import { useRef as l, useCallback as n, useMemo as f } from "react";
import { useDebounce as S } from "../../../hooks/useDebounce.es.js";
import { ON_SAVE_DELAY_IN_MS as b } from "../utils/constants.es.js";
import { parseRawValue as E } from "../utils/parseRawValue.es.js";
import { generatePlugins as N } from "../Plugins/GeneratePlugins.es.js";
const R = ({
  editorId: r,
  initialValue: u,
  plugins: t,
  onTextChange: e,
  onValueChanged: c
}) => {
  const m = l(null), a = n(
    (o) => {
      e && e(JSON.stringify(o));
    },
    [e]
  ), s = S(a, b), i = n(
    (o) => {
      s(o), m.current = o, c && c(o);
    },
    [s, m, c]
  ), p = f(
    () => E({ editorId: r, raw: u, plugins: t }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [r]
  ), _ = f(() => N(r, t), [r, t]);
  return { localValue: m, onChange: i, memoizedValue: p, config: _ };
};
export {
  R as useEditorState
};
//# sourceMappingURL=useEditorState.es.js.map
