diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index a829bb2d49864642505da629be167415ca8c28e8..b904479e4b69d63e7980b160e7eac0a196746fab 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -17,7 +17,7 @@ "test": "npm run build && npm run test:browser", "test:basic": "DEBUG=jsonql-client* ava ./tests/basic.test.js", "test:login": "DEBUG=jsonql-client* ava ./tests/login.test.js", - "prepare": "NODE_ENV=production npm run build", + "_prepare": "NODE_ENV=production npm run build", "test:browser": "DEBUG=jsonql* node ./tests/qunit/run-qunit.js", "start": "rollup -c -w --environment NODE_ENV:dev", "build": "npm run build:umd && npm run build:browser && npm run build:static && npm run build:full", @@ -43,7 +43,7 @@ }, "license": "MIT", "dependencies": { - "jsonql-client": "^1.4.3" + "jsonql-client": "^1.4.4" }, "optionalDependencies": { "@jsonql/ws": "^0.8.3" @@ -59,7 +59,7 @@ "nyc": "^14.1.1", "promise-polyfill": "8.1.3", "qunit": "^2.9.3", - "rollup": "^1.27.5", + "rollup": "^1.27.6", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-analyzer": "^3.2.2", "rollup-plugin-async": "^1.2.0", diff --git a/packages/@jsonql/client/tests/basic.test.js b/packages/@jsonql/client/tests/basic.test.js index 64bc0f977728182a882591bede4c6494e850b438..fd1451036561ebd2bdfeeb31af019c9d4fb24a70 100644 --- a/packages/@jsonql/client/tests/basic.test.js +++ b/packages/@jsonql/client/tests/basic.test.js @@ -2,14 +2,20 @@ const test = require('ava') const jsonqlWsClient = require('../ws') const debug = require('debug')('jsonql-client:test:basic') +const { CHECKED_KEY } = require('jsonql-constants') +const { objHasProp } = require('jsonql-utils') + +// debug(jsonqlWsClient) test(`Just checking the export options`, t => { - const result = jsonqlWsClient({socketClientType: 'ws'}) + const result = jsonqlWsClient.default({ + serverType: 'ws' + }) debug(result) - t.pass() + t.truthy(objHasProp(result, CHECKED_KEY)) }) diff --git a/packages/@jsonql/client/ws.js b/packages/@jsonql/client/ws.js index 4750a27bb5f175f297df3cb966c2c40c5145510a..936f25f684135b5dcbdf2cfc5232f6305f184573 100644 --- a/packages/@jsonql/client/ws.js +++ b/packages/@jsonql/client/ws.js @@ -1,9 +1,14 @@ // this is the jsonql client with ws // use like import jsonqlClient from '@jsonql/client/ws' import { jsonqlClient } from 'jsonql-client/module' -import preConfigCheck from 'jsonql-client/opt' +import { getPreConfigCheck } from 'jsonql-client/opt' import jsonqlWsClient from '@jsonql/ws' import { defaultOptions, constProps } from '@jsonql/ws/opt' +import debug from 'debug' + +const debugFn = debug('jsonql-client:ws') + +// debugFn(jsonqlWsClient) /** * @param {object} [config={}] developer supply options @@ -12,8 +17,8 @@ import { defaultOptions, constProps } from '@jsonql/ws/opt' */ export default function createJsonqlHttpWsClient(config = {}) { // @NOTE it return a function to accept the config - const fn = preConfigCheck(defaultOptions, constProps) + const fn = getPreConfigCheck(defaultOptions, constProps) const opts = fn(config) - + return opts; } diff --git a/packages/http-client/core.js b/packages/http-client/core.js index 416729f8cb9bfeedde241be10e2d22d6a8c78053..5ef8683dae99b29ab4b8491ee83abf1f47e1fd72 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message";var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},h="object"==typeof p&&p&&p.Object===Object&&p,d="object"==typeof self&&self&&self.Object===Object&&self,v=h||d||Function("return this")(),g=v.Symbol;function y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&I(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Z(t){return void 0===t}var tt="[object Boolean]";var et="[object Number]";function rt(t){return function(t){return"number"==typeof t||T(t)&&E(t)==et}(t)&&t!=+t}var nt="[object String]";function ot(t){return"string"==typeof t||!b(t)&&T(t)&&E(t)==nt}function it(t,e){return function(r){return t(e(r))}}var at=it(Object.getPrototypeOf,Object),ut="[object Object]",ct=Function.prototype,st=Object.prototype,ft=ct.toString,lt=st.hasOwnProperty,pt=ft.call(Object);function ht(t){if(!T(t)||E(t)!=ut)return!1;var e=at(t);if(null===e)return!0;var r=lt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var dt,vt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[dt?a:++n];if(!1===e(o[u],u,o))break}return t};var gt="[object Arguments]";function yt(t){return T(t)&&E(t)==gt}var bt=Object.prototype,mt=bt.hasOwnProperty,_t=bt.propertyIsEnumerable,wt=yt(function(){return arguments}())?yt:function(t){return T(t)&&mt.call(t,"callee")&&!_t.call(t,"callee")};var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,St=Ot&&Ot.exports===jt?v.Buffer:void 0,At=(St?St.isBuffer:void 0)||function(){return!1},kt=9007199254740991,Et=/^(?:0|[1-9]\d*)$/;function Tt(t,e){var r=typeof t;return!!(e=null==e?kt:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=xt}var qt={};qt["[object Float32Array]"]=qt["[object Float64Array]"]=qt["[object Int8Array]"]=qt["[object Int16Array]"]=qt["[object Int32Array]"]=qt["[object Uint8Array]"]=qt["[object Uint8ClampedArray]"]=qt["[object Uint16Array]"]=qt["[object Uint32Array]"]=!0,qt["[object Arguments]"]=qt["[object Array]"]=qt["[object ArrayBuffer]"]=qt["[object Boolean]"]=qt["[object DataView]"]=qt["[object Date]"]=qt["[object Error]"]=qt["[object Function]"]=qt["[object Map]"]=qt["[object Number]"]=qt["[object Object]"]=qt["[object RegExp]"]=qt["[object Set]"]=qt["[object String]"]=qt["[object WeakMap]"]=!1;var Ct,$t="object"==typeof exports&&exports&&!exports.nodeType&&exports,zt=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=zt&&zt.exports===$t&&h.process,Ft=function(){try{var t=zt&&zt.require&&zt.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch(t){}}(),It=Ft&&Ft.isTypedArray,Rt=It?(Ct=It,function(t){return Ct(t)}):function(t){return T(t)&&Pt(t.length)&&!!qt[E(t)]},Jt=Object.prototype.hasOwnProperty;function Mt(t,e){var r=b(t),n=!r&&wt(t),o=!r&&!n&&At(t),i=!r&&!n&&!o&&Rt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ne.prototype.set=function(t,e){var r=this.__data__,n=ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var oe,ie=v["__core-js_shared__"],ae=(oe=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+oe:"";var ue=Function.prototype.toString;function ce(t){if(null!=t){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var se=/^\[object .+?Constructor\]$/,fe=Function.prototype,le=Object.prototype,pe=fe.toString,he=le.hasOwnProperty,de=RegExp("^"+pe.call(he).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ve(t){return!(!Bt(t)||function(t){return!!ae&&ae in t}(t))&&(Yt(t)?de:se).test(ce(t))}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ve(r)?r:void 0}var ye=ge(v,"Map"),be=ge(Object,"create");var me="__lodash_hash_undefined__",_e=Object.prototype.hasOwnProperty;var we=Object.prototype.hasOwnProperty;var je="__lodash_hash_undefined__";function Oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ce?new xe:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=_n)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(mn);function Sn(t,e){return On(function(t,e,r){return e=bn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=bn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=An.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Bt(r))return!1;var n=typeof e;return!!("number"==n?Qt(r)&&Tt(e,r.length):"string"==n&&e in r)&&te(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Vn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Gn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Bn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Kn(r,t)})).length},Wn=function(t,e){if(void 0===e&&(e=null),ht(t)){if(!e)return!0;if(Kn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Z(r)||(!1!==(e=Vn(t))?!Gn({arg:r},e):!Bn(t)(r))})).length)})).length}return!1},Yn=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Wn.apply(null,n)},Qn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),Xn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Zn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),to=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),co=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),so=Object.freeze({__proto__:null,Jsonql406Error:Qn,Jsonql500Error:Xn,JsonqlAuthorisationError:Zn,JsonqlContractAuthError:to,JsonqlResolverAppError:eo,JsonqlResolverNotFoundError:ro,JsonqlEnumError:no,JsonqlTypeError:oo,JsonqlCheckerError:io,JsonqlValidationError:ao,JsonqlError:uo,JsonqlServerError:co}),fo=uo,lo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function po(t){if(lo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&so[o])throw new so[r](i,a);throw new fo(i,a)}return t}function ho(t){if(Array.isArray(t))throw new ao("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof Qn:throw new Qn(e,r);case t instanceof Xn:throw new Xn(e,r);case t instanceof Zn:throw new Zn(e,r);case t instanceof to:throw new to(e,r);case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof co:throw new co(e,r);default:throw new uo(e,r)}}function vo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var go=function(t,e){var r;switch(!0){case"object"===t:return!Yn(e);case"array"===t:return!Kn(e.arg);case!1!==(r=Vn(t)):return!Gn(e,r);default:return!Bn(t)(e.arg)}},yo=function(t,e){return Z(t)?!0!==e.optional||Z(e.defaultvalue)?null:e.defaultvalue:t},bo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Kn(e))throw new uo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Kn(t))throw new uo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return vo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:vo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:vo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?yo(t,a):t,index:r,param:a,optional:i}}));default:throw vo(5),new uo("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!$n(e)&&!(r.type.length>r.type.filter((function(e){return go(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return go(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},mo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},_o=function(t){return!$n(t)};function wo(t,e){var r=Cn(e,(function(t,e){return!t[Hn]}));return Sr(r,{})?t:function(t,e){var r={};return e=Yr(e),Zt(t,(function(t,n,o){Xr(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,Yr((function(t){return t.alias===e})),Zt)||e}))}function jo(t,e){return En(e,(function(e,r){var n,o;return Z(t[r])||!0===e[Jn]&&_o(t[r])?kn({},e,((n={})[Ln]=!0,n)):((o={})[Un]=t[r],o[Rn]=e[Rn],o[Jn]=e[Jn]||!1,o[Mn]=e[Mn]||!1,o[Dn]=e[Dn]||!1,o)}))}function Oo(t,e){var r=function(t,e){var r=wo(t,e);return{pristineValues:En(Cn(e,(function(t,e){return mo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Cn(e,(function(t,e){return!mo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[jo(n,r.checkAgainstAppProps),o]}var So=function(t){return Kn(t)?t:[t]};var Ao=function(t,e){return!Kn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},ko=function(t,e){try{return!!Yt(e)&&e.apply(null,[t])}catch(t){return!1}};function Eo(t){return function(e,r){if(e[Ln])return e[Un];var n=function(t,e){var r,n=[[t[Un]],[(r={},r[Rn]=So(t[Rn]),r[Jn]=t[Jn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw vo("runValidationAction",r,e),new oo(r,n);if(!1!==e[Mn]&&!Ao(e[Un],e[Mn]))throw vo(Mn,e[Mn]),new no(r);if(!1!==e[Dn]&&!ko(e[Un],e[Dn]))throw vo(Dn,e[Dn]),new io(r);return e[Un]}}var To=function(t,e){return Promise.resolve(Oo(t,e))};function xo(t,e,r,n){return void 0===t&&(t={}),To(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=En(r,Eo(e));return kn(o,n)}(t,n)})).then((function(t){return kn({},t,r)}))}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),Kn(s)&&(p[i]=s),Yt(f)&&(p[u]=f),ot(l)&&(p[c]=l),p}var qo=Nn,Co=Kn,$o=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=bo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},No=function(t){return function(e,r,n){return void 0===n&&(n={}),xo(e,r,n,t)}}(bo),Fo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Io=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ii().key(e);t(ai(r),r)}},remove:function(t){return ii().removeItem(t)},clearAll:function(){return ii().clear()}};function ii(){return ni.localStorage}function ai(t){return ii().getItem(t)}var ui=Uo.trim,ci={name:"cookieStorage",read:function(t){if(!t||!pi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(si.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;si.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:fi,remove:li,clearAll:function(){fi((function(t,e){li(e)}))}},si=Uo.Global.document;function fi(t){for(var e=si.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ui(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function li(t){t&&pi(t)&&(si.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function pi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(si.cookie)}var hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var di="expire_mixin",vi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+di);return{set:function(e,r,n,o){this.hasNamespace(di)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(di)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(di)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Oi=[oi,ci],Si=[hi,vi,_i,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ji.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ji.compress(this._serialize(r));t(e,n)}}}],Ai=ti.createStore(Oi,Si),ki=Uo.Global;function Ei(){return ki.sessionStorage}function Ti(t){return Ei().getItem(t)}var xi=[{name:"sessionStorage",read:Ti,write:function(t,e){return Ei().setItem(t,e)},each:function(t){for(var e=Ei().length-1;e>=0;e--){var r=Ei().key(e);t(Ti(r),r)}},remove:function(t){return Ei().removeItem(t)},clearAll:function(){return Ei().clear()}},ci],Pi=[hi,vi],qi=ti.createStore(xi,Pi),Ci=Ai,$i=qi,zi=Array.isArray,Ni=void 0!==p?p:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Fi="object"==typeof Ni&&Ni&&Ni.Object===Object&&Ni,Ii="object"==typeof self&&self&&self.Object===Object&&self,Ri=(Fi||Ii||Function("return this")()).Symbol,Ji=Object.prototype,Mi=Ji.hasOwnProperty,Ui=Ji.toString,Di=Ri?Ri.toStringTag:void 0;var Hi=Object.prototype.toString;var Li="[object Null]",Bi="[object Undefined]",Ki=Ri?Ri.toStringTag:void 0;function Vi(t){return null==t?void 0===t?Bi:Li:Ki&&Ki in Object(t)?function(t){var e=Mi.call(t,Di),r=t[Di];try{t[Di]=void 0;var n=!0}catch(t){}var o=Ui.call(t);return n&&(e?t[Di]=r:delete t[Di]),o}(t):function(t){return Hi.call(t)}(t)}var Gi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Wi(t){return null!=t&&"object"==typeof t}var Yi="[object Object]",Qi=Function.prototype,Xi=Object.prototype,Zi=Qi.toString,ta=Xi.hasOwnProperty,ea=Zi.call(Object);var ra=Ri?Ri.prototype:void 0,na=(ra&&ra.toString,"[object String]");function oa(t){return"string"==typeof t||!zi(t)&&Wi(t)&&Vi(t)==na}var ia=function(t,e){return!!t.filter((function(t){return t===e})).length},aa=function(t,e){var r=Object.keys(t);return ia(r,e)},ua=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ca="query",sa="mutation",fa="socket",la="payload",pa="condition",ha=function(){try{if(window||document)return!0}catch(t){}return!1},da=function(){try{if(!ha()&&Ni)return!0}catch(t){}return!1};var va=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ha()?"browser":da()?"node":"unknown"},e}(Error));var ga=function(t){var e;return(e={}).args=t,e};var ya=function(t){return aa(t,"data")&&!aa(t,"error")?t.data:t},ba=function(t){return function(t){if(!Wi(t)||Vi(t)!=Yi)return!1;var e=Gi(t);if(null===e)return!0;var r=ta.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zi.call(r)==ea}(t)&&(aa(t,ca)||aa(t,sa)||aa(t,fa))},ma=function(t,e){return void 0===e&&(e={}),ba(e)?Promise.resolve(e):t.getContract()},_a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function wa(t){this.message=t}wa.prototype=new Error,wa.prototype.name="InvalidCharacterError";var ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new wa("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=_a.indexOf(n);return a};var Oa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ja(e)}};function Sa(t){this.message=t}Sa.prototype=new Error,Sa.prototype.name="InvalidTokenError";var Aa=function(t,e){if("string"!=typeof t)throw new Sa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Oa(t.split(".")[r]))}catch(t){throw new Sa("Invalid token specified: "+t.message)}},ka=Sa;Aa.InvalidTokenError=ka;var Ea,Ta,xa,Pa,qa,Ca,$a,za,Na,Fa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ia(t){if(qo(t))return function(t){var e=t.iat||Fa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new uo("Token has expired on "+r,t)}return t}(Aa(t));throw new uo("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ea={})[c]="exp",Ea[o]=!0,Ea)),zo(!1,["boolean","number","string"],((Ta={})[c]="nbf",Ta[o]=!0,Ta)),zo(!1,["boolean","string"],((xa={})[c]="iss",xa[o]=!0,xa)),zo(!1,["boolean","string"],((Pa={})[c]="sub",Pa[o]=!0,Pa)),zo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),zo(!1,["boolean"],((Ca={})[o]=!0,Ca)),zo(!1,["boolean","string"],(($a={})[o]=!0,$a)),zo(!1,["boolean","string"],((za={})[o]=!0,za)),zo(!1,["boolean"],((Na={})[o]=!0,Na));var Ra=r[0],Ja=r[1],Ma=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ua={headers:{configurable:!0}};Ua.headers.set=function(t){this.extraHeader=t},Ma.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=kn({},{_cb:ua()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=kn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,kn({},{method:Ra,params:o},e))},Ma.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ma.prototype.processJsonp=function(t){return ya(t)},Ma.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=qo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ya(o)}),(function(t){throw e.cleanUp(),console.error(t),new co("Server side error",t)}))},Ma.prototype.getHeaders=function(){return this.opts.enableAuth?kn({},e,this.getAuthHeader(),this.extraHeader):kn({},e,this.extraHeader)},Ma.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ma.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=kn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(po).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ma.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),oa(t)&&zi(e)){var o=ga(e);return!0===r?o:((n={})[t]=o,n)}throw new va("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(po)},Ma.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[la]=e,i[pa]=r,!0===n)return i;if(oa(t))return(o={})[t]=i,o;throw new va("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ja}).then(po)},Object.defineProperties(Ma.prototype,Ua);var Da=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Co(t)&&t.length>=2&&Reflect.apply(Ci.set,Ci,t),new ao("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ci.get("endpoint")||[];ia(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ci.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ia(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ua();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ci.set,Ci,e)},r.jsonqlEndpoint.get=function(){var t=Ci.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ci.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return $i.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ia)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ba(t))throw new ao("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ba(this.opts.contract)?this.opts.contract:Ci.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ma))),Ha=function(t){return b(t)?t:[t]},La=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Ha(t))}),Reflect.apply(t,null,r))}};function Ba(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ka=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ho)}},Va=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ho)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Ga=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return $o(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ho)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ya=function(t,e,r,n){var o=function(t,e,r,n){return La(Va,Ga,Wa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.4",o},Qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xa={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function Za(t){return t[s]?t:function(t){var e=t.contract;return No(t,Xa,Qa).then((function(t){return t.contract=e,t}))}(t)}var tu=new WeakMap,eu=new WeakMap;var ru=function(){this.__suspend__=null,this.queueStore=new Set},nu={$suspend:{configurable:!0},$queues:{configurable:!0}};nu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ru.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},nu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ru.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ru.prototype,nu);var ou=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){tu.set(this,t)},r.normalStore.get=function(){return tu.get(this)},r.lazyStore.set=function(t){eu.set(this,t)},r.lazyStore.get=function(){return eu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(ru));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),Za(e).then((function(t){return{baseClient:new Da(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ma(r,n.contract).then((function(e){return Ya(r,n,e,t)}))}))}((r=e.debugOn,new ou({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message";var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},h="object"==typeof p&&p&&p.Object===Object&&p,d="object"==typeof self&&self&&self.Object===Object&&self,v=h||d||Function("return this")(),g=v.Symbol;function y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&I(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Z(t){return void 0===t}var tt="[object Boolean]";var et="[object Number]";function rt(t){return function(t){return"number"==typeof t||T(t)&&E(t)==et}(t)&&t!=+t}var nt="[object String]";function ot(t){return"string"==typeof t||!b(t)&&T(t)&&E(t)==nt}function it(t,e){return function(r){return t(e(r))}}var at=it(Object.getPrototypeOf,Object),ut="[object Object]",ct=Function.prototype,st=Object.prototype,ft=ct.toString,lt=st.hasOwnProperty,pt=ft.call(Object);function ht(t){if(!T(t)||E(t)!=ut)return!1;var e=at(t);if(null===e)return!0;var r=lt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var dt,vt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[dt?a:++n];if(!1===e(o[u],u,o))break}return t};var gt="[object Arguments]";function yt(t){return T(t)&&E(t)==gt}var bt=Object.prototype,mt=bt.hasOwnProperty,_t=bt.propertyIsEnumerable,wt=yt(function(){return arguments}())?yt:function(t){return T(t)&&mt.call(t,"callee")&&!_t.call(t,"callee")};var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,St=Ot&&Ot.exports===jt?v.Buffer:void 0,At=(St?St.isBuffer:void 0)||function(){return!1},kt=9007199254740991,Et=/^(?:0|[1-9]\d*)$/;function Tt(t,e){var r=typeof t;return!!(e=null==e?kt:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=xt}var qt={};qt["[object Float32Array]"]=qt["[object Float64Array]"]=qt["[object Int8Array]"]=qt["[object Int16Array]"]=qt["[object Int32Array]"]=qt["[object Uint8Array]"]=qt["[object Uint8ClampedArray]"]=qt["[object Uint16Array]"]=qt["[object Uint32Array]"]=!0,qt["[object Arguments]"]=qt["[object Array]"]=qt["[object ArrayBuffer]"]=qt["[object Boolean]"]=qt["[object DataView]"]=qt["[object Date]"]=qt["[object Error]"]=qt["[object Function]"]=qt["[object Map]"]=qt["[object Number]"]=qt["[object Object]"]=qt["[object RegExp]"]=qt["[object Set]"]=qt["[object String]"]=qt["[object WeakMap]"]=!1;var Ct,$t="object"==typeof exports&&exports&&!exports.nodeType&&exports,zt=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=zt&&zt.exports===$t&&h.process,Ft=function(){try{var t=zt&&zt.require&&zt.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch(t){}}(),It=Ft&&Ft.isTypedArray,Rt=It?(Ct=It,function(t){return Ct(t)}):function(t){return T(t)&&Pt(t.length)&&!!qt[E(t)]},Jt=Object.prototype.hasOwnProperty;function Mt(t,e){var r=b(t),n=!r&&wt(t),o=!r&&!n&&At(t),i=!r&&!n&&!o&&Rt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ne.prototype.set=function(t,e){var r=this.__data__,n=ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var oe,ie=v["__core-js_shared__"],ae=(oe=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+oe:"";var ue=Function.prototype.toString;function ce(t){if(null!=t){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var se=/^\[object .+?Constructor\]$/,fe=Function.prototype,le=Object.prototype,pe=fe.toString,he=le.hasOwnProperty,de=RegExp("^"+pe.call(he).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ve(t){return!(!Bt(t)||function(t){return!!ae&&ae in t}(t))&&(Yt(t)?de:se).test(ce(t))}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ve(r)?r:void 0}var ye=ge(v,"Map"),be=ge(Object,"create");var me="__lodash_hash_undefined__",_e=Object.prototype.hasOwnProperty;var we=Object.prototype.hasOwnProperty;var je="__lodash_hash_undefined__";function Oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ce?new xe:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=_n)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(mn);function Sn(t,e){return On(function(t,e,r){return e=bn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=bn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=An.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Bt(r))return!1;var n=typeof e;return!!("number"==n?Qt(r)&&Tt(e,r.length):"string"==n&&e in r)&&te(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Vn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Gn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Bn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Kn(r,t)})).length},Wn=function(t,e){if(void 0===e&&(e=null),ht(t)){if(!e)return!0;if(Kn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Z(r)||(!1!==(e=Vn(t))?!Gn({arg:r},e):!Bn(t)(r))})).length)})).length}return!1},Yn=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Wn.apply(null,n)},Qn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),Xn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Zn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),to=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),co=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),so=Object.freeze({__proto__:null,Jsonql406Error:Qn,Jsonql500Error:Xn,JsonqlAuthorisationError:Zn,JsonqlContractAuthError:to,JsonqlResolverAppError:eo,JsonqlResolverNotFoundError:ro,JsonqlEnumError:no,JsonqlTypeError:oo,JsonqlCheckerError:io,JsonqlValidationError:ao,JsonqlError:uo,JsonqlServerError:co}),fo=uo,lo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function po(t){if(lo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&so[o])throw new so[r](i,a);throw new fo(i,a)}return t}function ho(t){if(Array.isArray(t))throw new ao("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof Qn:throw new Qn(e,r);case t instanceof Xn:throw new Xn(e,r);case t instanceof Zn:throw new Zn(e,r);case t instanceof to:throw new to(e,r);case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof co:throw new co(e,r);default:throw new uo(e,r)}}function vo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var go=function(t,e){var r;switch(!0){case"object"===t:return!Yn(e);case"array"===t:return!Kn(e.arg);case!1!==(r=Vn(t)):return!Gn(e,r);default:return!Bn(t)(e.arg)}},yo=function(t,e){return Z(t)?!0!==e.optional||Z(e.defaultvalue)?null:e.defaultvalue:t},bo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Kn(e))throw new uo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Kn(t))throw new uo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return vo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:vo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:vo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?yo(t,a):t,index:r,param:a,optional:i}}));default:throw vo(5),new uo("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!$n(e)&&!(r.type.length>r.type.filter((function(e){return go(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return go(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},mo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},_o=function(t){return!$n(t)};function wo(t,e){var r=Cn(e,(function(t,e){return!t[Hn]}));return Sr(r,{})?t:function(t,e){var r={};return e=Yr(e),Zt(t,(function(t,n,o){Xr(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,Yr((function(t){return t.alias===e})),Zt)||e}))}function jo(t,e){return En(e,(function(e,r){var n,o;return Z(t[r])||!0===e[Jn]&&_o(t[r])?kn({},e,((n={})[Ln]=!0,n)):((o={})[Un]=t[r],o[Rn]=e[Rn],o[Jn]=e[Jn]||!1,o[Mn]=e[Mn]||!1,o[Dn]=e[Dn]||!1,o)}))}function Oo(t,e){var r=function(t,e){var r=wo(t,e);return{pristineValues:En(Cn(e,(function(t,e){return mo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Cn(e,(function(t,e){return!mo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[jo(n,r.checkAgainstAppProps),o]}var So=function(t){return Kn(t)?t:[t]};var Ao=function(t,e){return!Kn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},ko=function(t,e){try{return!!Yt(e)&&e.apply(null,[t])}catch(t){return!1}};function Eo(t){return function(e,r){if(e[Ln])return e[Un];var n=function(t,e){var r,n=[[t[Un]],[(r={},r[Rn]=So(t[Rn]),r[Jn]=t[Jn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw vo("runValidationAction",r,e),new oo(r,n);if(!1!==e[Mn]&&!Ao(e[Un],e[Mn]))throw vo(Mn,e[Mn]),new no(r);if(!1!==e[Dn]&&!ko(e[Un],e[Dn]))throw vo(Dn,e[Dn]),new io(r);return e[Un]}}var To=function(t,e){return Promise.resolve(Oo(t,e))};function xo(t,e,r,n){return void 0===t&&(t={}),To(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=En(r,Eo(e));return kn(o,n)}(t,n)})).then((function(t){return kn({},t,r)}))}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),Kn(s)&&(p[i]=s),Yt(f)&&(p[u]=f),ot(l)&&(p[c]=l),p}var qo=Nn,Co=Kn,$o=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=bo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},No=function(t){return function(e,r,n){return void 0===n&&(n={}),xo(e,r,n,t)}}(bo),Fo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Io=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ii().key(e);t(ai(r),r)}},remove:function(t){return ii().removeItem(t)},clearAll:function(){return ii().clear()}};function ii(){return ni.localStorage}function ai(t){return ii().getItem(t)}var ui=Uo.trim,ci={name:"cookieStorage",read:function(t){if(!t||!pi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(si.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;si.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:fi,remove:li,clearAll:function(){fi((function(t,e){li(e)}))}},si=Uo.Global.document;function fi(t){for(var e=si.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ui(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function li(t){t&&pi(t)&&(si.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function pi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(si.cookie)}var hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var di="expire_mixin",vi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+di);return{set:function(e,r,n,o){this.hasNamespace(di)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(di)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(di)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Oi=[oi,ci],Si=[hi,vi,_i,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ji.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ji.compress(this._serialize(r));t(e,n)}}}],Ai=ti.createStore(Oi,Si),ki=Uo.Global;function Ei(){return ki.sessionStorage}function Ti(t){return Ei().getItem(t)}var xi=[{name:"sessionStorage",read:Ti,write:function(t,e){return Ei().setItem(t,e)},each:function(t){for(var e=Ei().length-1;e>=0;e--){var r=Ei().key(e);t(Ti(r),r)}},remove:function(t){return Ei().removeItem(t)},clearAll:function(){return Ei().clear()}},ci],Pi=[hi,vi],qi=ti.createStore(xi,Pi),Ci=Ai,$i=qi,zi=Array.isArray,Ni=void 0!==p?p:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Fi="object"==typeof Ni&&Ni&&Ni.Object===Object&&Ni,Ii="object"==typeof self&&self&&self.Object===Object&&self,Ri=(Fi||Ii||Function("return this")()).Symbol,Ji=Object.prototype,Mi=Ji.hasOwnProperty,Ui=Ji.toString,Di=Ri?Ri.toStringTag:void 0;var Hi=Object.prototype.toString;var Li="[object Null]",Bi="[object Undefined]",Ki=Ri?Ri.toStringTag:void 0;function Vi(t){return null==t?void 0===t?Bi:Li:Ki&&Ki in Object(t)?function(t){var e=Mi.call(t,Di),r=t[Di];try{t[Di]=void 0;var n=!0}catch(t){}var o=Ui.call(t);return n&&(e?t[Di]=r:delete t[Di]),o}(t):function(t){return Hi.call(t)}(t)}var Gi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Wi(t){return null!=t&&"object"==typeof t}var Yi="[object Object]",Qi=Function.prototype,Xi=Object.prototype,Zi=Qi.toString,ta=Xi.hasOwnProperty,ea=Zi.call(Object);var ra=Ri?Ri.prototype:void 0,na=(ra&&ra.toString,"[object String]");function oa(t){return"string"==typeof t||!zi(t)&&Wi(t)&&Vi(t)==na}var ia=function(t,e){return!!t.filter((function(t){return t===e})).length},aa=function(t,e){var r=Object.keys(t);return ia(r,e)},ua=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ca="query",sa="mutation",fa="socket",la="payload",pa="condition",ha=function(){try{if(window||document)return!0}catch(t){}return!1},da=function(){try{if(!ha()&&Ni)return!0}catch(t){}return!1};var va=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ha()?"browser":da()?"node":"unknown"},e}(Error));var ga=function(t){var e;return(e={}).args=t,e};var ya=function(t){return aa(t,"data")&&!aa(t,"error")?t.data:t},ba=function(t){return function(t){if(!Wi(t)||Vi(t)!=Yi)return!1;var e=Gi(t);if(null===e)return!0;var r=ta.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zi.call(r)==ea}(t)&&(aa(t,ca)||aa(t,sa)||aa(t,fa))},ma=function(t,e){return void 0===e&&(e={}),ba(e)?Promise.resolve(e):t.getContract()},_a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function wa(t){this.message=t}wa.prototype=new Error,wa.prototype.name="InvalidCharacterError";var ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new wa("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=_a.indexOf(n);return a};var Oa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ja(e)}};function Sa(t){this.message=t}Sa.prototype=new Error,Sa.prototype.name="InvalidTokenError";var Aa=function(t,e){if("string"!=typeof t)throw new Sa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Oa(t.split(".")[r]))}catch(t){throw new Sa("Invalid token specified: "+t.message)}},ka=Sa;Aa.InvalidTokenError=ka;var Ea,Ta,xa,Pa,qa,Ca,$a,za,Na,Fa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ia(t){if(qo(t))return function(t){var e=t.iat||Fa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new uo("Token has expired on "+r,t)}return t}(Aa(t));throw new uo("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ea={})[c]="exp",Ea[o]=!0,Ea)),zo(!1,["boolean","number","string"],((Ta={})[c]="nbf",Ta[o]=!0,Ta)),zo(!1,["boolean","string"],((xa={})[c]="iss",xa[o]=!0,xa)),zo(!1,["boolean","string"],((Pa={})[c]="sub",Pa[o]=!0,Pa)),zo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),zo(!1,["boolean"],((Ca={})[o]=!0,Ca)),zo(!1,["boolean","string"],(($a={})[o]=!0,$a)),zo(!1,["boolean","string"],((za={})[o]=!0,za)),zo(!1,["boolean"],((Na={})[o]=!0,Na));var Ra=r[0],Ja=r[1],Ma=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ua={headers:{configurable:!0}};Ua.headers.set=function(t){this.extraHeader=t},Ma.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=kn({},{_cb:ua()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=kn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,kn({},{method:Ra,params:o},e))},Ma.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ma.prototype.processJsonp=function(t){return ya(t)},Ma.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=qo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ya(o)}),(function(t){throw e.cleanUp(),console.error(t),new co("Server side error",t)}))},Ma.prototype.getHeaders=function(){return this.opts.enableAuth?kn({},e,this.getAuthHeader(),this.extraHeader):kn({},e,this.extraHeader)},Ma.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ma.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=kn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(po).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ma.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),oa(t)&&zi(e)){var o=ga(e);return!0===r?o:((n={})[t]=o,n)}throw new va("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(po)},Ma.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[la]=e,i[pa]=r,!0===n)return i;if(oa(t))return(o={})[t]=i,o;throw new va("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ja}).then(po)},Object.defineProperties(Ma.prototype,Ua);var Da=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Co(t)&&t.length>=2&&Reflect.apply(Ci.set,Ci,t),new ao("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ci.get("endpoint")||[];ia(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ci.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ia(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ua();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ci.set,Ci,e)},r.jsonqlEndpoint.get=function(){var t=Ci.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ci.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return $i.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ia)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ba(t))throw new ao("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ba(this.opts.contract)?this.opts.contract:Ci.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ma))),Ha=function(t){return b(t)?t:[t]},La=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Ha(t))}),Reflect.apply(t,null,r))}};function Ba(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ka=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ho)}},Va=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ho)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Ga=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return $o(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ho)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ya=function(t,e,r,n){var o=function(t,e,r,n){return La(Va,Ga,Wa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.5",o},Qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xa={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function Za(t){return t[s]?t:function(t){var e=t.contract;return No(t,Xa,Qa).then((function(t){return t.contract=e,t}))}(t)}var tu=new WeakMap,eu=new WeakMap;var ru=function(){this.__suspend__=null,this.queueStore=new Set},nu={$suspend:{configurable:!0},$queues:{configurable:!0}};nu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ru.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},nu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ru.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ru.prototype,nu);var ou=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){tu.set(this,t)},r.normalStore.get=function(){return tu.get(this)},r.lazyStore.set=function(t){eu.set(this,t)},r.lazyStore.get=function(){return eu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(ru));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),Za(e).then((function(t){return{baseClient:new Da(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ma(r,n.contract).then((function(e){return Ya(r,n,e,t)}))}))}((r=e.debugOn,new ou({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 5418a9c39d3e644468095a66df8d0e8838a53f37..05abeb6176f1c8df96ee7bbf7485dc39bfc9dd33 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-client.static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message",y="onResult",b="onError",m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),A=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),P=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),q=Object.freeze({__proto__:null,Jsonql406Error:m,Jsonql500Error:_,JsonqlAuthorisationError:w,JsonqlContractAuthError:j,JsonqlResolverAppError:O,JsonqlResolverNotFoundError:S,JsonqlEnumError:E,JsonqlTypeError:k,JsonqlCheckerError:A,JsonqlValidationError:x,JsonqlError:T,JsonqlServerError:P}),C=T,$=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function N(t){if($(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&q[o])throw new q[r](i,a);throw new C(i,a)}return t}function z(t){if(Array.isArray(t))throw new x("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof k:throw new k(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof P:throw new P(e,r);default:throw new T(e,r)}}var F="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},R="object"==typeof F&&F&&F.Object===Object&&F,I="object"==typeof self&&self&&self.Object===Object&&self,J=R||I||Function("return this")(),M=J.Symbol;function U(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&ut(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Ot(t){return void 0===t}var St="[object Boolean]";var Et="[object Number]";function kt(t){return function(t){return"number"==typeof t||Q(t)&&X(t)==Et}(t)&&t!=+t}var At="[object String]";function xt(t){return"string"==typeof t||!D(t)&&Q(t)&&X(t)==At}function Tt(t,e){return function(r){return t(e(r))}}var Pt=Tt(Object.getPrototypeOf,Object),qt="[object Object]",Ct=Function.prototype,$t=Object.prototype,Nt=Ct.toString,zt=$t.hasOwnProperty,Ft=Nt.call(Object);function Rt(t){if(!Q(t)||X(t)!=qt)return!1;var e=Pt(t);if(null===e)return!0;var r=zt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Nt.call(r)==Ft}var It,Jt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[It?a:++n];if(!1===e(o[u],u,o))break}return t};var Mt="[object Arguments]";function Ut(t){return Q(t)&&X(t)==Mt}var Dt=Object.prototype,Ht=Dt.hasOwnProperty,Lt=Dt.propertyIsEnumerable,Bt=Ut(function(){return arguments}())?Ut:function(t){return Q(t)&&Ht.call(t,"callee")&&!Lt.call(t,"callee")};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=Vt&&Vt.exports===Kt?J.Buffer:void 0,Wt=(Gt?Gt.isBuffer:void 0)||function(){return!1},Yt=9007199254740991,Xt=/^(?:0|[1-9]\d*)$/;function Qt(t,e){var r=typeof t;return!!(e=null==e?Yt:e)&&("number"==r||"symbol"!=r&&Xt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Zt}var ee={};ee["[object Float32Array]"]=ee["[object Float64Array]"]=ee["[object Int8Array]"]=ee["[object Int16Array]"]=ee["[object Int32Array]"]=ee["[object Uint8Array]"]=ee["[object Uint8ClampedArray]"]=ee["[object Uint16Array]"]=ee["[object Uint32Array]"]=!0,ee["[object Arguments]"]=ee["[object Array]"]=ee["[object ArrayBuffer]"]=ee["[object Boolean]"]=ee["[object DataView]"]=ee["[object Date]"]=ee["[object Error]"]=ee["[object Function]"]=ee["[object Map]"]=ee["[object Number]"]=ee["[object Object]"]=ee["[object RegExp]"]=ee["[object Set]"]=ee["[object String]"]=ee["[object WeakMap]"]=!1;var re,ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,oe=ne&&"object"==typeof module&&module&&!module.nodeType&&module,ie=oe&&oe.exports===ne&&R.process,ae=function(){try{var t=oe&&oe.require&&oe.require("util").types;return t||ie&&ie.binding&&ie.binding("util")}catch(t){}}(),ue=ae&&ae.isTypedArray,ce=ue?(re=ue,function(t){return re(t)}):function(t){return Q(t)&&te(t.length)&&!!ee[X(t)]},se=Object.prototype.hasOwnProperty;function fe(t,e){var r=D(t),n=!r&&Bt(t),o=!r&&!n&&Wt(t),i=!r&&!n&&!o&&ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ae.prototype.set=function(t,e){var r=this.__data__,n=Ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var xe,Te=J["__core-js_shared__"],Pe=(xe=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||""))?"Symbol(src)_1."+xe:"";var qe=Function.prototype.toString;function Ce(t){if(null!=t){try{return qe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $e=/^\[object .+?Constructor\]$/,Ne=Function.prototype,ze=Object.prototype,Fe=Ne.toString,Re=ze.hasOwnProperty,Ie=RegExp("^"+Fe.call(Re).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Je(t){return!(!ve(t)||function(t){return!!Pe&&Pe in t}(t))&&(_e(t)?Ie:$e).test(Ce(t))}function Me(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Je(r)?r:void 0}var Ue=Me(J,"Map"),De=Me(Object,"create");var He="__lodash_hash_undefined__",Le=Object.prototype.hasOwnProperty;var Be=Object.prototype.hasOwnProperty;var Ke="__lodash_hash_undefined__";function Ve(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&rr?new Ze:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Ln)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Hn);function Gn(t,e){return Vn(function(t,e,r){return e=Dn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Dn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Wn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ve(r))return!1;var n=typeof e;return!!("number"==n?we(r)&&Qt(e,r.length):"string"==n&&e in r)&&Se(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},bo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!go(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yo(r,t)})).length},_o=function(t,e){if(void 0===e&&(e=null),Rt(t)){if(!e)return!0;if(yo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Ot(r)||(!1!==(e=bo(t))?!mo({arg:r},e):!go(t)(r))})).length)})).length}return!1},wo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),_o.apply(null,n)};function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!wo(e);case"array"===t:return!yo(e.arg);case!1!==(r=bo(t)):return!mo(e,r);default:return!go(t)(e.arg)}},So=function(t,e){return Ot(t)?!0!==e.optional||Ot(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yo(e))throw new T("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yo(t))throw new T("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new T("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!no(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!no(t)};function xo(t,e){var r=ro(e,(function(t,e){return!t[ho]}));return Gr(r,{})?t:function(t,e){var r={};return e=wn(e),Oe(t,(function(t,n,o){On(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,wn((function(t){return t.alias===e})),Oe)||e}))}function To(t,e){return Xn(e,(function(e,r){var n,o;return Ot(t[r])||!0===e[so]&&Ao(t[r])?Yn({},e,((n={})[vo]=!0,n)):((o={})[lo]=t[r],o[co]=e[co],o[so]=e[so]||!1,o[fo]=e[fo]||!1,o[po]=e[po]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:Xn(ro(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:ro(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return yo(t)?t:[t]};var Co=function(t,e){return!yo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!_e(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[vo])return e[lo];var n=function(t,e){var r,n=[[t[lo]],[(r={},r[co]=qo(t[co]),r[so]=t[so],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new k(r,n);if(!1!==e[fo]&&!Co(e[lo],e[fo]))throw jo(fo,e[fo]),new E(r);if(!1!==e[po]&&!$o(e[lo],e[po]))throw jo(po,e[po]),new A(r);return e[lo]}}function zo(t,e,r,n){return void 0===t&&(t={}),Yn(function(t,e){var r=t[0],n=t[1],o=Xn(r,No(e));return Yn(o,n)}(Po(t,e),n),r)}function Fo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),yo(n)&&(a[f]=n),_e(o)&&(a[p]=o),xt(i)&&(a[h]=i),a}var Ro=io,Io=yo,Jo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Mo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Fo.apply(null,[t,e,n,o,i,a])},Uo=function(t){return function(e,r,n){return void 0===n&&(n={}),zo(e,r,n,t)}}(Eo),Do=function(t){return D(t)?t:[t]},Ho=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Do(t))}),Reflect.apply(t,null,r))}};function Lo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(z)}},Ko=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(z)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(z)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Go=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Wo=Array.isArray,Yo=void 0!==F?F:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xo="object"==typeof Yo&&Yo&&Yo.Object===Object&&Yo,Qo="object"==typeof self&&self&&self.Object===Object&&self,Zo=(Xo||Qo||Function("return this")()).Symbol,ti=Object.prototype,ei=ti.hasOwnProperty,ri=ti.toString,ni=Zo?Zo.toStringTag:void 0;var oi=Object.prototype.toString;var ii="[object Null]",ai="[object Undefined]",ui=Zo?Zo.toStringTag:void 0;function ci(t){return null==t?void 0===t?ai:ii:ui&&ui in Object(t)?function(t){var e=ei.call(t,ni),r=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var o=ri.call(t);return n&&(e?t[ni]=r:delete t[ni]),o}(t):function(t){return oi.call(t)}(t)}var si=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function fi(t){return null!=t&&"object"==typeof t}var li="[object Object]",pi=Function.prototype,hi=Object.prototype,di=pi.toString,vi=hi.hasOwnProperty,gi=di.call(Object);var yi=Zo?Zo.prototype:void 0,bi=(yi&&yi.toString,"[object String]");function mi(t){return"string"==typeof t||!Wo(t)&&fi(t)&&ci(t)==bi}var _i=function(t,e){return!!t.filter((function(t){return t===e})).length},wi=function(t,e){var r=Object.keys(t);return _i(r,e)},ji=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Oi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Si="query",Ei="mutation",ki="socket",Ai="payload",xi="condition",Ti=function(){try{if(window||document)return!0}catch(t){}return!1},Pi=function(){try{if(!Ti()&&Yo)return!0}catch(t){}return!1};var qi=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ti()?"browser":Pi()?"node":"unknown"},e}(Error));var Ci=function(t){var e;return(e={}).args=t,e};var $i=function(t){return wi(t,"data")&&!wi(t,"error")?t.data:t},Ni=function(t){return function(t){if(!fi(t)||ci(t)!=li)return!1;var e=si(t);if(null===e)return!0;var r=vi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&di.call(r)==gi}(t)&&(wi(t,Si)||wi(t,Ei)||wi(t,ki))},zi=function(t,e){return void 0===e&&(e={}),Ni(e)?Promise.resolve(e):t.getContract()},Fi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(ji(e,r,y),o),t.$only(ji(e,r,b),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Ii(t,e,r,n){var o=function(t,e,r,n){return Ho(Ko,Vo,Go)({},t,e,r,n)}(t,e,r,n);Ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(ji(t,n,y),r)})).catch((function(r){e.$trigger(ji(t,n,b),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ji=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Ii(t,n,e,r)}));var o={query:Fi(n,"query"),mutation:Fi(n,"mutation"),auth:Fi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.4",o},Mi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ca().key(e);t(sa(r),r)}},remove:function(t){return ca().removeItem(t)},clearAll:function(){return ca().clear()}};function ca(){return aa.localStorage}function sa(t){return ca().getItem(t)}var fa=Li.trim,la={name:"cookieStorage",read:function(t){if(!t||!va(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(pa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;pa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ha,remove:da,clearAll:function(){ha((function(t,e){da(e)}))}},pa=Li.Global.document;function ha(t){for(var e=pa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(fa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function da(t){t&&va(t)&&(pa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function va(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(pa.cookie)}var ga=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ya="expire_mixin",ba=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ya);return{set:function(e,r,n,o){this.hasNamespace(ya)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ya)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ya)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ka=[ua,la],Aa=[ga,ba,Oa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ea.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ea.compress(this._serialize(r));t(e,n)}}}],xa=na.createStore(ka,Aa),Ta=Li.Global;function Pa(){return Ta.sessionStorage}function qa(t){return Pa().getItem(t)}var Ca=[{name:"sessionStorage",read:qa,write:function(t,e){return Pa().setItem(t,e)},each:function(t){for(var e=Pa().length-1;e>=0;e--){var r=Pa().key(e);t(qa(r),r)}},remove:function(t){return Pa().removeItem(t)},clearAll:function(){return Pa().clear()}},la],$a=[ga,ba],Na=na.createStore(Ca,$a),za=xa,Fa=Na,Ra="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidCharacterError";var Ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ia("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Ra.indexOf(n);return a};var Ma=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ja(e)}};function Ua(t){this.message=t}Ua.prototype=new Error,Ua.prototype.name="InvalidTokenError";var Da=function(t,e){if("string"!=typeof t)throw new Ua("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ma(t.split(".")[r]))}catch(t){throw new Ua("Invalid token specified: "+t.message)}},Ha=Ua;Da.InvalidTokenError=Ha;var La,Ba,Ka,Va,Ga,Wa,Ya,Xa,Qa,Za=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function tu(t){if(Ro(t))return function(t){var e=t.iat||Za(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new T("Token has expired on "+r,t)}return t}(Da(t));throw new T("Token must be a string!")}Mo("HS256",["string"]),Mo(!1,["boolean","number","string"],((La={})[h]="exp",La[s]=!0,La)),Mo(!1,["boolean","number","string"],((Ba={})[h]="nbf",Ba[s]=!0,Ba)),Mo(!1,["boolean","string"],((Ka={})[h]="iss",Ka[s]=!0,Ka)),Mo(!1,["boolean","string"],((Va={})[h]="sub",Va[s]=!0,Va)),Mo(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Mo(!1,["boolean"],((Wa={})[s]=!0,Wa)),Mo(!1,["boolean","string"],((Ya={})[s]=!0,Ya)),Mo(!1,["boolean","string"],((Xa={})[s]=!0,Xa)),Mo(!1,["boolean"],((Qa={})[s]=!0,Qa));var eu=u[0],ru=u[1],nu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ou={headers:{configurable:!0}};ou.headers.set=function(t){this.extraHeader=t},nu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Yn({},{_cb:Oi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Yn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Yn({},{method:eu,params:o},e))},nu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},nu.prototype.processJsonp=function(t){return $i(t)},nu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):$i(o)}),(function(t){throw e.cleanUp(),console.error(t),new P("Server side error",t)}))},nu.prototype.getHeaders=function(){return this.opts.enableAuth?Yn({},a,this.getAuthHeader(),this.extraHeader):Yn({},a,this.extraHeader)},nu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},nu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Yn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(N).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},nu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),mi(t)&&Wo(e)){var o=Ci(e);return!0===r?o:((n={})[t]=o,n)}throw new qi("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(N)},nu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ai]=e,i[xi]=r,!0===n)return i;if(mi(t))return(o={})[t]=i,o;throw new qi("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ru}).then(N)},Object.defineProperties(nu.prototype,ou);var iu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Io(t)&&t.length>=2&&Reflect.apply(za.set,za,t),new x("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=za.get("endpoint")||[];_i(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=za.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!_i(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Oi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(za.set,za,e)},r.jsonqlEndpoint.get=function(){var t=za.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(za.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Fa.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=tu)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Ni(t))throw new x("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Ni(this.opts.contract)?this.opts.contract:za.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(nu))),au={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},uu={hostname:Mo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Mo("jsonql",["string"]),loginHandlerName:Mo("login",["string"]),logoutHandlerName:Mo("logout",["string"]),enableJsonp:Mo(!1,["boolean"]),enableAuth:Mo(!1,["boolean"]),useJwt:Mo(!0,["boolean"]),useLocalstorage:Mo(!0,["boolean"]),storageKey:Mo("storageKey",["string"]),authKey:Mo("authKey",["string"]),contractExpired:Mo(0,["number"]),keepContract:Mo(!0,["boolean"]),exposeContract:Mo(!1,["boolean"]),showContractDesc:Mo(!1,["boolean"]),contractKey:Mo(!1,["boolean"]),contractKeyName:Mo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Mo(!1,["boolean"]),timeout:Mo(5e3,["number"]),returnInstance:Mo(!1,["boolean"]),allowReturnRawToken:Mo(!1,["boolean"]),debugOn:Mo(!1,["boolean"])};function cu(t){return t[d]?t:function(t){return Uo(t,uu,au)}(t)}var su=new WeakMap,fu=new WeakMap;var lu=function(){this.__suspend__=null,this.queueStore=new Set},pu={$suspend:{configurable:!0},$queues:{configurable:!0}};pu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},lu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},pu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},lu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(lu.prototype,pu);var hu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){su.set(this,t)},r.normalStore.get=function(){return su.get(this)},r.lazyStore.set=function(t){fu.set(this,t)},r.lazyStore.get=function(){return fu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(lu));function du(t,e){void 0===e&&(e={});var r,n=e.contract,o=cu(e),i=new iu(o,t),a=zi(i,n),u=(r=o.debugOn,new hu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ji(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),du(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message",y="onResult",b="onError",m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),A=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),P=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),q=Object.freeze({__proto__:null,Jsonql406Error:m,Jsonql500Error:_,JsonqlAuthorisationError:w,JsonqlContractAuthError:j,JsonqlResolverAppError:O,JsonqlResolverNotFoundError:S,JsonqlEnumError:E,JsonqlTypeError:k,JsonqlCheckerError:A,JsonqlValidationError:x,JsonqlError:T,JsonqlServerError:P}),C=T,$=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function N(t){if($(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&q[o])throw new q[r](i,a);throw new C(i,a)}return t}function z(t){if(Array.isArray(t))throw new x("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof k:throw new k(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof P:throw new P(e,r);default:throw new T(e,r)}}var F="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},R="object"==typeof F&&F&&F.Object===Object&&F,I="object"==typeof self&&self&&self.Object===Object&&self,J=R||I||Function("return this")(),M=J.Symbol;function U(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&ut(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Ot(t){return void 0===t}var St="[object Boolean]";var Et="[object Number]";function kt(t){return function(t){return"number"==typeof t||Q(t)&&X(t)==Et}(t)&&t!=+t}var At="[object String]";function xt(t){return"string"==typeof t||!D(t)&&Q(t)&&X(t)==At}function Tt(t,e){return function(r){return t(e(r))}}var Pt=Tt(Object.getPrototypeOf,Object),qt="[object Object]",Ct=Function.prototype,$t=Object.prototype,Nt=Ct.toString,zt=$t.hasOwnProperty,Ft=Nt.call(Object);function Rt(t){if(!Q(t)||X(t)!=qt)return!1;var e=Pt(t);if(null===e)return!0;var r=zt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Nt.call(r)==Ft}var It,Jt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[It?a:++n];if(!1===e(o[u],u,o))break}return t};var Mt="[object Arguments]";function Ut(t){return Q(t)&&X(t)==Mt}var Dt=Object.prototype,Ht=Dt.hasOwnProperty,Lt=Dt.propertyIsEnumerable,Bt=Ut(function(){return arguments}())?Ut:function(t){return Q(t)&&Ht.call(t,"callee")&&!Lt.call(t,"callee")};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=Vt&&Vt.exports===Kt?J.Buffer:void 0,Wt=(Gt?Gt.isBuffer:void 0)||function(){return!1},Yt=9007199254740991,Xt=/^(?:0|[1-9]\d*)$/;function Qt(t,e){var r=typeof t;return!!(e=null==e?Yt:e)&&("number"==r||"symbol"!=r&&Xt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Zt}var ee={};ee["[object Float32Array]"]=ee["[object Float64Array]"]=ee["[object Int8Array]"]=ee["[object Int16Array]"]=ee["[object Int32Array]"]=ee["[object Uint8Array]"]=ee["[object Uint8ClampedArray]"]=ee["[object Uint16Array]"]=ee["[object Uint32Array]"]=!0,ee["[object Arguments]"]=ee["[object Array]"]=ee["[object ArrayBuffer]"]=ee["[object Boolean]"]=ee["[object DataView]"]=ee["[object Date]"]=ee["[object Error]"]=ee["[object Function]"]=ee["[object Map]"]=ee["[object Number]"]=ee["[object Object]"]=ee["[object RegExp]"]=ee["[object Set]"]=ee["[object String]"]=ee["[object WeakMap]"]=!1;var re,ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,oe=ne&&"object"==typeof module&&module&&!module.nodeType&&module,ie=oe&&oe.exports===ne&&R.process,ae=function(){try{var t=oe&&oe.require&&oe.require("util").types;return t||ie&&ie.binding&&ie.binding("util")}catch(t){}}(),ue=ae&&ae.isTypedArray,ce=ue?(re=ue,function(t){return re(t)}):function(t){return Q(t)&&te(t.length)&&!!ee[X(t)]},se=Object.prototype.hasOwnProperty;function fe(t,e){var r=D(t),n=!r&&Bt(t),o=!r&&!n&&Wt(t),i=!r&&!n&&!o&&ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ae.prototype.set=function(t,e){var r=this.__data__,n=Ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var xe,Te=J["__core-js_shared__"],Pe=(xe=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||""))?"Symbol(src)_1."+xe:"";var qe=Function.prototype.toString;function Ce(t){if(null!=t){try{return qe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $e=/^\[object .+?Constructor\]$/,Ne=Function.prototype,ze=Object.prototype,Fe=Ne.toString,Re=ze.hasOwnProperty,Ie=RegExp("^"+Fe.call(Re).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Je(t){return!(!ve(t)||function(t){return!!Pe&&Pe in t}(t))&&(_e(t)?Ie:$e).test(Ce(t))}function Me(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Je(r)?r:void 0}var Ue=Me(J,"Map"),De=Me(Object,"create");var He="__lodash_hash_undefined__",Le=Object.prototype.hasOwnProperty;var Be=Object.prototype.hasOwnProperty;var Ke="__lodash_hash_undefined__";function Ve(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&rr?new Ze:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Ln)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Hn);function Gn(t,e){return Vn(function(t,e,r){return e=Dn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Dn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Wn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ve(r))return!1;var n=typeof e;return!!("number"==n?we(r)&&Qt(e,r.length):"string"==n&&e in r)&&Se(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},bo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!go(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yo(r,t)})).length},_o=function(t,e){if(void 0===e&&(e=null),Rt(t)){if(!e)return!0;if(yo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Ot(r)||(!1!==(e=bo(t))?!mo({arg:r},e):!go(t)(r))})).length)})).length}return!1},wo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),_o.apply(null,n)};function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!wo(e);case"array"===t:return!yo(e.arg);case!1!==(r=bo(t)):return!mo(e,r);default:return!go(t)(e.arg)}},So=function(t,e){return Ot(t)?!0!==e.optional||Ot(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yo(e))throw new T("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yo(t))throw new T("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new T("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!no(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!no(t)};function xo(t,e){var r=ro(e,(function(t,e){return!t[ho]}));return Gr(r,{})?t:function(t,e){var r={};return e=wn(e),Oe(t,(function(t,n,o){On(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,wn((function(t){return t.alias===e})),Oe)||e}))}function To(t,e){return Xn(e,(function(e,r){var n,o;return Ot(t[r])||!0===e[so]&&Ao(t[r])?Yn({},e,((n={})[vo]=!0,n)):((o={})[lo]=t[r],o[co]=e[co],o[so]=e[so]||!1,o[fo]=e[fo]||!1,o[po]=e[po]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:Xn(ro(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:ro(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return yo(t)?t:[t]};var Co=function(t,e){return!yo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!_e(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[vo])return e[lo];var n=function(t,e){var r,n=[[t[lo]],[(r={},r[co]=qo(t[co]),r[so]=t[so],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new k(r,n);if(!1!==e[fo]&&!Co(e[lo],e[fo]))throw jo(fo,e[fo]),new E(r);if(!1!==e[po]&&!$o(e[lo],e[po]))throw jo(po,e[po]),new A(r);return e[lo]}}function zo(t,e,r,n){return void 0===t&&(t={}),Yn(function(t,e){var r=t[0],n=t[1],o=Xn(r,No(e));return Yn(o,n)}(Po(t,e),n),r)}function Fo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),yo(n)&&(a[f]=n),_e(o)&&(a[p]=o),xt(i)&&(a[h]=i),a}var Ro=io,Io=yo,Jo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Mo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Fo.apply(null,[t,e,n,o,i,a])},Uo=function(t){return function(e,r,n){return void 0===n&&(n={}),zo(e,r,n,t)}}(Eo),Do=function(t){return D(t)?t:[t]},Ho=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Do(t))}),Reflect.apply(t,null,r))}};function Lo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(z)}},Ko=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(z)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(z)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Go=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Wo=Array.isArray,Yo=void 0!==F?F:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xo="object"==typeof Yo&&Yo&&Yo.Object===Object&&Yo,Qo="object"==typeof self&&self&&self.Object===Object&&self,Zo=(Xo||Qo||Function("return this")()).Symbol,ti=Object.prototype,ei=ti.hasOwnProperty,ri=ti.toString,ni=Zo?Zo.toStringTag:void 0;var oi=Object.prototype.toString;var ii="[object Null]",ai="[object Undefined]",ui=Zo?Zo.toStringTag:void 0;function ci(t){return null==t?void 0===t?ai:ii:ui&&ui in Object(t)?function(t){var e=ei.call(t,ni),r=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var o=ri.call(t);return n&&(e?t[ni]=r:delete t[ni]),o}(t):function(t){return oi.call(t)}(t)}var si=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function fi(t){return null!=t&&"object"==typeof t}var li="[object Object]",pi=Function.prototype,hi=Object.prototype,di=pi.toString,vi=hi.hasOwnProperty,gi=di.call(Object);var yi=Zo?Zo.prototype:void 0,bi=(yi&&yi.toString,"[object String]");function mi(t){return"string"==typeof t||!Wo(t)&&fi(t)&&ci(t)==bi}var _i=function(t,e){return!!t.filter((function(t){return t===e})).length},wi=function(t,e){var r=Object.keys(t);return _i(r,e)},ji=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Oi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Si="query",Ei="mutation",ki="socket",Ai="payload",xi="condition",Ti=function(){try{if(window||document)return!0}catch(t){}return!1},Pi=function(){try{if(!Ti()&&Yo)return!0}catch(t){}return!1};var qi=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ti()?"browser":Pi()?"node":"unknown"},e}(Error));var Ci=function(t){var e;return(e={}).args=t,e};var $i=function(t){return wi(t,"data")&&!wi(t,"error")?t.data:t},Ni=function(t){return function(t){if(!fi(t)||ci(t)!=li)return!1;var e=si(t);if(null===e)return!0;var r=vi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&di.call(r)==gi}(t)&&(wi(t,Si)||wi(t,Ei)||wi(t,ki))},zi=function(t,e){return void 0===e&&(e={}),Ni(e)?Promise.resolve(e):t.getContract()},Fi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(ji(e,r,y),o),t.$only(ji(e,r,b),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Ii(t,e,r,n){var o=function(t,e,r,n){return Ho(Ko,Vo,Go)({},t,e,r,n)}(t,e,r,n);Ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(ji(t,n,y),r)})).catch((function(r){e.$trigger(ji(t,n,b),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ji=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Ii(t,n,e,r)}));var o={query:Fi(n,"query"),mutation:Fi(n,"mutation"),auth:Fi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.5",o},Mi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ca().key(e);t(sa(r),r)}},remove:function(t){return ca().removeItem(t)},clearAll:function(){return ca().clear()}};function ca(){return aa.localStorage}function sa(t){return ca().getItem(t)}var fa=Li.trim,la={name:"cookieStorage",read:function(t){if(!t||!va(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(pa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;pa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ha,remove:da,clearAll:function(){ha((function(t,e){da(e)}))}},pa=Li.Global.document;function ha(t){for(var e=pa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(fa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function da(t){t&&va(t)&&(pa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function va(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(pa.cookie)}var ga=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ya="expire_mixin",ba=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ya);return{set:function(e,r,n,o){this.hasNamespace(ya)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ya)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ya)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ka=[ua,la],Aa=[ga,ba,Oa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ea.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ea.compress(this._serialize(r));t(e,n)}}}],xa=na.createStore(ka,Aa),Ta=Li.Global;function Pa(){return Ta.sessionStorage}function qa(t){return Pa().getItem(t)}var Ca=[{name:"sessionStorage",read:qa,write:function(t,e){return Pa().setItem(t,e)},each:function(t){for(var e=Pa().length-1;e>=0;e--){var r=Pa().key(e);t(qa(r),r)}},remove:function(t){return Pa().removeItem(t)},clearAll:function(){return Pa().clear()}},la],$a=[ga,ba],Na=na.createStore(Ca,$a),za=xa,Fa=Na,Ra="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidCharacterError";var Ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ia("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Ra.indexOf(n);return a};var Ma=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ja(e)}};function Ua(t){this.message=t}Ua.prototype=new Error,Ua.prototype.name="InvalidTokenError";var Da=function(t,e){if("string"!=typeof t)throw new Ua("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ma(t.split(".")[r]))}catch(t){throw new Ua("Invalid token specified: "+t.message)}},Ha=Ua;Da.InvalidTokenError=Ha;var La,Ba,Ka,Va,Ga,Wa,Ya,Xa,Qa,Za=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function tu(t){if(Ro(t))return function(t){var e=t.iat||Za(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new T("Token has expired on "+r,t)}return t}(Da(t));throw new T("Token must be a string!")}Mo("HS256",["string"]),Mo(!1,["boolean","number","string"],((La={})[h]="exp",La[s]=!0,La)),Mo(!1,["boolean","number","string"],((Ba={})[h]="nbf",Ba[s]=!0,Ba)),Mo(!1,["boolean","string"],((Ka={})[h]="iss",Ka[s]=!0,Ka)),Mo(!1,["boolean","string"],((Va={})[h]="sub",Va[s]=!0,Va)),Mo(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Mo(!1,["boolean"],((Wa={})[s]=!0,Wa)),Mo(!1,["boolean","string"],((Ya={})[s]=!0,Ya)),Mo(!1,["boolean","string"],((Xa={})[s]=!0,Xa)),Mo(!1,["boolean"],((Qa={})[s]=!0,Qa));var eu=u[0],ru=u[1],nu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ou={headers:{configurable:!0}};ou.headers.set=function(t){this.extraHeader=t},nu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Yn({},{_cb:Oi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Yn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Yn({},{method:eu,params:o},e))},nu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},nu.prototype.processJsonp=function(t){return $i(t)},nu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):$i(o)}),(function(t){throw e.cleanUp(),console.error(t),new P("Server side error",t)}))},nu.prototype.getHeaders=function(){return this.opts.enableAuth?Yn({},a,this.getAuthHeader(),this.extraHeader):Yn({},a,this.extraHeader)},nu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},nu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Yn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(N).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},nu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),mi(t)&&Wo(e)){var o=Ci(e);return!0===r?o:((n={})[t]=o,n)}throw new qi("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(N)},nu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ai]=e,i[xi]=r,!0===n)return i;if(mi(t))return(o={})[t]=i,o;throw new qi("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ru}).then(N)},Object.defineProperties(nu.prototype,ou);var iu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Io(t)&&t.length>=2&&Reflect.apply(za.set,za,t),new x("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=za.get("endpoint")||[];_i(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=za.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!_i(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Oi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(za.set,za,e)},r.jsonqlEndpoint.get=function(){var t=za.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(za.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Fa.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=tu)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Ni(t))throw new x("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Ni(this.opts.contract)?this.opts.contract:za.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(nu))),au={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},uu={hostname:Mo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Mo("jsonql",["string"]),loginHandlerName:Mo("login",["string"]),logoutHandlerName:Mo("logout",["string"]),enableJsonp:Mo(!1,["boolean"]),enableAuth:Mo(!1,["boolean"]),useJwt:Mo(!0,["boolean"]),useLocalstorage:Mo(!0,["boolean"]),storageKey:Mo("storageKey",["string"]),authKey:Mo("authKey",["string"]),contractExpired:Mo(0,["number"]),keepContract:Mo(!0,["boolean"]),exposeContract:Mo(!1,["boolean"]),showContractDesc:Mo(!1,["boolean"]),contractKey:Mo(!1,["boolean"]),contractKeyName:Mo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Mo(!1,["boolean"]),timeout:Mo(5e3,["number"]),returnInstance:Mo(!1,["boolean"]),allowReturnRawToken:Mo(!1,["boolean"]),debugOn:Mo(!1,["boolean"])};function cu(t){return t[d]?t:function(t){return Uo(t,uu,au)}(t)}var su=new WeakMap,fu=new WeakMap;var lu=function(){this.__suspend__=null,this.queueStore=new Set},pu={$suspend:{configurable:!0},$queues:{configurable:!0}};pu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},lu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},pu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},lu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(lu.prototype,pu);var hu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){su.set(this,t)},r.normalStore.get=function(){return su.get(this)},r.lazyStore.set=function(t){fu.set(this,t)},r.lazyStore.get=function(){return fu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(lu));function du(t,e){void 0===e&&(e={});var r,n=e.contract,o=cu(e),i=new iu(o,t),a=zi(i,n),u=(r=o.debugOn,new hu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ji(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),du(o,t)}})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index 3171166177df327416ed3a34b5627baa100061f3..462bda1ef737bdaa1e2a7a9388e402ef6fcf04b7 100644 --- a/packages/http-client/dist/jsonql-client.umd.js +++ b/packages/http-client/dist/jsonql-client.umd.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message";var y="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof y&&y&&y.Object===Object&&y,m="object"==typeof self&&self&&self.Object===Object&&self,_=b||m||Function("return this")(),w=_.Symbol;function j(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&D(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function ot(t){return void 0===t}var it="[object Boolean]";var at="[object Number]";function ut(t){return function(t){return"number"==typeof t||$(t)&&C(t)==at}(t)&&t!=+t}var ct="[object String]";function st(t){return"string"==typeof t||!O(t)&&$(t)&&C(t)==ct}function ft(t,e){return function(r){return t(e(r))}}var lt=ft(Object.getPrototypeOf,Object),pt="[object Object]",ht=Function.prototype,dt=Object.prototype,vt=ht.toString,gt=dt.hasOwnProperty,yt=vt.call(Object);function bt(t){if(!$(t)||C(t)!=pt)return!1;var e=lt(t);if(null===e)return!0;var r=gt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&vt.call(r)==yt}var mt,_t=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[mt?a:++n];if(!1===e(o[u],u,o))break}return t};var wt="[object Arguments]";function jt(t){return $(t)&&C(t)==wt}var Ot=Object.prototype,St=Ot.hasOwnProperty,Et=Ot.propertyIsEnumerable,kt=jt(function(){return arguments}())?jt:function(t){return $(t)&&St.call(t,"callee")&&!Et.call(t,"callee")};var At="object"==typeof exports&&exports&&!exports.nodeType&&exports,xt=At&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=xt&&xt.exports===At?_.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},qt=9007199254740991,Ct=/^(?:0|[1-9]\d*)$/;function $t(t,e){var r=typeof t;return!!(e=null==e?qt:e)&&("number"==r||"symbol"!=r&&Ct.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Nt}var Ft={};Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var Rt,It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=It&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Jt&&Jt.exports===It&&b.process,Ut=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch(t){}}(),Dt=Ut&&Ut.isTypedArray,Ht=Dt?(Rt=Dt,function(t){return Rt(t)}):function(t){return $(t)&&zt(t.length)&&!!Ft[C(t)]},Lt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=O(t),n=!r&&kt(t),o=!r&&!n&&Pt(t),i=!r&&!n&&!o&&Ht(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ce.prototype.set=function(t,e){var r=this.__data__,n=ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var se,fe=_["__core-js_shared__"],le=(se=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+se:"";var pe=Function.prototype.toString;function he(t){if(null!=t){try{return pe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var de=/^\[object .+?Constructor\]$/,ve=Function.prototype,ge=Object.prototype,ye=ve.toString,be=ge.hasOwnProperty,me=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _e(t){return!(!Yt(t)||function(t){return!!le&&le in t}(t))&&(ee(t)?me:de).test(he(t))}function we(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return _e(r)?r:void 0}var je=we(_,"Map"),Oe=we(Object,"create");var Se="__lodash_hash_undefined__",Ee=Object.prototype.hasOwnProperty;var ke=Object.prototype.hasOwnProperty;var Ae="__lodash_hash_undefined__";function xe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Re?new Ne:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=En)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Sn);function Tn(t,e){return xn(function(t,e,r){return e=On(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=On(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Pn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Yt(r))return!1;var n=typeof e;return!!("number"==n?re(r)&&$t(e,r.length):"string"==n&&e in r)&&ie(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Qn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Zn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Yn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Xn(r,t)})).length},to=function(t,e){if(void 0===e&&(e=null),bt(t)){if(!e)return!0;if(Xn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!ot(r)||(!1!==(e=Qn(t))?!Zn({arg:r},e):!Yn(t)(r))})).length)})).length}return!1},eo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),to.apply(null,n)},ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),co=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ho=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),vo=Object.freeze({__proto__:null,Jsonql406Error:ro,Jsonql500Error:no,JsonqlAuthorisationError:oo,JsonqlContractAuthError:io,JsonqlResolverAppError:ao,JsonqlResolverNotFoundError:uo,JsonqlEnumError:co,JsonqlTypeError:so,JsonqlCheckerError:fo,JsonqlValidationError:lo,JsonqlError:po,JsonqlServerError:ho}),go=po,yo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function bo(t){if(yo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&vo[o])throw new vo[r](i,a);throw new go(i,a)}return t}function mo(t){if(Array.isArray(t))throw new lo("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof uo:throw new uo(e,r);case t instanceof co:throw new co(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof ho:throw new ho(e,r);default:throw new po(e,r)}}function _o(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var wo=function(t,e){var r;switch(!0){case"object"===t:return!eo(e);case"array"===t:return!Xn(e.arg);case!1!==(r=Qn(t)):return!Zn(e,r);default:return!Yn(t)(e.arg)}},jo=function(t,e){return ot(t)?!0!==e.optional||ot(e.defaultvalue)?null:e.defaultvalue:t},Oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Xn(e))throw new po("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Xn(t))throw new po("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return _o(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:_o(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:_o(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?jo(t,a):t,index:r,param:a,optional:i}}));default:throw _o(5),new po("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!In(e)&&!(r.type.length>r.type.filter((function(e){return wo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return wo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},So=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Eo=function(t){return!In(t)};function ko(t,e){var r=Rn(e,(function(t,e){return!t[Gn]}));return Tr(r,{})?t:function(t,e){var r={};return e=en(e),oe(t,(function(t,n,o){nn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,en((function(t){return t.alias===e})),oe)||e}))}function Ao(t,e){return Cn(e,(function(e,r){var n,o;return ot(t[r])||!0===e[Ln]&&Eo(t[r])?qn({},e,((n={})[Wn]=!0,n)):((o={})[Kn]=t[r],o[Hn]=e[Hn],o[Ln]=e[Ln]||!1,o[Bn]=e[Bn]||!1,o[Vn]=e[Vn]||!1,o)}))}function xo(t,e){var r=function(t,e){var r=ko(t,e);return{pristineValues:Cn(Rn(e,(function(t,e){return So(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Rn(e,(function(t,e){return!So(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return Xn(t)?t:[t]};var Po=function(t,e){return!Xn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ee(e)&&e.apply(null,[t])}catch(t){return!1}};function Co(t){return function(e,r){if(e[Wn])return e[Kn];var n=function(t,e){var r,n=[[t[Kn]],[(r={},r[Hn]=To(t[Hn]),r[Ln]=t[Ln],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw _o("runValidationAction",r,e),new so(r,n);if(!1!==e[Bn]&&!Po(e[Kn],e[Bn]))throw _o(Bn,e[Bn]),new co(r);if(!1!==e[Vn]&&!qo(e[Kn],e[Vn]))throw _o(Vn,e[Vn]),new fo(r);return e[Kn]}}var $o=function(t,e){return Promise.resolve(xo(t,e))};function No(t,e,r,n){return void 0===t&&(t={}),$o(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=Cn(r,Co(e));return qn(o,n)}(t,n)})).then((function(t){return qn({},t,r)}))}function zo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Xn(n)&&(a[f]=n),ee(o)&&(a[p]=o),st(i)&&(a[h]=i),a}var Fo=Mn,Ro=Xn,Io=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Oo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Jo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return zo.apply(null,[t,e,n,o,i,a])},Mo=function(t){return function(e,r,n){return void 0===n&&(n={}),No(e,r,n,t)}}(Oo),Uo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=si().key(e);t(fi(r),r)}},remove:function(t){return si().removeItem(t)},clearAll:function(){return si().clear()}};function si(){return ui.localStorage}function fi(t){return si().getItem(t)}var li=Bo.trim,pi={name:"cookieStorage",read:function(t){if(!t||!gi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(hi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;hi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:di,remove:vi,clearAll:function(){di((function(t,e){vi(e)}))}},hi=Bo.Global.document;function di(t){for(var e=hi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(li(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function vi(t){t&&gi(t)&&(hi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function gi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(hi.cookie)}var yi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var bi="expire_mixin",mi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+bi);return{set:function(e,r,n,o){this.hasNamespace(bi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(bi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(bi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ai=[ci,pi],xi=[yi,mi,Si,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ki.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ki.compress(this._serialize(r));t(e,n)}}}],Ti=oi.createStore(Ai,xi),Pi=Bo.Global;function qi(){return Pi.sessionStorage}function Ci(t){return qi().getItem(t)}var $i=[{name:"sessionStorage",read:Ci,write:function(t,e){return qi().setItem(t,e)},each:function(t){for(var e=qi().length-1;e>=0;e--){var r=qi().key(e);t(Ci(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}},pi],Ni=[yi,mi],zi=oi.createStore($i,Ni),Fi=Ti,Ri=zi,Ii=Array.isArray,Ji=void 0!==y?y:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi="object"==typeof Ji&&Ji&&Ji.Object===Object&&Ji,Ui="object"==typeof self&&self&&self.Object===Object&&self,Di=(Mi||Ui||Function("return this")()).Symbol,Hi=Object.prototype,Li=Hi.hasOwnProperty,Bi=Hi.toString,Ki=Di?Di.toStringTag:void 0;var Vi=Object.prototype.toString;var Gi="[object Null]",Wi="[object Undefined]",Yi=Di?Di.toStringTag:void 0;function Xi(t){return null==t?void 0===t?Wi:Gi:Yi&&Yi in Object(t)?function(t){var e=Li.call(t,Ki),r=t[Ki];try{t[Ki]=void 0;var n=!0}catch(t){}var o=Bi.call(t);return n&&(e?t[Ki]=r:delete t[Ki]),o}(t):function(t){return Vi.call(t)}(t)}var Qi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Zi(t){return null!=t&&"object"==typeof t}var ta="[object Object]",ea=Function.prototype,ra=Object.prototype,na=ea.toString,oa=ra.hasOwnProperty,ia=na.call(Object);var aa=Di?Di.prototype:void 0,ua=(aa&&aa.toString,"[object String]");function ca(t){return"string"==typeof t||!Ii(t)&&Zi(t)&&Xi(t)==ua}var sa=function(t,e){return!!t.filter((function(t){return t===e})).length},fa=function(t,e){var r=Object.keys(t);return sa(r,e)},la=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},pa="query",ha="mutation",da="socket",va="payload",ga="condition",ya=function(){try{if(window||document)return!0}catch(t){}return!1},ba=function(){try{if(!ya()&&Ji)return!0}catch(t){}return!1};var ma=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ya()?"browser":ba()?"node":"unknown"},e}(Error));var _a=function(t){var e;return(e={}).args=t,e};var wa=function(t){return fa(t,"data")&&!fa(t,"error")?t.data:t},ja=function(t){return function(t){if(!Zi(t)||Xi(t)!=ta)return!1;var e=Qi(t);if(null===e)return!0;var r=oa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&na.call(r)==ia}(t)&&(fa(t,pa)||fa(t,ha)||fa(t,da))},Oa=function(t,e){return void 0===e&&(e={}),ja(e)?Promise.resolve(e):t.getContract()},Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ea(t){this.message=t}Ea.prototype=new Error,Ea.prototype.name="InvalidCharacterError";var ka="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ea("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Sa.indexOf(n);return a};var Aa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ka(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ka(e)}};function xa(t){this.message=t}xa.prototype=new Error,xa.prototype.name="InvalidTokenError";var Ta=function(t,e){if("string"!=typeof t)throw new xa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Aa(t.split(".")[r]))}catch(t){throw new xa("Invalid token specified: "+t.message)}},Pa=xa;Ta.InvalidTokenError=Pa;var qa,Ca,$a,Na,za,Fa,Ra,Ia,Ja,Ma=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ua(t){if(Fo(t))return function(t){var e=t.iat||Ma(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new po("Token has expired on "+r,t)}return t}(Ta(t));throw new po("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((qa={})[h]="exp",qa[s]=!0,qa)),Jo(!1,["boolean","number","string"],((Ca={})[h]="nbf",Ca[s]=!0,Ca)),Jo(!1,["boolean","string"],(($a={})[h]="iss",$a[s]=!0,$a)),Jo(!1,["boolean","string"],((Na={})[h]="sub",Na[s]=!0,Na)),Jo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Jo(!1,["boolean"],((Fa={})[s]=!0,Fa)),Jo(!1,["boolean","string"],((Ra={})[s]=!0,Ra)),Jo(!1,["boolean","string"],((Ia={})[s]=!0,Ia)),Jo(!1,["boolean"],((Ja={})[s]=!0,Ja));var Da=u[0],Ha=u[1],La=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ba={headers:{configurable:!0}};Ba.headers.set=function(t){this.extraHeader=t},La.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=qn({},{_cb:la()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,qn({},{method:Da,params:o},e))},La.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},La.prototype.processJsonp=function(t){return wa(t)},La.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ho("Server side error",t)}))},La.prototype.getHeaders=function(){return this.opts.enableAuth?qn({},a,this.getAuthHeader(),this.extraHeader):qn({},a,this.extraHeader)},La.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},La.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=qn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(bo).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},La.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),ca(t)&&Ii(e)){var o=_a(e);return!0===r?o:((n={})[t]=o,n)}throw new ma("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bo)},La.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[va]=e,i[ga]=r,!0===n)return i;if(ca(t))return(o={})[t]=i,o;throw new ma("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ha}).then(bo)},Object.defineProperties(La.prototype,Ba);var Ka=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Ro(t)&&t.length>=2&&Reflect.apply(Fi.set,Fi,t),new lo("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Fi.get("endpoint")||[];sa(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Fi.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!sa(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=la();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Fi.set,Fi,e)},r.jsonqlEndpoint.get=function(){var t=Fi.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Fi.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ri.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ua)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ja(t))throw new lo("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ja(this.opts.contract)?this.opts.contract:Fi.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(La))),Va=function(t){return O(t)?t:[t]},Ga=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Va(t))}),Reflect.apply(t,null,r))}};function Wa(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mo)}},Xa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mo)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Qa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Io(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Za=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var tu=function(t,e,r,n){var o=function(t,e,r,n){return Ga(Xa,Qa,Za)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.4",o},eu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ru={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("storageKey",["string"]),authKey:Jo("authKey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function nu(t){return t[d]?t:function(t){var e=t.contract;return Mo(t,ru,eu).then((function(t){return t.contract=e,t}))}(t)}var ou=new WeakMap,iu=new WeakMap;var au=function(){this.__suspend__=null,this.queueStore=new Set},uu={$suspend:{configurable:!0},$queues:{configurable:!0}};uu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},au.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},uu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},au.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(au.prototype,uu);var cu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ou.set(this,t)},r.normalStore.get=function(){return ou.get(this)},r.lazyStore.set=function(t){iu.set(this,t)},r.lazyStore.get=function(){return iu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(au));function su(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),nu(e).then((function(t){return{baseClient:new Ka(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Oa(r,n.contract).then((function(e){return tu(r,n,e,t)}))}))}((r=e.debugOn,new cu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),su(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message";var y="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof y&&y&&y.Object===Object&&y,m="object"==typeof self&&self&&self.Object===Object&&self,_=b||m||Function("return this")(),w=_.Symbol;function j(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&D(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function ot(t){return void 0===t}var it="[object Boolean]";var at="[object Number]";function ut(t){return function(t){return"number"==typeof t||$(t)&&C(t)==at}(t)&&t!=+t}var ct="[object String]";function st(t){return"string"==typeof t||!O(t)&&$(t)&&C(t)==ct}function ft(t,e){return function(r){return t(e(r))}}var lt=ft(Object.getPrototypeOf,Object),pt="[object Object]",ht=Function.prototype,dt=Object.prototype,vt=ht.toString,gt=dt.hasOwnProperty,yt=vt.call(Object);function bt(t){if(!$(t)||C(t)!=pt)return!1;var e=lt(t);if(null===e)return!0;var r=gt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&vt.call(r)==yt}var mt,_t=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[mt?a:++n];if(!1===e(o[u],u,o))break}return t};var wt="[object Arguments]";function jt(t){return $(t)&&C(t)==wt}var Ot=Object.prototype,St=Ot.hasOwnProperty,Et=Ot.propertyIsEnumerable,kt=jt(function(){return arguments}())?jt:function(t){return $(t)&&St.call(t,"callee")&&!Et.call(t,"callee")};var At="object"==typeof exports&&exports&&!exports.nodeType&&exports,xt=At&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=xt&&xt.exports===At?_.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},qt=9007199254740991,Ct=/^(?:0|[1-9]\d*)$/;function $t(t,e){var r=typeof t;return!!(e=null==e?qt:e)&&("number"==r||"symbol"!=r&&Ct.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Nt}var Ft={};Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var Rt,It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=It&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Jt&&Jt.exports===It&&b.process,Ut=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch(t){}}(),Dt=Ut&&Ut.isTypedArray,Ht=Dt?(Rt=Dt,function(t){return Rt(t)}):function(t){return $(t)&&zt(t.length)&&!!Ft[C(t)]},Lt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=O(t),n=!r&&kt(t),o=!r&&!n&&Pt(t),i=!r&&!n&&!o&&Ht(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ce.prototype.set=function(t,e){var r=this.__data__,n=ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var se,fe=_["__core-js_shared__"],le=(se=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+se:"";var pe=Function.prototype.toString;function he(t){if(null!=t){try{return pe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var de=/^\[object .+?Constructor\]$/,ve=Function.prototype,ge=Object.prototype,ye=ve.toString,be=ge.hasOwnProperty,me=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _e(t){return!(!Yt(t)||function(t){return!!le&&le in t}(t))&&(ee(t)?me:de).test(he(t))}function we(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return _e(r)?r:void 0}var je=we(_,"Map"),Oe=we(Object,"create");var Se="__lodash_hash_undefined__",Ee=Object.prototype.hasOwnProperty;var ke=Object.prototype.hasOwnProperty;var Ae="__lodash_hash_undefined__";function xe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Re?new Ne:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=En)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Sn);function Tn(t,e){return xn(function(t,e,r){return e=On(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=On(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Pn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Yt(r))return!1;var n=typeof e;return!!("number"==n?re(r)&&$t(e,r.length):"string"==n&&e in r)&&ie(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Qn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Zn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Yn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Xn(r,t)})).length},to=function(t,e){if(void 0===e&&(e=null),bt(t)){if(!e)return!0;if(Xn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!ot(r)||(!1!==(e=Qn(t))?!Zn({arg:r},e):!Yn(t)(r))})).length)})).length}return!1},eo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),to.apply(null,n)},ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),co=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ho=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),vo=Object.freeze({__proto__:null,Jsonql406Error:ro,Jsonql500Error:no,JsonqlAuthorisationError:oo,JsonqlContractAuthError:io,JsonqlResolverAppError:ao,JsonqlResolverNotFoundError:uo,JsonqlEnumError:co,JsonqlTypeError:so,JsonqlCheckerError:fo,JsonqlValidationError:lo,JsonqlError:po,JsonqlServerError:ho}),go=po,yo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function bo(t){if(yo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&vo[o])throw new vo[r](i,a);throw new go(i,a)}return t}function mo(t){if(Array.isArray(t))throw new lo("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof uo:throw new uo(e,r);case t instanceof co:throw new co(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof ho:throw new ho(e,r);default:throw new po(e,r)}}function _o(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var wo=function(t,e){var r;switch(!0){case"object"===t:return!eo(e);case"array"===t:return!Xn(e.arg);case!1!==(r=Qn(t)):return!Zn(e,r);default:return!Yn(t)(e.arg)}},jo=function(t,e){return ot(t)?!0!==e.optional||ot(e.defaultvalue)?null:e.defaultvalue:t},Oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Xn(e))throw new po("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Xn(t))throw new po("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return _o(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:_o(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:_o(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?jo(t,a):t,index:r,param:a,optional:i}}));default:throw _o(5),new po("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!In(e)&&!(r.type.length>r.type.filter((function(e){return wo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return wo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},So=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Eo=function(t){return!In(t)};function ko(t,e){var r=Rn(e,(function(t,e){return!t[Gn]}));return Tr(r,{})?t:function(t,e){var r={};return e=en(e),oe(t,(function(t,n,o){nn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,en((function(t){return t.alias===e})),oe)||e}))}function Ao(t,e){return Cn(e,(function(e,r){var n,o;return ot(t[r])||!0===e[Ln]&&Eo(t[r])?qn({},e,((n={})[Wn]=!0,n)):((o={})[Kn]=t[r],o[Hn]=e[Hn],o[Ln]=e[Ln]||!1,o[Bn]=e[Bn]||!1,o[Vn]=e[Vn]||!1,o)}))}function xo(t,e){var r=function(t,e){var r=ko(t,e);return{pristineValues:Cn(Rn(e,(function(t,e){return So(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Rn(e,(function(t,e){return!So(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return Xn(t)?t:[t]};var Po=function(t,e){return!Xn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ee(e)&&e.apply(null,[t])}catch(t){return!1}};function Co(t){return function(e,r){if(e[Wn])return e[Kn];var n=function(t,e){var r,n=[[t[Kn]],[(r={},r[Hn]=To(t[Hn]),r[Ln]=t[Ln],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw _o("runValidationAction",r,e),new so(r,n);if(!1!==e[Bn]&&!Po(e[Kn],e[Bn]))throw _o(Bn,e[Bn]),new co(r);if(!1!==e[Vn]&&!qo(e[Kn],e[Vn]))throw _o(Vn,e[Vn]),new fo(r);return e[Kn]}}var $o=function(t,e){return Promise.resolve(xo(t,e))};function No(t,e,r,n){return void 0===t&&(t={}),$o(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=Cn(r,Co(e));return qn(o,n)}(t,n)})).then((function(t){return qn({},t,r)}))}function zo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Xn(n)&&(a[f]=n),ee(o)&&(a[p]=o),st(i)&&(a[h]=i),a}var Fo=Mn,Ro=Xn,Io=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Oo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Jo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return zo.apply(null,[t,e,n,o,i,a])},Mo=function(t){return function(e,r,n){return void 0===n&&(n={}),No(e,r,n,t)}}(Oo),Uo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=si().key(e);t(fi(r),r)}},remove:function(t){return si().removeItem(t)},clearAll:function(){return si().clear()}};function si(){return ui.localStorage}function fi(t){return si().getItem(t)}var li=Bo.trim,pi={name:"cookieStorage",read:function(t){if(!t||!gi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(hi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;hi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:di,remove:vi,clearAll:function(){di((function(t,e){vi(e)}))}},hi=Bo.Global.document;function di(t){for(var e=hi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(li(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function vi(t){t&&gi(t)&&(hi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function gi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(hi.cookie)}var yi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var bi="expire_mixin",mi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+bi);return{set:function(e,r,n,o){this.hasNamespace(bi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(bi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(bi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ai=[ci,pi],xi=[yi,mi,Si,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ki.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ki.compress(this._serialize(r));t(e,n)}}}],Ti=oi.createStore(Ai,xi),Pi=Bo.Global;function qi(){return Pi.sessionStorage}function Ci(t){return qi().getItem(t)}var $i=[{name:"sessionStorage",read:Ci,write:function(t,e){return qi().setItem(t,e)},each:function(t){for(var e=qi().length-1;e>=0;e--){var r=qi().key(e);t(Ci(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}},pi],Ni=[yi,mi],zi=oi.createStore($i,Ni),Fi=Ti,Ri=zi,Ii=Array.isArray,Ji=void 0!==y?y:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi="object"==typeof Ji&&Ji&&Ji.Object===Object&&Ji,Ui="object"==typeof self&&self&&self.Object===Object&&self,Di=(Mi||Ui||Function("return this")()).Symbol,Hi=Object.prototype,Li=Hi.hasOwnProperty,Bi=Hi.toString,Ki=Di?Di.toStringTag:void 0;var Vi=Object.prototype.toString;var Gi="[object Null]",Wi="[object Undefined]",Yi=Di?Di.toStringTag:void 0;function Xi(t){return null==t?void 0===t?Wi:Gi:Yi&&Yi in Object(t)?function(t){var e=Li.call(t,Ki),r=t[Ki];try{t[Ki]=void 0;var n=!0}catch(t){}var o=Bi.call(t);return n&&(e?t[Ki]=r:delete t[Ki]),o}(t):function(t){return Vi.call(t)}(t)}var Qi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Zi(t){return null!=t&&"object"==typeof t}var ta="[object Object]",ea=Function.prototype,ra=Object.prototype,na=ea.toString,oa=ra.hasOwnProperty,ia=na.call(Object);var aa=Di?Di.prototype:void 0,ua=(aa&&aa.toString,"[object String]");function ca(t){return"string"==typeof t||!Ii(t)&&Zi(t)&&Xi(t)==ua}var sa=function(t,e){return!!t.filter((function(t){return t===e})).length},fa=function(t,e){var r=Object.keys(t);return sa(r,e)},la=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},pa="query",ha="mutation",da="socket",va="payload",ga="condition",ya=function(){try{if(window||document)return!0}catch(t){}return!1},ba=function(){try{if(!ya()&&Ji)return!0}catch(t){}return!1};var ma=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ya()?"browser":ba()?"node":"unknown"},e}(Error));var _a=function(t){var e;return(e={}).args=t,e};var wa=function(t){return fa(t,"data")&&!fa(t,"error")?t.data:t},ja=function(t){return function(t){if(!Zi(t)||Xi(t)!=ta)return!1;var e=Qi(t);if(null===e)return!0;var r=oa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&na.call(r)==ia}(t)&&(fa(t,pa)||fa(t,ha)||fa(t,da))},Oa=function(t,e){return void 0===e&&(e={}),ja(e)?Promise.resolve(e):t.getContract()},Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ea(t){this.message=t}Ea.prototype=new Error,Ea.prototype.name="InvalidCharacterError";var ka="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ea("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Sa.indexOf(n);return a};var Aa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ka(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ka(e)}};function xa(t){this.message=t}xa.prototype=new Error,xa.prototype.name="InvalidTokenError";var Ta=function(t,e){if("string"!=typeof t)throw new xa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Aa(t.split(".")[r]))}catch(t){throw new xa("Invalid token specified: "+t.message)}},Pa=xa;Ta.InvalidTokenError=Pa;var qa,Ca,$a,Na,za,Fa,Ra,Ia,Ja,Ma=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ua(t){if(Fo(t))return function(t){var e=t.iat||Ma(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new po("Token has expired on "+r,t)}return t}(Ta(t));throw new po("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((qa={})[h]="exp",qa[s]=!0,qa)),Jo(!1,["boolean","number","string"],((Ca={})[h]="nbf",Ca[s]=!0,Ca)),Jo(!1,["boolean","string"],(($a={})[h]="iss",$a[s]=!0,$a)),Jo(!1,["boolean","string"],((Na={})[h]="sub",Na[s]=!0,Na)),Jo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Jo(!1,["boolean"],((Fa={})[s]=!0,Fa)),Jo(!1,["boolean","string"],((Ra={})[s]=!0,Ra)),Jo(!1,["boolean","string"],((Ia={})[s]=!0,Ia)),Jo(!1,["boolean"],((Ja={})[s]=!0,Ja));var Da=u[0],Ha=u[1],La=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ba={headers:{configurable:!0}};Ba.headers.set=function(t){this.extraHeader=t},La.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=qn({},{_cb:la()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,qn({},{method:Da,params:o},e))},La.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},La.prototype.processJsonp=function(t){return wa(t)},La.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ho("Server side error",t)}))},La.prototype.getHeaders=function(){return this.opts.enableAuth?qn({},a,this.getAuthHeader(),this.extraHeader):qn({},a,this.extraHeader)},La.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},La.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=qn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(bo).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},La.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),ca(t)&&Ii(e)){var o=_a(e);return!0===r?o:((n={})[t]=o,n)}throw new ma("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bo)},La.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[va]=e,i[ga]=r,!0===n)return i;if(ca(t))return(o={})[t]=i,o;throw new ma("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ha}).then(bo)},Object.defineProperties(La.prototype,Ba);var Ka=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Ro(t)&&t.length>=2&&Reflect.apply(Fi.set,Fi,t),new lo("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Fi.get("endpoint")||[];sa(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Fi.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!sa(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=la();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Fi.set,Fi,e)},r.jsonqlEndpoint.get=function(){var t=Fi.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Fi.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ri.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ua)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ja(t))throw new lo("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ja(this.opts.contract)?this.opts.contract:Fi.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(La))),Va=function(t){return O(t)?t:[t]},Ga=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Va(t))}),Reflect.apply(t,null,r))}};function Wa(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mo)}},Xa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mo)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Qa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Io(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Za=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var tu=function(t,e,r,n){var o=function(t,e,r,n){return Ga(Xa,Qa,Za)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.5",o},eu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ru={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("storageKey",["string"]),authKey:Jo("authKey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function nu(t){return t[d]?t:function(t){var e=t.contract;return Mo(t,ru,eu).then((function(t){return t.contract=e,t}))}(t)}var ou=new WeakMap,iu=new WeakMap;var au=function(){this.__suspend__=null,this.queueStore=new Set},uu={$suspend:{configurable:!0},$queues:{configurable:!0}};uu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},au.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},uu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},au.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(au.prototype,uu);var cu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ou.set(this,t)},r.normalStore.get=function(){return ou.get(this)},r.lazyStore.set=function(t){iu.set(this,t)},r.lazyStore.get=function(){return iu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(au));function su(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),nu(e).then((function(t){return{baseClient:new Ka(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Oa(r,n.contract).then((function(e){return tu(r,n,e,t)}))}))}((r=e.debugOn,new cu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),su(o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 5c75046a15830ac958e59dbf3e55046832234156..c110c1c8c9dc2ed50a7282f7ad5b85c4d5b3ae63 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.4.4", + "version": "1.4.5", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js", @@ -17,14 +17,14 @@ "opt.js" ], "scripts": { - "test": "npm run build:test && npm run test:browser", - "_publish": "npm publish --access public", + "test": "ava --verbose", "prepare": "npm run build", + "test:browser": "npm run build:test && npm run test:browser:run", + "_publish": "npm publish --access public", "test:utils": "node ./main.js", - "test:node": "DEBUG=jsonql* ava --verbose", "test:opt": "DEBUG=jsonql-* ava --verbose ./tests/opt.test.js", "test:contract": "DEBUG=jsonql-* ava ./tests/contract-lock.test.js", - "test:browser": "DEBUG=jsonql* node ./tests/qunit/run-qunit.js", + "test:browser:run": "DEBUG=jsonql* node ./tests/qunit/run-qunit.js", "test:fn": "ava ./tests/fn.test.js", "run:browser": "DEBUG=jsonql-* node ./tests/fixtures/run.js", "start": "rollup -c -w --environment NODE_ENV:dev", @@ -65,7 +65,7 @@ "jsonql-errors": "^1.1.6", "jsonql-jwt": "^1.3.4", "jsonql-params-validator": "^1.4.11", - "jsonql-utils": "^0.8.9", + "jsonql-utils": "^0.8.10", "lodash-es": "^4.17.15", "nb-event-service": "^1.8.5", "store": "^2.0.12" @@ -81,7 +81,7 @@ "nyc": "^14.1.1", "promise-polyfill": "8.1.3", "qunit": "^2.9.3", - "rollup": "^1.27.5", + "rollup": "^1.27.6", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-analyzer": "^3.2.2", "rollup-plugin-async": "^1.2.0", diff --git a/packages/http-client/static.js b/packages/http-client/static.js index e694a3730eae36ae2feb8ade5b20a9f870f204f7..6baefe08d03f1c2f5cb9c8fa894aeb90a9eed642 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message",p="onResult",h="onError",d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),E=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),A=Object.freeze({__proto__:null,Jsonql406Error:d,Jsonql500Error:v,JsonqlAuthorisationError:g,JsonqlContractAuthError:y,JsonqlResolverAppError:b,JsonqlResolverNotFoundError:m,JsonqlEnumError:_,JsonqlTypeError:w,JsonqlCheckerError:j,JsonqlValidationError:O,JsonqlError:S,JsonqlServerError:E}),k=S,T=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function x(t){if(T(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&A[o])throw new A[r](i,a);throw new k(i,a)}return t}function q(t){if(Array.isArray(t))throw new O("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof E:throw new E(e,r);default:throw new S(e,r)}}var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C="object"==typeof P&&P&&P.Object===Object&&P,$="object"==typeof self&&self&&self.Object===Object&&self,N=C||$||Function("return this")(),z=N.Symbol;function F(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&rt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function bt(t){return void 0===t}var mt="[object Boolean]";var _t="[object Number]";function wt(t){return function(t){return"number"==typeof t||V(t)&&K(t)==_t}(t)&&t!=+t}var jt="[object String]";function Ot(t){return"string"==typeof t||!I(t)&&V(t)&&K(t)==jt}function St(t,e){return function(r){return t(e(r))}}var Et=St(Object.getPrototypeOf,Object),At="[object Object]",kt=Function.prototype,Tt=Object.prototype,xt=kt.toString,qt=Tt.hasOwnProperty,Pt=xt.call(Object);function Ct(t){if(!V(t)||K(t)!=At)return!1;var e=Et(t);if(null===e)return!0;var r=qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&xt.call(r)==Pt}var $t,Nt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[$t?a:++n];if(!1===e(o[u],u,o))break}return t};var zt="[object Arguments]";function Ft(t){return V(t)&&K(t)==zt}var It=Object.prototype,Rt=It.hasOwnProperty,Jt=It.propertyIsEnumerable,Mt=Ft(function(){return arguments}())?Ft:function(t){return V(t)&&Rt.call(t,"callee")&&!Jt.call(t,"callee")};var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Dt=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Ht=Dt&&Dt.exports===Ut?N.Buffer:void 0,Lt=(Ht?Ht.isBuffer:void 0)||function(){return!1},Bt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/;function Vt(t,e){var r=typeof t;return!!(e=null==e?Bt:e)&&("number"==r||"symbol"!=r&&Kt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Gt}var Yt={};Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Qt,Xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Xt&&"object"==typeof module&&module&&!module.nodeType&&module,te=Zt&&Zt.exports===Xt&&C.process,ee=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||te&&te.binding&&te.binding("util")}catch(t){}}(),re=ee&&ee.isTypedArray,ne=re?(Qt=re,function(t){return Qt(t)}):function(t){return V(t)&&Wt(t.length)&&!!Yt[K(t)]},oe=Object.prototype.hasOwnProperty;function ie(t,e){var r=I(t),n=!r&&Mt(t),o=!r&&!n&&Lt(t),i=!r&&!n&&!o&&ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},je.prototype.set=function(t,e){var r=this.__data__,n=_e(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Oe,Se=N["__core-js_shared__"],Ee=(Oe=/[^.]+$/.exec(Se&&Se.keys&&Se.keys.IE_PROTO||""))?"Symbol(src)_1."+Oe:"";var Ae=Function.prototype.toString;function ke(t){if(null!=t){try{return Ae.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,qe=Object.prototype,Pe=xe.toString,Ce=qe.hasOwnProperty,$e=RegExp("^"+Pe.call(Ce).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ne(t){return!(!fe(t)||function(t){return!!Ee&&Ee in t}(t))&&(ve(t)?$e:Te).test(ke(t))}function ze(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ne(r)?r:void 0}var Fe=ze(N,"Map"),Ie=ze(Object,"create");var Re="__lodash_hash_undefined__",Je=Object.prototype.hasOwnProperty;var Me=Object.prototype.hasOwnProperty;var Ue="__lodash_hash_undefined__";function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Qe?new Ge:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Jn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Rn);function Hn(t,e){return Dn(function(t,e,r){return e=In(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=In(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ln.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!fe(r))return!1;var n=typeof e;return!!("number"==n?ge(r)&&Vt(e,r.length):"string"==n&&e in r)&&me(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},po=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ho=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!fo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!lo(r,t)})).length},vo=function(t,e){if(void 0===e&&(e=null),Ct(t)){if(!e)return!0;if(lo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!bt(r)||(!1!==(e=po(t))?!ho({arg:r},e):!fo(t)(r))})).length)})).length}return!1},go=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),vo.apply(null,n)};function yo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,e){var r;switch(!0){case"object"===t:return!go(e);case"array"===t:return!lo(e.arg);case!1!==(r=po(t)):return!ho(e,r);default:return!fo(t)(e.arg)}},mo=function(t,e){return bt(t)?!0!==e.optional||bt(e.defaultvalue)?null:e.defaultvalue:t},_o=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!lo(e))throw new S("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!lo(t))throw new S("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return yo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:yo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:yo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?mo(t,a):t,index:r,param:a,optional:i}}));default:throw yo(5),new S("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Xn(e)&&!(r.type.length>r.type.filter((function(e){return bo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return bo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},jo=function(t){return!Xn(t)};function Oo(t,e){var r=Qn(e,(function(t,e){return!t[co]}));return Hr(r,{})?t:function(t,e){var r={};return e=gn(e),be(t,(function(t,n,o){bn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,gn((function(t){return t.alias===e})),be)||e}))}function So(t,e){return Kn(e,(function(e,r){var n,o;return bt(t[r])||!0===e[oo]&&jo(t[r])?Bn({},e,((n={})[so]=!0,n)):((o={})[ao]=t[r],o[no]=e[no],o[oo]=e[oo]||!1,o[io]=e[io]||!1,o[uo]=e[uo]||!1,o)}))}function Eo(t,e){var r=function(t,e){var r=Oo(t,e);return{pristineValues:Kn(Qn(e,(function(t,e){return wo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Qn(e,(function(t,e){return!wo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[So(n,r.checkAgainstAppProps),o]}var Ao=function(t){return lo(t)?t:[t]};var ko=function(t,e){return!lo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},To=function(t,e){try{return!!ve(e)&&e.apply(null,[t])}catch(t){return!1}};function xo(t){return function(e,r){if(e[so])return e[ao];var n=function(t,e){var r,n=[[t[ao]],[(r={},r[no]=Ao(t[no]),r[oo]=t[oo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw yo("runValidationAction",r,e),new w(r,n);if(!1!==e[io]&&!ko(e[ao],e[io]))throw yo(io,e[io]),new _(r);if(!1!==e[uo]&&!To(e[ao],e[uo]))throw yo(uo,e[uo]),new j(r);return e[ao]}}function qo(t,e,r,n){return void 0===t&&(t={}),Bn(function(t,e){var r=t[0],n=t[1],o=Kn(r,xo(e));return Bn(o,n)}(Eo(t,e),n),r)}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),lo(s)&&(p[i]=s),ve(f)&&(p[u]=f),Ot(l)&&(p[c]=l),p}var Co=to,$o=lo,No=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=_o(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},Fo=function(t){return function(e,r,n){return void 0===n&&(n={}),qo(e,r,n,t)}}(_o),Io=function(t){return I(t)?t:[t]},Ro=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Io(t))}),Reflect.apply(t,null,r))}};function Jo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Mo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(q)}},Uo=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(q)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Do=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return No(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(q)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Ho=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Lo=Array.isArray,Bo=void 0!==P?P:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ko="object"==typeof Bo&&Bo&&Bo.Object===Object&&Bo,Vo="object"==typeof self&&self&&self.Object===Object&&self,Go=(Ko||Vo||Function("return this")()).Symbol,Wo=Object.prototype,Yo=Wo.hasOwnProperty,Qo=Wo.toString,Xo=Go?Go.toStringTag:void 0;var Zo=Object.prototype.toString;var ti="[object Null]",ei="[object Undefined]",ri=Go?Go.toStringTag:void 0;function ni(t){return null==t?void 0===t?ei:ti:ri&&ri in Object(t)?function(t){var e=Yo.call(t,Xo),r=t[Xo];try{t[Xo]=void 0;var n=!0}catch(t){}var o=Qo.call(t);return n&&(e?t[Xo]=r:delete t[Xo]),o}(t):function(t){return Zo.call(t)}(t)}var oi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ii(t){return null!=t&&"object"==typeof t}var ai="[object Object]",ui=Function.prototype,ci=Object.prototype,si=ui.toString,fi=ci.hasOwnProperty,li=si.call(Object);var pi=Go?Go.prototype:void 0,hi=(pi&&pi.toString,"[object String]");function di(t){return"string"==typeof t||!Lo(t)&&ii(t)&&ni(t)==hi}var vi=function(t,e){return!!t.filter((function(t){return t===e})).length},gi=function(t,e){var r=Object.keys(t);return vi(r,e)},yi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},bi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},mi="query",_i="mutation",wi="socket",ji="payload",Oi="condition",Si=function(){try{if(window||document)return!0}catch(t){}return!1},Ei=function(){try{if(!Si()&&Bo)return!0}catch(t){}return!1};var Ai=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Si()?"browser":Ei()?"node":"unknown"},e}(Error));var ki=function(t){var e;return(e={}).args=t,e};var Ti=function(t){return gi(t,"data")&&!gi(t,"error")?t.data:t},xi=function(t){return function(t){if(!ii(t)||ni(t)!=ai)return!1;var e=oi(t);if(null===e)return!0;var r=fi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&si.call(r)==li}(t)&&(gi(t,mi)||gi(t,_i)||gi(t,wi))},qi=function(t,e){return void 0===e&&(e={}),xi(e)?Promise.resolve(e):t.getContract()},Pi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(yi(e,r,p),o),t.$only(yi(e,r,h),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ci=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function $i(t,e,r,n){var o=function(t,e,r,n){return Ro(Uo,Do,Ho)({},t,e,r,n)}(t,e,r,n);Ci(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(yi(t,n,p),r)})).catch((function(r){e.$trigger(yi(t,n,h),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ni=function(t,e,r,n){n.$suspend=!0,r.then((function(r){$i(t,n,e,r)}));var o={query:Pi(n,"query"),mutation:Pi(n,"mutation"),auth:Pi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.4",o},zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Fi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=oa().key(e);t(ia(r),r)}},remove:function(t){return oa().removeItem(t)},clearAll:function(){return oa().clear()}};function oa(){return ra.localStorage}function ia(t){return oa().getItem(t)}var aa=Mi.trim,ua={name:"cookieStorage",read:function(t){if(!t||!la(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ca.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ca.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:sa,remove:fa,clearAll:function(){sa((function(t,e){fa(e)}))}},ca=Mi.Global.document;function sa(t){for(var e=ca.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(aa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function fa(t){t&&la(t)&&(ca.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function la(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ca.cookie)}var pa=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ha="expire_mixin",da=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ha);return{set:function(e,r,n,o){this.hasNamespace(ha)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ha)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ha)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ja=[na,ua],Oa=[pa,da,ma,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=wa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=wa.compress(this._serialize(r));t(e,n)}}}],Sa=Zi.createStore(ja,Oa),Ea=Mi.Global;function Aa(){return Ea.sessionStorage}function ka(t){return Aa().getItem(t)}var Ta=[{name:"sessionStorage",read:ka,write:function(t,e){return Aa().setItem(t,e)},each:function(t){for(var e=Aa().length-1;e>=0;e--){var r=Aa().key(e);t(ka(r),r)}},remove:function(t){return Aa().removeItem(t)},clearAll:function(){return Aa().clear()}},ua],xa=[pa,da],qa=Zi.createStore(Ta,xa),Pa=Sa,Ca=qa,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Na(t){this.message=t}Na.prototype=new Error,Na.prototype.name="InvalidCharacterError";var za="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Na("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=$a.indexOf(n);return a};var Fa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(za(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return za(e)}};function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";var Ra=function(t,e){if("string"!=typeof t)throw new Ia("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fa(t.split(".")[r]))}catch(t){throw new Ia("Invalid token specified: "+t.message)}},Ja=Ia;Ra.InvalidTokenError=Ja;var Ma,Ua,Da,Ha,La,Ba,Ka,Va,Ga,Wa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ya(t){if(Co(t))return function(t){var e=t.iat||Wa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new S("Token has expired on "+r,t)}return t}(Ra(t));throw new S("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ma={})[c]="exp",Ma[o]=!0,Ma)),zo(!1,["boolean","number","string"],((Ua={})[c]="nbf",Ua[o]=!0,Ua)),zo(!1,["boolean","string"],((Da={})[c]="iss",Da[o]=!0,Da)),zo(!1,["boolean","string"],((Ha={})[c]="sub",Ha[o]=!0,Ha)),zo(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),zo(!1,["boolean"],((Ba={})[o]=!0,Ba)),zo(!1,["boolean","string"],((Ka={})[o]=!0,Ka)),zo(!1,["boolean","string"],((Va={})[o]=!0,Va)),zo(!1,["boolean"],((Ga={})[o]=!0,Ga));var Qa=r[0],Xa=r[1],Za=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},tu={headers:{configurable:!0}};tu.headers.set=function(t){this.extraHeader=t},Za.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Bn({},{_cb:bi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Bn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Bn({},{method:Qa,params:o},e))},Za.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Za.prototype.processJsonp=function(t){return Ti(t)},Za.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Co(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Ti(o)}),(function(t){throw e.cleanUp(),console.error(t),new E("Server side error",t)}))},Za.prototype.getHeaders=function(){return this.opts.enableAuth?Bn({},e,this.getAuthHeader(),this.extraHeader):Bn({},e,this.extraHeader)},Za.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Za.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Bn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(x).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Za.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),di(t)&&Lo(e)){var o=ki(e);return!0===r?o:((n={})[t]=o,n)}throw new Ai("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(x)},Za.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ji]=e,i[Oi]=r,!0===n)return i;if(di(t))return(o={})[t]=i,o;throw new Ai("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xa}).then(x)},Object.defineProperties(Za.prototype,tu);var eu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),$o(t)&&t.length>=2&&Reflect.apply(Pa.set,Pa,t),new O("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Pa.get("endpoint")||[];vi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Pa.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!vi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=bi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Pa.set,Pa,e)},r.jsonqlEndpoint.get=function(){var t=Pa.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Pa.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ca.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ya)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!xi(t))throw new O("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return xi(this.opts.contract)?this.opts.contract:Pa.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Za))),ru={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},nu={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function ou(t){return t[s]?t:function(t){return Fo(t,nu,ru)}(t)}var iu=new WeakMap,au=new WeakMap;var uu=function(){this.__suspend__=null,this.queueStore=new Set},cu={$suspend:{configurable:!0},$queues:{configurable:!0}};cu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},uu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},cu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},uu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(uu.prototype,cu);var su=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){iu.set(this,t)},r.normalStore.get=function(){return iu.get(this)},r.lazyStore.set=function(t){au.set(this,t)},r.lazyStore.get=function(){return au.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(uu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=ou(e),i=new eu(o,t),a=qi(i,n),u=(r=o.debugOn,new su({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ni(i,o,a,u);return c.eventEmitter=u,c}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message",p="onResult",h="onError",d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),E=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),A=Object.freeze({__proto__:null,Jsonql406Error:d,Jsonql500Error:v,JsonqlAuthorisationError:g,JsonqlContractAuthError:y,JsonqlResolverAppError:b,JsonqlResolverNotFoundError:m,JsonqlEnumError:_,JsonqlTypeError:w,JsonqlCheckerError:j,JsonqlValidationError:O,JsonqlError:S,JsonqlServerError:E}),k=S,T=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function x(t){if(T(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&A[o])throw new A[r](i,a);throw new k(i,a)}return t}function q(t){if(Array.isArray(t))throw new O("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof E:throw new E(e,r);default:throw new S(e,r)}}var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C="object"==typeof P&&P&&P.Object===Object&&P,$="object"==typeof self&&self&&self.Object===Object&&self,N=C||$||Function("return this")(),z=N.Symbol;function F(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&rt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function bt(t){return void 0===t}var mt="[object Boolean]";var _t="[object Number]";function wt(t){return function(t){return"number"==typeof t||V(t)&&K(t)==_t}(t)&&t!=+t}var jt="[object String]";function Ot(t){return"string"==typeof t||!I(t)&&V(t)&&K(t)==jt}function St(t,e){return function(r){return t(e(r))}}var Et=St(Object.getPrototypeOf,Object),At="[object Object]",kt=Function.prototype,Tt=Object.prototype,xt=kt.toString,qt=Tt.hasOwnProperty,Pt=xt.call(Object);function Ct(t){if(!V(t)||K(t)!=At)return!1;var e=Et(t);if(null===e)return!0;var r=qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&xt.call(r)==Pt}var $t,Nt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[$t?a:++n];if(!1===e(o[u],u,o))break}return t};var zt="[object Arguments]";function Ft(t){return V(t)&&K(t)==zt}var It=Object.prototype,Rt=It.hasOwnProperty,Jt=It.propertyIsEnumerable,Mt=Ft(function(){return arguments}())?Ft:function(t){return V(t)&&Rt.call(t,"callee")&&!Jt.call(t,"callee")};var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Dt=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Ht=Dt&&Dt.exports===Ut?N.Buffer:void 0,Lt=(Ht?Ht.isBuffer:void 0)||function(){return!1},Bt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/;function Vt(t,e){var r=typeof t;return!!(e=null==e?Bt:e)&&("number"==r||"symbol"!=r&&Kt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Gt}var Yt={};Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Qt,Xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Xt&&"object"==typeof module&&module&&!module.nodeType&&module,te=Zt&&Zt.exports===Xt&&C.process,ee=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||te&&te.binding&&te.binding("util")}catch(t){}}(),re=ee&&ee.isTypedArray,ne=re?(Qt=re,function(t){return Qt(t)}):function(t){return V(t)&&Wt(t.length)&&!!Yt[K(t)]},oe=Object.prototype.hasOwnProperty;function ie(t,e){var r=I(t),n=!r&&Mt(t),o=!r&&!n&&Lt(t),i=!r&&!n&&!o&&ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},je.prototype.set=function(t,e){var r=this.__data__,n=_e(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Oe,Se=N["__core-js_shared__"],Ee=(Oe=/[^.]+$/.exec(Se&&Se.keys&&Se.keys.IE_PROTO||""))?"Symbol(src)_1."+Oe:"";var Ae=Function.prototype.toString;function ke(t){if(null!=t){try{return Ae.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,qe=Object.prototype,Pe=xe.toString,Ce=qe.hasOwnProperty,$e=RegExp("^"+Pe.call(Ce).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ne(t){return!(!fe(t)||function(t){return!!Ee&&Ee in t}(t))&&(ve(t)?$e:Te).test(ke(t))}function ze(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ne(r)?r:void 0}var Fe=ze(N,"Map"),Ie=ze(Object,"create");var Re="__lodash_hash_undefined__",Je=Object.prototype.hasOwnProperty;var Me=Object.prototype.hasOwnProperty;var Ue="__lodash_hash_undefined__";function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Qe?new Ge:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Jn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Rn);function Hn(t,e){return Dn(function(t,e,r){return e=In(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=In(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ln.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!fe(r))return!1;var n=typeof e;return!!("number"==n?ge(r)&&Vt(e,r.length):"string"==n&&e in r)&&me(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},po=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ho=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!fo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!lo(r,t)})).length},vo=function(t,e){if(void 0===e&&(e=null),Ct(t)){if(!e)return!0;if(lo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!bt(r)||(!1!==(e=po(t))?!ho({arg:r},e):!fo(t)(r))})).length)})).length}return!1},go=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),vo.apply(null,n)};function yo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,e){var r;switch(!0){case"object"===t:return!go(e);case"array"===t:return!lo(e.arg);case!1!==(r=po(t)):return!ho(e,r);default:return!fo(t)(e.arg)}},mo=function(t,e){return bt(t)?!0!==e.optional||bt(e.defaultvalue)?null:e.defaultvalue:t},_o=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!lo(e))throw new S("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!lo(t))throw new S("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return yo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:yo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:yo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?mo(t,a):t,index:r,param:a,optional:i}}));default:throw yo(5),new S("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Xn(e)&&!(r.type.length>r.type.filter((function(e){return bo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return bo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},jo=function(t){return!Xn(t)};function Oo(t,e){var r=Qn(e,(function(t,e){return!t[co]}));return Hr(r,{})?t:function(t,e){var r={};return e=gn(e),be(t,(function(t,n,o){bn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,gn((function(t){return t.alias===e})),be)||e}))}function So(t,e){return Kn(e,(function(e,r){var n,o;return bt(t[r])||!0===e[oo]&&jo(t[r])?Bn({},e,((n={})[so]=!0,n)):((o={})[ao]=t[r],o[no]=e[no],o[oo]=e[oo]||!1,o[io]=e[io]||!1,o[uo]=e[uo]||!1,o)}))}function Eo(t,e){var r=function(t,e){var r=Oo(t,e);return{pristineValues:Kn(Qn(e,(function(t,e){return wo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Qn(e,(function(t,e){return!wo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[So(n,r.checkAgainstAppProps),o]}var Ao=function(t){return lo(t)?t:[t]};var ko=function(t,e){return!lo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},To=function(t,e){try{return!!ve(e)&&e.apply(null,[t])}catch(t){return!1}};function xo(t){return function(e,r){if(e[so])return e[ao];var n=function(t,e){var r,n=[[t[ao]],[(r={},r[no]=Ao(t[no]),r[oo]=t[oo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw yo("runValidationAction",r,e),new w(r,n);if(!1!==e[io]&&!ko(e[ao],e[io]))throw yo(io,e[io]),new _(r);if(!1!==e[uo]&&!To(e[ao],e[uo]))throw yo(uo,e[uo]),new j(r);return e[ao]}}function qo(t,e,r,n){return void 0===t&&(t={}),Bn(function(t,e){var r=t[0],n=t[1],o=Kn(r,xo(e));return Bn(o,n)}(Eo(t,e),n),r)}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),lo(s)&&(p[i]=s),ve(f)&&(p[u]=f),Ot(l)&&(p[c]=l),p}var Co=to,$o=lo,No=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=_o(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},Fo=function(t){return function(e,r,n){return void 0===n&&(n={}),qo(e,r,n,t)}}(_o),Io=function(t){return I(t)?t:[t]},Ro=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Io(t))}),Reflect.apply(t,null,r))}};function Jo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Mo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(q)}},Uo=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(q)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Do=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return No(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(q)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Ho=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Lo=Array.isArray,Bo=void 0!==P?P:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ko="object"==typeof Bo&&Bo&&Bo.Object===Object&&Bo,Vo="object"==typeof self&&self&&self.Object===Object&&self,Go=(Ko||Vo||Function("return this")()).Symbol,Wo=Object.prototype,Yo=Wo.hasOwnProperty,Qo=Wo.toString,Xo=Go?Go.toStringTag:void 0;var Zo=Object.prototype.toString;var ti="[object Null]",ei="[object Undefined]",ri=Go?Go.toStringTag:void 0;function ni(t){return null==t?void 0===t?ei:ti:ri&&ri in Object(t)?function(t){var e=Yo.call(t,Xo),r=t[Xo];try{t[Xo]=void 0;var n=!0}catch(t){}var o=Qo.call(t);return n&&(e?t[Xo]=r:delete t[Xo]),o}(t):function(t){return Zo.call(t)}(t)}var oi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ii(t){return null!=t&&"object"==typeof t}var ai="[object Object]",ui=Function.prototype,ci=Object.prototype,si=ui.toString,fi=ci.hasOwnProperty,li=si.call(Object);var pi=Go?Go.prototype:void 0,hi=(pi&&pi.toString,"[object String]");function di(t){return"string"==typeof t||!Lo(t)&&ii(t)&&ni(t)==hi}var vi=function(t,e){return!!t.filter((function(t){return t===e})).length},gi=function(t,e){var r=Object.keys(t);return vi(r,e)},yi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},bi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},mi="query",_i="mutation",wi="socket",ji="payload",Oi="condition",Si=function(){try{if(window||document)return!0}catch(t){}return!1},Ei=function(){try{if(!Si()&&Bo)return!0}catch(t){}return!1};var Ai=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Si()?"browser":Ei()?"node":"unknown"},e}(Error));var ki=function(t){var e;return(e={}).args=t,e};var Ti=function(t){return gi(t,"data")&&!gi(t,"error")?t.data:t},xi=function(t){return function(t){if(!ii(t)||ni(t)!=ai)return!1;var e=oi(t);if(null===e)return!0;var r=fi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&si.call(r)==li}(t)&&(gi(t,mi)||gi(t,_i)||gi(t,wi))},qi=function(t,e){return void 0===e&&(e={}),xi(e)?Promise.resolve(e):t.getContract()},Pi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(yi(e,r,p),o),t.$only(yi(e,r,h),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ci=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function $i(t,e,r,n){var o=function(t,e,r,n){return Ro(Uo,Do,Ho)({},t,e,r,n)}(t,e,r,n);Ci(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(yi(t,n,p),r)})).catch((function(r){e.$trigger(yi(t,n,h),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ni=function(t,e,r,n){n.$suspend=!0,r.then((function(r){$i(t,n,e,r)}));var o={query:Pi(n,"query"),mutation:Pi(n,"mutation"),auth:Pi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.5",o},zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Fi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=oa().key(e);t(ia(r),r)}},remove:function(t){return oa().removeItem(t)},clearAll:function(){return oa().clear()}};function oa(){return ra.localStorage}function ia(t){return oa().getItem(t)}var aa=Mi.trim,ua={name:"cookieStorage",read:function(t){if(!t||!la(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ca.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ca.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:sa,remove:fa,clearAll:function(){sa((function(t,e){fa(e)}))}},ca=Mi.Global.document;function sa(t){for(var e=ca.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(aa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function fa(t){t&&la(t)&&(ca.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function la(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ca.cookie)}var pa=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ha="expire_mixin",da=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ha);return{set:function(e,r,n,o){this.hasNamespace(ha)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ha)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ha)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ja=[na,ua],Oa=[pa,da,ma,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=wa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=wa.compress(this._serialize(r));t(e,n)}}}],Sa=Zi.createStore(ja,Oa),Ea=Mi.Global;function Aa(){return Ea.sessionStorage}function ka(t){return Aa().getItem(t)}var Ta=[{name:"sessionStorage",read:ka,write:function(t,e){return Aa().setItem(t,e)},each:function(t){for(var e=Aa().length-1;e>=0;e--){var r=Aa().key(e);t(ka(r),r)}},remove:function(t){return Aa().removeItem(t)},clearAll:function(){return Aa().clear()}},ua],xa=[pa,da],qa=Zi.createStore(Ta,xa),Pa=Sa,Ca=qa,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Na(t){this.message=t}Na.prototype=new Error,Na.prototype.name="InvalidCharacterError";var za="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Na("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=$a.indexOf(n);return a};var Fa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(za(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return za(e)}};function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";var Ra=function(t,e){if("string"!=typeof t)throw new Ia("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fa(t.split(".")[r]))}catch(t){throw new Ia("Invalid token specified: "+t.message)}},Ja=Ia;Ra.InvalidTokenError=Ja;var Ma,Ua,Da,Ha,La,Ba,Ka,Va,Ga,Wa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ya(t){if(Co(t))return function(t){var e=t.iat||Wa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new S("Token has expired on "+r,t)}return t}(Ra(t));throw new S("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ma={})[c]="exp",Ma[o]=!0,Ma)),zo(!1,["boolean","number","string"],((Ua={})[c]="nbf",Ua[o]=!0,Ua)),zo(!1,["boolean","string"],((Da={})[c]="iss",Da[o]=!0,Da)),zo(!1,["boolean","string"],((Ha={})[c]="sub",Ha[o]=!0,Ha)),zo(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),zo(!1,["boolean"],((Ba={})[o]=!0,Ba)),zo(!1,["boolean","string"],((Ka={})[o]=!0,Ka)),zo(!1,["boolean","string"],((Va={})[o]=!0,Va)),zo(!1,["boolean"],((Ga={})[o]=!0,Ga));var Qa=r[0],Xa=r[1],Za=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},tu={headers:{configurable:!0}};tu.headers.set=function(t){this.extraHeader=t},Za.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Bn({},{_cb:bi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Bn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Bn({},{method:Qa,params:o},e))},Za.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Za.prototype.processJsonp=function(t){return Ti(t)},Za.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Co(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Ti(o)}),(function(t){throw e.cleanUp(),console.error(t),new E("Server side error",t)}))},Za.prototype.getHeaders=function(){return this.opts.enableAuth?Bn({},e,this.getAuthHeader(),this.extraHeader):Bn({},e,this.extraHeader)},Za.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Za.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Bn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(x).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Za.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),di(t)&&Lo(e)){var o=ki(e);return!0===r?o:((n={})[t]=o,n)}throw new Ai("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(x)},Za.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ji]=e,i[Oi]=r,!0===n)return i;if(di(t))return(o={})[t]=i,o;throw new Ai("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xa}).then(x)},Object.defineProperties(Za.prototype,tu);var eu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),$o(t)&&t.length>=2&&Reflect.apply(Pa.set,Pa,t),new O("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Pa.get("endpoint")||[];vi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Pa.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!vi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=bi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Pa.set,Pa,e)},r.jsonqlEndpoint.get=function(){var t=Pa.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Pa.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ca.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ya)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!xi(t))throw new O("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return xi(this.opts.contract)?this.opts.contract:Pa.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Za))),ru={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},nu={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function ou(t){return t[s]?t:function(t){return Fo(t,nu,ru)}(t)}var iu=new WeakMap,au=new WeakMap;var uu=function(){this.__suspend__=null,this.queueStore=new Set},cu={$suspend:{configurable:!0},$queues:{configurable:!0}};cu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},uu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},cu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},uu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(uu.prototype,cu);var su=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){iu.set(this,t)},r.normalStore.get=function(){return iu.get(this)},r.lazyStore.set=function(t){au.set(this,t)},r.lazyStore.get=function(){return au.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(uu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=ou(e),i=new eu(o,t),a=qi(i,n),u=(r=o.debugOn,new su({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ni(i,o,a,u);return c.eventEmitter=u,c}})); //# sourceMappingURL=static.js.map diff --git a/packages/http-client/tests/fn.test.js b/packages/http-client/tests/fn.test.js index c142e51599961336825c5971465a776fcc52a258..aafa66b6347efdee673a9a652a3f197594e8296d 100644 --- a/packages/http-client/tests/fn.test.js +++ b/packages/http-client/tests/fn.test.js @@ -1,6 +1,6 @@ const test = require('ava') -const { isObjectHasKey } = require('jsonql-params-validator') +const { isObjectHasKey } = require('jsonql-utils') test('It should have isObjectHasKey exported', t => { diff --git a/packages/utils/browser.js b/packages/utils/browser.js index 73a8b379ac89ffa0651b21d70ac928e47f8a67ae..a1ab55f628cb50a7e819f8d1df66bffdbca7b7b1 100644 --- a/packages/utils/browser.js +++ b/packages/utils/browser.js @@ -1,2 +1,2 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p="[object Null]",v="[object Undefined]",d=i?i.toStringTag:void 0;function y(t){return null==t?void 0===t?v:p:d&&d in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var h,g,b=(h=Object.getPrototypeOf,g=Object,function(t){return h(g(t))});function _(t){return null!=t&&"object"==typeof t}var j="[object Object]",m=Function.prototype,O=Object.prototype,w=m.toString,P=O.hasOwnProperty,S=w.call(Object);function A(t){if(!_(t)||y(t)!=j)return!1;var r=b(t);if(null===r)return!0;var e=P.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&w.call(e)==S}var N="[object Symbol]";var k=1/0,z=i?i.prototype:void 0,F=z?z.toString:void 0;function x(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&C(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var K=function(t,r){return!!t.filter((function(t){return t===r})).length},W=function(t){return r(t)?t:[t]},Z=function(t,r){try{var e=Object.keys(t);return K(e,r)}catch(t){return!1}},X=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},Y=function(t,r){var e=[];for(var n in r)e.push([n,r[n]].join("="));return[t,e.join("&")].join("?")},tt=function(){return{_cb:X()}},rt=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,W(t))}),Reflect.apply(t,null,e))}};function et(t,r){return t===r||t!=t&&r!=r}function nt(t,r){for(var e=t.length;e--;)if(et(t[e][0],r))return e;return-1}var ot=Array.prototype.splice;function ut(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},ut.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var at="[object AsyncFunction]",ct="[object Function]",ft="[object GeneratorFunction]",st="[object Proxy]";function lt(t){if(!it(t))return!1;var r=y(t);return r==ct||r==ft||r==at||r==st}var pt,vt=u["__core-js_shared__"],dt=(pt=/[^.]+$/.exec(vt&&vt.keys&&vt.keys.IE_PROTO||""))?"Symbol(src)_1."+pt:"";var yt=Function.prototype.toString;var ht=/^\[object .+?Constructor\]$/,gt=Function.prototype,bt=Object.prototype,_t=gt.toString,jt=bt.hasOwnProperty,mt=RegExp("^"+_t.call(jt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ot(t){return!(!it(t)||function(t){return!!dt&&dt in t}(t))&&(lt(t)?mt:ht).test(function(t){if(null!=t){try{return yt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function wt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return Ot(e)?e:void 0}var Pt=wt(u,"Map"),St=wt(Object,"create");var At="__lodash_hash_undefined__",Nt=Object.prototype.hasOwnProperty;var kt=Object.prototype.hasOwnProperty;var zt="__lodash_hash_undefined__";function Ft(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=er}function or(t){return null!=t&&nr(t.length)&&!lt(t)}var ur="object"==typeof t&&t&&!t.nodeType&&t,ir=ur&&"object"==typeof module&&module&&!module.nodeType&&module,ar=ir&&ir.exports===ur?u.Buffer:void 0,cr=(ar?ar.isBuffer:void 0)||function(){return!1},fr={};fr["[object Float32Array]"]=fr["[object Float64Array]"]=fr["[object Int8Array]"]=fr["[object Int16Array]"]=fr["[object Int32Array]"]=fr["[object Uint8Array]"]=fr["[object Uint8ClampedArray]"]=fr["[object Uint16Array]"]=fr["[object Uint32Array]"]=!0,fr["[object Arguments]"]=fr["[object Array]"]=fr["[object ArrayBuffer]"]=fr["[object Boolean]"]=fr["[object DataView]"]=fr["[object Date]"]=fr["[object Error]"]=fr["[object Function]"]=fr["[object Map]"]=fr["[object Number]"]=fr["[object Object]"]=fr["[object RegExp]"]=fr["[object Set]"]=fr["[object String]"]=fr["[object WeakMap]"]=!1;var sr="object"==typeof t&&t&&!t.nodeType&&t,lr=sr&&"object"==typeof module&&module&&!module.nodeType&&module,pr=lr&&lr.exports===sr&&n.process,vr=function(){try{var t=lr&&lr.require&&lr.require("util").types;return t||pr&&pr.binding&&pr.binding("util")}catch(t){}}(),dr=vr&&vr.isTypedArray,yr=dr?function(t){return function(r){return t(r)}}(dr):function(t){return _(t)&&nr(t.length)&&!!fr[y(t)]};function hr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var gr=Object.prototype.hasOwnProperty;function br(t,r,e){var n=t[r];gr.call(t,r)&&et(n,e)&&(void 0!==e||r in t)||Mt(t,r,e)}var _r=9007199254740991,jr=/^(?:0|[1-9]\d*)$/;function mr(t,r){var e=typeof t;return!!(r=null==r?_r:r)&&("number"==e||"symbol"!=e&&jr.test(t))&&t>-1&&t%1==0&&t0){if(++r>=Cr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Tr);function Ur(t,r){return Rr(function(t,r,e){return r=Er(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=Er(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=qr.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!it(e))return!1;var n=typeof r;return!!("number"==n?or(e)&&mr(r,e.length):"string"==n&&r in e)&&et(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):$r(t,e)}))}))}),Promise.resolve(!1===r?[]:A(r)?r:{}))},t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=se,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(se(t,r,e,n))},t.createQuery=fe,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(fe(t,r,e))},t.dasherize=function(t){return G(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case Ir:return t[Kr];case Qr:return[t[Hr],t[Lr]];default:throw new re("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Yr(e,r);return n}catch(t){throw new Yr(e,t)}},t.extractSocketPart=ee,t.formatPayload=ie,t.getCallMethod=function(t){switch(!0){case t===Zr[0]:return Ir;case t===Zr[1]:return Qr;default:return!1}},t.getConfigValue=function(t,r){return r&&A(r)&&t in r?r[t]:void 0},t.getMutationFromArgs=ve,t.getMutationFromPayload=function(t){var r=pe(t,ve);if(!1!==r)return r;throw new te("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=ae,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getQueryFromArgs=le,t.getQueryFromPayload=function(t){var r=pe(t,le);if(!1!==r)return r;throw new te("[getQueryArgs] Payload is malformed!",t)},t.groupByNamespace=function(t,r){void 0===r&&(r=!1);var e=ee(t);if(!1===e){if(r)return t;throw new re("socket not found in contract!")}var n,o={},u=0;for(var i in e){var a=e[i],c=a.namespace;c&&(o[c]||(++u,o[c]={}),o[c][i]=a,n||a.public&&(n=c))}return{size:u,nspSet:o,publicNamespace:n}},t.inArray=K,t.injectToFn=Dr,t.isContract=function(t){return!!function(t){return A(t)&&(Z(t,Ir)||Z(t,Qr)||Z(t,Vr))}(t)&&t},t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type!")},t.isJsonqlErrorObj=de,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==G(t)},t.isObjectHasKey=Z,t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=Br,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=de(t)||u,o[Wr]=X(),o))},t.packResult=function(t,e){void 0===e&&(e=!1);var n={};return n.data=t,e&&r(e)&&(e.push(X()),n[Wr]=e),JSON.stringify(n)},t.preConfigCheck=function(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];var o=e.length>0?Reflect.apply(rt,null,e):e[0];return function(e){return void 0===e&&(e={}),Dr(o(e,t,r),Xr,X())}},t.resultHandler=function(t){return Z(t,"data")&&!Z(t,"error")?t.data:t},t.timestamp=X,t.toArray=W,t.toJson=function(t){return"string"==typeof t?function(t){try{return JSON.parse(t)}catch(r){return t}}(t):JSON.parse(JSON.stringify(t))},t.toPayload=ue,t.urlParams=Y,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p="[object Null]",v="[object Undefined]",d=i?i.toStringTag:void 0;function y(t){return null==t?void 0===t?v:p:d&&d in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var h,g,b=(h=Object.getPrototypeOf,g=Object,function(t){return h(g(t))});function _(t){return null!=t&&"object"==typeof t}var j="[object Object]",m=Function.prototype,O=Object.prototype,w=m.toString,P=O.hasOwnProperty,S=w.call(Object);function A(t){if(!_(t)||y(t)!=j)return!1;var r=b(t);if(null===r)return!0;var e=P.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&w.call(e)==S}var N="[object Symbol]";var k=1/0,z=i?i.prototype:void 0,F=z?z.toString:void 0;function x(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&C(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var K=function(t,r){return!!t.filter((function(t){return t===r})).length},W=function(t){return r(t)?t:[t]},Z=function(t,r){try{var e=Object.keys(t);return K(e,r)}catch(t){return!1}},X=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},Y=function(t,r){var e=[];for(var n in r)e.push([n,r[n]].join("="));return[t,e.join("&")].join("?")},tt=function(){return{_cb:X()}},rt=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,W(t))}),Reflect.apply(t,null,e))}};function et(t,r){return t===r||t!=t&&r!=r}function nt(t,r){for(var e=t.length;e--;)if(et(t[e][0],r))return e;return-1}var ot=Array.prototype.splice;function ut(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},ut.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var at="[object AsyncFunction]",ct="[object Function]",ft="[object GeneratorFunction]",st="[object Proxy]";function lt(t){if(!it(t))return!1;var r=y(t);return r==ct||r==ft||r==at||r==st}var pt,vt=u["__core-js_shared__"],dt=(pt=/[^.]+$/.exec(vt&&vt.keys&&vt.keys.IE_PROTO||""))?"Symbol(src)_1."+pt:"";var yt=Function.prototype.toString;var ht=/^\[object .+?Constructor\]$/,gt=Function.prototype,bt=Object.prototype,_t=gt.toString,jt=bt.hasOwnProperty,mt=RegExp("^"+_t.call(jt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ot(t){return!(!it(t)||function(t){return!!dt&&dt in t}(t))&&(lt(t)?mt:ht).test(function(t){if(null!=t){try{return yt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function wt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return Ot(e)?e:void 0}var Pt=wt(u,"Map"),St=wt(Object,"create");var At="__lodash_hash_undefined__",Nt=Object.prototype.hasOwnProperty;var kt=Object.prototype.hasOwnProperty;var zt="__lodash_hash_undefined__";function Ft(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=er}function or(t){return null!=t&&nr(t.length)&&!lt(t)}var ur="object"==typeof t&&t&&!t.nodeType&&t,ir=ur&&"object"==typeof module&&module&&!module.nodeType&&module,ar=ir&&ir.exports===ur?u.Buffer:void 0,cr=(ar?ar.isBuffer:void 0)||function(){return!1},fr={};fr["[object Float32Array]"]=fr["[object Float64Array]"]=fr["[object Int8Array]"]=fr["[object Int16Array]"]=fr["[object Int32Array]"]=fr["[object Uint8Array]"]=fr["[object Uint8ClampedArray]"]=fr["[object Uint16Array]"]=fr["[object Uint32Array]"]=!0,fr["[object Arguments]"]=fr["[object Array]"]=fr["[object ArrayBuffer]"]=fr["[object Boolean]"]=fr["[object DataView]"]=fr["[object Date]"]=fr["[object Error]"]=fr["[object Function]"]=fr["[object Map]"]=fr["[object Number]"]=fr["[object Object]"]=fr["[object RegExp]"]=fr["[object Set]"]=fr["[object String]"]=fr["[object WeakMap]"]=!1;var sr="object"==typeof t&&t&&!t.nodeType&&t,lr=sr&&"object"==typeof module&&module&&!module.nodeType&&module,pr=lr&&lr.exports===sr&&n.process,vr=function(){try{var t=lr&&lr.require&&lr.require("util").types;return t||pr&&pr.binding&&pr.binding("util")}catch(t){}}(),dr=vr&&vr.isTypedArray,yr=dr?function(t){return function(r){return t(r)}}(dr):function(t){return _(t)&&nr(t.length)&&!!fr[y(t)]};function hr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var gr=Object.prototype.hasOwnProperty;function br(t,r,e){var n=t[r];gr.call(t,r)&&et(n,e)&&(void 0!==e||r in t)||Mt(t,r,e)}var _r=9007199254740991,jr=/^(?:0|[1-9]\d*)$/;function mr(t,r){var e=typeof t;return!!(r=null==r?_r:r)&&("number"==e||"symbol"!=e&&jr.test(t))&&t>-1&&t%1==0&&t0){if(++r>=Cr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Tr);function Ur(t,r){return Rr(function(t,r,e){return r=Er(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=Er(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=qr.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!it(e))return!1;var n=typeof r;return!!("number"==n?or(e)&&mr(r,e.length):"string"==n&&r in e)&&et(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):$r(t,e)}))}))}),Promise.resolve(!1===r?[]:A(r)?r:{}))},t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=se,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(se(t,r,e,n))},t.createQuery=fe,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(fe(t,r,e))},t.dasherize=function(t){return G(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case Ir:return t[Kr];case Qr:return[t[Hr],t[Lr]];default:throw new re("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Yr(e,r);return n}catch(t){throw new Yr(e,t)}},t.extractSocketPart=ee,t.formatPayload=ie,t.getCallMethod=function(t){switch(!0){case t===Zr[0]:return Ir;case t===Zr[1]:return Qr;default:return!1}},t.getConfigValue=function(t,r){return r&&A(r)&&t in r?r[t]:void 0},t.getMutationFromArgs=ve,t.getMutationFromPayload=function(t){var r=pe(t,ve);if(!1!==r)return r;throw new te("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=ae,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getQueryFromArgs=le,t.getQueryFromPayload=function(t){var r=pe(t,le);if(!1!==r)return r;throw new te("[getQueryArgs] Payload is malformed!",t)},t.groupByNamespace=function(t,r){void 0===r&&(r=!1);var e=ee(t);if(!1===e){if(r)return t;throw new re("socket not found in contract!")}var n,o={},u=0;for(var i in e){var a=e[i],c=a.namespace;c&&(o[c]||(++u,o[c]={}),o[c][i]=a,n||a.public&&(n=c))}return{size:u,nspSet:o,publicNamespace:n}},t.inArray=K,t.injectToFn=Dr,t.isContract=function(t){return!!function(t){return A(t)&&(Z(t,Ir)||Z(t,Qr)||Z(t,Vr))}(t)&&t},t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type!")},t.isJsonqlErrorObj=de,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==G(t)},t.isObjectHasKey=Z,t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=Br,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=de(t)||u,o[Wr]=X(),o))},t.packResult=function(t,e){void 0===e&&(e=!1);var n={};return n.data=t,e&&r(e)&&(e.push(X()),n[Wr]=e),JSON.stringify(n)},t.preConfigCheck=function(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];var o=Reflect.apply(rt,null,e.concat((function(t){return Dr(t,Xr,X())})));return function(e){return void 0===e&&(e={}),o(e,t,r)}},t.resultHandler=function(t){return Z(t,"data")&&!Z(t,"error")?t.data:t},t.timestamp=X,t.toArray=W,t.toJson=function(t){return"string"==typeof t?function(t){try{return JSON.parse(t)}catch(r){return t}}(t):JSON.parse(JSON.stringify(t))},t.toPayload=ue,t.urlParams=Y,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=browser.js.map diff --git a/packages/utils/main.js b/packages/utils/main.js index 2deb42d21eaaee5a712d7e3d2dc905fd37c2a91b..115de1e0d90bdf2e35ff1196fa93bbb136f41ebc 100644 --- a/packages/utils/main.js +++ b/packages/utils/main.js @@ -1,2 +1,2 @@ -"use strict";function _interopDefault(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var fs=_interopDefault(require("fs")),path=require("path"),isArray=Array.isArray,global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},freeGlobal="object"==typeof global$1&&global$1&&global$1.Object===Object&&global$1,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol=root.Symbol,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol?Symbol.toStringTag:void 0;function getRawTag(r){var t=hasOwnProperty.call(r,symToStringTag),e=r[symToStringTag];try{r[symToStringTag]=void 0;var n=!0}catch(r){}var o=nativeObjectToString.call(r);return n&&(t?r[symToStringTag]=e:delete r[symToStringTag]),o}var objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;function objectToString(r){return nativeObjectToString$1.call(r)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=Symbol?Symbol.toStringTag:void 0;function baseGetTag(r){return null==r?void 0===r?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(r)?getRawTag(r):objectToString(r)}function overArg(r,t){return function(e){return r(t(e))}}var getPrototype=overArg(Object.getPrototypeOf,Object);function isObjectLike(r){return null!=r&&"object"==typeof r}var objectTag="[object Object]",funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$1=objectProto$2.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(r){if(!isObjectLike(r)||baseGetTag(r)!=objectTag)return!1;var t=getPrototype(r);if(null===t)return!0;var e=hasOwnProperty$1.call(t,"constructor")&&t.constructor;return"function"==typeof e&&e instanceof e&&funcToString.call(e)==objectCtorString}function arrayMap(r,t){for(var e=-1,n=null==r?0:r.length,o=Array(n);++eo?0:o+t),(e=e>o?o:e)<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var a=Array(o);++n=n?r:baseSlice(r,t,e)}function baseFindIndex(r,t,e,n){for(var o=r.length,a=e+(n?1:-1);n?a--:++a-1;);return e}function charsStartIndex(r,t){for(var e=-1,n=r.length;++e-1;);return e}function asciiToArray(r){return r.split("")}var rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsVarRange="\\ufe0e\\ufe0f",rsZWJ="\\u200d",reHasUnicode=RegExp("["+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+"]");function hasUnicode(r){return reHasUnicode.test(r)}var rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$1="\\u0300-\\u036f",reComboHalfMarksRange$1="\\ufe20-\\ufe2f",rsComboSymbolsRange$1="\\u20d0-\\u20ff",rsComboRange$1=rsComboMarksRange$1+reComboHalfMarksRange$1+rsComboSymbolsRange$1,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo="["+rsComboRange$1+"]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier="(?:"+rsCombo+"|"+rsFitz+")",rsNonAstral="[^"+rsAstralRange$1+"]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod=rsModifier+"?",rsOptVar="["+rsVarRange$1+"]?",rsOptJoin="(?:"+rsZWJ$1+"(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")"+rsOptVar+reOptMod+")*",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g");function unicodeToArray(r){return r.match(reUnicode)||[]}function stringToArray(r){return hasUnicode(r)?unicodeToArray(r):asciiToArray(r)}function toString(r){return null==r?"":baseToString(r)}var reTrim=/^\s+|\s+$/g;function trim(r,t,e){if((r=toString(r))&&(e||void 0===t))return r.replace(reTrim,"");if(!r||!(t=baseToString(t)))return r;var n=stringToArray(r),o=stringToArray(t);return castSlice(n,charsStartIndex(n,o),charsEndIndex(n,o)+1).join("")}var inArray=function(r,t){return!!r.filter((function(r){return r===t})).length},toArray=function(r){return isArray(r)?r:[r]},parse=function(r){try{return JSON.parse(r)}catch(t){return r}},isObjectHasKey=function(r,t){try{var e=Object.keys(r);return inArray(e,t)}catch(r){return!1}},createEvt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.join("_")},timestamp=function(r){void 0===r&&(r=!1);var t=Date.now();return r?Math.floor(t/1e3):t},urlParams=function(r,t){var e=[];for(var n in t)e.push([n,t[n]].join("="));return[r,e.join("&")].join("?")},cacheBurstUrl=function(r){return urlParams(r,cacheBurst())},cacheBurst=function(){return{_cb:timestamp()}},dasherize=function(r){return trim(r).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},getConfigValue=function(r,t){return t&&isPlainObject(t)&&r in t?t[r]:void 0},toJson=function(r){return"string"==typeof r?parse(r):JSON.parse(JSON.stringify(r))},isNotEmpty=function(r){return void 0!==r&&!1!==r&&null!==r&&""!==trim(r)},chainFns=function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.reduce((function(r,t){return Reflect.apply(t,null,toArray(r))}),Reflect.apply(r,null,e))}};function listCacheClear(){this.__data__=[],this.size=0}function eq(r,t){return r===t||r!=r&&t!=t}function assocIndexOf(r,t){for(var e=r.length;e--;)if(eq(r[e][0],t))return e;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(r){var t=this.__data__,e=assocIndexOf(t,r);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}function listCacheGet(r){var t=this.__data__,e=assocIndexOf(t,r);return e<0?void 0:t[e][1]}function listCacheHas(r){return assocIndexOf(this.__data__,r)>-1}function listCacheSet(r,t){var e=this.__data__,n=assocIndexOf(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}function ListCache(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t-1&&r%1==0&&r<=MAX_SAFE_INTEGER}function isArrayLike(r){return null!=r&&isLength(r.length)&&!isFunction(r)}function isArrayLikeObject(r){return isObjectLike(r)&&isArrayLike(r)}function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(r){return isObjectLike(r)&&isLength(r.length)&&!!typedArrayTags[baseGetTag(r)]}function baseUnary(r){return function(t){return r(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{var r=freeModule$2&&freeModule$2.require&&freeModule$2.require("util").types;return r||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(r){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;function safeGet(r,t){if(("constructor"!==t||"function"!=typeof r[t])&&"__proto__"!=t)return r[t]}var objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty;function assignValue(r,t,e){var n=r[t];hasOwnProperty$6.call(r,t)&&eq(n,e)&&(void 0!==e||t in r)||baseAssignValue(r,t,e)}function copyObject(r,t,e,n){var o=!e;e||(e={});for(var a=-1,i=t.length;++a-1&&r%1==0&&r0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var setToString=shortOut(baseSetToString);function baseRest(r,t){return setToString(overRest(r,t,identity),r+"")}function isIterateeCall(r,t,e){if(!isObject(e))return!1;var n=typeof t;return!!("number"==n?isArrayLike(e)&&isIndex(t,e.length):"string"==n&&t in e)&&eq(e[t],r)}function createAssigner(r){return baseRest((function(t,e){var n=-1,o=e.length,a=o>1?e[o-1]:void 0,i=o>2?e[2]:void 0;for(a=r.length>3&&"function"==typeof a?(o--,a):void 0,i&&isIterateeCall(e[0],e[1],i)&&(a=o<3?void 0:a,o=1),t=Object(t);++n0;)e[n]=arguments[n+2];var o=e.length>0?Reflect.apply(chainFns,null,e):e[0];return function(e){return void 0===e&&(e={}),injectToFn(o(e,r,t),CHECKED_KEY,timestamp())}}var VERSION="0.8.9",lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===r[s-2]?2:"="===r[s-1]?1:0,i=new Arr(3*s/4-a),n=a>0?s-4:s;var u=0;for(t=0,e=0;t>16&255,i[u++]=o>>8&255,i[u++]=255&o;return 2===a?(o=revLookup[r.charCodeAt(t)]<<2|revLookup[r.charCodeAt(t+1)]>>4,i[u++]=255&o):1===a&&(o=revLookup[r.charCodeAt(t)]<<10|revLookup[r.charCodeAt(t+1)]<<4|revLookup[r.charCodeAt(t+2)]>>2,i[u++]=o>>8&255,i[u++]=255&o),i}function tripletToBase64(r){return lookup[r>>18&63]+lookup[r>>12&63]+lookup[r>>6&63]+lookup[63&r]}function encodeChunk(r,t,e){for(var n,o=[],a=t;as?s:i+16383));return 1===n?(t=r[e-1],o+=lookup[t>>2],o+=lookup[t<<4&63],o+="=="):2===n&&(t=(r[e-2]<<8)+r[e-1],o+=lookup[t>>10],o+=lookup[t>>4&63],o+=lookup[t<<2&63],o+="="),a.push(o),a.join("")}function read(r,t,e,n,o){var a,i,s=8*o-n-1,u=(1<>1,c=-7,l=e?o-1:0,p=e?-1:1,h=r[t+l];for(l+=p,a=h&(1<<-c)-1,h>>=-c,c+=s;c>0;a=256*a+r[t+l],l+=p,c-=8);for(i=a&(1<<-c)-1,a>>=-c,c+=n;c>0;i=256*i+r[t+l],l+=p,c-=8);if(0===a)a=1-f;else{if(a===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),a-=f}return(h?-1:1)*i*Math.pow(2,a-n)}function write(r,t,e,n,o,a){var i,s,u,f=8*a-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=c):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(i++,u/=2),i+l>=c?(s=0,i=c):i+l>=1?(s=(t*u-1)*Math.pow(2,o),i+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,o),i=0));o>=8;r[e+h]=255&s,h+=g,s/=256,o-=8);for(i=i<0;r[e+h]=255&i,h+=g,i/=256,f-=8);r[e+h-g]|=128*y}var toString$1={}.toString,isArray$1=Array.isArray||function(r){return"[object Array]"==toString$1.call(r)},INSPECT_MAX_BYTES=50;function kMaxLength(){return Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(r,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|r}function internalIsBuffer(r){return!(null==r||!r._isBuffer)}function byteLength(r,t){if(internalIsBuffer(r))return r.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;"string"!=typeof r&&(r=""+r);var e=r.length;if(0===e)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return utf8ToBytes(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return base64ToBytes(r).length;default:if(n)return utf8ToBytes(r).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(r,t,e){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(r||(r="utf8");;)switch(r){case"hex":return hexSlice(this,t,e);case"utf8":case"utf-8":return utf8Slice(this,t,e);case"ascii":return asciiSlice(this,t,e);case"latin1":case"binary":return latin1Slice(this,t,e);case"base64":return base64Slice(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function swap(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function bidirectionalIndexOf(r,t,e,n,o){if(0===r.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof t&&(t=Buffer$2.from(t,n)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(r,t,e,n,o);if("number"==typeof t)return t&=255,Buffer$2.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):arrayIndexOf(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(r,t,e,n,o){var a,i=1,s=r.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(r.length<2||t.length<2)return-1;i=2,s/=2,u/=2,e/=2}function f(r,t){return 1===i?r[t]:r.readUInt16BE(t*i)}if(o){var c=-1;for(a=e;as&&(e=s-u),a=e;a>=0;a--){for(var l=!0,p=0;po&&(n=o):n=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var i=0;i239?4:f>223?3:f>191?2:1;if(o+l<=e)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(a=r[o+1]))&&(u=(31&f)<<6|63&a)>127&&(c=u);break;case 3:a=r[o+1],i=r[o+2],128==(192&a)&&128==(192&i)&&(u=(15&f)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=r[o+1],i=r[o+2],s=r[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&f)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return decodeCodePointsArray(n)}Buffer$2.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT,Buffer$2.poolSize=8192,Buffer$2._augment=function(r){return r.__proto__=Buffer$2.prototype,r},Buffer$2.from=function(r,t,e){return from(null,r,t,e)},Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array),Buffer$2.alloc=function(r,t,e){return alloc(null,r,t,e)},Buffer$2.allocUnsafe=function(r){return allocUnsafe$1(null,r)},Buffer$2.allocUnsafeSlow=function(r){return allocUnsafe$1(null,r)},Buffer$2.isBuffer=isBuffer$1,Buffer$2.compare=function(r,t){if(!internalIsBuffer(r)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(r===t)return 0;for(var e=r.length,n=t.length,o=0,a=Math.min(e,n);o0&&(r=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(r+=" ... ")),""},Buffer$2.prototype.compare=function(r,t,e,n,o){if(!internalIsBuffer(r))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===e&&(e=r?r.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||e>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=e)return 0;if(n>=o)return-1;if(t>=e)return 1;if(this===r)return 0;for(var a=(o>>>=0)-(n>>>=0),i=(e>>>=0)-(t>>>=0),s=Math.min(a,i),u=this.slice(n,o),f=r.slice(t,e),c=0;co)&&(e=o),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return hexWrite(this,r,t,e);case"utf8":case"utf-8":return utf8Write(this,r,t,e);case"ascii":return asciiWrite(this,r,t,e);case"latin1":case"binary":return latin1Write(this,r,t,e);case"base64":return base64Write(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,r,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},Buffer$2.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(r){var t=r.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,r);for(var e="",n=0;nn)&&(e=n);for(var o="",a=t;ae)throw new RangeError("Trying to access beyond buffer length")}function checkInt(r,t,e,n,o,a){if(!internalIsBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||tr.length)throw new RangeError("Index out of range")}function objectWriteUInt16(r,t,e,n){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(r.length-e,2);o>>8*(n?o:1-o)}function objectWriteUInt32(r,t,e,n){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(r.length-e,4);o>>8*(n?o:3-o)&255}function checkIEEE754(r,t,e,n,o,a){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function writeFloat(r,t,e,n,o){return o||checkIEEE754(r,t,e,4),write(r,t,e,n,23,4),e+4}function writeDouble(r,t,e,n,o){return o||checkIEEE754(r,t,e,8),write(r,t,e,n,52,8),e+8}Buffer$2.prototype.slice=function(r,t){var e,n=this.length;if((r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[r+--t]*o;return n},Buffer$2.prototype.readUInt8=function(r,t){return t||checkOffset(r,1,this.length),this[r]},Buffer$2.prototype.readUInt16LE=function(r,t){return t||checkOffset(r,2,this.length),this[r]|this[r+1]<<8},Buffer$2.prototype.readUInt16BE=function(r,t){return t||checkOffset(r,2,this.length),this[r]<<8|this[r+1]},Buffer$2.prototype.readUInt32LE=function(r,t){return t||checkOffset(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},Buffer$2.prototype.readUInt32BE=function(r,t){return t||checkOffset(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},Buffer$2.prototype.readIntLE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=this[r],o=1,a=0;++a=(o*=128)&&(n-=Math.pow(2,8*t)),n},Buffer$2.prototype.readIntBE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=t,o=1,a=this[r+--n];n>0&&(o*=256);)a+=this[r+--n]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},Buffer$2.prototype.readInt8=function(r,t){return t||checkOffset(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},Buffer$2.prototype.readInt16LE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r]|this[r+1]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt16BE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r+1]|this[r]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt32LE=function(r,t){return t||checkOffset(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},Buffer$2.prototype.readInt32BE=function(r,t){return t||checkOffset(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},Buffer$2.prototype.readFloatLE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!0,23,4)},Buffer$2.prototype.readFloatBE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!1,23,4)},Buffer$2.prototype.readDoubleLE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!0,52,8)},Buffer$2.prototype.readDoubleBE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!1,52,8)},Buffer$2.prototype.writeUIntLE=function(r,t,e,n){(r=+r,t|=0,e|=0,n)||checkInt(this,r,t,e,Math.pow(2,8*e)-1,0);var o=1,a=0;for(this[t]=255&r;++a=0&&(a*=256);)this[t+o]=r/a&255;return t+e},Buffer$2.prototype.writeUInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,255,0),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[t]=255&r,t+1},Buffer$2.prototype.writeUInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeUInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeUInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=255&r):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeUInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=0,i=1,s=0;for(this[t]=255&r;++a>0)-s&255;return t+e},Buffer$2.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=e-1,i=1,s=0;for(this[t+a]=255&r;--a>=0&&(i*=256);)r<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(r/i>>0)-s&255;return t+e},Buffer$2.prototype.writeInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,127,-128),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[t]=255&r,t+1},Buffer$2.prototype.writeInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeFloatLE=function(r,t,e){return writeFloat(this,r,t,!0,e)},Buffer$2.prototype.writeFloatBE=function(r,t,e){return writeFloat(this,r,t,!1,e)},Buffer$2.prototype.writeDoubleLE=function(r,t,e){return writeDouble(this,r,t,!0,e)},Buffer$2.prototype.writeDoubleBE=function(r,t,e){return writeDouble(this,r,t,!1,e)},Buffer$2.prototype.copy=function(r,t,e,n){if(e||(e=0),n||0===n||(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t=0;--o)r[o+t]=this[o+e];else if(a<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,r||(r=0),"number"==typeof r)for(a=t;a55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&a.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&a.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;a.push(e)}else if(e<2048){if((t-=2)<0)break;a.push(e>>6|192,63&e|128)}else if(e<65536){if((t-=3)<0)break;a.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return a}function asciiToBytes(r){for(var t=[],e=0;e>8,o=e%256,a.push(o),a.push(n);return a}function base64ToBytes(r){return toByteArray(base64clean(r))}function blitBuffer(r,t,e,n){for(var o=0;o=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function isnan(r){return r!=r}function isBuffer$1(r){return null!=r&&(!!r._isBuffer||isFastBuffer(r)||isSlowBuffer(r))}function isFastBuffer(r){return!!r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r)}function isSlowBuffer(r){return"function"==typeof r.readFloatLE&&"function"==typeof r.slice&&isFastBuffer(r.slice(0,0))}function buff(r,t){return void 0===t&&(t=BASE64_FORMAT),isBuffer$1(r)?r:new Buffer$2.from(r,t)}var replaceErrors=function(r,t){if(t instanceof Error){var e={};return Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]})),e}return t},printError=function(r){return JSON.stringify(r,replaceErrors)};function findFromContract(r,t,e){return!!(e[r]&&e[r][t]&&e[r][t].file&&fs.existsSync(e[r][t].file))&&e[r][t].file}var DOT=".",getDocLen=function(r){return Buffer$2.byteLength(r,"utf8")},headerParser=function(r,t){try{var e=r.headers.accept.split(",");return t?e.filter((function(r){return r===t})):e}catch(r){return[]}},isHeaderPresent=function(r,t){return!!headerParser(r,t).length},getPathToFn=function(r,t,e){var n=e.resolverDir,o=dasherize(r),a=[];e.contract&&e.contract[t]&&e.contract[t].path&&a.push(e.contract[t].path),a.push(path.join(n,t,o,[INDEX_KEY,EXT].join(DOT))),a.push(path.join(n,t,[o,EXT].join(DOT)));for(var i=a.length,s=0;so?0:o+t),(e=e>o?o:e)<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var a=Array(o);++n=n?r:baseSlice(r,t,e)}function baseFindIndex(r,t,e,n){for(var o=r.length,a=e+(n?1:-1);n?a--:++a-1;);return e}function charsStartIndex(r,t){for(var e=-1,n=r.length;++e-1;);return e}function asciiToArray(r){return r.split("")}var rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsVarRange="\\ufe0e\\ufe0f",rsZWJ="\\u200d",reHasUnicode=RegExp("["+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+"]");function hasUnicode(r){return reHasUnicode.test(r)}var rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$1="\\u0300-\\u036f",reComboHalfMarksRange$1="\\ufe20-\\ufe2f",rsComboSymbolsRange$1="\\u20d0-\\u20ff",rsComboRange$1=rsComboMarksRange$1+reComboHalfMarksRange$1+rsComboSymbolsRange$1,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo="["+rsComboRange$1+"]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier="(?:"+rsCombo+"|"+rsFitz+")",rsNonAstral="[^"+rsAstralRange$1+"]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod=rsModifier+"?",rsOptVar="["+rsVarRange$1+"]?",rsOptJoin="(?:"+rsZWJ$1+"(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")"+rsOptVar+reOptMod+")*",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g");function unicodeToArray(r){return r.match(reUnicode)||[]}function stringToArray(r){return hasUnicode(r)?unicodeToArray(r):asciiToArray(r)}function toString(r){return null==r?"":baseToString(r)}var reTrim=/^\s+|\s+$/g;function trim(r,t,e){if((r=toString(r))&&(e||void 0===t))return r.replace(reTrim,"");if(!r||!(t=baseToString(t)))return r;var n=stringToArray(r),o=stringToArray(t);return castSlice(n,charsStartIndex(n,o),charsEndIndex(n,o)+1).join("")}var inArray=function(r,t){return!!r.filter((function(r){return r===t})).length},toArray=function(r){return isArray(r)?r:[r]},parse=function(r){try{return JSON.parse(r)}catch(t){return r}},isObjectHasKey=function(r,t){try{var e=Object.keys(r);return inArray(e,t)}catch(r){return!1}},createEvt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.join("_")},timestamp=function(r){void 0===r&&(r=!1);var t=Date.now();return r?Math.floor(t/1e3):t},urlParams=function(r,t){var e=[];for(var n in t)e.push([n,t[n]].join("="));return[r,e.join("&")].join("?")},cacheBurstUrl=function(r){return urlParams(r,cacheBurst())},cacheBurst=function(){return{_cb:timestamp()}},dasherize=function(r){return trim(r).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},getConfigValue=function(r,t){return t&&isPlainObject(t)&&r in t?t[r]:void 0},toJson=function(r){return"string"==typeof r?parse(r):JSON.parse(JSON.stringify(r))},isNotEmpty=function(r){return void 0!==r&&!1!==r&&null!==r&&""!==trim(r)},chainFns=function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.reduce((function(r,t){return Reflect.apply(t,null,toArray(r))}),Reflect.apply(r,null,e))}};function listCacheClear(){this.__data__=[],this.size=0}function eq(r,t){return r===t||r!=r&&t!=t}function assocIndexOf(r,t){for(var e=r.length;e--;)if(eq(r[e][0],t))return e;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(r){var t=this.__data__,e=assocIndexOf(t,r);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}function listCacheGet(r){var t=this.__data__,e=assocIndexOf(t,r);return e<0?void 0:t[e][1]}function listCacheHas(r){return assocIndexOf(this.__data__,r)>-1}function listCacheSet(r,t){var e=this.__data__,n=assocIndexOf(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}function ListCache(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t-1&&r%1==0&&r<=MAX_SAFE_INTEGER}function isArrayLike(r){return null!=r&&isLength(r.length)&&!isFunction(r)}function isArrayLikeObject(r){return isObjectLike(r)&&isArrayLike(r)}function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(r){return isObjectLike(r)&&isLength(r.length)&&!!typedArrayTags[baseGetTag(r)]}function baseUnary(r){return function(t){return r(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{var r=freeModule$2&&freeModule$2.require&&freeModule$2.require("util").types;return r||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(r){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;function safeGet(r,t){if(("constructor"!==t||"function"!=typeof r[t])&&"__proto__"!=t)return r[t]}var objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty;function assignValue(r,t,e){var n=r[t];hasOwnProperty$6.call(r,t)&&eq(n,e)&&(void 0!==e||t in r)||baseAssignValue(r,t,e)}function copyObject(r,t,e,n){var o=!e;e||(e={});for(var a=-1,i=t.length;++a-1&&r%1==0&&r0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var setToString=shortOut(baseSetToString);function baseRest(r,t){return setToString(overRest(r,t,identity),r+"")}function isIterateeCall(r,t,e){if(!isObject(e))return!1;var n=typeof t;return!!("number"==n?isArrayLike(e)&&isIndex(t,e.length):"string"==n&&t in e)&&eq(e[t],r)}function createAssigner(r){return baseRest((function(t,e){var n=-1,o=e.length,a=o>1?e[o-1]:void 0,i=o>2?e[2]:void 0;for(a=r.length>3&&"function"==typeof a?(o--,a):void 0,i&&isIterateeCall(e[0],e[1],i)&&(a=o<3?void 0:a,o=1),t=Object(t);++n0;)e[n]=arguments[n+2];var o=Reflect.apply(chainFns,null,e.concat((function(r){return injectToFn(r,CHECKED_KEY,timestamp())})));return function(e){return void 0===e&&(e={}),o(e,r,t)}}var VERSION="0.8.10",lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===r[s-2]?2:"="===r[s-1]?1:0,i=new Arr(3*s/4-a),n=a>0?s-4:s;var u=0;for(t=0,e=0;t>16&255,i[u++]=o>>8&255,i[u++]=255&o;return 2===a?(o=revLookup[r.charCodeAt(t)]<<2|revLookup[r.charCodeAt(t+1)]>>4,i[u++]=255&o):1===a&&(o=revLookup[r.charCodeAt(t)]<<10|revLookup[r.charCodeAt(t+1)]<<4|revLookup[r.charCodeAt(t+2)]>>2,i[u++]=o>>8&255,i[u++]=255&o),i}function tripletToBase64(r){return lookup[r>>18&63]+lookup[r>>12&63]+lookup[r>>6&63]+lookup[63&r]}function encodeChunk(r,t,e){for(var n,o=[],a=t;as?s:i+16383));return 1===n?(t=r[e-1],o+=lookup[t>>2],o+=lookup[t<<4&63],o+="=="):2===n&&(t=(r[e-2]<<8)+r[e-1],o+=lookup[t>>10],o+=lookup[t>>4&63],o+=lookup[t<<2&63],o+="="),a.push(o),a.join("")}function read(r,t,e,n,o){var a,i,s=8*o-n-1,u=(1<>1,c=-7,l=e?o-1:0,p=e?-1:1,h=r[t+l];for(l+=p,a=h&(1<<-c)-1,h>>=-c,c+=s;c>0;a=256*a+r[t+l],l+=p,c-=8);for(i=a&(1<<-c)-1,a>>=-c,c+=n;c>0;i=256*i+r[t+l],l+=p,c-=8);if(0===a)a=1-f;else{if(a===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),a-=f}return(h?-1:1)*i*Math.pow(2,a-n)}function write(r,t,e,n,o,a){var i,s,u,f=8*a-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=c):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(i++,u/=2),i+l>=c?(s=0,i=c):i+l>=1?(s=(t*u-1)*Math.pow(2,o),i+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,o),i=0));o>=8;r[e+h]=255&s,h+=g,s/=256,o-=8);for(i=i<0;r[e+h]=255&i,h+=g,i/=256,f-=8);r[e+h-g]|=128*y}var toString$1={}.toString,isArray$1=Array.isArray||function(r){return"[object Array]"==toString$1.call(r)},INSPECT_MAX_BYTES=50;function kMaxLength(){return Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(r,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|r}function internalIsBuffer(r){return!(null==r||!r._isBuffer)}function byteLength(r,t){if(internalIsBuffer(r))return r.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;"string"!=typeof r&&(r=""+r);var e=r.length;if(0===e)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return utf8ToBytes(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return base64ToBytes(r).length;default:if(n)return utf8ToBytes(r).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(r,t,e){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(r||(r="utf8");;)switch(r){case"hex":return hexSlice(this,t,e);case"utf8":case"utf-8":return utf8Slice(this,t,e);case"ascii":return asciiSlice(this,t,e);case"latin1":case"binary":return latin1Slice(this,t,e);case"base64":return base64Slice(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function swap(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function bidirectionalIndexOf(r,t,e,n,o){if(0===r.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof t&&(t=Buffer$2.from(t,n)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(r,t,e,n,o);if("number"==typeof t)return t&=255,Buffer$2.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):arrayIndexOf(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(r,t,e,n,o){var a,i=1,s=r.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(r.length<2||t.length<2)return-1;i=2,s/=2,u/=2,e/=2}function f(r,t){return 1===i?r[t]:r.readUInt16BE(t*i)}if(o){var c=-1;for(a=e;as&&(e=s-u),a=e;a>=0;a--){for(var l=!0,p=0;po&&(n=o):n=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var i=0;i239?4:f>223?3:f>191?2:1;if(o+l<=e)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(a=r[o+1]))&&(u=(31&f)<<6|63&a)>127&&(c=u);break;case 3:a=r[o+1],i=r[o+2],128==(192&a)&&128==(192&i)&&(u=(15&f)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=r[o+1],i=r[o+2],s=r[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&f)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return decodeCodePointsArray(n)}Buffer$2.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT,Buffer$2.poolSize=8192,Buffer$2._augment=function(r){return r.__proto__=Buffer$2.prototype,r},Buffer$2.from=function(r,t,e){return from(null,r,t,e)},Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array),Buffer$2.alloc=function(r,t,e){return alloc(null,r,t,e)},Buffer$2.allocUnsafe=function(r){return allocUnsafe$1(null,r)},Buffer$2.allocUnsafeSlow=function(r){return allocUnsafe$1(null,r)},Buffer$2.isBuffer=isBuffer$1,Buffer$2.compare=function(r,t){if(!internalIsBuffer(r)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(r===t)return 0;for(var e=r.length,n=t.length,o=0,a=Math.min(e,n);o0&&(r=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(r+=" ... ")),""},Buffer$2.prototype.compare=function(r,t,e,n,o){if(!internalIsBuffer(r))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===e&&(e=r?r.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||e>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=e)return 0;if(n>=o)return-1;if(t>=e)return 1;if(this===r)return 0;for(var a=(o>>>=0)-(n>>>=0),i=(e>>>=0)-(t>>>=0),s=Math.min(a,i),u=this.slice(n,o),f=r.slice(t,e),c=0;co)&&(e=o),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return hexWrite(this,r,t,e);case"utf8":case"utf-8":return utf8Write(this,r,t,e);case"ascii":return asciiWrite(this,r,t,e);case"latin1":case"binary":return latin1Write(this,r,t,e);case"base64":return base64Write(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,r,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},Buffer$2.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(r){var t=r.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,r);for(var e="",n=0;nn)&&(e=n);for(var o="",a=t;ae)throw new RangeError("Trying to access beyond buffer length")}function checkInt(r,t,e,n,o,a){if(!internalIsBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||tr.length)throw new RangeError("Index out of range")}function objectWriteUInt16(r,t,e,n){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(r.length-e,2);o>>8*(n?o:1-o)}function objectWriteUInt32(r,t,e,n){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(r.length-e,4);o>>8*(n?o:3-o)&255}function checkIEEE754(r,t,e,n,o,a){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function writeFloat(r,t,e,n,o){return o||checkIEEE754(r,t,e,4),write(r,t,e,n,23,4),e+4}function writeDouble(r,t,e,n,o){return o||checkIEEE754(r,t,e,8),write(r,t,e,n,52,8),e+8}Buffer$2.prototype.slice=function(r,t){var e,n=this.length;if((r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[r+--t]*o;return n},Buffer$2.prototype.readUInt8=function(r,t){return t||checkOffset(r,1,this.length),this[r]},Buffer$2.prototype.readUInt16LE=function(r,t){return t||checkOffset(r,2,this.length),this[r]|this[r+1]<<8},Buffer$2.prototype.readUInt16BE=function(r,t){return t||checkOffset(r,2,this.length),this[r]<<8|this[r+1]},Buffer$2.prototype.readUInt32LE=function(r,t){return t||checkOffset(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},Buffer$2.prototype.readUInt32BE=function(r,t){return t||checkOffset(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},Buffer$2.prototype.readIntLE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=this[r],o=1,a=0;++a=(o*=128)&&(n-=Math.pow(2,8*t)),n},Buffer$2.prototype.readIntBE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=t,o=1,a=this[r+--n];n>0&&(o*=256);)a+=this[r+--n]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},Buffer$2.prototype.readInt8=function(r,t){return t||checkOffset(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},Buffer$2.prototype.readInt16LE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r]|this[r+1]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt16BE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r+1]|this[r]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt32LE=function(r,t){return t||checkOffset(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},Buffer$2.prototype.readInt32BE=function(r,t){return t||checkOffset(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},Buffer$2.prototype.readFloatLE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!0,23,4)},Buffer$2.prototype.readFloatBE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!1,23,4)},Buffer$2.prototype.readDoubleLE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!0,52,8)},Buffer$2.prototype.readDoubleBE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!1,52,8)},Buffer$2.prototype.writeUIntLE=function(r,t,e,n){(r=+r,t|=0,e|=0,n)||checkInt(this,r,t,e,Math.pow(2,8*e)-1,0);var o=1,a=0;for(this[t]=255&r;++a=0&&(a*=256);)this[t+o]=r/a&255;return t+e},Buffer$2.prototype.writeUInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,255,0),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[t]=255&r,t+1},Buffer$2.prototype.writeUInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeUInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeUInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=255&r):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeUInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=0,i=1,s=0;for(this[t]=255&r;++a>0)-s&255;return t+e},Buffer$2.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=e-1,i=1,s=0;for(this[t+a]=255&r;--a>=0&&(i*=256);)r<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(r/i>>0)-s&255;return t+e},Buffer$2.prototype.writeInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,127,-128),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[t]=255&r,t+1},Buffer$2.prototype.writeInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeFloatLE=function(r,t,e){return writeFloat(this,r,t,!0,e)},Buffer$2.prototype.writeFloatBE=function(r,t,e){return writeFloat(this,r,t,!1,e)},Buffer$2.prototype.writeDoubleLE=function(r,t,e){return writeDouble(this,r,t,!0,e)},Buffer$2.prototype.writeDoubleBE=function(r,t,e){return writeDouble(this,r,t,!1,e)},Buffer$2.prototype.copy=function(r,t,e,n){if(e||(e=0),n||0===n||(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t=0;--o)r[o+t]=this[o+e];else if(a<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,r||(r=0),"number"==typeof r)for(a=t;a55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&a.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&a.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;a.push(e)}else if(e<2048){if((t-=2)<0)break;a.push(e>>6|192,63&e|128)}else if(e<65536){if((t-=3)<0)break;a.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return a}function asciiToBytes(r){for(var t=[],e=0;e>8,o=e%256,a.push(o),a.push(n);return a}function base64ToBytes(r){return toByteArray(base64clean(r))}function blitBuffer(r,t,e,n){for(var o=0;o=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function isnan(r){return r!=r}function isBuffer$1(r){return null!=r&&(!!r._isBuffer||isFastBuffer(r)||isSlowBuffer(r))}function isFastBuffer(r){return!!r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r)}function isSlowBuffer(r){return"function"==typeof r.readFloatLE&&"function"==typeof r.slice&&isFastBuffer(r.slice(0,0))}function buff(r,t){return void 0===t&&(t=BASE64_FORMAT),isBuffer$1(r)?r:new Buffer$2.from(r,t)}var replaceErrors=function(r,t){if(t instanceof Error){var e={};return Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]})),e}return t},printError=function(r){return JSON.stringify(r,replaceErrors)};function findFromContract(r,t,e){return!!(e[r]&&e[r][t]&&e[r][t].file&&fs.existsSync(e[r][t].file))&&e[r][t].file}var DOT=".",getDocLen=function(r){return Buffer$2.byteLength(r,"utf8")},headerParser=function(r,t){try{var e=r.headers.accept.split(",");return t?e.filter((function(r){return r===t})):e}catch(r){return[]}},isHeaderPresent=function(r,t){return!!headerParser(r,t).length},getPathToFn=function(r,t,e){var n=e.resolverDir,o=dasherize(r),a=[];e.contract&&e.contract[t]&&e.contract[t].path&&a.push(e.contract[t].path),a.push(path.join(n,t,o,[INDEX_KEY,EXT].join(DOT))),a.push(path.join(n,t,[o,EXT].join(DOT)));for(var i=a.length,s=0;s injectToFn(opt, CHECKED_KEY, timestamp()) // if there is more than one then chain it otherwise just return the zero idx one - const fn = fns.length > 0 ? Reflect.apply(chainFns, null, fns) : fns[0] + const fn = Reflect.apply(chainFns, null, fns.concat(finalFn)) // 0.8.8 add a default property empty object - return (config = {}) => ( - injectToFn(fn(config, defaultOptions, constProps), CHECKED_KEY, timestamp()) - ) + return (config = {}) => fn(config, defaultOptions, constProps) } diff --git a/packages/utils/tests/chain-fn.test.js b/packages/utils/tests/chain-fn.test.js index b5b2d63c30c93844d67975ba6b53761d9875eee7..f0d1b62f32555adf1b0913dfaafe194778c79c3e 100644 --- a/packages/utils/tests/chain-fn.test.js +++ b/packages/utils/tests/chain-fn.test.js @@ -11,7 +11,7 @@ const { JsonqlTypeError } = require('jsonql-errors') const debug = require('debug')('jsonql-utils:test:chain-fn') -test.only(`It should able to create the configuration check function with combine fns`, t => { +test(`It should able to create the configuration check function with combine fns`, t => { const defaultOptions = { option1: createConfig(false, [BOOLEAN_TYPE]), option2: createConfig(1, [NUMBER_TYPE])