"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.buttonCoreDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
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 buttonCoreDriverFactory = base => {
  var reactBase = (0, _unidriver.ReactBase)(base);
  var getSuffix = () => (0, _unidriver.findByHook)(base, _constants.dataHooks.suffixIcon);
  var getPrefix = () => (0, _unidriver.findByHook)(base, _constants.dataHooks.prefixIcon);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    getButtonTextContent: function () {
      var _getButtonTextContent = (0, _asyncToGenerator2.default)(function* () {
        return base.text();
      });
      function getButtonTextContent() {
        return _getButtonTextContent.apply(this, arguments);
      }
      return getButtonTextContent;
    }(),
    isButtonDisabled: function () {
      var _isButtonDisabled = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('aria-disabled')) === 'true';
      });
      function isButtonDisabled() {
        return _isButtonDisabled.apply(this, arguments);
      }
      return isButtonDisabled;
    }(),
    isDisabled: function () {
      var _isDisabled = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('aria-disabled')) === 'true';
      });
      function isDisabled() {
        return _isDisabled.apply(this, arguments);
      }
      return isDisabled;
    }(),
    isFocused: function () {
      var _isFocused = (0, _asyncToGenerator2.default)(function* () {
        return reactBase.isFocus();
      });
      function isFocused() {
        return _isFocused.apply(this, arguments);
      }
      return isFocused;
    }(),
    isSuffixIconExists: function () {
      var _isSuffixIconExists = (0, _asyncToGenerator2.default)(function* () {
        return getSuffix().exists();
      });
      function isSuffixIconExists() {
        return _isSuffixIconExists.apply(this, arguments);
      }
      return isSuffixIconExists;
    }(),
    isPrefixIconExists: function () {
      var _isPrefixIconExists = (0, _asyncToGenerator2.default)(function* () {
        return getPrefix().exists();
      });
      function isPrefixIconExists() {
        return _isPrefixIconExists.apply(this, arguments);
      }
      return isPrefixIconExists;
    }(),
    focus: () => reactBase.focus(),
    getHref: function () {
      var _getHref = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('href');
      });
      function getHref() {
        return _getHref.apply(this, arguments);
      }
      return getHref;
    }(),
    getTabIndex: function () {
      var _getTabIndex = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('tabIndex');
      });
      function getTabIndex() {
        return _getTabIndex.apply(this, arguments);
      }
      return getTabIndex;
    }(),
    getTagName: function () {
      var _getTagName = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.prop('tagName')).toLowerCase();
      });
      function getTagName() {
        return _getTagName.apply(this, arguments);
      }
      return getTagName;
    }(),
    getType: function () {
      var _getType = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.prop('type')).toLowerCase();
      });
      function getType() {
        return _getType.apply(this, arguments);
      }
      return getType;
    }(),
    hasPrefixClass: function () {
      var _hasPrefixClass = (0, _asyncToGenerator2.default)(function* (className) {
        return getPrefix().hasClass(className);
      });
      function hasPrefixClass(_x) {
        return _hasPrefixClass.apply(this, arguments);
      }
      return hasPrefixClass;
    }(),
    hasSuffixClass: function () {
      var _hasSuffixClass = (0, _asyncToGenerator2.default)(function* (className) {
        return getSuffix().hasClass(className);
      });
      function hasSuffixClass(_x2) {
        return _hasSuffixClass.apply(this, arguments);
      }
      return hasSuffixClass;
    }()
  });
};
exports.buttonCoreDriverFactory = buttonCoreDriverFactory;
//# sourceMappingURL=ButtonCore.uni.driver.js.map