import x from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import w from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import G from "../../../classnames/index.mjs";
import * as o from "react";
import J from "../context.mjs";
import { SEARCH_MARK as Q } from "../hooks/useSearchOptions.mjs";
import { isLeaf as U, toPathKey as W } from "../utils/commonUtil.mjs";
import Y from "./Checkbox.mjs";
var Z = "__cascader_fix_label__";
function ce(a) {
  var P = a.prefixCls, S = a.multiple, L = a.options, E = a.activeValue, M = a.prevValuePath, R = a.onToggleOpen, T = a.onSelect, B = a.onActive, N = a.checkedSet, I = a.halfCheckedSet, K = a.loadingKeys, F = a.isSelectable, X = a.searchValue, $ = "".concat(P, "-menu"), t = "".concat(P, "-menu-item"), i = o.useContext(J), h = i.fieldNames, H = i.changeOnSelect, j = i.expandTrigger, O = i.expandIcon, A = i.loadingIcon, q = i.dropdownMenuColumnStyle, V = j === "hover", z = o.useMemo(function() {
    return L.map(function(e) {
      var l, m = e.disabled, v = e.disableCheckbox, p = e[Q], c = (l = e[Z]) !== null && l !== void 0 ? l : e[h.label], r = e[h.value], C = U(e, h), b = p ? p.map(function(k) {
        return k[h.value];
      }) : [].concat(w(M), [r]), n = W(b), g = K.includes(n), f = N.has(n), s = I.has(n);
      return {
        disabled: m,
        label: c,
        value: r,
        isLeaf: C,
        isLoading: g,
        checked: f,
        halfChecked: s,
        option: e,
        disableCheckbox: v,
        fullPath: b,
        fullPathKey: n
      };
    });
  }, [L, N, h, I, K, M]);
  return /* @__PURE__ */ o.createElement("ul", {
    className: $,
    role: "menu"
  }, z.map(function(e) {
    var l, m = e.disabled, v = e.label, p = e.value, c = e.isLeaf, r = e.isLoading, C = e.checked, b = e.halfChecked, n = e.option, g = e.fullPath, f = e.fullPathKey, s = e.disableCheckbox, k = function() {
      if (!(m || X)) {
        var u = w(g);
        V && c && u.pop(), B(u);
      }
    }, D = function() {
      F(n) && T(g, c);
    }, y;
    return typeof n.title == "string" ? y = n.title : typeof v == "string" && (y = v), /* @__PURE__ */ o.createElement("li", {
      key: f,
      className: G(t, (l = {}, x(l, "".concat(t, "-expand"), !c), x(l, "".concat(t, "-active"), E === p || E === f), x(l, "".concat(t, "-disabled"), m), x(l, "".concat(t, "-loading"), r), l)),
      style: q,
      role: "menuitemcheckbox",
      title: y,
      "aria-checked": C,
      "data-path-key": f,
      onClick: function() {
        k(), !s && (!S || c) && D();
      },
      onDoubleClick: function() {
        H && R(!1);
      },
      onMouseEnter: function() {
        V && k();
      },
      onMouseDown: function(u) {
        u.preventDefault();
      }
    }, S && /* @__PURE__ */ o.createElement(Y, {
      prefixCls: "".concat(P, "-checkbox"),
      checked: C,
      halfChecked: b,
      disabled: m || s,
      disableCheckbox: s,
      onClick: function(u) {
        s || (u.stopPropagation(), D());
      }
    }), /* @__PURE__ */ o.createElement("div", {
      className: "".concat(t, "-content")
    }, v), !r && O && !c && /* @__PURE__ */ o.createElement("div", {
      className: "".concat(t, "-expand-icon")
    }, O), r && A && /* @__PURE__ */ o.createElement("div", {
      className: "".concat(t, "-loading-icon")
    }, A));
  }));
}
export {
  Z as FIX_LABEL,
  ce as default
};
