import y from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import h from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import * as _ from "react";
import { toArray as C } from "../utils/commonUtil.mjs";
import { injectPropsWithOption as S } from "../utils/valueUtil.mjs";
function v(f, n) {
  return C(f).join("").toUpperCase().includes(n);
}
const z = function(f, n, t, e, c) {
  return _.useMemo(function() {
    if (!t || e === !1)
      return f;
    var o = n.options, s = n.label, j = n.value, i = [], d = typeof e == "function", p = t.toUpperCase(), a = d ? e : function(r, u) {
      return c ? v(u[c], p) : u[o] ? v(u[s !== "children" ? s : "label"], p) : v(u[j], p);
    }, l = d ? function(r) {
      return S(r);
    } : function(r) {
      return r;
    };
    return f.forEach(function(r) {
      if (r[o]) {
        var u = a(t, l(r));
        if (u)
          i.push(r);
        else {
          var b = r[o].filter(function(m) {
            return a(t, l(m));
          });
          b.length && i.push(h(h({}, r), {}, y({}, o, b)));
        }
        return;
      }
      a(t, l(r)) && i.push(r);
    }), i;
  }, [f, e, c, t, n]);
};
export {
  z as default
};
