import { jsx as i } from "react/jsx-runtime";
import { useState as F, useMemo as y } from "react";
import { a as N } from "./index-react-spring_web.modern.js";
import { HOVER_DEFAULTS as x, getEntryPresetConfig as O, GENERIC_LEAVE as C } from "./index-CardMotion.config.js";
import p from "./index-CardMotion.module.scss.js";
import { useSpring as P, useTransition as R, to as T } from "./index-react-spring_core.modern.js";
function U({
  delay: f,
  className: a,
  style: g,
  children: E,
  hoverable: o = !1,
  glowIn: H = !1,
  index: d,
  isVisible: n = !0,
  entryPreset: L,
  entryAnimation: m,
  leaveAnimation: l,
  hoverAnimation: r
}) {
  const [S, $] = F(!1), v = L ?? (H ? "glow-in" : "fade-up"), c = y(() => r === !1 || !o && r === void 0 ? {
    ...x,
    y: 0
  } : {
    ...x,
    ...o ? {} : {
      y: 0
    },
    ...r
  }, [r, o]), w = P({
    hoverY: S ? c.y : 0,
    hoverScale: S ? c.scale : 1,
    config: {
      tension: c.tension,
      friction: c.friction
    }
  }), e = y(() => O(v, f, g, d, m), [v, f, g, d, m]), t = y(() => ({
    ...C,
    ...l === !1 ? {
      ...C,
      opacity: 1,
      y: 0,
      scale: 1,
      blur: 0,
      duration: 0,
      delay: 0
    } : l
  }), [l]), M = R(n ? ["visible"] : [], {
    keys: (s) => s,
    from: e.transitionFrom,
    enter: e.transitionEnter,
    leave: l === !1 ? {
      opacity: 1,
      y: 0,
      scale: 1,
      blur: 0
    } : {
      opacity: t.opacity,
      y: t.y,
      scale: t.scale,
      blur: t.blur
    },
    delay: n ? (f + e.delayOffset) * 1e3 : t.delay * 1e3,
    config: {
      duration: (n ? e.duration : t.duration) * 1e3
    },
    expires: !0
  });
  return !n && l === !1 ? null : M((s) => i(N.div, {
    className: e.kind === "spring" ? a : void 0,
    onMouseEnter: o || r ? () => $(!0) : void 0,
    onMouseLeave: o || r ? () => $(!1) : void 0,
    style: {
      ...e.baseStyle ?? {},
      opacity: s.opacity,
      filter: s.blur.to((u) => `blur(${u}px)`),
      transform: T([s.y, s.scale, w.hoverY, w.hoverScale], (u, k, I, h) => `translate3d(0, ${u + I}px, 0) scale(${k * h})`)
    },
    children: e.kind === "glow-shell" ? i("div", {
      className: a ? `${p.glowShell} ${a}` : p.glowShell,
      style: e.shellStyle,
      "data-card-motion-index": d,
      children: i("div", {
        className: p.contentIn,
        style: e.contentStyle,
        children: E
      })
    }) : E
  }));
}
export {
  U as CardMotion
};
