Liferay.Loader.define("dynamic-data-mapping-form-field-type@5.0.73/Options/DragPreview.es", ['module', 'exports', 'require', 'frontend-js-react-web$react', 'frontend-js-react-web$react-dnd', 'frontend-js-react-web$react-dom', './DnD.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    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);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = DragPreview;

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _reactDnd = require("frontend-js-react-web$react-dnd");

    var _reactDom = _interopRequireDefault(require("frontend-js-react-web$react-dom"));

    var _DnD = require("./DnD.es");

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    var layerStyles = {
      height: '100%',
      left: 0,
      pointerEvents: 'none',
      position: 'fixed',
      top: 0,
      width: '100%',
      zIndex: 100
    };

    var getItemStyles = function getItemStyles(currentOffset, ref) {
      if (!currentOffset || !ref.current) {
        return {
          display: 'none'
        };
      }

      var x = currentOffset.x,
          y = currentOffset.y;
      var transform = "translate(".concat(x, "px, ").concat(y, "px)");
      return {
        WebkitTransform: transform,
        transform: transform
      };
    };

    function DragPreview(_ref) {
      var children = _ref.children,
          Component = _ref.component;
      var ref = (0, _react.useRef)();

      var _useDragLayer = (0, _reactDnd.useDragLayer)(function (monitor) {
        return {
          currentOffset: monitor.getClientOffset(),
          isDragging: monitor.isDragging(),
          item: monitor.getItem()
        };
      }),
          currentOffset = _useDragLayer.currentOffset,
          isDragging = _useDragLayer.isDragging,
          item = _useDragLayer.item;

      if (!isDragging || isDragging && item.type !== _DnD.OPTIONS_TYPES.OPTION) {
        return null;
      }

      return (/*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
          style: layerStyles
        }, /*#__PURE__*/_react.default.createElement(Component, _extends({}, item.option, {
          className: "dragging",
          ref: ref,
          style: getItemStyles(currentOffset, ref)
        }), children({
          index: item.position,
          option: item.option
        }))), document.body)
      );
    }
    //# sourceMappingURL=DragPreview.es.js.map
  }
});
//# sourceMappingURL=DragPreview.es.js.map