import { jsx as l } from "react/jsx-runtime";
import { useContext as w, createContext as I, useState as C, useCallback as e } from "react";
const p = I(void 0);
function h({
  children: r,
  initialComponents: c = {}
}) {
  const [i, s] = C(
    c
  ), [a, m] = C({}), x = e(
    (t, o) => {
      s((n) => ({
        ...n,
        [t]: o
      }));
    },
    []
  ), d = e(
    (t) => {
      s((o) => ({
        ...o,
        ...t
      }));
    },
    []
  ), f = e((t) => {
    s((o) => {
      const { [t]: n, ...u } = o;
      return u;
    });
  }, []), g = e(
    (t, o) => {
      m((n) => ({
        ...n,
        [t]: o
      }));
    },
    []
  ), v = e((t) => {
    m((o) => {
      const { [t]: n, ...u } = o;
      return u;
    });
  }, []);
  return /* @__PURE__ */ l(
    p.Provider,
    {
      value: {
        components: i,
        registerComponent: x,
        registerComponents: d,
        unregisterComponent: f,
        interruptComponents: a,
        registerInterruptComponent: g,
        unregisterInterruptComponent: v
      },
      children: r
    }
  );
}
function _() {
  const r = w(p);
  if (!r)
    throw new Error(
      "useCustomComponents must be used within a CustomComponentProvider"
    );
  return r;
}
export {
  h as CustomComponentProvider,
  _ as useCustomComponents
};
//# sourceMappingURL=CustomComponentProvider.es.js.map
