text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.tryURLParse = tryURLParse;
  exports.isUrlString = isUrlString;
  exports.hasFetchScheme = hasFetchScheme;
  exports.tryURLLikeSpecifierParse = tryURLLikeSpecifierParse;
  exports.mergeImportMaps = mergeImportMaps;
  exports.BUILT_IN_MODULE_PROTOCOL = exports.BUILT_IN_MODULE_SCHEME = void 0;
  
  var _url = require("url");
  
  // https://fetch.spec.whatwg.org/#fetch-scheme
  const FETCH_SCHEMES = new Set(['http', 'https', 'ftp', 'about', 'blob', 'data', 'file', 'filesystem']); // Tentative, so better to centralize so we can change in one place as necessary (including tests).
  
  const BUILT_IN_MODULE_SCHEME = 'std'; // Useful for comparing to .protocol
  
  exports.BUILT_IN_MODULE_SCHEME = BUILT_IN_MODULE_SCHEME;
  const BUILT_IN_MODULE_PROTOCOL = `${BUILT_IN_MODULE_SCHEME}:`;
  exports.BUILT_IN_MODULE_PROTOCOL = BUILT_IN_MODULE_PROTOCOL;
  
  function tryURLParse(string, baseURL) {
    try {
      return new _url.URL(string, baseURL);
    } catch (e) {
      // TODO remove useless binding when ESLint and Jest support that
      return null;
    }
  }
  
  function isUrlString(string) {
    return !!tryURLParse(string);
  }
  
  function hasFetchScheme(url) {
    return FETCH_SCHEMES.has(url.protocol.slice(0, -1));
  }
  
  function tryURLLikeSpecifierParse(specifier, baseURL) {
    if (baseURL.includes('::')) {
      return null;
    }
  
    if (specifier.startsWith('/') || specifier.startsWith('./') || specifier.startsWith('../')) {
      return new _url.URL(specifier, baseURL);
    }
  
    const url = tryURLParse(specifier);
  
    if (url === null) {
      return null;
    }
  
    if (hasFetchScheme(url) || url.protocol === BUILT_IN_MODULE_PROTOCOL) {
      return url;
    }
  
    return null;
  }
  
  function mergeImportMaps(mapA, mapB) {
    const mapAImports = mapA && mapA.imports ? mapA.imports : {};
    const mapBImports = mapB && mapB.imports ? mapB.imports : {};
    const mapAScopes = mapA && mapA.scopes ? mapA.scopes : {};
    const mapBScopes = mapB && mapB.scopes ? mapB.scopes : {};
    return {
      imports: { ...mapAImports,
        ...mapBImports
      },
      scopes: { ...mapAScopes,
        ...mapBScopes
      }
    };
  }