Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ololoepepe/api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ololoepepe/api-wrapper - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/index.browser.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apiWrapper=e():t.apiWrapper=e()}(self,(function(){return(()=>{var t={757:(t,e,r)=>{t.exports=r(666)},187:t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function i(){i.init.call(this)}t.exports=i,t.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}v(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&v(t,"error",e,r)}(t,o,{once:!0})}))},i.EventEmitter=i,i.prototype._events=undefined,i.prototype._eventsCount=0,i.prototype._maxListeners=undefined;var a=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return t._maxListeners===undefined?i.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var o,i,a,u;if(c(r),(i=t._events)===undefined?(i=t._events=Object.create(null),t._eventsCount=0):(i.newListener!==undefined&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),a=i[e]),a===undefined)a=i[e]=r,++t._eventsCount;else if("function"==typeof a?a=i[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,r){var n={fired:!1,wrapFn:undefined,target:t,type:e,listener:r},o=l.bind(n);return o.listener=r,n.wrapFn=o,o}function h(t,e,r){var n=t._events;if(n===undefined)return[];var o=n[e];return o===undefined?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):d(o,o.length)}function f(t){var e=this._events;if(e!==undefined){var r=e[t];if("function"==typeof r)return 1;if(r!==undefined)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function v(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),i.init=function(){this._events!==undefined&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||undefined},i.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var o="error"===t,i=this._events;if(i!==undefined)o=o&&i.error===undefined;else if(!o)return!1;if(o){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var s=i[t];if(s===undefined)return!1;if("function"==typeof s)n(s,this,e);else{var u=s.length,l=d(s,u);for(r=0;r<u;++r)n(l[r],this,e)}return!0},i.prototype.addListener=function(t,e){return u(this,t,e,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(t,e){return u(this,t,e,!0)},i.prototype.once=function(t,e){return c(e),this.on(t,p(this,t,e)),this},i.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,p(this,t,e)),this},i.prototype.removeListener=function(t,e){var r,n,o,i,a;if(c(e),(n=this._events)===undefined)return this;if((r=n[t])===undefined)return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),n.removeListener!==undefined&&this.emit("removeListener",t,a||e)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(t){var e,r,n;if((r=this._events)===undefined)return this;if(r.removeListener===undefined)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):r[t]!==undefined&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e!==undefined)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},i.prototype.listeners=function(t){return h(this,t,!0)},i.prototype.rawListeners=function(t){return h(this,t,!1)},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(M){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),a=new D(n||[]);return i._invoke=function(t,e,r){var n=p;return function(o,i){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return L()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=k(a,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var s=l(t,e,r);if("normal"===s.type){if(n=r.done?d:h,s.arg===v)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,a),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var p="suspendedStart",h="suspendedYield",f="executing",d="completed",v={};function y(){}function m(){}function g(){}var b={};b[i]=function(){return this};var w=Object.getPrototypeOf,A=w&&w(w(S([])));A&&A!==r&&n.call(A,i)&&(b=A);var _=g.prototype=y.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var s=l(t[o],t,i);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function k(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator["return"]&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function D(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function S(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:L}}function L(){return{value:e,done:!0}}return m.prototype=_.constructor=g,g.constructor=m,m.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},E(x.prototype),x.prototype[a]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(_),s(_,c,"Generator"),_[i]=function(){return this},_.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=S,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),R(r),v}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}},e={};function r(n){var o=e[n];if(o!==undefined)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t["default"]:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";function t(e,r){return(t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(e,r)}function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function o(r,n,i){return(o=e()?Reflect.construct:function(e,r,n){var o=[null];o.push.apply(o,r);var i=new(Function.bind.apply(e,o));return n&&t(i,n.prototype),i}).apply(null,arguments)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,s,"next",t)}function s(t){c(i,n,o,a,s,"throw",t)}a(undefined)}))}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),t}r.r(n),r.d(n,{ApiAuthenticator:()=>S,ApiError:()=>D,ApiRealtimeTransport:()=>L,ApiTransport:()=>M,ApiWrapper:()=>H});var h=r(757),f=r.n(h);function d(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&t(e,r)}function v(t){return(v="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)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){return!e||"object"!==v(e)&&"function"!=typeof e?y(t):e}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(e){var r="function"==typeof Map?new Map:undefined;return(b=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,i)}function i(){return o(e,arguments,g(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),t(i,e)})(e)}function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=g(t);if(e){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m(this,r)}}var A="api_wrapper/access_restricted",_="api_wrapper/authentication_failed",E="api_wrapper/method_not_implemented",x="api_wrapper/parameter_not_provided",k="api_wrapper/realtime_transport",T="api_wrapper/session_expired",R="api_wrapper/unexpected",D=function(t){d(r,t);var e=w(r);function r(){var t,n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:R,o=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n,i=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return u(this,r),(t=e.call(this,o)).code=n,t.data=i,t}return p(r,null,[{key:"createAccessRestrictedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[A,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Access restricted"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createAuthenticationFailedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[_,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Authentication failed"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createMethodNotImplementedErrorArgs",value:function(t,e){return[E,"[".concat(t,".").concat(e,"] Method not implemented: ").concat(e),{className:t,methodName:e}]}},{key:"createParameterNotProvidedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[x,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Parameter not provided: ").concat(t),{className:e,methodName:r,parameterName:t,place:n}]}},{key:"createRealtimeTransportErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[k,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Realtime transport error: ").concat(t.message),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createSessionExpiredErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[T,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Session expired"),{className:e,methodName:r,originalError:t,place:n}]}}]),r}(b(Error)),S=function(){function t(){u(this,t)}var e,r,n;return p(t,[{key:"authenticate",value:(n=s(f().mark((function i(t,e){return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw console.log("[ApiAuthenticator.authenticate]","wrapper:",t),console.log("[ApiAuthenticator.authenticate]","previousAuthenticationData:",e),o(D,a(D.createMethodNotImplementedErrorArgs("ApiAuthenticator","authenticate")));case 3:case"end":return r.stop()}}),i)}))),function(t,e){return n.apply(this,arguments)})},{key:"loadAuthenticationData",value:(r=s(f().mark((function c(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiAuthenticator","loadAuthenticationData")));case 1:case"end":return t.stop()}}),c)}))),function(){return r.apply(this,arguments)})},{key:"saveAuthenticationData",value:(e=s(f().mark((function l(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw console.log("[ApiAuthenticator.saveAuthenticationData]","authenticationData:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiAuthenticator","saveAuthenticationData")));case 2:case"end":return e.stop()}}),l)}))),function(t){return e.apply(this,arguments)})}]),t}(),L=function(){function t(){u(this,t)}return p(t,[{key:"authenticate",value:function(t){var e=t.authenticationData,r=t.onAuthentication;throw console.log("[ApiRealtimeTransport.authenticate]","authenticationData:",e),console.log("[ApiRealtimeTransport.authenticate]","onAuthentication:",r),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","authenticate")))}},{key:"connect",value:function(t){var e=t.onConnect,r=t.onDisconnect,n=t.onError;throw console.log("[ApiRealtimeTransport.connect]","onConnect:",e),console.log("[ApiRealtimeTransport.connect]","onDisconnect:",r),console.log("[ApiRealtimeTransport.connect]","onError:",n),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","connect")))}},{key:"disconnect",value:function(){throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","disconnect")))}},{key:"isAccessRestrictedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAccessRestrictedError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAccessRestrictedError")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAuthenticationFailedError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiRealtimeTransport.isSessionExpiredError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isSessionExpiredError")))}},{key:"subscribe",value:function(t){var e=t.callbacks,r=t.onSubscribe,n=t.subscriptionData;throw console.log("[ApiRealtimeTransport.subscribe]","callbacks:",e),console.log("[ApiRealtimeTransport.subscribe]","onSubscribe:",r),console.log("[ApiRealtimeTransport.subscribe]","subscriptionData:",n),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","subscribe")))}},{key:"unsubscribe",value:function(t){var e=t.subscriptionData;throw console.log("[ApiRealtimeTransport.unsubscribe]","subscriptionData:",e),o(D,a(D.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","unsubscribe")))}}]),t}(),M=function(){function t(){u(this,t)}var e;return p(t,[{key:"callMethod",value:(e=s(f().mark((function r(t){var e,n,i,c;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw e=t.authenticationData,n=t.methodData,i=t.requestData,c=t.wrapper,console.log("[ApiTransport.callMethod]","authenticationData:",e),console.log("[ApiTransport.callMethod]","methodData:",n),console.log("[ApiTransport.callMethod]","requestData:",i),console.log("[ApiTransport.callMethod]","wrapper:",c),o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","callMethod")));case 6:case"end":return r.stop()}}),r)}))),function(t){return e.apply(this,arguments)})},{key:"getCreateMethodData",value:function(){throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","getCreateMethodData")))}},{key:"getDeleteMethodData",value:function(){throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","getDeleteMethodData")))}},{key:"getReadMethodData",value:function(){throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","getReadMethodData")))}},{key:"getUpdateMethodData",value:function(){throw o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","getUpdateMethodData")))}},{key:"isAccessRestrictedError",value:function(t){throw console.log("[ApiTransport.isAccessRestrictedError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","isAccessRestrictedError")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiTransport.isAuthenticationFailedError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiTransport.isSessionExpiredError]","error:",t),o(D,a(D.createMethodNotImplementedErrorArgs("ApiTransport","isSessionExpiredError")))}}]),t}(),O=r(187),P=r.n(O);function N(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return j(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return j(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r["return"]||r["return"]()}finally{if(c)throw i}}}}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var I="authenticated",C="authenticating",W="unauthenticated",F={Connected:"connected",Connecting:"connecting",Disconnected:"disconnected",Disconnecting:"disconnecting"},q="access_restricted_error",G="authentication_error",U="authentication_failed_error",B="error",K="session_expired_error",Y=function(){function t(e){var r=e.onEvent,n=e.realtimeTransport,o=e.wrapper;u(this,t),this._authenticationState=W,this._connectionState=F.Disconnected,this._onEvent=r,this._realtimeTransport=n,this._reconnectDelay=1e3,this._subscriptions=new Set,this._wrapper=o}return p(t,[{key:"disconnect",value:function(){[F.Disconnected,F.Disconnecting].includes(this._connectionState)||this._disconnect()}},{key:"getRealtimeTransport",value:function(){return this._realtimeTransport}},{key:"getWrapper",value:function(){return this._wrapper}},{key:"subscribe",value:function(t){var e=this,r=t.callbacks,n=t.isPrivate,o=void 0!==n&&n,i=t.subscriptionData,a=this.getRealtimeTransport(),c={callbacks:r,isPrivate:o,subscriptionData:i,isSubscribed:!1};return this._subscriptions.add(c),this._canSubscribe(o)&&this._subscribe(c),this._connectionState===F.Disconnected&&this._connect(),this._connectionState===F.Connected&&o&&this._authenticationState===W&&this._authenticate(),function(){c.isSubscribed&&a.unsubscribe({subscriptionData:i}),e._subscriptions["delete"](c)}}},{key:"_authenticate",value:function(){var t=this;this._authenticationState=C;var e=this.getRealtimeTransport();s(f().mark((function r(){var n;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,t.getWrapper().getAuthenticationData();case 3:n=r.sent,e.authenticate({authenticationData:n,onAuthentication:function(){return t._handleAuthentication()}}),r.next=10;break;case 7:r.prev=7,r.t0=r["catch"](0),t._onEvent(G,r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})))()}},{key:"_canSubscribe",value:function(t){return this._connectionState===F.Connected&&(!t||this._authenticationState===I)}},{key:"_connect",value:function(){var t=this;this._connectionState=F.Connecting,this.getRealtimeTransport().connect({onConnect:function(){return t._handleConnect()},onDisconnect:function(){return t._handleDisconnect()},onError:function(e){return t._handleError(e)}})}},{key:"_disconnect",value:function(){this._authenticationState=W,this._connectionState=F.Disconnecting,this.getRealtimeTransport().disconnect()}},{key:"_handleAuthentication",value:function(){var t=this;this._authenticationState=I,Array.from(this._subscriptions).filter((function(t){return t.isPrivate})).forEach((function(e){return t._subscribe(e)}))}},{key:"_handleConnect",value:function(){var t=this;this._connectionState=F.Connected;var e=Array.from(this._subscriptions);e.filter((function(t){return!t.isPrivate})).forEach((function(e){return t._subscribe(e)})),e.some((function(t){return t.isPrivate}))&&this._authenticate()}},{key:"_handleDisconnect",value:function(){var t=this,e=this._connectionState===F.Disconnecting;this._connectionState=F.Disconnected;var r,n=N(this._subscriptions);try{for(n.s();!(r=n.n()).done;){r.value.isSubscribed=!1}}catch(o){n.e(o)}finally{n.f()}e||this._subscriptions.size<1||(this._reconnectDelay<32e3&&(this._reconnectDelay*=2),setTimeout((function(){return t._connect()}),this._reconnectDelay))}},{key:"_handleError",value:function(t){var e=this.getRealtimeTransport();if(e.isSessionExpiredError(t))return this._onEvent(K,t),void this._authenticate();var r=this._authenticationState===C;r&&e.isAuthenticationFailedError(t)?this._onEvent(U,t):r||!e.isAccessRestrictedError(t)?this._onEvent(B,t):this._onEvent(q,t)}},{key:"_subscribe",value:function(t){var e=t.callbacks,r=t.subscriptionData;this.getRealtimeTransport().subscribe({callbacks:e,subscriptionData:r,onSubscribe:function(){t.isSubscribed=!0}})}}]),t}();function $(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=g(t);if(e){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m(this,r)}}var z=new Map,H=function(t){d(g,t);var e,r,n,i,c,l,h,v,m=$(g);function g(t){var e,r=t.authenticator,n=t.realtimeTransport,i=t.transport;if(u(this,g),!r)throw o(D,a(D.createParameterNotProvidedErrorArgs("authenticator","ApiWrapper","constructor")));if(!n)throw o(D,a(D.createParameterNotProvidedErrorArgs("realtimeTransport","ApiWrapper","constructor")));if(!i)throw o(D,a(D.createParameterNotProvidedErrorArgs("transport","ApiWrapper","constructor")));return(e=m.call(this))._authenticator=r,e._realtimeTransportWrapper=new Y({realtimeTransport:n,onEvent:function(){var t;return(t=e)._handleRealtimeTransportWrapperEvent.apply(t,arguments)},wrapper:y(e)}),e._transport=i,e}return p(g,[{key:"authenticate",value:(v=s(f().mark((function b(){var t,e,r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.getAuthenticator(),n.prev=1,n.next=4,this._getAuthenticationPromise();case 4:return e=n.sent,n.next=7,t.saveAuthenticationData(e);case 7:return n.abrupt("return",e);case 10:if(n.prev=10,n.t0=n["catch"](1),!this.getTransport().isAuthenticationFailedError(n.t0)){n.next=16;break}throw r=o(D,a(D.createAuthenticationFailedErrorArgs(n.t0,"ApiWrapper","authenticate"))),this.emit("error",r),r;case 16:throw this.emit("error",n.t0),n.t0;case 18:case"end":return n.stop()}}),b,this,[[1,10]])}))),function(){return v.apply(this,arguments)})},{key:"callMethod",value:(h=s(f().mark((function w(t){var e,r,n=arguments;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.length>1&&n[1]!==undefined?n[1]:null,r=n.length>2&&n[2]!==undefined&&n[2],o.next=4,this._callMethod({isPrivate:r,methodData:t,requestData:e});case 4:return o.abrupt("return",o.sent);case 5:case"end":return o.stop()}}),w,this)}))),function(t){return h.apply(this,arguments)})},{key:"create",value:(l=s(f().mark((function A(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getCreateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),A,this)}))),function(){return l.apply(this,arguments)})},{key:"delete",value:(c=s(f().mark((function _(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getDeleteMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),_,this)}))),function(){return c.apply(this,arguments)})},{key:"getAuthenticationData",value:(i=s(f().mark((function E(){var t,e;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.getAuthenticator(),r.next=3,t.loadAuthenticationData();case 3:if(e=r.sent){r.next=8;break}return r.next=7,this.authenticate();case 7:e=r.sent;case 8:return r.abrupt("return",e);case 9:case"end":return r.stop()}}),E,this)}))),function(){return i.apply(this,arguments)})},{key:"getAuthenticator",value:function(){return this._authenticator}},{key:"getRealtimeTransportWrapper",value:function(){return this._realtimeTransportWrapper}},{key:"getTransport",value:function(){return this._transport}},{key:"read",value:(n=s(f().mark((function x(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getReadMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),x,this)}))),function(){return n.apply(this,arguments)})},{key:"subscribe",value:function(t,e){var r=arguments.length>2&&arguments[2]!==undefined&&arguments[2];return this.getRealtimeTransportWrapper().subscribe({callbacks:e,isPrivate:r,subscriptionData:t})}},{key:"update",value:(r=s(f().mark((function k(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getUpdateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),k,this)}))),function(){return r.apply(this,arguments)})},{key:"_callMethod",value:(e=s(f().mark((function T(){var t,e,r,n,i,c,s,u,l,p,h,d,v=arguments;return f().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:if(t=v.length>0&&v[0]!==undefined?v[0]:{},e=t.isPrivate,r=void 0!==e&&e,n=t.isRetry,i=void 0!==n&&n,c=t.methodData,s=t.requestData,u=void 0===s?null:s,l=this.getTransport(),!r){f.next=8;break}return f.next=5,this.getAuthenticationData();case 5:f.t0=f.sent,f.next=9;break;case 8:f.t0=null;case 9:return p=f.t0,f.prev=10,f.next=13,l.callMethod({authenticationData:p,methodData:c,requestData:u,wrapper:this});case 13:return f.abrupt("return",f.sent);case 16:if(f.prev=16,f.t1=f["catch"](10),!l.isSessionExpiredError(f.t1)){f.next=28;break}if(h=o(D,a(D.createSessionExpiredErrorArgs(f.t1,"ApiWrapper","_callMethod"))),this.emit("error",h),!i){f.next=23;break}throw h;case 23:return f.next=25,this.authenticate(p);case 25:return f.next=27,this._callMethod({isPrivate:r,methodData:c,requestData:u,isRetry:!0});case 27:return f.abrupt("return",f.sent);case 28:if(!l.isAccessRestrictedError(f.t1)){f.next=32;break}throw d=o(D,a(D.createAccessRestrictedErrorArgs(f.t1,"ApiWrapper","_callMethod"))),this.emit("error",d),d;case 32:throw this.emit("error",f.t1),f.t1;case 34:case"end":return f.stop()}}),T,this,[[10,16]])}))),function(){return e.apply(this,arguments)})},{key:"_getAuthenticationPromise",value:function(){var t=this,e=this.getAuthenticator(),r=z.get(e);return r||(r=s(f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.loadAuthenticationData();case 2:return r=n.sent,n.next=5,e.authenticate(t,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n)})))(),z.set(e,r),s(f().mark((function o(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,r;case 3:return t.prev=3,z["delete"](e),t.finish(3);case 6:case"end":return t.stop()}}),o,null,[[0,,3,6]])})))(),r)}},{key:"_handleRealtimeTransportWrapperEvent",value:function(t,e){switch(t){case q:this.emit("error",o(D,a(D.createAccessRestrictedErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case G:this.emit("error",o(D,a(D.createRealtimeTransportErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case U:this.emit("error",o(D,a(D.createAuthenticationFailedErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case B:this.emit("error",o(D,a(D.createRealtimeTransportErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case K:this.emit("error",o(D,a(D.createSessionExpiredErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))))}}}]),g}(P())})(),n})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apiWrapper=e():t.apiWrapper=e()}(self,(function(){return(()=>{var t={757:(t,e,r)=>{t.exports=r(666)},187:t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function i(){i.init.call(this)}t.exports=i,t.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}v(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&v(t,"error",e,r)}(t,o,{once:!0})}))},i.EventEmitter=i,i.prototype._events=undefined,i.prototype._eventsCount=0,i.prototype._maxListeners=undefined;var a=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return t._maxListeners===undefined?i.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var o,i,a,u;if(c(r),(i=t._events)===undefined?(i=t._events=Object.create(null),t._eventsCount=0):(i.newListener!==undefined&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),a=i[e]),a===undefined)a=i[e]=r,++t._eventsCount;else if("function"==typeof a?a=i[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,r){var n={fired:!1,wrapFn:undefined,target:t,type:e,listener:r},o=l.bind(n);return o.listener=r,n.wrapFn=o,o}function f(t,e,r){var n=t._events;if(n===undefined)return[];var o=n[e];return o===undefined?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):d(o,o.length)}function h(t){var e=this._events;if(e!==undefined){var r=e[t];if("function"==typeof r)return 1;if(r!==undefined)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function v(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),i.init=function(){this._events!==undefined&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||undefined},i.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var o="error"===t,i=this._events;if(i!==undefined)o=o&&i.error===undefined;else if(!o)return!1;if(o){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var s=i[t];if(s===undefined)return!1;if("function"==typeof s)n(s,this,e);else{var u=s.length,l=d(s,u);for(r=0;r<u;++r)n(l[r],this,e)}return!0},i.prototype.addListener=function(t,e){return u(this,t,e,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(t,e){return u(this,t,e,!0)},i.prototype.once=function(t,e){return c(e),this.on(t,p(this,t,e)),this},i.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,p(this,t,e)),this},i.prototype.removeListener=function(t,e){var r,n,o,i,a;if(c(e),(n=this._events)===undefined)return this;if((r=n[t])===undefined)return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),n.removeListener!==undefined&&this.emit("removeListener",t,a||e)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(t){var e,r,n;if((r=this._events)===undefined)return this;if(r.removeListener===undefined)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):r[t]!==undefined&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e!==undefined)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},i.prototype.listeners=function(t){return f(this,t,!0)},i.prototype.rawListeners=function(t){return f(this,t,!1)},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):h.call(t,e)},i.prototype.listenerCount=h,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(M){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n=p;return function(o,i){if(n===h)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=k(a,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var s=l(t,e,r);if("normal"===s.type){if(n=r.done?d:f,s.arg===v)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,a),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",d="completed",v={};function y(){}function m(){}function g(){}var b={};b[i]=function(){return this};var w=Object.getPrototypeOf,_=w&&w(w(R([])));_&&_!==r&&n.call(_,i)&&(b=_);var A=g.prototype=y.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var s=l(t[o],t,i);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function k(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator["return"]&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function R(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:S}}function S(){return{value:e,done:!0}}return m.prototype=A.constructor=g,g.constructor=m,m.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(A),t},t.awrap=function(t){return{__await:t}},E(x.prototype),x.prototype[a]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(A),s(A,c,"Generator"),A[i]=function(){return this},A.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=R,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),D(r),v}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;D(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}},e={};function r(n){var o=e[n];if(o!==undefined)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t["default"]:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";function t(e,r){return(t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(e,r)}function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function o(r,n,i){return(o=e()?Reflect.construct:function(e,r,n){var o=[null];o.push.apply(o,r);var i=new(Function.bind.apply(e,o));return n&&t(i,n.prototype),i}).apply(null,arguments)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,s,"next",t)}function s(t){c(i,n,o,a,s,"throw",t)}a(undefined)}))}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),t}r.r(n),r.d(n,{ApiAuthenticator:()=>D,ApiError:()=>T,ApiRealtimeTransport:()=>L,ApiTransport:()=>R,ApiWrapper:()=>K});var f=r(757),h=r.n(f);function d(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&t(e,r)}function v(t){return(v="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)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){return!e||"object"!==v(e)&&"function"!=typeof e?y(t):e}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(e){var r="function"==typeof Map?new Map:undefined;return(b=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,i)}function i(){return o(e,arguments,g(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),t(i,e)})(e)}function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=g(t);if(e){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m(this,r)}}var _="api_wrapper/authentication_failed",A="api_wrapper/method_not_implemented",E="api_wrapper/parameter_not_provided",x="api_wrapper/realtime_transport",k="api_wrapper/unexpected",T=function(t){d(r,t);var e=w(r);function r(){var t,n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:k,o=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n,i=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return u(this,r),(t=e.call(this,o)).code=n,t.data=i,t}return p(r,null,[{key:"createAuthenticationFailedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[_,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Authentication failed"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createMethodNotImplementedErrorArgs",value:function(t,e){return[A,"[".concat(t,".").concat(e,"] Method not implemented: ").concat(e),{className:t,methodName:e}]}},{key:"createParameterNotProvidedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[E,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Parameter not provided: ").concat(t),{className:e,methodName:r,parameterName:t,place:n}]}},{key:"createRealtimeTransportErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[x,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Realtime transport error: ").concat(t.message),{className:e,methodName:r,originalError:t,place:n}]}}]),r}(b(Error)),D=function(){function t(){u(this,t)}var e,r,n;return p(t,[{key:"authenticate",value:(n=s(h().mark((function i(t,e){return h().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw console.log("[ApiAuthenticator.authenticate]","wrapper:",t),console.log("[ApiAuthenticator.authenticate]","previousAuthenticationData:",e),o(T,a(T.createMethodNotImplementedErrorArgs("ApiAuthenticator","authenticate")));case 3:case"end":return r.stop()}}),i)}))),function(t,e){return n.apply(this,arguments)})},{key:"loadAuthenticationData",value:(r=s(h().mark((function c(){return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiAuthenticator","loadAuthenticationData")));case 1:case"end":return t.stop()}}),c)}))),function(){return r.apply(this,arguments)})},{key:"saveAuthenticationData",value:(e=s(h().mark((function l(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw console.log("[ApiAuthenticator.saveAuthenticationData]","authenticationData:",t),o(T,a(T.createMethodNotImplementedErrorArgs("ApiAuthenticator","saveAuthenticationData")));case 2:case"end":return e.stop()}}),l)}))),function(t){return e.apply(this,arguments)})}]),t}(),L=function(){function t(){u(this,t)}return p(t,[{key:"authenticate",value:function(t){var e=t.authenticationData,r=t.onAuthentication;throw console.log("[ApiRealtimeTransport.authenticate]","authenticationData:",e),console.log("[ApiRealtimeTransport.authenticate]","onAuthentication:",r),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","authenticate")))}},{key:"connect",value:function(t){var e=t.onConnect,r=t.onDisconnect,n=t.onError;throw console.log("[ApiRealtimeTransport.connect]","onConnect:",e),console.log("[ApiRealtimeTransport.connect]","onDisconnect:",r),console.log("[ApiRealtimeTransport.connect]","onError:",n),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","connect")))}},{key:"disconnect",value:function(){throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","disconnect")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAuthenticationFailedError]","error:",t),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiRealtimeTransport.isSessionExpiredError]","error:",t),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isSessionExpiredError")))}},{key:"subscribe",value:function(t){var e=t.callbacks,r=t.onSubscribe,n=t.subscriptionData;throw console.log("[ApiRealtimeTransport.subscribe]","callbacks:",e),console.log("[ApiRealtimeTransport.subscribe]","onSubscribe:",r),console.log("[ApiRealtimeTransport.subscribe]","subscriptionData:",n),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","subscribe")))}},{key:"unsubscribe",value:function(t){var e=t.subscriptionData;throw console.log("[ApiRealtimeTransport.unsubscribe]","subscriptionData:",e),o(T,a(T.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","unsubscribe")))}}]),t}(),R=function(){function t(){u(this,t)}var e;return p(t,[{key:"callMethod",value:(e=s(h().mark((function r(t){var e,n,i,c;return h().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw e=t.authenticationData,n=t.methodData,i=t.requestData,c=t.wrapper,console.log("[ApiTransport.callMethod]","authenticationData:",e),console.log("[ApiTransport.callMethod]","methodData:",n),console.log("[ApiTransport.callMethod]","requestData:",i),console.log("[ApiTransport.callMethod]","wrapper:",c),o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","callMethod")));case 6:case"end":return r.stop()}}),r)}))),function(t){return e.apply(this,arguments)})},{key:"getCreateMethodData",value:function(){throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","getCreateMethodData")))}},{key:"getDeleteMethodData",value:function(){throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","getDeleteMethodData")))}},{key:"getReadMethodData",value:function(){throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","getReadMethodData")))}},{key:"getUpdateMethodData",value:function(){throw o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","getUpdateMethodData")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiTransport.isAuthenticationFailedError]","error:",t),o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiTransport.isSessionExpiredError]","error:",t),o(T,a(T.createMethodNotImplementedErrorArgs("ApiTransport","isSessionExpiredError")))}}]),t}(),S=r(187),M=r.n(S);function O(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return P(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r["return"]||r["return"]()}finally{if(c)throw i}}}}function P(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var j="authenticated",N="authenticating",C="unauthenticated",I={Connected:"connected",Connecting:"connecting",Disconnected:"disconnected",Disconnecting:"disconnecting"},F="authentication_error",W="authentication_failed_error",q="error",G=function(){function t(e){var r=e.onEvent,n=e.realtimeTransport,o=e.wrapper;u(this,t),this._authenticationState=C,this._connectionState=I.Disconnected,this._onEvent=r,this._realtimeTransport=n,this._reconnectDelay=1e3,this._subscriptions=new Set,this._wrapper=o}return p(t,[{key:"disconnect",value:function(){[I.Disconnected,I.Disconnecting].includes(this._connectionState)||this._disconnect()}},{key:"getRealtimeTransport",value:function(){return this._realtimeTransport}},{key:"getWrapper",value:function(){return this._wrapper}},{key:"subscribe",value:function(t){var e=this,r=t.callbacks,n=t.isPrivate,o=void 0!==n&&n,i=t.subscriptionData,a=this.getRealtimeTransport(),c={callbacks:r,isPrivate:o,subscriptionData:i,isSubscribed:!1};return this._subscriptions.add(c),this._canSubscribe(o)&&this._subscribe(c),this._connectionState===I.Disconnected&&this._connect(),this._connectionState===I.Connected&&o&&this._authenticationState===C&&this._authenticate(),function(){c.isSubscribed&&a.unsubscribe({subscriptionData:i}),e._subscriptions["delete"](c)}}},{key:"_authenticate",value:function(){var t=this;this._authenticationState=N;var e=this.getRealtimeTransport();s(h().mark((function r(){var n;return h().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,t.getWrapper().getAuthenticationData();case 3:n=r.sent,e.authenticate({authenticationData:n,onAuthentication:function(){return t._handleAuthentication()}}),r.next=10;break;case 7:r.prev=7,r.t0=r["catch"](0),t._onEvent(F,r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})))()}},{key:"_canSubscribe",value:function(t){return this._connectionState===I.Connected&&(!t||this._authenticationState===j)}},{key:"_connect",value:function(){var t=this;this._connectionState=I.Connecting,this.getRealtimeTransport().connect({onConnect:function(){return t._handleConnect()},onDisconnect:function(){return t._handleDisconnect()},onError:function(e){return t._handleError(e)}})}},{key:"_disconnect",value:function(){this._authenticationState=C,this._connectionState=I.Disconnecting,this.getRealtimeTransport().disconnect()}},{key:"_handleAuthentication",value:function(){var t=this;this._authenticationState=j,Array.from(this._subscriptions).filter((function(t){return t.isPrivate})).forEach((function(e){return t._subscribe(e)}))}},{key:"_handleConnect",value:function(){var t=this;this._connectionState=I.Connected;var e=Array.from(this._subscriptions);e.filter((function(t){return!t.isPrivate})).forEach((function(e){return t._subscribe(e)})),e.some((function(t){return t.isPrivate}))&&this._authenticate()}},{key:"_handleDisconnect",value:function(){var t=this,e=this._connectionState===I.Disconnecting;this._connectionState=I.Disconnected;var r,n=O(this._subscriptions);try{for(n.s();!(r=n.n()).done;){r.value.isSubscribed=!1}}catch(o){n.e(o)}finally{n.f()}e||this._subscriptions.size<1||(this._reconnectDelay<32e3&&(this._reconnectDelay*=2),setTimeout((function(){return t._connect()}),this._reconnectDelay))}},{key:"_handleError",value:function(t){var e=this.getRealtimeTransport();e.isSessionExpiredError(t)?this._authenticate():this._authenticationState===N&&e.isAuthenticationFailedError(t)?this._onEvent(W,t):this._onEvent(q,t)}},{key:"_subscribe",value:function(t){var e=t.callbacks,r=t.subscriptionData;this.getRealtimeTransport().subscribe({callbacks:e,subscriptionData:r,onSubscribe:function(){t.isSubscribed=!0}})}}]),t}();function U(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=g(t);if(e){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m(this,r)}}var B=new Map,K=function(t){d(g,t);var e,r,n,i,c,l,f,v,m=U(g);function g(t){var e,r=t.authenticator,n=t.realtimeTransport,i=t.transport;if(u(this,g),!r)throw o(T,a(T.createParameterNotProvidedErrorArgs("authenticator","ApiWrapper","constructor")));if(!n)throw o(T,a(T.createParameterNotProvidedErrorArgs("realtimeTransport","ApiWrapper","constructor")));if(!i)throw o(T,a(T.createParameterNotProvidedErrorArgs("transport","ApiWrapper","constructor")));return(e=m.call(this))._authenticator=r,e._realtimeTransportWrapper=new G({realtimeTransport:n,onEvent:function(){var t;return(t=e)._handleRealtimeTransportWrapperEvent.apply(t,arguments)},wrapper:y(e)}),e._transport=i,e}return p(g,[{key:"authenticate",value:(v=s(h().mark((function b(){var t,e,r;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.getAuthenticator(),n.prev=1,n.next=4,this._getAuthenticationPromise();case 4:return e=n.sent,n.next=7,t.saveAuthenticationData(e);case 7:return n.abrupt("return",e);case 10:if(n.prev=10,n.t0=n["catch"](1),!this.getTransport().isAuthenticationFailedError(n.t0)){n.next=16;break}throw r=o(T,a(T.createAuthenticationFailedErrorArgs(n.t0,"ApiWrapper","authenticate"))),this.emit("error",r),r;case 16:throw this.emit("error",n.t0),n.t0;case 18:case"end":return n.stop()}}),b,this,[[1,10]])}))),function(){return v.apply(this,arguments)})},{key:"callMethod",value:(f=s(h().mark((function w(t){var e,r,n=arguments;return h().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.length>1&&n[1]!==undefined?n[1]:null,r=n.length>2&&n[2]!==undefined&&n[2],o.next=4,this._callMethod({isPrivate:r,methodData:t,requestData:e});case 4:return o.abrupt("return",o.sent);case 5:case"end":return o.stop()}}),w,this)}))),function(t){return f.apply(this,arguments)})},{key:"create",value:(l=s(h().mark((function _(){var t,e,r=arguments;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getCreateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),_,this)}))),function(){return l.apply(this,arguments)})},{key:"delete",value:(c=s(h().mark((function A(){var t,e,r=arguments;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getDeleteMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),A,this)}))),function(){return c.apply(this,arguments)})},{key:"getAuthenticationData",value:(i=s(h().mark((function E(){var t,e;return h().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.getAuthenticator(),r.next=3,t.loadAuthenticationData();case 3:if(e=r.sent){r.next=8;break}return r.next=7,this.authenticate();case 7:e=r.sent;case 8:return r.abrupt("return",e);case 9:case"end":return r.stop()}}),E,this)}))),function(){return i.apply(this,arguments)})},{key:"getAuthenticator",value:function(){return this._authenticator}},{key:"getRealtimeTransportWrapper",value:function(){return this._realtimeTransportWrapper}},{key:"getTransport",value:function(){return this._transport}},{key:"read",value:(n=s(h().mark((function x(){var t,e,r=arguments;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getReadMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),x,this)}))),function(){return n.apply(this,arguments)})},{key:"subscribe",value:function(t,e){var r=arguments.length>2&&arguments[2]!==undefined&&arguments[2];return this.getRealtimeTransportWrapper().subscribe({callbacks:e,isPrivate:r,subscriptionData:t})}},{key:"update",value:(r=s(h().mark((function k(){var t,e,r=arguments;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getUpdateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),k,this)}))),function(){return r.apply(this,arguments)})},{key:"_callMethod",value:(e=s(h().mark((function D(){var t,e,r,n,o,i,a,c,s,u,l=arguments;return h().wrap((function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>0&&l[0]!==undefined?l[0]:{},e=t.isPrivate,r=void 0!==e&&e,n=t.isRetry,o=void 0!==n&&n,i=t.methodData,a=t.requestData,c=void 0===a?null:a,s=this.getTransport(),!r){p.next=8;break}return p.next=5,this.getAuthenticationData();case 5:p.t0=p.sent,p.next=9;break;case 8:p.t0=null;case 9:return u=p.t0,p.prev=10,p.next=13,s.callMethod({authenticationData:u,methodData:i,requestData:c,wrapper:this});case 13:return p.abrupt("return",p.sent);case 16:if(p.prev=16,p.t1=p["catch"](10),o||!s.isSessionExpiredError(p.t1)){p.next=24;break}return p.next=21,this.authenticate(u);case 21:return p.next=23,this._callMethod({isPrivate:r,methodData:i,requestData:c,isRetry:!0});case 23:return p.abrupt("return",p.sent);case 24:throw this.emit("error",p.t1),p.t1;case 26:case"end":return p.stop()}}),D,this,[[10,16]])}))),function(){return e.apply(this,arguments)})},{key:"_getAuthenticationPromise",value:function(){var t=this,e=this.getAuthenticator(),r=B.get(e);return r||(r=s(h().mark((function n(){var r;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.loadAuthenticationData();case 2:return r=n.sent,n.next=5,e.authenticate(t,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n)})))(),B.set(e,r),s(h().mark((function o(){return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,r;case 3:t.next=7;break;case 5:t.prev=5,t.t0=t["catch"](0);case 7:return t.prev=7,B["delete"](e),t.finish(7);case 10:case"end":return t.stop()}}),o,null,[[0,5,7,10]])})))(),r)}},{key:"_handleRealtimeTransportWrapperEvent",value:function(t,e){switch(t){case F:this.emit("error",o(T,a(T.createRealtimeTransportErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case W:this.emit("error",o(T,a(T.createAuthenticationFailedErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case q:this.emit("error",o(T,a(T.createRealtimeTransportErrorArgs(e,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))))}}}]),g}(M())})(),n})()}));
//# sourceMappingURL=index.browser.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apiWrapper=e():t.apiWrapper=e()}(global,(function(){return(()=>{var t={228:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n},t.exports["default"]=t.exports,t.exports.__esModule=!0},646:(t,e,r)=>{var n=r(228);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0},506:t=>{t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports["default"]=t.exports,t.exports.__esModule=!0},926:t=>{function e(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function c(t){e(i,o,a,c,s,"next",t)}function s(t){e(i,o,a,c,s,"throw",t)}c(undefined)}))}},t.exports["default"]=t.exports,t.exports.__esModule=!0},575:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports["default"]=t.exports,t.exports.__esModule=!0},100:(t,e,r)=>{var n=r(489),o=r(67);function a(e,r,i){return o()?(t.exports=a=Reflect.construct,t.exports["default"]=t.exports,t.exports.__esModule=!0):(t.exports=a=function(t,e,r){var o=[null];o.push.apply(o,e);var a=new(Function.bind.apply(t,o));return r&&n(a,r.prototype),a},t.exports["default"]=t.exports,t.exports.__esModule=!0),a.apply(null,arguments)}t.exports=a,t.exports["default"]=t.exports,t.exports.__esModule=!0},913:t=>{function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t},t.exports["default"]=t.exports,t.exports.__esModule=!0},754:t=>{function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0,e(r)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},205:(t,e,r)=>{var n=r(489);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)},t.exports["default"]=t.exports,t.exports.__esModule=!0},430:t=>{t.exports=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},t.exports["default"]=t.exports,t.exports.__esModule=!0},67:t=>{t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}},t.exports["default"]=t.exports,t.exports.__esModule=!0},860:t=>{t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0},206:t=>{t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports["default"]=t.exports,t.exports.__esModule=!0},585:(t,e,r)=>{var n=r(8)["default"],o=r(506);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?o(t):e},t.exports["default"]=t.exports,t.exports.__esModule=!0},489:t=>{function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports["default"]=t.exports,t.exports.__esModule=!0,e(r,n)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},319:(t,e,r)=>{var n=r(646),o=r(860),a=r(379),i=r(206);t.exports=function(t){return n(t)||o(t)||a(t)||i()},t.exports["default"]=t.exports,t.exports.__esModule=!0},8:t=>{function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=e=function(t){return typeof t},t.exports["default"]=t.exports,t.exports.__esModule=!0):(t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports["default"]=t.exports,t.exports.__esModule=!0),e(r)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},379:(t,e,r)=>{var n=r(228);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports["default"]=t.exports,t.exports.__esModule=!0},957:(t,e,r)=>{var n=r(754),o=r(489),a=r(430),i=r(100);function c(e){var r="function"==typeof Map?new Map:undefined;return t.exports=c=function(t){if(null===t||!a(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return i(t,arguments,n(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},t.exports["default"]=t.exports,t.exports.__esModule=!0,c(e)}t.exports=c,t.exports["default"]=t.exports,t.exports.__esModule=!0},757:(t,e,r)=>{t.exports=r(666)},666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(N){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,a=Object.create(o.prototype),i=new D(n||[]);return a._invoke=function(t,e,r){var n=l;return function(o,a){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw a;return S()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=k(i,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var s=p(t,e,r);if("normal"===s.type){if(n=r.done?d:h,s.arg===v)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,i),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(N){return{type:"throw",arg:N}}}t.wrap=u;var l="suspendedStart",h="suspendedYield",f="executing",d="completed",v={};function m(){}function y(){}function g(){}var x={};x[a]=function(){return this};var _=Object.getPrototypeOf,b=_&&_(_(R([])));b&&b!==r&&n.call(b,a)&&(x=b);var A=g.prototype=m.prototype=Object.create(x);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(o,a,i,c){var s=p(t[o],t,a);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){u.value=t,i(u)}),(function(t){return r("throw",t,i,c)}))}c(s.arg)}var o;this._invoke=function(t,n){function a(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(a,a):a()}}function k(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator["return"]&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=p(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function M(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function D(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(M,this),this.reset(!0)}function R(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:S}}function S(){return{value:e,done:!0}}return y.prototype=A.constructor=g,g.constructor=y,y.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(A),t},t.awrap=function(t){return{__await:t}},w(E.prototype),E.prototype[i]=function(){return this},t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},w(A),s(A,c,"Generator"),A[a]=function(){return this},A.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=R,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}},e={};function r(n){var o=e[n];if(o!==undefined)return o.exports;var a=e[n]={exports:{}};return t[n](a,a.exports,r),a.exports}r.n=t=>{var e=t&&t.__esModule?()=>t["default"]:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ApiAuthenticator:()=>S,ApiError:()=>R,ApiRealtimeTransport:()=>N,ApiTransport:()=>P,ApiWrapper:()=>V});var t=r(100),e=r.n(t),o=r(319),a=r.n(o),i=r(926),c=r.n(i),s=r(575),u=r.n(s),p=r(913),l=r.n(p),h=r(757),f=r.n(h),d=r(205),v=r.n(d),m=r(585),y=r.n(m),g=r(754),x=r.n(g),_=r(957);function b(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x()(t);if(e){var o=x()(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return y()(this,r)}}var A="api_wrapper/access_restricted",w="api_wrapper/authentication_failed",E="api_wrapper/method_not_implemented",k="api_wrapper/parameter_not_provided",M="api_wrapper/realtime_transport",T="api_wrapper/session_expired",D="api_wrapper/unexpected",R=function(t){v()(r,t);var e=b(r);function r(){var t,n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:D,o=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n,a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return u()(this,r),(t=e.call(this,o)).code=n,t.data=a,t}return l()(r,null,[{key:"createAccessRestrictedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[A,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Access restricted"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createAuthenticationFailedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[w,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Authentication failed"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createMethodNotImplementedErrorArgs",value:function(t,e){return[E,"[".concat(t,".").concat(e,"] Method not implemented: ").concat(e),{className:t,methodName:e}]}},{key:"createParameterNotProvidedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[k,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Parameter not provided: ").concat(t),{className:e,methodName:r,parameterName:t,place:n}]}},{key:"createRealtimeTransportErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[M,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Realtime transport error: ").concat(t.message),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createSessionExpiredErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[T,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Session expired"),{className:e,methodName:r,originalError:t,place:n}]}}]),r}(r.n(_)()(Error)),S=function(){function t(){u()(this,t)}var r,n,o;return l()(t,[{key:"authenticate",value:(o=c()(f().mark((function i(t,r){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:throw console.log("[ApiAuthenticator.authenticate]","wrapper:",t),console.log("[ApiAuthenticator.authenticate]","previousAuthenticationData:",r),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiAuthenticator","authenticate")));case 3:case"end":return n.stop()}}),i)}))),function(t,e){return o.apply(this,arguments)})},{key:"loadAuthenticationData",value:(n=c()(f().mark((function s(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiAuthenticator","loadAuthenticationData")));case 1:case"end":return t.stop()}}),s)}))),function(){return n.apply(this,arguments)})},{key:"saveAuthenticationData",value:(r=c()(f().mark((function p(t){return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw console.log("[ApiAuthenticator.saveAuthenticationData]","authenticationData:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiAuthenticator","saveAuthenticationData")));case 2:case"end":return r.stop()}}),p)}))),function(t){return r.apply(this,arguments)})}]),t}(),N=function(){function t(){u()(this,t)}return l()(t,[{key:"authenticate",value:function(t){var r=t.authenticationData,n=t.onAuthentication;throw console.log("[ApiRealtimeTransport.authenticate]","authenticationData:",r),console.log("[ApiRealtimeTransport.authenticate]","onAuthentication:",n),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","authenticate")))}},{key:"connect",value:function(t){var r=t.onConnect,n=t.onDisconnect,o=t.onError;throw console.log("[ApiRealtimeTransport.connect]","onConnect:",r),console.log("[ApiRealtimeTransport.connect]","onDisconnect:",n),console.log("[ApiRealtimeTransport.connect]","onError:",o),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","connect")))}},{key:"disconnect",value:function(){throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","disconnect")))}},{key:"isAccessRestrictedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAccessRestrictedError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAccessRestrictedError")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAuthenticationFailedError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiRealtimeTransport.isSessionExpiredError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isSessionExpiredError")))}},{key:"subscribe",value:function(t){var r=t.callbacks,n=t.onSubscribe,o=t.subscriptionData;throw console.log("[ApiRealtimeTransport.subscribe]","callbacks:",r),console.log("[ApiRealtimeTransport.subscribe]","onSubscribe:",n),console.log("[ApiRealtimeTransport.subscribe]","subscriptionData:",o),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","subscribe")))}},{key:"unsubscribe",value:function(t){var r=t.subscriptionData;throw console.log("[ApiRealtimeTransport.unsubscribe]","subscriptionData:",r),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","unsubscribe")))}}]),t}(),P=function(){function t(){u()(this,t)}var r;return l()(t,[{key:"callMethod",value:(r=c()(f().mark((function n(t){var r,o,i,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:throw r=t.authenticationData,o=t.methodData,i=t.requestData,c=t.wrapper,console.log("[ApiTransport.callMethod]","authenticationData:",r),console.log("[ApiTransport.callMethod]","methodData:",o),console.log("[ApiTransport.callMethod]","requestData:",i),console.log("[ApiTransport.callMethod]","wrapper:",c),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","callMethod")));case 6:case"end":return n.stop()}}),n)}))),function(t){return r.apply(this,arguments)})},{key:"getCreateMethodData",value:function(){throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","getCreateMethodData")))}},{key:"getDeleteMethodData",value:function(){throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","getDeleteMethodData")))}},{key:"getReadMethodData",value:function(){throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","getReadMethodData")))}},{key:"getUpdateMethodData",value:function(){throw e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","getUpdateMethodData")))}},{key:"isAccessRestrictedError",value:function(t){throw console.log("[ApiTransport.isAccessRestrictedError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","isAccessRestrictedError")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiTransport.isAuthenticationFailedError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiTransport.isSessionExpiredError]","error:",t),e()(R,a()(R.createMethodNotImplementedErrorArgs("ApiTransport","isSessionExpiredError")))}}]),t}(),O=r(506),j=r.n(O);const I=require("events");var L=r.n(I);function W(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r["return"]||r["return"]()}finally{if(c)throw a}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var C="authenticated",q="authenticating",G="unauthenticated",B={Connected:"connected",Connecting:"connecting",Disconnected:"disconnected",Disconnecting:"disconnecting"},U="access_restricted_error",Y="authentication_error",$="authentication_failed_error",z="error",H="session_expired_error",J=function(){function t(e){var r=e.onEvent,n=e.realtimeTransport,o=e.wrapper;u()(this,t),this._authenticationState=G,this._connectionState=B.Disconnected,this._onEvent=r,this._realtimeTransport=n,this._reconnectDelay=1e3,this._subscriptions=new Set,this._wrapper=o}return l()(t,[{key:"disconnect",value:function(){[B.Disconnected,B.Disconnecting].includes(this._connectionState)||this._disconnect()}},{key:"getRealtimeTransport",value:function(){return this._realtimeTransport}},{key:"getWrapper",value:function(){return this._wrapper}},{key:"subscribe",value:function(t){var e=this,r=t.callbacks,n=t.isPrivate,o=void 0!==n&&n,a=t.subscriptionData,i=this.getRealtimeTransport(),c={callbacks:r,isPrivate:o,subscriptionData:a,isSubscribed:!1};return this._subscriptions.add(c),this._canSubscribe(o)&&this._subscribe(c),this._connectionState===B.Disconnected&&this._connect(),this._connectionState===B.Connected&&o&&this._authenticationState===G&&this._authenticate(),function(){c.isSubscribed&&i.unsubscribe({subscriptionData:a}),e._subscriptions["delete"](c)}}},{key:"_authenticate",value:function(){var t=this;this._authenticationState=q;var e=this.getRealtimeTransport();c()(f().mark((function r(){var n;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,t.getWrapper().getAuthenticationData();case 3:n=r.sent,e.authenticate({authenticationData:n,onAuthentication:function(){return t._handleAuthentication()}}),r.next=10;break;case 7:r.prev=7,r.t0=r["catch"](0),t._onEvent(Y,r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})))()}},{key:"_canSubscribe",value:function(t){return this._connectionState===B.Connected&&(!t||this._authenticationState===C)}},{key:"_connect",value:function(){var t=this;this._connectionState=B.Connecting,this.getRealtimeTransport().connect({onConnect:function(){return t._handleConnect()},onDisconnect:function(){return t._handleDisconnect()},onError:function(e){return t._handleError(e)}})}},{key:"_disconnect",value:function(){this._authenticationState=G,this._connectionState=B.Disconnecting,this.getRealtimeTransport().disconnect()}},{key:"_handleAuthentication",value:function(){var t=this;this._authenticationState=C,Array.from(this._subscriptions).filter((function(t){return t.isPrivate})).forEach((function(e){return t._subscribe(e)}))}},{key:"_handleConnect",value:function(){var t=this;this._connectionState=B.Connected;var e=Array.from(this._subscriptions);e.filter((function(t){return!t.isPrivate})).forEach((function(e){return t._subscribe(e)})),e.some((function(t){return t.isPrivate}))&&this._authenticate()}},{key:"_handleDisconnect",value:function(){var t=this,e=this._connectionState===B.Disconnecting;this._connectionState=B.Disconnected;var r,n=W(this._subscriptions);try{for(n.s();!(r=n.n()).done;){r.value.isSubscribed=!1}}catch(o){n.e(o)}finally{n.f()}e||this._subscriptions.size<1||(this._reconnectDelay<32e3&&(this._reconnectDelay*=2),setTimeout((function(){return t._connect()}),this._reconnectDelay))}},{key:"_handleError",value:function(t){var e=this.getRealtimeTransport();if(e.isSessionExpiredError(t))return this._onEvent(H,t),void this._authenticate();var r=this._authenticationState===q;r&&e.isAuthenticationFailedError(t)?this._onEvent($,t):r||!e.isAccessRestrictedError(t)?this._onEvent(z,t):this._onEvent(U,t)}},{key:"_subscribe",value:function(t){var e=t.callbacks,r=t.subscriptionData;this.getRealtimeTransport().subscribe({callbacks:e,subscriptionData:r,onSubscribe:function(){t.isSubscribed=!0}})}}]),t}();function K(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x()(t);if(e){var o=x()(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return y()(this,r)}}var Q=new Map,V=function(t){v()(y,t);var r,n,o,i,s,p,h,d,m=K(y);function y(t){var r,n=t.authenticator,o=t.realtimeTransport,i=t.transport;if(u()(this,y),!n)throw e()(R,a()(R.createParameterNotProvidedErrorArgs("authenticator","ApiWrapper","constructor")));if(!o)throw e()(R,a()(R.createParameterNotProvidedErrorArgs("realtimeTransport","ApiWrapper","constructor")));if(!i)throw e()(R,a()(R.createParameterNotProvidedErrorArgs("transport","ApiWrapper","constructor")));return(r=m.call(this))._authenticator=n,r._realtimeTransportWrapper=new J({realtimeTransport:o,onEvent:function(){var t;return(t=r)._handleRealtimeTransportWrapperEvent.apply(t,arguments)},wrapper:j()(r)}),r._transport=i,r}return l()(y,[{key:"authenticate",value:(d=c()(f().mark((function g(){var t,r,n;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return t=this.getAuthenticator(),o.prev=1,o.next=4,this._getAuthenticationPromise();case 4:return r=o.sent,o.next=7,t.saveAuthenticationData(r);case 7:return o.abrupt("return",r);case 10:if(o.prev=10,o.t0=o["catch"](1),!this.getTransport().isAuthenticationFailedError(o.t0)){o.next=16;break}throw n=e()(R,a()(R.createAuthenticationFailedErrorArgs(o.t0,"ApiWrapper","authenticate"))),this.emit("error",n),n;case 16:throw this.emit("error",o.t0),o.t0;case 18:case"end":return o.stop()}}),g,this,[[1,10]])}))),function(){return d.apply(this,arguments)})},{key:"callMethod",value:(h=c()(f().mark((function x(t){var e,r,n=arguments;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.length>1&&n[1]!==undefined?n[1]:null,r=n.length>2&&n[2]!==undefined&&n[2],o.next=4,this._callMethod({isPrivate:r,methodData:t,requestData:e});case 4:return o.abrupt("return",o.sent);case 5:case"end":return o.stop()}}),x,this)}))),function(t){return h.apply(this,arguments)})},{key:"create",value:(p=c()(f().mark((function _(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getCreateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),_,this)}))),function(){return p.apply(this,arguments)})},{key:"delete",value:(s=c()(f().mark((function b(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getDeleteMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),b,this)}))),function(){return s.apply(this,arguments)})},{key:"getAuthenticationData",value:(i=c()(f().mark((function A(){var t,e;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.getAuthenticator(),r.next=3,t.loadAuthenticationData();case 3:if(e=r.sent){r.next=8;break}return r.next=7,this.authenticate();case 7:e=r.sent;case 8:return r.abrupt("return",e);case 9:case"end":return r.stop()}}),A,this)}))),function(){return i.apply(this,arguments)})},{key:"getAuthenticator",value:function(){return this._authenticator}},{key:"getRealtimeTransportWrapper",value:function(){return this._realtimeTransportWrapper}},{key:"getTransport",value:function(){return this._transport}},{key:"read",value:(o=c()(f().mark((function w(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getReadMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),w,this)}))),function(){return o.apply(this,arguments)})},{key:"subscribe",value:function(t,e){var r=arguments.length>2&&arguments[2]!==undefined&&arguments[2];return this.getRealtimeTransportWrapper().subscribe({callbacks:e,isPrivate:r,subscriptionData:t})}},{key:"update",value:(n=c()(f().mark((function E(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getUpdateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),E,this)}))),function(){return n.apply(this,arguments)})},{key:"_callMethod",value:(r=c()(f().mark((function k(){var t,r,n,o,i,c,s,u,p,l,h,d,v=arguments;return f().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:if(t=v.length>0&&v[0]!==undefined?v[0]:{},r=t.isPrivate,n=void 0!==r&&r,o=t.isRetry,i=void 0!==o&&o,c=t.methodData,s=t.requestData,u=void 0===s?null:s,p=this.getTransport(),!n){f.next=8;break}return f.next=5,this.getAuthenticationData();case 5:f.t0=f.sent,f.next=9;break;case 8:f.t0=null;case 9:return l=f.t0,f.prev=10,f.next=13,p.callMethod({authenticationData:l,methodData:c,requestData:u,wrapper:this});case 13:return f.abrupt("return",f.sent);case 16:if(f.prev=16,f.t1=f["catch"](10),!p.isSessionExpiredError(f.t1)){f.next=28;break}if(h=e()(R,a()(R.createSessionExpiredErrorArgs(f.t1,"ApiWrapper","_callMethod"))),this.emit("error",h),!i){f.next=23;break}throw h;case 23:return f.next=25,this.authenticate(l);case 25:return f.next=27,this._callMethod({isPrivate:n,methodData:c,requestData:u,isRetry:!0});case 27:return f.abrupt("return",f.sent);case 28:if(!p.isAccessRestrictedError(f.t1)){f.next=32;break}throw d=e()(R,a()(R.createAccessRestrictedErrorArgs(f.t1,"ApiWrapper","_callMethod"))),this.emit("error",d),d;case 32:throw this.emit("error",f.t1),f.t1;case 34:case"end":return f.stop()}}),k,this,[[10,16]])}))),function(){return r.apply(this,arguments)})},{key:"_getAuthenticationPromise",value:function(){var t=this,e=this.getAuthenticator(),r=Q.get(e);return r||(r=c()(f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.loadAuthenticationData();case 2:return r=n.sent,n.next=5,e.authenticate(t,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n)})))(),Q.set(e,r),c()(f().mark((function o(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,r;case 3:return t.prev=3,Q["delete"](e),t.finish(3);case 6:case"end":return t.stop()}}),o,null,[[0,,3,6]])})))(),r)}},{key:"_handleRealtimeTransportWrapperEvent",value:function(t,r){switch(t){case U:this.emit("error",e()(R,a()(R.createAccessRestrictedErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case Y:this.emit("error",e()(R,a()(R.createRealtimeTransportErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case $:this.emit("error",e()(R,a()(R.createAuthenticationFailedErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case z:this.emit("error",e()(R,a()(R.createRealtimeTransportErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case H:this.emit("error",e()(R,a()(R.createSessionExpiredErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))))}}}]),y}(L())})(),n})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apiWrapper=e():t.apiWrapper=e()}(global,(function(){return(()=>{var t={228:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n},t.exports["default"]=t.exports,t.exports.__esModule=!0},646:(t,e,r)=>{var n=r(228);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0},506:t=>{t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports["default"]=t.exports,t.exports.__esModule=!0},926:t=>{function e(t,e,r,n,o,a,i){try{var c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function c(t){e(i,o,a,c,s,"next",t)}function s(t){e(i,o,a,c,s,"throw",t)}c(undefined)}))}},t.exports["default"]=t.exports,t.exports.__esModule=!0},575:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports["default"]=t.exports,t.exports.__esModule=!0},100:(t,e,r)=>{var n=r(489),o=r(67);function a(e,r,i){return o()?(t.exports=a=Reflect.construct,t.exports["default"]=t.exports,t.exports.__esModule=!0):(t.exports=a=function(t,e,r){var o=[null];o.push.apply(o,e);var a=new(Function.bind.apply(t,o));return r&&n(a,r.prototype),a},t.exports["default"]=t.exports,t.exports.__esModule=!0),a.apply(null,arguments)}t.exports=a,t.exports["default"]=t.exports,t.exports.__esModule=!0},913:t=>{function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t},t.exports["default"]=t.exports,t.exports.__esModule=!0},754:t=>{function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0,e(r)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},205:(t,e,r)=>{var n=r(489);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)},t.exports["default"]=t.exports,t.exports.__esModule=!0},430:t=>{t.exports=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},t.exports["default"]=t.exports,t.exports.__esModule=!0},67:t=>{t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}},t.exports["default"]=t.exports,t.exports.__esModule=!0},860:t=>{t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)},t.exports["default"]=t.exports,t.exports.__esModule=!0},206:t=>{t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports["default"]=t.exports,t.exports.__esModule=!0},585:(t,e,r)=>{var n=r(8)["default"],o=r(506);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?o(t):e},t.exports["default"]=t.exports,t.exports.__esModule=!0},489:t=>{function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports["default"]=t.exports,t.exports.__esModule=!0,e(r,n)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},319:(t,e,r)=>{var n=r(646),o=r(860),a=r(379),i=r(206);t.exports=function(t){return n(t)||o(t)||a(t)||i()},t.exports["default"]=t.exports,t.exports.__esModule=!0},8:t=>{function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=e=function(t){return typeof t},t.exports["default"]=t.exports,t.exports.__esModule=!0):(t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports["default"]=t.exports,t.exports.__esModule=!0),e(r)}t.exports=e,t.exports["default"]=t.exports,t.exports.__esModule=!0},379:(t,e,r)=>{var n=r(228);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports["default"]=t.exports,t.exports.__esModule=!0},957:(t,e,r)=>{var n=r(754),o=r(489),a=r(430),i=r(100);function c(e){var r="function"==typeof Map?new Map:undefined;return t.exports=c=function(t){if(null===t||!a(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return i(t,arguments,n(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},t.exports["default"]=t.exports,t.exports.__esModule=!0,c(e)}t.exports=c,t.exports["default"]=t.exports,t.exports.__esModule=!0},757:(t,e,r)=>{t.exports=r(666)},666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(P){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),i=new T(n||[]);return a._invoke=function(t,e,r){var n=l;return function(o,a){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw a;return R()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=k(i,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var s=p(t,e,r);if("normal"===s.type){if(n=r.done?d:h,s.arg===v)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,i),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(P){return{type:"throw",arg:P}}}t.wrap=u;var l="suspendedStart",h="suspendedYield",f="executing",d="completed",v={};function y(){}function m(){}function g(){}var x={};x[a]=function(){return this};var b=Object.getPrototypeOf,_=b&&b(b(S([])));_&&_!==r&&n.call(_,a)&&(x=_);var w=g.prototype=y.prototype=Object.create(x);function A(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(o,a,i,c){var s=p(t[o],t,a);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){u.value=t,i(u)}),(function(t){return r("throw",t,i,c)}))}c(s.arg)}var o;this._invoke=function(t,n){function a(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(a,a):a()}}function k(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator["return"]&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=p(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function D(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(D,this),this.reset(!0)}function S(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:R}}function R(){return{value:e,done:!0}}return m.prototype=w.constructor=g,g.constructor=m,m.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},A(E.prototype),E.prototype[i]=function(){return this},t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},A(w),s(w,c,"Generator"),w[a]=function(){return this},w.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=S,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),v}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;M(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}},e={};function r(n){var o=e[n];if(o!==undefined)return o.exports;var a=e[n]={exports:{}};return t[n](a,a.exports,r),a.exports}r.n=t=>{var e=t&&t.__esModule?()=>t["default"]:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{ApiAuthenticator:()=>T,ApiError:()=>M,ApiRealtimeTransport:()=>S,ApiTransport:()=>R,ApiWrapper:()=>H});var t=r(100),e=r.n(t),o=r(319),a=r.n(o),i=r(926),c=r.n(i),s=r(575),u=r.n(s),p=r(913),l=r.n(p),h=r(757),f=r.n(h),d=r(205),v=r.n(d),y=r(585),m=r.n(y),g=r(754),x=r.n(g),b=r(957);function _(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x()(t);if(e){var o=x()(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m()(this,r)}}var w="api_wrapper/authentication_failed",A="api_wrapper/method_not_implemented",E="api_wrapper/parameter_not_provided",k="api_wrapper/realtime_transport",D="api_wrapper/unexpected",M=function(t){v()(r,t);var e=_(r);function r(){var t,n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:D,o=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n,a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return u()(this,r),(t=e.call(this,o)).code=n,t.data=a,t}return l()(r,null,[{key:"createAuthenticationFailedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[w,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Authentication failed"),{className:e,methodName:r,originalError:t,place:n}]}},{key:"createMethodNotImplementedErrorArgs",value:function(t,e){return[A,"[".concat(t,".").concat(e,"] Method not implemented: ").concat(e),{className:t,methodName:e}]}},{key:"createParameterNotProvidedErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[E,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Parameter not provided: ").concat(t),{className:e,methodName:r,parameterName:t,place:n}]}},{key:"createRealtimeTransportErrorArgs",value:function(t,e,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return[k,"[".concat(e,".").concat(r).concat(n?"::".concat(n):"","] Realtime transport error: ").concat(t.message),{className:e,methodName:r,originalError:t,place:n}]}}]),r}(r.n(b)()(Error)),T=function(){function t(){u()(this,t)}var r,n,o;return l()(t,[{key:"authenticate",value:(o=c()(f().mark((function i(t,r){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:throw console.log("[ApiAuthenticator.authenticate]","wrapper:",t),console.log("[ApiAuthenticator.authenticate]","previousAuthenticationData:",r),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiAuthenticator","authenticate")));case 3:case"end":return n.stop()}}),i)}))),function(t,e){return o.apply(this,arguments)})},{key:"loadAuthenticationData",value:(n=c()(f().mark((function s(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiAuthenticator","loadAuthenticationData")));case 1:case"end":return t.stop()}}),s)}))),function(){return n.apply(this,arguments)})},{key:"saveAuthenticationData",value:(r=c()(f().mark((function p(t){return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:throw console.log("[ApiAuthenticator.saveAuthenticationData]","authenticationData:",t),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiAuthenticator","saveAuthenticationData")));case 2:case"end":return r.stop()}}),p)}))),function(t){return r.apply(this,arguments)})}]),t}(),S=function(){function t(){u()(this,t)}return l()(t,[{key:"authenticate",value:function(t){var r=t.authenticationData,n=t.onAuthentication;throw console.log("[ApiRealtimeTransport.authenticate]","authenticationData:",r),console.log("[ApiRealtimeTransport.authenticate]","onAuthentication:",n),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","authenticate")))}},{key:"connect",value:function(t){var r=t.onConnect,n=t.onDisconnect,o=t.onError;throw console.log("[ApiRealtimeTransport.connect]","onConnect:",r),console.log("[ApiRealtimeTransport.connect]","onDisconnect:",n),console.log("[ApiRealtimeTransport.connect]","onError:",o),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","connect")))}},{key:"disconnect",value:function(){throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","disconnect")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiRealtimeTransport.isAuthenticationFailedError]","error:",t),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiRealtimeTransport.isSessionExpiredError]","error:",t),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","isSessionExpiredError")))}},{key:"subscribe",value:function(t){var r=t.callbacks,n=t.onSubscribe,o=t.subscriptionData;throw console.log("[ApiRealtimeTransport.subscribe]","callbacks:",r),console.log("[ApiRealtimeTransport.subscribe]","onSubscribe:",n),console.log("[ApiRealtimeTransport.subscribe]","subscriptionData:",o),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","subscribe")))}},{key:"unsubscribe",value:function(t){var r=t.subscriptionData;throw console.log("[ApiRealtimeTransport.unsubscribe]","subscriptionData:",r),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiRealtimeTransport","unsubscribe")))}}]),t}(),R=function(){function t(){u()(this,t)}var r;return l()(t,[{key:"callMethod",value:(r=c()(f().mark((function n(t){var r,o,i,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:throw r=t.authenticationData,o=t.methodData,i=t.requestData,c=t.wrapper,console.log("[ApiTransport.callMethod]","authenticationData:",r),console.log("[ApiTransport.callMethod]","methodData:",o),console.log("[ApiTransport.callMethod]","requestData:",i),console.log("[ApiTransport.callMethod]","wrapper:",c),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","callMethod")));case 6:case"end":return n.stop()}}),n)}))),function(t){return r.apply(this,arguments)})},{key:"getCreateMethodData",value:function(){throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","getCreateMethodData")))}},{key:"getDeleteMethodData",value:function(){throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","getDeleteMethodData")))}},{key:"getReadMethodData",value:function(){throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","getReadMethodData")))}},{key:"getUpdateMethodData",value:function(){throw e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","getUpdateMethodData")))}},{key:"isAuthenticationFailedError",value:function(t){throw console.log("[ApiTransport.isAuthenticationFailedError]","error:",t),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","isAuthenticationFailedError")))}},{key:"isSessionExpiredError",value:function(t){throw console.log("[ApiTransport.isSessionExpiredError]","error:",t),e()(M,a()(M.createMethodNotImplementedErrorArgs("ApiTransport","isSessionExpiredError")))}}]),t}(),P=r(506),N=r.n(P);const O=require("events");var j=r.n(O);function L(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return I(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return I(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r["return"]||r["return"]()}finally{if(c)throw a}}}}function I(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var W="authenticated",F="authenticating",C="unauthenticated",q={Connected:"connected",Connecting:"connecting",Disconnected:"disconnected",Disconnecting:"disconnecting"},G="authentication_error",B="authentication_failed_error",U="error",Y=function(){function t(e){var r=e.onEvent,n=e.realtimeTransport,o=e.wrapper;u()(this,t),this._authenticationState=C,this._connectionState=q.Disconnected,this._onEvent=r,this._realtimeTransport=n,this._reconnectDelay=1e3,this._subscriptions=new Set,this._wrapper=o}return l()(t,[{key:"disconnect",value:function(){[q.Disconnected,q.Disconnecting].includes(this._connectionState)||this._disconnect()}},{key:"getRealtimeTransport",value:function(){return this._realtimeTransport}},{key:"getWrapper",value:function(){return this._wrapper}},{key:"subscribe",value:function(t){var e=this,r=t.callbacks,n=t.isPrivate,o=void 0!==n&&n,a=t.subscriptionData,i=this.getRealtimeTransport(),c={callbacks:r,isPrivate:o,subscriptionData:a,isSubscribed:!1};return this._subscriptions.add(c),this._canSubscribe(o)&&this._subscribe(c),this._connectionState===q.Disconnected&&this._connect(),this._connectionState===q.Connected&&o&&this._authenticationState===C&&this._authenticate(),function(){c.isSubscribed&&i.unsubscribe({subscriptionData:a}),e._subscriptions["delete"](c)}}},{key:"_authenticate",value:function(){var t=this;this._authenticationState=F;var e=this.getRealtimeTransport();c()(f().mark((function r(){var n;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,t.getWrapper().getAuthenticationData();case 3:n=r.sent,e.authenticate({authenticationData:n,onAuthentication:function(){return t._handleAuthentication()}}),r.next=10;break;case 7:r.prev=7,r.t0=r["catch"](0),t._onEvent(G,r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})))()}},{key:"_canSubscribe",value:function(t){return this._connectionState===q.Connected&&(!t||this._authenticationState===W)}},{key:"_connect",value:function(){var t=this;this._connectionState=q.Connecting,this.getRealtimeTransport().connect({onConnect:function(){return t._handleConnect()},onDisconnect:function(){return t._handleDisconnect()},onError:function(e){return t._handleError(e)}})}},{key:"_disconnect",value:function(){this._authenticationState=C,this._connectionState=q.Disconnecting,this.getRealtimeTransport().disconnect()}},{key:"_handleAuthentication",value:function(){var t=this;this._authenticationState=W,Array.from(this._subscriptions).filter((function(t){return t.isPrivate})).forEach((function(e){return t._subscribe(e)}))}},{key:"_handleConnect",value:function(){var t=this;this._connectionState=q.Connected;var e=Array.from(this._subscriptions);e.filter((function(t){return!t.isPrivate})).forEach((function(e){return t._subscribe(e)})),e.some((function(t){return t.isPrivate}))&&this._authenticate()}},{key:"_handleDisconnect",value:function(){var t=this,e=this._connectionState===q.Disconnecting;this._connectionState=q.Disconnected;var r,n=L(this._subscriptions);try{for(n.s();!(r=n.n()).done;){r.value.isSubscribed=!1}}catch(o){n.e(o)}finally{n.f()}e||this._subscriptions.size<1||(this._reconnectDelay<32e3&&(this._reconnectDelay*=2),setTimeout((function(){return t._connect()}),this._reconnectDelay))}},{key:"_handleError",value:function(t){var e=this.getRealtimeTransport();e.isSessionExpiredError(t)?this._authenticate():this._authenticationState===F&&e.isAuthenticationFailedError(t)?this._onEvent(B,t):this._onEvent(U,t)}},{key:"_subscribe",value:function(t){var e=t.callbacks,r=t.subscriptionData;this.getRealtimeTransport().subscribe({callbacks:e,subscriptionData:r,onSubscribe:function(){t.isSubscribed=!0}})}}]),t}();function $(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x()(t);if(e){var o=x()(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m()(this,r)}}var z=new Map,H=function(t){v()(m,t);var r,n,o,i,s,p,h,d,y=$(m);function m(t){var r,n=t.authenticator,o=t.realtimeTransport,i=t.transport;if(u()(this,m),!n)throw e()(M,a()(M.createParameterNotProvidedErrorArgs("authenticator","ApiWrapper","constructor")));if(!o)throw e()(M,a()(M.createParameterNotProvidedErrorArgs("realtimeTransport","ApiWrapper","constructor")));if(!i)throw e()(M,a()(M.createParameterNotProvidedErrorArgs("transport","ApiWrapper","constructor")));return(r=y.call(this))._authenticator=n,r._realtimeTransportWrapper=new Y({realtimeTransport:o,onEvent:function(){var t;return(t=r)._handleRealtimeTransportWrapperEvent.apply(t,arguments)},wrapper:N()(r)}),r._transport=i,r}return l()(m,[{key:"authenticate",value:(d=c()(f().mark((function g(){var t,r,n;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return t=this.getAuthenticator(),o.prev=1,o.next=4,this._getAuthenticationPromise();case 4:return r=o.sent,o.next=7,t.saveAuthenticationData(r);case 7:return o.abrupt("return",r);case 10:if(o.prev=10,o.t0=o["catch"](1),!this.getTransport().isAuthenticationFailedError(o.t0)){o.next=16;break}throw n=e()(M,a()(M.createAuthenticationFailedErrorArgs(o.t0,"ApiWrapper","authenticate"))),this.emit("error",n),n;case 16:throw this.emit("error",o.t0),o.t0;case 18:case"end":return o.stop()}}),g,this,[[1,10]])}))),function(){return d.apply(this,arguments)})},{key:"callMethod",value:(h=c()(f().mark((function x(t){var e,r,n=arguments;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.length>1&&n[1]!==undefined?n[1]:null,r=n.length>2&&n[2]!==undefined&&n[2],o.next=4,this._callMethod({isPrivate:r,methodData:t,requestData:e});case 4:return o.abrupt("return",o.sent);case 5:case"end":return o.stop()}}),x,this)}))),function(t){return h.apply(this,arguments)})},{key:"create",value:(p=c()(f().mark((function b(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getCreateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),b,this)}))),function(){return p.apply(this,arguments)})},{key:"delete",value:(s=c()(f().mark((function _(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getDeleteMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),_,this)}))),function(){return s.apply(this,arguments)})},{key:"getAuthenticationData",value:(i=c()(f().mark((function w(){var t,e;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.getAuthenticator(),r.next=3,t.loadAuthenticationData();case 3:if(e=r.sent){r.next=8;break}return r.next=7,this.authenticate();case 7:e=r.sent;case 8:return r.abrupt("return",e);case 9:case"end":return r.stop()}}),w,this)}))),function(){return i.apply(this,arguments)})},{key:"getAuthenticator",value:function(){return this._authenticator}},{key:"getRealtimeTransportWrapper",value:function(){return this._realtimeTransportWrapper}},{key:"getTransport",value:function(){return this._transport}},{key:"read",value:(o=c()(f().mark((function A(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getReadMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),A,this)}))),function(){return o.apply(this,arguments)})},{key:"subscribe",value:function(t,e){var r=arguments.length>2&&arguments[2]!==undefined&&arguments[2];return this.getRealtimeTransportWrapper().subscribe({callbacks:e,isPrivate:r,subscriptionData:t})}},{key:"update",value:(n=c()(f().mark((function E(){var t,e,r=arguments;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=r.length>0&&r[0]!==undefined?r[0]:null,e=r.length>1&&r[1]!==undefined&&r[1],n.next=4,this._callMethod({isPrivate:e,requestData:t,methodData:this.getTransport().getUpdateMethodData()});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),E,this)}))),function(){return n.apply(this,arguments)})},{key:"_callMethod",value:(r=c()(f().mark((function k(){var t,e,r,n,o,a,i,c,s,u,p=arguments;return f().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:if(t=p.length>0&&p[0]!==undefined?p[0]:{},e=t.isPrivate,r=void 0!==e&&e,n=t.isRetry,o=void 0!==n&&n,a=t.methodData,i=t.requestData,c=void 0===i?null:i,s=this.getTransport(),!r){l.next=8;break}return l.next=5,this.getAuthenticationData();case 5:l.t0=l.sent,l.next=9;break;case 8:l.t0=null;case 9:return u=l.t0,l.prev=10,l.next=13,s.callMethod({authenticationData:u,methodData:a,requestData:c,wrapper:this});case 13:return l.abrupt("return",l.sent);case 16:if(l.prev=16,l.t1=l["catch"](10),o||!s.isSessionExpiredError(l.t1)){l.next=24;break}return l.next=21,this.authenticate(u);case 21:return l.next=23,this._callMethod({isPrivate:r,methodData:a,requestData:c,isRetry:!0});case 23:return l.abrupt("return",l.sent);case 24:throw this.emit("error",l.t1),l.t1;case 26:case"end":return l.stop()}}),k,this,[[10,16]])}))),function(){return r.apply(this,arguments)})},{key:"_getAuthenticationPromise",value:function(){var t=this,e=this.getAuthenticator(),r=z.get(e);return r||(r=c()(f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.loadAuthenticationData();case 2:return r=n.sent,n.next=5,e.authenticate(t,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n)})))(),z.set(e,r),c()(f().mark((function o(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,r;case 3:t.next=7;break;case 5:t.prev=5,t.t0=t["catch"](0);case 7:return t.prev=7,z["delete"](e),t.finish(7);case 10:case"end":return t.stop()}}),o,null,[[0,5,7,10]])})))(),r)}},{key:"_handleRealtimeTransportWrapperEvent",value:function(t,r){switch(t){case G:this.emit("error",e()(M,a()(M.createRealtimeTransportErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case B:this.emit("error",e()(M,a()(M.createAuthenticationFailedErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))));break;case U:this.emit("error",e()(M,a()(M.createRealtimeTransportErrorArgs(r,"ApiWrapper","_handleRealtimeTransportWrapperEvent"))))}}}]),m}(j())})(),n})()}));
//# sourceMappingURL=index.node.js.map
{
"name": "@ololoepepe/api-wrapper",
"version": "0.0.2",
"version": "0.0.3",
"description": "A wrapper around your API calls",

@@ -5,0 +5,0 @@ "main": "dist/index.node.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc