'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) {
  function a(a, b, c) {
    return new Promise(async (e, g) => {
      let h = r(b, c),
        i = p.srcPath,
        k =
          (c &&
            c.pages.map(a => {
              return d.posix.join(c.root, a)
            })) ||
          b.pages,
        n = 0,
        o = [],
        q = {}
      h.forEach(a => {
        q[a] = !0
      }),
        k.forEach(a => {
          q[`${a}.wxss`] && (n++, o.push(`./${a}.wxss`), delete q[`${a}.wxss`])
        })
      let s = []
      try {
        s = await j.getFileList(a, b, c)
      } catch (a) {
        return g(a)
      }
      for (let a in (s.forEach(a => {
        q[`${a}.wxss`] && (n++, o.push(`./${a}.wxss`), delete q[`${a}.wxss`])
      }),
      q))
        o.push(`./${a}`)
      let t = ['-db', '-pc', n].concat(o)
      const u = f.getWXSSParsePath()
      let v = l(u, t, { cwd: i }),
        w = [],
        x = []
      v.on('close', a => {
        if (0 === a) {
          let a = Buffer.concat(w).toString(),
            b = a.split('='),
            c = {}
          for (let a = 0, d = b.length; a < d && b[a + 1]; a += 2)
            c[b[a]] = b[a + 1]
          return e(c)
        }
        let b = Buffer.concat(x).toString(),
          c = new Error(
            `编译 .wxss 文件错误，错误信息如上，可在控制台查看更详细信息`
          )
        return (c.code = m), (c.msgForConsole = b), g(c)
      }),
        v.stdout.on('data', a => {
          w.push(a)
        }),
        v.stderr.on('data', a => {
          x.push(a)
        })
    })
  }
  function b(a, b) {
    let c = d.extname(b)
    '.wxss' === c ? o() : 'app.json' == b && o()
  }
  async function c(a) {
    if (q) {
      let b = q.setting && q.setting.newFeature,
        c = a.setting && a.setting.newFeature
      b != c && o()
    }
    q = a
    let c = await i(a)
    ;(p && p.srcPath == c.srcPath) ||
      (o(), p && p.unWatch(b), (p = c), p.watch(b))
  }
  const d = require('path'),
    e = require('./1dea83a77e99a7c94f6b6f01f5c175b0.js'),
    f = require('./d28a711224425b00101635efe1034c99.js'),
    g = require('child_process'),
    h = require('./949d8235c744ced2a80121e4dba34c28.js'),
    i = require('./162bf2ee28b76d3b3d95b685cede4146.js'),
    j = require('./6b5520e429c60abf5d2f924c0fa05fd0.js'),
    k = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),
    l = g.spawn,
    m = h.TRANS_WXSS_JS_ERR
  var n = {}
  const o = () => {
    n = {}
  }
  var p, q
  const r = (a, b) => {
    let c = p.getAllWXSSFiles()
    if (a.subPackages) {
      let d = c.filter(b => {
        let c = !0
        return (
          a.subPackages.forEach(a => {
            0 == b.indexOf(a.root) && (c = !1)
          }),
          c
        )
      })
      c = b
        ? d.concat(
            c.filter(a => {
              return 0 == a.indexOf(b.root)
            })
          )
        : d
    }
    return c
  }
  module.exports = async function(b, d = {}) {
    let { app: f, page: g } = d
    await c(b)
    let h = await e(b)
    if (f) {
      if ('undefined' == typeof n.comm) {
        let c = await a(b, h)
        n = _extends({}, n, c)
      }
      return n.comm
    }
    let i = `./${g}.wxss`,
      j = k.checkIsInSubPackage(h, g)
    if (!j) return { page: n[i] }
    if ('undefined' == typeof n[i]) {
      let c = await a(b, h, j)
      ;(n[j.root] = c.comm), delete c.comm, (n = _extends({}, n, c))
    }
    return { comm: n[j.root], page: n[i] }
  }
})(require('lazyload'), require)
