import { useEventListener as e } from "../composition/useEventListener.js";
import { eventListener as t } from "../helpers/dom.js";
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, normalizeStyle as s, openBlock as c, ref as l, unref as u } from "vue";
var d = /* @__PURE__ */ o({
	__name: "VScroll",
	props: {
		scrollTop: {},
		clientHeight: {},
		scrollHeight: {}
	},
	emits: ["update:scrollTop"],
	setup(o, { emit: d }) {
		let f = d, p = o, m = l(), h = n(() => p.clientHeight / (p.scrollHeight || 1)), g = n(() => h.value < 1), _ = n(() => {
			let e = u(h);
			return {
				top: p.scrollTop * e + "px",
				height: Math.floor(p.clientHeight * e) + "px"
			};
		});
		return e(m, "pointerdown", (e) => {
			let n = { clientY: e.clientY }, r = t(document, "mousemove", (e) => {
				let t = (e.clientY - n.clientY) / h.value;
				f("update:scrollTop", p.scrollTop + t), n.clientY = e.clientY;
			});
			["mouseup", "pointercancel"].forEach((e) => {
				document.addEventListener(e, r, { once: !0 });
			});
		}), (e, t) => g.value ? (c(), i("div", {
			key: 0,
			ref_key: "scrollRef",
			ref: m,
			class: "v-scroll"
		}, [a("div", {
			class: "v-scroll__scrollbar",
			style: s(_.value)
		}, null, 4)], 512)) : r("", !0);
	}
});
export { d as default };

//# sourceMappingURL=VScroll.vue2.js.map