@function ImmutableCoreModule

instantiate new ImmutableCoreModule

@param {string} moduleName
@param {object} options

@returns {ImmutableCoreModule}

@throws {Error}
18777
function ImmutableCoreModule (moduleName, options) {
    // require name
    this.assert(typeof moduleName === 'string', 'name required')
    // require options to be an object
    var options = requireValidOptionalObject(options)
    // set module meta data
    this.meta = {
        name: moduleName,
        options: options,
    }
    // hidden variable for global meta data
    var data
    // create getter/setter for global meta data on meta
    Object.defineProperty(this.meta, 'data', {
        get: () => data,
        set: newData => {
            // validate data - throws on error
            newData = validateSetData(this, newData)
            // set data if defined
            if (defined(newData)) {
                data = newData
            }
        },
    })
    // create getter/setter for global meta data on instance
    Object.defineProperty(this, 'data', {
        get: () => data,
        set: newData => {
            // validate data - throws on error
            newData = validateSetData(this, newData)
            // set data if defined
            if (defined(newData)) {
                data = newData
            }
        },
    })
}
298156
function create(modulePath, moduleStack, options) {

        // first check the cache to see if we already loaded it
        if (this.cache[modulePath]) {
            return this.cache[modulePath];
        }

        var uipart = this.getUiPart(modulePath, options);

        // check if parent we want to merge with the parent
        if (uipart.parent) {
            var parts = modulePath.split(delim);
            parts[3] = uipart.parent + '.' + parts[2].substring(0, parts[2].length - 1);
            var parent = this.getUiPart(parts.join(delim), options);
            uipart = _.merge({}, parent, uipart);
            delete uipart.abstract;
        }

        this.cache[modulePath] = uipart;
        return uipart;
    }
84804
function initModule (args) {
    // require string name
    this.assert(typeof args.name === 'string' && args.name.length, 101)
    // component must not already be defined
    this.assert(!defined(this.global().components[args.name]), 102, `${args.name} component already defined`)
    // store name
    this.name = args.name
    // create module name from string with `Component` appended
    this.moduleName = `${this.name}Component`
    // create new module - throws error if defined
    this.module = ImmutableCore.module(this.moduleName, {})
    // add info to module meta
    this.module.meta.class = 'ImmutableCoreComponent'
    this.module.meta.instance = this
    // add component to global register
    this.global().components[this.name] = this
}
315008
function createJsModule(source) {
    var compilerOptions = {
        compilerOptions: {
            target: ts.ScriptTarget.ES5,
            module: ts.ModuleKind.CommonJS,
            alwaysStrict: false
        }
    };
    var transpiled = ts.transpileModule(source, compilerOptions);
    return transpiled.outputText;
}
1026668
function Assemble(options) {
  if (!(this instanceof Assemble)) {
    return new Assemble(options);
  }
  Templates.call(this, options);
  this.is('assemble');
  this.initCore();
}
286643
function initModule (args) {
    debug('new ImmutableCoreModel', args)
    // require object for args
    assert.equal(typeof args, 'object', 'argument must be object')
    // require name for model
    assert.equal(typeof args.name, 'string', 'name required')
    // set model name
    this.name = args.name
    // create title from name
    this.title = changeCase.titleCase(this.name)
    // create path from name
    this.path = changeCase.paramCase(this.name)
    // module name is model name with Model appended
    this.moduleName = args.name+'Model'
    // create new immutable module for model - this will throw error
    // if moduleName is already defined
    this.module = immutable.module(this.moduleName, {})
    // add info to module meta
    this.module.meta.class = 'ImmutableCoreModel'
    this.module.meta.instance = this
    // and model to global registers
    this.global().models[this.name] = this
    // set to true if model is an action for another model
    this.isAction = false
    // parent model for action models
    this.model = undefined
    // controller object will be set when controller created for model
    this.controller = undefined
    // transformation functions keyed by property name
    this.transform = {}
    // get transform functions from args
    _.each(args.transform, (transform, property) => {
        // require function
        assert.equal(typeof transform, 'function', `tranform must be function for ${this.name} ${property}`)
        // set transform function
        this.transform[property] = transform
    })

    /* cache */

    if (defined(args.redis)) {
        this.redis(args.redis)
    }

    /* database */

    // database is now deprecated so this will throw error
    if (defined(args.database)) {
        this.database(args.database)
    }

    /* binaryIds */

    // use setting from env if set
    if (defined(process.env.DEFAULT_BINARY_IDS)) {
        this.binaryIds = process.env.DEFAULT_BINARY_IDS === 'true' || process.env.DEFAULT_BINARY_IDS === '1' ? true : false
    }
    // use binary ids setting for model if set
    else if (defined(args.binaryIds)) {
        this.binaryIds = !!args.binaryIds
    }
    // use global setting
    else {
        this.binaryIds = this.global().defaultBinaryIds
    }

    /* compression */

    // use setting from env
    if (defined(process.env.DEFAULT_COMPRESSION)) {
        this.compression = process.env.DEFAULT_COMPRESSION === 'true' || process.env.DEFAULT_COMPRESSION === '0' ? true : false
    }
    // use compresion setting for model if set
    else if (defined(args.compression)) {
        this.compression = !!args.compression
    }
    // use global setting
    else {
        this.compression = this.global().defaultCompression
    }

    /* insert delayed */

    // use insert delayed setting for model if set
    if (args.insertDelayed !== undefined) {
        this.insertDelayed = args.insertDelayed
    }
    // use global setting
    else if (process.env.DEFAULT_INSERT_DELAYED) {
        this.insertDelayed = process.env.DEFAULT_INSERT_DELAYED === 'true' ? true : false
    }
    // use global setting
    else {
        this.insertDelayed = this.global().insertDelayed
    }

    /* concurrency */

    // use concurrency setting from args if set
    if (parseInt(args.concurrency)) {
        this.concurrency = parseInt(args.concurrency)
    }
    // use global setting
    else {
        this.concurrency = this.global().concurrency
    }

    /* charset */

    // charset to use when creating table - this only applies when mode is
    // first syncd and will not be changed
    this.charset = args.charset || process.env.DEFAULT_CHARSET || this.global().defaultCharset

    /* database engine */

    // database engine to use when creating table - this only applies when model
    // is first syncd and will not be changed
    this.engine = args.engine || process.env.DEFAULT_ENGINE || this.global().defaultEngine

    /* elasticsearch configuration */

    // if elasticsearch is true then client will be set later and is required
    if (args.elasticsearch === true) {
        this.elasticsearchClient = true
    }
    // set elasticsearch client
    else if (args.elasticsearch) {
        this.elasticsearch(args.elasticsearch)
    }
    else {
        this.elasticsearchClient = null
    }
    // retain deleted records - default false
    this.esDeleted = !!args.esDeleted
    // set index name - default to model path
    this.esIndex = args.esIndex || this.path
    // set type selector - if not defined model name will also be used for type
    this.esType = args.esType

    /* mysql */

    if (defined(args.mysql)) {
        this.mysql(args.mysql)
    }
    else {
        this.mysqlClient = null
    }
}
64551
function Assemble(options) {
  if (!(this instanceof Assemble)) {
    return new Assemble(options);
  }
  Core.call(this, options);
  this.is('assemble');
  this.initAssemble();
}
676818
function initModule(forge) {

/* DEBUG API */
forge.debug = forge.debug || {};

// Private storage for debugging.
// Useful to expose data that is otherwise unviewable behind closures.
// NOTE: remember that this can hold references to data and cause leaks!
// format is "forge._debug.<modulename>.<dataname> = data"
// Example:
// (function() {
//   var cat = 'forge.test.Test'; // debugging category
//   var sState = {...}; // local state
//   forge.debug.set(cat, 'sState', sState);
// })();
forge.debug.storage = {};

/**
 * Gets debug data. Omit name for all cat data  Omit name and cat for
 * all data.
 *
 * @param cat name of debugging category.
 * @param name name of data to get (optional).
 * @return object with requested debug data or undefined.
 */
forge.debug.get = function(cat, name) {
  var rval;
  if(typeof(cat) === 'undefined') {
    rval = forge.debug.storage;
  } else if(cat in forge.debug.storage) {
    if(typeof(name) === 'undefined') {
      rval = forge.debug.storage[cat];
    } else {
      rval = forge.debug.storage[cat][name];
    }
  }
  return rval;
};

/**
 * Sets debug data.
 *
 * @param cat name of debugging category.
 * @param name name of data to set.
 * @param data data to set.
 */
forge.debug.set = function(cat, name, data) {
  if(!(cat in forge.debug.storage)) {
    forge.debug.storage[cat] = {};
  }
  forge.debug.storage[cat][name] = data;
};

/**
 * Clears debug data. Omit name for all cat data. Omit name and cat for
 * all data.
 *
 * @param cat name of debugging category.
 * @param name name of data to clear or omit to clear entire category.
 */
forge.debug.clear = function(cat, name) {
  if(typeof(cat) === 'undefined') {
    forge.debug.storage = {};
  } else if(cat in forge.debug.storage) {
    if(typeof(name) === 'undefined') {
      delete forge.debug.storage[cat];
    } else {
      delete forge.debug.storage[cat][name];
    }
  }
};

}
423776
function newTask (call) {
    // get clone of call and reset original
    call = resetCall(call)
    // require ImmutableCoreComponent
    assert.ok(GLOBAL.immutableCoreTask !== undefined, 'ImmutableAI configuration error: immutableCoreTask required')
    // get task - throws error if not found
    var task = GLOBAL.immutableCoreTask.task(call.module)
    // return function wrapper that calls new with session
    return args => {
        // make sure args is object
        if (!defined(args)) {
            args = {}
        }
        // add session to args if not defined
        if (!defined(args.session)) {
            args.session = call.session
        }
        // create new component
        return task.new(args)
    }
}
1009099
function ImmutableCoreModelCacheQuerySelect (args) {
    // store args
    this.cache = args.cache
    this.query = args.query
    // init properties
    this.cached = null
    this.selectCacheKey = this.cacheKey()
}
1190582
function create(modulePath, moduleStack, options) {

        // if flapjack passed in, inject the flapjack and use that without caching anything
        if (options && options.flapjack) {
            return this.injector.injectFlapjack(options.flapjack, moduleStack, options);
        }

        // first check the cache to see if we already loaded it
        if (this.cache[modulePath]) {
            return this.cache[modulePath];
        }

        // if the file doesn't exist throw an error
        var rootDir = this.injector.rootDir;
        var filePath = modulePath;
        if (filePath.indexOf(rootDir) !== 0) { filePath = rootDir + '/' + filePath; }   // add rootDir if not there
        if (!filePath.match(/\.js$/)) { filePath = filePath + '.js'; }                  // add .js if not there
        if (!fs.existsSync(path.normalize(filePath))) {                                                 // if file not there, throw error
            throw new Error('FlapjackFactory got invalid file path: ' + filePath);
        }

        // get the flapjack
        filePath = filePath.substring(0, filePath.length - 3);      // remove the .js
        var flapjack = this.injector.require(filePath);             // require() the module without injecting it
        flapjack = flapjack.server ? flapjack.server : flapjack;    // use the server val if it exists

        // if flapjack is not a function, just return it (i.e. its just a normal require()
        if (!_.isFunction(flapjack)) {
            this.cache[modulePath] = flapjack;
            return flapjack;
        }

        this.cache[modulePath] = this.injector.injectFlapjack(flapjack, moduleStack, options);
        return this.cache[modulePath];
    }
320542
function initComponents (config) {
    // check if immutable-app-component module is loaded
    var hasImmutableAppComponent = defined(config.modules['immutable-app-component'])
    // get components directory
    var dirs = getDir(config, 'components')
    // load component definitions from each directory
    _.each(dirs, dir => initComponentsDir(config, dir))
    // if there are components but component module is not loaded throw error
    if (_.keys(config.components).length > 0 && !hasImmutableAppComponent) {
        throw new Error('immutable-app-component not loaded')
    }
    // create new component instances from definitions
    _.each(config.components, (component, name) => {
        config.components[name] = new ImmutableCoreComponent(component)
    })
}
11270
function hotCreateModule(moduleId) {
/******/ 		var hot = {
/******/ 			// private stuff
/******/ 			_acceptedDependencies: {},
/******/ 			_declinedDependencies: {},
/******/ 			_selfAccepted: false,
/******/ 			_selfDeclined: false,
/******/ 			_disposeHandlers: [],
/******/ 			_main: hotCurrentChildModule !== moduleId,
/******/
/******/ 			// Module API
/******/ 			active: true,
/******/ 			accept: function(dep, callback) {
/******/ 				if (dep === undefined) hot._selfAccepted = true;
/******/ 				else if (typeof dep === "function") hot._selfAccepted = dep;
/******/ 				else if (typeof dep === "object")
/******/ 					for (var i = 0; i < dep.length; i++)
/******/ 						hot._acceptedDependencies[dep[i]] = callback || function() {};
/******/ 				else hot._acceptedDependencies[dep] = callback || function() {};
/******/ 			},
/******/ 			decline: function(dep) {
/******/ 				if (dep === undefined) hot._selfDeclined = true;
/******/ 				else if (typeof dep === "object")
/******/ 					for (var i = 0; i < dep.length; i++)
/******/ 						hot._declinedDependencies[dep[i]] = true;
/******/ 				else hot._declinedDependencies[dep] = true;
/******/ 			},
/******/ 			dispose: function(callback) {
/******/ 				hot._disposeHandlers.push(callback);
/******/ 			},
/******/ 			addDisposeHandler: function(callback) {
/******/ 				hot._disposeHandlers.push(callback);
/******/ 			},
/******/ 			removeDisposeHandler: function(callback) {
/******/ 				var idx = hot._disposeHandlers.indexOf(callback);
/******/ 				if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
/******/ 			},
/******/
/******/ 			// Management API
/******/ 			check: hotCheck,
/******/ 			apply: hotApply,
/******/ 			status: function(l) {
/******/ 				if (!l) return hotStatus;
/******/ 				hotStatusHandlers.push(l);
/******/ 			},
/******/ 			addStatusHandler: function(l) {
/******/ 				hotStatusHandlers.push(l);
/******/ 			},
/******/ 			removeStatusHandler: function(l) {
/******/ 				var idx = hotStatusHandlers.indexOf(l);
/******/ 				if (idx >= 0) hotStatusHandlers.splice(idx, 1);
/******/ 			},
/******/
/******/ 			//inherit from previous dispose call
/******/ 			data: hotCurrentModuleData[moduleId]
/******/ 		};
/******/ 		hotCurrentChildModule = undefined;
/******/ 		return hot;
/******/ 	}
95622
function createModule(filename) {
  const mod = new Module(filename)
  mod.filename = filename
  mod.paths = Module._nodeModulePaths(path.dirname(filename))
  return mod
}
572604
function initModule(forge) {

// forge.prime already defined
if(forge.prime) {
  return;
}

/* PRIME API */
var prime = forge.prime = forge.prime || {};

var BigInteger = forge.jsbn.BigInteger;

// primes are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
var THIRTY = new BigInteger(null);
THIRTY.fromInt(30);
var op_or = function(x, y) {return x|y;};

/**
 * Generates a random probable prime with the given number of bits.
 *
 * Alternative algorithms can be specified by name as a string or as an
 * object with custom options like so:
 *
 * {
 *   name: 'PRIMEINC',
 *   options: {
 *     maxBlockTime: <the maximum amount of time to block the main
 *       thread before allowing I/O other JS to run>,
 *     millerRabinTests: <the number of miller-rabin tests to run>,
 *     workerScript: <the worker script URL>,
 *     workers: <the number of web workers (if supported) to use,
 *       -1 to use estimated cores minus one>.
 *     workLoad: the size of the work load, ie: number of possible prime
 *       numbers for each web worker to check per work assignment,
 *       (default: 100).
 *   }
 * }
 *
 * @param bits the number of bits for the prime number.
 * @param options the options to use.
 *          [algorithm] the algorithm to use (default: 'PRIMEINC').
 *          [prng] a custom crypto-secure pseudo-random number generator to use,
 *            that must define "getBytesSync".
 *
 * @return callback(err, num) called once the operation completes.
 */
prime.generateProbablePrime = function(bits, options, callback) {
  if(typeof options === 'function') {
    callback = options;
    options = {};
  }
  options = options || {};

  // default to PRIMEINC algorithm
  var algorithm = options.algorithm || 'PRIMEINC';
  if(typeof algorithm === 'string') {
    algorithm = {name: algorithm};
  }
  algorithm.options = algorithm.options || {};

  // create prng with api that matches BigInteger secure random
  var prng = options.prng || forge.random;
  var rng = {
    // x is an array to fill with bytes
    nextBytes: function(x) {
      var b = prng.getBytesSync(x.length);
      for(var i = 0; i < x.length; ++i) {
        x[i] = b.charCodeAt(i);
      }
    }
  };

  if(algorithm.name === 'PRIMEINC') {
    return primeincFindPrime(bits, rng, algorithm.options, callback);
  }

  throw new Error('Invalid prime generation algorithm: ' + algorithm.name);
};

function primeincFindPrime(bits, rng, options, callback) {
  if('workers' in options) {
    return primeincFindPrimeWithWorkers(bits, rng, options, callback);
  }
  return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
}

function primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {
  // initialize random number
  var num = generateRandom(bits, rng);

  /* Note: All primes are of the form 30k+i for i < 30 and gcd(30, i)=1. The
  number we are given is always aligned at 30k + 1. Each time the number is
  determined not to be prime we add to get to the next 'i', eg: if the number
  was at 30k + 1 we add 6. */
  var deltaIdx = 0;

  // get required number of MR tests
  var mrTests = getMillerRabinTests(num.bitLength());
  if('millerRabinTests' in options) {
    mrTests = options.millerRabinTests;
  }

  // find prime nearest to 'num' for maxBlockTime ms
  // 10 ms gives 5ms of leeway for other calculations before dropping
  // below 60fps (1000/60 == 16.67), but in reality, the number will
  // likely be higher due to an 'atomic' big int modPow
  var maxBlockTime = 10;
  if('maxBlockTime' in options) {
    maxBlockTime = options.maxBlockTime;
  }
  var start = +new Date();
  do {
    // overflow, regenerate random number
    if(num.bitLength() > bits) {
      num = generateRandom(bits, rng);
    }
    // do primality test
    if(num.isProbablePrime(mrTests)) {
      return callback(null, num);
    }
    // get next potential prime
    num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
  } while(maxBlockTime < 0 || (+new Date() - start < maxBlockTime));

  // keep trying (setImmediate would be better here)
  forge.util.setImmediate(function() {
    primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
  });
}

function primeincFindPrimeWithWorkers(bits, rng, options, callback) {
  // web workers unavailable
  if(typeof Worker === 'undefined') {
    return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
  }

  // initialize random number
  var num = generateRandom(bits, rng);

  // use web workers to generate keys
  var numWorkers = options.workers;
  var workLoad = options.workLoad || 100;
  var range = workLoad * 30 / 8;
  var workerScript = options.workerScript || 'forge/prime.worker.js';
  if(numWorkers === -1) {
    return forge.util.estimateCores(function(err, cores) {
      if(err) {
        // default to 2
        cores = 2;
      }
      numWorkers = cores - 1;
      generate();
    });
  }
  generate();

  function generate() {
    // require at least 1 worker
    numWorkers = Math.max(1, numWorkers);

    // TODO: consider optimizing by starting workers outside getPrime() ...
    // note that in order to clean up they will have to be made internally
    // asynchronous which may actually be slower

    // start workers immediately
    var workers = [];
    for(var i = 0; i < numWorkers; ++i) {
      // FIXME: fix path or use blob URLs
      workers[i] = new Worker(workerScript);
    }
    var running = numWorkers;

    // listen for requests from workers and assign ranges to find prime
    for(var i = 0; i < numWorkers; ++i) {
      workers[i].addEventListener('message', workerMessage);
    }

    /* Note: The distribution of random numbers is unknown. Therefore, each
    web worker is continuously allocated a range of numbers to check for a
    random number until one is found.

    Every 30 numbers will be checked just 8 times, because prime numbers
    have the form:

    30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)

    Therefore, if we want a web worker to run N checks before asking for
    a new range of numbers, each range must contain N*30/8 numbers.

    For 100 checks (workLoad), this is a range of 375. */

    var found = false;
    function workerMessage(e) {
      // ignore message, prime already found
      if(found) {
        return;
      }

      --running;
      var data = e.data;
      if(data.found) {
        // terminate all workers
        for(var i = 0; i < workers.length; ++i) {
          workers[i].terminate();
        }
        found = true;
        return callback(null, new BigInteger(data.prime, 16));
      }

      // overflow, regenerate random number
      if(num.bitLength() > bits) {
        num = generateRandom(bits, rng);
      }

      // assign new range to check
      var hex = num.toString(16);

      // start prime search
      e.target.postMessage({
        hex: hex,
        workLoad: workLoad
      });

      num.dAddOffset(range, 0);
    }
  }
}

/**
 * Generates a random number using the given number of bits and RNG.
 *
 * @param bits the number of bits for the number.
 * @param rng the random number generator to use.
 *
 * @return the random number.
 */
function generateRandom(bits, rng) {
  var num = new BigInteger(bits, rng);
  // force MSB set
  var bits1 = bits - 1;
  if(!num.testBit(bits1)) {
    num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
  }
  // align number on 30k+1 boundary
  num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
  return num;
}

/**
 * Returns the required number of Miller-Rabin tests to generate a
 * prime with an error probability of (1/2)^80.
 *
 * See Handbook of Applied Cryptography Chapter 4, Table 4.4.
 *
 * @param bits the bit size.
 *
 * @return the required number of iterations.
 */
function getMillerRabinTests(bits) {
  if(bits <= 100) return 27;
  if(bits <= 150) return 18;
  if(bits <= 200) return 15;
  if(bits <= 250) return 12;
  if(bits <= 300) return 9;
  if(bits <= 350) return 8;
  if(bits <= 400) return 7;
  if(bits <= 500) return 6;
  if(bits <= 600) return 5;
  if(bits <= 800) return 4;
  if(bits <= 1250) return 3;
  return 2;
}

}
499454
function evaluateModule(id, input, type) {
		if (/javascript/.test(type)) {
			var fn = new Function("module", "exports", input);
			var moduleExports = {};
			var moduleObject = { exports: moduleExports };
			fn(moduleObject, moduleExports);
			return moduleObject.exports;
		}
		/* @if jsonLoader  */
		if (/json/.test(type)) {
			return JSON.parse(input);
		}
		/* @end */

		return input;
	}
499492
function Module(moduleId, ctx, combineConfig) {
    this.moduleId = moduleId;
    this.compiler = ctx;
    this.combineConfig = combineConfig || ctx.getCombineConfig(moduleId);
    this.definition = null;
    this.prepare();
}