"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactstrap = require("reactstrap");
var _reactI18next = require("react-i18next");
var _copyToClipboard = _interopRequireDefault(require("copy-to-clipboard"));
var _modalHeader = _interopRequireDefault(require("../modal-header"));
var _constants = require("../../constants");
require("./index.css");
/* eslint-disable react-hooks/rules-of-hooks */

const LinkVerifiedDialog = _ref => {
  let {
    onToggle,
    link
  } = _ref;
  const {
    t
  } = (0, _reactI18next.useTranslation)(_constants.TRANSLATE_NAMESPACE);
  const copyLink = (0, _react.useCallback)(() => {
    (0, _copyToClipboard.default)(link);
    onToggle && onToggle();
  }, [link, onToggle]);
  const openLink = (0, _react.useCallback)(() => {
    window.open(link);
    onToggle && onToggle();
  }, [link, onToggle]);
  const {
    host,
    protocol,
    pathname
  } = new URL(link);
  return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
    isOpen: true,
    toggle: onToggle,
    className: "sf-link-verified-dialog",
    zIndex: 1071
  }, /*#__PURE__*/_react.default.createElement(_modalHeader.default, {
    toggle: onToggle
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: "mr-2"
  }, t('This_link_is_not_verified'))), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, null, /*#__PURE__*/_react.default.createElement("p", {
    className: "sf-tip-default mb-5"
  }, t('This_link_is_not_verified_tip')), /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-verify-link"
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: "sf-tip-default"
  }, protocol + '//'), /*#__PURE__*/_react.default.createElement("span", null, host), /*#__PURE__*/_react.default.createElement("span", {
    className: "sf-tip-default"
  }, decodeURIComponent(pathname)))), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
    onClick: copyLink,
    className: "m-0 mr-2"
  }, t('Copy_link')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
    color: "primary",
    className: "m-0",
    onClick: openLink
  }, t('Open_link'))));
};
var _default = exports.default = LinkVerifiedDialog;