import { useContext } from 'react';
import { SmartCardContext } from '@atlaskit/link-provider';
var allowedHostnames = ['sharepoint.com', 'onedrive.live.com', 'docs.google.com', 'drive.google.com'];
export var shouldResolveUrl = function shouldResolveUrl(href) {
  try {
    var hostname = new URL(href).hostname.toLowerCase();
    return allowedHostnames.some(function (allowedHostname) {
      return hostname.includes(allowedHostname);
    });
  } catch (_unused) {
    return false;
  }
};
var useResolveHyperlinkValidator = function useResolveHyperlinkValidator() {
  var href = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var hasSmartCardProvider = !!useContext(SmartCardContext);
  return hasSmartCardProvider && shouldResolveUrl(href);
};
export default useResolveHyperlinkValidator;