import { u as useRecordVisibilityChanges, j as jsxRuntimeExports } from "./doenetml-BPsLSRHD.js";
import React__default, { useRef } from "react";
import { u as useDoenetRenderer } from "./useDoenetRenderer-BDC0Rur_.js";
import { a as addCommasForCompositeRanges } from "./composites-BvS-pDok.js";
import { c as calculateValidationState, u as useSubmitActionWithDelay, a as createCheckWorkComponent } from "./useSubmitActionWithDelay-bJj16Fl0.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;
  const validationState = calculateValidationState(SVs);
  const { isPending, submitActionWithPending } = useSubmitActionWithDelay({
    actionKey: "submitAllAnswers",
    actions,
    callAction,
    validationState,
    justSubmitted: SVs.justSubmitted
  });
  if (actions.submitAllAnswers) {
    checkWorkComponent = createCheckWorkComponent(
      SVs,
      id,
      validationState,
      submitActionWithPending,
      true,
      isPending
    );
  }
  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
};
