text: /**
   * @license
   * Copyright Google Inc. All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  var __extends = (this && this.__extends) || function (d, b) {
      for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
      function __() { this.constructor = d; }
      d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
  import { Injector, THROW_IF_NOT_FOUND } from '../di/injector';
  import { unimplemented } from '../facade/errors';
  import { stringify } from '../facade/lang';
  import { CodegenComponentFactoryResolver, ComponentFactoryResolver } from './component_factory_resolver';
  /**
   * Represents an instance of an NgModule created via a {@link NgModuleFactory}.
   *
   * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
   * NgModule Instance.
   *
   * @stable
   */
  export var NgModuleRef = (function () {
      function NgModuleRef() {
      }
      Object.defineProperty(NgModuleRef.prototype, "injector", {
          /**
           * The injector that contains all of the providers of the NgModule.
           */
          get: function () { return unimplemented(); },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(NgModuleRef.prototype, "componentFactoryResolver", {
          /**
           * The ComponentFactoryResolver to get hold of the ComponentFactories
           * declared in the `entryComponents` property of the module.
           */
          get: function () { return unimplemented(); },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(NgModuleRef.prototype, "instance", {
          /**
           * The NgModule instance.
           */
          get: function () { return unimplemented(); },
          enumerable: true,
          configurable: true
      });
      return NgModuleRef;
  }());
  /**
   * @experimental
   */
  export var NgModuleFactory = (function () {
      function NgModuleFactory(_injectorClass, _moduleType) {
          this._injectorClass = _injectorClass;
          this._moduleType = _moduleType;
      }
      Object.defineProperty(NgModuleFactory.prototype, "moduleType", {
          get: function () { return this._moduleType; },
          enumerable: true,
          configurable: true
      });
      NgModuleFactory.prototype.create = function (parentInjector) {
          if (!parentInjector) {
              parentInjector = Injector.NULL;
          }
          var instance = new this._injectorClass(parentInjector);
          instance.create();
          return instance;
      };
      return NgModuleFactory;
  }());
  var _UNDEFINED = new Object();
  export var NgModuleInjector = (function (_super) {
      __extends(NgModuleInjector, _super);
      function NgModuleInjector(parent, factories, bootstrapFactories) {
          _super.call(this, factories, parent.get(ComponentFactoryResolver, ComponentFactoryResolver.NULL));
          this.parent = parent;
          this.bootstrapFactories = bootstrapFactories;
          this._destroyListeners = [];
          this._destroyed = false;
      }
      NgModuleInjector.prototype.create = function () { this.instance = this.createInternal(); };
      NgModuleInjector.prototype.get = function (token, notFoundValue) {
          if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
          if (token === Injector || token === ComponentFactoryResolver) {
              return this;
          }
          var result = this.getInternal(token, _UNDEFINED);
          return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
      };
      Object.defineProperty(NgModuleInjector.prototype, "injector", {
          get: function () { return this; },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(NgModuleInjector.prototype, "componentFactoryResolver", {
          get: function () { return this; },
          enumerable: true,
          configurable: true
      });
      NgModuleInjector.prototype.destroy = function () {
          if (this._destroyed) {
              throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
          }
          this._destroyed = true;
          this.destroyInternal();
          this._destroyListeners.forEach(function (listener) { return listener(); });
      };
      NgModuleInjector.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
      return NgModuleInjector;
  }(CodegenComponentFactoryResolver));
  //# sourceMappingURL=ng_module_factory.js.map