import { Composer as f } from "./accelbyte-widgets708.mjs";
import "./accelbyte-widgets649.mjs";
import "./accelbyte-widgets650.mjs";
import "./accelbyte-widgets651.mjs";
import "./accelbyte-widgets652.mjs";
import { warn as c } from "./accelbyte-widgets736.mjs";
import "./accelbyte-widgets653.mjs";
import "./accelbyte-widgets654.mjs";
import "./accelbyte-widgets648.mjs";
import { prettifyError as p, YAMLParseError as m } from "./accelbyte-widgets710.mjs";
import { LineCounter as a } from "./accelbyte-widgets734.mjs";
import { Parser as u } from "./accelbyte-widgets735.mjs";
function d(t) {
  const e = t.prettyErrors !== !1;
  return { lineCounter: t.lineCounter || e && new a() || null, prettyErrors: e };
}
function g(t, e = {}) {
  const { lineCounter: r, prettyErrors: s } = d(e), o = new u(r == null ? void 0 : r.addNewLine), i = new f(e);
  let n = null;
  for (const l of i.compose(o.parse(t), !0, t.length))
    if (!n)
      n = l;
    else if (n.options.logLevel !== "silent") {
      n.errors.push(new m(l.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
      break;
    }
  return s && r && (n.errors.forEach(p(t, r)), n.warnings.forEach(p(t, r))), n;
}
function S(t, e, r) {
  let s;
  typeof e == "function" ? s = e : r === void 0 && e && typeof e == "object" && (r = e);
  const o = g(t, r);
  if (!o)
    return null;
  if (o.warnings.forEach((i) => c(o.options.logLevel, i)), o.errors.length > 0) {
    if (o.options.logLevel !== "silent")
      throw o.errors[0];
    o.errors = [];
  }
  return o.toJS(Object.assign({ reviver: s }, r));
}
export {
  S as parse,
  g as parseDocument
};
