import e from"@babel/runtime/helpers/defineProperty";import{getLocalStorageItem as r,updateLocalStorageItem as a}from"./localStorage.js";var t=/^[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 o(e){if(!t.test(e))throw new Error("shared DC store key should be a valid UUID string")}function n(e){return"".concat("SHARED_DC_STORES",":").concat(e,":update")}function S(e){return r("SHARED_DC_STORES")[e]}var s={setSharedDCStore:function(r,t){o(r);var s=t(S(r));a("SHARED_DC_STORES",e({},r,s));var c=new BroadcastChannel(n(r));c.postMessage(JSON.stringify(S(r))),c.close()},getSharedDCStore:S,subscribeForSharedDCStore:function(e,r){o(e);var a=S(e);r(a);var t=new BroadcastChannel(n(e));return t.onmessage=function(e){r(JSON.parse(e.data))},function(){t.close()}},__removeSharedDCStores:function(){localStorage.removeItem("SHARED_DC_STORES")}};export{s as sharedDCStore};
//# sourceMappingURL=sharedDCStore.js.map
