"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_viewerjs=require("viewerjs"),_viewerjs2=_interopRequireDefault(_viewerjs),_reactDom=require("react-dom");function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var Previewimg=function(e){function r(e){(0,_classCallCheck3.default)(this,r);var t=(0,_possibleConstructorReturn3.default)(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.defaultList=["zoomIn","zoomOut","prev","next","reset"],t.moreList=["zoomIn","zoomOut","oneToOne","reset","prev","play","next","rotateRight","rotateLeft","flipHorizontal","flipVertical"],t.options={zoomIn:!0,zoomOut:!0,oneToOne:!1,reset:!0,prev:!0,play:!1,next:!0,rotateLeft:!1,rotateRight:!1,flipHorizontal:!1,flipVertical:!1},t.state={instance:null,parameter:{src:"src",original:"original",alt:"alt"}},t}return(0,_inherits3.default)(r,e),(0,_createClass3.default)(r,[{key:"loadViewer",value:function(){var t=this;("more"===this.props.type?this.moreList:this.defaultList).forEach(function(e){t.options[e]=!0}),this.setState({instance:new _viewerjs2.default((0,_reactDom.findDOMNode)(this),{url:"data-original",toolbar:this.options})})}},{key:"componentDidMount",value:function(){var t=this,r=this.props.listParams||{};Object.keys(r).forEach(function(e){t.state.parameter[e]&&(t.state.parameter[e]=r[e])}),this.setState({parameter:this.state.parameter}),this.loadViewer()}},{key:"render",value:function(){var e=this.props,t=e.list,r=void 0===t?[]:t,a=e.className,i=e.prefixCls,s=(0,_classnames2.default)(i,a,(0,_defineProperty3.default)({},i+"-container",!0)),o=this.state.parameter,l=r.map(function(e,t){var r="string"==typeof e?e:e[o.src],a=e[o.original]?e[o.original]:r,i=e[o.alt]?e[o.alt]:e[o.original]?e[o.original]:r;return React.createElement("li",{key:"img--"+t},React.createElement("img",{src:r,"data-original":a,alt:i}))});return React.createElement("ul",{className:s},l)}}]),r}(React.Component);(exports.default=Previewimg).defaultProps={prefixCls:"dt-previewimg",type:"default",list:[],listParams:{src:"src",original:"original",alt:"alt"}},Previewimg.propTypes={className:PropTypes.string,prefixCls:PropTypes.string,type:PropTypes.oneOf(["default","more"]),list:PropTypes.array,listParams:PropTypes.object},module.exports=exports.default;