import { Component } from '@angular/core';

export class Hero {
  id: number;
  name: string;
}

@Component({
  selector: 'my-app',
  template: `
    <h1>{{title}}</h1>
    <h2>{{hero.name}} details!</h2>
    <div><label>id: </label>{{hero.id}}</div>
    <div>
      <label>name: </label>
      <input [(ngModel)]="hero.name" placeholder="name">
    </div>
    `
})
export class AppComponent {
  title = 'Tour of Heroes';
  hero: Hero = {
    id: 1,
    name: 'Windstorm'
  };
}


/*
Copyright 2017 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 http://angular.io/license
*/
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';

import { AppComponent }  from './app.component';
import { TranslatorModule } from 'angular2-translator'


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    TranslatorModule
  ],
  declarations: [
    AppComponent
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }


/*
Copyright 2017 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 http://angular.io/license
*/
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);


/*
Copyright 2017 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 http://angular.io/license
*/
/* Master Styles */
h1 {
  color: #369;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 250%;
}
h2, h3 {
  color: #444;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: lighter;
}
body {
  margin: 2em;
}
body, input[text], button {
  color: #888;
  font-family: Cambria, Georgia;
}
a {
  cursor: pointer;
  cursor: hand;
}
button {
  font-family: Arial;
  background-color: #eee;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  cursor: hand;
}
button:hover {
  background-color: #cfd8dc;
}
button:disabled {
  background-color: #eee;
  color: #aaa;
  cursor: auto;
}

/* Navigation link styles */
nav a {
  padding: 5px 10px;
  text-decoration: none;
  margin-right: 10px;
  margin-top: 10px;
  display: inline-block;
  background-color: #eee;
  border-radius: 4px;
}
nav a:visited, a:link {
  color: #607D8B;
}
nav a:hover {
  color: #039be5;
  background-color: #CFD8DC;
}
nav a.active {
  color: #039be5;
}

/* items class */
.items {
  margin: 0 0 2em 0;
  list-style-type: none;
  padding: 0;
  width: 24em;
}
.items li {
  cursor: pointer;
  position: relative;
  left: 0;
  background-color: #EEE;
  margin: .5em;
  padding: .3em 0;
  height: 1.6em;
  border-radius: 4px;
}
.items li:hover {
  color: #607D8B;
  background-color: #DDD;
  left: .1em;
}
.items li.selected {
  background-color: #CFD8DC;
  color: white;
}
.items li.selected:hover {
  background-color: #BBD8DC;
}
.items .text {
  position: relative;
  top: -3px;
}
.items .badge {
  display: inline-block;
  font-size: small;
  color: white;
  padding: 0.8em 0.7em 0 0.7em;
  background-color: #607D8B;
  line-height: 1em;
  position: relative;
  left: -1px;
  top: -4px;
  height: 1.8em;
  margin-right: .8em;
  border-radius: 4px 0 0 4px;
}
/* everywhere else */
* {
  font-family: Arial, Helvetica, sans-serif;
}


/*
Copyright 2017 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 http://angular.io/license
*/
<!DOCTYPE html>
<html>
  <head>
    <title>Angular Tour of Heroes</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">

    <!-- Polyfills -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>

    <script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>

    <script src="systemjs.config.js"></script>
    <script>
      System.import('main.js').catch(function(err){ console.error(err); });
    </script>
  </head>

  <body>
    <my-app>Loading...</my-app>
  </body>
</html>


<!-- 
Copyright 2017 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 http://angular.io/license
-->
/**
 * WEB ANGULAR VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es2015", "dom"],
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs@5.0.1',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@5.2.7/lib/plugin.js',
      'typescript':                'npm:typescript@2.0.10/lib/typescript.js',
      'angular2-translator':       'bundle/angular2-translator.js'

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });

})(this);

/*
Copyright 2016 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 http://angular.io/license
*/
!function (a) {
    function b(a) {Object.defineProperty(this, a, {enumerable: !0, get: function () {return this[o][a]}})}

    function c(a) {
        var b;
        if (a && a.__esModule) {
            b = {};
            for (var c in a)Object.hasOwnProperty.call(a, c) && (b[c] = a[c]);
            b.__useDefault = !1, b.__esModule = !0
        } else {
            if ("[object Module]" === Object.prototype.toString.call(a) || "undefined" != typeof System && System.isModule && System.isModule(a))return a;
            b = {default: a, __useDefault: !0}
        }
        return new d(b)
    }

    function d(a) {Object.defineProperty(this, o, {value: a}), Object.keys(a).forEach(b, this)}

    function e(a) {return "@node/" === a.substr(0, 6) ? m(a, c(p(a.substr(6))), {}) : n[a]}

    function f(a) {
        var b = e(a);
        if (!b)throw new Error('Module "' + a + '" expected, but not contained in build.');
        if (b.module)return b.module;
        var c = b.linkRecord;
        return g(b, c), l(b, c, []), b.module
    }

    function g(a, b) {
        if (!b.depLoads) {
            b.declare && h(a, b), b.depLoads = [];
            for (var c = 0; c < b.deps.length; c++) {
                var d = e(b.deps[c]);
                b.depLoads.push(d), d.linkRecord && g(d, d.linkRecord);
                var f = b.setters && b.setters[c];
                f && (f(d.module || d.linkRecord.moduleObj), d.importerSetters.push(f))
            }
            return a
        }
    }

    function h(b, c) {
        var d = c.moduleObj, e = b.importerSetters, f = !1, g = c.declare.call(a, function (a, b) {
            if (!f) {
                if ("object" == typeof a)for (var c in a)"__useDefault" !== c && (d[c] = a[c]); else d[a] = b;
                f = !0;
                for (var g = 0; g < e.length; g++)e[g](d);
                return f = !1, b
            }
        }, {id: b.key});
        "function" != typeof g ? (c.setters = g.setters, c.execute = g.execute) : (c.setters = [], c.execute = g)
    }

    function i(a, b, c) {
        return n[a] = {
            key: a,
            module: void 0,
            importerSetters: [],
            linkRecord: {deps: b, depLoads: void 0, declare: c, setters: void 0, execute: void 0, moduleObj: {}}
        }
    }

    function j(a, b, c, d) {
        return n[a] = {
            key: a,
            module: void 0,
            importerSetters: [],
            linkRecord: {
                deps: b,
                depLoads: void 0,
                declare: void 0,
                execute: d,
                executingRequire: c,
                moduleObj: {default: {}, __useDefault: !0},
                setters: void 0
            }
        }
    }

    function k(a, b, c) {
        return function (d) {
            for (var e = 0; e < a.length; e++)if (a[e] === d) {
                var f, g = b[e];
                return f = -1 === c.indexOf(g) ? l(g, g.linkRecord, c) : g.linkRecord.moduleObj, f.__useDefault ? f.default : f
            }
        }
    }

    function l(b, c, e) {
        if (e.push(b), b.module)return b.module;
        if (c.setters) {
            for (var f = 0; f < c.deps.length; f++) {
                var g = c.depLoads[f], h = g.linkRecord;
                h && -1 === e.indexOf(g) && l(g, h, h.setters ? e : [])
            }
            c.execute.call(q)
        } else {
            var i = {id: b.key}, j = c.moduleObj;
            Object.defineProperty(i, "exports", {
                configurable: !0,
                set: function (a) {j.default = a},
                get: function () {return j.default}
            });
            var m = k(c.deps, c.depLoads, e);
            if (!c.executingRequire)for (var f = 0; f < c.deps.length; f++)m(c.deps[f]);
            var n = c.execute.call(a, m, j.default, i);
            if (void 0 !== n ? j.default = n : i.exports !== j.default && (j.default = i.exports), j.default && j.default.__esModule)for (var o in j.default)Object.hasOwnProperty.call(j.default, o) && "default" !== o && (j[o] = j.default[o])
        }
        var i = b.module = new d(c.moduleObj);
        if (!c.setters)for (var f = 0; f < b.importerSetters.length; f++)b.importerSetters[f](i);
        return i
    }

    function m(a, b) {return n[a] = {key: a, module: b, importerSetters: [], linkRecord: void 0}}

    var n = {}, o = "undefined" != typeof Symbol ? Symbol() : "@@baseObject";
    d.prototype = Object.create(null), "undefined" != typeof Symbol && Symbol.toStringTag && (d.prototype[Symbol.toStringTag] = "Module");
    var p = "undefined" != typeof System && System._nodeRequire || "undefined" != typeof require && void 0 !== require.resolve && "undefined" != typeof process && process.platform && require, q = {};
    return Object.freeze && Object.freeze(q), function (a, b, e, g) {
        return function (h) {
            h(function (h) {
                var k = {
                    _nodeRequire: p,
                    register: i,
                    registerDynamic: j,
                    registry: {get: function (a) {return n[a].module}, set: m},
                    newModule: function (a) {return new d(a)}
                };
                m("@empty", new d({}));
                for (var l = 0; l < b.length; l++)m(b[l], c(arguments[l], {}));
                g(k);
                var o = f(a[0]);
                if (a.length > 1)for (var l = 1; l < a.length; l++)f(a[l]);
                return e ? o.default : (o instanceof d && Object.defineProperty(o, "__esModule", {value: !0}), o)
            })
        }
    }
}("undefined" != typeof self ? self : global)(["a"], ["d", "10", "13", "14"], !0, function ($__System) {
    var require = this.require, exports = this.exports, module = this.module;
    $__System.registerDynamic("b", ["c", "d"], !0, function (a, b, c) {
        "use strict";
        var d = (this || self, b && b.__decorate || function (a, b, c, d) {
            var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
            return f > 3 && g && Object.defineProperty(b, c, g), g
        }), e = b && b.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(b, "__esModule", {value: !0});
        var f = a("c"), g = a("d"), h = function () {
            function a(a) {
                var b = this;
                this.translation = "", this._params = {}, this._translate = a, a.languageChanged.subscribe(function () {b._startTranslation()})
            }

            return Object.defineProperty(a.prototype, "key", {
                set: function (a) {this._key = a, this._startTranslation()},
                enumerable: !0,
                configurable: !0
            }), Object.defineProperty(a.prototype, "params", {
                set: function (a) {
                    if ("object" != typeof a)return void this._translate.logHandler.error("Params have to be an object");
                    this._params = a, this._startTranslation()
                }, enumerable: !0, configurable: !0
            }), a.prototype._startTranslation = function () {
                var a = this;
                this._key && this._translate.translate(this._key, this._params).then(function (b) {return a.translation = String(b)})
            }, a
        }();
        d([g.Input("translate")], h.prototype, "key", null), d([g.Input("translateParams")], h.prototype, "params", null), h = d([g.Component({
            selector: "[translate]",
            template: "{{translation}}"
        }), e(0, g.Inject(f.TranslateService))], h), b.TranslateComponent = h
    }), $__System.registerDynamic("e", ["f", "d", "10"], !0, function (a, b, c) {
        "use strict";
        var d = (this || self, b && b.__extends || function () {
            var a = Object.setPrototypeOf || {__proto__: []} instanceof Array && function (a, b) {a.__proto__ = b} || function (a, b) {for (var c in b)b.hasOwnProperty(c) && (a[c] = b[c])};
            return function (b, c) {
                function d() {this.constructor = b}

                a(b, c), b.prototype = null === c ? Object.create(c) : (d.prototype = c.prototype, new d)
            }
        }()), e = b && b.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, f = b && b.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(b, "__esModule", {value: !0});
        var g = a("f"), h = a("d"), i = a("10"), j = function () {
            function a(a, b) {this.path = "i18n/", this.extension = ".json", a && (this.path = a.replace(/\/+$/, "") + "/"), b && (this.extension = b)}

            return a
        }();
        b.TranslateLoaderJsonConfig = j;
        var k = function (a) {
            function b(b, c) {
                var d = a.call(this) || this;
                return d._http = b, d._config = c, d
            }

            return d(b, a), b.prototype.load = function (a) {
                var b = this;
                return new Promise(function (c, d) {
                    var e = b._config.path + a + b._config.extension;
                    b._http.get(e).subscribe(function (a) {
                        if (200 === a.status) {
                            var e = {};
                            b.flattenTranslations(e, a.json()), c(e)
                        } else d("StatusCode: " + a.status)
                    }, function (a) {d(a.message)})
                })
            }, b.prototype.flattenTranslations = function (a, b, c) {
                void 0 === c && (c = "");
                for (var d in b)Array.isArray(b[d]) ? a[c + d] = b[d].filter(function (a) {return "string" == typeof a}).join("") : "object" == typeof b[d] ? this.flattenTranslations(a, b[d], c + d + ".") : "string" == typeof b[d] && (a[c + d] = b[d])
            }, b
        }(g.TranslateLoader);
        k = e([h.Injectable(), f(0, h.Inject(i.Http)), f(1, h.Inject(j))], k), b.TranslateLoaderJson = k
    }), $__System.registerDynamic("11", ["c", "d"], !0, function ($__require, exports, module) {
        "use strict";
        var global = this || self, GLOBAL = global, __decorate = exports && exports.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, __param = exports && exports.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(exports, "__esModule", {value: !0});
        var TranslateService_1 = $__require("c"), core_1 = $__require("d"), TranslatePipe = TranslatePipe_1 = function () {
            function TranslatePipe(a) {
                var b = this;
                this._translation = "", this._translate = a, a.languageChanged.subscribe(function () {b._startTranslation()})
            }

            return TranslatePipe._parseParams = function (arg) {
                try {
                    var o = eval("(" + arg + ")");
                    if ("object" == typeof o)return o
                } catch (a) {}
                return {}
            }, TranslatePipe.prototype.transform = function (a, b) {
                void 0 === b && (b = []);
                var c = {};
                return b[0] && ("string" == typeof b[0] ? (c = TranslatePipe_1._parseParams(b[0]), Object.keys(c).length || this._translate.logHandler.error("'" + b[0] + "' could not be parsed to object")) : "object" == typeof b[0] && (c = b[0])), this._translated && this._promise && (this._translated.key !== a || JSON.stringify(this._translated.params) !== JSON.stringify(c)) && (this._promise = null), this._promise || (this._translated = {
                    key: a,
                    params: c
                }, this._startTranslation()), this._translation
            }, TranslatePipe.prototype._startTranslation = function () {
                var a = this;
                this._translated && this._translated.key && (this._promise = this._translate.translate(this._translated.key, this._translated.params), this._promise.then(function (b) {return a._translation = String(b)}))
            }, TranslatePipe
        }();
        TranslatePipe = TranslatePipe_1 = __decorate([core_1.Pipe({
            name: "translate",
            pure: !1
        }), __param(0, core_1.Inject(TranslateService_1.TranslateService))], TranslatePipe), exports.TranslatePipe = TranslatePipe;
        var TranslatePipe_1
    }), $__System.registerDynamic("12", [], !0, function (a, b, c) {
        "use strict";
        this || self;
        Object.defineProperty(b, "__esModule", {value: !0});
        var d = function () {
            function a(b) {
                var c = b.defaultLang, d = void 0 === c ? "en" : c, e = b.providedLangs, f = void 0 === e ? ["en"] : e, g = b.detectLanguageOnStart, h = void 0 === g || g;
                this.defaultLang = f.indexOf(d) > -1 ? d : f[0], this.providedLangs = f, this.detectLanguageOnStart = h, this.navigatorLanguages = function () {
                    var b = a.navigator;
                    return b.languages instanceof Array ? Array.prototype.slice.call(b.languages) : "string" == typeof b.languages ? [String(b.languages)] : "string" == typeof b.language ? [b.language] : []
                }()
            }

            return a.prototype.langProvided = function (a, b) {
                void 0 === b && (b = !1);
                var c, d = !1, e = function (a) {
                    var b = /^([A-Za-z]{2})(?:[\.\-_\/]?([A-Za-z]{2}))?$/;
                    return a.match(b) ? a.replace(b, function (a, b, c) {return void 0 === c && (c = ""), b = b.toLowerCase(), c = c.toUpperCase(), c ? b + "-" + c : b}) : ""
                }, f = this.providedLangs.map(e);
                return a = e(a), 0 === a.length ? d : (c = f.indexOf(a), c > -1 ? d = this.providedLangs[c] : b || (a = a.substr(0, 2), c = f.indexOf(a), c > -1 ? d = this.providedLangs[c] : (c = f.map(function (a) {return a.substr(0, 2)}).indexOf(a), c > -1 && (d = this.providedLangs[c]))), d)
            }, a
        }();
        d.navigator = window && window.navigator ? window.navigator : {}, b.TranslateConfig = d
    }), $__System.registerDynamic("f", [], !0, function (a, b, c) {
        "use strict";
        this || self;
        Object.defineProperty(b, "__esModule", {value: !0});
        var d = function () {
            function a() {}

            return a
        }();
        b.TranslateLoader = d
    }), $__System.registerDynamic("c", ["12", "f", "d", "13", "14"], !0, function ($__require, exports, module) {
        "use strict";
        var global = this || self, GLOBAL = global, __decorate = exports && exports.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, __param = exports && exports.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(exports, "__esModule", {value: !0});
        var TranslateConfig_1 = $__require("12"), TranslateLoader_1 = $__require("f"), core_1 = $__require("d"), Observable_1 = $__require("13");
        $__require("14"), exports.TranslateLogHandler = {
            debug: function () {},
            error: function (a) {return console && console.error && console.error(a)},
            info: function () {}
        };
        var TranslateService = function () {
            function TranslateService(a, b, c) {
                var d = this;
                if (this._loadedLangs = {}, this._translations = {}, this._config = a, this._loader = b, this.logHandler = c, this._lang = a.defaultLang, a.detectLanguageOnStart) {
                    var e = this.detectLang(a.navigatorLanguages);
                    e && (this._lang = String(e), c.info("Language " + e + " got detected"))
                }
                this.languageChanged = new Observable_1.Observable(function (a) {return d._languageChangedObserver = a}).share()
            }

            return Object.defineProperty(TranslateService.prototype, "lang", {
                get: function () {return this._lang},
                set: function (a) {
                    var b = this._config.langProvided(a, !0);
                    if ("string" == typeof b)return this._lang = b, this.logHandler.info("Language changed to " + b), void(this._languageChangedObserver && this._languageChangedObserver.next(this._lang));
                    throw new Error("Language not provided")
                },
                enumerable: !0,
                configurable: !0
            }), TranslateService.prototype.detectLang = function (a) {
                var b, c = !1;
                for (b = 0; b < a.length && !(c = this._config.langProvided(a[b], !0)); b++);
                if (!c)for (b = 0; b < a.length && !(c = this._config.langProvided(a[b])); b++);
                return c
            }, TranslateService.prototype.waitForTranslation = function (a) {
                void 0 === a && (a = this._lang);
                var b = this._config.langProvided(a, !0);
                return b ? (a = String(b), this._loadLang(a)) : Promise.reject("Language not provided")
            }, TranslateService.prototype.translate = function (a, b, c) {
                var d = this;
                return void 0 === b && (b = {}), void 0 === c && (c = this._lang), new Promise(function (e) {
                    if (c !== d._lang) {
                        var f = d._config.langProvided(c, !0);
                        if (!f)return void e(a);
                        c = String(f)
                    }
                    d._loadLang(c).then(function () {e(d.instant(a, b, c))}, function () {e(a)})
                })
            }, TranslateService.prototype.instant = function (a, b, c) {
                var d = this;
                if (void 0 === b && (b = {}), void 0 === c && (c = this._lang), "string" == typeof a)return this.instant([a], b, c)[0];
                if (c !== this._lang) {
                    var e = this._config.langProvided(c, !0);
                    e && (c = String(e))
                }
                for (var f, g = [], h = a.length; h--;)this._translations[c] && this._translations[c][a[h]] ? (f = this._translations[c][a[h]], f = f.replace(/\[\[([\sA-Za-z0-9_.,=:-]*)]]/g, function (a, e) {return d._translateReferenced(a, e, b, c)}), f = f.replace(/{{\s*(.*?)\s*}}/g, function (a, c) {try {return d._parse(c, b) || ""} catch (b) {return b && b.message && b.message.indexOf("is not defined") === -1 && d.logHandler.error("Parsing error for expression '" + a + "'"), ""}}), g.unshift(f)) : (this.logHandler.info("Translation for '" + a[h] + "' in language " + c + " not found"), g.unshift(a[h]));
                return g
            }, TranslateService.prototype._loadLang = function (a) {
                var b = this;
                return this._loadedLangs[a] || (this._loadedLangs[a] = new Promise(function (c, d) {b._loader.load(a).then(function (d) {b._translations[a] = d, b.logHandler.info("Language " + a + " got loaded"), c()}, function (c) {b.logHandler.error("Language " + a + " could not be loaded (" + c + ")"), d(c)})})), this._loadedLangs[a]
            }, TranslateService.prototype._parse = function (expression, __context) {
                var func = [], varName;
                if (func.push("(function() {"), Array.isArray(__context)) this.logHandler.error("Parameters can not be an array."); else for (varName in __context)__context.hasOwnProperty(varName) && ("__context" !== varName && varName.match(/[a-zA-Z_][a-zA-Z0-9_]*/) ? func.push("try { var " + varName + " = __context['" + varName + "']; } catch(e) {}") : this.logHandler.error("Parameter '" + varName + "' is not allowed."));
                return func.push("return (" + expression + "); })()"), eval(func.join("\n"))
            }, TranslateService.prototype._referencedError = function (a, b, c, d) {
                var e = "Parse error unexpected " + b;
                return void 0 !== d && (e += " at pos " + (d + 3)), c && (e += " expected " + c), this.logHandler.error(e + " in '" + a + "'"), ""
            }, TranslateService.prototype._getParam = function (a, b) {
                var c = b.indexOf(".");
                if (c === -1)return a.hasOwnProperty(b) ? a[b] : void 0;
                var d = b.substr(0, c);
                return a.hasOwnProperty(d) && "object" == typeof a[d] ? this._getParam(a[d], b.substr(c + 1)) : void 0
            }, TranslateService.prototype._translateReferenced = function (a, b, c, d) {
                var e, f, g, h, i = this, j = "wait_key", k = {}, l = function (b) {void 0 === b && (b = !0), b && !g ? "object" != typeof i._getParam(c, h) ? i.logHandler.error("Only objects can be passed as params in '" + a + "'") : k = i._getParam(c, h) : k[g] = b ? i._getParam(c, h) : i._getParam(c, g)};
                for (e = 0; e < b.length; e++)switch (j) {
                    case"wait_key":
                        if (b[e].match(/\s/)); else {
                            if (!b[e].match(/[A-Za-z0-9_.-]/))return this._referencedError(a, "character", "key", e);
                            j = "read_key", f = b[e]
                        }
                        break;
                    case"read_key":
                        if (b[e].match(/[A-Za-z0-9_.-]/)) f += b[e]; else if (":" === b[e]) j = "wait_param"; else {
                            if (!b[e].match(/\s/))return this._referencedError(a, "character", "colon or end", e);
                            j = "key_readed"
                        }
                        break;
                    case"key_readed":
                        if (b[e].match(/\s/)); else {
                            if (":" !== b[e])return this._referencedError(a, "character", "colon or end", e);
                            j = "wait_param"
                        }
                        break;
                    case"wait_param":
                        if (b[e].match(/\s/)); else if (b[e].match(/[A-Za-z0-9_]/)) j = "read_param_key", g = b[e]; else {
                            if ("=" !== b[e])return this._referencedError(a, "character", "parameter", e);
                            if (Object.keys(k).length > 0)return this.logHandler.error("Parse error only first parameter can be passed as params in '" + a + "'"), "";
                            j = "wait_getter"
                        }
                        break;
                    case"read_param_key":
                        if (b[e].match(/[A-Za-z0-9_]/)) g += b[e]; else if ("=" === b[e]) j = "wait_getter"; else if ("," === b[e]) l(!1), j = "wait_param"; else {
                            if (!b[e].match(/\s/))return this._referencedError(a, "character", "comma, equal sign or end", e);
                            j = "param_key_readed"
                        }
                        break;
                    case"param_key_readed":
                        if (b[e].match(/\s/)); else if ("=" === b[e]) j = "wait_getter"; else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma, equal sign or end", e);
                            l(!1), j = "wait_param"
                        }
                        break;
                    case"wait_getter":
                        if (b[e].match(/\s/)); else {
                            if (!b[e].match(/[A-Za-z0-9_]/))return this._referencedError(a, "character", "getter", e);
                            j = "read_getter", h = b[e]
                        }
                        break;
                    case"read_getter":
                        if (b[e].match(/[A-Za-z0-9_.]/)) h += b[e]; else if (b[e].match(/\s/)) j = "getter_readed"; else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma or end", e);
                            l(), j = "wait_param"
                        }
                        break;
                    case"getter_readed":
                        if (b[e].match(/\s/)); else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma or end", e);
                            l(), j = "wait_param"
                        }
                }
                switch (j) {
                    case"param_key_readed":
                    case"read_param_key":
                        l(!1);
                        break;
                    case"getter_readed":
                    case"read_getter":
                        l();
                        break;
                    case"wait_key":
                        return this._referencedError(a, "end", "key");
                    case"wait_param":
                        return this._referencedError(a, "end", "parameter");
                    case"wait_getter":
                        return this._referencedError(a, "end", "getter")
                }
                return String(this.instant(f, k, d))
            }, TranslateService
        }();
        TranslateService = __decorate([core_1.Injectable(), __param(0, core_1.Inject(TranslateConfig_1.TranslateConfig)), __param(1, core_1.Inject(TranslateLoader_1.TranslateLoader)), __param(2, core_1.Inject(exports.TranslateLogHandler))], TranslateService), exports.TranslateService = TranslateService
    }), $__System.registerDynamic("a", ["b", "12", "f", "e", "11", "c", "d", "10"], !0, function (a, b, c) {
        "use strict";
        function d(a) {for (var c in a)b.hasOwnProperty(c) || (b[c] = a[c])}

        var e = (this || self, b && b.__decorate || function (a, b, c, d) {
            var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
            return f > 3 && g && Object.defineProperty(b, c, g), g
        });
        Object.defineProperty(b, "__esModule", {value: !0});
        var f = a("b"), g = a("12"), h = a("f"), i = a("e"), j = a("11"), k = a("c"), l = a("d"), m = a("10");
        d(a("c")), d(a("11")), d(a("b")), d(a("12")), d(a("f")), d(a("e"));
        var n = function () {
            function a() {}

            return a
        }();
        n = e([l.NgModule({
            declarations: [j.TranslatePipe, f.TranslateComponent],
            exports: [j.TranslatePipe, f.TranslateComponent],
            imports: [m.HttpModule],
            providers: [{
                provide: g.TranslateConfig,
                useValue: new g.TranslateConfig({})
            }, {
                provide: i.TranslateLoaderJsonConfig,
                useValue: new i.TranslateLoaderJsonConfig
            }, {provide: h.TranslateLoader, useClass: i.TranslateLoaderJson}, {
                provide: k.TranslateLogHandler,
                useValue: k.TranslateLogHandler
            }, k.TranslateService]
        })], n), b.TranslatorModule = n, b.TRANSLATE_PROVIDERS = [{
            provide: g.TranslateConfig,
            useValue: new g.TranslateConfig({})
        }, {
            provide: i.TranslateLoaderJsonConfig,
            useValue: new i.TranslateLoaderJsonConfig
        }, {provide: h.TranslateLoader, useClass: i.TranslateLoaderJson}, {
            provide: k.TranslateLogHandler,
            useValue: k.TranslateLogHandler
        }, k.TranslateService]
    })
})(function (a) {
    if ("function" == typeof define && define.amd) define(["@angular/core", "@angular/http", "rxjs/Observable", "rxjs/add/operator/share"], a); else {
        if ("object" != typeof module || !module.exports || "function" != typeof require)throw new Error("Module must be loaded as AMD or CommonJS");
        module.exports = a(require("@angular/core"), require("@angular/http"), require("rxjs/Observable"), require("rxjs/add/operator/share"))
    }
});
//# sourceMappingURL=angular2-translator.js.map
export * from "./angular2-translator/TranslateService";
export * from "./angular2-translator/TranslatePipe";
export * from "./angular2-translator/TranslateComponent";
export * from "./angular2-translator/TranslateConfig";
export * from "./angular2-translator/TranslateLoader";
export * from "./angular2-translator/TranslateLoaderJson";
export declare class TranslatorModule {
}
export declare const TRANSLATE_PROVIDERS: any[];
import {TranslateConfig} from "./TranslateConfig";
import {TranslateLoader} from "./TranslateLoader";

import {Inject, Injectable} from "@angular/core";
import {Observable}         from "rxjs/Observable";
import {Observer}           from "rxjs/Observer";

import "rxjs/add/operator/share";

export interface ITranslateLogHandler {
    error(message: string): void;
    info(message: string): void;
    debug(message: string): void;
}

export const TranslateLogHandler = <ITranslateLogHandler> {
    debug: () => {},
    error: (message) => console && console.error && console.error(message),
    info: () => {},
};

@Injectable()
export class TranslateService {
    public languageChanged: Observable<string>;
    public logHandler: ITranslateLogHandler;

    private _config: TranslateConfig;
    private _loader: TranslateLoader;

    private _lang: string;
    private _loadedLangs: Object = {};
    private _translations: Object = {};
    private _languageChangedObserver: Observer<string>;

    constructor(@Inject(TranslateConfig) config: TranslateConfig,
                @Inject(TranslateLoader) loader: TranslateLoader,
                @Inject(TranslateLogHandler) logHandler: ITranslateLogHandler) {
        this._config = config;
        this._loader = loader;
        this.logHandler = logHandler;

        this._lang = config.defaultLang;

        if (config.detectLanguageOnStart) {
            let lang = this.detectLang(config.navigatorLanguages);
            if (lang) {
                this._lang = String(lang);
                logHandler.info("Language " + lang + " got detected");
            }
        }

        this.languageChanged = new Observable<string>(
            (observer: any) => this._languageChangedObserver = observer
        ).share();
    }

    get lang(): string {
        return this._lang;
    }

    set lang(lang: string) {
        let providedLang = this._config.langProvided(lang, true);

        if (typeof providedLang === "string") {
            this._lang = providedLang;
            this.logHandler.info("Language changed to " + providedLang);
            if (this._languageChangedObserver) {
                this._languageChangedObserver.next(this._lang);
            }

            return;
        }

        throw new Error("Language not provided");
    }

    /**
     * Detects the preferred language by navLangs.
     *
     * Returns false if the user prefers a language that is not provided or
     * the provided language.
     *
     * @param {string[]} navLangs (usually navigator.languages)
     * @returns {string|boolean}
     */
    public detectLang(navLangs: string[]): string|boolean {
        let detected: string|boolean = false;
        let i: number;

        for (i = 0; i < navLangs.length; i++) {
            detected = this._config.langProvided(navLangs[i], true);
            if (detected) {
                break;
            }
        }
        if (!detected) {
            for (i = 0; i < navLangs.length; i++) {
                detected = this._config.langProvided(navLangs[i]);
                if (detected) {
                    break;
                }
            }
        }

        return detected;
    }

    /**
     * Waits for the current language to be loaded.
     *
     * @param {string?} lang
     * @returns {Promise<void>|Promise}
     */
    public waitForTranslation(lang: string = this._lang): Promise<void> {
        let l = this._config.langProvided(lang, true);
        if (!l) {
            return Promise.reject("Language not provided");
        } else {
            lang = String(l);
        }
        return this._loadLang(lang);
    }

    /**
     * Translate keys for current language or given language (lang) asynchronously.
     *
     * Optionally you can pass params for translation to be interpolated.
     *
     * @param {string|string[]} keys
     * @param {any?} params
     * @param {string?} lang
     * @returns {Promise<string|string[]>|Promise}
     */
    public translate(keys: string|string[], params: any = {}, lang: string = this._lang): Promise<string|string[]> {
        return new Promise<string|string[]>((resolve) => {
            if (lang !== this._lang) {
                let l = this._config.langProvided(lang, true);
                if (!l) {
                    resolve(keys);
                    return;
                } else {
                    lang = String(l);
                }
            }

            this._loadLang(lang).then(() => {
                resolve(this.instant(keys, params, lang));
            }, () => {
                resolve(keys);
            });
        });
    }

    /**
     * Translate keys for current language or given language (lang) synchronously.
     *
     * Optionally you can pass params for translation to be interpolated.
     *
     * @param {string|string[]} keys
     * @param {any?} params
     * @param {string?} lang
     * @returns {string|string[]}
     */
    public instant(keys: string|string[], params: any = {}, lang: string = this._lang): string|string[] {
        if (typeof keys === "string") {
            return this.instant([keys], params, lang)[0];
        }

        if (lang !== this._lang) {
            let l = this._config.langProvided(lang, true);
            if (l) {
                lang = String(l);
            }
        }

        let result: string[] = [];
        let i = keys.length;
        let t: string;
        while (i--) {
            if (!this._translations[lang] || !this._translations[lang][keys[i]]) {
                this.logHandler.info("Translation for '" + keys[i] + "' in language " + lang + " not found");
                result.unshift(keys[i]);
                continue;
            }
            t = this._translations[lang][keys[i]];

            t = t.replace(/\[\[([\sA-Za-z0-9_.,=:-]*)]]/g, (sub: string, expression: string) => {
                return this._translateReferenced(sub, expression, params, lang);
            });

            // simple interpolation
            t = t.replace(/{{\s*(.*?)\s*}}/g, (sub: string, expression: string) => {
                try {
                    return this._parse(expression, params) || "";
                } catch (e) {
                    if (e && e.message && e.message.indexOf("is not defined") === -1) {
                        this.logHandler.error("Parsing error for expression '" + sub + "'");
                    }
                    return "";
                }
            });

            result.unshift(t);
        }

        return result;
    }

    /**
     * Load a language.
     *
     * @param {string} lang
     * @returns {Promise<void>|Promise}
     * @private
     */
    private _loadLang(lang: string): Promise<void> {
        if (!this._loadedLangs[lang]) {
            this._loadedLangs[lang] = new Promise<void>((resolve, reject) => {
                this._loader.load(lang).then((translations) => {
                    this._translations[lang] = translations;
                    this.logHandler.info("Language " + lang + " got loaded");
                    resolve();
                }, (reason) => {
                    this.logHandler.error("Language " + lang + " could not be loaded (" + reason + ")");
                    reject(reason);
                });
            });
        }
        return this._loadedLangs[lang];
    }

    /**
     * Parses the expression in the given __context.
     *
     * @param   {string} expression
     * @param   {object} __context
     * @returns {string}
     * @private
     */
    private _parse(expression: string, __context: any): string {
        let func: string[] = [];
        let varName: string;
        func.push("(function() {");
        if (Array.isArray(__context)) {
            this.logHandler.error("Parameters can not be an array.");
        } else {
            for (varName in __context) {
                if (!__context.hasOwnProperty(varName)) {
                    continue;
                }
                if (varName === "__context" || !varName.match(/[a-zA-Z_][a-zA-Z0-9_]*/)) {
                    this.logHandler.error("Parameter '" + varName + "' is not allowed.");
                    continue;
                }
                func.push("try { var " + varName + " = __context['" + varName + "']; } catch(e) {}");
            }
        }
        func.push("return (" + expression + "); })()");
        return eval(func.join("\n"));
    }

    /**
     * Outputs a parse error for an error in translation references.
     *
     * @param   {string} sub
     * @param   {string} unexpected
     * @param   {string} expected
     * @param   {number} pos
     * @returns {string}
     * @private
     */
    private _referencedError(sub: string, unexpected: string, expected?: string, pos?: number): string {
        let msg = "Parse error unexpected " + unexpected;

        if (pos !== undefined) {
            msg += " at pos " + (pos + 3);
        }

        if (expected) {
            msg += " expected " + expected;
        }

        this.logHandler.error(msg + " in '" + sub + "'");
        return "";
    }

    /**
     * Gets a parameter from params defined by getter recursive.
     *
     * @param   {object} params
     * @param   {string} getter
     * @returns {any}
     * @private
     */
    private _getParam(params: Object, getter: string): any {
        let pos = getter.indexOf(".");

        if (pos === -1) {
            return params.hasOwnProperty(getter) ? params[getter] : undefined;
        } else {
            let key = getter.substr(0, pos);
            return params.hasOwnProperty(key) && typeof params[key] === "object" ?
                this._getParam(params[key], getter.substr(pos + 1)) : undefined;
        }
    }

    /**
     * Translates a reference expression like '<key> [: <param> [= <getter> [, <param..n> [= <getter..n>]]]]'
     *
     * @param   {string} sub
     * @param   {string} expression
     * @param   {Object} params
     * @param   {string} lang
     * @returns {string}
     * @private
     */
    private _translateReferenced(sub: string, expression: string, params: Object, lang: string): string {
        let j: number;
        let state = "wait_key";
        let key: string;
        let translateParams = {};
        let paramKey: string;
        let getter: string;

        let transferParam = (useGetter = true) => {
            if (useGetter && !paramKey) {
                if (typeof this._getParam(params, getter) !== "object") {
                    this.logHandler.error("Only objects can be passed as params in '" + sub + "'");
                } else {
                    translateParams = this._getParam(params, getter);
                }
            } else {
                if (!useGetter) {
                    translateParams[paramKey] = this._getParam(params, paramKey);
                } else {
                    translateParams[paramKey] = this._getParam(params, getter);
                }
            }
        };

        for (j = 0; j < expression.length; j++) {
            switch (state) {
                case "wait_key":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j].match(/[A-Za-z0-9_.-]/)) {
                        state = "read_key";
                        key = expression[j];
                    } else {
                        return this._referencedError(sub, "character", "key", j);
                    }
                    break;

                case "read_key":
                    if (expression[j].match(/[A-Za-z0-9_.-]/)) {
                        key += expression[j];
                    } else if (expression[j] === ":") {
                        state = "wait_param";
                    } else if (expression[j].match(/\s/)) {
                        state = "key_readed";
                    } else {
                        return this._referencedError(sub, "character", "colon or end", j);
                    }
                    break;

                case "key_readed":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j] === ":") {
                        state = "wait_param";
                    } else {
                        return this._referencedError(sub, "character", "colon or end", j);
                    }
                    break;

                case "wait_param":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j].match(/[A-Za-z0-9_]/)) {
                        state    = "read_param_key";
                        paramKey = expression[j];
                    } else if (expression[j] === "=") {
                        if (Object.keys(translateParams).length > 0) {
                            this.logHandler.error(
                                "Parse error only first parameter can be passed as params in " + "'" + sub + "'"
                            );
                            return "";
                        }
                        state = "wait_getter";
                    } else {
                        return this._referencedError(sub, "character", "parameter", j);
                    }
                    break;

                case "read_param_key":
                    if (expression[j].match(/[A-Za-z0-9_]/)) {
                        paramKey += expression[j];
                    } else if (expression[j] === "=") {
                        state = "wait_getter";
                    } else if (expression[j] === ",") {
                        transferParam(false);
                        state = "wait_param";
                    } else if (expression[j].match(/\s/)) {
                        state = "param_key_readed";
                    } else {
                        return this._referencedError(sub, "character", "comma, equal sign or end", j);
                    }
                    break;

                case "param_key_readed":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j] === "=") {
                        state = "wait_getter";
                    } else if (expression[j] === ",") {
                        transferParam(false);
                        state = "wait_param";
                    } else {
                        return this._referencedError(sub, "character", "comma, equal sign or end", j);
                    }
                    break;

                case "wait_getter":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j].match(/[A-Za-z0-9_]/)) {
                        state = "read_getter";
                        getter = expression[j];
                    } else {
                        return this._referencedError(sub, "character", "getter", j);
                    }
                    break;

                case "read_getter":
                    if (expression[j].match(/[A-Za-z0-9_.]/)) {
                        getter += expression[j];
                    } else if (expression[j].match(/\s/)) {
                        state = "getter_readed";
                    } else if (expression[j] === ",") {
                        transferParam();
                        state = "wait_param";
                    } else {
                        return this._referencedError(sub, "character", "comma or end", j);
                    }
                    break;

                case "getter_readed":
                    if (expression[j].match(/\s/)) {
                        // nothing to do here
                    } else if (expression[j] === ",") {
                        transferParam();
                        state = "wait_param";
                    } else {
                        return this._referencedError(sub, "character", "comma or end", j);
                    }
                    break;
            }
        }

        switch (state) {
            case "param_key_readed":
            case "read_param_key":
                transferParam(false);
                break;

            case "getter_readed":
            case "read_getter":
                transferParam();
                break;

            case "wait_key":
                return this._referencedError(sub, "end", "key");
            case "wait_param":
                return this._referencedError(sub, "end", "parameter");
            case "wait_getter":
                return this._referencedError(sub, "end", "getter");
        }

        return String(this.instant(key, translateParams, lang));
    }
}
import {TranslateService}         from "./TranslateService";

import {Component, Inject, Input} from "@angular/core";

@Component({
    selector: "[translate]",
    template: "{{translation}}",
})
export class TranslateComponent {
    public translation: string = "";

    private _translate: TranslateService;
    private _key: string;
    private _params: any = {};

    constructor(@Inject(TranslateService) translate: TranslateService) {
        this._translate = translate;

        translate.languageChanged.subscribe(() => {
            this._startTranslation();
        });
    }

    @Input("translate") set key(key: string) {
        this._key = key;
        this._startTranslation();
    }

    @Input("translateParams") set params(params: any) {
        if (typeof params !== "object") {
            this._translate.logHandler.error("Params have to be an object");
            return;
        }

        this._params = params;
        this._startTranslation();
    }

    private _startTranslation() {
        if (!this._key) {
            return;
        }
        this._translate.translate(this._key, this._params).then(
            (translation) => this.translation = String(translation)
        );
    }
}
export class TranslateConfig {
    public static navigator: any = window && window.navigator ? window.navigator : {};

    public defaultLang: string;
    public providedLangs: string[];
    public detectLanguageOnStart: boolean;
    public navigatorLanguages: string[];

    constructor({
        defaultLang = "en",
        providedLangs = ["en"],
        detectLanguageOnStart = true,
        }: {
        defaultLang?: string,
        providedLangs?: string[]
        detectLanguageOnStart?: boolean
    }) {
        this.defaultLang   = providedLangs.indexOf(defaultLang) > -1 ? defaultLang : providedLangs[0];
        this.providedLangs = providedLangs;
        this.detectLanguageOnStart = detectLanguageOnStart;
        this.navigatorLanguages = ((): string[] => {
            let navigator: any = TranslateConfig.navigator;

            if (navigator.languages instanceof Array) {
                return Array.prototype.slice.call(navigator.languages);
            } else if (typeof navigator.languages === "string") {
                return [String(navigator.languages)];
            } else if (typeof navigator.language === "string") {
                return [navigator.language];
            } else {
                return [];
            }
        })();
    }

    /**
     * Checks if given language "lang" is provided and returns the language.
     *
     * The checks running on normalized strings matching this pattern: /[a-z]{2}(-[A-Z]{2})?/
     * Transformation is done with this pattern: /^([A-Za-z]{2})([\.\-_\/]?([A-Za-z]{2}))?/
     *
     * If strict is false it checks country independent.
     *
     * @param {string} lang
     * @param {boolean?} strict
     * @returns {string|boolean}
     */
    public langProvided(lang: string, strict: boolean = false): string|boolean {
        let provided: string|boolean = false;
        let p: number;

        let normalizeLang = function (languageString: string) {
            let regExp = /^([A-Za-z]{2})(?:[\.\-_\/]?([A-Za-z]{2}))?$/;
            if (!languageString.match(regExp)) {
                return "";
            }
            return languageString.replace(
                regExp,
                function (substring: string, language: string, country: string = "") {
                    language    = language.toLowerCase();
                    country     = country.toUpperCase();
                    return country ? language + "-" + country : language;
                }
            );
        };

        let providedLangsNormalized = this.providedLangs.map(normalizeLang);
        lang = normalizeLang(lang);

        if (lang.length === 0) {
            return provided;
        }

        p = providedLangsNormalized.indexOf(lang);
        if (p > -1) {
            provided = this.providedLangs[p];
        } else if (!strict) {
            lang = lang.substr(0, 2);
            p    = providedLangsNormalized.indexOf(lang);
            if (p > -1) {
                provided = this.providedLangs[p];
            } else {
                p = providedLangsNormalized.map(function (language) {
                    return language.substr(0, 2);
                }).indexOf(lang);
                if (p > -1) {
                    provided = this.providedLangs[p];
                }
            }
        }

        return provided;
    }
}
/**
 * A TranslateLoader has to load every file even if they are divided to partials. If a TranslateLoader resolves
 * the language is marked as loaded. It will not get loaded again.
 */
export interface ITranslateLoader {
    load(lang: string): Promise<Object>;
}

export abstract class TranslateLoader implements ITranslateLoader {
    public abstract load(lang: string): Promise<Object>;
}
import {TranslateLoader}    from "./TranslateLoader";
import {Inject, Injectable} from "@angular/core";
import {Http}               from "@angular/http";

export class TranslateLoaderJsonConfig {
    public path: string = "i18n/";
    public extension: string = ".json";

    // @todo maybe we will change it to a destructed parameter like we did for TranslateConfig
    constructor(path?: string, extension?: string) {
        if (path) {
            this.path = path.replace(/\/+$/, "") + "/";
        }

        if (extension) {
            this.extension = extension;
        }
    }
}

@Injectable()
export class TranslateLoaderJson extends TranslateLoader {
    private _http: Http;
    private _config: TranslateLoaderJsonConfig;

    constructor(@Inject(Http) http: Http, @Inject(TranslateLoaderJsonConfig) config: TranslateLoaderJsonConfig) {
        super();
        this._http = http;
        this._config = config;
    }

    public load(lang: string): Promise<Object> {
        return new Promise((resolve, reject) => {
            let file = this._config.path + lang + this._config.extension;
            this._http.get(file)
                .subscribe(
                    (response) => {
                        if (response.status === 200) {
                            let translations = {};
                            this.flattenTranslations(translations, response.json());
                            resolve(translations);
                        } else {
                            reject("StatusCode: " + response.status + "");
                        }
                    },
                    (reason: Error) => {
                        reject(reason.message);
                    }
                );
        });
    }

    private flattenTranslations(translations: any, data: any, prefix: string = "") {
        for (let key in data) {
            if (Array.isArray(data[key])) {
                translations[prefix + key] = data[key].filter((v: any) => typeof v === "string").join("");
            } else if (typeof data[key] === "object") {
                this.flattenTranslations(translations, data[key], prefix + key + ".");
            } else if (typeof data[key] === "string") {
                translations[prefix + key] = data[key];
            }
        }
    }
}
import {TranslateService}            from "./TranslateService";
import {Inject, Pipe, PipeTransform} from "@angular/core";

@Pipe({
    name: "translate",
    pure: false,
})
export class TranslatePipe implements PipeTransform {
    private static _parseParams(arg: string): Object {
        try {
            let o = eval("(" + arg + ")");
            if (typeof o === "object") {
                return o;
            }
        } catch (e) {}
        return {};
    }

    private _translate: TranslateService;
    private _promise: Promise<string|string[]>;
    private _translation: string = "";
    private _translated: { key: string, params: any };

    constructor(@Inject(TranslateService) translate: TranslateService) {
        this._translate = translate;

        translate.languageChanged.subscribe(() => {
            this._startTranslation();
        });
    }

    /**
     * Translates key with given args.
     *
     * @see TranslateService.translate
     * @param {string} key
     * @param {array?} args
     * @returns {string}
     */
    public transform(key: string, args: any[] = []): string {
        let params: Object = <ObjectConstructor> {};

        if (args[0]) {
            if (typeof args[0] === "string") {
                params = TranslatePipe._parseParams(args[0]);
                if (!Object.keys(params).length) {
                    this._translate.logHandler.error("'" + args[0] + "' could not be parsed to object");
                }
            } else if (typeof args[0] === "object") {
                params = args[0];
            }
        }

        if (this._translated && this._promise &&
            ( this._translated.key !== key ||
              JSON.stringify(this._translated.params) !== JSON.stringify(params)
            )
        ) {
            this._promise = null;
        }

        if (!this._promise) {
            this._translated = {
                key,
                params,
            };
            this._startTranslation();
        }

        return this._translation;
    }

    private _startTranslation() {
        if (!this._translated || !this._translated.key) {
            return;
        }
        this._promise = this._translate.translate(this._translated.key, this._translated.params);
        this._promise.then((translation) => this._translation = String(translation));
    }
}
!function (a) {
    function b(a) {Object.defineProperty(this, a, {enumerable: !0, get: function () {return this[o][a]}})}

    function c(a) {
        var b;
        if (a && a.__esModule) {
            b = {};
            for (var c in a)Object.hasOwnProperty.call(a, c) && (b[c] = a[c]);
            b.__useDefault = !1, b.__esModule = !0
        } else {
            if ("[object Module]" === Object.prototype.toString.call(a) || "undefined" != typeof System && System.isModule && System.isModule(a))return a;
            b = {default: a, __useDefault: !0}
        }
        return new d(b)
    }

    function d(a) {Object.defineProperty(this, o, {value: a}), Object.keys(a).forEach(b, this)}

    function e(a) {return "@node/" === a.substr(0, 6) ? m(a, c(p(a.substr(6))), {}) : n[a]}

    function f(a) {
        var b = e(a);
        if (!b)throw new Error('Module "' + a + '" expected, but not contained in build.');
        if (b.module)return b.module;
        var c = b.linkRecord;
        return g(b, c), l(b, c, []), b.module
    }

    function g(a, b) {
        if (!b.depLoads) {
            b.declare && h(a, b), b.depLoads = [];
            for (var c = 0; c < b.deps.length; c++) {
                var d = e(b.deps[c]);
                b.depLoads.push(d), d.linkRecord && g(d, d.linkRecord);
                var f = b.setters && b.setters[c];
                f && (f(d.module || d.linkRecord.moduleObj), d.importerSetters.push(f))
            }
            return a
        }
    }

    function h(b, c) {
        var d = c.moduleObj, e = b.importerSetters, f = !1, g = c.declare.call(a, function (a, b) {
            if (!f) {
                if ("object" == typeof a)for (var c in a)"__useDefault" !== c && (d[c] = a[c]); else d[a] = b;
                f = !0;
                for (var g = 0; g < e.length; g++)e[g](d);
                return f = !1, b
            }
        }, {id: b.key});
        "function" != typeof g ? (c.setters = g.setters, c.execute = g.execute) : (c.setters = [], c.execute = g)
    }

    function i(a, b, c) {
        return n[a] = {
            key: a,
            module: void 0,
            importerSetters: [],
            linkRecord: {deps: b, depLoads: void 0, declare: c, setters: void 0, execute: void 0, moduleObj: {}}
        }
    }

    function j(a, b, c, d) {
        return n[a] = {
            key: a,
            module: void 0,
            importerSetters: [],
            linkRecord: {
                deps: b,
                depLoads: void 0,
                declare: void 0,
                execute: d,
                executingRequire: c,
                moduleObj: {default: {}, __useDefault: !0},
                setters: void 0
            }
        }
    }

    function k(a, b, c) {
        return function (d) {
            for (var e = 0; e < a.length; e++)if (a[e] === d) {
                var f, g = b[e];
                return f = -1 === c.indexOf(g) || !g.linkRecord ? l(g, g.linkRecord, c) : g.linkRecord.moduleObj, f.__useDefault ? f.default : f
            }
        }
    }

    function l(b, c, e) {
        if (e.push(b), b.module)return b.module;
        if (c.setters) {
            for (var f = 0; f < c.deps.length; f++) {
                var g = c.depLoads[f], h = g.linkRecord;
                h && -1 === e.indexOf(g) && l(g, h, h.setters ? e : [])
            }
            c.execute.call(q)
        } else {
            var i = {id: b.key}, j = c.moduleObj;
            Object.defineProperty(i, "exports", {
                configurable: !0,
                set: function (a) {j.default = a},
                get: function () {return j.default}
            });
            var m = k(c.deps, c.depLoads, e);
            if (!c.executingRequire)for (var f = 0; f < c.deps.length; f++)m(c.deps[f]);
            var n = c.execute.call(a, m, j.default, i);
            if (void 0 !== n ? j.default = n : i.exports !== j.default && (j.default = i.exports), j.default && j.default.__esModule)for (var o in j.default)Object.hasOwnProperty.call(j.default, o) && "default" !== o && (j[o] = j.default[o])
        }
        var i = b.module = new d(c.moduleObj);
        if (!c.setters)for (var f = 0; f < b.importerSetters.length; f++)b.importerSetters[f](i);
        return i
    }

    function m(a, b) {return n[a] = {key: a, module: b, importerSetters: [], linkRecord: void 0}}

    var n = {}, o = "undefined" != typeof Symbol ? Symbol() : "@@baseObject";
    d.prototype = Object.create(null), "undefined" != typeof Symbol && Symbol.toStringTag && (d.prototype[Symbol.toStringTag] = "Module");
    var p = "undefined" != typeof System && System._nodeRequire || "undefined" != typeof require && void 0 !== require.resolve && "undefined" != typeof process && process.platform && require, q = {};
    return Object.freeze && Object.freeze(q), function (a, b, e, g) {
        return function (h) {
            h(function (h) {
                var k = {
                    _nodeRequire: p,
                    register: i,
                    registerDynamic: j,
                    registry: {get: function (a) {return n[a].module}, set: m},
                    newModule: function (a) {return new d(a)}
                };
                m("@empty", new d({}));
                for (var l = 0; l < b.length; l++)m(b[l], c(arguments[l], {}));
                g(k);
                var o = f(a[0]);
                if (a.length > 1)for (var l = 1; l < a.length; l++)f(a[l]);
                return e ? o.default : (o instanceof d && Object.defineProperty(o, "__esModule", {value: !0}), o)
            })
        }
    }
}("undefined" != typeof self ? self : global)(["a"], ["d", "10", "13", "14"], !0, function ($__System) {
    var require = this.require, exports = this.exports, module = this.module;
    $__System.registerDynamic("b", ["c", "d"], !0, function (a, b, c) {
        "use strict";
        var d = (this || self, b && b.__decorate || function (a, b, c, d) {
            var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
            return f > 3 && g && Object.defineProperty(b, c, g), g
        }), e = b && b.__metadata || function (a, b) {if ("object" == typeof Reflect && "function" == typeof Reflect.metadata)return Reflect.metadata(a, b)}, f = b && b.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(b, "__esModule", {value: !0});
        var g = a("c"), h = a("d"), i = function () {
            function a(a) {
                var b = this;
                this.translation = "", this._params = {}, this._translate = a, a.languageChanged.subscribe(function () {b._startTranslation()})
            }

            return Object.defineProperty(a.prototype, "key", {
                set: function (a) {this._key = a, this._startTranslation()},
                enumerable: !0,
                configurable: !0
            }), Object.defineProperty(a.prototype, "params", {
                set: function (a) {
                    if ("object" != typeof a)return void this._translate.logHandler.error("Params have to be an object");
                    this._params = a, this._startTranslation()
                }, enumerable: !0, configurable: !0
            }), a.prototype._startTranslation = function () {
                var a = this;
                this._key && this._translate.translate(this._key, this._params).then(function (b) {return a.translation = String(b)})
            }, a
        }();
        d([h.Input("translate"), e("design:type", String), e("design:paramtypes", [String])], i.prototype, "key", null), d([h.Input("translateParams"), e("design:type", Object), e("design:paramtypes", [Object])], i.prototype, "params", null), i = d([h.Component({
            selector: "[translate]",
            template: "{{translation}}"
        }), f(0, h.Inject(g.TranslateService)), e("design:paramtypes", [g.TranslateService])], i), b.TranslateComponent = i
    }), $__System.registerDynamic("e", ["f", "d", "10"], !0, function (a, b, c) {
        "use strict";
        var d = (this || self, b && b.__extends || function () {
            var a = Object.setPrototypeOf || {__proto__: []} instanceof Array && function (a, b) {a.__proto__ = b} || function (a, b) {for (var c in b)b.hasOwnProperty(c) && (a[c] = b[c])};
            return function (b, c) {
                function d() {this.constructor = b}

                a(b, c), b.prototype = null === c ? Object.create(c) : (d.prototype = c.prototype, new d)
            }
        }()), e = b && b.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, f = b && b.__metadata || function (a, b) {if ("object" == typeof Reflect && "function" == typeof Reflect.metadata)return Reflect.metadata(a, b)}, g = b && b.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(b, "__esModule", {value: !0});
        var h = a("f"), i = a("d"), j = a("10"), k = function () {
            function a(a, b) {this.path = "i18n/", this.extension = ".json", a && (this.path = a.replace(/\/+$/, "") + "/"), b && (this.extension = b)}

            return a
        }();
        b.TranslateLoaderJsonConfig = k;
        var l = function (a) {
            function b(b, c) {
                var d = a.call(this) || this;
                return d._http = b, d._config = c, d
            }

            return d(b, a), b.prototype.load = function (a) {
                var b = this;
                return new Promise(function (c, d) {
                    var e = b._config.path + a + b._config.extension;
                    b._http.get(e).subscribe(function (a) {
                        if (200 === a.status) {
                            var e = {};
                            b.flattenTranslations(e, a.json()), c(e)
                        } else d("StatusCode: " + a.status)
                    }, function (a) {d(a.message)})
                })
            }, b.prototype.flattenTranslations = function (a, b, c) {
                void 0 === c && (c = "");
                for (var d in b)Array.isArray(b[d]) ? a[c + d] = b[d].filter(function (a) {return "string" == typeof a}).join("") : "object" == typeof b[d] ? this.flattenTranslations(a, b[d], c + d + ".") : "string" == typeof b[d] && (a[c + d] = b[d])
            }, b
        }(h.TranslateLoader);
        l = e([i.Injectable(), g(0, i.Inject(j.Http)), g(1, i.Inject(k)), f("design:paramtypes", [j.Http, k])], l), b.TranslateLoaderJson = l
    }), $__System.registerDynamic("11", ["c", "d"], !0, function ($__require, exports, module) {
        "use strict";
        var global = this || self, GLOBAL = global, __decorate = exports && exports.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, __metadata = exports && exports.__metadata || function (a, b) {if ("object" == typeof Reflect && "function" == typeof Reflect.metadata)return Reflect.metadata(a, b)}, __param = exports && exports.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(exports, "__esModule", {value: !0});
        var TranslateService_1 = $__require("c"), core_1 = $__require("d"), TranslatePipe = TranslatePipe_1 = function () {
            function TranslatePipe(a) {
                var b = this;
                this._translation = "", this._translate = a, a.languageChanged.subscribe(function () {b._startTranslation()})
            }

            return TranslatePipe._parseParams = function (arg) {
                try {
                    var o = eval("(" + arg + ")");
                    if ("object" == typeof o)return o
                } catch (a) {}
                return {}
            }, TranslatePipe.prototype.transform = function (a, b) {
                void 0 === b && (b = []);
                var c = {};
                return b[0] && ("string" == typeof b[0] ? (c = TranslatePipe_1._parseParams(b[0]), Object.keys(c).length || this._translate.logHandler.error("'" + b[0] + "' could not be parsed to object")) : "object" == typeof b[0] && (c = b[0])), this._translated && this._promise && (this._translated.key !== a || JSON.stringify(this._translated.params) !== JSON.stringify(c)) && (this._promise = null), this._promise || (this._translated = {
                    key: a,
                    params: c
                }, this._startTranslation()), this._translation
            }, TranslatePipe.prototype._startTranslation = function () {
                var a = this;
                this._translated && this._translated.key && (this._promise = this._translate.translate(this._translated.key, this._translated.params), this._promise.then(function (b) {return a._translation = String(b)}))
            }, TranslatePipe
        }();
        TranslatePipe = TranslatePipe_1 = __decorate([core_1.Pipe({
            name: "translate",
            pure: !1
        }), __param(0, core_1.Inject(TranslateService_1.TranslateService)), __metadata("design:paramtypes", [TranslateService_1.TranslateService])], TranslatePipe), exports.TranslatePipe = TranslatePipe;
        var TranslatePipe_1
    }), $__System.registerDynamic("12", [], !0, function (a, b, c) {
        "use strict";
        this || self;
        Object.defineProperty(b, "__esModule", {value: !0});
        var d = function () {
            function a(b) {
                var c = b.defaultLang, d = void 0 === c ? "en" : c, e = b.providedLangs, f = void 0 === e ? ["en"] : e, g = b.detectLanguageOnStart, h = void 0 === g || g;
                this.defaultLang = f.indexOf(d) > -1 ? d : f[0], this.providedLangs = f, this.detectLanguageOnStart = h, this.navigatorLanguages = function () {
                    var b = a.navigator;
                    return b.languages instanceof Array ? Array.prototype.slice.call(b.languages) : "string" == typeof b.languages ? [String(b.languages)] : "string" == typeof b.language ? [b.language] : []
                }()
            }

            return a.prototype.langProvided = function (a, b) {
                void 0 === b && (b = !1);
                var c, d = !1, e = function (a) {
                    var b = /^([A-Za-z]{2})(?:[\.\-_\/]?([A-Za-z]{2}))?$/;
                    return a.match(b) ? a.replace(b, function (a, b, c) {return void 0 === c && (c = ""), b = b.toLowerCase(), c = c.toUpperCase(), c ? b + "-" + c : b}) : ""
                }, f = this.providedLangs.map(e);
                return a = e(a), 0 === a.length ? d : (c = f.indexOf(a), c > -1 ? d = this.providedLangs[c] : b || (a = a.substr(0, 2), c = f.indexOf(a), c > -1 ? d = this.providedLangs[c] : (c = f.map(function (a) {return a.substr(0, 2)}).indexOf(a), c > -1 && (d = this.providedLangs[c]))), d)
            }, a
        }();
        d.navigator = window && window.navigator ? window.navigator : {}, b.TranslateConfig = d
    }), $__System.registerDynamic("f", [], !0, function (a, b, c) {
        "use strict";
        this || self;
        Object.defineProperty(b, "__esModule", {value: !0});
        var d = function () {
            function a() {}

            return a
        }();
        b.TranslateLoader = d
    }), $__System.registerDynamic("c", ["12", "f", "d", "13", "14"], !0, function ($__require, exports, module) {
        "use strict";
        var global = this || self, GLOBAL = global, __decorate = exports && exports.__decorate || function (a, b, c, d) {
                var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
                if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
                return f > 3 && g && Object.defineProperty(b, c, g), g
            }, __metadata = exports && exports.__metadata || function (a, b) {if ("object" == typeof Reflect && "function" == typeof Reflect.metadata)return Reflect.metadata(a, b)}, __param = exports && exports.__param || function (a, b) {return function (c, d) {b(c, d, a)}};
        Object.defineProperty(exports, "__esModule", {value: !0});
        var TranslateConfig_1 = $__require("12"), TranslateLoader_1 = $__require("f"), core_1 = $__require("d"), Observable_1 = $__require("13");
        $__require("14"), exports.TranslateLogHandler = {
            debug: function () {},
            error: function (a) {return console && console.error && console.error(a)},
            info: function () {}
        };
        var TranslateService = function () {
            function TranslateService(a, b, c) {
                var d = this;
                if (this._loadedLangs = {}, this._translations = {}, this._config = a, this._loader = b, this.logHandler = c, this._lang = a.defaultLang, a.detectLanguageOnStart) {
                    var e = this.detectLang(a.navigatorLanguages);
                    e && (this._lang = String(e), c.info("Language " + e + " got detected"))
                }
                this.languageChanged = new Observable_1.Observable(function (a) {return d._languageChangedObserver = a}).share()
            }

            return Object.defineProperty(TranslateService.prototype, "lang", {
                get: function () {return this._lang},
                set: function (a) {
                    var b = this._config.langProvided(a, !0);
                    if ("string" == typeof b)return this._lang = b, this.logHandler.info("Language changed to " + b), void(this._languageChangedObserver && this._languageChangedObserver.next(this._lang));
                    throw new Error("Language not provided")
                },
                enumerable: !0,
                configurable: !0
            }), TranslateService.prototype.detectLang = function (a) {
                var b, c = !1;
                for (b = 0; b < a.length && !(c = this._config.langProvided(a[b], !0)); b++);
                if (!c)for (b = 0; b < a.length && !(c = this._config.langProvided(a[b])); b++);
                return c
            }, TranslateService.prototype.waitForTranslation = function (a) {
                void 0 === a && (a = this._lang);
                var b = this._config.langProvided(a, !0);
                return b ? (a = String(b), this._loadLang(a)) : Promise.reject("Language not provided")
            }, TranslateService.prototype.translate = function (a, b, c) {
                var d = this;
                return void 0 === b && (b = {}), void 0 === c && (c = this._lang), new Promise(function (e) {
                    if (c !== d._lang) {
                        var f = d._config.langProvided(c, !0);
                        if (!f)return void e(a);
                        c = String(f)
                    }
                    d._loadLang(c).then(function () {e(d.instant(a, b, c))}, function () {e(a)})
                })
            }, TranslateService.prototype.instant = function (a, b, c) {
                var d = this;
                if (void 0 === b && (b = {}), void 0 === c && (c = this._lang), "string" == typeof a)return this.instant([a], b, c)[0];
                if (c !== this._lang) {
                    var e = this._config.langProvided(c, !0);
                    e && (c = String(e))
                }
                for (var f, g = [], h = a.length; h--;)this._translations[c] && this._translations[c][a[h]] ? (f = this._translations[c][a[h]], f = f.replace(/\[\[([\sA-Za-z0-9_.,=:-]*)]]/g, function (a, e) {return d._translateReferenced(a, e, b, c)}), f = f.replace(/{{\s*(.*?)\s*}}/g, function (a, c) {try {return d._parse(c, b) || ""} catch (b) {return b && b.message && b.message.indexOf("is not defined") === -1 && d.logHandler.error("Parsing error for expression '" + a + "'"), ""}}), g.unshift(f)) : (this.logHandler.info("Translation for '" + a[h] + "' in language " + c + " not found"), g.unshift(a[h]));
                return g
            }, TranslateService.prototype._loadLang = function (a) {
                var b = this;
                return this._loadedLangs[a] || (this._loadedLangs[a] = new Promise(function (c, d) {b._loader.load(a).then(function (d) {b._translations[a] = d, b.logHandler.info("Language " + a + " got loaded"), c()}, function (c) {b.logHandler.error("Language " + a + " could not be loaded (" + c + ")"), d(c)})})), this._loadedLangs[a]
            }, TranslateService.prototype._parse = function (expression, __context) {
                var func = [], varName;
                if (func.push("(function() {"), Array.isArray(__context)) this.logHandler.error("Parameters can not be an array."); else for (varName in __context)__context.hasOwnProperty(varName) && ("__context" !== varName && varName.match(/[a-zA-Z_][a-zA-Z0-9_]*/) ? func.push("try { var " + varName + " = __context['" + varName + "']; } catch(e) {}") : this.logHandler.error("Parameter '" + varName + "' is not allowed."));
                return func.push("return (" + expression + "); })()"), eval(func.join("\n"))
            }, TranslateService.prototype._referencedError = function (a, b, c, d) {
                var e = "Parse error unexpected " + b;
                return void 0 !== d && (e += " at pos " + (d + 3)), c && (e += " expected " + c), this.logHandler.error(e + " in '" + a + "'"), ""
            }, TranslateService.prototype._getParam = function (a, b) {
                var c = b.indexOf(".");
                if (c === -1)return a.hasOwnProperty(b) ? a[b] : void 0;
                var d = b.substr(0, c);
                return a.hasOwnProperty(d) && "object" == typeof a[d] ? this._getParam(a[d], b.substr(c + 1)) : void 0
            }, TranslateService.prototype._translateReferenced = function (a, b, c, d) {
                var e, f, g, h, i = this, j = "wait_key", k = {}, l = function (b) {void 0 === b && (b = !0), b && !g ? "object" != typeof i._getParam(c, h) ? i.logHandler.error("Only objects can be passed as params in '" + a + "'") : k = i._getParam(c, h) : k[g] = b ? i._getParam(c, h) : i._getParam(c, g)};
                for (e = 0; e < b.length; e++)switch (j) {
                    case"wait_key":
                        if (b[e].match(/\s/)); else {
                            if (!b[e].match(/[A-Za-z0-9_.-]/))return this._referencedError(a, "character", "key", e);
                            j = "read_key", f = b[e]
                        }
                        break;
                    case"read_key":
                        if (b[e].match(/[A-Za-z0-9_.-]/)) f += b[e]; else if (":" === b[e]) j = "wait_param"; else {
                            if (!b[e].match(/\s/))return this._referencedError(a, "character", "colon or end", e);
                            j = "key_readed"
                        }
                        break;
                    case"key_readed":
                        if (b[e].match(/\s/)); else {
                            if (":" !== b[e])return this._referencedError(a, "character", "colon or end", e);
                            j = "wait_param"
                        }
                        break;
                    case"wait_param":
                        if (b[e].match(/\s/)); else if (b[e].match(/[A-Za-z0-9_]/)) j = "read_param_key", g = b[e]; else {
                            if ("=" !== b[e])return this._referencedError(a, "character", "parameter", e);
                            if (Object.keys(k).length > 0)return this.logHandler.error("Parse error only first parameter can be passed as params in '" + a + "'"), "";
                            j = "wait_getter"
                        }
                        break;
                    case"read_param_key":
                        if (b[e].match(/[A-Za-z0-9_]/)) g += b[e]; else if ("=" === b[e]) j = "wait_getter"; else if ("," === b[e]) l(!1), j = "wait_param"; else {
                            if (!b[e].match(/\s/))return this._referencedError(a, "character", "comma, equal sign or end", e);
                            j = "param_key_readed"
                        }
                        break;
                    case"param_key_readed":
                        if (b[e].match(/\s/)); else if ("=" === b[e]) j = "wait_getter"; else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma, equal sign or end", e);
                            l(!1), j = "wait_param"
                        }
                        break;
                    case"wait_getter":
                        if (b[e].match(/\s/)); else {
                            if (!b[e].match(/[A-Za-z0-9_]/))return this._referencedError(a, "character", "getter", e);
                            j = "read_getter", h = b[e]
                        }
                        break;
                    case"read_getter":
                        if (b[e].match(/[A-Za-z0-9_.]/)) h += b[e]; else if (b[e].match(/\s/)) j = "getter_readed"; else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma or end", e);
                            l(), j = "wait_param"
                        }
                        break;
                    case"getter_readed":
                        if (b[e].match(/\s/)); else {
                            if ("," !== b[e])return this._referencedError(a, "character", "comma or end", e);
                            l(), j = "wait_param"
                        }
                }
                switch (j) {
                    case"param_key_readed":
                    case"read_param_key":
                        l(!1);
                        break;
                    case"getter_readed":
                    case"read_getter":
                        l();
                        break;
                    case"wait_key":
                        return this._referencedError(a, "end", "key");
                    case"wait_param":
                        return this._referencedError(a, "end", "parameter");
                    case"wait_getter":
                        return this._referencedError(a, "end", "getter")
                }
                return String(this.instant(f, k, d))
            }, TranslateService
        }();
        TranslateService = __decorate([core_1.Injectable(), __param(0, core_1.Inject(TranslateConfig_1.TranslateConfig)), __param(1, core_1.Inject(TranslateLoader_1.TranslateLoader)), __param(2, core_1.Inject(exports.TranslateLogHandler)), __metadata("design:paramtypes", [TranslateConfig_1.TranslateConfig, TranslateLoader_1.TranslateLoader, Object])], TranslateService), exports.TranslateService = TranslateService
    }), $__System.registerDynamic("a", ["b", "12", "f", "e", "11", "c", "d", "10"], !0, function (a, b, c) {
        "use strict";
        function d(a) {for (var c in a)b.hasOwnProperty(c) || (b[c] = a[c])}

        var e = (this || self, b && b.__decorate || function (a, b, c, d) {
            var e, f = arguments.length, g = f < 3 ? b : null === d ? d = Object.getOwnPropertyDescriptor(b, c) : d;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) g = Reflect.decorate(a, b, c, d); else for (var h = a.length - 1; h >= 0; h--)(e = a[h]) && (g = (f < 3 ? e(g) : f > 3 ? e(b, c, g) : e(b, c)) || g);
            return f > 3 && g && Object.defineProperty(b, c, g), g
        });
        Object.defineProperty(b, "__esModule", {value: !0});
        var f = a("b"), g = a("12"), h = a("f"), i = a("e"), j = a("11"), k = a("c"), l = a("d"), m = a("10");
        d(a("c")), d(a("11")), d(a("b")), d(a("12")), d(a("f")), d(a("e"));
        var n = function () {
            function a() {}

            return a
        }();
        n = e([l.NgModule({
            declarations: [j.TranslatePipe, f.TranslateComponent],
            exports: [j.TranslatePipe, f.TranslateComponent],
            imports: [m.HttpModule],
            providers: [{
                provide: g.TranslateConfig,
                useValue: new g.TranslateConfig({})
            }, {
                provide: i.TranslateLoaderJsonConfig,
                useValue: new i.TranslateLoaderJsonConfig
            }, {provide: h.TranslateLoader, useClass: i.TranslateLoaderJson}, {
                provide: k.TranslateLogHandler,
                useValue: k.TranslateLogHandler
            }, k.TranslateService]
        })], n), b.TranslatorModule = n, b.TRANSLATE_PROVIDERS = [{
            provide: g.TranslateConfig,
            useValue: new g.TranslateConfig({})
        }, {
            provide: i.TranslateLoaderJsonConfig,
            useValue: new i.TranslateLoaderJsonConfig
        }, {provide: h.TranslateLoader, useClass: i.TranslateLoaderJson}, {
            provide: k.TranslateLogHandler,
            useValue: k.TranslateLogHandler
        }, k.TranslateService]
    })
})(function (a) {
    if ("function" == typeof define && define.amd) define(["@angular/core", "@angular/http", "rxjs/Observable", "rxjs/add/operator/share"], a); else {
        if ("object" != typeof module || !module.exports || "function" != typeof require)throw new Error("Module must be loaded as AMD or CommonJS");
        module.exports = a(require("@angular/core"), require("@angular/http"), require("rxjs/Observable"), require("rxjs/add/operator/share"))
    }
});
//# sourceMappingURL=angular2-translator.js.map