(function (global, factory) {
	if (typeof define === "function" && define.amd) {
		define(['exports', 'react', 'classnames'], factory);
	} else if (typeof exports !== "undefined") {
		factory(exports, require('react'), require('classnames'));
	} else {
		var mod = {
			exports: {}
		};
		factory(mod.exports, global.react, global.classnames);
		global.IronPages = mod.exports;
	}
})(this, function (exports, _react, _classnames) {
	'use strict';

	Object.defineProperty(exports, "__esModule", {
		value: true
	});

	var _react2 = _interopRequireDefault(_react);

	var _classnames2 = _interopRequireDefault(_classnames);

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

	function _classCallCheck(instance, Constructor) {
		if (!(instance instanceof Constructor)) {
			throw new TypeError("Cannot call a class as a function");
		}
	}

	var _createClass = function () {
		function defineProperties(target, props) {
			for (var i = 0; i < props.length; i++) {
				var descriptor = props[i];
				descriptor.enumerable = descriptor.enumerable || false;
				descriptor.configurable = true;
				if ("value" in descriptor) descriptor.writable = true;
				Object.defineProperty(target, descriptor.key, descriptor);
			}
		}

		return function (Constructor, protoProps, staticProps) {
			if (protoProps) defineProperties(Constructor.prototype, protoProps);
			if (staticProps) defineProperties(Constructor, staticProps);
			return Constructor;
		};
	}();

	function _possibleConstructorReturn(self, call) {
		if (!self) {
			throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
		}

		return call && (typeof call === "object" || typeof call === "function") ? call : self;
	}

	function _inherits(subClass, superClass) {
		if (typeof superClass !== "function" && superClass !== null) {
			throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
		}

		subClass.prototype = Object.create(superClass && superClass.prototype, {
			constructor: {
				value: subClass,
				enumerable: false,
				writable: true,
				configurable: true
			}
		});
		if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
	}

	var IronPages = function (_React$Component) {
		_inherits(IronPages, _React$Component);

		function IronPages(props) {
			_classCallCheck(this, IronPages);

			var _this = _possibleConstructorReturn(this, (IronPages.__proto__ || Object.getPrototypeOf(IronPages)).call(this, props));

			_this.displayName = 'IronPages';

			return _this;
		}

		_createClass(IronPages, [{
			key: '_renderChildren',
			value: function _renderChildren() {
				var selected = this.props.selected;
				var child = null;
				var len = this.props.children.length;
				if (selected > len - 1) {
					child = this.props.children[0];
				} else {
					child = this.props.children[selected];
				}
				var selectedClassName = (0, _classnames2.default)(this.props.selectedClassName);
				return _react2.default.createElement(
					'div',
					{ className: selectedClassName },
					child
				);
			}
		}, {
			key: 'render',
			value: function render() {
				var _props = this.props,
				    children = _props.children,
				    className = _props.className,
				    selectedClassName = _props.selectedClassName,
				    style = _props.style;


				return _react2.default.createElement(
					'div',
					{ className: (0, _classnames2.default)(className) },
					this._renderChildren()
				);
			}
		}]);

		return IronPages;
	}(_react2.default.Component);

	IronPages.defaultProps = {
		propForSelect: null,
		selected: 0,
		selectedItem: null,
		selectedClassName: 'iron-selected',
		className: 'iron-selector'
	};

	exports.default = IronPages;
});