import G from "../../../@babel/runtime/helpers/esm/typeof.mjs";
import y from "../../../rc-util/es/Children/toArray.mjs";
import { warningOnce as n, noteOnce as g } from "../../../rc-util/es/warning.mjs";
import * as w from "react";
import { isMultiple as z } from "../BaseSelect.mjs";
import { toArray as L } from "./commonUtil.mjs";
import { convertChildrenToData as R } from "./legacyUtil.mjs";
function q(o) {
  var e = o.mode, f = o.options, l = o.children, c = o.backfill, m = o.allowClear, u = o.placeholder, r = o.getInputElement, h = o.showSearch, O = o.onSearch, S = o.defaultOpen, x = o.autoFocus, k = o.labelInValue, s = o.value, V = o.inputValue, A = o.optionLabelProp, p = z(e), I = h !== void 0 ? h : p || e === "combobox", v = f || R(l);
  if (n(e !== "tags" || v.every(function(t) {
    return !t.disabled;
  }), "Please avoid setting option to disabled in tags mode since user can always type text as tag."), e === "tags" || e === "combobox") {
    var E = v.some(function(t) {
      return t.options ? t.options.some(function(i) {
        return typeof ("value" in i ? i.value : i.key) == "number";
      }) : typeof ("value" in t ? t.value : t.key) == "number";
    });
    n(!E, "`value` of Option should not use number type when `mode` is `tags` or `combobox`.");
  }
  if (n(e !== "combobox" || !A, "`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."), n(e === "combobox" || !c, "`backfill` only works with `combobox` mode."), n(e === "combobox" || !r, "`getInputElement` only work with `combobox` mode."), g(e !== "combobox" || !r || !m || !u, "Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."), O && !I && e !== "combobox" && e !== "tags" && n(!1, "`onSearch` should work with `showSearch` instead of use alone."), g(!S || x, "`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."), s != null) {
    var P = L(s);
    n(!k || P.every(function(t) {
      return G(t) === "object" && ("key" in t || "value" in t);
    }), "`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"), n(!p || Array.isArray(s), "`value` should be array when `mode` is `multiple` or `tags`");
  }
  if (l) {
    var a = null;
    y(l).some(function(t) {
      if (!/* @__PURE__ */ w.isValidElement(t) || !t.type)
        return !1;
      var i = t, b = i.type;
      if (b.isSelectOption)
        return !1;
      if (b.isSelectOptGroup) {
        var F = y(t.props.children).every(function(d) {
          return !/* @__PURE__ */ w.isValidElement(d) || !t.type || d.type.isSelectOption ? !0 : (a = d.type, !1);
        });
        return !F;
      }
      return a = b, !0;
    }), a && n(!1, "`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(a.displayName || a.name || a, "`.")), n(V === void 0, "`inputValue` is deprecated, please use `searchValue` instead.");
  }
}
function B(o, e) {
  if (o) {
    var f = function l(c) {
      for (var m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, u = 0; u < c.length; u++) {
        var r = c[u];
        if (r[e == null ? void 0 : e.value] === null)
          return n(!1, "`value` in Select options should not be `null`."), !0;
        if (!m && Array.isArray(r[e == null ? void 0 : e.options]) && l(r[e == null ? void 0 : e.options], !0))
          break;
      }
    };
    f(o);
  }
}
export {
  q as default,
  B as warningNullOptions
};
