"use strict";

exports.__esModule = true;
exports.ImportModalUniDriver = ImportModalUniDriver;
exports.default = void 0;
var _unidriver = require("@wix/wix-ui-test-utils/unidriver");
var _unidriver2 = require("../../unidriver");
var _unidriver3 = require("@wix/design-system/dist/testkit/unidriver");
function ImportModalUniDriver(base, body) {
  const modalBase = () => body.$('.portal-import-modal');
  const modalLayoutBase = () => body.$('[data-hook="import-modal-layout"]');
  const footerBase = () => modalLayoutBase().$('[data-hook="import-modal-footer-text"]');
  const getModal = () => (0, _unidriver3.ModalUniDriver)(modalBase(), modalBase());
  const getModalLayout = () => (0, _unidriver3.CustomModalLayoutUniDriver)(modalLayoutBase(), body);
  const getFooterText = async () => (await (0, _unidriver3.TextUniDriver)(footerBase(), body)).getText();
  const footerExists = () => footerBase().exists();
  const fileInputBase = () => modalLayoutBase().$('[data-hook="import-file-input"]');
  const configurationStepBase = () => modalLayoutBase().$('[data-hook="import-mapping-step"]');
  const summaryStepBase = () => modalLayoutBase().$('[data-hook="import-summary-step"]');
  const progressLabelBase = () => modalLayoutBase().$('[data-hook="import-progress-label"]');
  return {
    wait: timeout => base.wait(timeout),
    ...(0, _unidriver2.baseUniDriverFactory)(base),
    getModal,
    getModalLayout,
    waitModalClosed: timeout => (0, _unidriver.waitFor)(async () => !(await getModalLayout().exists()), timeout),
    clickPrimaryAction: async () => (await getModalLayout().getPrimaryButtonDriver()).click(),
    getPrimaryActionText: async () => (await getModalLayout().getPrimaryButtonDriver()).getButtonTextContent(),
    isPrimaryButtonDisabled: async () => (await getModalLayout().getPrimaryButtonDriver()).isButtonDisabled(),
    getSecondaryButtonText: async () => (await getModalLayout().getSecondaryButtonDriver()).getButtonTextContent(),
    clickSecondaryAction: async () => (await getModalLayout().getSecondaryButtonDriver()).click(),
    clickCloseButton: () => getModalLayout().clickCloseButton(),
    getModalTitle: () => getModalLayout().getTitleText(),
    getSubtitleText: () => getModalLayout().getSubtitleText(),
    getFooterText,
    footerExists,
    isUploadStepVisible: () => fileInputBase().exists(),
    isConfigurationStepVisible: () => configurationStepBase().exists(),
    isSummaryStepVisible: () => summaryStepBase().exists(),
    /** Simulates selecting a file in the upload step */
    uploadFile: async file => {
      const nativeInput = await fileInputBase().$('input[type="file"]').getNative();
      Object.defineProperty(nativeInput, 'files', {
        value: [file]
      });
      nativeInput.dispatchEvent(new Event('change', {
        bubbles: true
      }));
    },
    noRowsWarningExists: () => modalLayoutBase().$('[data-hook="import-no-rows-warning"]').exists(),
    getProgressLabel: () => progressLabelBase().text(),
    progressLabelExists: () => progressLabelBase().exists(),
    getPartialErrorText: () => modalLayoutBase().$('[data-hook="import-partial-error"]').text(),
    partialErrorExists: () => modalLayoutBase().$('[data-hook="import-partial-error"]').exists(),
    getErrorMessageText: () => modalLayoutBase().$('[data-hook="import-error-message"]').text(),
    errorMessageExists: () => modalLayoutBase().$('[data-hook="import-error-message"]').exists(),
    /** Get the CounterBadge driver for the columns found counter */
    getColumnsFoundCounter: () => (0, _unidriver3.CounterBadgeUniDriver)(modalLayoutBase().$('[data-hook="import-columns-found-counter"]'), body),
    /** Get the Dropdown driver for a specific CSV header mapping */
    getMappingDropdown: header => (0, _unidriver3.DropdownUniDriver)(modalLayoutBase().$(`[data-hook="import-mapping-${header}"]`), body),
    /** Get the discard changes confirmation modal driver */
    getDiscardChangesModal: () => (0, _unidriver3.MessageModalLayoutUniDriver)(body.$('[data-hook="import-discard-changes-modal"]'), body)
  };
}
var _default = exports.default = ImportModalUniDriver;
//# sourceMappingURL=ImportModal.uni.driver.js.map