import { e as A, d as et, n as rt, b as nt, c as it, a as T, _ as $, h as at } from "./PlainValue-b8036b75.js";
import { P as ot, S as v, n as O, a as y, k as g, N as P, A as ft, d as B, g as st, Y as C, h as ut, i as d, j as Y, c as lt, s as ct } from "./resolveSeq-492ab440.js";
import { a as gt, b as J, o as L, p as q, s as U, i as R, f as H, t as V } from "./warnings-df54cb69.js";
function yt(e, t, r) {
  var n = new B(e);
  if (t instanceof Map) {
    var i = $(t), a;
    try {
      for (i.s(); !(a = i.n()).done; ) {
        var o = at(a.value, 2), s = o[0], u = o[1];
        n.items.push(e.createPair(s, u, r));
      }
    } catch (w) {
      i.e(w);
    } finally {
      i.f();
    }
  } else if (t && T(t) === "object")
    for (var f = 0, l = Object.keys(t); f < l.length; f++) {
      var c = l[f];
      n.items.push(e.createPair(c, t[c], r));
    }
  return typeof e.sortMapEntries == "function" && n.items.sort(e.sortMapEntries), n;
}
var b = {
  createNode: yt,
  default: !0,
  nodeClass: B,
  tag: "tag:yaml.org,2002:map",
  resolve: st
};
function vt(e, t, r) {
  var n = new C(e);
  if (t && t[Symbol.iterator]) {
    var i = $(t), a;
    try {
      for (i.s(); !(a = i.n()).done; ) {
        var o = a.value, s = e.createNode(o, r.wrapScalars, null, r);
        n.items.push(s);
      }
    } catch (u) {
      i.e(u);
    } finally {
      i.f();
    }
  }
  return n;
}
var I = {
  createNode: vt,
  default: !0,
  nodeClass: C,
  tag: "tag:yaml.org,2002:seq",
  resolve: ut
}, dt = {
  identify: function(t) {
    return typeof t == "string";
  },
  default: !0,
  tag: "tag:yaml.org,2002:str",
  resolve: Y,
  stringify: function(t, r, n, i) {
    return r = Object.assign({
      actualString: !0
    }, r), lt(t, r, n, i);
  },
  options: ct
}, F = [b, I, dt], h = function(t) {
  return typeof t == "bigint" || Number.isInteger(t);
}, j = function(t, r, n) {
  return d.asBigInt ? BigInt(t) : parseInt(r, n);
};
function X(e, t, r) {
  var n = e.value;
  return h(n) && n >= 0 ? r + n.toString(t) : g(e);
}
var D = {
  identify: function(t) {
    return t == null;
  },
  createNode: function(t, r, n) {
    return n.wrapScalars ? new v(null) : null;
  },
  default: !0,
  tag: "tag:yaml.org,2002:null",
  test: /^(?:~|[Nn]ull|NULL)?$/,
  resolve: function() {
    return null;
  },
  options: O,
  stringify: function() {
    return O.nullStr;
  }
}, G = {
  identify: function(t) {
    return typeof t == "boolean";
  },
  default: !0,
  tag: "tag:yaml.org,2002:bool",
  test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
  resolve: function(t) {
    return t[0] === "t" || t[0] === "T";
  },
  options: y,
  stringify: function(t) {
    var r = t.value;
    return r ? y.trueStr : y.falseStr;
  }
}, K = {
  identify: function(t) {
    return h(t) && t >= 0;
  },
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "OCT",
  test: /^0o([0-7]+)$/,
  resolve: function(t, r) {
    return j(t, r, 8);
  },
  options: d,
  stringify: function(t) {
    return X(t, 8, "0o");
  }
}, W = {
  identify: h,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  test: /^[-+]?[0-9]+$/,
  resolve: function(t) {
    return j(t, t, 10);
  },
  options: d,
  stringify: g
}, x = {
  identify: function(t) {
    return h(t) && t >= 0;
  },
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "HEX",
  test: /^0x([0-9a-fA-F]+)$/,
  resolve: function(t, r) {
    return j(t, r, 16);
  },
  options: d,
  stringify: function(t) {
    return X(t, 16, "0x");
  }
}, z = {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  test: /^(?:[-+]?\.inf|(\.nan))$/i,
  resolve: function(t, r) {
    return r ? NaN : t[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
  },
  stringify: g
}, Q = {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  format: "EXP",
  test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
  resolve: function(t) {
    return parseFloat(t);
  },
  stringify: function(t) {
    var r = t.value;
    return Number(r).toExponential();
  }
}, Z = {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
  resolve: function(t, r, n) {
    var i = r || n, a = new v(parseFloat(t));
    return i && i[i.length - 1] === "0" && (a.minFractionDigits = i.length), a;
  },
  stringify: g
}, pt = F.concat([D, G, K, W, x, z, Q, Z]), k = function(t) {
  return typeof t == "bigint" || Number.isInteger(t);
}, N = function(t) {
  var r = t.value;
  return JSON.stringify(r);
}, _ = [b, I, {
  identify: function(t) {
    return typeof t == "string";
  },
  default: !0,
  tag: "tag:yaml.org,2002:str",
  resolve: Y,
  stringify: N
}, {
  identify: function(t) {
    return t == null;
  },
  createNode: function(t, r, n) {
    return n.wrapScalars ? new v(null) : null;
  },
  default: !0,
  tag: "tag:yaml.org,2002:null",
  test: /^null$/,
  resolve: function() {
    return null;
  },
  stringify: N
}, {
  identify: function(t) {
    return typeof t == "boolean";
  },
  default: !0,
  tag: "tag:yaml.org,2002:bool",
  test: /^true|false$/,
  resolve: function(t) {
    return t === "true";
  },
  stringify: N
}, {
  identify: k,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  test: /^-?(?:0|[1-9][0-9]*)$/,
  resolve: function(t) {
    return d.asBigInt ? BigInt(t) : parseInt(t, 10);
  },
  stringify: function(t) {
    var r = t.value;
    return k(r) ? r.toString() : JSON.stringify(r);
  }
}, {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
  resolve: function(t) {
    return parseFloat(t);
  },
  stringify: N
}];
_.scalarFallback = function(e) {
  throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(e)));
};
var M = function(t) {
  var r = t.value;
  return r ? y.trueStr : y.falseStr;
}, m = function(t) {
  return typeof t == "bigint" || Number.isInteger(t);
};
function S(e, t, r) {
  var n = t.replace(/_/g, "");
  if (d.asBigInt) {
    switch (r) {
      case 2:
        n = "0b".concat(n);
        break;
      case 8:
        n = "0o".concat(n);
        break;
      case 16:
        n = "0x".concat(n);
        break;
    }
    var i = BigInt(n);
    return e === "-" ? BigInt(-1) * i : i;
  }
  var a = parseInt(n, r);
  return e === "-" ? -1 * a : a;
}
function E(e, t, r) {
  var n = e.value;
  if (m(n)) {
    var i = n.toString(t);
    return n < 0 ? "-" + r + i.substr(1) : r + i;
  }
  return g(e);
}
var mt = F.concat([{
  identify: function(t) {
    return t == null;
  },
  createNode: function(t, r, n) {
    return n.wrapScalars ? new v(null) : null;
  },
  default: !0,
  tag: "tag:yaml.org,2002:null",
  test: /^(?:~|[Nn]ull|NULL)?$/,
  resolve: function() {
    return null;
  },
  options: O,
  stringify: function() {
    return O.nullStr;
  }
}, {
  identify: function(t) {
    return typeof t == "boolean";
  },
  default: !0,
  tag: "tag:yaml.org,2002:bool",
  test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
  resolve: function() {
    return !0;
  },
  options: y,
  stringify: M
}, {
  identify: function(t) {
    return typeof t == "boolean";
  },
  default: !0,
  tag: "tag:yaml.org,2002:bool",
  test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
  resolve: function() {
    return !1;
  },
  options: y,
  stringify: M
}, {
  identify: m,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "BIN",
  test: /^([-+]?)0b([0-1_]+)$/,
  resolve: function(t, r, n) {
    return S(r, n, 2);
  },
  stringify: function(t) {
    return E(t, 2, "0b");
  }
}, {
  identify: m,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "OCT",
  test: /^([-+]?)0([0-7_]+)$/,
  resolve: function(t, r, n) {
    return S(r, n, 8);
  },
  stringify: function(t) {
    return E(t, 8, "0");
  }
}, {
  identify: m,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  test: /^([-+]?)([0-9][0-9_]*)$/,
  resolve: function(t, r, n) {
    return S(r, n, 10);
  },
  stringify: g
}, {
  identify: m,
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "HEX",
  test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
  resolve: function(t, r, n) {
    return S(r, n, 16);
  },
  stringify: function(t) {
    return E(t, 16, "0x");
  }
}, {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  test: /^(?:[-+]?\.inf|(\.nan))$/i,
  resolve: function(t, r) {
    return r ? NaN : t[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
  },
  stringify: g
}, {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  format: "EXP",
  test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
  resolve: function(t) {
    return parseFloat(t.replace(/_/g, ""));
  },
  stringify: function(t) {
    var r = t.value;
    return Number(r).toExponential();
  }
}, {
  identify: function(t) {
    return typeof t == "number";
  },
  default: !0,
  tag: "tag:yaml.org,2002:float",
  test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
  resolve: function(t, r) {
    var n = new v(parseFloat(t.replace(/_/g, "")));
    if (r) {
      var i = r.replace(/_/g, "");
      i[i.length - 1] === "0" && (n.minFractionDigits = i.length);
    }
    return n;
  },
  stringify: g
}], J, L, q, U, R, H, V), bt = {
  core: pt,
  failsafe: F,
  json: _,
  yaml11: mt
}, Nt = {
  binary: J,
  bool: G,
  float: Z,
  floatExp: Q,
  floatNaN: z,
  floatTime: H,
  int: W,
  intHex: x,
  intOct: K,
  intTime: R,
  map: b,
  null: D,
  omap: L,
  pairs: q,
  seq: I,
  set: U,
  timestamp: V
};
function St(e, t, r) {
  if (t) {
    var n = r.filter(function(a) {
      return a.tag === t;
    }), i = n.find(function(a) {
      return !a.format;
    }) || n[0];
    if (!i)
      throw new Error("Tag ".concat(t, " not found"));
    return i;
  }
  return r.find(function(a) {
    return (a.identify && a.identify(e) || a.class && e instanceof a.class) && !a.format;
  });
}
function Ot(e, t, r) {
  if (e instanceof P)
    return e;
  var n = r.defaultPrefix, i = r.onTagObj, a = r.prevObjects, o = r.schema, s = r.wrapScalars;
  t && t.startsWith("!!") && (t = n + t.slice(2));
  var u = St(e, t, o.tags);
  if (!u) {
    if (typeof e.toJSON == "function" && (e = e.toJSON()), !e || T(e) !== "object")
      return s ? new v(e) : e;
    u = e instanceof Map ? b : e[Symbol.iterator] ? I : b;
  }
  i && (i(u), delete r.onTagObj);
  var f = {
    value: void 0,
    node: void 0
  };
  if (e && T(e) === "object" && a) {
    var l = a.get(e);
    if (l) {
      var c = new ft(l);
      return r.aliasNodes.push(c), c;
    }
    f.value = e, a.set(e, f);
  }
  return f.node = u.createNode ? u.createNode(r.schema, e, r) : s ? new v(e) : e, t && f.node instanceof P && (f.node.tag = t), f.node;
}
function It(e, t, r, n) {
  var i = e[n.replace(/\W/g, "")];
  if (!i) {
    var a = Object.keys(e).map(function(p) {
      return JSON.stringify(p);
    }).join(", ");
    throw new Error('Unknown schema "'.concat(n, '"; use one of ').concat(a));
  }
  if (Array.isArray(r)) {
    var o = $(r), s;
    try {
      for (o.s(); !(s = o.n()).done; ) {
        var u = s.value;
        i = i.concat(u);
      }
    } catch (p) {
      o.e(p);
    } finally {
      o.f();
    }
  } else
    typeof r == "function" && (i = r(i.slice()));
  for (var f = 0; f < i.length; ++f) {
    var l = i[f];
    if (typeof l == "string") {
      var c = t[l];
      if (!c) {
        var w = Object.keys(t).map(function(p) {
          return JSON.stringify(p);
        }).join(", ");
        throw new Error('Unknown custom tag "'.concat(l, '"; use one of ').concat(w));
      }
      i[f] = c;
    }
  }
  return i;
}
var ht = function(t, r) {
  return t.key < r.key ? -1 : t.key > r.key ? 1 : 0;
}, tt = /* @__PURE__ */ function() {
  function e(t) {
    var r = t.customTags, n = t.merge, i = t.schema, a = t.sortMapEntries, o = t.tags;
    it(this, e), this.merge = !!n, this.name = i, this.sortMapEntries = a === !0 ? ht : a || null, !r && o && gt("tags", "customTags"), this.tags = It(bt, Nt, r || o, i);
  }
  return nt(e, [{
    key: "createNode",
    value: function(r, n, i, a) {
      var o = {
        defaultPrefix: e.defaultPrefix,
        schema: this,
        wrapScalars: n
      }, s = a ? Object.assign(a, o) : o;
      return Ot(r, i, s);
    }
  }, {
    key: "createPair",
    value: function(r, n, i) {
      i || (i = {
        wrapScalars: !0
      });
      var a = this.createNode(r, i.wrapScalars, null, i), o = this.createNode(n, i.wrapScalars, null, i);
      return new ot(a, o);
    }
  }]), e;
}();
A(tt, "defaultPrefix", et);
A(tt, "defaultTags", rt);
export {
  tt as S
};
//# sourceMappingURL=Schema-e94716c8.js.map
