import { defineComponent as G, ref as J, unref as e, computed as C, openBlock as r, createBlock as S, withCtx as k, createElementVNode as K, normalizeClass as I, normalizeStyle as Q, createElementBlock as p, Fragment as y, renderList as R, createVNode as T, mergeProps as X, resolveDynamicComponent as Y, createCommentVNode as E } from "vue";
import { omit as Z } from "lodash-unified";
import "../config-provider/index.mjs";
import "../resize-observer/index.mjs";
import { useDevWarning as x } from "../utils/warning.mjs";
import { useItems as _ } from "./hooks/useItems.mjs";
import { useResizable as ee } from "./hooks/useResizable.mjs";
import { useResize as te } from "./hooks/useResize.mjs";
import { useSizes as oe } from "./hooks/useSizes.mjs";
import "./Panel.vue.mjs";
import "./SplitBar.vue.mjs";
import ae from "./style/index.mjs";
import { useNamespace as ne } from "../config-provider/hooks/use-namespace.mjs";
import le from "../resize-observer/index.vue.mjs";
import se from "./Panel.vue2.mjs";
import ie from "./SplitBar.vue2.mjs";
const Re = /* @__PURE__ */ G({
  name: "Splitter",
  __name: "Splitter",
  props: {
    prefixCls: {},
    className: {},
    style: {},
    rootClassName: {},
    layout: { default: "horizontal" },
    onResizeStart: {},
    onResize: {},
    onResizeEnd: {},
    lazy: { type: Boolean },
    draggerIcon: {},
    collapsibleIcon: {},
    collapsible: {},
    destroyOnHidden: { type: Boolean },
    onDraggerDoubleClick: {}
  },
  setup(l) {
    const s = l, { b: u } = ne("splitter"), w = ae("splitter");
    x("Splitter").deprecated(!s.collapsibleIcon, "deprecated", "collapsible.icon");
    const c = _(), m = J(), D = (t) => {
      const { offsetWidth: n, offsetHeight: a } = t.target, o = s.layout === "vertical" ? a : n;
      m.value !== 0 && (m.value = o);
    }, [
      O,
      z,
      v,
      N,
      P,
      M
    ] = oe(c, m), i = ee(c, z, !1), [B, H, U, $, d] = te(
      c,
      i,
      v,
      m,
      M,
      !1
    ), V = (t) => {
      B(t), s.onResizeStart?.(e(z));
    }, W = (t, n) => {
      const a = H(t, n);
      s.onResize?.(a);
    }, A = () => {
      U(), s.onResizeEnd?.(e(z));
    }, F = (t, n) => {
      const a = $(t, n);
      s.onResize?.(a), s.onResizeEnd?.(a);
    }, L = C(() => [u(), s.className, u(s.layout), w.value]), h = C(() => {
      const t = [];
      let n = 0;
      for (let a = 0; a < c.value.length; a += 1)
        n += e(v)[a], t.push(n);
      return t;
    }), f = (t) => {
      const n = e(h), a = e(N), o = e(P);
      return {
        minStart: (n[t - 1] || 0) + a[t],
        minEnd: (n[t + 1] || 100) - o[t + 1],
        maxStart: (n[t - 1] || 0) + o[t],
        maxEnd: (n[t + 1] || 100) - a[t + 1]
      };
    };
    return (t, n) => (r(), S(e(le), { onResize: D }, {
      default: k(() => [
        K("div", {
          style: Q(l.style),
          class: I(L.value)
        }, [
          (r(!0), p(y, null, R(e(c), (a, o) => (r(), p(y, { key: o }, [
            T(se, X({ ref_for: !0 }, e(Z)(a, "_child"), {
              size: e(O)[o],
              "support-motion": l.collapsible?.motion && e(d) === void 0,
              "destroy-on-hidden": a.destroyOnHidden ?? l.destroyOnHidden
            }), {
              default: k(() => [
                (r(!0), p(y, null, R(a._child, (g, b) => (r(), S(Y(g), { key: b }))), 128))
              ]),
              _: 2
            }, 1040, ["size", "support-motion", "destroy-on-hidden"]),
            e(i)[o] ? (r(), S(ie, {
              key: 0,
              lazy: l.lazy,
              index: o,
              active: e(d) === o,
              vertical: l.layout === "vertical",
              resizable: e(i)[o].resizable,
              "aria-valuenow": h.value[o] * 100,
              "aria-valuemin": Math.max(
                f(o).minStart,
                f(o).minEnd
              ) * 100,
              "aria-valuemax": Math.min(
                f(o).maxStart,
                f(o).maxEnd
              ) * 100,
              "start-collapsible": e(i)[o].startCollapsible,
              "end-collapsible": e(i)[o].endCollapsible,
              "show-start-collapsible-icon": e(i)[o].showStartCollapsibleIcon,
              "show-end-collapsible-icon": e(i)[o].showEndCollapsibleIcon,
              "container-size": m.value || 0,
              "dragger-icon": l.draggerIcon,
              "collapsible-icon": l.collapsible?.icon || l.collapsibleIcon,
              onOffsetStart: V,
              onOffsetUpdate: (g, b, j) => {
                let q = l.layout === "vertical" ? j : b;
                W(g, q);
              },
              onOffsetEnd: A,
              onCollapse: F,
              onDraggerDoubleClick: l.onDraggerDoubleClick
            }, null, 8, ["lazy", "index", "active", "vertical", "resizable", "aria-valuenow", "aria-valuemin", "aria-valuemax", "start-collapsible", "end-collapsible", "show-start-collapsible-icon", "show-end-collapsible-icon", "container-size", "dragger-icon", "collapsible-icon", "onOffsetUpdate", "onDraggerDoubleClick"])) : E("", !0)
          ], 64))), 128)),
          typeof e(d) == "number" ? (r(), p("div", {
            key: 0,
            "aria-hidden": "",
            class: I([e(u)("mask"), e(u)(`mask-${l.layout}`)])
          }, null, 2)) : E("", !0)
        ], 6)
      ]),
      _: 1
    }));
  }
});
export {
  Re as default
};
