"use strict";const index=require("./index-8acc3c89.js");var multiverse=new Map,updateConsumer=function(e,t){var n=e.fields,a=e.updater;n.forEach((function(e){a(e,t[e])}))},Universe={create:function(e,t){var n=index.getElement(e),a=new Map,c={wormholes:a,state:t};multiverse.set(e,c);var l=e.connectedCallback;e.connectedCallback=function(){multiverse.set(e,c),l&&l.call(e)};var o=e.disconnectedCallback;e.disconnectedCallback=function(){multiverse.delete(e),o&&o.call(e)},n.addEventListener("openWormhole",(function(e){e.stopPropagation();var t=e.detail,n=t.consumer,l=t.onOpen;if(!a.has(n)){if("symbol"!=typeof n){var o=n.connectedCallback,i=n.disconnectedCallback;n.connectedCallback=function(){a.set(n,e.detail),o&&o.call(n)},n.disconnectedCallback=function(){a.delete(n),i&&i.call(n)}}a.set(n,e.detail),updateConsumer(e.detail,c.state),null==l||l.resolve((function(){a.delete(n)}))}})),n.addEventListener("closeWormhole",(function(e){var t=e.detail;a.delete(t)}))},Provider:function(e,t){var n=e.state,a=index.getRenderingRef();if(multiverse.has(a)){var c=multiverse.get(a);c.state=n,c.wormholes.forEach((function(e){updateConsumer(e,n)}))}return t}};exports.Universe=Universe;