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