/* drag-preview.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DragPreview = DragPreview;
require("./drag-preview.compiled.css");
var React = _interopRequireWildcard(require("react"));
var _runtime = require("@compiled/react/runtime");
var _expandableMenuItemLevelContext = require("../expandable-menu-item/expandable-menu-item-level-context");
var _menuItem = require("../menu-item");
var _menuItemSignals = require("../menu-item-signals");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// Using JavaScript for detecting Safari, as I could not find a reliable way to do it with CSS.
function isSafari() {
  if (process.env.NODE_ENV === 'test') {
    return false;
  }
  if (typeof window === 'undefined') {
    return false;
  }
  var _navigator = navigator,
    userAgent = _navigator.userAgent;
  return userAgent.includes('AppleWebKit') && !userAgent.includes('Chrome');
}
var dragPreviewStyles = {
  root: "_2rko12b0 _189ee4h9 _1h6dmuej _1dqonqa1 _bfhkvuon _y4ti1b66 _p12fgx0z",
  safariFix: "_1ul9uuw1"
};

/**
 * A drag preview for sidebar menu items.
 *
 * The limited API corresponds with the limited amount of information we
 * want to show in drag previews.
 *
 * If no `elemBefore` is provided, then the `elemBefore` will automatically collapse.
 * There is no need to pass in `COLLAPSE_ELEM_BEFORE`. We do this as there is no
 * need to maintain vertical side navigation vertical alignment in the drag preview.
 *
 * Please ensure the drag preview is pushed away from the users pointer
 * (with `pointerOutsideOfPreview()` from Pragmatic drag and drop) by our
 * standard amount (`{x: token('space.200'), y: token('space.100')`)
 */
function DragPreview(_ref) {
  var elemBefore = _ref.elemBefore,
    children = _ref.children;
  return (
    /*#__PURE__*/
    // Resetting the expandable menu items to 0.
    // This is to prevent our hidden element from pushing
    // the drag preview further away from the users pointer
    React.createElement(_expandableMenuItemLevelContext.ExpandableMenuItemLevelContext.Provider, {
      value: 0
    }, /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([dragPreviewStyles.root, isSafari() && dragPreviewStyles.safariFix])
    }, /*#__PURE__*/React.createElement(_menuItem.MenuItemBase, {
      elemBefore: elemBefore !== null && elemBefore !== void 0 ? elemBefore : _menuItemSignals.COLLAPSE_ELEM_BEFORE
    }, children)))
  );
}