{
  "version": 3,
  "sources": ["../../src/helpers/convert-to-local-ref.ts"],
  "sourcesContent": ["/**\n * Translates a JSON Reference ($ref) to a local object path within the root schema.\n *\n * @param ref - The JSON Reference string (e.g., \"#/foo/bar\", \"other.json#/baz\", \"other.json#anchor\")\n * @param currentContext - The current base context (usually the $id of the current schema or parent)\n * @param schemas - A map of schema identifiers ($id, $anchor) to their local object paths\n * @returns The local object path as a string, or undefined if the reference cannot be resolved\n */\nexport const convertToLocalRef = (\n  ref: string,\n  currentContext: string,\n  schemas: Map<string, string>,\n): string | undefined => {\n  // Split the reference into base URL and path/anchor (e.g., \"foo.json#/bar\" => [\"foo.json\", \"/bar\"])\n  const [baseUrl, pathOrAnchor] = ref.split('#', 2)\n\n  if (baseUrl) {\n    if (!schemas.has(baseUrl)) {\n      return undefined\n    }\n\n    if (!pathOrAnchor) {\n      return schemas.get(baseUrl)\n    }\n\n    // If the pathOrAnchor is a JSON pointer, we need to append it to the baseUrl\n    if (pathOrAnchor.startsWith('/')) {\n      return `${schemas.get(baseUrl)}${pathOrAnchor}`\n    }\n\n    // If the pathOrAnchor is an anchor, we need to return the anchor\n    return schemas.get(`${baseUrl}#${pathOrAnchor}`)\n  }\n\n  if (pathOrAnchor) {\n    if (pathOrAnchor.startsWith('/')) {\n      return pathOrAnchor.slice(1)\n    }\n    return schemas.get(`${currentContext}#${pathOrAnchor}`)\n  }\n\n  return undefined\n}\n"],
  "mappings": "AAQO,MAAM,oBAAoB,CAC/B,KACA,gBACA,YACuB;AAEvB,QAAM,CAAC,SAAS,YAAY,IAAI,IAAI,MAAM,KAAK,CAAC;AAEhD,MAAI,SAAS;AACX,QAAI,CAAC,QAAQ,IAAI,OAAO,GAAG;AACzB,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,cAAc;AACjB,aAAO,QAAQ,IAAI,OAAO;AAAA,IAC5B;AAGA,QAAI,aAAa,WAAW,GAAG,GAAG;AAChC,aAAO,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,YAAY;AAAA,IAC/C;AAGA,WAAO,QAAQ,IAAI,GAAG,OAAO,IAAI,YAAY,EAAE;AAAA,EACjD;AAEA,MAAI,cAAc;AAChB,QAAI,aAAa,WAAW,GAAG,GAAG;AAChC,aAAO,aAAa,MAAM,CAAC;AAAA,IAC7B;AACA,WAAO,QAAQ,IAAI,GAAG,cAAc,IAAI,YAAY,EAAE;AAAA,EACxD;AAEA,SAAO;AACT;",
  "names": []
}
