"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 settings_tab_exports = {};
__export(settings_tab_exports, {
  SettingsTab: () => SettingsTab
});
module.exports = __toCommonJS(settings_tab_exports);
var import_design_system = require("@wix/design-system");
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../ricos-context/index.js");
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_bi_context_provider = require("./../../_shared/bi-context-provider/bi-context-provider.js");
var import_ui_components = require("./../../ui-components/index.js");
var import_constants = require("../constants.js");
var import_data_hooks = require("../data-hooks.js");
const getDefaultButtonText = (embedType, t) => {
  switch (embedType) {
    case import_v1.AppEmbedData_AppType.PRODUCT:
      return t("VerticalEmbed_Products_Button");
    case import_v1.AppEmbedData_AppType.EVENT:
      return t("VerticalEmbed_Events_Button");
    case import_v1.AppEmbedData_AppType.BOOKING:
      return t("VerticalEmbed_Bookings_Button");
    default:
      return t("VerticalEmbed_Products_Button");
  }
};
const SettingsTab = ({ pmNodeAttrs, patchPmNodeAttrs }) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const logBi = (0, import_bi_context_provider.useBiNext)({
    modalId: import_constants.verticalEmbedModals.settings,
    pluginId: "verticalEmbed",
    nodeId: pmNodeAttrs?.id
  });
  const isProductEmbed = pmNodeAttrs?.type === import_v1.AppEmbedData_AppType.PRODUCT;
  const isEventEmbed = pmNodeAttrs?.type === import_v1.AppEmbedData_AppType.EVENT;
  const isBookingEmbed = pmNodeAttrs?.type === import_v1.AppEmbedData_AppType.BOOKING;
  return /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { direction: "vertical", gap: "SP2", padding: "SP3", overflow: "auto" }, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Image"),
      checked: !pmNodeAttrs?.hideImage,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_IMAGE_TOGGLE,
          value: !pmNodeAttrs?.hideImage
        });
        patchPmNodeAttrs({
          hideImage: !pmNodeAttrs?.hideImage
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_IMAGE_TOGGLE,
      size: "small"
    }
  ), isProductEmbed && /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Price"),
      checked: !pmNodeAttrs?.hidePrice,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
          value: !pmNodeAttrs?.hidePrice
        });
        patchPmNodeAttrs({
          hidePrice: !pmNodeAttrs?.hidePrice
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
      size: "small"
    }
  ), isEventEmbed && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Price"),
      checked: !pmNodeAttrs?.hidePrice,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
          value: !pmNodeAttrs?.hidePrice
        });
        patchPmNodeAttrs({
          hidePrice: !pmNodeAttrs?.hidePrice
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
      size: "small"
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_DateTime"),
      checked: !pmNodeAttrs?.hideDateTime,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_DATETIME_TOGGLE,
          value: !pmNodeAttrs?.hideDateTime
        });
        patchPmNodeAttrs({
          hideDateTime: !pmNodeAttrs?.hideDateTime
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_DATETIME_TOGGLE,
      size: "small"
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Location"),
      checked: !pmNodeAttrs?.hideLocation,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_LOCATION_TOGGLE,
          value: !pmNodeAttrs?.hideLocation
        });
        patchPmNodeAttrs({
          hideLocation: !pmNodeAttrs?.hideLocation
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_LOCATION_TOGGLE,
      size: "small"
    }
  )), isBookingEmbed && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Price"),
      checked: !pmNodeAttrs?.hidePrice,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
          value: !pmNodeAttrs?.hidePrice
        });
        patchPmNodeAttrs({
          hidePrice: !pmNodeAttrs?.hidePrice
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_PRICE_TOGGLE,
      size: "small"
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Duration"),
      checked: !pmNodeAttrs?.hideDuration,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_DURATION_TOGGLE,
          value: !pmNodeAttrs?.hideDuration
        });
        patchPmNodeAttrs({
          hideDuration: !pmNodeAttrs?.hideDuration
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_DURATION_TOGGLE,
      size: "small"
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Location"),
      checked: !pmNodeAttrs?.hideLocation,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_LOCATION_TOGGLE,
          value: !pmNodeAttrs?.hideLocation
        });
        patchPmNodeAttrs({
          hideLocation: !pmNodeAttrs?.hideLocation
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_LOCATION_TOGGLE,
      size: "small"
    }
  )), /* @__PURE__ */ import_react.default.createElement(import_design_system.Divider, null), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Button"),
      checked: !pmNodeAttrs?.hideButton,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_BUTTON_TOGGLE,
          value: !pmNodeAttrs?.hideButton
        });
        patchPmNodeAttrs({
          hideButton: !pmNodeAttrs?.hideButton
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_BUTTON_TOGGLE,
      size: "small"
    }
  ), !pmNodeAttrs?.hideButton && /* @__PURE__ */ import_react.default.createElement(import_design_system.FormField, { label: t("Embed_Vertical_Settings_Button_Text") }, /* @__PURE__ */ import_react.default.createElement(
    import_design_system.Input,
    {
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_BUTTON_TEXT_INPUT,
      type: "text",
      maxLength: import_constants.MAX_BUTTON_TEXT_LENGTH,
      value: pmNodeAttrs?.buttonStyles?.buttonText ?? getDefaultButtonText(pmNodeAttrs?.type, t),
      onChange: (e) => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_BUTTON_TEXT_INPUT,
          value: e.target.value
        });
        patchPmNodeAttrs({
          buttonStyles: {
            ...pmNodeAttrs?.buttonStyles,
            buttonText: e.target.value
          }
        });
      },
      onBlur: (e) => {
        if (e.target.value === "") {
          const defaultText = getDefaultButtonText(
            pmNodeAttrs?.type,
            t
          );
          patchPmNodeAttrs({
            buttonStyles: {
              ...pmNodeAttrs?.buttonStyles,
              buttonText: defaultText
            }
          });
        }
      },
      size: "small",
      textOverflow: "ellipsis"
    }
  )), /* @__PURE__ */ import_react.default.createElement(import_design_system.Divider, null), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      title: t("Embed_Vertical_Settings_Show_Ribbon"),
      checked: !(pmNodeAttrs?.hideRibbon ?? true),
      onChange: () => {
        const currentHideRibbon = pmNodeAttrs?.hideRibbon ?? true;
        const newHideRibbon = !currentHideRibbon;
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_RIBBON_TOGGLE,
          value: !newHideRibbon
        });
        patchPmNodeAttrs({
          hideRibbon: newHideRibbon
        });
      },
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_RIBBON_TOGGLE,
      size: "small"
    }
  ), !(pmNodeAttrs?.hideRibbon ?? true) && /* @__PURE__ */ import_react.default.createElement(import_design_system.FormField, { label: t("Embed_Vertical_Settings_Ribbon_Text") }, /* @__PURE__ */ import_react.default.createElement(
    import_design_system.Input,
    {
      dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_RIBBON_TEXT_INPUT,
      type: "text",
      maxLength: import_constants.MAX_RIBBON_TEXT_LENGTH,
      value: pmNodeAttrs?.ribbonStyles?.ribbonText ?? t("VerticalEmbed_Ribbon"),
      onChange: (e) => {
        logBi({
          dataHook: import_data_hooks.SETTINGS_VERTICAL_EMBED_RIBBON_TEXT_INPUT,
          value: e.target.value
        });
        patchPmNodeAttrs({
          ribbonStyles: {
            ...pmNodeAttrs?.ribbonStyles,
            ribbonText: e.target.value
          }
        });
      },
      onBlur: (e) => {
        if (e.target.value === "") {
          const defaultText = t("VerticalEmbed_Ribbon");
          patchPmNodeAttrs({
            ribbonStyles: {
              ...pmNodeAttrs?.ribbonStyles,
              ribbonText: defaultText
            }
          });
        }
      },
      size: "small",
      textOverflow: "ellipsis"
    }
  )));
};
//# sourceMappingURL=settings-tab.js.map
