import { defineComponent as a, ref as h, reactive as u, onMounted as m, unref as c, onUnmounted as _, createElementBlock as g, openBlock as L, createElementVNode as W, createVNode as s, renderSlot as v, withModifiers as d } from "vue";
import T from "./VScroll.vue.js";
import w from "./HScroll.vue.js";
import { tapIf as n, copyProps as H } from "../helpers/functions.js";
import { useResizeObserver as b } from "../composition/useResizeObserver.js";
const E = { class: "ui-scrollable" }, B = /* @__PURE__ */ a({
  __name: "Scrollable",
  setup(k) {
    const o = h(), l = u({
      scrollTop: 0,
      scrollLeft: 0,
      clientHeight: 0,
      clientWidth: 0,
      scrollHeight: 0,
      scrollWidth: 0
    });
    function r(e) {
      H(l, e, "scrollTop", "scrollLeft", "clientHeight", "clientWidth", "scrollHeight", "scrollWidth");
    }
    const i = (e) => {
      e.preventDefault();
      const t = e.currentTarget;
      t.scrollTop += e.deltaY, t.scrollLeft += e.deltaX, r(t);
    };
    function f(e) {
      n(c(o), (t) => {
        t.scrollTop = e, r(t);
      });
    }
    function p(e) {
      n(c(o), (t) => {
        t.scrollLeft = e, r(t);
      });
    }
    return b(o, (e) => {
      n(e, (t) => r(t));
    }), m(() => {
      n(c(o), (e) => {
        r(e), e.addEventListener("wheel", i);
      });
    }), _(() => {
      n(c(o), (e) => e.removeEventListener("wheel", i));
    }), (e, t) => (L(), g("div", E, [
      W("div", {
        ref_key: "containerRef",
        ref: o,
        class: "ui-scrollable__container",
        onWheel: i
      }, [
        v(e.$slots, "default")
      ], 544),
      s(T, {
        "scroll-top": l.scrollTop,
        "client-height": l.clientHeight,
        "scroll-height": l.scrollHeight,
        onWheel: t[0] || (t[0] = d(() => {
        }, ["stop"])),
        "onUpdate:scrollTop": f
      }, null, 8, ["scroll-top", "client-height", "scroll-height"]),
      s(w, {
        "scroll-left": l.scrollLeft,
        "client-width": l.clientWidth,
        "scroll-width": l.scrollWidth,
        onWheel: t[1] || (t[1] = d(() => {
        }, ["stop"])),
        "onUpdate:scrollLeft": p
      }, null, 8, ["scroll-left", "client-width", "scroll-width"])
    ]));
  }
});
export {
  B as default
};
//# sourceMappingURL=Scrollable.vue.js.map
