"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./localStorage.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e),o=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function n(e){if(!o.test(e))throw new Error("shared DC store key should be a valid UUID string")}function s(e){return"".concat("SHARED_DC_STORES",":").concat(e,":update")}function S(e){return r.getLocalStorageItem("SHARED_DC_STORES")[e]}var u={setSharedDCStore:function(e,t){n(e);var o=t(S(e));r.updateLocalStorageItem("SHARED_DC_STORES",a.default({},e,o));var u=new BroadcastChannel(s(e));u.postMessage(JSON.stringify(S(e))),u.close()},getSharedDCStore:S,subscribeForSharedDCStore:function(e,r){n(e);var t=S(e);r(t);var a=new BroadcastChannel(s(e));return a.onmessage=function(e){r(JSON.parse(e.data))},function(){a.close()}},__removeSharedDCStores:function(){localStorage.removeItem("SHARED_DC_STORES")}};exports.sharedDCStore=u;
