'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = connect;

var _ssh;

function _load_ssh() {
  return _ssh = _interopRequireDefault(require('./ssh'));
}

var _fs;

function _load_fs() {
  return _fs = _interopRequireDefault(require('./fs'));
}

var _exceptions;

function _load_exceptions() {
  return _exceptions = require('./exceptions');
}

var _utils;

function _load_utils() {
  return _utils = require('../../utils');
}

var _logger;

function _load_logger() {
  return _logger = _interopRequireDefault(require('../../logger/logger'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function connect(host) {
  if (host.startsWith('ssh://') || host.startsWith('bit://')) {
    (_logger || _load_logger()).default.debug(`Establishing a new SSH connection to ${host}`);
    var sshProps = (0, (_utils || _load_utils()).parseSSHUrl)(host);
    return new (_ssh || _load_ssh()).default(sshProps).connect();
  }

  if (host.startsWith('file://')) {
    return new (_fs || _load_fs()).default(host.replace('file://', '')).connect();
  }

  throw new (_exceptions || _load_exceptions()).ProtocolNotSupported();
}