"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DragSourceImpl = void 0; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var DragSourceImpl = /*#__PURE__*/function () { function DragSourceImpl(spec, monitor, connector) { _classCallCheck(this, DragSourceImpl); _defineProperty(this, "spec", void 0); _defineProperty(this, "monitor", void 0); _defineProperty(this, "connector", void 0); this.spec = spec; this.monitor = monitor; this.connector = connector; } _createClass(DragSourceImpl, [{ key: "beginDrag", value: function beginDrag() { var _result; var spec = this.spec; var monitor = this.monitor; var result = null; if (_typeof(spec.item) === 'object') { result = spec.item; } else if (typeof spec.item === 'function') { result = spec.item(monitor); } else { result = {}; } return (_result = result) !== null && _result !== void 0 ? _result : null; } }, { key: "canDrag", value: function canDrag() { var spec = this.spec; var monitor = this.monitor; if (typeof spec.canDrag === 'boolean') { return spec.canDrag; } else if (typeof spec.canDrag === 'function') { return spec.canDrag(monitor); } else { return true; } } }, { key: "isDragging", value: function isDragging(globalMonitor, target) { var spec = this.spec; var monitor = this.monitor; var isDragging = spec.isDragging; return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId(); } }, { key: "endDrag", value: function endDrag() { var spec = this.spec; var monitor = this.monitor; var connector = this.connector; var end = spec.end; if (end) { end(monitor.getItem(), monitor); } connector.reconnect(); } }]); return DragSourceImpl; }(); exports.DragSourceImpl = DragSourceImpl;