'use strict'
!(function(require, directRequire) {
  function a(d, g, h) {
    let { files: i, reg: j, project: k } = d
    if (0 === i.length) return void h(null, g)
    let l = i.shift(),
      n = 1,
      m = e.extname(l)
    if (!f[m]) a(d, g, h)
    else {
      let f = e.relative(k.projectpath, l),
        i = f.replace(/\\/g, '/'),
        m = c.createReadStream(l, { encoding: 'utf8' }),
        o = b.createInterface({ input: m })
      o.on('line', a => {
        let b = a.match(j)
        b && (!g[i] && (g[i] = []), g[i].push({ line: n, data: a })), n++
      }),
        o.on('close', () => {
          a(d, g, h)
        })
    }
  }
  const b = require('readline'),
    c = require('fs'),
    d = require('glob'),
    e = require('path'),
    f = {
      '.js': !0,
      '.json': !0,
      '.wxml': !0,
      '.wxss': !0,
      '.html': !0,
      '.css': !0,
      '.md': !0,
      '.txt': !0
    }
  module.exports = (b = {}, c) => {
    let { cwd: e, wholeword: f, i: g, str: h, project: i } = b,
      j = {}
    d(`${e}/**/*`, { nodir: !0 }, (b, d) => {
      if (b) return void c(b)
      let e = h.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
      f && (e = `\\b${e}\\b`),
        (e = g ? new RegExp(e, 'i') : new RegExp(e)),
        a({ files: d, reg: e, project: i }, j, c)
    })
  }
})(require('lazyload'), require)
