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";
import { c as calculateValidationState, a as createCheckWorkComponent } from "./checkWork-D9syAFsW.js";
const p = React__default.memo(function P(props) {
  let { id, SVs, children, actions, callAction } = useDoenetRenderer(props);
  const ref = useRef(null);
  useRecordVisibilityChanges(ref, callAction, actions);
  if (SVs.hidden) {
    return null;
  }
  let checkWorkComponent = null;
  if (actions.submitAllAnswers) {
    const submitAllAnswers = () => callAction({
      action: actions.submitAllAnswers
    });
    const validationState = calculateValidationState(SVs);
    checkWorkComponent = createCheckWorkComponent(
      SVs,
      id,
      validationState,
      submitAllAnswers,
      true
    );
  }
  if (SVs._compositeReplacementActiveRange) {
    children = addCommasForCompositeRanges({
      children,
      compositeReplacementActiveRange: SVs._compositeReplacementActiveRange,
      startInd: 0,
      endInd: children.length - 1
    });
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { id, ref, className: "para", children: [
    children,
    checkWorkComponent
  ] });
});
export {
  p as default
};
