import { jsx as d } from "react/jsx-runtime";
import * as i from "react";
import { useAnimationControls as f } from "../../shop-minis-react/node_modules/.pnpm/motion@12.17.3_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/motion/dist/es/framer-motion/dist/es/animation/hooks/use-animation.js";
import { motion as h } from "../../shop-minis-react/node_modules/.pnpm/motion@12.17.3_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/motion/dist/es/framer-motion/dist/es/render/components/motion/proxy.js";
const L = ({
  children: l,
  onClick: a,
  stopPropagation: e = !1,
  ...u
}) => {
  const r = i.useRef(null), n = f(), { ref: v, ...m } = u, p = i.useCallback(
    (t) => {
      e && t.stopPropagation(), a?.(t);
    },
    [e, a]
  );
  return i.useEffect(() => {
    if (!e || !r.current) return;
    const t = r.current, s = (o) => {
      o.stopImmediatePropagation(), o.stopPropagation(), n.start({
        scale: 0.95,
        opacity: 0.7
      });
    }, c = (o) => {
      o.stopImmediatePropagation(), o.stopPropagation(), n.start({
        scale: 1,
        opacity: 1
      });
    };
    return t.addEventListener("pointerdown", s, !0), t.addEventListener("pointerup", c, !0), () => {
      t.removeEventListener("pointerdown", s, !0), t.removeEventListener("pointerup", c, !0);
    };
  }, [e, n]), /* @__PURE__ */ d(
    h.div,
    {
      ref: r,
      "data-touchable": "true",
      className: "flex w-full",
      animate: e ? n : void 0,
      whileTap: e ? void 0 : { scale: 0.95, opacity: 0.7 },
      transition: {
        scale: { type: "tween", duration: 0.08, ease: "linear" },
        opacity: { type: "tween", duration: 0.08, ease: "linear" }
      },
      onClick: p,
      style: {
        touchAction: e ? "manipulation" : void 0
      },
      ...m,
      children: l
    }
  );
};
export {
  L as Touchable
};
//# sourceMappingURL=touchable.js.map
