import { defineComponent as z, computed as u, openBlock as a, createElementBlock as c, normalizeClass as o, unref as e, createVNode as d, withModifiers as v, createBlock as m, createCommentVNode as f } from "vue";
import { EyeInvisibleOutlined as A, EyeOutlined as U, CaretUpOutlined as $, CaretDownOutlined as q, CaretLeftOutlined as F, CaretRightOutlined as H } from "@ant-design/icons-vue";
import { useToken as J } from "@aplus-frontend/antdv/es/theme/internal";
import { useInjectSorter as K, useInjectExpandable as P, useMaskVisible as Q } from "../../context.mjs";
import { getTableTitle as W } from "../../../ap-table/utils.mjs";
import "../../../config-provider/index.mjs";
import "../../../render/index.mjs";
import X from "../../style/custom-header.mjs";
import { useNamespace as S } from "../../../config-provider/hooks/use-namespace.mjs";
import Y from "../../../render/render.mjs";
const ce = /* @__PURE__ */ z({
  __name: "index",
  props: {
    params: {}
  },
  setup(n) {
    const t = n, { b: h, e: l } = S("ag-custom-header"), { be: y, bem: I } = S("ag-grid"), w = X("ag-custom-header"), [, E] = J(), i = u(() => t.params?.column?.getColId?.()), { sorter: g, setSorter: T } = K(), p = u(() => t.params.column.sorter);
    function O(r) {
      return r ? r === "asc" ? "desc" : null : "asc";
    }
    function V() {
      if (!p.value)
        return;
      const s = t.params.column.getColId(), L = t.params.column.getSort(), C = O(L), b = t.params.api, R = b.getColumnState().map((x) => ({
        ...x,
        sort: x.colId === s ? C : null
      }));
      b.applyColumnState({
        state: R
      }), T({ [s]: C });
    }
    const { expandable: G } = P(), M = u(() => t.params.columnGroup?.getLeafColumns?.()?.some((r) => r.getColDef().columnGroupShow)), k = u(() => {
      const r = t.params.columnGroup?.getGroupId?.();
      return r ? G.value[r] ?? !1 : !1;
    });
    function N() {
      t.params.setExpanded(!k.value);
    }
    const { maskVisible: B, toggleMaskVisible: j } = Q(i), D = u(() => t.params.column.mask);
    return (r, s) => (a(), c("div", {
      class: o([
        e(h)(),
        { sortable: p.value },
        `align-${n.params.column.align || "left"}`,
        e(w)
      ]),
      onClick: V
    }, [
      d(e(Y), {
        renderer: () => e(W)(
          n.params.column,
          [
            e(y)("table-header", "title"),
            n.params.column.tooltip ? "" : e(I)("table-header", "title", "single")
          ],
          n.params.headerCell,
          e(E).colorTextTertiary
        )
      }, null, 8, ["renderer"]),
      D.value ? (a(), c("span", {
        key: 0,
        class: o(e(l)("mask-wrapper")),
        onClick: s[0] || (s[0] = v(() => e(j)(), ["stop"]))
      }, [
        e(B) ? (a(), m(e(A), { key: 0 })) : (a(), m(e(U), { key: 1 }))
      ], 2)) : f("", !0),
      p.value ? (a(), c("span", {
        key: 1,
        class: o(e(l)("sort-wrapper"))
      }, [
        d(e($), {
          class: o({ [e(l)("sorter-up")]: !0, active: e(g)[i.value] === "asc" })
        }, null, 8, ["class"]),
        d(e(q), {
          class: o({ [e(l)("sorter-down")]: !0, active: e(g)[i.value] === "desc" })
        }, null, 8, ["class"])
      ], 2)) : f("", !0),
      M.value ? (a(), c("span", {
        key: 2,
        class: o(e(l)("expand-wrapper")),
        onClick: v(N, ["stop"])
      }, [
        k.value ? (a(), m(e(F), { key: 0 })) : (a(), m(e(H), { key: 1 }))
      ], 2)) : f("", !0)
    ], 2));
  }
});
export {
  ce as default
};
