"use client";
import * as React from "react";
import { useRenderElement } from "../../utils/useRenderElement.js";
import { useRadioRootContext } from "../root/RadioRootContext.js";
import { stateAttributesMapping } from "../utils/stateAttributesMapping.js";
import { useOpenChangeComplete } from "../../utils/useOpenChangeComplete.js";
import { useTransitionStatus } from "../../utils/useTransitionStatus.js";
const RadioIndicator = /* @__PURE__ */ React.forwardRef(function RadioIndicator2(componentProps, forwardedRef) {
  const {
    render,
    className,
    keepMounted = false,
    ...elementProps
  } = componentProps;
  const rootState = useRadioRootContext();
  const rendered = rootState.checked;
  const {
    transitionStatus,
    setMounted
  } = useTransitionStatus(rendered);
  const state = React.useMemo(() => ({
    ...rootState,
    transitionStatus
  }), [rootState, transitionStatus]);
  const indicatorRef = React.useRef(null);
  const shouldRender = keepMounted || rendered;
  const element = useRenderElement("span", componentProps, {
    enabled: shouldRender,
    ref: [forwardedRef, indicatorRef],
    state,
    props: elementProps,
    stateAttributesMapping
  });
  useOpenChangeComplete({
    open: rendered,
    ref: indicatorRef,
    onComplete() {
      if (!rendered) {
        setMounted(false);
      }
    }
  });
  if (!shouldRender) {
    return null;
  }
  return element;
});
if (process.env.NODE_ENV !== "production") RadioIndicator.displayName = "RadioIndicator";
export {
  RadioIndicator
};
//# sourceMappingURL=RadioIndicator.js.map
