'use strict'
var _extends =
  Object.assign ||
  function(a) {
    for (var b, c = 1; c < arguments.length; c++)
      for (var d in ((b = arguments[c]), b))
        Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d])
    return a
  }
!(function(require, directRequire) {
  const a = require('react'),
    b = require('./e3681b47a6ce46a8998b8cdff40bdb12.js'),
    c = require('./tools.js'),
    d = require('./5c35f819ec22ae81c6f8ea88445932d6.js')
  class e extends a.Component {
    onTextViewClick() {
      const a = this.props.node
      a.clickable &&
        b.triggerOnEvent({
          eventName: 'onTextViewClick',
          data: { data: a.data }
        })
    }
    onImageViewClick() {
      const a = this.props.node
      a.clickable &&
        b.triggerOnEvent({
          eventName: 'onImageViewClick',
          data: { data: a.data }
        })
    }
    getStyle() {
      const a = this.props.node || {},
        b = a.style || {},
        d = a.type,
        e = a.position
      let f = _extends(
        {
          display: a.hide ? 'none' : '',
          pointerEvents: a.transEvt ? 'none' : '',
          boxSize: 'border-box',
          overflow: b.overflow,
          backgroundColor: b.bgColor,
          borderRadius: b.borderRadius,
          borderWidth: b.borderWidth + 'px',
          borderColor: b.borderColor,
          borderStyle: 'solid',
          opacity: b.opacity,
          position: b.fixed ? 'fixed' : 'absolute'
        },
        e
      )
      if (
        ('array' === c.getType(b.padding) &&
          (f.padding = b.padding.join('px ') + 'px'),
        'text' == d)
      ) {
        const b = a.label || {}
        f = _extends({}, f, {
          color: b.color,
          fontSize: b.fontSize,
          textAlign: b.textAlign,
          fontWeight: b.fontWeight,
          lineHeight: b.lineHeight ? b.lineHeight + 'px' : 1,
          lineBreak: b.lineBreak
        })
      }
      let g = a.animation
      if (g) {
        let a = g.finalStyle
        a &&
          ((f.transform = ''),
          'undefined' != typeof a.scaleX &&
            (f.transform += ` scaleX(${a.scaleX})`),
          'undefined' != typeof a.scaleY &&
            (f.transform += ` scaleX(${a.scaleY})`),
          'undefined' != typeof a.rotate &&
            (f.transform += ` rotate(${a.scaleX}deg)`),
          'undefined' != typeof a.opacity && (f.opacity = a.opacity),
          'undefined' != typeof a.left && (f.left = a.left + 'px'),
          'undefined' != typeof a.top && (f.top = a.top + 'px'),
          (f.transition = `all ${g.duration}ms ${g.easing}`))
      }
      return f
    }
    getSonNodes() {
      const b = this.props.node,
        c = this.props.tree
      let d = []
      return (
        (b.sons || []).forEach(b => {
          c[b] && d.push(a.createElement(e, { key: b, node: c[b], tree: c }))
        }),
        d
      )
    }
    renderTextNode() {
      const b = this.props.node
      return a.createElement(
        'div',
        { style: this.getStyle(), onClick: this.onTextViewClick.bind(this) },
        b.label && b.label.content,
        this.getSonNodes()
      )
    }
    renderImageNode() {
      const b = this.props.node
      return a.createElement(
        'div',
        { style: this.getStyle(), onClick: this.onImageViewClick.bind(this) },
        a.createElement('img', {
          src: b.iconPath,
          style: { width: '100%', height: '100%' }
        }),
        this.getSonNodes()
      )
    }
    renderNativeNode() {
      this.props.node
      return a.createElement(
        'div',
        null,
        a.createElement(d, { node: this.props.node }),
        this.getSonNodes()
      )
    }
    render() {
      const a = this.props.node.type
      if ('text' == a) return this.renderTextNode()
      return 'image' == a
        ? this.renderImageNode()
        : 'native' == a
          ? this.renderNativeNode()
          : null
    }
  }
  module.exports = e
})(require('lazyload'), require)
