2 | !function(u,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("rxjs")):"function"==typeof define&&define.amd?define(["rxjs"],t):"object"==typeof exports?exports.Horizon=t(require("rxjs")):u.Horizon=t(u.Rx)}(this,function(u){return function(u){function t(n){if(e[n])return e[n].exports;var r=e[n]={exports:{},id:n,loaded:!1};return u[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var e={};return t.m=u,t.c=e,t.p="",t(0)}([function(u,t,e){"use strict";function n(){function u(u){return new l(t,u,y)}function t(u,t){var e,n="removeAll"===u?"remove":u;return(e=(e=_.makeRequest({type:n,options:t}),s.concatMap).call(e,function(u){return u.data?o.from.call(c,u.data):o.from.call(c,[{state:u.state,type:u.type}])}),i._catch).call(e,function(u){return c.create(function(t){t.error(u)})})}var e,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],f=n.host,A=void 0===f?v:f,d=n.secure,F=void 0===d?b:d,p=n.path,C=void 0===p?"horizon":p,h=n.lazyWrites,y=void 0===h?!1:h,m=n.authType,w=void 0===m?"unauthenticated":m,g=new D(w);g.setAuthFromQueryParams();var _=new E(A,F,C,g.handshake.bind(g));return _.handshake.subscribe(function(u){return g.set(u.token)}),u.dispose=function(){_.complete()},u.connect=function(){var u=arguments.length<=0||void 0===arguments[0]?function(u){console.error("Received an error: "+u)}:arguments[0];_.subscribe(function(){},u)},u.status=r(_.status),u.onDisconnected=r((e=_.status,a.filter).call(e,function(u){return"disconnected"===u.type})),u.onConnected=r((e=_.status,a.filter).call(e,function(u){return"connected"===u.type})),u.onReady=r((e=_.status,a.filter).call(e,function(u){return"ready"===u.type})),u.onSocketError=r((e=_.status,a.filter).call(e,function(u){return"error"===u.type})),u._authMethods=null,u._horizonPath=C,u.authEndpoint=B,u.hasAuthToken=g.hasAuthToken.bind(g),u}function r(u){return function(){return arguments.length>0?u.subscribe.apply(u,arguments):u}}var o=e(1),i=e(1),s=e(1),a=e(1),f=e(1),c=f.Observable,A=e(46),l=A.Collection,E=e(49),d=e(32),F=d.log,p=d.logError,C=d.enableLogging,h=e(47),B=h.authEndpoint,D=h.TokenStorage,y=h.clearAuthTokens,v="undefined"!=typeof window&&window.location&&""+window.location.host||"localhost:8181",b="undefined"!=typeof window&&window.location&&"https:"===window.location.protocol||!1;n.log=F,n.logError=p,n.enableLogging=C,n.Socket=E,n.clearAuthTokens=y,u.exports=n},function(t,e){t.exports=u},function(u,t){var e=u.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(u,t){var e={}.hasOwnProperty;u.exports=function(u,t){return e.call(u,t)}},function(u,t,e){var n=e(68),r=e(19);u.exports=function(u){return n(r(u))}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}t.__esModule=!0;var r=e(58),o=n(r),i=e(57),s=n(i),a="function"==typeof s["default"]&&"symbol"==typeof o["default"]?function(u){return typeof u}:function(u){return u&&"function"==typeof s["default"]&&u.constructor===s["default"]?"symbol":typeof u};t["default"]="function"==typeof s["default"]&&"symbol"===a(o["default"])?function(u){return"undefined"==typeof u?"undefined":a(u)}:function(u){return u&&"function"==typeof s["default"]&&u.constructor===s["default"]?"symbol":"undefined"==typeof u?"undefined":a(u)}},function(u,t,e){u.exports=!e(14)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(u,t,e){var n=e(8),r=e(16);u.exports=e(6)?function(u,t,e){return n.f(u,t,r(1,e))}:function(u,t,e){return u[t]=e,u}},function(u,t,e){var n=e(10),r=e(39),o=e(29),i=Object.defineProperty;t.f=e(6)?Object.defineProperty:function(u,t,e){if(n(u),t=o(t,!0),n(e),r)try{return i(u,t,e)}catch(s){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(u[t]=e.value),u}},function(u,t,e){var n=e(27)("wks"),r=e(17),o=e(2).Symbol,i="function"==typeof o,s=u.exports=function(u){return n[u]||(n[u]=i&&o[u]||(i?o:r)("Symbol."+u))};s.store=n},function(u,t,e){var n=e(12);u.exports=function(u){if(!n(u))throw TypeError(u+" is not an object!");return u}},function(u,t){var e=u.exports={version:"2.3.0"};"number"==typeof __e&&(__e=e)},function(u,t){u.exports=function(u){return"object"==typeof u?null!==u:"function"==typeof u}},function(u,t,e){var n=e(2),r=e(11),o=e(37),i=e(7),s="prototype",a=function(u,t,e){var f,c,A,l=u&a.F,E=u&a.G,d=u&a.S,F=u&a.P,p=u&a.B,C=u&a.W,h=E?r:r[t]||(r[t]={}),B=h[s],D=E?n:d?n[t]:(n[t]||{})[s];E&&(e=t);for(f in e)c=!l&&D&&void 0!==D[f],c&&f in h||(A=c?D[f]:e[f],h[f]=E&&"function"!=typeof D[f]?e[f]:p&&c?o(A,n):C&&D[f]==A?function(u){var t=function(t,e,n){if(this instanceof u){switch(arguments.length){case 0:return new u;case 1:return new u(t);case 2:return new u(t,e)}return new u(t,e,n)}return u.apply(this,arguments)};return t[s]=u[s],t}(A):F&&"function"==typeof A?o(Function.call,A):A,F&&((h.virtual||(h.virtual={}))[f]=A,u&a.R&&B&&!B[f]&&i(B,f,A)))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,u.exports=a},function(u,t){u.exports=function(u){try{return!!u()}catch(t){return!0}}},function(u,t,e){var n=e(44),r=e(20);u.exports=Object.keys||function(u){return n(u,r)}},function(u,t){u.exports=function(u,t){return{enumerable:!(1&u),configurable:!(2&u),writable:!(4&u),value:t}}},function(u,t){var e=0,n=Math.random();u.exports=function(u){return"Symbol(".concat(void 0===u?"":u,")_",(++e+n).toString(36))}},function(u,t){"use strict";t.__esModule=!0,t["default"]=function(u,t){if(!(u instanceof t))throw new TypeError("Cannot call a class as a function")}},function(u,t){u.exports=function(u){if(void 0==u)throw TypeError("Can't call method on "+u);return u}},function(u,t){u.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(u,t){u.exports={}},function(u,t){u.exports=!0},function(u,t,e){var n=e(10),r=e(74),o=e(20),i=e(26)("IE_PROTO"),s=function(){},a="prototype",f=function(){var u,t=e(38)("iframe"),n=o.length,r=">";for(t.style.display="none",e(67).appendChild(t),t.src="javascript:",u=t.contentWindow.document,u.open(),u.write("<script>document.F=Object</script"+r),u.close(),f=u.F;n--;)delete f[a][o[n]];return f()};u.exports=Object.create||function(u,t){var e;return null!==u?(s[a]=n(u),e=new s,s[a]=null,e[i]=u):e=f(),void 0===t?e:r(e,t)}},function(u,t){t.f={}.propertyIsEnumerable},function(u,t,e){var n=e(8).f,r=e(3),o=e(9)("toStringTag");u.exports=function(u,t,e){u&&!r(u=e?u:u.prototype,o)&&n(u,o,{configurable:!0,value:t})}},function(u,t,e){var n=e(27)("keys"),r=e(17);u.exports=function(u){return n[u]||(n[u]=r(u))}},function(u,t,e){var n=e(2),r="__core-js_shared__",o=n[r]||(n[r]={});u.exports=function(u){return o[u]||(o[u]={})}},function(u,t){var e=Math.ceil,n=Math.floor;u.exports=function(u){return isNaN(u=+u)?0:(u>0?n:e)(u)}},function(u,t,e){var n=e(12);u.exports=function(u,t){if(!n(u))return u;var e,r;if(t&&"function"==typeof(e=u.toString)&&!n(r=e.call(u)))return r;if("function"==typeof(e=u.valueOf)&&!n(r=e.call(u)))return r;if(!t&&"function"==typeof(e=u.toString)&&!n(r=e.call(u)))return r;throw TypeError("Can't convert object to primitive value")}},function(u,t,e){var n=e(2),r=e(11),o=e(22),i=e(31),s=e(8).f;u.exports=function(u){var t=r.Symbol||(r.Symbol=o?{}:n.Symbol||{});"_"==u.charAt(0)||u in t||s(t,u,{value:i.f(u)})}},function(u,t,e){t.f=e(9)},function(u,t){"use strict";var e=!1;u.exports={log:function(){var u;return e?(u=console).log.apply(u,arguments):void 0},logError:function(){var u;return e?(u=console).error.apply(u,arguments):void 0},enableLogging:function(){var u=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];e=u}}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u){return Object.keys(u).forEach(function(t){u[t]=o(u[t])}),u}function o(u){if(null==u)return u;if(-1!==c.indexOf("undefined"==typeof u?"undefined":(0,f["default"])(u)))return u;if(Array.isArray(u))return u.map(o);if("TIME"===u.$reql_type$){var t=new Date;return t.setTime(1e3*u.epoch_time),t}return r(u)}function i(u){return Object.keys(u).forEach(function(t){u[t]=s(u[t])}),u}function s(u){return null==u?u:-1!==c.indexOf("undefined"==typeof u?"undefined":(0,f["default"])(u))?u:Array.isArray(u)?u.map(s):u instanceof Date?{$reql_type$:"TIME",epoch_time:u.getTime()/1e3,timezone:"Z"}:i(u)}t.__esModule=!0;var a=e(5),f=n(a);t.deserialize=o,t.serialize=s;var c=["string","number","boolean","function","symbol"]},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}t.__esModule=!0;var r=e(56),o=n(r),i=e(55),s=n(i),a=e(5),f=n(a);t["default"]=function(u,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":(0,f["default"])(t)));u.prototype=(0,s["default"])(t&&t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),t&&(o["default"]?(0,o["default"])(u,t):u.__proto__=t)}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}t.__esModule=!0;var r=e(5),o=n(r);t["default"]=function(u,t){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":(0,o["default"])(t))&&"function"!=typeof t?u:t}},function(u,t){var e={}.toString;u.exports=function(u){return e.call(u).slice(8,-1)}},function(u,t,e){var n=e(63);u.exports=function(u,t,e){if(n(u),void 0===t)return u;switch(e){case 1:return function(e){return u.call(t,e)};case 2:return function(e,n){return u.call(t,e,n)};case 3:return function(e,n,r){return u.call(t,e,n,r)}}return function(){return u.apply(t,arguments)}}},function(u,t,e){var n=e(12),r=e(2).document,o=n(r)&&n(r.createElement);u.exports=function(u){return o?r.createElement(u):{}}},function(u,t,e){u.exports=!e(6)&&!e(14)(function(){return 7!=Object.defineProperty(e(38)("div"),"a",{get:function(){return 7}}).a})},function(u,t,e){"use strict";var n=e(22),r=e(13),o=e(45),i=e(7),s=e(3),a=e(21),f=e(70),c=e(25),A=e(76),l=e(9)("iterator"),E=!([].keys&&"next"in[].keys()),d="@@iterator",F="keys",p="values",C=function(){return this};u.exports=function(u,t,e,h,B,D,y){f(e,t,h);var v,b,m,w=function(u){if(!E&&u in O)return O[u];switch(u){case F:return function(){return new e(this,u)};case p:return function(){return new e(this,u)}}return function(){return new e(this,u)}},g=t+" Iterator",_=B==p,x=!1,O=u.prototype,S=O[l]||O[d]||B&&O[B],j=S||w(B),T=B?_?w("entries"):j:void 0,k="Array"==t?O.entries||S:S;if(k&&(m=A(k.call(new u)),m!==Object.prototype&&(c(m,g,!0),n||s(m,l)||i(m,l,C))),_&&S&&S.name!==p&&(x=!0,j=function(){return S.call(this)}),n&&!y||!E&&!x&&O[l]||i(O,l,j),a[t]=j,a[g]=C,B)if(v={values:_?j:w(p),keys:D?j:w(F),entries:T},y)for(b in v)b in O||o(O,b,v[b]);else r(r.P+r.F*(E||x),t,v);return v}},function(u,t,e){var n=e(24),r=e(16),o=e(4),i=e(29),s=e(3),a=e(39),f=Object.getOwnPropertyDescriptor;t.f=e(6)?f:function(u,t){if(u=o(u),t=i(t,!0),a)try{return f(u,t)}catch(e){}return s(u,t)?r(!n.f.call(u,t),u[t]):void 0}},function(u,t,e){var n=e(44),r=e(20).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(u){return n(u,r)}},function(u,t){t.f=Object.getOwnPropertySymbols},function(u,t,e){var n=e(3),r=e(4),o=e(65)(!1),i=e(26)("IE_PROTO");u.exports=function(u,t){var e,s=r(u),a=0,f=[];for(e in s)e!=i&&n(s,e)&&f.push(e);for(;t.length>a;)n(s,e=t[a++])&&(~o(f,e)||f.push(e));return f}},function(u,t,e){u.exports=e(7)},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u){if(-1===this._legalMethods.indexOf(u))throw new Error(u+" cannot be called on the current query");if((0,b["default"])(u)in this._query)throw new Error(u+" has already been called on this query")}function o(u,t){var e=Boolean(t.find);if(!e){var n,r={emitted:!1,val:[]};return(n=(n=B.scan.call(u,function(u,t){return"synced"===t.state&&(u.emitted=!0),u.val=i(u.val.slice(),t),u},r),D.filter).call(n,function(u){return u.emitted}),y.map).call(n,function(u){return u.val})}var o=function(){var t,e=!1,n=null;return{v:(t=D.filter.call(u,function(u){return!e||"state"!==u.type}),B.scan).call(t,function(u,t){return e=!0,"synced"===t.state?u:t.new_val},n)}}();return"object"===("undefined"==typeof o?"undefined":(0,E["default"])(o))?o.v:void 0}function i(u,t){switch(t.type){case"remove":case"uninitial":if(null!=t.old_offset)u.splice(t.old_offset,1);else{var e=u.findIndex(function(u){return u.id===t.old_val.id});u.splice(e,1)}break;case"add":case"initial":null!=t.new_offset?u.splice(t.new_offset,0,t.new_val):u.push(t.new_val);break;case"change":if(null!=t.old_offset&&u.splice(t.old_offset,1),null!=t.new_offset)u.splice(t.new_offset,0,t.new_val);else{var n=u.findIndex(function(u){return u.id===t.old_val.id});u[n]=t.new_val}break;case"state":break;default:throw new Error("unrecognized 'type' field from server "+JSON.stringify(t))}return u}function s(u,t,e){(0,w["default"])(u,t);var n=e;if(Array.isArray(e)){if(0===e.length)return C.empty.call(p.Observable)}else n=[e];var r=Object.assign({},this._query,{data:(0,x.serialize)(n)}),o=this._sendRequest(u,r);if(!this._lazyWrites){var i;o=(i=o,h.publishReplay).call(i).refCount(),o.subscribe()}return o}var a=e(35),f=n(a),c=e(34),A=n(c),l=e(5),E=n(l),d=e(18),F=n(d),p=e(1),C=e(1),h=e(1),B=e(1),D=e(1),y=e(1),v=e(98),b=n(v),m=e(50),w=n(m),g=e(54),_=n(g),x=e(33),O=function(){function u(t,e,n){(0,F["default"])(this,u),this._sendRequest=t,this._query=e,this._legalMethods=n}return u.prototype.watch=function(){var u=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=u.rawChanges,e=void 0===t?!1:t,n=this._sendRequest("subscribe",this._query);return e?n:o(n,this._query)},u.prototype.fetch=function(){return this._sendRequest("query",this._query)},u.prototype.findAll=function(){for(var u=arguments.length,t=Array(u),e=0;u>e;e++)t[e]=arguments[e];return r.call(this,"findAll"),(0,w["default"])("findAll",arguments,{maxArgs:100}),new T(this._sendRequest,this._query,t)},u.prototype.find=function(u){return r.call(this,"find"),(0,w["default"])("find",arguments),new j(this._sendRequest,this._query,u)},u.prototype.order=function(u){var t=arguments.length<=1||void 0===arguments[1]?"ascending":arguments[1];return r.call(this,"order"),(0,w["default"])("order",arguments,{minArgs:1,maxArgs:2}),new M(this._sendRequest,this._query,u,t)},u.prototype.above=function(u){var t=arguments.length<=1||void 0===arguments[1]?"closed":arguments[1];return r.call(this,"above"),(0,w["default"])("above",arguments,{minArgs:1,maxArgs:2}),new k(this._sendRequest,this._query,u,t)},u.prototype.below=function(u){var t=arguments.length<=1||void 0===arguments[1]?"open":arguments[1];return r.call(this,"below"),(0,w["default"])("below",arguments,{minArgs:1,maxArgs:2}),new P(this._sendRequest,this._query,u,t)},u.prototype.limit=function(u){return r.call(this,"limit"),(0,w["default"])("limit",arguments),new R(this._sendRequest,this._query,u)},u}(),S=function(u){function t(e,n,r){(0,F["default"])(this,t);var o={collection:n},i=["find","findAll","justInitial","order","above","below","limit"],s=(0,f["default"])(this,u.call(this,e,o,i));return s._lazyWrites=r,s}return(0,A["default"])(t,u),t.prototype.store=function(u){return s.call(this,"store",arguments,u)},t.prototype.upsert=function(u){return s.call(this,"upsert",arguments,u)},t.prototype.insert=function(u){return s.call(this,"insert",arguments,u)},t.prototype.replace=function(u){return s.call(this,"replace",arguments,u)},t.prototype.update=function(u){return s.call(this,"update",arguments,u)},t.prototype.remove=function(u){var t=(0,_["default"])(u)?{id:u}:u;return s.call(this,"remove",arguments,t)},t.prototype.removeAll=function(u){if(!Array.isArray(u))throw new Error("removeAll takes an array as an argument");var t=u.map(function(u){return(0,_["default"])(u)?{id:u}:u});return s.call(this,"removeAll",arguments,t)},t}(O),j=function(u){function t(e,n,r){(0,F["default"])(this,t);var o=(0,_["default"])(r)?{id:r}:r,i=Object.assign({},n,{find:o});return(0,f["default"])(this,u.call(this,e,i,[]))}return(0,A["default"])(t,u),t}(O),T=function(u){function t(e,n,r){(0,F["default"])(this,t);var o=r.map(function(u){return(0,_["default"])(u)?{id:u}:u}),i={find_all:o},s=Object.assign({},n,i),a=void 0;return a=1===o.length?["order","above","below","limit"]:[],(0,f["default"])(this,u.call(this,e,s,a))}return(0,A["default"])(t,u),t}(O),k=function(u){function t(e,n,r,o){(0,F["default"])(this,t);var i={above:[r,o]},s=Object.assign({},n,i),a=["findAll","order","below","limit"];return(0,f["default"])(this,u.call(this,e,s,a))}return(0,A["default"])(t,u),t}(O),P=function(u){function t(e,n,r,o){(0,F["default"])(this,t);var i={below:[r,o]},s=Object.assign({},n,i),a=["findAll","order","above","limit"];return(0,f["default"])(this,u.call(this,e,s,a))}return(0,A["default"])(t,u),t}(O),M=function(u){function t(e,n,r,o){(0,F["default"])(this,t);var i=Array.isArray(r)?r:[r],s={order:[i,o]},a=Object.assign({},n,s),c=["findAll","above","below","limit"];return(0,f["default"])(this,u.call(this,e,a,c))}return(0,A["default"])(t,u),t}(O),R=function(u){function t(e,n,r){(0,F["default"])(this,t);var o=Object.assign({},n,{limit:r});return(0,f["default"])(this,u.call(this,e,o,[]))}return(0,A["default"])(t,u),t}(O);u.exports={TermBase:O,Collection:S,FindAll:T,Find:j,Above:k,Below:P,Order:M,Limit:R}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u){var t=this,e=function(t){if(t.hasOwnProperty(u))return t[u];throw new Error("Unconfigured auth type: "+u)};if(this._authMethods){var n;return(n=E.Observable.of(this._authMethods),d.map).call(n,e)}var r;return console.log("No auth methods, have to fetch"),(r=(0,p["default"])(this._horizonPath+"/auth_methods")["do"](function(u){t._authMethods=u}),d.map).call(r,e)}function o(){try{return"object"!==("undefined"==typeof window?"undefined":(0,a["default"])(window))||void 0===window.localStorage?new h:(window.localStorage.setItem("$$fake",1),window.localStorage.removeItem("$$fake"),window.localStorage)}catch(u){return void 0===window.sessionStorage?new h:window.sessionStorage}}function i(){return o().removeItem(C)}t.__esModule=!0,t.TokenStorage=void 0;var s=e(5),a=n(s),f=e(18),c=n(f);t.authEndpoint=r,t.clearAuthTokens=i;var A=e(53),l=n(A),E=e(1),d=e(1),F=e(51),p=n(F),C="horizon-jwt",h=function(){function u(){(0,c["default"])(this,u),this._storage=new Map}return u.prototype.setItem=function(u,t){return this._storage.set(u,t)},u.prototype.getItem=function(u){return this._storage.get(u)},u.prototype.removeItem=function(u){return this._storage["delete"](u)},u}();t.TokenStorage=function(){function u(){var t=arguments.length<=0||void 0===arguments[0]?"unauthenticated":arguments[0];(0,c["default"])(this,u),this._storage=o(),this._authType=t}return u.prototype.set=function(u){return this._storage.setItem(C,u)},u.prototype.get=function(){return this._storage.getItem(C)},u.prototype.remove=function(){return this._storage.removeItem(C)},u.prototype.setAuthFromQueryParams=function(){var u=(0,l["default"])(window.location.search);null!=u.horizon_auth&&this.set(u.horizon_auth)},u.prototype.handshake=function(){var u=this.get();if(null!=u)return{method:"token",token:u};if("token"===this._authType)throw new Error("Attempting to authenticate with a token, but no token is present");return{method:this._authType}},u.prototype.hasAuthToken=function(){return Boolean(this.get())},u}()},function(u,t){"use strict";"undefined"!=typeof WebSocket?u.exports.WebSocket=WebSocket:u.exports.WebSocket=function(){console.error("Tried to use WebSocket but it isn't defined or polyfilled")}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}var r=e(18),o=n(r),i=e(35),s=n(i),a=e(34),f=n(a),c=e(1),A=e(1),l=e(1),E=e(1),d=e(1),F=e(1),p=e(1),C=e(48),h=e(33),B=e(32),D="rethinkdb-horizon-v0",y={type:"unconnected"},v={type:"connected"},b={type:"ready"},m={type:"error"},w={type:"disconnected"},g=function(u){function t(e,n){(0,o["default"])(this,t);var r=(0,s["default"])(this,u.call(this,e));return r.errorCode=n,r}return(0,f["default"])(t,u),t.prototype.toString=function(){return this.message+" (Code: "+this.errorCode+")"},t}(Error),_=function(u){function t(e,n,r,i){function a(u){var t=JSON.stringify((0,h.serialize)(u));S.send(t)}function f(u,t){k.next(w),u?S.close(u,t):S.close(),S.onopen=void 0,S.onclose=void 0,S.onmessage=void 0}var _;(0,o["default"])(this,t);var x="ws"+(n?"s":"")+"://"+e+"/"+r,O=[],S=void 0,j=void 0,T=new c.AsyncSubject,k=new A.BehaviorSubject(y),P=function(){return Boolean(S)&&S.readyState===C.WebSocket.OPEN},M=(_=E.Observable.create(function(u){return S=new C.WebSocket(x,D),S.onerror=function(){k.next(m);var t="Websocket "+x+" experienced an error";u.error(new Error(t))},S.onopen=function(){for(k.next(v),j=I.makeRequest(i()).subscribe(function(u){T.next(u),T.complete(),T.next(b)},function(u){return T.error(u)},function(){return T.complete()});O.length>0;){var u=O.shift();(0,B.log)("Sending buffered:",u),a(u)}},S.onmessage=function(t){var e=(0,h.deserialize)(JSON.parse(t.data));(0,B.log)("Received",e),u.next(e)},S.onclose=function(t){k.next(w),1e3===t.code&&t.wasClean?u.complete():u.error(new Error("Socket closed unexpectedly with code: "+t.code))},function(){j&&j.unsubscribe(),f(1e3,"")}}),p.share).call(_),R={next:function(u){P()?((0,B.log)("Sending",u),a(u)):((0,B.log)("Buffering",u),O.push(u))},error:function(u){if(!u.code)throw new Error('no code specified. Be sure to pass { code: ###, reason: "" } to error()');f(u.code,u.reason)},complete:function(){f(1e3,"")}},I=(0,s["default"])(this,u.call(this,R,M)),q=new l.Subject,N=new l.Subject,z=d.merge.call(E.Observable,q,N),U=0,L=0,W=null;I.handshake=T,I.status=k;var $=function(){1===++U&&(W=z.subscribe(I))},H=function(){0===--U&&W.unsubscribe()};return I.makeRequest=function(u){return E.Observable.create(function(t){var e=L++;u.request_id=e;var n=void 0;"subscribe"===u.type&&(n={request_id:e,type:"end_subscription"}),$(),q.next(u);var r=F.filter.call(I,function(u){return u.request_id===e}).subscribe(function(u){if(void 0!==u.error)t.error(new g(u.error,u.error_code));else if(void 0!==u.data||void 0!==u.token)try{t.next(u)}catch(e){}"synced"===u.state?t.next({type:"state",state:"synced"}):"complete"===u.state&&t.complete()},function(u){return t.error(u)},function(){return t.complete()});return function(){n&&N.next(n),H(),r.unsubscribe()}})},I}return(0,f["default"])(t,u),t}(l.Subject);u.exports=_},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u,t){var e=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=e.nullable,r=void 0===n?!1:n,o=e.minArgs,s=void 0===o?1:o,a=e.maxArgs,f=void 0===a?1:a;if(s===f&&t.length!==s){var c=1===s?"":"s";throw new Error(u+" must receive exactly "+s+" argument"+c)}if(t.length<s){var A=1===s?"":"s";throw new Error(u+" must receive at least "+s+" argument"+A+".")}if(t.length>f){var l=1===f?"":"s";throw new Error(u+" accepts at most "+f+" argument"+l+".")}for(var E=0;E<t.length;E++){if(!r&&null===t[E]){var d=1!==f?" "+(0,i["default"])(E+1):"";throw new Error("The"+d+" argument to "+u+" must be non-null")}if(void 0===t[E])throw new Error("The "+(0,i["default"])(E+1)+" argument to "+u+" must be defined")}}t.__esModule=!0,t["default"]=r;var o=e(52),i=n(o)},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u){var t;return(t=i.fromPromise.call(o.Observable,(0,f["default"])(u)),s.map).call(t,function(u){return u.json()})}t.__esModule=!0,t["default"]=r;var o=e(1),i=e(1),s=e(1),a=e(91),f=n(a)},function(u,t){"use strict";function e(u){return-1!==[11,12,13].indexOf(u)?u+"th":u%10===1?u+"st":u%10===2?u+"nd":u%10===3?u+"rd":u+"th"}t.__esModule=!0,t["default"]=e},function(u,t){"use strict";t.__esModule=!0,t["default"]=function(u){if("string"!=typeof u)return{};var t=u.trim().replace(/^(\?|#|&)/,"");return t?t.split("&").reduce(function(u,t){var e=t.replace(/\+/g," ").split("="),n=e.shift(),r=e.length>0?e.join("="):void 0,o=decodeURIComponent(n),i=void 0===r?null:decodeURIComponent(r);return u.hasOwnProperty(o)?Array.isArray(u[o])?u[o].push(i):u[o]=[u[o],i]:u[o]=i,u},{}):{}}},function(u,t,e){"use strict";function n(u){return u&&u.__esModule?u:{"default":u}}function r(u){if(null===u)return!1;if(-1!==["boolean","number","string"].indexOf("undefined"==typeof u?"undefined":(0,i["default"])(u)))return!0;if(Array.isArray(u)){var t=function(){var t=!1;return u.forEach(function(u){t=t||r(u)}),{v:t}}();if("object"===("undefined"==typeof t?"undefined":(0,i["default"])(t)))return t.v}return!1}t.__esModule=!0;var o=e(5),i=n(o);t["default"]=r},function(u,t,e){u.exports={"default":e(59),__esModule:!0}},function(u,t,e){u.exports={"default":e(60),__esModule:!0}},function(u,t,e){u.exports={"default":e(61),__esModule:!0}},function(u,t,e){u.exports={"default":e(62),__esModule:!0}},function(u,t,e){e(83);var n=e(11).Object;u.exports=function(u,t){return n.create(u,t)}},function(u,t,e){e(84),u.exports=e(11).Object.setPrototypeOf},function(u,t,e){e(87),e(85),e(88),e(89),u.exports=e(11).Symbol},function(u,t,e){e(86),e(90),u.exports=e(31).f("iterator")},function(u,t){u.exports=function(u){if("function"!=typeof u)throw TypeError(u+" is not a function!");return u}},function(u,t){u.exports=function(){}},function(u,t,e){var n=e(4),r=e(80),o=e(79);u.exports=function(u){return function(t,e,i){var s,a=n(t),f=r(a.length),c=o(i,f);if(u&&e!=e){for(;f>c;)if(s=a[c++],s!=s)return!0}else for(;f>c;c++)if((u||c in a)&&a[c]===e)return u||c||0;return!u&&-1}}},function(u,t,e){var n=e(15),r=e(43),o=e(24);u.exports=function(u){var t=n(u),e=r.f;if(e)for(var i,s=e(u),a=o.f,f=0;s.length>f;)a.call(u,i=s[f++])&&t.push(i);return t}},function(u,t,e){u.exports=e(2).document&&document.documentElement},function(u,t,e){var n=e(36);u.exports=Object("z").propertyIsEnumerable(0)?Object:function(u){return"String"==n(u)?u.split(""):Object(u)}},function(u,t,e){var n=e(36);u.exports=Array.isArray||function(u){return"Array"==n(u)}},function(u,t,e){"use strict";var n=e(23),r=e(16),o=e(25),i={};e(7)(i,e(9)("iterator"),function(){return this}),u.exports=function(u,t,e){u.prototype=n(i,{next:r(1,e)}),o(u,t+" Iterator")}},function(u,t){u.exports=function(u,t){return{value:t,done:!!u}}},function(u,t,e){var n=e(15),r=e(4);u.exports=function(u,t){for(var e,o=r(u),i=n(o),s=i.length,a=0;s>a;)if(o[e=i[a++]]===t)return e}},function(u,t,e){var n=e(17)("meta"),r=e(12),o=e(3),i=e(8).f,s=0,a=Object.isExtensible||function(){return!0},f=!e(14)(function(){return a(Object.preventExtensions({}))}),c=function(u){i(u,n,{value:{i:"O"+ ++s,w:{}}})},A=function(u,t){if(!r(u))return"symbol"==typeof u?u:("string"==typeof u?"S":"P")+u;if(!o(u,n)){if(!a(u))return"F";if(!t)return"E";c(u)}return u[n].i},l=function(u,t){if(!o(u,n)){if(!a(u))return!0;if(!t)return!1;c(u)}return u[n].w},E=function(u){return f&&d.NEED&&a(u)&&!o(u,n)&&c(u),u},d=u.exports={KEY:n,NEED:!1,fastKey:A,getWeak:l,onFreeze:E}},function(u,t,e){var n=e(8),r=e(10),o=e(15);u.exports=e(6)?Object.defineProperties:function(u,t){r(u);for(var e,i=o(t),s=i.length,a=0;s>a;)n.f(u,e=i[a++],t[e]);return u}},function(u,t,e){var n=e(4),r=e(42).f,o={}.toString,i="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(u){try{return r(u)}catch(t){return i.slice()}};u.exports.f=function(u){return i&&"[object Window]"==o.call(u)?s(u):r(n(u))}},function(u,t,e){var n=e(3),r=e(81),o=e(26)("IE_PROTO"),i=Object.prototype;u.exports=Object.getPrototypeOf||function(u){return u=r(u),n(u,o)?u[o]:"function"==typeof u.constructor&&u instanceof u.constructor?u.constructor.prototype:u instanceof Object?i:null}},function(u,t,e){var n=e(12),r=e(10),o=function(u,t){if(r(u),!n(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};u.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(u,t,n){try{n=e(37)(Function.call,e(41).f(Object.prototype,"__proto__").set,2),n(u,[]),t=!(u instanceof Array)}catch(r){t=!0}return function(u,e){return o(u,e),t?u.__proto__=e:n(u,e),u}}({},!1):void 0),check:o}},function(u,t,e){var n=e(28),r=e(19);u.exports=function(u){return function(t,e){var o,i,s=String(r(t)),a=n(e),f=s.length;return 0>a||a>=f?u?"":void 0:(o=s.charCodeAt(a),55296>o||o>56319||a+1===f||(i=s.charCodeAt(a+1))<56320||i>57343?u?s.charAt(a):o:u?s.slice(a,a+2):(o-55296<<10)+(i-56320)+65536)}}},function(u,t,e){var n=e(28),r=Math.max,o=Math.min;u.exports=function(u,t){return u=n(u),0>u?r(u+t,0):o(u,t)}},function(u,t,e){var n=e(28),r=Math.min;u.exports=function(u){return u>0?r(n(u),9007199254740991):0}},function(u,t,e){var n=e(19);u.exports=function(u){return Object(n(u))}},function(u,t,e){"use strict";var n=e(64),r=e(71),o=e(21),i=e(4);u.exports=e(40)(Array,"Array",function(u,t){this._t=i(u),this._i=0,this._k=t},function(){var u=this._t,t=this._k,e=this._i++;return!u||e>=u.length?(this._t=void 0,r(1)):"keys"==t?r(0,e):"values"==t?r(0,u[e]):r(0,[e,u[e]])},"values"),o.Arguments=o.Array,n("keys"),n("values"),n("entries")},function(u,t,e){var n=e(13);n(n.S,"Object",{create:e(23)})},function(u,t,e){var n=e(13);n(n.S,"Object",{setPrototypeOf:e(77).set})},function(u,t){},function(u,t,e){"use strict";var n=e(78)(!0);e(40)(String,"String",function(u){this._t=String(u),this._i=0},function(){var u,t=this._t,e=this._i;return e>=t.length?{value:void 0,done:!0}:(u=n(t,e),this._i+=u.length,{value:u,done:!1})})},function(u,t,e){"use strict";var n=e(2),r=e(3),o=e(6),i=e(13),s=e(45),a=e(73).KEY,f=e(14),c=e(27),A=e(25),l=e(17),E=e(9),d=e(31),F=e(30),p=e(72),C=e(66),h=e(69),B=e(10),D=e(4),y=e(29),v=e(16),b=e(23),m=e(75),w=e(41),g=e(8),_=e(15),x=w.f,O=g.f,S=m.f,j=n.Symbol,T=n.JSON,k=T&&T.stringify,P="prototype",M=E("_hidden"),R=E("toPrimitive"),I={}.propertyIsEnumerable,q=c("symbol-registry"),N=c("symbols"),z=Object[P],U="function"==typeof j,L=n.QObject,W=!L||!L[P]||!L[P].findChild,$=o&&f(function(){return 7!=b(O({},"a",{get:function(){return O(this,"a",{value:7}).a}})).a})?function(u,t,e){var n=x(z,t);n&&delete z[t],O(u,t,e),n&&u!==z&&O(z,t,n)}:O,H=function(u){var t=N[u]=b(j[P]);return t._k=u,t},J=U&&"symbol"==typeof j.iterator?function(u){return"symbol"==typeof u}:function(u){return u instanceof j},G=function(u,t,e){return B(u),t=y(t,!0),B(e),r(N,t)?(e.enumerable?(r(u,M)&&u[M][t]&&(u[M][t]=!1),e=b(e,{enumerable:v(0,!1)})):(r(u,M)||O(u,M,v(1,{})),u[M][t]=!0),$(u,t,e)):O(u,t,e)},K=function(u,t){B(u);for(var e,n=C(t=D(t)),r=0,o=n.length;o>r;)G(u,e=n[r++],t[e]);return u},Q=function(u,t){return void 0===t?b(u):K(b(u),t)},X=function(u){var t=I.call(this,u=y(u,!0));return t||!r(this,u)||!r(N,u)||r(this,M)&&this[M][u]?t:!0},Y=function(u,t){var e=x(u=D(u),t=y(t,!0));return!e||!r(N,t)||r(u,M)&&u[M][t]||(e.enumerable=!0),e},Z=function(u){for(var t,e=S(D(u)),n=[],o=0;e.length>o;)r(N,t=e[o++])||t==M||t==a||n.push(t);return n},V=function(u){for(var t,e=S(D(u)),n=[],o=0;e.length>o;)r(N,t=e[o++])&&n.push(N[t]);return n};U||(j=function(){if(this instanceof j)throw TypeError("Symbol is not a constructor!");var u=l(arguments.length>0?arguments[0]:void 0);return o&&W&&$(z,u,{configurable:!0,set:function(t){r(this,M)&&r(this[M],u)&&(this[M][u]=!1),$(this,u,v(1,t))}}),H(u)},s(j[P],"toString",function(){return this._k}),w.f=Y,g.f=G,e(42).f=m.f=Z,e(24).f=X,e(43).f=V,o&&!e(22)&&s(z,"propertyIsEnumerable",X,!0),d.f=function(u){return H(E(u))}),i(i.G+i.W+i.F*!U,{Symbol:j});for(var uu="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),tu=0;uu.length>tu;)E(uu[tu++]);for(var uu=_(E.store),tu=0;uu.length>tu;)F(uu[tu++]);i(i.S+i.F*!U,"Symbol",{"for":function(u){return r(q,u+="")?q[u]:q[u]=j(u)},keyFor:function(u){if(J(u))return p(q,u);throw TypeError(u+" is not a symbol!")},useSetter:function(){W=!0},useSimple:function(){W=!1}}),i(i.S+i.F*!U,"Object",{create:Q,defineProperty:G,defineProperties:K,getOwnPropertyDescriptor:Y,getOwnPropertyNames:Z,getOwnPropertySymbols:V
|