'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('fs'),
    b = require('path'),
    c = require('mkdir-p'),
    d = require('glob'),
    e = require('lodash'),
    f = require('./0634ee2ebd3e560d9d4804ecc960160f.js'),
    g = require('./f171257bbcaef547a3cf27266ccb0db2.js'),
    h = require('./15ba1827c7f6564a45df6bd44da3a977.js'),
    i = require('./logger.js'),
    j = require('./3bfffbe88b3d923921f851c0697974fe.js'),
    k = require('./d28a711224425b00101635efe1034c99.js'),
    l = require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),
    m = require('./a8c87029da0fa06e986298d447ab0fe2.js'),
    n = require('./84858de8a097c9cf84ff2c2e3d86e2a9.js'),
    o = require('./df6d0ff021a69fb541c733de4dbba0fe.js'),
    p = require('./da7c31daaf542cf1796023d8e344b98a.js'),
    q = require('./common/locales/index.js'),
    r = require('./9fdd4ac31a05c27355910f0d74accd4c.js'),
    s = require('./42191d95974f14b18961c9f2c730464e.js'),
    t = require('./1fcc6bd55b687d154a4247e57fe3011d.js'),
    u = require('./6242f55dbdfe53c2f07b7a51568311f2.js'),
    v = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),
    w = require('./tools.js'),
    x = require('./eb1fe4da47d7ed10884f8b039b058c5b.js'),
    y = require('./9ebfd1a4a241684455002e8c6d889fd7.js'),
    z = require('./881e653f19d837f2408386047cb8c38c.js'),
    A = require('./b543ae2da406cea63b3ad8951f17b6c0.js'),
    {
      default_weapp_header: B
    } = require('./5498e660c05c574f739a28bd5d202cfa.js'),
    C = 'darwin' === process.platform,
    D = (a, b) => {
      if (!a) return !1
      b = _extends({}, b || {})
      const c = [
        'setting',
        'compileType',
        'condiction',
        'libVersion',
        'appid',
        'projectname',
        'svr',
        'client',
        'qcloudRoot',
        'miniprogramRoot',
        'pluginRoot',
        'isGameTourist',
        'packOptions',
        'scripts'
      ]
      for (let d in b)
        b.hasOwnProperty(d) && 0 > c.findIndex(a => a === d) && delete b[d]
      const d = s.generateConfigTemplate(),
        e = _extends(
          {},
          d,
          {
            setting: _extends({}, a.setting),
            compileType: a.compileType,
            condiction: a.condiction,
            libVersion: a.libVersion,
            appid: a.appid,
            projectname: a.projectname,
            svr: a.svr,
            client: a.client,
            qcloudRoot: a.qcloudRoot,
            miniprogramRoot: a.miniprogramRoot,
            pluginRoot: a.pluginRoot,
            packOptions: a.packOptions,
            scripts: a.scripts
          },
          b
        )
      delete e.setting.scriptsEnable
      const f = s.writeObjectToConfigFile(a, e)
      return !f.error
    },
    E = (a, b, c) => d => {
      return 'parseerror' === a
        ? void d(
            t.setConfirmInfo({
              show: !0,
              showCancel: !0,
              title: '',
              content:
                'project.config.json \u6587\u4EF6\u53EF\u80FD\u635F\u574F\u3002\u662F\u5426\u91CD\u65B0\u521B\u5EFA\u6B64\u6587\u4EF6\uFF1F',
              callback(a) {
                a && D(b, c)
              }
            })
          )
        : void D(b, c)
    },
    F = a => (b, c) => {
      const d = c()
      if (!a) {
        if (((a = d.project.current), !a || a.isTemp)) return
        ;(a.accessTime = +new Date()),
          n.updateProject(a.projectid, a),
          b({
            type: f.PROJECT_UPDATE_LIST,
            list: _extends({}, d.project.list, { [a.projectid]: a })
          })
      } else
        (a.accessTime = +new Date()),
          n.updateProject(a.projectid, a),
          b({
            type: f.PROJECT_UPDATE_LIST,
            list: _extends({}, d.project.list, { [a.projectid]: a })
          })
    },
    G = a =>
      Object.prototype.toString
        .call(a)
        .toLowerCase()
        .slice(8, -1),
    H = (a, b, c, d) => {
      return G(b) === c ? (d ? (0 <= d.findIndex(a => a === b) ? b : a) : b) : a
    }
  module.exports = {
    selectDevType: a => (b, c) => {
      if (a !== l.DEV_TYPE.MP_WEB)
        try {
          const a = c().project.list
          0 < Object.keys(a).length
            ? b(m.setMainWindow(l.MAIN_WINDOW_TYPE.SELECT_PROJECT))
            : b(m.setMainWindow(l.MAIN_WINDOW_TYPE.CREATE_PROJECT))
        } catch (a) {
          b(m.setMainWindow(l.MAIN_WINDOW_TYPE.SELECT_PROJECT))
        }
      else
        x.openWebDebugger(),
          (n.lastSelect = l.MAIN_WINDOW_TYPE.WEB_DEBUGGER),
          p('url_open')
    },
    selectProjectRequest: a => {
      return { type: f.PROJECT_SELECT_PROJECT_REQUEST, options: a }
    },
    selectProjectCancel: () => {
      return { type: f.PROJECT_SELECT_PROJECT_CANCEL }
    },
    selectProjectOpen: a => () => {
      y.selectProjectOpen(a)
    },
    selectProjectClose: () => {
      return { type: f.PROJECT_SELECT_PROJECT_CLOSE }
    },
    createProjectRequest: () => {
      return { type: f.PROJECT_CREATE_PROJECT_REQUEST }
    },
    createProjectSuccess: (
      g,
      { initQuickStart: h = !1, quickstartHost: k = '' } = {}
    ) => m => {
      const n = e.merge(j.projectConfigDefault(g), g)
      if (h) {
        let e,
          f = g.projectpath
        e =
          h === l.QUICKSTART_TYPE.WEAPP
            ? 'weapp'
            : h === l.QUICKSTART_TYPE.QCLOUD_NODEJS
              ? 'node'
              : h === l.QUICKSTART_TYPE.QCLOUD_PHP
                ? 'php'
                : h === l.QUICKSTART_TYPE.QCLOUD_NODEJS_GAME
                  ? 'node-game'
                  : h === l.QUICKSTART_TYPE.QCLOUD_PHP_GAME
                    ? 'php-game'
                    : h === l.QUICKSTART_TYPE.PLUGIN
                      ? 'plugin'
                      : h === l.QUICKSTART_TYPE.GAME
                        ? 'game'
                        : h === l.QUICKSTART_TYPE.WEAPP_MINI
                          ? 'weapp-mini'
                          : h === l.QUICKSTART_TYPE.GAME_MINI
                            ? 'game-mini'
                            : h === l.QUICKSTART_TYPE.PLUGIN_MINI
                              ? 'plugin-mini'
                              : 'weapp'
        let j = global.appConfig.isDev
          ? b.join(__dirname, '../../vendor/quickstart', e)
          : b.join(__dirname, './vendor/quickstart', e)
        try {
          let e = d.sync(`./**/**`, { cwd: j })
          if (
            (e.forEach(d => {
              let e = b.join(j, d),
                h = b.join(f, d),
                i = a.lstatSync(e)
              if (i.isDirectory()) c.sync(h)
              else {
                let c = a.readFileSync(e)
                g.compileType == r.plugin &&
                  'app.json' == b.basename(d) &&
                  (c = c.toString().replace('{{provider}}', g.appid)),
                  a.writeFileSync(h, c)
              }
            }),
            h === l.QUICKSTART_TYPE.QCLOUD_NODEJS)
          ) {
            let c = b.join(f, './server/config.js'),
              d = a.readFileSync(c, 'utf8')
            if (
              (a.writeFileSync(
                c,
                d
                  .replace(`appId: '',`, `appId: '${n.appid}',`)
                  .replace(`pass: '',`, `pass: '${n.appid}',`),
                'utf8'
              ),
              k)
            ) {
              let c = b.join(f, './client/config.js'),
                d = a.readFileSync(c, 'utf8')
              a.writeFileSync(
                c,
                d.replace(`host = 'https://123456.qcloud.la'`, `host = '${k}'`),
                'utf8'
              )
            }
          } else if (h === l.QUICKSTART_TYPE.QCLOUD_PHP) {
            let c = b.join(f, './server/config.php'),
              d = a.readFileSync(c, 'utf8')
            if (
              (a.writeFileSync(
                c,
                d
                  .replace(`'appId' => '',`, `'appId' => '${n.appid}',`)
                  .replace(`'pass' => '',`, `'pass' => '${n.appid}',`),
                'utf8'
              ),
              k)
            ) {
              let c = b.join(f, './client/config.js'),
                d = a.readFileSync(c, 'utf8')
              a.writeFileSync(
                c,
                d.replace(`host = 'https://123456.qcloud.la'`, `host = '${k}'`),
                'utf8'
              )
            }
          } else if (h === l.QUICKSTART_TYPE.QCLOUD_NODEJS_GAME) {
            let c = b.join(f, './server/config.js'),
              d = a.readFileSync(c, 'utf8')
            if (
              (a.writeFileSync(
                c,
                d
                  .replace(`appId: '',`, `appId: '${n.appid}',`)
                  .replace(`pass: '',`, `pass: '${n.appid}',`),
                'utf8'
              ),
              k)
            ) {
              let c = b.join(f, './client/config.js'),
                d = a.readFileSync(c, 'utf8')
              a.writeFileSync(
                c,
                d.replace(`host = 'https://123456.qcloud.la'`, `host = '${k}'`),
                'utf8'
              )
            }
          } else if (h === l.QCLOUD_ACTION_TYPE.QCLOUD_PHP_GAME) {
            let c = b.join(f, './server/config.php'),
              d = a.readFileSync(c, 'utf8')
            if (
              (a.writeFileSync(
                c,
                d
                  .replace(`'appId' => '',`, `'appId' => '${n.appid}',`)
                  .replace(`'pass' => '',`, `'pass' => '${n.appid}',`),
                'utf8'
              ),
              k)
            ) {
              let c = b.join(f, './client/config.js'),
                d = a.readFileSync(c, 'utf8')
              a.writeFileSync(
                c,
                d.replace(`host = 'https://123456.qcloud.la'`, `host = '${k}'`),
                'utf8'
              )
            }
          }
        } catch (a) {
          i.error(`project.actions.js initProject error ${a.toString()}`)
        }
      }
      const o = s.getConfigFileInfo(g)
      if (!o.error) {
        const a = _extends({}, o.config, {
          appid: n.appid,
          projectname: n.projectname
        })
        g.isGameTourist && (a.setting.urlCheck = !1),
          s.writeObjectToConfigFile(g, a)
      } else D(g, n)
      m({ type: f.PROJECT_CREATE_PROJECT_SUCCESS, project: n }), m(F(n))
    },
    createProjectFail: a => {
      return { type: f.PROJECT_CREATE_PROJECT_FAIL, err: a }
    },
    createProjectCancel: () => (a, b) => {
      b()
      try {
        const c = b().project.list
        0 < Object.keys(c).length
          ? a(m.setMainWindow(l.MAIN_WINDOW_TYPE.SELECT_PROJECT))
          : a(m.setMainWindow(l.MAIN_WINDOW_TYPE.ENTRANCE))
      } catch (b) {
        a(m.setMainWindow(l.MAIN_WINDOW_TYPE.SELECT_PROJECT))
      }
    },
    createProjectOpen: () => () => {
      y.createProjectOpen()
    },
    createProjectClose: () => {
      return { type: f.PROJECT_CREATE_PROJECT_CLOSE }
    },
    createMiniCodeRequest: (a = 'create', b) => {
      return {
        type: f.PROJECT_CREATE_MINICODE_REQUEST,
        createType: a,
        options: b
      }
    },
    createMiniCodeOpen: (a, b) => () => {
      y.createMiniCodeOpen(a, b)
    },
    createMiniCodeClose: () => {
      return { type: f.PROJECT_CREATE_MINICODE_CLOSE }
    },
    removeProject: a => b => {
      n.removeProject(a),
        A.closeDevWindow(a),
        b({ type: f.PROJECT_REMOVE_PROJECT, id: a })
    },
    openProject: a => b =>
      new Promise(async (c, d) => {
        try {
          const d = n.projectList
          d[a] || i.error(`open project with unknown projectid ${a}`)
          const e = d[a]
          e && (e.storage = {}), (e.accessTime = +new Date())
          let { appid: f, projectname: g, projectpath: h } = e
          ;(h = encodeURIComponent(h)),
            x.openMiniProgram({ appid: f, projectname: g, projectpath: h }),
            c(),
            b(F()),
            (n.lastSelect = a),
            p('project_open', e.appid)
        } catch (a) {
          d(a)
        }
      }),
    closeProject: () => (a, b) => {
      const c = b()
      c.window.remoteDebugWindow.debuggingProjectId ===
        c.project.current.projectid &&
        a(m.setRemoteDebugWindow({ show: !1, debuggingProjectId: null })),
        z.notifyCloseWindow(!0),
        global.windowMap.forEach(a => {
          try {
            a !== Win && a.close(!0)
          } catch (a) {}
        }),
        nw.Window.get().close(!0)
    },
    requestProjectAttr: () => a =>
      new Promise(async b => {
        let c = j.getCurrent()
        if (!(c && c.isTourist))
          try {
            const d = await j.getLatestProjectAttr()
            a({ type: f.PROJECT_UPDATE_ATTR, data: d }),
              a({
                type: f.SIMULATOR_SET_GROUP_INFO,
                data: { list: d.share_info }
              }),
              a(F(c)),
              b()
          } catch (d) {
            i.error(`requestProjectAttr catch error ${d}`),
              d === q.config.CGI_ERR_NOT_BAND
                ? a({
                    type: f.PROJECT_UPDATE_ATTR,
                    data: { userbanded: !1 },
                    project: c
                  })
                : (d === q.config.CGI_ERR_PLATFORM_INVALID_EXT_APPID ||
                    d === q.config.CGI_ERR_PLATFORM_EXT_APPID_NOT_AUTH) &&
                  a({ type: f.PROJECT_SET_EXT_INFO, data: { errMsg: d } }),
              b(d)
          }
      }),
    setCompileCondiction: a => b => {
      b({ type: f.PROJECT_SET_COMPILE_CONDICTION, data: a })
      const c = j.getCurrent(),
        d = c.compileType,
        e = s.getConfigFileInfo(c),
        g = [...c.condiction[d].list]
      if (e.error)
        b(
          E(e.error.type, c, {
            condiction: _extends({}, c.condiction, {
              [d]: _extends({}, c.condiction[d], { list: g })
            })
          })
        )
      else {
        const a = _extends({}, e.config, {
          condiction: _extends({}, c.condiction, e.config.condiction || {}, {
            [d]: _extends({}, c.condiction[d], { list: g })
          })
        })
        s.writeObjectToConfigFile(c, a)
      }
      b(F())
    },
    removeCompileCondiction: a => b => {
      b({ type: f.PROJECT_REMOVE_COMPILE_CONDICTION, data: a })
      const c = j.getCurrent(),
        d = c.compileType,
        e = s.getConfigFileInfo(c),
        g = [...c.condiction[d].list]
      if (e.error)
        b(
          E(e.error.type, c, {
            condiction: _extends({}, c.condiction, {
              [d]: _extends({}, c.condiction[d], { list: g })
            })
          })
        )
      else {
        const a = _extends({}, e.config, {
          condiction: _extends({}, c.condiction, e.config.condiction || {}, {
            [d]: _extends({}, c.condiction[d], { list: g })
          })
        })
        s.writeObjectToConfigFile(c, a)
      }
      b(F())
    },
    setProjectSetting: a => b => {
      const c = j.getCurrent()
      b({ type: f.PROJECT_SET_SETTING, data: a })
      const d = s.getConfigFileInfo(c)
      if (d.error) {
        let e = _extends({}, c.setting, a)
        delete e.scriptsEnable, b(E(d.error.type, c, { setting: e }))
      } else {
        const b = _extends({}, d.config, {
          setting: _extends({}, c.setting, d.config.setting || {}, a)
        })
        delete b.setting.scriptsEnable, s.writeObjectToConfigFile(c, b)
      }
      b(F())
    },
    selectCompileCondiction: a => b => {
      b({ type: f.PROJECT_SELECT_COMPILE_CONDICTION, current: a })
      const c = j.getCurrent(),
        d = c.compileType,
        e = s.getConfigFileInfo(c)
      if (e.error)
        b(
          E(e.error.type, c, {
            condiction: _extends({}, c.condiction, {
              [d]: _extends({}, c.condiction[d], { current: a })
            })
          })
        )
      else {
        const b = _extends({}, e.config, {
          condiction: _extends({}, c.condiction, e.config.condiction || {}, {
            [d]: _extends({}, c.condiction[d], { current: a })
          })
        })
        s.writeObjectToConfigFile(c, b)
      }
      b(F())
    },
    setProjectLibVersion: a => b => {
      k.setVersionAsync(a), b({ type: f.PROJECT_SET_LIBVERSION, data: a })
      const c = j.getCurrent(),
        d = s.getConfigFileInfo(c)
      if (d.error) b(E(d.error.type, c, { libVersion: a }))
      else {
        const b = _extends({}, d.config, { libVersion: a })
        s.writeObjectToConfigFile(c, b)
      }
      b(F())
    },
    checkUploadStatus: () => {
      let a = j.getCurrent()
      if (a.compileType == r.plugin) {
        return {
          type: f.INFO_SET_UPLOAD,
          data: {
            status: 1,
            wording:
              '\u6B63\u5728\u4E0A\u4F20\u63D2\u4EF6\u4EE3\u7801\uFF0C\u662F\u5426\u7EE7\u7EED\uFF1F'
          }
        }
      }
      if (a && a.pluginInfo && a.pluginInfo.length)
        try {
          for (const b of a.pluginInfo)
            if (
              b.current &&
              b.onlineVersion &&
              b.onlineVersion !== b.current.version &&
              0 > w.compareSemVer(b.current.version, b.onlineVersion)
            )
              return {
                type: f.INFO_SET_UPLOAD,
                data: {
                  status: 1,
                  wording: `插件 ${b.name} 当前选择的版本 (${
                    b.current.version
                  }) 小于线上小程序使用的版本 (${b.onlineVersion})，是否继续？`
                }
              }
        } catch (a) {
          i.error(
            `project.actions.js check plugin info during checkUploadStatus failed with error: ${a.toString()}`
          )
        }
      return b => {
        h({
          url: `${g.uploadQrCodeURL}?appid=${a.appid}`,
          method: 'get',
          needToken: 1
        })
          .then(({ resp: a, body: c }) => {
            let d =
              1 === c.is_experience
                ? '\u4E0A\u6B21\u63D0\u4EA4\u5DF2\u88AB\u9009\u4E3A\u4F53\u9A8C\u7248\uFF0C\u672C\u6B21\u4E0A\u4F20\u5C06\u4F1A\u8986\u76D6\u4F53\u9A8C\u7248\uFF0C\u662F\u5426\u7EE7\u7EED\uFF1F'
                : '\u4E0A\u4F20\u6210\u529F\u540E\uFF0C\u9700\u8981\u8054\u7CFB\u7BA1\u7406\u5458\u5728\u5C0F\u7A0B\u5E8F\u7BA1\u7406\u540E\u53F0\u5C06\u672C\u6B21\u4E0A\u4F20\u8BBE\u7F6E\u4E3A\u4F53\u9A8C\u7248\u672C\u3002'
            b({ type: f.INFO_SET_UPLOAD, data: { status: 1, wording: d } })
          })
          .catch(a => {
            b({ type: f.INFO_SET_UPLOAD, data: { show: !1 } }),
              b({ type: f.INFO_SHOW_ERROR, data: { message: a.toString() } })
          })
      }
    },
    setProjectCompileType: a => {
      return b => {
        b({ type: f.PROJECT_SET_COMPILE_TYPE, data: a })
        const c = j.getCurrent(),
          d = s.getConfigFileInfo(c)
        if (d.error) b(E(d.error.type, c, { compileType: a }))
        else {
          const b = _extends({}, d.config, { compileType: a })
          s.writeObjectToConfigFile(c, b)
        }
        b(F())
      }
    },
    setProjectQCloud: a => {
      return { type: f.PROJECT_SET_QCLOUD, data: a }
    },
    setPkgSize: a => b => {
      b({ type: f.PROJECT_SET_PKG_SIZE, data: a }), b(F())
    },
    setPluginInfo: a => b => {
      b({ type: f.PROJECT_SET_PLUGIN_INFO, data: a }), b(F())
    },
    setProjectConfig: a => b => {
      const c = j.getCurrent()
      ;(a.setting = a.setting || {}),
        (a.scripts = H({}, a.scripts, 'object')),
        (a.condiction = a.condiction || {}),
        (a.condiction.weapp = a.condiction.weapp || {}),
        (a.condiction.weapp.list = H(
          [...c.condiction.weapp.list],
          a.condiction.weapp.list,
          'array'
        )),
        (a.condiction.search = a.condiction.search || {}),
        (a.condiction.search.list = H(
          [...c.condiction.search.list],
          a.condiction.search.list,
          'array'
        )),
        (a.condiction.conversation = a.condiction.conversation || {}),
        (a.condiction.conversation.list = H(
          [...c.condiction.conversation.list],
          a.condiction.conversation.list,
          'array'
        )),
        (a.condiction.plugin = a.condiction.plugin || {}),
        (a.condiction.plugin.list = H(
          [...c.condiction.plugin.list],
          a.condiction.plugin.list,
          'array'
        )),
        (a.condiction.game = a.condiction.game || {}),
        (a.condiction.game.list = H(
          [...c.condiction.game.list],
          a.condiction.game.list,
          'array'
        )),
        (a.packOptions = a.packOptions || {}),
        (a.packOptions.ignore = H([], a.packOptions.ignore, 'array'))
      const d = [],
        e = ['folder', 'file', 'suffix', 'prefix']
      for (const c of a.packOptions.ignore)
        c &&
          'string' === G(c.value) &&
          0 <= e.findIndex(a => a === c.type) &&
          d.push({ value: c.value, type: c.type })
      const g = []
      for (let c of a.condiction.weapp.list)
        c &&
          'number' === G(c.id) &&
          'string' === G(c.name) &&
          'string' === G(c.pathName) &&
          g.push({
            id: c.id,
            name: c.name,
            pathName: c.pathName,
            query: H('', c.query, 'string'),
            scene: c.scene,
            shareInfo: H(void 0, c.shareInfo, 'object'),
            referrerInfo: H(void 0, c.referrerInfo, 'object')
          })
      const h = []
      for (let c of a.condiction.plugin.list)
        c &&
          'number' === G(c.id) &&
          'string' === G(c.name) &&
          'string' === G(c.pathName) &&
          h.push({
            id: c.id,
            name: c.name,
            pathName: c.pathName,
            query: H('', c.query, 'string'),
            scene: c.scene,
            shareInfo: H(void 0, c.shareInfo, 'object'),
            referrerInfo: H(void 0, c.referrerInfo, 'object')
          })
      const i = []
      for (let c of a.condiction.search.list)
        c &&
          'number' === G(c.id) &&
          'string' === G(c.name) &&
          i.push({
            id: c.id,
            name: c.name,
            widgetData: H('', c.widgetData, 'string'),
            service: H(void 0, c.service, 'object'),
            query: H('', c.query, 'string'),
            customQuery: H('', c.customQuery, 'string'),
            boxQI: H('', c.boxQI, 'string'),
            debugUrl: H('', c.debugUrl, 'string')
          })
      const l = []
      for (let c of a.condiction.conversation.list)
        c &&
          'number' === G(c.id) &&
          'string' === G(c.name) &&
          l.push({
            id: c.id,
            name: c.name,
            pathName: H(void 0, c.pathName, 'string'),
            title: H(void 0, c.title, 'string'),
            cachekey: H(void 0, c.cachekey, 'string')
          })
      const m = []
      for (let c of a.condiction.game.list)
        c &&
          'number' === G(c.id) &&
          'string' === G(c.name) &&
          m.push({
            id: c.id,
            name: c.name,
            query: H('', c.query, 'string'),
            scene: c.scene,
            shareInfo: H(void 0, c.shareInfo, 'object'),
            referrerInfo: H(void 0, c.referrerInfo, 'object')
          })
      const n = k.getVendorConfig(),
        o =
          c.attr && c.attr.gameApp
            ? ['game', 'search']
            : ['weapp', 'search', 'conversation', 'plugin'],
        p = {
          setting: {
            urlCheck: H(c.setting.urlCheck, a.setting.urlCheck, 'boolean'),
            es6: H(c.setting.es6, a.setting.es6, 'boolean'),
            postcss: H(c.setting.postcss, a.setting.postcss, 'boolean'),
            minified: H(c.setting.minified, a.setting.minified, 'boolean'),
            newFeature: H(
              c.setting.newFeature,
              a.setting.newFeature,
              'boolean'
            ),
            scriptsEnable: c.setting.scriptsEnable
          },
          scripts: {
            beforeCompile: H(
              c.scripts.beforeCompile,
              a.scripts.beforeCompile,
              'string'
            ),
            beforePreview: H(
              c.scripts.beforePreview,
              a.scripts.beforePreview,
              'string'
            ),
            beforeUpload: H(
              c.scripts.beforeUpload,
              a.scripts.beforeUpload,
              'string'
            )
          },
          compileType: H(c.compileType, a.compileType, 'string', [
            'game',
            'weapp',
            'search',
            'conversation',
            'plugin'
          ]),
          condiction: {
            weapp: {
              current: H(
                c.condiction.weapp.current,
                a.condiction.weapp.current,
                'number'
              ),
              list: [...g]
            },
            search: {
              current: H(
                c.condiction.search.current,
                a.condiction.search.current,
                'number'
              ),
              list: [...i]
            },
            conversation: {
              current: H(
                c.condiction.conversation.current,
                a.condiction.conversation.current,
                'number'
              ),
              list: [...l]
            },
            plugin: {
              current: H(
                c.condiction.plugin.current,
                a.condiction.plugin.current,
                'number'
              ),
              list: [...h]
            },
            game: {
              current: H(
                c.condiction.game.current,
                a.condiction.game.current,
                'number'
              ),
              list: [...m]
            }
          },
          libVersion: H(
            c.libVersion,
            a.libVersion,
            'string',
            Object.keys(n.libs)
          ),
          svr: H(c.svr, a.svr || '', 'string'),
          client: H(c.client, a.client || '', 'string'),
          qcloudRoot: H(c.qcloudRoot, a.qcloudRoot || '', 'string'),
          miniprogramRoot: H(
            c.miniprogramRoot,
            a.miniprogramRoot || '',
            'string'
          ),
          pluginRoot: H(c.pluginRoot, a.pluginRoot || '', 'string'),
          packOptions: { ignore: d }
        }
      !p.qcloudRoot && p.svr && (p.qcloudRoot = p.svr),
        !p.miniprogramRoot && p.client && (p.miniprogramRoot = p.client),
        p.libVersion !== c.libVersion && k.setVersionAsync(p.libVersion),
        0 > o.indexOf(p.compileType) &&
          (p.compileType = c.attr && c.attr.gameApp ? 'game' : 'weapp'),
        b({
          type: f.PROJECT_SET_PROJECT_CONFIG,
          data: JSON.parse(JSON.stringify(p))
        }),
        b(F())
    },
    setProjectExtInfo: a => {
      return { type: f.PROJECT_SET_EXT_INFO, data: a }
    },
    saveUploadInfo: a => b => {
      b({ type: f.PROJECT_SET_UPLOAD_INFO, data: a }), b(F())
    },
    saveShareInfo: a => (b, c) => {
      try {
        const d = c(),
          e = d.project.current
        if (!e) return
        let g = e.shareInfo || {},
          h = g.history || []
        h.unshift(a),
          (g = _extends({}, g, { history: h })),
          b({ type: f.PROJECT_SET_SHARE_INFO, data: g }),
          b(F())
      } catch (a) {}
    },
    updateProjectCover: a => (b, c) => {
      let d = a.project
      if (!d) {
        const b = c()
        if (((d = b.project.current), !d)) return
        n.setProjectCover(d.projectid, a.image)
      } else n.setProjectCover(d.projectid, a.image)
    },
    openTempProject: a => () => {
      let { appid: b, projectname: c, projectpath: d } = a
      ;(c = encodeURIComponent(c)),
        (d = encodeURIComponent(d)),
        x.openTempOnlineMiniProgram({
          appid: b,
          projectname: c,
          projectpath: d
        })
    },
    syncProject: (a, b) => {
      return { type: f.PROJECT_SYNC_STORE, data: a, syncTime: b }
    },
    setProjectScripts: a => b => {
      const c = j.getCurrent()
      b({ type: f.PROJECT_SET_SCRIPTS, data: a })
      const d = s.getConfigFileInfo(c)
      if (d.error)
        b(E(d.error.type, c, { scripts: _extends({}, c.scripts, a) }))
      else {
        const b = _extends({}, d.config, {
          scripts: _extends({}, c.scripts, d.config.scripts || {}, a)
        })
        s.writeObjectToConfigFile(c, b)
      }
      b(F())
    },
    setTimeRecords: a => b => {
      b({ type: f.PROJECT_SET_TIME_RECORDS, data: a })
    }
  }
})(require('lazyload'), require)
