/*

config = {
autostart: undefined,
sync: undefined,
}
504558
function Scheduler(config = {})
{
    const stack = []

    let shouldRun = false
    let isRunning = false

    this.addRetryAction = (method, action, config) =>
    {
        action.__method = method

        action.__retry = Object.assign(
            {
                method: method
            },
            defaultRetryConfig,
            config
        )

        return this.addAction(action)
    }

    this.addAction = action =>
    {
        let job = { action }

        let jobPromise = new Promise((resolve, reject) =>
        {
            job.__resolve = resolve
            job.__reject = reject
        })

        stack[action.__method](job)

        if (shouldRun && !isRunning) this.next()

        return jobPromise
    }

    this.push = action =>
    {
        action.__method = PUSH

        return this.addAction(action)
    }

    this.unshift = action =>
    {
        action.__method = UNSHIFT

        return this.addAction(action)
    }

    this.pushRetry = (action, config) =>
    {
        return this.addRetryAction(PUSH, action, config)
    }

    this.unshiftRetry = (action, config) =>
    {
        return this.addRetryAction(UNSHIFT, action, config)
    }

    this.start = () =>
    {
        if (shouldRun) return // avoid running next when already running

        shouldRun = true
        this.next()
    }

    this.pause = () =>
    {
        shouldRun = false
    }

    this.next = () =>
    {
        if (!shouldRun) return isRunning = false

        let job = stack.shift()

        if (!job) return isRunning = false

        isRunning = true

        let executionPromise = this.execute(job)

        if (!config.sync)
        {
            setTimeout(this.next.bind(this), 0)
        }
        else
        {
            executionPromise
            .then(response =>
            {
                this.next()
                return response
            })
        }
    }

    this.execute = job =>
    {
        if (job.action.__retry)
        {
            job.action.__retry.attempts++

            return job.action()
            .then(job.__resolve)
            .catch(error =>
            {
                if (
                    job.action.__retry.limit > 0
                    && job.action.__retry.attempts == job.action.__retry.limit
                )
                {
                    job.__reject(`retry limit reached: ${job.action.__retry.limit}`)
                    return
                }

                // re-schedule job
                this[job.action.__retry.method](job.action)
                .then(job.__resolve)
                .catch(job.__reject)
            })
        }

        return job.action()
        .then(job.__resolve)
        .catch(job.__reject)
    }

    if (config.autostart) this.start()

    return {
        push: this.push,
        unshift: this.unshift,
        pushRetry: this.pushRetry,
        unshiftRetry: this.unshiftRetry,
        start: this.start,
        pause: this.pause,
    }
}
171519
function start() {
  const node = process.execPath
  const daemonFile = path.join(__dirname, '../daemon')
  const startupFile = startup.getFile('hotel')

  startup.create('hotel', node, [daemonFile], common.logFile)

  // Save startup file path in ~/.hotel
  // Will be used later by uninstall script
  mkdirp.sync(common.hotelDir)
  fs.writeFileSync(common.startupFile, startupFile)

  console.log(`Started http://localhost:${conf.port}`)
}
972402
async function updateConfig(updater) {
  await isReady();
  const newConfig = updater(config);
  validateSchema(
    configSchema,
    newConfig,
    'Please fix the config being used in Bolt CLI.',
  );
  // console.log('new config:');
  // console.log(newConfig);
  config = newConfig;
  if (config.prod) {
    process.env.NODE_ENV = 'production';
  }
  return config;
}
443285
function checkConfiguration(conf) {
    let failedChecks = 0;

    for (const path of Object.keys(CHECKS)) {
        // @todo avoid try..catch
        try {
            checkProperty(path, get(conf, path), CHECKS[path]);
        } catch (error) {
            LusterConfigurationError.ensureError(error).log();
            ++failedChecks;
        }
    }

    return failedChecks;
}
158624
function defaultConfig(config) {
	config.urls = config.urls || [];
	config.defaults = config.defaults || {};
	config.defaults.log = config.defaults.log || console;
	// 	Setting to undefined rather than 0 allows for a fallback to the default
	config.defaults.wrapWidth = process.stdout.columns || undefined;
	if (program.json) {
		delete config.defaults.log;
	}
	return config;
}
38029
function useDefaultConfig(){
	logger.info(process.cwd());
	if(fileutil.isExist(path.join(process.cwd() , "/config.json"))){
		var jsonconfig = require(path.join(process.cwd() ,'/config.json'));
		buildFromJsonConfig(jsonconfig);
	}else{
		logger.warn("config.json is not found. Checking for directory structure");
		buildFromDirectory(process.cwd());
	}
}
48858
function () {
    var done = this.async();
    var options = this.options();
    var data = this.data;

    // default settings, overwritten with user defined settings
    settings = {
      pattern_port: Array.isArray(data.ports) && data.ports[0] ? data.ports[0] : Array.isArray(options.ports) && options.ports[0] ? options.ports[0] : 7020,
      snapshot_port: Array.isArray(data.ports) && data.ports[1] ? data.ports[1] : Array.isArray(options.ports) && options.ports[1] ? options.ports[1] : 7040,
      wwwroot: data.wwwroot || options.wwwroot || 'public',
      src: data.src || options.src || 'public/patterns',
      files: data.files || options.files || [],
      dest: data.dest || options.dest || 'docs',
      snapshot: (data.snapshot !== undefined ? data.snapshot : (options.snapshot !== undefined ? options.snapshot : false)),
      index: data.index || options.index || null,
      css: data.css || options.css || ['global.css']
    };

    var primer;

    // local pattern folder (there are the html snapshots)
    if (settings.files.length > 0) {
      var patterns = settings.files;
      var patternsFolder = settings.src;

      // our main function that starts the process
      primer = function (cb) {
        handleFiles(patternsFolder, patterns, cb);
      };

    } else {
     var patternFolder = './' + settings.src;

      // our main function that starts the process
      primer = function (cb) {
        readPatterns(patternFolder, cb);
      };
    }

   

    // middleware to spit out 404 (in case a non existing ressource is request)
    // or to process the `non static` requests
    var middleware = function (req, resp) {
      if (req.url !== '/') {
        resp.writeHead(404, {
          'Content-Length': 0,
          'Content-Type': 'text/plain'
        });
        resp.end();
        return;
      }

      // 200, success, always
      resp.writeHead(200, {'Content-Type': 'text/html'});
      // run the primer with cb
      primer(resp.end.bind(resp));
    };

    // initialize the server with static routes & dynamic template middleware
    var liveServer = connect.createServer(
      connect.static(process.cwd() + '/' + settings.wwwroot),
      middleware
    );

    // initialize the static server pointing to your snapshots
    var snapshotServer = connect.createServer(connect.static(process.cwd() + '/' + settings.dest));

    // starts the live server
    var startLiveServer = function () {
      liveServer.listen(settings.pattern_port, function () {
        grunt.log.ok('You can now visit http://localhost:' + settings.pattern_port + '/ to see your patterns.');
      });
    };

    // starts the snapshot server
    var startSnapshotServer = function () {
      snapshotServer.listen(settings.snapshot_port, function () {
        grunt.log.ok('You can now visit http://localhost:' + settings.snapshot_port + '/ to see your snaphsot patterns.');
      });
    };

    // writes the task output to a file 
    var writeSnapshot = function () {
      primer(function (content) {
        var promises = [];
        // write the index file
        grunt.file.write('./' + settings.dest + '/index.html', content);
        // copy css files
        settings.css.forEach(function (file) {
          var deferred = Q.defer();
          promises.push(deferred.promise);
          if (file.search('http://') !== -1) {

            var data = '';
            http.get(file, function (res) {
              res.on('data', function(chunk) {
                data += chunk;
              });
              res.on('end', function () {
                grunt.file.write('./' + settings.dest + '/style.css', data);
                deferred.resolve();
              });
            })
            .on('err', deferred.reject);
          } else {
            grunt.file.copy('./' + settings.wwwroot + '/' + file, './' + settings.dest + '/' + file);
            deferred.resolve();
          }
        });

        grunt.log.ok('Stand-alone output can now be found in "' + settings.dest + '/"');
        grunt.event.emit('patternprimer:snapshot:written');
        if (promises.length === 0) {
          done();
        } else {
          Q.allSettled(promises).then(done);
        }
      });
    };

    // writes to file or starts a server,
    // depending on the given snapshot var
    if (!!settings.snapshot) {
      writeSnapshot();
    } else {
      startLiveServer();
      // only start snapshot server, if snapshots are available
      if (grunt.file.exists('./' + settings.dest + '/index.html')) {
        startSnapshotServer();
      }
    }

  }
1089147
function(namespace, config) {
        if ( typeof(config) == "undefined" )
            var config = self.getSync(app);

        if (config != null) {
            var split = namespace.split('.'), k=0;
            while (k<split.length) {
                config = config[split[k++]]
            }
            return config
        } else {
            return null
        }
    }
1070881
function init(nodes, edges, config) {
      config = config || {};
      var i, l;

      // Matrices
      NodeMatrix = nodes;
      EdgeMatrix = edges;

      // Length
      W.nodesLength = NodeMatrix.length;
      W.edgesLength = EdgeMatrix.length;

      // Merging configuration
      configure(config);
    }
189125
function(bundle, i) {
        var i = i || 0;
        var configuration = config.getInstance(bundle);

        try {

            var locals = _locals = utilsConfig.getSync('gina', 'locals.json')
        } catch (err) {
            console.emerg('Error while calling `Model::getConfigSync()` '+ err.stack||err.message);
            if ( i < 10) {
                console.debug('about to retry to load locals.json');
                setTimeout(function(){

                    i = i+1;
                    console.debug('retry ('+i+') ...');
                    return getConfigSync(bundle, i)
                }, 300)

            } else {
                throw new Error('Config could not be loaded');
                process.exit(1)
            }
            return false
        }

        if ( typeof(configuration) != 'undefined' && locals) {

            var env = configuration.Env.current;
            var conf = configuration.Env.getConf(bundle, env);

            // configuration object.
            var confObj = {
                connectors  : conf.content.connectors,
                path        : conf.modelsPath,
                locals      : locals
            };

            return confObj
        } else {
            throw new Error('Config not instantiated');
            return undefined
        }
    }
606584
function initConfig(obj) {
  Object.keys(obj).forEach(item => {
    if (!process.env[item]) {
      process.env[item] = obj[item];
    }
  });
}
509679
function mergeDefaultConfig(opts) {

    let devModeEnabled = isDevelopMode();
    let debugModeEnabled = isDebugMode();

    console.log('------------------------------------------------------------------------------------');
    console.log(`Executing build for ` + (devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD));
    console.log('------------------------------------------------------------------------------------');

    let config = {

        metadata: {
            ENV: devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD
        },
        devtool: 'source-map',
        debug: debugModeEnabled,

        entry: {},

        output: {
            filename: devModeEnabled ? '[name].bundle.js' : '[name].[chunkhash].bundle.js',
            sourceMapFilename: devModeEnabled ? '[name].bundle.map' : '[name].[chunkhash].bundle.map',
            chunkFilename: devModeEnabled ? '[id].chunk.js' : '[id].[chunkhash].chunk.js'
        },

        resolve: {
            cache: false,
            extensions: ['', '.ts', '.tsx', '.js', '.json', '.css', '.html']
        },

        module: {
            preLoaders: [],
            loaders: []
        },

        plugins: [],

        // we need this due to problems with es6-shim
        node: {
            global: 'window',
            progress: false,
            crypto: 'empty',
            module: false,
            clearImmediate: false,
            setImmediate: false
        }
    };

    if (debugModeEnabled) {
        console.log(merge(config, opts));
        console.log('------------------------------------------------------------------------------------');
    }

    return merge(config, opts);
}
864155
function ZoologistConfig() {
  this.initialised = false;
  this.client = null;
  this.serviceInstance = null;
  this.serviceDiscovery = null;
  this.serviceDependencies = null;
}
679778
async function initializeConfig() {
    process.stdout.write(chalk.cyan.bold('\nThis util will walk you through creating a .luisrc file\n\nPress ^C at any time to quit.\n\n'));
    //const validRegions = 'westus westus2 eastus eastus2 westcentralus southcentralus westeurope northeurope southeastasia eastasia australiaeast brazilsouth'.split(' ');
    const validRegions = 'westus westeurope australiaeast'.split(' ');
    const questions = [
        'What is your LUIS Authoring key (from luis.ai portal User Settings page)? ',
        `What is your region? [${validRegions.join(', ')}] `,
        'What is your LUIS App ID? [Default: skip] ',
        'What is your LUIS Version ID? [Default: 0.1] ',
    ];

    const prompt = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
    });

    const answers = [];
    for (let i = 0; i < questions.length; i++) {
        const question = questions[i];
        const answer = await new Promise((resolve) => {

            function doPrompt(promptMessage) {
                prompt.question(promptMessage, response => {
                    if (i === 1 && (!response || !validRegions.includes(response))) {
                        doPrompt(chalk.red.bold(`${response} is not a valid region`) + '\n' + question);
                    } else {
                        resolve(response);
                    }
                });
            }

            doPrompt(question);
        });
        if (i == 2 && answer.trim().length == 0)
            break;
        answers.push(answer.trim());
    }

    const [authoringKey, region, appId, versionId] = answers;
    const config = Object.assign({}, {
        appId,
        authoringKey,
        versionId,
        region: region,
    });
    try {
        await new Promise((resolve, reject) => {
            const confirmation = `\n\nDoes this look ok?\n${JSON.stringify(config, null, 2)}\n[Yes]/No: `;
            prompt.question(confirmation, response => {
                /^(y|yes)$/.test((response || 'yes').toLowerCase()) ? resolve(response) : reject();
            });
        });
    } catch (e) {
        return false;
    }
    await fs.writeJson(path.join(process.cwd(), '.luisrc'), config, { spaces: 2 });
    return true;
}
309799
function() {
    this.generator = undefined;
    this.headerHash = undefined;
    this.settingsChanged = undefined;
    this._name = undefined;
    this.nameChanged = undefined;
    this._desc = undefined;
    this.descChanged = undefined;
    this._defaultUser = undefined;
    this.defaultUserChanged = undefined;
    this._mntncHistoryDays = undefined;
    this._color = undefined;
    this.keyChanged = undefined;
    this._keyChangeRec = undefined;
    this._keyChangeForce = undefined;
    this._recycleBinEnabled = undefined;
    this._recycleBinUuid = undefined;
    this.recycleBinChanged = undefined;
    this._entryTemplatesGroup = undefined;
    this.entryTemplatesGroupChanged = undefined;
    this._historyMaxItems = undefined;
    this._historyMaxSize = undefined;
    this._lastSelectedGroup = undefined;
    this._lastTopVisibleGroup = undefined;
    this._memoryProtection = {
        title: undefined, userName: undefined, password: undefined, url: undefined, notes: undefined
    };
    this.customData = {};
    this.customIcons = {};
    this._editState = undefined;
    Object.preventExtensions(this);
}
194637
function(key, silent) {
            this._configs = this._configs || {};
            var configs = this._configs;
            
            key = ( ( Lang.isString(key) ) ? [key] : key ) || 
                    this.getAttributeKeys();
            
            for (var i = 0, len = key.length; i < len; ++i) { 
                if (configs.hasOwnProperty(key[i])) {
                    this._configs[key[i]].refresh(silent);
                }
            }
        }
537800
function init(){
    self.type = config.type || 'redis';
    if(config.redisMock){
      self.db = config.redisMock;
    }
    else{
      if(config.redisUrl){
        self.redisData = config.redisUrl || null;
      }
      else if(config.redisEnv){
        self.redisData = process.env[config.redisEnv] || null;
      }
      else if(config.redisData){
        self.redisData = config.redisData;
      }
      self.readOnly = (typeof config.readOnly === 'boolean') ? config.readOnly : false;
      try {
        if (self.redisData) {
          if(typeof self.redisData === 'string'){
            self.db = redis.createClient(self.redisData,
              {'no_ready_check': true,
              retry_strategy: retryStrategy});
          } else {
            self.db = redis.createClient(self.redisData.port,
              self.redisData.hostname, {'no_ready_check': true,
              retry_strategy: retryStrategy});

            // don't call redis auth method if no auth info passed
            if (self.redisData.auth) {
              self.db.auth(self.redisData.auth);
            }
          }
          self.db.on('error', function(err) {
            console.log('Error ' + err);
          });
          process.on('SIGTERM', function() {
            self.db.quit();
          });
          log(false, 'Redis client created with the following defaults:', {expiration: self.defaultExpiration, verbose: self.verbose, readOnly: self.readOnly});
        } else {
          self.db = false;
          log(false, 'Redis client not created: no redis config provided');
        }
      } catch (err) {
        self.db = false;
        log(true, 'Redis client not created:', err);
      }
    }
  }