/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("./index.compiled.css");
var _runtime = require("@compiled/react/runtime");
var _react = _interopRequireWildcard(require("react"));
var _reactIntlNext = require("react-intl-next");
var _heading = _interopRequireDefault(require("@atlaskit/heading"));
var _download = _interopRequireDefault(require("@atlaskit/icon/core/download"));
var _fullscreenExit = _interopRequireDefault(require("@atlaskit/icon/core/fullscreen-exit"));
var _fullscreenEnterVidFullScreenOn = _interopRequireDefault(require("@atlaskit/icon/core/migration/fullscreen-enter--vid-full-screen-on"));
var _linkExternalShortcut = _interopRequireDefault(require("@atlaskit/icon/core/migration/link-external--shortcut"));
var _download2 = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
var _vidFullScreenOff = _interopRequireDefault(require("@atlaskit/icon/glyph/vid-full-screen-off"));
var _modalDialog = require("@atlaskit/modal-dialog");
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
var _messages = require("../../../../messages");
var _Icon = require("../../../common/Icon");
var _constants = require("../../constants");
var _linkInfoButton = _interopRequireDefault(require("./link-info-button"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var containerStyles = null;
var iconSize = '24px';

// EDM-7328: CSS Specificity
// An embed modal icon css for img, span, svg has specificity weight of 0-1-1.
// Specify flex ui icon selector to increase specificity weight to 0-2-1.
var iconCss = null;
var titleCss = null;
var actionCss = null;
var LinkInfo = function LinkInfo(_ref) {
  var icon = _ref.icon,
    providerName = _ref.providerName,
    onDownloadButtonClick = _ref.onDownloadButtonClick,
    onResizeButtonClick = _ref.onResizeButtonClick,
    onViewButtonClick = _ref.onViewButtonClick,
    size = _ref.size,
    testId = _ref.testId,
    title = _ref.title;
  var _useModal = (0, _modalDialog.useModal)(),
    onClose = _useModal.onClose;
  var _useIntl = (0, _reactIntlNext.useIntl)(),
    formatMessage = _useIntl.formatMessage;
  var downloadButton = (0, _react.useMemo)(function () {
    if (onDownloadButtonClick) {
      return /*#__PURE__*/_react.default.createElement(_linkInfoButton.default, {
        content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.download),
        icon: function icon() {
          return /*#__PURE__*/_react.default.createElement(_download.default, {
            label: _messages.messages.download.defaultMessage,
            LEGACY_fallbackIcon: _download2.default,
            spacing: "spacious",
            color: "currentColor"
          });
        },
        label: _messages.messages.download,
        onClick: onDownloadButtonClick,
        testId: "".concat(testId, "-download")
      });
    }
  }, [onDownloadButtonClick, testId]);
  var urlButton = (0, _react.useMemo)(function () {
    if (onViewButtonClick) {
      var content = providerName ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.viewIn), " ", providerName) : /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.viewOriginal);
      return /*#__PURE__*/_react.default.createElement(_linkInfoButton.default, {
        content: content,
        icon: function icon() {
          return /*#__PURE__*/_react.default.createElement(_linkExternalShortcut.default, {
            label: _messages.messages.viewOriginal.defaultMessage,
            spacing: "spacious",
            color: "currentColor"
          });
        },
        label: _messages.messages.viewOriginal,
        onClick: onViewButtonClick,
        testId: "".concat(testId, "-url")
      });
    }
  }, [onViewButtonClick, providerName, testId]);
  var sizeButton = (0, _react.useMemo)(function () {
    var isFullScreen = size === _constants.MAX_MODAL_SIZE;
    var message = isFullScreen ? _messages.messages.preview_min_size : _messages.messages.preview_max_size;
    var _icon = isFullScreen ? /*#__PURE__*/_react.default.createElement(_fullscreenExit.default, {
      LEGACY_fallbackIcon: _vidFullScreenOff.default,
      label: message.defaultMessage,
      spacing: "spacious",
      color: "currentColor"
    }) : /*#__PURE__*/_react.default.createElement(_fullscreenEnterVidFullScreenOn.default, {
      label: message.defaultMessage,
      spacing: "spacious",
      color: "currentColor"
    });
    return (
      /*#__PURE__*/
      // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
      _react.default.createElement("span", {
        className: "smart-link-resize-button"
      }, /*#__PURE__*/_react.default.createElement(_linkInfoButton.default, {
        content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, message),
        icon: function icon() {
          return _icon;
        },
        label: message,
        onClick: onResizeButtonClick,
        testId: "".concat(testId, "-resize")
      }))
    );
  }, [onResizeButtonClick, size, testId]);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _runtime.ax)(["_zulpu2gc _1e0c1txw _19bv1ejb _u5f31ejb _ca0q1ejb _n3tdpxbi _1wpz1fhb _4t3i1tcg"])
  }, icon && /*#__PURE__*/_react.default.createElement("div", {
    "data-testid": "".concat(testId, "-icon"),
    className: (0, _runtime.ax)(["_4t3i1tcg _gire1tcg _yrry1tcg _1bnm1tcg _bna71tcg _1xjx1tcg _17521tcg _1tke1tcg _x9xj1tcg _v5981tcg _z15s1tcg _qci81tcg _15iz1tcg _erub1tcg _c71l1tcg _1q121tcg _2s1x1tcg _1rh41tcg _19l31tcg _1pr21tcg _1u5t1tcg _1bsb1tcg _1xyl1tcg _1h1b1tcg _prfw1tcg _mezj1tcg _e2oo1tcg _w8l51tcg _1ul91tcg _1ekg1tcg _jbhf1tcg _11hh1tcg _1rg21tcg _q7cv1tcg _xwbj1tcg _p12f1tcg _1mj01tcg _1r9c1tcg _1xch1tcg _rtys1tcg _b8nk1tcg _4x201tcg"])
  }, /*#__PURE__*/_react.default.createElement(_Icon.Icon, icon)), /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _runtime.ax)(["_16jlkb7n _1o9zidpf _i0dlf1ug _1e0c1txw _2lx21bp4 _1bah1h6o _1wpz1fhb"])
  }, /*#__PURE__*/_react.default.createElement(_heading.default, {
    size: "small",
    color: "color.text",
    testId: "".concat(testId, "-title")
  }, title), /*#__PURE__*/_react.default.createElement("span", {
    tabIndex: 0,
    role: "button",
    "aria-hidden": true
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _runtime.ax)(["_16jlidpf _1o9zidpf _i0dl1wug _zulp1b66 _1e0c1txw _3kllglyw"])
  }, downloadButton, urlButton, sizeButton, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
    content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.preview_close),
    hideTooltipOnClick: true,
    tag: "span",
    testId: "".concat(testId, "-close-tooltip")
  }, /*#__PURE__*/_react.default.createElement(_modalDialog.CloseButton, {
    onClick: onClose,
    label: formatMessage(_messages.messages.preview_close),
    testId: testId
  }))));
};
var _default = exports.default = LinkInfo;