var debug = require('debug')('rpcify')
762111
function RPCify (obj, opts) {
  if (!obj) return null
  if (!(this instanceof RPCify)) return new RPCify(obj, opts)
  opts = opts || {}

  var defaults = {
    skipPrivate: true,
    include: null,
    exclude: [],
    override: {},
    factory: null,
    name: null,
    access: function () { return true }
  }

  if (obj.__hyperpc) {
    this.opts = Object.assign(defaults, obj.__hyperpc, opts)
  } else if (obj.prototype && obj.prototype.__hyperpc) {
    this.opts = Object.assign(defaults, obj.prototype.__hyperpc, opts)
  } else if (!obj.prototype && Object.getPrototypeOf(obj) && Object.getPrototypeOf(obj).__hyperpc) {
    this.opts = Object.assign(defaults, Object.getPrototypeOf(obj).__hyperpc, opts)
  } else {
    this.opts = Object.assign(defaults, opts)
  }

  this.access = this.opts.access
  this.override = this.opts.override
  this.cache = {}

  if (obj.prototype) {
    // 1. Class (prototype)

    if (opts.factory) this.factory = opts.factory
    else this.factory = makeDefaultFactory(obj)

    this.instance = null
    this.name = obj.name
    this.funcs = getAllFuncs(obj.prototype)
  } else {
    // 2. Object instance

    this.factory = null
    this.instance = obj
    this.name = Object.getPrototypeOf(obj).name
    this.funcs = getAllFuncs(obj)
  }

  var out = ['constructor']
  if (this.opts.exclude) out = out.concat(this.opts.exclude)

  this.filteredFuncs = this.funcs.filter(f => {
    if (this.opts.include && this.opts.include.indexOf(f) === -1) return false
    if (out.indexOf(f) !== -1) return false
    if (this.opts.skipPrivate && f.substr(0, 1) === '_') return false
    return true
  })
}
477564
function parseModule (row, index, rows, opts) {
  // Holds the `module.exports` variable name.
  var moduleExportsName = toIdentifier('_$' + getModuleName(row.file || '') + '_' + row.id)

  // browserify is clever about deduping modules with the same source code,
  // but it needs the browser-pack runtime in order to do so.
  // we don't have that runtime so this … re-dupes those modules.
  if (dedupedRx.test(row.source)) {
    var n = row.source.match(dedupedRx)[1]
    var dedup = rows.filter(function (other) {
      return String(other.id) === n
    })[0]
    row.source = dedup.source
  }

  var requireCalls = []
  var orderOfExecution = new Map()

  var ast
  // hack to keep track of `module`/`exports` references correctly.
  // in node.js they're defined by a function wrapper, so their scope is
  // one level higher-ish than the module scope. this emulates that.
  var globalScope = {
    type: 'BrowserPackFlatWrapper',
    parent: null
  }
  scan.createScope(globalScope, ['module', 'exports'])

  var source = row.source

  // Determine if a require() call may not be evaluated according to its linear source position
  // This happens primarily if the call is inside a function, or inside a conditional branch
  function isOrderUnpredictable (node) {
    while ((node = node.parent)) {
      // Special-case for IIFE, behaviour is the same as evaluating inline
      if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
        // (() => {})()
        if (node.parent && node.parent.type === 'CallExpression' && node.parent.callee === node) {
          continue
        }
        // (function(){}).call(null)
        // this form is added by browserify to inject globals
        if (node.parent && node.parent.type === 'MemberExpression' &&
            node.parent.object === node &&
            (node.parent.property.name === 'call' || node.parent.property.name === 'apply') &&
            node.parent.parent && node.parent.parent.type === 'CallExpression') {
          continue
        }
      }

      // if(require('d')) is still in-order
      // the same is technically true for while(require()) and for(require();;) but those are more rare
      if (node.parent && node.parent.type === 'IfStatement' && node.parent.test === node) {
        // Skip the IfStatement
        node = node.parent
        continue
      }

      if (node.type === 'IfStatement' || // if(false) require()
          node.type === 'WhileStatement' || // while(false) require()
          node.type === 'ForStatement' || // for(;false;) require()
          node.type === 'ForInStatement' || // for(x in []) require()
          node.type === 'FunctionExpression' || // setTimeout(function(){ require() })
          node.type === 'FunctionDeclaration' || // function neverCalled(){ require() }
          node.type === 'ArrowFunctionExpression' // setTimeout(()=> require())
      ) {
        return true
      }
    }
    return false
  }

  // Keep track of modules that were already evaluated in a predictable order so that multiple
  // require('a') occurences don't force 'a' to become on-demand
  var alreadyPredictablyEvaluated = new Set()
  // we'll do two walks along the AST in order to detect variables and their references.
  // we initialise the scopes and declarations in the first one here, and then collect
  // references in the second.
  var magicString = transformAst(source, {
    ecmaVersion: 9,
    inputFilename: row.sourceFile,
    sourceType: opts.sourceType || 'script'
  }, function (node) {
    if (node.type === 'Program') ast = node
    scan.visitScope(node)

    // also collect requires while we're here
    if (isRequire(node)) {
      var argument = node.arguments[0]
      var required = argument.type === 'Literal' ? argument.value : null

      if (required !== null && moduleExists(row.deps[required])) {
        var other = rows.byId[row.deps[required]]
        if (isOrderUnpredictable(node)) {
          if (!alreadyPredictablyEvaluated.has(other)) {
            other[kEvaluateOnDemand] = true
          }
        } else {
          alreadyPredictablyEvaluated.add(other)
        }
        requireCalls.push({
          id: row.deps[required],
          node: node,
          requiredModule: other
        })
      } else if (required !== null) {
        requireCalls.push({
          external: true,
          id: row.deps[required] || required,
          node: node
        })
      }

      if (required !== null) {
        orderOfExecution.set(row.deps[required] || required, node.end)
      }

      function moduleExists (id) {
        return id != null && !!rows.byId[id]
      }
    }
  })
  magicString.walk(function (node) {
    // transform-ast has set this to `undefined`
    ast.parent = globalScope
    scan.visitBinding(node)
  })

  var moduleExportsList = scan.scope(globalScope).getReferences('module')
    .map(function (node) { return node.parent })
    .filter(isModuleExports)
  var exportsList = scan.scope(globalScope).getReferences('exports')
  var moduleList = scan.scope(globalScope).getReferences('module')
    .filter(function (node) { return !isModuleExports(node.parent) })

  // Detect simple exports that are just `module.exports = xyz`, we can compile them to a single
  // variable assignment.
  var isSimpleExport = false
  if (moduleExportsList.length === 1 && exportsList.length === 0 && moduleList.length === 0) {
    var node = moduleExportsList[0]
    if (node.parent.type === 'AssignmentExpression' && node.parent.left === node &&
        node.parent.parent.type === 'ExpressionStatement') {
      isSimpleExport = scan.nearestScope(node.object, false) === ast

      var name = getNodeName(node.parent.right)
      if (name) {
        moduleExportsName = toIdentifier('_$' + name + '_' + row.id)
      }
    }
  }

  row[kAst] = ast
  row[kIsSimpleExport] = isSimpleExport
  row[kExportsName] = moduleExportsName
  row.hasExports = (moduleExportsList.length + exportsList.length) > 0
  row[kRequireCalls] = requireCalls
  row[kDependencyOrder] = orderOfExecution
  row[kReferences] = {
    module: moduleList,
    exports: exportsList,
    'module.exports': moduleExportsList
  }
  row[kMagicString] = magicString
}
818037
function Slack(opts, debug) {
  if (!(this instanceof Slack)) return new Slack(opts);
  this.opts = opts;
  this.debug = debug;

  /**
   * Do everything.
   */

  this.import = function *() {
    try {
      console.log('Starting import');
      yield this.tokens();
      console.log('Got tokens');
      yield this.login();
      console.log('Logged in');
    } catch (e) {
      console.log('Uh oh! ' + e);
      throw e;
    }
    console.log('Getting emoji page');
    var emojiList = '';
    var aliasList = '';
    for (var i = 0; i < Object.keys(this.opts.emojis).length; i++) {
      var e = this.opts.emojis[i];
      if (e.src) {
        var uploadRes = yield this.upload(e.name, e.src);
        emojiList += ' :' + e.name + ':';
      }
      if (e.aliases) {
        for (var n = 0; n < e.aliases.length; n++) {
          yield this.alias(e.name, e.aliases[n]);
          aliasList += ' :' + e.aliases[n] + ':';
        }
      }
    }
    console.log('Uploaded emojis:' + emojiList);
    console.log('Uploaded emoji aliases:' + aliasList);
    return 'Success';
  };

  /**
   * Get login page (aka credentials).
   */

  this.tokens = function *() {
    var opts = this.opts;
    opts.jar = opts.jar || { _jar: { store: { idx: {} } } };
    var load = {
      url: opts.url + loginFormPath,
      headers: headers,
      jar: opts.jar,
      method: 'GET'
    };
    var res = yield request(load);
    var $ = cheerio.load(res[0].body);
    if (this.debug) write($('title').text(), $.html());
    opts.formData = {
      signin: $('#signin_form input[name="signin"]').attr('value'),
      redir: $('#signin_form input[name="redir"]').attr('value'),
      crumb: $('#signin_form input[name="crumb"]').attr('value'),
      remember: 'on',
      email: opts.email,
      password: opts.password
    };
    if (!opts.formData.signin && !opts.formData.redir && !opts.formData.crumb) throw new Error('Login error: could not get login form for ' + opts.url);
    return this.opts = opts;
  };

  /**
   * Log into Slack and populate cookies.
   */

  this.login = function *() {
    var opts = this.opts;
    var load = {
      url: opts.url + loginFormPath,
      headers: headers,
      jar: opts.jar,
      method: 'POST',
      followAllRedirects: true,
      formData: opts.formData
    };
    var res = yield request(load);
    if(res[0].body.indexOf("Sorry, you entered an incorrect email address or password.") != -1){
      throw new Error('Login error: incorrect username / password');
    }

    if(res[0].body.indexOf("Enter your authentication code") != -1){

      var $ = cheerio.load(res[0].body);

      var inputs = $("form input")

      var formData = {};

      inputs.each(function(i,v){
        formData[v.attribs.name] = v.attribs.value;
      })

      user_2fa_code = yield ask('2FA Code: ', isPassword, 'A password (as defined by this script) needs to have at least one character (not including you).');
      formData["2fa_code"] = user_2fa_code

      delete formData[undefined]
      delete formData['input']

      var load_2fa = {
        url: opts.url + "/",
        headers: headers,
        jar: opts.jar,
        method: 'POST',
        followAllRedirects: true,
        formData: formData
      };
      res = yield request(load_2fa);
    }

    //TODO: it may be necessary in the future to replace this with a user-supplied token
    var match = apiTokenRegex.exec(res[0].body);
    if (!match || !match[1]) {
      throw new Error('Application Error: unable to find api token on login page');
    }
    opts.apiToken = match[1];

    return this.opts = opts;
  };

  /**
   * Upload the emoji.
   */

  this.upload = function *(name, emoji) {
    console.log('Uploading %s with %s', name, emoji);
    return new Promise(function(resolve, reject, notify) {
      var opts = this.opts;
      var r = req({
        url: opts.url + emojiAddEndpoint,
        headers: headers,
        method: 'POST',
        jar: opts.jar,
        followAllRedirects: true
      }, function(err, res, body) {
        if (err || !body) return reject(err);
        resolve(body);
      });
      var form = r.form();
      form.append('name', name);
      form.append('mode', 'data');
      form.append('image', req(emoji));
      form.append('token', opts.apiToken);
    }.bind(this));
  };

  this.alias = function *(name, alias) {
    console.log('Aliasing %s to %s', alias, name);
    return new Promise(function(resolve, reject, notify) {
      var opts = this.opts;
      var r = req({
        url: opts.url + emojiAddEndpoint,
      headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'},
        method: 'POST',
        jar: opts.jar,
        followAllRedirects: true
      }, function(err, res, body) {
        if (err || !body) return reject(err);
        resolve(body);
      });
      var form = r.form();
      form.append('name', alias);
      form.append('mode', 'alias');
      form.append('alias', name);
      form.append('token', opts.apiToken);
    }.bind(this));
  };
}
41334
function client(req, res) {
  const compiler = webpack(config);
  compiler.outputFileSystem = fsys;

  compiler.run((err, stats) => {
    const file = fsys.readFileSync(path.join(__dirname, 'dist', 'client.js'));

    res.setHeader('Content-Length', file.length);
    res.writeHead(200, { 'Content-Type': 'text/javascript' });

    res.end(file);
  });
}
171020
def debug(self, debug_commands):
    """"""
    if isinstance(debug_commands, sc_debug.DebugCommand):
      debug_commands = [debug_commands]
    return self._client.send(debug=sc_pb.RequestDebug(debug=debug_commands))
472223
function isDebug(debugging) {
    // If manually passed just return.
    if (isValue(debugging))
        return debugging;
    var eargv = process && process.execArgv;
    function chkDebug() {
        return (eargv.filter(function (v) { return /^(--debug|--inspect)/.test(v); }).length ||
            isValue(v8debug));
    }
    return function_1.tryWrap(chkDebug)(false);
}
462124
function requirejs(deps, callback, errback) {
  if (!Array.isArray(deps)) throw new Error('missing deps array');
  if (callback && typeof callback !== 'function') throw new Error('callback is not a function');
  if (errback && typeof errback !== 'function') throw new Error('errback is not a function');

  // return AMD require function or commonjs require function
  function requireFunc() {
    if (typeof arguments[0] === 'string') {
      const dep = arguments[0];
      const got = defined(dep);
      if (got) return got.val;
      throw new Error(`commonjs dependency "${dep}" is not prepared.`);
    }

    return requirejs.apply(null, arguments);
  }

  requireFunc.toUrl = toUrl;

  const depValues = serialResults(deps, d => {
    if (d === 'require') return requireFunc;
    if (d instanceof RegExp) {
      const expanded = [...userSpace.ids(), ...packageSpace.ids()].filter(id => id.match(d));
      return serialResults(expanded, e => userSpace.req(e));
    }
    return userSpace.req(mappedId(d));
  });

  const finalize = results => {
    if (callback) return callback.apply(_global, results);
    else return results;
  };

  const errHandler = err => {
    if (errback) return errback(err);
    else console.error(err); // eslint-disable-line no-console
  };

  if (depValues && typeof depValues.then === 'function') {
    // asynchronous callback
    return depValues.then(finalize, errHandler);
  }

  // synchronous callback
  return new Promise(resolve => {
    resolve(finalize(depValues));
  });
}
1346965
function (subTplName, callback) {
            var tpl = S.require(subTplName);
            if (tpl) {
                callback(undefined, tpl);
            } else {
                var warning = 'template "' + subTplName + '" does not exist, ' + 'better required or used first for performance!';
                S.log(warning, 'error');
                callback(warning, undefined);
            }
        }
638367
function debug(name) {
  if (!debug.enabled(name)) return function(){};

  return function(fmt){
    var curr = new Date;
    var ms = curr - (debug[name] || curr);
    debug[name] = curr;

    fmt = name
      + ' '
      + fmt
      + ' +' + debug.humanize(ms);

    // This hackery is required for IE8
    // where `console.log` doesn't have 'apply'
    window.console
      && console.log
      && Function.prototype.apply.call(console.log, console, arguments);
  }
}
576866
function (opt, handler) {

			var recquire_t = require('aureooms-node-recursive-require');
			var extend = require('node.extend');

			var dflt = {
				name: undefined,
				src: undefined,
				exports: undefined,
				base: 0,
				index: 'index.js',
				intro: 'intro.js',
				outro: 'outro.js',
				rec: false,
				flat: true,
				debug: false
			};

			opt = extend({}, dflt, opt);

			if (opt.name) opt.name = opt.name.replace(/-/g, '');

			var recquire = recquire_t(opt);

			recquire(opt.src, opt.exports, -opt.base, handler);
		}
1066827
function (bundle, context, validate, debug) {
        var opts = { debug: debug };
        var ycb = new Ycb(bundle, opts);
        return ycb.readNoMerge(context, opts);
    }
1011464
function override (server) {
  ['trace', 'log', 'info', 'warn', 'error'].forEach(method => {
    const target = method === 'log' ? 'debug' : method
    console[method] = wrapper.bind(undefined, server, target)
  })
}
1240156
function(mod) {
  // XXX: consider using `Module.parent` and `delete require.cache[module.id]`
  if (!(mod instanceof Module)) {
    throw new TypeError(
      'Module required (e.g., "var __ = require(\'@carbon-io/fibers\').__(module)")')
  }
  var __ = function(f, cb) {
    if (typeof __ensure._getCurrentFiber() === 'undefined') {
      return __spawn(f, cb, _debugLogger.bind(undefined, mod))
    }
    var ret = undefined
    try {
      ret = f()
      if (cb) {
        cb(null, ret)
      }
    } catch (e) {
      // XXX: do we want to log to stderr here? setting mod to undefined for 
      //      now to disable stderr
      _debugLogger(
        undefined, 'Exception caught with cb undefined in __: ' + inspect(e))
      if (cb) {
        cb(e)
      } else {
        throw e
      }
    }
  }

  //  __(.main)?
  __.main = function() {
    console.warn('"__.main" is DEPRECATED and no longer necessary')
    return __.apply(undefined, arguments)
  }

  //  __(.ensure)*(.main)?
  __.ensure = __

  //  __(.(ensure|main))*
  __.main.ensure = __

  //  __(.(ensure|main))*(.spawn)?
  __.spawn = __spawn

  //  __(.(ensure|main))*(.spawn(.main(.(ensure|main))*)?)?
  __.spawn.main = __.main

  //  __(.(ensure|main))*(.spawn(.(ensure|main))*)?
  __.spawn.ensure = __

  //  __(.(spawn|ensure|main))*
  __.spawn.spawn = __spawn

  return __
}
858864
function()
	{
		if (typeof console !== 'undefined' && ((pwf.has('module', 'config') && pwf.config.get('debug.frontend')) || !pwf.has('module', 'config'))) {
			var args = pwf.clone_array(arguments);

			if (args.length > 1) {
				console.log(args);
			} else {
				console.log(args[0]);
			}
		}
	}
968373
function subscribe() {
    console.log(' > ', 'init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123']);
    rpcClient.methodCall('init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123'], function (err, res) {
        console.log(err, res);
    });
}
486101
def debug(trace=True, backtrace=1, other=None, output=sys.stderr):
    """"""
    from pprint import pprint
    import traceback
    def debugdeco(func):
        def tracer(frame, event, arg):
            print>>output, '--- Tracer: %s, %r' % (event, arg)
            traceback.print_stack(frame, 1, output)
            return tracer
        def wrapped(*a, **k):
            print>>output
            print>>output, '--- Calling %s.%s with:' % (
                getattr(func, '__module__', ''),
                func.__name__
            )
            for i in enumerate(a):
                print>>output, '    | %s: %s' % i
            print>>output, '    | ',
            pprint(k, output)
            print>>output, '    From:'
            for i in traceback.format_stack(sys._getframe(1), backtrace):
                print>>output, i,
            if other:
                print>>output, '---      [ %r ]' % (other(func,a,k))
            if trace: sys.settrace(tracer)
            ret = func(*a, **k)
            if trace: sys.settrace(None)
            #~ a = list(a)
            print>>output, '--- %s.%s returned: %r' % (
                getattr(func, '__module__', ''),
                func.__name__,
                #~ ret not in a and ret or "ARG%s"%a.index(ret)
                ret
            )
            return ret
        return wrapped
    return debugdeco
491610
function checkJs (mode, callback) {
  var exercise = this

  if (!exercise.passed)
    return callback(null, true) // shortcut if we've already had a failure

  gyp.rebuild(copyFauxTempDir, function (err) {
    if (err) {
      exercise.emit('fail', 'Compile mock C++ to test JavaScript: ' + err.message)
      return callback(null, false)
    }

    execWith(copyFauxTempDir, 111, 'FAUX 111\nDone!\n', function (err, pass) {
      if (err)
        return callback(err)
      if (!pass) {
        exercise.emit('fail', 'JavaScript code loads addon and invokes `delay(x, cb)` method')
        return callback(null, false)
      }

      execWith(copyFauxTempDir, 1111, 'FAUX 1111\nDone!\n', function (err, pass) {
        if (err)
          return callback(err)

        exercise.emit(pass ? 'pass' : 'fail'
            , 'JavaScript code loads addon and invokes `delay(x, cb)` method')
        callback(null, pass)
      })
    })
  })
}