import _toPairs from "lodash/fp/toPairs";
import _set from "lodash/fp/set";
import _pipe from "lodash/fp/pipe";
import _map from "lodash/fp/map";
import _join from "lodash/fp/join";
import _isObject from "lodash/fp/isObject";
import _isNil from "lodash/fp/isNil";
import _get from "lodash/fp/get";
import _filter from "lodash/fp/filter";
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); }
import React from 'react';
import PropTypes from 'prop-types';
import { SrcPropType } from '../../util/proptypes';
import style from './style.css';
const toSrcSet = src => {
  if (!_isObject(src)) return {};
  return _pipe(_set('srcSet', _pipe(_toPairs, _filter(([key, url]) => url), _map(([key, url]) => `${url} ${key}`), _join(','))(src)), _set('src', _get('1x', src)))({});
};
const toSetAlt = alt => {
  return alt ? {
    alt
  } : {
    alt: '',
    'aria-hidden': true
  };
};
const Picture = props => {
  const {
    src,
    alt
  } = props;
  if (_isNil(src)) {
    return /*#__PURE__*/React.createElement("div", {
      className: style.empty
    });
  }
  return /*#__PURE__*/React.createElement("img", _extends({}, props, toSrcSet(src), toSetAlt(alt)));
};
Picture.propTypes = process.env.NODE_ENV !== "production" ? {
  src: PropTypes.oneOfType([SrcPropType, PropTypes.objectOf(SrcPropType)]),
  alt: PropTypes.string
} : {};
export default Picture;
//# sourceMappingURL=index.js.map