'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HookHeader = exports.Hook = undefined;

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _mobxReact = require('mobx-react');

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _command = require('../commands/command');

var _command2 = _interopRequireDefault(_command);

var _collapsible = require('../collapsible/collapsible');

var _collapsible2 = _interopRequireDefault(_collapsible);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var HookHeader = function HookHeader(_ref) {
  var name = _ref.name;
  return _react2.default.createElement(
    'span',
    null,
    name,
    ' ',
    _react2.default.createElement(
      'span',
      { className: 'hook-failed-message' },
      '(failed)'
    )
  );
};

var Hook = (0, _mobxReact.observer)(function (_ref2) {
  var model = _ref2.model;
  return _react2.default.createElement(
    'li',
    { className: (0, _classnames2.default)('hook-item', { 'hook-failed': model.failed }) },
    _react2.default.createElement(
      _collapsible2.default,
      {
        header: _react2.default.createElement(HookHeader, { name: model.name }),
        headerClass: 'hook-name',
        isOpen: true
      },
      _react2.default.createElement(
        'ul',
        { className: 'commands-container' },
        _lodash2.default.map(model.commands, function (command) {
          return _react2.default.createElement(_command2.default, { key: command.id, model: command });
        })
      )
    )
  );
});

var Hooks = (0, _mobxReact.observer)(function (_ref3) {
  var model = _ref3.model;
  return _react2.default.createElement(
    'ul',
    { className: 'hooks-container' },
    _lodash2.default.map(model.hooks, function (hook) {
      return _react2.default.createElement(Hook, { key: hook.id, model: hook });
    })
  );
});

exports.Hook = Hook;
exports.HookHeader = HookHeader;
exports.default = Hooks;