function d(o) {
  const s = new BroadcastChannel(o), n = /* @__PURE__ */ new Map();
  function c(e) {
    const { type: t, payload: a } = e.data, r = n.get(t) || [];
    for (const i of r)
      i({ type: t, payload: a });
  }
  return s.addEventListener("message", c), s.addEventListener("messageerror", console.error), {
    subscribe(e, t) {
      const a = n.has(e) ? n.get(e) : [];
      n.set(e, a.concat(t));
    },
    unsubscribe() {
    },
    send(e) {
      s.postMessage(e);
    },
    reset() {
      n.clear();
    },
    close() {
      s.close(), s.removeEventListener("message", c);
    }
  };
}
export {
  d as createBroadcastChannel
};
//# sourceMappingURL=broadcast.mjs.map
