import * as b from "react";
import { convertChildrenToData as h } from "../utils/legacyUtil.mjs";
function p(n, f, r, g, O) {
  return b.useMemo(function() {
    var s = n, m = !n;
    m && (s = h(f));
    var c = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), u = function(v, a, e) {
      e && typeof e == "string" && v.set(a[e], a);
    };
    function i(l) {
      for (var v = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, a = 0; a < l.length; a += 1) {
        var e = l[a];
        !e[r.options] || v ? (c.set(e[r.value], e), u(t, e, r.label), u(t, e, g), u(t, e, O)) : i(e[r.options], !0);
      }
    }
    return i(s), {
      options: s,
      valueOptions: c,
      labelOptions: t
    };
  }, [n, f, r, g, O]);
}
export {
  p as default
};
