"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const index$1 = require("../../../../../@vueuse/core/index.js");
const bar2 = require("./bar2.js");
const constants = require("./constants.js");
const scrollbar = require("./scrollbar.js");
const pluginVue_exportHelper = require("../../../_virtual/plugin-vue_export-helper.js");
const index = require("../../../hooks/use-namespace/index.js");
const style = require("../../../utils/dom/style.js");
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const types = require("../../../utils/types.js");
const d = "ElScrollbar", ee = Vue.defineComponent({
  name: d
}), re = /* @__PURE__ */ Vue.defineComponent({
  ...ee,
  props: scrollbar.scrollbarProps,
  emits: scrollbar.scrollbarEmits,
  setup(E, { expose: T, emit: L }) {
    const r = E, t = index.useNamespace("scrollbar");
    let c, f;
    const b = Vue.ref(), l = Vue.ref(), h = Vue.ref(), a = Vue.ref(), N = Vue.computed(() => {
      const e = {};
      return r.height && (e.height = style.addUnit(r.height)), r.maxHeight && (e.maxHeight = style.addUnit(r.maxHeight)), [r.wrapStyle, e];
    }), g = Vue.computed(() => [
      r.wrapClass,
      t.e("wrap"),
      { [t.em("wrap", "hidden-default")]: !r.native }
    ]), O = Vue.computed(() => [t.e("view"), r.viewClass]), y = () => {
      var e;
      l.value && ((e = a.value) == null || e.handleScroll(l.value), L("scroll", {
        scrollTop: l.value.scrollTop,
        scrollLeft: l.value.scrollLeft
      }));
    };
    function B(e, m) {
      shared_esmBundler.isObject(e) ? l.value.scrollTo(e) : types.isNumber(e) && types.isNumber(m) && l.value.scrollTo(e, m);
    }
    const H = (e) => {
      if (!types.isNumber(e)) {
        return;
      }
      l.value.scrollTop = e;
    }, K = (e) => {
      if (!types.isNumber(e)) {
        return;
      }
      l.value.scrollLeft = e;
    }, o = () => {
      var e;
      (e = a.value) == null || e.update();
    };
    return Vue.watch(() => r.noresize, (e) => {
      e ? (c == null || c(), f == null || f()) : ({ stop: c } = index$1.useResizeObserver(h, o), f = index$1.useEventListener("resize", o));
    }, { immediate: true }), Vue.watch(() => [r.maxHeight, r.height], () => {
      r.native || Vue.nextTick(() => {
        var e;
        o(), l.value && ((e = a.value) == null || e.handleScroll(l.value));
      });
    }), Vue.provide(constants.scrollbarContextKey, Vue.reactive({
      scrollbarElement: b,
      wrapElement: l
    })), Vue.onMounted(() => {
      r.native || Vue.nextTick(() => {
        o();
      });
    }), Vue.onUpdated(() => o()), T({
      wrapRef: l,
      update: o,
      scrollTo: B,
      setScrollTop: H,
      setScrollLeft: K,
      handleScroll: y
    }), (e, m) => (Vue.openBlock(), Vue.createElementBlock("div", {
      ref_key: "scrollbarRef",
      ref: b,
      class: Vue.normalizeClass(Vue.unref(t).b())
    }, [
      Vue.createElementVNode("div", {
        ref_key: "wrapRef",
        ref: l,
        class: Vue.normalizeClass(Vue.unref(g)),
        style: Vue.normalizeStyle(Vue.unref(N)),
        onScroll: y
      }, [
        (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(e.tag), {
          id: e.id,
          ref_key: "resizeRef",
          ref: h,
          class: Vue.normalizeClass(Vue.unref(O)),
          style: Vue.normalizeStyle(e.viewStyle),
          role: e.role,
          "aria-label": e.ariaLabel,
          "aria-orientation": e.ariaOrientation
        }, {
          default: Vue.withCtx(() => [
            Vue.renderSlot(e.$slots, "default")
          ]),
          _: 3
        }, 8, ["id", "class", "style", "role", "aria-label", "aria-orientation"]))
      ], 38),
      e.native ? Vue.createCommentVNode("v-if", true) : (Vue.openBlock(), Vue.createBlock(bar2.default, {
        key: 0,
        ref_key: "barRef",
        ref: a,
        always: e.always,
        "min-size": e.minSize
      }, null, 8, ["always", "min-size"]))
    ], 2));
  }
});
var pe = /* @__PURE__ */ pluginVue_exportHelper.default(re, [["__file", "scrollbar.vue"]]);
exports.default = pe;
