/* ########## Begin module implementation ##########
509853
function initModule(forge) {

forge.kem = forge.kem || {};

var BigInteger = forge.jsbn.BigInteger;

/**
 * The API for the RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.
 */
forge.kem.rsa = {};

/**
 * Creates an RSA KEM API object for generating a secret asymmetric key.
 *
 * The symmetric key may be generated via a call to 'encrypt', which will
 * produce a ciphertext to be transmitted to the recipient and a key to be
 * kept secret. The ciphertext is a parameter to be passed to 'decrypt' which
 * will produce the same secret key for the recipient to use to decrypt a
 * message that was encrypted with the secret key.
 *
 * @param kdf the KDF API to use (eg: new forge.kem.kdf1()).
 * @param options the options to use.
 *          [prng] a custom crypto-secure pseudo-random number generator to use,
 *            that must define "getBytesSync".
 */
forge.kem.rsa.create = function(kdf, options) {
  options = options || {};
  var prng = options.prng || forge.random;

  var kem = {};

  /**
   * Generates a secret key and its encapsulation.
   *
   * @param publicKey the RSA public key to encrypt with.
   * @param keyLength the length, in bytes, of the secret key to generate.
   *
   * @return an object with:
   *   encapsulation: the ciphertext for generating the secret key, as a
   *     binary-encoded string of bytes.
   *   key: the secret key to use for encrypting a message.
   */
  kem.encrypt = function(publicKey, keyLength) {
    // generate a random r where 1 > r > n
    var byteLength = Math.ceil(publicKey.n.bitLength() / 8);
    var r;
    do {
      r = new BigInteger(
        forge.util.bytesToHex(prng.getBytesSync(byteLength)),
        16).mod(publicKey.n);
    } while(r.equals(BigInteger.ZERO));

    // prepend r with zeros
    r = forge.util.hexToBytes(r.toString(16));
    var zeros = byteLength - r.length;
    if(zeros > 0) {
      r = forge.util.fillString(String.fromCharCode(0), zeros) + r;
    }

    // encrypt the random
    var encapsulation = publicKey.encrypt(r, 'NONE');

    // generate the secret key
    var key = kdf.generate(r, keyLength);

    return {encapsulation: encapsulation, key: key};
  };

  /**
   * Decrypts an encapsulated secret key.
   *
   * @param privateKey the RSA private key to decrypt with.
   * @param encapsulation the ciphertext for generating the secret key, as
   *          a binary-encoded string of bytes.
   * @param keyLength the length, in bytes, of the secret key to generate.
   *
   * @return the secret key as a binary-encoded string of bytes.
   */
  kem.decrypt = function(privateKey, encapsulation, keyLength) {
    // decrypt the encapsulation and generate the secret key
    var r = privateKey.decrypt(encapsulation, 'NONE');
    return kdf.generate(r, keyLength);
  };

  return kem;
};

// TODO: add forge.kem.kdf.create('KDF1', {md: ..., ...}) API?

/**
 * Creates a key derivation API object that implements KDF1 per ISO 18033-2.
 *
 * @param md the hash API to use.
 * @param [digestLength] an optional digest length that must be positive and
 *          less than or equal to md.digestLength.
 *
 * @return a KDF1 API object.
 */
forge.kem.kdf1 = function(md, digestLength) {
  _createKDF(this, md, 0, digestLength || md.digestLength);
};

/**
 * Creates a key derivation API object that implements KDF2 per ISO 18033-2.
 *
 * @param md the hash API to use.
 * @param [digestLength] an optional digest length that must be positive and
 *          less than or equal to md.digestLength.
 *
 * @return a KDF2 API object.
 */
forge.kem.kdf2 = function(md, digestLength) {
  _createKDF(this, md, 1, digestLength || md.digestLength);
};

/**
 * Creates a KDF1 or KDF2 API object.
 *
 * @param md the hash API to use.
 * @param counterStart the starting index for the counter.
 * @param digestLength the digest length to use.
 *
 * @return the KDF API object.
 */
function _createKDF(kdf, md, counterStart, digestLength) {
  /**
   * Generate a key of the specified length.
   *
   * @param x the binary-encoded byte string to generate a key from.
   * @param length the number of bytes to generate (the size of the key).
   *
   * @return the key as a binary-encoded string.
   */
  kdf.generate = function(x, length) {
    var key = new forge.util.ByteBuffer();

    // run counter from counterStart to ceil(length / Hash.len)
    var k = Math.ceil(length / digestLength) + counterStart;

    var c = new forge.util.ByteBuffer();
    for(var i = counterStart; i < k; ++i) {
      // I2OSP(i, 4): convert counter to an octet string of 4 octets
      c.putInt32(i);

      // digest 'x' and the counter and add the result to the key
      md.start();
      md.update(x + c.getBytes());
      var hash = md.digest();
      key.putBytes(hash.getBytes(digestLength));
    }

    // truncate to the correct key length
    key.truncate(key.length() - length);
    return key.getBytes();
  };
}

}
881307
function() {

     	var modules = this.modules;
     	for(var i = 0 ; i < modules.length ; i++) {
		  	this.addModuleToList(modules[i]);
     	}

     	// Make the layer a drag drop target
     	if(!this.ddTarget) {
       	this.ddTarget = new YAHOO.util.DDTarget(this.layer.el, "module");
       	this.ddTarget._layer = this.layer;
     	}
 	}
816576
public <T extends SourceFile> void initModules(
      List<T> externs, List<JSModule> modules, CompilerOptions options) {
    initOptions(options);

    checkFirstModule(modules);

    this.externs = makeExternInputs(externs);

    // Generate the module graph, and report any errors in the module specification as errors.
    try {
      this.moduleGraph = new JSModuleGraph(modules);
    } catch (JSModuleGraph.ModuleDependenceException e) {
      // problems with the module format.  Report as an error.  The
      // message gives all details.
      report(JSError.make(MODULE_DEPENDENCY_ERROR,
          e.getModule().getName(), e.getDependentModule().getName()));
      return;
    }

    // Creating the module graph can move weak source around, and end up with empty modules.
    fillEmptyModules(getModules());

    this.commentsPerFile = new ConcurrentHashMap<>(moduleGraph.getInputCount());
    initBasedOnOptions();

    initInputsByIdMap();

    initAST();
  }
543939
@Override
	public Module start(Module.Context context) {
		// FIXME: logger is a hack!
		final Logger logger = new Logger.Default(System.err);
		// List of commands to use
		context.register(Build.Platform.class, WHILEY_PLATFORM);
		// List of content types
		context.register(Content.Type.class, WhileyFile.ContentType);
		context.register(Content.Type.class, WyilFile.ContentType);
		// Done
		return new Module() {
			// what goes here?
		};
	}
956665
function init(options) {

    var fs = require('fs');
    var path = require('path');
    var rootdir = path.dirname(require.main);
    var options = options || {
        config: require(path.join(rootdir, 'config.json')),
        root: rootdir,
        callback: function (noop) {}
    };
    var def = {};
    function ModulePaths (moduledir) {
        this.moduledir = moduledir;
    }

    ModulePaths.prototype.then = function (accept, reject) {
      var moduledir = this.moduledir;
      fs.readdir(moduledir, function (err, files) {
        if (err) reject(err);
        files.forEach(function (file) {
            var name = path.basename(file, '.js');
            def[name] = path.join(moduledir, name);
        });
        accept();
      });
    };
    var pubpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'public', 'js'));
    var prvpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'private', 'js'));

    Promise.all([pubpath, prvpath])
        .then(function () {
            var requirejs = require('requirejs');
            requirejs.config({
                baseUrl: path.join(rootdir),
                paths: def
            });

            requirejs(['loader_factory'], function (LoaderFactory) {
                var fs = require('fs');
                var config = options.config;
                config.paths.push(path.dirname(pubpath.moduledir));
                var loader = 'loader_express';
                var db = 'db_mongo';
                if (config.loader) loader = config.loader;
                if (config.db) db = config.db;

                new LoaderFactory().create(loader, db, function (loader) {
                    loader.init(config, options.callback);
                });
            });
        })
    .catch(function (err) {
        console.error('err:', err);
    });
}
1091962
private void processLegacyModuleCall(String namespace, Node googModuleCall, JSModule module) {
    registerAnyProvidedPrefixes(namespace, googModuleCall, module);
    providedNames.put(
        namespace,
        new ProvidedName(
            namespace,
            googModuleCall,
            module,
            /* explicit= */ true,
            /* fromPreviousProvide= */ false));
  }
1157895
public static function initSubmodules($module)
    {
        $submodules = ArrayHelper::merge($module->modules, static::submodules($module));
        foreach ($submodules as $submoduleId => $submodule) {
            if (is_array($submodule)) $submodule = $module->getModule($submoduleId);
            if (empty($submodule)) continue;
            static::initSubmodules($submodule);
        }
    }
1326740
public void addModule(Module module) {
        PreconditionUtil.verify(!initialized, "CrnkClient already initialized, cannot add further modules");
        if (module instanceof HttpAdapterAware) {
            ((HttpAdapterAware) module).setHttpAdapter(getHttpAdapter());
        }
        this.moduleRegistry.addModule(module);
    }
814031
function(parentModule, kbox, id, app, callback) {

  if (typeof callback === 'undefined' && typeof app === 'function') {
    callback = app;
    app = undefined;
  }

  // Try to load module from node_module directories.
  return requireFromNodeModules(parentModule, id)
  // If module was not found in node_module directories, try to load
  // from other directories.
  .then(function(mod) {
    if (mod) {
      return mod;
    } else {
      return requireFromOtherDirs(kbox, id, app);
    }
  })
  // Return.
  .nodeify(callback);

}
32220
@Override
    public void generate(final Module module, final Element element) {
        if (!(module instanceof SimpleListExtension)) {
            return;
        }

        final SimpleListExtension sle = (SimpleListExtension) module;
        addNotNullElement(element, "treatAs", sle.getTreatAs());

        final Group[] groups = sle.getGroupFields();
        final Element listInfo = new Element("listinfo", ModuleParser.NS);

        for (int i = 0; groups != null && i < groups.length; i++) {
            final Element group = new Element("group", ModuleParser.NS);

            if (groups[i].getNamespace() != Namespace.NO_NAMESPACE) {
                addNotNullAttribute(group, "ns", groups[i].getNamespace().getURI());
            }

            addNotNullAttribute(group, "element", groups[i].getElement());
            addNotNullAttribute(group, "label", groups[i].getLabel());
            listInfo.addContent(group);
        }

        final Sort[] sorts = sle.getSortFields();

        for (int i = 0; sorts != null && i < sorts.length; i++) {
            final Element sort = new Element("sort", ModuleParser.NS);

            if (sorts[i].getNamespace() != Namespace.NO_NAMESPACE) {
                addNotNullAttribute(sort, "ns", sorts[i].getNamespace().getURI());
            }

            addNotNullAttribute(sort, "element", sorts[i].getElement());
            addNotNullAttribute(sort, "label", sorts[i].getLabel());
            addNotNullAttribute(sort, "data-type", sorts[i].getDataType());

            if (sorts[i].getDefaultOrder()) {
                addNotNullAttribute(sort, "default", "true");
            }

            listInfo.addContent(sort);
        }

        if (!listInfo.getChildren().isEmpty()) {
            element.addContent(listInfo);
        }
    }
1081732
function initModule(forge) {

// shortcut for ASN.1 API
var asn1 = forge.asn1;

// shortcut for PKCS#7 API
var p7v = forge.pkcs7asn1 = forge.pkcs7asn1 || {};
forge.pkcs7 = forge.pkcs7 || {};
forge.pkcs7.asn1 = p7v;

var contentInfoValidator = {
  name: 'ContentInfo',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'ContentInfo.ContentType',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.OID,
    constructed: false,
    capture: 'contentType'
  }, {
    name: 'ContentInfo.content',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 0,
    constructed: true,
    optional: true,
    captureAsn1: 'content'
  }]
};
p7v.contentInfoValidator = contentInfoValidator;

var encryptedContentInfoValidator = {
  name: 'EncryptedContentInfo',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'EncryptedContentInfo.contentType',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.OID,
    constructed: false,
    capture: 'contentType'
  }, {
    name: 'EncryptedContentInfo.contentEncryptionAlgorithm',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true,
    value: [{
      name: 'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',
      tagClass: asn1.Class.UNIVERSAL,
      type: asn1.Type.OID,
      constructed: false,
      capture: 'encAlgorithm'
    }, {
      name: 'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',
      tagClass: asn1.Class.UNIVERSAL,
      captureAsn1: 'encParameter'
    }]
  }, {
    name: 'EncryptedContentInfo.encryptedContent',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 0,
    /* The PKCS#7 structure output by OpenSSL somewhat differs from what
     * other implementations do generate.
     *
     * OpenSSL generates a structure like this:
     * SEQUENCE {
     *    ...
     *    [0]
     *       26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
     *       C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
     *       ...
     * }
     *
     * Whereas other implementations (and this PKCS#7 module) generate:
     * SEQUENCE {
     *    ...
     *    [0] {
     *       OCTET STRING
     *          26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
     *          C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
     *          ...
     *    }
     * }
     *
     * In order to support both, we just capture the context specific
     * field here.  The OCTET STRING bit is removed below.
     */
    capture: 'encryptedContent',
    captureAsn1: 'encryptedContentAsn1'
  }]
};

p7v.envelopedDataValidator = {
  name: 'EnvelopedData',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'EnvelopedData.Version',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.INTEGER,
    constructed: false,
    capture: 'version'
  }, {
    name: 'EnvelopedData.RecipientInfos',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SET,
    constructed: true,
    captureAsn1: 'recipientInfos'
  }].concat(encryptedContentInfoValidator)
};

p7v.encryptedDataValidator = {
  name: 'EncryptedData',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'EncryptedData.Version',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.INTEGER,
    constructed: false,
    capture: 'version'
  }].concat(encryptedContentInfoValidator)
};

var signerValidator = {
  name: 'SignerInfo',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'SignerInfo.Version',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.INTEGER,
    constructed: false
  }, {
    name: 'SignerInfo.IssuerAndSerialNumber',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true
  }, {
    name: 'SignerInfo.DigestAlgorithm',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true
  }, {
    name: 'SignerInfo.AuthenticatedAttributes',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 0,
    constructed: true,
    optional: true,
    capture: 'authenticatedAttributes'
  }, {
    name: 'SignerInfo.DigestEncryptionAlgorithm',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true
  }, {
    name: 'SignerInfo.EncryptedDigest',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.OCTETSTRING,
    constructed: false,
    capture: 'signature'
  }, {
    name: 'SignerInfo.UnauthenticatedAttributes',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 1,
    constructed: true,
    optional: true
  }]
};

p7v.signedDataValidator = {
  name: 'SignedData',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'SignedData.Version',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.INTEGER,
    constructed: false,
    capture: 'version'
  }, {
    name: 'SignedData.DigestAlgorithms',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SET,
    constructed: true,
    captureAsn1: 'digestAlgorithms'
  },
  contentInfoValidator,
  {
    name: 'SignedData.Certificates',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 0,
    optional: true,
    captureAsn1: 'certificates'
  }, {
    name: 'SignedData.CertificateRevocationLists',
    tagClass: asn1.Class.CONTEXT_SPECIFIC,
    type: 1,
    optional: true,
    captureAsn1: 'crls'
  }, {
    name: 'SignedData.SignerInfos',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SET,
    capture: 'signerInfos',
    optional: true,
    value: [signerValidator]
  }]
};

p7v.recipientInfoValidator = {
  name: 'RecipientInfo',
  tagClass: asn1.Class.UNIVERSAL,
  type: asn1.Type.SEQUENCE,
  constructed: true,
  value: [{
    name: 'RecipientInfo.version',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.INTEGER,
    constructed: false,
    capture: 'version'
  }, {
    name: 'RecipientInfo.issuerAndSerial',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true,
    value: [{
      name: 'RecipientInfo.issuerAndSerial.issuer',
      tagClass: asn1.Class.UNIVERSAL,
      type: asn1.Type.SEQUENCE,
      constructed: true,
      captureAsn1: 'issuer'
    }, {
      name: 'RecipientInfo.issuerAndSerial.serialNumber',
      tagClass: asn1.Class.UNIVERSAL,
      type: asn1.Type.INTEGER,
      constructed: false,
      capture: 'serial'
    }]
  }, {
    name: 'RecipientInfo.keyEncryptionAlgorithm',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.SEQUENCE,
    constructed: true,
    value: [{
      name: 'RecipientInfo.keyEncryptionAlgorithm.algorithm',
      tagClass: asn1.Class.UNIVERSAL,
      type: asn1.Type.OID,
      constructed: false,
      capture: 'encAlgorithm'
    }, {
      name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',
      tagClass: asn1.Class.UNIVERSAL,
      constructed: false,
      captureAsn1: 'encParameter'
    }]
  }, {
    name: 'RecipientInfo.encryptedKey',
    tagClass: asn1.Class.UNIVERSAL,
    type: asn1.Type.OCTETSTRING,
    constructed: false,
    capture: 'encKey'
  }]
};

}
1136871
function initModule (args) {
    debug('new ImmutableCoreController', args)
    // require object for args
    assert.equal(typeof args, 'object', 'argument must be object')
    // get name from args if set
    if (args.name) {
        // require name to be string
        assert.equal(typeof args.name, 'string', 'name must be string')
        // set name
        this.name = args.name
    }
    else {
        // use model name if set
        if (args.model) {
            this.name = args.model.name
        }
        // require name
        else {
            throw new Error('name required')
        }
    }
    // set model
    this.model = args.model
    // module name is model name with Controller appended
    this.moduleName = this.name+'Controller'
    // 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 = 'ImmutableCoreController'
    this.module.meta.instance = this
    // set default limit for index results
    this.defaultLimit = args.defaultLimit || DEFAULT_LIMIT
}
1060792
function(parentModule, kbox, id, app, callback) {

  if (typeof callback === 'undefined' && typeof app === 'function') {
    callback = app;
    app = undefined;
  }

  // Try to load module from node_modules and other directories.
  var parts = id.split('@');
  var pkg = parts[0];
  //var ver = parts[1];

  // Try to load module.
  return requireFromNodeModulesAndOtherDirs(parentModule, kbox, pkg, app)
  // Return.
  .nodeify(callback);

}
1312018
function Module (rawModule, runtime) {
  this.runtime = runtime;
  // Store some children item
  this._children = Object.create(null);
  // Store the origin module object which passed by programmer
  this._rawModule = rawModule;
  var rawState = rawModule.state;

  // Store the origin module's state
  this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
}
110570
function boot_module() {
    var mtor = function() {};
    mtor.prototype = RubyModule.constructor.prototype;

    function OpalModule() {};
    OpalModule.prototype = new mtor();

    var module = new OpalModule();

    module._id         = unique_id++;
    module._isClass    = true;
    module.constructor = OpalModule;
    module._super      = RubyModule;
    module._methods    = [];
    module.__inc__     = [];
    module.__parent    = RubyModule;
    module._proto      = {};
    module.__mod__     = true;
    module.__dep__     = [];

    return module;
  }
944070
function initModule($fh, cameraOptionsBuilder, mode) {
  var moduleName = 'wfm.step.gallery';
  // require http module to get server baseUrl
  var ngModule = angular.module(moduleName, []);

  require('../../dist');

  ngModule.directive('gallery', function($templateCache) {
    return {
      restrict: 'E'
      , template: $templateCache.get('wfm-template/gallery.tpl.html')
      , controller: function($scope) {
        var self = this;

        getServerUrl($fh).then(function(serverBaseUrl) {
          var baseFileUrl = new URL('/file/', serverBaseUrl);
          $scope.pictures = self.getPictures(baseFileUrl);
        });

        self.getPictures = function(baseFileUrl) {
          var gallery = $scope.result.submission.gallery;
          var pictures = [];
          for (var i in gallery) {
            if (gallery[i]) {
              if (mode === "admin") {
                pictures.push(baseFileUrl + gallery[i].id);
              } else {
                pictures.push(gallery[i].uri);
              }
            }
          }
          return pictures;
        };
      },
      controllerAs: 'ctrl'
    };
  });

  ngModule.directive('galleryForm', ['$templateCache', '$http', '$mdDialog', function($templateCache, $http, $mdDialog) {
    return {
      restrict: 'E'
      , template: $templateCache.get('wfm-template/gallery-form.tpl.html')
      , controller: function($scope) {
        var self = this;
        var fileManagerClient = {
          upload: function(uri, formData) {
            return $http({
              url: uri,
              method: 'POST',
              headers: {
                'Content-Type': undefined
              },
              data: formData
            });
          },
          download: function(uri) {
            return $http({
              method: 'GET',
              url: uri
            });
          }
        };

        getServerUrl($fh).then(function(serverBaseUrl) {
          var url = new URL('/file/', serverBaseUrl);
          self.fileManager = new FileManager(url.toString(), 'gallery', fileManagerClient);
          self.camera = new Camera(cameraOptionsBuilder);
        });

        self.model = {};
        self.parentController = $scope.$parent;
        self.back = function(event) {
          self.parentController.ctrl.triggerBackStep(self.model);
          event.preventDefault();
          event.stopPropagation();
        };
        self.done = function(event) {
          self.parentController.ctrl.triggerCompleteStep(self.model);
          event.preventDefault();
          event.stopPropagation();
        };

        self.addImage = function(uri, id) {
          $scope.$apply(function() {
            self.model.gallery = self.model.gallery || [];
            self.model.gallery.push({ uri: uri, id: id });
          });
        };

        self.takePicture = function() {
          if (!window.navigator.camera) {
            var alert = $mdDialog.alert({
              title: 'Camera not available in browser',
              textContent: 'Camera plugin not available. Try running project in emulator or using `cordova run browser`.',
              ok: 'Close'
            });
            return $mdDialog.show(alert);
          }
          self.camera.capture().then(function(captureResponse) {
            captureResponse.id = uuid.create().toString();
            self.addImage(captureResponse.value, captureResponse.id);
            return captureResponse;
          }).then(function(captureResponse) {
            var file = {
              uri: captureResponse.value,
              type: captureResponse.type,
              id: captureResponse.id
            };
            return self.fileManager.scheduleFileToBeUploaded(file);
          }).catch(console.error);
        };
      }
      , controllerAs: 'ctrl'
    };
  }]);

  return moduleName;
}
1309945
function createModule(module) {
        var moduleInstance,
            moduleId;

        if (typeof module === 'function') {
            try {
                moduleInstance = module();
            } catch (ex) {
                if (module.getId) {
                    moduleId = module.getId();
                } else {
                    moduleId = module.name;
                }

                error('Failed to create an instance of module "' + moduleId + '".',
                      'Application will continue running without the module. ' +
                      'See following exception stack for more details.',
                      ex.stack);
            }
        } else {
            moduleInstance = module;
        }

        addOne(moduleInstances, moduleInstance);

        return moduleInstance;
    }