"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getPromptAction = exports.RovoChatPromptKey = void 0;
var _react = _interopRequireDefault(require("react"));
var _aiSearch = _interopRequireDefault(require("@atlaskit/icon-lab/core/ai-search"));
var _aiChat = _interopRequireDefault(require("@atlaskit/icon/core/ai-chat"));
var _aiGenerativeTextSummary = _interopRequireDefault(require("@atlaskit/icon/core/ai-generative-text-summary"));
var _rovoChat = _interopRequireDefault(require("@atlaskit/icon/core/rovo-chat"));
var _logo = require("@atlaskit/logo");
var _constants = require("../../../constants");
var _messages = require("../../../messages");
var _useBlockCardRovoActionExperiment = require("../../../state/hooks/use-block-card-rovo-action-experiment");
var _aiChapterIcon = _interopRequireDefault(require("../../FlexibleCard/assets/ai-chapter-icon"));
var _aiEditIcon = _interopRequireDefault(require("../../FlexibleCard/assets/ai-edit-icon"));
var _aiSearchIcon = _interopRequireDefault(require("../../FlexibleCard/assets/ai-search-icon"));
var _htmlToAdf = _interopRequireDefault(require("../../FlexibleCard/components/actions/rovo-chat-action/html-to-adf"));
var RovoChatPromptKey = exports.RovoChatPromptKey = /*#__PURE__*/function (RovoChatPromptKey) {
  RovoChatPromptKey["RECOMMEND_OTHER_SOURCES"] = "recommend-other-sources";
  RovoChatPromptKey["SHOW_OTHER_MENTIONS"] = "show-other-mentions";
  RovoChatPromptKey["SUGGEST_IMPROVEMENT"] = "suggest-improvement";
  RovoChatPromptKey["SUMMARIZE_LINK"] = "summarize-link";
  RovoChatPromptKey["KEY_HIGHLIGHTS"] = "key-highlights";
  RovoChatPromptKey["ASK_ROVO_ANYTHING"] = "ask-rovo-anything";
  RovoChatPromptKey["IDENTIFY_KEY_POINTS"] = "identify-key-points";
  RovoChatPromptKey["IDENTIFY_KEY_TRENDS"] = "identify-key-trends";
  RovoChatPromptKey["FIND_OPEN_QUESTIONS"] = "find-open-questions";
  RovoChatPromptKey["HIGHLIGHT_RELEVANT_CONTENT"] = "highlight-relevant-content";
  RovoChatPromptKey["SUMMARIZE_THIS_FOR_ME"] = "summarize-this-for-me";
  RovoChatPromptKey["ASK_A_SPECIFIC_QUESTION"] = "ask-a-specific-question";
  RovoChatPromptKey["SHOW_ME_WHATS_RELEVANT"] = "show-me-whats-relevant";
  return RovoChatPromptKey;
}({});
var getContext = function getContext(intl, product) {
  switch (product) {
    case 'CONFLUENCE':
      return {
        contextLong: intl.formatMessage(_messages.messages.rovo_prompt_context_confluence_page),
        contextShort: intl.formatMessage(_messages.messages.rovo_prompt_context_confluence_page_short)
      };
    case 'JSW':
    case 'JWM':
    case 'JSM':
    case 'JPD':
      return {
        contextLong: intl.formatMessage(_messages.messages.rovo_prompt_context_jira_work_item),
        contextShort: intl.formatMessage(_messages.messages.rovo_prompt_context_jira_work_item_short)
      };
  }
};
var getPromptAction = exports.getPromptAction = function getPromptAction(promptKey, intl) {
  var _getContext;
  var url = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  var product = arguments.length > 3 ? arguments[3] : undefined;
  var iconSize = arguments.length > 4 ? arguments[4] : undefined;
  var cardAppearance = arguments.length > 5 ? arguments[5] : undefined;
  var _ref = (_getContext = getContext(intl, product)) !== null && _getContext !== void 0 ? _getContext : {
      contextLong: intl.formatMessage(_messages.messages.rovo_prompt_context_generic),
      contextShort: intl.formatMessage(_messages.messages.rovo_prompt_context_generic)
    },
    contextLong = _ref.contextLong,
    contextShort = _ref.contextShort;
  var isBlockCard3PExperimentEnabled = (0, _useBlockCardRovoActionExperiment.isBlockCardRovoActionExperimentEnabled)(product);
  switch (promptKey) {
    case RovoChatPromptKey.RECOMMEND_OTHER_SOURCES:
      var label_recommend = intl.formatMessage(_messages.messages.rovo_prompt_button_recommend_other_sources);
      var html_recommend = intl.formatMessage(_messages.messages.rovo_prompt_message_recommend_other_sources, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiEditIcon.default, null),
        content: label_recommend,
        tooltipMessage: label_recommend,
        data: {
          name: label_recommend,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_recommend)
        }
      };
    case RovoChatPromptKey.SHOW_OTHER_MENTIONS:
      var label_other_mentions = intl.formatMessage(_messages.messages.rovo_prompt_button_show_other_mentions);
      var html_other_mentions = intl.formatMessage(_messages.messages.rovo_prompt_message_show_other_mentions, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChapterIcon.default, null),
        content: label_other_mentions,
        tooltipMessage: label_other_mentions,
        data: {
          name: label_other_mentions,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_other_mentions)
        }
      };
    case RovoChatPromptKey.SUGGEST_IMPROVEMENT:
      var label_improvement = intl.formatMessage(_messages.messages.rovo_prompt_button_suggest_improvement, {
        context: contextShort
      });
      var html_improvement = intl.formatMessage(_messages.messages.rovo_prompt_message_suggest_improvement, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiSearchIcon.default, null),
        content: label_improvement,
        tooltipMessage: label_improvement,
        data: {
          name: label_improvement,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_improvement)
        }
      };
    case RovoChatPromptKey.SUMMARIZE_LINK:
      var label_summarize = intl.formatMessage(_messages.messages.ai_summarize);
      var html_summarize = intl.formatMessage(_messages.messages.rovo_prompt_message_summarize, {
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: cardAppearance === _constants.CardDisplay.Block && isBlockCard3PExperimentEnabled ? /*#__PURE__*/_react.default.createElement(_aiChat.default, {
          label: label_summarize,
          size: iconSize
        }) : /*#__PURE__*/_react.default.createElement(_aiEditIcon.default, null),
        content: label_summarize,
        tooltipMessage: label_summarize,
        data: {
          name: label_summarize,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_summarize),
          mode: {
            fastModeEnabled: true
          }
        }
      };
    case RovoChatPromptKey.SUMMARIZE_THIS_FOR_ME:
      var label_summarize_this_for_me = intl.formatMessage(_messages.messages.rovo_prompt_button_summarize_this);
      var html_summarize_this_for_me = intl.formatMessage(_messages.messages.rovo_prompt_message_summarize, {
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiGenerativeTextSummary.default, {
          label: label_summarize_this_for_me
        }),
        content: label_summarize_this_for_me,
        tooltipMessage: label_summarize_this_for_me,
        data: {
          name: label_summarize_this_for_me,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_summarize_this_for_me),
          mode: {
            fastModeEnabled: true
          }
        }
      };
    case RovoChatPromptKey.HIGHLIGHT_RELEVANT_CONTENT:
      var label_highlight_relevant_content = intl.formatMessage(_messages.messages.rovo_prompt_button_highlight_relevant_content);
      var html_highlight_relevant_content = intl.formatMessage(_messages.messages.rovo_prompt_message_highlight_relevant_content, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChapterIcon.default, null),
        content: label_highlight_relevant_content,
        tooltipMessage: label_highlight_relevant_content,
        data: {
          name: label_highlight_relevant_content,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_highlight_relevant_content),
          mode: {
            fastModeEnabled: true
          }
        }
      };
    case RovoChatPromptKey.ASK_ROVO_ANYTHING:
      var label_ask_rovo_anything = intl.formatMessage(_messages.messages.rovo_prompt_button_ask_rovo_anything);
      var prompt_ask_rovo_anything = intl.formatMessage(_messages.messages.rovo_prompt_message_ask_rovo_anything, {
        url: url
      });
      return {
        icon: cardAppearance === _constants.CardDisplay.Block && isBlockCard3PExperimentEnabled ? /*#__PURE__*/_react.default.createElement(_logo.RovoIcon, {
          label: label_ask_rovo_anything,
          size: 'xxsmall',
          shouldUseHexLogo: true
        }) : /*#__PURE__*/_react.default.createElement(_aiSearchIcon.default, null),
        content: label_ask_rovo_anything,
        tooltipMessage: label_ask_rovo_anything,
        data: {
          name: label_ask_rovo_anything,
          dialogues: [],
          prompt: prompt_ask_rovo_anything,
          isPromptPlaceholder: true,
          placeholderType: 'generic'
        }
      };
    case RovoChatPromptKey.ASK_A_SPECIFIC_QUESTION:
      var label_ask_a_specific_question = intl.formatMessage(_messages.messages.rovo_prompt_button_ask_a_specific_question);
      var prompt_ask_a_specific_question = intl.formatMessage(_messages.messages.rovo_prompt_message_ask_rovo_anything, {
        url: url
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_rovoChat.default, {
          label: label_ask_a_specific_question
        }),
        content: label_ask_a_specific_question,
        tooltipMessage: label_ask_a_specific_question,
        data: {
          name: label_ask_a_specific_question,
          dialogues: [],
          prompt: prompt_ask_a_specific_question,
          isPromptPlaceholder: true,
          placeholderType: 'generic'
        }
      };
    case RovoChatPromptKey.KEY_HIGHLIGHTS:
      var label_key_highlights = intl.formatMessage(_messages.messages.rovo_prompt_button_key_highlights);
      var html_key_highlights = intl.formatMessage(_messages.messages.rovo_prompt_message_key_highlights, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChat.default, {
          label: label_key_highlights,
          size: iconSize
        }),
        content: label_key_highlights,
        tooltipMessage: label_key_highlights,
        data: {
          name: label_key_highlights,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_key_highlights)
        }
      };
    case RovoChatPromptKey.SHOW_ME_WHATS_RELEVANT:
      var label_show_me_whats_relevant = intl.formatMessage(_messages.messages.rovo_prompt_button_show_me_whats_relevant);
      var html_show_me_whats_relevant = intl.formatMessage(_messages.messages.rovo_prompt_message_highlight_relevant_content, {
        context: contextLong,
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiSearch.default, {
          label: label_show_me_whats_relevant
        }),
        content: label_show_me_whats_relevant,
        tooltipMessage: label_show_me_whats_relevant,
        data: {
          name: label_show_me_whats_relevant,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_show_me_whats_relevant)
        }
      };
    case RovoChatPromptKey.IDENTIFY_KEY_TRENDS:
      var label_identify_key_trends = intl.formatMessage(_messages.messages.rovo_prompt_button_identify_key_trends);
      var html_identify_key_trends = intl.formatMessage(_messages.messages.rovo_prompt_message_identify_key_trends, {
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChat.default, {
          label: label_identify_key_trends,
          size: iconSize
        }),
        content: label_identify_key_trends,
        tooltipMessage: label_identify_key_trends,
        data: {
          name: label_identify_key_trends,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_identify_key_trends)
        }
      };
    case RovoChatPromptKey.IDENTIFY_KEY_POINTS:
      var label_identify_key_points = intl.formatMessage(_messages.messages.rovo_prompt_button_identify_key_points);
      var html_identify_key_points = intl.formatMessage(_messages.messages.rovo_prompt_message_identify_key_points, {
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChat.default, {
          label: label_identify_key_points,
          size: iconSize
        }),
        content: label_identify_key_points,
        tooltipMessage: label_identify_key_points,
        data: {
          name: label_identify_key_points,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_identify_key_points)
        }
      };
    case RovoChatPromptKey.FIND_OPEN_QUESTIONS:
      var label_find_open_questions = intl.formatMessage(_messages.messages.rovo_prompt_button_find_open_questions);
      var html_find_open_questions = intl.formatMessage(_messages.messages.rovo_prompt_message_find_open_questions, {
        url: url
      }, {
        ignoreTag: true
      });
      return {
        icon: /*#__PURE__*/_react.default.createElement(_aiChat.default, {
          label: label_find_open_questions,
          size: iconSize
        }),
        content: label_find_open_questions,
        tooltipMessage: label_find_open_questions,
        data: {
          name: label_find_open_questions,
          dialogues: [],
          prompt: (0, _htmlToAdf.default)(html_find_open_questions)
        }
      };
  }
};