import ee from "./index-objectWithoutPropertiesLoose.js";
import r from "./index-extends.js";
import * as z from "react";
import { clsx as te } from "./index-clsx.js";
import e from "./index-_virtual16.js";
import b from "./index-styled.js";
import { duration as ne } from "./index-createTransitions.js";
import { getTransitionProps as H } from "./index-utils6.js";
import oe from "./index-useTheme.js";
import { getCollapseUtilityClass as ie } from "./index-collapseClasses.js";
import { jsx as T } from "react/jsx-runtime";
import { useDefaultProps as re } from "./index-DefaultPropsProvider.js";
import se from "./index-Transition.js";
import ae from "./index-useTimeout.js";
import le from "./index-useForkRef.js";
import pe from "./index-composeClasses.js";
import ce from "./index-elementTypeAcceptingRef.js";
const de = ["addEndListener", "children", "className", "collapsedSize", "component", "easing", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "orientation", "style", "timeout", "TransitionComponent"], ue = (o) => {
  const {
    orientation: n,
    classes: s
  } = o, d = {
    root: ["root", `${n}`],
    entered: ["entered"],
    hidden: ["hidden"],
    wrapper: ["wrapper", `${n}`],
    wrapperInner: ["wrapperInner", `${n}`]
  };
  return pe(d, ie, s);
}, me = b("div", {
  name: "MuiCollapse",
  slot: "Root",
  overridesResolver: (o, n) => {
    const {
      ownerState: s
    } = o;
    return [n.root, n[s.orientation], s.state === "entered" && n.entered, s.state === "exited" && !s.in && s.collapsedSize === "0px" && n.hidden];
  }
})(({
  theme: o,
  ownerState: n
}) => r({
  height: 0,
  overflow: "hidden",
  transition: o.transitions.create("height")
}, n.orientation === "horizontal" && {
  height: "auto",
  width: 0,
  transition: o.transitions.create("width")
}, n.state === "entered" && r({
  height: "auto",
  overflow: "visible"
}, n.orientation === "horizontal" && {
  width: "auto"
}), n.state === "exited" && !n.in && n.collapsedSize === "0px" && {
  visibility: "hidden"
})), fe = b("div", {
  name: "MuiCollapse",
  slot: "Wrapper",
  overridesResolver: (o, n) => n.wrapper
})(({
  ownerState: o
}) => r({
  // Hack to get children with a negative margin to not falsify the height computation.
  display: "flex",
  width: "100%"
}, o.orientation === "horizontal" && {
  width: "auto",
  height: "100%"
})), he = b("div", {
  name: "MuiCollapse",
  slot: "WrapperInner",
  overridesResolver: (o, n) => n.wrapperInner
})(({
  ownerState: o
}) => r({
  width: "100%"
}, o.orientation === "horizontal" && {
  width: "auto",
  height: "100%"
})), I = /* @__PURE__ */ z.forwardRef(function(n, s) {
  const d = re({
    props: n,
    name: "MuiCollapse"
  }), {
    addEndListener: S,
    children: M,
    className: _,
    collapsedSize: g = "0px",
    component: U,
    easing: D,
    in: $,
    onEnter: O,
    onEntered: N,
    onEntering: W,
    onExit: L,
    onExited: V,
    onExiting: j,
    orientation: P = "vertical",
    style: v,
    timeout: l = ne.standard,
    // eslint-disable-next-line react/prop-types
    TransitionComponent: k = se
  } = d, q = ee(d, de), E = r({}, d, {
    orientation: P,
    collapsedSize: g
  }), u = ue(E), A = oe(), B = ae(), p = z.useRef(null), C = z.useRef(), x = typeof g == "number" ? `${g}px` : g, m = P === "horizontal", f = m ? "width" : "height", y = z.useRef(null), G = le(s, y), c = (t) => (i) => {
    if (t) {
      const a = y.current;
      i === void 0 ? t(a) : t(a, i);
    }
  }, R = () => p.current ? p.current[m ? "clientWidth" : "clientHeight"] : 0, J = c((t, i) => {
    p.current && m && (p.current.style.position = "absolute"), t.style[f] = x, O && O(t, i);
  }), K = c((t, i) => {
    const a = R();
    p.current && m && (p.current.style.position = "");
    const {
      duration: h,
      easing: w
    } = H({
      style: v,
      timeout: l,
      easing: D
    }, {
      mode: "enter"
    });
    if (l === "auto") {
      const F = A.transitions.getAutoHeightDuration(a);
      t.style.transitionDuration = `${F}ms`, C.current = F;
    } else
      t.style.transitionDuration = typeof h == "string" ? h : `${h}ms`;
    t.style[f] = `${a}px`, t.style.transitionTimingFunction = w, W && W(t, i);
  }), Q = c((t, i) => {
    t.style[f] = "auto", N && N(t, i);
  }), X = c((t) => {
    t.style[f] = `${R()}px`, L && L(t);
  }), Y = c(V), Z = c((t) => {
    const i = R(), {
      duration: a,
      easing: h
    } = H({
      style: v,
      timeout: l,
      easing: D
    }, {
      mode: "exit"
    });
    if (l === "auto") {
      const w = A.transitions.getAutoHeightDuration(i);
      t.style.transitionDuration = `${w}ms`, C.current = w;
    } else
      t.style.transitionDuration = typeof a == "string" ? a : `${a}ms`;
    t.style[f] = x, t.style.transitionTimingFunction = h, j && j(t);
  });
  return /* @__PURE__ */ T(k, r({
    in: $,
    onEnter: J,
    onEntered: Q,
    onEntering: K,
    onExit: X,
    onExited: Y,
    onExiting: Z,
    addEndListener: (t) => {
      l === "auto" && B.start(C.current || 0, t), S && S(y.current, t);
    },
    nodeRef: y,
    timeout: l === "auto" ? null : l
  }, q, {
    children: (t, i) => /* @__PURE__ */ T(me, r({
      as: U,
      className: te(u.root, _, {
        entered: u.entered,
        exited: !$ && x === "0px" && u.hidden
      }[t]),
      style: r({
        [m ? "minWidth" : "minHeight"]: x
      }, v),
      ref: G
    }, i, {
      // `ownerState` is set after `childProps` to override any existing `ownerState` property in `childProps`
      // that might have been forwarded from the Transition component.
      ownerState: r({}, E, {
        state: t
      }),
      children: /* @__PURE__ */ T(fe, {
        ownerState: r({}, E, {
          state: t
        }),
        className: u.wrapper,
        ref: p,
        children: /* @__PURE__ */ T(he, {
          ownerState: r({}, E, {
            state: t
          }),
          className: u.wrapperInner,
          children: M
        })
      })
    }))
  }));
});
process.env.NODE_ENV !== "production" && (I.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * Add a custom transition end trigger. Called with the transitioning DOM
   * node and a done callback. Allows for more fine grained transition end
   * logic. Note: Timeouts are still used as a fallback if provided.
   */
  addEndListener: e.func,
  /**
   * The content node to be collapsed.
   */
  children: e.node,
  /**
   * Override or extend the styles applied to the component.
   */
  classes: e.object,
  /**
   * @ignore
   */
  className: e.string,
  /**
   * The width (horizontal) or height (vertical) of the container when collapsed.
   * @default '0px'
   */
  collapsedSize: e.oneOfType([e.number, e.string]),
  /**
   * The component used for the root node.
   * Either a string to use a HTML element or a component.
   */
  component: ce,
  /**
   * The transition timing function.
   * You may specify a single easing or a object containing enter and exit values.
   */
  easing: e.oneOfType([e.shape({
    enter: e.string,
    exit: e.string
  }), e.string]),
  /**
   * If `true`, the component will transition in.
   */
  in: e.bool,
  /**
   * @ignore
   */
  onEnter: e.func,
  /**
   * @ignore
   */
  onEntered: e.func,
  /**
   * @ignore
   */
  onEntering: e.func,
  /**
   * @ignore
   */
  onExit: e.func,
  /**
   * @ignore
   */
  onExited: e.func,
  /**
   * @ignore
   */
  onExiting: e.func,
  /**
   * The transition orientation.
   * @default 'vertical'
   */
  orientation: e.oneOf(["horizontal", "vertical"]),
  /**
   * @ignore
   */
  style: e.object,
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]),
  /**
   * The duration for the transition, in milliseconds.
   * You may specify a single timeout for all transitions, or individually with an object.
   *
   * Set to 'auto' to automatically calculate transition time based on height.
   * @default duration.standard
   */
  timeout: e.oneOfType([e.oneOf(["auto"]), e.number, e.shape({
    appear: e.number,
    enter: e.number,
    exit: e.number
  })])
});
I.muiSupportAuto = !0;
export {
  I as default
};
