"use strict";

exports.__esModule = true;
exports.floatingHelperContentDriverFactory = void 0;
var _constants = require("./constants");
var floatingHelperContentDriverFactory = _ref => {
  var {
    element,
    eventTrigger
  } = _ref;
  var getElementByDataHook = dataHook => element.querySelector("[data-hook='".concat(dataHook, "']"));
  var title = () => getElementByDataHook(_constants.dataHooks.title);
  var body = () => getElementByDataHook(_constants.dataHooks.body);
  var image = () => getElementByDataHook(_constants.dataHooks.image);
  var actionButton = () => getElementByDataHook(_constants.dataHooks.actionButton);
  var footer = () => getElementByDataHook(_constants.dataHooks.footer);
  return {
    /** checks if the element exists */
    exists: () => !!element,
    /** checks if title exists */
    hasTitle: () => !!title(),
    /** checks if text content exists */
    hasBody: () => !!body(),
    /** checks if the action button exists */
    hasActionButton: () => !!actionButton(),
    /** checks if the footer exists */
    hasFooter: () => !!footer(),
    /** checks if an image exists */
    hasImage: () => !!image(),
    /** Get image HTML element*/
    getImage: () => image() && image().childNodes[0] /* as HTMLElement*/,

    /** Get footer HTML element*/
    getFooter: () => footer() && footer().childNodes[0] /* as HTMLElement*/,

    /** Get the text content of the title */
    getTitleContent: () => title().textContent,
    /** Get the text content of the helper's text */
    getBodyContent: () => body().textContent,
    /** Get text of action button */
    getActionButtonText: () => actionButton().textContent,
    /** naive way to check for stylable class */
    matchesActionButtonClassName: className => !!Array.from(actionButton().classList).find(c => c.includes(className)),
    /** click on the action button */
    clickActionButton: () => eventTrigger.click(actionButton()),
    /** Returns direction property value */
    getDirection: () => element.getAttribute('data-direction')
  };
};
exports.floatingHelperContentDriverFactory = floatingHelperContentDriverFactory;
//# sourceMappingURL=FloatingHelperContent.driver.js.map