"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var feed_exports = {};
__export(feed_exports, {
  Feed: () => Feed
});
module.exports = __toCommonJS(feed_exports);
var import_design_system = require("@wix/design-system");
var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../../ricos-context/index.js");
var import_uncreachable = require("./../../../_shared/uncreachable.js");
var import_data_hooks = require("../../data-hooks.js");
var import_result_content = require("../result-content/result-content.js");
var import_results_footer = require("../results-footer/results-footer.js");
var import_text_cursor = require("../text-cursor/text-cursor.js");
var import_feed_scss = __toESM(require("./feed-scss.js"));
const defaultFeedUserEntryFormatter = (prompt, t) => {
  return typeof prompt === "string" ? prompt : t(prompt.title);
};
const Feed = ({
  entries,
  zIndex,
  getResultActions,
  isLoading,
  modalRef,
  feedUserEntryFormatter = defaultFeedUserEntryFormatter
}) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  return /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical" }, entries.map((entry, index) => {
    switch (entry.type) {
      case "request": {
        return /* @__PURE__ */ import_react.default.createElement(
          import_design_system.Box,
          {
            key: index,
            direction: "vertical",
            paddingLeft: "SP4",
            paddingRight: "SP4",
            paddingTop: "SP2",
            paddingBottom: "SP2",
            gap: "SP1"
          },
          /* @__PURE__ */ import_react.default.createElement(
            import_design_system.Text,
            {
              size: "small",
              weight: "bold",
              tagName: "h6",
              className: import_feed_scss.default.label,
              skin: "disabled"
            },
            t("AIPlugin_FeedLabel_You")
          ),
          /* @__PURE__ */ import_react.default.createElement(import_design_system.Text, { size: "small", tagName: "p", className: import_feed_scss.default.entry, skin: "disabled" }, feedUserEntryFormatter(entry.requestPrompt, t))
        );
      }
      case "result": {
        return /* @__PURE__ */ import_react.default.createElement(
          import_design_system.Box,
          {
            key: index,
            direction: "vertical",
            paddingTop: "SP2",
            backgroundColor: entries.length - 1 === index ? "B60" : void 0,
            dataHook: import_data_hooks.AI_MODAL_RESULTS_CONTENT_ITEM
          },
          /* @__PURE__ */ import_react.default.createElement(ResponseBodyEntry, { key: index }, /* @__PURE__ */ import_react.default.createElement(import_result_content.ResultContentViewer, { resultItem: entry.response })),
          /* @__PURE__ */ import_react.default.createElement(
            import_results_footer.ResultsFooter,
            {
              actions: getResultActions(entry),
              entry,
              zIndex,
              modalRef
            }
          )
        );
      }
      default: {
        throw (0, import_uncreachable.unreachable)(entry);
      }
    }
  }), isLoading && /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", paddingTop: "SP2" }, /* @__PURE__ */ import_react.default.createElement(ResponseBodyEntry, null, /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", paddingBottom: "SP3" }, /* @__PURE__ */ import_react.default.createElement(import_text_cursor.TextCursor, null)))));
};
const ResponseBodyEntry = ({ children }) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  return /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", paddingLeft: "SP4", paddingRight: "SP4", gap: "SP1" }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { verticalAlign: "middle" }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Text, { size: "small", weight: "bold", tagName: "h6", className: import_feed_scss.default.label }, t("AIPlugin_FeedLabel_Assistant")), /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { color: "B10" }, /* @__PURE__ */ import_react.default.createElement(import_wix_ui_icons_common.SparklesFilledSmall, null))), children);
};
//# sourceMappingURL=feed.js.map
