import { u as useRecordVisibilityChanges, j as jsxRuntimeExports } from "./doenetml-cB_aZGJ5.js";
import React__default, { useRef } from "react";
import { u as useDoenetRenderer } from "./useDoenetRenderer-DN3Z9CW3.js";
import { a as addCommasForCompositeRanges } from "./composites-DgtFnuE1.js";
const pre = React__default.memo(function Pre(props) {
  let { id, SVs, children, actions, callAction } = useDoenetRenderer(props);
  const ref = useRef(null);
  useRecordVisibilityChanges(ref, callAction, actions);
  if (SVs.hidden) return null;
  if (SVs._compositeReplacementActiveRange) {
    children = addCommasForCompositeRanges({
      children,
      compositeReplacementActiveRange: SVs._compositeReplacementActiveRange,
      startInd: 0,
      endInd: children.length - 1
    });
  }
  for (let ind of SVs.displayDoenetMLIndices) {
    let prevChild = children[ind - 1];
    if (typeof prevChild === "string") {
      let lastLineBreak = prevChild.lastIndexOf("\n");
      if (/^\s*$/.test(prevChild.slice(lastLineBreak + 1))) {
        prevChild = prevChild.slice(0, lastLineBreak + 1);
        children[ind - 1] = prevChild;
      }
    }
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { id, style: { margin: "12px 0" }, ref, children });
});
export {
  pre as default
};
