import { jsx as a } from "react/jsx-runtime";
import { createContext as u, useContext as c, useState as f, useEffect as m, useMemo as p } from "react";
import { appConsole as d } from "../utils/appConsole.js";
import { useInitialStateContext as x } from "./InitialStateContext.js";
import { useDocumentContext as C } from "./RPDocumentContext.js";
const s = u({
  rotate: 0,
  setRotate: () => {
  }
}), S = () => {
  const t = c(s);
  return typeof (t == null ? void 0 : t.rotate) > "u" && d.error("Please use this hooks inside children component of RPProvider"), t;
}, j = ({ children: t }) => {
  const { initialRotation: o = 0 } = x(), { pdf: r } = C(), [n, e] = f(o);
  m(() => {
    r && e(o);
  }, [r, o]);
  const i = p(() => ({
    rotate: n,
    setRotate: e
  }), [n, e]);
  return /* @__PURE__ */ a(s.Provider, { value: i, children: t });
};
export {
  s as RotateContext,
  j as RotateProvider,
  S as useRotationContext
};
