diff --git a/packages/@jsonql/client/README.md b/packages/@jsonql/client/README.md index 5b4bacc6e895e5a0c78d69f0c027164d980cf7cc..2381d43da61df3069b3997715496d0036b1d475a 100644 --- a/packages/@jsonql/client/README.md +++ b/packages/@jsonql/client/README.md @@ -18,7 +18,7 @@ jsonqlClient(config) ``` -Using the static client with pre-generated contract (works better with other frameworks) +Using the static client with pre-generated contract (works better with Third party JS frameworks) ```js import { jsonqlStaticClient } from '@jsonql/client/static' @@ -27,31 +27,30 @@ import Fly from 'flyio' // or specific client to your need const client = jsonqlStaticClient(Fly, { contract }) -client.query('helloWorld') +client.query.helloWorld() .then(msg => { // you get Hello world! }) - ``` -## Framework modules +## Third party JS Framework modules -We have develop several module for integrate with some of the popular js framework. +We have developed several modules to integrate with some of the third party JS frameworks. ### Vuex module -We add a vuex store support in version 1.5.19 +[Vuex](https://vuex.vuejs.org) store support was add in version 1.5.19 -First create a new file (let say call it `jsonql.js`) +First create a new Vuex store file (let say call it `jsonql.js`) ```js import contract from 'path/to/your/public-contract.json' -import { getJsonqlVuexModule } from '@jsonql/client/vue' +import { jsonqlVuex } from '@jsonql/client/vue' import Fly from 'flyio' -const jsonqlModule = getJsonqlVuexModule(Fly, { contract }) +const jsonqlVuexModule = jsonqlVuex(Fly, { contract }) -export { jsonqlModule } +export { jsonqlVuexModule } ``` Now in your `store.js` where you define your Vuex store @@ -62,7 +61,7 @@ import Vuex from 'vuex' Vue.use(Vuex) -import { jsonqlModule } from './jsonql' +import { jsonqlVuexModule } from './jsonql' export default new Vuex.Store({ state: {}, @@ -70,7 +69,7 @@ export default new Vuex.Store({ actions: {}, getters: {}, modules: { - jsonqlModule + jsonqlVuexModule } }) ``` @@ -89,41 +88,157 @@ export default { name: 'test', computed: { hello() { - this.getJsonqlResult('queryHelloWorld') + return this.getJsonqlResult('helloWorld') } } actions: { - ...mapActions('jsonqlModule', ['queryHelloWorld']) + ...mapActions('jsonqlVuexModule', ['helloWorld']) }, getters: { - ...mapGetters('jsonqlModule', ['getJsonqlResult']) + ...mapGetters('jsonqlVuexModule', ['getJsonqlResult']) } } ``` -You might be asking why the resolver name is different from the contract from `query.helloWorld` turn into `queryHelloWorld`. -We use their type to prefix each resolvers, so you might get `query`, `mutation`, `auth` etc. This is to avoid duplicated naming. -You can turn this off by passing a `prefix:false` in the `config` when you set up your store file: + +### Prefix your resolver with their type + +There is a little different between our core jsonql client and in the above module. Normally, the client will namespaced each +methods under their type: ```js -// the import -const jsonqlModule = getJsonqlVuexModule(Fly, { contract, prefix: false }) -// the export +jsonql() + .then(client => { + // query + client.query.helloWorld() + // mutation + client.mutation.updateSomething() + // auth + client.auth.login() + // etc + }) + ``` -### getters getJsonqlResult +We try to be compatible with the Vuex (or most of the js state machine) style, we remove the namespace, and just construct +the resolver under the client, there is one little potential danger, when you don't name each of your resolver with a unique name. +But again this is an edge case, I don't think anyone in their right mind will have a `query.login`, `auth.login` at the same time? + +But when you find yourself in this situation. You can use the `prefix` option. + +```js +import contract from 'path/to/your/public-contract.json' +import { jsonqlVuex } from '@jsonql/client/vue' +import Fly from 'flyio' +// here we pass the prefix: true option +const jsonqlVuexModule = jsonqlVuex(Fly, { contract, prefix: true }) + +export { jsonqlVuexModule } + +``` + +Then it will turn `query.helloWorld` into `queryHelloWorld`. + +```html + + +``` + +If you need this option, then remember, everything will prefix with their `resolver type` name, in camel case. + +### Vuex getter: getJsonqlResult -You should notice there is a getter method call `getJsonqlResult` and you pass the resolver name (with prefix or not when you turn it off). -The reason is in the Vuex model, after we call the resolver, we store (commit) the result in our internal `result` state, and key with the resolver name. And whenever a new result return, it will get overwritten, because it's a flat object. +You should notice there is a *Vuex getter* method call `getJsonqlResult`, and you pass the resolver name (with prefix if you use `prefix:true` option). Then you will get back the last resolver call result via this *getter*. -Of course, you can simply call the actions and wait for the promise to resolve. You will get the same effect. +The reason is in the Vuex model, after the call to resolver, we store (*commit*) the result in our internal `result` state, and key with the resolver name. And whenever a new result return, it will get overwritten, because it's a flat object. -### getters getJsonqlError +Of course, you can simply call the actions, and wait for the promise to resolve. You will get the same effect. For example: -Whenever an error happens, we do the same like success result, we commit to our internal `error` state, and you can use this getter to get it. -And after we commit, we will throw it again which wrap in a generic `Error`. So you can also catch it again. +```js + + + +``` + +### Vuex getter: getJsonqlError + +Whenever an error happens, we do the same like success result, we commit to our internal `error` state, and you can use this *getter* to get it. +And after we commit, we will throw it again which wrap in a generic `Error`. So you can also catch it again. For example: + +```js + + + +``` +This *getter* is literally identical to `getJsonqlResult`. --- diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index 6adaa410b548d0fd147df15c609f9899cc887d04..e6a8a92b4fb3291e642c915124858ae782c691c7 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -1,6 +1,6 @@ { "name": "@jsonql/client", - "version": "0.3.2", + "version": "0.4.0", "description": "jsonql js http and socket client for browser with multiple API for different framework", "main": "dist/jsonql-client.cjs.js", "module": "index.js", diff --git a/packages/@jsonql/client/vue/vuex.js b/packages/@jsonql/client/vue/vuex.js index 1877eeb3efd7e071154f1cb73b7f905198cc1aef..0bac69c7366b2192271ea99e2b6029f2e16bab27 100644 --- a/packages/@jsonql/client/vue/vuex.js +++ b/packages/@jsonql/client/vue/vuex.js @@ -16,7 +16,7 @@ const ucword = str => ( * @param {boolean} [prefix=true] add prefix or not * @return {array} actions, names */ -function getActions(contract, jsonqlClient, prefix = true) { +function getActions(contract, jsonqlClient, prefix = false) { const availableTypes = ['query', 'mutation', 'auth'] let actions = {} let names = {} @@ -46,7 +46,7 @@ function getActions(contract, jsonqlClient, prefix = true) { /** * We export a function to generate the relevant code - * @param {object} Fly the fly object + * @param {object} Fly the fly object for http request * @param {object} config configuration with the contract * @return {object} the Vuex store object */ @@ -69,7 +69,7 @@ function getJsonqlVuexModule(Fly, config) { state.error[name] = error } }, - // because jsonql are all async call, everything will be create as actions + // because jsonql are all async call, everything will be create as action actions: actions, getters: { getJsonqlResult: (state) => (name) => { diff --git a/packages/http-client/README-OLD.md b/packages/http-client/README-OLD.md new file mode 100644 index 0000000000000000000000000000000000000000..d834c68b16ec8470dad0db6c1e60b62ccf15b697 --- /dev/null +++ b/packages/http-client/README-OLD.md @@ -0,0 +1,133 @@ +# jsonql-client + +> This is jsonql browser HTTP client for jsonql services + +This is **NOT** just a HTTP client, it comes with full user client side management (using JWT) + +Instead of using this directly, we recommend you to use [@jsonql/client](https://npmjs.com/package/@jsonql/client). + +If you need to use in node environment, then you should use [jsonql-node-client](https://npmjs.com/package/jsonql-node-client) instead. + +## How to use it + +First, this module **DOES NOT** distribute with the [Flyio](https://github.com/wendux/fly) module. You have to explicitly import it yourself. +The reason is - we intend to support as many platform as possible, and Fly allow you to do just that, check their +[documentation](https://github.com/wendux/fly) for more information. + +```js +import Fly from 'flyio' +import jsonqlClient from '@jsonql/http-client' + +const client = jsonqlClient(Fly, config) + +client.then(c => { + c.query.helloWorld() + .then(msg => { + // should be a Hello World message + }) +}) + +``` + +### Pass contract via config gives you the client directly + +If you pass the `contract` via the config, then you don't need to call the end + +```js +import contract from 'some/where/contract.json' +import Fly from 'flyio' +import jsonqlClient from 'jsonql-client' + +let config = { contract } +const client = jsonqlClient(Fly, config) + +client.query.helloWorld() + .then(msg => { + // Hello world + }) +``` + +### Using a static client + +There is a different style client that you can use: + +```js +import Fly from 'flyio/dist/npm/fly' // using the Fly.js browser client +import jsonqlClientStatic from 'jsonql-client/static' + +const client = jsonqlClientStatic(Fly) // optional pass a config + +client.query('helloWorld') + .then(msg => { + + }) + +``` + +As you can see from the above example, it also returned a promise, but the call signature +is different; the first parameter is the name of the resolver, +and the subsequence parameters are their expected parameters like so `client.query(resolverName, ...args)` + +### Include from the dist to use + +If you are not using build tools to build your js project and import via the HTML. +There are two files to use + +- jsonql-client/dist/jsonql-client.umd.js (global name `jsonqlClient`) +- jsonql-client/dist/jsonql-client.static.js (global name `jsonqlClientStatic`) + +**You must include the fly.js in the html document before any one of both of them** + +See the following example (pretty close to our own test version as well) + +```js +(function() { + // jsonql-client/dist/jsonql-client.umd.js + // you don't need to pass the Fly but you DO need to include in the html document + jsonqlClient() + .then(function(client) { + // now use the client to do your thing + client.query.helloWorld() + .then(function(msg) { + // hello world + }) + }) + + // jsonql-client/dist/jsonql-client.static.js + jsonqlClientStatic() + .then(function(staticClient) { + // now use your static client to do your thing + staticClient.query('helloWorld') + .then(function(msg) { + // hello world + }) + // example of mutation fn(resolverName, payload, condition) + staticClient.mutation('updateSomething', {data: 'something'}, {id: 1}) + .then(function(result) { + // use the result to do stuff + }) + }) + +})() + +``` + +## Configuration options + +| Name | Description | Expected Type | Default value | +| ----------- |:----------------------| :------------:| :--------------| +| hostname | The hostname of the jsonql server | `String` | capture via the `window.location` object | +| loginHandlerName | custom login function name must match the server side resolver name | `String` | `login` | +| logoutHandlerName | custom logout function name must match the server side resolver name | `String` | `logout` | +| enableAuth | Whether to use authorisation or not | `Boolean` | `false` | +| storageKey | client side local storage key name | `String` | `CLIENT_STORAGE_KEY` | +| debugOn | When enable, you will see debug message in your browser console | `Boolean` | `false` | + + +--- + +Please consult [jsonql.org](https:jsonql.js.org) for more information. + +--- + +NB + T1S diff --git a/packages/http-client/README.md b/packages/http-client/README.md index d834c68b16ec8470dad0db6c1e60b62ccf15b697..7928d01556b7e165370a51b585b1955a41be3dd9 100644 --- a/packages/http-client/README.md +++ b/packages/http-client/README.md @@ -1,133 +1,9 @@ # jsonql-client -> This is jsonql browser HTTP client for jsonql services +**We have made some major changes starting from the 1.6.0, the old README is completely obsoleted** -This is **NOT** just a HTTP client, it comes with full user client side management (using JWT) - -Instead of using this directly, we recommend you to use [@jsonql/client](https://npmjs.com/package/@jsonql/client). - -If you need to use in node environment, then you should use [jsonql-node-client](https://npmjs.com/package/jsonql-node-client) instead. - -## How to use it - -First, this module **DOES NOT** distribute with the [Flyio](https://github.com/wendux/fly) module. You have to explicitly import it yourself. -The reason is - we intend to support as many platform as possible, and Fly allow you to do just that, check their -[documentation](https://github.com/wendux/fly) for more information. - -```js -import Fly from 'flyio' -import jsonqlClient from '@jsonql/http-client' - -const client = jsonqlClient(Fly, config) - -client.then(c => { - c.query.helloWorld() - .then(msg => { - // should be a Hello World message - }) -}) - -``` - -### Pass contract via config gives you the client directly - -If you pass the `contract` via the config, then you don't need to call the end - -```js -import contract from 'some/where/contract.json' -import Fly from 'flyio' -import jsonqlClient from 'jsonql-client' - -let config = { contract } -const client = jsonqlClient(Fly, config) - -client.query.helloWorld() - .then(msg => { - // Hello world - }) -``` - -### Using a static client - -There is a different style client that you can use: - -```js -import Fly from 'flyio/dist/npm/fly' // using the Fly.js browser client -import jsonqlClientStatic from 'jsonql-client/static' - -const client = jsonqlClientStatic(Fly) // optional pass a config - -client.query('helloWorld') - .then(msg => { - - }) - -``` - -As you can see from the above example, it also returned a promise, but the call signature -is different; the first parameter is the name of the resolver, -and the subsequence parameters are their expected parameters like so `client.query(resolverName, ...args)` - -### Include from the dist to use - -If you are not using build tools to build your js project and import via the HTML. -There are two files to use - -- jsonql-client/dist/jsonql-client.umd.js (global name `jsonqlClient`) -- jsonql-client/dist/jsonql-client.static.js (global name `jsonqlClientStatic`) - -**You must include the fly.js in the html document before any one of both of them** - -See the following example (pretty close to our own test version as well) - -```js -(function() { - // jsonql-client/dist/jsonql-client.umd.js - // you don't need to pass the Fly but you DO need to include in the html document - jsonqlClient() - .then(function(client) { - // now use the client to do your thing - client.query.helloWorld() - .then(function(msg) { - // hello world - }) - }) - - // jsonql-client/dist/jsonql-client.static.js - jsonqlClientStatic() - .then(function(staticClient) { - // now use your static client to do your thing - staticClient.query('helloWorld') - .then(function(msg) { - // hello world - }) - // example of mutation fn(resolverName, payload, condition) - staticClient.mutation('updateSomething', {data: 'something'}, {id: 1}) - .then(function(result) { - // use the result to do stuff - }) - }) - -})() - -``` - -## Configuration options - -| Name | Description | Expected Type | Default value | -| ----------- |:----------------------| :------------:| :--------------| -| hostname | The hostname of the jsonql server | `String` | capture via the `window.location` object | -| loginHandlerName | custom login function name must match the server side resolver name | `String` | `login` | -| logoutHandlerName | custom logout function name must match the server side resolver name | `String` | `logout` | -| enableAuth | Whether to use authorisation or not | `Boolean` | `false` | -| storageKey | client side local storage key name | `String` | `CLIENT_STORAGE_KEY` | -| debugOn | When enable, you will see debug message in your browser console | `Boolean` | `false` | - - ---- - -Please consult [jsonql.org](https:jsonql.js.org) for more information. +Please wait for the brand new README, and we will update the our main website [jsonql.org](https://jsonql.js.org) ASAP --- -NB + T1S +Joel (2020-02-29) diff --git a/packages/http-client/_README.md b/packages/http-client/_README.md deleted file mode 100644 index 5d4a85f56847bfc2bc9d3e43bc0f0315e3dca0c2..0000000000000000000000000000000000000000 --- a/packages/http-client/_README.md +++ /dev/null @@ -1,59 +0,0 @@ -# @jsonql/http-client - -> This is jsonql http client for javascript, previously release as jsonql-client - -## How to use it - -First this version **DOES NOT** distribute with the [Flyio](https://github.com/wendux/fly) module. You have to explicitly import it yourself. -The reason is - we intend to support as many platform as possible, and Fly allow you to do just that, check their -[documentation](https://github.com/wendux/fly) for more information. - -```js -import Fly from 'flyio' -import jsonqlClient from '@jsonql/http-client' - -const client = jsonqlClient(Fly, config) - -client.then(c => { - c.query.helloWorld() - .then(msg => { - // should be a Hello World message - }) -}) - -``` - -### Pass contract via config gives you the client directly - -If you pass the `contract` via the config, then you don't need to call the end - -```js -import contract from 'some/where/contract.json' -import Fly from 'flyio' -import jsonqlClient from '@jsonql/http-client' - -let config = { contract } -const client = jsonqlClient(Fly, config) - -client.query.helloWorld() - .then(msg => { - // Hello world - }) -``` - -### Using a static client - -There is a different style client that you can use: - -```js - - -``` - - - -Please consult [jsonql.org](https:jsonql.js.org) for more information. - ---- - -NB + T1S diff --git a/packages/http-client/cb.js b/packages/http-client/cb.js new file mode 100644 index 0000000000000000000000000000000000000000..de8cdbdf916e32c261d8062283d32dbac0c14b06 --- /dev/null +++ b/packages/http-client/cb.js @@ -0,0 +1,31 @@ +// as of 1.5.15 this no longer build +// it's a source files that require to build on the your client side +// this is the new Event base with callback style interface +// the export will be different and purposely design for framework that +// is very hard to use Promise such as Vue +import { jsonqlCbGenerator } from './src/core/jsonql-cb-generator' +import { JsonqlBaseEngine } from './src/base' +import { checkOptions } from './src/options' +import { getContractFromConfig } from './src/utils' +import { getEventEmitter } from './src' + +/** + * this is the slim client without Fly, you pick the version of Fly to use + * This is a breaking change because it swap the input positions + * @param {object} fly fly.js + * @param {object} config configuration + * @return {object} the jsonql client instance + */ +export function jsonqlCallbackClient(fly, config) { + const { contract } = config + const opts = checkOptions(config) + const jsonqlBaseCls = new JsonqlBaseEngine(fly, opts) + const contractPromise = getContractFromConfig(jsonqlBaseCls, contract) + const ee = getEventEmitter(opts.debugOn) + // finally + let methods = jsonqlCbGenerator(jsonqlBaseCls, opts, contractPromise, ee) + methods.eventEmitter = ee + // 1.5.21 port the logger for other part to use + methods.getLogger = (name) => (...args) => Reflect.apply(jsonqlInstance.log, jsonqlInstance, [name, ...args]) + return methods +} diff --git a/packages/http-client/core.js b/packages/http-client/core.js index abf14031b723876437893c6abe9cc95ebcd385af..4713a3b767459ec5a5f2c6a28298476685259aaa 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),e=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),r=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),n=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),o=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),s=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),f="application/vnd.api+json",p={Accept:f,"Content-Type":[f,"charset=utf-8"].join(";")},h=["POST","PUT"],d={desc:"y"},v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),g=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),y=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:r,JsonqlAuthorisationError:n,JsonqlContractAuthError:o,JsonqlResolverAppError:i,JsonqlResolverNotFoundError:a,JsonqlEnumError:u,JsonqlTypeError:c,JsonqlCheckerError:s,JsonqlValidationError:l,JsonqlError:v,JsonqlServerError:g}),b=v;function _(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&y[o])throw new y[r](i,a);throw new b(i,a)}return t}function m(f){if(Array.isArray(f))throw new l("",f);var p=f.message||"No message",h=f.detail||f;switch(!0){case f instanceof t:throw new t(p,h);case f instanceof e:throw new e(p,h);case f instanceof r:throw new r(p,h);case f instanceof n:throw new n(p,h);case f instanceof o:throw new o(p,h);case f instanceof i:throw new i(p,h);case f instanceof a:throw new a(p,h);case f instanceof u:throw new u(p,h);case f instanceof c:throw new c(p,h);case f instanceof s:throw new s(p,h);case f instanceof l:throw new l(p,h);case f instanceof g:throw new g(p,h);default:throw new v(p,h)}}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol;function A(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&L(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var ot=function(t){return!!E(t)||null!=t&&""!==nt(t)};function it(t){return function(t){return"number"==typeof t||N(t)&&"[object Number]"==z(t)}(t)&&t!=+t}function at(t){return"string"==typeof t||!E(t)&&N(t)&&"[object String]"==z(t)}var ut=function(t){return!at(t)&&!it(parseFloat(t))},ct=function(t){return""!==nt(t)&&at(t)},st=function(t){return null!=t&&"boolean"==typeof t},lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==nt(t)&&(!1===e||!0===e&&null!==t)},ft=function(t){switch(t){case"number":return ut;case"string":return ct;case"boolean":return st;default:return lt}},pt=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===nt(e)||!(t.filter((function(t){return!ft(e)(t)})).length>0))},ht=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},dt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ft(e)(t)})).length)})).length:e.length>e.filter((function(t){return!pt(r,t)})).length};function vt(t,e){return function(r){return t(e(r))}}var gt=vt(Object.getPrototypeOf,Object),yt=Function.prototype,bt=Object.prototype,_t=yt.toString,mt=bt.hasOwnProperty,wt=_t.call(Object);function jt(t){if(!N(t)||"[object Object]"!=z(t))return!1;var e=gt(t);if(null===e)return!0;var r=mt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&_t.call(r)==wt}var St,Ot=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[St?a:++n];if(!1===e(o[u],u,o))break}return t};function kt(t){return N(t)&&"[object Arguments]"==z(t)}var At=Object.prototype,Et=At.hasOwnProperty,Tt=At.propertyIsEnumerable,xt=kt(function(){return arguments}())?kt:function(t){return N(t)&&Et.call(t,"callee")&&!Tt.call(t,"callee")};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=qt&&qt.exports===Pt?O.Buffer:void 0,$t=(Ct?Ct.isBuffer:void 0)||function(){return!1},zt=/^(?:0|[1-9]\d*)$/;function Nt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var It={};It["[object Float32Array]"]=It["[object Float64Array]"]=It["[object Int8Array]"]=It["[object Int16Array]"]=It["[object Int32Array]"]=It["[object Uint8Array]"]=It["[object Uint8ClampedArray]"]=It["[object Uint16Array]"]=It["[object Uint32Array]"]=!0,It["[object Arguments]"]=It["[object Array]"]=It["[object ArrayBuffer]"]=It["[object Boolean]"]=It["[object DataView]"]=It["[object Date]"]=It["[object Error]"]=It["[object Function]"]=It["[object Map]"]=It["[object Number]"]=It["[object Object]"]=It["[object RegExp]"]=It["[object Set]"]=It["[object String]"]=It["[object WeakMap]"]=!1;var Rt,Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=Jt&&Jt.exports===Ft&&j.process,Lt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Ht=Lt&&Lt.isTypedArray,Dt=Ht?(Rt=Ht,function(t){return Rt(t)}):function(t){return N(t)&&Mt(t.length)&&!!It[z(t)]},Kt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=E(t),n=!r&&xt(t),o=!r&&!n&&$t(t),i=!r&&!n&&!o&&Dt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ie.prototype.set=function(t,e){var r=this.__data__,n=ne(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ae,ue=O["__core-js_shared__"],ce=(ae=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+ae:"";var se=Function.prototype.toString;function le(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,he=Object.prototype,de=pe.toString,ve=he.hasOwnProperty,ge=RegExp("^"+de.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ye(t){return!(!Qt(t)||function(t){return!!ce&&ce in t}(t))&&(Xt(t)?ge:fe).test(le(t))}function be(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ye(r)?r:void 0}var _e=be(O,"Map"),me=be(Object,"create");var we=Object.prototype.hasOwnProperty;var je=Object.prototype.hasOwnProperty;function Se(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var l=-1,f=!0,p=2&r?new Ee:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=ht(t))?!dt({arg:r},e):!ft(t)(r))})).length)})).length}return!1},Sr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(jr,null,a);case"array"===t:return!pt(e.arg);case!1!==(r=ht(t)):return!dt(e,r);default:return!ft(t)(e.arg)}},Or=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},kr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!pt(e))throw new v("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!pt(t))throw new v("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Or(t,a):t,index:r,param:a,optional:i}}));default:throw new v("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!ot(e)&&!(r.type.length>r.type.filter((function(e){return Sr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Sr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ar=function(){try{var t=be(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Er(t,e,r){"__proto__"==e&&Ar?Ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Tr(t,e,r){(void 0===r||re(t[e],r))&&(void 0!==r||e in t)||Er(t,e,r)}var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Pr&&Pr.exports===xr?O.Buffer:void 0,Cr=qr?qr.allocUnsafe:void 0;function $r(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pe(n).set(new Pe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var zr=Object.create,Nr=function(){function t(){}return function(e){if(!Qt(e))return{};if(zr)return zr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ir=Object.prototype.hasOwnProperty;function Rr(t,e,r){var n=t[e];Ir.call(t,e)&&re(n,r)&&(void 0!==r||e in t)||Er(t,e,r)}var Fr=Object.prototype.hasOwnProperty;function Jr(t){if(!Qt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Ur(t){return Zt(t)?Bt(t,!0):Jr(t)}function Lr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Gr);function Yr(t,e){return Wr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Qt(r))return!1;var n=typeof e;return!!("number"==n?Zt(r)&&Nt(e,r.length):"string"==n&&e in r)&&re(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,yn(t))}),Reflect.apply(t,null,r))}};function mn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function wn(t,e,r,n){void 0===n&&(n=!1);var o=mn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var jn=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return dn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(m)}},Sn=function(t,e,r,n,o){var i={},a=function(t){i=wn(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return dn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(m)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},On=function(t,e,r,n,o){var i={},a=function(t){i=wn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return dn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(m)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},kn=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var An=function(t,e,r,n){var o=function(t,e,r,n){var o=[Sn,On,kn];return Reflect.apply(_n,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.21",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function En(t){return!!function(t){return jt(t)&&(bn(t,"query")||bn(t,"mutation")||bn(t,"socket"))}(t)&&t}function Tn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function xn(t){this.message=t}xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Pn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new xn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var qn=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Pn(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Pn(e)}};function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidTokenError";var $n=function(t,e){if("string"!=typeof t)throw new Cn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(qn(t.split(".")[r]))}catch(t){throw new Cn("Invalid token specified: "+t.message)}};$n.InvalidTokenError=Cn;var zn,Nn,Mn,In,Rn,Fn,Jn,Un,Ln;function Hn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new v("Token has expired on "+r,t)}return t}function Dn(t){if(ct(t))return Hn($n(t));throw new v("Token must be a string!")}vn("HS256",["string"]),vn(!1,["boolean","number","string"],((zn={}).alias="exp",zn.optional=!0,zn)),vn(!1,["boolean","number","string"],((Nn={}).alias="nbf",Nn.optional=!0,Nn)),vn(!1,["boolean","string"],((Mn={}).alias="iss",Mn.optional=!0,Mn)),vn(!1,["boolean","string"],((In={}).alias="sub",In.optional=!0,In)),vn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),vn(!1,["boolean"],((Fn={}).optional=!0,Fn)),vn(!1,["boolean","string"],((Jn={}).optional=!0,Jn)),vn(!1,["boolean","string"],((Un={}).optional=!0,Un)),vn(!1,["boolean"],((Ln={}).optional=!0,Ln));var Kn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Bn(t,e){var r;return(r={})[t]=e,r.TS=[Kn()],r}var Gn=function(t){return bn(t,"data")&&!bn(t,"error")?t.data:t},Vn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Wn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=bo().key(e);t(_o(r),r)}},remove:function(t){return bo().removeItem(t)},clearAll:function(){return bo().clear()}};function bo(){return go.localStorage}function _o(t){return bo().getItem(t)}var mo=Zn.trim,wo={name:"cookieStorage",read:function(t){if(!t||!ko(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(jo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;jo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:So,remove:Oo,clearAll:function(){So((function(t,e){Oo(e)}))}},jo=Zn.Global.document;function So(t){for(var e=jo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(mo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Oo(t){t&&ko(t)&&(jo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ko(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(jo.cookie)}var Ao=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Eo=Zn.bind,To=Zn.each,xo=Zn.create,Po=Zn.slice,qo=function(){var t=xo(Co,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Eo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Eo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),To(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Co={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Eo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Po(arguments,1);To(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},$o=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(l=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),zo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=$o.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=$o.compress(this._serialize(r));t(e,n)}}};var No=[yo,wo],Mo=[Ao,qo,zo],Io=po.createStore(No,Mo),Ro=Zn.Global;function Fo(){return Ro.sessionStorage}function Jo(t){return Fo().getItem(t)}var Uo=[{name:"sessionStorage",read:Jo,write:function(t,e){return Fo().setItem(t,e)},each:function(t){for(var e=Fo().length-1;e>=0;e--){var r=Fo().key(e);t(Jo(r),r)}},remove:function(t){return Fo().removeItem(t)},clearAll:function(){return Fo().clear()}},wo],Lo=[Ao,zo],Ho=po.createStore(Uo,Lo),Do=Io,Ko=Ho,Bo=function(t){this.opts=t,this.instanceKey=Tn(this.opts.hostname),this.localStore=Do,this.sessionStore=Ko},Go={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Bo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?Xr({},o,e):e,r))},Bo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Bo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Bo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Go.lset.set=function(t){return this.__setMethod("localStore",t)},Go.lget.get=function(){return this.__getMethod("localStore")},Bo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Bo.prototype.lclear=function(){return this.__clearMethod("localStore")},Go.sset.set=function(t){return this.__setMethod("sessionStore",t)},Go.sget.get=function(){return this.__getMethod("sessionStore")},Bo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Bo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Bo.prototype,Go);var Vo=h[0],Wo=h[1],Yo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Dn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(hn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new l("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&hn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!En(t))throw new l("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=En(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Xr({},{_cb:Kn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Xr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Xr({},{method:Vo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Gn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=pn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Gn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new g("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Xr({},p,this.getAuthHeader(),this.extraHeader):Xr({},p,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Xr({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new g("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),at(t)&&E(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Bn(t,n)}throw new l("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(at(t))return Bn(t,o);throw new l("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Wo}).then(_)},Object.defineProperties(e.prototype,r),e}(Bo)))),Qo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:f,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xo={hostname:vn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:vn("jsonql",["string"]),loginHandlerName:vn("login",["string"]),logoutHandlerName:vn("logout",["string"]),enableJsonp:vn(!1,["boolean"]),enableAuth:vn(!1,["boolean"]),useJwt:vn(!0,["boolean"]),persistToken:vn(!1,["boolean","number"]),useLocalstorage:vn(!0,["boolean"]),storageKey:vn("jsonqlstore",["string"]),authKey:vn("jsonqlauthkey",["string"]),contractExpired:vn(0,["number"]),keepContract:vn(!0,["boolean"]),exposeContract:vn(!1,["boolean"]),exposeStore:vn(!1,["boolean"]),showContractDesc:vn(!1,["boolean"]),contractKey:vn(!1,["boolean"]),contractKeyName:vn("X-JSONQL-CV-KEY",["string"]),enableTimeout:vn(!1,["boolean"]),timeout:vn(5e3,["number"]),returnInstance:vn(!1,["boolean"]),allowReturnRawToken:vn(!1,["boolean"]),debugOn:vn(!1,["boolean"])};function Zo(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return wn(t,"__checked__",Kn())};r.push(o);var i=Reflect.apply(_n,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ti(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),mn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(Zo,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Xo,Qo,gn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ei(t,e,r){return void 0===r&&(r={}),ti(r).then((function(t){return{baseClient:new Yo(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),En(n)?Promise.resolve(n):r.getContract()).then((function(e){return An(o,i,e,t)}))}))}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},oi.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(oi.prototype,ii);var ai=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,l=0;l0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return Tn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));return function(t,e){var r;return ei((r=e.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),e=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),r=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),n=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),o=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),s=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),f="application/vnd.api+json",p={Accept:f,"Content-Type":[f,"charset=utf-8"].join(";")},h=["POST","PUT"],d={desc:"y"},v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),g=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),y=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:r,JsonqlAuthorisationError:n,JsonqlContractAuthError:o,JsonqlResolverAppError:i,JsonqlResolverNotFoundError:a,JsonqlEnumError:u,JsonqlTypeError:c,JsonqlCheckerError:s,JsonqlValidationError:l,JsonqlError:v,JsonqlServerError:g}),b=v;function _(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&y[o])throw new y[r](i,a);throw new b(i,a)}return t}function m(f){if(Array.isArray(f))throw new l("",f);var p=f.message||"No message",h=f.detail||f;switch(!0){case f instanceof t:throw new t(p,h);case f instanceof e:throw new e(p,h);case f instanceof r:throw new r(p,h);case f instanceof n:throw new n(p,h);case f instanceof o:throw new o(p,h);case f instanceof i:throw new i(p,h);case f instanceof a:throw new a(p,h);case f instanceof u:throw new u(p,h);case f instanceof c:throw new c(p,h);case f instanceof s:throw new s(p,h);case f instanceof l:throw new l(p,h);case f instanceof g:throw new g(p,h);default:throw new v(p,h)}}var w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol;function A(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&L(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var ot=function(t){return!!E(t)||null!=t&&""!==nt(t)};function it(t){return function(t){return"number"==typeof t||N(t)&&"[object Number]"==z(t)}(t)&&t!=+t}function at(t){return"string"==typeof t||!E(t)&&N(t)&&"[object String]"==z(t)}var ut=function(t){return!at(t)&&!it(parseFloat(t))},ct=function(t){return""!==nt(t)&&at(t)},st=function(t){return null!=t&&"boolean"==typeof t},lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==nt(t)&&(!1===e||!0===e&&null!==t)},ft=function(t){switch(t){case"number":return ut;case"string":return ct;case"boolean":return st;default:return lt}},pt=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===nt(e)||!(t.filter((function(t){return!ft(e)(t)})).length>0))},ht=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},dt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ft(e)(t)})).length)})).length:e.length>e.filter((function(t){return!pt(r,t)})).length};function vt(t,e){return function(r){return t(e(r))}}var gt=vt(Object.getPrototypeOf,Object),yt=Function.prototype,bt=Object.prototype,_t=yt.toString,mt=bt.hasOwnProperty,wt=_t.call(Object);function jt(t){if(!N(t)||"[object Object]"!=z(t))return!1;var e=gt(t);if(null===e)return!0;var r=mt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&_t.call(r)==wt}var St,Ot=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[St?a:++n];if(!1===e(o[u],u,o))break}return t};function kt(t){return N(t)&&"[object Arguments]"==z(t)}var At=Object.prototype,Et=At.hasOwnProperty,Tt=At.propertyIsEnumerable,xt=kt(function(){return arguments}())?kt:function(t){return N(t)&&Et.call(t,"callee")&&!Tt.call(t,"callee")};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=qt&&qt.exports===Pt?O.Buffer:void 0,$t=(Ct?Ct.isBuffer:void 0)||function(){return!1},zt=/^(?:0|[1-9]\d*)$/;function Nt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Rt={};Rt["[object Float32Array]"]=Rt["[object Float64Array]"]=Rt["[object Int8Array]"]=Rt["[object Int16Array]"]=Rt["[object Int32Array]"]=Rt["[object Uint8Array]"]=Rt["[object Uint8ClampedArray]"]=Rt["[object Uint16Array]"]=Rt["[object Uint32Array]"]=!0,Rt["[object Arguments]"]=Rt["[object Array]"]=Rt["[object ArrayBuffer]"]=Rt["[object Boolean]"]=Rt["[object DataView]"]=Rt["[object Date]"]=Rt["[object Error]"]=Rt["[object Function]"]=Rt["[object Map]"]=Rt["[object Number]"]=Rt["[object Object]"]=Rt["[object RegExp]"]=Rt["[object Set]"]=Rt["[object String]"]=Rt["[object WeakMap]"]=!1;var It,Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=Jt&&Jt.exports===Ft&&j.process,Lt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Ht=Lt&&Lt.isTypedArray,Dt=Ht?(It=Ht,function(t){return It(t)}):function(t){return N(t)&&Mt(t.length)&&!!Rt[z(t)]},Kt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=E(t),n=!r&&xt(t),o=!r&&!n&&$t(t),i=!r&&!n&&!o&&Dt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ie.prototype.set=function(t,e){var r=this.__data__,n=ne(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ae,ue=O["__core-js_shared__"],ce=(ae=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+ae:"";var se=Function.prototype.toString;function le(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,he=Object.prototype,de=pe.toString,ve=he.hasOwnProperty,ge=RegExp("^"+de.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ye(t){return!(!Qt(t)||function(t){return!!ce&&ce in t}(t))&&(Xt(t)?ge:fe).test(le(t))}function be(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ye(r)?r:void 0}var _e=be(O,"Map"),me=be(Object,"create");var we=Object.prototype.hasOwnProperty;var je=Object.prototype.hasOwnProperty;function Se(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var l=-1,f=!0,p=2&r?new Ee:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=ht(t))?!dt({arg:r},e):!ft(t)(r))})).length)})).length}return!1},Sr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(jr,null,a);case"array"===t:return!pt(e.arg);case!1!==(r=ht(t)):return!dt(e,r);default:return!ft(t)(e.arg)}},Or=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},kr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!pt(e))throw new v("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!pt(t))throw new v("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Or(t,a):t,index:r,param:a,optional:i}}));default:throw new v("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!ot(e)&&!(r.type.length>r.type.filter((function(e){return Sr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Sr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ar=function(){try{var t=be(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Er(t,e,r){"__proto__"==e&&Ar?Ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Tr(t,e,r){(void 0===r||re(t[e],r))&&(void 0!==r||e in t)||Er(t,e,r)}var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Pr&&Pr.exports===xr?O.Buffer:void 0,Cr=qr?qr.allocUnsafe:void 0;function $r(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pe(n).set(new Pe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var zr=Object.create,Nr=function(){function t(){}return function(e){if(!Qt(e))return{};if(zr)return zr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Rr=Object.prototype.hasOwnProperty;function Ir(t,e,r){var n=t[e];Rr.call(t,e)&&re(n,r)&&(void 0!==r||e in t)||Er(t,e,r)}var Fr=Object.prototype.hasOwnProperty;function Jr(t){if(!Qt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Ur(t){return Zt(t)?Bt(t,!0):Jr(t)}function Lr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Gr);function Wr(t,e){return Yr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Qt(r))return!1;var n=typeof e;return!!("number"==n?Zt(r)&&Nt(e,r.length):"string"==n&&e in r)&&re(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,yn(t))}),Reflect.apply(t,null,r))}};function mn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function wn(t,e,r,n){void 0===n&&(n=!1);var o=mn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var jn=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return dn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(m)}},Sn=function(t,e,r,n){var o;return!0===t.namespaced?(o=r)[e]=n:o=n,o},On=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=wn(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return dn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(m)}))};for(var u in o.query)a(u);return[Sn(n,"query",t,i),e,r,n,o]},kn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=wn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return dn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(m)}))};for(var u in o.mutation)a(u);return[Sn(n,"mutation",t,i),e,r,n,o]},An=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i=!1===n.namespaced?t:{},a=n.loginHandlerName,u=n.logoutHandlerName;return o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=jn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},Sn(n,"auth",t,i)}return t};var En=function(t,e,r,n){var o=function(t,e,r,n){var o=[On,kn,An];return Reflect.apply(_n,null,o)({},t,e,r,n)}(t,n,e,r);return o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.6.0",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.getUserdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function Tn(t){return!!function(t){return jt(t)&&(bn(t,"query")||bn(t,"mutation")||bn(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Pn(t){this.message=t}Pn.prototype=new Error,Pn.prototype.name="InvalidCharacterError";var qn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Pn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Cn=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(qn(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 qn(e)}};function $n(t){this.message=t}$n.prototype=new Error,$n.prototype.name="InvalidTokenError";var zn=function(t,e){if("string"!=typeof t)throw new $n("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Cn(t.split(".")[r]))}catch(t){throw new $n("Invalid token specified: "+t.message)}};zn.InvalidTokenError=$n;var Nn,Mn,Rn,In,Fn,Jn,Un,Ln,Hn;function Dn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new v("Token has expired on "+r,t)}return t}function Kn(t){if(ct(t))return Dn(zn(t));throw new v("Token must be a string!")}vn("HS256",["string"]),vn(!1,["boolean","number","string"],((Nn={}).alias="exp",Nn.optional=!0,Nn)),vn(!1,["boolean","number","string"],((Mn={}).alias="nbf",Mn.optional=!0,Mn)),vn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),vn(!1,["boolean","string"],((In={}).alias="sub",In.optional=!0,In)),vn(!1,["boolean","string"],((Fn={}).alias="iss",Fn.optional=!0,Fn)),vn(!1,["boolean"],((Jn={}).optional=!0,Jn)),vn(!1,["boolean","string"],((Un={}).optional=!0,Un)),vn(!1,["boolean","string"],((Ln={}).optional=!0,Ln)),vn(!1,["boolean"],((Hn={}).optional=!0,Hn));var Bn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Gn(t,e){var r;return(r={})[t]=e,r.TS=[Bn()],r}var Vn=function(t){return bn(t,"data")&&!bn(t,"error")?t.data:t},Yn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Wn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=_o().key(e);t(mo(r),r)}},remove:function(t){return _o().removeItem(t)},clearAll:function(){return _o().clear()}};function _o(){return yo.localStorage}function mo(t){return _o().getItem(t)}var wo=to.trim,jo={name:"cookieStorage",read:function(t){if(!t||!Ao(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(So.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;So.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Oo,remove:ko,clearAll:function(){Oo((function(t,e){ko(e)}))}},So=to.Global.document;function Oo(t){for(var e=So.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(wo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ko(t){t&&Ao(t)&&(So.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Ao(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(So.cookie)}var Eo=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 To=to.bind,xo=to.each,Po=to.create,qo=to.slice,Co=function(){var t=Po($o,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,To(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,To(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),xo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var $o={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,To(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=qo(arguments,1);xo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},zo=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(l=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),No=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=zo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=zo.compress(this._serialize(r));t(e,n)}}};var Mo=[bo,jo],Ro=[Eo,Co,No],Io=ho.createStore(Mo,Ro),Fo=to.Global;function Jo(){return Fo.sessionStorage}function Uo(t){return Jo().getItem(t)}var Lo=[{name:"sessionStorage",read:Uo,write:function(t,e){return Jo().setItem(t,e)},each:function(t){for(var e=Jo().length-1;e>=0;e--){var r=Jo().key(e);t(Uo(r),r)}},remove:function(t){return Jo().removeItem(t)},clearAll:function(){return Jo().clear()}},jo],Ho=[Eo,No],Do=ho.createStore(Lo,Ho),Ko=Io,Bo=Do,Go=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Ko,this.sessionStore=Bo},Vo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Go.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?Xr({},o,e):e,r))},Go.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Go.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Go.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Vo.lset.set=function(t){return this.__setMethod("localStore",t)},Vo.lget.get=function(){return this.__getMethod("localStore")},Go.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Go.prototype.lclear=function(){return this.__clearMethod("localStore")},Vo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Vo.sget.get=function(){return this.__getMethod("sessionStore")},Go.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Go.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Go.prototype,Vo);var Yo=h[0],Wo=h[1],Qo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Kn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(hn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new l("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&hn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Tn(t))throw new l("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Tn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Xr({},{_cb:Bn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Xr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Xr({},{method:Yo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Vn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=pn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Vn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new g("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Xr({},p,this.getAuthHeader(),this.extraHeader):Xr({},p,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Xr({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new g("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),at(t)&&E(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Gn(t,n)}throw new l("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(at(t))return Gn(t,o);throw new l("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Wo}).then(_)},Object.defineProperties(e.prototype,r),e}(Go)))),Xo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:f,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Zo={hostname:vn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return"/"}}(),["string"]),jsonqlPath:vn("jsonql",["string"]),loginHandlerName:vn("login",["string"]),logoutHandlerName:vn("logout",["string"]),enableJsonp:vn(!1,["boolean"]),enableAuth:vn(!1,["boolean"]),useJwt:vn(!0,["boolean"]),persistToken:vn(!1,["boolean","number"]),useLocalstorage:vn(!0,["boolean"]),storageKey:vn("jsonqlstore",["string"]),authKey:vn("jsonqlauthkey",["string"]),contractExpired:vn(0,["number"]),keepContract:vn(!0,["boolean"]),exposeContract:vn(!1,["boolean"]),exposeStore:vn(!1,["boolean"]),showContractDesc:vn(!1,["boolean"]),contractKey:vn(!1,["boolean"]),contractKeyName:vn("X-JSONQL-CV-KEY",["string"]),enableTimeout:vn(!1,["boolean"]),timeout:vn(5e3,["number"]),returnInstance:vn(!1,["boolean"]),allowReturnRawToken:vn(!1,["boolean"]),debugOn:vn(!1,["boolean"]),namespaced:vn(!1,["boolean"]),cacheResult:vn(!1,["boolean","number"]),cacheExcludedList:vn([],["array"])};function ti(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return wn(t,"__checked__",Bn())};r.push(o);var i=Reflect.apply(_n,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ei(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),mn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ti,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Zo,Xo,gn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ri(t,e,r){return void 0===r&&(r={}),ei(r).then((function(t){return{baseClient:new Qo(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),Tn(n)?Promise.resolve(n):r.getContract()).then((function(e){return En(o,i,e,t)}))}))}var ni=new WeakMap,oi=new WeakMap,ii=function(){this.__suspend__=null,this.queueStore=new Set},ai={$suspend:{configurable:!0},$queues:{configurable:!0}};ai.$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)},ii.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__},ai.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ii.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(ii.prototype,ai);var ui=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,l=0;l0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ni.set(this,t)},r.normalStore.get=function(){return ni.get(this)},r.lazyStore.set=function(t){oi.set(this,t)},r.lazyStore.get=function(){return oi.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(ii)));return function(t,e){var r;return ri((r=e.debugOn,new ui({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/core.js.map b/packages/http-client/core.js.map index 0a97fb6f095856855867d7422a5fab7c75369246..71527b94d84a5cd672bad2088c9bd0b171a666ea 100644 --- a/packages/http-client/core.js.map +++ b/packages/http-client/core.js.map @@ -1 +1 @@ -{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wl1CAAA"} \ No newline at end of file +{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"4s1CAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static-full.js b/packages/http-client/dist/jsonql-client.static-full.js index 4d034ee57a65f2d382829f9e465b002496d3fe1c..dc9d3dc113a3ce4f57f4e072a26f91f756a5664f 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js +++ b/packages/http-client/dist/jsonql-client.static-full.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,T=k.toString,A=E.hasOwnProperty,x=T.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=A.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&T.call(r)==x}function q(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&I(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},rt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),st=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),ft=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),lt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ht=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),dt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),vt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),gt=Object.freeze({__proto__:null,Jsonql406Error:nt,Jsonql500Error:ot,JsonqlForbiddenError:it,JsonqlAuthorisationError:at,JsonqlContractAuthError:ut,JsonqlResolverAppError:ct,JsonqlResolverNotFoundError:st,JsonqlEnumError:ft,JsonqlTypeError:lt,JsonqlCheckerError:pt,JsonqlValidationError:ht,JsonqlError:dt,JsonqlServerError:vt}),yt=dt;function bt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&>[o])throw new gt[r](i,a);throw new yt(i,a)}return t}function mt(t){if(Array.isArray(t))throw new ht("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof ht:throw new ht(e,r);case t instanceof vt:throw new vt(e,r);default:throw new dt(e,r)}}var _t=function(t){return!!s(t)||null!=t&&""!==Z(t)};function wt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}function jt(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var Ot=function(t){return!jt(t)&&!wt(parseFloat(t))},St=function(t){return""!==Z(t)&&jt(t)},kt=function(t){return null!=t&&"boolean"==typeof t},Et=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Tt=function(t){switch(t){case"number":return Ot;case"string":return St;case"boolean":return kt;default:return Et}},At=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Tt(e)(t)})).length>0))},xt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Pt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Tt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!At(r,t)})).length};var qt,Ct=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[qt?a:++n];if(!1===e(o[u],u,o))break}return t};function $t(t){return S(t)&&"[object Arguments]"==w(t)}var Nt=Object.prototype,zt=Nt.hasOwnProperty,Rt=Nt.propertyIsEnumerable,Mt=$t(function(){return arguments}())?$t:function(t){return S(t)&&zt.call(t,"callee")&&!Rt.call(t,"callee")};var It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=It&&"object"==typeof module&&module&&!module.nodeType&&module,Ft=Jt&&Jt.exports===It?h.Buffer:void 0,Ut=(Ft?Ft.isBuffer:void 0)||function(){return!1},Lt=/^(?:0|[1-9]\d*)$/;function Dt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Lt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Bt={};Bt["[object Float32Array]"]=Bt["[object Float64Array]"]=Bt["[object Int8Array]"]=Bt["[object Int16Array]"]=Bt["[object Int32Array]"]=Bt["[object Uint8Array]"]=Bt["[object Uint8ClampedArray]"]=Bt["[object Uint16Array]"]=Bt["[object Uint32Array]"]=!0,Bt["[object Arguments]"]=Bt["[object Array]"]=Bt["[object ArrayBuffer]"]=Bt["[object Boolean]"]=Bt["[object DataView]"]=Bt["[object Date]"]=Bt["[object Error]"]=Bt["[object Function]"]=Bt["[object Map]"]=Bt["[object Number]"]=Bt["[object Object]"]=Bt["[object RegExp]"]=Bt["[object Set]"]=Bt["[object String]"]=Bt["[object WeakMap]"]=!1;var Kt,Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Vt&&Vt.exports===Gt&&l.process,Yt=function(){try{var t=Vt&&Vt.require&&Vt.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch(t){}}(),Qt=Yt&&Yt.isTypedArray,Xt=Qt?(Kt=Qt,function(t){return Kt(t)}):function(t){return S(t)&&Ht(t.length)&&!!Bt[w(t)]},Zt=Object.prototype.hasOwnProperty;function te(t,e){var r=s(t),n=!r&&Mt(t),o=!r&&!n&&Ut(t),i=!r&&!n&&!o&&Xt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},he.prototype.set=function(t,e){var r=this.__data__,n=le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var de,ve=h["__core-js_shared__"],ge=(de=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";var ye=Function.prototype.toString;function be(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var me=/^\[object .+?Constructor\]$/,_e=Function.prototype,we=Object.prototype,je=_e.toString,Oe=we.hasOwnProperty,Se=RegExp("^"+je.call(Oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ke(t){return!(!ie(t)||function(t){return!!ge&&ge in t}(t))&&(ae(t)?Se:me).test(be(t))}function Ee(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ke(r)?r:void 0}var Te=Ee(h,"Map"),Ae=Ee(Object,"create");var xe=Object.prototype.hasOwnProperty;var Pe=Object.prototype.hasOwnProperty;function qe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=2&r?new ze:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=xt(t))?!Pt({arg:r},e):!Tt(t)(r))})).length)})).length}return!1},qr=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Pr,null,a);case"array"===t:return!At(e.arg);case!1!==(r=xt(t)):return!Pt(e,r);default:return!Tt(t)(e.arg)}},Cr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},$r=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!At(e))throw new dt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!At(t))throw new dt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Cr(t,a):t,index:r,param:a,optional:i}}));default:throw new dt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!_t(e)&&!(r.type.length>r.type.filter((function(e){return qr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return qr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Nr=function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function zr(t,e,r){"__proto__"==e&&Nr?Nr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Rr(t,e,r){(void 0===r||fe(t[e],r))&&(void 0!==r||e in t)||zr(t,e,r)}var Mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ir=Mr&&"object"==typeof module&&module&&!module.nodeType&&module,Jr=Ir&&Ir.exports===Mr?h.Buffer:void 0,Fr=Jr?Jr.allocUnsafe:void 0;function Ur(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ie(n).set(new Ie(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Lr=Object.create,Dr=function(){function t(){}return function(e){if(!ie(e))return{};if(Lr)return Lr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Hr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Br=Object.prototype.hasOwnProperty;function Kr(t,e,r){var n=t[e];Br.call(t,e)&&fe(n,r)&&(void 0!==r||e in t)||zr(t,e,r)}var Gr=Object.prototype.hasOwnProperty;function Vr(t){if(!ie(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=re(t),r=[];for(var n in t)("constructor"!=n||!e&&Gr.call(t,n))&&r.push(n);return r}function Wr(t){return ue(t)?te(t,!0):Vr(t)}function Yr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(en);function on(t,e){return nn(function(t,e,r){return e=tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=tn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=an.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ie(r))return!1;var n=typeof e;return!!("number"==n?ue(r)&&Dt(e,r.length):"string"==n&&e in r)&&fe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,tt(t))}),Reflect.apply(t,null,r))}};function En(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Tn(t,e,r,n){void 0===n&&(n=!1);var o=En(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var An=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return jn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mt)}},xn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return jn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Pn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return jn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},qn=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=An(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=An(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Cn=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(rt(e,r,"onResult"),o),t.$only(rt(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function $n(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(kn,null,o)({},t,e,r,n)}(t,e,r,n);!function(t,e,r,n){var o=t.$queues;n("(validateRegisteredEvents)","storedEvt",o),o.forEach((function(t){var r=t[0],o=t[1].resolverName;if(n("(validateRegisteredEvents)",r,o),!e[r][o])throw new Error(r+"."+o+" not existed in contract!")}))}(e,n,0,(function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,e)}));var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$call(rt(t,n,"onResult"))(r)})).catch((function(r){e.$trigger(rt(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function Nn(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function zn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Rn(t){this.message=t}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var In=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Mn(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Mn(e)}};function Jn(t){this.message=t}Jn.prototype=new Error,Jn.prototype.name="InvalidTokenError";var Fn=function(t,e){if("string"!=typeof t)throw new Jn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(In(t.split(".")[r]))}catch(t){throw new Jn("Invalid token specified: "+t.message)}};Fn.InvalidTokenError=Jn;var Un,Ln,Dn,Hn,Bn,Kn,Gn,Vn,Wn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new dt("Token has expired on "+r,t)}return t}function Qn(t){if(St(t))return Yn(Fn(t));throw new dt("Token must be a string!")}On("HS256",["string"]),On(!1,["boolean","number","string"],((Un={}).alias="exp",Un.optional=!0,Un)),On(!1,["boolean","number","string"],((Ln={}).alias="nbf",Ln.optional=!0,Ln)),On(!1,["boolean","string"],((Dn={}).alias="iss",Dn.optional=!0,Dn)),On(!1,["boolean","string"],((Hn={}).alias="sub",Hn.optional=!0,Hn)),On(!1,["boolean","string"],((Bn={}).alias="iss",Bn.optional=!0,Bn)),On(!1,["boolean"],((Kn={}).optional=!0,Kn)),On(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),On(!1,["boolean","string"],((Vn={}).optional=!0,Vn)),On(!1,["boolean"],((Wn={}).optional=!0,Wn));var Xn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zn(t,e){var r;return(r={})[t]=e,r.TS=[Xn()],r}var to=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},eo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=So().key(e);t(ko(r),r)}},remove:function(t){return So().removeItem(t)},clearAll:function(){return So().clear()}};function So(){return jo.localStorage}function ko(t){return So().getItem(t)}var Eo=io.trim,To={name:"cookieStorage",read:function(t){if(!t||!qo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ao.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ao.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:xo,remove:Po,clearAll:function(){xo((function(t,e){Po(e)}))}},Ao=io.Global.document;function xo(t){for(var e=Ao.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Eo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Po(t){t&&qo(t)&&(Ao.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function qo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ao.cookie)}var Co=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var $o=io.bind,No=io.each,zo=io.create,Ro=io.slice,Mo=function(){var t=zo(Io,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,$o(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,$o(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),No(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Io={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,$o(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Ro(arguments,1);No(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Jo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Fo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Jo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Jo.compress(this._serialize(r));t(e,n)}}};var Uo=[Oo,To],Lo=[Co,Mo,Fo],Do=mo.createStore(Uo,Lo),Ho=io.Global;function Bo(){return Ho.sessionStorage}function Ko(t){return Bo().getItem(t)}var Go=[{name:"sessionStorage",read:Ko,write:function(t,e){return Bo().setItem(t,e)},each:function(t){for(var e=Bo().length-1;e>=0;e--){var r=Bo().key(e);t(Ko(r),r)}},remove:function(t){return Bo().removeItem(t)},clearAll:function(){return Bo().clear()}},To],Vo=[Co,Fo],Wo=mo.createStore(Go,Vo),Yo=Do,Qo=Wo,Xo=function(t){this.opts=t,this.instanceKey=zn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Qo},Zo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Xo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?un({},o,e):e,r))},Xo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Xo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Xo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Zo.lset.set=function(t){return this.__setMethod("localStore",t)},Zo.lget.get=function(){return this.__getMethod("localStore")},Xo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Xo.prototype.lclear=function(){return this.__clearMethod("localStore")},Zo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Zo.sget.get=function(){return this.__getMethod("sessionStore")},Xo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Xo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Xo.prototype,Zo);var ti=u[0],ei=u[1],ri=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Qn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(wn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ht("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&wn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Nn(t))throw new ht("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Nn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=un({},{_cb:Xn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=un({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=un({},{method:ti,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return to(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=_n(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):to(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new vt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?un({},a,this.getAuthHeader(),this.extraHeader):un({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=un({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(bt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new vt("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),jt(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Zn(t,n)}throw new ht("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(jt(t))return Zn(t,o);throw new ht("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ei}).then(bt)},Object.defineProperties(e.prototype,r),e}(Xo)))),ni={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},oi={hostname:On(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:On("jsonql",["string"]),loginHandlerName:On("login",["string"]),logoutHandlerName:On("logout",["string"]),enableJsonp:On(!1,["boolean"]),enableAuth:On(!1,["boolean"]),useJwt:On(!0,["boolean"]),persistToken:On(!1,["boolean","number"]),useLocalstorage:On(!0,["boolean"]),storageKey:On("jsonqlstore",["string"]),authKey:On("jsonqlauthkey",["string"]),contractExpired:On(0,["number"]),keepContract:On(!0,["boolean"]),exposeContract:On(!1,["boolean"]),exposeStore:On(!1,["boolean"]),showContractDesc:On(!1,["boolean"]),contractKey:On(!1,["boolean"]),contractKeyName:On("X-JSONQL-CV-KEY",["string"]),enableTimeout:On(!1,["boolean"]),timeout:On(5e3,["number"]),returnInstance:On(!1,["boolean"]),allowReturnRawToken:On(!1,["boolean"]),debugOn:On(!1,["boolean"])};var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ui.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ui.prototype,ci);var si=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return zn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r,n=e.contract,o=function(t){return En(t,"__checked__")?Object.assign(t,ni):Sn(t,oi,ni)}(e),i=new ri(t,o),a=function(t,e){return void 0===e&&(e={}),Nn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new si({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){$n(t,n,e,r)})),{query:Cn(n,"query"),mutation:Cn(n,"mutation"),auth:Cn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c.getLogger=function(t){return function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(jsonqlInstance.log,jsonqlInstance,[t].concat(e))}},c}return function(t){return void 0===t&&(t={}),fi(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlStaticClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),s=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),f=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),p=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),h=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"y"},_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),w=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||F(t)&&"[object Number]"==J(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&F(t)&&"[object String]"==J(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!F(t)||"[object Object]"!=J(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return F(t)&&"[object Arguments]"==J(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return F(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Jt=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Jt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Dt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Yt=Vt?(Dt=Vt,function(t){return Dt(t)}):function(t){return F(t)&&Ut(t.length)&&!!Lt[J(t)]},Wt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Yt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Jr=Object.create,Fr=function(){function t(){}return function(e){if(!re(e))return{};if(Jr)return Jr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Lr=Object.prototype.hasOwnProperty;function Dr(t,e,r){var n=t[e];Lr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Ft(e,r.length):"string"==n&&e in r)&&ue(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n){var o;return!0===t.namespaced?(o=r)[e]=n:o=n,o},xn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=En(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return[An(n,"query",t,i),e,r,n,o]},Pn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return[An(n,"mutation",t,i),e,r,n,o]},qn=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i=!1===n.namespaced?t:{},a=n.loginHandlerName,u=n.logoutHandlerName;return o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},An(n,"auth",t,i)}return t};var Cn=function(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.6.0",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.getUserdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function $n(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function zn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidCharacterError";var Rn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Nn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Mn=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(Rn(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 Rn(e)}};function In(t){this.message=t}In.prototype=new Error,In.prototype.name="InvalidTokenError";var Jn=function(t,e){if("string"!=typeof t)throw new In("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Mn(t.split(".")[r]))}catch(t){throw new In("Invalid token specified: "+t.message)}};Jn.InvalidTokenError=In;var Fn,Un,Ln,Dn,Hn,Bn,Kn,Gn,Vn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Yn(Jn(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Fn={}).alias="exp",Fn.optional=!0,Fn)),_n(!1,["boolean","number","string"],((Un={}).alias="nbf",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),_n(!1,["boolean","string"],((Dn={}).alias="sub",Dn.optional=!0,Dn)),_n(!1,["boolean","string"],((Hn={}).alias="iss",Hn.optional=!0,Hn)),_n(!1,["boolean"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),_n(!1,["boolean"],((Vn={}).optional=!0,Vn));var Qn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Xn(t,e){var r;return(r={})[t]=e,r.TS=[Qn()],r}var Zn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},to=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Oo().key(e);t(So(r),r)}},remove:function(t){return Oo().removeItem(t)},clearAll:function(){return Oo().clear()}};function Oo(){return wo.localStorage}function So(t){return Oo().getItem(t)}var ko=oo.trim,Eo={name:"cookieStorage",read:function(t){if(!t||!Po(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(To.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;To.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ao,remove:xo,clearAll:function(){Ao((function(t,e){xo(e)}))}},To=oo.Global.document;function Ao(t){for(var e=To.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ko(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function xo(t){t&&Po(t)&&(To.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Po(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(To.cookie)}var qo=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 Co=oo.bind,$o=oo.each,zo=oo.create,No=oo.slice,Ro=function(){var t=zo(Mo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Co(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Co(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),$o(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Mo={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Co(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=No(arguments,1);$o(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Io=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Jo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Io.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Io.compress(this._serialize(r));t(e,n)}}};var Fo=[jo,Eo],Uo=[qo,Ro,Jo],Lo=bo.createStore(Fo,Uo),Do=oo.Global;function Ho(){return Do.sessionStorage}function Bo(t){return Ho().getItem(t)}var Ko=[{name:"sessionStorage",read:Bo,write:function(t,e){return Ho().setItem(t,e)},each:function(t){for(var e=Ho().length-1;e>=0;e--){var r=Ho().key(e);t(Bo(r),r)}},remove:function(t){return Ho().removeItem(t)},clearAll:function(){return Ho().clear()}},Eo],Go=[qo,Jo],Vo=bo.createStore(Ko,Go),Yo=Lo,Wo=Vo,Qo=function(t){this.opts=t,this.instanceKey=zn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Wo},Xo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Qo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?nn({},o,e):e,r))},Qo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Qo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Qo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Xo.lset.set=function(t){return this.__setMethod("localStore",t)},Xo.lget.get=function(){return this.__getMethod("localStore")},Qo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Qo.prototype.lclear=function(){return this.__clearMethod("localStore")},Xo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Xo.sget.get=function(){return this.__getMethod("sessionStore")},Qo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Qo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Qo.prototype,Xo);var Zo=b[0],ti=b[1],ei=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Wn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&bn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!$n(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=$n(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=nn({},{_cb:Qn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Zo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Zn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Zn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new w("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Xn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Xn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ti}).then(S)},Object.defineProperties(e.prototype,r),e}(Qo)))),ri={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ni={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return"/"}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"]),namespaced:_n(!1,["boolean"]),cacheResult:_n(!1,["boolean","number"]),cacheExcludedList:_n([],["array"])};function oi(t,e,r){void 0===r&&(r={});var n=r.contract,o=function(t){return kn(t,"__checked__")?Object.assign(t,ri):wn(t,ni,ri)}(r),i=new ei(e,o);return Cn(i,o,n,t)}var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ui.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ui.prototype,ci);var si=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return zn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r;if(e.contract&&$n(e.contract))return oi((r=e.debugOn,new si({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e);throw new _("jsonqlStaticClient","Expect to pass the contract via configuration!")}return function(t){return void 0===t&&(t={}),fi(new o,t)}})); //# sourceMappingURL=jsonql-client.static-full.js.map diff --git a/packages/http-client/dist/jsonql-client.static-full.js.map b/packages/http-client/dist/jsonql-client.static-full.js.map index 3c65edf105d418c4a40f6d5cd83342e251675506..02809d71cd9d578234c9f57cdcca0f383eb6f1eb 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js.map +++ b/packages/http-client/dist/jsonql-client.static-full.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wriDAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"k1hDAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 22e6d724a00b8d0930972b76e85f9c4b8632078c..006bac22c0c9ce5437ec7f4bfbb123e47b6faf80 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-client.static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlClientStatic={})}(this,(function(t){"use strict";var e="application/vnd.api+json",r={Accept:e,"Content-Type":[e,"charset=utf-8"].join(";")},n=["POST","PUT"],o={desc:"y"},i=Array.isArray,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,s=u||c||Function("return this")(),l=s.Symbol,f=Object.prototype,p=f.hasOwnProperty,h=f.toString,d=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return v.call(t)}(t)}function b(t,e){return function(r){return t(e(r))}}var _=b(Object.getPrototypeOf,Object);function m(t){return null!=t&&"object"==typeof t}var w=Function.prototype,j=Object.prototype,S=w.toString,O=j.hasOwnProperty,k=S.call(Object);function E(t){if(!m(t)||"[object Object]"!=y(t))return!1;var e=_(t);if(null===e)return!0;var r=O.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&S.call(r)==k}function A(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&z(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Y=function(t){return i(t)?t:[t]},Q=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),st=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),lt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ft=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),pt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlForbiddenError:et,JsonqlAuthorisationError:rt,JsonqlContractAuthError:nt,JsonqlResolverAppError:ot,JsonqlResolverNotFoundError:it,JsonqlEnumError:at,JsonqlTypeError:ut,JsonqlCheckerError:ct,JsonqlValidationError:st,JsonqlError:lt,JsonqlServerError:ft}),ht=lt;function dt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&pt[o])throw new pt[r](i,a);throw new ht(i,a)}return t}function vt(t){if(Array.isArray(t))throw new st("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);default:throw new lt(e,r)}}var gt=function(t){return!!i(t)||null!=t&&""!==W(t)};function yt(t){return function(t){return"number"==typeof t||m(t)&&"[object Number]"==y(t)}(t)&&t!=+t}function bt(t){return"string"==typeof t||!i(t)&&m(t)&&"[object String]"==y(t)}var _t=function(t){return!bt(t)&&!yt(parseFloat(t))},mt=function(t){return""!==W(t)&&bt(t)},wt=function(t){return null!=t&&"boolean"==typeof t},jt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==W(t)&&(!1===e||!0===e&&null!==t)},St=function(t){switch(t){case"number":return _t;case"string":return mt;case"boolean":return wt;default:return jt}},Ot=function(t,e){return void 0===e&&(e=""),!!i(t)&&(""===e||""===W(e)||!(t.filter((function(t){return!St(e)(t)})).length>0))},kt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Et=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!St(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Ot(r,t)})).length};var At,Tt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function qt(t){return m(t)&&"[object Arguments]"==y(t)}var Pt=Object.prototype,xt=Pt.hasOwnProperty,Ct=Pt.propertyIsEnumerable,$t=qt(function(){return arguments}())?qt:function(t){return m(t)&&xt.call(t,"callee")&&!Ct.call(t,"callee")};var zt="object"==typeof t&&t&&!t.nodeType&&t,Nt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=Nt&&Nt.exports===zt?s.Buffer:void 0,Mt=(Rt?Rt.isBuffer:void 0)||function(){return!1},It=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&It.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof t&&t&&!t.nodeType&&t,Dt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Dt&&Dt.exports===Ht&&u.process,Bt=function(){try{var t=Dt&&Dt.require&&Dt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Gt=Bt&&Bt.isTypedArray,Vt=Gt?(Lt=Gt,function(t){return Lt(t)}):function(t){return m(t)&&Jt(t.length)&&!!Ut[y(t)]},Wt=Object.prototype.hasOwnProperty;function Yt(t,e){var r=i(t),n=!r&&$t(t),o=!r&&!n&&Mt(t),a=!r&&!n&&!o&&Vt(t),u=r||n||o||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},se.prototype.set=function(t,e){var r=this.__data__,n=ue(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,fe=s["__core-js_shared__"],pe=(le=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var he=Function.prototype.toString;function de(t){if(null!=t){try{return he.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ve=/^\[object .+?Constructor\]$/,ge=Function.prototype,ye=Object.prototype,be=ge.toString,_e=ye.hasOwnProperty,me=RegExp("^"+be.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function we(t){return!(!ee(t)||function(t){return!!pe&&pe in t}(t))&&(re(t)?me:ve).test(de(t))}function je(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return we(r)?r:void 0}var Se=je(s,"Map"),Oe=je(Object,"create");var ke=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;function Ae(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var l=-1,f=!0,p=2&r?new xe:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=kt(t))?!Et({arg:r},e):!St(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Er,null,a);case"array"===t:return!Ot(e.arg);case!1!==(r=kt(t)):return!Et(e,r);default:return!St(t)(e.arg)}},Tr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},qr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Ot(e))throw new lt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Ot(t))throw new lt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Tr(t,a):t,index:r,param:a,optional:i}}));default:throw new lt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!gt(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Pr=function(){try{var t=je(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function xr(t,e,r){"__proto__"==e&&Pr?Pr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Cr(t,e,r){(void 0===r||ae(t[e],r))&&(void 0!==r||e in t)||xr(t,e,r)}var $r="object"==typeof t&&t&&!t.nodeType&&t,zr=$r&&"object"==typeof module&&module&&!module.nodeType&&module,Nr=zr&&zr.exports===$r?s.Buffer:void 0,Rr=Nr?Nr.allocUnsafe:void 0;function Mr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ze(n).set(new ze(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ir=Object.create,Fr=function(){function t(){}return function(e){if(!ee(e))return{};if(Ir)return Ir(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Jr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ur=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Ur.call(t,e)&&ae(n,r)&&(void 0!==r||e in t)||xr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Dr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return ne(t)?Yt(t,!0):Dr(t)}function Br(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Qr);function tn(t,e){return Zr(function(t,e,r){return e=Yr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Yr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=en.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?ne(r)&&Ft(e,r.length):"string"==n&&e in r)&&ae(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Y(t))}),Reflect.apply(t,null,r))}};function jn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Sn(t,e,r,n){void 0===n&&(n=!1);var o=jn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var On=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return bn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},kn=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return bn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},En=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return bn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},An=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=On(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=On(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Tn=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(X(e,r,"onResult"),o),t.$only(X(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function qn(t,e,r,n){var o=function(t,e,r,n){var o=[kn,En,An];return Reflect.apply(wn,null,o)({},t,e,r,n)}(t,e,r,n);!function(t,e,r,n){var o=t.$queues;n("(validateRegisteredEvents)","storedEvt",o),o.forEach((function(t){var r=t[0],o=t[1].resolverName;if(n("(validateRegisteredEvents)",r,o),!e[r][o])throw new Error(r+"."+o+" not existed in contract!")}))}(e,n,0,(function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,e)}));var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$call(X(t,n,"onResult"))(r)})).catch((function(r){e.$trigger(X(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function Pn(t){return!!function(t){return E(t)&&(Q(t,"query")||Q(t,"mutation")||Q(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidCharacterError";var $n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Cn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var zn=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent($n(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return $n(e)}};function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidTokenError";var Rn=function(t,e){if("string"!=typeof t)throw new Nn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(zn(t.split(".")[r]))}catch(t){throw new Nn("Invalid token specified: "+t.message)}};Rn.InvalidTokenError=Nn;var Mn,In,Fn,Jn,Un,Ln,Hn,Dn,Kn;function Bn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new lt("Token has expired on "+r,t)}return t}function Gn(t){if(mt(t))return Bn(Rn(t));throw new lt("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Mn={}).alias="exp",Mn.optional=!0,Mn)),_n(!1,["boolean","number","string"],((In={}).alias="nbf",In.optional=!0,In)),_n(!1,["boolean","string"],((Fn={}).alias="iss",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Jn={}).alias="sub",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean"],((Ln={}).optional=!0,Ln)),_n(!1,["boolean","string"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Dn={}).optional=!0,Dn)),_n(!1,["boolean"],((Kn={}).optional=!0,Kn));var Vn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Wn(t,e){var r;return(r={})[t]=e,r.TS=[Vn()],r}var Yn=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},Qn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Xn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=wo().key(e);t(jo(r),r)}},remove:function(t){return wo().removeItem(t)},clearAll:function(){return wo().clear()}};function wo(){return _o.localStorage}function jo(t){return wo().getItem(t)}var So=ro.trim,Oo={name:"cookieStorage",read:function(t){if(!t||!To(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ko.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ko.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Eo,remove:Ao,clearAll:function(){Eo((function(t,e){Ao(e)}))}},ko=ro.Global.document;function Eo(t){for(var e=ko.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&To(t)&&(ko.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function To(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ko.cookie)}var qo=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 Po=ro.bind,xo=ro.each,Co=ro.create,$o=ro.slice,zo=function(){var t=Co(No,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Po(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Po(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),xo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var No={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Po(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=$o(arguments,1);xo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Ro=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(l=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Mo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ro.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ro.compress(this._serialize(r));t(e,n)}}};var Io=[mo,Oo],Fo=[qo,zo,Mo],Jo=go.createStore(Io,Fo),Uo=ro.Global;function Lo(){return Uo.sessionStorage}function Ho(t){return Lo().getItem(t)}var Do=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},Oo],Ko=[qo,Mo],Bo=go.createStore(Do,Ko),Go=Jo,Vo=Bo,Wo=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Go,this.sessionStore=Vo},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Wo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?rn({},o,e):e,r))},Wo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Wo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Wo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Wo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Wo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Wo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Wo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Wo.prototype,Yo);var Qo=n[0],Xo=n[1],Zo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Gn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(yn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new st("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&yn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Pn(t))throw new st("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Pn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=rn({},{_cb:Vn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=rn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=rn({},{method:Qo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Yn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=gn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Yn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new ft("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?rn({},r,this.getAuthHeader(),this.extraHeader):rn({},r,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=rn({},this.extraParams,o)),this.request({},{method:"GET"},this.contractHeader).then(dt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new ft("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),bt(t)&&i(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Wn(t,n)}throw new st("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(bt(t))return Wn(t,o);throw new st("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xo}).then(dt)},Object.defineProperties(e.prototype,n),e}(Wo)))),ti={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:e,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ei={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},oi.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(oi.prototype,ii);var ai=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,l=0;l0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r,n=e.contract,o=function(t){return jn(t,"__checked__")?Object.assign(t,ti):mn(t,ei,ti)}(e),i=new Zo(t,o),a=function(t,e){return void 0===e&&(e={}),Pn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){qn(t,n,e,r)})),{query:Tn(n,"query"),mutation:Tn(n,"mutation"),auth:Tn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c.getLogger=function(t){return function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(jsonqlInstance.log,jsonqlInstance,[t].concat(e))}},c},Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlStaticClient={})}(this,(function(t){"use strict";var e=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),r=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),n=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),o=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"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),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),f=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),p="application/vnd.api+json",h={Accept:p,"Content-Type":[p,"charset=utf-8"].join(";")},d=["POST","PUT"],v={desc:"y"},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={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),y=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),b=Object.freeze({__proto__:null,Jsonql406Error:e,Jsonql500Error:r,JsonqlForbiddenError:n,JsonqlAuthorisationError:o,JsonqlContractAuthError:i,JsonqlResolverAppError:a,JsonqlResolverNotFoundError:u,JsonqlEnumError:c,JsonqlTypeError:s,JsonqlCheckerError:l,JsonqlValidationError:f,JsonqlError:g,JsonqlServerError:y}),_=g;function m(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&b[o])throw new b[r](i,a);throw new _(i,a)}return t}function w(t){if(Array.isArray(t))throw new f("",t);var p=t.message||"No message",h=t.detail||t;switch(!0){case t instanceof e:throw new e(p,h);case t instanceof r:throw new r(p,h);case t instanceof n:throw new n(p,h);case t instanceof o:throw new o(p,h);case t instanceof i:throw new i(p,h);case t instanceof a:throw new a(p,h);case t instanceof u:throw new u(p,h);case t instanceof c:throw new c(p,h);case t instanceof s:throw new s(p,h);case t instanceof l:throw new l(p,h);case t instanceof f:throw new f(p,h);case t instanceof y:throw new y(p,h);default:throw new g(p,h)}}var j="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},S="object"==typeof j&&j&&j.Object===Object&&j,O="object"==typeof self&&self&&self.Object===Object&&self,k=S||O||Function("return this")(),A=k.Symbol;function E(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--&&H(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var it=function(t){return!!T(t)||null!=t&&""!==ot(t)};function at(t){return function(t){return"number"==typeof t||M(t)&&"[object Number]"==N(t)}(t)&&t!=+t}function ut(t){return"string"==typeof t||!T(t)&&M(t)&&"[object String]"==N(t)}var ct=function(t){return!ut(t)&&!at(parseFloat(t))},st=function(t){return""!==ot(t)&&ut(t)},lt=function(t){return null!=t&&"boolean"==typeof t},ft=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ot(t)&&(!1===e||!0===e&&null!==t)},pt=function(t){switch(t){case"number":return ct;case"string":return st;case"boolean":return lt;default:return ft}},ht=function(t,e){return void 0===e&&(e=""),!!T(t)&&(""===e||""===ot(e)||!(t.filter((function(t){return!pt(e)(t)})).length>0))},dt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},vt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!pt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ht(r,t)})).length};function gt(t,e){return function(r){return t(e(r))}}var yt=gt(Object.getPrototypeOf,Object),bt=Function.prototype,_t=Object.prototype,mt=bt.toString,wt=_t.hasOwnProperty,jt=mt.call(Object);function St(t){if(!M(t)||"[object Object]"!=N(t))return!1;var e=yt(t);if(null===e)return!0;var r=wt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&mt.call(r)==jt}var Ot,kt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[Ot?a:++n];if(!1===e(o[u],u,o))break}return t};function At(t){return M(t)&&"[object Arguments]"==N(t)}var Et=Object.prototype,Tt=Et.hasOwnProperty,xt=Et.propertyIsEnumerable,Pt=At(function(){return arguments}())?At:function(t){return M(t)&&Tt.call(t,"callee")&&!xt.call(t,"callee")};var qt="object"==typeof t&&t&&!t.nodeType&&t,Ct=qt&&"object"==typeof module&&module&&!module.nodeType&&module,$t=Ct&&Ct.exports===qt?k.Buffer:void 0,zt=($t?$t.isBuffer:void 0)||function(){return!1},Nt=/^(?:0|[1-9]\d*)$/;function Mt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Nt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Rt={};Rt["[object Float32Array]"]=Rt["[object Float64Array]"]=Rt["[object Int8Array]"]=Rt["[object Int16Array]"]=Rt["[object Int32Array]"]=Rt["[object Uint8Array]"]=Rt["[object Uint8ClampedArray]"]=Rt["[object Uint16Array]"]=Rt["[object Uint32Array]"]=!0,Rt["[object Arguments]"]=Rt["[object Array]"]=Rt["[object ArrayBuffer]"]=Rt["[object Boolean]"]=Rt["[object DataView]"]=Rt["[object Date]"]=Rt["[object Error]"]=Rt["[object Function]"]=Rt["[object Map]"]=Rt["[object Number]"]=Rt["[object Object]"]=Rt["[object RegExp]"]=Rt["[object Set]"]=Rt["[object String]"]=Rt["[object WeakMap]"]=!1;var Ft,Jt="object"==typeof t&&t&&!t.nodeType&&t,Ut=Jt&&"object"==typeof module&&module&&!module.nodeType&&module,Lt=Ut&&Ut.exports===Jt&&S.process,Ht=function(){try{var t=Ut&&Ut.require&&Ut.require("util").types;return t||Lt&&Lt.binding&&Lt.binding("util")}catch(t){}}(),Dt=Ht&&Ht.isTypedArray,Kt=Dt?(Ft=Dt,function(t){return Ft(t)}):function(t){return M(t)&&It(t.length)&&!!Rt[N(t)]},Bt=Object.prototype.hasOwnProperty;function Gt(t,e){var r=T(t),n=!r&&Pt(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Kt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ae.prototype.set=function(t,e){var r=this.__data__,n=oe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ue,ce=k["__core-js_shared__"],se=(ue=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||""))?"Symbol(src)_1."+ue:"";var le=Function.prototype.toString;function fe(t){if(null!=t){try{return le.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var pe=/^\[object .+?Constructor\]$/,he=Function.prototype,de=Object.prototype,ve=he.toString,ge=de.hasOwnProperty,ye=RegExp("^"+ve.call(ge).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function be(t){return!(!Xt(t)||function(t){return!!se&&se in t}(t))&&(Zt(t)?ye:pe).test(fe(t))}function _e(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return be(r)?r:void 0}var me=_e(k,"Map"),we=_e(Object,"create");var je=Object.prototype.hasOwnProperty;var Se=Object.prototype.hasOwnProperty;function Oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var l=-1,f=!0,p=2&r?new Te:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=dt(t))?!vt({arg:r},e):!pt(t)(r))})).length)})).length}return!1},Or=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Sr,null,a);case"array"===t:return!ht(e.arg);case!1!==(r=dt(t)):return!vt(e,r);default:return!pt(t)(e.arg)}},kr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Ar=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ht(e))throw new g("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ht(t))throw new g("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?kr(t,a):t,index:r,param:a,optional:i}}));default:throw new g("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!!it(e)&&!(r.type.length>r.type.filter((function(e){return Or(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Or(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Er=function(){try{var t=_e(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Tr(t,e,r){"__proto__"==e&&Er?Er(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function xr(t,e,r){(void 0===r||ne(t[e],r))&&(void 0!==r||e in t)||Tr(t,e,r)}var Pr="object"==typeof t&&t&&!t.nodeType&&t,qr=Pr&&"object"==typeof module&&module&&!module.nodeType&&module,Cr=qr&&qr.exports===Pr?k.Buffer:void 0,$r=Cr?Cr.allocUnsafe:void 0;function zr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new qe(n).set(new qe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Nr=Object.create,Mr=function(){function t(){}return function(e){if(!Xt(e))return{};if(Nr)return Nr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ir(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Rr=Object.prototype.hasOwnProperty;function Fr(t,e,r){var n=t[e];Rr.call(t,e)&&ne(n,r)&&(void 0!==r||e in t)||Tr(t,e,r)}var Jr=Object.prototype.hasOwnProperty;function Ur(t){if(!Xt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Yt(t),r=[];for(var n in t)("constructor"!=n||!e&&Jr.call(t,n))&&r.push(n);return r}function Lr(t){return te(t)?Gt(t,!0):Ur(t)}function Hr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Vr);function Qr(t,e){return Wr(function(t,e,r){return e=Gr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Gr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Xr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Xt(r))return!1;var n=typeof e;return!!("number"==n?te(r)&&Mt(e,r.length):"string"==n&&e in r)&&ne(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,bn(t))}),Reflect.apply(t,null,r))}};function wn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function jn(t,e,r,n){void 0===n&&(n=!1);var o=wn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Sn=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 vn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(w)}},On=function(t,e,r,n){var o;return!0===t.namespaced?(o=r)[e]=n:o=n,o},kn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=jn(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return vn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(w)}))};for(var u in o.query)a(u);return[On(n,"query",t,i),e,r,n,o]},An=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=jn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return vn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(w)}))};for(var u in o.mutation)a(u);return[On(n,"mutation",t,i),e,r,n,o]},En=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i=!1===n.namespaced?t:{},a=n.loginHandlerName,u=n.logoutHandlerName;return o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Sn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Sn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},On(n,"auth",t,i)}return t};var Tn=function(t,e,r,n){var o=function(t,e,r,n){var o=[kn,An,En];return Reflect.apply(mn,null,o)({},t,e,r,n)}(t,n,e,r);return o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.6.0",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.getUserdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function xn(t){return!!function(t){return St(t)&&(_n(t,"query")||_n(t,"mutation")||_n(t,"socket"))}(t)&&t}function Pn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function qn(t){this.message=t}qn.prototype=new Error,qn.prototype.name="InvalidCharacterError";var Cn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new qn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var $n=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(Cn(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 Cn(e)}};function zn(t){this.message=t}zn.prototype=new Error,zn.prototype.name="InvalidTokenError";var Nn=function(t,e){if("string"!=typeof t)throw new zn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse($n(t.split(".")[r]))}catch(t){throw new zn("Invalid token specified: "+t.message)}};Nn.InvalidTokenError=zn;var Mn,In,Rn,Fn,Jn,Un,Ln,Hn,Dn;function Kn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new g("Token has expired on "+r,t)}return t}function Bn(t){if(st(t))return Kn(Nn(t));throw new g("Token must be a string!")}gn("HS256",["string"]),gn(!1,["boolean","number","string"],((Mn={}).alias="exp",Mn.optional=!0,Mn)),gn(!1,["boolean","number","string"],((In={}).alias="nbf",In.optional=!0,In)),gn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),gn(!1,["boolean","string"],((Fn={}).alias="sub",Fn.optional=!0,Fn)),gn(!1,["boolean","string"],((Jn={}).alias="iss",Jn.optional=!0,Jn)),gn(!1,["boolean"],((Un={}).optional=!0,Un)),gn(!1,["boolean","string"],((Ln={}).optional=!0,Ln)),gn(!1,["boolean","string"],((Hn={}).optional=!0,Hn)),gn(!1,["boolean"],((Dn={}).optional=!0,Dn));var Gn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Vn(t,e){var r;return(r={})[t]=e,r.TS=[Gn()],r}var Yn=function(t){return _n(t,"data")&&!_n(t,"error")?t.data:t},Wn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Qn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=mo().key(e);t(wo(r),r)}},remove:function(t){return mo().removeItem(t)},clearAll:function(){return mo().clear()}};function mo(){return bo.localStorage}function wo(t){return mo().getItem(t)}var jo=eo.trim,So={name:"cookieStorage",read:function(t){if(!t||!Eo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Oo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Oo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ko,remove:Ao,clearAll:function(){ko((function(t,e){Ao(e)}))}},Oo=eo.Global.document;function ko(t){for(var e=Oo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(jo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&Eo(t)&&(Oo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Eo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Oo.cookie)}var To=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 xo=eo.bind,Po=eo.each,qo=eo.create,Co=eo.slice,$o=function(){var t=qo(zo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,xo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,xo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Po(r,(function(e,r){t.fire(r,void 0,e)}))}}};var zo={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,xo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Co(arguments,1);Po(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},No=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(l=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Mo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=No.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=No.compress(this._serialize(r));t(e,n)}}};var Io=[_o,So],Ro=[To,$o,Mo],Fo=vo.createStore(Io,Ro),Jo=eo.Global;function Uo(){return Jo.sessionStorage}function Lo(t){return Uo().getItem(t)}var Ho=[{name:"sessionStorage",read:Lo,write:function(t,e){return Uo().setItem(t,e)},each:function(t){for(var e=Uo().length-1;e>=0;e--){var r=Uo().key(e);t(Lo(r),r)}},remove:function(t){return Uo().removeItem(t)},clearAll:function(){return Uo().clear()}},So],Do=[To,Mo],Ko=vo.createStore(Ho,Do),Bo=Fo,Go=Ko,Vo=function(t){this.opts=t,this.instanceKey=Pn(this.opts.hostname),this.localStore=Bo,this.sessionStore=Go},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Vo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?Zr({},o,e):e,r))},Vo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Vo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Vo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Vo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Vo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Vo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Vo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Vo.prototype,Yo);var Wo=d[0],Qo=d[1],Xo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Bn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(dn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new f("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&dn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!xn(t))throw new f("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=xn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Zr({},{_cb:Gn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Zr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Zr({},{method:Wo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Yn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=hn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Yn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new y("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Zr({},h,this.getAuthHeader(),this.extraHeader):Zr({},h,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Zr({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(m).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new y("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),ut(t)&&T(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Vn(t,n)}throw new f("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(m)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(ut(t))return Vn(t,o);throw new f("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Qo}).then(m)},Object.defineProperties(e.prototype,r),e}(Vo)))),Zo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:p,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ti={hostname:gn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return"/"}}(),["string"]),jsonqlPath:gn("jsonql",["string"]),loginHandlerName:gn("login",["string"]),logoutHandlerName:gn("logout",["string"]),enableJsonp:gn(!1,["boolean"]),enableAuth:gn(!1,["boolean"]),useJwt:gn(!0,["boolean"]),persistToken:gn(!1,["boolean","number"]),useLocalstorage:gn(!0,["boolean"]),storageKey:gn("jsonqlstore",["string"]),authKey:gn("jsonqlauthkey",["string"]),contractExpired:gn(0,["number"]),keepContract:gn(!0,["boolean"]),exposeContract:gn(!1,["boolean"]),exposeStore:gn(!1,["boolean"]),showContractDesc:gn(!1,["boolean"]),contractKey:gn(!1,["boolean"]),contractKeyName:gn("X-JSONQL-CV-KEY",["string"]),enableTimeout:gn(!1,["boolean"]),timeout:gn(5e3,["number"]),returnInstance:gn(!1,["boolean"]),allowReturnRawToken:gn(!1,["boolean"]),debugOn:gn(!1,["boolean"]),namespaced:gn(!1,["boolean"]),cacheResult:gn(!1,["boolean","number"]),cacheExcludedList:gn([],["array"])};function ei(t,e,r){void 0===r&&(r={});var n=r.contract,o=function(t){return wn(t,"__checked__")?Object.assign(t,Zo):yn(t,ti,Zo)}(r),i=new Xo(e,o);return Tn(i,o,n,t)}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},oi.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(oi.prototype,ii);var ai=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,l=0;l0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return Pn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r;if(e.contract&&xn(e.contract))return ei((r=e.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e);throw new g("jsonqlStaticClient","Expect to pass the contract via configuration!")},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js.map b/packages/http-client/dist/jsonql-client.static.js.map index f7669d589917db43b742ee52ae09ef16d768915d..adaeb2f654e2a63d552aa822192a0759a9554af2 100644 --- a/packages/http-client/dist/jsonql-client.static.js.map +++ b/packages/http-client/dist/jsonql-client.static.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"k/1CAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"mp1CAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index 6eddf4664f21abef62930577ac0b0d37e27976f9..a4e221cdb746e7e48c049437a1dc7ba6ca818d5d 100644 --- a/packages/http-client/dist/jsonql-client.umd.js +++ b/packages/http-client/dist/jsonql-client.umd.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),s=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),f=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),p=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),h=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"y"},_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),w=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||F(t)&&"[object Number]"==J(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&F(t)&&"[object String]"==J(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!F(t)||"[object Object]"!=J(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return F(t)&&"[object Arguments]"==J(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return F(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Jt=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Jt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Dt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Wt=Vt?(Dt=Vt,function(t){return Dt(t)}):function(t){return F(t)&&Ut(t.length)&&!!Lt[J(t)]},Yt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Wt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Jr=Object.create,Fr=function(){function t(){}return function(e){if(!re(e))return{};if(Jr)return Jr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Lr=Object.prototype.hasOwnProperty;function Dr(t,e,r){var n=t[e];Lr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Ft(e,r.length):"string"==n&&e in r)&&ue(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n,o){var i={},a=function(t){i=En(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},xn=function(t,e,r,n,o){var i={},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Pn=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var qn=function(t,e,r,n){var o=function(t,e,r,n){var o=[An,xn,Pn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.21",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function Cn(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function $n(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function zn(t){this.message=t}zn.prototype=new Error,zn.prototype.name="InvalidCharacterError";var Nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new zn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Rn=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Nn(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Nn(e)}};function Mn(t){this.message=t}Mn.prototype=new Error,Mn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Mn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Rn(t.split(".")[r]))}catch(t){throw new Mn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Mn;var Jn,Fn,Un,Ln,Dn,Hn,Bn,Kn,Gn;function Vn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Vn(In(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Jn={}).alias="exp",Jn.optional=!0,Jn)),_n(!1,["boolean","number","string"],((Fn={}).alias="nbf",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Ln={}).alias="sub",Ln.optional=!0,Ln)),_n(!1,["boolean","string"],((Dn={}).alias="iss",Dn.optional=!0,Dn)),_n(!1,["boolean"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean"],((Gn={}).optional=!0,Gn));var Yn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Qn(t,e){var r;return(r={})[t]=e,r.TS=[Yn()],r}var Xn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},Zn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=jo().key(e);t(Oo(r),r)}},remove:function(t){return jo().removeItem(t)},clearAll:function(){return jo().clear()}};function jo(){return _o.localStorage}function Oo(t){return jo().getItem(t)}var So=no.trim,ko={name:"cookieStorage",read:function(t){if(!t||!xo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Eo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Eo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:To,remove:Ao,clearAll:function(){To((function(t,e){Ao(e)}))}},Eo=no.Global.document;function To(t){for(var e=Eo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&xo(t)&&(Eo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function xo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Eo.cookie)}var Po=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var qo=no.bind,Co=no.each,$o=no.create,zo=no.slice,No=function(){var t=$o(Ro,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Co(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ro={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=zo(arguments,1);Co(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Jo=[wo,ko],Fo=[Po,No,Io],Uo=yo.createStore(Jo,Fo),Lo=no.Global;function Do(){return Lo.sessionStorage}function Ho(t){return Do().getItem(t)}var Bo=[{name:"sessionStorage",read:Ho,write:function(t,e){return Do().setItem(t,e)},each:function(t){for(var e=Do().length-1;e>=0;e--){var r=Do().key(e);t(Ho(r),r)}},remove:function(t){return Do().removeItem(t)},clearAll:function(){return Do().clear()}},ko],Ko=[Po,Io],Go=yo.createStore(Bo,Ko),Vo=Uo,Wo=Go,Yo=function(t){this.opts=t,this.instanceKey=$n(this.opts.hostname),this.localStore=Vo,this.sessionStore=Wo},Qo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Yo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?nn({},o,e):e,r))},Yo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Yo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Yo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Qo.lset.set=function(t){return this.__setMethod("localStore",t)},Qo.lget.get=function(){return this.__getMethod("localStore")},Yo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Yo.prototype.lclear=function(){return this.__clearMethod("localStore")},Qo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Qo.sget.get=function(){return this.__getMethod("sessionStore")},Yo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Yo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Yo.prototype,Qo);var Xo=b[0],Zo=b[1],ti=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Wn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&bn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Cn(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Cn(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=nn({},{_cb:Yn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Xo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Xn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Xn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new w("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Qn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Qn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Zo}).then(S)},Object.defineProperties(e.prototype,r),e}(Yo)))),ei={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ri={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};function ni(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return En(t,"__checked__",Yn())};r.push(o);var i=Reflect.apply(Sn,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function oi(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),kn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ni,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ri,ei,wn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ii(t,e,r){return void 0===r&&(r={}),oi(r).then((function(t){return{baseClient:new ti(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),Cn(n)?Promise.resolve(n):r.getContract()).then((function(e){return qn(o,i,e,t)}))}))}var ai=new WeakMap,ui=new WeakMap,ci=function(){this.__suspend__=null,this.queueStore=new Set},si={$suspend:{configurable:!0},$queues:{configurable:!0}};si.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ci.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},si.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ci.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ci.prototype,si);var fi=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ai.set(this,t)},r.normalStore.get=function(){return ai.get(this)},r.lazyStore.set=function(t){ui.set(this,t)},r.lazyStore.get=function(){return ui.get(this)},e.prototype.hashFnToKey=function(t){return $n(t.toString())},Object.defineProperties(e.prototype,r),e}(ci)));function li(t,e){var r;return ii((r=e.debugOn,new fi({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}return function(t){return void 0===t&&(t={}),li(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),a=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),u=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),c=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),s=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),f=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),l=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),p=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),h=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"y"},_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),w=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||F(t)&&"[object Number]"==J(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&F(t)&&"[object String]"==J(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!F(t)||"[object Object]"!=J(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return F(t)&&"[object Arguments]"==J(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return F(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Jt=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Jt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Dt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Yt=Vt?(Dt=Vt,function(t){return Dt(t)}):function(t){return F(t)&&Ut(t.length)&&!!Lt[J(t)]},Wt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Yt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Jr=Object.create,Fr=function(){function t(){}return function(e){if(!re(e))return{};if(Jr)return Jr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Lr=Object.prototype.hasOwnProperty;function Dr(t,e,r){var n=t[e];Lr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Ft(e,r.length):"string"==n&&e in r)&&ue(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n){var o;return!0===t.namespaced?(o=r)[e]=n:o=n,o},xn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=En(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return[An(n,"query",t,i),e,r,n,o]},Pn=function(t,e,r,n,o){var i=!1===n.namespaced?t:{},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return[An(n,"mutation",t,i),e,r,n,o]},qn=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i=!1===n.namespaced?t:{},a=n.loginHandlerName,u=n.logoutHandlerName;return o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Tn(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},An(n,"auth",t,i)}return t};var Cn=function(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.6.0",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.getUserdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function $n(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function zn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidCharacterError";var Rn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Nn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Mn=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(Rn(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 Rn(e)}};function In(t){this.message=t}In.prototype=new Error,In.prototype.name="InvalidTokenError";var Jn=function(t,e){if("string"!=typeof t)throw new In("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Mn(t.split(".")[r]))}catch(t){throw new In("Invalid token specified: "+t.message)}};Jn.InvalidTokenError=In;var Fn,Un,Ln,Dn,Hn,Bn,Kn,Gn,Vn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Yn(Jn(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Fn={}).alias="exp",Fn.optional=!0,Fn)),_n(!1,["boolean","number","string"],((Un={}).alias="nbf",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),_n(!1,["boolean","string"],((Dn={}).alias="sub",Dn.optional=!0,Dn)),_n(!1,["boolean","string"],((Hn={}).alias="iss",Hn.optional=!0,Hn)),_n(!1,["boolean"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),_n(!1,["boolean"],((Vn={}).optional=!0,Vn));var Qn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Xn(t,e){var r;return(r={})[t]=e,r.TS=[Qn()],r}var Zn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},to=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Oo().key(e);t(So(r),r)}},remove:function(t){return Oo().removeItem(t)},clearAll:function(){return Oo().clear()}};function Oo(){return wo.localStorage}function So(t){return Oo().getItem(t)}var ko=oo.trim,Eo={name:"cookieStorage",read:function(t){if(!t||!Po(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(To.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;To.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ao,remove:xo,clearAll:function(){Ao((function(t,e){xo(e)}))}},To=oo.Global.document;function Ao(t){for(var e=To.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ko(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function xo(t){t&&Po(t)&&(To.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Po(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(To.cookie)}var qo=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 Co=oo.bind,$o=oo.each,zo=oo.create,No=oo.slice,Ro=function(){var t=zo(Mo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Co(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Co(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),$o(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Mo={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Co(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=No(arguments,1);$o(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Io=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Jo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Io.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Io.compress(this._serialize(r));t(e,n)}}};var Fo=[jo,Eo],Uo=[qo,Ro,Jo],Lo=bo.createStore(Fo,Uo),Do=oo.Global;function Ho(){return Do.sessionStorage}function Bo(t){return Ho().getItem(t)}var Ko=[{name:"sessionStorage",read:Bo,write:function(t,e){return Ho().setItem(t,e)},each:function(t){for(var e=Ho().length-1;e>=0;e--){var r=Ho().key(e);t(Bo(r),r)}},remove:function(t){return Ho().removeItem(t)},clearAll:function(){return Ho().clear()}},Eo],Go=[qo,Jo],Vo=bo.createStore(Ko,Go),Yo=Lo,Wo=Vo,Qo=function(t){this.opts=t,this.instanceKey=zn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Wo},Xo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Qo.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?nn({},o,e):e,r))},Qo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Qo.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Qo.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Xo.lset.set=function(t){return this.__setMethod("localStore",t)},Xo.lget.get=function(){return this.__getMethod("localStore")},Qo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Qo.prototype.lclear=function(){return this.__clearMethod("localStore")},Xo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Xo.sget.get=function(){return this.__getMethod("sessionStore")},Qo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Qo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Qo.prototype,Xo);var Zo=b[0],ti=b[1],ei=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,["[JSONQL_LOG]"].concat(t))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Wn),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&bn(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!$n(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=$n(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=nn({},{_cb:Qn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Zo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Zn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Zn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new w("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Xn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Xn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ti}).then(S)},Object.defineProperties(e.prototype,r),e}(Qo)))),ri={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ni={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return"/"}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"]),namespaced:_n(!1,["boolean"]),cacheResult:_n(!1,["boolean","number"]),cacheExcludedList:_n([],["array"])};function oi(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return En(t,"__checked__",Qn())};r.push(o);var i=Reflect.apply(Sn,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ii(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),kn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(oi,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ni,ri,wn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ai(t,e,r){return void 0===r&&(r={}),ii(r).then((function(t){return{baseClient:new ei(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),$n(n)?Promise.resolve(n):r.getContract()).then((function(e){return Cn(o,i,e,t)}))}))}var ui=new WeakMap,ci=new WeakMap,si=function(){this.__suspend__=null,this.queueStore=new Set},fi={$suspend:{configurable:!0},$queues:{configurable:!0}};fi.$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)},si.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__},fi.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},si.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(si.prototype,fi);var li=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ui.set(this,t)},r.normalStore.get=function(){return ui.get(this)},r.lazyStore.set=function(t){ci.set(this,t)},r.lazyStore.get=function(){return ci.get(this)},e.prototype.hashFnToKey=function(t){return zn(t.toString())},Object.defineProperties(e.prototype,r),e}(si)));function pi(t,e){var r;return ai((r=e.debugOn,new li({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}return function(t){return void 0===t&&(t={}),pi(new o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js.map b/packages/http-client/dist/jsonql-client.umd.js.map index 53788d4b37d0840085996f5a3f0c84a2513edf1f..cd2021ce4fbfa2a3410f2cdd328a520d79927762 100644 --- a/packages/http-client/dist/jsonql-client.umd.js.map +++ b/packages/http-client/dist/jsonql-client.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wthDAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"40hDAAA"} \ No newline at end of file diff --git a/packages/http-client/index.js b/packages/http-client/index.js index e551515fcbe087cd3f0e6fb468d07938e5a4bb4f..7f1de88198eb6a801e7e417aae9d6e1f46d65a99 100644 --- a/packages/http-client/index.js +++ b/packages/http-client/index.js @@ -10,5 +10,6 @@ import { jsonqlAsync, getEventEmitter } from './src' */ export default function jsonqlClient(fly, config) { const ee = getEventEmitter(config.debugOn) + // @TODO the callback style will be the default interface from now on return jsonqlAsync(ee, fly, config) } diff --git a/packages/http-client/module.js b/packages/http-client/module.js index a4ea0c881c769526bd084c35001d2c95ba0c35ed..129ef1935c7902ea43cfcb69397311ced007c55f 100644 --- a/packages/http-client/module.js +++ b/packages/http-client/module.js @@ -1,7 +1,8 @@ // new module interface for @jsonql/client // this will be use with the @jsonql/ws, @jsonql/socketio // 1.5.8 we move the implmentation out and they should be in the @jsonql/client -import generator from './src/core/jsonql-api-generator' +import { jsonqlApiGenerator } from './src/core/jsonql-api-generator' +import { jsonqlCbGenerator } from './src/core/jsonql-cb-generator' import { JsonqlBaseEngine } from './src/base' import { getEventEmitter } from './src' import { checkOptionsAsync } from './src/options' @@ -30,12 +31,13 @@ function getPreConfigCheck(extraProps = {}, extraConstProps = {}) { const jsonqlHttpClientAppProps = appProps const jsonqlHttpClientConstProps = constProps // just duplicate it and export to avoid the crash out -// and take down those name later on -const JsonqlBase = JsonqlBaseEngine +// and take down those name later on +const JsonqlBase = JsonqlBaseEngine // export export { - generator, + jsonqlApiGenerator, + jsonqlCbGenerator, jsonqlHttpClientAppProps, jsonqlHttpClientConstProps, JsonqlBase, diff --git a/packages/http-client/package.json b/packages/http-client/package.json index cb6ed6795136832cdbb899f9d4f0fed958e6de08..7cc0d26da59ae094cb8854e39f2ac928c67ce0be 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.5.21", + "version": "1.6.0", "description": "jsonql http browser client using Fly.js with full user profile management with jwt and more", "main": "core.js", "module": "index.js", @@ -78,11 +78,11 @@ "esm": "^3.2.25", "glob": "^7.1.6", "jsonql-koa": "^1.5.7", - "koa-favicon": "^2.0.1", + "koa-favicon": "^2.1.0", "nyc": "^15.0.0", "promise-polyfill": "8.1.3", "qunit": "^2.9.3", - "rollup": "^1.31.1", + "rollup": "^1.32.0", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-analyzer": "^3.2.2", "rollup-plugin-async": "^1.2.0", @@ -97,7 +97,7 @@ "rollup-plugin-serve": "^1.0.1", "rollup-plugin-terser": "^5.2.0", "rollup-plugin-uglify": "^6.0.4", - "server-io-core": "^1.2.0", + "server-io-core": "^1.3.1", "window": "^4.2.6" }, "ava": { diff --git a/packages/http-client/rollup.config.js b/packages/http-client/rollup.config.js index d9ee4f14c5ecd29fe5212dd11352b5040d19158c..72dec3f34bcf218d3ae1ecd1a12ef62e45341845 100644 --- a/packages/http-client/rollup.config.js +++ b/packages/http-client/rollup.config.js @@ -65,12 +65,12 @@ switch (target) { distFile = join('dist', 'jsonql-client.umd.js') break; case 'STATIC': - moduleName = 'jsonqlClientStatic' + moduleName = 'jsonqlStaticClient' sourceFile = join('static.js') distFile = join('dist', 'jsonql-client.static.js') break; case 'FULL': - moduleName = 'jsonqlClientStatic' + moduleName = 'jsonqlStaticClient' sourceFile = join('src', 'static-full.js') distFile = join('dist', 'jsonql-client.static-full.js') break; diff --git a/packages/http-client/src/core/jsonql-api-generator.js b/packages/http-client/src/core/jsonql-api-generator.js index 4bba0195d4cd72063d27e77006eca410d472ac1b..99bbdb0fd2a27fc1ea38f164a782fd3b441c570f 100644 --- a/packages/http-client/src/core/jsonql-api-generator.js +++ b/packages/http-client/src/core/jsonql-api-generator.js @@ -25,27 +25,11 @@ import { methodsGenerator, addPropsToClient } from './methods-generator' * @param {object} ee eventEmitter * @return {object} constructed functions call */ -const generator = (jsonqlInstance, config, contract, ee) => { +export const jsonqlApiGenerator = (jsonqlInstance, config, contract, ee) => { // V1.3.0 - now everything wrap inside this method let client = methodsGenerator(jsonqlInstance, ee, config, contract) - // allow developer to access the store api - if (config.exposeStore) { - // @TODO in 1.6.x - /* - client.tmpSave = data => {} - client.tmpGet = (key = false) => {} - client.tmpDel = (key = false) => {} - - client.persistSave = data => {} - client.persistGet = (key = false) => {} - client.persistDel = (key = false) => {} - */ - } client = addPropsToClient(client, jsonqlInstance, ee, config, contract) - // output return client } -// export -export default generator diff --git a/packages/http-client/src/core/jsonql-static-generator.js b/packages/http-client/src/core/jsonql-cb-generator.js similarity index 97% rename from packages/http-client/src/core/jsonql-static-generator.js rename to packages/http-client/src/core/jsonql-cb-generator.js index 89293f573b3ed22db2fb21c0e43220ccb2639c21..d4b0636126699fdc643b0cc54b3dea12f780c6b7 100644 --- a/packages/http-client/src/core/jsonql-static-generator.js +++ b/packages/http-client/src/core/jsonql-cb-generator.js @@ -89,7 +89,7 @@ function setupEventHandlers(jsonqlInstance, ee, config, contract) { * @param {object} ee eventEmitter * @return {object} constructed functions call */ -const staticGenerator = (jsonqlInstance, config, contractPromise, ee) => { +export const jsonqlCbGenerator = (jsonqlInstance, config, contractPromise, ee) => { ee.$suspend = true; // hold all the calls // wait for the promise to resolve contractPromise.then(contract => { @@ -106,5 +106,3 @@ const staticGenerator = (jsonqlInstance, config, contractPromise, ee) => { // output return obj } - -export { staticGenerator } diff --git a/packages/http-client/src/core/methods-generator.js b/packages/http-client/src/core/methods-generator.js index 1b69cfa74b39421b563f7c1a8dc145fb5c41cfa7..887bc3d827f07953cbb781a42e1c8b26d82e4f97 100644 --- a/packages/http-client/src/core/methods-generator.js +++ b/packages/http-client/src/core/methods-generator.js @@ -9,6 +9,7 @@ import { validateAsync } from 'jsonql-params-validator' import { LOGOUT_NAME, LOGIN_NAME, KEY_WORD } from 'jsonql-constants' import { chainFns } from 'jsonql-utils/src/chain-fns' import { injectToFn } from 'jsonql-utils/src/obj-define-props' +import merge from 'lodash-es/merge' /** * generate authorisation specific methods @@ -32,6 +33,25 @@ const authMethodGenerator = (jsonqlInstance, name, opts, contract) => { } } +/** + * construct the final obj namespaced or not @1.6.0 + * @param {object} config --> namespaced + * @param {string} type of resolver + * @param {object} obj original object + * @param {object} _obj the local obj + * @return {object} the mutated object + */ +const getFinalObj = ({namespaced}, type, obj, _obj) => { + let finalObj + if (namespaced === true) { + finalObj = obj + finalObj[type] = _obj + } else { + finalObj = _obj + } + return finalObj +} + /** * Break up the different type each - create query methods * @param {object} obj to hold all the objects @@ -42,12 +62,9 @@ const authMethodGenerator = (jsonqlInstance, name, opts, contract) => { * @return {object} modified output for next op */ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { - let query = {} + let _obj = config.namespaced === false ? obj : {} for (let queryFn in contract.query) { - // to keep it clean we use a param to id the auth method - // const fn = (_contract.query[queryFn].auth === true) ? 'auth' : queryFn; - // generate the query method - query = injectToFn(query, queryFn, function queryFnHandler(...args) { + _obj = injectToFn(_obj, queryFn, function queryFnHandler(...args) { const params = contract.query[queryFn].params; const _args = params.map((param, i) => args[i]) // debug('query', queryFn, _params); @@ -62,10 +79,8 @@ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { .catch(finalCatch) }) } - obj.query = query - // create an alias to the helloWorld method - obj.helloWorld = query.helloWorld - return [ obj, jsonqlInstance, ee, config, contract ] + + return [ getFinalObj(config, 'query', obj, _obj), jsonqlInstance, ee, config, contract ] } /** @@ -78,14 +93,14 @@ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { * @return {object} modified output for next op */ const createMutationMethods = (obj, jsonqlInstance, ee, config, contract) => { - let mutation = {} + let _obj = config.namespaced === false ? obj : {} // process the mutation, the reason the mutation has a fixed number of parameters // there is only the payload, and conditions parameters // plus a header at the end for (let mutationFn in contract.mutation) { - mutation = injectToFn(mutation, mutationFn, function mutationFnHandler(payload, conditions, header = {}) { - const args = [payload, conditions]; - const params = contract.mutation[mutationFn].params; + _obj = injectToFn(_obj, mutationFn, function mutationFnHandler(payload, conditions, header = {}) { + const args = [payload, conditions] + const params = contract.mutation[mutationFn].params return validateAsync(args, params) .then(() => jsonqlInstance .mutation @@ -94,8 +109,8 @@ const createMutationMethods = (obj, jsonqlInstance, ee, config, contract) => { .catch(finalCatch) }) } - obj.mutation = mutation; - return [ obj, jsonqlInstance, ee, config, contract ] + + return [ getFinalObj(config, 'mutation', obj, _obj), jsonqlInstance, ee, config, contract ] } /** @@ -109,7 +124,7 @@ const createMutationMethods = (obj, jsonqlInstance, ee, config, contract) => { */ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { if (config.enableAuth && contract.auth) { - let auth = {} // v1.3.1 add back the auth prop name in contract + let auth = config.namespaced === false ? obj : {} const { loginHandlerName, logoutHandlerName } = config; if (contract.auth[loginHandlerName]) { // changing to the name the config specify @@ -142,7 +157,8 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { ee.$trigger(LOGOUT_NAME, KEY_WORD) } } - obj.auth = auth + // @1.6.0 + return getFinalObj(config, 'auth', obj, auth) } return obj @@ -153,8 +169,8 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { * Therefore we need to take the one been used and return it */ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { - obj.eventEmitter = ee - obj.contract = contract + obj.eventEmitter = ee // this might have to enable by config + obj.contract = contract // do we need this? obj.version = '__VERSION__' // use this method then we can hook into the debugOn at the same time // 1.5.2 change it to a getter to return a method, pass a name to id which one is which @@ -167,7 +183,7 @@ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { * @TODO allow to pass an id to switch to different userdata * @return {*} userdata */ - obj.userdata = () => jsonqlInstance.jsonqlUserdata + obj.getUserdata = () => jsonqlInstance.jsonqlUserdata // allow getting the token for valdiate agains the socket // if it's not require auth there is no point of calling getToken obj.getToken = (idx = false) => jsonqlInstance.rawAuthToken(idx) @@ -181,6 +197,7 @@ export function addPropsToClient(obj, jsonqlInstance, ee, config, contract) { // new in 1.5.1 to return different profiles obj.getProfiles = (idx = false) => jsonqlInstance.getProfiles(idx) } + // @1.6.0 @TODO expose the store? return obj } diff --git a/packages/http-client/src/jsonql-async.js b/packages/http-client/src/jsonql-async.js index 2006ddd3e1680cccafd4f431fc742ee8aefa23f2..4cc2b35b307804005578c95c423ba30c6126c891 100644 --- a/packages/http-client/src/jsonql-async.js +++ b/packages/http-client/src/jsonql-async.js @@ -1,14 +1,25 @@ // this is new for the flyio and normalize the name from now on -import generator from './core/jsonql-api-generator' +import { jsonqlApiGenerator } from './core/jsonql-api-generator' import { JsonqlBaseEngine } from './base' import { checkOptionsAsync } from './options' import { getContractFromConfig } from './utils' +/** +@TODO in the 1.6.x + +The default client without passing the contract as static option should be +a callback style interface, the reason is the cb call accept any name +(internally it just turn into an event name and pre-register it) and on the +developer side, they don't need to care when the contract finish loading, +because we could reverse trigger the calls in queue. + +**/ + /** * Main interface for jsonql fetch api * @param {object} ee EventEmitter * @param {object} fly this is really pain in the backside ... long story - * @param {object} [config={}] configuration options + * @param {object} [config={}] configuration options * @return {object} jsonql client */ export function jsonqlAsync(ee, fly, config = {}) { @@ -21,7 +32,7 @@ export function jsonqlAsync(ee, fly, config = {}) { )) .then( ({baseClient, opts}) => ( getContractFromConfig(baseClient, opts.contract) - .then(contract => generator(baseClient, opts, contract, ee)) + .then(contract => jsonqlApiGenerator(baseClient, opts, contract, ee)) ) ) } diff --git a/packages/http-client/src/jsonql-sync.js b/packages/http-client/src/jsonql-sync.js index 186909515a89ef4055b1dd0ba7caf88aa7292eb5..22448cdc8d745c37a2a1a79f590ecabbaa2a15f2 100644 --- a/packages/http-client/src/jsonql-sync.js +++ b/packages/http-client/src/jsonql-sync.js @@ -1,5 +1,5 @@ // this will be the sync version -import generator from './core/jsonql-api-generator' +import { jsonqlApiGenerator } from './core/jsonql-api-generator' import { JsonqlBaseEngine } from './base' import { checkOptions } from './options' @@ -11,10 +11,11 @@ import { checkOptions } from './options' * @return {object} the client */ export function jsonqlSync(ee, fly, config = {}) { - const { contract } = config; + const { contract } = config + const opts = checkOptions(config) const jsonqlBaseCls = new JsonqlBaseEngine(fly, opts) - return generator(jsonqlBaseCls, opts, contract, ee) + return jsonqlApiGenerator(jsonqlBaseCls, opts, contract, ee) } diff --git a/packages/http-client/src/options/base-options.js b/packages/http-client/src/options/base-options.js index a0daa78f0ead31050e4f4c1b499b62a207d0a652..27a0daf75aa27422279d1d65b7390fdf06992371 100644 --- a/packages/http-client/src/options/base-options.js +++ b/packages/http-client/src/options/base-options.js @@ -12,6 +12,7 @@ import { BOOLEAN_TYPE, STRING_TYPE, NUMBER_TYPE, + ARRAY_TYPE, DEFAULT_HEADER } from 'jsonql-constants' import { createConfig } from 'jsonql-params-validator' @@ -28,18 +29,19 @@ const getHostName = () => { try { return [window.location.protocol, window.location.host].join('//') } catch(e) { - return null + return '/' } } export const appProps = { - - hostname: createConfig(getHostName(), [STRING_TYPE]), // required the hostname - jsonqlPath: createConfig(JSONQL_PATH, [STRING_TYPE]), // The path on the server - + // The hostname to call + hostname: createConfig(getHostName(), [STRING_TYPE]), + // The path on the server NOT RECOMMENDED to change! + jsonqlPath: createConfig(JSONQL_PATH, [STRING_TYPE]), + // the name of the auth handler, if you want to change it but it must change in pair on both server and client side loginHandlerName: createConfig(ISSUER_NAME, [STRING_TYPE]), logoutHandlerName: createConfig(LOGOUT_NAME, [STRING_TYPE]), - // add to koa v1.3.0 - this might remove in the future + // @TODO add to koa v1.3.0 - this might remove in the future enableJsonp: createConfig(false, [BOOLEAN_TYPE]), enableAuth: createConfig(false, [BOOLEAN_TYPE]), // enable useJwt by default @TODO replace with something else and remove them later @@ -47,27 +49,38 @@ export const appProps = { // when true then store infinity or pass a time in seconds then we check against // the token date of creation persistToken: createConfig(false, [BOOLEAN_TYPE, NUMBER_TYPE]), - // the header - // v1.2.0 we are using this option during the dev - // so it won't save anything to the localstorage and fetch a new contract - // whenever the browser reload + // the header + // v1.2.0 we are using this option during the dev + // so it won't save anything to the localstorage and fetch a new contract + // whenever the browser reload useLocalstorage: createConfig(true, [BOOLEAN_TYPE]), // should we store the contract into localStorage storageKey: createConfig(CLIENT_STORAGE_KEY, [STRING_TYPE]),// the key to use when store into localStorage authKey: createConfig(CLIENT_AUTH_KEY, [STRING_TYPE]),// the key to use when store into the sessionStorage - contractExpired: createConfig(0, [NUMBER_TYPE]),// -1 always fetch contract, - // 0 never expired, - // > 0 then compare the timestamp with the current one to see if we need to get contract again + // -1 always fetch contract, + // 0 never expired, + // > 0 then compare the timestamp with the current one to see if we need to get contract again + contractExpired: createConfig(0, [NUMBER_TYPE]), // useful during development keepContract: createConfig(true, [BOOLEAN_TYPE]), exposeContract: createConfig(false, [BOOLEAN_TYPE]), - exposeStore: createConfig(false, [BOOLEAN_TYPE]), // whether to allow developer to access the store fn + exposeStore: createConfig(false, [BOOLEAN_TYPE]), // whether to allow developer to access the store fn // @1.2.1 new option for the contract-console to fetch the contract with description showContractDesc: createConfig(false, [BOOLEAN_TYPE]), - contractKey: createConfig(false, [BOOLEAN_TYPE]), // if the server side is lock by the key you need this - contractKeyName: createConfig(CONTRACT_KEY_NAME, [STRING_TYPE]), // same as above they go in pairs + // if the server side is lock by the key you need this + contractKey: createConfig(false, [BOOLEAN_TYPE]), + // same as above they go in pairs + contractKeyName: createConfig(CONTRACT_KEY_NAME, [STRING_TYPE]), enableTimeout: createConfig(false, [BOOLEAN_TYPE]), // @TODO timeout: createConfig(5000, [NUMBER_TYPE]), // 5 seconds returnInstance: createConfig(false, [BOOLEAN_TYPE]), allowReturnRawToken: createConfig(false, [BOOLEAN_TYPE]), - debugOn: createConfig(false, [BOOLEAN_TYPE]) + debugOn: createConfig(false, [BOOLEAN_TYPE]), + /////////////////////////////// + // options added in 1.6.0 // + /////////////////////////////// + // we will flatten all the resolver into the client level if this is false + namespaced: createConfig(false, [BOOLEAN_TYPE]), + // use the session store to cache the result temporary, or set a expired time (in ms) @TODO in 1.7.0 + cacheResult: createConfig(false, [BOOLEAN_TYPE, NUMBER_TYPE]), + cacheExcludedList: createConfig([], [ARRAY_TYPE]) } diff --git a/packages/http-client/src/utils.js b/packages/http-client/src/utils.js index 9c0a9d7b5ad94aedcdb70db5379f8e64645b862c..6a43ded52a082d53b3fb70c66b475a3f6df83ade 100644 --- a/packages/http-client/src/utils.js +++ b/packages/http-client/src/utils.js @@ -35,6 +35,7 @@ const LOG_ERROR_SWITCH = '__error__' const ZERO_IDX = 0 // export export { + isContract, hashCode, getContractFromConfig, // constants diff --git a/packages/http-client/static.js b/packages/http-client/static.js index f7e6b5d26e3cc68a816f50c13d13b0d49cd35481..7e5e1da7e8e604ee51afaebb8b42d738511f203a 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,31 +1,22 @@ -// as of 1.5.15 this no longer build -// it's a source files that require to build on the your client side -// this is the new Event base interface -// the export will be different and purposely design for framework that -// is very hard to use Promise such as Vue -import { staticGenerator } from './src/core/jsonql-static-generator' -import { JsonqlBaseEngine } from './src/base' -import { checkOptions } from './src/options' -import { getContractFromConfig } from './src/utils' -import { getEventEmitter } from './src' +// this will return the sync interface instead of the switching +// because that will cause a lot of confusion about the api +// new module interface for @jsonql/client +// this will be use with the @jsonql/ws, @jsonql/socketio +import { jsonqlSync, getEventEmitter } from './src' +import { isContract } from './src/utils' +import { JsonqlError } from 'jsonql-errors' /** - * this is the slim client without Fly, you pick the version of Fly to use - * This is a breaking change because it swap the input positions - * @param {object} fly fly.js + * When pass a static contract then it return a static interface + * otherwise it will become the async interface + * @param {object} Fly the http engine * @param {object} config configuration - * @return {object} the jsonql client instance + * @return {object} jsonqlClient */ -export function jsonqlStaticClient(fly, config) { - const { contract } = config; - const opts = checkOptions(config) - const jsonqlBaseCls = new JsonqlBaseEngine(fly, opts) - const contractPromise = getContractFromConfig(jsonqlBaseCls, contract) - const ee = getEventEmitter(opts.debugOn) - // finally - let methods = staticGenerator(jsonqlBaseCls, opts, contractPromise, ee) - methods.eventEmitter = ee - // 1.5.21 port the logger for other part to use - methods.getLogger = (name) => (...args) => Reflect.apply(jsonqlInstance.log, jsonqlInstance, [name, ...args]) - return methods +export function jsonqlStaticClient(Fly, config) { + if (config.contract && isContract(config.contract)) { + const ee = getEventEmitter(config.debugOn) + return jsonqlSync(ee, Fly, config) + } + throw new JsonqlError('jsonqlStaticClient', `Expect to pass the contract via configuration!`) } diff --git a/packages/http-client/sync.js b/packages/http-client/sync.js deleted file mode 100644 index 2e536748c391eebdc6248178c0d2c6c889d4d2d8..0000000000000000000000000000000000000000 --- a/packages/http-client/sync.js +++ /dev/null @@ -1,22 +0,0 @@ -// this will return the sync interface instead of the switching -// because that will cause a lot of confusion about the api -// new module interface for @jsonql/client -// this will be use with the @jsonql/ws, @jsonql/socketio -import { jsonqlSync, getEventEmitter } from './src' -import { isContract } from './src/utils' -import { JsonqlError } from 'jsonql-errors' - -/** - * When pass a static contract then it return a static interface - * otherwise it will become the async interface - * @param {object} Fly the http engine - * @param {object} config configuration - * @return {object} jsonqlClient - */ -export function jsonqlSyncClient(Fly, config) { - const ee = getEventEmitter(config.debugOn) - if (config.contract && isContract(config.contract)) { - return jsonqlSync(ee, Fly, config) - } - throw new JsonqlError('jsonqlSyncClient', `Expect to pass the contract via configuration!`) -} diff --git a/packages/http-client/tests/qunit/run-qunit-setup.js b/packages/http-client/tests/qunit/run-qunit-setup.js index 3265bcf63824187d6b342414bcfafa1016cd7dac..a39ad02582612cb594a92d0f50bd51da2827c049 100644 --- a/packages/http-client/tests/qunit/run-qunit-setup.js +++ b/packages/http-client/tests/qunit/run-qunit-setup.js @@ -5,7 +5,10 @@ const { join, resolve } = require('path') const serverIoCore = require('server-io-core') const jsonqlKoaDir = join(__dirname, '..', 'fixtures') const { jsonqlKoa } = require('jsonql-koa') -// const jsonqlKoa = jsonqlKoaMiddleware.default +const fsx = require('fs-extra') + +const publicJson = fsx.readJsonSync(join(jsonqlKoaDir, 'contracts', 'public-contract.json')) + /** * @param {object} config configuration * @return {object} promise resolve the config for server-io-core @@ -30,7 +33,16 @@ const getConfig = (config) => { insertBefore: false, target: { body: files.map( file => file.replace(baseDir, '') ) - } + }, + replace: [ + { + target: '', + str: '\n' + } + ] }, middlewares: [ jsonqlKoa({ diff --git a/packages/http-client/tests/qunit/tests/base-test.js b/packages/http-client/tests/qunit/tests/base-test.js index 4a79590d411504e81c77f36523e026e8bc809ccb..486ab2d4fb2ab462adab3e4823c51eadbf3017df 100644 --- a/packages/http-client/tests/qunit/tests/base-test.js +++ b/packages/http-client/tests/qunit/tests/base-test.js @@ -25,12 +25,12 @@ QUnit.test('jsonqlClient should able to connect to server', function(assert) { done1() }) // test the query with wrong param - client.query.getSomething(1).catch(err => { + client.getSomething(1).catch(err => { assert.equal(err.className, 'JsonqlValidationError', 'Expect validation error') done2() }) // call the mutation before login - client.mutation.plus({a: '1', b: '1'}) + client.plus({a: '1', b: '1'}) .catch(err => { console.error(`--- NOT LOGIN ERROR ---`, err) // @NOTE this is a cheat because the finalCatch from jsonql-errors not always able to catch the correct error @@ -38,13 +38,13 @@ QUnit.test('jsonqlClient should able to connect to server', function(assert) { done3() // test the login - client.auth.login('joel') + client.login('joel') .then(userdata => { // console.info('login result', userdata) assert.equal(userdata.name, 'joel', 'Expect the login stored userdata name to be the same as we supplied') done4() // test the mutation AGAIN - client.mutation.plus({a: 'a', b: 'b'}) + client.plus({a: 'a', b: 'b'}) .then(result => { assert.equal(result, 'ab', 'We should now able to call private mutation method after login') done5() diff --git a/packages/http-client/tests/qunit/tests/static-test.js b/packages/http-client/tests/qunit/tests/static-test.js index f7658cc74804e8d23a5aeb884ac017b5f79ca8c1..2e0c65b749231c24ac437b8476606c56ff1e3478 100644 --- a/packages/http-client/tests/qunit/tests/static-test.js +++ b/packages/http-client/tests/qunit/tests/static-test.js @@ -5,20 +5,17 @@ QUnit.test('jsonqlClientStatic should able to connect to server', function(asser var done2 = assert.async() var done3 = assert.async() // init client - var client = jsonqlClientStatic({ + var client = jsonqlStaticClient({ + contract: publicJson, hostname: 'http://localhost:10081', showContractDesc: true, keepContract: false, debugOn: true }) - /* - client.query('getSomethingNonExisted', 'whatever') - .then(function(result) { - console.log('[Qunit]', 'getSomething result', result) - }) - */ - client.query('getSomething', 'whatever', 'shit') + console.info('static client', client) + + client.getSomething('whatever', 'shit') .then(function(result) { console.log('[Qunit]', 'getSomething result', result) assert.equal(true, typeof result.whatever === 'string', 'just passing this one') @@ -29,7 +26,7 @@ QUnit.test('jsonqlClientStatic should able to connect to server', function(asser done2() }) - client.query('helloWorld') + client.helloWorld() .then(function(result) { console.info(result) assert.equal('Hello world!', result, "Hello world test done") @@ -40,20 +37,20 @@ QUnit.test('jsonqlClientStatic should able to connect to server', function(asser done1() }) - - client.query('getArray') - .then(function(result) { - try { - console.log('getArray result', result) - assert.equal(4, result.length, 'Check the length of the array') - done3() - } catch(e) { - throw new Error(e) - } - }) - .catch(function(error) { - console.error(`[Qunit]`, 'get array error', error) + client.getArray() + .then(function(result) { + try { + console.log('getArray result', result) + assert.equal(4, result.length, 'Check the length of the array') done3() - }) + } catch(e) { + throw new Error(e) + } + }) + .catch(function(error) { + console.error(`[Qunit]`, 'get array error', error) + done3() + }) + // @TODO test the auth }) diff --git a/packages/http-client/tests/qunit/webroot/index.html b/packages/http-client/tests/qunit/webroot/index.html index ded9bae66b1e8636e3247c5854665afdf3fc5064..81019a3070bdc72affa503bbcbe8aab7b68cde19 100644 --- a/packages/http-client/tests/qunit/webroot/index.html +++ b/packages/http-client/tests/qunit/webroot/index.html @@ -10,7 +10,7 @@
- + diff --git a/packages/utils/src/obj-define-props.js b/packages/utils/src/obj-define-props.js index 54ddf26acc0c6939217f1f19bd3dc1b9df83ff64..993f7ee95572ad8132b6cef3da8b702358ccc005 100644 --- a/packages/utils/src/obj-define-props.js +++ b/packages/utils/src/obj-define-props.js @@ -27,7 +27,7 @@ export function objDefineProps(obj, name, setter, getter = null) { */ export function objHasProp(obj, name) { const prop = Object.getOwnPropertyDescriptor(obj, name) - return prop !== undefined && prop.value ? prop.value : prop; + return prop !== undefined && prop.value ? prop.value : prop } /** @@ -43,7 +43,7 @@ export function injectToFn(resolver, name, data, overwrite = false) { let check = objHasProp(resolver, name) if (overwrite === false && check !== undefined) { // console.info(`NOT INJECTED`) - return resolver; + return resolver } /* this will throw error! if (overwrite === true && check !== undefined) { @@ -56,5 +56,5 @@ export function injectToFn(resolver, name, data, overwrite = false) { writable: overwrite // if its set to true then we should able to overwrite it }) - return resolver; + return resolver }