'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('redux'),
    c = require('./cc2c2970ff81ae4a83123e81ee123da2.js'),
    d = require('./a8c87029da0fa06e986298d447ab0fe2.js'),
    e = require('./6620a0cf7dad1b400d60f0fdae40f524.js'),
    f = require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),
    g = require('./da7c31daaf542cf1796023d8e344b98a.js')
  module.exports = class extends a.Component {
    constructor(a) {
      super(a),
        (this.toggleCheckbox = a => {
          const b = a.currentTarget.dataset.id
          b &&
            this.setState({
              checked: _extends({}, this.state.checked, {
                [b]: !this.state.checked[b]
              })
            })
        }),
        (this.onDel = async a => {
          const b = this.props.list[a.currentTarget.dataset.id]
          if (b) {
            this.props.win && this.props.win.setAlwaysOnTop(!0),
              this.setState({ showMask: !0 })
            const a = await this.props.confirm({
              id: b.projectpath,
              title: `确认删除项目 ${b.projectname} ？`,
              content: `删除项目只会删除记录，不会删除硬盘上的项目文件`
            })
            if (
              (this.props.win && this.props.win.setAlwaysOnTop(!1),
              this.setState({ showMask: !1 }),
              a)
            )
              try {
                this.props.removeProject(b.projectid)
              } catch (a) {}
            this.setState({
              checked: _extends({}, this.state.checked, {
                [b.projectid]: void 0
              })
            }),
              g('weapp_manager_del')
          }
        }),
        (this.onDelMultiple = async () => {
          const a = Object.keys(this.state.checked).filter(
            a => this.state.checked[a]
          )
          if (a && 0 !== a.length) {
            const b = a
                .filter(a => this.props.list[a])
                .map(a => this.props.list[a]),
              c = b.map(a => a.projectname).join('\uFF0C')
            this.props.win && this.props.win.setAlwaysOnTop(!0),
              this.setState({ showMask: !0 })
            const d = await this.props.confirm({
              id: 'PM-MULTI-DEL',
              title: `确认删除项目 ${c}`,
              content: `删除项目只会删除记录，不会删除硬盘上的项目文件`
            })
            if (
              (this.props.win && this.props.win.setAlwaysOnTop(!1),
              this.setState({ showMask: !1 }),
              d)
            )
              for (const a of b)
                try {
                  this.props.removeProject(a.projectid)
                  const c = _extends({}, this.state.checked)
                  for (const a of b) delete c[a.projectid]
                  this.setState({ checked: c })
                } catch (a) {}
            g('weapp_manager_multi_del')
          }
        }),
        (this.onNew = () => {
          'minicode' === this.props.projectManagementWindow.type
            ? this.props.createMiniCodeRequest()
            : this.props.createProjectRequest(),
            this.props.closeProjectManagement(),
            g('weapp_manager_add')
        }),
        (this._compareProject = this.compareProject.bind(this)),
        (this._filterProject = this.filterProject.bind(this)),
        (this.state = { checked: {}, showMask: !1 })
      try {
        a.win.focus()
      } catch (a) {}
    }
    compareProject(c, a) {
      try {
        return (
          (this.props.list[a].accessTime || 1) -
          (this.props.list[c].accessTime || 1)
        )
      } catch (a) {
        return !1
      }
    }
    filterProject(a) {
      if (this.props.projectManagementWindow.filter)
        try {
          return this.props.projectManagementWindow.filter(this.props.list[a])
        } catch (a) {
          return !0
        }
      else return !0
    }
    render() {
      const b = Object.keys(this.props.list)
        .filter(this._filterProject)
        .sort(this._compareProject)
        .map(b => {
          const c = this.props.list[b],
            d = c.appShowImageUrl || ''
          return a.createElement(
            'div',
            { className: 'pm-item ui-flex', key: b },
            a.createElement(
              'div',
              { className: 'pm-item-hd' },
              a.createElement(
                'label',
                { className: 'ui-checkbox' },
                a.createElement('input', { type: 'checkbox' }),
                a.createElement('i', {
                  className: this.state.checked[b]
                    ? 'ui-icon-checkbox-o'
                    : 'ui-icon-checkbox',
                  onClick: this.toggleCheckbox,
                  'data-id': b
                })
              )
            ),
            a.createElement(
              'div',
              { className: 'pm-item-bd ui-flex ui-flex-item' },
              a.createElement(
                'div',
                { className: 'pm-item-logo' },
                a.createElement('img', { src: d, alt: '' })
              ),
              a.createElement(
                'div',
                { className: 'pm-item-info ui-flex-item' },
                a.createElement(
                  'h3',
                  { className: 'pm-item-name' },
                  decodeURIComponent(c.projectname)
                ),
                a.createElement(
                  'p',
                  { className: 'pm-item-desc' },
                  c.projectpath
                )
              )
            ),
            a.createElement(
              'div',
              { className: 'pm-item-ft', onClick: this.onDel, 'data-id': b },
              a.createElement(
                'a',
                null,
                a.createElement('i', { className: 'ui-icon-trash' })
              )
            )
          )
        })
      let c = !0
      for (const a in this.state.checked)
        if (this.state.checked[a]) {
          c = !1
          break
        }
      const d = this.state.showMask ? {} : { display: 'none' }
      return a.createElement(
        'div',
        {
          className: 'container',
          style: { top: 0, width: '100%', position: 'fixed' }
        },
        a.createElement('div', {
          className: 'ui-mask ui-mask-transparent',
          style: d
        }),
        a.createElement(
          'div',
          null,
          a.createElement(
            'div',
            null,
            a.createElement(
              'div',
              { className: 'pm-container' },
              a.createElement('div', { className: 'pm-list' }, b),
              a.createElement(
                'div',
                { className: 'pm-action' },
                a.createElement(
                  'button',
                  {
                    className: 'ui-button ui-button-warn',
                    onClick: this.onDelMultiple,
                    disabled: c
                  },
                  '\u5220\u9664'
                ),
                a.createElement(
                  'button',
                  {
                    className: 'ui-button ui-button-primary',
                    onClick: this.onNew
                  },
                  '\u65B0\u589E'
                )
              )
            )
          )
        )
      )
    }
  }
})(require('lazyload'), require)
