import { __exports as i } from "../../../../../../../_virtual/resolve.js";
import { __require as k } from "./util.js";
import { __require as D } from "../../../../../fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js";
import { __require as K } from "../../../../../json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js";
var P;
function G() {
  if (P) return i;
  P = 1, Object.defineProperty(i, "__esModule", { value: !0 }), i.getSchemaRefs = i.resolveUrl = i.normalizeId = i._getFullPath = i.getFullPath = i.inlineRef = void 0;
  const b = k(), w = D(), z = K(), F = /* @__PURE__ */ new Set([
    "type",
    "format",
    "pattern",
    "maxLength",
    "minLength",
    "maxProperties",
    "minProperties",
    "maxItems",
    "minItems",
    "maximum",
    "minimum",
    "uniqueItems",
    "multipleOf",
    "required",
    "enum",
    "const"
  ]);
  function x(e, t = !0) {
    return typeof e == "boolean" ? !0 : t === !0 ? !c(e) : t ? h(e) <= t : !1;
  }
  i.inlineRef = x;
  const E = /* @__PURE__ */ new Set([
    "$ref",
    "$recursiveRef",
    "$recursiveAnchor",
    "$dynamicRef",
    "$dynamicAnchor"
  ]);
  function c(e) {
    for (const t in e) {
      if (E.has(t))
        return !0;
      const r = e[t];
      if (Array.isArray(r) && r.some(c) || typeof r == "object" && c(r))
        return !0;
    }
    return !1;
  }
  function h(e) {
    let t = 0;
    for (const r in e) {
      if (r === "$ref")
        return 1 / 0;
      if (t++, !F.has(r) && (typeof e[r] == "object" && (0, b.eachItem)(e[r], (u) => t += h(u)), t === 1 / 0))
        return 1 / 0;
    }
    return t;
  }
  function p(e, t = "", r) {
    r !== !1 && (t = s(t));
    const u = e.parse(t);
    return _(e, u);
  }
  i.getFullPath = p;
  function _(e, t) {
    return e.serialize(t).split("#")[0] + "#";
  }
  i._getFullPath = _;
  const L = /#\/?$/;
  function s(e) {
    return e ? e.replace(L, "") : "";
  }
  i.normalizeId = s;
  function O(e, t, r) {
    return r = s(r), e.resolve(t, r);
  }
  i.resolveUrl = O;
  const H = /^[a-z_][-a-z0-9._]*$/i;
  function N(e, t) {
    if (typeof e == "boolean")
      return {};
    const { schemaId: r, uriResolver: u } = this.opts, d = s(e[r] || t), R = { "": d }, U = p(u, d, !1), m = {}, y = /* @__PURE__ */ new Set();
    return z(e, { allKeys: !0 }, (o, f, g, q) => {
      if (q === void 0)
        return;
      const $ = U + f;
      let a = R[q];
      typeof o[r] == "string" && (a = S.call(this, o[r])), A.call(this, o.$anchor), A.call(this, o.$dynamicAnchor), R[f] = a;
      function S(n) {
        const j = this.opts.uriResolver.resolve;
        if (n = s(a ? j(a, n) : n), y.has(n))
          throw I(n);
        y.add(n);
        let l = this.refs[n];
        return typeof l == "string" && (l = this.refs[l]), typeof l == "object" ? v(o, l.schema, n) : n !== s($) && (n[0] === "#" ? (v(o, m[n], n), m[n] = o) : this.refs[n] = $), n;
      }
      function A(n) {
        if (typeof n == "string") {
          if (!H.test(n))
            throw new Error(`invalid anchor "${n}"`);
          S.call(this, `#${n}`);
        }
      }
    }), m;
    function v(o, f, g) {
      if (f !== void 0 && !w(o, f))
        throw I(g);
    }
    function I(o) {
      return new Error(`reference "${o}" resolves to more than one schema`);
    }
  }
  return i.getSchemaRefs = N, i;
}
export {
  G as __require
};
//# sourceMappingURL=resolve.js.map
