"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.baseModalLayoutDriverFactory = void 0;
var _ButtonLegacy = _interopRequireDefault(require("../Button/Button.legacy.driver"));
var _constants = require("./constants");
var _testUtils = require("../utils/test-utils");
var _testUtils2 = _interopRequireDefault(require("react-dom/test-utils"));
var _Tooltip = require("../Tooltip/Tooltip.driver");
var fDataHooks = (0, _testUtils.getFormattedDataHooks)(_constants.dataHooks);
var baseModalLayoutDriverFactory = _ref => {
  var {
    element,
    eventTrigger
  } = _ref;
  var getButtonDriver = dataHook => (0, _ButtonLegacy.default)({
    element: element.querySelector("[data-hook-internal=\"".concat(dataHook, "\"]"))
  });
  var tooltipTestkit = (0, _Tooltip.tooltipLegacyDriverFactory)({
    element: element.querySelector(fDataHooks.primaryButtonTooltip),
    eventTrigger
  });
  return {
    exists: () => !!element,
    _hasClass: className => (0, _testUtils.isClassExists)(element, className),
    _closeButtonExists: () => !!element.querySelector(fDataHooks.closeButton),
    _helpButtonExists: () => !!element.querySelector(fDataHooks.helpButton),
    /** Returns the modal theme */
    getTheme: () => element.getAttribute('data-theme'),
    /** Click the modal close-button */
    clickCloseButton: () => _testUtils2.default.Simulate.click(element.querySelector(fDataHooks.closeButton)),
    clickHelpButton: () => _testUtils2.default.Simulate.click(element.querySelector(fDataHooks.helpButton)),
    /** Checks that a node with the provided dataHook exists */
    childExists: dataHook => !!element.querySelector("[data-hook=\"".concat(dataHook, "\"]")) || !!element.querySelector("[data-hook-internal=\"".concat(dataHook, "\"]")),
    /** Get the title's text */
    getTitleText: () => element.querySelector(fDataHooks.headerTitle).textContent,
    /** Get the subtitle's text */
    getSubtitleText: () => element.querySelector(fDataHooks.headerSubtitle).textContent,
    /** Return the secondary button driver*/
    secondaryButtonDriver: getButtonDriver(_constants.dataHooks.footerSecondaryButton),
    /**
     * @deprecated use secondaryButtonDriver
     * Return the secondary button driver*/
    getSecondaryButtonDriver: () => getButtonDriver(_constants.dataHooks.footerSecondaryButton),
    /** Return the primary button driver */
    primaryButtonDriver: getButtonDriver(_constants.dataHooks.footerPrimaryButton),
    /**
     * @deprecated use primaryButtonDriver
     * Return the primary button driver */
    getPrimaryButtonDriver: () => getButtonDriver(_constants.dataHooks.footerPrimaryButton),
    /** Return the primary button tooltip's content */
    getPrimaryButtonTooltipContent: () => tooltipTestkit.getTooltipText(),
    getIllustrationSrc: () => element.querySelector(fDataHooks.illustrationSrc).getAttribute('src')
  };
};
exports.baseModalLayoutDriverFactory = baseModalLayoutDriverFactory;
//# sourceMappingURL=BaseModalLayout.legacy.driver.js.map