{"version":3,"file":"coerce.cjs","sources":["../../../../../../node_modules/semver/functions/coerce.js"],"sourcesContent":["const SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n  if (version instanceof SemVer) {\n    return version\n  }\n\n  if (typeof version === 'number') {\n    version = String(version)\n  }\n\n  if (typeof version !== 'string') {\n    return null\n  }\n\n  options = options || {}\n\n  let match = null\n  if (!options.rtl) {\n    match = version.match(re[t.COERCE])\n  } else {\n    // Find the right-most coercible string that does not share\n    // a terminus with a more left-ward coercible string.\n    // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n    //\n    // Walk through the string checking with a /g regexp\n    // Manually set the index so as to pick up overlapping matches.\n    // Stop when we get a match that ends at the string end, since no\n    // coercible string can be more right-ward without the same terminus.\n    let next\n    while ((next = re[t.COERCERTL].exec(version)) &&\n        (!match || match.index + match[0].length !== version.length)\n    ) {\n      if (!match ||\n            next.index + next[0].length !== match.index + match[0].length) {\n        match = next\n      }\n      re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length\n    }\n    // leave it in a clean state\n    re[t.COERCERTL].lastIndex = -1\n  }\n\n  if (match === null) {\n    return null\n  }\n\n  return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)\n}\nmodule.exports = coerce\n"],"names":["require$$0","require$$1","require$$2"],"mappings":";;;;;AAAA,MAAM,SAASA,OAAAA;AACf,MAAM,QAAQC,QAAAA;AACd,MAAM,EAAE,IAAI,MAAMC,KAAAA;AAElB,MAAM,SAAS,CAAC,SAAS,YAAY;AACnC,MAAI,mBAAmB,QAAQ;AAC7B,WAAO;AAAA,EACX;AAEE,MAAI,OAAO,YAAY,UAAU;AAC/B,cAAU,OAAO,OAAO;AAAA,EAC5B;AAEE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACX;AAEE,YAAU,WAAW,CAAA;AAErB,MAAI,QAAQ;AACZ,MAAI,CAAC,QAAQ,KAAK;AAChB,YAAQ,QAAQ,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EACtC,OAAS;AASL,QAAI;AACJ,YAAQ,OAAO,GAAG,EAAE,SAAS,EAAE,KAAK,OAAO,OACtC,CAAC,SAAS,MAAM,QAAQ,MAAM,CAAC,EAAE,WAAW,QAAQ,SACvD;AACA,UAAI,CAAC,SACC,KAAK,QAAQ,KAAK,CAAC,EAAE,WAAW,MAAM,QAAQ,MAAM,CAAC,EAAE,QAAQ;AACnE,gBAAQ;AAAA,MAChB;AACM,SAAG,EAAE,SAAS,EAAE,YAAY,KAAK,QAAQ,KAAK,CAAC,EAAE,SAAS,KAAK,CAAC,EAAE;AAAA,IACxE;AAEI,OAAG,EAAE,SAAS,EAAE,YAAY;AAAA,EAChC;AAEE,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACX;AAEE,SAAO,MAAM,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,OAAO;AAC3E;AACA,IAAA,WAAiB;;","x_google_ignoreList":[0]}