function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from "react";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
var SortableItem = function SortableItem(_ref) {
  var animateLayoutChanges = _ref.animateLayoutChanges,
    draggable = _ref.draggable,
    id = _ref.id,
    index = _ref.index,
    onRemove = _ref.onRemove,
    itemProps = _ref.itemProps,
    Item = _ref.Item,
    lastTabRef = _ref.lastTabRef;
  var _useSortable = useSortable({
      id: id,
      animateLayoutChanges: animateLayoutChanges,
      disabled: !draggable,
      data: {
        sortable: true,
        navigationTab: true
      }
    }),
    attributes = _useSortable.attributes,
    isDragging = _useSortable.isDragging,
    isSorting = _useSortable.isSorting,
    listeners = _useSortable.listeners,
    setNodeRef = _useSortable.setNodeRef,
    setActivatorNodeRef = _useSortable.setActivatorNodeRef,
    transform = _useSortable.transform,
    transition = _useSortable.transition;
  var style = {
    transform: CSS.Transform.toString(transform),
    transition: transition
  };
  var setRef = function setRef(el) {
    setNodeRef(el);
    if (lastTabRef) lastTabRef.current = el;
  };
  return /*#__PURE__*/React.createElement(Item, _extends({}, itemProps, {
    ref: setRef,
    dragging: isDragging,
    sorting: isSorting,
    draggable: draggable,
    handleProps: draggable ? {
      ref: setActivatorNodeRef
    } : undefined,
    index: index,
    style: style,
    onRemove: onRemove,
    id: id,
    attributes: attributes,
    listeners: listeners
  }));
};
export default SortableItem;