"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.sortableListBaseUniDriverFactory = exports.default = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _dragAndDropDriverFactory = require("../utils/DragAndDrop/dragAndDropDriverFactory");
var _unidriver = require("../utils/test-utils/unidriver");
var _DraggableUni = require("../DragAndDrop/Draggable/Draggable.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 sortableListBaseUniDriverFactory = (base, body) => {
  var getDraggableUniDriver = () => (0, _DraggableUni.draggableUniDriverFactory)((0, _unidriver.findByHook)(base, _constants.dataHooks.provider));
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
    /**
     * reorder sortable list items
     * @param {ReorderDataHooks} dataHooks { from: string, to: string }
     * @return {Promise<void>}
     */

    reorder: function () {
      var _reorder = (0, _asyncToGenerator2.default)(function* (_ref) {
        var {
          dataHookFrom,
          dataHookTo
        } = _ref;
        var draggableDriver = getDraggableUniDriver();
        yield draggableDriver.beginDrag({
          dataHook: dataHookFrom
        });
        yield draggableDriver.dragOver({
          dataHook: dataHookTo
        });
        yield draggableDriver.endDrag({
          dataHook: dataHookTo
        });
      });
      function reorder(_x) {
        return _reorder.apply(this, arguments);
      }
      return reorder;
    }(),
    /**
     * get draggable item current position
     * @param itemDetails { dataHook: string }
     * @return {Promise<void>}
     */

    getItemPosition: function () {
      var _getItemPosition = (0, _asyncToGenerator2.default)(function* (_ref2) {
        var {
          dataHook
        } = _ref2;
        return (0, _dragAndDropDriverFactory.dragAndDropDriverFactory)({
          base
        }).getItemPosition({
          dataHook
        });
      });
      function getItemPosition(_x2) {
        return _getItemPosition.apply(this, arguments);
      }
      return getItemPosition;
    }()
  });
};
exports.sortableListBaseUniDriverFactory = sortableListBaseUniDriverFactory;
var _default = exports.default = sortableListBaseUniDriverFactory;
//# sourceMappingURL=SortableListBase.uni.driver.js.map