'use strict'
!(function(require, directRequire) {
  const a = require('react'),
    b = require('./3b5f8e2469c474c8d433c1c6926d8999.js'),
    c = require('./59394b696f4be6762ad2b2bf3e1575a7.js')
  class d extends a.Component {
    constructor(a) {
      super(a),
        (this.state = { hourCurrent: 0, minuteCurrent: 0 }),
        (this.range = {}),
        (this.hourArray = [])
      for (let b = 0; 24 > b; b++) this.hourArray.push(9 < b ? '' + b : '0' + b)
      this.minuteArray = []
      for (let b = 0; 60 > b; b++)
        this.minuteArray.push(9 < b ? '' + b : '0' + b)
    }
    componentDidMount() {
      this.setRange('start', this.props.start || '00:00'),
        this.setRange('end', this.props.end || '23:59'),
        this.setCurrent(this.props.current || '00:00')
    }
    componentWillReceiveProps(a) {
      a.show &&
        (a.current != this.props.current && this.setCurrent(a.current),
        a.start != this.props.start && this.setRange('start', a.start),
        a.end != this.props.end && this.setRange('end', a.end))
    }
    setCurrent(a) {
      var b = Math.min,
        c = Math.max
      let d = a.split(':'),
        e = parseInt(d[0]),
        f = parseInt(d[1])
      this.setState({
        hourCurrent: isNaN(e) ? 0 : b(c(e, 0), 23),
        minuteCurrent: isNaN(f) ? 0 : b(c(f, 0), 59)
      })
    }
    setRange(a, b) {
      let c = b.split(':'),
        d = parseInt(c[0])
      d = isNaN(d) ? 0 : d
      let e = parseInt(c[1])
      ;(e = isNaN(e) ? 0 : e), (this.range[a] = 60 * d + e)
    }
    onHourSelect(a) {
      let b = 60 * a + this.state.minuteCurrent,
        c = a
      b < this.range.start
        ? (c = parseInt(this.range.start / 60))
        : b > this.range.end && (c = parseInt(this.range.end / 60)),
        this.setState({ hourCurrent: c }),
        this.refs.hourPicker.setCurrent(c)
    }
    onMinuteSelect(a) {
      let b = 60 * this.state.hourCurrent + a,
        c = a
      b < this.range.start
        ? (c = parseInt(this.range.start % 60))
        : b > this.range.end &&
          ((c = parseInt(this.range.end % 60)),
          this.setState({ minuteCurrent: c }),
          this.refs.minutePicker.setCurrent(c)),
        this.setState({ minuteCurrent: c }),
        this.refs.minutePicker.setCurrent(c)
    }
    getValue() {
      return (
        this.hourArray[this.state.hourCurrent] +
        ':' +
        this.minuteArray[this.state.minuteCurrent]
      )
    }
    hide() {
      this.props.hidePicker({
        callbackID: this.props.callbackID,
        webviewID: this.props.webviewID,
        res: { errMsg: 'showDatePickerView:cancel' }
      })
    }
    confirm() {
      this.props.hidePicker({
        callbackID: this.props.callbackID,
        webviewID: this.props.webviewID,
        res: { errMsg: 'showDatePickerView:ok', value: this.getValue() }
      })
    }
    render() {
      let d = this.props
      return a.createElement(
        'div',
        { style: d.show ? {} : b.displayNone },
        a.createElement('div', {
          className: 'weui-mask weui-animate-fade-in',
          onClick: this.hide.bind(this)
        }),
        a.createElement(
          'div',
          { className: 'weui-picker weui-animate-slide-up' },
          a.createElement(
            'div',
            { className: 'weui-picker__hd' },
            a.createElement(
              'a',
              {
                className: 'weui-picker__action',
                onClick: this.hide.bind(this)
              },
              '\u53D6\u6D88'
            ),
            a.createElement(
              'a',
              {
                className: 'weui-picker__action',
                onClick: this.confirm.bind(this)
              },
              '\u786E\u5B9A'
            )
          ),
          a.createElement(
            'div',
            { className: 'weui-picker__bd' },
            a.createElement(c, {
              ref: 'hourPicker',
              array: this.hourArray,
              current: this.state.hourCurrent,
              onPickerSelect: this.onHourSelect.bind(this)
            }),
            a.createElement(c, {
              ref: 'minutePicker',
              array: this.minuteArray,
              current: this.state.minuteCurrent,
              onPickerSelect: this.onMinuteSelect.bind(this)
            })
          )
        )
      )
    }
  }
  module.exports = d
})(require('lazyload'), require)
