"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.selectorUniDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _TextUni = require("../Text/Text.uni.driver");
var _CheckboxUni = require("../Checkbox/Checkbox.uni.driver");
var _unidriver = require("../utils/test-utils/unidriver");
var _constants = require("./constants");
var _TooltipUni = require("../Tooltip/Tooltip.uni.driver");
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 selectorUniDriverFactory = (base, body) => {
  var toggleInput = () => base.$('[data-hook="toggle"] input');
  var image = () => base.$('[data-hook="selector-image"]');
  var titleTextDriver = () => (0, _TextUni.textUniDriverFactory)(base.$('[data-hook="selector-title"]'));
  var subtitleTextDriver = () => (0, _TextUni.textUniDriverFactory)(base.$('[data-hook="selector-subtitle"]'));
  var extraNode = () => base.$('[data-hook="selector-extra-node"]');
  var checkboxDriver = () => (0, _CheckboxUni.checkboxUniDriverFactory)(base.$('[data-hook="toggle"]'), base);
  var getTooltipDriver = () => {
    return (0, _TooltipUni.tooltipDriverFactory)(base.$('[data-hook="toggle-tooltip"]'), body);
  };
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    isImageTiny: function () {
      var _isImageTiny = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SIZE)) === _constants.sizes.TINY;
      });
      function isImageTiny() {
        return _isImageTiny.apply(this, arguments);
      }
      return isImageTiny;
    }(),
    isImageSmall: function () {
      var _isImageSmall = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SIZE)) === _constants.sizes.SMALL;
      });
      function isImageSmall() {
        return _isImageSmall.apply(this, arguments);
      }
      return isImageSmall;
    }(),
    isImagePortrait: function () {
      var _isImagePortrait = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SIZE)) === _constants.sizes.PORTRAIT;
      });
      function isImagePortrait() {
        return _isImagePortrait.apply(this, arguments);
      }
      return isImagePortrait;
    }(),
    isImageLarge: function () {
      var _isImageLarge = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SIZE)) === _constants.sizes.LARGE;
      });
      function isImageLarge() {
        return _isImageLarge.apply(this, arguments);
      }
      return isImageLarge;
    }(),
    isImageCinema: function () {
      var _isImageCinema = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SIZE)) === _constants.sizes.CINEMA;
      });
      function isImageCinema() {
        return _isImageCinema.apply(this, arguments);
      }
      return isImageCinema;
    }(),
    isImageCircle: function () {
      var _isImageCircle = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SHAPE)) === _constants.shapes.CIRCLE;
      });
      function isImageCircle() {
        return _isImageCircle.apply(this, arguments);
      }
      return isImageCircle;
    }(),
    isImageRectangular: function () {
      var _isImageRectangular = (0, _asyncToGenerator2.default)(function* () {
        return (yield (0, _unidriver.getDataAttributeValue)(base, _constants.dataAttr.SHAPE)) === _constants.shapes.RECTANGULAR;
      });
      function isImageRectangular() {
        return _isImageRectangular.apply(this, arguments);
      }
      return isImageRectangular;
    }(),
    isDisabled: () => toggleInput().prop('disabled'),
    toggleType: () => toggleInput().prop('type'),
    isChecked: function () {
      var _isChecked = (0, _asyncToGenerator2.default)(function* () {
        return (yield toggleInput().exists()) && toggleInput().prop('checked');
      });
      function isChecked() {
        return _isChecked.apply(this, arguments);
      }
      return isChecked;
    }(),
    isIndeterminate: () => checkboxDriver().isIndeterminate(),
    hasImage: () => image().exists(),
    getImage: function () {
      var _getImage = (0, _asyncToGenerator2.default)(function* () {
        return image().prop('firstChild');
      });
      function getImage() {
        return _getImage.apply(this, arguments);
      }
      return getImage;
    }(),
    titleTextDriver,
    subtitleTextDriver,
    hasExtraNode: () => extraNode().exists(),
    getExtraNode: () => extraNode().prop('firstChild'),
    toggle: () => base.click(),
    getTooltipText: function () {
      var _getTooltipText = (0, _asyncToGenerator2.default)(function* () {
        var tooltip = getTooltipDriver();
        if (!(yield tooltip.exists())) {
          return null;
        }
        return tooltip.getTooltipText();
      });
      function getTooltipText() {
        return _getTooltipText.apply(this, arguments);
      }
      return getTooltipText;
    }()
  });
};
exports.selectorUniDriverFactory = selectorUniDriverFactory;
//# sourceMappingURL=Selector.uni.driver.js.map