import React from 'react';
import { observer } from 'mobx-react-lite';
import GroupItem from "./GroupItem";
import DetailItem from "./DetailItem";
import { useEnvironmentStore } from "../../../stores";
var TreeItem = observer(function (_ref) {
  var record = _ref.record,
      search = _ref.search;

  var _useEnvironmentStore = useEnvironmentStore(),
      intlPrefix = _useEnvironmentStore.intlPrefix,
      _useEnvironmentStore$ = _useEnvironmentStore.itemType,
      DETAIL_ITEM = _useEnvironmentStore$.DETAIL_ITEM,
      GROUP_ITEM = _useEnvironmentStore$.GROUP_ITEM;

  function getItem() {
    var itemName = record.get('name') || '';
    var type = record.get('itemType');

    if (type === GROUP_ITEM) {
      return /*#__PURE__*/React.createElement(GroupItem, {
        record: record,
        search: search,
        intlPrefix: intlPrefix
      });
    } else if (type === DETAIL_ITEM) {
      return /*#__PURE__*/React.createElement(DetailItem, {
        record: record,
        search: search,
        intlPrefix: intlPrefix
      });
    } else {
      return itemName;
    }
  }

  return getItem();
});
TreeItem.defaultProps = {
  record: {}
};
export default TreeItem;