"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-namespace/index.js");
const index$1 = require("../../../hooks/use-ordered-children/index.js");
const splitter = require("./splitter.js");
const useContainer = require("./hooks/useContainer.js");
const useSize = require("./hooks/useSize.js");
const useResize = require("./hooks/useResize.js");
const type = require("./type.js");
const vue = require("vue");
var splitter_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
  name: "ElSplitter",
  __name: "splitter",
  props: splitter.splitterProps,
  emits: splitter.splitterEmits,
  setup(__props, { emit: __emit }) {
    const ns = index.useNamespace("splitter");
    const emits = __emit;
    const props = __props;
    const layout = vue.toRef(props, "layout");
    const lazy = vue.toRef(props, "lazy");
    const { containerEl, containerSize } = useContainer.useContainer(layout);
    const { removeChild: unregisterPanel, children: panels, addChild: registerPanel, ChildrenSorter: PanelsSorter } = index$1.useOrderedChildren(vue.getCurrentInstance(), "ElSplitterPanel");
    vue.watch(panels, () => {
      movingIndex.value = null;
      panels.value.forEach((instance, index2) => {
        instance.setIndex(index2);
      });
    });
    const { percentSizes, pxSizes } = useSize.useSize(panels, containerSize);
    const { lazyOffset, movingIndex, onMoveStart, onMoving, onMoveEnd, onCollapse } = useResize.useResize(panels, containerSize, pxSizes, lazy);
    const splitterStyles = vue.computed(() => {
      return { [ns.cssVarBlockName("bar-offset")]: lazy.value ? `${lazyOffset.value}px` : void 0 };
    });
    const onResizeStart = (index2) => {
      onMoveStart(index2);
      emits("resizeStart", index2, pxSizes.value);
    };
    const onResize = (index2, offset) => {
      onMoving(index2, offset);
      if (!lazy.value) emits("resize", index2, pxSizes.value);
    };
    const onResizeEnd = async (index2) => {
      onMoveEnd();
      await vue.nextTick();
      emits("resizeEnd", index2, pxSizes.value);
    };
    const onCollapsible = (index2, type2) => {
      onCollapse(index2, type2);
      emits("collapse", index2, type2, pxSizes.value);
    };
    vue.provide(type.splitterRootContextKey, vue.reactive({
      panels,
      percentSizes,
      pxSizes,
      layout,
      lazy,
      movingIndex,
      containerSize,
      onMoveStart: onResizeStart,
      onMoving: onResize,
      onMoveEnd: onResizeEnd,
      onCollapse: onCollapsible,
      registerPanel,
      unregisterPanel
    }));
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", {
        ref_key: "containerEl",
        ref: containerEl,
        class: vue.normalizeClass([vue.unref(ns).b(), vue.unref(ns).e(layout.value)]),
        style: vue.normalizeStyle(splitterStyles.value)
      }, [
        vue.renderSlot(_ctx.$slots, "default"),
        vue.createVNode(vue.unref(PanelsSorter)),
        vue.createCommentVNode(" Prevent iframe touch events from breaking "),
        vue.unref(movingIndex) ? (vue.openBlock(), vue.createElementBlock("div", {
          key: 0,
          class: vue.normalizeClass([vue.unref(ns).e("mask"), vue.unref(ns).e(`mask-${layout.value}`)])
        }, null, 2)) : vue.createCommentVNode("v-if", true)
      ], 6);
    };
  }
});
exports.default = splitter_vue_vue_type_script_setup_true_lang_default;
