import React, { Suspense } from 'react';
import Tabs from 'antd/es/tabs';
import 'antd/es/tabs/style';
import Skeleton from 'antd/es/skeleton';
import 'antd/es/skeleton/style';
import Alert from 'antd/es/alert';
import 'antd/es/alert/style';
import { Copy } from '../../topBar/controls/Copy';
var Code = React.lazy(function () {
  return import(
  /* webpackChunkName: "code" */
  './Code');
});
var DependenciesTab = React.lazy(function () {
  return import(
  /* webpackChunkName: "dependencies-tab" */
  './DependenciesTab');
});
var CrumbsTab = React.lazy(function () {
  return import(
  /* webpackChunkName: "crumbs-tab" */
  './CrumbsTab');
});
var FlowChartTab = React.lazy(function () {
  return import(
  /* webpackChunkName: "flow-chart-tab" */
  './FlowChartTab');
});
import './SideBar.less';
var TabPane = Tabs.TabPane; //TODO: Add slide from right animation

export default (function (_ref) {
  var namespace = _ref.namespace,
      language = _ref.language,
      selectedNode = _ref.selectedNode,
      filesMap = _ref.filesMap,
      onClose = _ref.onClose,
      selectedTabInSideBar = _ref.selectedTabInSideBar,
      dependenciesDiagramOn = _ref.dependenciesDiagramOn,
      codeCrumbsDiagramOn = _ref.codeCrumbsDiagramOn,
      fullFeaturesSupport = _ref.fullFeaturesSupport,
      onTabSelect = _ref.onTabSelect;
  var file = selectedNode && filesMap[selectedNode.path];
  var standaloneNoCode = !process.env.LOCAL && (!file || !file.fileCode);
  var header = standaloneNoCode ? React.createElement(Alert, {
    message: "No code for this file in standalone mode.",
    description: "Only files with codecrumbs have pre-fetched code. Consider to run codecrumbs locally for this project to access all code. Check instructions here https://github.com/Bogdan-Lyashenko/codecrumbs",
    type: "warning",
    showIcon: true
  }) : React.createElement(React.Fragment, null, React.createElement("div", null, file.path), React.createElement("div", {
    className: 'copyIcon'
  }, React.createElement(Copy, {
    copyText: file.path
  })));
  var content = React.createElement(Tabs, {
    defaultActiveKey: selectedTabInSideBar,
    onChange: onTabSelect
  }, React.createElement(TabPane, {
    tab: "Code",
    key: "Code"
  }, React.createElement(Suspense, {
    fallback: null
  }, standaloneNoCode ? React.createElement(Skeleton, null) : React.createElement(Code, {
    namespace: namespace,
    language: language,
    code: file.fileCode
  }))), dependenciesDiagramOn && fullFeaturesSupport && React.createElement(TabPane, {
    tab: "Dependencies",
    key: "Dependencies"
  }, React.createElement(Suspense, {
    fallback: null
  }, React.createElement(DependenciesTab, {
    namespace: namespace,
    language: language
  }))) || null, codeCrumbsDiagramOn && React.createElement(TabPane, {
    tab: "Crumbs",
    key: "Crumbs"
  }, React.createElement(Suspense, {
    fallback: null
  }, React.createElement(CrumbsTab, {
    namespace: namespace,
    language: language
  }))) || null, fullFeaturesSupport && React.createElement(TabPane, {
    tab: "FlowChart",
    key: "FlowChart"
  }, React.createElement(Suspense, {
    fallback: null
  }, React.createElement(FlowChartTab, {
    namespace: namespace,
    language: language,
    fileCode: file.fileCode,
    active: selectedTabInSideBar === 'FlowChart'
  }))) || null);
  return React.createElement("div", {
    className: "SideBar"
  }, React.createElement("div", {
    className: "header"
  }, React.createElement("div", {
    className: 'filePath'
  }, header), React.createElement("a", {
    href: "#",
    onClick: onClose
  }, "X")), React.createElement("div", {
    className: "bodySideBar"
  }, content));
});