"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = exports.colorInputDriverFactory = 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 _InputUni = _interopRequireDefault(require("../Input/Input.uni.driver"));
var _ColorPickerUni = require("../ColorPicker/ColorPicker.uni.driver");
var _DataHooks = _interopRequireDefault(require("./DataHooks"));
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 colorInputDriverFactory = (base, body) => {
  var inputTestkit = (0, _InputUni.default)(base, body);
  var colorPickerTestkit = (0, _ColorPickerUni.colorPickerUniDriverFactory)(base.$("[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_COLOR_PICKER, "\"]")));
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /**
     * Cancels color selection
     * @returns {Promise<Void>}
     * */
    cancel: () => colorPickerTestkit.cancel(),
    /**
     * Confirms color selection
     * @returns {Promise<Void>}
     * */
    confirm: () => colorPickerTestkit.confirm(),
    /**
     * Clicks on color viewer box
     * @returns {Promise<Void>}
     */
    clickColorViewer: function () {
      var _clickColorViewer = (0, _asyncToGenerator2.default)(function* () {
        return base.$("[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_POPOVER, "-trigger\"]")).click();
      });
      function clickColorViewer() {
        return _clickColorViewer.apply(this, arguments);
      }
      return clickColorViewer;
    }(),
    /**
     * Enters text to color input
     * @returns {Promise<Void>}
     * */
    enterText: function () {
      var _enterText = (0, _asyncToGenerator2.default)(function* (text) {
        yield inputTestkit.click();
        yield inputTestkit.enterText(text);
      });
      function enterText(_x) {
        return _enterText.apply(this, arguments);
      }
      return enterText;
    }(),
    /**
     * Gets the input value
     * @returns {Promise<string>}
     * */
    getValue: () => inputTestkit.getValue(),
    /**
     * Gets the placeholder of the input
     * @returns {Promise<string | null>}
     * */
    getPlaceholder: () => inputTestkit.getPlaceholder(),
    /**
     * Gets the input size
     * @returns {Promise<string>}
     * */
    getSize: () => inputTestkit.getSize(),
    /**
     * Checks whether the input is disabled
     * @returns {Promise<boolean>}
     * */
    isDisabled: () => inputTestkit.isDisabled(),
    /**
     * Checks whether the color picker is visible
     * @returns {Promise<boolean>}
     * */
    colorPickerVisible: () => colorPickerTestkit.exists(),
    /**
     * Clicks on input
     * @returns {Promise<Void>}
     * */
    click: () => inputTestkit.click(),
    /**
     * Checks whether the given status is displayed
     * @returns {Promise<boolean>}
     * */
    hasStatus: inputTestkit.hasStatus,
    /**
     * Gets the status message
     * @returns {Promise<(string|null)>}
     * */
    getStatusMessage: inputTestkit.getStatusMessage
  });
};
exports.colorInputDriverFactory = colorInputDriverFactory;
var _default = exports.default = colorInputDriverFactory;
//# sourceMappingURL=ColorInput.uni.driver.js.map