"use strict";

exports.__esModule = true;
exports.default = void 0;
var _toPairs2 = _interopRequireDefault(require("lodash/fp/toPairs"));
var _set2 = _interopRequireDefault(require("lodash/fp/set"));
var _pipe2 = _interopRequireDefault(require("lodash/fp/pipe"));
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _join2 = _interopRequireDefault(require("lodash/fp/join"));
var _isObject2 = _interopRequireDefault(require("lodash/fp/isObject"));
var _isNil2 = _interopRequireDefault(require("lodash/fp/isNil"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _filter2 = _interopRequireDefault(require("lodash/fp/filter"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _proptypes = require("../../util/proptypes");
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 toSrcSet = src => {
  if (!(0, _isObject2.default)(src)) return {};
  return (0, _pipe2.default)((0, _set2.default)('srcSet', (0, _pipe2.default)(_toPairs2.default, (0, _filter2.default)(([key, url]) => url), (0, _map2.default)(([key, url]) => `${url} ${key}`), (0, _join2.default)(','))(src)), (0, _set2.default)('src', (0, _get2.default)('1x', src)))({});
};
const toSetAlt = alt => {
  return alt ? {
    alt
  } : {
    alt: '',
    'aria-hidden': true
  };
};
const Picture = props => {
  const {
    src,
    alt
  } = props;
  if ((0, _isNil2.default)(src)) {
    return /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.empty
    });
  }
  return /*#__PURE__*/_react.default.createElement("img", _extends({}, props, toSrcSet(src), toSetAlt(alt)));
};
Picture.propTypes = process.env.NODE_ENV !== "production" ? {
  src: _propTypes.default.oneOfType([_proptypes.SrcPropType, _propTypes.default.objectOf(_proptypes.SrcPropType)]),
  alt: _propTypes.default.string
} : {};
var _default = exports.default = Picture;
//# sourceMappingURL=index.js.map