text: // https://www.npmjs.org/package/react-interpolate-component
  // TODO: Drop this in favor of es6 string interpolation
  
  'use strict';
  
  var _extends = require('babel-runtime/helpers/extends')['default'];
  
  var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
  
  exports.__esModule = true;
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _utilsValidComponentChildren = require('./utils/ValidComponentChildren');
  
  var _utilsValidComponentChildren2 = _interopRequireDefault(_utilsValidComponentChildren);
  
  var REGEXP = /\%\((.+?)\)s/;
  
  var Interpolate = _react2['default'].createClass({
    displayName: 'Interpolate',
  
    propTypes: {
      component: _react2['default'].PropTypes.node,
      format: _react2['default'].PropTypes.string,
      unsafe: _react2['default'].PropTypes.bool
    },
  
    getDefaultProps: function getDefaultProps() {
      return { component: 'span' };
    },
  
    render: function render() {
      var format = _utilsValidComponentChildren2['default'].hasValidComponent(this.props.children) || typeof this.props.children === 'string' ? this.props.children : this.props.format;
      var parent = this.props.component;
      var unsafe = this.props.unsafe === true;
      var props = _extends({}, this.props);
  
      delete props.children;
      delete props.format;
      delete props.component;
      delete props.unsafe;
  
      if (unsafe) {
        var content = format.split(REGEXP).reduce(function (memo, match, index) {
          var html = undefined;
  
          if (index % 2 === 0) {
            html = match;
          } else {
            html = props[match];
            delete props[match];
          }
  
          if (_react2['default'].isValidElement(html)) {
            throw new Error('cannot interpolate a React component into unsafe text');
          }
  
          memo += html;
  
          return memo;
        }, '');
  
        props.dangerouslySetInnerHTML = { __html: content };
  
        return _react2['default'].createElement(parent, props);
      } else {
        var kids = format.split(REGEXP).reduce(function (memo, match, index) {
          var child = undefined;
  
          if (index % 2 === 0) {
            if (match.length === 0) {
              return memo;
            }
  
            child = match;
          } else {
            child = props[match];
            delete props[match];
          }
  
          memo.push(child);
  
          return memo;
        }, []);
  
        return _react2['default'].createElement(parent, props, kids);
      }
    }
  });
  
  exports['default'] = Interpolate;
  module.exports = exports['default'];