"use strict";

exports.__esModule = true;
exports.default = void 0;
var _omit2 = _interopRequireDefault(require("lodash/fp/omit"));
var _find2 = _interopRequireDefault(require("lodash/fp/find"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _resourceMiniature = _interopRequireDefault(require("../../atom/resource-miniature"));
var _resourcePlayer = _interopRequireDefault(require("../../molecule/resource-player"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const hideResources = resources => !resources || resources.length < 2;
const Resources = ({
  resources,
  className
}) => {
  if (hideResources(resources)) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.resourcesList
  }, resources.map(resource => /*#__PURE__*/_react.default.createElement(_resourceMiniature.default, _extends({}, (0, _omit2.default)('ref', resource), {
    key: resource._id
  }))));
};
Resources.propTypes = process.env.NODE_ENV !== "production" ? {
  resources: _propTypes.default.arrayOf(_propTypes.default.shape((0, _omit2.default)('ref', _resourceMiniature.default.propTypes))),
  className: _propTypes.default.string
} : {};
const ResourceBrowser = props => {
  const {
    resources,
    className,
    overlay
  } = props;
  const selectedResource = (0, _find2.default)(({
    selected
  }) => selected, resources);
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "resourceBrowser",
    className: (0, _classnames.default)(_style.default.defaultStyle, className)
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.resourcePlayerWrapper
  }, selectedResource ? /*#__PURE__*/_react.default.createElement(_resourcePlayer.default, {
    overlay: overlay,
    className: _style.default.resourcePlayer,
    resource: selectedResource
  }) : null), /*#__PURE__*/_react.default.createElement(Resources, {
    resources: resources,
    className: className
  }));
};
ResourceBrowser.propTypes = process.env.NODE_ENV !== "production" ? {
  className: _propTypes.default.string,
  resources: Resources.propTypes.resources,
  overlay: _resourcePlayer.default.propTypes.overlay
} : {};
var _default = exports.default = ResourceBrowser;
//# sourceMappingURL=index.js.map