"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _InputUni = require("../../Input/Input.uni.driver");
var _default = (base, body) => {
  var getButtons = () => base.$$("[data-hook*=\"richtextarea-button\"]");
  var getButtonByType = type => base.$("[data-hook*=\"richtextarea-button-".concat(type, "\"]"));
  var insertUrl = url => {
    var urlInputDriver = (0, _InputUni.testkit)(body.$('[data-hook="richtextarea-form-link-url"]'));
    return urlInputDriver.enterText(url);
  };
  return {
    getButtonTypes: () => getButtons().map(/*#__PURE__*/function () {
      var _ref = (0, _asyncToGenerator2.default)(function* (button) {
        return (yield button.attr('data-hook')).replace(/^richtextarea-button-/, '');
      });
      return function (_x) {
        return _ref.apply(this, arguments);
      };
    }()),
    getBoldButton: () => getButtonByType('bold'),
    getItalicButton: () => getButtonByType('italic'),
    getUnderlineButton: () => getButtonByType('underline'),
    getBulletedListButton: () => getButtonByType('unordered-list-item'),
    getNumberedListButton: () => getButtonByType('ordered-list-item'),
    getLinkButton: () => getButtonByType('link'),
    isFormConfirmButtonDisabled: function () {
      var _isFormConfirmButtonDisabled = (0, _asyncToGenerator2.default)(function* () {
        return (yield body.$('[data-hook=richtextarea-form-confirm-button]').attr('aria-disabled')) === 'true';
      });
      function isFormConfirmButtonDisabled() {
        return _isFormConfirmButtonDisabled.apply(this, arguments);
      }
      return isFormConfirmButtonDisabled;
    }(),
    isFormDisplayed: () => body.$('[data-hook=richtextarea-form]').exists(),
    isActive: function () {
      var _isActive = (0, _asyncToGenerator2.default)(function* (element) {
        return (yield element.attr('data-active')) === 'true';
      });
      function isActive(_x2) {
        return _isActive.apply(this, arguments);
      }
      return isActive;
    }(),
    clickBoldButton: () => getButtonByType('bold').click(),
    clickItalicButton: () => getButtonByType('italic').click(),
    clickUnderlineButton: () => getButtonByType('underline').click(),
    clickBulletedListButton: () => getButtonByType('unordered-list-item').click(),
    clickNumberedListButton: () => getButtonByType('ordered-list-item').click(),
    clickLinkButton: () => getButtonByType('link').click(),
    clickFormCancelButton: () => body.$('[data-hook="richtextarea-form-cancel-button"]').click(),
    insertUrl,
    insertLink: function () {
      var _insertLink = (0, _asyncToGenerator2.default)(function* (text, url) {
        var textInputDriver = (0, _InputUni.testkit)(body.$('[data-hook="richtextarea-form-link-text"]'));
        var submitButton = body.$('[data-hook="richtextarea-form-confirm-button"]');
        yield textInputDriver.enterText(text);
        yield insertUrl(url);
        yield submitButton.click();
      });
      function insertLink(_x3, _x4) {
        return _insertLink.apply(this, arguments);
      }
      return insertLink;
    }()
  };
};
exports.default = _default;
//# sourceMappingURL=RichTextToolbar.private.uni.driver.js.map