"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertDescriptorFromJsrToNpm = convertDescriptorFromJsrToNpm; exports.convertLocatorFromJsrToNpm = convertLocatorFromJsrToNpm; exports.convertLocatorFromNpmToJsr = convertLocatorFromNpmToJsr; const core_1 = require("@yarnpkg/core"); const core_2 = require("@yarnpkg/core"); function convertDescriptorFromJsrToNpm(dependency) { const rangeWithoutProtocol = dependency.range.slice(4); if (core_1.semverUtils.validRange(rangeWithoutProtocol)) return core_2.structUtils.makeDescriptor(dependency, `npm:${core_2.structUtils.stringifyIdent(core_2.structUtils.wrapIdentIntoScope(dependency, `jsr`))}@${rangeWithoutProtocol}`); const parsedRange = core_2.structUtils.tryParseDescriptor(rangeWithoutProtocol, true); if (parsedRange !== null) return core_2.structUtils.makeDescriptor(dependency, `npm:${core_2.structUtils.stringifyIdent(core_2.structUtils.wrapIdentIntoScope(parsedRange, `jsr`))}@${parsedRange.range}`); throw new Error(`Invalid range: ${dependency.range}`); } function convertLocatorFromJsrToNpm(locator) { return core_2.structUtils.makeLocator(core_2.structUtils.wrapIdentIntoScope(locator, `jsr`), `npm:${locator.reference.slice(4)}`); } function convertLocatorFromNpmToJsr(locator) { return core_2.structUtils.makeLocator(core_2.structUtils.unwrapIdentFromScope(locator, `jsr`), `jsr:${locator.reference.slice(4)}`); }