var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));

// ../../node_modules/protocols/lib/index.js
var require_lib = __commonJS({
  "../../node_modules/protocols/lib/index.js"(exports, module) {
    "use strict";
    module.exports = function protocols(input, first) {
      if (first === true) {
        first = 0;
      }
      var prots = "";
      if (typeof input === "string") {
        try {
          prots = new URL(input).protocol;
        } catch (e) {
        }
      } else if (input && input.constructor === URL) {
        prots = input.protocol;
      }
      var splits = prots.split(/\:|\+/).filter(Boolean);
      if (typeof first === "number") {
        return splits[first];
      }
      return splits;
    };
  }
});

// ../../node_modules/parse-path/lib/index.js
var require_lib2 = __commonJS({
  "../../node_modules/parse-path/lib/index.js"(exports, module) {
    "use strict";
    var protocols = require_lib();
    function parsePath(url) {
      var output = {
        protocols: [],
        protocol: null,
        port: null,
        resource: "",
        host: "",
        user: "",
        password: "",
        pathname: "",
        hash: "",
        search: "",
        href: url,
        query: {},
        parse_failed: false
      };
      try {
        var parsed = new URL(url);
        output.protocols = protocols(parsed);
        output.protocol = output.protocols[0];
        output.port = parsed.port;
        output.resource = parsed.hostname;
        output.host = parsed.host;
        output.user = parsed.username || "";
        output.password = parsed.password || "";
        output.pathname = parsed.pathname;
        output.hash = parsed.hash.slice(1);
        output.search = parsed.search.slice(1);
        output.href = parsed.href;
        output.query = Object.fromEntries(parsed.searchParams);
      } catch (e) {
        output.protocols = ["file"];
        output.protocol = output.protocols[0];
        output.port = "";
        output.resource = "";
        output.user = "";
        output.pathname = "";
        output.hash = "";
        output.search = "";
        output.href = url;
        output.query = {};
        output.parse_failed = true;
      }
      return output;
    }
    module.exports = parsePath;
  }
});

// ../../node_modules/parse-url/dist/index.js
var require_dist = __commonJS({
  "../../node_modules/parse-url/dist/index.js"(exports, module) {
    "use strict";
    var require$$1 = require_lib2();
    function _interopDefaultLegacy(e) {
      return e && typeof e === "object" && "default" in e ? e : { "default": e };
    }
    var require$$1__default = /* @__PURE__ */ _interopDefaultLegacy(require$$1);
    function getAugmentedNamespace(n) {
      if (n.__esModule) return n;
      var f = n.default;
      if (typeof f == "function") {
        var a = function a2() {
          if (this instanceof a2) {
            var args = [null];
            args.push.apply(args, arguments);
            var Ctor = Function.bind.apply(f, args);
            return new Ctor();
          }
          return f.apply(this, arguments);
        };
        a.prototype = f.prototype;
      } else a = {};
      Object.defineProperty(a, "__esModule", { value: true });
      Object.keys(n).forEach(function(k) {
        var d = Object.getOwnPropertyDescriptor(n, k);
        Object.defineProperty(a, k, d.get ? d : {
          enumerable: true,
          get: function() {
            return n[k];
          }
        });
      });
      return a;
    }
    var src = {};
    var DATA_URL_DEFAULT_MIME_TYPE = "text/plain";
    var DATA_URL_DEFAULT_CHARSET = "us-ascii";
    var testParameter = (name, filters) => filters.some((filter) => filter instanceof RegExp ? filter.test(name) : filter === name);
    var normalizeDataURL = (urlString, { stripHash }) => {
      const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
      if (!match) {
        throw new Error(`Invalid URL: ${urlString}`);
      }
      let { type, data, hash } = match.groups;
      const mediaType = type.split(";");
      hash = stripHash ? "" : hash;
      let isBase64 = false;
      if (mediaType[mediaType.length - 1] === "base64") {
        mediaType.pop();
        isBase64 = true;
      }
      const mimeType = (mediaType.shift() || "").toLowerCase();
      const attributes = mediaType.map((attribute) => {
        let [key, value = ""] = attribute.split("=").map((string) => string.trim());
        if (key === "charset") {
          value = value.toLowerCase();
          if (value === DATA_URL_DEFAULT_CHARSET) {
            return "";
          }
        }
        return `${key}${value ? `=${value}` : ""}`;
      }).filter(Boolean);
      const normalizedMediaType = [
        ...attributes
      ];
      if (isBase64) {
        normalizedMediaType.push("base64");
      }
      if (normalizedMediaType.length > 0 || mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE) {
        normalizedMediaType.unshift(mimeType);
      }
      return `data:${normalizedMediaType.join(";")},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ""}`;
    };
    function normalizeUrl(urlString, options) {
      options = {
        defaultProtocol: "http:",
        normalizeProtocol: true,
        forceHttp: false,
        forceHttps: false,
        stripAuthentication: true,
        stripHash: false,
        stripTextFragment: true,
        stripWWW: true,
        removeQueryParameters: [/^utm_\w+/i],
        removeTrailingSlash: true,
        removeSingleSlash: true,
        removeDirectoryIndex: false,
        sortQueryParameters: true,
        ...options
      };
      urlString = urlString.trim();
      if (/^data:/i.test(urlString)) {
        return normalizeDataURL(urlString, options);
      }
      if (/^view-source:/i.test(urlString)) {
        throw new Error("`view-source:` is not supported as it is a non-standard protocol");
      }
      const hasRelativeProtocol = urlString.startsWith("//");
      const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);
      if (!isRelativeUrl) {
        urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);
      }
      const urlObject = new URL(urlString);
      if (options.forceHttp && options.forceHttps) {
        throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");
      }
      if (options.forceHttp && urlObject.protocol === "https:") {
        urlObject.protocol = "http:";
      }
      if (options.forceHttps && urlObject.protocol === "http:") {
        urlObject.protocol = "https:";
      }
      if (options.stripAuthentication) {
        urlObject.username = "";
        urlObject.password = "";
      }
      if (options.stripHash) {
        urlObject.hash = "";
      } else if (options.stripTextFragment) {
        urlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, "");
      }
      if (urlObject.pathname) {
        const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g;
        let lastIndex = 0;
        let result = "";
        for (; ; ) {
          const match = protocolRegex.exec(urlObject.pathname);
          if (!match) {
            break;
          }
          const protocol = match[0];
          const protocolAtIndex = match.index;
          const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);
          result += intermediate.replace(/\/{2,}/g, "/");
          result += protocol;
          lastIndex = protocolAtIndex + protocol.length;
        }
        const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);
        result += remnant.replace(/\/{2,}/g, "/");
        urlObject.pathname = result;
      }
      if (urlObject.pathname) {
        try {
          urlObject.pathname = decodeURI(urlObject.pathname);
        } catch {
        }
      }
      if (options.removeDirectoryIndex === true) {
        options.removeDirectoryIndex = [/^index\.[a-z]+$/];
      }
      if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
        let pathComponents = urlObject.pathname.split("/");
        const lastComponent = pathComponents[pathComponents.length - 1];
        if (testParameter(lastComponent, options.removeDirectoryIndex)) {
          pathComponents = pathComponents.slice(0, -1);
          urlObject.pathname = pathComponents.slice(1).join("/") + "/";
        }
      }
      if (urlObject.hostname) {
        urlObject.hostname = urlObject.hostname.replace(/\.$/, "");
        if (options.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(urlObject.hostname)) {
          urlObject.hostname = urlObject.hostname.replace(/^www\./, "");
        }
      }
      if (Array.isArray(options.removeQueryParameters)) {
        for (const key of [...urlObject.searchParams.keys()]) {
          if (testParameter(key, options.removeQueryParameters)) {
            urlObject.searchParams.delete(key);
          }
        }
      }
      if (options.removeQueryParameters === true) {
        urlObject.search = "";
      }
      if (options.sortQueryParameters) {
        urlObject.searchParams.sort();
        try {
          urlObject.search = decodeURIComponent(urlObject.search);
        } catch {
        }
      }
      if (options.removeTrailingSlash) {
        urlObject.pathname = urlObject.pathname.replace(/\/$/, "");
      }
      const oldUrlString = urlString;
      urlString = urlObject.toString();
      if (!options.removeSingleSlash && urlObject.pathname === "/" && !oldUrlString.endsWith("/") && urlObject.hash === "") {
        urlString = urlString.replace(/\/$/, "");
      }
      if ((options.removeTrailingSlash || urlObject.pathname === "/") && urlObject.hash === "" && options.removeSingleSlash) {
        urlString = urlString.replace(/\/$/, "");
      }
      if (hasRelativeProtocol && !options.normalizeProtocol) {
        urlString = urlString.replace(/^http:\/\//, "//");
      }
      if (options.stripProtocol) {
        urlString = urlString.replace(/^(?:https?:)?\/\//, "");
      }
      return urlString;
    }
    var normalizeUrl$1 = /* @__PURE__ */ Object.freeze({
      __proto__: null,
      "default": normalizeUrl
    });
    var require$$0 = /* @__PURE__ */ getAugmentedNamespace(normalizeUrl$1);
    Object.defineProperty(src, "__esModule", {
      value: true
    });
    var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
      return typeof obj;
    } : function(obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
    var _normalizeUrl = require$$0;
    var _normalizeUrl2 = _interopRequireDefault(_normalizeUrl);
    var _parsePath = require$$1__default["default"];
    var _parsePath2 = _interopRequireDefault(_parsePath);
    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }
    var parseUrl = function parseUrl2(url) {
      var normalize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
      var GIT_RE = /^(?:([a-zA-Z_][a-zA-Z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:](([\~,\.\w,\-,\_,\/,\s]|%[0-9A-Fa-f]{2})+?(?:\.git|\/)?)$/;
      var throwErr = function throwErr2(msg) {
        var err = new Error(msg);
        err.subject_url = url;
        throw err;
      };
      if (typeof url !== "string" || !url.trim()) {
        throwErr("Invalid url.");
      }
      if (url.length > parseUrl2.MAX_INPUT_LENGTH) {
        throwErr("Input exceeds maximum length. If needed, change the value of parseUrl.MAX_INPUT_LENGTH.");
      }
      if (normalize) {
        if ((typeof normalize === "undefined" ? "undefined" : _typeof(normalize)) !== "object") {
          normalize = {
            stripHash: false
          };
        }
        url = (0, _normalizeUrl2.default)(url, normalize);
      }
      var parsed = (0, _parsePath2.default)(url);
      if (parsed.parse_failed) {
        var matched = parsed.href.match(GIT_RE);
        if (matched) {
          parsed.protocols = ["ssh"];
          parsed.protocol = "ssh";
          parsed.resource = matched[2];
          parsed.host = matched[2];
          parsed.user = matched[1];
          parsed.pathname = "/" + matched[3];
          parsed.parse_failed = false;
        } else {
          throwErr("URL parsing failed.");
        }
      }
      return parsed;
    };
    parseUrl.MAX_INPUT_LENGTH = 2048;
    var _default = src.default = parseUrl;
    module.exports = _default;
  }
});

// ../../node_modules/is-ssh/lib/index.js
var require_lib3 = __commonJS({
  "../../node_modules/is-ssh/lib/index.js"(exports, module) {
    "use strict";
    var protocols = require_lib();
    function isSsh(input) {
      if (Array.isArray(input)) {
        return input.indexOf("ssh") !== -1 || input.indexOf("rsync") !== -1;
      }
      if (typeof input !== "string") {
        return false;
      }
      var prots = protocols(input);
      input = input.substring(input.indexOf("://") + 3);
      if (isSsh(prots)) {
        return true;
      }
      var urlPortPattern = new RegExp(".([a-zA-Z\\d]+):(\\d+)/");
      return !input.match(urlPortPattern) && input.indexOf("@") < input.indexOf(":");
    }
    module.exports = isSsh;
  }
});

// ../../node_modules/git-up/lib/index.js
var require_lib4 = __commonJS({
  "../../node_modules/git-up/lib/index.js"(exports, module) {
    "use strict";
    var parseUrl = require_dist();
    var isSsh = require_lib3();
    function gitUp(input) {
      let output = parseUrl(input);
      output.token = "";
      if (output.password === "x-oauth-basic") {
        output.token = output.user;
      } else if (output.user === "x-token-auth") {
        output.token = output.password;
      }
      if (isSsh(output.protocols) || output.protocols.length === 0 && isSsh(input)) {
        output.protocol = "ssh";
      } else if (output.protocols.length) {
        output.protocol = output.protocols[0];
      } else {
        output.protocol = "file";
        output.protocols = ["file"];
      }
      output.href = output.href.replace(/\/$/, "");
      return output;
    }
    module.exports = gitUp;
  }
});

// ../../node_modules/git-url-parse/lib/index.js
var require_lib5 = __commonJS({
  "../../node_modules/git-url-parse/lib/index.js"(exports, module) {
    "use strict";
    var gitUp = require_lib4();
    function gitUrlParse2(url, refs) {
      refs = refs || [];
      if (typeof url !== "string") {
        throw new Error("The url must be a string.");
      }
      if (!refs.every(function(item) {
        return typeof item === "string";
      })) {
        throw new Error("The refs should contain only strings");
      }
      var shorthandRe = /^([a-z\d-]{1,39})\/([-\.\w]{1,100})$/i;
      if (shorthandRe.test(url)) {
        url = "https://github.com/" + url;
      }
      var urlInfo = gitUp(url), sourceParts = urlInfo.resource.split("."), splits = null;
      urlInfo.toString = function(type) {
        return gitUrlParse2.stringify(this, type);
      };
      urlInfo.source = sourceParts.length > 2 ? sourceParts.slice(1 - sourceParts.length).join(".") : urlInfo.source = urlInfo.resource;
      urlInfo.git_suffix = /\.git$/.test(urlInfo.pathname);
      urlInfo.name = decodeURIComponent((urlInfo.pathname || urlInfo.href).replace(/(^\/)|(\/$)/g, "").replace(/\.git$/, ""));
      urlInfo.owner = decodeURIComponent(urlInfo.user);
      switch (urlInfo.source) {
        case "git.cloudforge.com":
          urlInfo.owner = urlInfo.user;
          urlInfo.organization = sourceParts[0];
          urlInfo.source = "cloudforge.com";
          break;
        case "visualstudio.com":
          if (urlInfo.resource === "vs-ssh.visualstudio.com") {
            splits = urlInfo.name.split("/");
            if (splits.length === 4) {
              urlInfo.organization = splits[1];
              urlInfo.owner = splits[2];
              urlInfo.name = splits[3];
              urlInfo.full_name = splits[2] + "/" + splits[3];
            }
            break;
          } else {
            splits = urlInfo.name.split("/");
            if (splits.length === 2) {
              urlInfo.owner = splits[1];
              urlInfo.name = splits[1];
              urlInfo.full_name = "_git/" + urlInfo.name;
            } else if (splits.length === 3) {
              urlInfo.name = splits[2];
              if (splits[0] === "DefaultCollection") {
                urlInfo.owner = splits[2];
                urlInfo.organization = splits[0];
                urlInfo.full_name = urlInfo.organization + "/_git/" + urlInfo.name;
              } else {
                urlInfo.owner = splits[0];
                urlInfo.full_name = urlInfo.owner + "/_git/" + urlInfo.name;
              }
            } else if (splits.length === 4) {
              urlInfo.organization = splits[0];
              urlInfo.owner = splits[1];
              urlInfo.name = splits[3];
              urlInfo.full_name = urlInfo.organization + "/" + urlInfo.owner + "/_git/" + urlInfo.name;
            }
            break;
          }
        // Azure DevOps (formerly Visual Studio Team Services)
        case "dev.azure.com":
        case "azure.com":
          if (urlInfo.resource === "ssh.dev.azure.com") {
            splits = urlInfo.name.split("/");
            if (splits.length === 4) {
              urlInfo.organization = splits[1];
              urlInfo.owner = splits[2];
              urlInfo.name = splits[3];
            }
            break;
          } else {
            splits = urlInfo.name.split("/");
            if (splits.length === 5) {
              urlInfo.organization = splits[0];
              urlInfo.owner = splits[1];
              urlInfo.name = splits[4];
              urlInfo.full_name = "_git/" + urlInfo.name;
            } else if (splits.length === 3) {
              urlInfo.name = splits[2];
              if (splits[0] === "DefaultCollection") {
                urlInfo.owner = splits[2];
                urlInfo.organization = splits[0];
                urlInfo.full_name = urlInfo.organization + "/_git/" + urlInfo.name;
              } else {
                urlInfo.owner = splits[0];
                urlInfo.full_name = urlInfo.owner + "/_git/" + urlInfo.name;
              }
            } else if (splits.length === 4) {
              urlInfo.organization = splits[0];
              urlInfo.owner = splits[1];
              urlInfo.name = splits[3];
              urlInfo.full_name = urlInfo.organization + "/" + urlInfo.owner + "/_git/" + urlInfo.name;
            }
            if (urlInfo.query && urlInfo.query["path"]) {
              urlInfo.filepath = urlInfo.query["path"].replace(/^\/+/g, "");
            }
            if (urlInfo.query && urlInfo.query["version"]) {
              urlInfo.ref = urlInfo.query["version"].replace(/^GB/, "");
            }
            break;
          }
        default:
          splits = urlInfo.name.split("/");
          var nameIndex = splits.length - 1;
          if (splits.length >= 2) {
            var dashIndex = splits.indexOf("-", 2);
            var blobIndex = splits.indexOf("blob", 2);
            var treeIndex = splits.indexOf("tree", 2);
            var commitIndex = splits.indexOf("commit", 2);
            var issuesIndex = splits.indexOf("issues", 2);
            var srcIndex = splits.indexOf("src", 2);
            var rawIndex = splits.indexOf("raw", 2);
            var editIndex = splits.indexOf("edit", 2);
            nameIndex = dashIndex > 0 ? dashIndex - 1 : blobIndex > 0 && treeIndex > 0 ? Math.min(blobIndex - 1, treeIndex - 1) : blobIndex > 0 ? blobIndex - 1 : issuesIndex > 0 ? issuesIndex - 1 : treeIndex > 0 ? treeIndex - 1 : commitIndex > 0 ? commitIndex - 1 : srcIndex > 0 ? srcIndex - 1 : rawIndex > 0 ? rawIndex - 1 : editIndex > 0 ? editIndex - 1 : nameIndex;
            urlInfo.owner = splits.slice(0, nameIndex).join("/");
            urlInfo.name = splits[nameIndex];
            if (commitIndex && issuesIndex < 0) {
              urlInfo.commit = splits[nameIndex + 2];
            }
          }
          urlInfo.ref = "";
          urlInfo.filepathtype = "";
          urlInfo.filepath = "";
          var offsetNameIndex = splits.length > nameIndex && splits[nameIndex + 1] === "-" ? nameIndex + 1 : nameIndex;
          if (splits.length > offsetNameIndex + 2 && ["raw", "src", "blob", "tree", "edit"].indexOf(splits[offsetNameIndex + 1]) >= 0) {
            urlInfo.filepathtype = splits[offsetNameIndex + 1];
            urlInfo.ref = splits[offsetNameIndex + 2];
            if (splits.length > offsetNameIndex + 3) {
              urlInfo.filepath = splits.slice(offsetNameIndex + 3).join("/");
            }
          }
          urlInfo.organization = urlInfo.owner;
          break;
      }
      if (!urlInfo.full_name) {
        urlInfo.full_name = urlInfo.owner;
        if (urlInfo.name) {
          urlInfo.full_name && (urlInfo.full_name += "/");
          urlInfo.full_name += urlInfo.name;
        }
      }
      if (urlInfo.owner.startsWith("scm/")) {
        urlInfo.source = "bitbucket-server";
        urlInfo.owner = urlInfo.owner.replace("scm/", "");
        urlInfo.organization = urlInfo.owner;
        urlInfo.full_name = urlInfo.owner + "/" + urlInfo.name;
      }
      var bitbucket = /(projects|users)\/(.*?)\/repos\/(.*?)((\/.*$)|$)/;
      var matches = bitbucket.exec(urlInfo.pathname);
      if (matches != null) {
        urlInfo.source = "bitbucket-server";
        if (matches[1] === "users") {
          urlInfo.owner = "~" + matches[2];
        } else {
          urlInfo.owner = matches[2];
        }
        urlInfo.organization = urlInfo.owner;
        urlInfo.name = matches[3];
        splits = matches[4].split("/");
        if (splits.length > 1) {
          if (["raw", "browse"].indexOf(splits[1]) >= 0) {
            urlInfo.filepathtype = splits[1];
            if (splits.length > 2) {
              urlInfo.filepath = splits.slice(2).join("/");
            }
          } else if (splits[1] === "commits" && splits.length > 2) {
            urlInfo.commit = splits[2];
          }
        }
        urlInfo.full_name = urlInfo.owner + "/" + urlInfo.name;
        if (urlInfo.query.at) {
          urlInfo.ref = urlInfo.query.at;
        } else {
          urlInfo.ref = "";
        }
      }
      if (refs.length !== 0 && urlInfo.ref) {
        urlInfo.ref = findLongestMatchingSubstring(urlInfo.href, refs) || urlInfo.ref;
        urlInfo.filepath = urlInfo.href.split(urlInfo.ref + "/")[1];
      }
      return urlInfo;
    }
    gitUrlParse2.stringify = function(obj, type) {
      type = type || (obj.protocols && obj.protocols.length ? obj.protocols.join("+") : obj.protocol);
      var port = obj.port ? ":" + obj.port : "";
      var user = obj.user || "git";
      var maybeGitSuffix = obj.git_suffix ? ".git" : "";
      switch (type) {
        case "ssh":
          if (port) return "ssh://" + user + "@" + obj.resource + port + "/" + obj.full_name + maybeGitSuffix;
          else return user + "@" + obj.resource + ":" + obj.full_name + maybeGitSuffix;
        case "git+ssh":
        case "ssh+git":
        case "ftp":
        case "ftps":
          return type + "://" + user + "@" + obj.resource + port + "/" + obj.full_name + maybeGitSuffix;
        case "http":
        case "https":
          var auth = obj.token ? buildToken(obj) : obj.user && (obj.protocols.includes("http") || obj.protocols.includes("https")) ? obj.user + "@" : "";
          return type + "://" + auth + obj.resource + port + "/" + buildPath(obj) + maybeGitSuffix;
        default:
          return obj.href;
      }
    };
    function buildToken(obj) {
      switch (obj.source) {
        case "bitbucket.org":
          return "x-token-auth:" + obj.token + "@";
        default:
          return obj.token + "@";
      }
    }
    function buildPath(obj) {
      switch (obj.source) {
        case "bitbucket-server":
          return "scm/" + obj.full_name;
        default:
          var encoded_full_name = obj.full_name.split("/").map(function(x) {
            return encodeURIComponent(x);
          }).join("/");
          return encoded_full_name;
      }
    }
    function findLongestMatchingSubstring(string, array) {
      var longestMatch = "";
      array.forEach(function(item) {
        if (string.includes(item) && item.length > longestMatch.length) {
          longestMatch = item;
        }
      });
      return longestMatch;
    }
    module.exports = gitUrlParse2;
  }
});

// ../git/dist/signed-commit.js
import * as childProcess3 from "child_process";

// ../git/dist/gh.js
import * as childProcess from "child_process";

// ../git/dist/utils.js
var import_git_url_parse = __toESM(require_lib5(), 1);
import * as childProcess2 from "child_process";
import * as fs from "fs/promises";
import * as os from "os";
import * as path from "path";

// ../git/dist/signed-commit.js
var DEFAULT_MAX_PAYLOAD_BYTES = 35 * 1024 * 1024;
var MAX_GIT_BUFFER = 256 * 1024 * 1024;

// src/utils/common.ts
var IS_ROOT = typeof process !== "undefined" && (process.geteuid?.() ?? process.getuid?.()) === 0;
var ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;

// src/execution-mode.ts
var availableModes = [
  {
    id: "default",
    name: "Default",
    description: "Standard behavior, prompts for dangerous operations"
  },
  {
    id: "acceptEdits",
    name: "Accept Edits",
    description: "Auto-accept file edit operations"
  },
  {
    id: "plan",
    name: "Plan Mode",
    description: "Planning mode, no actual tool execution"
  }
];
if (ALLOW_BYPASS) {
  availableModes.push(
    {
      id: "bypassPermissions",
      name: "Bypass Permissions",
      description: "Auto-accept all permission requests"
    },
    {
      id: "auto",
      name: "Auto Mode",
      description: "Use a model classifier to approve/deny permission prompts"
    }
  );
}
var CODE_EXECUTION_MODES = [
  "default",
  "acceptEdits",
  "plan",
  "bypassPermissions",
  "auto"
];
function isCodeExecutionMode(mode) {
  return CODE_EXECUTION_MODES.includes(mode);
}
function getAvailableModes() {
  return ALLOW_BYPASS ? availableModes : availableModes.filter((m) => m.id !== "bypassPermissions");
}
var CODEX_NATIVE_MODES = ["auto", "read-only", "full-access"];
function isCodexNativeMode(mode) {
  return CODEX_NATIVE_MODES.includes(mode);
}
var codexModes = [
  {
    id: "read-only",
    name: "Read Only",
    description: "Read-only access, no file modifications"
  },
  {
    id: "auto",
    name: "Auto",
    description: "Standard behavior, prompts for dangerous operations"
  }
];
if (ALLOW_BYPASS) {
  codexModes.push({
    id: "full-access",
    name: "Full Access",
    description: "Auto-accept all permission requests"
  });
}
function getAvailableCodexModes() {
  return ALLOW_BYPASS ? codexModes : codexModes.filter((m) => m.id !== "full-access");
}
export {
  CODEX_NATIVE_MODES,
  CODE_EXECUTION_MODES,
  getAvailableCodexModes,
  getAvailableModes,
  isCodeExecutionMode,
  isCodexNativeMode
};
/*! Bundled license information:

git-url-parse/lib/index.js:
  (*!
   * buildToken
   * Builds OAuth token prefix (helper function)
   *
   * @name buildToken
   * @function
   * @param {GitUrl} obj The parsed Git url object.
   * @return {String} token prefix
   *)
*/
//# sourceMappingURL=execution-mode.js.map