"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.carouselDriverFactory = void 0;
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
var carouselDriverFactory = _ref => {
  var {
    element
  } = _ref;
  // Embla carousel doesn't duplicate slides like react-slick, so we can use simpler selectors
  var slideSelector = '.embla__slide';
  return {
    exists: () => !!element,
    isLoading: () => {
      var loader = element.querySelector('[data-hook="loader"]');
      return !!loader;
    },
    getChildren: () => element.querySelectorAll(slideSelector),
    getImages: () => {
      // Converting the result from NodeList to a real array
      return Array.from(element.querySelectorAll(slideSelector + ' [data-hook="carousel-img"]')).map(img => img.src);
    },
    clickPrevious: () => {
      var prevButton = element.querySelector('[data-hook="prev-button-element"]');
      if (prevButton) {
        _testUtils.default.Simulate.click(prevButton);
      }
    },
    clickNext: () => {
      var nextButton = element.querySelector('[data-hook="next-button-element"]');
      if (nextButton) {
        _testUtils.default.Simulate.click(nextButton);
      }
    }
  };
};
exports.carouselDriverFactory = carouselDriverFactory;
//# sourceMappingURL=Carousel.driver.js.map