"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var collapsible_list_testkit_exports = {};
__export(collapsible_list_testkit_exports, {
  createCollapsibleListTestkit: () => createCollapsibleListTestkit
});
module.exports = __toCommonJS(collapsible_list_testkit_exports);
var import_unidriver = require("@wix/design-system/dist/testkit/unidriver.js");
var import_ricos_types = require("./../../ricos-types/index.js");
var import_data_hooks = require("./../../_shared/data-hooks.js");
var import_wix_rich_content_common = require("./../../wix-rich-content-common/index.js");
var import_data_hooks2 = require("../data-hooks.js");
var import_get_add_buttons = require("../get-add-buttons.js");
var import_collapsible_list_item_uni_driver = require("./collapsible-list-item.uni.driver.js");
const createCollapsibleListTestkit = (getBase) => {
  const getCollapsibleList = async (index, options) => {
    const collapsibleList = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT), options);
    return collapsibleList.at(index);
  };
  const getSettingsModal = async () => await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_MODAL));
  const getModalBase = () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_MODAL));
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const collapsibleList = await getCollapsibleList(index, options);
              return collapsibleList.exists();
            } catch {
              return false;
            }
          },
          getItemsCount: async () => {
            const collapsibleList = await getCollapsibleList(index);
            const listItems = await collapsibleList.getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.COLLAPSIBLE_LIST_ITEM));
            return listItems.count();
          },
          getExpandedListItemsCount: async () => {
            const collapsibleList = await getCollapsibleList(index);
            const listItems = await collapsibleList.$$(
              (0, import_wix_rich_content_common.dataHook)([import_data_hooks2.COLLAPSIBLE_LIST_ITEM, "expanded"])
            );
            return listItems.count();
          },
          addNewItem: async () => {
            const collapsibleList = await getCollapsibleList(index);
            const addNewItemButton = await collapsibleList.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.NEW_PAIR_BUTTON));
            await addNewItemButton.click();
          },
          addNewItemButtonExists: async () => {
            try {
              const collapsibleList = await getCollapsibleList(index);
              const button = await collapsibleList.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.NEW_PAIR_BUTTON));
              return button.exists();
            } catch {
              return false;
            }
          },
          listItem: (0, import_collapsible_list_item_uni_driver.createCollapsibleListItemUniDriver)(getBase)
        };
      }
    },
    toolbar: {},
    modal: {
      exists: async () => {
        try {
          const settingsModal = await getSettingsModal();
          return settingsModal.exists();
        } catch {
          return false;
        }
      },
      initialExpandedItems: {
        allOption: (0, import_unidriver.RadioUniDriver)(
          getModalBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_INITIAL_EXPANDED_ALL)),
          getBase()
        ),
        firstOption: (0, import_unidriver.RadioUniDriver)(
          getModalBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_INITIAL_EXPANDED_FIRST)),
          getBase()
        ),
        noneOption: (0, import_unidriver.RadioUniDriver)(
          getModalBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_INITIAL_EXPANDED_NONE)),
          getBase()
        )
      },
      expandOnlyOneToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getModalBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_EXPAND_ONLY_ONE_TOGGLE)),
        getBase()
      )
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          const collapsibleListButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_COLLAPSIBLE_LIST_BUTTON)
          );
          await collapsibleListButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        clickEdit: async () => {
          const editButton = await getPluginToolbarBase(
            import_ricos_types.RicosPluginToolbarNames.COLLAPSIBLE_LIST
          ).get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON), {
            timeout: 5e3
          });
          return editButton.click();
        },
        clickDelete: async () => {
          const deleteButton = await getPluginToolbarBase(
            import_ricos_types.RicosPluginToolbarNames.COLLAPSIBLE_LIST
          ).get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON), {
            timeout: 5e3
          });
          return deleteButton.click();
        },
        exists: async () => {
          try {
            const pluginToolbar = await getPluginToolbarBase(
              import_ricos_types.RicosPluginToolbarNames.COLLAPSIBLE_LIST
            );
            return pluginToolbar.exists();
          } catch {
            return false;
          }
        }
      })
    }
  };
};
//# sourceMappingURL=collapsible-list.testkit.js.map
