"use client";
import { t as e } from "../chunks/clsx.js";
import { useCallback as t, useRef as n } from "react";
import { jsx as r, jsxs as i } from "react/jsx-runtime";
//#region lib/ui/Scrollbar.tsx
function a({ children: a, timelineName: o = "--scroller", scrollbarWidth: s = "60%", variant: c = "light", className: l, scrollerClassName: u, scrollbarClassName: d, "aria-label": f = "Scrollable content" }) {
	let p = n(null), m = n(null), h = n(null), g = t((e) => {
		e.preventDefault();
		let t = p.current, n = m.current, r = h.current;
		if (!t || !n || !r) return;
		n.setPointerCapture(e.pointerId);
		let i = n.getBoundingClientRect(), a = n.clientWidth - r.offsetWidth - 2, o = t.scrollWidth - t.clientWidth;
		if (e.target !== r) {
			let n = e.clientX - i.left - 1;
			t.scrollLeft = Math.max(0, Math.min(a, n - r.offsetWidth / 2)) / a * o;
		}
		let s = e.clientX, c = t.scrollLeft, l = (e) => {
			let n = (e.clientX - s) / a * o;
			t.scrollLeft = Math.max(0, Math.min(o, c + n));
		}, u = () => {
			n.removeEventListener("pointermove", l), n.removeEventListener("pointerup", u);
		};
		n.addEventListener("pointermove", l), n.addEventListener("pointerup", u);
	}, []);
	return /* @__PURE__ */ i("div", {
		className: e(l),
		style: { timelineScope: o },
		children: [/* @__PURE__ */ r("div", {
			ref: p,
			"data-scroller": c,
			className: u,
			style: { scrollTimeline: `${o} x` },
			role: "region",
			"aria-label": f,
			tabIndex: 0,
			children: a
		}), /* @__PURE__ */ r("div", {
			ref: m,
			"data-scrollbar": !0,
			className: d,
			style: {
				"--scrollbar-width": s,
				pointerEvents: "auto",
				cursor: "pointer"
			},
			role: "scrollbar",
			"aria-controls": "scrollable-content",
			"aria-orientation": "horizontal",
			"aria-valuemin": 0,
			"aria-valuemax": 100,
			"aria-valuenow": 0,
			onPointerDown: g,
			children: /* @__PURE__ */ r("div", {
				ref: h,
				"data-scrollprogress": !0,
				style: {
					animationTimeline: o,
					pointerEvents: "auto"
				},
				role: "presentation"
			})
		})]
	});
}
//#endregion
export { a as Scrollbar };

//# sourceMappingURL=Scrollbar.js.map