'use strict'
!(function(require, directRequire) {
  const a = require('react'),
    b = require('./6620a0cf7dad1b400d60f0fdae40f524.js'),
    c = require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),
    d = require('./bc04f89cf8edab62335086e0a2a5a103.js'),
    e = require('./da7c31daaf542cf1796023d8e344b98a.js'),
    f = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),
    g = require('./5498e660c05c574f739a28bd5d202cfa.js'),
    h = c.SELECT_PROJECT_TAB
  module.exports = class extends a.Component {
    constructor(a) {
      super(a),
        (this.switchTab = a => {
          const b = a.currentTarget.dataset.type
          'minicode' === b
            ? this.props.currentTab !== h.MINI_CODE &&
              this.props.selectProjectRequest({ tab: h.MINI_CODE })
            : this.props.currentTab !== h.PROJECT &&
              this.props.selectProjectRequest({ tab: h.PROJECT })
        }),
        (this.filterProjectsByTab = a => {
          try {
            return this.props.currentTab === h.MINI_CODE
              ? a.isMiniCode
              : !a.isMiniCode
          } catch (a) {
            return !0
          }
        }),
        (this.handleMaskClick = () => {
          this.setState({ showMask: !1 })
        }),
        (this._compareProject = this.compareProject.bind(this)),
        (this.state = { showMask: !1, focus: '' }),
        this.setupController()
    }
    componentDidMount() {
      this.resize()
    }
    componentWillUnmount() {}
    setupController() {}
    resize() {
      try {
        let a = this.props.win ? this.props.win : global.Win
        this.props.detach ||
          (a.show(),
          a.setResizable(!0),
          a.resizeTo(c.SIZE.SELECT_PROJECT.WIDTH, c.SIZE.SELECT_PROJECT.HEIGHT),
          a.setResizable(!1))
      } catch (a) {}
    }
    cancel() {
      this.props.cancel()
    }
    manageProjects() {
      this.props.setProjectManagement({
        show: !0,
        type: 'project',
        filter: a => !a.isMiniCode
      }),
        e('weapp_manager')
    }
    manageMiniCode() {
      this.props.setProjectManagement({
        show: !0,
        type: 'minicode',
        filter: a => a.isMiniCode
      }),
        e('weapp_manager')
    }
    createMiniCode() {
      switch (this.props.mainWindow) {
        case c.MAIN_WINDOW_TYPE.DEV:
        case c.MAIN_WINDOW_TYPE.WEB_DEBUGGER: {
          this.props.createMiniCodeOpen('create')
          break
        }
        default:
          this.props.createMiniCodeRequest('create')
      }
    }
    importMiniCode() {
      switch (this.props.mainWindow) {
        case c.MAIN_WINDOW_TYPE.DEV:
        case c.MAIN_WINDOW_TYPE.WEB_DEBUGGER: {
          this.props.createMiniCodeOpen('import')
          break
        }
        default:
          this.props.createMiniCodeRequest('import')
      }
    }
    handleQuitClick() {
      f.quit()
    }
    focusProject(a) {
      const b = a.currentTarget.dataset.projectid
      this.setState({ focus: b })
    }
    openProject(a) {
      if (this.props.currentProject) {
        this.props.closeProject()
        const b = a.currentTarget.dataset.projectid
        setTimeout(() => this.props.openProject(b), 50)
      } else this.props.openProject(a.currentTarget.dataset.projectid)
    }
    createProject() {
      switch (this.props.mainWindow) {
        case c.MAIN_WINDOW_TYPE.DEV:
        case c.MAIN_WINDOW_TYPE.WEB_DEBUGGER: {
          this.props.createProjectOpen()
          break
        }
        default:
          this.props.createProjectRequest()
      }
    }
    jumpMiniCodeDoc() {
      nw.Shell.openExternal(
        'https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/minicode.html'
      )
    }
    compareProject(c, a) {
      try {
        return (
          (this.props.projects[a].accessTime || 1) -
          (this.props.projects[c].accessTime || 1)
        )
      } catch (a) {
        return !1
      }
    }
    render() {
      let b = [],
        c = []
      Object.keys(this.props.projects)
        .sort(this._compareProject)
        .forEach(d => {
          const e = this.props.projects[d]
          if (e.isMiniCode) {
            const b = e.appShowImageUrl || g.default_weapp_header
            c.push(
              a.createElement(
                'div',
                {
                  className:
                    this.state.focus === e.projectid
                      ? 'snippet-item snippet-item-active'
                      : 'snippet-item',
                  key: d,
                  'data-projectid': e.projectid,
                  onClick: this.openProject.bind(this)
                },
                a.createElement(
                  'div',
                  { className: 'snippet-hd' },
                  a.createElement('img', {
                    className: 'snippet-avatar',
                    src: b,
                    alt: ''
                  })
                ),
                a.createElement(
                  'div',
                  { className: 'snippet-bd' },
                  a.createElement(
                    'h4',
                    { className: 'snippet-name' },
                    decodeURIComponent(e.projectname)
                  ),
                  a.createElement(
                    'p',
                    { className: 'snippet-desc' },
                    e.projectpath
                  )
                ),
                a.createElement('div', { className: 'snippet-ft' })
              )
            )
          } else {
            const c = e.appShowImageUrl || g.default_weapp_header,
              f = { backgroundSize: 'cover' }
            this.props.covers[e.projectid]
              ? (f.backgroundImage = `url('${this.props.covers[e.projectid]}')`)
              : (f.backgroundColor = '#EDEDED'),
              b.push(
                a.createElement(
                  'div',
                  {
                    className:
                      this.state.focus === e.projectid
                        ? 'project-item project-item-active'
                        : 'project-item',
                    key: d,
                    'data-projectid': e.projectid,
                    onClick: this.openProject.bind(this)
                  },
                  a.createElement('div', {
                    className: 'project-item-cover',
                    style: f
                  }),
                  a.createElement(
                    'div',
                    { className: 'project-logo' },
                    a.createElement('img', { src: c, alt: '' })
                  ),
                  a.createElement(
                    'div',
                    { className: 'project-info' },
                    a.createElement(
                      'h4',
                      null,
                      decodeURIComponent(e.projectname)
                    ),
                    a.createElement('p', null, e.projectpath)
                  )
                )
              )
          }
        })
      const d = this.props.detach ? { display: 'none' } : {},
        e = { WebkitAppRegion: 'no-drag' }
      return a.createElement(
        'div',
        null,
        this.state.showMask
          ? a.createElement('div', {
              className: 'ui-mask ui-mask-transparent',
              onClick: this.handleMaskClick
            })
          : null,
        a.createElement(
          'div',
          { className: 'dashboard' },
          a.createElement(
            'div',
            {
              className: 'dashboard-commands',
              style: { WebkitAppRegion: 'drag' }
            },
            a.createElement(
              'div',
              { className: 'dashboard-navigator', style: d },
              a.createElement(
                'a',
                { style: e, onClick: this.props.cancel },
                a.createElement('i', { className: 'ui-icon-back' })
              )
            ),
            a.createElement(
              'div',
              { className: 'dashboard-brand' },
              a.createElement(
                'div',
                { className: 'dashboard-logo' },
                a.createElement('i', { className: 'ui-icon-mini-app' })
              ),
              a.createElement(
                'h3',
                { className: 'dashboard-caption' },
                '\u5C0F\u7A0B\u5E8F\u9879\u76EE'
              ),
              a.createElement(
                'p',
                { className: 'dashboard-subtitle' },
                '\u7F16\u8F91\u3001\u8C03\u8BD5\u5C0F\u7A0B\u5E8F'
              )
            ),
            a.createElement(
              'div',
              { className: 'dashboard-content' },
              a.createElement(
                'section',
                { className: 'dashboard-content-section' },
                a.createElement('h4', null, '\u5E2E\u52A9'),
                a.createElement(
                  'ul',
                  null,
                  a.createElement(
                    'li',
                    { style: e },
                    a.createElement(
                      'a',
                      { onClick: this.props.openDoc },
                      '\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u6587\u6863'
                    )
                  ),
                  a.createElement(
                    'li',
                    { style: e },
                    a.createElement(
                      'a',
                      { onClick: this.props.openBBS },
                      '\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u793E\u533A'
                    )
                  )
                )
              )
            ),
            a.createElement(
              'div',
              { className: 'dashboard-command-ft' },
              a.createElement(
                'div',
                { className: 'luncher-account', style: e },
                a.createElement(
                  'div',
                  { className: 'luncher-account-avatar' },
                  a.createElement('img', {
                    src: this.props.user ? this.props.user.headUrl : '',
                    alt: ''
                  })
                ),
                a.createElement(
                  'div',
                  {
                    className: 'luncher-account-name',
                    onClick: this.props.logout
                  },
                  a.createElement('p', null, '\u5207\u6362\u5E10\u53F7'),
                  a.createElement('i', { className: 'ui-icon-arrow-right-o' })
                )
              )
            )
          ),
          a.createElement(
            'div',
            { className: 'dashboard-splash' },
            a.createElement(
              'div',
              { className: 'dashboard-splash-bd' },
              a.createElement(
                'div',
                { className: 'tab' },
                a.createElement(
                  'div',
                  { className: 'tab-hd' },
                  a.createElement(
                    'div',
                    {
                      className:
                        'tab-hd-item' +
                        (this.props.currentTab === h.PROJECT
                          ? ' tab-hd-item-active'
                          : ''),
                      'data-type': 'project',
                      onClick: this.switchTab
                    },
                    '\u9879\u76EE'
                  ),
                  a.createElement(
                    'div',
                    {
                      className:
                        'tab-hd-item' +
                        (this.props.currentTab === h.MINI_CODE
                          ? ' tab-hd-item-active'
                          : ''),
                      'data-type': 'minicode',
                      onClick: this.switchTab
                    },
                    '\u4EE3\u7801\u7247\u6BB5'
                  )
                ),
                a.createElement(
                  'div',
                  { className: 'tab-bd' },
                  a.createElement(
                    'div',
                    {
                      className:
                        'tab-content' +
                        (this.props.currentTab === h.PROJECT
                          ? ' tab-content-active'
                          : '')
                    },
                    a.createElement(
                      'div',
                      { className: 'miniapps' },
                      a.createElement('div', { className: 'miniapp-list' }, b),
                      a.createElement(
                        'div',
                        { className: 'miniapp-opr' },
                        a.createElement(
                          'div',
                          { className: 'ui-flex' },
                          a.createElement(
                            'div',
                            { className: 'ui-flex-item' },
                            a.createElement(
                              'a',
                              {
                                style: e,
                                onClick: this.manageProjects.bind(this)
                              },
                              '\u7BA1\u7406\u9879\u76EE'
                            )
                          ),
                          a.createElement(
                            'div',
                            null,
                            a.createElement(
                              'a',
                              { style: e },
                              a.createElement('i', {
                                className: 'ui-icon-plus',
                                onClick: this.createProject.bind(this)
                              })
                            )
                          )
                        )
                      )
                    )
                  ),
                  a.createElement(
                    'div',
                    {
                      className:
                        'tab-content' +
                        (this.props.currentTab === h.MINI_CODE
                          ? ' tab-content-active'
                          : '')
                    },
                    a.createElement(
                      'div',
                      { className: 'snippets' },
                      a.createElement(
                        'div',
                        { className: 'snippet-list' },
                        c,
                        0 < c.length
                          ? null
                          : a.createElement(
                              'div',
                              { className: 'snippet-item-empty' },
                              a.createElement(
                                'p',
                                null,
                                '\u4EE3\u7801\u7247\u6BB5\u662F\u4E00\u79CD\u53EF\u5206\u4EAB\u7684\u5C0F\u9879\u76EE ',
                                a.createElement(
                                  'a',
                                  {
                                    onClick: this.jumpMiniCodeDoc,
                                    href: 'javascript:;'
                                  },
                                  '\u6587\u6863\u94FE\u63A5'
                                )
                              )
                            )
                      ),
                      a.createElement(
                        'div',
                        { className: 'snippet-opr' },
                        a.createElement(
                          'div',
                          { className: 'ui-flex' },
                          a.createElement(
                            'div',
                            { className: 'ui-flex-item' },
                            a.createElement(
                              'a',
                              {
                                style: e,
                                onClick: this.manageMiniCode.bind(this)
                              },
                              '\u7BA1\u7406\u4EE3\u7801\u7247\u6BB5'
                            )
                          ),
                          a.createElement(
                            'div',
                            null,
                            a.createElement(
                              'a',
                              {
                                style: e,
                                onClick: this.createMiniCode.bind(this)
                              },
                              '\u521B\u5EFA'
                            ),
                            a.createElement('span', {
                              className: 'snippet-opr-sep'
                            }),
                            a.createElement(
                              'a',
                              {
                                style: e,
                                onClick: this.importMiniCode.bind(this)
                              },
                              '\u5BFC\u5165'
                            )
                          )
                        )
                      )
                    )
                  )
                )
              )
            )
          )
        )
      )
    }
  }
})(require('lazyload'), require)
