import x from "./index-objectWithoutPropertiesLoose.js";
import n from "./index-extends.js";
import * as b from "react";
import r from "./index-_virtual16.js";
import { clsx as h } from "./index-clsx.js";
import v from "./index-formControlState.js";
import k from "./index-useFormControl.js";
import z from "./index-styled.js";
import { getInputLabelUtilityClasses as C } from "./index-inputLabelClasses.js";
import { jsx as O } from "react/jsx-runtime";
import { useDefaultProps as g } from "./index-DefaultPropsProvider.js";
import L from "./index-capitalize.js";
import I from "./index-composeClasses.js";
import y from "./index-FormLabel.js";
import W from "./index-formLabelClasses.js";
import A from "./index-rootShouldForwardProp.js";
const E = ["disableAnimation", "margin", "shrink", "variant", "className"], N = (s) => {
  const {
    classes: o,
    formControl: e,
    size: t,
    shrink: m,
    disableAnimation: p,
    variant: c,
    required: f
  } = s, a = {
    root: ["root", e && "formControl", !p && "animated", m && "shrink", t && t !== "normal" && `size${L(t)}`, c],
    asterisk: [f && "asterisk"]
  }, i = I(a, C, o);
  return n({}, o, i);
}, P = z(y, {
  shouldForwardProp: (s) => A(s) || s === "classes",
  name: "MuiInputLabel",
  slot: "Root",
  overridesResolver: (s, o) => {
    const {
      ownerState: e
    } = s;
    return [{
      [`& .${W.asterisk}`]: o.asterisk
    }, o.root, e.formControl && o.formControl, e.size === "small" && o.sizeSmall, e.shrink && o.shrink, !e.disableAnimation && o.animated, e.focused && o.focused, o[e.variant]];
  }
})(({
  theme: s,
  ownerState: o
}) => n({
  display: "block",
  transformOrigin: "top left",
  whiteSpace: "nowrap",
  overflow: "hidden",
  textOverflow: "ellipsis",
  maxWidth: "100%"
}, o.formControl && {
  position: "absolute",
  left: 0,
  top: 0,
  // slight alteration to spec spacing to match visual spec result
  transform: "translate(0, 20px) scale(1)"
}, o.size === "small" && {
  // Compensation for the `Input.inputSizeSmall` style.
  transform: "translate(0, 17px) scale(1)"
}, o.shrink && {
  transform: "translate(0, -1.5px) scale(0.75)",
  transformOrigin: "top left",
  maxWidth: "133%"
}, !o.disableAnimation && {
  transition: s.transitions.create(["color", "transform", "max-width"], {
    duration: s.transitions.duration.shorter,
    easing: s.transitions.easing.easeOut
  })
}, o.variant === "filled" && n({
  // Chrome's autofill feature gives the input field a yellow background.
  // Since the input field is behind the label in the HTML tree,
  // the input field is drawn last and hides the label with an opaque background color.
  // zIndex: 1 will raise the label above opaque background-colors of input.
  zIndex: 1,
  pointerEvents: "none",
  transform: "translate(12px, 16px) scale(1)",
  maxWidth: "calc(100% - 24px)"
}, o.size === "small" && {
  transform: "translate(12px, 13px) scale(1)"
}, o.shrink && n({
  userSelect: "none",
  pointerEvents: "auto",
  transform: "translate(12px, 7px) scale(0.75)",
  maxWidth: "calc(133% - 24px)"
}, o.size === "small" && {
  transform: "translate(12px, 4px) scale(0.75)"
})), o.variant === "outlined" && n({
  // see comment above on filled.zIndex
  zIndex: 1,
  pointerEvents: "none",
  transform: "translate(14px, 16px) scale(1)",
  maxWidth: "calc(100% - 24px)"
}, o.size === "small" && {
  transform: "translate(14px, 9px) scale(1)"
}, o.shrink && {
  userSelect: "none",
  pointerEvents: "auto",
  // Theoretically, we should have (8+5)*2/0.75 = 34px
  // but it feels a better when it bleeds a bit on the left, so 32px.
  maxWidth: "calc(133% - 32px)",
  transform: "translate(14px, -9px) scale(0.75)"
}))), T = /* @__PURE__ */ b.forwardRef(function(o, e) {
  const t = g({
    name: "MuiInputLabel",
    props: o
  }), {
    disableAnimation: m = !1,
    shrink: p,
    className: c
  } = t, f = x(t, E), a = k();
  let i = p;
  typeof i > "u" && a && (i = a.filled || a.focused || a.adornedStart);
  const l = v({
    props: t,
    muiFormControl: a,
    states: ["size", "variant", "required", "focused"]
  }), d = n({}, t, {
    disableAnimation: m,
    formControl: a,
    shrink: i,
    size: l.size,
    variant: l.variant,
    required: l.required,
    focused: l.focused
  }), u = N(d);
  return /* @__PURE__ */ O(P, n({
    "data-shrink": i,
    ownerState: d,
    ref: e,
    className: h(u.root, c)
  }, f, {
    classes: u
  }));
});
process.env.NODE_ENV !== "production" && (T.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * The content of the component.
   */
  children: r.node,
  /**
   * Override or extend the styles applied to the component.
   */
  classes: r.object,
  /**
   * @ignore
   */
  className: r.string,
  /**
   * The color of the component.
   * It supports both default and custom theme colors, which can be added as shown in the
   * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
   */
  color: r.oneOfType([r.oneOf(["error", "info", "primary", "secondary", "success", "warning"]), r.string]),
  /**
   * If `true`, the transition animation is disabled.
   * @default false
   */
  disableAnimation: r.bool,
  /**
   * If `true`, the component is disabled.
   */
  disabled: r.bool,
  /**
   * If `true`, the label is displayed in an error state.
   */
  error: r.bool,
  /**
   * If `true`, the `input` of this label is focused.
   */
  focused: r.bool,
  /**
   * If `dense`, will adjust vertical spacing. This is normally obtained via context from
   * FormControl.
   */
  margin: r.oneOf(["dense"]),
  /**
   * if `true`, the label will indicate that the `input` is required.
   */
  required: r.bool,
  /**
   * If `true`, the label is shrunk.
   */
  shrink: r.bool,
  /**
   * The size of the component.
   * @default 'normal'
   */
  size: r.oneOfType([r.oneOf(["normal", "small"]), r.string]),
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: r.oneOfType([r.arrayOf(r.oneOfType([r.func, r.object, r.bool])), r.func, r.object]),
  /**
   * The variant to use.
   */
  variant: r.oneOf(["filled", "outlined", "standard"])
});
export {
  T as default
};
