"use client";
'use strict';

var React = require('react');
var framerMotion = require('framer-motion');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespace(React);

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function cn(...inputs) {
  return tailwindMerge.twMerge(clsx.clsx(inputs));
}
__name(cn, "cn");
var DockContext = React__namespace.createContext({
  magnification: 60,
  distance: 140,
  mouseX: null
});
var Dock = React__namespace.forwardRef(
  ({ className, children, magnification = 60, distance = 140 }, ref) => {
    const mouseX = framerMotion.useMotionValue(Infinity);
    return /* @__PURE__ */ jsxRuntime.jsx(DockContext.Provider, { value: { magnification, distance, mouseX }, children: /* @__PURE__ */ jsxRuntime.jsx(
      framerMotion.motion.div,
      {
        ref,
        onMouseMove: (e) => mouseX.set(e.pageX),
        onMouseLeave: () => mouseX.set(Infinity),
        className: cn(
          "mx-auto flex h-16 items-end gap-2 rounded-2xl border border-white/10 bg-black/10 px-3 pb-2 backdrop-blur-xl",
          "shadow-2xl shadow-black/20",
          "before:absolute before:inset-0 before:rounded-2xl before:bg-gradient-to-b before:from-white/10 before:to-transparent before:opacity-50",
          className
        ),
        children
      }
    ) });
  }
);
Dock.displayName = "Dock";
var DockItem = React__namespace.forwardRef(
  ({ className, children, onClick, tooltip }, ref) => {
    const buttonRef = React__namespace.useRef(null);
    const { magnification, distance, mouseX } = React__namespace.useContext(DockContext);
    const [isHovered, setIsHovered] = React__namespace.useState(false);
    const distanceCalc = framerMotion.useTransform(mouseX, (val) => {
      const bounds = buttonRef.current?.getBoundingClientRect() ?? {
        x: 0,
        width: 0
      };
      return val - bounds.x - bounds.width / 2;
    });
    const widthSync = framerMotion.useTransform(
      distanceCalc,
      [-distance, 0, distance],
      [48, 48 + magnification, 48]
    );
    const width = framerMotion.useSpring(widthSync, {
      mass: 0.1,
      stiffness: 150,
      damping: 12
    });
    return /* @__PURE__ */ jsxRuntime.jsxs(
      framerMotion.motion.div,
      {
        className: "relative",
        onMouseEnter: () => setIsHovered(true),
        onMouseLeave: () => setIsHovered(false),
        children: [
          tooltip && isHovered && /* @__PURE__ */ jsxRuntime.jsxs(
            framerMotion.motion.div,
            {
              initial: { opacity: 0, y: 10, scale: 0.9 },
              animate: { opacity: 1, y: 0, scale: 1 },
              exit: { opacity: 0, y: 5, scale: 0.95 },
              transition: { duration: 0.15 },
              className: "absolute bottom-full left-1/2 mb-2 -translate-x-1/2 whitespace-nowrap rounded-lg bg-black/80 px-2 py-1 text-xs text-white backdrop-blur-md",
              children: [
                tooltip,
                /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -bottom-1 left-1/2 h-2 w-2 -translate-x-1/2 rotate-45 bg-black/80" })
              ]
            }
          ),
          /* @__PURE__ */ jsxRuntime.jsxs(
            framerMotion.motion.button,
            {
              ref: buttonRef,
              style: { width },
              whileTap: { scale: 0.95 },
              onClick,
              className: cn(
                "aspect-square w-12 rounded-xl bg-white/10 backdrop-blur-md transition-colors",
                "hover:bg-white/20",
                "focus:outline-none focus-visible:ring-2 focus-visible:ring-white/50",
                "relative overflow-hidden",
                className
              ),
              children: [
                /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center justify-center", children }),
                /* @__PURE__ */ jsxRuntime.jsx(
                  "div",
                  {
                    className: "pointer-events-none absolute inset-0 rounded-xl",
                    style: {
                      background: "linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%)"
                    }
                  }
                )
              ]
            }
          )
        ]
      }
    );
  }
);
DockItem.displayName = "DockItem";

exports.Dock = Dock;
exports.DockItem = DockItem;
