'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('lodash'),
    { REHYDRATE: b } = require('redux-persist/constants'),
    c = require('./46696da2c374c1de94184ccaf32ab38a.js'),
    d = require('./0634ee2ebd3e560d9d4804ecc960160f.js'),
    e = require('./eadce02c750c875a10680bcfedadec88.js'),
    f = require('./6242f55dbdfe53c2f07b7a51568311f2.js'),
    g = () => {
      return c.map(a => {
        let b = a.statusbarHeight || f.default_statusbar_height,
          c = f.default_android_navigationbar_height,
          d = f.default_android_tabbar_height
        'iOS' == a.os &&
          ((c = f.default_ios_navigationbar_height),
          (d = a.tabbarHeight || f.default_ios_tabbar_height))
        let { height: e, width: g, dpr: h, title: i } = a,
          j = {
            os: a.os,
            ua: a.ua,
            title: i,
            model: i,
            dpr: h,
            screenHeight: e,
            screenWidth: g,
            statusbarHeight: b,
            navigationbarHeight: c,
            tabbarHeight: d
          }
        return {
          name: i,
          desc: `${g} x ${e} | Dpr:${h}`,
          type: 'default',
          info: j
        }
      })
    },
    h = () => {
      let a = g()
      return {
        clickKey: 'none',
        network: { current: 0, list: ['wifi', '2g', '3g', '4g', 'none'] },
        device: { current: 0, list: a },
        deviceInfo: _extends({}, a[0].info),
        deviceStatus: {
          brightness: 0.5,
          accelerometer: !1,
          compass: !1,
          screenon: !1
        },
        compileType: {
          current: 'weapp',
          list: {
            weapp: '\u5C0F\u7A0B\u5E8F',
            widget: '\u52A8\u6001\u9875',
            search: '\u641C\u7D22\u9875'
          }
        },
        deviceScale: 1,
        config: {
          title: !0,
          cos: !0,
          qcloud: !0,
          test: !0,
          tgit: !0,
          upload: !0
        }
      }
    }
  module.exports = function(c = h(), i = {}) {
    switch (i.type) {
      case d.BODY_CLICK:
        return _extends({}, c, { clickKey: e.NONE })
      case d.TOOLBAR_TOGGLE_NETWORK: {
        let a = c.clickKey == e.NETWORK ? e.NONE : e.NETWORK
        return _extends({}, c, { clickKey: a })
      }
      case d.TOOLBAR_TOGGLE_DEVICE: {
        let a = c.clickKey == e.DEVICE ? e.NONE : e.DEVICE
        return _extends({}, c, { clickKey: a })
      }
      case d.TOOLBAR_TOGGLE_COMPACT: {
        let a = c.clickKey == e.COMPACT ? e.NONE : e.COMPACT
        return _extends({}, c, { clickKey: a })
      }
      case d.TOOLBAR_TOGGLE_INFO: {
        let a = c.clickKey == e.INFO ? e.NONE : e.INFO
        return _extends({}, c, { clickKey: a })
      }
      case d.TOOLBAR_TOGGLE_COMPILETYPE: {
        let a = c.clickKey == e.COMPILETYPE ? e.NONE : e.COMPILETYPE
        return _extends({}, c, { clickKey: a })
      }
      case d.WINDOW_SET_MAIN_WINDOW:
        return _extends({}, c, { clickKey: e.NONE })
      case d.TOOLBAR_SELECT_NETWORK:
        return _extends({}, c, {
          clickKey: e.NONE,
          network: _extends({}, c.network, { current: i.data })
        })
      case d.TOOLBAR_SELECT_DEVICE: {
        let a
        try {
          a = c.device.list[i.data].info
        } catch (a) {
          return c
        }
        return _extends({}, c, {
          clickKey: e.NONE,
          device: _extends({}, c.device, { current: i.data }),
          deviceInfo: a
        })
      }
      case d.TOOLBAR_SELECT_COMPILETYPE:
        return _extends({}, c, {
          clickKey: e.NONE,
          compileType: _extends({}, c.compileType, { current: i.data })
        })
      case d.TOOLBAR_TOGGLE_CLICKKEY: {
        let a = c.clickKey == i.clickKey ? e.NONE : i.clickKey
        return _extends({}, c, { clickKey: a })
      }
      case d.TOOLBAR_PREVIEW_CODE:
        return _extends({}, c, { clickKey: e.PREVIEWCODE })
      case d.TOOLBAR_REMOTE_DEBUG_CODE:
        return _extends({}, c, { clickKey: e.REMOTEDEBUGCODE })
      case d.TOOLBAR_SET_DEVICE_STATUS:
        return _extends({}, c, {
          deviceStatus: _extends({}, c.deviceStatus, i.data)
        })
      case d.TOOLBAR_SET_CLICKKEY:
        return _extends({}, c, { clickKey: i.data })
      case d.WINDOW_RESIZE:
        return _extends({}, c, { clickKey: e.NONE })
      case d.PROJECT_CLOSE_PROJECT:
        return _extends({}, c, { clickKey: e.NONE })
      case d.TOOLBAR_SET_DEVICESCALE:
        return _extends({}, c, { deviceScale: i.data })
      case d.USER_LOGIN_EXPIRED:
        return _extends({}, c, { clickKey: e.LOGINQRCODE })
      case d.TOOLBAR_ADD_DEVICE: {
        const a = global.appVersion
        let b = [].concat(c.device.list),
          { height: d, width: e, dpr: g, name: h } = i.data,
          j = {
            title: h,
            os: 'Android',
            ua: `Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36 wechatdevtools/${a} MicroMessenger/${'6.5.7'} webview/{{webviewID}}`,
            dpr: g,
            screenWidth: e,
            screenHeight: d,
            statusbarHeight: f.default_statusbar_height,
            navigationbarHeight: f.default_android_navigationbar_height,
            tabbarHeight: f.default_android_tabbar_height
          },
          k = {
            name: h,
            desc: `${e} x ${d} | Dpr:${g}`,
            type: 'custom',
            info: j
          }
        return (
          b.push(k),
          _extends({}, c, {
            device: { current: b.length - 1, list: b },
            deviceInfo: _extends({}, j)
          })
        )
      }
      case d.TOOLBAR_REMOVE_DEVICE: {
        try {
          let a = c.device.list[i.data]
          if ('custom' == a.type) {
            let a = [].concat(c.device.list)
            a.splice(i.data, 1)
            let b = _extends({}, c, {
              device: { current: 0, list: a },
              deviceInfo: _extends({}, a[0].info)
            })
            return b
          }
        } catch (a) {}
        return c
      }
      case d.TOOLBAR_CONFIG:
        return _extends({}, c, { config: _extends({}, c.config, i.data) })
      case b: {
        let b = a.merge(a.cloneDeep(c), i.payload.toolbar || {})
        b.clickKey = e.NONE
        let d = g()
        return (
          b.device.list.forEach(a => {
            'default' != a.type && d.push(a)
          }),
          (b.device.list = d),
          (b.deviceInfo.ua = b.deviceInfo.ua.replace(
            /wechatdevtools\/([\d\.]*)/,
            `wechatdevtools/${global.appVersion}`
          )),
          'iPhone X' == b.deviceInfo.model && (b.deviceInfo.tabbarHeight = 82),
          b
        )
      }
      default:
        return c
    }
  }
})(require('lazyload'), require)
