UNPKG

@pusher/chatkit

Version:

Pusher Chatkit client library for browsers and react native

1 lines 81.2 kB
!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,n=(function(e,t){var n;n=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t,n){function r(e){var t={};if(!e)return t;for(var n=0,r=e.split("\r\n");n<r.length;n++){var o=r[n],i=o.indexOf(": ");if(i>0){var s=o.substring(0,i),u=o.substring(i+2);t[s]=u}}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.responseToHeadersObject=r;var o=function(){function e(e,t,n){this.statusCode=e,this.headers=t,this.info=n}return e.fromXHR=function(t){var n=t.responseText;try{n=JSON.parse(t.responseText)}catch(e){}return new e(t.status,r(t.getAllResponseHeaders()),n)},e}();t.ErrorResponse=o;var i=function(){return function(e){this.error=e}}();t.NetworkError=i,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,n){var r;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"}(r=t.LogLevel||(t.LogLevel={}));var o=function(){function e(e){void 0===e&&(e=2),this.threshold=e;var t=Array(),n="--------------------------------------------------------------------------------";window.console.group||(window.console.group=function(e){t.push(e),window.console.log("%c \nBEGIN GROUP: %c",n,e)}),window.console.groupEnd||(window.console.groupEnd=function(){window.console.log("END GROUP: %c\n%c",t.pop(),n)})}return e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.log,r.VERBOSE,e)},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.log,r.DEBUG,e)},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.info,r.INFO,e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.warn,r.WARNING,e)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.log(window.console.error,r.ERROR,e)},e.prototype.log=function(e,t,n){var o=this;if(t>=this.threshold){var i="Logger."+r[t];n.length>1?(window.console.group(),n.forEach(function(t){o.errorAwareLog(e,t,i)}),window.console.groupEnd()):this.errorAwareLog(e,n[0],i)}},e.prototype.errorAwareLog=function(e,t,n){if(void 0!==t&&t.info&&t.info.error_uri){var r=t.info.error_description;e((r||"An error has occurred")+". More information can be found at "+t.info.error_uri+". Error object: ",t)}else e(n+": ",t)},e}();t.ConsoleLogger=o;var i=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=i},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.createRetryStrategyOptionsOrDefault=function(e){var t=e.initialTimeoutMillis||1e3,n=e.maxTimeoutMillis||5e3,r=-1;return void 0!==e.limit&&null!=e.limit&&(r=e.limit),{increaseTimeout:void 0!==e.increaseTimeout?e.increaseTimeout:function(e){return 2*e>n?n:2*e},initialTimeoutMillis:t,limit:r,maxTimeoutMillis:n}};var o=function(){return function(e){this.waitTimeMillis=e}}();t.Retry=o;var i=function(){return function(e){this.error=e}}();t.DoNotRetry=i;var s=function(){function e(e,t,n){this.options=e,this.logger=t,this.retryUnsafeRequests=n,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 i(e)):e instanceof r.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 r.NetworkError||e instanceof r.ErrorResponse&&("GET"===(t=(t=e.headers["Request-Method"]).toUpperCase())||"HEAD"===t||"OPTIONS"===t||"SUBSCRIBE"===t)||this.retryUnsafeRequests?this.shouldSafeRetry(e):e instanceof r.NetworkError?this.shouldSafeRetry(e):(this.logger.verbose(this.constructor.name+": Error is not retryable",e),new i(e));var t},e.prototype.shouldSafeRetry=function(e){return e instanceof r.NetworkError?(this.logger.verbose(this.constructor.name+": It's a Network Error, will retry",e),new o(this.calulateMillisToRetry())):e instanceof r.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 i(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=s},function(e,t,n){var r=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(4),s=n(5),u=n(6),a=n(11),c=n(12),h=n(7),l=n(13),f=n(14),d=n(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 n=this;return e.tokenProvider?e.tokenProvider.fetchToken(t).then(function(t){return void 0!==e.headers?e.headers.Authorization="Bearer "+t:e.headers=((n={}).Authorization="Bearer "+t,n),e;var n}).then(function(e){return n.makeRequest(e)}):this.makeRequest(e)},e.prototype.subscribeResuming=function(e,t,n,o,i,u){var l=c.replaceMissingListenersWithNoOps(n),f=a.subscribeStrategyListenersFromSubscriptionListeners(l),p=!1;return s.createResumingStrategy(o,h.createTokenProvidingStrategy(d.createTransportStrategy(e,this.websocketTransport,this.logger),this.logger,u),this.logger,i)({onEnd:f.onEnd,onError:f.onError,onEvent:f.onEvent,onOpen:function(e){p||(p=!0,f.onOpen(e)),l.onSubscribe()},onRetrying:f.onRetrying},r({},t,this.infoHeaders()))},e.prototype.subscribeNonResuming=function(e,t,n,o,i){var s=c.replaceMissingListenersWithNoOps(n),l=a.subscribeStrategyListenersFromSubscriptionListeners(s),f=!1;return u.createRetryingStrategy(o,h.createTokenProvidingStrategy(d.createTransportStrategy(e,this.websocketTransport,this.logger),this.logger,i),this.logger)({onEnd:l.onEnd,onError:l.onError,onEvent:l.onEvent,onOpen:function(e){f||(f=!0,l.onOpen(e)),s.onSubscribe()},onRetrying:l.onRetrying},r({},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 i.executeNetworkRequest(function(){return t.httpTransport.request(r({},e,{headers:r({},e.headers,t.infoHeaders())}))},e).catch(function(e){throw t.logger.error(e),e})},e}();t.BaseClient=p},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function o(e,t,n){return e.onreadystatechange=function(){4===e.readyState&&(e.status>=200&&e.status<300?t(e.response):0!==e.status?n(r.ErrorResponse.fromXHR(e)):n(new r.NetworkError("No Connection")))},e}t.executeNetworkRequest=function(e,t){return new Promise(function(n,r){!function(e,t){t.json?e.send(JSON.stringify(t.json)):e.send(t.body)}(o(e(),n,r),t)})},t.sendRawRequest=function(e){return new Promise(function(t,n){var r=o(new window.XMLHttpRequest,t,n);if(r.open(e.method.toUpperCase(),e.url,!0),e.headers)for(var i in e.headers)e.headers.hasOwnProperty(i)&&r.setRequestHeader(i,e.headers[i]);r.send(e.body)})}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(2);t.createResumingStrategy=function(e,t,n,r){var s=o.createRetryStrategyOptionsOrDefault(e),u=new o.RetryResolution(s,n);return function(e,r){return new i(n,r,t,e,u)}};var i=function(){return function(e,t,n,r,o){var i=this;this.unsubscribe=function(){i.state.unsubscribe()},this.onTransition=function(e){i.state=e},this.state=new s(this.onTransition,e,t,n,r,o)}}(),s=function(){function e(e,t,n,r,o,i,s){var c=this;this.onTransition=e,this.logger=t,this.headers=n,this.nextSubscribeStrategy=r,this.listeners=o,this.retryResolution=i,this.initialEventId=s;var l=s;t.verbose("ResumingSubscription: transitioning to OpeningSubscriptionState"),l&&(n["Last-Event-Id"]=l,t.verbose("ResumingSubscription: initialEventId is "+l)),this.underlyingSubscription=r({onEnd:function(n){e(new h(t,o,n))},onError:function(s){e(new a(s,e,t,n,o,r,i,l))},onEvent:function(e){l=e.eventId,o.onEvent(e)},onOpen:function(n){e(new u(t,n,o,c.underlyingSubscription,e))},onRetrying:o.onRetrying},n)}return e.prototype.unsubscribe=function(){this.onTransition(new c(this.logger)),this.underlyingSubscription.unsubscribe()},e}(),u=function(){function e(e,t,n,r,o){this.logger=e,this.headers=t,this.listeners=n,this.underlyingSubscription=r,this.onTransition=o,e.verbose("ResumingSubscription: transitioning to OpenSubscriptionState"),n.onOpen(t)}return e.prototype.unsubscribe=function(){this.onTransition(new c(this.logger)),this.underlyingSubscription.unsubscribe()},e}(),a=function(){function e(e,t,n,i,s,a,c,f){var d=this;this.onTransition=t,this.logger=n,this.headers=i,this.listeners=s,this.nextSubscribeStrategy=a,this.retryResolution=c,n.verbose("ResumingSubscription: transitioning to ResumingSubscriptionState");var p=function(e,i){s.onRetrying();var u,a=((u=e)instanceof r.ErrorResponse&&(u.headers["Request-Method"]="SUBSCRIBE"),c.attemptRetry(u));a instanceof o.Retry?d.timeout=window.setTimeout(function(){g(i)},a.waitTimeMillis):t(new l(n,s,e))},g=function(e){n.verbose("ResumingSubscription: trying to re-establish the subscription"),e&&(n.verbose("ResumingSubscription: lastEventId: "+e),i["Last-Event-Id"]=e),d.underlyingSubscription=a({onEnd:function(e){t(new h(n,s,e))},onError:function(e){p(e,f)},onEvent:function(e){f=e.eventId,s.onEvent(e)},onOpen:function(e){t(new u(n,e,s,d.underlyingSubscription,t))},onRetrying:s.onRetrying},i)};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,n){this.logger=e,this.listeners=t,e.verbose("ResumingSubscription: transitioning to EndedSubscriptionState"),t.onEnd(n)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}(),l=function(){function e(e,t,n){this.logger=e,this.listeners=t,e.verbose("ResumingSubscription: transitioning to FailedSubscriptionState",n),t.onError(n)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}()},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(2);t.createRetryingStrategy=function(e,t,n){var r=o.createRetryStrategyOptionsOrDefault(e),s=new o.RetryResolution(r,n);return function(e,r){return new i(n,r,e,t,s)}};var i=function(){return function(e,t,n,r,o){var i=this;this.unsubscribe=function(){i.state.unsubscribe()},this.onTransition=function(e){i.state=e},this.state=new s(this.onTransition,e,t,n,r,o)}}(),s=function(){function e(e,t,n,r,o,i){var s=this;this.logger=t,this.headers=n,this.listeners=r,this.nextSubscribeStrategy=o,this.retryResolution=i,t.verbose("RetryingSubscription: transitioning to OpeningSubscriptionState"),this.underlyingSubscription=o({onEnd:function(n){return e(new c(t,r,n))},onError:function(s){return e(new u(s,e,t,n,r,o,i))},onEvent:r.onEvent,onOpen:function(n){return e(new a(t,r,n,s.underlyingSubscription,e))},onRetrying:r.onRetrying},n)}return e.prototype.unsubscribe=function(){throw this.underlyingSubscription.unsubscribe(),new Error("Method not implemented.")},e}(),u=function(){function e(e,t,n,i,s,u,l){var f=this;this.onTransition=t,this.logger=n,this.headers=i,this.listeners=s,this.nextSubscribeStrategy=u,this.retryResolution=l,n.verbose("RetryingSubscription: transitioning to RetryingSubscriptionState");var d=function(e){s.onRetrying();var i,u=((i=e)instanceof r.ErrorResponse&&(i.headers["Request-Method"]="SUBSCRIBE"),l.attemptRetry(i));u instanceof o.Retry?f.timeout=window.setTimeout(function(){p()},u.waitTimeMillis):t(new h(n,s,e))},p=function(){n.verbose("RetryingSubscription: trying to re-establish the subscription");var e=u({onEnd:function(e){return t(new c(n,s,e))},onError:function(e){return d(e)},onEvent:s.onEvent,onOpen:function(r){t(new a(n,s,r,e,t))},onRetrying:s.onRetrying},i)};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,n,r,o){this.logger=e,this.listeners=t,this.headers=n,this.underlyingSubscription=r,this.onTransition=o,e.verbose("RetryingSubscription: transitioning to OpenSubscriptionState"),t.onOpen(n)}return e.prototype.unsubscribe=function(){this.underlyingSubscription.unsubscribe(),this.onTransition(new c(this.logger,this.listeners))},e}(),c=function(){function e(e,t,n){this.logger=e,this.listeners=t,e.verbose("RetryingSubscription: transitioning to EndedSubscriptionState"),t.onEnd(n)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}(),h=function(){function e(e,t,n){this.logger=e,this.listeners=t,e.verbose("RetryingSubscription: transitioning to FailedSubscriptionState",n),t.onError(n)}return e.prototype.unsubscribe=function(){throw new Error("Subscription has already ended")},e}()},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.createTokenProvidingStrategy=function(e,t,n){return n?function(r,i){return new o(t,r,i,n,e)}:e};var o=function(){function e(e,t,n,r,o){var u=this;this.logger=e,this.listeners=t,this.headers=n,this.tokenProvider=r,this.nextSubscribeStrategy=o,this.unsubscribe=function(){u.state.unsubscribe(),u.state=new s(u.logger)},this.state=new i(e,n,o),this.subscribe()}return e.prototype.subscribe=function(){var e=this;this.tokenProvider.fetchToken().then(function(t){var n=Object.assign({},e.listeners);e.state.subscribe(t,{onEnd:function(t){e.state=new s(e.logger),n.onEnd(t)},onError:function(r){e.isTokenExpiredError(r)?(e.tokenProvider.clearToken(t),e.subscribe()):(e.state=new s(e.logger),n.onError(r))},onEvent:e.listeners.onEvent,onOpen:e.listeners.onOpen})}).catch(function(t){e.logger.debug("TokenProvidingSubscription: error when fetching token:",t),e.state=new s(e.logger),e.listeners.onError(t)})},e.prototype.isTokenExpiredError=function(e){return e instanceof r.ErrorResponse&&401===e.statusCode&&"authentication/expired"===e.info},e}(),i=function(){function e(e,t,n){this.logger=e,this.headers=t,this.nextSubscribeStrategy=n,e.verbose("TokenProvidingSubscription: transitioning to ActiveState")}return e.prototype.subscribe=function(e,t){var n=this;this.putTokenIntoHeader(e),this.underlyingSubscription=this.nextSubscribeStrategy({onEnd:function(e){n.logger.verbose("TokenProvidingSubscription: subscription ended"),t.onEnd(e)},onError:function(e){n.logger.verbose("TokenProvidingSubscription: subscription errored:",e),t.onError(e)},onEvent:t.onEvent,onOpen:function(e){n.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}(),s=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,n){Object.defineProperty(t,"__esModule",{value:!0}),t.createTransportStrategy=function(e,t,n){return function(n,r){return t.subscribe(e,n,r)}}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_BASE="pusherplatform.io"},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(3);t.BaseClient=r.BaseClient;var o=n(9);t.HOST_BASE=o.HOST_BASE;var i=n(15);t.Instance=i.default;var s=n(1);t.ConsoleLogger=s.ConsoleLogger,t.EmptyLogger=s.EmptyLogger;var u=n(0);t.ErrorResponse=u.ErrorResponse,t.NetworkError=u.NetworkError,t.responseToHeadersObject=u.responseToHeadersObject,t.XhrReadyState=u.XhrReadyState;var a=n(4);t.executeNetworkRequest=a.executeNetworkRequest,t.sendRawRequest=a.sendRawRequest;var c=n(5);t.createResumingStrategy=c.createResumingStrategy;var h=n(2);t.createRetryStrategyOptionsOrDefault=h.createRetryStrategyOptionsOrDefault,t.DoNotRetry=h.DoNotRetry,t.Retry=h.Retry,t.RetryResolution=h.RetryResolution;var l=n(6);t.createRetryingStrategy=l.createRetryingStrategy;var f=n(7);t.createTokenProvidingStrategy=f.createTokenProvidingStrategy;var d=n(8);t.createTransportStrategy=d.createTransportStrategy,t.default={BaseClient:r.BaseClient,ConsoleLogger:s.ConsoleLogger,EmptyLogger:s.EmptyLogger,Instance:i.default}},function(e,t,n){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,n){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,n){Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(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"}(r=t.HttpTransportState||(t.HttpTransportState={}));var i=function(){function e(e,t){var n=this;return this.gotEOS=!1,this.lastNewlineIndex=0,this.state=r.UNOPENED,this.xhr=e,this.listeners=t,this.xhr.onreadystatechange=function(){switch(n.xhr.readyState){case o.XhrReadyState.UNSENT:case o.XhrReadyState.OPENED:case o.XhrReadyState.HEADERS_RECEIVED:n.assertStateIsIn(r.OPENING);break;case o.XhrReadyState.LOADING:n.onLoading();break;case o.XhrReadyState.DONE:n.onDone()}},this.state=r.OPENING,this.xhr.send(),this}return e.prototype.unsubscribe=function(){this.state=r.ENDED,this.xhr.abort(),this.listeners.onEnd&&this.listeners.onEnd(null)},e.prototype.onLoading=function(){if(this.assertStateIsIn(r.OPENING,r.OPEN,r.ENDING),200===this.xhr.status){this.state===r.OPENING&&(this.state=r.OPEN,window.console.log(o.responseToHeadersObject(this.xhr.getAllResponseHeaders())),this.listeners.onOpen&&this.listeners.onOpen(o.responseToHeadersObject(this.xhr.getAllResponseHeaders()))),this.assertStateIsIn(r.OPEN);var e=this.onChunk();this.assertStateIsIn(r.OPEN,r.ENDING),e&&(this.state=r.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===r.OPENING&&(this.state=r.OPEN,this.listeners.onOpen&&this.listeners.onOpen(o.responseToHeadersObject(this.xhr.getAllResponseHeaders()))),this.assertStateIsIn(r.OPEN,r.ENDING);var e=this.onChunk();e?(this.state=r.ENDED,204===e.statusCode?this.listeners.onEnd&&this.listeners.onEnd(null):this.listeners.onError&&this.listeners.onError(e)):this.state<=r.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(r.OPENING,r.OPEN,r.ENDED),this.state===r.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(r.OPEN);var e=this.xhr.responseText,t=e.lastIndexOf("\n");if(t>this.lastNewlineIndex){var n=e.slice(this.lastNewlineIndex,t).split("\n");this.lastNewlineIndex=t;for(var o=0,i=n;o<i.length;o++){var s=i[o];if(0!==s.length){var u=JSON.parse(s),a=this.onMessage(u);if(null!=a)return a}}}},e.prototype.assertStateIsIn=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(!t.some(function(t){return t===e.state})){var o=t.map(function(e){return r[e]}).join(", "),i=r[this.state];window.console.warn("Expected this.state to be one of ["+o+"] but it is "+i)}},e.prototype.onMessage=function(e){switch(this.assertStateIsIn(r.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(r.OPEN),4!==e.length)return new Error("Event message has "+e.length+" elements (expected 4)");e[0];var t=e[1],n=e[2],o=e[3];return"string"!=typeof t?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)):(this.listeners.onEvent&&this.listeners.onEvent({body:o,headers:n,eventId:t}),null)},e.prototype.onEOSMessage=function(e){if(this.assertStateIsIn(r.OPEN),4!==e.length)return new Error("EOS message has "+e.length+" elements (expected 4)");e[0];var t=e[1],n=e[2],i=e[3];return"number"!=typeof t?new Error("Invalid EOS Status Code"):"object"!=typeof n||Array.isArray(n)?new Error("Invalid EOS ElementsHeaders"):(this.state=r.ENDING,new o.ErrorResponse(t,n,i))},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}(),s=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,n){var r={headers:n,method:"SUBSCRIBE",path:e};return new i(this.createXHR(this.baseURL,r),t)},e.prototype.createXHR=function(e,t){var n=new window.XMLHttpRequest,r=e+"/"+t.path.replace(/^\/+/,"");if(n.open(t.method.toUpperCase(),r,!0),n=this.setJSONHeaderIfAppropriate(n,t),t.jwt&&n.setRequestHeader("authorization","Bearer "+t.jwt),t.headers)for(var o in t.headers)t.headers.hasOwnProperty(o)&&n.setRequestHeader(o,t.headers[o]);return n},e.prototype.setJSONHeaderIfAppropriate=function(e,t){return t.json&&e.setRequestHeader("content-type","application/json"),e},e}();t.default=s},function(e,t,n){var r=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};Object.defineProperty(t,"__esModule",{value:!0});var o,i=n(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 s=function(){function e(){this.subscriptions={}}return e.prototype.add=function(e,t,n,r){return this.subscriptions[e]={headers:r,listeners:n,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 r({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 s,this.pendingSubscriptions=new s,this.connect()}return e.prototype.subscribe=function(e,t,n){this.tryReconnectIfNeeded();var r=this.lastSubscriptionID++;return this.socket.readyState!==o.Open?(this.pendingSubscriptions.add(r,e,t,n),new u(this,r)):(this.subscriptions.add(r,e,t,n),this.sendMessage(this.getMessage(100,r,e,n)),new u(this,r))},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 n=t.subID,r=t.path,o=t.listeners,i=t.headers;e.subscribePending(r,o,i,n)}),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 i.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 i.NetworkError("Connection was lost."))},this.socket.onclose=function(t){if(e.forcedClose){var n=e.closedError?function(t){t.listeners.onError&&t.listeners.onError(e.closedError)}:function(e){e.listeners.onEnd&&e.listeners.onEnd(null)},r=!1===e.pendingSubscriptions.isEmpty()?e.pendingSubscriptions:e.subscriptions;r.getAllAsArray().forEach(n),r.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,n,r){void 0!==r?(this.subscriptions.add(r,e,t,n),this.sendMessage(this.getMessage(100,r,e,n))):window.console.logger.debug("Subscription to path "+e+" has an undefined ID")},e.prototype.getMessage=function(e,t,n,r){return[e,t,n,r]},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 n=this.validateMessage(t);if(n)this.close(new Error(n.message));else{var r=t.shift();switch(r){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(),i=this.subscription(o);if(i){var s=i.listeners;switch(r){case 101:this.onOpenMessage(t,o,s);break;case 102:this.onEventMessage(t,s);break;case 199:this.onEOSMessage(t,o,s);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,n){n.onOpen&&n.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 n=e[0],r=e[1],o=e[2];return"string"!=typeof n?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)):void(t.onEvent&&t.onEvent({eventId:n,headers:r,body:o}))},e.prototype.onEOSMessage=function(e,t,n){if(this.subscriptions.remove(t),3===e.length){var r=e[0],o=e[1],s=e[2];"number"==typeof r?"object"!=typeof o||Array.isArray(o)?n.onError&&n.onError(new Error("Invalid EOS ElementsHeaders")):204!==r?n.onError&&n.onError(new i.ErrorResponse(r,o,s)):n.onEnd&&n.onEnd(null):n.onError&&n.onError(new Error("Invalid EOS Status Code"))}else n.onError&&n.onError(new Error("EOS message has "+e.length+" elements (expected 4)"))},e.prototype.onCloseMessage=function(e){var t=e[0],n=e[1];e[2];return"number"!=typeof t?this.close(new Error("Close message: Invalid EOS Status Code")):"object"!=typeof n||Array.isArray(n)?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 i.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,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(9),i=n(1),s=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 i.ConsoleLogger,this.client=e.client||new r.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||{},n=e.retryStrategyOptions||{},r=e.tokenProvider||this.tokenProvider;return this.client.subscribeNonResuming(this.absPath(e.path),t,e.listeners,n,r)},e.prototype.subscribeResuming=function(e){var t=e.headers||{},n=e.retryStrategyOptions||{},r=e.tokenProvider||this.tokenProvider;return this.client.subscribeResuming(this.absPath(e.path),t,e.listeners,n,e.initialEventId,r)},e.prototype.absPath=function(e){return("/services/"+this.serviceName+"/"+this.serviceVersion+"/"+this.id+"/"+e).replace(/\/+/g,"/").replace(/\/+$/,"")},e}();t.default=s}])},e.exports=n()}(e={exports:{}},e.exports),e.exports);(t=n)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")&&t.default;var r=n.BaseClient,o=n.HOST_BASE,i=n.Instance,s=n.sendRawRequest;function u(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function a(e){return function t(n){return 0===arguments.length||u(n)?t:e.apply(this,arguments)}}function c(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return u(n)?t:a(function(t){return e(n,t)});default:return u(n)&&u(r)?t:u(n)?a(function(t){return e(t,r)}):u(r)?a(function(t){return e(n,t)}):e(n,r)}}}function h(e,t){var n;e=e||[],t=t||[];var r=e.length,o=t.length,i=[];for(n=0;n<r;)i[i.length]=e[n],n+=1;for(n=0;n<o;)i[i.length]=t[n],n+=1;return i}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,n){return t.apply(this,arguments)};case 3:return function(e,n,r){return t.apply(this,arguments)};case 4:return function(e,n,r,o){return t.apply(this,arguments)};case 5:return function(e,n,r,o,i){return t.apply(this,arguments)};case 6:return function(e,n,r,o,i,s){return t.apply(this,arguments)};case 7:return function(e,n,r,o,i,s,u){return t.apply(this,arguments)};case 8:return function(e,n,r,o,i,s,u,a){return t.apply(this,arguments)};case 9:return function(e,n,r,o,i,s,u,a,c){return t.apply(this,arguments)};case 10:return function(e,n,r,o,i,s,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,n){return function(){for(var r=[],o=0,i=e,s=0;s<t.length||o<arguments.length;){var a;s<t.length&&(!u(t[s])||o>=arguments.length)?a=t[s]:(a=arguments[o],o+=1),r[s]=a,u(a)||(i-=1),s+=1}return i<=0?n.apply(this,r):l(i,f(e,r,n))}}var d=c(function(e,t){return 1===e?a(t):l(e,f(e,[],t))});function p(e){return function t(n,r,o){switch(arguments.length){case 0:return t;case 1:return u(n)?t:c(function(t,r){return e(n,t,r)});case 2:return u(n)&&u(r)?t:u(n)?c(function(t,n){return e(t,r,n)}):u(r)?c(function(t,r){return e(n,t,r)}):a(function(t){return e(n,r,t)});default:return u(n)&&u(r)&&u(o)?t:u(n)&&u(r)?c(function(t,n){return e(t,n,o)}):u(n)&&u(o)?c(function(t,n){return e(t,r,n)}):u(r)&&u(o)?c(function(t,r){return e(n,t,r)}):u(n)?a(function(t){return e(t,r,o)}):u(r)?a(function(t){return e(n,t,o)}):u(o)?a(function(t){return e(n,r,t)}):e(n,r,o)}}}var g=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function m(e,t,n){return function(){if(0===arguments.length)return n();var r=Array.prototype.slice.call(arguments,0),o=r.pop();if(!g(o)){for(var i=0;i<e.length;){if("function"==typeof o[e[i]])return o[e[i]].apply(o,r);i+=1}if(function(e){return"function"==typeof e["@@transducer/step"]}(o))return t.apply(null,r)(o)}return n.apply(this,arguments)}}var v={init:function(){return this.xf["@@transducer/init"]()},result:function(e){return this.xf["@@transducer/result"](e)}},y=c(function(e,t){return t>e?t:e});function b(e,t){for(var n=0,r=t.length,o=Array(r);n<r;)o[n]=e(t[n]),n+=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,n){for(var r=n.next();!r.done;){if((t=e["@@transducer/step"](t,r.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r=n.next()}return e["@@transducer/result"](t)}function O(e,t,n,r){return e["@@transducer/result"](n[r](R(e["@@transducer/step"],e),t))}var T="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function N(e,t,n){if("function"==typeof e&&(e=I(e)),w(n))return function(e,t,n){for(var r=0,o=n.length;r<o;){if((t=e["@@transducer/step"](t,n[r]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r+=1}return e["@@transducer/result"](t)}(e,t,n);if("function"==typeof n["fantasy-land/reduce"])return O(e,t,n,"fantasy-land/reduce");if(null!=n[T])return k(e,t,n[T]());if("function"==typeof n.next)return k(e,t,n);if("function"==typeof n.reduce)return O(e,t,n,"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 j=Object.prototype.toString,U=function(){return"[object Arguments]"===j.call(arguments)?function(e){return"[object Arguments]"===j.call(e)}:function(e){return A("callee",e)}},M=!{toString:null}.propertyIsEnumerable("toString"),C=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],x=function(){return arguments.propertyIsEnumerable("length")}(),D=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1},q=a("function"!=typeof Object.keys||x?function(e){if(Object(e)!==e)return[];var t,n,r=[],o=x&&U(e);for(t in e)!A(t,e)||o&&"length"===t||(r[r.length]=t);if(M)for(n=C.length-1;n>=0;)A(t=C[n],e)&&!D(r,t)&&(r[r.length]=t),n-=1;return r}: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(n,r){return n[r]=e(t[r]),n},{},q(t));default:return b(e,t)}})),L=c(function(e,t){for(var n=t,r=0;r<e.length;){if(null==n)return;n=n[e[r]],r+=1}return n}),H=c(function(e,t){return L([e],t)}),G=p(N),J=c(function(e,t){return h(t,[e])}),F=a(function(e){for(var t=q(e),n=t.length,r=[],o=0;o<n;)r[o]=e[t[o]],o+=1;return r});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,n){var r=e["@@transducer/step"](t,n);return r["@@transducer/reduced"]?{"@@transducer/value":r,"@@transducer/reduced":!0}:r}}}(e);return{"@@transducer/init":v.init,"@@transducer/result":function(e){return t["@@transducer/result"](e)},"@@transducer/step":function(e,n){return w(n)?N(t,e,n):N(t,e,[n])}}},V=c(m(["fantasy-land/chain","chain"],c(function(e,t){return B(e,X(t))}),function(e,t){return"function"==typeof t?function(n){return e(t(n))(n)}:(n=!1,function e(t){for(var r,o,i,s=[],u=0,a=t.length;u<a;){if(w(t[u]))for(i=0,o=(r=n?e(t[u]):t[u]).length;i<o;)s[s.length]=r[i],i+=1;else s[s.length]=t[u];u+=1}return s})(B(e,t));var n})),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 n=arguments.length;if(0===n)return t();var r=arguments[n-1];return g(r)||"function"!=typeof r[e]?t.apply(this,arguments):r[e].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var Y=p($("slice",function(e,t,n){return Array.prototype.slice.call(n,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 ne(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function re(e,t,n){for(var r=0,o=n.length;r<o;){if(e(t,n[r]))return!0;r+=1}return!1}var oe=c(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t});function ie(e,t,n,r){var o=ne(e);function i(e,t){return se(e,t,n.slice(),r.slice())}return!re(function(e,t){return!re(i,t,e)},ne(t),o)}function se(e,t,n,r){if(oe(e,t))return!0;var o,i,s=W(e);if(s!==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(s){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(o=e.constructor,null==(i=String(o).match(/^function (\w*)/))?"":i[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=n.length-1;u>=0;){if(n[u]===e)return r[u]===t;u-=1}switch(s){case"Map":return e.size===t.size&&ie(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size===t.size&&ie(e.values(),t.values(),n.concat([e]),r.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=n.concat([e]),h=r.concat([t]);for(u=a.length-1;u>=0;){var l=a[u];if(!A(l,t)||!se(t[l],e[l],c,h))return!1;u-=1}return!0}var ue=c(function(e,t){return se(e,t,[],[])});function ae(e,t){return function(e,t,n){var r,o;if("function"==typeof e.indexOf)switch(typeof t){case"number":if(0===t){for(r=1/t;n<e.length;){if(0===(o=e[n])&&1/o===r)return n;n+=1}return-1}if(t!=t){for(;n<e.length;){if("number"==typeof(o=e[n])&&o!=o)return n;n+=1}return-1}return e.indexOf(t,n);case"string":case"boolean":case"function":case"undefined":return e.indexOf(t,n);case"object":if(null===t)return e.indexOf(t,n)}for(;n<e.length;){if(ue(e[n],t))return n;n+=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(n,r){return e(t[r])&&(n[r]=t[r]),n},{},q(t)):function(e,t){for(var n=0,r=t.length,o=[];n<r;)e(t[n])&&(o[o.length]=t[n]),n+=1;return o}(e,t)})),ge=c(function(e,t){return pe((n=e,function(){return!n.apply(this,arguments)}),t);var n});var me=a(function(e){return function e(t,n){var r=function(r){var o=n.concat([t]);return ae(r,o)?"<Circular>":e(r,o)},o=function(e,t){return b(function(t){return ce(t)+": "+r(e[t])},t.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+b(r,t).join(", ")+"))";case"[object Array]":return"["+b(r,t).concat(o(t,ge(function(e){return/^\d+$/.test(e)},q(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(NaN):ce(le(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":ce(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var i=t.toString();if("[object Object]"!==i)return i}return"{"+o(t,q(t)).join(", ")+"}"}}(e,[])}),ve=c(ae),ye=function(){function e(e,t,n,r){this.valueFn=e,this.valueAcc=t,this.keyFn=n,this.xf=r,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 n=this.keyFn(t);return this.inputs[n]=this.inputs[n]||[n,this.valueAcc],this.inputs[n][1]=this.valueFn(this.inputs[n][1],t),e},e}(),be=f(4,[],m([],f(4,[],function(e,t,n,r){return new ye(e,t,n,r)}),function(e,t,n,r){return N(function(r,o){var i=n(o);return r[i]=e(A(i,r)?r[i]:t,o),r},{},r)})),Se=c(function(e,t){for(var n=[],r=0,o=e.length;r<o;)ae(e[r],t)||ae(e[r],n)||(n[n.length]=e[r]),r+=1;return n}),we=c(function(e,t){var n=e<0?t.length+e:e;return S(t)?t.charAt(n):t[n]}),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)?{}:U(e)?function(){return arguments}():void 0}),Ie=c($("forEach",function(e,t){for(var n=t.length,r=0;r<n;)e(t[r]),r+=1;return t})),Re=c(function(e,t){for(var n=q(t),r=0;r<n.length;){var o=n[r];e(t[o],o,t),r+=1}return t}),ke=a(function(e){for(var t={},n=0;n<e.length;)t[e[n][0]]=e[n][1],n+=1;return t}),Oe=c(A),Te=we(0);function Ne(e){return e}var Pe=a(Ne),_e=be(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!je(e,!0,this)},e.prototype.has=function(e){return je(e,!1,this)},e}();function je(e,t,n){var r,o=typeof e;switch(o){case"string":case"number":return 0===e&&1/e==-1/0?!!n._items["-0"]||(t&&(n._items["-0"]=!0),!1):null!==n._nativeSet?t?(r=n._nativeSet.size,n._nativeSet.add(e),n._nativeSet.size===r):n._nativeSet.has(e):o in n._items?e in n._items[o]||(t&&(n._items[o][e]=!0),!1):(t&&(n._items[o]={},n._items[o][e]=!0),!1);case"boolean":if(o in n._items){var i=e?1:0;return!!n._items[o][i]||(t&&(n._items[o][i]=!0),!1)}return t&&(n._items[o]=e?[!1,!0]:[!0,!1]),!1;case"function":return null!==n._nativeSet?t?(r=n._nativeSet.size,n._nativeSet.add(e),n._nativeSet.size===r):n._nativeSet.has(e):o in n._items?!!ae(e,n._items[o])||(t&&n._items[o].push(e),!1):(t&&(n._items[o]=[e]),!1);case"undefined":return!!n._items[o]||(t&&(n._items[o]=!0),!1);case"object":if(null===e)return!!n._items.null||(t&&(n._items.null=!0),!1);default:return(o=Object.prototype.toString.call(e))in n._items?!!ae(e,n._items[o])||(t&&n._items[o].push(e),!1):(t&&(n._items[o]=[e]),!1)}}var Ue=c(function(e,t){for(var n,r,o=new Ae,i=[],s=0;s<t.length;)n=e(r=t[s]),o.add(n)&&i.push(r),s+=1;return i})(Pe),Me=c(function(e,t){return d(e+1,function(){var n,r=arguments[e];if(null!=r&&(n=r[t],"[object Function]"===Object.prototype.toString.call(n)))return r[t].apply(r,Array.prototype.slice.call(arguments,0,e));throw new TypeError(me(r)+' does not have a method named "'+t+'"')})}),Ce=a(function(e){return null!=e&&ue(e,Ee(e))}),xe=Me(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 n={},r=0;r<e.length;)e[r]in t&&(n[e[r]]=t[e[r]]),r+=1;return n}),Be=c(function(e,t){return Array.prototype.slice.call(t,0).sort(e)}),Le=Me(1,"split"),He=a(function(e){var t=[];for(var n in e)A(n,e)&&(t[t.length]=[n,e[n]]);return t}),Ge="\t\n\v\f\r   ᠎