"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/defineProperty"),n=require("socket.io-client"),i=require("./constants.js"),c=require("./subscriptions-client.js"),s=require("./subscriptions-client.dummy.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(e),a=o(t),l=o(r);function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var f=function(){function e(){u.default(this,e)}return a.default(e,null,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i.SUBSCRIPTIONS_URL,t=new URL(e).origin;return this.instances.has(t)||this.instances.set(t,this.create(e)),this.instances.get(t)}},{key:"create",value:function(e){if(i.IGNORED_ROUTES_REGEXP.test(window.location.pathname))return new s.DummySubscriptionsClient;var t=n.io(e,{transports:["websocket"],autoConnect:!0,path:process.env.REACT_APP_SUBSCRIPTIONS_PATH||"/socket.io"}),r=0;return t.on("connect",(function(){(r+=1,t.recovered)||1!==r&&Object.keys(t._callbacks).filter((function(e){return e.startsWith("$data#")})).map((function(e){return e.replace("$data#","")})).forEach((function(e){t.emit("subscribe",function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){l.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({channel:e},i.getHrefDebugField()))}))})),new c.SubscriptionsClientV2(t)}}]),e}();l.default(f,"instances",new Map),exports.SubscriptionsClientFactory=f;
//# sourceMappingURL=subscriptions-client.factory.js.map
