'use strict'
!(function(require, directRequire) {
  const a = require('react'),
    b = require('redux'),
    c = require('./a8c87029da0fa06e986298d447ab0fe2.js'),
    d = require('./cc2c2970ff81ae4a83123e81ee123da2.js'),
    e = require('./25d0beb4120ce2acafb4e03b95444fda.js'),
    f = require('./1fcc6bd55b687d154a4247e57fe3011d.js'),
    g = require('./0794878a22a26634e42df858bbaca543.js'),
    h = require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),
    i = require('./72410b6d4968336cd8b2fc1d41f52cdf.js'),
    j = require('./3b5f8e2469c474c8d433c1c6926d8999.js'),
    k = require('moment'),
    l = require('./common/locales/index.js'),
    m = require('./875171e7b864aa58d026d4fa0999fbd1.js'),
    { connect: n } = require('react-redux')
  class o extends a.Component {
    constructor(a) {
      super(a),
        (this.state = { show: a.show, version: '', desc: '' }),
        k.locale(navigator.language)
    }
    componentWillReceiveProps(a) {
      a.show != this.props.show && this.setState({ show: a.show })
    }
    onClose() {
      this.setState({ show: !1 })
    }
    async onConfirm() {
      if (!this.state.version) return void this.refs.versionInput.focus()
      try {
        this.setState({ show: !1 }),
          this.props.setProjectQCloud({
            uploadStatus: h.STATUS.LOADING,
            currentOperation: i.CLOUD_ACTION_UPLOAD_IDC
          })
        let a =
          'PROXY dev-proxy.oa.com:8080' ===
          nw.App.getProxyForURL('https://gz.file.myqcloud.com')
        this.props.setQCloudWnd({
          show: !0,
          status: h.QCLOUD_STATUS.UPLOADING,
          text: l.config.QCLOUD_WATING_TIP_UPLOADING
        })
        const b = await g.uploadSvrCode(this.props.project, {
          devEnv: this.props.env,
          cleverPack: !1,
          src: !0,
          node_modules: !0,
          packagejson: !0,
          env: i.CLOUD_ENV_PRODUCT,
          version: this.state.version,
          remark: this.state.desc || this.getPlaceHolder(),
          onBeforeUpload: b => {
            if (a) {
              const a = b.pDataLength / 1024,
                c = (a / 40).toFixed(0)
              this.props.setQCloudWnd({
                show: !0,
                status: h.QCLOUD_STATUS.UPLOADING,
                text: l.config.QCLOUD_WATING_TIP_UPLOADING,
                descList: [
                  `因开发网上传速度受限，预计需时 ${c}s，请等待上传完成通知`
                ],
                estimateTime: c
              })
            }
          }
        })
        this.props.setProjectQCloud({
          data: b,
          uploadStatus: h.STATUS.SUCCESS,
          currentOperation: ''
        }),
          this.props.setQCloudWnd({
            show: !0,
            status: h.QCLOUD_STATUS.UPLOAD_SUCCESS,
            text: l.config.QCLOUD_UPLOAD_SUCCESS_TITLE,
            descList: [
              l.config.QCLOUD_SUCCESS_TIP_UPLOAD.format(
                k(new Date()).calendar()
              )
            ],
            estimateTime: void 0
          })
      } catch (a) {
        this.props.showUploading(h.QCLOUD_STATUS.UPLOAD_FAIL, a.toString()),
          this.props.setProjectQCloud({
            uploadStatus: h.STATUS.FAIL,
            currentOperation: ''
          })
      }
    }
    onAnimationOut() {
      this.props.close()
    }
    onVersionChange(a) {
      let b = a.target.value
      ;(b = b.replace(/[^0-9a-zA-Z\.]/g, '')), this.setState({ version: b })
    }
    onInputChange(a) {
      let b = a.currentTarget,
        c = b.dataset,
        d = c.name
      this.setState({ [d]: b.value })
    }
    getPlaceHolder() {
      let a = new Date()
      return `${
        this.props.nickName
      } 在 ${a.toLocaleDateString()} ${a.toLocaleTimeString()} 提交上传`
    }
    render() {
      let b = this.props
      const c = 'nodejs' === b.env ? 'Node.js' : 'PHP'
      return a.createElement(
        m,
        {
          show: this.state.show,
          style: { width: 420, marginLeft: -210 },
          inClassName: 'ui-animate-pull-down ui-dialog',
          outClassName: 'ui-animate-pull-up ui-dialog',
          onAnimationOut: this.onAnimationOut.bind(this)
        },
        a.createElement(
          'div',
          { className: 'ui-dialog-hd' },
          a.createElement(
            'h3',
            { className: 'ui-dialog-title' },
            '\u4E0A\u4F20\u6B63\u5F0F\u4EE3\u7801\uFF08',
            c,
            '\uFF09'
          )
        ),
        a.createElement(
          'div',
          { className: 'ui-dialog-bd' },
          a.createElement(
            'div',
            { className: 'ui-form' },
            a.createElement(
              'div',
              { className: 'ui-form-item ui-form-item-inline' },
              a.createElement(
                'label',
                { for: '', className: 'ui-form-label' },
                '\u7248\u672C\u53F7'
              ),
              a.createElement(
                'div',
                { className: 'ui-form-controls' },
                a.createElement(
                  'div',
                  { className: 'ui-input-box' },
                  a.createElement('input', {
                    ref: 'versionInput',
                    type: 'text',
                    className: 'ui-input',
                    maxLength: 10,
                    'data-name': 'version',
                    value: this.state.version,
                    onChange: this.onVersionChange.bind(this)
                  })
                ),
                a.createElement(
                  'p',
                  { className: 'ui-form-tips' },
                  '\u5408\u7406\u8BBE\u7F6E\u7248\u672C\u53F7\u4FBF\u4E8E\u7BA1\u7406\uFF0C\u53EA\u80FD\u8F93\u5165\u5B57\u6BCD\u3001\u6570\u5B57\u3001. \u5982v1.0.0'
                )
              )
            ),
            a.createElement(
              'div',
              { className: 'ui-form-item ui-form-item-inline' },
              a.createElement(
                'label',
                { for: '', className: 'ui-form-label' },
                '\u5907\u6CE8'
              ),
              a.createElement(
                'div',
                { className: 'ui-form-controls' },
                a.createElement(
                  'div',
                  { className: 'ui-input-box' },
                  a.createElement('input', {
                    type: 'text',
                    ref: 'descInput',
                    className: 'ui-input',
                    value: this.state.desc,
                    maxLength: 100,
                    'data-name': 'desc',
                    onChange: this.onInputChange.bind(this),
                    placeholder: this.getPlaceHolder()
                  })
                ),
                a.createElement(
                  'p',
                  { className: 'ui-form-tips' },
                  '\u53EF\u4EE5\u5907\u6CE8\u9879\u76EE\u7248\u672C\u4F18\u5316\u5185\u5BB9\u7B49\uFF0C\u4FBF\u4E8E\u7BA1\u7406\u5458\u8BC6\u522B'
                )
              )
            )
          )
        ),
        a.createElement(
          'div',
          { className: 'ui-dialog-ft' },
          a.createElement(
            'div',
            { className: 'ui-dialog-action' },
            a.createElement(
              'button',
              {
                className: 'ui-button ui-button-default',
                onClick: this.onClose.bind(this)
              },
              '\u53D6\u6D88'
            ),
            a.createElement(
              'button',
              {
                className: 'ui-button ui-button-primary',
                onClick: this.onConfirm.bind(this)
              },
              '\u786E\u5B9A'
            )
          )
        )
      )
    }
  }
  module.exports = n(
    a => {
      let b =
          (a.window.qcloud.uploading && a.window.qcloud.uploading.descList) ||
          [],
        c = a.project.current,
        d = 'nodejs'
      try {
        d =
          2 === parseInt(c.attr.qcloud.qcloud_product_info.current_language, 10)
            ? 'php'
            : 'nodejs'
      } catch (a) {}
      return {
        env: d,
        qcloud: c && c.qcloud,
        show: a.window.qcloud.uploadIDCShow,
        nickName: a.user.nickName,
        project: c,
        descList: b
      }
    },
    a => {
      return {
        setAutoInstallDependence: b => {
          a(c.setQCloud({ autoInstallDependence: b }))
        },
        setQCloudWnd: b => {
          a(c.setQCloud({ uploading: b }))
        },
        showUploading: (
          b = h.QCLOUD_UPLOADING_STATUS.UPLOADING,
          d = '',
          e = ''
        ) => {
          a(
            c.setQCloud({
              uploading: { show: !0, status: b, text: d, estimateTime: e }
            })
          )
        },
        closeUploading: () => {
          a(
            c.setQCloud({
              uploading: {
                show: !1,
                status: h.QCLOUD_UPLOADING_STATUS.UPLOADING,
                text: ''
              }
            })
          )
        },
        close: () => {
          a(c.setQCloud({ uploadIDCShow: !1 }))
        },
        setProjectQCloud: b => {
          a(d.setProjectQCloud(b))
        },
        setQCloudActionType: (b, d) => {
          a(c.setQCloudActionType({ actionType: b, options: d }))
        },
        notifyFail: b =>
          a(
            f.setConfirmInfo({
              show: !0,
              showCancel: !1,
              title: l.config.QCLOUD_UPLOAD_FAIL_TITLE,
              content: b,
              callback: async () => {
                a(f.setConfirmInfo({ show: !1 }))
              }
            })
          )
      }
    }
  )(o)
})(require('lazyload'), require)
