diff --git a/packages/@jsonql/koa/index.js b/packages/@jsonql/koa/index.js index 3fe031d5ee66dbdbbff96d9667ea82f09aeaa02d..a8f3e3d7a12d3f5f42071c019a2d98105fefff15 100644 --- a/packages/@jsonql/koa/index.js +++ b/packages/@jsonql/koa/index.js @@ -3,33 +3,42 @@ const debug = require('debug')('jsonql-koa:main') const checkOptions = require('./src/options') const { initServer } = require('./src/init-server') const { version } = require('./package.json') -let started = false; + /** + * We need to create this as a class to protect the property * @param {object} config options * @return {object} with several method to control the server */ -module.exports = function createKoaServer(config = {}, middlewares = []) { - // keep a copy of the original config - do we need this anymore? - // const originalConfig = Object.assign({}, config) - const opts = checkOptions(config) +class JsonqlKoaServer { - const { server, app, ws } = initServer(opts, middlewares) - // call this to start the server - const start = () => { - if (!started) { - debug(`Server version: ${version} start on ${opts.port}`) - server.listen(opts.port) - started = true; + constructor(config = {}, middlewares = []) { + // keep a copy of the original config - do we need this anymore? + // const originalConfig = Object.assign({}, config) + this.opts = checkOptions(config) + const { server, app, ws } = initServer(this.opts, middlewares) + this.server = server; + this.app = app; + this.ws = ws; + this.started = false; + if (this.opts.autoStart) { + this.start() } } - // call this to stop the server - const stop = () => { - server.close() + + // start the server + start() { + if (!this.started) { + console.info(`Server version: ${version} start on ${this.opts.port}`) + this.server.listen(this.opts.port) + this.started = true; + } } - if (opts.autoStart) { - start() + // stop the server + stop() { + this.server.close() } - // export - return { start, stop, app, ws } } + +// default export +module.exports = JsonqlKoaServer diff --git a/packages/@jsonql/koa/package.json b/packages/@jsonql/koa/package.json index 3ca1e436416361be6f2788e44df3c26e2fdc11bf..ed2be7fbdcc996dfe8708aa71adf41a2ba7a4f0a 100644 --- a/packages/@jsonql/koa/package.json +++ b/packages/@jsonql/koa/package.json @@ -7,8 +7,8 @@ "test": "ava --verbose", "test:basic": "DEBUG=jsonql-koa* ava --verbose ./tests/basic.test.js", "test:auth": "DEBUG=jsonql-* ava --verbose ./tests/auth.test.js", - "test:socket": "DEBUG=jsonql-koa* ava --verbose ./tests/socket.test.js", - "test:ms": "DEBUG=jsonql-koa* ava --verbose ./tests/ms.test.js", + "test:socket": "DEBUG=jsonql-koa:test:socket ava --verbose ./tests/socket.test.js", + "test:ms": "DEBUG=jsonql-koa:test* ava --verbose ./tests/ms.test.js", "test:cli": "DEBUG=jsonql-koa* node ./cli.js" }, "keywords": [ @@ -53,12 +53,12 @@ "debug": "^4.1.1", "fs-extra": "^8.1.0", "jsonql-constants": "^1.8.10", - "jsonql-koa": "^1.4.13", + "jsonql-koa": "^1.4.15", "jsonql-params-validator": "^1.4.11", "koa": "^2.11.0", "koa-bodyparser": "^4.2.1", "koa-cors": "0.0.16", - "yargs": "^14.2.0" + "yargs": "^15.0.2" }, "optionalDependencies": { "jsonql-ws-server": "^1.4.3" diff --git a/packages/@jsonql/koa/src/get-socket-server.js b/packages/@jsonql/koa/src/get-socket-server.js index 8459e681e04777d82e72597092886477edeb88fc..542691fe0c5e27023e1a6d4f8b3bcd8db32d35f2 100644 --- a/packages/@jsonql/koa/src/get-socket-server.js +++ b/packages/@jsonql/koa/src/get-socket-server.js @@ -11,7 +11,7 @@ function getSocketServer(config, server) { switch (config.serverType) { case JS_WS_NAME: // @NOTE replace the module name later jsonql-ws-server - const { jsonqlWsServer } = require('../../../ws-server') + const { jsonqlWsServer } = require('jsonql-ws-server' /*'../../../ws-server'*/) wsServer = jsonqlWsServer break; case JS_WS_SOCKET_IO_NAME: diff --git a/packages/@jsonql/koa/src/init-server.js b/packages/@jsonql/koa/src/init-server.js index 1e4ea508f06234ef261e7a037d0177abcf1bcc4c..46547543727ca51f52f3ceca8ebf36496772885f 100644 --- a/packages/@jsonql/koa/src/init-server.js +++ b/packages/@jsonql/koa/src/init-server.js @@ -3,8 +3,8 @@ const http = require('http') const Koa = require('koa') const bodyparser = require('koa-bodyparser') const cors = require('koa-cors') -const { jsonqlKoa } = require('../../../koa/main') -// const { jsonqlKoa } = require('jsonql-koa') +// const { jsonqlKoa } = require('../../../koa/main') +const { jsonqlKoa } = require('jsonql-koa') const { getSocketServer } = require('./get-socket-server') // const debug = require('debug')('jsonql-koa:init-server') @@ -18,7 +18,9 @@ function initServer(config, middlewares) { const app = new Koa() // apply default middlewares app.use(bodyparser()) - app.use(cors()) + if (config.cors === true) { // default is true + app.use(cors()) + } // init jsonqlKoa app.use(jsonqlKoa(config)) // if any diff --git a/packages/@jsonql/koa/src/options/options.js b/packages/@jsonql/koa/src/options/options.js index dda45cd63b2b7df1b9893f7a1517f62a7a1bf058..636aba94b47b6ba956116e78b675f48240d86ac3 100644 --- a/packages/@jsonql/koa/src/options/options.js +++ b/packages/@jsonql/koa/src/options/options.js @@ -12,6 +12,7 @@ const { } = require('jsonql-constants') const options = { + cors: createConfig(true, [BOOLEAN_TYPE]), autoStart: createConfig(true, [BOOLEAN_TYPE]), port: createConfig(DEFAULT_PORT_NUM, [NUMBER_TYPE]), // new prop for socket client diff --git a/packages/@jsonql/koa/tests/fixtures/ms-test-servers.js b/packages/@jsonql/koa/tests/fixtures/ms-test-servers.js new file mode 100644 index 0000000000000000000000000000000000000000..2b90b652784623645877c5d52bdcba74c45c1d67 --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/ms-test-servers.js @@ -0,0 +1,38 @@ +// server for the ms test only +const JsonqlKoaServer = require('../../index') +const { join } = require('path') +const { + resolverDir, + contractBaseDir, + keysDir, + AUTH_DIR, + BASIC_DIR, + SOCKET_DIR, + MS_A_DIR, + MS_B_DIR, + PORT_A, + PORT_B +} = require('./options') + +module.exports = function createMsTestServer(name) { + let opts = { serverType: 'ws' } + if (name === 'A') { // use all the default options here + let cbd = join(contractBaseDir, MS_A_DIR) + opts.resolverDir = resolverDir + opts.contractDir = cbd + opts.port = PORT_A + opts.name = 'serverA' + opts.clientConfig = [{ + hostname: `http://localhost:${PORT_B}`, + name: 'client0', + serverType: 'ws', + contractDir: join(cbd, 'client0') + }] + } else { + opts.resolverDir = join(__dirname, 'resolvers-ext') + opts.contractDir = join(contractBaseDir, MS_B_DIR) + opts.port = PORT_B + opts.name = 'serverB' + } + return new JsonqlKoaServer(opts) +} diff --git a/packages/@jsonql/koa/tests/fixtures/options.js b/packages/@jsonql/koa/tests/fixtures/options.js index 1c7636ca80851ce568300a75a55d61bdc1061569..f34f293e1e3ca76343ca93986ec9b0f501eb0f01 100644 --- a/packages/@jsonql/koa/tests/fixtures/options.js +++ b/packages/@jsonql/koa/tests/fixtures/options.js @@ -5,8 +5,12 @@ const keysDir = join(__dirname, 'keys') const AUTH_DIR = 'auth' const BASIC_DIR = 'basic' const SOCKET_DIR = 'socket' -const MS_DIR = 'ms' const MAIN_DIR = 'main' +const MS_A_DIR = 'ms-a' +const MS_B_DIR = 'ms-b' +const PORT_A = 8084 +const PORT_B = 8085 + module.exports = { resolverDir, @@ -15,6 +19,9 @@ module.exports = { AUTH_DIR, BASIC_DIR, SOCKET_DIR, - MS_DIR, + MS_A_DIR, + MS_B_DIR, + PORT_A, + PORT_B, MAIN_DIR } diff --git a/packages/@jsonql/koa/tests/fixtures/resolvers-ext/query/sending-out-something.js b/packages/@jsonql/koa/tests/fixtures/resolvers-ext/query/sending-out-something.js new file mode 100644 index 0000000000000000000000000000000000000000..349d8903c224393f9ce600850e386a80fff45df7 --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/resolvers-ext/query/sending-out-something.js @@ -0,0 +1,8 @@ +/** + * This is publicly available server whenever connect just send out a random message + * @return {string} a random message + */ +module.exports = function sendingOutSomething() { + + return `sending out message on ${Date.now()}` +} diff --git a/packages/@jsonql/koa/tests/fixtures/resolvers-ext/socket/give-number.js b/packages/@jsonql/koa/tests/fixtures/resolvers-ext/socket/give-number.js new file mode 100644 index 0000000000000000000000000000000000000000..e709c6d3cfe039a193739854e12be7dd29898b2b --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/resolvers-ext/socket/give-number.js @@ -0,0 +1,11 @@ +/** + * This is the socket interface that is publicly available and whenever connect + * will give you a timestamp + */ +module.exports = function giveNumber() { + const ts = Date.now() + // could add a few more things here for testing purpose + + + return ts; +} diff --git a/packages/@jsonql/koa/tests/fixtures/resolvers/query/get-something.js b/packages/@jsonql/koa/tests/fixtures/resolvers/query/get-something.js new file mode 100644 index 0000000000000000000000000000000000000000..b3fb16736db92366d05c74cdada1e8a36ad641d7 --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/resolvers/query/get-something.js @@ -0,0 +1,8 @@ + +/** + * just a pass over method to get something from server b + * @return {object} an object contains two different time stamps + */ +module.exports = function getSomething() { + +} diff --git a/packages/@jsonql/koa/tests/fixtures/resolvers/socket/ms-pass.js b/packages/@jsonql/koa/tests/fixtures/resolvers/socket/ms-pass.js new file mode 100644 index 0000000000000000000000000000000000000000..11b2dc34564906aa5efd562eb6864e8b2d71208a --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/resolvers/socket/ms-pass.js @@ -0,0 +1,9 @@ +/** + * just a pass over method to call server B + * @param {string} msg an incoming message + * @return {object} contain everything and send it back + */ +module.exports = function msPass(msg) { + // then we call the client and get something from it + +} diff --git a/packages/@jsonql/koa/tests/fixtures/test-server.js b/packages/@jsonql/koa/tests/fixtures/test-server.js index e9f11508214beb21786e381d29712f219283e05c..dddd5c477706bcaaad00c4253aba9c625e73cb5c 100644 --- a/packages/@jsonql/koa/tests/fixtures/test-server.js +++ b/packages/@jsonql/koa/tests/fixtures/test-server.js @@ -1,9 +1,13 @@ // create server for testing -const jsonqlKoaServer = require('../../index') +const JsonqlKoaServer = require('../../index') const { join } = require('path') const { - resolverDir, contractBaseDir, keysDir, - AUTH_DIR, BASIC_DIR, SOCKET_DIR + resolverDir, + contractBaseDir, + keysDir, + AUTH_DIR, + BASIC_DIR, + SOCKET_DIR } = require('./options') module.exports = function testServer(config = {}) { @@ -19,11 +23,11 @@ module.exports = function testServer(config = {}) { default: contractDir = join(contractBaseDir, BASIC_DIR) } - + const baseConfig = { resolverDir, contractDir, keysDir } - return jsonqlKoaServer(Object.assign(baseConfig, config)) + return new JsonqlKoaServer(Object.assign(baseConfig, config)) } diff --git a/packages/@jsonql/koa/tests/ms.test.js b/packages/@jsonql/koa/tests/ms.test.js index 0297cbe505fa861271b27a04c2cf2fe5dcadabf0..7eb4bcbcfe648bf391f6f4b7bed7478414e4dc1e 100644 --- a/packages/@jsonql/koa/tests/ms.test.js +++ b/packages/@jsonql/koa/tests/ms.test.js @@ -6,7 +6,43 @@ const jsonqlNodeClient = require('jsonql-node-client') const debug = require('debug')('jsonql-koa:test:basic') const { JS_WS_NAME, HELLO } = require('jsonql-constants') -const { contractBaseDir, MS_DIR, MAIN_DIR } = require('./fixtures/options') -const contractDir = join(contractBaseDir, MAIN_DIR) +const { contractBaseDir, MS_A_DIR, MS_B_DIR, PORT_A, PORT_B } = require('./fixtures/options') +const contractDirA = join(contractBaseDir, MS_A_DIR) +const contractDirB = join(contractBaseDir, MS_B_DIR) + +const createMsTestServer = require('./fixtures/ms-test-servers') + +test.before(t => { + t.context.serverA = createMsTestServer('A') + t.context.serverB = createMsTestServer('B') +}) + +test.after(t => { + + t.context.serverA.stop() + t.context.serverB.stop() + +}) + +test(`It should able to connect to service A directly`, async t => { + const client1 = await jsonqlNodeClient({ + hostname: `http://localhost:${PORT_A}`, + contractDir: join(__dirname, 'fixtures', 'contract', 'client1') + }) + + const res1 = await client1.query.helloWorld() + + t.is(res1, HELLO) +}) + +test(`It should able to connect to server B directly`, async t => { + const client2 = await jsonqlNodeClient({ + hostname: `http://localhost:${PORT_B}`, + contractDir: join(__dirname, 'fixtures', 'contract', 'client2') + }) + const res2 = await client2.query.helloWorld() + t.is(res2, HELLO) +}) + test.todo(`It should able to connect to another service via the internal nodeClient`) diff --git a/packages/@jsonql/koa/tests/socket.test.js b/packages/@jsonql/koa/tests/socket.test.js index fc9b64c640f550af26df98dbc29b3d91835e9773..8ecc71b94f5062755c30e739b85fe789e544dff5 100644 --- a/packages/@jsonql/koa/tests/socket.test.js +++ b/packages/@jsonql/koa/tests/socket.test.js @@ -61,15 +61,16 @@ test.cb.only(`It should able to login to the socket and connect to a private soc // login method which is shouldn't and needn't client.login('Jack') .then(result => { - debug(result) - t.pass() + // how to test this token as valid? + // debug(result) + t.truthy(result) }) // @TODO should make this onLogin available as a global method client.socket.onLogin = function() { - debug(client.userdata()) + const user = client.userdata() - t.pass() + t.is(user.name, 'Jack') t.end() } diff --git a/packages/http-client/core.js b/packages/http-client/core.js index b23a87e8d000ffc4b02e78badfc0d448f981fb1a..46000dcea99005f5ce7df67356b64682d0ca4e02 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t=t||self).jsonqlClient=r()}(this,(function(){"use strict";var t="application/vnd.api+json",r={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},e=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s={desc:"y"},f="No message";var l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},p="object"==typeof l&&l&&l.Object===Object&&l,h="object"==typeof self&&self&&self.Object===Object&&self,d=p||h||Function("return this")(),v=d.Symbol;function g(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&F(r,t[e],0)>-1;);return e}(n,o)+1).join("")}function X(t){return void 0===t}var Z="[object Boolean]";var tt="[object Number]";function rt(t){return function(t){return"number"==typeof t||k(t)&&A(t)==tt}(t)&&t!=+t}var et="[object String]";function nt(t){return"string"==typeof t||!y(t)&&k(t)&&A(t)==et}function ot(t,r){return function(e){return t(r(e))}}var it=ot(Object.getPrototypeOf,Object),at="[object Object]",ut=Function.prototype,ct=Object.prototype,st=ut.toString,ft=ct.hasOwnProperty,lt=st.call(Object);function pt(t){if(!k(t)||A(t)!=at)return!1;var r=it(t);if(null===r)return!0;var e=ft.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&st.call(e)==lt}var ht,dt=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),a=i.length;a--;){var u=i[ht?a:++n];if(!1===r(o[u],u,o))break}return t};var vt="[object Arguments]";function gt(t){return k(t)&&A(t)==vt}var yt=Object.prototype,bt=yt.hasOwnProperty,mt=yt.propertyIsEnumerable,_t=gt(function(){return arguments}())?gt:function(t){return k(t)&&bt.call(t,"callee")&&!mt.call(t,"callee")};var wt="object"==typeof exports&&exports&&!exports.nodeType&&exports,jt=wt&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=jt&&jt.exports===wt?d.Buffer:void 0,St=(Ot?Ot.isBuffer:void 0)||function(){return!1},Et=9007199254740991,At=/^(?:0|[1-9]\d*)$/;function kt(t,r){var e=typeof t;return!!(r=null==r?Et:r)&&("number"==e||"symbol"!=e&&At.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Tt}var Pt={};Pt["[object Float32Array]"]=Pt["[object Float64Array]"]=Pt["[object Int8Array]"]=Pt["[object Int16Array]"]=Pt["[object Int32Array]"]=Pt["[object Uint8Array]"]=Pt["[object Uint8ClampedArray]"]=Pt["[object Uint16Array]"]=Pt["[object Uint32Array]"]=!0,Pt["[object Arguments]"]=Pt["[object Array]"]=Pt["[object ArrayBuffer]"]=Pt["[object Boolean]"]=Pt["[object DataView]"]=Pt["[object Date]"]=Pt["[object Error]"]=Pt["[object Function]"]=Pt["[object Map]"]=Pt["[object Number]"]=Pt["[object Object]"]=Pt["[object RegExp]"]=Pt["[object Set]"]=Pt["[object String]"]=Pt["[object WeakMap]"]=!1;var qt,Ct="object"==typeof exports&&exports&&!exports.nodeType&&exports,$t=Ct&&"object"==typeof module&&module&&!module.nodeType&&module,zt=$t&&$t.exports===Ct&&p.process,Nt=function(){try{var t=$t&&$t.require&&$t.require("util").types;return t||zt&&zt.binding&&zt.binding("util")}catch(t){}}(),Ft=Nt&&Nt.isTypedArray,It=Ft?(qt=Ft,function(t){return qt(t)}):function(t){return k(t)&&xt(t.length)&&!!Pt[A(t)]},Rt=Object.prototype.hasOwnProperty;function Jt(t,r){var e=y(t),n=!e&&_t(t),o=!e&&!n&&St(t),i=!e&&!n&&!o&&It(t),a=e||n||o||i,u=a?function(t,r){for(var e=-1,n=Array(t);++e-1},er.prototype.set=function(t,r){var e=this.__data__,n=tr(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var nr,or=d["__core-js_shared__"],ir=(nr=/[^.]+$/.exec(or&&or.keys&&or.keys.IE_PROTO||""))?"Symbol(src)_1."+nr:"";var ar=Function.prototype.toString;function ur(t){if(null!=t){try{return ar.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var cr=/^\[object .+?Constructor\]$/,sr=Function.prototype,fr=Object.prototype,lr=sr.toString,pr=fr.hasOwnProperty,hr=RegExp("^"+lr.call(pr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function dr(t){return!(!Lt(t)||function(t){return!!ir&&ir in t}(t))&&(Yt(t)?hr:cr).test(ur(t))}function vr(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return dr(e)?e:void 0}var gr=vr(d,"Map"),yr=vr(Object,"create");var br="__lodash_hash_undefined__",mr=Object.prototype.hasOwnProperty;var _r=Object.prototype.hasOwnProperty;var wr="__lodash_hash_undefined__";function jr(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ru))return!1;var s=i.get(t);if(s&&i.get(r))return s==r;var f=-1,l=!0,p=e&qr?new Tr:void 0;for(i.set(t,r),i.set(r,t);++f0){if(++r>=mn)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(bn);function On(t,r){return jn(function(t,r,e){return r=yn(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=yn(n.length-r,0),a=Array(i);++o1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=Sn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!Lt(e))return!1;var n=typeof r;return!!("number"==n?Wt(e)&&kt(r,e.length):"string"==n&&r in e)&&Zt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0))},Kn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},Vn=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!Ln(r)(t)})).length)})).length:r.length>r.filter((function(t){return!Bn(e,t)})).length},Gn=function(t,r){if(void 0===r&&(r=null),pt(t)){if(!r)return!0;if(Bn(r))return!r.filter((function(r){var e=t[r.name];return!(r.type.length>r.type.filter((function(t){var r;return!!X(e)||(!1!==(r=Kn(t))?!Vn({arg:e},r):!Ln(t)(e))})).length)})).length}return!1},Yn=function(t){var r=t.arg,e=t.param,n=[r];return Array.isArray(e.keys)&&e.keys.length&&n.push(e.keys),Gn.apply(null,n)},Wn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(r,e),r}(Error),Qn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(r,e),r}(Error),Xn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(r,e),r}(Error),Zn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(r,e),r}(Error),to=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(r,e),r}(Error),ro=function(){try{if(window||document)return!0}catch(t){}return!1},eo=function(){try{if(!ro()&&l)return!0}catch(t){}return!1};var no=function(t){function r(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];t.apply(this,r)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.where=function(){return ro()?"browser":eo()?"node":"unknown"},r}(Error),oo=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(r,e),r}(no),io=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,e),r}(Error),ao=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,e),r}(Error),uo=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,e),r}(Error),co=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(no),so=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(no),fo=function(t){function r(e,n){t.call(this,n),this.statusCode=e,this.className=r.name}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(r,e),r}(Error),lo=Object.freeze({__proto__:null,Jsonql406Error:Wn,Jsonql500Error:Qn,JsonqlAuthorisationError:Xn,JsonqlContractAuthError:Zn,JsonqlResolverAppError:to,JsonqlResolverNotFoundError:oo,JsonqlEnumError:io,JsonqlTypeError:ao,JsonqlCheckerError:uo,JsonqlValidationError:co,JsonqlError:so,JsonqlServerError:fo}),po=so,ho=function(t,r){return!!Object.keys(t).filter((function(t){return r===t})).length};function vo(t){if(ho(t,"error")){var r=t.error,e=r.className,n=r.name,o=e||n,i=r.message||f,a=r.detail||r;if(o&&lo[o])throw new lo[e](i,a);throw new po(i,a)}return t}function go(t){if(Array.isArray(t))throw new co("",t);var r=t.message||f,e=t.detail||t;switch(!0){case t instanceof Wn:throw new Wn(r,e);case t instanceof Qn:throw new Qn(r,e);case t instanceof Xn:throw new Xn(r,e);case t instanceof Zn:throw new Zn(r,e);case t instanceof to:throw new to(r,e);case t instanceof oo:throw new oo(r,e);case t instanceof io:throw new io(r,e);case t instanceof ao:throw new ao(r,e);case t instanceof uo:throw new uo(r,e);case t instanceof co:throw new co(r,e);case t instanceof fo:throw new fo(r,e);default:throw new so(r,e)}}function yo(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,r){var e;switch(!0){case"object"===t:return!Yn(r);case"array"===t:return!Bn(r.arg);case!1!==(e=Kn(t)):return!Vn(r,e);default:return!Ln(t)(r.arg)}},mo=function(t,r){return X(t)?!0!==r.optional||X(r.defaultvalue)?null:r.defaultvalue:t},_o=function(t,r,e){var n;void 0===e&&(e=!1);var o=function(t,r){if(!Bn(r))throw new so("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===r.length)return[];if(!Bn(t))throw new so("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==r.length:return yo(1),t.map((function(t,e){return{arg:t,index:e,param:r[e]}}));case!0===r[0].variable:yo(2);var e=r[0].type;return t.map((function(t,n){return{arg:t,index:n,param:r[n]||{type:e,name:"_"}}}));case t.lengthr.length:yo(4);var n=r.length,o=["any"];return t.map((function(t,e){var i=e>=n||!!r[e].optional,a=r[e]||{type:o,name:"_"+e};return{arg:i?mo(t,a):t,index:e,param:a,optional:i}}));default:throw yo(5),new so("Could not understand your arguments and parameter structure!",{args:t,params:r})}}(t,r),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!Cn(r)&&!(e.type.length>e.type.filter((function(r){return bo(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return bo(r,t)})).length)}));return e?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,r){var e,n=Object.keys(t);return e=r,!!n.filter((function(t){return t===e})).length},jo=function(t){return!Cn(t)};function Oo(t,r){var e=qn(r,(function(t,r){return!t[Dn]}));return Oe(e,{})?t:function(t,r){var e={};return r=Ye(r),Xt(t,(function(t,n,o){Qe(e,r(t,n,o),t)})),e}(t,(function(t,r){return function(t,r,e){var n;return e(t,(function(t,e,o){if(r(t,e,o))return n=e,!1})),n}(e,Ye((function(t){return t.alias===r})),Xt)||r}))}function So(t,r){return An(r,(function(r,e){var n,o;return X(t[e])||!0===r[Rn]&&jo(t[e])?En({},r,((n={})[Hn]=!0,n)):((o={})[Mn]=t[e],o[In]=r[In],o[Rn]=r[Rn]||!1,o[Jn]=r[Jn]||!1,o[Un]=r[Un]||!1,o)}))}function Eo(t,r){var e=function(t,r){var e=Oo(t,r);return{pristineValues:An(qn(r,(function(t,r){return wo(e,r)})),(function(t){return t.args})),checkAgainstAppProps:qn(r,(function(t,r){return!wo(e,r)})),config:e}}(t,r),n=e.config,o=e.pristineValues;return[So(n,e.checkAgainstAppProps),o]}var Ao=function(t){return Bn(t)?t:[t]};var ko=function(t,r){return!Bn(r)||function(t,r){return!!t.filter((function(t){return t===r})).length}(r,t)},To=function(t,r){try{return!!Yt(r)&&r.apply(null,[t])}catch(t){return!1}};function xo(t){return function(r,e){if(r[Hn])return r[Mn];var n=function(t,r){var e,n=[[t[Mn]],[(e={},e[In]=Ao(t[In]),e[Rn]=t[Rn],e)]];return Reflect.apply(r,null,n)}(r,t);if(n.length)throw yo("runValidationAction",e,r),new ao(e,n);if(!1!==r[Jn]&&!ko(r[Mn],r[Jn]))throw yo(Jn,r[Jn]),new io(e);if(!1!==r[Un]&&!To(r[Mn],r[Un]))throw yo(Un,r[Un]),new uo(e);return r[Mn]}}var Po=function(t,r){return Promise.resolve(Eo(t,r))};function qo(t,r,e,n){return void 0===t&&(t={}),Po(t,r).then((function(t){return function(t,r){var e=t[0],n=t[1],o=An(e,xo(r));return En(o,n)}(t,n)})).then((function(t){return En({},t,e)}))}function Co(t,r,e,s,f,l){void 0===e&&(e=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=r,!0===e&&(p[o]=!0),Bn(s)&&(p[i]=s),Yt(f)&&(p[u]=f),nt(l)&&(p[c]=l),p}var $o=zn,zo=Bn,No=function(t,r,e){return void 0===e&&(e=!1),new Promise((function(n,o){var i=_o(t,r,e);return e?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Fo=function(t,r,e){void 0===e&&(e={});var n=e[o],a=e[i],s=e[u],f=e[c];return Co.apply(null,[t,r,n,a,s,f])},Io=function(t){return function(r,e,n){return void 0===n&&(n={}),qo(r,e,n,t)}}(_o),Ro="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Jo=Object.assign?Object.assign:function(t,r,e,n){for(var o=arguments,i=1;i=0;r--){var e=ui().key(r);t(ci(e),e)}},remove:function(t){return ui().removeItem(t)},clearAll:function(){return ui().clear()}};function ui(){return ii.localStorage}function ci(t){return ui().getItem(t)}var si=Ho.trim,fi={name:"cookieStorage",read:function(t){if(!t||!di(t))return null;var r="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(li.cookie.replace(new RegExp(r),"$1"))},write:function(t,r){if(!t)return;li.cookie=escape(t)+"="+escape(r)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:pi,remove:hi,clearAll:function(){pi((function(t,r){hi(r)}))}},li=Ho.Global.document;function pi(t){for(var r=li.cookie.split(/; ?/g),e=r.length-1;e>=0;e--)if(si(r[e])){var n=r[e].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function hi(t){t&&di(t)&&(li.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function di(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(li.cookie)}var vi=function(){var t={};return{defaults:function(r,e){t=e},get:function(r,e){var n=r();return void 0!==n?n:t[e]}}};var gi="expire_mixin",yi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+gi);return{set:function(r,e,n,o){this.hasNamespace(gi)||t.set(e,o);return r()},get:function(t,e){this.hasNamespace(gi)||r.call(this,e);return t()},remove:function(r,e){this.hasNamespace(gi)||t.remove(e);return r()},getExpiration:function(r,e){return t.get(e)},removeExpiredKeys:function(t){var e=[];this.each((function(t,r){e.push(r)}));for(var n=0;n>>8,e[2*n+1]=a%256}return e},decompressFromUint8Array:function(r){if(null==r)return i.decompress(r);for(var e=new Array(r.length/2),n=0,o=e.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==r-1){d.push(e(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(r){return t.charCodeAt(r)}))},_decompress:function(r,e,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:e,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=e,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=e,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=e,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>r)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=e,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=e,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=e,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=r)}));var Ei=[ai,fi],Ai=[vi,yi,ji,function(){return{get:function(t,r){var e=t(r);if(!e)return e;var n=Si.decompress(e);return null==n?e:this._deserialize(n)},set:function(t,r,e){var n=Si.compress(this._serialize(e));t(r,n)}}}],ki=ei.createStore(Ei,Ai),Ti=Ho.Global;function xi(){return Ti.sessionStorage}function Pi(t){return xi().getItem(t)}var qi=[{name:"sessionStorage",read:Pi,write:function(t,r){return xi().setItem(t,r)},each:function(t){for(var r=xi().length-1;r>=0;r--){var e=xi().key(r);t(Pi(e),e)}},remove:function(t){return xi().removeItem(t)},clearAll:function(){return xi().clear()}},fi],Ci=[vi,yi],$i=ei.createStore(qi,Ci),zi=ki,Ni=$i,Fi=Array.isArray,Ii=void 0!==l?l:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ri="object"==typeof Ii&&Ii&&Ii.Object===Object&&Ii,Ji="object"==typeof self&&self&&self.Object===Object&&self,Mi=(Ri||Ji||Function("return this")()).Symbol,Ui=Object.prototype,Di=Ui.hasOwnProperty,Hi=Ui.toString,Li=Mi?Mi.toStringTag:void 0;var Bi=Object.prototype.toString;var Ki="[object Null]",Vi="[object Undefined]",Gi=Mi?Mi.toStringTag:void 0;function Yi(t){return null==t?void 0===t?Vi:Ki:Gi&&Gi in Object(t)?function(t){var r=Di.call(t,Li),e=t[Li];try{t[Li]=void 0;var n=!0}catch(t){}var o=Hi.call(t);return n&&(r?t[Li]=e:delete t[Li]),o}(t):function(t){return Bi.call(t)}(t)}var Wi=function(t,r){return function(e){return t(r(e))}}(Object.getPrototypeOf,Object);function Qi(t){return null!=t&&"object"==typeof t}var Xi="[object Object]",Zi=Function.prototype,ta=Object.prototype,ra=Zi.toString,ea=ta.hasOwnProperty,na=ra.call(Object);var oa=Mi?Mi.prototype:void 0,ia=(oa&&oa.toString,"[object String]");function aa(t){return"string"==typeof t||!Fi(t)&&Qi(t)&&Yi(t)==ia}var ua=function(t,r){return!!t.filter((function(t){return t===r})).length},ca=function(t,r){var e=Object.keys(t);return ua(e,r)},sa=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},fa="query",la="mutation",pa="socket",ha="payload",da="condition",va=function(){try{if(window||document)return!0}catch(t){}return!1},ga=function(){try{if(!va()&&Ii)return!0}catch(t){}return!1};var ya=function(t){function r(){for(var e=arguments,n=[],o=arguments.length;o--;)n[o]=e[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(function(t){function r(){for(var r=arguments,e=[],n=arguments.length;n--;)e[n]=r[n];t.apply(this,e)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.where=function(){return va()?"browser":ga()?"node":"unknown"},r}(Error));var ba=function(t){var r;return(r={}).args=t,r};var ma=function(t){return ca(t,"data")&&!ca(t,"error")?t.data:t},_a=function(t){return function(t){if(!Qi(t)||Yi(t)!=Xi)return!1;var r=Wi(t);if(null===r)return!0;var e=ea.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&ra.call(e)==na}(t)&&(ca(t,fa)||ca(t,la)||ca(t,pa))},wa=function(t,r){return void 0===r&&(r={}),_a(r)?Promise.resolve(r):t.getContract()},ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Oa(t){this.message=t}Oa.prototype=new Error,Oa.prototype.name="InvalidCharacterError";var Sa="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new Oa("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,n,o=0,i=0,a="";n=r.charAt(i++);~n&&(e=o%4?64*e+n:n,o++%4)?a+=String.fromCharCode(255&e>>(-2*o&6)):0)n=ja.indexOf(n);return a};var Ea=function(t){var r=t.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Sa(t).replace(/(.)/g,(function(t,r){var e=r.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e})))}(r)}catch(t){return Sa(r)}};function Aa(t){this.message=t}Aa.prototype=new Error,Aa.prototype.name="InvalidTokenError";var ka=function(t,r){if("string"!=typeof t)throw new Aa("Invalid token specified");var e=!0===(r=r||{}).header?0:1;try{return JSON.parse(Ea(t.split(".")[e]))}catch(t){throw new Aa("Invalid token specified: "+t.message)}},Ta=Aa;ka.InvalidTokenError=Ta;var xa,Pa,qa,Ca,$a,za,Na,Fa,Ia,Ra=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r};function Ja(t){if($o(t))return function(t){var r=t.iat||Ra(!0);if(t.exp&&r>=t.exp){var e=new Date(t.exp).toISOString();throw new so("Token has expired on "+e,t)}return t}(ka(t));throw new so("Token must be a string!")}Fo("HS256",["string"]),Fo(!1,["boolean","number","string"],((xa={})[c]="exp",xa[o]=!0,xa)),Fo(!1,["boolean","number","string"],((Pa={})[c]="nbf",Pa[o]=!0,Pa)),Fo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),Fo(!1,["boolean","string"],((Ca={})[c]="sub",Ca[o]=!0,Ca)),Fo(!1,["boolean","string"],(($a={})[c]="iss",$a[o]=!0,$a)),Fo(!1,["boolean"],((za={})[o]=!0,za)),Fo(!1,["boolean","string"],((Na={})[o]=!0,Na)),Fo(!1,["boolean","string"],((Fa={})[o]=!0,Fa)),Fo(!1,["boolean"],((Ia={})[o]=!0,Ia));var Ma=e[0],Ua=e[1],Da=function(t){!function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ha={headers:{configurable:!0}};Ha.headers.set=function(t){this.extraHeader=t},Da.prototype.request=function(t,r,e){var n;void 0===r&&(r={}),void 0===e&&(e={}),this.headers=e;var o=En({},{_cb:sa()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=En({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,En({},{method:Ma,params:o},r))},Da.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(r){var e=t.getHeaders();for(var n in t.log("request interceptor call",e),e)r.headers[n]=e[n];return r}))},Da.prototype.processJsonp=function(t){return ma(t)},Da.prototype.resInterceptor=function(){var t=this,r=this,e=r.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),r.cleanUp();var o=$o(n.data)?JSON.parse(n.data):n.data;return e?r.processJsonp(o):ma(o)}),(function(t){throw r.cleanUp(),console.error(t),new fo("Server side error",t)}))},Da.prototype.getHeaders=function(){return this.opts.enableAuth?En({},r,this.getAuthHeader(),this.extraHeader):En({},r,this.extraHeader)},Da.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Da.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=En({},this.extraParams,s)),this.request({},{method:"GET"},this.contractHeader).then(vo).then((function(r){return t.log("get contract result",r),r.cache&&r.contract?r.contract:r}))},Da.prototype.query=function(t,r){return void 0===r&&(r=[]),this.request(function(t,r,e){var n;if(void 0===r&&(r=[]),void 0===e&&(e=!1),aa(t)&&Fi(r)){var o=ba(r);return!0===e?o:((n={})[t]=o,n)}throw new ya("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:r})}(t,r)).then(vo)},Da.prototype.mutation=function(t,r,e){return void 0===r&&(r={}),void 0===e&&(e={}),this.request(function(t,r,e,n){var o;void 0===e&&(e={}),void 0===n&&(n=!1);var i={};if(i[ha]=r,i[da]=e,!0===n)return i;if(aa(t))return(o={})[t]=i,o;throw new ya("[createMutation] expect resolverName to be string!",{resolverName:t,payload:r,condition:e})}(t,r,e),{method:Ua}).then(vo)},Object.defineProperties(Da.prototype,Ha);var La=function(t){function r(r,e){void 0===e&&(e=null),e&&(r.Fly=e),t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.storeIt.set=function(t){throw console.info("storeIt",t),zo(t)&&t.length>=2&&Reflect.apply(zi.set,zi,t),new co("Expect argument to be array and least 2 items!")},e.jsonqlEndpoint.set=function(t){var r=zi.get("endpoint")||[];ua(r,t)||(r.push(t),this.storeId=["endpoint",r],this.endpointIndex=r.length-1)},e.jsonqlContract.set=function(t){var r=this.opts.storageKey,e=[r],n=t[0],o=t[1],i=zi.get(r)||[];i[this.endpointIndex||0]=n,e.push(i),o&&e.push(o),this.opts.keepContract&&(this.storeIt=e)},e.jsonqlToken.set=function(t){var r="credential",e=localStorage.get(r)||[];if(!ua(e,t)){var n=e.length-1;e[n]=t,this[r+"Index"]=n;var o=[r,e];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=sa();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},e.jsonqlUserdata.set=function(t){var r=["userdata",t];return t.exp&&r.push(t.exp),Reflect.apply(zi.set,zi,r)},e.jsonqlEndpoint.get=function(){var t=zi.get("endpoint");if(!t){var r=this.opts,e=[r.hostname,r.jsonqlPath].join("/");return this.jsonqlEndpoint=e,e}return t[this.endpointIndex]},e.jsonqlContract.get=function(){var t=this.opts.storageKey;return(zi.get(t)||[])[this.endpointIndex]||!1},e.jsonqlToken.get=function(){var t="credential",r=localStorage.get(t);return!!r&&r[this[t+"Index"]]},e.jsonqlUserdata.get=function(){return Ni.get("userdata")},r.prototype.log=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(r.prototype,e),r}(function(t){function r(r){t.call(this,r),r.enableAuth&&r.useJwt&&(this.setDecoder=Ja)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return e.userdata.get=function(){return this.jsonqlUserdata},e.rawAuthToken.get=function(){return this.jsonqlToken},e.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.prototype.storeToken=function(t){return this.jsonqlToken=t},r.prototype.decoder=function(t){return t},r.prototype.getAuthHeader=function(){var t,r=this.rawAuthToken;return r?((t={})[this.opts.AUTH_HEADER]="Bearer "+r,t):{}},Object.defineProperties(r.prototype,e),r}(function(t){function r(r){t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={contractHeader:{configurable:!0}};return r.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var r=t[this.endpointIndex||0];if(r)return Promise.resolve(r)}return this.get().then(this.storeContract.bind(this))},e.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},r.prototype.storeContract=function(t){if(!_a(t))throw new co("Contract is malformed!");var r=[t];if(this.opts.contractExpired){var e=parseFloat(this.opts.contractExpired);!isNaN(e)&&e>0&&r.push(e)}return this.jsonqlContract=r,this.log("storeContract return result",t),t},r.prototype.readContract=function(){return _a(this.opts.contract)?this.opts.contract:zi.get(this.opts.storageKey)},Object.defineProperties(r.prototype,e),r}(Da))),Ba=function(t){return y(t)?t:[t]},Ka=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,Ba(t))}),Reflect.apply(t,null,e))}};function Va(t,r,e,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,r);return!1===n&&void 0!==o?t:(Object.defineProperty(t,r,{value:e,writable:n}),t)}var Ga=function(t,r,e,n){return function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];var i=n.auth[r].params,a=i.map((function(t,r){return e[r]})),u=e[i.length]||{};return No(e,i).then((function(){return t.query.apply(t,[r,a,u])})).catch(go)}},Ya=function(t,r,e,n,o){var i={},a=function(t){i=Va(i,t,(function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,r){return e[r]})),u=e[i.length]||{};return No(a,i).then((function(){return r.query.apply(r,[t,a,u])})).catch(go)}))};for(var u in o.query)a(u);return t.query=i,[t,r,e,n,o]},Wa=function(t,r,e,n,o){var i={},a=function(t){i=Va(i,t,(function(e,n,i){void 0===i&&(i={});var a=[e,n],u=o.mutation[t].params;return No(a,u).then((function(){return r.mutation.apply(r,[t,e,n,i])})).catch(go)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,r,e,n,o]},Qa=function(t,r,e,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=Ga(r,a,0,o);return i.apply(null,t).then(r.postLoginAction).then((function(t){return e.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ga(r,u,0,o);return i.apply(null,t).then(r.postLogoutAction).then((function(t){return e.$trigger("logout",t),t}))}:i[u]=function(){r.postLogoutAction("continue"),e.$trigger("logout","continue")},t.auth=i}return t};var Xa=function(t,r,e,n){var o=function(t,r,e,n){return Ka(Ya,Wa,Qa)({},t,r,e,n)}(t,n,r,e);return r.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},r.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.0",o},Za={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},tu={hostname:Fo([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Fo("jsonql",["string"]),loginHandlerName:Fo("login",["string"]),logoutHandlerName:Fo("logout",["string"]),enableJsonp:Fo(!1,["boolean"]),enableAuth:Fo(!1,["boolean"]),useJwt:Fo(!0,["boolean"]),useLocalstorage:Fo(!0,["boolean"]),storageKey:Fo("storageKey",["string"]),authKey:Fo("authKey",["string"]),contractExpired:Fo(0,["number"]),keepContract:Fo(!0,["boolean"]),exposeContract:Fo(!1,["boolean"]),showContractDesc:Fo(!1,["boolean"]),contractKey:Fo(!1,["boolean"]),contractKeyName:Fo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Fo(!1,["boolean"]),timeout:Fo(5e3,["number"]),returnInstance:Fo(!1,["boolean"]),allowReturnRawToken:Fo(!1,["boolean"]),debugOn:Fo(!1,["boolean"])};function ru(t,r,e){return void 0===r&&(r={}),void 0===e&&(e=null),function(t){var r=t.contract;return Io(t,tu,Za).then((function(t){return t.contract=r,t}))}(r).then((function(t){return{baseClient:new La(t,e),opts:t}})).then((function(r){var e=r.baseClient,n=r.opts;return wa(e,n.contract).then((function(r){return Xa(e,n,r,t)}))}))}var eu=new WeakMap,nu=new WeakMap;var ou=function(){this.__suspend__=null,this.queueStore=new Set},iu={$suspend:{configurable:!0},$queues:{configurable:!0}};iu.$suspend.set=function(t){var r=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var e=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+e+" --\x3e "+t),!0===e&&!1===t&&setTimeout((function(){r.release()}),1)},ou.prototype.$queue=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},iu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ou.prototype.release=function(){var t=this,r=this.queueStore.size;if(this.logger("(release)","Release was called "+r),r>0){var e=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",e),e.forEach((function(r){t.logger(r),Reflect.apply(t.$trigger,t,r)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ou.prototype,iu);var au=function(t){function r(r){void 0===r&&(r={}),t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={$done:{configurable:!0}};return r.prototype.logger=function(){},r.prototype.$on=function(t,r,e){var n=this;void 0===e&&(e=null);this.validate(t,r);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",r,e);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(r,a,e||u),i+=n.addToNormalStore(t,"on",r,e||u)})),i},r.prototype.$once=function(t,r,e){void 0===e&&(e=null),this.validate(t,r);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",r,e);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(r,i,e||a),this.$off(t)},r.prototype.$only=function(t,r,e){var n=this;void 0===e&&(e=null),this.validate(t,r);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",r,e)),!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(r,i,e||a)})));return o},r.prototype.$onlyOnce=function(t,r,e){void 0===e&&(e=null),this.validate(t,r);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",r,e)),!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(r,a,e||u),this.$off(t)}return n},r.prototype.$replace=function(t,r,e,n){if(void 0===e&&(e=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,r),Reflect.apply(o,this,[t,r,e])}throw new Error(n+" is not supported!")},r.prototype.$trigger=function(t,r,e,n){void 0===r&&(r=[]),void 0===e&&(e=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,r,e,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(r)?(this.logger("(addToStore)",r+" existed"),e=t.get(r)):(this.logger("(addToStore)","create new Set for "+r),e=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(r,i)||e.add(n)}else this.checkContentExist(n,e)||(this.logger("(addToStore)","insert new",n),e.add(n));else e.add(n);return t.set(r,e),[t,e.size]},r.prototype.checkContentExist=function(t,r){return!!Array.from(r).filter((function(r){return r[0]===t[0]})).length},r.prototype.checkTypeInStore=function(t,r){this.validateEvt(t,r);var e=this.$get(t,!0);return!1===e||!e.filter((function(t){var e=t[3];return r!==e})).length},r.prototype.checkTypeInLazyStore=function(t,r){this.validateEvt(t,r);var e=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",e),!!e&&!!Array.from(e).filter((function(t){return t[2]!==r})).length},r.prototype.addToNormalStore=function(t,r,e,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,r,"try to add to normal store"),this.checkTypeInStore(t,r)){this.logger("(addToNormalStore)",r+" can add to "+t+" normal store");var o=this.hashFnToKey(e),i=[this.normalStore,t,o,e,n,r],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},r.prototype.addToLazyStore=function(t,r,e,n){void 0===r&&(r=[]),void 0===e&&(e=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(r),e];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},r.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},e.normalStore.set=function(t){eu.set(this,t)},e.normalStore.get=function(){return eu.get(this)},e.lazyStore.set=function(t){nu.set(this,t)},e.lazyStore.get=function(){return nu.get(this)},r.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,r){return(t=(t<<5)-t+r.charCodeAt(0))&t}),0)+""},Object.defineProperties(r.prototype,e),r}(ou));return function(t,r){var e;return ru((e=r.debugOn,new au({logger:e?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),r,t)}})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t=t||self).jsonqlClient=r()}(this,(function(){"use strict";var t="application/vnd.api+json",r={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},e=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s={desc:"y"},f="No message";var l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},p="object"==typeof l&&l&&l.Object===Object&&l,h="object"==typeof self&&self&&self.Object===Object&&self,d=p||h||Function("return this")(),v=d.Symbol;function g(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&F(r,t[e],0)>-1;);return e}(n,o)+1).join("")}function X(t){return void 0===t}var Z="[object Boolean]";var tt="[object Number]";function rt(t){return function(t){return"number"==typeof t||k(t)&&A(t)==tt}(t)&&t!=+t}var et="[object String]";function nt(t){return"string"==typeof t||!y(t)&&k(t)&&A(t)==et}function ot(t,r){return function(e){return t(r(e))}}var it=ot(Object.getPrototypeOf,Object),at="[object Object]",ut=Function.prototype,ct=Object.prototype,st=ut.toString,ft=ct.hasOwnProperty,lt=st.call(Object);function pt(t){if(!k(t)||A(t)!=at)return!1;var r=it(t);if(null===r)return!0;var e=ft.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&st.call(e)==lt}var ht,dt=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),a=i.length;a--;){var u=i[ht?a:++n];if(!1===r(o[u],u,o))break}return t};var vt="[object Arguments]";function gt(t){return k(t)&&A(t)==vt}var yt=Object.prototype,bt=yt.hasOwnProperty,mt=yt.propertyIsEnumerable,_t=gt(function(){return arguments}())?gt:function(t){return k(t)&&bt.call(t,"callee")&&!mt.call(t,"callee")};var wt="object"==typeof exports&&exports&&!exports.nodeType&&exports,jt=wt&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=jt&&jt.exports===wt?d.Buffer:void 0,St=(Ot?Ot.isBuffer:void 0)||function(){return!1},Et=9007199254740991,At=/^(?:0|[1-9]\d*)$/;function kt(t,r){var e=typeof t;return!!(r=null==r?Et:r)&&("number"==e||"symbol"!=e&&At.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Tt}var Pt={};Pt["[object Float32Array]"]=Pt["[object Float64Array]"]=Pt["[object Int8Array]"]=Pt["[object Int16Array]"]=Pt["[object Int32Array]"]=Pt["[object Uint8Array]"]=Pt["[object Uint8ClampedArray]"]=Pt["[object Uint16Array]"]=Pt["[object Uint32Array]"]=!0,Pt["[object Arguments]"]=Pt["[object Array]"]=Pt["[object ArrayBuffer]"]=Pt["[object Boolean]"]=Pt["[object DataView]"]=Pt["[object Date]"]=Pt["[object Error]"]=Pt["[object Function]"]=Pt["[object Map]"]=Pt["[object Number]"]=Pt["[object Object]"]=Pt["[object RegExp]"]=Pt["[object Set]"]=Pt["[object String]"]=Pt["[object WeakMap]"]=!1;var qt,Ct="object"==typeof exports&&exports&&!exports.nodeType&&exports,$t=Ct&&"object"==typeof module&&module&&!module.nodeType&&module,zt=$t&&$t.exports===Ct&&p.process,Nt=function(){try{var t=$t&&$t.require&&$t.require("util").types;return t||zt&&zt.binding&&zt.binding("util")}catch(t){}}(),Ft=Nt&&Nt.isTypedArray,It=Ft?(qt=Ft,function(t){return qt(t)}):function(t){return k(t)&&xt(t.length)&&!!Pt[A(t)]},Rt=Object.prototype.hasOwnProperty;function Jt(t,r){var e=y(t),n=!e&&_t(t),o=!e&&!n&&St(t),i=!e&&!n&&!o&&It(t),a=e||n||o||i,u=a?function(t,r){for(var e=-1,n=Array(t);++e-1},er.prototype.set=function(t,r){var e=this.__data__,n=tr(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var nr,or=d["__core-js_shared__"],ir=(nr=/[^.]+$/.exec(or&&or.keys&&or.keys.IE_PROTO||""))?"Symbol(src)_1."+nr:"";var ar=Function.prototype.toString;function ur(t){if(null!=t){try{return ar.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var cr=/^\[object .+?Constructor\]$/,sr=Function.prototype,fr=Object.prototype,lr=sr.toString,pr=fr.hasOwnProperty,hr=RegExp("^"+lr.call(pr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function dr(t){return!(!Lt(t)||function(t){return!!ir&&ir in t}(t))&&(Wt(t)?hr:cr).test(ur(t))}function vr(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return dr(e)?e:void 0}var gr=vr(d,"Map"),yr=vr(Object,"create");var br="__lodash_hash_undefined__",mr=Object.prototype.hasOwnProperty;var _r=Object.prototype.hasOwnProperty;var wr="__lodash_hash_undefined__";function jr(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ru))return!1;var s=i.get(t);if(s&&i.get(r))return s==r;var f=-1,l=!0,p=e&qr?new Tr:void 0;for(i.set(t,r),i.set(r,t);++f0){if(++r>=mn)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(bn);function On(t,r){return jn(function(t,r,e){return r=yn(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=yn(n.length-r,0),a=Array(i);++o1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=Sn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!Lt(e))return!1;var n=typeof r;return!!("number"==n?Yt(e)&&kt(r,e.length):"string"==n&&r in e)&&Zt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0))},Kn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},Vn=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!Ln(r)(t)})).length)})).length:r.length>r.filter((function(t){return!Bn(e,t)})).length},Gn=function(t,r){if(void 0===r&&(r=null),pt(t)){if(!r)return!0;if(Bn(r))return!r.filter((function(r){var e=t[r.name];return!(r.type.length>r.type.filter((function(t){var r;return!!X(e)||(!1!==(r=Kn(t))?!Vn({arg:e},r):!Ln(t)(e))})).length)})).length}return!1},Wn=function(t){var r=t.arg,e=t.param,n=[r];return Array.isArray(e.keys)&&e.keys.length&&n.push(e.keys),Gn.apply(null,n)},Yn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(r,e),r}(Error),Qn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(r,e),r}(Error),Xn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(r,e),r}(Error),Zn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(r,e),r}(Error),to=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(r,e),r}(Error),ro=function(){try{if(window||document)return!0}catch(t){}return!1},eo=function(){try{if(!ro()&&l)return!0}catch(t){}return!1};var no=function(t){function r(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];t.apply(this,r)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.where=function(){return ro()?"browser":eo()?"node":"unknown"},r}(Error),oo=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(r,e),r}(no),io=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,e),r}(Error),ao=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,e),r}(Error),uo=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,e),r}(Error),co=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(no),so=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(no),fo=function(t){function r(e,n){t.call(this,n),this.statusCode=e,this.className=r.name}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(r,e),r}(Error),lo=Object.freeze({__proto__:null,Jsonql406Error:Yn,Jsonql500Error:Qn,JsonqlAuthorisationError:Xn,JsonqlContractAuthError:Zn,JsonqlResolverAppError:to,JsonqlResolverNotFoundError:oo,JsonqlEnumError:io,JsonqlTypeError:ao,JsonqlCheckerError:uo,JsonqlValidationError:co,JsonqlError:so,JsonqlServerError:fo}),po=so,ho=function(t,r){return!!Object.keys(t).filter((function(t){return r===t})).length};function vo(t){if(ho(t,"error")){var r=t.error,e=r.className,n=r.name,o=e||n,i=r.message||f,a=r.detail||r;if(o&&lo[o])throw new lo[e](i,a);throw new po(i,a)}return t}function go(t){if(Array.isArray(t))throw new co("",t);var r=t.message||f,e=t.detail||t;switch(!0){case t instanceof Yn:throw new Yn(r,e);case t instanceof Qn:throw new Qn(r,e);case t instanceof Xn:throw new Xn(r,e);case t instanceof Zn:throw new Zn(r,e);case t instanceof to:throw new to(r,e);case t instanceof oo:throw new oo(r,e);case t instanceof io:throw new io(r,e);case t instanceof ao:throw new ao(r,e);case t instanceof uo:throw new uo(r,e);case t instanceof co:throw new co(r,e);case t instanceof fo:throw new fo(r,e);default:throw new so(r,e)}}function yo(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,r){var e;switch(!0){case"object"===t:return!Wn(r);case"array"===t:return!Bn(r.arg);case!1!==(e=Kn(t)):return!Vn(r,e);default:return!Ln(t)(r.arg)}},mo=function(t,r){return X(t)?!0!==r.optional||X(r.defaultvalue)?null:r.defaultvalue:t},_o=function(t,r,e){var n;void 0===e&&(e=!1);var o=function(t,r){if(!Bn(r))throw new so("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===r.length)return[];if(!Bn(t))throw new so("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==r.length:return yo(1),t.map((function(t,e){return{arg:t,index:e,param:r[e]}}));case!0===r[0].variable:yo(2);var e=r[0].type;return t.map((function(t,n){return{arg:t,index:n,param:r[n]||{type:e,name:"_"}}}));case t.lengthr.length:yo(4);var n=r.length,o=["any"];return t.map((function(t,e){var i=e>=n||!!r[e].optional,a=r[e]||{type:o,name:"_"+e};return{arg:i?mo(t,a):t,index:e,param:a,optional:i}}));default:throw yo(5),new so("Could not understand your arguments and parameter structure!",{args:t,params:r})}}(t,r),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!Cn(r)&&!(e.type.length>e.type.filter((function(r){return bo(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return bo(r,t)})).length)}));return e?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,r){var e,n=Object.keys(t);return e=r,!!n.filter((function(t){return t===e})).length},jo=function(t){return!Cn(t)};function Oo(t,r){var e=qn(r,(function(t,r){return!t[Dn]}));return Oe(e,{})?t:function(t,r){var e={};return r=We(r),Xt(t,(function(t,n,o){Qe(e,r(t,n,o),t)})),e}(t,(function(t,r){return function(t,r,e){var n;return e(t,(function(t,e,o){if(r(t,e,o))return n=e,!1})),n}(e,We((function(t){return t.alias===r})),Xt)||r}))}function So(t,r){return An(r,(function(r,e){var n,o;return X(t[e])||!0===r[Rn]&&jo(t[e])?En({},r,((n={})[Hn]=!0,n)):((o={})[Mn]=t[e],o[In]=r[In],o[Rn]=r[Rn]||!1,o[Jn]=r[Jn]||!1,o[Un]=r[Un]||!1,o)}))}function Eo(t,r){var e=function(t,r){var e=Oo(t,r);return{pristineValues:An(qn(r,(function(t,r){return wo(e,r)})),(function(t){return t.args})),checkAgainstAppProps:qn(r,(function(t,r){return!wo(e,r)})),config:e}}(t,r),n=e.config,o=e.pristineValues;return[So(n,e.checkAgainstAppProps),o]}var Ao=function(t){return Bn(t)?t:[t]};var ko=function(t,r){return!Bn(r)||function(t,r){return!!t.filter((function(t){return t===r})).length}(r,t)},To=function(t,r){try{return!!Wt(r)&&r.apply(null,[t])}catch(t){return!1}};function xo(t){return function(r,e){if(r[Hn])return r[Mn];var n=function(t,r){var e,n=[[t[Mn]],[(e={},e[In]=Ao(t[In]),e[Rn]=t[Rn],e)]];return Reflect.apply(r,null,n)}(r,t);if(n.length)throw yo("runValidationAction",e,r),new ao(e,n);if(!1!==r[Jn]&&!ko(r[Mn],r[Jn]))throw yo(Jn,r[Jn]),new io(e);if(!1!==r[Un]&&!To(r[Mn],r[Un]))throw yo(Un,r[Un]),new uo(e);return r[Mn]}}var Po=function(t,r){return Promise.resolve(Eo(t,r))};function qo(t,r,e,n){return void 0===t&&(t={}),Po(t,r).then((function(t){return function(t,r){var e=t[0],n=t[1],o=An(e,xo(r));return En(o,n)}(t,n)})).then((function(t){return En({},t,e)}))}function Co(t,r,e,s,f,l){void 0===e&&(e=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=r,!0===e&&(p[o]=!0),Bn(s)&&(p[i]=s),Wt(f)&&(p[u]=f),nt(l)&&(p[c]=l),p}var $o=zn,zo=Bn,No=function(t,r,e){return void 0===e&&(e=!1),new Promise((function(n,o){var i=_o(t,r,e);return e?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Fo=function(t,r,e){void 0===e&&(e={});var n=e[o],a=e[i],s=e[u],f=e[c];return Co.apply(null,[t,r,n,a,s,f])},Io=function(t){return function(r,e,n){return void 0===n&&(n={}),qo(r,e,n,t)}}(_o),Ro="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Jo=Object.assign?Object.assign:function(t,r,e,n){for(var o=arguments,i=1;i=0;r--){var e=ui().key(r);t(ci(e),e)}},remove:function(t){return ui().removeItem(t)},clearAll:function(){return ui().clear()}};function ui(){return ii.localStorage}function ci(t){return ui().getItem(t)}var si=Ho.trim,fi={name:"cookieStorage",read:function(t){if(!t||!di(t))return null;var r="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(li.cookie.replace(new RegExp(r),"$1"))},write:function(t,r){if(!t)return;li.cookie=escape(t)+"="+escape(r)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:pi,remove:hi,clearAll:function(){pi((function(t,r){hi(r)}))}},li=Ho.Global.document;function pi(t){for(var r=li.cookie.split(/; ?/g),e=r.length-1;e>=0;e--)if(si(r[e])){var n=r[e].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function hi(t){t&&di(t)&&(li.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function di(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(li.cookie)}var vi=function(){var t={};return{defaults:function(r,e){t=e},get:function(r,e){var n=r();return void 0!==n?n:t[e]}}};var gi="expire_mixin",yi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+gi);return{set:function(r,e,n,o){this.hasNamespace(gi)||t.set(e,o);return r()},get:function(t,e){this.hasNamespace(gi)||r.call(this,e);return t()},remove:function(r,e){this.hasNamespace(gi)||t.remove(e);return r()},getExpiration:function(r,e){return t.get(e)},removeExpiredKeys:function(t){var e=[];this.each((function(t,r){e.push(r)}));for(var n=0;n>>8,e[2*n+1]=a%256}return e},decompressFromUint8Array:function(r){if(null==r)return i.decompress(r);for(var e=new Array(r.length/2),n=0,o=e.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==r-1){d.push(e(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(r){return t.charCodeAt(r)}))},_decompress:function(r,e,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:e,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=e,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=e,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=e,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>r)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=e,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=e,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=e,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=r)}));var Ei=[ai,fi],Ai=[vi,yi,ji,function(){return{get:function(t,r){var e=t(r);if(!e)return e;var n=Si.decompress(e);return null==n?e:this._deserialize(n)},set:function(t,r,e){var n=Si.compress(this._serialize(e));t(r,n)}}}],ki=ei.createStore(Ei,Ai),Ti=Ho.Global;function xi(){return Ti.sessionStorage}function Pi(t){return xi().getItem(t)}var qi=[{name:"sessionStorage",read:Pi,write:function(t,r){return xi().setItem(t,r)},each:function(t){for(var r=xi().length-1;r>=0;r--){var e=xi().key(r);t(Pi(e),e)}},remove:function(t){return xi().removeItem(t)},clearAll:function(){return xi().clear()}},fi],Ci=[vi,yi],$i=ei.createStore(qi,Ci),zi=ki,Ni=$i,Fi=Array.isArray,Ii=void 0!==l?l:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ri="object"==typeof Ii&&Ii&&Ii.Object===Object&&Ii,Ji="object"==typeof self&&self&&self.Object===Object&&self,Mi=(Ri||Ji||Function("return this")()).Symbol,Ui=Object.prototype,Di=Ui.hasOwnProperty,Hi=Ui.toString,Li=Mi?Mi.toStringTag:void 0;var Bi=Object.prototype.toString;var Ki="[object Null]",Vi="[object Undefined]",Gi=Mi?Mi.toStringTag:void 0;function Wi(t){return null==t?void 0===t?Vi:Ki:Gi&&Gi in Object(t)?function(t){var r=Di.call(t,Li),e=t[Li];try{t[Li]=void 0;var n=!0}catch(t){}var o=Hi.call(t);return n&&(r?t[Li]=e:delete t[Li]),o}(t):function(t){return Bi.call(t)}(t)}var Yi=function(t,r){return function(e){return t(r(e))}}(Object.getPrototypeOf,Object);function Qi(t){return null!=t&&"object"==typeof t}var Xi="[object Object]",Zi=Function.prototype,ta=Object.prototype,ra=Zi.toString,ea=ta.hasOwnProperty,na=ra.call(Object);var oa=Mi?Mi.prototype:void 0,ia=(oa&&oa.toString,"[object String]");function aa(t){return"string"==typeof t||!Fi(t)&&Qi(t)&&Wi(t)==ia}var ua=function(t,r){return!!t.filter((function(t){return t===r})).length},ca=function(t,r){var e=Object.keys(t);return ua(e,r)},sa=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},fa="query",la="mutation",pa="socket",ha="payload",da="condition",va=function(){try{if(window||document)return!0}catch(t){}return!1},ga=function(){try{if(!va()&&Ii)return!0}catch(t){}return!1};var ya=function(t){function r(){for(var e=arguments,n=[],o=arguments.length;o--;)n[o]=e[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,Error.captureStackTrace&&Error.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(function(t){function r(){for(var r=arguments,e=[],n=arguments.length;n--;)e[n]=r[n];t.apply(this,e)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.where=function(){return va()?"browser":ga()?"node":"unknown"},r}(Error));var ba=function(t){var r;return(r={}).args=t,r};var ma=function(t){return ca(t,"data")&&!ca(t,"error")?t.data:t},_a=function(t){return function(t){if(!Qi(t)||Wi(t)!=Xi)return!1;var r=Yi(t);if(null===r)return!0;var e=ea.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&ra.call(e)==na}(t)&&(ca(t,fa)||ca(t,la)||ca(t,pa))},wa=function(t,r){return void 0===r&&(r={}),_a(r)?Promise.resolve(r):t.getContract()},ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Oa(t){this.message=t}Oa.prototype=new Error,Oa.prototype.name="InvalidCharacterError";var Sa="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new Oa("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,n,o=0,i=0,a="";n=r.charAt(i++);~n&&(e=o%4?64*e+n:n,o++%4)?a+=String.fromCharCode(255&e>>(-2*o&6)):0)n=ja.indexOf(n);return a};var Ea=function(t){var r=t.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Sa(t).replace(/(.)/g,(function(t,r){var e=r.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e})))}(r)}catch(t){return Sa(r)}};function Aa(t){this.message=t}Aa.prototype=new Error,Aa.prototype.name="InvalidTokenError";var ka=function(t,r){if("string"!=typeof t)throw new Aa("Invalid token specified");var e=!0===(r=r||{}).header?0:1;try{return JSON.parse(Ea(t.split(".")[e]))}catch(t){throw new Aa("Invalid token specified: "+t.message)}},Ta=Aa;ka.InvalidTokenError=Ta;var xa,Pa,qa,Ca,$a,za,Na,Fa,Ia,Ra=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r};function Ja(t){if($o(t))return function(t){var r=t.iat||Ra(!0);if(t.exp&&r>=t.exp){var e=new Date(t.exp).toISOString();throw new so("Token has expired on "+e,t)}return t}(ka(t));throw new so("Token must be a string!")}Fo("HS256",["string"]),Fo(!1,["boolean","number","string"],((xa={})[c]="exp",xa[o]=!0,xa)),Fo(!1,["boolean","number","string"],((Pa={})[c]="nbf",Pa[o]=!0,Pa)),Fo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),Fo(!1,["boolean","string"],((Ca={})[c]="sub",Ca[o]=!0,Ca)),Fo(!1,["boolean","string"],(($a={})[c]="iss",$a[o]=!0,$a)),Fo(!1,["boolean"],((za={})[o]=!0,za)),Fo(!1,["boolean","string"],((Na={})[o]=!0,Na)),Fo(!1,["boolean","string"],((Fa={})[o]=!0,Fa)),Fo(!1,["boolean"],((Ia={})[o]=!0,Ia));var Ma=e[0],Ua=e[1],Da=function(t){!function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ha={headers:{configurable:!0}};Ha.headers.set=function(t){this.extraHeader=t},Da.prototype.request=function(t,r,e){var n;void 0===r&&(r={}),void 0===e&&(e={}),this.headers=e;var o=En({},{_cb:sa()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=En({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,En({},{method:Ma,params:o},r))},Da.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(r){var e=t.getHeaders();for(var n in t.log("request interceptor call",e),e)r.headers[n]=e[n];return r}))},Da.prototype.processJsonp=function(t){return ma(t)},Da.prototype.resInterceptor=function(){var t=this,r=this,e=r.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),r.cleanUp();var o=$o(n.data)?JSON.parse(n.data):n.data;return e?r.processJsonp(o):ma(o)}),(function(t){throw r.cleanUp(),console.error(t),new fo("Server side error",t)}))},Da.prototype.getHeaders=function(){return this.opts.enableAuth?En({},r,this.getAuthHeader(),this.extraHeader):En({},r,this.extraHeader)},Da.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Da.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=En({},this.extraParams,s)),this.request({},{method:"GET"},this.contractHeader).then(vo).then((function(r){return t.log("get contract result",r),r.cache&&r.contract?r.contract:r}))},Da.prototype.query=function(t,r){return void 0===r&&(r=[]),this.request(function(t,r,e){var n;if(void 0===r&&(r=[]),void 0===e&&(e=!1),aa(t)&&Fi(r)){var o=ba(r);return!0===e?o:((n={})[t]=o,n)}throw new ya("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:r})}(t,r)).then(vo)},Da.prototype.mutation=function(t,r,e){return void 0===r&&(r={}),void 0===e&&(e={}),this.request(function(t,r,e,n){var o;void 0===e&&(e={}),void 0===n&&(n=!1);var i={};if(i[ha]=r,i[da]=e,!0===n)return i;if(aa(t))return(o={})[t]=i,o;throw new ya("[createMutation] expect resolverName to be string!",{resolverName:t,payload:r,condition:e})}(t,r,e),{method:Ua}).then(vo)},Object.defineProperties(Da.prototype,Ha);var La=function(t){function r(r,e){void 0===e&&(e=null),e&&(r.Fly=e),t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.storeIt.set=function(t){throw console.info("storeIt",t),zo(t)&&t.length>=2&&Reflect.apply(zi.set,zi,t),new co("Expect argument to be array and least 2 items!")},e.jsonqlEndpoint.set=function(t){var r=zi.get("endpoint")||[];ua(r,t)||(r.push(t),this.storeId=["endpoint",r],this.endpointIndex=r.length-1)},e.jsonqlContract.set=function(t){var r=this.opts.storageKey,e=[r],n=t[0],o=t[1],i=zi.get(r)||[];i[this.endpointIndex||0]=n,e.push(i),o&&e.push(o),this.opts.keepContract&&(this.storeIt=e)},e.jsonqlToken.set=function(t){var r="credential",e=localStorage.get(r)||[];if(!ua(e,t)){var n=e.length-1;e[n]=t,this[r+"Index"]=n;var o=[r,e];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=sa();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},e.jsonqlUserdata.set=function(t){var r=["userdata",t];return t.exp&&r.push(t.exp),Reflect.apply(zi.set,zi,r)},e.jsonqlEndpoint.get=function(){var t=zi.get("endpoint");if(!t){var r=this.opts,e=[r.hostname,r.jsonqlPath].join("/");return this.jsonqlEndpoint=e,e}return t[this.endpointIndex]},e.jsonqlContract.get=function(){var t=this.opts.storageKey;return(zi.get(t)||[])[this.endpointIndex]||!1},e.jsonqlToken.get=function(){var t="credential",r=localStorage.get(t);return!!r&&r[this[t+"Index"]]},e.jsonqlUserdata.get=function(){return Ni.get("userdata")},r.prototype.log=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(r.prototype,e),r}(function(t){function r(r){t.call(this,r),r.enableAuth&&r.useJwt&&(this.setDecoder=Ja)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return e.userdata.get=function(){return this.jsonqlUserdata},e.rawAuthToken.get=function(){return this.jsonqlToken},e.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.prototype.storeToken=function(t){return this.jsonqlToken=t},r.prototype.decoder=function(t){return t},r.prototype.getAuthHeader=function(){var t,r=this.rawAuthToken;return r?((t={})[this.opts.AUTH_HEADER]="Bearer "+r,t):{}},Object.defineProperties(r.prototype,e),r}(function(t){function r(r){t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={contractHeader:{configurable:!0}};return r.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var r=t[this.endpointIndex||0];if(r)return Promise.resolve(r)}return this.get().then(this.storeContract.bind(this))},e.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},r.prototype.storeContract=function(t){if(!_a(t))throw new co("Contract is malformed!");var r=[t];if(this.opts.contractExpired){var e=parseFloat(this.opts.contractExpired);!isNaN(e)&&e>0&&r.push(e)}return this.jsonqlContract=r,this.log("storeContract return result",t),t},r.prototype.readContract=function(){return _a(this.opts.contract)?this.opts.contract:zi.get(this.opts.storageKey)},Object.defineProperties(r.prototype,e),r}(Da))),Ba=function(t){return y(t)?t:[t]},Ka=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,Ba(t))}),Reflect.apply(t,null,e))}};function Va(t,r,e,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,r);return!1===n&&void 0!==o?t:(Object.defineProperty(t,r,{value:e,writable:n}),t)}var Ga=function(t,r,e,n){return function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];var i=n.auth[r].params,a=i.map((function(t,r){return e[r]})),u=e[i.length]||{};return No(e,i).then((function(){return t.query.apply(t,[r,a,u])})).catch(go)}},Wa=function(t,r,e,n,o){var i={},a=function(t){i=Va(i,t,(function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,r){return e[r]})),u=e[i.length]||{};return No(a,i).then((function(){return r.query.apply(r,[t,a,u])})).catch(go)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,r,e,n,o]},Ya=function(t,r,e,n,o){var i={},a=function(t){i=Va(i,t,(function(e,n,i){void 0===i&&(i={});var a=[e,n],u=o.mutation[t].params;return No(a,u).then((function(){return r.mutation.apply(r,[t,e,n,i])})).catch(go)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,r,e,n,o]},Qa=function(t,r,e,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=Ga(r,a,0,o);return i.apply(null,t).then(r.postLoginAction).then((function(t){return e.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ga(r,u,0,o);return i.apply(null,t).then(r.postLogoutAction).then((function(t){return e.$trigger("logout",t),t}))}:i[u]=function(){r.postLogoutAction("continue"),e.$trigger("logout","continue")},t.auth=i}return t};var Xa=function(t,r,e,n){var o=function(t,r,e,n){return Ka(Wa,Ya,Qa)({},t,r,e,n)}(t,n,r,e);return r.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},r.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.2",o},Za={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},tu={hostname:Fo([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Fo("jsonql",["string"]),loginHandlerName:Fo("login",["string"]),logoutHandlerName:Fo("logout",["string"]),enableJsonp:Fo(!1,["boolean"]),enableAuth:Fo(!1,["boolean"]),useJwt:Fo(!0,["boolean"]),useLocalstorage:Fo(!0,["boolean"]),storageKey:Fo("storageKey",["string"]),authKey:Fo("authKey",["string"]),contractExpired:Fo(0,["number"]),keepContract:Fo(!0,["boolean"]),exposeContract:Fo(!1,["boolean"]),showContractDesc:Fo(!1,["boolean"]),contractKey:Fo(!1,["boolean"]),contractKeyName:Fo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Fo(!1,["boolean"]),timeout:Fo(5e3,["number"]),returnInstance:Fo(!1,["boolean"]),allowReturnRawToken:Fo(!1,["boolean"]),debugOn:Fo(!1,["boolean"])};function ru(t,r,e){return void 0===r&&(r={}),void 0===e&&(e=null),function(t){var r=t.contract;return Io(t,tu,Za).then((function(t){return t.contract=r,t}))}(r).then((function(t){return{baseClient:new La(t,e),opts:t}})).then((function(r){var e=r.baseClient,n=r.opts;return wa(e,n.contract).then((function(r){return Xa(e,n,r,t)}))}))}var eu=new WeakMap,nu=new WeakMap;var ou=function(){this.__suspend__=null,this.queueStore=new Set},iu={$suspend:{configurable:!0},$queues:{configurable:!0}};iu.$suspend.set=function(t){var r=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var e=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+e+" --\x3e "+t),!0===e&&!1===t&&setTimeout((function(){r.release()}),1)},ou.prototype.$queue=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},iu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ou.prototype.release=function(){var t=this,r=this.queueStore.size;if(this.logger("(release)","Release was called "+r),r>0){var e=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",e),e.forEach((function(r){t.logger(r),Reflect.apply(t.$trigger,t,r)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ou.prototype,iu);var au=function(t){function r(r){void 0===r&&(r={}),t.call(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={$done:{configurable:!0}};return r.prototype.logger=function(){},r.prototype.$on=function(t,r,e){var n=this;void 0===e&&(e=null);this.validate(t,r);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",r,e);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(r,a,e||u),i+=n.addToNormalStore(t,"on",r,e||u)})),i},r.prototype.$once=function(t,r,e){void 0===e&&(e=null),this.validate(t,r);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",r,e);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(r,i,e||a),this.$off(t)},r.prototype.$only=function(t,r,e){var n=this;void 0===e&&(e=null),this.validate(t,r);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",r,e)),!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(r,i,e||a)})));return o},r.prototype.$onlyOnce=function(t,r,e){void 0===e&&(e=null),this.validate(t,r);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",r,e)),!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(r,a,e||u),this.$off(t)}return n},r.prototype.$replace=function(t,r,e,n){if(void 0===e&&(e=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,r),Reflect.apply(o,this,[t,r,e])}throw new Error(n+" is not supported!")},r.prototype.$trigger=function(t,r,e,n){void 0===r&&(r=[]),void 0===e&&(e=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,r,e,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(r)?(this.logger("(addToStore)",r+" existed"),e=t.get(r)):(this.logger("(addToStore)","create new Set for "+r),e=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(r,i)||e.add(n)}else this.checkContentExist(n,e)||(this.logger("(addToStore)","insert new",n),e.add(n));else e.add(n);return t.set(r,e),[t,e.size]},r.prototype.checkContentExist=function(t,r){return!!Array.from(r).filter((function(r){return r[0]===t[0]})).length},r.prototype.checkTypeInStore=function(t,r){this.validateEvt(t,r);var e=this.$get(t,!0);return!1===e||!e.filter((function(t){var e=t[3];return r!==e})).length},r.prototype.checkTypeInLazyStore=function(t,r){this.validateEvt(t,r);var e=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",e),!!e&&!!Array.from(e).filter((function(t){return t[2]!==r})).length},r.prototype.addToNormalStore=function(t,r,e,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,r,"try to add to normal store"),this.checkTypeInStore(t,r)){this.logger("(addToNormalStore)",r+" can add to "+t+" normal store");var o=this.hashFnToKey(e),i=[this.normalStore,t,o,e,n,r],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},r.prototype.addToLazyStore=function(t,r,e,n){void 0===r&&(r=[]),void 0===e&&(e=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(r),e];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},r.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},e.normalStore.set=function(t){eu.set(this,t)},e.normalStore.get=function(){return eu.get(this)},e.lazyStore.set=function(t){nu.set(this,t)},e.lazyStore.get=function(){return nu.get(this)},r.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,r){return(t=(t<<5)-t+r.charCodeAt(0))&t}),0)+""},Object.defineProperties(r.prototype,e),r}(ou));return function(t,r){var e;return ru((e=r.debugOn,new au({logger:e?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),r,t)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 515ae409ab82eca35e9e6b26fab81441106038b4..ac53adfb55da368c2804315b83c9dfa6e4e3a7df 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-client.static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d={desc:"y"},v="No message",g="onResult",y="onError",b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},S=function(){try{if(window||document)return!0}catch(t){}return!1},E=function(){try{if(!S()&&O)return!0}catch(t){}return!1};var k=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return S()?"browser":E()?"node":"unknown"},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,Error.captureStackTrace&&Error.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}(k),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},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"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),q=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(k),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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(k),$=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),N=Object.freeze({__proto__:null,Jsonql406Error:b,Jsonql500Error:m,JsonqlAuthorisationError:_,JsonqlContractAuthError:w,JsonqlResolverAppError:j,JsonqlResolverNotFoundError:A,JsonqlEnumError:x,JsonqlTypeError:T,JsonqlCheckerError:P,JsonqlValidationError:q,JsonqlError:C,JsonqlServerError:$}),z=C,F=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function R(t){if(F(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||v,a=e.detail||e;if(o&&N[o])throw new N[r](i,a);throw new z(i,a)}return t}function I(t){if(Array.isArray(t))throw new q("",t);var e=t.message||v,r=t.detail||t;switch(!0){case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof T:throw new T(e,r);case t instanceof P:throw new P(e,r);case t instanceof q:throw new q(e,r);case t instanceof $:throw new $(e,r);default:throw new C(e,r)}}var J="object"==typeof O&&O&&O.Object===Object&&O,M="object"==typeof self&&self&&self.Object===Object&&self,U=J||M||Function("return this")(),D=U.Symbol;function H(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--&&st(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Et(t){return void 0===t}var kt="[object Boolean]";var At="[object Number]";function xt(t){return function(t){return"number"==typeof t||tt(t)&&Z(t)==At}(t)&&t!=+t}var Tt="[object String]";function Pt(t){return"string"==typeof t||!L(t)&&tt(t)&&Z(t)==Tt}function qt(t,e){return function(r){return t(e(r))}}var Ct=qt(Object.getPrototypeOf,Object),$t="[object Object]",Nt=Function.prototype,zt=Object.prototype,Ft=Nt.toString,Rt=zt.hasOwnProperty,It=Ft.call(Object);function Jt(t){if(!tt(t)||Z(t)!=$t)return!1;var e=Ct(t);if(null===e)return!0;var r=Rt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ft.call(r)==It}var Mt,Ut=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[Mt?a:++n];if(!1===e(o[u],u,o))break}return t};var Dt="[object Arguments]";function Ht(t){return tt(t)&&Z(t)==Dt}var Lt=Object.prototype,Bt=Lt.hasOwnProperty,Kt=Lt.propertyIsEnumerable,Vt=Ht(function(){return arguments}())?Ht:function(t){return tt(t)&&Bt.call(t,"callee")&&!Kt.call(t,"callee")};var Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Yt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Yt&&Yt.exports===Gt?U.Buffer:void 0,Xt=(Wt?Wt.isBuffer:void 0)||function(){return!1},Qt=9007199254740991,Zt=/^(?:0|[1-9]\d*)$/;function te(t,e){var r=typeof t;return!!(e=null==e?Qt:e)&&("number"==r||"symbol"!=r&&Zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ee}var ne={};ne["[object Float32Array]"]=ne["[object Float64Array]"]=ne["[object Int8Array]"]=ne["[object Int16Array]"]=ne["[object Int32Array]"]=ne["[object Uint8Array]"]=ne["[object Uint8ClampedArray]"]=ne["[object Uint16Array]"]=ne["[object Uint32Array]"]=!0,ne["[object Arguments]"]=ne["[object Array]"]=ne["[object ArrayBuffer]"]=ne["[object Boolean]"]=ne["[object DataView]"]=ne["[object Date]"]=ne["[object Error]"]=ne["[object Function]"]=ne["[object Map]"]=ne["[object Number]"]=ne["[object Object]"]=ne["[object RegExp]"]=ne["[object Set]"]=ne["[object String]"]=ne["[object WeakMap]"]=!1;var oe,ie="object"==typeof exports&&exports&&!exports.nodeType&&exports,ae=ie&&"object"==typeof module&&module&&!module.nodeType&&module,ue=ae&&ae.exports===ie&&J.process,ce=function(){try{var t=ae&&ae.require&&ae.require("util").types;return t||ue&&ue.binding&&ue.binding("util")}catch(t){}}(),se=ce&&ce.isTypedArray,fe=se?(oe=se,function(t){return oe(t)}):function(t){return tt(t)&&re(t.length)&&!!ne[Z(t)]},le=Object.prototype.hasOwnProperty;function pe(t,e){var r=L(t),n=!r&&Vt(t),o=!r&&!n&&Xt(t),i=!r&&!n&&!o&&fe(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Te.prototype.set=function(t,e){var r=this.__data__,n=Ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Pe,qe=U["__core-js_shared__"],Ce=(Pe=/[^.]+$/.exec(qe&&qe.keys&&qe.keys.IE_PROTO||""))?"Symbol(src)_1."+Pe:"";var $e=Function.prototype.toString;function Ne(t){if(null!=t){try{return $e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ze=/^\[object .+?Constructor\]$/,Fe=Function.prototype,Re=Object.prototype,Ie=Fe.toString,Je=Re.hasOwnProperty,Me=RegExp("^"+Ie.call(Je).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ue(t){return!(!ye(t)||function(t){return!!Ce&&Ce in t}(t))&&(je(t)?Me:ze).test(Ne(t))}function De(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ue(r)?r:void 0}var He=De(U,"Map"),Le=De(Object,"create");var Be="__lodash_hash_undefined__",Ke=Object.prototype.hasOwnProperty;var Ve=Object.prototype.hasOwnProperty;var Ge="__lodash_hash_undefined__";function Ye(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&or?new er:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Kn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Bn);function Wn(t,e){return Yn(function(t,e,r){return e=Ln(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Ln(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Xn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ye(r))return!1;var n=typeof e;return!!("number"==n?Oe(r)&&te(e,r.length):"string"==n&&e in r)&&ke(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},_o=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},wo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!bo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!mo(r,t)})).length},jo=function(t,e){if(void 0===e&&(e=null),Jt(t)){if(!e)return!0;if(mo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Et(r)||(!1!==(e=_o(t))?!wo({arg:r},e):!bo(t)(r))})).length)})).length}return!1},Oo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),jo.apply(null,n)};function So(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Eo=function(t,e){var r;switch(!0){case"object"===t:return!Oo(e);case"array"===t:return!mo(e.arg);case!1!==(r=_o(t)):return!wo(e,r);default:return!bo(t)(e.arg)}},ko=function(t,e){return Et(t)?!0!==e.optional||Et(e.defaultvalue)?null:e.defaultvalue:t},Ao=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!mo(e))throw new C("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!mo(t))throw new C("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 So(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:So(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:So(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?ko(t,a):t,index:r,param:a,optional:i}}));default:throw So(5),new C("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!!io(e)&&!(r.type.length>r.type.filter((function(e){return Eo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Eo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},xo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},To=function(t){return!io(t)};function Po(t,e){var r=oo(e,(function(t,e){return!t[go]}));return Wr(r,{})?t:function(t,e){var r={};return e=On(e),Ee(t,(function(t,n,o){En(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,On((function(t){return t.alias===e})),Ee)||e}))}function qo(t,e){return Zn(e,(function(e,r){var n,o;return Et(t[r])||!0===e[lo]&&To(t[r])?Qn({},e,((n={})[yo]=!0,n)):((o={})[ho]=t[r],o[fo]=e[fo],o[lo]=e[lo]||!1,o[po]=e[po]||!1,o[vo]=e[vo]||!1,o)}))}function Co(t,e){var r=function(t,e){var r=Po(t,e);return{pristineValues:Zn(oo(e,(function(t,e){return xo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:oo(e,(function(t,e){return!xo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[qo(n,r.checkAgainstAppProps),o]}var $o=function(t){return mo(t)?t:[t]};var No=function(t,e){return!mo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},zo=function(t,e){try{return!!je(e)&&e.apply(null,[t])}catch(t){return!1}};function Fo(t){return function(e,r){if(e[yo])return e[ho];var n=function(t,e){var r,n=[[t[ho]],[(r={},r[fo]=$o(t[fo]),r[lo]=t[lo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw So("runValidationAction",r,e),new T(r,n);if(!1!==e[po]&&!No(e[ho],e[po]))throw So(po,e[po]),new x(r);if(!1!==e[vo]&&!zo(e[ho],e[vo]))throw So(vo,e[vo]),new P(r);return e[ho]}}function Ro(t,e,r,n){return void 0===t&&(t={}),Qn(function(t,e){var r=t[0],n=t[1],o=Zn(r,Fo(e));return Qn(o,n)}(Co(t,e),n),r)}function Io(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),mo(n)&&(a[f]=n),je(o)&&(a[p]=o),Pt(i)&&(a[h]=i),a}var Jo=uo,Mo=mo,Uo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Ao(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Do=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Io.apply(null,[t,e,n,o,i,a])},Ho=function(t){return function(e,r,n){return void 0===n&&(n={}),Ro(e,r,n,t)}}(Ao),Lo=function(t){return L(t)?t:[t]},Bo=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Lo(t))}),Reflect.apply(t,null,r))}};function Ko(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Vo=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 Uo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(I)}},Go=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Uo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(I)}))};for(var u in o.query)a(u);return t.query=i,[t,e,r,n,o]},Yo=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Uo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(I)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wo=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=Vo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Vo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Xo=Array.isArray,Qo=void 0!==O?O:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Zo="object"==typeof Qo&&Qo&&Qo.Object===Object&&Qo,ti="object"==typeof self&&self&&self.Object===Object&&self,ei=(Zo||ti||Function("return this")()).Symbol,ri=Object.prototype,ni=ri.hasOwnProperty,oi=ri.toString,ii=ei?ei.toStringTag:void 0;var ai=Object.prototype.toString;var ui="[object Null]",ci="[object Undefined]",si=ei?ei.toStringTag:void 0;function fi(t){return null==t?void 0===t?ci:ui:si&&si in Object(t)?function(t){var e=ni.call(t,ii),r=t[ii];try{t[ii]=void 0;var n=!0}catch(t){}var o=oi.call(t);return n&&(e?t[ii]=r:delete t[ii]),o}(t):function(t){return ai.call(t)}(t)}var li=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function pi(t){return null!=t&&"object"==typeof t}var hi="[object Object]",di=Function.prototype,vi=Object.prototype,gi=di.toString,yi=vi.hasOwnProperty,bi=gi.call(Object);var mi=ei?ei.prototype:void 0,_i=(mi&&mi.toString,"[object String]");function wi(t){return"string"==typeof t||!Xo(t)&&pi(t)&&fi(t)==_i}var ji=function(t,e){return!!t.filter((function(t){return t===e})).length},Oi=function(t,e){var r=Object.keys(t);return ji(r,e)},Si=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Ei=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ki="query",Ai="mutation",xi="socket",Ti="payload",Pi="condition",qi=function(){try{if(window||document)return!0}catch(t){}return!1},Ci=function(){try{if(!qi()&&Qo)return!0}catch(t){}return!1};var $i=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return qi()?"browser":Ci()?"node":"unknown"},e}(Error));var Ni=function(t){var e;return(e={}).args=t,e};var zi=function(t){return Oi(t,"data")&&!Oi(t,"error")?t.data:t},Fi=function(t){return function(t){if(!pi(t)||fi(t)!=hi)return!1;var e=li(t);if(null===e)return!0;var r=yi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&gi.call(r)==bi}(t)&&(Oi(t,ki)||Oi(t,Ai)||Oi(t,xi))},Ri=function(t,e){return void 0===e&&(e={}),Fi(e)?Promise.resolve(e):t.getContract()},Ii=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(Si(e,r,g),o),t.$only(Si(e,r,y),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ji=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Mi(t,e,r,n){var o=function(t,e,r,n){return Bo(Go,Yo,Wo)({},t,e,r,n)}(t,e,r,n);Ji(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(Si(t,n,g),r)})).catch((function(r){e.$trigger(Si(t,n,y),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ui=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Mi(t,n,e,r)}));var o={query:Ii(n,"query"),mutation:Ii(n,"mutation"),auth:Ii(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.0",o},Di=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=fa().key(e);t(la(r),r)}},remove:function(t){return fa().removeItem(t)},clearAll:function(){return fa().clear()}};function fa(){return ca.localStorage}function la(t){return fa().getItem(t)}var pa=Ki.trim,ha={name:"cookieStorage",read:function(t){if(!t||!ya(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(da.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;da.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:va,remove:ga,clearAll:function(){va((function(t,e){ga(e)}))}},da=Ki.Global.document;function va(t){for(var e=da.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(pa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ga(t){t&&ya(t)&&(da.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ya(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(da.cookie)}var ba=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 ma="expire_mixin",_a=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ma);return{set:function(e,r,n,o){this.hasNamespace(ma)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ma)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ma)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var xa=[sa,ha],Ta=[ba,_a,Ea,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Aa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Aa.compress(this._serialize(r));t(e,n)}}}],Pa=ia.createStore(xa,Ta),qa=Ki.Global;function Ca(){return qa.sessionStorage}function $a(t){return Ca().getItem(t)}var Na=[{name:"sessionStorage",read:$a,write:function(t,e){return Ca().setItem(t,e)},each:function(t){for(var e=Ca().length-1;e>=0;e--){var r=Ca().key(e);t($a(r),r)}},remove:function(t){return Ca().removeItem(t)},clearAll:function(){return Ca().clear()}},ha],za=[ba,_a],Fa=ia.createStore(Na,za),Ra=Pa,Ia=Fa,Ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ma(t){this.message=t}Ma.prototype=new Error,Ma.prototype.name="InvalidCharacterError";var Ua="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ma("'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=Ja.indexOf(n);return a};var Da=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(Ua(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 Ua(e)}};function Ha(t){this.message=t}Ha.prototype=new Error,Ha.prototype.name="InvalidTokenError";var La=function(t,e){if("string"!=typeof t)throw new Ha("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Da(t.split(".")[r]))}catch(t){throw new Ha("Invalid token specified: "+t.message)}},Ba=Ha;La.InvalidTokenError=Ba;var Ka,Va,Ga,Ya,Wa,Xa,Qa,Za,tu,eu=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function ru(t){if(Jo(t))return function(t){var e=t.iat||eu(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new C("Token has expired on "+r,t)}return t}(La(t));throw new C("Token must be a string!")}Do("HS256",["string"]),Do(!1,["boolean","number","string"],((Ka={})[h]="exp",Ka[s]=!0,Ka)),Do(!1,["boolean","number","string"],((Va={})[h]="nbf",Va[s]=!0,Va)),Do(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Do(!1,["boolean","string"],((Ya={})[h]="sub",Ya[s]=!0,Ya)),Do(!1,["boolean","string"],((Wa={})[h]="iss",Wa[s]=!0,Wa)),Do(!1,["boolean"],((Xa={})[s]=!0,Xa)),Do(!1,["boolean","string"],((Qa={})[s]=!0,Qa)),Do(!1,["boolean","string"],((Za={})[s]=!0,Za)),Do(!1,["boolean"],((tu={})[s]=!0,tu));var nu=u[0],ou=u[1],iu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},au={headers:{configurable:!0}};au.headers.set=function(t){this.extraHeader=t},iu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Qn({},{_cb:Ei()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Qn({},{method:nu,params:o},e))},iu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},iu.prototype.processJsonp=function(t){return zi(t)},iu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Jo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):zi(o)}),(function(t){throw e.cleanUp(),console.error(t),new $("Server side error",t)}))},iu.prototype.getHeaders=function(){return this.opts.enableAuth?Qn({},a,this.getAuthHeader(),this.extraHeader):Qn({},a,this.extraHeader)},iu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},iu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Qn({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(R).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},iu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),wi(t)&&Xo(e)){var o=Ni(e);return!0===r?o:((n={})[t]=o,n)}throw new $i("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(R)},iu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ti]=e,i[Pi]=r,!0===n)return i;if(wi(t))return(o={})[t]=i,o;throw new $i("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ou}).then(R)},Object.defineProperties(iu.prototype,au);var uu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Mo(t)&&t.length>=2&&Reflect.apply(Ra.set,Ra,t),new q("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ra.get("endpoint")||[];ji(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ra.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ji(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Ei();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ra.set,Ra,e)},r.jsonqlEndpoint.get=function(){var t=Ra.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ra.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ia.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=ru)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Fi(t))throw new q("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Fi(this.opts.contract)?this.opts.contract:Ra.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(iu))),cu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},su={hostname:Do([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Do("jsonql",["string"]),loginHandlerName:Do("login",["string"]),logoutHandlerName:Do("logout",["string"]),enableJsonp:Do(!1,["boolean"]),enableAuth:Do(!1,["boolean"]),useJwt:Do(!0,["boolean"]),useLocalstorage:Do(!0,["boolean"]),storageKey:Do("storageKey",["string"]),authKey:Do("authKey",["string"]),contractExpired:Do(0,["number"]),keepContract:Do(!0,["boolean"]),exposeContract:Do(!1,["boolean"]),showContractDesc:Do(!1,["boolean"]),contractKey:Do(!1,["boolean"]),contractKeyName:Do("X-JSONQL-CV-KEY",["string"]),enableTimeout:Do(!1,["boolean"]),timeout:Do(5e3,["number"]),returnInstance:Do(!1,["boolean"]),allowReturnRawToken:Do(!1,["boolean"]),debugOn:Do(!1,["boolean"])};var fu=new WeakMap,lu=new WeakMap;var pu=function(){this.__suspend__=null,this.queueStore=new Set},hu={$suspend:{configurable:!0},$queues:{configurable:!0}};hu.$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)},pu.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__},hu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},pu.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(pu.prototype,hu);var du=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){fu.set(this,t)},r.normalStore.get=function(){return fu.get(this)},r.lazyStore.set=function(t){lu.set(this,t)},r.lazyStore.get=function(){return lu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(pu));function vu(t,e){void 0===e&&(e={});var r,n=e.contract,o=function(t){return Ho(t,su,cu)}(e),i=new uu(o,t),a=Ri(i,n),u=(r=o.debugOn,new du({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ui(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),vu(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d={desc:"y"},v="No message",g="onResult",y="onError",b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},S=function(){try{if(window||document)return!0}catch(t){}return!1},E=function(){try{if(!S()&&O)return!0}catch(t){}return!1};var k=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return S()?"browser":E()?"node":"unknown"},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,Error.captureStackTrace&&Error.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}(k),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},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"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),q=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(k),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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(k),$=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),N=Object.freeze({__proto__:null,Jsonql406Error:b,Jsonql500Error:m,JsonqlAuthorisationError:_,JsonqlContractAuthError:w,JsonqlResolverAppError:j,JsonqlResolverNotFoundError:A,JsonqlEnumError:x,JsonqlTypeError:T,JsonqlCheckerError:P,JsonqlValidationError:q,JsonqlError:C,JsonqlServerError:$}),z=C,F=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function R(t){if(F(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||v,a=e.detail||e;if(o&&N[o])throw new N[r](i,a);throw new z(i,a)}return t}function I(t){if(Array.isArray(t))throw new q("",t);var e=t.message||v,r=t.detail||t;switch(!0){case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof T:throw new T(e,r);case t instanceof P:throw new P(e,r);case t instanceof q:throw new q(e,r);case t instanceof $:throw new $(e,r);default:throw new C(e,r)}}var J="object"==typeof O&&O&&O.Object===Object&&O,M="object"==typeof self&&self&&self.Object===Object&&self,U=J||M||Function("return this")(),D=U.Symbol;function H(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--&&st(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Et(t){return void 0===t}var kt="[object Boolean]";var At="[object Number]";function xt(t){return function(t){return"number"==typeof t||tt(t)&&Z(t)==At}(t)&&t!=+t}var Tt="[object String]";function Pt(t){return"string"==typeof t||!L(t)&&tt(t)&&Z(t)==Tt}function qt(t,e){return function(r){return t(e(r))}}var Ct=qt(Object.getPrototypeOf,Object),$t="[object Object]",Nt=Function.prototype,zt=Object.prototype,Ft=Nt.toString,Rt=zt.hasOwnProperty,It=Ft.call(Object);function Jt(t){if(!tt(t)||Z(t)!=$t)return!1;var e=Ct(t);if(null===e)return!0;var r=Rt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ft.call(r)==It}var Mt,Ut=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[Mt?a:++n];if(!1===e(o[u],u,o))break}return t};var Dt="[object Arguments]";function Ht(t){return tt(t)&&Z(t)==Dt}var Lt=Object.prototype,Bt=Lt.hasOwnProperty,Kt=Lt.propertyIsEnumerable,Vt=Ht(function(){return arguments}())?Ht:function(t){return tt(t)&&Bt.call(t,"callee")&&!Kt.call(t,"callee")};var Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Yt=Wt&&Wt.exports===Gt?U.Buffer:void 0,Xt=(Yt?Yt.isBuffer:void 0)||function(){return!1},Qt=9007199254740991,Zt=/^(?:0|[1-9]\d*)$/;function te(t,e){var r=typeof t;return!!(e=null==e?Qt:e)&&("number"==r||"symbol"!=r&&Zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ee}var ne={};ne["[object Float32Array]"]=ne["[object Float64Array]"]=ne["[object Int8Array]"]=ne["[object Int16Array]"]=ne["[object Int32Array]"]=ne["[object Uint8Array]"]=ne["[object Uint8ClampedArray]"]=ne["[object Uint16Array]"]=ne["[object Uint32Array]"]=!0,ne["[object Arguments]"]=ne["[object Array]"]=ne["[object ArrayBuffer]"]=ne["[object Boolean]"]=ne["[object DataView]"]=ne["[object Date]"]=ne["[object Error]"]=ne["[object Function]"]=ne["[object Map]"]=ne["[object Number]"]=ne["[object Object]"]=ne["[object RegExp]"]=ne["[object Set]"]=ne["[object String]"]=ne["[object WeakMap]"]=!1;var oe,ie="object"==typeof exports&&exports&&!exports.nodeType&&exports,ae=ie&&"object"==typeof module&&module&&!module.nodeType&&module,ue=ae&&ae.exports===ie&&J.process,ce=function(){try{var t=ae&&ae.require&&ae.require("util").types;return t||ue&&ue.binding&&ue.binding("util")}catch(t){}}(),se=ce&&ce.isTypedArray,fe=se?(oe=se,function(t){return oe(t)}):function(t){return tt(t)&&re(t.length)&&!!ne[Z(t)]},le=Object.prototype.hasOwnProperty;function pe(t,e){var r=L(t),n=!r&&Vt(t),o=!r&&!n&&Xt(t),i=!r&&!n&&!o&&fe(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Te.prototype.set=function(t,e){var r=this.__data__,n=Ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Pe,qe=U["__core-js_shared__"],Ce=(Pe=/[^.]+$/.exec(qe&&qe.keys&&qe.keys.IE_PROTO||""))?"Symbol(src)_1."+Pe:"";var $e=Function.prototype.toString;function Ne(t){if(null!=t){try{return $e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ze=/^\[object .+?Constructor\]$/,Fe=Function.prototype,Re=Object.prototype,Ie=Fe.toString,Je=Re.hasOwnProperty,Me=RegExp("^"+Ie.call(Je).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ue(t){return!(!ye(t)||function(t){return!!Ce&&Ce in t}(t))&&(je(t)?Me:ze).test(Ne(t))}function De(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ue(r)?r:void 0}var He=De(U,"Map"),Le=De(Object,"create");var Be="__lodash_hash_undefined__",Ke=Object.prototype.hasOwnProperty;var Ve=Object.prototype.hasOwnProperty;var Ge="__lodash_hash_undefined__";function We(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&or?new er:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Kn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Bn);function Yn(t,e){return Wn(function(t,e,r){return e=Ln(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Ln(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Xn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ye(r))return!1;var n=typeof e;return!!("number"==n?Oe(r)&&te(e,r.length):"string"==n&&e in r)&&ke(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},_o=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},wo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!bo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!mo(r,t)})).length},jo=function(t,e){if(void 0===e&&(e=null),Jt(t)){if(!e)return!0;if(mo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Et(r)||(!1!==(e=_o(t))?!wo({arg:r},e):!bo(t)(r))})).length)})).length}return!1},Oo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),jo.apply(null,n)};function So(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Eo=function(t,e){var r;switch(!0){case"object"===t:return!Oo(e);case"array"===t:return!mo(e.arg);case!1!==(r=_o(t)):return!wo(e,r);default:return!bo(t)(e.arg)}},ko=function(t,e){return Et(t)?!0!==e.optional||Et(e.defaultvalue)?null:e.defaultvalue:t},Ao=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!mo(e))throw new C("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!mo(t))throw new C("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 So(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:So(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:So(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?ko(t,a):t,index:r,param:a,optional:i}}));default:throw So(5),new C("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!!io(e)&&!(r.type.length>r.type.filter((function(e){return Eo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Eo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},xo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},To=function(t){return!io(t)};function Po(t,e){var r=oo(e,(function(t,e){return!t[go]}));return Yr(r,{})?t:function(t,e){var r={};return e=On(e),Ee(t,(function(t,n,o){En(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,On((function(t){return t.alias===e})),Ee)||e}))}function qo(t,e){return Zn(e,(function(e,r){var n,o;return Et(t[r])||!0===e[lo]&&To(t[r])?Qn({},e,((n={})[yo]=!0,n)):((o={})[ho]=t[r],o[fo]=e[fo],o[lo]=e[lo]||!1,o[po]=e[po]||!1,o[vo]=e[vo]||!1,o)}))}function Co(t,e){var r=function(t,e){var r=Po(t,e);return{pristineValues:Zn(oo(e,(function(t,e){return xo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:oo(e,(function(t,e){return!xo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[qo(n,r.checkAgainstAppProps),o]}var $o=function(t){return mo(t)?t:[t]};var No=function(t,e){return!mo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},zo=function(t,e){try{return!!je(e)&&e.apply(null,[t])}catch(t){return!1}};function Fo(t){return function(e,r){if(e[yo])return e[ho];var n=function(t,e){var r,n=[[t[ho]],[(r={},r[fo]=$o(t[fo]),r[lo]=t[lo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw So("runValidationAction",r,e),new T(r,n);if(!1!==e[po]&&!No(e[ho],e[po]))throw So(po,e[po]),new x(r);if(!1!==e[vo]&&!zo(e[ho],e[vo]))throw So(vo,e[vo]),new P(r);return e[ho]}}function Ro(t,e,r,n){return void 0===t&&(t={}),Qn(function(t,e){var r=t[0],n=t[1],o=Zn(r,Fo(e));return Qn(o,n)}(Co(t,e),n),r)}function Io(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),mo(n)&&(a[f]=n),je(o)&&(a[p]=o),Pt(i)&&(a[h]=i),a}var Jo=uo,Mo=mo,Uo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Ao(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Do=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Io.apply(null,[t,e,n,o,i,a])},Ho=function(t){return function(e,r,n){return void 0===n&&(n={}),Ro(e,r,n,t)}}(Ao),Lo=function(t){return L(t)?t:[t]},Bo=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Lo(t))}),Reflect.apply(t,null,r))}};function Ko(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Vo=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 Uo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(I)}},Go=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Uo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(I)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Wo=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Uo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(I)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Yo=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=Vo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Vo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Xo=Array.isArray,Qo=void 0!==O?O:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Zo="object"==typeof Qo&&Qo&&Qo.Object===Object&&Qo,ti="object"==typeof self&&self&&self.Object===Object&&self,ei=(Zo||ti||Function("return this")()).Symbol,ri=Object.prototype,ni=ri.hasOwnProperty,oi=ri.toString,ii=ei?ei.toStringTag:void 0;var ai=Object.prototype.toString;var ui="[object Null]",ci="[object Undefined]",si=ei?ei.toStringTag:void 0;function fi(t){return null==t?void 0===t?ci:ui:si&&si in Object(t)?function(t){var e=ni.call(t,ii),r=t[ii];try{t[ii]=void 0;var n=!0}catch(t){}var o=oi.call(t);return n&&(e?t[ii]=r:delete t[ii]),o}(t):function(t){return ai.call(t)}(t)}var li=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function pi(t){return null!=t&&"object"==typeof t}var hi="[object Object]",di=Function.prototype,vi=Object.prototype,gi=di.toString,yi=vi.hasOwnProperty,bi=gi.call(Object);var mi=ei?ei.prototype:void 0,_i=(mi&&mi.toString,"[object String]");function wi(t){return"string"==typeof t||!Xo(t)&&pi(t)&&fi(t)==_i}var ji=function(t,e){return!!t.filter((function(t){return t===e})).length},Oi=function(t,e){var r=Object.keys(t);return ji(r,e)},Si=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Ei=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ki="query",Ai="mutation",xi="socket",Ti="payload",Pi="condition",qi=function(){try{if(window||document)return!0}catch(t){}return!1},Ci=function(){try{if(!qi()&&Qo)return!0}catch(t){}return!1};var $i=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return qi()?"browser":Ci()?"node":"unknown"},e}(Error));var Ni=function(t){var e;return(e={}).args=t,e};var zi=function(t){return Oi(t,"data")&&!Oi(t,"error")?t.data:t},Fi=function(t){return function(t){if(!pi(t)||fi(t)!=hi)return!1;var e=li(t);if(null===e)return!0;var r=yi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&gi.call(r)==bi}(t)&&(Oi(t,ki)||Oi(t,Ai)||Oi(t,xi))},Ri=function(t,e){return void 0===e&&(e={}),Fi(e)?Promise.resolve(e):t.getContract()},Ii=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(Si(e,r,g),o),t.$only(Si(e,r,y),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ji=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Mi(t,e,r,n){var o=function(t,e,r,n){return Bo(Go,Wo,Yo)({},t,e,r,n)}(t,e,r,n);Ji(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(Si(t,n,g),r)})).catch((function(r){e.$trigger(Si(t,n,y),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ui=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Mi(t,n,e,r)}));var o={query:Ii(n,"query"),mutation:Ii(n,"mutation"),auth:Ii(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.2",o},Di=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=fa().key(e);t(la(r),r)}},remove:function(t){return fa().removeItem(t)},clearAll:function(){return fa().clear()}};function fa(){return ca.localStorage}function la(t){return fa().getItem(t)}var pa=Ki.trim,ha={name:"cookieStorage",read:function(t){if(!t||!ya(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(da.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;da.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:va,remove:ga,clearAll:function(){va((function(t,e){ga(e)}))}},da=Ki.Global.document;function va(t){for(var e=da.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(pa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ga(t){t&&ya(t)&&(da.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ya(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(da.cookie)}var ba=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 ma="expire_mixin",_a=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ma);return{set:function(e,r,n,o){this.hasNamespace(ma)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ma)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ma)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var xa=[sa,ha],Ta=[ba,_a,Ea,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Aa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Aa.compress(this._serialize(r));t(e,n)}}}],Pa=ia.createStore(xa,Ta),qa=Ki.Global;function Ca(){return qa.sessionStorage}function $a(t){return Ca().getItem(t)}var Na=[{name:"sessionStorage",read:$a,write:function(t,e){return Ca().setItem(t,e)},each:function(t){for(var e=Ca().length-1;e>=0;e--){var r=Ca().key(e);t($a(r),r)}},remove:function(t){return Ca().removeItem(t)},clearAll:function(){return Ca().clear()}},ha],za=[ba,_a],Fa=ia.createStore(Na,za),Ra=Pa,Ia=Fa,Ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ma(t){this.message=t}Ma.prototype=new Error,Ma.prototype.name="InvalidCharacterError";var Ua="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ma("'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=Ja.indexOf(n);return a};var Da=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(Ua(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 Ua(e)}};function Ha(t){this.message=t}Ha.prototype=new Error,Ha.prototype.name="InvalidTokenError";var La=function(t,e){if("string"!=typeof t)throw new Ha("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Da(t.split(".")[r]))}catch(t){throw new Ha("Invalid token specified: "+t.message)}},Ba=Ha;La.InvalidTokenError=Ba;var Ka,Va,Ga,Wa,Ya,Xa,Qa,Za,tu,eu=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function ru(t){if(Jo(t))return function(t){var e=t.iat||eu(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new C("Token has expired on "+r,t)}return t}(La(t));throw new C("Token must be a string!")}Do("HS256",["string"]),Do(!1,["boolean","number","string"],((Ka={})[h]="exp",Ka[s]=!0,Ka)),Do(!1,["boolean","number","string"],((Va={})[h]="nbf",Va[s]=!0,Va)),Do(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Do(!1,["boolean","string"],((Wa={})[h]="sub",Wa[s]=!0,Wa)),Do(!1,["boolean","string"],((Ya={})[h]="iss",Ya[s]=!0,Ya)),Do(!1,["boolean"],((Xa={})[s]=!0,Xa)),Do(!1,["boolean","string"],((Qa={})[s]=!0,Qa)),Do(!1,["boolean","string"],((Za={})[s]=!0,Za)),Do(!1,["boolean"],((tu={})[s]=!0,tu));var nu=u[0],ou=u[1],iu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},au={headers:{configurable:!0}};au.headers.set=function(t){this.extraHeader=t},iu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Qn({},{_cb:Ei()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Qn({},{method:nu,params:o},e))},iu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},iu.prototype.processJsonp=function(t){return zi(t)},iu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Jo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):zi(o)}),(function(t){throw e.cleanUp(),console.error(t),new $("Server side error",t)}))},iu.prototype.getHeaders=function(){return this.opts.enableAuth?Qn({},a,this.getAuthHeader(),this.extraHeader):Qn({},a,this.extraHeader)},iu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},iu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Qn({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(R).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},iu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),wi(t)&&Xo(e)){var o=Ni(e);return!0===r?o:((n={})[t]=o,n)}throw new $i("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(R)},iu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ti]=e,i[Pi]=r,!0===n)return i;if(wi(t))return(o={})[t]=i,o;throw new $i("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ou}).then(R)},Object.defineProperties(iu.prototype,au);var uu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Mo(t)&&t.length>=2&&Reflect.apply(Ra.set,Ra,t),new q("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ra.get("endpoint")||[];ji(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ra.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ji(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Ei();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ra.set,Ra,e)},r.jsonqlEndpoint.get=function(){var t=Ra.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ra.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ia.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=ru)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Fi(t))throw new q("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Fi(this.opts.contract)?this.opts.contract:Ra.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(iu))),cu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},su={hostname:Do([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Do("jsonql",["string"]),loginHandlerName:Do("login",["string"]),logoutHandlerName:Do("logout",["string"]),enableJsonp:Do(!1,["boolean"]),enableAuth:Do(!1,["boolean"]),useJwt:Do(!0,["boolean"]),useLocalstorage:Do(!0,["boolean"]),storageKey:Do("storageKey",["string"]),authKey:Do("authKey",["string"]),contractExpired:Do(0,["number"]),keepContract:Do(!0,["boolean"]),exposeContract:Do(!1,["boolean"]),showContractDesc:Do(!1,["boolean"]),contractKey:Do(!1,["boolean"]),contractKeyName:Do("X-JSONQL-CV-KEY",["string"]),enableTimeout:Do(!1,["boolean"]),timeout:Do(5e3,["number"]),returnInstance:Do(!1,["boolean"]),allowReturnRawToken:Do(!1,["boolean"]),debugOn:Do(!1,["boolean"])};var fu=new WeakMap,lu=new WeakMap;var pu=function(){this.__suspend__=null,this.queueStore=new Set},hu={$suspend:{configurable:!0},$queues:{configurable:!0}};hu.$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)},pu.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__},hu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},pu.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(pu.prototype,hu);var du=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){fu.set(this,t)},r.normalStore.get=function(){return fu.get(this)},r.lazyStore.set=function(t){lu.set(this,t)},r.lazyStore.get=function(){return lu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(pu));function vu(t,e){void 0===e&&(e={});var r,n=e.contract,o=function(t){return Ho(t,su,cu)}(e),i=new uu(o,t),a=Ri(i,n),u=(r=o.debugOn,new du({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ui(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),vu(o,t)}})); //# 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 8ad92573d802250351e3a325559e9b3715753e28..b6213a18ea698260d69205c88b03924ac9515229 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","../node_modules/store/plugins/expire.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","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d={desc:"y"},v="No message";var g="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},y="object"==typeof g&&g&&g.Object===Object&&g,b="object"==typeof self&&self&&self.Object===Object&&self,m=y||b||Function("return this")(),_=m.Symbol;function w(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--&&U(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function nt(t){return void 0===t}var ot="[object Boolean]";var it="[object Number]";function at(t){return function(t){return"number"==typeof t||C(t)&&q(t)==it}(t)&&t!=+t}var ut="[object String]";function ct(t){return"string"==typeof t||!j(t)&&C(t)&&q(t)==ut}function st(t,e){return function(r){return t(e(r))}}var ft=st(Object.getPrototypeOf,Object),lt="[object Object]",pt=Function.prototype,ht=Object.prototype,dt=pt.toString,vt=ht.hasOwnProperty,gt=dt.call(Object);function yt(t){if(!C(t)||q(t)!=lt)return!1;var e=ft(t);if(null===e)return!0;var r=vt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&dt.call(r)==gt}var bt,mt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[bt?a:++n];if(!1===e(o[u],u,o))break}return t};var _t="[object Arguments]";function wt(t){return C(t)&&q(t)==_t}var jt=Object.prototype,Ot=jt.hasOwnProperty,St=jt.propertyIsEnumerable,Et=wt(function(){return arguments}())?wt:function(t){return C(t)&&Ot.call(t,"callee")&&!St.call(t,"callee")};var kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,At=kt&&"object"==typeof module&&module&&!module.nodeType&&module,xt=At&&At.exports===kt?m.Buffer:void 0,Tt=(xt?xt.isBuffer:void 0)||function(){return!1},Pt=9007199254740991,qt=/^(?:0|[1-9]\d*)$/;function Ct(t,e){var r=typeof t;return!!(e=null==e?Pt:e)&&("number"==r||"symbol"!=r&&qt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=$t}var zt={};zt["[object Float32Array]"]=zt["[object Float64Array]"]=zt["[object Int8Array]"]=zt["[object Int16Array]"]=zt["[object Int32Array]"]=zt["[object Uint8Array]"]=zt["[object Uint8ClampedArray]"]=zt["[object Uint16Array]"]=zt["[object Uint32Array]"]=!0,zt["[object Arguments]"]=zt["[object Array]"]=zt["[object ArrayBuffer]"]=zt["[object Boolean]"]=zt["[object DataView]"]=zt["[object Date]"]=zt["[object Error]"]=zt["[object Function]"]=zt["[object Map]"]=zt["[object Number]"]=zt["[object Object]"]=zt["[object RegExp]"]=zt["[object Set]"]=zt["[object String]"]=zt["[object WeakMap]"]=!1;var Ft,Rt="object"==typeof exports&&exports&&!exports.nodeType&&exports,It=Rt&&"object"==typeof module&&module&&!module.nodeType&&module,Jt=It&&It.exports===Rt&&y.process,Mt=function(){try{var t=It&&It.require&&It.require("util").types;return t||Jt&&Jt.binding&&Jt.binding("util")}catch(t){}}(),Ut=Mt&&Mt.isTypedArray,Dt=Ut?(Ft=Ut,function(t){return Ft(t)}):function(t){return C(t)&&Nt(t.length)&&!!zt[q(t)]},Ht=Object.prototype.hasOwnProperty;function Lt(t,e){var r=j(t),n=!r&&Et(t),o=!r&&!n&&Tt(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},ue.prototype.set=function(t,e){var r=this.__data__,n=ie(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ce,se=m["__core-js_shared__"],fe=(ce=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||""))?"Symbol(src)_1."+ce:"";var le=Function.prototype.toString;function pe(t){if(null!=t){try{return le.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var he=/^\[object .+?Constructor\]$/,de=Function.prototype,ve=Object.prototype,ge=de.toString,ye=ve.hasOwnProperty,be=RegExp("^"+ge.call(ye).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function me(t){return!(!Yt(t)||function(t){return!!fe&&fe in t}(t))&&(te(t)?be:he).test(pe(t))}function _e(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return me(r)?r:void 0}var we=_e(m,"Map"),je=_e(Object,"create");var Oe="__lodash_hash_undefined__",Se=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;var ke="__lodash_hash_undefined__";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=r&Fe?new $e:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Sn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(On);function xn(t,e){return An(function(t,e,r){return e=jn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=jn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Tn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Yt(r))return!1;var n=typeof e;return!!("number"==n?ee(r)&&Ct(e,r.length):"string"==n&&e in r)&&oe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Xn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Qn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Yn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Wn(r,t)})).length},Zn=function(t,e){if(void 0===e&&(e=null),yt(t)){if(!e)return!0;if(Wn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!nt(r)||(!1!==(e=Xn(t))?!Qn({arg:r},e):!Yn(t)(r))})).length)})).length}return!1},to=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Zn.apply(null,n)},eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ao=function(){try{if(window||document)return!0}catch(t){}return!1},uo=function(){try{if(!ao()&&g)return!0}catch(t){}return!1};var co=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ao()?"browser":uo()?"node":"unknown"},e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.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}(co),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ho=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(co),vo=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(co),go=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),yo=Object.freeze({__proto__:null,Jsonql406Error:eo,Jsonql500Error:ro,JsonqlAuthorisationError:no,JsonqlContractAuthError:oo,JsonqlResolverAppError:io,JsonqlResolverNotFoundError:so,JsonqlEnumError:fo,JsonqlTypeError:lo,JsonqlCheckerError:po,JsonqlValidationError:ho,JsonqlError:vo,JsonqlServerError:go}),bo=vo,mo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function _o(t){if(mo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||v,a=e.detail||e;if(o&&yo[o])throw new yo[r](i,a);throw new bo(i,a)}return t}function wo(t){if(Array.isArray(t))throw new ho("",t);var e=t.message||v,r=t.detail||t;switch(!0){case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof po:throw new po(e,r);case t instanceof ho:throw new ho(e,r);case t instanceof go:throw new go(e,r);default:throw new vo(e,r)}}function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!to(e);case"array"===t:return!Wn(e.arg);case!1!==(r=Xn(t)):return!Qn(e,r);default:return!Yn(t)(e.arg)}},So=function(t,e){return nt(t)?!0!==e.optional||nt(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Wn(e))throw new vo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Wn(t))throw new vo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new vo("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!!Rn(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!Rn(t)};function xo(t,e){var r=Fn(e,(function(t,e){return!t[Vn]}));return xr(r,{})?t:function(t,e){var r={};return e=tn(e),ne(t,(function(t,n,o){rn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,tn((function(t){return t.alias===e})),ne)||e}))}function To(t,e){return qn(e,(function(e,r){var n,o;return nt(t[r])||!0===e[Hn]&&Ao(t[r])?Pn({},e,((n={})[Gn]=!0,n)):((o={})[Bn]=t[r],o[Dn]=e[Dn],o[Hn]=e[Hn]||!1,o[Ln]=e[Ln]||!1,o[Kn]=e[Kn]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:qn(Fn(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Fn(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return Wn(t)?t:[t]};var Co=function(t,e){return!Wn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!te(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[Gn])return e[Bn];var n=function(t,e){var r,n=[[t[Bn]],[(r={},r[Dn]=qo(t[Dn]),r[Hn]=t[Hn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new lo(r,n);if(!1!==e[Ln]&&!Co(e[Bn],e[Ln]))throw jo(Ln,e[Ln]),new fo(r);if(!1!==e[Kn]&&!$o(e[Bn],e[Kn]))throw jo(Kn,e[Kn]),new po(r);return e[Bn]}}var zo=function(t,e){return Promise.resolve(Po(t,e))};function Fo(t,e,r,n){return void 0===t&&(t={}),zo(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=qn(r,No(e));return Pn(o,n)}(t,n)})).then((function(t){return Pn({},t,r)}))}function Ro(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Wn(n)&&(a[f]=n),te(o)&&(a[p]=o),ct(i)&&(a[h]=i),a}var Io=Jn,Jo=Wn,Mo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Uo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Ro.apply(null,[t,e,n,o,i,a])},Do=function(t){return function(e,r,n){return void 0===n&&(n={}),Fo(e,r,n,t)}}(Eo),Ho=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=li().key(e);t(pi(r),r)}},remove:function(t){return li().removeItem(t)},clearAll:function(){return li().clear()}};function li(){return si.localStorage}function pi(t){return li().getItem(t)}var hi=Vo.trim,di={name:"cookieStorage",read:function(t){if(!t||!bi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(vi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;vi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:gi,remove:yi,clearAll:function(){gi((function(t,e){yi(e)}))}},vi=Vo.Global.document;function gi(t){for(var e=vi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(hi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function yi(t){t&&bi(t)&&(vi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function bi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(vi.cookie)}var mi=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 _i="expire_mixin",wi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+_i);return{set:function(e,r,n,o){this.hasNamespace(_i)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(_i)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(_i)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ti=[fi,di],Pi=[mi,wi,ki,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=xi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=xi.compress(this._serialize(r));t(e,n)}}}],qi=ai.createStore(Ti,Pi),Ci=Vo.Global;function $i(){return Ci.sessionStorage}function Ni(t){return $i().getItem(t)}var zi=[{name:"sessionStorage",read:Ni,write:function(t,e){return $i().setItem(t,e)},each:function(t){for(var e=$i().length-1;e>=0;e--){var r=$i().key(e);t(Ni(r),r)}},remove:function(t){return $i().removeItem(t)},clearAll:function(){return $i().clear()}},di],Fi=[mi,wi],Ri=ai.createStore(zi,Fi),Ii=qi,Ji=Ri,Mi=Array.isArray,Ui=void 0!==g?g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Di="object"==typeof Ui&&Ui&&Ui.Object===Object&&Ui,Hi="object"==typeof self&&self&&self.Object===Object&&self,Li=(Di||Hi||Function("return this")()).Symbol,Bi=Object.prototype,Ki=Bi.hasOwnProperty,Vi=Bi.toString,Gi=Li?Li.toStringTag:void 0;var Yi=Object.prototype.toString;var Wi="[object Null]",Xi="[object Undefined]",Qi=Li?Li.toStringTag:void 0;function Zi(t){return null==t?void 0===t?Xi:Wi:Qi&&Qi in Object(t)?function(t){var e=Ki.call(t,Gi),r=t[Gi];try{t[Gi]=void 0;var n=!0}catch(t){}var o=Vi.call(t);return n&&(e?t[Gi]=r:delete t[Gi]),o}(t):function(t){return Yi.call(t)}(t)}var ta=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ea(t){return null!=t&&"object"==typeof t}var ra="[object Object]",na=Function.prototype,oa=Object.prototype,ia=na.toString,aa=oa.hasOwnProperty,ua=ia.call(Object);var ca=Li?Li.prototype:void 0,sa=(ca&&ca.toString,"[object String]");function fa(t){return"string"==typeof t||!Mi(t)&&ea(t)&&Zi(t)==sa}var la=function(t,e){return!!t.filter((function(t){return t===e})).length},pa=function(t,e){var r=Object.keys(t);return la(r,e)},ha=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},da="query",va="mutation",ga="socket",ya="payload",ba="condition",ma=function(){try{if(window||document)return!0}catch(t){}return!1},_a=function(){try{if(!ma()&&Ui)return!0}catch(t){}return!1};var wa=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ma()?"browser":_a()?"node":"unknown"},e}(Error));var ja=function(t){var e;return(e={}).args=t,e};var Oa=function(t){return pa(t,"data")&&!pa(t,"error")?t.data:t},Sa=function(t){return function(t){if(!ea(t)||Zi(t)!=ra)return!1;var e=ta(t);if(null===e)return!0;var r=aa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ia.call(r)==ua}(t)&&(pa(t,da)||pa(t,va)||pa(t,ga))},Ea=function(t,e){return void 0===e&&(e={}),Sa(e)?Promise.resolve(e):t.getContract()},ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Aa(t){this.message=t}Aa.prototype=new Error,Aa.prototype.name="InvalidCharacterError";var xa="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Aa("'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=ka.indexOf(n);return a};var Ta=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(xa(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 xa(e)}};function Pa(t){this.message=t}Pa.prototype=new Error,Pa.prototype.name="InvalidTokenError";var qa=function(t,e){if("string"!=typeof t)throw new Pa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ta(t.split(".")[r]))}catch(t){throw new Pa("Invalid token specified: "+t.message)}},Ca=Pa;qa.InvalidTokenError=Ca;var $a,Na,za,Fa,Ra,Ia,Ja,Ma,Ua,Da=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ha(t){if(Io(t))return function(t){var e=t.iat||Da(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new vo("Token has expired on "+r,t)}return t}(qa(t));throw new vo("Token must be a string!")}Uo("HS256",["string"]),Uo(!1,["boolean","number","string"],(($a={})[h]="exp",$a[s]=!0,$a)),Uo(!1,["boolean","number","string"],((Na={})[h]="nbf",Na[s]=!0,Na)),Uo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Uo(!1,["boolean","string"],((Fa={})[h]="sub",Fa[s]=!0,Fa)),Uo(!1,["boolean","string"],((Ra={})[h]="iss",Ra[s]=!0,Ra)),Uo(!1,["boolean"],((Ia={})[s]=!0,Ia)),Uo(!1,["boolean","string"],((Ja={})[s]=!0,Ja)),Uo(!1,["boolean","string"],((Ma={})[s]=!0,Ma)),Uo(!1,["boolean"],((Ua={})[s]=!0,Ua));var La=u[0],Ba=u[1],Ka=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Va={headers:{configurable:!0}};Va.headers.set=function(t){this.extraHeader=t},Ka.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Pn({},{_cb:ha()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Pn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Pn({},{method:La,params:o},e))},Ka.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ka.prototype.processJsonp=function(t){return Oa(t)},Ka.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Io(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Oa(o)}),(function(t){throw e.cleanUp(),console.error(t),new go("Server side error",t)}))},Ka.prototype.getHeaders=function(){return this.opts.enableAuth?Pn({},a,this.getAuthHeader(),this.extraHeader):Pn({},a,this.extraHeader)},Ka.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ka.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Pn({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_o).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ka.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),fa(t)&&Mi(e)){var o=ja(e);return!0===r?o:((n={})[t]=o,n)}throw new wa("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_o)},Ka.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ya]=e,i[ba]=r,!0===n)return i;if(fa(t))return(o={})[t]=i,o;throw new wa("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ba}).then(_o)},Object.defineProperties(Ka.prototype,Va);var Ga=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Jo(t)&&t.length>=2&&Reflect.apply(Ii.set,Ii,t),new ho("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ii.get("endpoint")||[];la(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ii.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!la(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ha();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ii.set,Ii,e)},r.jsonqlEndpoint.get=function(){var t=Ii.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ii.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ji.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ha)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Sa(t))throw new ho("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Sa(this.opts.contract)?this.opts.contract:Ii.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ka))),Ya=function(t){return j(t)?t:[t]},Wa=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Ya(t))}),Reflect.apply(t,null,r))}};function Xa(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Qa=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 Mo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(wo)}},Za=function(t,e,r,n,o){var i={},a=function(t){i=Xa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Mo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(wo)}))};for(var u in o.query)a(u);return t.query=i,[t,e,r,n,o]},tu=function(t,e,r,n,o){var i={},a=function(t){i=Xa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Mo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(wo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},eu=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=Qa(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qa(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var ru=function(t,e,r,n){var o=function(t,e,r,n){return Wa(Za,tu,eu)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.0",o},nu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ou={hostname:Uo([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Uo("jsonql",["string"]),loginHandlerName:Uo("login",["string"]),logoutHandlerName:Uo("logout",["string"]),enableJsonp:Uo(!1,["boolean"]),enableAuth:Uo(!1,["boolean"]),useJwt:Uo(!0,["boolean"]),useLocalstorage:Uo(!0,["boolean"]),storageKey:Uo("storageKey",["string"]),authKey:Uo("authKey",["string"]),contractExpired:Uo(0,["number"]),keepContract:Uo(!0,["boolean"]),exposeContract:Uo(!1,["boolean"]),showContractDesc:Uo(!1,["boolean"]),contractKey:Uo(!1,["boolean"]),contractKeyName:Uo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Uo(!1,["boolean"]),timeout:Uo(5e3,["number"]),returnInstance:Uo(!1,["boolean"]),allowReturnRawToken:Uo(!1,["boolean"]),debugOn:Uo(!1,["boolean"])};function iu(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),function(t){var e=t.contract;return Do(t,ou,nu).then((function(t){return t.contract=e,t}))}(e).then((function(t){return{baseClient:new Ga(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Ea(r,n.contract).then((function(e){return ru(r,n,e,t)}))}))}var au=new WeakMap,uu=new WeakMap;var cu=function(){this.__suspend__=null,this.queueStore=new Set},su={$suspend:{configurable:!0},$queues:{configurable:!0}};su.$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)},cu.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__},su.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},cu.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(cu.prototype,su);var fu=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){au.set(this,t)},r.normalStore.get=function(){return au.get(this)},r.lazyStore.set=function(t){uu.set(this,t)},r.lazyStore.get=function(){return uu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(cu));function lu(t,e){var r;return iu((r=e.debugOn,new fu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),lu(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d={desc:"y"},v="No message";var g="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},y="object"==typeof g&&g&&g.Object===Object&&g,b="object"==typeof self&&self&&self.Object===Object&&self,m=y||b||Function("return this")(),_=m.Symbol;function w(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--&&U(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function nt(t){return void 0===t}var ot="[object Boolean]";var it="[object Number]";function at(t){return function(t){return"number"==typeof t||C(t)&&q(t)==it}(t)&&t!=+t}var ut="[object String]";function ct(t){return"string"==typeof t||!j(t)&&C(t)&&q(t)==ut}function st(t,e){return function(r){return t(e(r))}}var ft=st(Object.getPrototypeOf,Object),lt="[object Object]",pt=Function.prototype,ht=Object.prototype,dt=pt.toString,vt=ht.hasOwnProperty,gt=dt.call(Object);function yt(t){if(!C(t)||q(t)!=lt)return!1;var e=ft(t);if(null===e)return!0;var r=vt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&dt.call(r)==gt}var bt,mt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[bt?a:++n];if(!1===e(o[u],u,o))break}return t};var _t="[object Arguments]";function wt(t){return C(t)&&q(t)==_t}var jt=Object.prototype,Ot=jt.hasOwnProperty,St=jt.propertyIsEnumerable,Et=wt(function(){return arguments}())?wt:function(t){return C(t)&&Ot.call(t,"callee")&&!St.call(t,"callee")};var kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,At=kt&&"object"==typeof module&&module&&!module.nodeType&&module,xt=At&&At.exports===kt?m.Buffer:void 0,Tt=(xt?xt.isBuffer:void 0)||function(){return!1},Pt=9007199254740991,qt=/^(?:0|[1-9]\d*)$/;function Ct(t,e){var r=typeof t;return!!(e=null==e?Pt:e)&&("number"==r||"symbol"!=r&&qt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=$t}var zt={};zt["[object Float32Array]"]=zt["[object Float64Array]"]=zt["[object Int8Array]"]=zt["[object Int16Array]"]=zt["[object Int32Array]"]=zt["[object Uint8Array]"]=zt["[object Uint8ClampedArray]"]=zt["[object Uint16Array]"]=zt["[object Uint32Array]"]=!0,zt["[object Arguments]"]=zt["[object Array]"]=zt["[object ArrayBuffer]"]=zt["[object Boolean]"]=zt["[object DataView]"]=zt["[object Date]"]=zt["[object Error]"]=zt["[object Function]"]=zt["[object Map]"]=zt["[object Number]"]=zt["[object Object]"]=zt["[object RegExp]"]=zt["[object Set]"]=zt["[object String]"]=zt["[object WeakMap]"]=!1;var Ft,Rt="object"==typeof exports&&exports&&!exports.nodeType&&exports,It=Rt&&"object"==typeof module&&module&&!module.nodeType&&module,Jt=It&&It.exports===Rt&&y.process,Mt=function(){try{var t=It&&It.require&&It.require("util").types;return t||Jt&&Jt.binding&&Jt.binding("util")}catch(t){}}(),Ut=Mt&&Mt.isTypedArray,Dt=Ut?(Ft=Ut,function(t){return Ft(t)}):function(t){return C(t)&&Nt(t.length)&&!!zt[q(t)]},Ht=Object.prototype.hasOwnProperty;function Lt(t,e){var r=j(t),n=!r&&Et(t),o=!r&&!n&&Tt(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},ue.prototype.set=function(t,e){var r=this.__data__,n=ie(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ce,se=m["__core-js_shared__"],fe=(ce=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||""))?"Symbol(src)_1."+ce:"";var le=Function.prototype.toString;function pe(t){if(null!=t){try{return le.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var he=/^\[object .+?Constructor\]$/,de=Function.prototype,ve=Object.prototype,ge=de.toString,ye=ve.hasOwnProperty,be=RegExp("^"+ge.call(ye).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function me(t){return!(!Wt(t)||function(t){return!!fe&&fe in t}(t))&&(te(t)?be:he).test(pe(t))}function _e(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return me(r)?r:void 0}var we=_e(m,"Map"),je=_e(Object,"create");var Oe="__lodash_hash_undefined__",Se=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;var ke="__lodash_hash_undefined__";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=r&Fe?new $e:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Sn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(On);function xn(t,e){return An(function(t,e,r){return e=jn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=jn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Tn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Wt(r))return!1;var n=typeof e;return!!("number"==n?ee(r)&&Ct(e,r.length):"string"==n&&e in r)&&oe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Xn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Qn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Wn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Yn(r,t)})).length},Zn=function(t,e){if(void 0===e&&(e=null),yt(t)){if(!e)return!0;if(Yn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!nt(r)||(!1!==(e=Xn(t))?!Qn({arg:r},e):!Wn(t)(r))})).length)})).length}return!1},to=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Zn.apply(null,n)},eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ao=function(){try{if(window||document)return!0}catch(t){}return!1},uo=function(){try{if(!ao()&&g)return!0}catch(t){}return!1};var co=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ao()?"browser":uo()?"node":"unknown"},e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.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}(co),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ho=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(co),vo=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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(co),go=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),yo=Object.freeze({__proto__:null,Jsonql406Error:eo,Jsonql500Error:ro,JsonqlAuthorisationError:no,JsonqlContractAuthError:oo,JsonqlResolverAppError:io,JsonqlResolverNotFoundError:so,JsonqlEnumError:fo,JsonqlTypeError:lo,JsonqlCheckerError:po,JsonqlValidationError:ho,JsonqlError:vo,JsonqlServerError:go}),bo=vo,mo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function _o(t){if(mo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||v,a=e.detail||e;if(o&&yo[o])throw new yo[r](i,a);throw new bo(i,a)}return t}function wo(t){if(Array.isArray(t))throw new ho("",t);var e=t.message||v,r=t.detail||t;switch(!0){case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof po:throw new po(e,r);case t instanceof ho:throw new ho(e,r);case t instanceof go:throw new go(e,r);default:throw new vo(e,r)}}function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!to(e);case"array"===t:return!Yn(e.arg);case!1!==(r=Xn(t)):return!Qn(e,r);default:return!Wn(t)(e.arg)}},So=function(t,e){return nt(t)?!0!==e.optional||nt(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Yn(e))throw new vo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Yn(t))throw new vo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new vo("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!!Rn(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!Rn(t)};function xo(t,e){var r=Fn(e,(function(t,e){return!t[Vn]}));return xr(r,{})?t:function(t,e){var r={};return e=tn(e),ne(t,(function(t,n,o){rn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,tn((function(t){return t.alias===e})),ne)||e}))}function To(t,e){return qn(e,(function(e,r){var n,o;return nt(t[r])||!0===e[Hn]&&Ao(t[r])?Pn({},e,((n={})[Gn]=!0,n)):((o={})[Bn]=t[r],o[Dn]=e[Dn],o[Hn]=e[Hn]||!1,o[Ln]=e[Ln]||!1,o[Kn]=e[Kn]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:qn(Fn(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Fn(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return Yn(t)?t:[t]};var Co=function(t,e){return!Yn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!te(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[Gn])return e[Bn];var n=function(t,e){var r,n=[[t[Bn]],[(r={},r[Dn]=qo(t[Dn]),r[Hn]=t[Hn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new lo(r,n);if(!1!==e[Ln]&&!Co(e[Bn],e[Ln]))throw jo(Ln,e[Ln]),new fo(r);if(!1!==e[Kn]&&!$o(e[Bn],e[Kn]))throw jo(Kn,e[Kn]),new po(r);return e[Bn]}}var zo=function(t,e){return Promise.resolve(Po(t,e))};function Fo(t,e,r,n){return void 0===t&&(t={}),zo(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=qn(r,No(e));return Pn(o,n)}(t,n)})).then((function(t){return Pn({},t,r)}))}function Ro(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Yn(n)&&(a[f]=n),te(o)&&(a[p]=o),ct(i)&&(a[h]=i),a}var Io=Jn,Jo=Yn,Mo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Uo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Ro.apply(null,[t,e,n,o,i,a])},Do=function(t){return function(e,r,n){return void 0===n&&(n={}),Fo(e,r,n,t)}}(Eo),Ho=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=li().key(e);t(pi(r),r)}},remove:function(t){return li().removeItem(t)},clearAll:function(){return li().clear()}};function li(){return si.localStorage}function pi(t){return li().getItem(t)}var hi=Vo.trim,di={name:"cookieStorage",read:function(t){if(!t||!bi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(vi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;vi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:gi,remove:yi,clearAll:function(){gi((function(t,e){yi(e)}))}},vi=Vo.Global.document;function gi(t){for(var e=vi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(hi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function yi(t){t&&bi(t)&&(vi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function bi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(vi.cookie)}var mi=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 _i="expire_mixin",wi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+_i);return{set:function(e,r,n,o){this.hasNamespace(_i)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(_i)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(_i)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ti=[fi,di],Pi=[mi,wi,ki,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=xi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=xi.compress(this._serialize(r));t(e,n)}}}],qi=ai.createStore(Ti,Pi),Ci=Vo.Global;function $i(){return Ci.sessionStorage}function Ni(t){return $i().getItem(t)}var zi=[{name:"sessionStorage",read:Ni,write:function(t,e){return $i().setItem(t,e)},each:function(t){for(var e=$i().length-1;e>=0;e--){var r=$i().key(e);t(Ni(r),r)}},remove:function(t){return $i().removeItem(t)},clearAll:function(){return $i().clear()}},di],Fi=[mi,wi],Ri=ai.createStore(zi,Fi),Ii=qi,Ji=Ri,Mi=Array.isArray,Ui=void 0!==g?g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Di="object"==typeof Ui&&Ui&&Ui.Object===Object&&Ui,Hi="object"==typeof self&&self&&self.Object===Object&&self,Li=(Di||Hi||Function("return this")()).Symbol,Bi=Object.prototype,Ki=Bi.hasOwnProperty,Vi=Bi.toString,Gi=Li?Li.toStringTag:void 0;var Wi=Object.prototype.toString;var Yi="[object Null]",Xi="[object Undefined]",Qi=Li?Li.toStringTag:void 0;function Zi(t){return null==t?void 0===t?Xi:Yi:Qi&&Qi in Object(t)?function(t){var e=Ki.call(t,Gi),r=t[Gi];try{t[Gi]=void 0;var n=!0}catch(t){}var o=Vi.call(t);return n&&(e?t[Gi]=r:delete t[Gi]),o}(t):function(t){return Wi.call(t)}(t)}var ta=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ea(t){return null!=t&&"object"==typeof t}var ra="[object Object]",na=Function.prototype,oa=Object.prototype,ia=na.toString,aa=oa.hasOwnProperty,ua=ia.call(Object);var ca=Li?Li.prototype:void 0,sa=(ca&&ca.toString,"[object String]");function fa(t){return"string"==typeof t||!Mi(t)&&ea(t)&&Zi(t)==sa}var la=function(t,e){return!!t.filter((function(t){return t===e})).length},pa=function(t,e){var r=Object.keys(t);return la(r,e)},ha=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},da="query",va="mutation",ga="socket",ya="payload",ba="condition",ma=function(){try{if(window||document)return!0}catch(t){}return!1},_a=function(){try{if(!ma()&&Ui)return!0}catch(t){}return!1};var wa=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ma()?"browser":_a()?"node":"unknown"},e}(Error));var ja=function(t){var e;return(e={}).args=t,e};var Oa=function(t){return pa(t,"data")&&!pa(t,"error")?t.data:t},Sa=function(t){return function(t){if(!ea(t)||Zi(t)!=ra)return!1;var e=ta(t);if(null===e)return!0;var r=aa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ia.call(r)==ua}(t)&&(pa(t,da)||pa(t,va)||pa(t,ga))},Ea=function(t,e){return void 0===e&&(e={}),Sa(e)?Promise.resolve(e):t.getContract()},ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Aa(t){this.message=t}Aa.prototype=new Error,Aa.prototype.name="InvalidCharacterError";var xa="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Aa("'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=ka.indexOf(n);return a};var Ta=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(xa(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 xa(e)}};function Pa(t){this.message=t}Pa.prototype=new Error,Pa.prototype.name="InvalidTokenError";var qa=function(t,e){if("string"!=typeof t)throw new Pa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ta(t.split(".")[r]))}catch(t){throw new Pa("Invalid token specified: "+t.message)}},Ca=Pa;qa.InvalidTokenError=Ca;var $a,Na,za,Fa,Ra,Ia,Ja,Ma,Ua,Da=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ha(t){if(Io(t))return function(t){var e=t.iat||Da(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new vo("Token has expired on "+r,t)}return t}(qa(t));throw new vo("Token must be a string!")}Uo("HS256",["string"]),Uo(!1,["boolean","number","string"],(($a={})[h]="exp",$a[s]=!0,$a)),Uo(!1,["boolean","number","string"],((Na={})[h]="nbf",Na[s]=!0,Na)),Uo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Uo(!1,["boolean","string"],((Fa={})[h]="sub",Fa[s]=!0,Fa)),Uo(!1,["boolean","string"],((Ra={})[h]="iss",Ra[s]=!0,Ra)),Uo(!1,["boolean"],((Ia={})[s]=!0,Ia)),Uo(!1,["boolean","string"],((Ja={})[s]=!0,Ja)),Uo(!1,["boolean","string"],((Ma={})[s]=!0,Ma)),Uo(!1,["boolean"],((Ua={})[s]=!0,Ua));var La=u[0],Ba=u[1],Ka=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Va={headers:{configurable:!0}};Va.headers.set=function(t){this.extraHeader=t},Ka.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Pn({},{_cb:ha()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Pn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Pn({},{method:La,params:o},e))},Ka.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ka.prototype.processJsonp=function(t){return Oa(t)},Ka.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Io(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Oa(o)}),(function(t){throw e.cleanUp(),console.error(t),new go("Server side error",t)}))},Ka.prototype.getHeaders=function(){return this.opts.enableAuth?Pn({},a,this.getAuthHeader(),this.extraHeader):Pn({},a,this.extraHeader)},Ka.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ka.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Pn({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_o).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ka.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),fa(t)&&Mi(e)){var o=ja(e);return!0===r?o:((n={})[t]=o,n)}throw new wa("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_o)},Ka.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ya]=e,i[ba]=r,!0===n)return i;if(fa(t))return(o={})[t]=i,o;throw new wa("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ba}).then(_o)},Object.defineProperties(Ka.prototype,Va);var Ga=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Jo(t)&&t.length>=2&&Reflect.apply(Ii.set,Ii,t),new ho("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ii.get("endpoint")||[];la(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ii.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!la(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ha();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ii.set,Ii,e)},r.jsonqlEndpoint.get=function(){var t=Ii.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ii.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ji.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ha)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Sa(t))throw new ho("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Sa(this.opts.contract)?this.opts.contract:Ii.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ka))),Wa=function(t){return j(t)?t:[t]},Ya=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Wa(t))}),Reflect.apply(t,null,r))}};function Xa(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Qa=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 Mo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(wo)}},Za=function(t,e,r,n,o){var i={},a=function(t){i=Xa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Mo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(wo)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},tu=function(t,e,r,n,o){var i={},a=function(t){i=Xa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Mo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(wo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},eu=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=Qa(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qa(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var ru=function(t,e,r,n){var o=function(t,e,r,n){return Ya(Za,tu,eu)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.2",o},nu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ou={hostname:Uo([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Uo("jsonql",["string"]),loginHandlerName:Uo("login",["string"]),logoutHandlerName:Uo("logout",["string"]),enableJsonp:Uo(!1,["boolean"]),enableAuth:Uo(!1,["boolean"]),useJwt:Uo(!0,["boolean"]),useLocalstorage:Uo(!0,["boolean"]),storageKey:Uo("storageKey",["string"]),authKey:Uo("authKey",["string"]),contractExpired:Uo(0,["number"]),keepContract:Uo(!0,["boolean"]),exposeContract:Uo(!1,["boolean"]),showContractDesc:Uo(!1,["boolean"]),contractKey:Uo(!1,["boolean"]),contractKeyName:Uo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Uo(!1,["boolean"]),timeout:Uo(5e3,["number"]),returnInstance:Uo(!1,["boolean"]),allowReturnRawToken:Uo(!1,["boolean"]),debugOn:Uo(!1,["boolean"])};function iu(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),function(t){var e=t.contract;return Do(t,ou,nu).then((function(t){return t.contract=e,t}))}(e).then((function(t){return{baseClient:new Ga(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Ea(r,n.contract).then((function(e){return ru(r,n,e,t)}))}))}var au=new WeakMap,uu=new WeakMap;var cu=function(){this.__suspend__=null,this.queueStore=new Set},su={$suspend:{configurable:!0},$queues:{configurable:!0}};su.$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)},cu.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__},su.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},cu.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(cu.prototype,su);var fu=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){au.set(this,t)},r.normalStore.get=function(){return au.get(this)},r.lazyStore.set=function(t){uu.set(this,t)},r.lazyStore.get=function(){return uu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(cu));function lu(t,e){var r;return iu((r=e.debugOn,new fu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),lu(o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/package.json b/packages/http-client/package.json index e02fa970d51a8127dc0330f2501d3afa46a87b4c..db13cc70cec6ba956347f96b693062fc60827b1a 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.4.1", + "version": "1.4.2", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js", diff --git a/packages/http-client/src/core/methods-generator.js b/packages/http-client/src/core/methods-generator.js index 4bfe27311a62d6f8f87c798c037b632e974f4995..89257a10cb652aadeb0df2bc8ede23462e728dc3 100644 --- a/packages/http-client/src/core/methods-generator.js +++ b/packages/http-client/src/core/methods-generator.js @@ -64,6 +64,8 @@ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { }) } obj.query = query; + // create an alias to the helloWorld method + obj.helloWorld = query.helloWorld; return [ obj, jsonqlInstance, ee, config, contract ] } diff --git a/packages/http-client/static.js b/packages/http-client/static.js index 26c426d339a0ac05869b284598081012ef83efdd..dc44c0922ca3536c8ea508d8198bdc3e5c5b5285 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s={desc:"y"},f="No message",l="onResult",p="onError",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={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),d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),b="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m=function(){try{if(window||document)return!0}catch(t){}return!1},_=function(){try{if(!m()&&b)return!0}catch(t){}return!1};var w=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return m()?"browser":_()?"node":"unknown"},e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.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}(w),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},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"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(w),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(w),T=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),x=Object.freeze({__proto__:null,Jsonql406Error:h,Jsonql500Error:d,JsonqlAuthorisationError:v,JsonqlContractAuthError:g,JsonqlResolverAppError:y,JsonqlResolverNotFoundError:j,JsonqlEnumError:O,JsonqlTypeError:S,JsonqlCheckerError:E,JsonqlValidationError:A,JsonqlError:k,JsonqlServerError:T}),q=k,P=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function C(t){if(P(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||f,a=e.detail||e;if(o&&x[o])throw new x[r](i,a);throw new q(i,a)}return t}function $(t){if(Array.isArray(t))throw new A("",t);var e=t.message||f,r=t.detail||t;switch(!0){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 g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof A:throw new A(e,r);case t instanceof T:throw new T(e,r);default:throw new k(e,r)}}var N="object"==typeof b&&b&&b.Object===Object&&b,z="object"==typeof self&&self&&self.Object===Object&&self,F=N||z||Function("return this")(),I=F.Symbol;function R(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--&&ot(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function _t(t){return void 0===t}var wt="[object Boolean]";var jt="[object Number]";function Ot(t){return function(t){return"number"==typeof t||Y(t)&&G(t)==jt}(t)&&t!=+t}var St="[object String]";function Et(t){return"string"==typeof t||!J(t)&&Y(t)&&G(t)==St}function At(t,e){return function(r){return t(e(r))}}var kt=At(Object.getPrototypeOf,Object),Tt="[object Object]",xt=Function.prototype,qt=Object.prototype,Pt=xt.toString,Ct=qt.hasOwnProperty,$t=Pt.call(Object);function Nt(t){if(!Y(t)||G(t)!=Tt)return!1;var e=kt(t);if(null===e)return!0;var r=Ct.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Pt.call(r)==$t}var zt,Ft=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[zt?a:++n];if(!1===e(o[u],u,o))break}return t};var It="[object Arguments]";function Rt(t){return Y(t)&&G(t)==It}var Jt=Object.prototype,Mt=Jt.hasOwnProperty,Ut=Jt.propertyIsEnumerable,Dt=Rt(function(){return arguments}())?Rt:function(t){return Y(t)&&Mt.call(t,"callee")&&!Ut.call(t,"callee")};var Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Lt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Bt=Lt&&Lt.exports===Ht?F.Buffer:void 0,Kt=(Bt?Bt.isBuffer:void 0)||function(){return!1},Vt=9007199254740991,Gt=/^(?:0|[1-9]\d*)$/;function Yt(t,e){var r=typeof t;return!!(e=null==e?Vt:e)&&("number"==r||"symbol"!=r&&Gt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Wt}var Xt={};Xt["[object Float32Array]"]=Xt["[object Float64Array]"]=Xt["[object Int8Array]"]=Xt["[object Int16Array]"]=Xt["[object Int32Array]"]=Xt["[object Uint8Array]"]=Xt["[object Uint8ClampedArray]"]=Xt["[object Uint16Array]"]=Xt["[object Uint32Array]"]=!0,Xt["[object Arguments]"]=Xt["[object Array]"]=Xt["[object ArrayBuffer]"]=Xt["[object Boolean]"]=Xt["[object DataView]"]=Xt["[object Date]"]=Xt["[object Error]"]=Xt["[object Function]"]=Xt["[object Map]"]=Xt["[object Number]"]=Xt["[object Object]"]=Xt["[object RegExp]"]=Xt["[object Set]"]=Xt["[object String]"]=Xt["[object WeakMap]"]=!1;var Zt,te="object"==typeof exports&&exports&&!exports.nodeType&&exports,ee=te&&"object"==typeof module&&module&&!module.nodeType&&module,re=ee&&ee.exports===te&&N.process,ne=function(){try{var t=ee&&ee.require&&ee.require("util").types;return t||re&&re.binding&&re.binding("util")}catch(t){}}(),oe=ne&&ne.isTypedArray,ie=oe?(Zt=oe,function(t){return Zt(t)}):function(t){return Y(t)&&Qt(t.length)&&!!Xt[G(t)]},ae=Object.prototype.hasOwnProperty;function ue(t,e){var r=J(t),n=!r&&Dt(t),o=!r&&!n&&Kt(t),i=!r&&!n&&!o&&ie(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Se.prototype.set=function(t,e){var r=this.__data__,n=je(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ee,Ae=F["__core-js_shared__"],ke=(Ee=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||""))?"Symbol(src)_1."+Ee:"";var Te=Function.prototype.toString;function xe(t){if(null!=t){try{return Te.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var qe=/^\[object .+?Constructor\]$/,Pe=Function.prototype,Ce=Object.prototype,$e=Pe.toString,Ne=Ce.hasOwnProperty,ze=RegExp("^"+$e.call(Ne).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fe(t){return!(!pe(t)||function(t){return!!ke&&ke in t}(t))&&(ye(t)?ze:qe).test(xe(t))}function Ie(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Fe(r)?r:void 0}var Re=Ie(F,"Map"),Je=Ie(Object,"create");var Me="__lodash_hash_undefined__",Ue=Object.prototype.hasOwnProperty;var De=Object.prototype.hasOwnProperty;var He="__lodash_hash_undefined__";function Le(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ze?new We:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Un)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Mn);function Bn(t,e){return Ln(function(t,e,r){return e=Jn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Jn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Kn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!pe(r))return!1;var n=typeof e;return!!("number"==n?be(r)&&Yt(e,r.length):"string"==n&&e in r)&&we(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},vo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},go=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!po(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ho(r,t)})).length},yo=function(t,e){if(void 0===e&&(e=null),Nt(t)){if(!e)return!0;if(ho(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!_t(r)||(!1!==(e=vo(t))?!go({arg:r},e):!po(t)(r))})).length)})).length}return!1},bo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),yo.apply(null,n)};function mo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var _o=function(t,e){var r;switch(!0){case"object"===t:return!bo(e);case"array"===t:return!ho(e.arg);case!1!==(r=vo(t)):return!go(e,r);default:return!po(t)(e.arg)}},wo=function(t,e){return _t(t)?!0!==e.optional||_t(e.defaultvalue)?null:e.defaultvalue:t},jo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ho(e))throw new k("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ho(t))throw new k("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 mo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:mo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:mo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?wo(t,a):t,index:r,param:a,optional:i}}));default:throw mo(5),new k("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!!to(e)&&!(r.type.length>r.type.filter((function(e){return _o(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return _o(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Oo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},So=function(t){return!to(t)};function Eo(t,e){var r=Zn(e,(function(t,e){return!t[fo]}));return Br(r,{})?t:function(t,e){var r={};return e=bn(e),_e(t,(function(t,n,o){_n(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,bn((function(t){return t.alias===e})),_e)||e}))}function Ao(t,e){return Gn(e,(function(e,r){var n,o;return _t(t[r])||!0===e[ao]&&So(t[r])?Vn({},e,((n={})[lo]=!0,n)):((o={})[co]=t[r],o[io]=e[io],o[ao]=e[ao]||!1,o[uo]=e[uo]||!1,o[so]=e[so]||!1,o)}))}function ko(t,e){var r=function(t,e){var r=Eo(t,e);return{pristineValues:Gn(Zn(e,(function(t,e){return Oo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Zn(e,(function(t,e){return!Oo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return ho(t)?t:[t]};var xo=function(t,e){return!ho(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ye(e)&&e.apply(null,[t])}catch(t){return!1}};function Po(t){return function(e,r){if(e[lo])return e[co];var n=function(t,e){var r,n=[[t[co]],[(r={},r[io]=To(t[io]),r[ao]=t[ao],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw mo("runValidationAction",r,e),new S(r,n);if(!1!==e[uo]&&!xo(e[co],e[uo]))throw mo(uo,e[uo]),new O(r);if(!1!==e[so]&&!qo(e[co],e[so]))throw mo(so,e[so]),new E(r);return e[co]}}function Co(t,e,r,n){return void 0===t&&(t={}),Vn(function(t,e){var r=t[0],n=t[1],o=Gn(r,Po(e));return Vn(o,n)}(ko(t,e),n),r)}function $o(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),ho(s)&&(p[i]=s),ye(f)&&(p[u]=f),Et(l)&&(p[c]=l),p}var No=ro,zo=ho,Fo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=jo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Io=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return $o.apply(null,[t,e,n,a,s,f])},Ro=function(t){return function(e,r,n){return void 0===n&&(n={}),Co(e,r,n,t)}}(jo),Jo=function(t){return J(t)?t:[t]},Mo=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Jo(t))}),Reflect.apply(t,null,r))}};function Uo(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Do=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 Fo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch($)}},Ho=function(t,e,r,n,o){var i={},a=function(t){i=Uo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Fo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch($)}))};for(var u in o.query)a(u);return t.query=i,[t,e,r,n,o]},Lo=function(t,e,r,n,o){var i={},a=function(t){i=Uo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Fo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch($)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Bo=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=Do(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Do(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ko=Array.isArray,Vo=void 0!==b?b:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Go="object"==typeof Vo&&Vo&&Vo.Object===Object&&Vo,Yo="object"==typeof self&&self&&self.Object===Object&&self,Wo=(Go||Yo||Function("return this")()).Symbol,Qo=Object.prototype,Xo=Qo.hasOwnProperty,Zo=Qo.toString,ti=Wo?Wo.toStringTag:void 0;var ei=Object.prototype.toString;var ri="[object Null]",ni="[object Undefined]",oi=Wo?Wo.toStringTag:void 0;function ii(t){return null==t?void 0===t?ni:ri:oi&&oi in Object(t)?function(t){var e=Xo.call(t,ti),r=t[ti];try{t[ti]=void 0;var n=!0}catch(t){}var o=Zo.call(t);return n&&(e?t[ti]=r:delete t[ti]),o}(t):function(t){return ei.call(t)}(t)}var ai=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ui(t){return null!=t&&"object"==typeof t}var ci="[object Object]",si=Function.prototype,fi=Object.prototype,li=si.toString,pi=fi.hasOwnProperty,hi=li.call(Object);var di=Wo?Wo.prototype:void 0,vi=(di&&di.toString,"[object String]");function gi(t){return"string"==typeof t||!Ko(t)&&ui(t)&&ii(t)==vi}var yi=function(t,e){return!!t.filter((function(t){return t===e})).length},bi=function(t,e){var r=Object.keys(t);return yi(r,e)},mi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},_i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},wi="query",ji="mutation",Oi="socket",Si="payload",Ei="condition",Ai=function(){try{if(window||document)return!0}catch(t){}return!1},ki=function(){try{if(!Ai()&&Vo)return!0}catch(t){}return!1};var Ti=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ai()?"browser":ki()?"node":"unknown"},e}(Error));var xi=function(t){var e;return(e={}).args=t,e};var qi=function(t){return bi(t,"data")&&!bi(t,"error")?t.data:t},Pi=function(t){return function(t){if(!ui(t)||ii(t)!=ci)return!1;var e=ai(t);if(null===e)return!0;var r=pi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&li.call(r)==hi}(t)&&(bi(t,wi)||bi(t,ji)||bi(t,Oi))},Ci=function(t,e){return void 0===e&&(e={}),Pi(e)?Promise.resolve(e):t.getContract()},$i=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(mi(e,r,l),o),t.$only(mi(e,r,p),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ni=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function zi(t,e,r,n){var o=function(t,e,r,n){return Mo(Ho,Lo,Bo)({},t,e,r,n)}(t,e,r,n);Ni(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(mi(t,n,l),r)})).catch((function(r){e.$trigger(mi(t,n,p),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Fi=function(t,e,r,n){n.$suspend=!0,r.then((function(r){zi(t,n,e,r)}));var o={query:$i(n,"query"),mutation:$i(n,"mutation"),auth:$i(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.0",o},Ii="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Ri=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=aa().key(e);t(ua(r),r)}},remove:function(t){return aa().removeItem(t)},clearAll:function(){return aa().clear()}};function aa(){return oa.localStorage}function ua(t){return aa().getItem(t)}var ca=Di.trim,sa={name:"cookieStorage",read:function(t){if(!t||!ha(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(fa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;fa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:la,remove:pa,clearAll:function(){la((function(t,e){pa(e)}))}},fa=Di.Global.document;function la(t){for(var e=fa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ca(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function pa(t){t&&ha(t)&&(fa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ha(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(fa.cookie)}var da=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 va="expire_mixin",ga=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+va);return{set:function(e,r,n,o){this.hasNamespace(va)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(va)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(va)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Sa=[ia,sa],Ea=[da,ga,wa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Oa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Oa.compress(this._serialize(r));t(e,n)}}}],Aa=ea.createStore(Sa,Ea),ka=Di.Global;function Ta(){return ka.sessionStorage}function xa(t){return Ta().getItem(t)}var qa=[{name:"sessionStorage",read:xa,write:function(t,e){return Ta().setItem(t,e)},each:function(t){for(var e=Ta().length-1;e>=0;e--){var r=Ta().key(e);t(xa(r),r)}},remove:function(t){return Ta().removeItem(t)},clearAll:function(){return Ta().clear()}},sa],Pa=[da,ga],Ca=ea.createStore(qa,Pa),$a=Aa,Na=Ca,za="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Fa(t){this.message=t}Fa.prototype=new Error,Fa.prototype.name="InvalidCharacterError";var Ia="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Fa("'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=za.indexOf(n);return a};var Ra=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(Ia(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 Ia(e)}};function Ja(t){this.message=t}Ja.prototype=new Error,Ja.prototype.name="InvalidTokenError";var Ma=function(t,e){if("string"!=typeof t)throw new Ja("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ra(t.split(".")[r]))}catch(t){throw new Ja("Invalid token specified: "+t.message)}},Ua=Ja;Ma.InvalidTokenError=Ua;var Da,Ha,La,Ba,Ka,Va,Ga,Ya,Wa,Qa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Xa(t){if(No(t))return function(t){var e=t.iat||Qa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new k("Token has expired on "+r,t)}return t}(Ma(t));throw new k("Token must be a string!")}Io("HS256",["string"]),Io(!1,["boolean","number","string"],((Da={})[c]="exp",Da[o]=!0,Da)),Io(!1,["boolean","number","string"],((Ha={})[c]="nbf",Ha[o]=!0,Ha)),Io(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),Io(!1,["boolean","string"],((Ba={})[c]="sub",Ba[o]=!0,Ba)),Io(!1,["boolean","string"],((Ka={})[c]="iss",Ka[o]=!0,Ka)),Io(!1,["boolean"],((Va={})[o]=!0,Va)),Io(!1,["boolean","string"],((Ga={})[o]=!0,Ga)),Io(!1,["boolean","string"],((Ya={})[o]=!0,Ya)),Io(!1,["boolean"],((Wa={})[o]=!0,Wa));var Za=r[0],tu=r[1],eu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ru={headers:{configurable:!0}};ru.headers.set=function(t){this.extraHeader=t},eu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Vn({},{_cb:_i()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Vn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Vn({},{method:Za,params:o},e))},eu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},eu.prototype.processJsonp=function(t){return qi(t)},eu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=No(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):qi(o)}),(function(t){throw e.cleanUp(),console.error(t),new T("Server side error",t)}))},eu.prototype.getHeaders=function(){return this.opts.enableAuth?Vn({},e,this.getAuthHeader(),this.extraHeader):Vn({},e,this.extraHeader)},eu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},eu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Vn({},this.extraParams,s)),this.request({},{method:"GET"},this.contractHeader).then(C).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},eu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),gi(t)&&Ko(e)){var o=xi(e);return!0===r?o:((n={})[t]=o,n)}throw new Ti("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(C)},eu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Si]=e,i[Ei]=r,!0===n)return i;if(gi(t))return(o={})[t]=i,o;throw new Ti("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:tu}).then(C)},Object.defineProperties(eu.prototype,ru);var nu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),zo(t)&&t.length>=2&&Reflect.apply($a.set,$a,t),new A("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=$a.get("endpoint")||[];yi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=$a.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!yi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=_i();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply($a.set,$a,e)},r.jsonqlEndpoint.get=function(){var t=$a.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return($a.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Na.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Xa)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Pi(t))throw new A("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Pi(this.opts.contract)?this.opts.contract:$a.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(eu))),ou={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},iu={hostname:Io([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Io("jsonql",["string"]),loginHandlerName:Io("login",["string"]),logoutHandlerName:Io("logout",["string"]),enableJsonp:Io(!1,["boolean"]),enableAuth:Io(!1,["boolean"]),useJwt:Io(!0,["boolean"]),useLocalstorage:Io(!0,["boolean"]),storageKey:Io("storageKey",["string"]),authKey:Io("authKey",["string"]),contractExpired:Io(0,["number"]),keepContract:Io(!0,["boolean"]),exposeContract:Io(!1,["boolean"]),showContractDesc:Io(!1,["boolean"]),contractKey:Io(!1,["boolean"]),contractKeyName:Io("X-JSONQL-CV-KEY",["string"]),enableTimeout:Io(!1,["boolean"]),timeout:Io(5e3,["number"]),returnInstance:Io(!1,["boolean"]),allowReturnRawToken:Io(!1,["boolean"]),debugOn:Io(!1,["boolean"])};var au=new WeakMap,uu=new WeakMap;var cu=function(){this.__suspend__=null,this.queueStore=new Set},su={$suspend:{configurable:!0},$queues:{configurable:!0}};su.$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)},cu.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__},su.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},cu.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(cu.prototype,su);var fu=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){au.set(this,t)},r.normalStore.get=function(){return au.get(this)},r.lazyStore.set=function(t){uu.set(this,t)},r.lazyStore.get=function(){return uu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(cu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=function(t){return Ro(t,iu,ou)}(e),i=new nu(o,t),a=Ci(i,n),u=(r=o.debugOn,new fu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Fi(i,o,a,u);return c.eventEmitter=u,c}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s={desc:"y"},f="No message",l="onResult",p="onError",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={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),d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),b="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m=function(){try{if(window||document)return!0}catch(t){}return!1},_=function(){try{if(!m()&&b)return!0}catch(t){}return!1};var w=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return m()?"browser":_()?"node":"unknown"},e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.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}(w),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},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"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},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,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(w),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(w),T=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),x=Object.freeze({__proto__:null,Jsonql406Error:h,Jsonql500Error:d,JsonqlAuthorisationError:v,JsonqlContractAuthError:g,JsonqlResolverAppError:y,JsonqlResolverNotFoundError:j,JsonqlEnumError:O,JsonqlTypeError:S,JsonqlCheckerError:E,JsonqlValidationError:A,JsonqlError:k,JsonqlServerError:T}),q=k,P=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function C(t){if(P(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||f,a=e.detail||e;if(o&&x[o])throw new x[r](i,a);throw new q(i,a)}return t}function $(t){if(Array.isArray(t))throw new A("",t);var e=t.message||f,r=t.detail||t;switch(!0){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 g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof A:throw new A(e,r);case t instanceof T:throw new T(e,r);default:throw new k(e,r)}}var N="object"==typeof b&&b&&b.Object===Object&&b,z="object"==typeof self&&self&&self.Object===Object&&self,F=N||z||Function("return this")(),I=F.Symbol;function R(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--&&ot(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function _t(t){return void 0===t}var wt="[object Boolean]";var jt="[object Number]";function Ot(t){return function(t){return"number"==typeof t||W(t)&&G(t)==jt}(t)&&t!=+t}var St="[object String]";function Et(t){return"string"==typeof t||!J(t)&&W(t)&&G(t)==St}function At(t,e){return function(r){return t(e(r))}}var kt=At(Object.getPrototypeOf,Object),Tt="[object Object]",xt=Function.prototype,qt=Object.prototype,Pt=xt.toString,Ct=qt.hasOwnProperty,$t=Pt.call(Object);function Nt(t){if(!W(t)||G(t)!=Tt)return!1;var e=kt(t);if(null===e)return!0;var r=Ct.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Pt.call(r)==$t}var zt,Ft=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[zt?a:++n];if(!1===e(o[u],u,o))break}return t};var It="[object Arguments]";function Rt(t){return W(t)&&G(t)==It}var Jt=Object.prototype,Mt=Jt.hasOwnProperty,Ut=Jt.propertyIsEnumerable,Dt=Rt(function(){return arguments}())?Rt:function(t){return W(t)&&Mt.call(t,"callee")&&!Ut.call(t,"callee")};var Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Lt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Bt=Lt&&Lt.exports===Ht?F.Buffer:void 0,Kt=(Bt?Bt.isBuffer:void 0)||function(){return!1},Vt=9007199254740991,Gt=/^(?:0|[1-9]\d*)$/;function Wt(t,e){var r=typeof t;return!!(e=null==e?Vt:e)&&("number"==r||"symbol"!=r&&Gt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Yt}var Xt={};Xt["[object Float32Array]"]=Xt["[object Float64Array]"]=Xt["[object Int8Array]"]=Xt["[object Int16Array]"]=Xt["[object Int32Array]"]=Xt["[object Uint8Array]"]=Xt["[object Uint8ClampedArray]"]=Xt["[object Uint16Array]"]=Xt["[object Uint32Array]"]=!0,Xt["[object Arguments]"]=Xt["[object Array]"]=Xt["[object ArrayBuffer]"]=Xt["[object Boolean]"]=Xt["[object DataView]"]=Xt["[object Date]"]=Xt["[object Error]"]=Xt["[object Function]"]=Xt["[object Map]"]=Xt["[object Number]"]=Xt["[object Object]"]=Xt["[object RegExp]"]=Xt["[object Set]"]=Xt["[object String]"]=Xt["[object WeakMap]"]=!1;var Zt,te="object"==typeof exports&&exports&&!exports.nodeType&&exports,ee=te&&"object"==typeof module&&module&&!module.nodeType&&module,re=ee&&ee.exports===te&&N.process,ne=function(){try{var t=ee&&ee.require&&ee.require("util").types;return t||re&&re.binding&&re.binding("util")}catch(t){}}(),oe=ne&&ne.isTypedArray,ie=oe?(Zt=oe,function(t){return Zt(t)}):function(t){return W(t)&&Qt(t.length)&&!!Xt[G(t)]},ae=Object.prototype.hasOwnProperty;function ue(t,e){var r=J(t),n=!r&&Dt(t),o=!r&&!n&&Kt(t),i=!r&&!n&&!o&&ie(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Se.prototype.set=function(t,e){var r=this.__data__,n=je(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ee,Ae=F["__core-js_shared__"],ke=(Ee=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||""))?"Symbol(src)_1."+Ee:"";var Te=Function.prototype.toString;function xe(t){if(null!=t){try{return Te.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var qe=/^\[object .+?Constructor\]$/,Pe=Function.prototype,Ce=Object.prototype,$e=Pe.toString,Ne=Ce.hasOwnProperty,ze=RegExp("^"+$e.call(Ne).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fe(t){return!(!pe(t)||function(t){return!!ke&&ke in t}(t))&&(ye(t)?ze:qe).test(xe(t))}function Ie(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Fe(r)?r:void 0}var Re=Ie(F,"Map"),Je=Ie(Object,"create");var Me="__lodash_hash_undefined__",Ue=Object.prototype.hasOwnProperty;var De=Object.prototype.hasOwnProperty;var He="__lodash_hash_undefined__";function Le(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ze?new Ye:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Un)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Mn);function Bn(t,e){return Ln(function(t,e,r){return e=Jn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Jn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Kn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!pe(r))return!1;var n=typeof e;return!!("number"==n?be(r)&&Wt(e,r.length):"string"==n&&e in r)&&we(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},vo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},go=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!po(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ho(r,t)})).length},yo=function(t,e){if(void 0===e&&(e=null),Nt(t)){if(!e)return!0;if(ho(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!_t(r)||(!1!==(e=vo(t))?!go({arg:r},e):!po(t)(r))})).length)})).length}return!1},bo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),yo.apply(null,n)};function mo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var _o=function(t,e){var r;switch(!0){case"object"===t:return!bo(e);case"array"===t:return!ho(e.arg);case!1!==(r=vo(t)):return!go(e,r);default:return!po(t)(e.arg)}},wo=function(t,e){return _t(t)?!0!==e.optional||_t(e.defaultvalue)?null:e.defaultvalue:t},jo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ho(e))throw new k("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ho(t))throw new k("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 mo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:mo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:mo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?wo(t,a):t,index:r,param:a,optional:i}}));default:throw mo(5),new k("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!!to(e)&&!(r.type.length>r.type.filter((function(e){return _o(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return _o(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Oo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},So=function(t){return!to(t)};function Eo(t,e){var r=Zn(e,(function(t,e){return!t[fo]}));return Br(r,{})?t:function(t,e){var r={};return e=bn(e),_e(t,(function(t,n,o){_n(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,bn((function(t){return t.alias===e})),_e)||e}))}function Ao(t,e){return Gn(e,(function(e,r){var n,o;return _t(t[r])||!0===e[ao]&&So(t[r])?Vn({},e,((n={})[lo]=!0,n)):((o={})[co]=t[r],o[io]=e[io],o[ao]=e[ao]||!1,o[uo]=e[uo]||!1,o[so]=e[so]||!1,o)}))}function ko(t,e){var r=function(t,e){var r=Eo(t,e);return{pristineValues:Gn(Zn(e,(function(t,e){return Oo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Zn(e,(function(t,e){return!Oo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return ho(t)?t:[t]};var xo=function(t,e){return!ho(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ye(e)&&e.apply(null,[t])}catch(t){return!1}};function Po(t){return function(e,r){if(e[lo])return e[co];var n=function(t,e){var r,n=[[t[co]],[(r={},r[io]=To(t[io]),r[ao]=t[ao],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw mo("runValidationAction",r,e),new S(r,n);if(!1!==e[uo]&&!xo(e[co],e[uo]))throw mo(uo,e[uo]),new O(r);if(!1!==e[so]&&!qo(e[co],e[so]))throw mo(so,e[so]),new E(r);return e[co]}}function Co(t,e,r,n){return void 0===t&&(t={}),Vn(function(t,e){var r=t[0],n=t[1],o=Gn(r,Po(e));return Vn(o,n)}(ko(t,e),n),r)}function $o(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),ho(s)&&(p[i]=s),ye(f)&&(p[u]=f),Et(l)&&(p[c]=l),p}var No=ro,zo=ho,Fo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=jo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Io=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return $o.apply(null,[t,e,n,a,s,f])},Ro=function(t){return function(e,r,n){return void 0===n&&(n={}),Co(e,r,n,t)}}(jo),Jo=function(t){return J(t)?t:[t]},Mo=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Jo(t))}),Reflect.apply(t,null,r))}};function Uo(t,e,r,n){void 0===n&&(n=!1);var o=Object.getOwnPropertyDescriptor(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Do=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 Fo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch($)}},Ho=function(t,e,r,n,o){var i={},a=function(t){i=Uo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Fo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch($)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Lo=function(t,e,r,n,o){var i={},a=function(t){i=Uo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Fo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch($)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Bo=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=Do(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Do(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ko=Array.isArray,Vo=void 0!==b?b:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Go="object"==typeof Vo&&Vo&&Vo.Object===Object&&Vo,Wo="object"==typeof self&&self&&self.Object===Object&&self,Yo=(Go||Wo||Function("return this")()).Symbol,Qo=Object.prototype,Xo=Qo.hasOwnProperty,Zo=Qo.toString,ti=Yo?Yo.toStringTag:void 0;var ei=Object.prototype.toString;var ri="[object Null]",ni="[object Undefined]",oi=Yo?Yo.toStringTag:void 0;function ii(t){return null==t?void 0===t?ni:ri:oi&&oi in Object(t)?function(t){var e=Xo.call(t,ti),r=t[ti];try{t[ti]=void 0;var n=!0}catch(t){}var o=Zo.call(t);return n&&(e?t[ti]=r:delete t[ti]),o}(t):function(t){return ei.call(t)}(t)}var ai=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ui(t){return null!=t&&"object"==typeof t}var ci="[object Object]",si=Function.prototype,fi=Object.prototype,li=si.toString,pi=fi.hasOwnProperty,hi=li.call(Object);var di=Yo?Yo.prototype:void 0,vi=(di&&di.toString,"[object String]");function gi(t){return"string"==typeof t||!Ko(t)&&ui(t)&&ii(t)==vi}var yi=function(t,e){return!!t.filter((function(t){return t===e})).length},bi=function(t,e){var r=Object.keys(t);return yi(r,e)},mi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},_i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},wi="query",ji="mutation",Oi="socket",Si="payload",Ei="condition",Ai=function(){try{if(window||document)return!0}catch(t){}return!1},ki=function(){try{if(!Ai()&&Vo)return!0}catch(t){}return!1};var Ti=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ai()?"browser":ki()?"node":"unknown"},e}(Error));var xi=function(t){var e;return(e={}).args=t,e};var qi=function(t){return bi(t,"data")&&!bi(t,"error")?t.data:t},Pi=function(t){return function(t){if(!ui(t)||ii(t)!=ci)return!1;var e=ai(t);if(null===e)return!0;var r=pi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&li.call(r)==hi}(t)&&(bi(t,wi)||bi(t,ji)||bi(t,Oi))},Ci=function(t,e){return void 0===e&&(e={}),Pi(e)?Promise.resolve(e):t.getContract()},$i=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(mi(e,r,l),o),t.$only(mi(e,r,p),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ni=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function zi(t,e,r,n){var o=function(t,e,r,n){return Mo(Ho,Lo,Bo)({},t,e,r,n)}(t,e,r,n);Ni(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(mi(t,n,l),r)})).catch((function(r){e.$trigger(mi(t,n,p),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Fi=function(t,e,r,n){n.$suspend=!0,r.then((function(r){zi(t,n,e,r)}));var o={query:$i(n,"query"),mutation:$i(n,"mutation"),auth:$i(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.2",o},Ii="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Ri=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=aa().key(e);t(ua(r),r)}},remove:function(t){return aa().removeItem(t)},clearAll:function(){return aa().clear()}};function aa(){return oa.localStorage}function ua(t){return aa().getItem(t)}var ca=Di.trim,sa={name:"cookieStorage",read:function(t){if(!t||!ha(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(fa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;fa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:la,remove:pa,clearAll:function(){la((function(t,e){pa(e)}))}},fa=Di.Global.document;function la(t){for(var e=fa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ca(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function pa(t){t&&ha(t)&&(fa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ha(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(fa.cookie)}var da=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 va="expire_mixin",ga=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+va);return{set:function(e,r,n,o){this.hasNamespace(va)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(va)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(va)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Sa=[ia,sa],Ea=[da,ga,wa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Oa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Oa.compress(this._serialize(r));t(e,n)}}}],Aa=ea.createStore(Sa,Ea),ka=Di.Global;function Ta(){return ka.sessionStorage}function xa(t){return Ta().getItem(t)}var qa=[{name:"sessionStorage",read:xa,write:function(t,e){return Ta().setItem(t,e)},each:function(t){for(var e=Ta().length-1;e>=0;e--){var r=Ta().key(e);t(xa(r),r)}},remove:function(t){return Ta().removeItem(t)},clearAll:function(){return Ta().clear()}},sa],Pa=[da,ga],Ca=ea.createStore(qa,Pa),$a=Aa,Na=Ca,za="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Fa(t){this.message=t}Fa.prototype=new Error,Fa.prototype.name="InvalidCharacterError";var Ia="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Fa("'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=za.indexOf(n);return a};var Ra=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(Ia(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 Ia(e)}};function Ja(t){this.message=t}Ja.prototype=new Error,Ja.prototype.name="InvalidTokenError";var Ma=function(t,e){if("string"!=typeof t)throw new Ja("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ra(t.split(".")[r]))}catch(t){throw new Ja("Invalid token specified: "+t.message)}},Ua=Ja;Ma.InvalidTokenError=Ua;var Da,Ha,La,Ba,Ka,Va,Ga,Wa,Ya,Qa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Xa(t){if(No(t))return function(t){var e=t.iat||Qa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new k("Token has expired on "+r,t)}return t}(Ma(t));throw new k("Token must be a string!")}Io("HS256",["string"]),Io(!1,["boolean","number","string"],((Da={})[c]="exp",Da[o]=!0,Da)),Io(!1,["boolean","number","string"],((Ha={})[c]="nbf",Ha[o]=!0,Ha)),Io(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),Io(!1,["boolean","string"],((Ba={})[c]="sub",Ba[o]=!0,Ba)),Io(!1,["boolean","string"],((Ka={})[c]="iss",Ka[o]=!0,Ka)),Io(!1,["boolean"],((Va={})[o]=!0,Va)),Io(!1,["boolean","string"],((Ga={})[o]=!0,Ga)),Io(!1,["boolean","string"],((Wa={})[o]=!0,Wa)),Io(!1,["boolean"],((Ya={})[o]=!0,Ya));var Za=r[0],tu=r[1],eu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ru={headers:{configurable:!0}};ru.headers.set=function(t){this.extraHeader=t},eu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Vn({},{_cb:_i()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Vn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Vn({},{method:Za,params:o},e))},eu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},eu.prototype.processJsonp=function(t){return qi(t)},eu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=No(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):qi(o)}),(function(t){throw e.cleanUp(),console.error(t),new T("Server side error",t)}))},eu.prototype.getHeaders=function(){return this.opts.enableAuth?Vn({},e,this.getAuthHeader(),this.extraHeader):Vn({},e,this.extraHeader)},eu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},eu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Vn({},this.extraParams,s)),this.request({},{method:"GET"},this.contractHeader).then(C).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},eu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),gi(t)&&Ko(e)){var o=xi(e);return!0===r?o:((n={})[t]=o,n)}throw new Ti("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(C)},eu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Si]=e,i[Ei]=r,!0===n)return i;if(gi(t))return(o={})[t]=i,o;throw new Ti("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:tu}).then(C)},Object.defineProperties(eu.prototype,ru);var nu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),zo(t)&&t.length>=2&&Reflect.apply($a.set,$a,t),new A("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=$a.get("endpoint")||[];yi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=$a.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!yi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=_i();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply($a.set,$a,e)},r.jsonqlEndpoint.get=function(){var t=$a.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return($a.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Na.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Xa)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Pi(t))throw new A("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Pi(this.opts.contract)?this.opts.contract:$a.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(eu))),ou={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},iu={hostname:Io([window.location.protocol,window.location.host].join("//"),["string"]),jsonqlPath:Io("jsonql",["string"]),loginHandlerName:Io("login",["string"]),logoutHandlerName:Io("logout",["string"]),enableJsonp:Io(!1,["boolean"]),enableAuth:Io(!1,["boolean"]),useJwt:Io(!0,["boolean"]),useLocalstorage:Io(!0,["boolean"]),storageKey:Io("storageKey",["string"]),authKey:Io("authKey",["string"]),contractExpired:Io(0,["number"]),keepContract:Io(!0,["boolean"]),exposeContract:Io(!1,["boolean"]),showContractDesc:Io(!1,["boolean"]),contractKey:Io(!1,["boolean"]),contractKeyName:Io("X-JSONQL-CV-KEY",["string"]),enableTimeout:Io(!1,["boolean"]),timeout:Io(5e3,["number"]),returnInstance:Io(!1,["boolean"]),allowReturnRawToken:Io(!1,["boolean"]),debugOn:Io(!1,["boolean"])};var au=new WeakMap,uu=new WeakMap;var cu=function(){this.__suspend__=null,this.queueStore=new Set},su={$suspend:{configurable:!0},$queues:{configurable:!0}};su.$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)},cu.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__},su.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},cu.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(cu.prototype,su);var fu=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){au.set(this,t)},r.normalStore.get=function(){return au.get(this)},r.lazyStore.set=function(t){uu.set(this,t)},r.lazyStore.get=function(){return uu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(cu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=function(t){return Ro(t,iu,ou)}(e),i=new nu(o,t),a=Ci(i,n),u=(r=o.debugOn,new fu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Fi(i,o,a,u);return c.eventEmitter=u,c}})); //# sourceMappingURL=static.js.map diff --git a/packages/http-client/static.js.map b/packages/http-client/static.js.map index b8c301683744302feed477970b6abe35907ef1dc..2b30e8fb0fc2394f14db4c2fae3073f12ce9d651 100644 --- a/packages/http-client/static.js.map +++ b/packages/http-client/static.js.map @@ -1 +1 @@ -{"version":3,"file":"static.js","sources":["node_modules/store/plugins/defaults.js","node_modules/store/plugins/expire.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","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i jsonqlInstance.userdata; } + // create an alias to the helloWorld make it easier for testing + obj.helloWorld = obj.query.helloWorld; // the eventEmitter getter - it should not be inside the auth! obj.eventEmitter = () => jsonqlInstance.eventEmitter // store this once again and export it diff --git a/packages/node-client/tests/main.test.js b/packages/node-client/tests/main.test.js index 012aa4bfeae0354b87aa00f55fa7784dae909c8e..749b778ed0e6c8455e80db8fcb4e91bd4fcacbda 100755 --- a/packages/node-client/tests/main.test.js +++ b/packages/node-client/tests/main.test.js @@ -29,9 +29,9 @@ test(`Just to cause the jsonql-koa to run`, t => { }) */ -test('Should able to say Hello world!' , async t => { +test('Should able to say Hello world using the shorthand version!' , async t => { // debug(t.context.client); - const result = await t.context.client.query.helloWorld() + const result = await t.context.client.helloWorld() t.is('Hello world!', result) }) @@ -40,5 +40,4 @@ test(`It should able to access the mutation call`, async t => { const result = await t.context.client.mutation.sendUser({name: 'Joel'}, {id: 1}) t.truthy(result.timestamp) - })