"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 layout_settings_section_exports = {};
__export(layout_settings_section_exports, {
  LayoutSettingsSection: () => LayoutSettingsSection
});
module.exports = __toCommonJS(layout_settings_section_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_next_schema = require("./../../../ricos-schema/next-schema/index.js");
var import_log_invariant = require("./../../../_shared/log-invariant.js");
var import_use_node_attrs = require("./../../../_shared/use-node-attrs.js");
var import_plugin_commons = require("./../../../plugin-commons/index.js");
var import_ui_components = require("./../../../ui-components/index.js");
var import_layout_grid_icon = require("../../assets/icons/layout-grid-icon.js");
var import_layout_list_icon = require("../../assets/icons/layout-list-icon.js");
var import_data_hooks = require("../../data-hooks.js");
var import_section = require("./section.js");
const LayoutSettingsSection = ({ nodeId, logBi }) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const zIndexService = (0, import_react.useContext)(import_ricos_context.ZIndexContext);
  const { pmNodeAttrs, patchPmNodeAttrs } = (0, import_use_node_attrs.useNodeAttrs)(nodeId, "POLL");
  const containerEl = (0, import_ui_components.usePanelContainerElement)();
  if (!pmNodeAttrs) {
    (0, import_log_invariant.logInvariant)(Error("Poll settings: node attrs not found"));
    return null;
  }
  const { poll, options } = pmNodeAttrs.layout ?? {};
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_section.Section, { title: t("Poll_PollSettings_Tab_Layout_Section_Question_Header") }, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      checked: Boolean(poll?.enableImage),
      title: t("Poll_PollSettings_Tab_Layout_Section_Question_Image"),
      dataHook: import_data_hooks.LAYOUT_SETTINGS_IMAGE_TO_QUESTION_TOGGLE,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.LAYOUT_SETTINGS_IMAGE_TO_QUESTION_TOGGLE,
          value: !poll?.enableImage
        });
        patchPmNodeAttrs({
          layout: { ...pmNodeAttrs.layout, poll: { ...poll, enableImage: !poll?.enableImage } }
        });
      },
      size: "small"
    }
  )), /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { marginInline: "-18px" }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Divider, null)), /* @__PURE__ */ import_react.default.createElement(import_section.Section, { title: t("Poll_PollSettings_Tab_Layout_Section_Answers_Header") }, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ThumbnailPicker,
    {
      dataHook: import_data_hooks.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL_PICKER,
      logBi,
      dataSource: [
        {
          dataHook: import_data_hooks.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL + import_next_schema.PollData_Layout_PollLayout_Type.LIST,
          value: import_next_schema.PollData_Layout_PollLayout_Type.LIST,
          label: t("Poll_PollSettings_Tab_Layout_Section_Answers_Layout_List"),
          renderBackgroundImage: (props) => /* @__PURE__ */ import_react.default.createElement(import_layout_list_icon.LayoutListIcon, { ...props })
        },
        {
          dataHook: import_data_hooks.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL + import_next_schema.PollData_Layout_PollLayout_Type.GRID,
          value: import_next_schema.PollData_Layout_PollLayout_Type.GRID,
          label: t("Poll_PollSettings_Tab_Layout_Section_Answers_Layout_Grid"),
          renderBackgroundImage: (props) => /* @__PURE__ */ import_react.default.createElement(import_layout_grid_icon.LayoutGridIcon, { ...props })
        }
      ],
      selectedValue: poll?.type ?? import_next_schema.PollData_Layout_PollLayout_Type.LIST,
      title: t("Poll_PollSettings_Tab_Layout_Section_Answers_Layout"),
      onChange: (type) => {
        patchPmNodeAttrs({
          layout: {
            ...pmNodeAttrs.layout,
            poll: { ...poll, type }
          }
        });
        window.dispatchEvent(new Event("resize"));
      }
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ToggleButton,
    {
      checked: Boolean(options?.enableImage),
      title: t("Poll_PollSettings_Tab_Layout_Section_Answers_Image"),
      dataHook: import_data_hooks.LAYOUT_SETTINGS_IMAGE_TO_ANSWERS_TOGGLE,
      onChange: () => {
        logBi({
          dataHook: import_data_hooks.LAYOUT_SETTINGS_IMAGE_TO_ANSWERS_TOGGLE,
          value: !options?.enableImage
        });
        patchPmNodeAttrs({
          layout: {
            ...pmNodeAttrs.layout,
            options: { ...options, enableImage: !options?.enableImage }
          }
        });
      },
      size: "small"
    }
  )), /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { marginInline: "-18px" }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Divider, null)), /* @__PURE__ */ import_react.default.createElement(
    import_section.Section,
    {
      title: /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, t("Poll_PollSettings_Tab_Layout_Section_TextDirection_Header"), " ", /* @__PURE__ */ import_react.default.createElement(
        import_design_system.InfoIcon,
        {
          content: t("Poll_PollSettings_Tab_Layout_Section_TextDirection_Header_Tooltip"),
          size: "small",
          tooltipProps: {
            appendTo: containerEl,
            zIndex: zIndexService.getZIndex("TOOLTIP")
          }
        }
      ))
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_design_system.FormField,
      {
        label: t("CollapsibleList_CollapsibleListSettings_Tab_Settings_Direction_Title")
      },
      /* @__PURE__ */ import_react.default.createElement(import_design_system.Box, { marginTop: "SP1" }),
      /* @__PURE__ */ import_react.default.createElement(
        import_design_system.SegmentedToggle,
        {
          size: "small",
          selected: pmNodeAttrs.layout?.poll?.direction,
          defaultSelected: pmNodeAttrs.layout?.poll?.direction,
          onClick: (_, direction) => {
            logBi({
              dataHook: import_data_hooks.LAYOUT_SETTINGS_DIRECTION_TOGGLE,
              value: direction
            });
            patchPmNodeAttrs({
              layout: {
                ...pmNodeAttrs.layout,
                poll: { ...poll, direction }
              }
            });
          },
          dataHook: import_data_hooks.LAYOUT_SETTINGS_DIRECTION_TOGGLE
        },
        /* @__PURE__ */ import_react.default.createElement(
          import_design_system.SegmentedToggle.Button,
          {
            key: import_next_schema.PollData_Layout_PollLayout_Direction.LTR,
            value: import_next_schema.PollData_Layout_PollLayout_Direction.LTR,
            size: "small",
            prefixIcon: /* @__PURE__ */ import_react.default.createElement(import_plugin_commons.LTRIcon, null)
          },
          t("Poll_PollSettings_Tab_Layout_Section_TextDirection_LTR")
        ),
        /* @__PURE__ */ import_react.default.createElement(
          import_design_system.SegmentedToggle.Button,
          {
            key: import_next_schema.PollData_Layout_PollLayout_Direction.RTL,
            value: import_next_schema.PollData_Layout_PollLayout_Direction.RTL,
            size: "small",
            prefixIcon: /* @__PURE__ */ import_react.default.createElement(import_plugin_commons.RTLIcon, null)
          },
          t("Poll_PollSettings_Tab_Layout_Section_TextDirection_RTL")
        )
      )
    )
  ));
};
//# sourceMappingURL=layout-settings-section.js.map
