import T from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import f from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import re from "../../classnames/index.mjs";
import b from "../../rc-util/es/hooks/useEvent.mjs";
import ne from "../../rc-util/es/hooks/useMergedState.mjs";
import * as r from "react";
import "../../rc-util/node_modules/react-is/index.mjs";
import "../../rc-util/es/warning.mjs";
import le from "./context.mjs";
import ie from "./hooks/useMissingValues.mjs";
import se from "./hooks/useOptions.mjs";
import ce from "./hooks/useSelect.mjs";
import ue from "./hooks/useValues.mjs";
import me from "./OptionList/List.mjs";
import { fillFieldNames as de, toRawValues as D } from "./utils/commonUtil.mjs";
import { toPathOptions as pe } from "./utils/treeUtil.mjs";
function fe() {
}
function we($) {
  var n, e = $, g = e.prefixCls, v = g === void 0 ? "rc-cascader" : g, K = e.style, R = e.className, A = e.options, i = e.checkable, B = e.defaultValue, J = e.value, h = e.fieldNames, C = e.changeOnSelect, S = e.onChange, L = e.showCheckedStrategy, y = e.loadData, x = e.expandTrigger, V = e.expandIcon, _ = V === void 0 ? ">" : V, N = e.loadingIcon, O = e.direction, k = e.notFoundContent, j = k === void 0 ? "Not Found" : k, t = !!i, q = ne(B, {
    value: J,
    postState: D
  }), I = f(q, 2), z = I[0], G = I[1], a = r.useMemo(
    function() {
      return de(h);
    },
    /* eslint-disable react-hooks/exhaustive-deps */
    [JSON.stringify(h)]
    /* eslint-enable react-hooks/exhaustive-deps */
  ), H = se(a, A), s = f(H, 3), o = s[0], M = s[1], P = s[2], Q = ie(o, a), U = ue(t, z, M, P, Q), c = f(U, 3), u = c[0], m = c[1], W = c[2], X = b(function(l) {
    if (G(l), S) {
      var p = D(l), F = p.map(function(ae) {
        return pe(ae, o, a).map(function(oe) {
          return oe.option;
        });
      }), ee = t ? p : p[0], te = t ? F : F[0];
      S(ee, te);
    }
  }), Y = ce(t, X, u, m, W, M, P, L), w = b(function(l) {
    Y(l);
  }), Z = r.useMemo(function() {
    return {
      options: o,
      fieldNames: a,
      values: u,
      halfValues: m,
      changeOnSelect: C,
      onSelect: w,
      checkable: i,
      searchOptions: [],
      dropdownPrefixCls: null,
      loadData: y,
      expandTrigger: x,
      expandIcon: _,
      loadingIcon: N,
      dropdownMenuColumnStyle: null
    };
  }, [o, a, u, m, C, w, i, y, x, _, N]), d = "".concat(v, "-panel"), E = !o.length;
  return /* @__PURE__ */ r.createElement(le.Provider, {
    value: Z
  }, /* @__PURE__ */ r.createElement("div", {
    className: re(d, (n = {}, T(n, "".concat(d, "-rtl"), O === "rtl"), T(n, "".concat(d, "-empty"), E), n), R),
    style: K
  }, E ? j : /* @__PURE__ */ r.createElement(me, {
    prefixCls: v,
    searchValue: null,
    multiple: t,
    toggleOpen: fe,
    open: !0,
    direction: O
  })));
}
export {
  we as default
};
