import { t as e } from "./utils-B7XIe3qq.js";
import { t } from "./createLucideIcon-wKpAnzBe.js";
import * as n from "react";
import { jsx as r, jsxs as i } from "react/jsx-runtime";
var a = t("arrow-left", [["path", {
	d: "m12 19-7-7 7-7",
	key: "1l729n"
}], ["path", {
	d: "M19 12H5",
	key: "x3x0zl"
}]]), o = t("arrow-right", [["path", {
	d: "M5 12h14",
	key: "1ays0h"
}], ["path", {
	d: "m12 5 7 7-7 7",
	key: "xquz4c"
}]]), s = n.createContext(null);
function c() {
	let e = n.useContext(s);
	if (!e) throw Error("useCarousel must be used within a <Carousel />");
	return e;
}
function l({ className: t, orientation: i = "horizontal", loop: a = !1, autoplay: o = !1, autoplayInterval: c = 5e3, children: l, ...u }) {
	let [d, f] = n.useState(0), [p, m] = n.useState(0), h = a || d > 0, g = a || d < p - 1, _ = n.useCallback(() => {
		f((e) => e > 0 ? e - 1 : a && p > 0 ? p - 1 : e);
	}, [a, p]), v = n.useCallback(() => {
		f((e) => e < p - 1 ? e + 1 : a ? 0 : e);
	}, [a, p]), y = n.useCallback((e) => {
		m(e);
	}, []);
	n.useEffect(() => {
		if (!o || p <= 1) return;
		let e = setInterval(() => {
			v();
		}, c);
		return () => clearInterval(e);
	}, [
		o,
		c,
		p,
		v
	]);
	let b = n.useCallback((e) => {
		let t = i === "horizontal" ? "ArrowLeft" : "ArrowUp", n = i === "horizontal" ? "ArrowRight" : "ArrowDown";
		e.key === t ? (e.preventDefault(), _()) : e.key === n && (e.preventDefault(), v());
	}, [
		i,
		_,
		v
	]), x = n.useMemo(() => ({
		orientation: i,
		canScrollPrev: h,
		canScrollNext: g,
		scrollPrev: _,
		scrollNext: v,
		currentIndex: d,
		setSlideCount: y
	}), [
		i,
		h,
		g,
		_,
		v,
		d,
		y
	]);
	return /* @__PURE__ */ r(s.Provider, {
		value: x,
		children: /* @__PURE__ */ r("div", {
			"data-slot": "carousel",
			role: "region",
			"aria-roledescription": "carousel",
			"aria-label": "Content carousel",
			tabIndex: 0,
			onKeyDown: b,
			className: e("relative", t),
			...u,
			children: l
		})
	});
}
function u({ className: t, children: i, ...a }) {
	let { orientation: o, currentIndex: s, setSlideCount: l } = c(), u = n.Children.count(i);
	return n.useEffect(() => {
		l(u);
	}, [u, l]), /* @__PURE__ */ r("div", {
		"data-slot": "carousel-content",
		className: e("overflow-hidden", t),
		...a,
		children: /* @__PURE__ */ r("div", {
			className: e("flex transition-transform duration-300 ease-in-out", o === "vertical" && "flex-col"),
			style: { transform: o === "horizontal" ? `translateX(-${String(s * 100)}%)` : `translateY(-${String(s * 100)}%)` },
			children: i
		})
	});
}
function d({ className: t, ...n }) {
	return /* @__PURE__ */ r("div", {
		"data-slot": "carousel-item",
		role: "group",
		"aria-roledescription": "slide",
		className: e("min-w-0 shrink-0 grow-0 basis-full", t),
		...n
	});
}
function f({ className: t, ...n }) {
	let { canScrollPrev: o, scrollPrev: s, orientation: l } = c();
	return /* @__PURE__ */ i("button", {
		"data-slot": "carousel-previous",
		type: "button",
		disabled: !o,
		onClick: s,
		className: e("absolute z-10 flex size-8 items-center justify-center rounded-full border border-border-glass bg-background/80 shadow-sm backdrop-blur-sm transition-all", "hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50", l === "horizontal" ? "-left-12 top-1/2 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", t),
		...n,
		children: [/* @__PURE__ */ r(a, { className: "size-4" }), /* @__PURE__ */ r("span", {
			className: "sr-only",
			children: "Previous slide"
		})]
	});
}
function p({ className: t, ...n }) {
	let { canScrollNext: a, scrollNext: s, orientation: l } = c();
	return /* @__PURE__ */ i("button", {
		"data-slot": "carousel-next",
		type: "button",
		disabled: !a,
		onClick: s,
		className: e("absolute z-10 flex size-8 items-center justify-center rounded-full border border-border-glass bg-background/80 shadow-sm backdrop-blur-sm transition-all", "hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50", l === "horizontal" ? "-right-12 top-1/2 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", t),
		...n,
		children: [/* @__PURE__ */ r(o, { className: "size-4" }), /* @__PURE__ */ r("span", {
			className: "sr-only",
			children: "Next slide"
		})]
	});
}
//#endregion
export { f as a, p as i, u as n, c as o, d as r, l as t };

//# sourceMappingURL=carousel-CJ5lxMYs.js.map