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