"use strict";

exports.__esModule = true;
exports.PickerModalLayoutUniDriver = PickerModalLayoutUniDriver;
var _unidriver = require("@wix/design-system/dist/testkit/unidriver");
var _unidriver2 = require("../../unidriver");
var _unidriver3 = require("@wix/wix-ui-test-utils/unidriver");
function PickerModalLayoutUniDriver(base, body) {
  const modal = (0, _unidriver.CustomModalLayoutUniDriver)(base, body);
  const getInitialLoader = () => base.$('[data-hook="splash-loader"]');
  const getSearch = () => (0, _unidriver.SearchUniDriver)(base.$('[data-hook="collection-search"]'), body);
  const customNotificationExists = () => {
    return base.$('[data-hook="custom-notification"]').exists();
  };
  const getCustomContentButton = () => (0, _unidriver.TextButtonUniDriver)(base.$('[data-hook="custom-content-button"]'), body);
  const getBackButton = () => (0, _unidriver.TextButtonUniDriver)(base.$('[data-hook="back-button"]'), body);
  const getMaxSelectionLabel = () => base.$('[data-hook="selection-max-label"]');
  const getFilterDropdown = filterName => (0, _unidriver.DropdownUniDriver)(base.$(`[data-hook="collection-filter-${filterName}"]`), body);
  return {
    ...(0, _unidriver2.baseUniDriverFactory)(base),
    waitInitialLoader: timeout => getInitialLoader().wait(timeout),
    waitInitialLoaderRemoved: timeout => (0, _unidriver3.waitFor)(async () => !(await getInitialLoader().exists()), timeout),
    ctaButtonExists: async () => (await modal.getPrimaryButtonDriver()).exists(),
    clickCTAButton: async () => (await modal.getPrimaryButtonDriver()).click(),
    clickBackButton: async () => getBackButton().click(),
    backButtonExists: () => getBackButton().exists(),
    clickCancelButton: async () => (await modal.getSecondaryButtonDriver()).click(),
    getCancelButtonText: async () => (await modal.getSecondaryButtonDriver()).getButtonTextContent(),
    cancelButtonExists: async () => (await modal.getSecondaryButtonDriver()).exists(),
    clickCloseButton: () => modal.clickCloseButton(),
    customContentButtonExists: () => getCustomContentButton().exists(),
    getCustomContentButtonText: () => getCustomContentButton().getButtonTextContent(),
    isCustomContentButtonDisabled: () => getCustomContentButton().isButtonDisabled(),
    getCustomContentButtonTooltipText: () => (0, _unidriver.TooltipUniDriver)(base.$('[data-hook="custom-content-button-tooltip"]'), body).getTooltipText(),
    customContentButtonTooltipExists: () => (0, _unidriver.TooltipUniDriver)(base.$('[data-hook="custom-content-button-tooltip"]'), body).exists(),
    clickCustomContentButton: () => getCustomContentButton().click(),
    getMaxSelectionLabelText: () => getMaxSelectionLabel().text(),
    getCTAButtonText: async () => (await modal.getPrimaryButtonDriver()).getButtonTextContent(),
    isCTAButtonDisabled: async () => (await modal.getPrimaryButtonDriver()).isButtonDisabled(),
    getTitleText: () => modal.getTitleText(),
    getSubtitleText: () => modal.getSubtitleText(),
    enterSearchTerm: value => getSearch().inputDriver.enterText(value),
    clearSearchTerm: () => getSearch().inputDriver.clearText(),
    getSearchTerm: () => getSearch().inputDriver.getText(),
    getSearchPlaceholder: () => getSearch().inputDriver.getPlaceholder(),
    searchExists: () => getSearch().inputDriver.exists(),
    initialLoaderExists: () => getInitialLoader().exists(),
    customNotificationExists,
    getErrorStateByDataHook: dataHook => (0, _unidriver.EmptyStateUniDriver)(base.$('[data-hook="splash-error-container"]').$(`[data-hook="${dataHook}"]`), body),
    getSelectAllCheckbox: () => (0, _unidriver.CheckboxUniDriver)(base.$('[data-hook="picker-select-all-checkbox"]'), body),
    getSelectedItemsCountText: () => (0, _unidriver.TextUniDriver)(base.$('[data-hook="cairo-selected-items-count"]'), body),
    getFilterDropdown,
    filterDropdownExists: async filterName => getFilterDropdown(filterName).exists(),
    getSelectedFilterName: async filterName => getFilterDropdown(filterName).inputDriver.getText(),
    selectFilterItem: async (filterName, index) => getFilterDropdown(filterName).dropdownLayoutDriver.clickAtOption(index),
    selectFilterItems: async (filterName, ids) => {
      for (const id of ids) {
        await getFilterDropdown(filterName).dropdownLayoutDriver.clickAtOptionByDataHook(`dropdown-item-${id}`);
      }
    }
  };
}
//# sourceMappingURL=PickerModalLayout.uni.driver.js.map