import { omit as d, isUndefined as s, isFunction as g, isNumber as m } from "lodash-unified";
import "../../utils/index.mjs";
import { isDef as C } from "../../utils/is.mjs";
const b = 20, y = 50, v = (e) => e.some((i) => !!i.html);
function z(e, i) {
  const t = {
    ...d(e, [
      "columns",
      "request",
      "searchForm",
      "dataSource",
      "rowKey",
      "value",
      "round"
    ])
  };
  return t.rowConfig = {
    isHover: !0,
    keyField: e.rowKey,
    isCurrent: !!e.rowHighlightable
  }, t.columnConfig = {}, v(e.columns || []) && (t.rowConfig.useKey = !0, t.columnConfig.useKey = !0), e.adaptive && (t.autoResize = !0, t.height = "100%"), e.columnResizable && (t.columnConfig.resizable = !0), i && (i.type === "radio" ? t.radioConfig = {
    highlight: !0,
    checkMethod({ row: r }) {
      return i.disabled ? !i.disabled(r) : !0;
    },
    visibleMethod({ row: r }) {
      return i.shown ? i.shown(r) : !0;
    },
    checkRowKey: i.defaultSelectedRowKeys?.[0],
    reserve: i.preserveSelectedRowKeys || s(e.dataSource)
  } : t.checkboxConfig = {
    highlight: !0,
    checkMethod({ row: r }) {
      return i.disabled ? !i.disabled(r) : !0;
    },
    visibleMethod({ row: r }) {
      return i.shown ? i.shown(r) : !0;
    },
    // tips: 离线表格或者手动设置了缓存都会将此字段设置为true
    reserve: i.preserveSelectedRowKeys || s(e.dataSource),
    range: i.range || !1
  }), t.border = e.bordered === !1 ? "inner" : !0, e.expandable && (t.expandConfig = d(e.expandable, [
    "renderContent",
    "width",
    "title"
  ])), e.footer && (t.showFooter = !0, g(e.footer) ? t.footerMethod = e.footer : t.footerData = e.footer), e.virtual === !1 ? (t.virtualXConfig = {
    enabled: !1
  }, t.virtualYConfig = {
    enabled: !1
  }) : (l(t, "X", e.virtual), l(t, "Y", e.virtual)), t.round = C(e.round) ? e.round : !e.card, t.headerCellConfig = {
    height: 36,
    ...t.headerCellConfig || {}
  }, t.treeConfig && (t.treeConfig = {
    ...t.treeConfig || {},
    /**
     * 使用非树层级列表，配合transform
     */
    transform: !0
  }), t.resizableConfig = {
    minWidth({ cell: r }) {
      return R(r, e.size);
    }
  }, t;
}
function l(e, i, t) {
  const n = i === "X", r = n ? "x" : "y", a = n ? "virtualXConfig" : "virtualYConfig", o = t?.[r], u = o !== !1, f = n ? b : y, c = m(o) && o >= 0 ? o : f;
  e[a] = {
    enabled: u,
    gt: c,
    oSize: t?.oSize || 0
  };
}
function x(e) {
  return e === !0 ? "left" : e;
}
function F(e, i, t) {
  const n = e === !0 || !e.type ? "checkbox" : e.type, r = (t === "mini" ? 18 : 24) + 16, a = e === !0 ? r : e.columnWidth || r;
  let o = e === !0 ? void 0 : x(e.fixed);
  return o || (o === !1 ? o = void 0 : o = i.some(
    (u) => u.fixed === "left" || u.fixed === !0
  ) ? "left" : void 0), {
    type: n,
    width: a,
    fixed: o
  };
}
function K(e) {
  const i = e?.width || "auto";
  return {
    type: "expand",
    title: e?.title,
    width: i
  };
}
function h(e) {
  if (!e)
    return 0;
  const i = getComputedStyle(e);
  return e.offsetWidth + (Number.parseFloat(i.marginLeft) || 0) + Number.parseFloat(i.marginRight) || 0;
}
function R(e, i) {
  if (!e)
    return "auto";
  const t = getComputedStyle(e);
  let n = i === "medium" ? 24 : 18;
  const r = (Number.parseFloat(t.fontSize) || 14) * 1.6;
  return n += r, e.querySelector("span.anticon-question-circle") && (n += 20), n += h(e.querySelector(".vxe-cell--sort")) + h(e.querySelector(".vxe-cell--filter")), Math.ceil(n);
}
export {
  K as getRowExpandProps,
  F as getRowSelectionProps,
  z as toVxeProps
};
