/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
function a(t) {
  if (!("enum" in t)) return t.anyOf ?? t.oneOf;
  let { enum: r, enumNames: e, "ui:icons": i } = t;
  return r.map((n, f) => ({ const: n, title: e ? e[f] : n, "ui:icon": i ? i[f] : void 0 }));
}
function l(t, r) {
  if (t.type === "object" && "properties" in t) {
    let e = t, i = {};
    for (let [n, f] of Object.entries(e.properties)) {
      let o = s(f, r);
      o !== void 0 && (i[n] = o);
    }
    return i;
  }
  if (t.type === "array" && "items" in t) {
    let e = t;
    return r && typeof e[`default:${r}`] < "u" ? e[`default:${r}`] : e.default ? e.default : [];
  }
  throw new Error("Schema must be either TObject or TArray");
}
function s(t, r) {
  if (r && typeof t[`default:${r}`] < "u") return t[`default:${r}`];
  if ("default" in t && t.default !== void 0) return t.default;
  if (t.type === "object" && "properties" in t) {
    let e = t, i = {};
    for (let [n, f] of Object.entries(e.properties)) {
      let o = s(f, r);
      o !== void 0 && (i[n] = o);
    }
    return Object.keys(i).length > 0 ? i : void 0;
  }
  t.type === "array" && "items" in t;
}
function p(t, r) {
  function e(i) {
    let n = {};
    for (let [f, o] of Object.entries(i.properties)) if (r(o)) n[f] = o;
    else if (o.type === "object" && o.properties) {
      let u = e(o);
      Object.keys(u).length > 0 && Object.assign(n, u);
    }
    return n;
  }
  return e(t);
}
export {
  a,
  l as b,
  p as c
};
//# sourceMappingURL=chunk-I46VBMLF.js.map
