"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _button = require("../button");
var _ = require(".");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const FileTreeItem = ({
  item,
  onClick,
  onMouseOver,
  onDoubleClick,
  isActive,
  actions,
  testId = 'file-tree-item',
  children = null,
  ItemActions = _.FileTreeItemActions,
  disabled = false,
  rowSize = _button.BUTTON_SIZES.XS
}) => {
  const onItemClick = () => {
    if (!disabled) {
      onClick?.(item);
    }
  };
  const handleDoubleClick = e => {
    e?.preventDefault();
    onDoubleClick?.(item);
  };
  const onMouseEnter = () => onMouseOver?.(true, item);
  const onMouseLeave = () => onMouseOver?.(false, item);
  return (
    /*#__PURE__*/
    // Parent components are focusable and have role, etc.
    // eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
    (0, _jsxRuntime.jsxs)("div", {
      className: (0, _classnames.default)('item', {
        'is-active': isActive,
        'is-disabled': disabled
      }, rowSize),
      onClick: onItemClick,
      onDoubleClick: !disabled && onDoubleClick && handleDoubleClick || undefined,
      onMouseOver: !disabled && onMouseOver && onMouseEnter || undefined,
      onMouseLeave: !disabled && onMouseOver && onMouseLeave || undefined,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        "test-id": testId,
        className: "file-tree-item-content",
        children: children
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: (0, _classnames.default)('actions-container', isActive && 'is-active')
        /* eslint-disable-next-line react/forbid-dom-props */,
        style: {
          visibility: isActive ? 'visible' : 'hidden'
        },
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemActions, {
          item: item,
          actions: actions,
          buttonsSize: rowSize,
          isActive: isActive
        })
      })]
    })
  );
};
FileTreeItem.displayName = 'FileTreeItem';
var _default = exports.default = FileTreeItem;