text: var __extends = (this && this.__extends) || (function () {
      var extendStatics = Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
      return function (d, b) {
          extendStatics(d, b);
          function __() { this.constructor = d; }
          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
  })();
  import { Inject, Injectable, Optional } from '@angular/core';
  import { HttpHeaders, HttpParams, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
  import { map } from 'rxjs/operator/map';
  import { STATUS } from './http-status-codes';
  import { InMemoryBackendConfig, InMemoryBackendConfigArgs, InMemoryDbService } from './interfaces';
  import { BackendService } from './backend.service';
  /**
   * For Angular `HttpClient` simulate the behavior of a RESTy web api
   * backed by the simple in-memory data store provided by the injected `InMemoryDbService`.
   * Conforms mostly to behavior described here:
   * http://www.restapitutorial.com/lessons/httpmethods.html
   *
   * ### Usage
   *
   * Create an in-memory data store class that implements `InMemoryDbService`.
   * Call `config` static method with this service class and optional configuration object:
   * ```
   * // other imports
   * import { HttpClientModule } from '@angular/common/http';
   * import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
   *
   * import { InMemHeroService, inMemConfig } from '../api/in-memory-hero.service';
   * @NgModule({
   *  imports: [
   *    HttpModule,
   *    HttpClientInMemoryWebApiModule.forRoot(InMemHeroService, inMemConfig),
   *    ...
   *  ],
   *  ...
   * })
   * export class AppModule { ... }
   * ```
   */
  var HttpClientBackendService = (function (_super) {
      __extends(HttpClientBackendService, _super);
      function HttpClientBackendService(inMemDbService, config, xhrFactory) {
          var _this = _super.call(this, inMemDbService, config) || this;
          _this.xhrFactory = xhrFactory;
          return _this;
      }
      HttpClientBackendService.prototype.handle = function (req) {
          try {
              return this.handleRequest(req);
          }
          catch (error) {
              var err = error.message || error;
              var resOptions_1 = this.createErrorResponseOptions(req.url, STATUS.INTERNAL_SERVER_ERROR, "" + err);
              return this.createResponse$(function () { return resOptions_1; });
          }
      };
      ////  protected overrides /////
      HttpClientBackendService.prototype.getJsonBody = function (req) {
          return req.body;
      };
      HttpClientBackendService.prototype.getRequestMethod = function (req) {
          return (req.method || 'get').toLowerCase();
      };
      HttpClientBackendService.prototype.createHeaders = function (headers) {
          return new HttpHeaders(headers);
      };
      HttpClientBackendService.prototype.createQueryMap = function (search) {
          var map = new Map();
          if (search) {
              var params_1 = new HttpParams({ fromString: search });
              params_1.keys().forEach(function (p) { return map.set(p, params_1.getAll(p)); });
          }
          return map;
      };
      HttpClientBackendService.prototype.createResponse$fromResponseOptions$ = function (resOptions$) {
          return map.call(resOptions$, function (opts) { return new HttpResponse(opts); });
      };
      HttpClientBackendService.prototype.createPassThruBackend = function () {
          try {
              return new HttpXhrBackend(this.xhrFactory);
          }
          catch (ex) {
              ex.message = 'Cannot create passThru404 backend; ' + (ex.message || '');
              throw ex;
          }
      };
      return HttpClientBackendService;
  }(BackendService));
  export { HttpClientBackendService };
  HttpClientBackendService.decorators = [
      { type: Injectable },
  ];
  /** @nocollapse */
  HttpClientBackendService.ctorParameters = function () { return [
      { type: InMemoryDbService, },
      { type: InMemoryBackendConfigArgs, decorators: [{ type: Inject, args: [InMemoryBackendConfig,] }, { type: Optional },] },
      { type: XhrFactory, },
  ]; };
  //# sourceMappingURL=http-client-backend.service.js.map