"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.filterUniqueItems = filterUniqueItems;
exports.wordCount = exports.sha1 = exports.mapContentTypeToIcon = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactIntl = require("react-intl");
var _rusha = _interopRequireDefault(require("rusha"));
var _blog = _interopRequireDefault(require("@atlaskit/object/blog"));
var _bug = _interopRequireDefault(require("@atlaskit/object/bug"));
var _page = _interopRequireDefault(require("@atlaskit/object/page"));
var _story = _interopRequireDefault(require("@atlaskit/object/story"));
var _task = _interopRequireDefault(require("@atlaskit/object/task"));
var _workItem = _interopRequireDefault(require("@atlaskit/object/work-item"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _messages = require("./messages");
function filterUniqueItems(arr, comparator) {
  return arr.filter(function (firstItem, index, self) {
    return self.findIndex(function (secondItem) {
      return comparator ? comparator(firstItem, secondItem) : firstItem === secondItem;
    }) === index;
  });
}
var Issue16 = function Issue16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_workItem.default, {
    label: intl.formatMessage((0, _platformFeatureFlags.fg)('confluence-issue-terminology-refresh') ? _messages.utilMessages.hyperlinkIconIssueLabelIssueTermRefresh : _messages.utilMessages.hyperlinkIconIssueLabel)
  });
};
var Bug16 = function Bug16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_bug.default, {
    label: intl.formatMessage(_messages.utilMessages.hyperlinkIconBugLabel)
  });
};
var Story16 = function Story16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_story.default, {
    label: intl.formatMessage(_messages.utilMessages.hyperlinkIconStoryLabel)
  });
};
var Task16 = function Task16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_task.default, {
    label: intl.formatMessage(_messages.utilMessages.hyperlinkIconTaskLabel)
  });
};
var Page16 = function Page16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_page.default, {
    label: intl.formatMessage(_messages.utilMessages.hyperlinkIconPageLabel)
  });
};
var Blog16 = function Blog16(props) {
  var intl = props.intl;
  return /*#__PURE__*/_react.default.createElement(_blog.default, {
    label: intl.formatMessage(_messages.utilMessages.hyperlinkIconBlogLabel)
  });
};
var IntlIssue16Icon = (0, _reactIntl.injectIntl)(Issue16);
var IntlBug16Icon = (0, _reactIntl.injectIntl)(Bug16);
var IntlStory16Icon = (0, _reactIntl.injectIntl)(Story16);
var IntlTask16Icon = (0, _reactIntl.injectIntl)(Task16);
var IntlPage16Icon = (0, _reactIntl.injectIntl)(Page16);
var IntlBlog16Icon = (0, _reactIntl.injectIntl)(Blog16);
var mapContentTypeToIcon = exports.mapContentTypeToIcon = {
  'jira.issue': /*#__PURE__*/_react.default.createElement(IntlIssue16Icon, null),
  'jira.issue.bug': /*#__PURE__*/_react.default.createElement(IntlBug16Icon, null),
  'jira.issue.story': /*#__PURE__*/_react.default.createElement(IntlStory16Icon, null),
  'jira.issue.task': /*#__PURE__*/_react.default.createElement(IntlTask16Icon, null),
  'confluence.page': /*#__PURE__*/_react.default.createElement(IntlPage16Icon, null),
  'confluence.blogpost': /*#__PURE__*/_react.default.createElement(IntlBlog16Icon, null)
};
var sha1 = exports.sha1 = function sha1(input) {
  return _rusha.default.createHash().update(input).digest('hex');
};
var wordCount = exports.wordCount = function wordCount(input) {
  return input.split(' ').length;
};