import e, { memo as g, isValidElement as p } from "react";
function y(n, t, a, o, l) {
  return p(n) ? n : n(t, a, o, l);
}
var h = g(function(n) {
  const { values: t, otherwise: a } = n;
  if (t?.length) {
    if ("layouts" in n) {
      const { type: l, layouts: r, silent: u } = n;
      return e.createElement(e.Fragment, null, t.map((c, i, s) => {
        const m = l(c, i, s), f = r[m];
        if (f) return y(f, c, i, s, m);
        if (!u) {
          const E = Array.isArray(r) ? `[ 0..${r.length - 1} ]` : Object.keys(r).join(", ");
          throw new TypeError(`Type "${m}" was not found in <Each layouts={{ ${E} }} />`);
        }
        return e.createElement(e.Fragment, null);
      }));
    }
    const { layout: o } = n;
    return e.createElement(e.Fragment, null, t.map((l, r, u) => y(o, l, r, u)));
  }
  return a ? e.createElement(e.Fragment, null, a) : e.createElement(e.Fragment, null);
});
export {
  h as l
};
