{"version":3,"sources":["jsdelivr-header.js","/npm/git-a-repo@0.0.0-development/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,IAAI,YAAc,QAAQ,YACtB,SAAW,QAAQ,aACnB,GAAK,QAAQ,UAAU,KAiB3B,SAAS,SAAS,EAAM,EAAM,EAAM,GACd,mBAAT,IACT,EAAK,EACL,EAAO,MAGT,IAAI,GADJ,EAAO,GAAQ,CAAC,GACC,QAAS,SACnB,EAAK,MAGZ,IAAI,GADJ,EAAO,UAAU,IACF,KAAO,OAAO,EAAM,GAEnC,GAAI,EAAO,CACT,IAAI,EAAe,CACjB,SAAU,EAAK,SACf,QAA2B,SAAlB,EAAK,YACX,GAEL,SAAS,EAAK,EAAM,GAAc,SAAU,QAC9B,IAAR,GACF,GAAG,EAAO,SACV,KAEA,EAAG,EAEP,GACF,KAAO,CACL,IAAI,EAAkB,CACpB,SAAS,EACT,MAAO,EACP,KAAM,SACH,EACH,QAAS,CACP,OAAQ,qBACJ,EAAK,SAAW,CAAC,IAGzB,YAAY,EAAK,EAAM,GACpB,MAAK,SAAU,GACd,GACF,IACC,OAAM,SAAU,GACf,EAAG,EACL,GACJ,CACF,CASA,SAAS,UAAU,GACjB,IAAI,EAAQ,mCACR,EAAQ,EAAM,KAAK,GAEvB,GAAI,EAIF,MAAO,CACL,KAAM,SACN,IALQ,EAAM,GAMd,SALmB,EAAM,IAAM,QAWjC,IAAI,GADJ,GAFA,EACE,yEACY,KAAK,IACF,IAAM,SACnB,EAAS,EAAM,IAAM,KAezB,OAVc,MAAV,IACW,WAAT,EACF,EAAS,aACS,WAAT,EACT,EAAS,aACS,cAAT,IACT,EAAS,kBAIN,CACL,KAAM,EACN,OAAQ,EACR,MAjBU,EAAM,GAkBhB,KAjBS,EAAM,GAkBf,SAjBa,EAAM,IAAM,OAoB/B,CASA,SAAS,YAAY,EAAQ,GAS3B,MARK,oBAAoB,KAAK,KAE1B,EADE,EACO,OAAS,EAET,WAAa,GAInB,CACT,CASA,SAAS,OAAO,EAAM,GACpB,IAAI,EAGA,EAAS,YAAY,EAAK,OAAQ,GA6CtC,MA5CI,SAAS,KAAK,GAChB,GAAkB,IAElB,GAAkB,IAIhB,EACF,EAAM,EAAS,EAAK,MAAQ,IAAM,EAAK,KAAO,OAE5B,WAAd,EAAK,KACP,EACE,EACA,EAAK,MACL,IACA,EAAK,KACL,YACA,EAAK,SACL,OACqB,WAAd,EAAK,KACd,EACE,EACA,EAAK,MACL,IACA,EAAK,KACL,cACA,EAAK,SACL,IACA,EAAK,KACL,IACA,EAAK,SAAS,QAAQ,MAAO,KAC7B,OACqB,cAAd,EAAK,OACd,EACE,EACA,EAAK,MACL,IACA,EAAK,KACL,QACA,EAAK,SACL,QAIC,CACT,CAxLA,OAAO,QAAU","file":"/npm/git-a-repo@0.0.0-development/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/git-a-repo@0.0.0-development/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var downloadUrl = require(\"download\");\nvar gitclone = require(\"git-clone\");\nvar rm = require(\"rimraf\").sync;\n\n/**\n * Expose `download`.\n */\n\nmodule.exports = download;\n\n/**\n * Download `repo` to `dest` and callback `fn(err)`.\n *\n * @param {String} repo\n * @param {String} dest\n * @param {Object} opts\n * @param {Function} fn\n */\n\nfunction download(repo, dest, opts, fn) {\n  if (typeof opts === \"function\") {\n    fn = opts;\n    opts = null;\n  }\n  opts = opts || {};\n  var clone = opts.clone || false;\n  delete opts.clone;\n\n  repo = normalize(repo);\n  var url = repo.url || getUrl(repo, clone);\n\n  if (clone) {\n    var cloneOptions = {\n      checkout: repo.checkout,\n      shallow: repo.checkout === \"main\",\n      ...opts,\n    };\n    gitclone(url, dest, cloneOptions, function (err) {\n      if (err === undefined) {\n        rm(dest + \"/.git\");\n        fn();\n      } else {\n        fn(err);\n      }\n    });\n  } else {\n    var downloadOptions = {\n      extract: true,\n      strip: 1,\n      mode: \"666\",\n      ...opts,\n      headers: {\n        accept: \"application/zip\",\n        ...(opts.headers || {}),\n      },\n    };\n    downloadUrl(url, dest, downloadOptions)\n      .then(function (data) {\n        fn();\n      })\n      .catch(function (err) {\n        fn(err);\n      });\n  }\n}\n\n/**\n * Normalize a repo string.\n *\n * @param {String} repo\n * @return {Object}\n */\n\nfunction normalize(repo) {\n  var regex = /^(?:(direct):([^#]+)(?:#(.+))?)$/;\n  var match = regex.exec(repo);\n\n  if (match) {\n    var url = match[2];\n    var directCheckout = match[3] || \"main\";\n\n    return {\n      type: \"direct\",\n      url: url,\n      checkout: directCheckout,\n    };\n  } else {\n    regex =\n      /^(?:(github|gitlab|bitbucket):)?(?:(.+):)?([^/]+)\\/([^#]+)(?:#(.+))?$/;\n    match = regex.exec(repo);\n    var type = match[1] || \"github\";\n    var origin = match[2] || null;\n    var owner = match[3];\n    var name = match[4];\n    var checkout = match[5] || \"main\";\n\n    if (origin == null) {\n      if (type === \"github\") {\n        origin = \"github.com\";\n      } else if (type === \"gitlab\") {\n        origin = \"gitlab.com\";\n      } else if (type === \"bitbucket\") {\n        origin = \"bitbucket.org\";\n      }\n    }\n\n    return {\n      type: type,\n      origin: origin,\n      owner: owner,\n      name: name,\n      checkout: checkout,\n    };\n  }\n}\n\n/**\n * Adds protocol to url in none specified\n *\n * @param {String} url\n * @return {String}\n */\n\nfunction addProtocol(origin, clone) {\n  if (!/^(f|ht)tps?:\\/\\//i.test(origin)) {\n    if (clone) {\n      origin = \"git@\" + origin;\n    } else {\n      origin = \"https://\" + origin;\n    }\n  }\n\n  return origin;\n}\n\n/**\n * Return a zip or git url for a given `repo`.\n *\n * @param {Object} repo\n * @return {String}\n */\n\nfunction getUrl(repo, clone) {\n  var url;\n\n  // Get origin with protocol and add trailing slash or colon (for ssh)\n  var origin = addProtocol(repo.origin, clone);\n  if (/^git@/i.test(origin)) {\n    origin = origin + \":\";\n  } else {\n    origin = origin + \"/\";\n  }\n\n  // Build url\n  if (clone) {\n    url = origin + repo.owner + \"/\" + repo.name + \".git\";\n  } else {\n    if (repo.type === \"github\") {\n      url =\n        origin +\n        repo.owner +\n        \"/\" +\n        repo.name +\n        \"/archive/\" +\n        repo.checkout +\n        \".zip\";\n    } else if (repo.type === \"gitlab\") {\n      url =\n        origin +\n        repo.owner +\n        \"/\" +\n        repo.name +\n        \"/-/archive/\" +\n        repo.checkout +\n        \"/\" +\n        repo.name +\n        \"-\" +\n        repo.checkout.replace(/\\//g, \"-\") +\n        \".zip\";\n    } else if (repo.type === \"bitbucket\") {\n      url =\n        origin +\n        repo.owner +\n        \"/\" +\n        repo.name +\n        \"/get/\" +\n        repo.checkout +\n        \".zip\";\n    }\n  }\n\n  return url;\n}\n"]}