"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.SelectorListPrivateUniDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _SelectorListUni = require("./SelectorList.uni.driver");
var _LoaderUni = require("../Loader/Loader.uni.driver");
var _SearchUni = require("../Search/Search.uni.driver");
var _SelectorUni = require("../Selector/Selector.uni.driver");
var _SelectorList = require("./SelectorList.helpers");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var SelectorListPrivateUniDriverFactory = (base, body) => {
  var mainLoaderDriver = (0, _LoaderUni.loaderUniDriverFactory)(base.$("[data-hook=\"".concat(_SelectorList.dataHooks.mainLoader, "\"]")), body);
  var nextPageLoaderDriver = (0, _LoaderUni.loaderUniDriverFactory)(base.$("[data-hook=\"".concat(_SelectorList.dataHooks.nextPageLoader, "\"]")), body);
  var searchDriver = (0, _SearchUni.searchUniDriverFactory)(base.$("[data-hook=\"".concat(_SelectorList.dataHooks.search, "\"]")), body);
  var findInListByDataHook = dataHook => base.$("[data-hook=\"".concat(dataHook, "\"]"));
  var getList = () => findInListByDataHook(_SelectorList.dataHooks.list);
  var getContent = () => findInListByDataHook(_SelectorList.dataHooks.content);
  var getSelectors = () => getList().$$("[data-hook=\"".concat(_SelectorList.dataHooks.selector, "\"]"));
  var selectorDriverAt = i => (0, _SelectorUni.selectorUniDriverFactory)(getSelectors().get(i));
  var pressKey = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* (key) {
      var el = yield getContent().getNative();
      el.dispatchEvent(new KeyboardEvent('keydown', {
        key,
        bubbles: true
      }));
    });
    return function pressKey(_x) {
      return _ref.apply(this, arguments);
    };
  }();
  return _objectSpread(_objectSpread({}, (0, _SelectorListUni.selectorListUniDriverFactory)(base, body)), {}, {
    isMainLoaderMedium: mainLoaderDriver.isMedium,
    isNextPageLoaderSmall: nextPageLoaderDriver.isSmall,
    getSearchPlaceholder: searchDriver.inputDriver.getPlaceholder,
    getSearchMaxLength: () => searchDriver.inputDriver.getMaxLength(),
    getSelectorToggleTypeAt: i => selectorDriverAt(i).toggleType(),
    isSelectorImageTinyAt: i => selectorDriverAt(i).isImageTiny(),
    isSelectorImageSmallAt: i => selectorDriverAt(i).isImageSmall(),
    isSelectorImagePortraitAt: i => selectorDriverAt(i).isImagePortrait(),
    isSelectorImageLargeAt: i => selectorDriverAt(i).isImageLarge(),
    isSelectorImageCinemaAt: i => selectorDriverAt(i).isImageCinema(),
    isSelectorImageCircleAt: i => selectorDriverAt(i).isImageCircle(),
    isSelectorImageRectangularAt: i => selectorDriverAt(i).isImageRectangular(),
    focusContent: function () {
      var _focusContent = (0, _asyncToGenerator2.default)(function* () {
        var el = yield getContent().getNative();
        el.focus();
      });
      function focusContent() {
        return _focusContent.apply(this, arguments);
      }
      return focusContent;
    }(),
    clickContent: function () {
      var _clickContent = (0, _asyncToGenerator2.default)(function* () {
        var el = yield getContent().getNative();
        el.dispatchEvent(new MouseEvent('mousedown', {
          bubbles: true
        }));
      });
      function clickContent() {
        return _clickContent.apply(this, arguments);
      }
      return clickContent;
    }(),
    focusSearch: () => searchDriver.inputDriver.focus(),
    pressArrowDown: () => pressKey('ArrowDown'),
    pressArrowUp: () => pressKey('ArrowUp'),
    pressEnter: () => pressKey('Enter'),
    pressSpace: () => pressKey(' '),
    isItemActiveAt: function () {
      var _isItemActiveAt = (0, _asyncToGenerator2.default)(function* (i) {
        var selectorElement = yield getSelectors().get(i).getNative();
        var classList = Array.from(selectorElement.classList);
        return classList.some(className => className.includes('isActive'));
      });
      function isItemActiveAt(_x2) {
        return _isItemActiveAt.apply(this, arguments);
      }
      return isItemActiveAt;
    }()
  });
};
exports.SelectorListPrivateUniDriverFactory = SelectorListPrivateUniDriverFactory;
//# sourceMappingURL=SelectorList.private.uni.driver.js.map