diff --git a/packages/@jsonql/client/README.md b/packages/@jsonql/client/README.md index 3a75700ae39d710e680c399c39c33140c06a01c0..5b4bacc6e895e5a0c78d69f0c027164d980cf7cc 100644 --- a/packages/@jsonql/client/README.md +++ b/packages/@jsonql/client/README.md @@ -2,11 +2,43 @@ > This is jsonql browser client comes with jsonql-client (http) and optional socket clients, plus various modules for ui frameworks -## Example +## Basic Example -Coming soon +Stock http client -## Vuex module +```js +import jsonqlClient from '@jsonql/client' +import Fly from 'flyio' +const config = {} // your configuration options + +jsonqlClient(config) + .then(client => { + // start to do your thing + }) +``` + + +Using the static client with pre-generated contract (works better with other frameworks) + +```js +import { jsonqlStaticClient } from '@jsonql/client/static' +import contract from 'path/to/your/public-contract.json' +import Fly from 'flyio' // or specific client to your need + +const client = jsonqlStaticClient(Fly, { contract }) + +client.query('helloWorld') + .then(msg => { + // you get Hello world! + }) + +``` + +## Framework modules + +We have develop several module for integrate with some of the popular js framework. + +### Vuex module We add a vuex store support in version 1.5.19 diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index dc6a6074099dfcb373f718aecac69c922077df65..f096d0c78f1750bd4b9110b4bdaa54b863a37f6f 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -19,6 +19,7 @@ "test:basic": "DEBUG=jsonql-client* ava ./tests/basic.test.js", "test:login": "DEBUG=jsonql-client* ava ./tests/login.test.js", "_prepare": "NODE_ENV=production npm run build", + "_publish": "npm publish --access public", "test:browser:ws": "npm run build:ws && npm run qunit", "start": "rollup -c -w --environment NODE_ENV:dev", "build": "npm run build:umd && npm run build:browser && npm run build:static && npm run build:full", @@ -47,7 +48,7 @@ "license": "MIT", "dependencies": { "flyio": "^0.6.14", - "jsonql-client": "^1.5.18" + "jsonql-client": "^1.5.19" }, "optionalDependencies": { "@jsonql/ws": "^1.0.11" @@ -81,14 +82,12 @@ }, "ava": { "files": [ - "tests/*.test.js", - "!tests/fixtures/*.*", - "!tests/browser/*.*", - "!tests/qunit/*.*", - "!tests/qunit/*.*", - "!tests/qunit/*.*", - "!tests/qunit/*.*", - "!tests/qunit/*.*" + "tests/*.test.js" + ], + "ignoredByWatcher": [ + "tests/fixtures/*.*", + "tests/browser/*.*", + "tests/qunit/*.*" ], "require": [ "esm" @@ -98,6 +97,6 @@ "failFast": true, "failWithoutAssertions": false, "tap": false, - "compileEnhancements": false + "verbose": false } } diff --git a/packages/@jsonql/client/src/index.js b/packages/@jsonql/client/src/index.js index e7507b460a0803993250bb33a0050bfce772ed59..b9c9cb1e3747aa8599aeace4656b65df94e042c9 100644 --- a/packages/@jsonql/client/src/index.js +++ b/packages/@jsonql/client/src/index.js @@ -5,7 +5,7 @@ import { isContract } from 'jsonql-utils/src/contract' import { isObjectHasKey } from 'jsonql-utils/src/generic' import { objHasProp } from 'jsonql-utils' import { - JsonqlBaseClient, + JsonqlBaseEngine, getEventEmitter, generator, getContractFromConfig, @@ -79,7 +79,7 @@ function getJsonqlClient(fly, extraDefaultOptions = {}, extraConstProps = {}) { .then(opts => ( { opts, - baseClient: new JsonqlBaseClient(fly, opts) + baseClient: new JsonqlBaseEngine(fly, opts) } )) // make sure the contract is presented diff --git a/packages/@jsonql/client/static.js b/packages/@jsonql/client/static.js index 728bf310ff42bb69aef28e88dd04c0df55155ff1..e07079812f27aa91be48414689784254c331b7a6 100644 --- a/packages/@jsonql/client/static.js +++ b/packages/@jsonql/client/static.js @@ -1 +1,4 @@ -// this will export the static version +// this will export the static version +import { jsonqlStaticClient } from 'jsonql-client/static' + +export { jsonqlStaticClient } diff --git a/packages/@jsonql/client/vue/index.js b/packages/@jsonql/client/vue/index.js index 349394df71c9ee83b4bfa0685ac953d5f5a3e3c4..34e40d81b4b91b7fc79bf0dcc5b170e5419eddc2 100644 --- a/packages/@jsonql/client/vue/index.js +++ b/packages/@jsonql/client/vue/index.js @@ -1 +1,8 @@ -// jsonql client for Vue and Vuex (TBC) how to do it +// jsonql client for Vue and Vuex (TBC) how to do it +import { getJsonqlVuexModule } from './vuex' + + + +export { + getJsonqlVuexModule +} diff --git a/packages/@jsonql/client/vue/vuex.js b/packages/@jsonql/client/vue/vuex.js index 68e409e3a4e9e6f5b5730c79bb42876bc0d88394..e142b545cef860d0a942deb7270c53365a953907 100644 --- a/packages/@jsonql/client/vue/vuex.js +++ b/packages/@jsonql/client/vue/vuex.js @@ -1,5 +1,5 @@ // this is an experiemental generic module for vuex -import { jsonqlStaticClient } from './static' +import { jsonqlStaticClient } from '../static' /** * @param {string} str to upper case first word diff --git a/packages/http-client/core.js b/packages/http-client/core.js index 5c71e7af720bfba0690e2acfe946cd26ae25b702..094bc29cf4ed064a3325c0e60aa480ef2e57e67f 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=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),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={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),r=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),n=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),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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),i=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),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={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),u=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),c=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),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}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),l=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),f="application/vnd.api+json",p={Accept:f,"Content-Type":[f,"charset=utf-8"].join(";")},h=["POST","PUT"],d={desc:"y"},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={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),g=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),y=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:r,JsonqlAuthorisationError:n,JsonqlContractAuthError:o,JsonqlResolverAppError:i,JsonqlResolverNotFoundError:a,JsonqlEnumError:u,JsonqlTypeError:c,JsonqlCheckerError:s,JsonqlValidationError:l,JsonqlError:v,JsonqlServerError:g}),b=v;function _(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&y[o])throw new y[r](i,a);throw new b(i,a)}return t}function m(f){if(Array.isArray(f))throw new l("",f);var p=f.message||"No message",h=f.detail||f;switch(!0){case f instanceof t:throw new t(p,h);case f instanceof e:throw new e(p,h);case f instanceof r:throw new r(p,h);case f instanceof n:throw new n(p,h);case f instanceof o:throw new o(p,h);case f instanceof i:throw new i(p,h);case f instanceof a:throw new a(p,h);case f instanceof u:throw new u(p,h);case f instanceof c:throw new c(p,h);case f instanceof s:throw new s(p,h);case f instanceof l:throw new l(p,h);case f instanceof g:throw new g(p,h);default:throw new v(p,h)}}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol;function A(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--&&L(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var ot=function(t){return!!E(t)||null!=t&&""!==nt(t)};function it(t){return function(t){return"number"==typeof t||N(t)&&"[object Number]"==z(t)}(t)&&t!=+t}function at(t){return"string"==typeof t||!E(t)&&N(t)&&"[object String]"==z(t)}var ut=function(t){return!at(t)&&!it(parseFloat(t))},ct=function(t){return""!==nt(t)&&at(t)},st=function(t){return null!=t&&"boolean"==typeof t},lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==nt(t)&&(!1===e||!0===e&&null!==t)},ft=function(t){switch(t){case"number":return ut;case"string":return ct;case"boolean":return st;default:return lt}},pt=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===nt(e)||!(t.filter((function(t){return!ft(e)(t)})).length>0))},ht=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},dt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ft(e)(t)})).length)})).length:e.length>e.filter((function(t){return!pt(r,t)})).length};function vt(t,e){return function(r){return t(e(r))}}var gt=vt(Object.getPrototypeOf,Object),yt=Function.prototype,bt=Object.prototype,_t=yt.toString,mt=bt.hasOwnProperty,wt=_t.call(Object);function jt(t){if(!N(t)||"[object Object]"!=z(t))return!1;var e=gt(t);if(null===e)return!0;var r=mt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&_t.call(r)==wt}var St,Ot=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[St?a:++n];if(!1===e(o[u],u,o))break}return t};function kt(t){return N(t)&&"[object Arguments]"==z(t)}var At=Object.prototype,Et=At.hasOwnProperty,Tt=At.propertyIsEnumerable,xt=kt(function(){return arguments}())?kt:function(t){return N(t)&&Et.call(t,"callee")&&!Tt.call(t,"callee")};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=qt&&qt.exports===Pt?O.Buffer:void 0,$t=(Ct?Ct.isBuffer:void 0)||function(){return!1},zt=/^(?:0|[1-9]\d*)$/;function Nt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var It={};It["[object Float32Array]"]=It["[object Float64Array]"]=It["[object Int8Array]"]=It["[object Int16Array]"]=It["[object Int32Array]"]=It["[object Uint8Array]"]=It["[object Uint8ClampedArray]"]=It["[object Uint16Array]"]=It["[object Uint32Array]"]=!0,It["[object Arguments]"]=It["[object Array]"]=It["[object ArrayBuffer]"]=It["[object Boolean]"]=It["[object DataView]"]=It["[object Date]"]=It["[object Error]"]=It["[object Function]"]=It["[object Map]"]=It["[object Number]"]=It["[object Object]"]=It["[object RegExp]"]=It["[object Set]"]=It["[object String]"]=It["[object WeakMap]"]=!1;var Rt,Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=Jt&&Jt.exports===Ft&&j.process,Lt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Ht=Lt&&Lt.isTypedArray,Dt=Ht?(Rt=Ht,function(t){return Rt(t)}):function(t){return N(t)&&Mt(t.length)&&!!It[z(t)]},Kt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=E(t),n=!r&&xt(t),o=!r&&!n&&$t(t),i=!r&&!n&&!o&&Dt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ie.prototype.set=function(t,e){var r=this.__data__,n=ne(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ae,ue=O["__core-js_shared__"],ce=(ae=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+ae:"";var se=Function.prototype.toString;function le(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,he=Object.prototype,de=pe.toString,ve=he.hasOwnProperty,ge=RegExp("^"+de.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ye(t){return!(!Qt(t)||function(t){return!!ce&&ce in t}(t))&&(Xt(t)?ge:fe).test(le(t))}function be(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ye(r)?r:void 0}var _e=be(O,"Map"),me=be(Object,"create");var we=Object.prototype.hasOwnProperty;var je=Object.prototype.hasOwnProperty;function Se(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 l=-1,f=!0,p=2&r?new Ee:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=ht(t))?!dt({arg:r},e):!ft(t)(r))})).length)})).length}return!1},Sr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(jr,null,a);case"array"===t:return!pt(e.arg);case!1!==(r=ht(t)):return!dt(e,r);default:return!ft(t)(e.arg)}},Or=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},kr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!pt(e))throw new v("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!pt(t))throw new v("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Or(t,a):t,index:r,param:a,optional:i}}));default:throw new v("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!!ot(e)&&!(r.type.length>r.type.filter((function(e){return Sr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Sr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ar=function(){try{var t=be(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Er(t,e,r){"__proto__"==e&&Ar?Ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Tr(t,e,r){(void 0===r||re(t[e],r))&&(void 0!==r||e in t)||Er(t,e,r)}var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Pr&&Pr.exports===xr?O.Buffer:void 0,Cr=qr?qr.allocUnsafe:void 0;function $r(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pe(n).set(new Pe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var zr=Object.create,Nr=function(){function t(){}return function(e){if(!Qt(e))return{};if(zr)return zr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ir=Object.prototype.hasOwnProperty;function Rr(t,e,r){var n=t[e];Ir.call(t,e)&&re(n,r)&&(void 0!==r||e in t)||Er(t,e,r)}var Fr=Object.prototype.hasOwnProperty;function Jr(t){if(!Qt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Gt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Ur(t){return Zt(t)?Bt(t,!0):Jr(t)}function Lr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Vr);function Yr(t,e){return Wr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Qt(r))return!1;var n=typeof e;return!!("number"==n?Zt(r)&&Nt(e,r.length):"string"==n&&e in r)&&re(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,yn(t))}),Reflect.apply(t,null,r))}};function mn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function wn(t,e,r,n){void 0===n&&(n=!1);var o=mn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var jn=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 dn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(m)}},Sn=function(t,e,r,n,o){var i={},a=function(t){i=wn(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={};return dn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(m)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},On=function(t,e,r,n,o){var i={},a=function(t){i=wn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return dn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(m)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},kn=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=jn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var An=function(t,e,r,n){var o=function(t,e,r,n){var o=[Sn,On,kn];return Reflect.apply(_n,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.19",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function En(t){return!!function(t){return jt(t)&&(bn(t,"query")||bn(t,"mutation")||bn(t,"socket"))}(t)&&t}function Tn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function xn(t){this.message=t}xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Pn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new xn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var qn=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(Pn(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 Pn(e)}};function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidTokenError";var $n=function(t,e){if("string"!=typeof t)throw new Cn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(qn(t.split(".")[r]))}catch(t){throw new Cn("Invalid token specified: "+t.message)}};$n.InvalidTokenError=Cn;var zn,Nn,Mn,In,Rn,Fn,Jn,Un,Ln;function Hn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new v("Token has expired on "+r,t)}return t}function Dn(t){if(ct(t))return Hn($n(t));throw new v("Token must be a string!")}vn("HS256",["string"]),vn(!1,["boolean","number","string"],((zn={}).alias="exp",zn.optional=!0,zn)),vn(!1,["boolean","number","string"],((Nn={}).alias="nbf",Nn.optional=!0,Nn)),vn(!1,["boolean","string"],((Mn={}).alias="iss",Mn.optional=!0,Mn)),vn(!1,["boolean","string"],((In={}).alias="sub",In.optional=!0,In)),vn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),vn(!1,["boolean"],((Fn={}).optional=!0,Fn)),vn(!1,["boolean","string"],((Jn={}).optional=!0,Jn)),vn(!1,["boolean","string"],((Un={}).optional=!0,Un)),vn(!1,["boolean"],((Ln={}).optional=!0,Ln));var Kn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Bn(t,e){var r;return(r={})[t]=e,r.TS=[Kn()],r}var Vn=function(t){return bn(t,"data")&&!bn(t,"error")?t.data:t},Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Wn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=bo().key(e);t(_o(r),r)}},remove:function(t){return bo().removeItem(t)},clearAll:function(){return bo().clear()}};function bo(){return go.localStorage}function _o(t){return bo().getItem(t)}var mo=Zn.trim,wo={name:"cookieStorage",read:function(t){if(!t||!ko(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(jo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;jo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:So,remove:Oo,clearAll:function(){So((function(t,e){Oo(e)}))}},jo=Zn.Global.document;function So(t){for(var e=jo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(mo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Oo(t){t&&ko(t)&&(jo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ko(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(jo.cookie)}var Ao=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 Eo=Zn.bind,To=Zn.each,xo=Zn.create,Po=Zn.slice,qo=function(){var t=xo(Co,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Eo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Eo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),To(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Co={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Eo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Po(arguments,1);To(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},$o=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),zo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=$o.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=$o.compress(this._serialize(r));t(e,n)}}};var No=[yo,wo],Mo=[Ao,qo,zo],Io=po.createStore(No,Mo),Ro=Zn.Global;function Fo(){return Ro.sessionStorage}function Jo(t){return Fo().getItem(t)}var Uo=[{name:"sessionStorage",read:Jo,write:function(t,e){return Fo().setItem(t,e)},each:function(t){for(var e=Fo().length-1;e>=0;e--){var r=Fo().key(e);t(Jo(r),r)}},remove:function(t){return Fo().removeItem(t)},clearAll:function(){return Fo().clear()}},wo],Lo=[Ao,zo],Ho=po.createStore(Uo,Lo),Do=Io,Ko=Ho,Bo=function(t){this.opts=t,this.instanceKey=Tn(this.opts.hostname),this.localStore=Do,this.sessionStore=Ko},Vo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Bo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?Xr({},o,e):e,r))},Bo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Bo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Bo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Vo.lset.set=function(t){return this.__setMethod("localStore",t)},Vo.lget.get=function(){return this.__getMethod("localStore")},Bo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Bo.prototype.lclear=function(){return this.__clearMethod("localStore")},Vo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Vo.sget.get=function(){return this.__getMethod("sessionStore")},Bo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Bo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Bo.prototype,Vo);var Go=h[0],Wo=h[1],Yo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Dn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(hn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new l("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&hn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!En(t))throw new l("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=En(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Xr({},{_cb:Kn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Xr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Xr({},{method:Go,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Vn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=pn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Vn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new g("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Xr({},p,this.getAuthHeader(),this.extraHeader):Xr({},p,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Xr({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new g("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),at(t)&&E(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Bn(t,n)}throw new l("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(at(t))return Bn(t,o);throw new l("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Wo}).then(_)},Object.defineProperties(e.prototype,r),e}(Bo)))),Qo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:f,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xo={hostname:vn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:vn("jsonql",["string"]),loginHandlerName:vn("login",["string"]),logoutHandlerName:vn("logout",["string"]),enableJsonp:vn(!1,["boolean"]),enableAuth:vn(!1,["boolean"]),useJwt:vn(!0,["boolean"]),persistToken:vn(!1,["boolean","number"]),useLocalstorage:vn(!0,["boolean"]),storageKey:vn("jsonqlstore",["string"]),authKey:vn("jsonqlauthkey",["string"]),contractExpired:vn(0,["number"]),keepContract:vn(!0,["boolean"]),exposeContract:vn(!1,["boolean"]),exposeStore:vn(!1,["boolean"]),showContractDesc:vn(!1,["boolean"]),contractKey:vn(!1,["boolean"]),contractKeyName:vn("X-JSONQL-CV-KEY",["string"]),enableTimeout:vn(!1,["boolean"]),timeout:vn(5e3,["number"]),returnInstance:vn(!1,["boolean"]),allowReturnRawToken:vn(!1,["boolean"]),debugOn:vn(!1,["boolean"])};function Zo(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return wn(t,"__checked__",Kn())};r.push(o);var i=Reflect.apply(_n,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ti(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),mn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(Zo,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Xo,Qo,gn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ei(t,e,r){return void 0===r&&(r={}),ti(r).then((function(t){return{baseClient:new Yo(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),En(n)?Promise.resolve(n):r.getContract()).then((function(e){return An(o,i,e,t)}))}))}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return Tn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));return function(t,e){var r;return ei((r=e.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}})); +!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=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),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={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),r=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),n=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),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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),i=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),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={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),u=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),c=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),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}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),l=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),f="application/vnd.api+json",p={Accept:f,"Content-Type":[f,"charset=utf-8"].join(";")},h=["POST","PUT"],d={desc:"y"},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={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),g=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),y=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:r,JsonqlAuthorisationError:n,JsonqlContractAuthError:o,JsonqlResolverAppError:i,JsonqlResolverNotFoundError:a,JsonqlEnumError:u,JsonqlTypeError:c,JsonqlCheckerError:s,JsonqlValidationError:l,JsonqlError:v,JsonqlServerError:g}),b=v;function _(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&y[o])throw new y[r](i,a);throw new b(i,a)}return t}function m(f){if(Array.isArray(f))throw new l("",f);var p=f.message||"No message",h=f.detail||f;switch(!0){case f instanceof t:throw new t(p,h);case f instanceof e:throw new e(p,h);case f instanceof r:throw new r(p,h);case f instanceof n:throw new n(p,h);case f instanceof o:throw new o(p,h);case f instanceof i:throw new i(p,h);case f instanceof a:throw new a(p,h);case f instanceof u:throw new u(p,h);case f instanceof c:throw new c(p,h);case f instanceof s:throw new s(p,h);case f instanceof l:throw new l(p,h);case f instanceof g:throw new g(p,h);default:throw new v(p,h)}}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol;function A(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--&&L(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var ot=function(t){return!!E(t)||null!=t&&""!==nt(t)};function it(t){return function(t){return"number"==typeof t||N(t)&&"[object Number]"==z(t)}(t)&&t!=+t}function at(t){return"string"==typeof t||!E(t)&&N(t)&&"[object String]"==z(t)}var ut=function(t){return!at(t)&&!it(parseFloat(t))},ct=function(t){return""!==nt(t)&&at(t)},st=function(t){return null!=t&&"boolean"==typeof t},lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==nt(t)&&(!1===e||!0===e&&null!==t)},ft=function(t){switch(t){case"number":return ut;case"string":return ct;case"boolean":return st;default:return lt}},pt=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===nt(e)||!(t.filter((function(t){return!ft(e)(t)})).length>0))},ht=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},dt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ft(e)(t)})).length)})).length:e.length>e.filter((function(t){return!pt(r,t)})).length};function vt(t,e){return function(r){return t(e(r))}}var gt=vt(Object.getPrototypeOf,Object),yt=Function.prototype,bt=Object.prototype,_t=yt.toString,mt=bt.hasOwnProperty,wt=_t.call(Object);function jt(t){if(!N(t)||"[object Object]"!=z(t))return!1;var e=gt(t);if(null===e)return!0;var r=mt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&_t.call(r)==wt}var St,Ot=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[St?a:++n];if(!1===e(o[u],u,o))break}return t};function kt(t){return N(t)&&"[object Arguments]"==z(t)}var At=Object.prototype,Et=At.hasOwnProperty,Tt=At.propertyIsEnumerable,xt=kt(function(){return arguments}())?kt:function(t){return N(t)&&Et.call(t,"callee")&&!Tt.call(t,"callee")};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=qt&&qt.exports===Pt?O.Buffer:void 0,$t=(Ct?Ct.isBuffer:void 0)||function(){return!1},zt=/^(?:0|[1-9]\d*)$/;function Nt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var It={};It["[object Float32Array]"]=It["[object Float64Array]"]=It["[object Int8Array]"]=It["[object Int16Array]"]=It["[object Int32Array]"]=It["[object Uint8Array]"]=It["[object Uint8ClampedArray]"]=It["[object Uint16Array]"]=It["[object Uint32Array]"]=!0,It["[object Arguments]"]=It["[object Array]"]=It["[object ArrayBuffer]"]=It["[object Boolean]"]=It["[object DataView]"]=It["[object Date]"]=It["[object Error]"]=It["[object Function]"]=It["[object Map]"]=It["[object Number]"]=It["[object Object]"]=It["[object RegExp]"]=It["[object Set]"]=It["[object String]"]=It["[object WeakMap]"]=!1;var Rt,Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=Jt&&Jt.exports===Ft&&j.process,Lt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Ht=Lt&&Lt.isTypedArray,Dt=Ht?(Rt=Ht,function(t){return Rt(t)}):function(t){return N(t)&&Mt(t.length)&&!!It[z(t)]},Kt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=E(t),n=!r&&xt(t),o=!r&&!n&&$t(t),i=!r&&!n&&!o&&Dt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ie.prototype.set=function(t,e){var r=this.__data__,n=ne(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ae,ue=O["__core-js_shared__"],ce=(ae=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+ae:"";var se=Function.prototype.toString;function le(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,he=Object.prototype,de=pe.toString,ve=he.hasOwnProperty,ge=RegExp("^"+de.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ye(t){return!(!Qt(t)||function(t){return!!ce&&ce in t}(t))&&(Xt(t)?ge:fe).test(le(t))}function be(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ye(r)?r:void 0}var _e=be(O,"Map"),me=be(Object,"create");var we=Object.prototype.hasOwnProperty;var je=Object.prototype.hasOwnProperty;function Se(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 l=-1,f=!0,p=2&r?new Ee:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=ht(t))?!dt({arg:r},e):!ft(t)(r))})).length)})).length}return!1},Sr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(jr,null,a);case"array"===t:return!pt(e.arg);case!1!==(r=ht(t)):return!dt(e,r);default:return!ft(t)(e.arg)}},Or=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},kr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!pt(e))throw new v("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!pt(t))throw new v("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Or(t,a):t,index:r,param:a,optional:i}}));default:throw new v("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!!ot(e)&&!(r.type.length>r.type.filter((function(e){return Sr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Sr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ar=function(){try{var t=be(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Er(t,e,r){"__proto__"==e&&Ar?Ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Tr(t,e,r){(void 0===r||re(t[e],r))&&(void 0!==r||e in t)||Er(t,e,r)}var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Pr&&Pr.exports===xr?O.Buffer:void 0,Cr=qr?qr.allocUnsafe:void 0;function $r(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pe(n).set(new Pe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var zr=Object.create,Nr=function(){function t(){}return function(e){if(!Qt(e))return{};if(zr)return zr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ir=Object.prototype.hasOwnProperty;function Rr(t,e,r){var n=t[e];Ir.call(t,e)&&re(n,r)&&(void 0!==r||e in t)||Er(t,e,r)}var Fr=Object.prototype.hasOwnProperty;function Jr(t){if(!Qt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Ur(t){return Zt(t)?Bt(t,!0):Jr(t)}function Lr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Gr);function Yr(t,e){return Wr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Qt(r))return!1;var n=typeof e;return!!("number"==n?Zt(r)&&Nt(e,r.length):"string"==n&&e in r)&&re(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,yn(t))}),Reflect.apply(t,null,r))}};function mn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function wn(t,e,r,n){void 0===n&&(n=!1);var o=mn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var jn=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 dn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(m)}},Sn=function(t,e,r,n,o){var i={},a=function(t){i=wn(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={};return dn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(m)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},On=function(t,e,r,n,o){var i={},a=function(t){i=wn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return dn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(m)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},kn=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=jn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var An=function(t,e,r,n){var o=function(t,e,r,n){var o=[Sn,On,kn];return Reflect.apply(_n,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.20",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function En(t){return!!function(t){return jt(t)&&(bn(t,"query")||bn(t,"mutation")||bn(t,"socket"))}(t)&&t}function Tn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function xn(t){this.message=t}xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Pn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new xn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var qn=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(Pn(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 Pn(e)}};function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidTokenError";var $n=function(t,e){if("string"!=typeof t)throw new Cn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(qn(t.split(".")[r]))}catch(t){throw new Cn("Invalid token specified: "+t.message)}};$n.InvalidTokenError=Cn;var zn,Nn,Mn,In,Rn,Fn,Jn,Un,Ln;function Hn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new v("Token has expired on "+r,t)}return t}function Dn(t){if(ct(t))return Hn($n(t));throw new v("Token must be a string!")}vn("HS256",["string"]),vn(!1,["boolean","number","string"],((zn={}).alias="exp",zn.optional=!0,zn)),vn(!1,["boolean","number","string"],((Nn={}).alias="nbf",Nn.optional=!0,Nn)),vn(!1,["boolean","string"],((Mn={}).alias="iss",Mn.optional=!0,Mn)),vn(!1,["boolean","string"],((In={}).alias="sub",In.optional=!0,In)),vn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),vn(!1,["boolean"],((Fn={}).optional=!0,Fn)),vn(!1,["boolean","string"],((Jn={}).optional=!0,Jn)),vn(!1,["boolean","string"],((Un={}).optional=!0,Un)),vn(!1,["boolean"],((Ln={}).optional=!0,Ln));var Kn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Bn(t,e){var r;return(r={})[t]=e,r.TS=[Kn()],r}var Gn=function(t){return bn(t,"data")&&!bn(t,"error")?t.data:t},Vn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Wn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=bo().key(e);t(_o(r),r)}},remove:function(t){return bo().removeItem(t)},clearAll:function(){return bo().clear()}};function bo(){return go.localStorage}function _o(t){return bo().getItem(t)}var mo=Zn.trim,wo={name:"cookieStorage",read:function(t){if(!t||!ko(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(jo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;jo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:So,remove:Oo,clearAll:function(){So((function(t,e){Oo(e)}))}},jo=Zn.Global.document;function So(t){for(var e=jo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(mo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Oo(t){t&&ko(t)&&(jo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ko(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(jo.cookie)}var Ao=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 Eo=Zn.bind,To=Zn.each,xo=Zn.create,Po=Zn.slice,qo=function(){var t=xo(Co,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Eo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Eo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),To(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Co={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Eo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Po(arguments,1);To(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},$o=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),zo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=$o.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=$o.compress(this._serialize(r));t(e,n)}}};var No=[yo,wo],Mo=[Ao,qo,zo],Io=po.createStore(No,Mo),Ro=Zn.Global;function Fo(){return Ro.sessionStorage}function Jo(t){return Fo().getItem(t)}var Uo=[{name:"sessionStorage",read:Jo,write:function(t,e){return Fo().setItem(t,e)},each:function(t){for(var e=Fo().length-1;e>=0;e--){var r=Fo().key(e);t(Jo(r),r)}},remove:function(t){return Fo().removeItem(t)},clearAll:function(){return Fo().clear()}},wo],Lo=[Ao,zo],Ho=po.createStore(Uo,Lo),Do=Io,Ko=Ho,Bo=function(t){this.opts=t,this.instanceKey=Tn(this.opts.hostname),this.localStore=Do,this.sessionStore=Ko},Go={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Bo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?Xr({},o,e):e,r))},Bo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Bo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Bo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Go.lset.set=function(t){return this.__setMethod("localStore",t)},Go.lget.get=function(){return this.__getMethod("localStore")},Bo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Bo.prototype.lclear=function(){return this.__clearMethod("localStore")},Go.sset.set=function(t){return this.__setMethod("sessionStore",t)},Go.sget.get=function(){return this.__getMethod("sessionStore")},Bo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Bo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Bo.prototype,Go);var Vo=h[0],Wo=h[1],Yo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Dn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(hn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new l("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&hn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!En(t))throw new l("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=En(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Xr({},{_cb:Kn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Xr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Xr({},{method:Vo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Gn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=pn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Gn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new g("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Xr({},p,this.getAuthHeader(),this.extraHeader):Xr({},p,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Xr({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new g("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),at(t)&&E(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Bn(t,n)}throw new l("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(at(t))return Bn(t,o);throw new l("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Wo}).then(_)},Object.defineProperties(e.prototype,r),e}(Bo)))),Qo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:f,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xo={hostname:vn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:vn("jsonql",["string"]),loginHandlerName:vn("login",["string"]),logoutHandlerName:vn("logout",["string"]),enableJsonp:vn(!1,["boolean"]),enableAuth:vn(!1,["boolean"]),useJwt:vn(!0,["boolean"]),persistToken:vn(!1,["boolean","number"]),useLocalstorage:vn(!0,["boolean"]),storageKey:vn("jsonqlstore",["string"]),authKey:vn("jsonqlauthkey",["string"]),contractExpired:vn(0,["number"]),keepContract:vn(!0,["boolean"]),exposeContract:vn(!1,["boolean"]),exposeStore:vn(!1,["boolean"]),showContractDesc:vn(!1,["boolean"]),contractKey:vn(!1,["boolean"]),contractKeyName:vn("X-JSONQL-CV-KEY",["string"]),enableTimeout:vn(!1,["boolean"]),timeout:vn(5e3,["number"]),returnInstance:vn(!1,["boolean"]),allowReturnRawToken:vn(!1,["boolean"]),debugOn:vn(!1,["boolean"])};function Zo(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return wn(t,"__checked__",Kn())};r.push(o);var i=Reflect.apply(_n,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ti(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),mn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(Zo,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Xo,Qo,gn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ei(t,e,r){return void 0===r&&(r={}),ti(r).then((function(t){return{baseClient:new Yo(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),En(n)?Promise.resolve(n):r.getContract()).then((function(e){return An(o,i,e,t)}))}))}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return Tn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));return function(t,e){var r;return ei((r=e.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/dist/jsonql-client.static-full.js b/packages/http-client/dist/jsonql-client.static-full.js index 5962ad003421001c1e8f61f1fa6f1ee299d833ad..4b14b821eda1a96b985de8a0ca320d7622186bd0 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js +++ b/packages/http-client/dist/jsonql-client.static-full.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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,T=k.toString,A=E.hasOwnProperty,x=T.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=A.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&T.call(r)==x}function q(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--&&F(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},rt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},nt=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),ot=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),it=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),at=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),ut=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),ct=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),st=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),ft=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),lt=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),pt=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),ht=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),dt=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),vt=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),gt=Object.freeze({__proto__:null,Jsonql406Error:nt,Jsonql500Error:ot,JsonqlForbiddenError:it,JsonqlAuthorisationError:at,JsonqlContractAuthError:ut,JsonqlResolverAppError:ct,JsonqlResolverNotFoundError:st,JsonqlEnumError:ft,JsonqlTypeError:lt,JsonqlCheckerError:pt,JsonqlValidationError:ht,JsonqlError:dt,JsonqlServerError:vt}),yt=dt;function bt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&>[o])throw new gt[r](i,a);throw new yt(i,a)}return t}function mt(t){if(Array.isArray(t))throw new ht("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof ht:throw new ht(e,r);case t instanceof vt:throw new vt(e,r);default:throw new dt(e,r)}}var _t=function(t){return!!s(t)||null!=t&&""!==Z(t)};function wt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}function jt(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var Ot=function(t){return!jt(t)&&!wt(parseFloat(t))},St=function(t){return""!==Z(t)&&jt(t)},kt=function(t){return null!=t&&"boolean"==typeof t},Et=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Tt=function(t){switch(t){case"number":return Ot;case"string":return St;case"boolean":return kt;default:return Et}},At=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Tt(e)(t)})).length>0))},xt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Pt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Tt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!At(r,t)})).length};var qt,Ct=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[qt?a:++n];if(!1===e(o[u],u,o))break}return t};function $t(t){return S(t)&&"[object Arguments]"==w(t)}var zt=Object.prototype,Nt=zt.hasOwnProperty,Rt=zt.propertyIsEnumerable,Mt=$t(function(){return arguments}())?$t:function(t){return S(t)&&Nt.call(t,"callee")&&!Rt.call(t,"callee")};var Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,It=Jt&&Jt.exports===Ft?h.Buffer:void 0,Ut=(It?It.isBuffer:void 0)||function(){return!1},Dt=/^(?:0|[1-9]\d*)$/;function Lt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Dt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Bt={};Bt["[object Float32Array]"]=Bt["[object Float64Array]"]=Bt["[object Int8Array]"]=Bt["[object Int16Array]"]=Bt["[object Int32Array]"]=Bt["[object Uint8Array]"]=Bt["[object Uint8ClampedArray]"]=Bt["[object Uint16Array]"]=Bt["[object Uint32Array]"]=!0,Bt["[object Arguments]"]=Bt["[object Array]"]=Bt["[object ArrayBuffer]"]=Bt["[object Boolean]"]=Bt["[object DataView]"]=Bt["[object Date]"]=Bt["[object Error]"]=Bt["[object Function]"]=Bt["[object Map]"]=Bt["[object Number]"]=Bt["[object Object]"]=Bt["[object RegExp]"]=Bt["[object Set]"]=Bt["[object String]"]=Bt["[object WeakMap]"]=!1;var Kt,Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Vt&&Vt.exports===Gt&&l.process,Yt=function(){try{var t=Vt&&Vt.require&&Vt.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch(t){}}(),Qt=Yt&&Yt.isTypedArray,Xt=Qt?(Kt=Qt,function(t){return Kt(t)}):function(t){return S(t)&&Ht(t.length)&&!!Bt[w(t)]},Zt=Object.prototype.hasOwnProperty;function te(t,e){var r=s(t),n=!r&&Mt(t),o=!r&&!n&&Ut(t),i=!r&&!n&&!o&&Xt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},he.prototype.set=function(t,e){var r=this.__data__,n=le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var de,ve=h["__core-js_shared__"],ge=(de=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";var ye=Function.prototype.toString;function be(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var me=/^\[object .+?Constructor\]$/,_e=Function.prototype,we=Object.prototype,je=_e.toString,Oe=we.hasOwnProperty,Se=RegExp("^"+je.call(Oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ke(t){return!(!ie(t)||function(t){return!!ge&&ge in t}(t))&&(ae(t)?Se:me).test(be(t))}function Ee(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ke(r)?r:void 0}var Te=Ee(h,"Map"),Ae=Ee(Object,"create");var xe=Object.prototype.hasOwnProperty;var Pe=Object.prototype.hasOwnProperty;function qe(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=2&r?new Ne:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=xt(t))?!Pt({arg:r},e):!Tt(t)(r))})).length)})).length}return!1},qr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Pr,null,a);case"array"===t:return!At(e.arg);case!1!==(r=xt(t)):return!Pt(e,r);default:return!Tt(t)(e.arg)}},Cr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},$r=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!At(e))throw new dt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!At(t))throw new dt("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Cr(t,a):t,index:r,param:a,optional:i}}));default:throw new dt("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!!_t(e)&&!(r.type.length>r.type.filter((function(e){return qr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return qr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},zr=function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Nr(t,e,r){"__proto__"==e&&zr?zr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Rr(t,e,r){(void 0===r||fe(t[e],r))&&(void 0!==r||e in t)||Nr(t,e,r)}var Mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fr=Mr&&"object"==typeof module&&module&&!module.nodeType&&module,Jr=Fr&&Fr.exports===Mr?h.Buffer:void 0,Ir=Jr?Jr.allocUnsafe:void 0;function Ur(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Fe(n).set(new Fe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Dr=Object.create,Lr=function(){function t(){}return function(e){if(!ie(e))return{};if(Dr)return Dr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Hr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Br=Object.prototype.hasOwnProperty;function Kr(t,e,r){var n=t[e];Br.call(t,e)&&fe(n,r)&&(void 0!==r||e in t)||Nr(t,e,r)}var Gr=Object.prototype.hasOwnProperty;function Vr(t){if(!ie(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=re(t),r=[];for(var n in t)("constructor"!=n||!e&&Gr.call(t,n))&&r.push(n);return r}function Wr(t){return ue(t)?te(t,!0):Vr(t)}function Yr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(en);function on(t,e){return nn(function(t,e,r){return e=tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=tn(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(!ie(r))return!1;var n=typeof e;return!!("number"==n?ue(r)&&Lt(e,r.length):"string"==n&&e in r)&&fe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,tt(t))}),Reflect.apply(t,null,r))}};function En(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Tn(t,e,r,n){void 0===n&&(n=!1);var o=En(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var An=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 jn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mt)}},xn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(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={};return jn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Pn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return jn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},qn=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=An(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=An(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Cn=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(rt(e,r,"onResult"),o),t.$only(rt(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function $n(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(kn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(rt(t,n,"onResult"),r)})).catch((function(r){e.$trigger(rt(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function zn(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function Nn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Rn(t){this.message=t}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Fn=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(Mn(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 Mn(e)}};function Jn(t){this.message=t}Jn.prototype=new Error,Jn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Jn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fn(t.split(".")[r]))}catch(t){throw new Jn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Jn;var Un,Dn,Ln,Hn,Bn,Kn,Gn,Vn,Wn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new dt("Token has expired on "+r,t)}return t}function Qn(t){if(St(t))return Yn(In(t));throw new dt("Token must be a string!")}On("HS256",["string"]),On(!1,["boolean","number","string"],((Un={}).alias="exp",Un.optional=!0,Un)),On(!1,["boolean","number","string"],((Dn={}).alias="nbf",Dn.optional=!0,Dn)),On(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),On(!1,["boolean","string"],((Hn={}).alias="sub",Hn.optional=!0,Hn)),On(!1,["boolean","string"],((Bn={}).alias="iss",Bn.optional=!0,Bn)),On(!1,["boolean"],((Kn={}).optional=!0,Kn)),On(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),On(!1,["boolean","string"],((Vn={}).optional=!0,Vn)),On(!1,["boolean"],((Wn={}).optional=!0,Wn));var Xn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zn(t,e){var r;return(r={})[t]=e,r.TS=[Xn()],r}var to=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},eo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=So().key(e);t(ko(r),r)}},remove:function(t){return So().removeItem(t)},clearAll:function(){return So().clear()}};function So(){return jo.localStorage}function ko(t){return So().getItem(t)}var Eo=io.trim,To={name:"cookieStorage",read:function(t){if(!t||!qo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ao.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ao.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:xo,remove:Po,clearAll:function(){xo((function(t,e){Po(e)}))}},Ao=io.Global.document;function xo(t){for(var e=Ao.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Eo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Po(t){t&&qo(t)&&(Ao.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function qo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ao.cookie)}var Co=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 $o=io.bind,zo=io.each,No=io.create,Ro=io.slice,Mo=function(){var t=No(Fo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,$o(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,$o(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),zo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Fo={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,$o(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Ro(arguments,1);zo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Jo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Jo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Jo.compress(this._serialize(r));t(e,n)}}};var Uo=[Oo,To],Do=[Co,Mo,Io],Lo=mo.createStore(Uo,Do),Ho=io.Global;function Bo(){return Ho.sessionStorage}function Ko(t){return Bo().getItem(t)}var Go=[{name:"sessionStorage",read:Ko,write:function(t,e){return Bo().setItem(t,e)},each:function(t){for(var e=Bo().length-1;e>=0;e--){var r=Bo().key(e);t(Ko(r),r)}},remove:function(t){return Bo().removeItem(t)},clearAll:function(){return Bo().clear()}},To],Vo=[Co,Io],Wo=mo.createStore(Go,Vo),Yo=Lo,Qo=Wo,Xo=function(t){this.opts=t,this.instanceKey=Nn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Qo},Zo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Xo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?un({},o,e):e,r))},Xo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Xo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Xo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Zo.lset.set=function(t){return this.__setMethod("localStore",t)},Zo.lget.get=function(){return this.__getMethod("localStore")},Xo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Xo.prototype.lclear=function(){return this.__clearMethod("localStore")},Zo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Zo.sget.get=function(){return this.__getMethod("sessionStore")},Xo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Xo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Xo.prototype,Zo);var ti=u[0],ei=u[1],ri=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Qn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(wn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ht("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&wn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!zn(t))throw new ht("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=un({},{_cb:Xn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=un({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=un({},{method:ti,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return to(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=_n(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):to(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new vt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?un({},a,this.getAuthHeader(),this.extraHeader):un({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=un({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(bt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new vt("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),jt(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Zn(t,n)}throw new ht("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(jt(t))return Zn(t,o);throw new ht("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ei}).then(bt)},Object.defineProperties(e.prototype,r),e}(Xo)))),ni={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},oi={hostname:On(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:On("jsonql",["string"]),loginHandlerName:On("login",["string"]),logoutHandlerName:On("logout",["string"]),enableJsonp:On(!1,["boolean"]),enableAuth:On(!1,["boolean"]),useJwt:On(!0,["boolean"]),persistToken:On(!1,["boolean","number"]),useLocalstorage:On(!0,["boolean"]),storageKey:On("jsonqlstore",["string"]),authKey:On("jsonqlauthkey",["string"]),contractExpired:On(0,["number"]),keepContract:On(!0,["boolean"]),exposeContract:On(!1,["boolean"]),exposeStore:On(!1,["boolean"]),showContractDesc:On(!1,["boolean"]),contractKey:On(!1,["boolean"]),contractKeyName:On("X-JSONQL-CV-KEY",["string"]),enableTimeout:On(!1,["boolean"]),timeout:On(5e3,["number"]),returnInstance:On(!1,["boolean"]),allowReturnRawToken:On(!1,["boolean"]),debugOn:On(!1,["boolean"])};var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$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)},ui.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__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.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(ui.prototype,ci);var si=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return Nn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r,n=e.contract,o=function(t){return En(t,"__checked__")?Object.assign(t,ni):Sn(t,oi,ni)}(e),i=new ri(t,o),a=function(t,e){return void 0===e&&(e={}),zn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new si({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){$n(t,n,e,r)})),{query:Cn(n,"query"),mutation:Cn(n,"mutation"),auth:Cn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),fi(new 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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,T=k.toString,A=E.hasOwnProperty,x=T.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=A.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&T.call(r)==x}function q(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--&&J(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},rt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},nt=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),ot=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),it=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),at=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),ut=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),ct=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),st=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),ft=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),lt=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),pt=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),ht=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),dt=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),vt=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),gt=Object.freeze({__proto__:null,Jsonql406Error:nt,Jsonql500Error:ot,JsonqlForbiddenError:it,JsonqlAuthorisationError:at,JsonqlContractAuthError:ut,JsonqlResolverAppError:ct,JsonqlResolverNotFoundError:st,JsonqlEnumError:ft,JsonqlTypeError:lt,JsonqlCheckerError:pt,JsonqlValidationError:ht,JsonqlError:dt,JsonqlServerError:vt}),yt=dt;function bt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&>[o])throw new gt[r](i,a);throw new yt(i,a)}return t}function mt(t){if(Array.isArray(t))throw new ht("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof ht:throw new ht(e,r);case t instanceof vt:throw new vt(e,r);default:throw new dt(e,r)}}var _t=function(t){return!!s(t)||null!=t&&""!==Z(t)};function wt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}function jt(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var Ot=function(t){return!jt(t)&&!wt(parseFloat(t))},St=function(t){return""!==Z(t)&&jt(t)},kt=function(t){return null!=t&&"boolean"==typeof t},Et=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Tt=function(t){switch(t){case"number":return Ot;case"string":return St;case"boolean":return kt;default:return Et}},At=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Tt(e)(t)})).length>0))},xt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Pt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Tt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!At(r,t)})).length};var qt,Ct=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[qt?a:++n];if(!1===e(o[u],u,o))break}return t};function $t(t){return S(t)&&"[object Arguments]"==w(t)}var Nt=Object.prototype,zt=Nt.hasOwnProperty,Rt=Nt.propertyIsEnumerable,Mt=$t(function(){return arguments}())?$t:function(t){return S(t)&&zt.call(t,"callee")&&!Rt.call(t,"callee")};var Jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ft=Jt&&"object"==typeof module&&module&&!module.nodeType&&module,It=Ft&&Ft.exports===Jt?h.Buffer:void 0,Ut=(It?It.isBuffer:void 0)||function(){return!1},Lt=/^(?:0|[1-9]\d*)$/;function Dt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Lt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Bt={};Bt["[object Float32Array]"]=Bt["[object Float64Array]"]=Bt["[object Int8Array]"]=Bt["[object Int16Array]"]=Bt["[object Int32Array]"]=Bt["[object Uint8Array]"]=Bt["[object Uint8ClampedArray]"]=Bt["[object Uint16Array]"]=Bt["[object Uint32Array]"]=!0,Bt["[object Arguments]"]=Bt["[object Array]"]=Bt["[object ArrayBuffer]"]=Bt["[object Boolean]"]=Bt["[object DataView]"]=Bt["[object Date]"]=Bt["[object Error]"]=Bt["[object Function]"]=Bt["[object Map]"]=Bt["[object Number]"]=Bt["[object Object]"]=Bt["[object RegExp]"]=Bt["[object Set]"]=Bt["[object String]"]=Bt["[object WeakMap]"]=!1;var Kt,Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Vt&&Vt.exports===Gt&&l.process,Yt=function(){try{var t=Vt&&Vt.require&&Vt.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch(t){}}(),Qt=Yt&&Yt.isTypedArray,Xt=Qt?(Kt=Qt,function(t){return Kt(t)}):function(t){return S(t)&&Ht(t.length)&&!!Bt[w(t)]},Zt=Object.prototype.hasOwnProperty;function te(t,e){var r=s(t),n=!r&&Mt(t),o=!r&&!n&&Ut(t),i=!r&&!n&&!o&&Xt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},he.prototype.set=function(t,e){var r=this.__data__,n=le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var de,ve=h["__core-js_shared__"],ge=(de=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";var ye=Function.prototype.toString;function be(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var me=/^\[object .+?Constructor\]$/,_e=Function.prototype,we=Object.prototype,je=_e.toString,Oe=we.hasOwnProperty,Se=RegExp("^"+je.call(Oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ke(t){return!(!ie(t)||function(t){return!!ge&&ge in t}(t))&&(ae(t)?Se:me).test(be(t))}function Ee(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ke(r)?r:void 0}var Te=Ee(h,"Map"),Ae=Ee(Object,"create");var xe=Object.prototype.hasOwnProperty;var Pe=Object.prototype.hasOwnProperty;function qe(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=2&r?new ze:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=xt(t))?!Pt({arg:r},e):!Tt(t)(r))})).length)})).length}return!1},qr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Pr,null,a);case"array"===t:return!At(e.arg);case!1!==(r=xt(t)):return!Pt(e,r);default:return!Tt(t)(e.arg)}},Cr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},$r=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!At(e))throw new dt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!At(t))throw new dt("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Cr(t,a):t,index:r,param:a,optional:i}}));default:throw new dt("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!!_t(e)&&!(r.type.length>r.type.filter((function(e){return qr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return qr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Nr=function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function zr(t,e,r){"__proto__"==e&&Nr?Nr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Rr(t,e,r){(void 0===r||fe(t[e],r))&&(void 0!==r||e in t)||zr(t,e,r)}var Mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jr=Mr&&"object"==typeof module&&module&&!module.nodeType&&module,Fr=Jr&&Jr.exports===Mr?h.Buffer:void 0,Ir=Fr?Fr.allocUnsafe:void 0;function Ur(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Je(n).set(new Je(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Lr=Object.create,Dr=function(){function t(){}return function(e){if(!ie(e))return{};if(Lr)return Lr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Hr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Br=Object.prototype.hasOwnProperty;function Kr(t,e,r){var n=t[e];Br.call(t,e)&&fe(n,r)&&(void 0!==r||e in t)||zr(t,e,r)}var Gr=Object.prototype.hasOwnProperty;function Vr(t){if(!ie(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=re(t),r=[];for(var n in t)("constructor"!=n||!e&&Gr.call(t,n))&&r.push(n);return r}function Wr(t){return ue(t)?te(t,!0):Vr(t)}function Yr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(en);function on(t,e){return nn(function(t,e,r){return e=tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=tn(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(!ie(r))return!1;var n=typeof e;return!!("number"==n?ue(r)&&Dt(e,r.length):"string"==n&&e in r)&&fe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,tt(t))}),Reflect.apply(t,null,r))}};function En(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Tn(t,e,r,n){void 0===n&&(n=!1);var o=En(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var An=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 jn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mt)}},xn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(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={};return jn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Pn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return jn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},qn=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=An(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=An(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Cn=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(rt(e,r,"onResult"),o),t.$only(rt(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function $n(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(kn,null,o)({},t,e,r,n)}(t,e,r,n);!function(t,e,r,n){var o=t.$queues;n("(validateRegisteredEvents)","storedEvt",o),o.forEach((function(t){var r=t[0],o=t[1].resolverName;if(n("(validateRegisteredEvents)",r,o),!e[r][o])throw new Error(r+"."+o+" not existed in contract!")}))}(e,n,0,(function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,e)}));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.$call(rt(t,n,"onResult"))(r)})).catch((function(r){e.$trigger(rt(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function Nn(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function zn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Rn(t){this.message=t}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Jn=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(Mn(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 Mn(e)}};function Fn(t){this.message=t}Fn.prototype=new Error,Fn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Fn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Jn(t.split(".")[r]))}catch(t){throw new Fn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Fn;var Un,Ln,Dn,Hn,Bn,Kn,Gn,Vn,Wn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new dt("Token has expired on "+r,t)}return t}function Qn(t){if(St(t))return Yn(In(t));throw new dt("Token must be a string!")}On("HS256",["string"]),On(!1,["boolean","number","string"],((Un={}).alias="exp",Un.optional=!0,Un)),On(!1,["boolean","number","string"],((Ln={}).alias="nbf",Ln.optional=!0,Ln)),On(!1,["boolean","string"],((Dn={}).alias="iss",Dn.optional=!0,Dn)),On(!1,["boolean","string"],((Hn={}).alias="sub",Hn.optional=!0,Hn)),On(!1,["boolean","string"],((Bn={}).alias="iss",Bn.optional=!0,Bn)),On(!1,["boolean"],((Kn={}).optional=!0,Kn)),On(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),On(!1,["boolean","string"],((Vn={}).optional=!0,Vn)),On(!1,["boolean"],((Wn={}).optional=!0,Wn));var Xn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zn(t,e){var r;return(r={})[t]=e,r.TS=[Xn()],r}var to=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},eo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=So().key(e);t(ko(r),r)}},remove:function(t){return So().removeItem(t)},clearAll:function(){return So().clear()}};function So(){return jo.localStorage}function ko(t){return So().getItem(t)}var Eo=io.trim,To={name:"cookieStorage",read:function(t){if(!t||!qo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ao.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ao.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:xo,remove:Po,clearAll:function(){xo((function(t,e){Po(e)}))}},Ao=io.Global.document;function xo(t){for(var e=Ao.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Eo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Po(t){t&&qo(t)&&(Ao.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function qo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ao.cookie)}var Co=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 $o=io.bind,No=io.each,zo=io.create,Ro=io.slice,Mo=function(){var t=zo(Jo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,$o(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,$o(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),No(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Jo={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,$o(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Ro(arguments,1);No(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Fo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Fo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Fo.compress(this._serialize(r));t(e,n)}}};var Uo=[Oo,To],Lo=[Co,Mo,Io],Do=mo.createStore(Uo,Lo),Ho=io.Global;function Bo(){return Ho.sessionStorage}function Ko(t){return Bo().getItem(t)}var Go=[{name:"sessionStorage",read:Ko,write:function(t,e){return Bo().setItem(t,e)},each:function(t){for(var e=Bo().length-1;e>=0;e--){var r=Bo().key(e);t(Ko(r),r)}},remove:function(t){return Bo().removeItem(t)},clearAll:function(){return Bo().clear()}},To],Vo=[Co,Io],Wo=mo.createStore(Go,Vo),Yo=Do,Qo=Wo,Xo=function(t){this.opts=t,this.instanceKey=zn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Qo},Zo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Xo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?un({},o,e):e,r))},Xo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Xo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Xo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Zo.lset.set=function(t){return this.__setMethod("localStore",t)},Zo.lget.get=function(){return this.__getMethod("localStore")},Xo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Xo.prototype.lclear=function(){return this.__clearMethod("localStore")},Zo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Zo.sget.get=function(){return this.__getMethod("sessionStore")},Xo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Xo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Xo.prototype,Zo);var ti=u[0],ei=u[1],ri=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Qn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(wn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ht("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&wn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!Nn(t))throw new ht("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Nn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=un({},{_cb:Xn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=un({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=un({},{method:ti,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return to(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=_n(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):to(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new vt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?un({},a,this.getAuthHeader(),this.extraHeader):un({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=un({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(bt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new vt("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),jt(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Zn(t,n)}throw new ht("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(jt(t))return Zn(t,o);throw new ht("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ei}).then(bt)},Object.defineProperties(e.prototype,r),e}(Xo)))),ni={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},oi={hostname:On(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:On("jsonql",["string"]),loginHandlerName:On("login",["string"]),logoutHandlerName:On("logout",["string"]),enableJsonp:On(!1,["boolean"]),enableAuth:On(!1,["boolean"]),useJwt:On(!0,["boolean"]),persistToken:On(!1,["boolean","number"]),useLocalstorage:On(!0,["boolean"]),storageKey:On("jsonqlstore",["string"]),authKey:On("jsonqlauthkey",["string"]),contractExpired:On(0,["number"]),keepContract:On(!0,["boolean"]),exposeContract:On(!1,["boolean"]),exposeStore:On(!1,["boolean"]),showContractDesc:On(!1,["boolean"]),contractKey:On(!1,["boolean"]),contractKeyName:On("X-JSONQL-CV-KEY",["string"]),enableTimeout:On(!1,["boolean"]),timeout:On(5e3,["number"]),returnInstance:On(!1,["boolean"]),allowReturnRawToken:On(!1,["boolean"]),debugOn:On(!1,["boolean"])};var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$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)},ui.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__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.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(ui.prototype,ci);var si=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return zn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r,n=e.contract,o=function(t){return En(t,"__checked__")?Object.assign(t,ni):Sn(t,oi,ni)}(e),i=new ri(t,o),a=function(t,e){return void 0===e&&(e={}),Nn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new si({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){$n(t,n,e,r)})),{query:Cn(n,"query"),mutation:Cn(n,"mutation"),auth:Cn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),fi(new o,t)}})); //# sourceMappingURL=jsonql-client.static-full.js.map diff --git a/packages/http-client/dist/jsonql-client.static-full.js.map b/packages/http-client/dist/jsonql-client.static-full.js.map index 3c08a4e16d61d10272adb7f868c817f0ec4a989c..3c65edf105d418c4a40f6d5cd83342e251675506 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js.map +++ b/packages/http-client/dist/jsonql-client.static-full.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"2niDAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wriDAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index ee54261e0ac8f03c55586a7846cd48e5abd935cc..bbcff0a863f67937c5a0980c6f475637afc655d5 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?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlClientStatic={})}(this,(function(t){"use strict";var e="application/vnd.api+json",r={Accept:e,"Content-Type":[e,"charset=utf-8"].join(";")},n=["POST","PUT"],o={desc:"y"},i=Array.isArray,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,s=u||c||Function("return this")(),l=s.Symbol,f=Object.prototype,p=f.hasOwnProperty,h=f.toString,d=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return v.call(t)}(t)}function b(t,e){return function(r){return t(e(r))}}var _=b(Object.getPrototypeOf,Object);function m(t){return null!=t&&"object"==typeof t}var w=Function.prototype,j=Object.prototype,S=w.toString,O=j.hasOwnProperty,k=S.call(Object);function E(t){if(!m(t)||"[object Object]"!=y(t))return!1;var e=_(t);if(null===e)return!0;var r=O.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&S.call(r)==k}function A(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--&&z(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Y=function(t){return i(t)?t:[t]},Q=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=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),tt=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),et=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),rt=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),nt=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),ot=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),it=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),at=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),ut=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),ct=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),st=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),lt=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),ft=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),pt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlForbiddenError:et,JsonqlAuthorisationError:rt,JsonqlContractAuthError:nt,JsonqlResolverAppError:ot,JsonqlResolverNotFoundError:it,JsonqlEnumError:at,JsonqlTypeError:ut,JsonqlCheckerError:ct,JsonqlValidationError:st,JsonqlError:lt,JsonqlServerError:ft}),ht=lt;function dt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&pt[o])throw new pt[r](i,a);throw new ht(i,a)}return t}function vt(t){if(Array.isArray(t))throw new st("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);default:throw new lt(e,r)}}var gt=function(t){return!!i(t)||null!=t&&""!==W(t)};function yt(t){return function(t){return"number"==typeof t||m(t)&&"[object Number]"==y(t)}(t)&&t!=+t}function bt(t){return"string"==typeof t||!i(t)&&m(t)&&"[object String]"==y(t)}var _t=function(t){return!bt(t)&&!yt(parseFloat(t))},mt=function(t){return""!==W(t)&&bt(t)},wt=function(t){return null!=t&&"boolean"==typeof t},jt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==W(t)&&(!1===e||!0===e&&null!==t)},St=function(t){switch(t){case"number":return _t;case"string":return mt;case"boolean":return wt;default:return jt}},Ot=function(t,e){return void 0===e&&(e=""),!!i(t)&&(""===e||""===W(e)||!(t.filter((function(t){return!St(e)(t)})).length>0))},kt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Et=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!St(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Ot(r,t)})).length};var At,Tt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return m(t)&&"[object Arguments]"==y(t)}var qt=Object.prototype,xt=qt.hasOwnProperty,Ct=qt.propertyIsEnumerable,$t=Pt(function(){return arguments}())?Pt:function(t){return m(t)&&xt.call(t,"callee")&&!Ct.call(t,"callee")};var zt="object"==typeof t&&t&&!t.nodeType&&t,Nt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Nt&&Nt.exports===zt?s.Buffer:void 0,Rt=(Mt?Mt.isBuffer:void 0)||function(){return!1},It=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&It.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof t&&t&&!t.nodeType&&t,Dt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Dt&&Dt.exports===Ht&&u.process,Bt=function(){try{var t=Dt&&Dt.require&&Dt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Bt&&Bt.isTypedArray,Gt=Vt?(Lt=Vt,function(t){return Lt(t)}):function(t){return m(t)&&Jt(t.length)&&!!Ut[y(t)]},Wt=Object.prototype.hasOwnProperty;function Yt(t,e){var r=i(t),n=!r&&$t(t),o=!r&&!n&&Rt(t),a=!r&&!n&&!o&&Gt(t),u=r||n||o||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},se.prototype.set=function(t,e){var r=this.__data__,n=ue(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,fe=s["__core-js_shared__"],pe=(le=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var he=Function.prototype.toString;function de(t){if(null!=t){try{return he.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ve=/^\[object .+?Constructor\]$/,ge=Function.prototype,ye=Object.prototype,be=ge.toString,_e=ye.hasOwnProperty,me=RegExp("^"+be.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function we(t){return!(!ee(t)||function(t){return!!pe&&pe in t}(t))&&(re(t)?me:ve).test(de(t))}function je(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return we(r)?r:void 0}var Se=je(s,"Map"),Oe=je(Object,"create");var ke=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;function Ae(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 l=-1,f=!0,p=2&r?new xe:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=kt(t))?!Et({arg:r},e):!St(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Er,null,a);case"array"===t:return!Ot(e.arg);case!1!==(r=kt(t)):return!Et(e,r);default:return!St(t)(e.arg)}},Tr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Ot(e))throw new lt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Ot(t))throw new lt("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Tr(t,a):t,index:r,param:a,optional:i}}));default:throw new lt("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!!gt(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=je(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function xr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Cr(t,e,r){(void 0===r||ae(t[e],r))&&(void 0!==r||e in t)||xr(t,e,r)}var $r="object"==typeof t&&t&&!t.nodeType&&t,zr=$r&&"object"==typeof module&&module&&!module.nodeType&&module,Nr=zr&&zr.exports===$r?s.Buffer:void 0,Mr=Nr?Nr.allocUnsafe:void 0;function Rr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ze(n).set(new ze(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ir=Object.create,Fr=function(){function t(){}return function(e){if(!ee(e))return{};if(Ir)return Ir(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Jr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ur=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Ur.call(t,e)&&ae(n,r)&&(void 0!==r||e in t)||xr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Dr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return ne(t)?Yt(t,!0):Dr(t)}function Br(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Qr);function tn(t,e){return Zr(function(t,e,r){return e=Yr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Yr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=en.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?ne(r)&&Ft(e,r.length):"string"==n&&e in r)&&ae(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,Y(t))}),Reflect.apply(t,null,r))}};function jn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Sn(t,e,r,n){void 0===n&&(n=!1);var o=jn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var On=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 bn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},kn=function(t,e,r,n,o){var i={},a=function(t){i=Sn(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={};return bn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},En=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return bn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},An=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=On(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=On(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Tn=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(X(e,r,"onResult"),o),t.$only(X(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function Pn(t,e,r,n){var o=function(t,e,r,n){var o=[kn,En,An];return Reflect.apply(wn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(X(t,n,"onResult"),r)})).catch((function(r){e.$trigger(X(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function qn(t){return!!function(t){return E(t)&&(Q(t,"query")||Q(t,"mutation")||Q(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidCharacterError";var $n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Cn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var zn=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($n(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 $n(e)}};function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidTokenError";var Mn=function(t,e){if("string"!=typeof t)throw new Nn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(zn(t.split(".")[r]))}catch(t){throw new Nn("Invalid token specified: "+t.message)}};Mn.InvalidTokenError=Nn;var Rn,In,Fn,Jn,Un,Ln,Hn,Dn,Kn;function Bn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new lt("Token has expired on "+r,t)}return t}function Vn(t){if(mt(t))return Bn(Mn(t));throw new lt("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Rn={}).alias="exp",Rn.optional=!0,Rn)),_n(!1,["boolean","number","string"],((In={}).alias="nbf",In.optional=!0,In)),_n(!1,["boolean","string"],((Fn={}).alias="iss",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Jn={}).alias="sub",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean"],((Ln={}).optional=!0,Ln)),_n(!1,["boolean","string"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Dn={}).optional=!0,Dn)),_n(!1,["boolean"],((Kn={}).optional=!0,Kn));var Gn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Wn(t,e){var r;return(r={})[t]=e,r.TS=[Gn()],r}var Yn=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},Qn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Xn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=wo().key(e);t(jo(r),r)}},remove:function(t){return wo().removeItem(t)},clearAll:function(){return wo().clear()}};function wo(){return _o.localStorage}function jo(t){return wo().getItem(t)}var So=ro.trim,Oo={name:"cookieStorage",read:function(t){if(!t||!To(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ko.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ko.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Eo,remove:Ao,clearAll:function(){Eo((function(t,e){Ao(e)}))}},ko=ro.Global.document;function Eo(t){for(var e=ko.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&To(t)&&(ko.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function To(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ko.cookie)}var Po=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 qo=ro.bind,xo=ro.each,Co=ro.create,$o=ro.slice,zo=function(){var t=Co(No,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),xo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var No={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=$o(arguments,1);xo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Ro=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Io=[mo,Oo],Fo=[Po,zo,Ro],Jo=go.createStore(Io,Fo),Uo=ro.Global;function Lo(){return Uo.sessionStorage}function Ho(t){return Lo().getItem(t)}var Do=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},Oo],Ko=[Po,Ro],Bo=go.createStore(Do,Ko),Vo=Jo,Go=Bo,Wo=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Vo,this.sessionStore=Go},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Wo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?rn({},o,e):e,r))},Wo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Wo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Wo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Wo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Wo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Wo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Wo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Wo.prototype,Yo);var Qo=n[0],Xo=n[1],Zo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Vn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(yn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new st("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&yn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!qn(t))throw new st("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=qn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=rn({},{_cb:Gn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=rn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=rn({},{method:Qo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Yn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=gn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Yn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new ft("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?rn({},r,this.getAuthHeader(),this.extraHeader):rn({},r,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=rn({},this.extraParams,o)),this.request({},{method:"GET"},this.contractHeader).then(dt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new ft("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),bt(t)&&i(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Wn(t,n)}throw new st("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(bt(t))return Wn(t,o);throw new st("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xo}).then(dt)},Object.defineProperties(e.prototype,n),e}(Wo)))),ti={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:e,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ei={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r,n=e.contract,o=function(t){return jn(t,"__checked__")?Object.assign(t,ti):mn(t,ei,ti)}(e),i=new Zo(t,o),a=function(t,e){return void 0===e&&(e={}),qn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){Pn(t,n,e,r)})),{query:Tn(n,"query"),mutation:Tn(n,"mutation"),auth:Tn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c},Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlClientStatic={})}(this,(function(t){"use strict";var e="application/vnd.api+json",r={Accept:e,"Content-Type":[e,"charset=utf-8"].join(";")},n=["POST","PUT"],o={desc:"y"},i=Array.isArray,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,s=u||c||Function("return this")(),l=s.Symbol,f=Object.prototype,p=f.hasOwnProperty,h=f.toString,d=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return v.call(t)}(t)}function b(t,e){return function(r){return t(e(r))}}var _=b(Object.getPrototypeOf,Object);function m(t){return null!=t&&"object"==typeof t}var w=Function.prototype,j=Object.prototype,S=w.toString,O=j.hasOwnProperty,k=S.call(Object);function E(t){if(!m(t)||"[object Object]"!=y(t))return!1;var e=_(t);if(null===e)return!0;var r=O.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&S.call(r)==k}function A(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--&&z(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Y=function(t){return i(t)?t:[t]},Q=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=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),tt=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),et=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),rt=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),nt=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),ot=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),it=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),at=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),ut=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),ct=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),st=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),lt=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),ft=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),pt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlForbiddenError:et,JsonqlAuthorisationError:rt,JsonqlContractAuthError:nt,JsonqlResolverAppError:ot,JsonqlResolverNotFoundError:it,JsonqlEnumError:at,JsonqlTypeError:ut,JsonqlCheckerError:ct,JsonqlValidationError:st,JsonqlError:lt,JsonqlServerError:ft}),ht=lt;function dt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&pt[o])throw new pt[r](i,a);throw new ht(i,a)}return t}function vt(t){if(Array.isArray(t))throw new st("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);default:throw new lt(e,r)}}var gt=function(t){return!!i(t)||null!=t&&""!==W(t)};function yt(t){return function(t){return"number"==typeof t||m(t)&&"[object Number]"==y(t)}(t)&&t!=+t}function bt(t){return"string"==typeof t||!i(t)&&m(t)&&"[object String]"==y(t)}var _t=function(t){return!bt(t)&&!yt(parseFloat(t))},mt=function(t){return""!==W(t)&&bt(t)},wt=function(t){return null!=t&&"boolean"==typeof t},jt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==W(t)&&(!1===e||!0===e&&null!==t)},St=function(t){switch(t){case"number":return _t;case"string":return mt;case"boolean":return wt;default:return jt}},Ot=function(t,e){return void 0===e&&(e=""),!!i(t)&&(""===e||""===W(e)||!(t.filter((function(t){return!St(e)(t)})).length>0))},kt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Et=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!St(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Ot(r,t)})).length};var At,Tt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return m(t)&&"[object Arguments]"==y(t)}var qt=Object.prototype,xt=qt.hasOwnProperty,Ct=qt.propertyIsEnumerable,$t=Pt(function(){return arguments}())?Pt:function(t){return m(t)&&xt.call(t,"callee")&&!Ct.call(t,"callee")};var zt="object"==typeof t&&t&&!t.nodeType&&t,Nt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=Nt&&Nt.exports===zt?s.Buffer:void 0,Mt=(Rt?Rt.isBuffer:void 0)||function(){return!1},It=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&It.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof t&&t&&!t.nodeType&&t,Dt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Dt&&Dt.exports===Ht&&u.process,Bt=function(){try{var t=Dt&&Dt.require&&Dt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Gt=Bt&&Bt.isTypedArray,Vt=Gt?(Lt=Gt,function(t){return Lt(t)}):function(t){return m(t)&&Jt(t.length)&&!!Ut[y(t)]},Wt=Object.prototype.hasOwnProperty;function Yt(t,e){var r=i(t),n=!r&&$t(t),o=!r&&!n&&Mt(t),a=!r&&!n&&!o&&Vt(t),u=r||n||o||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},se.prototype.set=function(t,e){var r=this.__data__,n=ue(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,fe=s["__core-js_shared__"],pe=(le=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var he=Function.prototype.toString;function de(t){if(null!=t){try{return he.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ve=/^\[object .+?Constructor\]$/,ge=Function.prototype,ye=Object.prototype,be=ge.toString,_e=ye.hasOwnProperty,me=RegExp("^"+be.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function we(t){return!(!ee(t)||function(t){return!!pe&&pe in t}(t))&&(re(t)?me:ve).test(de(t))}function je(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return we(r)?r:void 0}var Se=je(s,"Map"),Oe=je(Object,"create");var ke=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;function Ae(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 l=-1,f=!0,p=2&r?new xe:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=kt(t))?!Et({arg:r},e):!St(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Er,null,a);case"array"===t:return!Ot(e.arg);case!1!==(r=kt(t)):return!Et(e,r);default:return!St(t)(e.arg)}},Tr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Ot(e))throw new lt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Ot(t))throw new lt("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?Tr(t,a):t,index:r,param:a,optional:i}}));default:throw new lt("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!!gt(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=je(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function xr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Cr(t,e,r){(void 0===r||ae(t[e],r))&&(void 0!==r||e in t)||xr(t,e,r)}var $r="object"==typeof t&&t&&!t.nodeType&&t,zr=$r&&"object"==typeof module&&module&&!module.nodeType&&module,Nr=zr&&zr.exports===$r?s.Buffer:void 0,Rr=Nr?Nr.allocUnsafe:void 0;function Mr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ze(n).set(new ze(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ir=Object.create,Fr=function(){function t(){}return function(e){if(!ee(e))return{};if(Ir)return Ir(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Jr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ur=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Ur.call(t,e)&&ae(n,r)&&(void 0!==r||e in t)||xr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Dr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return ne(t)?Yt(t,!0):Dr(t)}function Br(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Qr);function tn(t,e){return Zr(function(t,e,r){return e=Yr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Yr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=en.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?ne(r)&&Ft(e,r.length):"string"==n&&e in r)&&ae(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,Y(t))}),Reflect.apply(t,null,r))}};function jn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Sn(t,e,r,n){void 0===n&&(n=!1);var o=jn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var On=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 bn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},kn=function(t,e,r,n,o){var i={},a=function(t){i=Sn(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={};return bn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},En=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return bn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},An=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=On(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=On(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Tn=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(X(e,r,"onResult"),o),t.$only(X(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function Pn(t,e,r,n){var o=function(t,e,r,n){var o=[kn,En,An];return Reflect.apply(wn,null,o)({},t,e,r,n)}(t,e,r,n);!function(t,e,r,n){var o=t.$queues;n("(validateRegisteredEvents)","storedEvt",o),o.forEach((function(t){var r=t[0],o=t[1].resolverName;if(n("(validateRegisteredEvents)",r,o),!e[r][o])throw new Error(r+"."+o+" not existed in contract!")}))}(e,n,0,(function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,e)}));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.$call(X(t,n,"onResult"))(r)})).catch((function(r){e.$trigger(X(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function qn(t){return!!function(t){return E(t)&&(Q(t,"query")||Q(t,"mutation")||Q(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidCharacterError";var $n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Cn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var zn=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($n(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 $n(e)}};function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidTokenError";var Rn=function(t,e){if("string"!=typeof t)throw new Nn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(zn(t.split(".")[r]))}catch(t){throw new Nn("Invalid token specified: "+t.message)}};Rn.InvalidTokenError=Nn;var Mn,In,Fn,Jn,Un,Ln,Hn,Dn,Kn;function Bn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new lt("Token has expired on "+r,t)}return t}function Gn(t){if(mt(t))return Bn(Rn(t));throw new lt("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Mn={}).alias="exp",Mn.optional=!0,Mn)),_n(!1,["boolean","number","string"],((In={}).alias="nbf",In.optional=!0,In)),_n(!1,["boolean","string"],((Fn={}).alias="iss",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Jn={}).alias="sub",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean"],((Ln={}).optional=!0,Ln)),_n(!1,["boolean","string"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Dn={}).optional=!0,Dn)),_n(!1,["boolean"],((Kn={}).optional=!0,Kn));var Vn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Wn(t,e){var r;return(r={})[t]=e,r.TS=[Vn()],r}var Yn=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},Qn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Xn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=wo().key(e);t(jo(r),r)}},remove:function(t){return wo().removeItem(t)},clearAll:function(){return wo().clear()}};function wo(){return _o.localStorage}function jo(t){return wo().getItem(t)}var So=ro.trim,Oo={name:"cookieStorage",read:function(t){if(!t||!To(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ko.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ko.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Eo,remove:Ao,clearAll:function(){Eo((function(t,e){Ao(e)}))}},ko=ro.Global.document;function Eo(t){for(var e=ko.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&To(t)&&(ko.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function To(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ko.cookie)}var Po=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 qo=ro.bind,xo=ro.each,Co=ro.create,$o=ro.slice,zo=function(){var t=Co(No,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),xo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var No={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=$o(arguments,1);xo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Ro=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Mo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ro.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ro.compress(this._serialize(r));t(e,n)}}};var Io=[mo,Oo],Fo=[Po,zo,Mo],Jo=go.createStore(Io,Fo),Uo=ro.Global;function Lo(){return Uo.sessionStorage}function Ho(t){return Lo().getItem(t)}var Do=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},Oo],Ko=[Po,Mo],Bo=go.createStore(Do,Ko),Go=Jo,Vo=Bo,Wo=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Go,this.sessionStore=Vo},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Wo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?rn({},o,e):e,r))},Wo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Wo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Wo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Wo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Wo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Wo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Wo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Wo.prototype,Yo);var Qo=n[0],Xo=n[1],Zo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Gn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(yn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new st("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&yn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!qn(t))throw new st("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=qn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=rn({},{_cb:Vn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=rn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=rn({},{method:Qo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Yn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=gn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Yn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new ft("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?rn({},r,this.getAuthHeader(),this.extraHeader):rn({},r,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=rn({},this.extraParams,o)),this.request({},{method:"GET"},this.contractHeader).then(dt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new ft("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),bt(t)&&i(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Wn(t,n)}throw new st("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(bt(t))return Wn(t,o);throw new st("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xo}).then(dt)},Object.defineProperties(e.prototype,n),e}(Wo)))),ti={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:e,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ei={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r,n=e.contract,o=function(t){return jn(t,"__checked__")?Object.assign(t,ti):mn(t,ei,ti)}(e),i=new Zo(t,o),a=function(t,e){return void 0===e&&(e={}),qn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){Pn(t,n,e,r)})),{query:Tn(n,"query"),mutation:Tn(n,"mutation"),auth:Tn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js.map b/packages/http-client/dist/jsonql-client.static.js.map index 29f492ffc1d5eaa05df5d451d090a599656c725f..f7669d589917db43b742ee52ae09ef16d768915d 100644 --- a/packages/http-client/dist/jsonql-client.static.js.map +++ b/packages/http-client/dist/jsonql-client.static.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"q71CAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"k/1CAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index 41019c374e38bd2bab496dd24340cea8b2c0a603..ade56507ed87fa5c70e4e8f313d4924707b28e6d 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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=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),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={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),u=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),c=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),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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),f=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),l=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),p=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),h=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),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={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},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={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"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={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),w=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),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(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--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||J(t)&&"[object Number]"==F(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&J(t)&&"[object String]"==F(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!J(t)||"[object Object]"!=F(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return J(t)&&"[object Arguments]"==F(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return J(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Ft=/^(?:0|[1-9]\d*)$/;function Jt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Ft.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Dt={};Dt["[object Float32Array]"]=Dt["[object Float64Array]"]=Dt["[object Int8Array]"]=Dt["[object Int16Array]"]=Dt["[object Int32Array]"]=Dt["[object Uint8Array]"]=Dt["[object Uint8ClampedArray]"]=Dt["[object Uint16Array]"]=Dt["[object Uint32Array]"]=!0,Dt["[object Arguments]"]=Dt["[object Array]"]=Dt["[object ArrayBuffer]"]=Dt["[object Boolean]"]=Dt["[object DataView]"]=Dt["[object Date]"]=Dt["[object Error]"]=Dt["[object Function]"]=Dt["[object Map]"]=Dt["[object Number]"]=Dt["[object Object]"]=Dt["[object RegExp]"]=Dt["[object Set]"]=Dt["[object String]"]=Dt["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Wt=Vt?(Lt=Vt,function(t){return Lt(t)}):function(t){return J(t)&&Ut(t.length)&&!!Dt[F(t)]},Yt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Wt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(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=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("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!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Fr=Object.create,Jr=function(){function t(){}return function(e){if(!re(e))return{};if(Fr)return Fr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Dr=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Dr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Jt(e,r.length):"string"==n&&e in r)&&ue(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=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 mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n,o){var i={},a=function(t){i=En(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={};return mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},xn=function(t,e,r,n,o){var i={},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Pn=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=Tn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var qn=function(t,e,r,n){var o=function(t,e,r,n){var o=[An,xn,Pn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.19",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function Cn(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function $n(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function zn(t){this.message=t}zn.prototype=new Error,zn.prototype.name="InvalidCharacterError";var Nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new zn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Rn=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(Nn(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 Nn(e)}};function Mn(t){this.message=t}Mn.prototype=new Error,Mn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Mn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Rn(t.split(".")[r]))}catch(t){throw new Mn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Mn;var Fn,Jn,Un,Dn,Ln,Hn,Bn,Kn,Gn;function Vn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Vn(In(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Fn={}).alias="exp",Fn.optional=!0,Fn)),_n(!1,["boolean","number","string"],((Jn={}).alias="nbf",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Dn={}).alias="sub",Dn.optional=!0,Dn)),_n(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),_n(!1,["boolean"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean"],((Gn={}).optional=!0,Gn));var Yn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Qn(t,e){var r;return(r={})[t]=e,r.TS=[Yn()],r}var Xn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},Zn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=jo().key(e);t(Oo(r),r)}},remove:function(t){return jo().removeItem(t)},clearAll:function(){return jo().clear()}};function jo(){return _o.localStorage}function Oo(t){return jo().getItem(t)}var So=no.trim,ko={name:"cookieStorage",read:function(t){if(!t||!xo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Eo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Eo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:To,remove:Ao,clearAll:function(){To((function(t,e){Ao(e)}))}},Eo=no.Global.document;function To(t){for(var e=Eo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&xo(t)&&(Eo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function xo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Eo.cookie)}var Po=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 qo=no.bind,Co=no.each,$o=no.create,zo=no.slice,No=function(){var t=$o(Ro,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Co(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ro={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=zo(arguments,1);Co(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Fo=[wo,ko],Jo=[Po,No,Io],Uo=yo.createStore(Fo,Jo),Do=no.Global;function Lo(){return Do.sessionStorage}function Ho(t){return Lo().getItem(t)}var Bo=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},ko],Ko=[Po,Io],Go=yo.createStore(Bo,Ko),Vo=Uo,Wo=Go,Yo=function(t){this.opts=t,this.instanceKey=$n(this.opts.hostname),this.localStore=Vo,this.sessionStore=Wo},Qo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Yo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?nn({},o,e):e,r))},Yo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Yo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Yo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Qo.lset.set=function(t){return this.__setMethod("localStore",t)},Qo.lget.get=function(){return this.__getMethod("localStore")},Yo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Yo.prototype.lclear=function(){return this.__clearMethod("localStore")},Qo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Qo.sget.get=function(){return this.__getMethod("sessionStore")},Yo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Yo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Yo.prototype,Qo);var Xo=b[0],Zo=b[1],ti=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Wn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&bn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!Cn(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Cn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=nn({},{_cb:Yn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Xo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Xn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Xn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new w("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Qn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Qn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Zo}).then(S)},Object.defineProperties(e.prototype,r),e}(Yo)))),ei={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ri={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};function ni(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return En(t,"__checked__",Yn())};r.push(o);var i=Reflect.apply(Sn,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function oi(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),kn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ni,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ri,ei,wn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ii(t,e,r){return void 0===r&&(r={}),oi(r).then((function(t){return{baseClient:new ti(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),Cn(n)?Promise.resolve(n):r.getContract()).then((function(e){return qn(o,i,e,t)}))}))}var ai=new WeakMap,ui=new WeakMap,ci=function(){this.__suspend__=null,this.queueStore=new Set},si={$suspend:{configurable:!0},$queues:{configurable:!0}};si.$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)},ci.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__},si.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ci.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(ci.prototype,si);var fi=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ai.set(this,t)},r.normalStore.get=function(){return ai.get(this)},r.lazyStore.set=function(t){ui.set(this,t)},r.lazyStore.get=function(){return ui.get(this)},e.prototype.hashFnToKey=function(t){return $n(t.toString())},Object.defineProperties(e.prototype,r),e}(ci)));function li(t,e){var r;return ii((r=e.debugOn,new fi({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}return function(t){return void 0===t&&(t={}),li(new 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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=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),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={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),u=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),c=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),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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),f=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),l=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),p=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),h=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),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={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},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={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"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={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),w=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),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(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--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||F(t)&&"[object Number]"==J(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&F(t)&&"[object String]"==J(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!F(t)||"[object Object]"!=J(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return F(t)&&"[object Arguments]"==J(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return F(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Jt=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Jt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Dt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Wt=Vt?(Dt=Vt,function(t){return Dt(t)}):function(t){return F(t)&&Ut(t.length)&&!!Lt[J(t)]},Yt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Wt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(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=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("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 t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable: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: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?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("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!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Jr=Object.create,Fr=function(){function t(){}return function(e){if(!re(e))return{};if(Jr)return Jr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Lr=Object.prototype.hasOwnProperty;function Dr(t,e,r){var n=t[e];Lr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Ft(e,r.length):"string"==n&&e in r)&&ue(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)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,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=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 mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n,o){var i={},a=function(t){i=En(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={};return mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},xn=function(t,e,r,n,o){var i={},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Pn=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=Tn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var qn=function(t,e,r,n){var o=function(t,e,r,n){var o=[An,xn,Pn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.20",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function Cn(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function $n(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function zn(t){this.message=t}zn.prototype=new Error,zn.prototype.name="InvalidCharacterError";var Nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new zn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Rn=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(Nn(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 Nn(e)}};function Mn(t){this.message=t}Mn.prototype=new Error,Mn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Mn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Rn(t.split(".")[r]))}catch(t){throw new Mn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Mn;var Jn,Fn,Un,Ln,Dn,Hn,Bn,Kn,Gn;function Vn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Vn(In(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Jn={}).alias="exp",Jn.optional=!0,Jn)),_n(!1,["boolean","number","string"],((Fn={}).alias="nbf",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Ln={}).alias="sub",Ln.optional=!0,Ln)),_n(!1,["boolean","string"],((Dn={}).alias="iss",Dn.optional=!0,Dn)),_n(!1,["boolean"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean"],((Gn={}).optional=!0,Gn));var Yn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Qn(t,e){var r;return(r={})[t]=e,r.TS=[Yn()],r}var Xn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},Zn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=jo().key(e);t(Oo(r),r)}},remove:function(t){return jo().removeItem(t)},clearAll:function(){return jo().clear()}};function jo(){return _o.localStorage}function Oo(t){return jo().getItem(t)}var So=no.trim,ko={name:"cookieStorage",read:function(t){if(!t||!xo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Eo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Eo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:To,remove:Ao,clearAll:function(){To((function(t,e){Ao(e)}))}},Eo=no.Global.document;function To(t){for(var e=Eo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&xo(t)&&(Eo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function xo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Eo.cookie)}var Po=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 qo=no.bind,Co=no.each,$o=no.create,zo=no.slice,No=function(){var t=$o(Ro,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Co(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ro={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=zo(arguments,1);Co(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Jo=[wo,ko],Fo=[Po,No,Io],Uo=yo.createStore(Jo,Fo),Lo=no.Global;function Do(){return Lo.sessionStorage}function Ho(t){return Do().getItem(t)}var Bo=[{name:"sessionStorage",read:Ho,write:function(t,e){return Do().setItem(t,e)},each:function(t){for(var e=Do().length-1;e>=0;e--){var r=Do().key(e);t(Ho(r),r)}},remove:function(t){return Do().removeItem(t)},clearAll:function(){return Do().clear()}},ko],Ko=[Po,Io],Go=yo.createStore(Bo,Ko),Vo=Uo,Wo=Go,Yo=function(t){this.opts=t,this.instanceKey=$n(this.opts.hostname),this.localStore=Vo,this.sessionStore=Wo},Qo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Yo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?nn({},o,e):e,r))},Yo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Yo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Yo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Qo.lset.set=function(t){return this.__setMethod("localStore",t)},Qo.lget.get=function(){return this.__getMethod("localStore")},Yo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Yo.prototype.lclear=function(){return this.__clearMethod("localStore")},Qo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Qo.sget.get=function(){return this.__getMethod("sessionStore")},Yo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Yo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Yo.prototype,Qo);var Xo=b[0],Zo=b[1],ti=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Wn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&bn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",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();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().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){var e;if(!Cn(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Cn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=nn({},{_cb:Yn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Xo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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}))},e.prototype.processJsonp=function(t){return Xn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Xn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new w("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Qn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Qn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Zo}).then(S)},Object.defineProperties(e.prototype,r),e}(Yo)))),ei={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ri={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};function ni(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return En(t,"__checked__",Yn())};r.push(o);var i=Reflect.apply(Sn,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function oi(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),kn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ni,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ri,ei,wn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ii(t,e,r){return void 0===r&&(r={}),oi(r).then((function(t){return{baseClient:new ti(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),Cn(n)?Promise.resolve(n):r.getContract()).then((function(e){return qn(o,i,e,t)}))}))}var ai=new WeakMap,ui=new WeakMap,ci=function(){this.__suspend__=null,this.queueStore=new Set},si={$suspend:{configurable:!0},$queues:{configurable:!0}};si.$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)},ci.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__},si.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ci.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(ci.prototype,si);var fi=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ai.set(this,t)},r.normalStore.get=function(){return ai.get(this)},r.lazyStore.set=function(t){ui.set(this,t)},r.lazyStore.get=function(){return ui.get(this)},e.prototype.hashFnToKey=function(t){return $n(t.toString())},Object.defineProperties(e.prototype,r),e}(ci)));function li(t,e){var r;return ii((r=e.debugOn,new fi({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}return function(t){return void 0===t&&(t={}),li(new o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 14c770c35857e74979a5314b419fe15f8efcf02d..3f31edd090369e5837fc20eb23b691d1ede59bf7 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.5.19", + "version": "1.5.20", "description": "jsonql http browser client using Fly.js with full user profile management with jwt and more", "main": "core.js", "module": "index.js", @@ -19,7 +19,6 @@ "test": "ava", "prepare": "npm run build", "test:browser": "npm run build:test && npm run test:browser:run", - "_publish": "npm publish --access public", "test:utils": "node ./main.js", "test:opt": "DEBUG=jsonql-* ava ./tests/opt.test.js", "test:contract": "DEBUG=jsonql-* ava ./tests/contract-lock.test.js", @@ -69,11 +68,11 @@ "jsonql-params-validator": "^1.5.2", "jsonql-utils": "^0.9.7", "lodash-es": "^4.17.15", - "nb-event-service": "^1.9.0", + "nb-event-service": "^1.9.1", "store": "^2.0.12" }, "devDependencies": { - "ava": "^3.3.0", + "ava": "^3.4.0", "browser-env": "^3.3.0", "debug": "^4.1.1", "esm": "^3.2.25", diff --git a/packages/http-client/src/base/base-cls.js b/packages/http-client/src/base/base-cls.js index 153fc5770ccc9ecbcd32d948beb588b82efcbef3..875f3bd46df94ba5da9bd508a4f8823c2f950c85 100644 --- a/packages/http-client/src/base/base-cls.js +++ b/packages/http-client/src/base/base-cls.js @@ -14,7 +14,7 @@ export default class JsonqlBaseEngine extends AuthCls { super(opts) // change at 1.4.10 pass it directly without init it this.httpEngine = httpEngine // fly.js - // this two methods defined in http-cls, and execute the create interceptors + // this two methods defined in http-cls, and execute the create interceptors this.reqInterceptor() this.resInterceptor() } @@ -29,7 +29,7 @@ export default class JsonqlBaseEngine extends AuthCls { } /** - * simple log control by the debugOn option + * simple log control by the debugOn option * @param {array<*>} args * @return {void} */ @@ -38,8 +38,13 @@ export default class JsonqlBaseEngine extends AuthCls { const fns = ['info', 'error'] const idx = (args[0] === LOG_ERROR_SWITCH) ? 1 : 0 args.splice(0, idx) - Reflect.apply(console[fns[idx]], console, args) + // add an id to the beginning + Reflect.apply(console[fns[idx]], console, ['[JSONQL_LOG]'].concat(args)) } + /* make it a function and pass to it? + else if (typeof this.opts.debugOn === 'function') { + Reflect.apply(this.opts.debugOn, null, [args]) + } */ } } diff --git a/packages/http-client/src/base/http-cls.js b/packages/http-client/src/base/http-cls.js index 7692685d359d0732952a85957448e22a6900eba7..f04639d9b259fc6a0290675a70e4fd84493631a0 100644 --- a/packages/http-client/src/base/http-cls.js +++ b/packages/http-client/src/base/http-cls.js @@ -70,7 +70,7 @@ export default class HttpClass extends StoreClass { /** * This will replace the create baseRequest method - * + * @return {null} nothing to return */ reqInterceptor() { this.httpEngine.interceptors.request.use( @@ -93,7 +93,7 @@ export default class HttpClass extends StoreClass { /** * This will be replacement of the first then call - * + * @return {null} nothing to return */ resInterceptor() { const self = this @@ -106,7 +106,7 @@ export default class HttpClass extends StoreClass { // there is a problem if we throw the result.error here // the original data is lost, so we need to do what we did before // deal with that error in the first then instead - const result = isString(res.data) ? JSON.parse(res.data) : res.data; + const result = isString(res.data) ? JSON.parse(res.data) : res.data if (jsonp) { return self.processJsonp(result) } diff --git a/packages/http-client/src/core/jsonql-static-generator.js b/packages/http-client/src/core/jsonql-static-generator.js index 162af238eb317ae519a6283abf213031bc92c82d..89293f573b3ed22db2fb21c0e43220ccb2639c21 100644 --- a/packages/http-client/src/core/jsonql-static-generator.js +++ b/packages/http-client/src/core/jsonql-static-generator.js @@ -2,7 +2,6 @@ // with default methods import { ON_RESULT_PROP_NAME, ON_ERROR_PROP_NAME } from 'jsonql-constants' import { createEvt } from 'jsonql-utils/src/generic' - import { methodsGenerator } from './methods-generator' /** @@ -14,7 +13,7 @@ import { methodsGenerator } from './methods-generator' * @return {function} the handler itself */ const handler = (ee, type) => { - // we don't run validate here because we want until the contract is ready + // we don't run validate here because we have to wait until the contract is ready return (resolverName, ...args) => ( new Promise((resolver, rejecter) => { // this are the callbacks @@ -27,22 +26,19 @@ const handler = (ee, type) => { } /** + * Validate the event names * @param {object} ee eventEmitter * @param {object} contract the map * @param {object} config configuration + * @param {function} logger pass the logger from the class */ -const validateRegisteredEvents = (ee, contract, config) => { - const storedEvt = ee.$queues; - const debug = config.debugOn; - if (debug) { - console.info('(validateRegisteredEvents)', 'storedEvt', storedEvt) - } +const validateRegisteredEvents = (ee, contract, config, logger) => { + const storedEvt = ee.$queues + logger('(validateRegisteredEvents)', 'storedEvt', storedEvt) storedEvt.forEach(args => { - let [type, payload] = args; - let { resolverName } = payload; - if (debug) { - console.info('(validateRegisteredEvents)', type, resolverName) - } + let [type, payload] = args + let { resolverName } = payload + logger('(validateRegisteredEvents)', type, resolverName) if (!contract[type][resolverName]) { throw new Error(`${type}.${resolverName} not existed in contract!`) } @@ -59,7 +55,8 @@ const validateRegisteredEvents = (ee, contract, config) => { */ function setupEventHandlers(jsonqlInstance, ee, config, contract) { let methods = methodsGenerator(jsonqlInstance, ee, config, contract) - validateRegisteredEvents(ee, contract, config) + let logger = (...args) => Reflect.apply(jsonqlInstance.log, jsonqlInstance, args) + validateRegisteredEvents(ee, contract, config, logger) // create handler for (let type in methods) { // setup event listeners - only one listener per type @@ -67,19 +64,21 @@ function setupEventHandlers(jsonqlInstance, ee, config, contract) { if (methods[type][resolverName]) { Reflect.apply(methods[type][resolverName], null, args) .then(result => { - ee.$trigger(createEvt(type, resolverName, ON_RESULT_PROP_NAME), result) + // using the new $call to handle this reason to make sure the array data is correct + ee.$call(createEvt(type, resolverName, ON_RESULT_PROP_NAME))(result) }) .catch(err => { ee.$trigger(createEvt(type, resolverName, ON_ERROR_PROP_NAME), err) }) } else { + // @TODO should this be a halt event? console.error(`${resolverName} is not defined in the contract!`) } }) } // all done now release the queue if any setTimeout(() => { - ee.$suspend = false; + ee.$suspend = false }, 1) } @@ -90,7 +89,7 @@ function setupEventHandlers(jsonqlInstance, ee, config, contract) { * @param {object} ee eventEmitter * @return {object} constructed functions call */ -const generator = (jsonqlInstance, config, contractPromise, ee) => { +const staticGenerator = (jsonqlInstance, config, contractPromise, ee) => { ee.$suspend = true; // hold all the calls // wait for the promise to resolve contractPromise.then(contract => { @@ -102,10 +101,10 @@ const generator = (jsonqlInstance, config, contractPromise, ee) => { mutation: handler(ee, 'mutation'), auth: handler(ee, 'auth') } - // todo + // todo // output - return obj; + return obj } -export default generator; +export { staticGenerator } diff --git a/packages/http-client/src/core/methods-generator.js b/packages/http-client/src/core/methods-generator.js index 74ada6ec9921ba3ebb9a927dfb17b5be8444925c..1b69cfa74b39421b563f7c1a8dc145fb5c41cfa7 100644 --- a/packages/http-client/src/core/methods-generator.js +++ b/packages/http-client/src/core/methods-generator.js @@ -62,9 +62,9 @@ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { .catch(finalCatch) }) } - obj.query = query; + obj.query = query // create an alias to the helloWorld method - obj.helloWorld = query.helloWorld; + obj.helloWorld = query.helloWorld return [ obj, jsonqlInstance, ee, config, contract ] } @@ -130,9 +130,9 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { const fn = authMethodGenerator(jsonqlInstance, logoutHandlerName, config, contract) return fn.apply(null, args) .then(jsonqlInstance.postLogoutAction.bind(jsonqlInstance)) - .then(r => { - ee.$trigger(LOGOUT_NAME, r) - return r; + .then(reason => { + ee.$trigger(LOGOUT_NAME, reason) + return reason }) } } else { // this is only for client side logout @@ -142,10 +142,10 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { ee.$trigger(LOGOUT_NAME, KEY_WORD) } } - obj.auth = auth; + obj.auth = auth } - return obj; + return obj } /** @@ -153,8 +153,8 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { * Therefore we need to take the one been used and return it */ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { - obj.eventEmitter = ee; - obj.contract = contract; + obj.eventEmitter = ee + obj.contract = contract obj.version = '__VERSION__' // use this method then we can hook into the debugOn at the same time // 1.5.2 change it to a getter to return a method, pass a name to id which one is which @@ -167,10 +167,10 @@ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { * @TODO allow to pass an id to switch to different userdata * @return {*} userdata */ - obj.userdata = () => jsonqlInstance.jsonqlUserdata; + obj.userdata = () => jsonqlInstance.jsonqlUserdata // allow getting the token for valdiate agains the socket // if it's not require auth there is no point of calling getToken - obj.getToken = (idx = false) => jsonqlInstance.rawAuthToken(idx); + obj.getToken = (idx = false) => jsonqlInstance.rawAuthToken(idx) // switch profile or read back what is the currenct index obj.profileIndex = (idx = false) => { if (idx === false) { @@ -182,7 +182,7 @@ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { obj.getProfiles = (idx = false) => jsonqlInstance.getProfiles(idx) } - return obj; + return obj } /** diff --git a/packages/http-client/static.js b/packages/http-client/static.js index ff7529064a25067c3ffbeab376b34a9ba3303385..8e06a378c36c29ce6307ac779f038acd6d2e33f7 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -3,7 +3,7 @@ // this is the new Event base interface // the export will be different and purposely design for framework that // is very hard to use Promise such as Vue -import jsonqlStaticGenerator from './src/core/jsonql-static-generator' +import { staticGenerator } from './src/core/jsonql-static-generator' import { JsonqlBaseEngine } from './src/base' import { checkOptions } from './src/options' import { getContractFromConfig } from './src/utils' @@ -23,7 +23,7 @@ export function jsonqlStaticClient(fly, config) { const contractPromise = getContractFromConfig(jsonqlBaseCls, contract) const ee = getEventEmitter(opts.debugOn) // finally - let methods = jsonqlStaticGenerator(jsonqlBaseCls, opts, contractPromise, ee) - methods.eventEmitter = ee; - return methods; + let methods = staticGenerator(jsonqlBaseCls, opts, contractPromise, ee) + methods.eventEmitter = ee + return methods } diff --git a/packages/http-client/tests/fixtures/contracts/contract.json b/packages/http-client/tests/fixtures/contracts/contract.json index 8d1a82fdad548dea27c863a2ae1a66a8dae3e1de..a8001368d996e2d0cff257e24fff447b552efcaa 100644 --- a/packages/http-client/tests/fixtures/contracts/contract.json +++ b/packages/http-client/tests/fixtures/contracts/contract.json @@ -1,5 +1,19 @@ { "query": { + "getArray": { + "public": true, + "file": "/home/joel/projects/open-source/jsonql/packages/http-client/tests/fixtures/resolvers/query/public/get-array.js", + "description": "Test to see why the return result only get the first item in the array", + "params": [], + "returns": [ + { + "type": [ + "array" + ], + "description": "an array result" + } + ] + }, "getSomething": { "public": true, "file": "/home/joel/projects/open-source/jsonql/packages/http-client/tests/fixtures/resolvers/query/public/get-something.js", @@ -118,6 +132,6 @@ ] } }, - "timestamp": 1575716341, + "timestamp": 1582529187, "sourceType": "script" } diff --git a/packages/http-client/tests/fixtures/contracts/public-contract.json b/packages/http-client/tests/fixtures/contracts/public-contract.json index 5467e726204c7251130af8c1349525dd75f744f8..8b9fd08427034a9b8e1cb225d2ad384211ac3e2b 100644 --- a/packages/http-client/tests/fixtures/contracts/public-contract.json +++ b/packages/http-client/tests/fixtures/contracts/public-contract.json @@ -10,6 +10,19 @@ } ] }, + "getArray": { + "public": true, + "description": "Test to see why the return result only get the first item in the array", + "params": [], + "returns": [ + { + "type": [ + "array" + ], + "description": "an array result" + } + ] + }, "getSomething": { "public": true, "description": "This is a new query that require parameters for testing", @@ -124,5 +137,5 @@ ] } }, - "timestamp": 1575716341 + "timestamp": 1582529187 } diff --git a/packages/http-client/tests/fixtures/helpers/setup-browser.js b/packages/http-client/tests/fixtures/helpers/setup-browser.js index 8e6e1dfead05e44f92de7c1675cf300fe657ca7d..fda26251b51d41c805d96547d3e007e475f26af0 100644 --- a/packages/http-client/tests/fixtures/helpers/setup-browser.js +++ b/packages/http-client/tests/fixtures/helpers/setup-browser.js @@ -1,2 +1,2 @@ -const browserEnv = require('browser-env'); -browserEnv(['window', 'document', 'navigator']); +const browserEnv = require('browser-env') +browserEnv(['window', 'document', 'navigator']) diff --git a/packages/http-client/tests/fixtures/resolvers/query/public/get-array.js b/packages/http-client/tests/fixtures/resolvers/query/public/get-array.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1d85e3d60548e051ae70d89edb45c73037e5eb --- /dev/null +++ b/packages/http-client/tests/fixtures/resolvers/query/public/get-array.js @@ -0,0 +1,12 @@ +/** + * Test to see why the return result only get the first item in the array + * @return {array} an array result + */ +module.exports = function getArray() { + return [ + {id: 1, name: 'Tomato'}, + {id: 2, name: 'Fortune'}, + {id: 3, name: 'Little feather'}, + {id: 4, name: 'Fa fa'} + ] +} diff --git a/packages/http-client/tests/fixtures/resolvers/query/test-list.js b/packages/http-client/tests/fixtures/resolvers/query/test-list.js index 1af62f209a2dd3f6f81c3da047bf91f12792c5bc..2febbdb53322f9c39e48f8748ccd5c72feaa3306 100644 --- a/packages/http-client/tests/fixtures/resolvers/query/test-list.js +++ b/packages/http-client/tests/fixtures/resolvers/query/test-list.js @@ -2,7 +2,7 @@ * Just return a Hello world object * @return {object} key hello prop world */ -module.exports = async function() { +module.exports = async function testList() { return { hello: 'World!' }; diff --git a/packages/http-client/tests/qunit/run-qunit-setup.js b/packages/http-client/tests/qunit/run-qunit-setup.js index 4a0f053c428a95808b0102419afc25c54d62690c..3265bcf63824187d6b342414bcfafa1016cd7dac 100644 --- a/packages/http-client/tests/qunit/run-qunit-setup.js +++ b/packages/http-client/tests/qunit/run-qunit-setup.js @@ -4,7 +4,6 @@ const glob = require('glob') const { join, resolve } = require('path') const serverIoCore = require('server-io-core') const jsonqlKoaDir = join(__dirname, '..', 'fixtures') - const { jsonqlKoa } = require('jsonql-koa') // const jsonqlKoa = jsonqlKoaMiddleware.default /** @@ -18,7 +17,7 @@ const getConfig = (config) => { glob(join(baseDir, config.testFilePattern), function(err, files) { // console.info('files found', files) if (err || !files.length) { - console.error('FAILED TO FETCH ANY TEST FILES!') + console.error('glob error', 'FAILED TO FETCH ANY TEST FILES!') return rejecter(err) } // now start the server @@ -40,7 +39,6 @@ const getConfig = (config) => { keysDir: join(jsonqlKoaDir, 'keys'), resolverDir: join(jsonqlKoaDir, 'resolvers'), contractDir: join(jsonqlKoaDir, 'contracts') - // loginHandlerName: 'issuer' }) ] } @@ -53,6 +51,6 @@ module.exports = async function runQunit(userConfig) { return getConfig(userConfig) .then(serverIoCore) .catch(err => { - console.error(err) + console.error('runQunit error', err) }) } diff --git a/packages/http-client/tests/qunit/run-qunit.js b/packages/http-client/tests/qunit/run-qunit.js index f2bfbac76781ba706f340f759b7a37ef75797809..ae12ef8bac05bcb3a160f55ef864590cf19c2b17 100644 --- a/packages/http-client/tests/qunit/run-qunit.js +++ b/packages/http-client/tests/qunit/run-qunit.js @@ -1,7 +1,7 @@ const runQunitSetup = require('./run-qunit-setup') const config = { - "port": 8081, + "port": 10081, "webroot": [ "./tests/qunit/webroot", "./tests/qunit/tests", diff --git a/packages/http-client/tests/qunit/tests/base-test.js b/packages/http-client/tests/qunit/tests/base-test.js index c9b5828dd149fb5ca832c9d26cbd14a95f6d830d..4a79590d411504e81c77f36523e026e8bc809ccb 100644 --- a/packages/http-client/tests/qunit/tests/base-test.js +++ b/packages/http-client/tests/qunit/tests/base-test.js @@ -9,7 +9,7 @@ QUnit.test('jsonqlClient should able to connect to server', function(assert) { var done5 = assert.async() jsonqlClient({ - hostname: 'http://localhost:8081', + hostname: 'http://localhost:10081', showContractDesc: true, keepContract: false, debugOn: true, diff --git a/packages/http-client/tests/qunit/tests/static-test.js b/packages/http-client/tests/qunit/tests/static-test.js index 0c1cbf16501fcc509d418cf7c33efa48730d597a..f7658cc74804e8d23a5aeb884ac017b5f79ca8c1 100644 --- a/packages/http-client/tests/qunit/tests/static-test.js +++ b/packages/http-client/tests/qunit/tests/static-test.js @@ -3,18 +3,20 @@ QUnit.test('jsonqlClientStatic should able to connect to server', function(assert) { var done1 = assert.async() var done2 = assert.async() + var done3 = assert.async() // init client var client = jsonqlClientStatic({ - hostname: 'http://localhost:8081', + hostname: 'http://localhost:10081', showContractDesc: true, keepContract: false, debugOn: true }) - + /* client.query('getSomethingNonExisted', 'whatever') .then(function(result) { console.log('[Qunit]', 'getSomething result', result) }) + */ client.query('getSomething', 'whatever', 'shit') .then(function(result) { @@ -39,4 +41,19 @@ QUnit.test('jsonqlClientStatic should able to connect to server', function(asser }) + client.query('getArray') + .then(function(result) { + try { + console.log('getArray result', result) + assert.equal(4, result.length, 'Check the length of the array') + done3() + } catch(e) { + throw new Error(e) + } + }) + .catch(function(error) { + console.error(`[Qunit]`, 'get array error', error) + done3() + }) + })