"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 spoiler_container_exports = {};
__export(spoiler_container_exports, {
  SpoilerContainer: () => SpoilerContainer
});
module.exports = __toCommonJS(spoiler_container_exports);
var import_classnames = __toESM(require("classnames"));
var import_prop_types = __toESM(require("prop-types"));
var import_react = __toESM(require("react"));
var import_data_hooks = require("./../../_shared/data-hooks.js");
var import_tooltip = require("./../../wix-rich-content-common/lib/tooltip.js");
var import_spoiler_container_icon = require("../icons/spoiler-container-icon.js");
var import_reveal_button = require("./reveal-button.js");
var import_spoiler_description_input = require("./spoiler-description-input.js");
class SpoilerContainer extends import_react.default.Component {
  constructor() {
    super(...arguments);
    this.getReducedContainer = (className) => {
      const { onRevealSpoiler, pluginType, t } = this.props;
      const disabledRevealBtn = !onRevealSpoiler;
      const container = /* @__PURE__ */ import_react.default.createElement(
        import_spoiler_container_icon.SpoilerContainerIcon,
        {
          className,
          style: { cursor: !disabledRevealBtn ? "pointer" : "auto", display: "inline" },
          onClick: onRevealSpoiler,
          "data-hook": import_data_hooks.REVEAL_SPOILER_BTN
        }
      );
      return disabledRevealBtn ? container : /* @__PURE__ */ import_react.default.createElement(import_tooltip.Tooltip, { content: t(`Spoiler_Reveal_${pluginType}_CTA`), hideArrow: true }, container);
    };
    this.getExpandedContainer = (containerClassName) => {
      const {
        description,
        buttonContent,
        pluginType,
        onRevealSpoiler,
        styles,
        setInPluginEditingMode,
        setFocusToBlock,
        handleButtonContentChange,
        isMobile,
        t
      } = this.props;
      const disabledRevealBtn = !onRevealSpoiler;
      const content = buttonContent ?? t(`Spoiler_Reveal_${pluginType}_CTA`);
      const buttonClassName = (0, import_classnames.default)(styles.revealSpoilerBtn, {
        [styles.revealSpoilerBtnMobile]: isMobile,
        [styles.onHoverBtn]: !disabledRevealBtn
      });
      return /* @__PURE__ */ import_react.default.createElement("div", { className: containerClassName, style: { width: "100%" } }, /* @__PURE__ */ import_react.default.createElement(
        import_spoiler_container_icon.SpoilerContainerIcon,
        {
          style: { cursor: !disabledRevealBtn ? "pointer" : "auto", display: "inline" },
          onClick: onRevealSpoiler
        }
      ), this.renderDescription(description), /* @__PURE__ */ import_react.default.createElement(
        import_reveal_button.RevealButton,
        {
          onRevealSpoiler,
          className: buttonClassName,
          value: content,
          onChange: handleButtonContentChange,
          setInPluginEditingMode,
          setFocusToBlock
        }
      ));
    };
  }
  renderDescription(description) {
    const {
      setInPluginEditingMode,
      pluginType,
      styles,
      handleDescriptionChange,
      setFocusToBlock,
      t
    } = this.props;
    return /* @__PURE__ */ import_react.default.createElement(
      import_spoiler_description_input.SpoilerDescriptionInput,
      {
        setInPluginEditingMode,
        className: styles.spoilerDescription,
        value: description ?? t(`Spoiler_Reveal_${pluginType}_Placeholder`),
        onChange: handleDescriptionChange,
        setFocusToBlock
      }
    );
  }
  render() {
    const { pluginType, width, height, styles } = this.props;
    const containerClassName = pluginType === "Gallery" ? styles.spoilerContainer_Gallery : styles.spoilerContainer;
    const spoilerContainer = width < 320 || height < 228 ? this.getReducedContainer(containerClassName) : this.getExpandedContainer(containerClassName);
    return spoilerContainer;
  }
}
SpoilerContainer.propTypes = {
  description: import_prop_types.default.string,
  buttonContent: import_prop_types.default.string,
  styles: import_prop_types.default.object,
  pluginType: import_prop_types.default.string,
  onRevealSpoiler: import_prop_types.default.func,
  setFocusToBlock: import_prop_types.default.func,
  setInPluginEditingMode: import_prop_types.default.func,
  width: import_prop_types.default.number,
  height: import_prop_types.default.number,
  handleDescriptionChange: import_prop_types.default.func,
  handleButtonContentChange: import_prop_types.default.func,
  t: import_prop_types.default.func,
  isMobile: import_prop_types.default.bool
};
//# sourceMappingURL=spoiler-container.js.map
