import { jsx } from "react/jsx-runtime";
import { lazy, useCallback } from "react";
import {
  isPropControllersHandle
} from "../../../../state/modules/prop-controller-handles";
import { useIsPreview } from "../../hooks/use-is-preview";
const EditableText = lazy(() => import("./EditableText"));
const ReadOnlyText = lazy(() => import("./ReadOnlyText"));
function renderRichText(data, control) {
  return /* @__PURE__ */ jsx(RichText, { data, control });
}
function RichText({
  data,
  control
}) {
  const textCallbackRef = useCallback(
    (handle) => {
      if (isPropControllersHandle(handle))
        handle?.setPropControllers?.(control == null ? null : { text: control });
    },
    [control]
  );
  const isPreview = useIsPreview();
  return isPreview ? /* @__PURE__ */ jsx(EditableText, { text: data, ref: textCallbackRef }) : /* @__PURE__ */ jsx(ReadOnlyText, { text: data, ref: textCallbackRef });
}
export {
  renderRichText
};
//# sourceMappingURL=rich-text.js.map