"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.TimeInputDriverFactory = 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");
var _InputUni = _interopRequireDefault(require("../Input/Input.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 TimeInputDriverFactory = (base, body) => {
  var inputDriver = (0, _InputUni.default)((0, _unidriver.findByHook)(base, _constants.DATA_HOOK.TimeInputInput), body);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
    /**
     * Gets passed date value
     * @returns {Promise<Date>}
     */
    getValue: function () {
      var _getValue = (0, _asyncToGenerator2.default)(function* () {
        return new Date(parseInt(yield base.attr('data-value')));
      });
      function getValue() {
        return _getValue.apply(this, arguments);
      }
      return getValue;
    }(),
    /**
     * Sets given value as an input value
     * @param {string} value text value to input
     * @returns {Promise<void>}
     */
    setValue: function () {
      var _setValue = (0, _asyncToGenerator2.default)(function* (value) {
        return inputDriver.enterText(value);
      });
      function setValue(_x) {
        return _setValue.apply(this, arguments);
      }
      return setValue;
    }(),
    /**
     * Confirms typed in value
     * @returns {Promise<void>}
     */
    confirmValue: function () {
      var _confirmValue = (0, _asyncToGenerator2.default)(function* () {
        return inputDriver.blur();
      });
      function confirmValue() {
        return _confirmValue.apply(this, arguments);
      }
      return confirmValue;
    }(),
    /**
     * Gets passed locale
     * @returns {Promise<string>}
     */
    getLocale: function () {
      var _getLocale = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('data-locale');
      });
      function getLocale() {
        return _getLocale.apply(this, arguments);
      }
      return getLocale;
    }(),
    /**
     * Gets passed timeStyle
     * @returns {Promise<string>}
     */
    getTimeStyle: function () {
      var _getTimeStyle = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('data-time-style');
      });
      function getTimeStyle() {
        return _getTimeStyle.apply(this, arguments);
      }
      return getTimeStyle;
    }(),
    /**
     * Checks if TimeInput is disabled
     * @return {Promise<boolean>}
     */
    isDisabled: function () {
      var _isDisabled = (0, _asyncToGenerator2.default)(function* () {
        return inputDriver.isDisabled();
      });
      function isDisabled() {
        return _isDisabled.apply(this, arguments);
      }
      return isDisabled;
    }(),
    /** Checks if TimeInput has status
     * @param {string} status status to check
     * @returns {Promise<boolean>}
     */
    hasStatus: function () {
      var _hasStatus = (0, _asyncToGenerator2.default)(function* (status) {
        return inputDriver.hasStatus(status);
      });
      function hasStatus(_x2) {
        return _hasStatus.apply(this, arguments);
      }
      return hasStatus;
    }(),
    /**
     * Gets TimeInput status message
     * @returns {Promise<string | null>}
     */
    getStatusMessage: function () {
      var _getStatusMessage = (0, _asyncToGenerator2.default)(function* () {
        return inputDriver.getStatusMessage();
      });
      function getStatusMessage() {
        return _getStatusMessage.apply(this, arguments);
      }
      return getStatusMessage;
    }()
  });
};
exports.TimeInputDriverFactory = TimeInputDriverFactory;
//# sourceMappingURL=TimeInput.uni.driver.js.map