'use strict'
!(function(require, directRequire) {
  function a() {
    j({
      title: `编辑器自动补全有新版本`,
      message: `新版本已经准备好，立刻重启更新？`,
      buttons: [{ title: '\u91CD\u542F' }],
      callback: a => {
        0 === a && chrome.runtime.reload()
      }
    })
  }
  const b = require('fs'),
    c = require('zlib'),
    d = require('asar'),
    e = require('path'),
    f = require('child_process').spawn,
    g = require('./233d77ecf0781f44985f684f70e316d0.js'),
    h = require('./f171257bbcaef547a3cf27266ccb0db2.js'),
    i = require('./92320c1386e6db6a6f2556736a9bc280.js'),
    j = require('./d3ce001ab1e75959382f6a7e0156dd17.js'),
    k = require('./logger.js'),
    l = c.createGunzip(),
    m = require('./dc59f57d54946e61d27c95ab24d8cb4f.js'),
    n = e.join(i.WeappEditor, 'js.api.js'),
    o = e.join(i.WeappEditor, 'js.api.monaco.js'),
    p = e.join(i.WeappEditor, 'component.api.js'),
    q = e.join(i.WeappEditor, 'wxml.api.js'),
    r = e.join(i.WeappEditor, 'lib.wa.es6.js'),
    s = e.join(i.WeappEditor, 'lib.wa.game.js'),
    t = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/js.api.js')
      : e.join(__dirname, './extensions/editor/assets/api/js.api.js'),
    u = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/js.api.monaco.js')
      : e.join(__dirname, './extensions/editor/assets/api/js.api.monaco.js'),
    v = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/component.api.js')
      : e.join(__dirname, './extensions/editor/assets/api/component.api.js'),
    w = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/wxml.api.js')
      : e.join(__dirname, './extensions/editor/assets/api/wxml.api.js'),
    x = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/lib.wa.es6.js')
      : e.join(__dirname, './extensions/editor/assets/api/lib.wa.es6.js'),
    y = global.appConfig.isDev
      ? e.join(__dirname, '../extensions/editor/assets/api/lib.wa.game.js')
      : e.join(__dirname, './extensions/editor/assets/api/lib.wa.game.js'),
    z = 'api_version'
  let A = localStorage.getItem(z) || '0.0.0.0',
    B = !1,
    C = []
  const D = () =>
      new Promise(async (a, c) => {
        if (
          !b.existsSync(n) ||
          !b.existsSync(o) ||
          !b.existsSync(p) ||
          !b.existsSync(q) ||
          !b.existsSync(r) ||
          !b.existsSync(s)
        )
          try {
            await E(), a()
          } catch (a) {
            c(a)
          }
        else a()
      }),
    E = () =>
      new Promise(async (a, c) => {
        function d(a) {
          c(a)
        }
        function e() {
          g++, g === f.length && a()
        }
        const f = [[t, n], [u, o], [v, p], [w, q], [x, r], [y, s]]
        let g = 0
        for (const [g, h] of f)
          b.createReadStream(g)
            .on('error', d)
            .pipe(
              b
                .createWriteStream(h)
                .on('error', d)
                .on('close', e)
            )
      })
  module.exports = {
    update: (a = !1) =>
      new Promise((a, b) => {
        return a()
      }),
    JSAPIFilePath: n,
    JSAPIMonacoFilePath: o,
    ComponentAPIFilePath: p,
    WXMLAPIFilePath: q,
    LibWaEs6FilePath: r,
    LibWaGameFilePath: s,
    fallbackJSAPIPath: t,
    fallbackJSAPIMonacoPath: u,
    fallbackComponentAPIPath: v,
    fallbackWXMLAPIPath: w,
    fallbackLibWaEs6Path: x,
    fallbackLibWaGamePath: y,
    getFallbackAPI: (a = !1) =>
      new Promise(async c => {
        function d() {
          e()
        }
        function e() {
          g++, g >= f.length && c(h)
        }
        const f = [t, u, v, w, x]
        a && f.push(y)
        let g = 0
        const h = []
        for (const a of f)
          b.readFile(a, 'utf8', (a, b) => {
            return a ? d() : void (h.push(b), e())
          })
      }),
    notifyReload: a,
    getAPIVersion() {
      return A
    }
  }
})(require('lazyload'), require)
