"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _ClosablePopoverUni = require("./ClosablePopover/ClosablePopover.uni.driver");
var _FloatingHelperContentUni = require("./FloatingHelperContent/FloatingHelperContent.uni.driver");
var _constants = require("./constants");
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 floatingHelperUniDriverFactory = (base, body) => {
  var closablePopoverUniDriver = (0, _ClosablePopoverUni.closablePopoverUniDriverFactory)(base, body);
  var popoverContent = () => closablePopoverUniDriver.getContentElement();
  var closeButton = () => body.$("[data-hook=\"".concat(_constants.dataHooks.closeButton, "\"]"));
  var contentWrapper = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* () {
      return (yield popoverContent()).querySelector("[data-hook=\"".concat(_constants.dataHooks.contentWrapper, "\"]"));
    });
    return function contentWrapper() {
      return _ref.apply(this, arguments);
    };
  }();
  var helperContent = (0, _FloatingHelperContentUni.floatingHelperContentUniDriverFactory)(base, body);
  return _objectSpread(_objectSpread({}, (0, _ClosablePopoverUni.closablePopoverUniDriverFactory)(base, body)), {}, {
    /**
     * Check whether the helper has a close button
     * @return {Promise<boolean>}
     */
    hasCloseButton: function () {
      var _hasCloseButton = (0, _asyncToGenerator2.default)(function* () {
        return (yield closeButton()).exists();
      });
      function hasCloseButton() {
        return _hasCloseButton.apply(this, arguments);
      }
      return hasCloseButton;
    }(),
    /**
     * Clicks the close button
     * @return {Promise<void>}
     */
    clickCloseButton: function () {
      var _clickCloseButton = (0, _asyncToGenerator2.default)(function* () {
        return (yield closeButton()).click();
      });
      function clickCloseButton() {
        return _clickCloseButton.apply(this, arguments);
      }
      return clickCloseButton;
    }(),
    /** @deprecated use helperContent */
    getHelperContentDriver: function () {
      var _getHelperContentDriver = (0, _asyncToGenerator2.default)(function* () {
        return helperContent;
      });
      function getHelperContentDriver() {
        return _getHelperContentDriver.apply(this, arguments);
      }
      return getHelperContentDriver;
    }(),
    /**
     * Gets the driver for the helper's content
     * @return {FloatingHelperContentUniDriver}
     */
    helperContent,
    /**
     * Gets the width of the content root element
     * @return {Promise<string>}
     */
    getWidth: function () {
      var _getWidth = (0, _asyncToGenerator2.default)(function* () {
        return (yield contentWrapper()).style.width;
      });
      function getWidth() {
        return _getWidth.apply(this, arguments);
      }
      return getWidth;
    }()
  });
};
var _default = exports.default = floatingHelperUniDriverFactory;
//# sourceMappingURL=FloatingHelper.uni.driver.js.map