"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
require("core-js/modules/es.array.concat.js");
require("core-js/modules/es.string.link.js");
var React = _interopRequireWildcard(require("react"));
var _uiCore = require("@megafon/ui-core");
var _uiHelpers = require("@megafon/ui-helpers");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var DownloadIcon = function DownloadIcon(props) {
  return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
    viewBox: "0 0 40 40"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M33 18a2 2 0 012 2c0 1.862-.398 3.701-1.165 5.411a13.988 13.988 0 01-3.286 4.544 15.123 15.123 0 01-4.86 3A15.948 15.948 0 0120 34c-1.948 0-3.882-.354-5.69-1.045a15.124 15.124 0 01-4.859-3 13.987 13.987 0 01-3.286-4.544A13.204 13.204 0 015 20a2 2 0 014 0c0 1.29.275 2.572.814 3.773a9.984 9.984 0 002.35 3.243 11.123 11.123 0 003.575 2.203c1.347.515 2.795.781 4.261.781 1.466 0 2.914-.266 4.26-.781a11.123 11.123 0 003.576-2.203 9.983 9.983 0 002.35-3.243A9.203 9.203 0 0031 20a2 2 0 012-2z"
  }), /*#__PURE__*/React.createElement("path", {
    d: "M20 8a2 2 0 012 2v7.172l2.586-2.586a2 2 0 112.828 2.828l-5.293 5.293-.111.107a3 3 0 01-4.131-.107l-5.293-5.293a2 2 0 112.828-2.828L18 17.172V10a2 2 0 012-2z"
  }));
};
var cn = (0, _uiHelpers.cnCreate)('mfui-9-download-link');
var DownloadLink = function DownloadLink(_ref) {
  var href = _ref.href,
    text = _ref.text,
    extension = _ref.extension,
    fileSize = _ref.fileSize,
    onClick = _ref.onClick,
    className = _ref.className,
    _ref$classes = _ref.classes,
    classes = _ref$classes === void 0 ? {} : _ref$classes,
    rootRef = _ref.rootRef,
    dataAttrs = _ref.dataAttrs,
    disableDownload = _ref.disableDownload,
    target = _ref.target,
    rel = _ref.rel;
  var setRelAttribute = function setRelAttribute() {
    if (rel) {
      return rel;
    }
    if (target && target !== '_self') {
      return 'noreferrer noopener';
    }
    return undefined;
  };
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    className: cn([className, classes.root]),
    ref: rootRef
  }), /*#__PURE__*/React.createElement("div", {
    className: cn('icon')
  }, /*#__PURE__*/React.createElement(DownloadIcon, {
    className: cn('icon-svg')
  })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_uiCore.TextLink, (0, _extends2["default"])({}, !disableDownload && {
    download: true
  }, {
    href: href,
    onClick: onClick,
    dataAttrs: {
      root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.link
    },
    className: cn('link', [classes.link]),
    target: target,
    rel: setRelAttribute()
  }), text), /*#__PURE__*/React.createElement("p", {
    className: cn('info')
  }, "".concat(extension).concat(extension && fileSize ? ', ' : '').concat(fileSize))));
};
var _default = exports["default"] = DownloadLink;