import x from "./index-objectWithoutPropertiesLoose.js";
import s from "./index-extends.js";
import * as R from "react";
import { clsx as O } from "./index-clsx.js";
import t from "./index-_virtual16.js";
import _ from "./index-styled.js";
import { getSkeletonUtilityClass as T } from "./index-skeletonClasses.js";
import { jsx as $ } from "react/jsx-runtime";
import { useDefaultProps as j } from "./index-DefaultPropsProvider.js";
import N from "./index-composeClasses.js";
import { getUnit as U, toUnitless as S } from "./index-cssUtils.js";
import { alpha as X } from "./index-colorManipulator.js";
import { css as m, keyframes as v } from "./index-emotion-react.browser.esm.js";
const A = ["animation", "className", "component", "height", "style", "variant", "width"];
let l = (o) => o, f, u, g, b;
const M = (o) => {
  const {
    classes: e,
    variant: a,
    animation: i,
    hasChildren: r,
    width: d,
    height: n
  } = o;
  return N({
    root: ["root", a, i, r && "withChildren", r && !d && "fitContent", r && !n && "heightAuto"]
  }, T, e);
}, P = v(f || (f = l`
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }

  100% {
    opacity: 1;
  }
`)), B = v(u || (u = l`
  0% {
    transform: translateX(-100%);
  }

  50% {
    /* +0.5s of delay between each loop */
    transform: translateX(100%);
  }

  100% {
    transform: translateX(100%);
  }
`)), D = _("span", {
  name: "MuiSkeleton",
  slot: "Root",
  overridesResolver: (o, e) => {
    const {
      ownerState: a
    } = o;
    return [e.root, e[a.variant], a.animation !== !1 && e[a.animation], a.hasChildren && e.withChildren, a.hasChildren && !a.width && e.fitContent, a.hasChildren && !a.height && e.heightAuto];
  }
})(({
  theme: o,
  ownerState: e
}) => {
  const a = U(o.shape.borderRadius) || "px", i = S(o.shape.borderRadius);
  return s({
    display: "block",
    // Create a "on paper" color with sufficient contrast retaining the color
    backgroundColor: o.vars ? o.vars.palette.Skeleton.bg : X(o.palette.text.primary, o.palette.mode === "light" ? 0.11 : 0.13),
    height: "1.2em"
  }, e.variant === "text" && {
    marginTop: 0,
    marginBottom: 0,
    height: "auto",
    transformOrigin: "0 55%",
    transform: "scale(1, 0.60)",
    borderRadius: `${i}${a}/${Math.round(i / 0.6 * 10) / 10}${a}`,
    "&:empty:before": {
      content: '"\\00a0"'
    }
  }, e.variant === "circular" && {
    borderRadius: "50%"
  }, e.variant === "rounded" && {
    borderRadius: (o.vars || o).shape.borderRadius
  }, e.hasChildren && {
    "& > *": {
      visibility: "hidden"
    }
  }, e.hasChildren && !e.width && {
    maxWidth: "fit-content"
  }, e.hasChildren && !e.height && {
    height: "auto"
  });
}, ({
  ownerState: o
}) => o.animation === "pulse" && m(g || (g = l`
      animation: ${0} 2s ease-in-out 0.5s infinite;
    `), P), ({
  ownerState: o,
  theme: e
}) => o.animation === "wave" && m(b || (b = l`
      position: relative;
      overflow: hidden;

      /* Fix bug in Safari https://bugs.webkit.org/show_bug.cgi?id=68196 */
      -webkit-mask-image: -webkit-radial-gradient(white, black);

      &::after {
        animation: ${0} 2s linear 0.5s infinite;
        background: linear-gradient(
          90deg,
          transparent,
          ${0},
          transparent
        );
        content: '';
        position: absolute;
        transform: translateX(-100%); /* Avoid flash during server-side hydration */
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
      }
    `), B, (e.vars || e).palette.action.hover)), E = /* @__PURE__ */ R.forwardRef(function(e, a) {
  const i = j({
    props: e,
    name: "MuiSkeleton"
  }), {
    animation: r = "pulse",
    className: d,
    component: n = "span",
    height: p,
    style: y,
    variant: k = "text",
    width: C
  } = i, c = x(i, A), h = s({}, i, {
    animation: r,
    component: n,
    variant: k,
    hasChildren: !!c.children
  }), w = M(h);
  return /* @__PURE__ */ $(D, s({
    as: n,
    ref: a,
    className: O(w.root, d),
    ownerState: h
  }, c, {
    style: s({
      width: C,
      height: p
    }, y)
  }));
});
process.env.NODE_ENV !== "production" && (E.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * The animation.
   * If `false` the animation effect is disabled.
   * @default 'pulse'
   */
  animation: t.oneOf(["pulse", "wave", !1]),
  /**
   * Optional children to infer width and height from.
   */
  children: t.node,
  /**
   * Override or extend the styles applied to the component.
   */
  classes: t.object,
  /**
   * @ignore
   */
  className: t.string,
  /**
   * The component used for the root node.
   * Either a string to use a HTML element or a component.
   */
  component: t.elementType,
  /**
   * Height of the skeleton.
   * Useful when you don't want to adapt the skeleton to a text element but for instance a card.
   */
  height: t.oneOfType([t.number, t.string]),
  /**
   * @ignore
   */
  style: t.object,
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: t.oneOfType([t.arrayOf(t.oneOfType([t.func, t.object, t.bool])), t.func, t.object]),
  /**
   * The type of content that will be rendered.
   * @default 'text'
   */
  variant: t.oneOfType([t.oneOf(["circular", "rectangular", "rounded", "text"]), t.string]),
  /**
   * Width of the skeleton.
   * Useful when the skeleton is inside an inline element with no width of its own.
   */
  width: t.oneOfType([t.number, t.string])
});
export {
  E as default
};
