"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getPlaceholder = exports.default = 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 _DraftJS = require("../utils/test-utils/unidriver/DraftJS");
var _StatusIndicatorUni = require("../StatusIndicator/StatusIndicator.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 _getPlaceholder = base => base.$('.public-DraftEditorPlaceholder-root');
exports.getPlaceholder = _getPlaceholder;
var _default = (base, body) => {
  var getStatusIndicatorDriver = () => (0, _StatusIndicatorUni.statusIndicatorDriverFactory)(base.$("[data-hook=\"richtextarea-status-indicator\"]"), body);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
    isDisabled: function () {
      var _isDisabled = (0, _asyncToGenerator2.default)(function* () {
        return Boolean(yield (0, _DraftJS.getContent)(base).attr('contenteditable'));
      });
      function isDisabled() {
        return _isDisabled.apply(this, arguments);
      }
      return isDisabled;
    }(),
    getContent: () => (0, _DraftJS.getContent)(base).text(),
    getPlaceholder: () => _getPlaceholder(base).text(),
    enterText: function () {
      var _enterText = (0, _asyncToGenerator2.default)(function* (text) {
        return (0, _DraftJS.enterRichTextValue)(base, text);
      });
      function enterText(_x) {
        return _enterText.apply(this, arguments);
      }
      return enterText;
    }(),
    hasFocus: () => (0, _DraftJS.isRichEditorFocused)(base),
    focus: () => (0, _DraftJS.focusRichEditor)(base),
    blur: () => (0, _DraftJS.blurRichEditor)(base),
    // Status
    /** Return true if there's a status */
    hasStatus: function () {
      var _hasStatus = (0, _asyncToGenerator2.default)(function* (status) {
        var statusIndicatorDriver = getStatusIndicatorDriver();
        if (yield statusIndicatorDriver.exists()) {
          return status === (yield statusIndicatorDriver.getStatus());
        }
        return false;
      });
      function hasStatus(_x2) {
        return _hasStatus.apply(this, arguments);
      }
      return hasStatus;
    }(),
    /** If there's a status message, returns its text value */
    getStatusMessage: function () {
      var _getStatusMessage = (0, _asyncToGenerator2.default)(function* () {
        var statusIndicatorDriver = getStatusIndicatorDriver();
        var tooltipText = null;
        if (yield statusIndicatorDriver.hasMessage()) {
          tooltipText = yield statusIndicatorDriver.getMessage();
        }
        return tooltipText;
      });
      function getStatusMessage() {
        return _getStatusMessage.apply(this, arguments);
      }
      return getStatusMessage;
    }()
  });
};
exports.default = _default;
//# sourceMappingURL=RichTextInputArea.uni.driver.js.map