import React from 'react';
import classNames from 'classnames';
import { BUTTON_SIZES } from '../button';
import { FileTreeItemActions } from '.';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const FileTreeItem = ({
  item,
  onClick,
  onMouseOver,
  onDoubleClick,
  isActive,
  actions,
  testId = 'file-tree-item',
  children = null,
  ItemActions = FileTreeItemActions,
  disabled = false,
  rowSize = 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
    _jsxs("div", {
      className: classNames('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__*/_jsx("div", {
        "test-id": testId,
        className: "file-tree-item-content",
        children: children
      }), /*#__PURE__*/_jsx("div", {
        className: classNames('actions-container', isActive && 'is-active')
        /* eslint-disable-next-line react/forbid-dom-props */,
        style: {
          visibility: isActive ? 'visible' : 'hidden'
        },
        children: /*#__PURE__*/_jsx(ItemActions, {
          item: item,
          actions: actions,
          buttonsSize: rowSize,
          isActive: isActive
        })
      })]
    })
  );
};
FileTreeItem.displayName = 'FileTreeItem';
export default FileTreeItem;