import React, { useMemo, useState } from "react";
import { createContext, useContextSelector } from "./../use-context-selector.js";
const noopSetter = (_api) => {
};
const RicosEditorApiContext = createContext({
  ricosEditorApi: null,
  setRicosEditorApi: noopSetter
});
const RicosEditorApiProvider = ({ children }) => {
  const [ricosEditorApi, setRicosEditorApi] = useState(null);
  const value = useMemo(() => ({ ricosEditorApi, setRicosEditorApi }), [ricosEditorApi]);
  return /* @__PURE__ */ React.createElement(RicosEditorApiContext.Provider, { value }, children);
};
const useRicosEditorApi = () => useContextSelector(RicosEditorApiContext, (c) => c.ricosEditorApi, Object.is);
const useSetRicosEditorApi = () => useContextSelector(RicosEditorApiContext, (c) => c.setRicosEditorApi, Object.is);
const withRicosEditorApi = (Component) => {
  const Wrapped = (props) => {
    const editor = useRicosEditorApi();
    return /* @__PURE__ */ React.createElement(Component, { ...props, editor });
  };
  Wrapped.displayName = `withRicosEditorApi(${Component.displayName ?? Component.name ?? "Component"})`;
  return Wrapped;
};
export {
  RicosEditorApiContext,
  RicosEditorApiProvider,
  useRicosEditorApi,
  useSetRicosEditorApi,
  withRicosEditorApi
};
//# sourceMappingURL=ricos-editor-api-context.js.map
