import g from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import h from "../../../@babel/runtime/helpers/esm/toArray.mjs";
import y from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import { warningOnce as O } from "../../../rc-util/es/warning.mjs";
function m(r, e) {
  var n = r.key, t;
  return "value" in r && (t = r.value), n ?? (t !== void 0 ? t : "rc-index-key-".concat(e));
}
function _(r, e) {
  var n = r || {}, t = n.label, i = n.value, o = n.options, a = n.groupLabel, u = t || (e ? "children" : "label");
  return {
    label: u,
    value: i || "value",
    options: o || "options",
    groupLabel: a || u
  };
}
function j(r) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = e.fieldNames, t = e.childrenAsData, i = [], o = _(n, !1), a = o.label, u = o.value, f = o.options, v = o.groupLabel;
  function s(p, c) {
    p.forEach(function(l) {
      if (c || !(f in l)) {
        var b = l[u];
        i.push({
          key: m(l, i.length),
          groupOption: c,
          data: l,
          label: l[a],
          value: b
        });
      } else {
        var d = l[v];
        d === void 0 && t && (d = l.label), i.push({
          key: m(l, i.length),
          group: !0,
          data: l,
          label: d
        }), s(l[f], !0);
      }
    });
  }
  return s(r, !1), i;
}
function P(r) {
  var e = y({}, r);
  return "props" in e || Object.defineProperty(e, "props", {
    get: function() {
      return O(!1, "Return type is option instead of Option instance. Please read value directly instead of reading from `props`."), e;
    }
  }), e;
}
function w(r, e) {
  if (!e || !e.length)
    return null;
  var n = !1;
  function t(o, a) {
    var u = h(a), f = u[0], v = u.slice(1);
    if (!f)
      return [o];
    var s = o.split(f);
    return n = n || s.length > 1, s.reduce(function(p, c) {
      return [].concat(g(p), g(t(c, v)));
    }, []).filter(function(p) {
      return p;
    });
  }
  var i = t(r, e);
  return n ? i : null;
}
export {
  _ as fillFieldNames,
  j as flattenOptions,
  w as getSeparatedContent,
  P as injectPropsWithOption
};
