"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.composerSidebarDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../utils/test-utils/unidriver");
var _ToggleButtonUni = require("../ToggleButton/ToggleButton.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 getItem = (base, itemId) => base.$("[data-hook=\"composer-sidebar-item-".concat(itemId, "\"]"));
var getItemContainer = (base, itemId) => base.$("[data-hook=\"composer-sidebar-item-container-".concat(itemId, "\"]"));
var getToggleButtonDriver = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2.default)(function* (base, body, itemId) {
    var item = yield getItem(base, itemId);
    return (0, _ToggleButtonUni.toggleButtonDriverFactory)(item, body);
  });
  return function getToggleButtonDriver(_x, _x2, _x3) {
    return _ref.apply(this, arguments);
  };
}();
var composerSidebarDriverFactory = (base, body) => {
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
    /** returns selected item id */
    getSelectedItemId: function () {
      var _getSelectedItemId = (0, _asyncToGenerator2.default)(function* () {
        return yield base.$('[data-hook="composer-sidebar-items-container"]').attr('data-selected-id');
      });
      function getSelectedItemId() {
        return _getSelectedItemId.apply(this, arguments);
      }
      return getSelectedItemId;
    }(),
    /** returns true if item is disabled */
    isItemDisabled: function () {
      var _isItemDisabled = (0, _asyncToGenerator2.default)(function* (itemId) {
        var toggleButtonDriver = yield getToggleButtonDriver(base, body, itemId);
        return toggleButtonDriver.isButtonDisabled();
      });
      function isItemDisabled(_x4) {
        return _isItemDisabled.apply(this, arguments);
      }
      return isItemDisabled;
    }(),
    /** clicks on given item by id */
    clickOnItem: function () {
      var _clickOnItem = (0, _asyncToGenerator2.default)(function* (itemId) {
        var toggleButtonDriver = yield getToggleButtonDriver(base, body, itemId);
        return toggleButtonDriver.click();
      });
      function clickOnItem(_x5) {
        return _clickOnItem.apply(this, arguments);
      }
      return clickOnItem;
    }(),
    /** returns item label value by id */
    getItemLabel: function () {
      var _getItemLabel = (0, _asyncToGenerator2.default)(function* (itemId) {
        var toggleButtonDriver = yield getToggleButtonDriver(base, body, itemId);
        return toggleButtonDriver.getLabelValue();
      });
      function getItemLabel(_x6) {
        return _getItemLabel.apply(this, arguments);
      }
      return getItemLabel;
    }(),
    /** returns label placement value */
    getLabelPlacement: function () {
      var _getLabelPlacement = (0, _asyncToGenerator2.default)(function* () {
        return base.$('[data-hook="composer-sidebar-items-container"]').attr('data-label-placement');
      });
      function getLabelPlacement() {
        return _getLabelPlacement.apply(this, arguments);
      }
      return getLabelPlacement;
    }(),
    /** returns item section title by id */
    getItemSectionTitle: function () {
      var _getItemSectionTitle = (0, _asyncToGenerator2.default)(function* (itemId) {
        return yield getItemContainer(base, itemId).attr('data-section-title');
      });
      function getItemSectionTitle(_x7) {
        return _getItemSectionTitle.apply(this, arguments);
      }
      return getItemSectionTitle;
    }()
  });
};
exports.composerSidebarDriverFactory = composerSidebarDriverFactory;
//# sourceMappingURL=ComposerSidebar.uni.driver.js.map