import { defineComponent as R, useTemplateRef as b, ref as S, shallowRef as P, onUnmounted as k, openBlock as z, createBlock as A, unref as r, normalizeProps as N, guardReactiveProps as T, withCtx as $, createElementVNode as B, normalizeStyle as D, normalizeClass as I, renderSlot as M } from "vue";
import { isNil as u } from "lodash-unified";
import { APConfigProvider as U } from "../../config-provider/index.mjs";
import q from "./style/index.mjs";
import { useGlobalConfig as E } from "../../config-provider/hooks/use-global-config.mjs";
import { globalConfigCached as d } from "../../config-provider/config-provider.mjs";
import { useNamespace as V } from "../../config-provider/hooks/use-namespace.mjs";
const Q = /* @__PURE__ */ R({
  __name: "index",
  props: {
    minHeight: { default: 150 },
    maxHeight: { default: "unset" },
    mode: { default: void 0 }
  },
  emits: ["heightChange"],
  setup(n, { emit: h }) {
    const l = E(), p = d.value.agGrid, s = n, H = h, a = b("wrapperContainer"), g = S(c(s.minHeight)), { b: C, m: w } = V("ag-grid-container"), x = q("ag-grid-container"), m = (e) => {
      const o = a.value?.clientHeight, t = a.value?.querySelector(
        ".ag-body.ag-layout-normal"
      )?.clientHeight;
      let i = 0;
      !o || !t ? i = 0 : i = o - t;
      const G = e + i, f = Math.max(G, s.minHeight);
      g.value = `${f}px`, H("heightChange", f);
    }, v = (e) => {
      if (!e) return;
      const o = e.getDisplayedRowCount();
      if (o > 0) {
        const t = e.getDisplayedRowAtIndex(o - 1);
        if (t && !u(t.rowTop) && !u(t.rowHeight)) {
          const i = t.rowTop + t.rowHeight;
          m(i);
        }
      } else
        m(150);
    }, y = P({
      ...l.value,
      agGrid: {
        ...l.value?.agGrid,
        onModelUpdated: v
      }
    });
    k(() => {
      d.value.agGrid = p;
    });
    function c(e) {
      return typeof e == "number" && e ? `${e}px` : e.toString();
    }
    return (e, o) => (z(), A(r(U), N(T(y.value)), {
      default: $(() => [
        B("div", {
          ref_key: "wrapperContainer",
          ref: a,
          class: I([r(C)(), n.mode === "form-item" ? r(w)("form-item") : "", r(x)]),
          style: D({
            height: g.value,
            maxHeight: n.maxHeight && c(n.maxHeight)
          })
        }, [
          M(e.$slots, "default")
        ], 6)
      ]),
      _: 3
    }, 16));
  }
});
export {
  Q as default
};
