@pusher/chatkit
Version:
Pusher Chatkit client library for browsers and react native
1 lines • 82.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Chatkit=t()}(this,function(){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,t,r=(function(e,t){var r;r=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}([function(e,t,r){function n(e){var t={};if(!e)return t;for(var r=0,n=e.split("\r\n");r<n.length;r++){var o=n[r],s=o.indexOf(": ");if(s>0){var i=o.substring(0,s),u=o.substring(s+2);t[i]=u}}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.responseToHeadersObject=n;var o=function(){function e(e,t,r){this.statusCode=e,this.headers=t,this.info=r}return e.fromXHR=function(t){var r=t.responseText;try{r=JSON.parse(t.responseText)}catch(e){}return new e(t.status,n(t.getAllResponseHeaders()),r)},e}();t.ErrorResponse=o;var s=function(){return function(e){this.error=e}}();t.NetworkError=s,function(e){e[e.UNSENT=0]="UNSENT",e[e.OPENED=1]="OPENED",e[e.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",e[e.LOADING=3]="LOADING",e[e.DONE=4]="DONE"}(t.XhrReadyState||(t.XhrReadyState={}))},function(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARNING=4]="WARNING",e[e.ERROR=5]="ERROR"}(n=t.LogLevel||(t.LogLevel={}));var o=function(){function e(e){void 0===e&&(e=2),this.threshold=e;var t=Array(),r="--------------------------------------------------------------------------------";window.console.group||(window.console.group=function(e){t.push(e),window.console.log("%c \nBEGIN GROUP: %c",r,e)}),window.console.groupEnd||(window.console.groupEnd=function(){window.console.log("END GROUP: %c\n%c",t.pop(),r)})}return e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.log,n.VERBOSE,e)},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.log,n.DEBUG,e)},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.info,n.INFO,e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.warn,n.WARNING,e)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.error,n.ERROR,e)},e.prototype.log=function(e,t,r){var o=this;if(t>=this.threshold){var s="Logger."+n[t];r.length>1?(window.console.group(),r.forEach(function(t){o.errorAwareLog(e,t,s)}),window.console.groupEnd()):this.errorAwareLog(e,r[0],s)}},e.prototype.errorAwareLog=function(e,t,r){if(void 0!==t&&t.info&&t.info.error_uri){var n=t.info.error_description;e((n||"An error has occurred")+". More information can be found at "+t.info.error_uri+". Error object: ",t)}else e(r+": ",t)},e}();t.ConsoleLogger=o;var s=function(){function e(){}return e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e}();t.EmptyLogger=s},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.createRetryStrategyOptionsOrDefault=function(e){var t=e.initialTimeoutMillis||1e3,r=e.maxTimeoutMillis||5e3,n=-1;return void 0!==e.limit&&null!=e.limit&&(n=e.limit),{increaseTimeout:void 0!==e.increaseTimeout?e.increaseTimeout:function(e){return 2*e>r?r:2*e},initialTimeoutMillis:t,limit:n,maxTimeoutMillis:r}};var o=function(){return function(e){this.waitTimeMillis=e}}();t.Retry=o;var s=function(){return function(e){this.error=e}}();t.DoNotRetry=s;var i=function(){function e(e,t,r){this.options=e,this.logger=t,this.retryUnsafeRequests=r,this.currentRetryCount=0,this.initialTimeoutMillis=e.initialTimeoutMillis,this.maxTimeoutMillis=e.maxTimeoutMillis,this.limit=e.limit,this.increaseTimeoutFunction=e.increaseTimeout,this.currentBackoffMillis=this.initialTimeoutMillis}return e.prototype.attemptRetry=function(e){return this.logger.verbose(this.constructor.name+": Error received",e),this.currentRetryCount>=this.limit&&this.limit>=0?(this.logger.verbose(this.constructor.name+": Retry count is over the maximum limit: "+this.limit),new s(e)):e instanceof n.ErrorResponse&&e.headers["Retry-After"]?(this.logger.verbose(this.constructor.name+": Retry-After header is present, retrying in "+e.headers["Retry-After"]),new o(1e3*parseInt(e.headers["Retry-After"],10))):e instanceof n.NetworkError||e instanceof n.ErrorResponse&&("GET"===(t=(t=e.headers["Request-Method"]).toUpperCase())||"HEAD"===t||"OPTIONS"===t||"SUBSCRIBE"===t)||this.retryUnsafeRequests?this.shouldSafeRetry(e):e instanceof n.NetworkError?this.shouldSafeRetry(e):(this.logger.verbose(this.constructor.name+": Error is not retryable",e),new s(e));var t},e.prototype.shouldSafeRetry=function(e){return e instanceof n.NetworkError?(this.logger.verbose(this.constructor.name+": It's a Network Error, will retry",e),new o(this.calulateMillisToRetry())):e instanceof n.ErrorResponse&&e.statusCode>=500&&e.statusCode<600?(this.logger.verbose(this.constructor.name+": Error 5xx, will retry"),new o(this.calulateMillisToRetry())):(this.logger.verbose(this.constructor.name+": Error is not retryable",e),new s(e))},e.prototype.calulateMillisToRetry=function(){return this.currentBackoffMillis=this.increaseTimeoutFunction(this.currentBackoffMillis),this.logger.verbose(this.constructor.name+": Retrying in "+this.currentBackoffMillis+"ms"),this.currentBackoffMillis},e}();t.RetryResolution=i},function(e,t,r){var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(4),i=r(5),u=r(6),a=r(11),c=r(12),h=r(7),l=r(13),f=r(14),d=r(8),p=function(){function e(e){this.options=e,this.host=e.host.replace(/(\/)+$/,""),this.logger=e.logger||new o.ConsoleLogger,this.websocketTransport=new f.default(this.host),this.httpTransport=new l.default(this.host,e.encrypted),this.sdkProduct=e.sdkProduct||"unknown",this.sdkVersion=e.sdkVersion||"unknown",this.sdkPlatform=navigator?"ReactNative"===navigator.product?"react-native":"web":"node"}return e.prototype.request=function(e,t){var r=this;return e.tokenProvider?e.tokenProvider.fetchToken(t).then(function(t){return void 0!==e.headers?e.headers.Authorization="Bearer "+t:e.headers=((r={}).Authorization="Bearer "+t,r),e;var r}).then(function(e){return r.makeRequest(e)}):this.makeRequest(e)},e.prototype.subscribeResuming=function(e,t,r,o,s,u){var l=c.replaceMissingListenersWithNoOps(r),f=a.subscribeStrategyListenersFromSubscriptionListeners(l),p=!1;return i.createResumingStrategy(o,h.createTokenProvidingStrategy(d.createTransportStrategy(e,this.websocketTransport,this.logger),this.logger,u),this.logger,s)({onEnd:f.onEnd,onError:f.onError,onEvent:f.onEvent,onOpen:function(e){p||(p=!0,f.onOpen(e)),l.onSubscribe()},onRetrying:f.onRetrying},n({},t,this.infoHeaders()))},e.prototype.subscribeNonResuming=function(e,t,r,o,s){var i=c.replaceMissingListenersWithNoOps(r),l=a.subscribeStrategyListenersFromSubscriptionListeners(i),f=!1;return u.createRetryingStrategy(o,h.createTokenProvidingStrategy(d.createTransportStrategy(e,this.websocketTransport,this.logger),this.logger,s),this.logger)({onEnd:l.onEnd,onError:l.onError,onEvent:l.onEvent,onOpen:function(e){f||(f=!0,l.onOpen(e)),i.onSubscribe()},onRetrying:l.onRetrying},n({},t,this.infoHeaders()))},e.prototype.infoHeaders=function(){return{"X-SDK-Language":"javascript","X-SDK-Platform":this.sdkPlatform,"X-SDK-Product":this.sdkProduct,"X-SDK-Version":this.sdkVersion}},e.prototype.makeRequest=function(e){var t=this;return s.executeNetworkRequest(function(){return t.httpTransport.request(n({},e,{headers:n({},e.headers,t.infoHeaders())}))},e).catch(function(e){throw t.logger.error(e),e})},e}();t.BaseClient=p},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);function o(e,t,r){return e.onreadystatechange=function(){4===e.readyState&&(e.status>=200&&e.status<300?t(e.response):0!==e.status?r(n.ErrorResponse.fromXHR(e)):r(new n.NetworkError("No Connection")))},e}t.executeNetworkRequest=function(e,t){return new Promise(function(r,n){!function(e,t){t.json?e.send(JSON.stringify(t.json)):e.send(t.body)}(o(e(),r,n),t)})},t.sendRawRequest=function(e){return new Promise(function(t,r){var n=o(new window.XMLHttpRequest,t,r);if(n.open(e.method.toUpperCase(),e.url,!0),e.headers)for(var s in e.headers)e.headers.hasOwnProperty(s)&&n.setRequestHeader(s,e.headers[s]);n.send(e.body)})}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(2);t.createResumingStrategy=function(e,t,r,n){var i=o.createRetryStrategyOptionsOrDefault(e),u=new o.RetryResolution(i,r);return function(e,n){return new s(r,n,t,e,u)}};var s=function(){return function(e,t,r,n,o){var s=this;this.unsubscribe=function(){s.state.unsubscribe()},this.onTransition=function(e){s.state=e},this.state=new i(this.onTransition,e,t,r,n,o)}}(),i=function(){function e(e,t,r,n,o,s,i){var c=this;this.onTransition=e,this.logger=t,this.headers=r,this.nextSubscribeStrategy=n,this.listeners=o,this.retryResolution=s,this.initialEventId=i;var l=i;t.verbose("ResumingSubscription: transitioning to OpeningSubscriptionState"),l&&(r["Last-Event-Id"]=l,t.verbose("ResumingSubscription: initialEventId is "+l)),this.underlyingSubscription=n({onEnd:function(r){e(new h(t,o,r))},onError:function(i){e(new a(i,e,t,r,o,n,s,l))},onEvent:function(e){l=e.eventId,o.onEvent(e)},onOpen:function(r){e(new u(t,r,o,c.underlyingSubscription,e))},onRetrying:o.onRetrying},r)}return e.prototype.unsubscribe=function(){this.onTransition(new c(this.logger)),this.underlyingSubscription.unsubscribe()},e}(),u=function(){function e(e,t,r,n,o){this.logger=e,this.headers=t,this.listeners=r,this.underlyingSubscription=n,this.onTransition=o,e.verbose("ResumingSubscription: transitioning to OpenSubscriptionState"),r.onOpen(t)}return e.prototype.unsubscribe=function(){this.onTransition(new c(this.logger)),this.underlyingSubscription.unsubscribe()},e}(),a=function(){function e(e,t,r,s,i,a,c,f){var d=this;this.onTransition=t,this.logger=r,this.headers=s,this.listeners=i,this.nextSubscribeStrategy=a,this.retryResolution=c,r.verbose("ResumingSubscription: transitioning to ResumingSubscriptionState");var p=function(e,s){i.onRetrying();var u,a=((u=e)instanceof n.ErrorResponse&&(u.headers["Request-Method"]="SUBSCRIBE"),c.attemptRetry(u));a instanceof o.Retry?d.timeout=window.setTimeout(function(){g(s)},a.waitTimeMillis):t(new l(r,i,e))},g=function(e){r.verbose("ResumingSubscription: trying to re-establish the subscription"),e&&(r.verbose("ResumingSubscription: lastEventId: "+e),s["Last-Event-Id"]=e),d.underlyingSubscription=a({onEnd:function(e){t(new h(r,i,e))},onError:function(e){p(e,f)},onEvent:function(e){f=e.eventId,i.onEvent(e)},onOpen:function(e){t(new u(r,e,i,d.underlyingSubscription,t))},onRetrying:i.onRetrying},s)};p(e,f)}return e.prototype.unsubscribe=function(){this.onTransition(new c(this.logger)),window.clearTimeout(this.timeout),this.underlyingSubscription.unsubscribe()},e}(),c=function(){function e(e,t){this.logger=e,e.verbose("ResumingSubscription: transitioning to EndingSubscriptionState")}return e.prototype.unsubscribe=function(){throw new Error("Subscription is already ending")},e}(),h=function(){function e(e,t,r){this.logger=e,this.listeners=t,e.verbose("ResumingSubscription: transitioning to EndedSubscriptionState"),t.onEnd(r)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}(),l=function(){function e(e,t,r){this.logger=e,this.listeners=t,e.verbose("ResumingSubscription: transitioning to FailedSubscriptionState",r),t.onError(r)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(2);t.createRetryingStrategy=function(e,t,r){var n=o.createRetryStrategyOptionsOrDefault(e),i=new o.RetryResolution(n,r);return function(e,n){return new s(r,n,e,t,i)}};var s=function(){return function(e,t,r,n,o){var s=this;this.unsubscribe=function(){s.state.unsubscribe()},this.onTransition=function(e){s.state=e},this.state=new i(this.onTransition,e,t,r,n,o)}}(),i=function(){function e(e,t,r,n,o,s){var i=this;this.logger=t,this.headers=r,this.listeners=n,this.nextSubscribeStrategy=o,this.retryResolution=s,t.verbose("RetryingSubscription: transitioning to OpeningSubscriptionState"),this.underlyingSubscription=o({onEnd:function(r){return e(new c(t,n,r))},onError:function(i){return e(new u(i,e,t,r,n,o,s))},onEvent:n.onEvent,onOpen:function(r){return e(new a(t,n,r,i.underlyingSubscription,e))},onRetrying:n.onRetrying},r)}return e.prototype.unsubscribe=function(){throw this.underlyingSubscription.unsubscribe(),new Error("Method not implemented.")},e}(),u=function(){function e(e,t,r,s,i,u,l){var f=this;this.onTransition=t,this.logger=r,this.headers=s,this.listeners=i,this.nextSubscribeStrategy=u,this.retryResolution=l,r.verbose("RetryingSubscription: transitioning to RetryingSubscriptionState");var d=function(e){i.onRetrying();var s,u=((s=e)instanceof n.ErrorResponse&&(s.headers["Request-Method"]="SUBSCRIBE"),l.attemptRetry(s));u instanceof o.Retry?f.timeout=window.setTimeout(function(){p()},u.waitTimeMillis):t(new h(r,i,e))},p=function(){r.verbose("RetryingSubscription: trying to re-establish the subscription");var e=u({onEnd:function(e){return t(new c(r,i,e))},onError:function(e){return d(e)},onEvent:i.onEvent,onOpen:function(n){t(new a(r,i,n,e,t))},onRetrying:i.onRetrying},s)};d(e)}return e.prototype.unsubscribe=function(){window.clearTimeout(this.timeout),this.onTransition(new c(this.logger,this.listeners))},e}(),a=function(){function e(e,t,r,n,o){this.logger=e,this.listeners=t,this.headers=r,this.underlyingSubscription=n,this.onTransition=o,e.verbose("RetryingSubscription: transitioning to OpenSubscriptionState"),t.onOpen(r)}return e.prototype.unsubscribe=function(){this.underlyingSubscription.unsubscribe(),this.onTransition(new c(this.logger,this.listeners))},e}(),c=function(){function e(e,t,r){this.logger=e,this.listeners=t,e.verbose("RetryingSubscription: transitioning to EndedSubscriptionState"),t.onEnd(r)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}(),h=function(){function e(e,t,r){this.logger=e,this.listeners=t,e.verbose("RetryingSubscription: transitioning to FailedSubscriptionState",r),t.onError(r)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.createTokenProvidingStrategy=function(e,t,r){return r?function(n,s){return new o(t,n,s,r,e)}:e};var o=function(){function e(e,t,r,n,o){var u=this;this.logger=e,this.listeners=t,this.headers=r,this.tokenProvider=n,this.nextSubscribeStrategy=o,this.unsubscribe=function(){u.state.unsubscribe(),u.state=new i(u.logger)},this.state=new s(e,r,o),this.subscribe()}return e.prototype.subscribe=function(){var e=this;this.tokenProvider.fetchToken().then(function(t){var r=Object.assign({},e.listeners);e.state.subscribe(t,{onEnd:function(t){e.state=new i(e.logger),r.onEnd(t)},onError:function(n){e.isTokenExpiredError(n)?(e.tokenProvider.clearToken(t),e.subscribe()):(e.state=new i(e.logger),r.onError(n))},onEvent:e.listeners.onEvent,onOpen:e.listeners.onOpen})}).catch(function(t){e.logger.debug("TokenProvidingSubscription: error when fetching token:",t),e.state=new i(e.logger),e.listeners.onError(t)})},e.prototype.isTokenExpiredError=function(e){return e instanceof n.ErrorResponse&&401===e.statusCode&&"authentication/expired"===e.info},e}(),s=function(){function e(e,t,r){this.logger=e,this.headers=t,this.nextSubscribeStrategy=r,e.verbose("TokenProvidingSubscription: transitioning to ActiveState")}return e.prototype.subscribe=function(e,t){var r=this;this.putTokenIntoHeader(e),this.underlyingSubscription=this.nextSubscribeStrategy({onEnd:function(e){r.logger.verbose("TokenProvidingSubscription: subscription ended"),t.onEnd(e)},onError:function(e){r.logger.verbose("TokenProvidingSubscription: subscription errored:",e),t.onError(e)},onEvent:t.onEvent,onOpen:function(e){r.logger.verbose("TokenProvidingSubscription: subscription opened"),t.onOpen(e)},onRetrying:t.onRetrying},this.headers)},e.prototype.unsubscribe=function(){this.underlyingSubscription.unsubscribe()},e.prototype.putTokenIntoHeader=function(e){this.headers.Authorization="Bearer "+e,this.logger.verbose("TokenProvidingSubscription: token fetched: "+e)},e}(),i=function(){function e(e){this.logger=e,e.verbose("TokenProvidingSubscription: transitioning to InactiveState")}return e.prototype.subscribe=function(e,t){this.logger.verbose("TokenProvidingSubscription: subscribe called in Inactive state; doing nothing")},e.prototype.unsubscribe=function(){this.logger.verbose("TokenProvidingSubscription: unsubscribe called in Inactive state; doing nothing")},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.createTransportStrategy=function(e,t,r){return function(r,n){return t.subscribe(e,r,n)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_BASE="pusherplatform.io"},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.BaseClient=n.BaseClient;var o=r(9);t.HOST_BASE=o.HOST_BASE;var s=r(15);t.Instance=s.default;var i=r(1);t.ConsoleLogger=i.ConsoleLogger,t.EmptyLogger=i.EmptyLogger;var u=r(0);t.ErrorResponse=u.ErrorResponse,t.NetworkError=u.NetworkError,t.responseToHeadersObject=u.responseToHeadersObject,t.XhrReadyState=u.XhrReadyState;var a=r(4);t.executeNetworkRequest=a.executeNetworkRequest,t.sendRawRequest=a.sendRawRequest;var c=r(5);t.createResumingStrategy=c.createResumingStrategy;var h=r(2);t.createRetryStrategyOptionsOrDefault=h.createRetryStrategyOptionsOrDefault,t.DoNotRetry=h.DoNotRetry,t.Retry=h.Retry,t.RetryResolution=h.RetryResolution;var l=r(6);t.createRetryingStrategy=l.createRetryingStrategy;var f=r(7);t.createTokenProvidingStrategy=f.createTokenProvidingStrategy;var d=r(8);t.createTransportStrategy=d.createTransportStrategy,t.default={BaseClient:n.BaseClient,ConsoleLogger:i.ConsoleLogger,EmptyLogger:i.EmptyLogger,Instance:s.default}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeStrategyListenersFromSubscriptionListeners=function(e){return{onEnd:e.onEnd,onError:e.onError,onEvent:e.onEvent,onOpen:e.onOpen,onRetrying:e.onRetrying}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.replaceMissingListenersWithNoOps=function(e){return{onEnd:e.onEnd||function(e){},onError:e.onError||function(e){},onEvent:e.onEvent||function(e){},onOpen:e.onOpen||function(e){},onRetrying:e.onRetrying||function(){},onSubscribe:e.onSubscribe||function(){}}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(0);!function(e){e[e.UNOPENED=0]="UNOPENED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.ENDING=3]="ENDING",e[e.ENDED=4]="ENDED"}(n=t.HttpTransportState||(t.HttpTransportState={}));var s=function(){function e(e,t){var r=this;return this.gotEOS=!1,this.lastNewlineIndex=0,this.state=n.UNOPENED,this.xhr=e,this.listeners=t,this.xhr.onreadystatechange=function(){switch(r.xhr.readyState){case o.XhrReadyState.UNSENT:case o.XhrReadyState.OPENED:case o.XhrReadyState.HEADERS_RECEIVED:r.assertStateIsIn(n.OPENING);break;case o.XhrReadyState.LOADING:r.onLoading();break;case o.XhrReadyState.DONE:r.onDone()}},this.state=n.OPENING,this.xhr.send(),this}return e.prototype.unsubscribe=function(){this.state=n.ENDED,this.xhr.abort(),this.listeners.onEnd&&this.listeners.onEnd(null)},e.prototype.onLoading=function(){if(this.assertStateIsIn(n.OPENING,n.OPEN,n.ENDING),200===this.xhr.status){this.state===n.OPENING&&(this.state=n.OPEN,window.console.log(o.responseToHeadersObject(this.xhr.getAllResponseHeaders())),this.listeners.onOpen&&this.listeners.onOpen(o.responseToHeadersObject(this.xhr.getAllResponseHeaders()))),this.assertStateIsIn(n.OPEN);var e=this.onChunk();this.assertStateIsIn(n.OPEN,n.ENDING),e&&(this.state=n.ENDED,e instanceof o.ErrorResponse&&204!==e.statusCode&&this.listeners.onError&&this.listeners.onError(e))}},e.prototype.onDone=function(){if(200===this.xhr.status){this.state===n.OPENING&&(this.state=n.OPEN,this.listeners.onOpen&&this.listeners.onOpen(o.responseToHeadersObject(this.xhr.getAllResponseHeaders()))),this.assertStateIsIn(n.OPEN,n.ENDING);var e=this.onChunk();e?(this.state=n.ENDED,204===e.statusCode?this.listeners.onEnd&&this.listeners.onEnd(null):this.listeners.onError&&this.listeners.onError(e)):this.state<=n.ENDING?this.listeners.onError&&this.listeners.onError(new Error("HTTP response ended without receiving EOS message")):this.listeners.onEnd&&this.listeners.onEnd(null)}else{if(this.assertStateIsIn(n.OPENING,n.OPEN,n.ENDED),this.state===n.ENDED)return;0===this.xhr.status?this.listeners.onError&&this.listeners.onError(new o.NetworkError("Connection lost.")):this.listeners.onError&&this.listeners.onError(o.ErrorResponse.fromXHR(this.xhr))}},e.prototype.onChunk=function(){this.assertStateIsIn(n.OPEN);var e=this.xhr.responseText,t=e.lastIndexOf("\n");if(t>this.lastNewlineIndex){var r=e.slice(this.lastNewlineIndex,t).split("\n");this.lastNewlineIndex=t;for(var o=0,s=r;o<s.length;o++){var i=s[o];if(0!==i.length){var u=JSON.parse(i),a=this.onMessage(u);if(null!=a)return a}}}},e.prototype.assertStateIsIn=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(!t.some(function(t){return t===e.state})){var o=t.map(function(e){return n[e]}).join(", "),s=n[this.state];window.console.warn("Expected this.state to be one of ["+o+"] but it is "+s)}},e.prototype.onMessage=function(e){switch(this.assertStateIsIn(n.OPEN),this.verifyMessage(e),e[0]){case 0:return null;case 1:return this.onEventMessage(e);case 255:return this.onEOSMessage(e);default:return new Error("Unknown Message: "+JSON.stringify(e))}},e.prototype.onEventMessage=function(e){if(this.assertStateIsIn(n.OPEN),4!==e.length)return new Error("Event message has "+e.length+" elements (expected 4)");e[0];var t=e[1],r=e[2],o=e[3];return"string"!=typeof t?new Error("Invalid event ID in message: "+JSON.stringify(e)):"object"!=typeof r||Array.isArray(r)?new Error("Invalid event headers in message: "+JSON.stringify(e)):(this.listeners.onEvent&&this.listeners.onEvent({body:o,headers:r,eventId:t}),null)},e.prototype.onEOSMessage=function(e){if(this.assertStateIsIn(n.OPEN),4!==e.length)return new Error("EOS message has "+e.length+" elements (expected 4)");e[0];var t=e[1],r=e[2],s=e[3];return"number"!=typeof t?new Error("Invalid EOS Status Code"):"object"!=typeof r||Array.isArray(r)?new Error("Invalid EOS ElementsHeaders"):(this.state=n.ENDING,new o.ErrorResponse(t,r,s))},e.prototype.verifyMessage=function(e){return this.gotEOS?new Error("Got another message after EOS message"):Array.isArray(e)?e.length<1?new Error("Message is empty array"):void 0:new Error("Message is not an array")},e}(),i=function(){function e(e,t){void 0===t&&(t=!0),this.baseURL=(t?"https":"http")+"://"+e}return e.prototype.request=function(e){return this.createXHR(this.baseURL,e)},e.prototype.subscribe=function(e,t,r){var n={headers:r,method:"SUBSCRIBE",path:e};return new s(this.createXHR(this.baseURL,n),t)},e.prototype.createXHR=function(e,t){var r=new window.XMLHttpRequest,n=e+"/"+t.path.replace(/^\/+/,"");if(r.open(t.method.toUpperCase(),n,!0),r=this.setJSONHeaderIfAppropriate(r,t),t.jwt&&r.setRequestHeader("authorization","Bearer "+t.jwt),t.headers)for(var o in t.headers)t.headers.hasOwnProperty(o)&&r.setRequestHeader(o,t.headers[o]);return r},e.prototype.setJSONHeaderIfAppropriate=function(e,t){return t.json&&e.setRequestHeader("content-type","application/json"),e},e}();t.default=i},function(e,t,r){var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};Object.defineProperty(t,"__esModule",{value:!0});var o,s=r(0);!function(e){e[e.Connecting=0]="Connecting",e[e.Open=1]="Open",e[e.Closing=2]="Closing",e[e.Closed=3]="Closed"}(o=t.WSReadyState||(t.WSReadyState={}));var i=function(){function e(){this.subscriptions={}}return e.prototype.add=function(e,t,r,n){return this.subscriptions[e]={headers:n,listeners:r,path:t},e},e.prototype.has=function(e){return void 0!==this.subscriptions[e]},e.prototype.isEmpty=function(){return 0===Object.keys(this.subscriptions).length},e.prototype.remove=function(e){return delete this.subscriptions[e]},e.prototype.get=function(e){return this.subscriptions[e]},e.prototype.getAll=function(){return this.subscriptions},e.prototype.getAllAsArray=function(){var e=this;return Object.keys(this.subscriptions).map(function(t){return n({subID:parseInt(t,10)},e.subscriptions[parseInt(t,10)])})},e.prototype.removeAll=function(){this.subscriptions={}},e}(),u=function(){function e(e,t){this.wsTransport=e,this.subID=t}return e.prototype.unsubscribe=function(){this.wsTransport.unsubscribe(this.subID)},e}(),a=function(){function e(e){this.webSocketPath="/ws",this.forcedClose=!1,this.closedError=null,this.baseURL="wss://"+e+this.webSocketPath,this.lastSubscriptionID=0,this.subscriptions=new i,this.pendingSubscriptions=new i,this.connect()}return e.prototype.subscribe=function(e,t,r){this.tryReconnectIfNeeded();var n=this.lastSubscriptionID++;return this.socket.readyState!==o.Open?(this.pendingSubscriptions.add(n,e,t,r),new u(this,n)):(this.subscriptions.add(n,e,t,r),this.sendMessage(this.getMessage(100,n,e,r)),new u(this,n))},e.prototype.unsubscribe=function(e){this.sendMessage(this.getMessage(198,e));var t=this.subscriptions.get(e);t.listeners.onEnd&&t.listeners.onEnd(null),this.subscriptions.remove(e)},e.prototype.connect=function(){var e=this;this.close(),this.forcedClose=!1,this.closedError=null,this.socket=new window.WebSocket(this.baseURL),this.socket.onopen=function(t){e.pendingSubscriptions.getAllAsArray().forEach(function(t){var r=t.subID,n=t.path,o=t.listeners,s=t.headers;e.subscribePending(n,o,s,r)}),e.pendingSubscriptions.removeAll(),e.pingInterval=window.setInterval(function(){if(!e.pongTimeout){var t=(new Date).getTime();1e4>t-e.lastMessageReceivedTimestamp||(e.sendMessage(e.getMessage(16,t)),e.lastSentPingID=t,e.pongTimeout=window.setTimeout(function(){1e4>(new Date).getTime()-e.lastMessageReceivedTimestamp?e.pongTimeout=null:e.close(new s.NetworkError("Pong response wasn't received until timeout."))},1e4))}},3e4)},this.socket.onmessage=function(t){return e.receiveMessage(t)},this.socket.onerror=function(t){e.close(new s.NetworkError("Connection was lost."))},this.socket.onclose=function(t){if(e.forcedClose){var r=e.closedError?function(t){t.listeners.onError&&t.listeners.onError(e.closedError)}:function(e){e.listeners.onEnd&&e.listeners.onEnd(null)},n=!1===e.pendingSubscriptions.isEmpty()?e.pendingSubscriptions:e.subscriptions;n.getAllAsArray().forEach(r),n.removeAll(),e.closedError&&e.tryReconnectIfNeeded()}else e.tryReconnectIfNeeded()}},e.prototype.close=function(e){this.socket instanceof window.WebSocket&&(this.forcedClose=!0,this.closedError=e,this.socket.close(),window.clearTimeout(this.pingInterval),window.clearTimeout(this.pongTimeout),delete this.pongTimeout,this.lastSentPingID=null)},e.prototype.tryReconnectIfNeeded=function(){this.socket.readyState===o.Closed&&this.connect()},e.prototype.subscribePending=function(e,t,r,n){void 0!==n?(this.subscriptions.add(n,e,t,r),this.sendMessage(this.getMessage(100,n,e,r))):window.console.logger.debug("Subscription to path "+e+" has an undefined ID")},e.prototype.getMessage=function(e,t,r,n){return[e,t,r,n]},e.prototype.sendMessage=function(e){if(this.socket.readyState!==o.Open)return window.console.warn("Can't send in \""+o[this.socket.readyState]+'" state');this.socket.send(JSON.stringify(e))},e.prototype.subscription=function(e){return this.subscriptions.get(e)},e.prototype.receiveMessage=function(e){var t;this.lastMessageReceivedTimestamp=(new Date).getTime();try{t=JSON.parse(e.data)}catch(t){return void this.close(new Error("Message is not valid JSON format. Getting "+e.data))}var r=this.validateMessage(t);if(r)this.close(new Error(r.message));else{var n=t.shift();switch(n){case 17:return void this.onPongMessage(t);case 16:return void this.onPingMessage(t);case 99:return void this.onCloseMessage(t)}var o=t.shift(),s=this.subscription(o);if(s){var i=s.listeners;switch(n){case 101:this.onOpenMessage(t,o,i);break;case 102:this.onEventMessage(t,i);break;case 199:this.onEOSMessage(t,o,i);break;default:this.close(new Error("Received non existing type of message."))}}else this.close(new Error('Received message for non existing subscription id: "'+o+'"'))}},e.prototype.validateMessage=function(e){return Array.isArray(e)?e.length<1?new Error("Message is empty array: "+JSON.stringify(e)):null:new Error("Message is expected to be an array. Getting: "+JSON.stringify(e))},e.prototype.onOpenMessage=function(e,t,r){r.onOpen&&r.onOpen(e[1])},e.prototype.onEventMessage=function(e,t){if(3!==e.length)return new Error("Event message has "+e.length+" elements (expected 4)");var r=e[0],n=e[1],o=e[2];return"string"!=typeof r?new Error("Invalid event ID in message: "+JSON.stringify(e)):"object"!=typeof n||Array.isArray(n)?new Error("Invalid event headers in message: "+JSON.stringify(e)):void(t.onEvent&&t.onEvent({eventId:r,headers:n,body:o}))},e.prototype.onEOSMessage=function(e,t,r){if(this.subscriptions.remove(t),3===e.length){var n=e[0],o=e[1],i=e[2];"number"==typeof n?"object"!=typeof o||Array.isArray(o)?r.onError&&r.onError(new Error("Invalid EOS ElementsHeaders")):204!==n?r.onError&&r.onError(new s.ErrorResponse(n,o,i)):r.onEnd&&r.onEnd(null):r.onError&&r.onError(new Error("Invalid EOS Status Code"))}else r.onError&&r.onError(new Error("EOS message has "+e.length+" elements (expected 4)"))},e.prototype.onCloseMessage=function(e){var t=e[0],r=e[1];e[2];return"number"!=typeof t?this.close(new Error("Close message: Invalid EOS Status Code")):"object"!=typeof r||Array.isArray(r)?this.close(new Error("Close message: Invalid EOS ElementsHeaders")):void this.close()},e.prototype.onPongMessage=function(e){var t=e[0];this.lastSentPingID!==t&&this.close(new s.NetworkError("Didn't received pong with proper ID")),window.clearTimeout(this.pongTimeout),delete this.pongTimeout,this.lastSentPingID=null},e.prototype.onPingMessage=function(e){var t=e[0];this.sendMessage(this.getMessage(17,t))},e}();t.default=a},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(3),o=r(9),s=r(1),i=function(){function e(e){if(!e.locator)throw new Error("Expected `locator` property in Instance options!");var t=e.locator.split(":");if(3!==t.length)throw new Error("The instance locator supplied is invalid. Did you copy it correctly from the Pusher dashboard?");if(!e.serviceName)throw new Error("Expected `serviceName` property in Instance options!");if(!e.serviceVersion)throw new Error("Expected `serviceVersion` property in Instance options!");this.platformVersion=t[0],this.cluster=t[1],this.id=t[2],this.serviceName=e.serviceName,this.serviceVersion=e.serviceVersion,this.host=e.host||this.cluster+"."+o.HOST_BASE,this.logger=e.logger||new s.ConsoleLogger,this.client=e.client||new n.BaseClient({encrypted:e.encrypted,host:this.host,logger:this.logger}),this.tokenProvider=e.tokenProvider}return e.prototype.request=function(e,t){return e.path=this.absPath(e.path),null!=e.headers&&void 0!==e.headers||(e.headers={}),e.tokenProvider=e.tokenProvider||this.tokenProvider,this.client.request(e,t)},e.prototype.subscribeNonResuming=function(e){var t=e.headers||{},r=e.retryStrategyOptions||{},n=e.tokenProvider||this.tokenProvider;return this.client.subscribeNonResuming(this.absPath(e.path),t,e.listeners,r,n)},e.prototype.subscribeResuming=function(e){var t=e.headers||{},r=e.retryStrategyOptions||{},n=e.tokenProvider||this.tokenProvider;return this.client.subscribeResuming(this.absPath(e.path),t,e.listeners,r,e.initialEventId,n)},e.prototype.absPath=function(e){return("/services/"+this.serviceName+"/"+this.serviceVersion+"/"+this.id+"/"+e).replace(/\/+/g,"/").replace(/\/+$/,"")},e}();t.default=i}])},e.exports=r()}(e={exports:{}},e.exports),e.exports);(t=r)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")&&t.default;var n=r.BaseClient,o=r.HOST_BASE,s=r.Instance,i=r.sendRawRequest;function u(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function a(e){return function t(r){return 0===arguments.length||u(r)?t:e.apply(this,arguments)}}function c(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return u(r)?t:a(function(t){return e(r,t)});default:return u(r)&&u(n)?t:u(r)?a(function(t){return e(t,n)}):u(n)?a(function(t){return e(r,t)}):e(r,n)}}}function h(e,t){var r;e=e||[],t=t||[];var n=e.length,o=t.length,s=[];for(r=0;r<n;)s[s.length]=e[r],r+=1;for(r=0;r<o;)s[s.length]=t[r],r+=1;return s}function l(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,r){return t.apply(this,arguments)};case 3:return function(e,r,n){return t.apply(this,arguments)};case 4:return function(e,r,n,o){return t.apply(this,arguments)};case 5:return function(e,r,n,o,s){return t.apply(this,arguments)};case 6:return function(e,r,n,o,s,i){return t.apply(this,arguments)};case 7:return function(e,r,n,o,s,i,u){return t.apply(this,arguments)};case 8:return function(e,r,n,o,s,i,u,a){return t.apply(this,arguments)};case 9:return function(e,r,n,o,s,i,u,a,c){return t.apply(this,arguments)};case 10:return function(e,r,n,o,s,i,u,a,c,h){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function f(e,t,r){return function(){for(var n=[],o=0,s=e,i=0;i<t.length||o<arguments.length;){var a;i<t.length&&(!u(t[i])||o>=arguments.length)?a=t[i]:(a=arguments[o],o+=1),n[i]=a,u(a)||(s-=1),i+=1}return s<=0?r.apply(this,n):l(s,f(e,n,r))}}var d=c(function(e,t){return 1===e?a(t):l(e,f(e,[],t))});function p(e){return function t(r,n,o){switch(arguments.length){case 0:return t;case 1:return u(r)?t:c(function(t,n){return e(r,t,n)});case 2:return u(r)&&u(n)?t:u(r)?c(function(t,r){return e(t,n,r)}):u(n)?c(function(t,n){return e(r,t,n)}):a(function(t){return e(r,n,t)});default:return u(r)&&u(n)&&u(o)?t:u(r)&&u(n)?c(function(t,r){return e(t,r,o)}):u(r)&&u(o)?c(function(t,r){return e(t,n,r)}):u(n)&&u(o)?c(function(t,n){return e(r,t,n)}):u(r)?a(function(t){return e(t,n,o)}):u(n)?a(function(t){return e(r,t,o)}):u(o)?a(function(t){return e(r,n,t)}):e(r,n,o)}}}var g=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function m(e,t,r){return function(){if(0===arguments.length)return r();var n=Array.prototype.slice.call(arguments,0),o=n.pop();if(!g(o)){for(var s=0;s<e.length;){if("function"==typeof o[e[s]])return o[e[s]].apply(o,n);s+=1}if(function(e){return"function"==typeof e["@@transducer/step"]}(o))return t.apply(null,n)(o)}return r.apply(this,arguments)}}var v={init:function(){return this.xf["@@transducer/init"]()},result:function(e){return this.xf["@@transducer/result"](e)}},b=c(function(e,t){return t>e?t:e});function y(e,t){for(var r=0,n=t.length,o=Array(n);r<n;)o[r]=e(t[r]),r+=1;return o}function S(e){return"[object String]"===Object.prototype.toString.call(e)}var w=a(function(e){return!!g(e)||!!e&&("object"==typeof e&&(!S(e)&&(1===e.nodeType?!!e.length:0===e.length||e.length>0&&(e.hasOwnProperty(0)&&e.hasOwnProperty(e.length-1)))))}),E=function(){function e(e){this.f=e}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(e){return e},e.prototype["@@transducer/step"]=function(e,t){return this.f(e,t)},e}();function I(e){return new E(e)}var R=c(function(e,t){return l(e.length,function(){return e.apply(t,arguments)})});function k(e,t,r){for(var n=r.next();!n.done;){if((t=e["@@transducer/step"](t,n.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n=r.next()}return e["@@transducer/result"](t)}function O(e,t,r,n){return e["@@transducer/result"](r[n](R(e["@@transducer/step"],e),t))}var T="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function N(e,t,r){if("function"==typeof e&&(e=I(e)),w(r))return function(e,t,r){for(var n=0,o=r.length;n<o;){if((t=e["@@transducer/step"](t,r[n]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n+=1}return e["@@transducer/result"](t)}(e,t,r);if("function"==typeof r["fantasy-land/reduce"])return O(e,t,r,"fantasy-land/reduce");if(null!=r[T])return k(e,t,r[T]());if("function"==typeof r.next)return k(e,t,r);if("function"==typeof r.reduce)return O(e,t,r,"reduce");throw new TypeError("reduce: list must be array or iterable")}var P=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=v.init,e.prototype["@@transducer/result"]=v.result,e.prototype["@@transducer/step"]=function(e,t){return this.xf["@@transducer/step"](e,this.f(t))},e}(),_=c(function(e,t){return new P(e,t)});function A(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var M=Object.prototype.toString,j=function(){return"[object Arguments]"===M.call(arguments)?function(e){return"[object Arguments]"===M.call(e)}:function(e){return A("callee",e)}},U=!{toString:null}.propertyIsEnumerable("toString"),C=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],x=function(){return arguments.propertyIsEnumerable("length")}(),D=function(e,t){for(var r=0;r<e.length;){if(e[r]===t)return!0;r+=1}return!1},q=a("function"!=typeof Object.keys||x?function(e){if(Object(e)!==e)return[];var t,r,n=[],o=x&&j(e);for(t in e)!A(t,e)||o&&"length"===t||(n[n.length]=t);if(U)for(r=C.length-1;r>=0;)A(t=C[r],e)&&!D(n,t)&&(n[n.length]=t),r-=1;return n}:function(e){return Object(e)!==e?[]:Object.keys(e)}),B=c(m(["fantasy-land/map","map"],_,function(e,t){switch(Object.prototype.toString.call(t)){case"[object Function]":return d(t.length,function(){return e.call(this,t.apply(this,arguments))});case"[object Object]":return N(function(r,n){return r[n]=e(t[n]),r},{},q(t));default:return y(e,t)}})),L=c(function(e,t){for(var r=t,n=0;n<e.length;){if(null==r)return;r=r[e[n]],n+=1}return r}),H=c(function(e,t){return L([e],t)}),G=p(N),F=c(function(e,t){return h(t,[e])}),J=a(function(e){for(var t=q(e),r=t.length,n=[],o=0;o<r;)n[o]=e[t[o]],o+=1;return n});var z=a(function(e){return d(e.length,e)});var X=function(e){var t=function(e){return{"@@transducer/init":v.init,"@@transducer/result":function(t){return e["@@transducer/result"](t)},"@@transducer/step":function(t,r){var n=e["@@transducer/step"](t,r);return n["@@transducer/reduced"]?{"@@transducer/value":n,"@@transducer/reduced":!0}:n}}}(e);return{"@@transducer/init":v.init,"@@transducer/result":function(e){return t["@@transducer/result"](e)},"@@transducer/step":function(e,r){return w(r)?N(t,e,r):N(t,e,[r])}}},V=c(m(["fantasy-land/chain","chain"],c(function(e,t){return B(e,X(t))}),function(e,t){return"function"==typeof t?function(r){return e(t(r))(r)}:(r=!1,function e(t){for(var n,o,s,i=[],u=0,a=t.length;u<a;){if(w(t[u]))for(s=0,o=(n=r?e(t[u]):t[u]).length;s<o;)i[i.length]=n[s],s+=1;else i[i.length]=t[u];u+=1}return i})(B(e,t));var r})),W=a(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function K(e,t){return function(){return t.call(this,e.apply(this,arguments))}}function $(e,t){return function(){var r=arguments.length;if(0===r)return t();var n=arguments[r-1];return g(n)||"function"!=typeof n[e]?t.apply(this,arguments):n[e].apply(n,Array.prototype.slice.call(arguments,0,r-1))}}var Y=p($("slice",function(e,t,r){return Array.prototype.slice.call(r,e,t)})),Z=a($("tail",Y(1,1/0)));function Q(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return l(arguments[0].length,G(K,arguments[0],Z(arguments)))}var ee=a(function(e){return S(e)?e.split("").reverse().join(""):Array.prototype.slice.call(e,0).reverse()});function te(){if(0===arguments.length)throw new Error("compose requires at least one argument");return Q.apply(this,ee(arguments))}function re(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function ne(e,t,r){for(var n=0,o=r.length;n<o;){if(e(t,r[n]))return!0;n+=1}return!1}var oe=c(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t});function se(e,t,r,n){var o=re(e);function s(e,t){return ie(e,t,r.slice(),n.slice())}return!ne(function(e,t){return!ne(s,t,e)},re(t),o)}function ie(e,t,r,n){if(oe(e,t))return!0;var o,s,i=W(e);if(i!==W(t))return!1;if(null==e||null==t)return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(o=e.constructor,null==(s=String(o).match(/^function (\w*)/))?"":s[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!oe(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!oe(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var u=r.length-1;u>=0;){if(r[u]===e)return n[u]===t;u-=1}switch(i){case"Map":return e.size===t.size&&se(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&se(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var a=q(e);if(a.length!==q(t).length)return!1;var c=r.concat([e]),h=n.concat([t]);for(u=a.length-1;u>=0;){var l=a[u];if(!A(l,t)||!ie(t[l],e[l],c,h))return!1;u-=1}return!0}var ue=c(function(e,t){return ie(e,t,[],[])});function ae(e,t){return function(e,t,r){var n,o;if("function"==typeof e.indexOf)switch(typeof t){case"number":if(0===t){for(n=1/t;r<e.length;){if(0===(o=e[r])&&1/o===n)return r;r+=1}return-1}if(t!=t){for(;r<e.length;){if("number"==typeof(o=e[r])&&o!=o)return r;r+=1}return-1}return e.indexOf(t,r);case"string":case"boolean":case"function":case"undefined":return e.indexOf(t,r);case"object":if(null===t)return e.indexOf(t,r)}for(;r<e.length;){if(ue(e[r],t))return r;r+=1}return-1}(t,e,0)>=0}function ce(e){return'"'+e.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var he=function(e){return(e<10?"0":"")+e},le="function"==typeof Date.prototype.toISOString?function(e){return e.toISOString()}:function(e){return e.getUTCFullYear()+"-"+he(e.getUTCMonth()+1)+"-"+he(e.getUTCDate())+"T"+he(e.getUTCHours())+":"+he(e.getUTCMinutes())+":"+he(e.getUTCSeconds())+"."+(e.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function fe(e){return"[object Object]"===Object.prototype.toString.call(e)}var de=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=v.init,e.prototype["@@transducer/result"]=v.result,e.prototype["@@transducer/step"]=function(e,t){return this.f(t)?this.xf["@@transducer/step"](e,t):e},e}(),pe=c(m(["filter"],c(function(e,t){return new de(e,t)}),function(e,t){return fe(t)?N(function(r,n){return e(t[n])&&(r[n]=t[n]),r},{},q(t)):function(e,t){for(var r=0,n=t.length,o=[];r<n;)e(t[r])&&(o[o.length]=t[r]),r+=1;return o}(e,t)})),ge=c(function(e,t){return pe((r=e,function(){return!r.apply(this,arguments)}),t);var r});var me=a(function(e){return function e(t,r){var n=function(n){var o=r.concat([t]);return ae(n,o)?"<Circular>":e(n,o)},o=function(e,t){return y(function(t){return ce(t)+": "+n(e[t])},t.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+y(n,t).join(", ")+"))";case"[object Array]":return"["+y(n,t).concat(o(t,ge(function(e){return/^\d+$/.test(e)},q(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):ce(le(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+n(t.valueOf())+")":ce(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var s=t.toString();if("[object Object]"!==s)return s}return"{"+o(t,q(t)).join(", ")+"}"}}(e,[])}),ve=c(ae),be=function(){function e(e,t,r,n){this.valueFn=e,this.valueAcc=t,this.keyFn=r,this.xf=n,this.inputs={}}return e.prototype["@@transducer/init"]=v.init,e.prototype["@@transducer/result"]=function(e){var t;for(t in this.inputs)if(A(t,this.inputs)&&(e=this.xf["@@transducer/step"](e,this.inputs[t]))["@@transducer/reduced"]){e=e["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](e)},e.prototype["@@transducer/step"]=function(e,t){var r=this.keyFn(t);return this.inputs[r]=this.inputs[r]||[r,this.valueAcc],this.inputs[r][1]=this.valueFn(this.inputs[r][1],t),e},e}(),ye=f(4,[],m([],f(4,[],function(e,t,r,n){return new be(e,t,r,n)}),function(e,t,r,n){return N(function(n,o){var s=r(o);return n[s]=e(A(s,n)?n[s]:t,o),n},{},n)})),Se=c(function(e,t){for(var r=[],n=0,o=e.length;n<o;)ae(e[n],t)||ae(e[n],r)||(r[r.length]=e[n]),n+=1;return r}),we=c(function(e,t){var r=e<0?t.length+e:e;return S(t)?t.charAt(r):t[r]}),Ee=a(function(e){return null!=e&&"function"==typeof e["fantasy-land/empty"]?e["fantasy-land/empty"]():null!=e&&null!=e.constructor&&"function"==typeof e.constructor["fantasy-land/empty"]?e.constructor["fantasy-land/empty"]():null!=e&&"function"==typeof e.empty?e.empty():null!=e&&null!=e.constructor&&"function"==typeof e.constructor.empty?e.constructor.empty():g(e)?[]:S(e)?"":fe(e)?{}:j(e)?function(){return arguments}():void 0}),Ie=c($("forEach",function(e,t){for(var r=t.length,n=0;n<r;)e(t[n]),n+=1;return t})),Re=c(function(e,t){for(var r=q(t),n=0;n<r.length;){var o=r[n];e(t[o],o,t),n+=1}return t}),ke=a(function(e){for(var t={},r=0;r<e.length;)t[e[r][0]]=e[r][1],r+=1;return t}),Oe=c(A),Te=we(0);function Ne(e){return e}var Pe=a(Ne),_e=ye(function(e,t){return t},null),Ae=function(){function e(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}return e.prototype.add=function(e){return!Me(e,!0,this)},e.prototype.has=function(e){return Me(e,!1,this)},e}();function Me(e,t,r){var n,o=typeof e;switch(o){case"string":case"number":return 0===e&&1/e==-1/0?!!r._items["-0"]||(t&&(r._items["-0"]=!0),!1):null!==r._nativeSet?t?(n=r._nativeSet.size,r._nativeSet.add(e),r._nativeSet.size===n):r._nativeSet.has(e):o in r._items?e in r._items[o]||(t&&(r._items[o][e]=!0),!1):(t&&(r._items[o]={},r._items[o][e]=!0),!1);case"boolean":if(o in r._items){var s=e?1:0;return!!r._items[o][s]||(t&&(r._items[o][s]=!0),!1)}return t&&(r._items[o]=e?[!1,!0]:[!0,!1]),!1;case"function":return null!==r._nativeSet?t?(n=r._nativeSet.size,r._nativeSet.add(e),r._nativeSet.size===n):r._nativeSet.has(e):o in r._items?!!ae(e,r._items[o])||(t&&r._items[o].push(e),!1):(t&&(r._items[o]=[e]),!1);case"undefined":return!!r._items[o]||(t&&(r._items[o]=!0),!1);case"object":if(null===e)return!!r._items.null||(t&&(r._items.null=!0),!1);default:return(o=Object.prototype.toString.call(e))in r._items?!!ae(e,r._items[o])||(t&&r._items[o].push(e),!1):(t&&(r._items[o]=[e]),!1)}}var je=c(function(e,t){for(var r,n,o=new Ae,s=[],i=0;i<t.length;)r=e(n=t[i]),o.add(r)&&s.push(n),i+=1;return s})(Pe),Ue=c(function(e,t){return d(e+1,function(){var r,n=arguments[e];if(null!=n&&(r=n[t],"[object Function]"===Object.prototype.toString.call(r)))return n[t].apply(n,Array.prototype.slice.call(arguments,0,e));throw new TypeError(me(n)+' does not have a method named "'+t+'"')})}),Ce=a(function(e){return null!=e&&ue(e,Ee(e))}),xe=Ue(1,"join");var De=a(function(e){return null!=e&&(t=e.length,"[object Number]"===Object.prototype.toString.call(t))?e.length:NaN;var t});var qe=c(function(e,t){for(var r={},n=0;n<e.length;)e[n]in t&&(r[e[n]]=t[e[n]]),n+=1;return r}),Be=c(function(e,t){return Array.prototype.slice.call(t,0).sort(e)}),Le=Ue(1,"split"),He=a(function(e){var t=[];for(var r in e)A(r,e)&&(t[t.length]=[r,e[r]]);return t}),Ge="\t\n\v\f\r