"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.breadcrumbsUniDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../utils/test-utils/unidriver");
var _constants = require("./constants");
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 breadcrumbsUniDriverFactory = base => {
  var optionAt = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* (position) {
      return base.$("[data-hook=\"".concat(_constants.DATA_HOOKS.ITEM_WRAPPER, "-").concat(position, "\"]"));
    });
    return function optionAt(_x) {
      return _ref.apply(this, arguments);
    };
  }();
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /**
     * Gets number of breadcrumbs
     * @return {Promise<number>}
     */
    breadcrumbsLength: function () {
      var _breadcrumbsLength = (0, _asyncToGenerator2.default)(function* () {
        return yield base.$$("[data-hook^=\"".concat(_constants.DATA_HOOKS.ITEM_WRAPPER, "-\"]")).count();
      });
      function breadcrumbsLength() {
        return _breadcrumbsLength.apply(this, arguments);
      }
      return breadcrumbsLength;
    }(),
    /**
     * Gets breadcrumb content at position
     * @param {number} position Breadcrumb index
     * @return {Promise<string>}
     */
    breadcrumbContentAt: function () {
      var _breadcrumbContentAt = (0, _asyncToGenerator2.default)(function* (position) {
        return yield (yield optionAt(position)).text();
      });
      function breadcrumbContentAt(_x2) {
        return _breadcrumbContentAt.apply(this, arguments);
      }
      return breadcrumbContentAt;
    }(),
    /**
     * Clicks on breadcrumb at position
     * @param {number} position Breadcrumb index
     * @return {Promise<void>}
     */
    clickBreadcrumbAt: function () {
      var _clickBreadcrumbAt = (0, _asyncToGenerator2.default)(function* (position) {
        return base.$("[data-hook^=\"".concat(_constants.DATA_HOOKS.BREADCRUMB_CLICKABLE, "-").concat(position, "\"]")).click();
      });
      function clickBreadcrumbAt(_x3) {
        return _clickBreadcrumbAt.apply(this, arguments);
      }
      return clickBreadcrumbAt;
    }(),
    /**
     * Gets the active breadcrumb position or null if no breadcrumb is active
     * @return {Promise<number | null>}
     */
    getActiveItemId: function () {
      var _getActiveItemId = (0, _asyncToGenerator2.default)(function* () {
        var activeItem = yield base.$$("[".concat(_constants.DATA_ATTRIBUTES.DATA_ACTIVE, "=\"true\"]"));
        return (yield activeItem.count()) === 1 ? parseInt(yield activeItem.get(0).attr(_constants.DATA_ATTRIBUTES.DATA_POSITION_ID)) : null;
      });
      function getActiveItemId() {
        return _getActiveItemId.apply(this, arguments);
      }
      return getActiveItemId;
    }(),
    /**
     * Checks whether breadcrumbs are size large
     * @return {Promise<boolean>}
     */
    isLarge: function () {
      var _isLarge = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SIZE)) === _constants.SIZES.large;
      });
      function isLarge() {
        return _isLarge.apply(this, arguments);
      }
      return isLarge;
    }(),
    /**
     * Checks whether breadcrumbs are size small
     * @return {Promise<boolean>}
     */
    isSmall: function () {
      var _isSmall = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SIZE)) === _constants.SIZES.small;
      });
      function isSmall() {
        return _isSmall.apply(this, arguments);
      }
      return isSmall;
    }(),
    /**
     * Checks whether breadcrumbs are size medium
     * @return {Promise<boolean>}
     */
    isMedium: function () {
      var _isMedium = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SIZE)) === _constants.SIZES.medium;
      });
      function isMedium() {
        return _isMedium.apply(this, arguments);
      }
      return isMedium;
    }(),
    /**
     * Checks whether breadcrumbs are on white background
     * @return {Promise<boolean>}
     */
    isOnWhiteBackground: function () {
      var _isOnWhiteBackground = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SKIN)) === _constants.SKINS.onWhiteBackground;
      });
      function isOnWhiteBackground() {
        return _isOnWhiteBackground.apply(this, arguments);
      }
      return isOnWhiteBackground;
    }(),
    /**
     * Checks whether breadcrumbs are on gray background
     * @return {Promise<boolean>}
     */
    isOnGrayBackground: function () {
      var _isOnGrayBackground = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SKIN)) === _constants.SKINS.onGrayBackground;
      });
      function isOnGrayBackground() {
        return _isOnGrayBackground.apply(this, arguments);
      }
      return isOnGrayBackground;
    }(),
    /**
     * Checks whether breadcrumbs are on dark background
     * @return {Promise<boolean>}
     */
    isOnDarkBackground: function () {
      var _isOnDarkBackground = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr(_constants.DATA_ATTRIBUTES.DATA_SKIN)) === _constants.SKINS.onDarkBackground;
      });
      function isOnDarkBackground() {
        return _isOnDarkBackground.apply(this, arguments);
      }
      return isOnDarkBackground;
    }(),
    /**
     * Checks whether breadcrumb at index is active
     * @param {number} index Breadcrumb index
     * @return {Promise<boolean>}
     */
    isActiveLinkAt: function () {
      var _isActiveLinkAt = (0, _asyncToGenerator2.default)(function* (index) {
        return yield (yield optionAt(index)).$('a').exists();
      });
      function isActiveLinkAt(_x4) {
        return _isActiveLinkAt.apply(this, arguments);
      }
      return isActiveLinkAt;
    }()
  });
};
exports.breadcrumbsUniDriverFactory = breadcrumbsUniDriverFactory;
//# sourceMappingURL=Breadcrumbs.uni.driver.js.map