PageSourceSearch

https://doolmojiapp.com/node_modules/systemjs/dist/system.src.js

js doolmojiapp.com collected 2026-10-06 16:27:28 UTC 158,205 bytes, 4,876 lines download raw bytes

1/*
2 * SystemJS v0.19.22
3 */
4(function() {
5function bootstrap() {(function(__global) {
6
7  var isWorker = typeof window == 'undefined' && typeof self != 'undefined' && typeof importScripts != 'undefined';
8  var isBrowser = typeof window != 'undefined' && typeof document != 'undefined';
9  var isWindows = typeof process != 'undefined' && typeof process.platform != 'undefined' && !!process.platform.match(/^win/);
10
11  if (!__global.console)
12    __global.console = { assert: function() {} };
13
14  // IE8 support
15  var indexOf = Array.prototype.indexOf || function(item) {
16    for (var i = 0, thisLen = this.length; i < thisLen; i++) {
17      if (this[i] === item) {
18        return i;
19      }
20    }
21    return -1;
22  };
23  
24  var defineProperty;
25  (function () {
26    try {
27      if (!!Object.defineProperty({}, 'a', {}))
28        defineProperty = Object.defineProperty;
29    }
30    catch (e) {
31      defineProperty = function(obj, prop, opt) {
32        try {
33          obj[prop] = opt.value || opt.get.call(obj);
34        }
35        catch(e) {}
36      }
37    }
38  })();
39
40  function addToError(err, msg) {
41    if (err instanceof Error)
42      err.message = err.message + '\n\t' + msg;
43    else
44      err += '\n\t' + msg;
45    return err;
46  }
47
48  function __eval(source, debugName, context) {
49    try {
50      new Function(source).call(context);
51    }
52    catch(e) {
53      throw addToError(e, 'Evaluating ' + debugName);
54    }
55  }
56
57  var baseURI;
58  // environent baseURI detection
59  if (typeof document != 'undefined' && document.getElementsByTagName) {
60    baseURI = document.baseURI;
61
62    if (!baseURI) {
63      var bases = document.getElementsByTagName('base');
64      baseURI = bases[0] && bases[0].href || window.location.href;
65    }
66
67    // sanitize out the hash and querystring
68    baseURI = baseURI.split('#')[0].split('?')[0];
69    baseURI = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
70  }
71  else if (typeof process != 'undefined' && process.cwd) {
72    baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
73    if (isWindows)
74      baseURI = baseURI.replace(/\\/g, '/');
75  }
76  else if (typeof location != 'undefined') {
77    baseURI = __global.location.href;
78  }
79  else {
80    throw new TypeError('No environment baseURI');
81  }
82
83  var URL = __global.URLPolyfill || __global.URL;
84/*
85*********************************************************************************************
86
87  Dynamic Module Loader Polyfill
88
89    - Implemented exactly to the former 2014-08-24 ES6 Specification Draft Rev 27, Section 15
90      http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27
91
92    - Functions are commented with their spec numbers, with spec differences commented.
93
94    - Spec bugs are commented in this code with links.
95
96    - Abstract functions have been combined where possible, and their associated functions
97      commented.
98
99    - Realm implementation is entirely omitted.
100
101*********************************************************************************************
102*/
103
104function Module() {}
105// http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag
106defineProperty(Module.prototype, 'toString', {
107  value: function() {
108    return 'Module';
109  }
110});
111function Loader(options) {
112  this._loader = {
113    loaderObj: this,
114    loads: [],
115    modules: {},
116    importPromises: {},
117    moduleRecords: {}
118  };
119
120  // 26.3.3.6
121  defineProperty(this, 'global', {
122    get: function() {
123      return __global;
124    }
125  });
126
127  // 26.3.3.13 realm not implemented
128}
129
130(function() {
131
132// Some Helpers
133
134// logs a linkset snapshot for debugging
135/* function snapshot(loader) {
136  console.log('---Snapshot---');
137  for (var i = 0; i < loader.loads.length; i++) {
138    var load = loader.loads[i];
139    var linkSetLog = '  ' + load.name + ' (' + load.status + '): ';
140
141    for (var j = 0; j < load.linkSets.length; j++) {
142      linkSetLog += '{' + logloads(load.linkSets[j].loads) + '} ';
143    }
144    console.log(linkSetLog);
145  }
146  console.log('');
147}
148function logloads(loads) {
149  var log = '';
150  for (var k = 0; k < loads.length; k++)
151    log += loads[k].name + (k != loads.length - 1 ? ' ' : '');
152  return log;
153} */
154
155
156/* function checkInvariants() {
157  // see https://bugs.ecmascript.org/show_bug.cgi?id=2603#c1
158
159  var loads = System._loader.loads;
160  var linkSets = [];
161
162  for (var i = 0; i < loads.length; i++) {
163    var load = loads[i];
164    console.assert(load.status == 'loading' || load.status == 'loaded', 'Each load is loading or loaded');
165
166    for (var j = 0; j < load.linkSets.length; j++) {
167      var linkSet = load.linkSets[j];
168
169      for (var k = 0; k < linkSet.loads.length; k++)
170        console.assert(loads.indexOf(linkSet.loads[k]) != -1, 'linkSet loads are a subset of loader loads');
171
172      if (linkSets.indexOf(linkSet) == -1)
173        linkSets.push(linkSet);
174    }
175  }
176
177  for (var i = 0; i < loads.length; i++) {
178    var load = loads[i];
179    for (var j = 0; j < linkSets.length; j++) {
180      var linkSet = linkSets[j];
181
182      if (linkSet.loads.indexOf(load) != -1)
183        console.assert(load.linkSets.indexOf(linkSet) != -1, 'linkSet contains load -> load contains linkSet');
184
185      if (load.linkSets.indexOf(linkSet) != -1)
186        console.assert(linkSet.loads.indexOf(load) != -1, 'load contains linkSet -> linkSet contains load');
187    }
188  }
189
190  for (var i = 0; i < linkSets.length; i++) {
191    var linkSet = linkSets[i];
192    for (var j = 0; j < linkSet.loads.length; j++) {
193      var load = linkSet.loads[j];
194
195      for (var k = 0; k < load.dependencies.length; k++) {
196        var depName = load.dependencies[k].value;
197        var depLoad;
198        for (var l = 0; l < loads.length; l++) {
199          if (loads[l].name != depName)
200            continue;
201          depLoad = loads[l];
202          break;
203        }
204
205        // loading records are allowed not to have their dependencies yet
206        // if (load.status != 'loading')
207        //  console.assert(depLoad, 'depLoad found');
208
209        // console.assert(linkSet.loads.indexOf(depLoad) != -1, 'linkset contains all dependencies');
210      }
211    }
212  }
213} */
214
215  // 15.2.3 - Runtime Semantics: Loader State
216
217  // 15.2.3.11
218  function createLoaderLoad(object) {
219    return {
220      // modules is an object for ES5 implementation
221      modules: {},
222      loads: [],
223      loaderObj: object
224    };
225  }
226
227  // 15.2.3.2 Load Records and LoadRequest Objects
228
229  // 15.2.3.2.1
230  function createLoad(name) {
231    return {
232      status: 'loading',
233      name: name,
234      linkSets: [],
235      dependencies: [],
236      metadata: {}
237    };
238  }
239
240  // 15.2.3.2.2 createLoadRequestObject, absorbed into calling functions
241
242  // 15.2.4
243
244  // 15.2.4.1
245  function loadModule(loader, name, options) {
246    return new Promise(asyncStartLoadPartwayThrough({
247      step: options.address ? 'fetch' : 'locate',
248      loader: loader,
249      moduleName: name,
250      // allow metadata for import https://bugs.ecmascript.org/show_bug.cgi?id=3091
251      moduleMetadata: options && options.metadata || {},
252      moduleSource: options.source,
253      moduleAddress: options.address
254    }));
255  }
256
257  // 15.2.4.2
258  function requestLoad(loader, request, refererName, refererAddress) {
259    // 15.2.4.2.1 CallNormalize
260    return new Promise(function(resolve, reject) {
261      resolve(loader.loaderObj.normalize(request, refererName, refererAddress));
262    })
263    // 15.2.4.2.2 GetOrCreateLoad
264    .then(function(name) {
265      var load;
266      if (loader.modules[name]) {
267        load = createLoad(name);
268        load.status = 'linked';
269        // https://bugs.ecmascript.org/show_bug.cgi?id=2795
270        load.module = loader.modules[name];
271        return load;
272      }
273
274      for (var i = 0, l = loader.loads.length; i < l; i++) {
275        load = loader.loads[i];
276        if (load.name != name)
277          continue;
278        console.assert(load.status == 'loading' || load.status == 'loaded', 'loading or loaded');
279        return load;
280      }
281
282      load = createLoad(name);
283      loader.loads.push(load);
284
285      proceedToLocate(loader, load);
286
287      return load;
288    });
289  }
290
291  // 15.2.4.3
292  function proceedToLocate(loader, load) {
293    proceedToFetch(loader, load,
294      Promise.resolve()
295      // 15.2.4.3.1 CallLocate
296      .then(function() {
297        return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
298      })
299    );
300  }
301
302  // 15.2.4.4
303  function proceedToFetch(loader, load, p) {
304    proceedToTranslate(loader, load,
305      p
306      // 15.2.4.4.1 CallFetch
307      .then(function(address) {
308        // adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
309        if (load.status != 'loading')
310          return;
311        load.address = address;
312
313        return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
314      })
315    );
316  }
317
318  var anonCnt = 0;
319
320  // 15.2.4.5
321  function proceedToTranslate(loader, load, p) {
322    p
323    // 15.2.4.5.1 CallTranslate
324    .then(function(source) {
325      if (load.status != 'loading')
326        return;
327
328      return Promise.resolve(loader.loaderObj.translate({ name: load.name, metadata: load.metadata, address: load.address, source: source }))
329
330      // 15.2.4.5.2 CallInstantiate
331      .then(function(source) {
332        load.source = source;
333        return loader.loaderObj.instantiate({ name: load.name, metadata: load.metadata, address: load.address, source: source });
334      })
335
336      // 15.2.4.5.3 InstantiateSucceeded
337      .then(function(instantiateResult) {
338        if (instantiateResult === undefined) {
339          load.address = load.address || '<Anonymous Module ' + ++anonCnt + '>';
340
341          // instead of load.kind, use load.isDeclarative
342          load.isDeclarative = true;
343          return transpile.call(loader.loaderObj, load)
344          .then(function(transpiled) {
345            // Hijack System.register to set declare function
346            var curSystem = __global.System;
347            var curRegister = curSystem.register;
348            curSystem.register = function(name, deps, declare) {
349              if (typeof name != 'string') {
350                declare = deps;
351                deps = name;
352              }
353              // store the registered declaration as load.declare
354              // store the deps as load.deps
355              load.declare = declare;
356              load.depsList = deps;
357            }
358            // empty {} context is closest to undefined 'this' we can get
359            __eval(transpiled, load.address, {});
360            curSystem.register = curRegister;
361          });
362        }
363        else if (typeof instantiateResult == 'object') {
364          load.depsList = instantiateResult.deps || [];
365          load.execute = instantiateResult.execute;
366          load.isDeclarative = false;
367        }
368        else
369          throw TypeError('Invalid instantiate return value');
370      })
371      // 15.2.4.6 ProcessLoadDependencies
372      .then(function() {
373        load.dependencies = [];
374        var depsList = load.depsList;
375
376        var loadPromises = [];
377        for (var i = 0, l = depsList.length; i < l; i++) (function(request, index) {
378          loadPromises.push(
379            requestLoad(loader, request, load.name, load.address)
380
381            // 15.2.4.6.1 AddDependencyLoad (load is parentLoad)
382            .then(function(depLoad) {
383
384              // adjusted from spec to maintain dependency order
385              // this is due to the System.register internal implementation needs
386              load.dependencies[index] = {
387                key: request,
388                value: depLoad.name
389              };
390
391              if (depLoad.status != 'linked') {
392                var linkSets = load.linkSets.concat([]);
393                for (var i = 0, l = linkSets.length; i < l; i++)
394                  addLoadToLinkSet(linkSets[i], depLoad);
395              }
396
397              // console.log('AddDependencyLoad ' + depLoad.name + ' for ' + load.name);
398              // snapshot(loader);
399            })
400          );
401        })(depsList[i], i);
402
403        return Promise.all(loadPromises);
404      })
405
406      // 15.2.4.6.2 LoadSucceeded
407      .then(function() {
408        // console.log('LoadSucceeded ' + load.name);
409        // snapshot(loader);
410
411        console.assert(load.status == 'loading', 'is loading');
412
413        load.status = 'loaded';
414
415        var linkSets = load.linkSets.concat([]);
416        for (var i = 0, l = linkSets.length; i < l; i++)
417          updateLinkSetOnLoad(linkSets[i], load);
418      });
419    })
420    // 15.2.4.5.4 LoadFailed
421    ['catch'](function(exc) {
422      load.status = 'failed';
423      load.exception = exc;
424
425      var linkSets = load.linkSets.concat([]);
426      for (var i = 0, l = linkSets.length; i < l; i++) {
427        linkSetFailed(linkSets[i], load, exc);
428      }
429
430      console.assert(load.linkSets.length == 0, 'linkSets not removed');
431    });
432  }
433
434  // 15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions
435
436  // 15.2.4.7.1
437  function asyncStartLoadPartwayThrough(stepState) {
438    return function(resolve, reject) {
439      var loader = stepState.loader;
440      var name = stepState.moduleName;
441      var step = stepState.step;
442
443      if (loader.modules[name])
444        throw new TypeError('"' + name + '" already exists in the module table');
445
446      // adjusted to pick up existing loads
447      var existingLoad;
448      for (var i = 0, l = loader.loads.length; i < l; i++) {
449        if (loader.loads[i].name == name) {
450          existingLoad = loader.loads[i];
451
452          if (step == 'translate' && !existingLoad.source) {
453            existingLoad.address = stepState.moduleAddress;
454            proceedToTranslate(loader, existingLoad, Promise.resolve(stepState.moduleSource));
455          }
456
457          // a primary load -> use that existing linkset if it is for the direct load here
458          // otherwise create a new linkset unit
459          if (existingLoad.linkSets.length && existingLoad.linkSets[0].loads[0].name == existingLoad.name)
460            return existingLoad.linkSets[0].done.then(function() {
461              resolve(existingLoad);
462            });
463        }
464      }
465
466      var load = existingLoad || createLoad(name);
467
468      load.metadata = stepState.moduleMetadata;
469
470      var linkSet = createLinkSet(loader, load);
471
472      loader.loads.push(load);
473
474      resolve(linkSet.done);
475
476      if (step == 'locate')
477        proceedToLocate(loader, load);
478
479      else if (step == 'fetch')
480        proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));
481
482      else {
483        console.assert(step == 'translate', 'translate step');
484        load.address = stepState.moduleAddress;
485        proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
486      }
487    }
488  }
489
490  // Declarative linking functions run through alternative implementation:
491  // 15.2.5.1.1 CreateModuleLinkageRecord not implemented
492  // 15.2.5.1.2 LookupExport not implemented
493  // 15.2.5.1.3 LookupModuleDependency not implemented
494
495  // 15.2.5.2.1
496  function createLinkSet(loader, startingLoad) {
497    var linkSet = {
498      loader: loader,
499      loads: [],
500      startingLoad: startingLoad, // added see spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
501      loadingCount: 0
502    };
503    linkSet.done = new Promise(function(resolve, reject) {
504      linkSet.resolve = resolve;
505      linkSet.reject = reject;
506    });
507    addLoadToLinkSet(linkSet, startingLoad);
508    return linkSet;
509  }
510  // 15.2.5.2.2
511  function addLoadToLinkSet(linkSet, load) {
512    if (load.status == 'failed')
513      return;
514
515    console.assert(load.status == 'loading' || load.status == 'loaded', 'loading or loaded on link set');
516
517    for (var i = 0, l = linkSet.loads.length; i < l; i++)
518      if (linkSet.loads[i] == load)
519        return;
520
521    linkSet.loads.push(load);
522    load.linkSets.push(linkSet);
523
524    // adjustment, see https://bugs.ecmascript.org/show_bug.cgi?id=2603
525    if (load.status != 'loaded') {
526      linkSet.loadingCount++;
527    }
528
529    var loader = linkSet.loader;
530
531    for (var i = 0, l = load.dependencies.length; i < l; i++) {
532      if (!load.dependencies[i])
533        continue;
534
535      var name = load.dependencies[i].value;
536
537      if (loader.modules[name])
538        continue;
539
540      for (var j = 0, d = loader.loads.length; j < d; j++) {
541        if (loader.loads[j].name != name)
542          continue;
543
544        addLoadToLinkSet(linkSet, loader.loads[j]);
545        break;
546      }
547    }
548    // console.log('add to linkset ' + load.name);
549    // snapshot(linkSet.loader);
550  }
551
552  // linking errors can be generic or load-specific
553  // this is necessary for debugging info
554  function doLink(linkSet) {
555    var error = false;
556    try {
557      link(linkSet, function(load, exc) {
558        linkSetFailed(linkSet, load, exc);
559        error = true;
560      });
561    }
562    catch(e) {
563      linkSetFailed(linkSet, null, e);
564      error = true;
565    }
566    return error;
567  }
568
569  // 15.2.5.2.3
570  function updateLinkSetOnLoad(linkSet, load) {
571    // console.log('update linkset on load ' + load.name);
572    // snapshot(linkSet.loader);
573
574    console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
575
576    linkSet.loadingCount--;
577
578    if (linkSet.loadingCount > 0)
579      return;
580
581    // adjusted for spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
582    var startingLoad = linkSet.startingLoad;
583
584    // non-executing link variation for loader tracing
585    // on the server. Not in spec.
586    /***/
587    if (linkSet.loader.loaderObj.execute === false) {
588      var loads = [].concat(linkSet.loads);
589      for (var i = 0, l = loads.length; i < l; i++) {
590        var load = loads[i];
591        load.module = !load.isDeclarative ? {
592          module: _newModule({})
593        } : {
594          name: load.name,
595          module: _newModule({}),
596          evaluated: true
597        };
598        load.status = 'linked';
599        finishLoad(linkSet.loader, load);
600      }
601      return linkSet.resolve(startingLoad);
602    }
603    /***/
604
605    var abrupt = doLink(linkSet);
606
607    if (abrupt)
608      return;
609
610    console.assert(linkSet.loads.length == 0, 'loads cleared');
611
612    linkSet.resolve(startingLoad);
613  }
614
615  // 15.2.5.2.4
616  function linkSetFailed(linkSet, load, exc) {
617    var loader = linkSet.loader;
618    var requests;
619
620    checkError: 
621    if (load) {
622      if (linkSet.loads[0].name == load.name) {
623        exc = addToError(exc, 'Error loading ' + load.name);
624      }
625      else {
626        for (var i = 0; i < linkSet.loads.length; i++) {
627          var pLoad = linkSet.loads[i];
628          for (var j = 0; j < pLoad.dependencies.length; j++) {
629            var dep = pLoad.dependencies[j];
630            if (dep.value == load.name) {
631              exc = addToError(exc, 'Error loading ' + load.name + ' as "' + dep.key + '" from ' + pLoad.name);
632              break checkError;
633            }
634          }
635        }
636        exc = addToError(exc, 'Error loading ' + load.name + ' from ' + linkSet.loads[0].name);
637      }
638    }
639    else {
640      exc = addToError(exc, 'Error linking ' + linkSet.loads[0].name);
641    }
642
643
644    var loads = linkSet.loads.concat([]);
645    for (var i = 0, l = loads.length; i < l; i++) {
646      var load = loads[i];
647
648      // store all failed load records
649      loader.loaderObj.failed = loader.loaderObj.failed || [];
650      if (indexOf.call(loader.loaderObj.failed, load) == -1)
651        loader.loaderObj.failed.push(load);
652
653      var linkIndex = indexOf.call(load.linkSets, linkSet);
654      console.assert(linkIndex != -1, 'link not present');
655      load.linkSets.splice(linkIndex, 1);
656      if (load.linkSets.length == 0) {
657        var globalLoadsIndex = indexOf.call(linkSet.loader.loads, load);
658        if (globalLoadsIndex != -1)
659          linkSet.loader.loads.splice(globalLoadsIndex, 1);
660      }
661    }
662    linkSet.reject(exc);
663  }
664
665  // 15.2.5.2.5
666  function finishLoad(loader, load) {
667    // add to global trace if tracing
668    if (loader.loaderObj.trace) {
669      if (!loader.loaderObj.loads)
670        loader.loaderObj.loads = {};
671      var depMap = {};
672      load.dependencies.forEach(function(dep) {
673        depMap[dep.key] = dep.value;
674      });
675      loader.loaderObj.loads[load.name] = {
676        name: load.name,
677        deps: load.dependencies.map(function(dep){ return dep.key }),
678        depMap: depMap,
679        address: load.address,
680        metadata: load.metadata,
681        source: load.source,
682        kind: load.isDeclarative ? 'declarative' : 'dynamic'
683      };
684    }
685    // if not anonymous, add to the module table
686    if (load.name) {
687      console.assert(!loader.modules[load.name], 'load not in module table');
688      loader.modules[load.name] = load.module;
689    }
690    var loadIndex = indexOf.call(loader.loads, load);
691    if (loadIndex != -1)
692      loader.loads.splice(loadIndex, 1);
693    for (var i = 0, l = load.linkSets.length; i < l; i++) {
694      loadIndex = indexOf.call(load.linkSets[i].loads, load);
695      if (loadIndex != -1)
696        load.linkSets[i].loads.splice(loadIndex, 1);
697    }
698    load.linkSets.splice(0, load.linkSets.length);
699  }
700
701  function doDynamicExecute(linkSet, load, linkError) {
702    try {
703      var module = load.execute();
704    }
705    catch(e) {
706      linkError(load, e);
707      return;
708    }
709    if (!module || !(module instanceof Module))
710      linkError(load, new TypeError('Execution must define a Module instance'));
711    else
712      return module;
713  }
714
715  // 26.3 Loader
716
717  // 26.3.1.1
718  // defined at top
719
720  // importPromises adds ability to import a module twice without error - https://bugs.ecmascript.org/show_bug.cgi?id=2601
721  function createImportPromise(loader, name, promise) {
722    var importPromises = loader._loader.importPromises;
723    return importPromises[name] = promise.then(function(m) {
724      importPromises[name] = undefined;
725      return m;
726    }, function(e) {
727      importPromises[name] = undefined;
728      throw e;
729    });
730  }
731
732  Loader.prototype = {
733    // 26.3.3.1
734    constructor: Loader,
735    // 26.3.3.2
736    define: function(name, source, options) {
737      // check if already defined
738      if (this._loader.importPromises[name])
739        throw new TypeError('Module is already loading.');
740      return createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
741        step: 'translate',
742        loader: this._loader,
743        moduleName: name,
744        moduleMetadata: options && options.metadata || {},
745        moduleSource: source,
746        moduleAddress: options && options.address
747      })));
748    },
749    // 26.3.3.3
750    'delete': function(name) {
751      var loader = this._loader;
752      delete loader.importPromises[name];
753      delete loader.moduleRecords[name];
754      return loader.modules[name] ? delete loader.modules[name] : false;
755    },
756    // 26.3.3.4 entries not implemented
757    // 26.3.3.5
758    get: function(key) {
759      if (!this._loader.modules[key])
760        return;
761      doEnsureEvaluated(this._loader.modules[key], [], this);
762      return this._loader.modules[key].module;
763    },
764    // 26.3.3.7
765    has: function(name) {
766      return !!this._loader.modules[name];
767    },
768    // 26.3.3.8
769    'import': function(name, parentName, parentAddress) {
770      if (typeof parentName == 'object')
771        parentName = parentName.name;
772
773      // run normalize first
774      var loaderObj = this;
775
776      // added, see https://bugs.ecmascript.org/show_bug.cgi?id=2659
777      return Promise.resolve(loaderObj.normalize(name, parentName))
778      .then(function(name) {
779        var loader = loaderObj._loader;
780
781        if (loader.modules[name]) {
782          doEnsureEvaluated(loader.modules[name], [], loader._loader);
783          return loader.modules[name].module;
784        }
785
786        return loader.importPromises[name] || createImportPromise(loaderObj, name,
787          loadModule(loader, name, {})
788          .then(function(load) {
789            delete loader.importPromises[name];
790            return evaluateLoadedModule(loader, load);
791          }));
792      });
793    },
794    // 26.3.3.9 keys not implemented
795    // 26.3.3.10
796    load: function(name) {
797      var loader = this._loader;
798      if (loader.modules[name])
799        return Promise.resolve();
800      return loader.importPromises[name] || createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
801        step: 'locate',
802        loader: loader,
803        moduleName: name,
804        moduleMetadata: {},
805        moduleSource: undefined,
806        moduleAddress: undefined
807      }))
808      .then(function() {
809        delete loader.importPromises[name];
810      }));
811    },
812    // 26.3.3.11
813    module: function(source, options) {
814      var load = createLoad();
815      load.address = options && options.address;
816      var linkSet = createLinkSet(this._loader, load);
817      var sourcePromise = Promise.resolve(source);
818      var loader = this._loader;
819      var p = linkSet.done.then(function() {
820        return evaluateLoadedModule(loader, load);
821      });
822      proceedToTranslate(loader, load, sourcePromise);
823      return p;
824    },
825    // 26.3.3.12
826    newModule: function (obj) {
827      if (typeof obj != 'object')
828        throw new TypeError('Expected object');
829
830      var m = new Module();
831
832      var pNames = [];
833      if (Object.getOwnPropertyNames && obj != null)
834        pNames = Object.getOwnPropertyNames(obj);
835      else
836        for (var key in obj)
837          pNames.push(key);
838
839      for (var i = 0; i < pNames.length; i++) (function(key) {
840        defineProperty(m, key, {
841          configurable: false,
842          enumerable: true,
843          get: function () {
844            return obj[key];
845          },
846          set: function() {
847            throw new Error('Module exports cannot be changed externally.');
848          }
849        });
850      })(pNames[i]);
851
852      if (Object.freeze)
853        Object.freeze(m);
854
855      return m;
856    },
857    // 26.3.3.14
858    set: function(name, module) {
859      if (!(module instanceof Module))
860        throw new TypeError('Loader.set(' + name + ', module) must be a module');
861      this._loader.modules[name] = {
862        module: module
863      };
864    },
865    // 26.3.3.15 values not implemented
866    // 26.3.3.16 @@iterator not implemented
867    // 26.3.3.17 @@toStringTag not implemented
868
869    // 26.3.3.18.1
870    normalize: function(name, referrerName, referrerAddress) {
871      return name;
872    },
873    // 26.3.3.18.2
874    locate: function(load) {
875      return load.name;
876    },
877    // 26.3.3.18.3
878    fetch: function(load) {
879    },
880    // 26.3.3.18.4
881    translate: function(load) {
882      return load.source;
883    },
884    // 26.3.3.18.5
885    instantiate: function(load) {
886    }
887  };
888
889  var _newModule = Loader.prototype.newModule;
890/*
891 * ES6 Module Declarative Linking Code - Dev Build Only
892 */
893  function link(linkSet, linkError) {
894
895    var loader = linkSet.loader;
896
897    if (!linkSet.loads.length)
898      return;
899
900    var loads = linkSet.loads.concat([]);
901
902    for (var i = 0; i < loads.length; i++) {
903      var load = loads[i];
904
905      var module = doDynamicExecute(linkSet, load, linkError);
906      if (!module)
907        return;
908      load.module = {
909        name: load.name,
910        module: module
911      };
912      load.status = 'linked';
913
914      finishLoad(loader, load);
915    }
916  }
917
918  function evaluateLoadedModule(loader, load) {
919    console.assert(load.status == 'linked', 'is linked ' + load.name);
920    return load.module.module;
921  }
922
923  function doEnsureEvaluated() {}
924
925  function transpile() {
926    throw new TypeError('ES6 transpilation is only provided in the dev module loader build.');
927  }
928})();/*
929*********************************************************************************************
930
931  System Loader Implementation
932
933    - Implemented to https://github.com/jorendorff/js-loaders/blob/master/browser-loader.js
934
935    - <script type="module"> supported
936
937*********************************************************************************************
938*/
939
940var System;
941
942function SystemLoader() {
943  Loader.call(this);
944  this.paths = {};
945}
946
947// NB no specification provided for System.paths, used ideas discu
947ssed in https://github.com/jorendorff/js-loaders/issues/25
948function applyPaths(paths, name) {
949  // most specific (most number of slashes in path) match wins
950  var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
951
952  // check to see if we have a paths entry
953  for (var p in paths) {
954    var pathParts = p.split('*');
955    if (pathParts.length > 2)
956      throw new TypeError('Only one wildcard in a path is permitted');
957
958    // exact path match
959    if (pathParts.length == 1) {
960      if (name == p)
961        return paths[p];
962      
963      // support trailing / in paths rules
964      else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && paths[p][paths[p].length - 1] == '/')
965        return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? '/' + name.substr(p.length) : '');
966    }
967    // wildcard path match
968    else {
969      var wildcardPrefixLen = pathParts[0].length;
970      if (wildcardPrefixLen >= maxWildcardPrefixLen &&
971          name.substr(0, pathParts[0].length) == pathParts[0] &&
972          name.substr(name.length - pathParts[1].length) == pathParts[1]) {
973            maxWildcardPrefixLen = wildcardPrefixLen;
974            pathMatch = p;
975            wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
976          }
977    }
978  }
979
980  var outPath = paths[pathMatch];
981  if (typeof wildcard == 'string')
982    outPath = outPath.replace('*', wildcard);
983
984  return outPath;
985}
986
987// inline Object.create-style class extension
988function LoaderProto() {}
989LoaderProto.prototype = Loader.prototype;
990SystemLoader.prototype = new LoaderProto();
991  var fetchTextFromURL;
992  if (typeof XMLHttpRequest != 'undefined') {
993    fetchTextFromURL = function(url, authorization, fulfill, reject) {
994      var xhr = new XMLHttpRequest();
995      var sameDomain = true;
996      var doTimeout = false;
997      if (!('withCredentials' in xhr)) {
998        // check if same domain
999        var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
1000        if (domainCheck) {
1001          sameDomain = domainCheck[2] === window.location.host;
1002          if (domainCheck[1])
1003            sameDomain &= domainCheck[1] === window.location.protocol;
1004        }
1005      }
1006      if (!sameDomain && typeof XDomainRequest != 'undefined') {
1007        xhr = new XDomainRequest();
1008        xhr.onload = load;
1009        xhr.onerror = error;
1010        xhr.ontimeout = error;
1011        xhr.onprogress = function() {};
1012        xhr.timeout = 0;
1013        doTimeout = true;
1014      }
1015      function load() {
1016        fulfill(xhr.responseText);
1017      }
1018      function error() {
1019        reject(new Error('XHR error' + (xhr.status ? ' (' + xhr.status + (xhr.statusText ? ' ' + xhr.statusText  : '') + ')' : '') + ' loading ' + url));
1020      }
1021
1022      xhr.onreadystatechange = function () {
1023        if (xhr.readyState === 4) {
1024          // in Chrome on file:/// URLs, status is 0
1025          if (xhr.status == 0) {
1026            if (xhr.responseText) {
1027              load();
1028            }
1029            else {
1030              // when responseText is empty, wait for load or error event
1031              // to inform if it is a 404 or empty file
1032              xhr.addEventListener('error', error);
1033              xhr.addEventListener('load', load);
1034            }
1035          }
1036          else if (xhr.status === 200) {
1037            load();
1038          }
1039          else {
1040            error();
1041          }
1042        }
1043      };
1044      xhr.open("GET", url, true);
1045
1046      if (xhr.setRequestHeader) {
1047        xhr.setRequestHeader('Accept', 'application/x-es-module, */*');
1048        // can set "authorization: true" to enable withCredentials only
1049        if (authorization) {
1050          if (typeof authorization == 'string')
1051            xhr.setRequestHeader('Authorization', authorization);
1052          xhr.withCredentials = true;
1053        }
1054      }
1055
1056      if (doTimeout) {
1057        setTimeout(function() {
1058          xhr.send();
1059        }, 0);
1060      } else {
1061        xhr.send(null);
1062      }
1063    };
1064  }
1065  else if (typeof require != 'undefined' && typeof process != 'undefined') {
1066    var fs;
1067    fetchTextFromURL = function(url, authorization, fulfill, reject) {
1068      if (url.substr(0, 8) != 'file:///')
1069        throw new Error('Unable to fetch "' + url + '". Only file URLs of the form file:/// allowed running in Node.');
1070      fs = fs || require('fs');
1071      if (isWindows)
1072        url = url.replace(/\//g, '\\').substr(8);
1073      else
1074        url = url.substr(7);
1075      return fs.readFile(url, function(err, data) {
1076        if (err) {
1077          return reject(err);
1078        }
1079        else {
1080          // Strip Byte Order Mark out if it's the leading char
1081          var dataString = data + '';
1082          if (dataString[0] === '\ufeff')
1083            dataString = dataString.substr(1);
1084
1085          fulfill(dataString);
1086        }
1087      });
1088    };
1089  }
1090  else if (typeof self != 'undefined' && typeof self.fetch != 'undefined') {
1091    fetchTextFromURL = function(url, authorization, fulfill, reject) {
1092      var opts = {
1093        headers: {'Accept': 'application/x-es-module, */*'}
1094      };
1095
1096      if (authorization) {
1097        if (typeof authorization == 'string')
1098          opts.headers['Authorization'] = authorization;
1099        opts.credentials = 'include';
1100      }
1101
1102      fetch(url, opts)
1103        .then(function (r) {
1104          if (r.ok) {
1105            return r.text();
1106          } else {
1107            throw new Error('Fetch error: ' + r.status + ' ' + r.statusText);
1108          }
1109        })
1110        .then(fulfill, reject);
1111    }
1112  }
1113  else {
1114    throw new TypeError('No environment fetch API available.');
1115  }
1116
1117  SystemLoader.prototype.fetch = function(load) {
1118    return new Promise(function(resolve, reject) {
1119      fetchTextFromURL(load.address, undefined, resolve, reject);
1120    });
1121  };
1122/*
1123 * Traceur, Babel and TypeScript transpile hook for Loader
1124 */
1125var transpile = (function() {
1126
1127  // use Traceur by default
1128  Loader.prototype.transpiler = 'traceur';
1129
1130  function transpile(load) {
1131    var self = this;
1132
1133    return Promise.resolve(__global[self.transpiler == 'typescript' ? 'ts' : self.transpiler]
1134        || (self.pluginLoader || self)['import'](self.transpiler))
1135    .then(function(transpiler) {
1136      if (transpiler.__useDefault)
1137        transpiler = transpiler['default'];
1138
1139      var transpileFunction;
1140      if (transpiler.Compiler)
1141        transpileFunction = traceurTranspile;
1142      else if (transpiler.createLanguageService)
1143        transpileFunction = typescriptTranspile;
1144      else
1145        transpileFunction = babelTranspile;
1146
1147      // note __moduleName will be part of the transformer meta in future when we have the spec for this
1148      return '(function(__moduleName){' + transpileFunction.call(self, load, transpiler) + '\n})("' + load.name + '");\n//# sourceURL=' + load.address + '!transpiled';
1149    });
1150  };
1151
1152  function traceurTranspile(load, traceur) {
1153    var options = this.traceurOptions || {};
1154    options.modules = 'instantiate';
1155    options.script = false;
1156    if (options.sourceMaps === undefined)
1157      options.sourceMaps = 'inline';
1158    options.filename = load.address;
1159    options.inputSourceMap = load.metadata.sourceMap;
1160    options.moduleName = false;
1161
1162    var compiler = new traceur.Compiler(options);
1163
1164    return doTraceurCompile(load.source, compiler, options.filename);
1165  }
1166  function doTraceurCompile(source, compiler, filename) {
1167    try {
1168      return compiler.compile(source, filename);
1169    }
1170    catch(e) {
1171      // on older versions of traceur (<0.9.3), an array of errors is thrown
1172      // rather than a single error.
1173      if (e.length) {
1174        throw e[0];
1175      }
1176      throw e;
1177    }
1178  }
1179
1180  function babelTranspile(load, babel) {
1181    var options = this.babelOptions || {};
1182    options.modules = 'system';
1183    if (options.sourceMap === undefined)
1184      options.sourceMap = 'inline';
1185    options.inputSourceMap = load.metadata.sourceMap;
1186    options.filename = load.address;
1187    options.code = true;
1188    options.ast = false;
1189
1190    return babel.transform(load.source, options).code;
1191  }
1192
1193  function typescriptTranspile(load, ts) {
1194    var options = this.typescriptOptions || {};
1195    options.target = options.target || ts.ScriptTarget.ES5;
1196    if (options.sourceMap === undefined)
1197      options.sourceMap = true;
1198    if (options.sourceMap && options.inlineSourceMap !== false)
1199      options.inlineSourceMap = true;
1200
1201    options.module = ts.ModuleKind.System;
1202
1203    return ts.transpile(load.source, options, load.address);
1204  }
1205
1206  return transpile;
1207})();
1208// SystemJS Loader Class and Extension helpers
1209
1210function SystemJSLoader() {
1211  SystemLoader.call(this);
1212
1213  systemJSConstructor.call(this);
1214}
1215
1216// inline Object.create-style class extension
1217function SystemProto() {};
1218SystemProto.prototype = SystemLoader.prototype;
1219SystemJSLoader.prototype = new SystemProto();
1220SystemJSLoader.prototype.constructor = SystemJSLoader;
1221
1222// remove ESML instantiate
1223SystemJSLoader.prototype.instantiate = function() {};
1224
1225var systemJSConstructor;
1226
1227function hook(name, hook) {
1228  SystemJSLoader.prototype[name] = hook(SystemJSLoader.prototype[name] || function() {});
1229}
1230function hookConstructor(hook) {
1231  systemJSConstructor = hook(systemJSConstructor || function() {});
1232}
1233
1234function dedupe(deps) {
1235  var newDeps = [];
1236  for (var i = 0, l = deps.length; i < l; i++)
1237    if (indexOf.call(newDeps, deps[i]) == -1)
1238      newDeps.push(deps[i])
1239  return newDeps;
1240}
1241
1242function group(deps) {
1243  var names = [];
1244  var indices = [];
1245  for (var i = 0, l = deps.length; i < l; i++) {
1246    var index = indexOf.call(names, deps[i]);
1247    if (index === -1) {
1248      names.push(deps[i]);
1249      indices.push([i]);
1250    }
1251    else {
1252      indices[index].push(i);
1253    }
1254  }
1255  return { names: names, indices: indices };
1256}
1257
1258var getOwnPropertyDescriptor = true;
1259try {
1260  Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
1261}
1262catch(e) {
1263  getOwnPropertyDescriptor = false;
1264}
1265
1266// converts any module.exports object into an object ready for SystemJS.newModule
1267function getESModule(exports) {
1268  var esModule = {};
1269  // don't trigger getters/setters in environments that support them
1270  if (typeof exports == 'object' || typeof exports == 'function') {
1271    if (getOwnPropertyDescriptor) {
1272      var d;
1273      for (var p in exports)
1274        if (d = Object.getOwnPropertyDescriptor(exports, p))
1275          defineProperty(esModule, p, d);
1276    }
1277    else {
1278      var hasOwnProperty = exports && exports.hasOwnProperty;
1279      for (var p in exports) {
1280        if (!hasOwnProperty || exports.hasOwnProperty(p))
1281          esModule[p] = exports[p];
1282      }
1283    }
1284  }
1285  esModule['default'] = exports;
1286  defineProperty(esModule, '__useDefault', {
1287    value: true
1288  });
1289  return esModule;
1290}
1291
1292function extend(a, b, prepend) {
1293  for (var p in b) {
1294    if (!prepend || !(p in a))
1295      a[p] = b[p];
1296  }
1297  return a;
1298}
1299
1300// package configuration options
1301var packageProperties = ['main', 'format', 'defaultExtension', 'meta', 'map', 'basePath', 'depCache'];
1302
1303// meta first-level extends where:
1304// array + array appends
1305// object + object extends
1306// other properties replace
1307function extendMeta(a, b, prepend) {
1308  for (var p in b) {
1309    var val = b[p];
1310    if (!(p in a))
1311      a[p] = val;
1312    else if (val instanceof Array && a[p] instanceof Array)
1313      a[p] = [].concat(prepend ? val : a[p]).concat(prepend ? a[p] : val);
1314    else if (typeof val == 'object' && val !== null && typeof a[p] == 'object')
1315      a[p] = extend(extend({}, a[p]), val, prepend);
1316    else if (!prepend)
1317      a[p] = val;
1318  }
1319}
1320
1321function warn(msg) {
1322  if (this.warnings && typeof console != 'undefined' && console.warn)
1323    console.warn(msg);
1324}// we define a __exec for globally-scoped execution
1325// used by module format implementations
1326var __exec;
1327
1328(function() {
1329
1330  var hasBtoa = typeof btoa != 'undefined';
1331
1332  // used to support leading #!/usr/bin/env in scripts as supported in Node
1333  var hashBangRegEx = /^\#\!.*/;
1334
1335  function getSource(load) {
1336    var lastLineIndex = load.source.lastIndexOf('\n');
1337
1338    // wrap ES formats with a System closure for System global encapsulation
1339    var wrap = load.metadata.format == 'esm' || load.metadata.format == 'register' || load.metadata.bundle;
1340
1341    var sourceMap = load.metadata.sourceMap;
1342    if (sourceMap) {
1343      if (typeof sourceMap != 'object')
1344        throw new TypeError('load.metadata.sourceMap must be set to an object.');
1345
1346      if (sourceMap.mappings)
1347        sourceMap.mappings = ';' + sourceMap.mappings;
1348    }
1349    
1350    sourceMap = JSON.stringify(sourceMap);
1351
1352    return (wrap ? '(function(System, SystemJS) {' : '') + (load.metadata.format == 'cjs' ? load.source.replace(hashBangRegEx, '') : load.source) + (wrap ? '\n})(System, System);' : '')
1353        // adds the sourceURL comment if not already present
1354        + (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL=' 
1355          ? '\n//# sourceURL=' + load.address + (sourceMap ? '!transpiled' : '') : '')
1356        // add sourceMappingURL if load.metadata.sourceMap is set
1357        + (sourceMap && hasBtoa && '\n//# sourceMappingURL=data:application/json;
1357base64,' + btoa(unescape(encodeURIComponent(sourceMap))) || '');
1358  }
1359
1360  var curLoad;
1361
1362  // System.register, System.registerDynamic, AMD define pipeline
1363  // if currently evalling code here, immediately reduce the registered entry against the load record
1364  hook('pushRegister_', function() {
1365    return function(register) {
1366      if (!curLoad)
1367        return false;
1368
1369      this.reduceRegister_(curLoad, register);
1370      return true;
1371    };
1372  });
1373
1374  // System clobbering protection (mostly for Traceur)
1375  var curSystem;
1376  var callCounter = 0;
1377  function preExec(loader, load) {
1378    curLoad = load;
1379    if (callCounter++ == 0)
1380      curSystem = __global.System;
1381    __global.System = __global.SystemJS = loader; 
1382  }
1383  function postExec() {
1384    if (--callCounter == 0)
1385      __global.System = __global.SystemJS = curSystem;
1386    curLoad = undefined;
1387  }
1388
1389  __exec = function(load) {
1390    if ((load.metadata.integrity || load.metadata.nonce) && supportsScriptExec)
1391      return scriptExec.call(this, load);
1392    try {
1393      preExec(this, load);
1394      curLoad = load;
1395      (0, eval)(getSource(load));
1396      postExec();
1397    }
1398    catch(e) {
1399      postExec(); 
1400      throw addToError(e, 'Evaluating ' + load.address);
1401    }
1402  };
1403
1404  var supportsScriptExec = false;
1405  if (isBrowser && typeof document != 'undefined' && document.getElementsByTagName) {
1406    var scripts = document.getElementsByTagName('script');
1407    $__curScript = scripts[scripts.length - 1];
1408
1409    if (!(window.chrome && window.chrome.extension || navigator.userAgent.match(/^Node\.js/)))
1410      supportsScriptExec = true;
1411  }
1412
1413  // script execution via injecting a script tag into the page
1414  // this allows CSP integrity and nonce to be set for CSP environments
1415  var head;
1416  function scriptExec(load) {
1417    if (!head)
1418      head = document.head || document.body || document.documentElement;
1419
1420    var script = document.createElement('script');
1421    script.text = getSource(load, false);
1422    var onerror = window.onerror;
1423    var e;
1424    window.onerror = function(_e) {
1425      e = addToError(_e, 'Evaluating ' + load.address);
1426    }
1427    preExec(this, load);
1428
1429    if (load.metadata.integrity)
1430      script.setAttribute('integrity', load.metadata.integrity);
1431    if (load.metadata.nonce)
1432      script.setAttribute('nonce', load.metadata.nonce);
1433
1434    head.appendChild(script);
1435    head.removeChild(script);
1436    postExec();
1437    window.onerror = onerror;
1438    if (e)
1439      throw e;
1440  }
1441
1442})();var absURLRegEx = /^[^\/]+:\/\//;
1443
1444function readMemberExpression(p, value) {
1445  var pParts = p.split('.');
1446  while (pParts.length)
1447    value = value[pParts.shift()];
1448  return value;
1449}
1450
1451var baseURLCache = {};
1452function getBaseURLObj() {
1453  if (baseURLCache[this.baseURL])
1454    return baseURLCache[this.baseURL];
1455
1456  // normalize baseURL if not already
1457  if (this.baseURL[this.baseURL.length - 1] != '/')
1458    this.baseURL += '/';
1459
1460  var baseURL = new URL(this.baseURL, baseURI);
1461
1462  this.baseURL = baseURL.href;
1463
1464  return (baseURLCache[this.baseURL] = baseURL);
1465}
1466
1467function getMapMatch(map, name) {
1468  var bestMatch, bestMatchLength = 0;
1469
1470  for (var p in map) {
1471    if (name.substr(0, p.length) == p && (name.length == p.length || name[p.length] == '/')) {
1472      var curMatchLength = p.split('/').length;
1473      if (curMatchLength <= bestMatchLength)
1474        continue;
1475      bestMatch = p;
1476      bestMatchLength = curMatchLength;
1477    }
1478  }
1479
1480  return bestMatch;
1481}
1482
1483function setProduction(isProduction) {
1484  this.set('@system-env', this.newModule({
1485    browser: isBrowser,
1486    node: !!this._nodeRequire,
1487    production: isProduction
1488  }));
1489}
1490
1491var baseURIObj = new URL(baseURI);
1492
1493hookConstructor(function(constructor) {
1494  return function() {
1495    constructor.call(this);
1496
1497    // support baseURL
1498    this.baseURL = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
1499
1500    // support map and paths
1501    this.map = {};
1502    this.paths = {};
1503
1504    // global behaviour flags
1505    this.warnings = false;
1506    this.defaultJSExtensions = false;
1507    this.pluginFirst = false;
1508
1509    // by default load ".json" files as json
1510    // leading * meta doesn't need normalization
1511    // NB add this in next breaking release
1512    // this.meta['*.json'] = { format: 'json' };
1513
1514    // support the empty module, as a concept
1515    this.set('@empty', this.newModule({}));
1516
1517    setProduction.call(this, false);
1518  };
1519});
1520
1521// include the node require since we're overriding it
1522if (typeof require != 'undefined' && typeof process != 'undefined' && !process.browser)
1523  SystemJSLoader.prototype._nodeRequire = require;
1524
1525var nodeCoreModules = ['assert', 'buffer', 'child_process', 'cluster', 'console', 'constants', 
1526    'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'module', 'net', 'os', 'path', 
1527    'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers', 
1528    'tls', 'tty', 'url', 'util', 'vm', 'zlib'];
1529
1530/*
1531  Core SystemJS Normalization
1532
1533  If a name is relative, we apply URL normalization to the page
1534  If a name is an absolute URL, we leave it as-is
1535
1536  Plain names (neither of the above) run through the map and paths
1537  normalization phases.
1538
1539  The paths normalization phase applies last (paths extension), which
1540  defines the `decanonicalize` function and normalizes everything into
1541  a URL.
1542 */
1543
1544function applyMap(name) {
1545  // first run map config
1546  if (name[0] != '.' && name[0] != '/' && !name.match(absURLRegEx)) {
1547    var mapMatch = getMapMatch(this.map, name);
1548    if (mapMatch)
1549      return this.map[mapMatch] + name.substr(mapMatch.length);
1550  }
1551  return name;
1552}
1553
1554hook('normalize', function(normalize) {
1555  return function(name, parentName, skipExt) {
1556    name = applyMap.call(this, name);
1557
1558    // dynamically load node-core modules when requiring `@node/fs` for example
1559    if (name.substr(0, 6) == '@node/' && nodeCoreModules.indexOf(name.substr(6)) != -1) {
1560      if (!this._nodeRequire)
1561        throw new TypeError('Error loading ' + name + '. Can only load node core modules in Node.');
1562      this.set(name, this.newModule(getESModule(this._nodeRequire(name.substr(6)))));
1563    }
1564    
1565    // relative URL-normalization
1566    if (name[0] == '.' || name[0] == '/') {
1567      if (parentName)
1568        name = new URL(name, parentName.replace(/#/g, '%05')).href.replace(/%05/g, '#');
1569      else
1570        name = new URL(name, baseURIObj).href;
1571    }
1572
1573    // if the module is in the registry already, use that
1574    if (this.has(name))
1575      return name;
1576
1577    if (name.match(absURLRegEx)) {
1578      // defaultJSExtensions backwards compatibility
1579      if (this.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js' && !skipExt)
1580        name += '.js';
1581      return name;
1582    }
1583
1584    // applyPaths implementation provided from ModuleLoader system.js source
1585    name = applyPaths(this.paths, name) || name;
1586
1587    // defaultJSExtensions backwards compatibility
1588    if (this.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js' && !skipExt)
1589      name += '.js';
1590
1591    // ./x, /x -> page-relative
1592    if (name[0] == '.' || name[0] == '/')
1593      return new URL(name, baseURIObj).href;
1594    // x -> baseURL-relative
1595    else
1596      return new URL(name, getBaseURLObj.call(this)).href;
1597  };
1598});
1599
1600// percent encode just '#' in urls if using HTTP requests
1601var httpRequest = typeof XMLHttpRequest != 'undefined';
1602hook('locate', function(locate) {
1603  return function(load) {
1604    return Promise.resolve(locate.call(this, load))
1605    .then(function(address) {
1606      if (httpRequest)
1607        return address.replace(/#/g, '%23');
1608      return address;
1609    });
1610  };
1611});
1612
1613/*
1614 * Fetch with authorization
1615 */
1616hook('fetch', function() {
1617  return function(load) {
1618    return new Promise(function(resolve, reject) {
1619      fetchTextFromURL(load.address, load.metadata.authorization, resolve, reject);
1620    });
1621  };
1622});
1623
1624/*
1625  __useDefault
1626  
1627  When a module object looks like:
1628  newModule(
1629    __useDefault: true,
1630    default: 'some-module'
1631  })
1632
1633  Then importing that module provides the 'some-module'
1634  result directly instead of the full module.
1635
1636  Useful for eg module.exports = function() {}
1637*/
1638hook('import', function(systemImport) {
1639  return function(name, parentName, parentAddress) {
1640    if (parentName && parentName.name)
1641      warn.call(this, 'SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing ' + name + ' from ' + parentName.name);
1642    return systemImport.call(this, name, parentName, parentAddress).then(function(module) {
1643      return module.__useDefault ? module['default'] : module;
1644    });
1645  };
1646});
1647
1648/*
1649 * Allow format: 'detect' meta to enable format detection
1650 */
1651hook('translate', function(systemTranslate) {
1652  return function(load) {
1653    if (load.metadata.format == 'detect')
1654      load.metadata.format = undefined;
1655    return systemTranslate.call(this, load);
1656  };
1657});
1658
1659
1660/*
1661 * JSON format support
1662 *
1663 * Supports loading JSON files as a module format itself
1664 *
1665 * Usage:
1666 *
1667 * SystemJS.config({
1668 *   meta: {
1669 *     '*.json': { format: 'json' }
1670 *   }
1671 * });
1672 *
1673 * Module is returned as if written:
1674 *
1675 * export default {JSON}
1676 *
1677 * No named exports are provided
1678 *
1679 * Files ending in ".json" are treated as json automatically by SystemJS
1680 */
1681hook('instantiate', function(instantiate) {
1682  return function(load) {
1683    if (load.metadata.format == 'json' && !this.builder) {
1684      var entry = load.metadata.entry = createEntry();
1685      entry.deps = [];
1686      entry.execute = function() {
1687        try {
1688          return JSON.parse(load.source);
1689        }
1690        catch(e) {
1691          throw new Error("Invalid JSON file " + load.name);
1692        }
1693      };
1694    }
1695  };
1696})
1697
1698/*
1699 Extend config merging one deep only
1700
1701  loader.config({
1702    some: 'random',
1703    config: 'here',
1704    deep: {
1705      config: { too: 'too' }
1706    }
1707  });
1708
1709  <=>
1710
1711  loader.some = 'random';
1712  loader.config = 'here'
1713  loader.deep = loader.deep || {};
1714  loader.deep.config = { too: 'too' };
1715
1716
1717  Normalizes meta and package configs allowing for:
1718
1719  SystemJS.config({
1720    meta: {
1721      './index.js': {}
1722    }
1723  });
1724
1725  To become
1726
1727  SystemJS.meta['https://thissite.com/index.js'] = {};
1728
1729  For easy normalization canonicalization with latest URL support.
1730
1731*/
1732SystemJSLoader.prototype.env = 'development';
1733
1734SystemJSLoader.prototype.config = function(cfg) {
1735  var loader = this;
1736
1737  if ('warnings' in cfg)
1738    loader.warnings = cfg.warnings;
1739
1740  // transpiler deprecation path
1741  if (cfg.transpilerRuntime === false)
1742    loader._loader.loadedTranspilerRuntime = true;
1743
1744  // always configure baseURL first
1745  if (cfg.baseURL) {
1746    var hasConfig = false;
1747    function checkHasConfig(obj) {
1748      for (var p in obj)
1749        if (hasOwnProperty.call(obj, p))
1750          return true;
1751    }
1752    if (checkHasConfig(loader.packages) || checkHasConfig(loader.meta) || checkHasConfig(loader.depCache) || checkHasConfig(loader.bundles) || checkHasConfig(loader.packageConfigPaths))
1753      throw new TypeError('Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.');
1754
1755    loader.baseURL = cfg.baseURL;
1756
1757    // sanitize baseURL
1758    getBaseURLObj.call(loader);
1759  }
1760
1761  if (cfg.defaultJSExtensions) {
1762    loader.defaultJSExtensions = cfg.defaultJSExtensions;
1763    warn.call(loader, 'The defaultJSExtensions configuration option is deprecated, use packages configuration instead.');
1764  }
1765
1766  if (cfg.pluginFirst)
1767    loader.pluginFirst = cfg.pluginFirst;
1768
1769  if (cfg.production)
1770    setProduction.call(loader, true);
1771
1772  if (cfg.paths) {
1773    for (var p in cfg.paths)
1774      loader.paths[p] = cfg.paths[p];
1775  }
1776
1777  if (cfg.map) {
1778    var objMaps = '';
1779    for (var p in cfg.map) {
1780      var v = cfg.map[p];
1781
1782      // object map backwards-compat into packages configuration
1783      if (typeof v !== 'string') {
1784        objMaps += (objMaps.length ? ', ' : '') + '"' + p + '"';
1785
1786        var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
1787        var prop = loader.decanonicalize(p);
1788        if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
1789          prop = prop.substr(0, prop.length - 3);
1790
1791        // if a package main, revert it
1792        var pkgMatch = '';
1793        for (var pkg in loader.packages) {
1794          if (prop.substr(0, pkg.length) == pkg 
1795              && (!prop[pkg.length] || prop[pkg.length] == '/') 
1796              && pkgMatch.split('/').length < pkg.split('/').length)
1797            pkgMatch = pkg;
1798        }
1799        if (pkgMatch && loader.packages[pkgMatch].main)
1800          prop = prop.substr(0, prop.length - loader.packages[pkgMatch].main.length - 1);
1801
1802        var pkg = loader.packages[prop] = loader.packages[prop] || {};
1803        pkg.map = v;
1804      }
1805      else {
1806        loader.map[p] = v;
1807      }
1808    }
1809    if (objMaps)
1810      warn.call(loader, 'The map configuration for ' + objMaps + ' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "' + p + '": { map: {...} } } }).');
1811  }
1812
1813  if (cfg.packageConfigPaths) {
1814    var packageConfigPaths = [];
1815    for (var i = 0; i < cfg.packageConfigPaths.length; i++) {
1816      var path = cfg.packageConfigPaths[i];
1817      var packageLength = Math.max(path.lastIndexOf('*') + 1, path.lastIndexOf('/'));
1818      var defaultJSExtension = loader.defaultJSExtensions && path.substr(packageLength - 3, 3) != '.js';
1819      var normalized = loader.decanonicalize(path.substr(0, packageLength));
1820      if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
1821        normalized = normalized.substr(0, normalized.length - 3);
1822      packageConfigPaths[i] = normalized + path.substr(packageLength);
1823    }
1824    loader.packageConfigPaths = packageConfigPaths;
1825  }
1826
1827  if (cfg.bundles) {
1828    for (var p in cfg.bundles) {
1829      var bundle = [];
1830      for (var i = 0; i < cfg.bundles[p].length; i++) {
1831        var defaultJSExtension = loader.defaultJSExtensions && cfg.bundles[p][i].substr(cfg.bundles[p][i].length - 3, 3) != '.js';
1832        var normalizedBundleDep = loader.decanonicalize(cfg.bundles[p][i]);
1833        if (defaultJSExtension && normalizedBundleDep.substr(normalizedBundleDep.length - 3, 3) == '.js')
1834          normalizedBundleDep = normalizedBundleDep.substr(0, normalizedBundleDep.length - 3);
1835        bundle.push(normalizedBundleDep);
1836      }
1837      loader.bundles[p] = bundle;
1838    }
1839  }
1840
1841  if (cfg.packages) {
1842    for (var p in cfg.packages) {
1843      if (p.match(/^([^\/]+:)?\/\/$/))
1844        throw new TypeError('"' + p + '" is not a valid package name.');
1845
1846      var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
1847      var prop = loader.decanonicalize(applyMap(p));
1848      if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
1849        prop = prop.substr(0, prop.length - 3);
1850
1851      // allow trailing slash in packages
1852      if (prop[prop.length - 1] == '/')
1853        prop = prop.substr(0, prop.length - 1);
1854
1855      loader.packages[prop] = loader.packages[prop] || {};
1856
1857      // meta backwards compatibility
1858      if (cfg.packages[p].modules) {
1859        warn.call(loader, 'Package ' + p + ' is configured with "modules", which is deprecated as it has been renamed to "meta".');
1860        cfg.packages[p].meta = cfg.packages[p].modules;
1861        delete cfg.packages[p].modules;
1862      }
1863
1864      for (var q in cfg.packages[p])
1865        if (indexOf.call(packageProperties, q) == -1)
1866          warn.call(loader, '"' + q + '" is not a valid package configuration option in package ' + p);
1867
1868      extendMeta(loader.packages[prop], cfg.packages[p]);
1869    }
1870  }
1871
1872  for (var c in cfg) {
1873    var v = cfg[c];
1874
1875    if (c == 'baseURL' || c == 'map' || c == 'packages' || c == 'bundles' || c == 'paths' || c == 'warnings' || c == 'packageConfigPaths')
1876      continue;
1877
1878    if (typeof v != 'object' || v instanceof Array) {
1879      loader[c] = v;
1880    }
1881    else {
1882      loader[c] = loader[c] || {};
1883
1884      for (var p in v) {
1885        // base-level wildcard meta does not normalize to retain catch-all quality
1886        if (c == 'meta' && p[0] == '*') {
1887          loader[c][p] = v[p];
1888        }
1889        else if (c == 'meta') {
1890          // meta can go through global map
1891          loader[c][loader.decanonicalize(applyMap(p))] = v[p];
1892        }
1893        else if (c == 'depCache') {
1894          var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
1895          var prop = loader.decanonicalize(p);
1896          if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
1897            prop = prop.substr(0, prop.length - 3);
1898          loader[c][prop] = v[p];
1899        }
1900        else {
1901          loader[c][p] = v[p];
1902        }
1903      }
1904    }
1905  }
1906};/*
1907 * Package Configuration Extension
1908 *
1909 * Example:
1910 *
1911 * SystemJS.packages = {
1912 *   jquery: {
1913 *     basePath: 'lib', // optionally only use a subdirectory within the package
1914 *     main: 'index.js', // when not set, package name is requested directly
1915 *     format: 'amd',
1916 *     defaultExtension: 'ts', // defaults to 'js', can be set to false
1917 *     modules: {
1918 *       '*.ts': {
1919 *         loader: 'typescript'
1920 *       },
1921 *       'vendor/sizzle.js': {
1922 *         format: 'global'
1923 *       }
1924 *     },
1925 *     map: {
1926 *        // map internal require('sizzle') to local require('./vendor/sizzle')
1927 *        sizzle: './vendor/sizzle.js',
1928 *        // map any internal or external require of 'jquery/vendor/another' to 'another/index.js'
1929 *        './vendor/another.js': './another/index.js',
1930 *        // test.js / test -> lib/test.js
1931 *        './test.js': './lib/test.js',
1932 *
1933 *        // environment-specific map configurations
1934 *        './index.js': {
1935 *          '~browser': './index-node.js'
1936 *        }
1937 *     },
1938 *     // allows for setting package-prefixed depCache
1939 *     // keys are normalized module names relative to the package itself
1940 *     depCache: {
1941 *       // import 'package/index.js' loads in parallel package/lib/test.js,package/vendor/sizzle.js
1942 *       './index.js': ['./test'],
1943 *       './test.js': ['external-dep'],
1944 *       'external-dep/path.js': ['./another.js']
1945 *     }
1946 *   }
1947 * };
1948 *
1949 * Then:
1950 *   import 'jquery'                       -> jquery/index.js
1951 *   import 'jquery/submodule'             -> jquery/submodule.js
1952 *   import 'jquery/submodule.ts'          -> jquery/submodule.ts loaded as typescript
1953 *   import 'jquery/vendor/another'        -> another/index.js
1954 *
1955 * Detailed Behaviours
1956 * - main can have a leading "./" can be added optionally
1957 * - map and defaultExtension are applied to the main
1958 * - defaultExtension adds the extension only if the exact extension is not present
1959 * - defaultJSExtensions applies after map when defaultExtension is not set
1960 * - if a meta value is available for a module, map and defaultExtension are skipped
1961 * - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
1962 * - condition module map is '@env' module in package or '@system-env' globally
1963 * - map targets support conditional interpolation ('./x': './x.#{|env}.js')
1964 * - internal package map targets cannot use boolean conditionals
1965 *
1966 * In addition, the following modules properties will be allowed to be package
1967 * -relative as well in the package module config:
1968 *
1969 *   - loader
1970 *   - alias
1971 *
1972 *
1973 * Package Configuration Loading
1974 *
1975 * Not all packages may already have their configuration present in the System config
1976 * For these cases, a list of packageConfigPaths can be provided, which when matched against
1977 * a request, will first request a ".json" file by the package name to derive the package
1978 * configuration from. This allows dynamic loading of non-predetermined code, a key use
1979 * case in SystemJS.
1980 *
1981 * Example:
1982 *
1983 *   SystemJS.packageConfigPaths = ['packages/test/package.json', 'packages/*.json'];
1984 *
1985 *   // will first request 'packages/new-package/package.json' for the package config
1986 *   // before completing the package request to 'packages/new-package/path'
1987 *   SystemJS.import('packages/new-package/path');
1988 *
1989 *   // will first request 'packages/test/package.json' before the main
1990 *   SystemJS.import('packages/test');
1991 *
1992 * When a package matches packageConfigPaths, it will always send a config request for
1993 * the package configuration.
1994 * The package name itself is taken to be the match up to and including the last wildcard
1995 * or trailing slash.
1996 * The most specific package config path will be used.
1997 * Any existing package configurations for the package will deeply merge with the
1998 * package config, with the existing package configurations taking preference.
1999 * To opt-out of the package configuration request for a package that matches
2000 * packageConfigPaths, use the { configured: true } package config option.
2001 *
2002 */
2003(function() {
2004
2005  hookConstructor(function(constructor) {
2006    return function() {
2007      constructor.call(this);
2008      this.packages = {};
2009      this.packageConfigPaths = [];
2010    };
2011  });
2012
2013  function getPackage(loader, normalized) {
2014    // use most specific package
2015    var curPkg, curPkgLen = 0, pkgLen;
2016    for (var p in loader.packages) {
2017      if (normalized.substr(0, p.length) === p && (normalized.length === p.length || normalized[p.length] === '/')) {
2018        pkgLen = p.split('/').length;
2019        if (pkgLen > curPkgLen) {
2020          curPkg = p;
2021          curPkgLen = pkgLen;
2022        }
2023      }
2024    }
2025    return curPkg;
2026  }
2027
2028  function getBasePath(pkg) {
2029    // sanitize basePath
2030    var basePath = pkg.basePath && pkg.basePath != '.' ? pkg.basePath : '';
2031    if (basePath) {
2032      if (basePath.substr(0, 2) == './')
2033        basePath = basePath.substr(2);
2034      if (basePath[basePath.length - 1] != '/')
2035        basePath += '/';
2036    }
2037    return basePath;
2038  }
2039
2040  function addDefaultExtension(loader, pkg, pkgName, basePath, subPath, skipExtensions) {
2041    // don't apply extensions to folders or if defaultExtension = false
2042    if (!subPath || subPath[subPath.length - 1] == '/' || skipExtensions || pkg.defaultExtension === false)
2043      return subPath;
2044
2045    // NB are you sure about this?
2046    // skip if we have interpolation conditional syntax in subPath?
2047    if (subPath.match(interpolationRegEx))
2048      return subPath;
2049
2050    var metaMatch = false;
2051
2052    // exact meta or meta with any content after the last wildcard skips extension
2053    if (pkg.meta)
2054      getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
2055        if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
2056          return metaMatch = true;
2057      });
2058
2059    // exact global meta or meta with any content after the last wildcard skips extension
2060    if (!metaMatch && loader.meta)
2061      getMetaMatches(loader.meta, pkgName + '/' + basePath + subPath, function(metaPattern, matchMeta, matchDepth) {
2062        if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
2063          return metaMatch = true;
2064      });
2065
2066    if (metaMatch)
2067      return subPath;
2068
2069    // work out what the defaultExtension is and add if not there already
2070    // NB reconsider if default should really be ".js"?
2071    var defaultExtension = '.' + (pkg.defaultExtension || 'js');
2072    if (subPath.substr(subPath.length - defaultExtension.length) != defaultExtension)
2073      return subPath + defaultExtension;
2074    else
2075      return subPath;
2076  }
2077
2078  function applyPackageConfigSync(loader, pkg, pkgName, subPath, skipExtensions) {
2079    // main
2080    if (!subPath) {
2081      if (pkg.main)
2082        subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
2083      // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
2084      else
2085        // NB can add a default package main convention here when defaultJSExtensions is deprecated
2086        // if it becomes internal to the package then it would no longer be an exit path
2087        return pkgName + (loader.defaultJSExtensions ? '.js' : '');
2088    }
2089
2090    var basePath = getBasePath(pkg);
2091
2092    // map config checking without then with extensions
2093    if (pkg.map) {
2094      var mapPath = './' + subPath;
2095
2096      var mapMatch = getMapMatch(pkg.map, mapPath);
2097
2098      // we then check map with the default extension adding
2099      if (!mapMatch) {
2100        mapPath = './' + addDefaultExtension(loader, pkg, pkgName, basePath, subPath, skipExtensions);
2101        if (mapPath != './' + subPath)
2102          mapMatch = getMapMatch(pkg.map, mapPath);
2103      }
2104      if (mapMatch)
2105        return doMapSync(loader, pkg, pkgName, basePath, mapMatch, mapPath, skipExtensions);
2106    }
2107
2108    // normal package resolution
2109    return pkgName + '/' + basePath + addDefaultExtension(loader, pkg, pkgName, basePath, subPath, skipExtensions);
2110  }
2111
2112  function doMapSync(loader, pkg, pkgName, basePath, mapMatch, path, skipExtensions) {
2113    var mapped = pkg.map[mapMatch];
2114
2115    // ignore conditionals in sync
2116    if (typeof mapped != 'string')
2117      mapped = mapMatch = path;
2118
2119    // package map to main / base-level
2120    if (mapped == '.')
2121      mapped = pkgName;
2122
2123    // internal package map
2124    else if (mapped.substr(0, 2) == './')
2125      return pkgName + '/' + basePath + addDefaultExtension(loader, pkg, pkgName, basePath, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions);
2126    
2127    // external map reference
2128    return loader.normalizeSync(mapped + path.substr(mapMatch.length), pkgName + '/');
2129  }
2130
2131  function applyPackageConfig(loader, pkg, pkgName, subPath, skipExtensions) {
2132    // main
2133    if (!subPath) {
2134      if (pkg.main)
2135        subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
2136      // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
2137      else
2138        // NB can add a default package main convention here when defaultJSExtensions is deprecated
2139        // if it becomes internal to the package then it would no longer be an exit path
2140        return Promise.resolve(pkgName + (loader.defaultJSExtensions ? '.js' : ''));
2141    }
2142
2143    var basePath = getBasePath(pkg);
2144
2145    // map config checking without then with extensions
2146    var mapPath, mapMatch;
2147
2148    if (pkg.map) {
2149      mapPath = './' + subPath;
2150      mapMatch = getMapMatch(pkg.map, mapPath);
2151
2152      // we then check map with the default extension adding
2153      if (!mapMatch) {
2154        mapPath = './' + addDefaultExtension(loader, pkg, pkgName, basePath, subPath, skipExtensions);
2155        if (mapPath != './' + subPath)
2156          mapMatch = getMapMatch(pkg.map, mapPath);
2157      }
2158    }
2159
2160    return (mapMatch ? doMap(loader, pkg, pkgName, basePath, mapMatch, mapPath, skipExtensions) : Promise.resolve())
2161    .then(function(mapped) {
2162      if (mapped)
2163        return Promise.resolve(mapped);
2164
2165      // normal package resolution / fallback resolution for no conditional match
2166      return Promise.resolve(pkgName + '/' + basePath + addDefaultExtension(loader, pkg, pkgName, basePath, subPath, skipExtensions));
2167    });
2168  }
2169
2170  function doStringMap(loader, pkg, pkgName, basePath, mapMatch, mapped, path, skipExtensions) {
2171    // NB the interpolation cases should strictly skip subsequent interpolation
2172
2173    // package map to main / base-level
2174    if (mapped == '.')
2175      mapped = pkgName;
2176    
2177    // internal package map
2178    else if (mapped.substr(0, 2) == './')
2179      return Promise.resolve(pkgName + '/' + basePath + addDefaultExtension(loader, pkg, pkgName, basePath, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions))
2180      .then(function(name) {
2181        return interpolateConditional.call(loader, name, pkgName + '/');
2182      });
2183    
2184    // external map reference
2185    // NB deprecate the use of the second argument here -> should be fully global reference
2186    return loader.normalize(mapped + path.substr(mapMatch.length), pkgName + '/');
2187  }
2188
2189  function doMap(loader, pkg, pkgName, basePath, mapMatch, path, skipExtensions) {
2190    var mapped = pkg.map[mapMatch];
2191
2192    if (typeof mapped == 'string')
2193      return doStringMap(loader, pkg, pkgName, basePath, mapMatch, mapped, path, skipExtensions);
2194
2195    // we use a special conditional syntax to allow the builder to handle conditional branch points further
2196    if (loader.builder)
2197      return Promise.resolve(pkgName + '/#:' + path);
2198
2199    // map object -> conditional map
2200    return loader['import'](pkg.map['@env'] || '@system-env', pkgName)
2201    .then(function(env) {
2202      // first map condition to match is used
2203      for (var e in mapped) {
2204        var negate = e[0] == '~';
2205
2206        var value = readMemberExpression(negate ? e.substr(1) : e, env);
2207
2208        if (!negate && value || negate && !value)
2209          return mapped[e];
2210      }
2211    })
2212    .then(function(mapped) {
2213      if (mapped)
2214        return doStringMap(loader, pkg, pkgName, basePath, mapMatch, mapped, path, skipExtensions);
2215
2216      // no environment match -> fallback to original subPath by returning undefined
2217    });
2218  }
2219
2220  // normalizeSync = decanonicalize + package resolution
2221  SystemJSLoader.prototype.normalizeSync = SystemJSLoader.prototype.decanonicalize = SystemJSLoader.prototype.normalize;
2222
2223  // decanonicalize must JUST handle package defaultExtension: false case when defaultJSExtensions is set
2224  // to be deprecated!
2225  hook('decanonicalize', function(decanonicalize) {
2226    return function(name, parentName) {
2227      if (this.builder)
2228        return decanonicalize.call(this, name, parentName, true);
2229
2230      var decanonicalized = decanonicalize.call(this, name, parentName);
2231
2232      if (!this.defaultJSExtensions)
2233        return decanonicalized;
2234    
2235      var pkgName = getPackage(this, decanonicalized);
2236
2237      var pkg = this.packages[pkgName];
2238      var defaultExtension = pkg && pkg.defaultExtension;
2239
2240      if (defaultExtension == undefined && pkg && pkg.meta)
2241        getMetaMatches(pkg.meta, decanonicalized.substr(pkgName), function(metaPattern, matchMeta, matchDepth) {
2242          if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1) {
2243            defaultExtension = false;
2244            return true;
2245          }
2246        });
2247      
2248      if ((defaultExtension === false || defaultExtension && defaultExtension != '.js') && name.substr(name.length - 3, 3) != '.js' && decanonicalized.substr(decanonicalized.length - 3, 3) == '.js')
2249        decanonicalized = decanonicalized.substr(0, decanonicalized.length - 3);
2250
2251      return decanonicalized;
2252    };
2253  });
2254
2255  hook('normalizeSync', function(normalizeSync) {
2256    return function(name, parentName, isPlugin) {
2257      warn.call(this, 'SystemJS.normalizeSync has been deprecated for SystemJS.decanonicalize.');
2258
2259      var loader = this;
2260      isPlugin = isPlugin === true;
2261
2262      // apply contextual package map first
2263      // (we assume the parent package config has already been loaded)
2264      if (parentName)
2265        var parentPackageName = getPackage(loader, parentName) ||
2266            loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
2267            getPackage(loader, parentName.substr(0, parentName.length - 3));
2268
2269      var parentPackage = parentPackageName && loader.packages[parentPackageName];
2270
2271      // remove any parent basePath from parentName
2272      if (parentPackage) {
2273        var parentBasePath = getBasePath(parentPackage);
2274        if (parentBasePath && parentName.substr(parentPackageName.length + 1, parentBasePath.length) == parentBasePath)
2275          parentName = parentPackageName + parentName.substr(parentPackageName.length + parentBasePath.length);
2276      }
2277
2278      // ignore . since internal maps handled by standard package resolution
2279      if (parentPackage && name[0] != '.') {
2280        var parentMap = parentPackage.map;
2281        var parentMapMatch = parentMap && getMapMatch(parentMap, name);
2282
2283        if (parentMapMatch && typeof parentMap[parentMapMatch] == 'string')
2284          return doMapSync(loader, parentPackage, parentPackageName, getBasePath(parentPackage), parentMapMatch, name, isPlugin);
2285      }
2286
2287      var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
2288
2289      // apply map, core, paths, contextual package map
2290      var normalized = normalizeSync.call(loader, name, parentName);
2291
2292      // undo defaultJSExtension
2293      if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
2294        defaultJSExtension = false;
2295      if (defaultJSExtension)
2296        normalized = normalized.substr(0, normalized.length - 3);
2297
2298      var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
2299      var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
2300
2301      if (!pkgName)
2302        return normalized + (defaultJSExtension ? '.js' : '');
2303
2304      var subPath = normalized.substr(pkgName.length + 1);
2305
2306      return applyPackageConfigSync(loader, loader.packages[pkgName] || {}, pkgName, subPath, isPlugin);
2307    };
2308  });
2309
2310  hook('normalize', function(normalize) {
2311    return function(name, parentName, isPlugin) {
2312      var loader = this;
2313      isPlugin = isPlugin === true;
2314
2315      return Promise.resolve()
2316      .then(function() {
2317        // apply contextual package map first
2318        // (we assume the parent package config has already been loaded)
2319        if (parentName)
2320          var parentPackageName = getPackage(loader, parentName) ||
2321              loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
2322              getPackage(loader, parentName.substr(0, parentName.length - 3));
2323
2324        var parentPackage = parentPackageName && loader.packages[parentPackageName];
2325
2326        // remove any parent basePath from parentName
2327        if (parentPackage) {
2328          var parentBasePath = getBasePath(parentPackage);
2329          if (parentBasePath && parentName.substr(parentPackageName.length + 1, parentBasePath.length) == parentBasePath)
2330            parentName = parentPackageName + parentName.substr(parentPackageName.length + parentBasePath.length);
2331        }
2332
2333        // ignore . since internal maps handled by standard package resolution
2334        if (parentPackage && name.substr(0, 2) != './') {
2335          var parentMap = parentPackage.map;
2336          var parentMapMatch = parentMap && getMapMatch(parentMap, name);
2337
2338          if (parentMapMatch)
2339            return doMap(loader, parentPackage, parentPackageName, parentBasePath, parentMapMatch, name, isPlugin);
2340        }
2341
2342        return Promise.resolve();
2343      })
2344      .then(function(mapped) {
2345        if (mapped)
2346          return mapped;
2347
2348        var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
2349
2350        // apply map, core, paths, contextual package map
2351        var normalized = normalize.call(loader, name, parentName);
2352
2353        // undo defaultJSExtension
2354        if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
2355          defaultJSExtension = false;
2356        if (defaultJSExtension)
2357          normalized = normalized.substr(0, normalized.length - 3);
2358
2359        var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
2360        var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
2361
2362        if (!pkgName)
2363          return Promise.resolve(normalized + (defaultJSExtension ? '.js' : ''));
2364
2365        var pkg = loader.packages[pkgName];
2366
2367        // if package is already configured or not a dynamic config package, use existing package config
2368        var isConfigured = pkg && (pkg.configured || !pkgConfigMatch);
2369        return (isConfigured ? Promise.resolve(pkg) : loadPackageConfigPath(loader, pkgName, pkgConfigMatch.configPath))
2370        .then(function(pkg) {
2371          var subPath = normalized.substr(pkgName.length + 1);
2372
2373          return applyPackageConfig(loader, pkg, pkgName, subPath, isPlugin);
2374        });
2375      });
2376    };
2377  });
2378
2379  // check if the given normalized name matches a packageConfigPath
2380  // if so, loads the config
2381  var packageConfigPaths = {};
2382
2383  // data object for quick checks against package paths
2384  function createPkgConfigPathObj(path) {
2385    var lastWildcard = path.lastIndexOf('*');
2386    var length = Math.max(lastWildcard + 1, path.lastIndexOf('/'));
2387    return {
2388      length: length,
2389      // NB handle regex control character escapes or simply create a test function here
2390      regEx: new RegExp('^(' + path.substr(0, length).replace(/\*/g, '[^\\/]+') + ')(\\/|$)'),
2391      wildcard: lastWildcard != -1
2392    };
2393  }
2394
2395  // most specific match wins
2396  function getPackageConfigMatch(loader, normalized) {
2397    var pkgName, exactMatch = false, configPath;
2398    for (var i = 0; i < loader.packageConfigPaths.length; i++) {
2399      var packageConfigPath = loader.packageConfigPaths[i];
2400      var p = packageConfigPaths[packageConfigPath] || (packageConfigPaths[packageConfigPath] = createPkgConfigPathObj(packageConfigPath));
2401      if (normalized.length < p.length)
2402        continue;
2403      var match = normalized.match(p.regEx);
2404      if (match && (!pkgName || (!(exactMatch && p.wildcard) && pkgName.length < match[1].length))) {
2405        pkgName = match[1];
2406        exactMatch = !p.wildcard;
2407        configPath = pkgName + packageConfigPath.substr(p.length);
2408      }
2409    }
2410
2411    if (!pkgName)
2412      return;
2413
2414    return {
2415      packageName: pkgName,
2416      configPath: configPath
2417    };
2418  }
2419
2420  function loadPackageConfigPath(loader, pkgName, pkgConfigPath) {
2421    var configLoader = loader.pluginLoader || loader;
2422
2423    // NB remove this when json is default
2424    (configLoader.meta[pkgConfigPath] = configLoader.meta[pkgConfigPath] || {}).format = 'json';
2425
2426    return configLoader.load(pkgConfigPath)
2427    .then(function() {
2428      pkgConfig = configLoader.get(pkgConfigPath);
2429
2430      var cfg = pkgConfig['default'];
2431
2432      // support "systemjs" prefixing
2433      if (cfg.systemjs)
2434        cfg = cfg.systemjs;
2435
2436      // modules backwards compatibility
2437      if (cfg.modules) {
2438        cfg.meta = cfg.modules;
2439        warn.call(loader, 'Package config file ' + pkgConfigPath + ' is configured with "modules", which is deprecated as it has been renamed to "meta".');
2440      }
2441
2442      // remove any non-system properties if generic config file (eg package.json)
2443      for (var p in cfg) {
2444        if (indexOf.call(packageProperties, p) == -1)
2445          delete cfg[p];
2446      }
2447
2448      // deeply-merge (to first level) config with any existing package config
2449      var pkg = loader.packages[pkgName] = loader.packages[pkgName] || {};
2450      extendMeta(pkg, cfg, true);
2451
2452      // support external depCache
2453      var basePath = getBasePath(pkg);
2454      if (cfg.depCache) {
2455        for (var d in cfg.depCache) {
2456          var dNormalized;
2457
2458          if (d.substr(0, 2) == './')
2459            dNormalized = pkgName + '/' + basePath + d.substr(2);
2460          else
2461            dNormalized = coreResolve.call(loader, d);
2462          loader.depCache[dNormalized] = (loader.depCache[dNormalized] || []).concat(cfg.depCache[d]);
2463        }
2464        delete cfg.depCache;
2465      }
2466
2467      return pkg;
2468    });
2469  }
2470
2471  function getMetaMatches(pkgMeta, subPath, matchFn) {
2472    // wildcard meta
2473    var meta = {};
2474    var wildcardIndex;
2475    for (var module in pkgMeta) {
2476      // allow meta to start with ./ for flexibility
2477      var dotRel = module.substr(0, 2) == './' ? './' : '';
2478      if (dotRel)
2479        module = module.substr(2);
2480
2481      wildcardIndex = module.indexOf('*');
2482      if (wildcardIndex === -1)
2483        continue;
2484
2485      if (module.substr(0, wildcardIndex) == subPath.substr(0, wildcardIndex)
2486          && module.substr(wildcardIndex + 1) == subPath.substr(subPath.length - module.length + wildcardIndex + 1)) {
2487        // alow match function to return true for an exit path
2488        if (matchFn(module, pkgMeta[dotRel + module], module.split('/').length))
2489          return;
2490      }
2491    }
2492    // exact meta
2493    var exactMeta = pkgMeta[subPath] || pkgMeta['./' + subPath];
2494    if (exactMeta)
2495      matchFn(exactMeta, exactMeta, 0);
2496  }
2497
2498  hook('locate', function(locate) {
2499    return function(load) {
2500      var loader = this;
2501      return Promise.resolve(locate.call(this, load))
2502      .then(function(address) {
2503        var pkgName = getPackage(loader, load.name);
2504        if (pkgName) {
2505          var pkg = loader.packages[pkgName];
2506          var basePath = getBasePath(pkg);
2507          var subPath = load.name.substr(pkgName.length + basePath.length + 1);
2508
2509          // format
2510          if (pkg.format)
2511            load.metadata.format = load.metadata.format || pkg.format;
2512
2513          var meta = {};
2514          if (pkg.meta) {
2515            var bestDepth = 0;
2516
2517            // NB support a main shorthand in meta here?
2518            getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
2519              if (matchDepth > bestDepth)
2520                bestDepth = matchDepth;
2521              extendMeta(meta, matchMeta, matchDepth && bestDepth >
2521 matchDepth);
2522            });
2523
2524            // allow alias and loader to be package-relative
2525            if (meta.alias && meta.alias.substr(0, 2) == './')
2526              meta.alias = pkgName + meta.alias.substr(1);
2527            if (meta.loader && meta.loader.substr(0, 2) == './')
2528              meta.loader = pkgName + meta.loader.substr(1);
2529            extendMeta(load.metadata, meta);
2530          }
2531        }
2532
2533        return address;
2534      });
2535    };
2536  });
2537
2538})();
2539/*
2540 * Script tag fetch
2541 *
2542 * When load.metadata.scriptLoad is true, we load via script tag injection.
2543 */
2544(function() {
2545
2546  if (typeof document != 'undefined')
2547    var head = document.getElementsByTagName('head')[0];
2548
2549  var curSystem;
2550
2551  // if doing worker executing, this is set to the load record being executed
2552  var workerLoad = null;
2553  
2554  // interactive mode handling method courtesy RequireJS
2555  var ieEvents = head && (function() {
2556    var s = document.createElement('script');
2557    var isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]';
2558    return s.attachEvent && !(s.attachEvent.toString && s.attachEvent.toString().indexOf('[native code') < 0) && !isOpera;
2559  })();
2560
2561  // IE interactive-only part
2562  // we store loading scripts array as { script: <script>, load: {...} }
2563  var interactiveLoadingScripts = [];
2564  var interactiveScript;
2565  function getInteractiveScriptLoad() {
2566    if (interactiveScript && interactiveScript.script.readyState === 'interactive')
2567      return interactiveScript.load;
2568
2569    for (var i = 0; i < interactiveLoadingScripts.length; i++)
2570      if (interactiveLoadingScripts[i].script.readyState == 'interactive') {
2571        interactiveScript = interactiveLoadingScripts[i];
2572        return interactiveScript.load;
2573      }
2574  }
2575  
2576  // System.register, System.registerDynamic, AMD define pipeline
2577  // this is called by the above methods when they execute
2578  // we then run the reduceRegister_ collection function either immediately
2579  // if we are in IE and know the currently executing script (interactive)
2580  // or later if we need to wait for the synchronous load callback to know the script
2581  var loadingCnt = 0;
2582  var registerQueue = [];
2583  hook('pushRegister_', function(pushRegister) {
2584    return function(register) {
2585      // if using eval-execution then skip
2586      if (pushRegister.call(this, register))
2587        return false;
2588
2589      // if using worker execution, then we're done
2590      if (workerLoad)
2591        this.reduceRegister_(workerLoad, register);
2592
2593      // detect if we know the currently executing load (IE)
2594      // if so, immediately call reduceRegister
2595      else if (ieEvents)
2596        this.reduceRegister_(getInteractiveScriptLoad(), register);
2597
2598      // otherwise, add to our execution queue
2599      // to call reduceRegister on sync script load event
2600      else if (loadingCnt)
2601        registerQueue.push(register);
2602
2603      // if we're not currently loading anything though
2604      // then do the reduction against a null load
2605      // (out of band named define or named register)
2606      // note even in non-script environments, this catch is used
2607      else
2608        this.reduceRegister_(null, register);
2609
2610      return true;
2611    };
2612  });
2613
2614  function webWorkerImport(loader, load) {
2615    return new Promise(function(resolve, reject) {
2616      if (load.metadata.integrity)
2617        reject(new Error('Subresource integrity checking is not supported in web workers.'));
2618
2619      workerLoad = load;
2620      try {
2621        importScripts(load.address);
2622      }
2623      catch(e) {
2624        workerLoad = null;
2625        reject(e);
2626      }
2627      workerLoad = null;
2628
2629      // if nothing registered, then something went wrong
2630      if (!load.metadata.entry)
2631        reject(new Error(load.address + ' did not call System.register or AMD define'));
2632
2633      resolve('');
2634    });
2635  }
2636
2637  // override fetch to use script injection
2638  hook('fetch', function(fetch) {
2639    return function(load) {
2640      var loader = this;
2641
2642      if (load.metadata.format == 'json' || !load.metadata.scriptLoad || (!isBrowser && !isWorker))
2643        return fetch.call(this, load);
2644
2645      if (isWorker)
2646        return webWorkerImport(loader, load);
2647
2648      return new Promise(function(resolve, reject) {
2649        var s = document.createElement('script');
2650        
2651        s.async = true;
2652        
2653        if (load.metadata.integrity)
2654          s.setAttribute('integrity', load.metadata.integrity);
2655
2656        if (ieEvents) {
2657          s.attachEvent('onreadystatechange', complete);
2658          interactiveLoadingScripts.push({
2659            script: s,
2660            load: load
2661          });
2662        }
2663        else {
2664          s.addEventListener('load', complete, false);
2665          s.addEventListener('error', error, false);
2666        }
2667
2668        loadingCnt++;
2669
2670        curSystem = __global.System;
2671
2672        s.src = load.address;
2673        head.appendChild(s);
2674
2675        function complete(evt) {
2676          if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete')
2677            return;
2678
2679          loadingCnt--;
2680
2681          // complete call is sync on execution finish
2682          // (in ie already done reductions)
2683          if (!load.metadata.entry && !registerQueue.length) {
2684            loader.reduceRegister_(load);
2685          }
2686          else if (!ieEvents) {
2687            for (var i = 0; i < registerQueue.length; i++)
2688              loader.reduceRegister_(load, registerQueue[i]);
2689            registerQueue = [];
2690          }
2691
2692          cleanup();
2693
2694          // if nothing registered, then something went wrong
2695          if (!load.metadata.entry && !load.metadata.bundle)
2696            reject(new Error(load.name + ' did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.'));
2697
2698          resolve('');
2699        }
2700
2701        function error(evt) {
2702          cleanup();
2703          reject(new Error('Unable to load script ' + load.address));
2704        }
2705
2706        function cleanup() {
2707          __global.System = curSystem;
2708
2709          if (s.detachEvent) {
2710            s.detachEvent('onreadystatechange', complete);
2711            for (var i = 0; i < interactiveLoadingScripts.length; i++)
2712              if (interactiveLoadingScripts[i].script == s) {
2713                if (interactiveScript && interactiveScript.script == s)
2714                  interactiveScript = null;
2715                interactiveLoadingScripts.splice(i, 1);
2716              }
2717          }
2718          else {
2719            s.removeEventListener('load', complete, false);
2720            s.removeEventListener('error', error, false);
2721          }
2722
2723          head.removeChild(s);
2724        }
2725      });
2726    };
2727  });
2728})();
2729/*
2730 * Instantiate registry extension
2731 *
2732 * Supports Traceur System.register 'instantiate' output for loading ES6 as ES5.
2733 *
2734 * - Creates the loader.register function
2735 * - Also supports metadata.format = 'register' in instantiate for anonymous register modules
2736 * - Also supports metadata.deps, metadata.execute and metadata.executingRequire
2737 *     for handling dynamic modules alongside register-transformed ES6 modules
2738 *
2739 *
2740 * The code here replicates the ES6 linking groups algorithm to ensure that
2741 * circular ES6 compiled into System.register can work alongside circular AMD 
2742 * and CommonJS, identically to the actual ES6 loader.
2743 *
2744 */
2745
2746
2747/*
2748 * Registry side table entries in loader.defined
2749 * Registry Entry Contains:
2750 *    - name
2751 *    - deps 
2752 *    - declare for declarative modules
2753 *    - execute for dynamic modules, different to declarative execute on module
2754 *    - executingRequire indicates require drives execution for circularity of dynamic modules
2755 *    - declarative optional boolean indicating which of the above
2756 *
2757 * Can preload modules directly on SystemJS.defined['my/module'] = { deps, execute, executingRequire }
2758 *
2759 * Then the entry gets populated with derived information during processing:
2760 *    - normalizedDeps derived from deps, created in instantiate
2761 *    - groupIndex used by group linking algorithm
2762 *    - evaluated indicating whether evaluation has happend
2763 *    - module the module record object, containing:
2764 *      - exports actual module exports
2765 *
2766 *    For dynamic we track the es module with:
2767 *    - esModule actual es module value
2768 *    - esmExports whether to extend the esModule with named exports
2769 *      
2770 *    Then for declarative only we track dynamic bindings with the 'module' records:
2771 *      - name
2772 *      - exports
2773 *      - setters declarative setter functions
2774 *      - dependencies, module records of dependencies
2775 *      - importers, module records of dependents
2776 *
2777 * After linked and evaluated, entries are removed, declarative module records remain in separate
2778 * module binding table
2779 *
2780 */
2781
2782var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;
2783function detectRegisterFormat(source) {
2784  var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx);
2785  return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register';
2786}
2787
2788function createEntry() {
2789  return {
2790    name: null,
2791    deps: null,
2792    originalIndices: null,
2793    declare: null,
2794    execute: null,
2795    executingRequire: false,
2796    declarative: false,
2797    normalizedDeps: null,
2798    groupIndex: null,
2799    evaluated: false,
2800    module: null,
2801    esModule: null,
2802    esmExports: false
2803  };
2804}
2805
2806(function() {
2807
2808  /*
2809   * There are two variations of System.register:
2810   * 1. System.register for ES6 conversion (2-3 params) - System.register([name, ]deps, declare)
2811   *    see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
2812   *
2813   * 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
2814   * the true or false statement 
2815   *
2816   * this extension implements the linking algorithm for the two variations identical to the spec
2817   * allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
2818   *
2819   */
2820  SystemJSLoader.prototype.register = function(name, deps, declare) {
2821    if (typeof name != 'string') {
2822      declare = deps;
2823      deps = name;
2824      name = null;
2825    }
2826
2827    // dynamic backwards-compatibility
2828    // can be deprecated eventually
2829    if (typeof declare == 'boolean')
2830      return this.registerDynamic.apply(this, arguments);
2831
2832    var entry = createEntry();
2833    // ideally wouldn't apply map config to bundle names but 
2834    // dependencies go through map regardless so we can't restrict
2835    // could reconsider in shift to new spec
2836    entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
2837    entry.declarative = true;
2838    entry.deps = deps;
2839    entry.declare = declare;
2840
2841    this.pushRegister_({
2842      amd: false,
2843      entry: entry
2844    });
2845  };
2846  SystemJSLoader.prototype.registerDynamic = function(name, deps, declare, execute) {
2847    if (typeof name != 'string') {
2848      execute = declare;
2849      declare = deps;
2850      deps = name;
2851      name = null;
2852    }
2853
2854    // dynamic
2855    var entry = createEntry();
2856    entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
2857    entry.deps = deps;
2858    entry.execute = execute;
2859    entry.executingRequire = declare;
2860
2861    this.pushRegister_({
2862      amd: false,
2863      entry: entry
2864    });
2865  };
2866  hook('reduceRegister_', function() {
2867    return function(load, register) {
2868      if (!register)
2869        return;
2870
2871      var entry = register.entry;
2872      var curMeta = load && load.metadata;
2873
2874      // named register
2875      if (entry.name) {
2876        if (!(entry.name in this.defined))
2877          this.defined[entry.name] = entry;
2878
2879        if (curMeta)
2880          curMeta.bundle = true;
2881      }
2882      // anonymous register
2883      if (!entry.name || load && entry.name == load.name) {
2884        if (!curMeta)
2885          throw new TypeError('Unexpected anonymous System.register call.');
2886        if (curMeta.entry) {
2887          if (curMeta.format == 'register')
2888            throw new Error('Multiple anonymous System.register calls in module ' + load.name + '. If loading a bundle, ensure all the System.register calls are named.');
2889          else
2890            throw new Error('Module ' + load.name + ' interpreted as ' + curMeta.format + ' module format, but called System.register.');
2891        }
2892        if (!curMeta.format)
2893          curMeta.format = 'register';
2894        curMeta.entry = entry;
2895      }
2896    };
2897  });
2898
2899  hookConstructor(function(constructor) {
2900    return function() {
2901      constructor.call(this);
2902
2903      this.defined = {};
2904      this._loader.moduleRecords = {};
2905    };
2906  });
2907
2908  function buildGroups(entry, loader, groups) {
2909    groups[entry.groupIndex] = groups[entry.groupIndex] || [];
2910
2911    if (indexOf.call(groups[entry.groupIndex], entry) != -1)
2912      return;
2913
2914    groups[entry.groupIndex].push(entry);
2915
2916    for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
2917      var depName = entry.normalizedDeps[i];
2918      var depEntry = loader.defined[depName];
2919      
2920      // not in the registry means already linked / ES6
2921      if (!depEntry || depEntry.evaluated)
2922        continue;
2923      
2924      // now we know the entry is in our unlinked linkage group
2925      var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
2926
2927      // the group index of an entry is always the maximum
2928      if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
2929        
2930        // if already in a group, remove from the old group
2931        if (depEntry.groupIndex !== null) {
2932          groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
2933
2934          // if the old group is empty, then we have a mixed depndency cycle
2935          if (groups[depEntry.groupIndex].length == 0)
2936            throw new Error("Mixed dependency cycle detected");
2937        }
2938
2939        depEntry.groupIndex = depGroupIndex;
2940      }
2941
2942      buildGroups(depEntry, loader, groups);
2943    }
2944  }
2945
2946  function link(name, loader) {
2947    var startEntry = loader.defined[name];
2948
2949    // skip if already linked
2950    if (startEntry.module)
2951      return;
2952
2953    startEntry.groupIndex = 0;
2954
2955    var groups = [];
2956
2957    buildGroups(startEntry, loader, groups);
2958
2959    var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
2960    for (var i = groups.length - 1; i >= 0; i--) {
2961      var group = groups[i];
2962      for (var j = 0; j < group.length; j++) {
2963        var entry = group[j];
2964
2965        // link each group
2966        if (curGroupDeclarative)
2967          linkDeclarativeModule(entry, loader);
2968        else
2969          linkDynamicModule(entry, loader);
2970      }
2971      curGroupDeclarative = !curGroupDeclarative; 
2972    }
2973  }
2974
2975  // module binding records
2976  function Module() {}
2977  defineProperty(Module, 'toString', {
2978    value: function() {
2979      return 'Module';
2980    }
2981  });
2982
2983  function getOrCreateModuleRecord(name, moduleRecords) {
2984    return moduleRecords[name] || (moduleRecords[name] = {
2985      name: name,
2986      dependencies: [],
2987      exports: new Module(), // start from an empty module and extend
2988      importers: []
2989    });
2990  }
2991
2992  function linkDeclarativeModule(entry, loader) {
2993    // only link if already not already started linking (stops at circular)
2994    if (entry.module)
2995      return;
2996
2997    var moduleRecords = loader._loader.moduleRecords;
2998    var module = entry.module = getOrCreateModuleRecord(entry.name, moduleRecords);
2999    var exports = entry.module.exports;
3000
3001    var declaration = entry.declare.call(__global, function(name, value) {
3002      module.locked = true;
3003
3004      if (typeof name == 'object') {
3005        for (var p in name)
3006          exports[p] = name[p];
3007      }
3008      else {
3009        exports[name] = value;
3010      }
3011
3012      for (var i = 0, l = module.importers.length; i < l; i++) {
3013        var importerModule = module.importers[i];
3014        if (!importerModule.locked) {
3015          var importerIndex = indexOf.call(importerModule.dependencies, module);
3016          importerModule.setters[importerIndex](exports);
3017        }
3018      }
3019
3020      module.locked = false;
3021      return value;
3022    }, { id: entry.name });
3023    
3024    module.setters = declaration.setters;
3025    module.execute = declaration.execute;
3026
3027    if (!module.setters || !module.execute) {
3028      throw new TypeError('Invalid System.register form for ' + entry.name);
3029    }
3030
3031    // now link all the module dependencies
3032    for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
3033      var depName = entry.normalizedDeps[i];
3034      var depEntry = loader.defined[depName];
3035      var depModule = moduleRecords[depName];
3036
3037      // work out how to set depExports based on scenarios...
3038      var depExports;
3039
3040      if (depModule) {
3041        depExports = depModule.exports;
3042      }
3043      // dynamic, already linked in our registry
3044      else if (depEntry && !depEntry.declarative) {
3045        depExports = depEntry.esModule;
3046      }
3047      // in the loader registry
3048      else if (!depEntry) {
3049        depExports = loader.get(depName);
3050      }
3051      // we have an entry -> link
3052      else {
3053        linkDeclarativeModule(depEntry, loader);
3054        depModule = depEntry.module;
3055        depExports = depModule.exports;
3056      }
3057
3058      // only declarative modules have dynamic bindings
3059      if (depModule && depModule.importers) {
3060        depModule.importers.push(module);
3061        module.dependencies.push(depModule);
3062      }
3063      else {
3064        module.dependencies.push(null);
3065      }
3066      
3067      // run setters for all entries with the matching dependency name
3068      var originalIndices = entry.originalIndices[i];
3069      for (var j = 0, len = originalIndices.length; j < len; ++j) {
3070        var index = originalIndices[j];
3071        if (module.setters[index]) {
3072          module.setters[index](depExports);
3073        }
3074      }
3075    }
3076  }
3077
3078  // An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
3079  function getModule(name, loader) {
3080    var exports;
3081    var entry = loader.defined[name];
3082
3083    if (!entry) {
3084      exports = loader.get(name);
3085      if (!exports)
3086        throw new Error('Unable to load dependency ' + name + '.');
3087    }
3088
3089    else {
3090      if (entry.declarative)
3091        ensureEvaluated(name, [], loader);
3092    
3093      else if (!entry.evaluated)
3094        linkDynamicModule(entry, loader);
3095
3096      exports = entry.module.exports;
3097    }
3098
3099    if ((!entry || entry.declarative) && exports && exports.__useDefault)
3100      return exports['default'];
3101    
3102    return exports;
3103  }
3104
3105  function linkDynamicModule(entry, loader) {
3106    if (entry.module)
3107      return;
3108
3109    var exports = {};
3110
3111    var module = entry.module = { exports: exports, id: entry.name };
3112
3113    // AMD requires execute the tree first
3114    if (!entry.executingRequire) {
3115      for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
3116        var depName = entry.normalizedDeps[i];
3117        // we know we only need to link dynamic due to linking algorithm
3118        var depEntry = loader.defined[depName];
3119        if (depEntry)
3120          linkDynamicModule(depEntry, loader);
3121      }
3122    }
3123
3124    // now execute
3125    entry.evaluated = true;
3126    var output = entry.execute.call(__global, function(name) {
3127      for (var i = 0, l = entry.deps.length; i < l; i++) {
3128        if (entry.deps[i] != name)
3129          continue;
3130        return getModule(entry.normalizedDeps[i], loader);
3131      }
3132      throw new Error('Module ' + name + ' not declared as a dependency.');
3133    }, exports, module);
3134    
3135    if (output)
3136      module.exports = output;
3137
3138    // create the esModule object, which allows ES6 named imports of dynamics
3139    exports = module.exports;
3140
3141    // __esModule flag treats as already-named
3142    if (exports && exports.__esModule)
3143      entry.esModule = exports;
3144    // set module as 'default' export, then fake named exports by iterating properties
3145    else if (entry.esmExports && exports !== __global)
3146      entry.esModule = getESModule(exports);
3147    // just use the 'default' export
3148    else
3149      entry.esModule = { 'default': exports };
3150  }
3151
3152  /*
3153   * Given a module, and the list of modules for this current branch,
3154   *  ensure that each of the dependencies of this module is evaluated
3155   *  (unless one is a circular dependency already in the list of seen
3156   *  modules, in which case we execute it)
3157   *
3158   * Then we evaluate the module itself depth-first left to right 
3159   * execution to match ES6 modules
3160   */
3161  function ensureEvaluated(moduleName, seen, loader) {
3162    var entry = loader.defined[moduleName];
3163
3164    // if already seen, that means it's an already-evaluated non circular dependency
3165    if (!entry || entry.evaluated || !entry.declarative)
3166      return;
3167
3168    // this only applies to declarative modules which late-execute
3169
3170    seen.push(moduleName);
3171
3172    for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
3173      var depName = entry.normalizedDeps[i];
3174      if (indexOf.call(seen, depName) == -1) {
3175        if (!loader.defined[depName])
3176          loader.get(depName);
3177        else
3178          ensureEvaluated(depName, seen, loader);
3179      }
3180    }
3181
3182    if (entry.evaluated)
3183      return;
3184
3185    entry.evaluated = true;
3186    entry.module.execute.call(__global);
3187  }
3188
3189  // override the delete method to also clear the register caches
3190  hook('delete', function(del) {
3191    return function(name) {
3192      delete this._loader.moduleRecords[name];
3193      delete this.defined[name];
3194      return del.call(this, name);
3195    };
3196  });
3197
3198  hook('fetch', function(fetch) {
3199    return function(load) {
3200      if (this.defined[load.name]) {
3201        load.metadata.format = 'defined';
3202        return '';
3203      }
3204
3205      load.metadata.deps = load.metadata.deps || [];
3206      
3207      return fetch.call(this, load);
3208    };
3209  });
3210
3211  hook('translate', function(translate) {
3212    // we run the meta detection here (register is after meta)
3213    return function(load) {
3214      load.metadata.deps = load.metadata.deps || [];
3215      return Promise.resolve(translate.call(this, load)).then(function(source) {
3216        // run detection for register format
3217        if (load.metadata.format == 'register' || !load.metadata.format && detectRegisterFormat(load.source))
3218          load.metadata.format = 'register';
3219        return source;
3220      });
3221    };
3222  });
3223
3224  hook('instantiate', function(instantiate) {
3225    return function(load) {
3226      if (load.metadata.format == 'detect')
3227        load.metadata.format = undefined;
3228
3229      // assumes previous instantiate is sync
3230      // (core json support)
3231      instantiate.call(this, load);
3232
3233      var loader = this;
3234
3235      var entry;
3236
3237      // first we check if this module has already been defined in the registry
3238      if (loader.defined[load.name]) {
3239        entry = loader.defined[load.name];
3240        // don't support deps for ES modules
3241        if (!entry.declarative)
3242          entry.deps = entry.deps.concat(load.metadata.deps);
3243      }
3244
3245      // picked up already by an anonymous System.register script injection
3246      // or via the dynamic formats
3247      else if (load.metadata.entry) {
3248        entry = load.metadata.entry;
3249        entry.deps = entry.deps.concat(load.metadata.deps);
3250      }
3251
3252      // Contains System.register calls
3253      // (dont run bundles in the builder)
3254      else if (!(loader.builder && load.metadata.bundle) 
3255          && (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
3256        
3257        if (typeof __exec != 'undefined')
3258          __exec.call(loader, load);
3259
3260        if (!load.metadata.entry && !load.metadata.bundle)
3261          throw new Error(load.name + ' detected as ' + load.metadata.format + ' but didn\'t execute.');
3262
3263        entry = load.metadata.entry;
3264
3265        // support metadata deps for System.register
3266        if (entry && load.metadata.deps)
3267          entry.deps = entry.deps.concat(load.metadata.deps);
3268      }
3269
3270      // named bundles are just an empty module
3271      if (!entry) {
3272        entry = createEntry();
3273        entry.deps = load.metadata.deps;
3274        entry.execute = function() {};
3275      }
3276
3277      // place this module onto defined for circular references
3278      loader.defined[load.name] = entry;
3279      
3280      var grouped = group(entry.deps);
3281      
3282      entry.deps = grouped.names;
3283      entry.originalIndices = grouped.indices;
3284      entry.name = load.name;
3285      entry.esmExports = load.metadata.esmExports !== false;
3286
3287      // first, normalize all dependencies
3288      var normalizePromises = [];
3289      for (var i = 0, l = entry.deps.length; i < l; i++)
3290        normalizePromises.push(Promise.resolve(loader.normalize(entry.deps[i], load.name)));
3291
3292      return Promise.all(normalizePromises).then(function(normalizedDeps) {
3293
3294        entry.normalizedDeps = normalizedDeps;
3295
3296        return {
3297          deps: entry.deps,
3298          execute: function() {
3299            // recursively ensure that the module and all its 
3300            // dependencies are linked (with dependency group handling)
3301            link(load.name, loader);
3302
3303            // now handle dependency execution in correct order
3304            ensureEvaluated(load.name, [], loader);
3305
3306            // remove from the registry
3307            loader.defined[load.name] = undefined;
3308
3309            // return the defined module object
3310            return loader.newModule(entry.declarative ? entry.module.exports : entry.esModule);
3311          }
3312        };
3313      });
3314    };
3315  });
3316})();
3317/*
3318 * Extension to detect ES6 and auto-load Traceur or Babel for processing
3319 */
3320(function() {
3321  // good enough ES6 module detection regex - format detections not designed to be accurate, but to handle the 99% use case
3322  var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/;
3323
3324  var traceurRuntimeRegEx = /\$traceurRuntime\s*\./;
3325  var babelHelpersRegEx = /babelHelpers\s*\./;
3326
3327  hook('translate', function(translate) {
3328    return function(load) {
3329      var loader = this;
3330      return translate.call(loader, load)
3331      .then(function(source) {
3332        // detect & transpile ES6
3333        if (load.metadata.format == 'esm' || load.metadata.format == 'es6' || !load.metadata.format && loader.transpiler !== false && source.match(esmRegEx)) {
3334          if (load.metadata.format == 'es6')
3335            warn.call(loader, 'Module ' + load.name + ' has metadata setting its format to "es6", which is deprecated.\nThis should be updated to "esm".');
3336
3337          load.metadata.format = 'esm';
3338
3339          if (loader.transpiler === false) {
3340            // we accept translation to esm for builds though to enable eg rollup optimizations
3341            if (loader.builder)
3342              return source;
3343            throw new TypeError('Unable to dynamically transpile ES module as SystemJS.transpiler set to false.');
3344          }
3345
3346          // setting _loader.loadedTranspiler = false tells the next block to
3347          // do checks for setting transpiler metadata
3348          loader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
3349          if (loader.pluginLoader)
3350            loader.pluginLoader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
3351
3352          // do transpilation
3353          return (loader._loader.transpilerPromise || (
3354            loader._loader.transpilerPromise = Promise.resolve(
3355              __global[loader.transpiler == 'typescript' ? 'ts' : loader.transpiler] || (loader.pluginLoader || loader)['import'](loader.transpiler)
3356          ))).then(function(transpiler) {
3357            loader._loader.loadedTranspilerRuntime = true;
3358
3359            // translate hooks means this is a transpiler plugin instead of a raw implementation
3360            if (transpiler.translate) {
3361              // if transpiler is the same as the plugin loader, then don't run twice
3362              if (transpiler == load.metadata.loaderModule)
3363                return load.source;
3364
3365              // convert the source map into an object for transpilation chaining
3366              if (typeof load.metadata.sourceMap == 'string')
3367                load.metadata.sourceMap = JSON.parse(load.metadata.sourceMap);
3368
3369              return Promise.resolve(transpiler.translate.call(loader, load))
3370              .then(function(source) {
3371                // sanitize sourceMap if an object not a JSON string
3372                var sourceMap = load.metadata.sourceMap;
3373                if (sourceMap && typeof sourceMap == 'object') {
3374                  var originalName = load.name.split('!')[0];
3375                  
3376                  // force set the filename of the original file
3377                  sourceMap.file = originalName + '!transpiled';
3378
3379                  // force set the sources list if only one source
3380                  if (!sourceMap.sources || sourceMap.sources.length <= 1)
3381                    sourceMap.sources = [originalName];
3382                }
3383
3384                if (load.metadata.format == 'esm' && !loader.builder && detectRegisterFormat(source))
3385                  load.metadata.format = 'register';
3386                return source;
3387              });
3388            }
3389
3390            // legacy builder support
3391            if (loader.builder)
3392              load.metadata.originalSource = load.source;
3393            
3394            // defined in es6-module-loader/src/transpile.js
3395            return transpile.call(loader, load)
3396            .then(function(source) {
3397              // clear sourceMap as transpiler embeds it
3398              load.metadata.sourceMap = undefined;
3399              return source;
3400            });            
3401          });
3402        }
3403
3404        // skip transpiler and transpiler runtime loading when transpiler is disabled
3405        if (loader.transpiler === false)
3406          return source;
3407
3408        // load the transpiler correctly
3409        if (loader._loader.loadedTranspiler === false && (loader.transpiler == 'traceur' || loader.transpiler == 'typescript' || loader.transpiler == 'babel')
3410            && load.name == loader.normalizeSync(loader.transpiler)) {
3411
3412          // always load transpiler as a global
3413          if (source.length > 100 && !load.metadata.format) {
3414            load.metadata.format = 'global';
3415
3416            if (loader.transpiler === 'traceur')
3417              load.metadata.exports = 'traceur';
3418            if (loader.transpiler === 'typescript')
3419              load.metadata.exports = 'ts';
3420          }
3421
3422          loader._loader.loadedTranspiler = true;
3423        }
3424
3425        // load the transpiler runtime correctly
3426        if (loader._loader.loadedTranspilerRuntime === false) {
3427          if (load.name == loader.normalizeSync('traceur-runtime')
3428              || load.name == loader.normalizeSync('babel/external-helpers*')) {
3429            if (source.length > 100)
3430              load.metadata.format = load.metadata.format || 'global';
3431
3432            loader._loader.loadedTranspilerRuntime = true;
3433          }
3434        }
3435
3436        // detect transpiler runtime usage to load runtimes
3437        if ((load.metadata.format == 'register' || load.metadata.bundle) && loader._loader.loadedTranspilerRuntime !== true) {
3438          if (!__global.$traceurRuntime && load.source.match(traceurRuntimeRegEx)) {
3439            loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
3440            return loader['import']('traceur-runtime').then(function() {
3441              return source;
3442            });
3443          }
3444          if (!__global.babelHelpers && load.source.match(babelHelpersRegEx)) {
3445            loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
3446            return loader['import']('babel/external-helpers').then(function() {
3447              return source;
3448            });
3449          }
3450        }
3451
3452        return source;
3453      });
3454    };
3455  });
3456
3457})();
3458/*
3459  SystemJS Global Format
3460
3461  Supports
3462    metadata.deps
3463    metadata.globals
3464    metadata.exports
3465
3466  Without metadata.exports, detects writes to the global object.
3467*/
3468var __globalName = typeof self != 'undefined' ? 'self' : 'global';
3469
3470hook('fetch', function(fetch) {
3471  return function(load) {
3472    if (load.metadata.exports && !load.metadata.format)
3473      load.metadata.format = 'global';
3474    return fetch.call(this, load);
3475  };
3476});
3477
3478// ideally we could support script loading for globals, but the issue with that is that
3479// we can't do it with AMD support side-by-side since AMD support means defining the
3480// global define, and global support means not definining it, yet we don't have any hook
3481// into the "pre-execution" phase of a script tag being loaded to handle both cases
3482hook('instantiate', function(instantiate) {
3483  return function(load) {
3484    var loader = this;
3485
3486    if (!load.metadata.format)
3487      load.metadata.format = 'global';
3488
3489    // global is a fallback module format
3490    if (load.metadata.format == 'global' && !load.metadata.registered) {
3491
3492      var entry = createEntry();
3493
3494      load.metadata.entry = entry;
3495
3496      entry.deps = [];
3497
3498      for (var g in load.metadata.globals) {
3499        var gl = load.metadata.globals[g];
3500        if (gl)
3501          entry.deps.push(gl);
3502      }
3503
3504      entry.execute = function(require, exports, module) {
3505
3506        var globals;
3507        if (load.metadata.globals) {
3508          globals = {};
3509          for (var g in load.metadata.globals)
3510            if (load.metadata.globals[g])
3511              globals[g] = require(load.metadata.globals[g]);
3512        }
3513        
3514        var exportName = load.metadata.exports;
3515
3516        if (exportName)
3517          load.source += '\n' + __globalName + '["' + exportName + '"] = ' + exportName + ';';
3518
3519        var retrieveGlobal = loader.get('@@global-helpers').prepareGlobal(module.id, exportName, globals);
3520
3521        __exec.call(loader, load);
3522
3523        return retrieveGlobal();
3524      }
3525    }
3526    return instantiate.call(this, load);
3527  };
3528});
3529hook('reduceRegister_', function(reduceRegister) {
3530  return function(load, register) {
3531    if (register || !load.metadata.exports)
3532      return reduceRegister.call(this, load, register);
3533
3534    load.metadata.format = 'global';
3535    var entry = load.metadata.entry = createEntry();
3536    entry.deps = load.metadata.deps;
3537    var globalValue = readMemberExpression(load.metadata.exports, __global);
3538    entry.execute = function() {
3539      return globalValue;
3540    };
3541  };
3542});
3543
3544hookConstructor(function(constructor) {
3545  return function() {
3546    var loader = this;
3547    constructor.call(loader);
3548
3549    var hasOwnProperty = Object.prototype.hasOwnProperty;
3550
3551    // bare minimum ignores for IE8
3552    var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external', 
3553      'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB', 'mozInnerScreenY', 'mozInnerScreenX'];
3554
3555    var globalSnapshot;
3556
3557    function forEachGlobal(callback) {
3558      if (Object.keys)
3559        Object.keys(__global).forEach(callback);
3560      else
3561        for (var g in __global) {
3562          if (!hasOwnProperty.call(__global, g))
3563            continue;
3564          callback(g);
3565        }
3566    }
3567
3568    function forEachGlobalValue(callback) {
3569      forEachGlobal(function(globalName) {
3570        if (indexOf.call(ignoredGlobalProps, globalName) != -1)
3571          return;
3572        try {
3573          var value = __global[globalName];
3574        }
3575        catch (e) {
3576          ignoredGlobalProps.push(globalName);
3577        }
3578        callback(globalName, value);
3579      });
3580    }
3581
3582    loader.set('@@global-helpers', loader.newModule({
3583      prepareGlobal: function(moduleName, exportName, globals) {
3584        // disable module detection
3585        var curDefine = __global.define;
3586        
3587        __global.define = undefined;
3588        __global.exports = undefined;
3589        if (__global.module && __global.module.exports)
3590          __global.module = undefined;
3591
3592        // set globals
3593        var oldGlobals;
3594        if (globals) {
3595          oldGlobals = {};
3596          for (var g in globals) {
3597            oldGlobals[g] = __global[g];
3598            __global[g] = globals[g];
3599          }
3600        }
3601
3602        // store a complete copy of the global object in order to detect changes
3603        if (!exportName) {
3604          globalSnapshot = {};
3605
3606          forEachGlobalValue(function(name, value) {
3607            globalSnapshot[name] = value;
3608          });
3609        }
3610
3611        // return function to retrieve global
3612        return function() {
3613          var globalValue;
3614
3615          if (exportName) {
3616            globalValue = readMemberExpression(exportName, __global);
3617          }
3618          else {
3619            var singleGlobal;
3620            var multipleExports;
3621            var exports = {};
3622
3623            forEachGlobalValue(function(name, value) {
3624              if (globalSnapshot[name] === value)
3625                return;
3626              if (typeof value == 'undefined')
3627                return;
3628              exports[name] = value;
3629
3630              if (typeof singleGlobal != 'undefined') {
3631                if (!multipleExports && singleGlobal !== value)
3632                  multipleExports = true;
3633              }
3634              else {
3635                singleGlobal = value;
3636              }
3637            });
3638            globalValue = multipleExports ? exports : singleGlobal;
3639          }
3640
3641          // revert globals
3642          if (oldGlobals) {
3643            for (var g in oldGlobals)
3644              __global[g] = oldGlobals[g];
3645          }
3646          __global.define = curDefine;
3647
3648          return globalValue;
3649        };
3650      }
3651    }));
3652  };
3653});
3654/*
3655  SystemJS CommonJS Format
3656*/
3657(function() {
3658  // CJS Module Format
3659  // require('...') || exports[''] = ... || exports.asd = ... || module.exports = ...
3660  var cjsExportsRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/;
3661  // RegEx adjusted from https://github.com/jbrantly/yabble/blob/master/lib/yabble.js#L339
3662  var cjsRequireRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g;
3663  var commentRegEx = /(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
3664
3665  var stringRegEx = /("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g;
3666
3667  function getCJSDeps(source) {
3668    cjsRequireRegEx.lastIndex = commentRegEx.lastIndex = stringRegEx.lastIndex = 0;
3669
3670    var deps = [];
3671
3672    var match;
3673
3674    // track string and comment locations for unminified source    
3675    var stringLocations = [], commentLocations = [];
3676
3677    function inLocation(locations, match) {
3678      for (var i = 0; i < locations.length; i++)
3679        if (locations[i][0] < match.index && locations[i][1] > match.index)
3680          return true;
3681      return false;
3682    }
3683
3684    if (source.length / source.split('\n').length < 200) {
3685      while (match = stringRegEx.exec(source))
3686        stringLocations.push([match.index, match.index + match[0].length]);
3687      
3688      while (match = commentRegEx.exec(source)) {
3689        // only track comments not starting in strings
3690        if (!inLocation(stringLocations, match))
3691          commentLocations.push([match.index, match.index + match[0].length]);
3692      }
3693    }
3694
3695    while (match = cjsRequireRegEx.exec(source)) {
3696      // ensure we're not within a string or comment location
3697      if (!inLocation(stringLocations, match) && !inLocation(commentLocations, match)) {
3698        var dep = match[1].substr(1, match[1].length - 2);
3699        // skip cases like require('" + file + "')
3700        if (dep.match(/"|'/))
3701          continue;
3702        // trailing slash requires are removed as they don't map mains in SystemJS
3703        if (dep[dep.length - 1] == '/')
3704          dep = dep.substr(0, dep.length - 1);
3705        deps.push(dep);
3706      }
3707    }
3708
3709    return deps;
3710  }
3711
3712  hook('instantiate', function(instantiate) {
3713    return function(load) {
3714      var loader = this;
3715      if (!load.metadata.format) {
3716        cjsExportsRegEx.lastIndex = 0;
3717        cjsRequireRegEx.lastIndex = 0;
3718        if (cjsRequireRegEx.exec(load.source) || cjsExportsRegEx.exec(load.source))
3719          load.metadata.format = 'cjs';
3720      }
3721
3722      if (load.metadata.format == 'cjs') {
3723        var metaDeps = load.metadata.deps;
3724        var deps = load.metadata.cjsRequireDetection === false ? [] : getCJSDeps(load.source);
3725
3726        for (var g in load.metadata.globals)
3727          if (load.metadata.globals[g])
3728            deps.push(load.metadata.globals[g]);
3729
3730        var entry = createEntry();
3731
3732        load.metadata.entry = entry;
3733
3734        entry.deps = deps;
3735        entry.executingRequire = true;
3736        entry.execute = function(_require, exports, module) {
3737          function require(name) {
3738            if (name[name.length - 1] == '/')
3739              name = name.substr(0, name.length - 1);
3740            return _require.apply(this, arguments);
3741          }
3742
3743          // ensure meta deps execute first
3744          for (var i = 0; i < metaDeps.length; i++)
3745            require(metaDeps[i]);
3746
3747          // disable AMD detection
3748          var define = __global.define;
3749          __global.define = undefined;
3750
3751          var pathVars = loader.get('@@cjs-helpers').getPathVars(module.id);
3752
3753          __global.__cjsWrapper = {
3754            exports: exports,
3755            args: [require, exports, module, pathVars.filename, pathVars.dirname, __global, __global]
3756          };
3757
3758          var globals = '';
3759          if (load.metadata.globals) {
3760            for (var g in load.metadata.globals)
3761              globals += 'var ' + g + ' = require("' + load.metadata.globals[g] + '");';
3762          }
3763
3764          load.source = "(function(require, exports, module, __filename, __dirname, global, GLOBAL) {" + globals
3765              + load.source + "\n}).apply(__cjsWrapper.exports, __cjsWrapper.args);";
3766
3767          __exec.call(loader, load);
3768
3769          __global.__cjsWrapper = undefined;
3770          __global.define = define;
3771        };
3772      }
3773
3774      return instantiate.call(loader, load);
3775    };
3776  });
3777})();
3778hookConstructor(function(constructor) {
3779  return function() {
3780    var loader = this;
3781    constructor.call(loader);
3782
3783    if (typeof window != 'undefined' && typeof document != 'undefined' && window.location)
3784      var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
3785
3786    loader.set('@@cjs-helpers', loader.newModule({
3787      getPathVars: function(moduleId) {
3788        // remove any plugin syntax
3789        var pluginIndex = moduleId.lastIndexOf('!');
3790        var filename;
3791        if (pluginIndex != -1)
3792          filename = moduleId.substr(0, pluginIndex);
3793        else
3794          filename = moduleId;
3795
3796        var dirname = filename.split('/');
3797        dirname.pop();
3798        dirname = dirname.join('/');
3799
3800        if (filename.substr(0, 8) == 'file:///') {
3801          filename = filename.substr(7);
3802          dirname = dirname.substr(7);
3803
3804          // on windows remove leading '/'
3805          if (isWindows) {
3806            filename = filename.substr(1);
3807            dirname = dirname.substr(1);
3808          }
3809        }
3810        else if (windowOrigin && filename.substr(0, windowOrigin.length) === windowOrigin) {
3811          filename = filename.substr(windowOrigin.length);
3812          dirname = dirname.substr(windowOrigin.length);
3813        }
3814
3815        return {
3816          filename: filename,
3817          dirname: dirname
3818        };
3819      }
3820    }))
3821  };
3822});/*
3823 * AMD Helper function module
3824 * Separated into its own file as this is the part needed for full AMD support in SFX builds
3825 * NB since implementations have now diverged this can be merged back with amd.js
3826 */
3827hookConstructor(function(constructor) {
3828  return function() {
3829    var loader = this;
3830    constructor.call(this);
3831
3832    var commentRegEx = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
3833    var cjsRequirePre = "(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])";
3834    var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
3835    var fnBracketRegEx = /\(([^\)]*)\)/;
3836    var wsRegEx = /^\s+|\s+$/g;
3837    
3838    var requireRegExs = {};
3839
3840    function getCJSDeps(source, requireIndex) {
3841
3842      // remove comments
3843      source = source.replace(commentRegEx, '');
3844
3845      // determine the require alias
3846      var params = source.match(fnBracketRegEx);
3847      var requireAlias = (params[1].split(',')[requireIndex] || 'require').replace(wsRegEx, '');
3848
3849      // find or generate the regex for this requireAlias
3850      var requireRegEx = requireRegExs[requireAlias] || (requireRegExs[requireAlias] = new RegExp(cjsRequirePre + requireAlias + cjsRequirePost, 'g'));
3851
3852      requireRegEx.lastIndex = 0;
3853
3854      var deps = [];
3855
3856      var match;
3857      while (match = requireRegEx.exec(source))
3858        deps.push(match[2] || match[3]);
3859
3860      return deps;
3861    }
3862
3863    /*
3864      AMD-compatible require
3865      To copy RequireJS, set window.require = window.requirejs = loader.amdRequire
3866    */
3867    function require(names, callback, errback, referer) {
3868      // in amd, first arg can be a config object... we just ignore
3869      if (typeof names == 'object' && !(names instanceof Array))
3870        return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));
3871
3872      // amd require
3873      if (typeof names == 'string' && typeof callback == 'function')
3874        names = [names];
3875      if (names instanceof Array) {
3876        var dynamicRequires = [];
3877        for (var i = 0; i < names.length; i++)
3878          dynamicRequires.push(loader['import'](names[i], referer));
3879        Promise.all(dynamicRequires).then(function(modules) {
3880          if (callback)
3881            callback.apply(null, modules);
3882        }, errback);
3883      }
3884
3885      // commonjs require
3886      else if (typeof names == 'string') {
3887        var defaultJSExtension = loader.defaultJSExtensions && names.substr(names.length - 3, 3) != '.js';
3888        var normalized = loader.decanonicalize(names, referer);
3889        if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
3890          normalized = normalized.substr(0, normalized.length - 3);
3891        var module = loader.get(normalized);
3892        if (!module)
3893          throw new Error('Module not already loaded loading "' + names + '" from "' + referer + '".');
3894        return module.__useDefault ? module['default'] : module;
3895      }
3896
3897      else
3898        throw new TypeError('Invalid require');
3899    }
3900
3901    function define(name, deps, factory) {
3902      if (typeof name != 'string') {
3903        factory = deps;
3904        deps = name;
3905        name = null;
3906      }
3907      if (!(deps instanceof Array)) {
3908        factory = deps;
3909        deps = ['require', 'exports', 'module'].splice(0, factory.length);
3910      }
3911
3912      if (typeof factory != 'function')
3913        factory = (function(factory) {
3914          return function() { return factory; }
3915        })(factory);
3916
3917      // in IE8, a trailing comma becomes a trailing undefined entry
3918      if (deps[deps.length - 1] === undefined)
3919        deps.pop();
3920
3921      // remove system dependencies
3922      var requireIndex, exportsIndex, moduleIndex;
3923      
3924      if ((requireIndex = indexOf.call(deps, 'require')) != -1) {
3925        
3926        deps.splice(requireIndex, 1);
3927
3928        // only trace cjs requires for non-named
3929        // named defines assume the trace has already been done
3930        if (!name)
3931          deps = deps.concat(getCJSDeps(factory.toString(), requireIndex));
3932      }
3933
3934      if ((exportsIndex = indexOf.call(deps, 'exports')) != -1)
3935        deps.splice(exportsIndex, 1);
3936      
3937      if ((moduleIndex = indexOf.call(deps, 'module')) != -1)
3938        deps.splice(moduleIndex, 1);
3939
3940      function execute(req, exports, module) {
3941        var depValues = [];
3942        for (var i = 0; i < deps.length; i++)
3943          depValues.push(req(deps[i]));
3944
3945        module.uri = module.id;
3946
3947        module.config = function() {};
3948
3949        // add back in system dependencies
3950        if (moduleIndex != -1)
3951          depValues.splice(moduleIndex, 0, module);
3952        
3953        if (exportsIndex != -1)
3954          depValues.splice(exportsIndex, 0, exports);
3955        
3956        if (requireIndex != -1) {
3957          function contextualRequire(names, callback, errback) {
3958            if (typeof names == 'string' && typeof callback != 'function')
3959              return req(names);
3960            return require.call(loader, names, callback, errback, module.id);
3961          }
3962          contextualRequire.toUrl = function(name) {
3963            // normalize without defaultJSExtensions
3964            var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
3965            var url = loader.decanonicalize(name, module.id);
3966            if (defaultJSExtension && url.substr(url.length - 3, 3) == '.js')
3967              url = url.substr(0, url.length - 3);
3968            return url;
3969          };
3970          depValues.splice(requireIndex, 0, contextualRequire);
3971        }
3972
3973        // set global require to AMD require
3974        var curRequire = __global.require;
3975        __global.require = require;
3976
3977        var output = factory.apply(exportsIndex == -1 ? __global : exports, depValues);
3978
3979        __global.require = curRequire;
3980
3981        if (typeof output == 'undefined' && module)
3982          output = module.exports;
3983
3984        if (typeof output != 'undefined')
3985          return output;
3986      }
3987
3988      var entry = createEntry();
3989      entry.name = name && (loader.decanonicalize || loader.normalize).call(loader, name);
3990      entry.deps = deps;
3991      entry.execute = execute;
3992
3993      loader.pushRegister_({
3994        amd: true,
3995        entry: entry
3996      });
3997    }
3998    define.amd = {};
3999
4000    // reduction function to attach defines to a load record
4001    hook('reduceRegister_', function(reduceRegister) {
4002      return function(load, register) {
4003        // only handle AMD registers here
4004        if (!register || !register.amd)
4005          return reduceRegister.call(this, load, register);
4006
4007        var curMeta = load && load.metadata;
4008        var entry = register.entry;
4009
4010        if (curMeta)
4011          curMeta.format = 'amd';
4012
4013        // anonymous define
4014        if (!entry.name) {
4015          if (!curMeta)
4016            throw new TypeError('Unexpected anonymous AMD define.');
4017
4018          // already defined anonymously -> throw
4019          if (curMeta.entry)
4020            throw new TypeError('Multiple defines for anonymous module ' + load.name);
4021          
4022          curMeta.entry = entry;
4023        }
4024        // named define
4025        else {
4026          // if we don't have any other defines, 
4027          // then let this be an anonymous define
4028          // this is just to support single modules of the form:
4029          // define('jquery')
4030          // still loading anonymously
4031          // because it is done widely enough to be useful
4032          // as soon as there is more than one define, this gets removed though
4033          if (curMeta) {
4034            if (!curMeta.entry && !curMeta.bundle)
4035              curMeta.entry = entry;
4036            else
4037              curMeta.entry = undefined;
4038
4039            // note this is now a bundle
4040            curMeta.bundle = true;
4041          }
4042
4043          // define the module through the register registry
4044          if (!(entry.name in this.defined))
4045            this.defined[entry.name] = entry;
4046        }
4047      };
4048    });
4049
4050    // adds define as a global (potentially just temporarily)
4051    function createDefine() {
4052      // ensure no NodeJS environment detection
4053      var oldModule = __global.module;
4054      var oldExports = __global.exports;
4055      var oldDefine = __global.define;
4056
4057      __global.module = undefined;
4058      __global.exports = undefined;
4059      __global.define = define;
4060
4061      return function() {
4062        __global.define = oldDefine;
4063        __global.module = oldModule;
4064        __global.exports = oldExports;
4065      };
4066    }
4067
4068    loader.set('@@amd-helpers', loader.newModule({
4069      createDefine: createDefine,
4070      require: require,
4071      define: define
4072    }));
4073    loader.amdDefine = define;
4074    loader.amdRequire = require;
4075  };
4076});/*
4077  SystemJS AMD Format
4078*/
4079(function() {
4080  // AMD Module Format Detection RegEx
4081  // define([.., .., ..], ...)
4082  // define(varName); || define(function(require, exports) {}); || define({})
4083  var amdRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])define\s*\(\s*("[^"]+"\s*,\s*|'[^']+'\s*,\s*)?\s*(\[(\s*(("[^"]+"|'[^']+')\s*,|\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*(\s*("[^"]+"|'[^']+')\s*,?)?(\s*(\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*\s*\]|function\s*|{|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*\))/;
4084
4085  hook('fetch', function(fetch) {
4086    return function(load) {
4087      // script load implies define global leak
4088      if (load.metadata.scriptLoad && isBrowser)
4089        this.get('@@amd-helpers').createDefine();
4090      return fetch.call(this, load);
4091    };
4092  });
4093
4094  hook('instantiate', function(instantiate) {
4095    return function(load) {
4096      var loader = this;
4097      
4098      if (load.metadata.format == 'amd' || !load.metadata.format && load.source.match(amdRegEx)) {
4099        load.metadata.format = 'amd';
4100        
4101        if (!loader.builder && loader.execute !== false) {
4102          var removeDefine = this.get('@@amd-helpers').createDefine();
4103
4104          try {
4105            __exec.call(loader, load);
4106          }
4107          finally {
4108            removeDefine();
4109          }
4110
4111          if (!load.metadata.entry && !load.metadata.bundle)
4112            throw new TypeError('AMD module ' + load.name + ' did not define');
4113        }
4114        else {
4115          load.metadata.execute = function() {
4116            return load.metadata.builderExecute.apply(this, arguments);
4117          };
4118        }
4119      }
4120
4121      return instantiate.call(loader, load);
4122    };
4123  });
4124
4125})();
4126/*
4127  SystemJS Loader Plugin Support
4128
4129  Supports plugin loader syntax with "!", or via metadata.loader
4130
4131  The plugin name is loaded as a module itself, and can override standard loader hooks
4132  for the plugin resource. See the plugin section of the systemjs readme.
4133*/
4134
4135(function() {
4136  function getParentName(loader, parentName) {
4137    // if parent is a plugin, normalize against the parent plugin argument only
4138    if (parentName) {
4139      var parentPluginIndex;
4140      if (loader.pluginFirst) {
4141        if ((parentPluginIndex = parentName.lastIndexOf('!')) != -1)
4142          return parentName.substr(parentPluginIndex + 1);
4143      }
4144      else {
4145        if ((parentPluginIndex = parentName.indexOf('!')) != -1)
4146          return parentName.substr(0, parentPluginIndex);
4147      }
4148
4149      return parentName;
4150    }
4151  }
4152
4153  function parsePlugin(loader, name) {
4154    var argumentName;
4155    var pluginName;
4156
4157    var pluginIndex = name.lastIndexOf('!');
4158
4159    if (pluginIndex == -1)
4160      return;
4161
4162    if (loader.pluginFirst) {
4163      argumentName = name.substr(pluginIndex + 1);
4164      pluginName = name.substr(0, pluginIndex);
4165    }
4166    else {
4167      argumentName = name.substr(0, pluginIndex);
4168      pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1);
4169    }
4170
4171    return {
4172      argument: argumentName,
4173      plugin: pluginName
4174    };
4175  }
4176
4177  // put name back together after parts have been normalized
4178  function combinePluginParts(loader, argumentName, pluginName, defaultExtension) {
4179    if (defaultExtension && argumentName.substr(argumentName.length - 3, 3) == '.js')
4180      argumentName = argumentName.substr(0, argumentName.length - 3);
4181
4182    if (loader.pluginFirst) {
4183      return pluginName + '!' + argumentName;
4184    }
4185    else {
4186      return argumentName + '!' + pluginName;
4187    }
4188  }
4189
4190  // note if normalize will add a default js extension
4191  // if so, remove for backwards compat
4192  // this is strange and sucks, but will be deprecated
4193  function checkDefaultExtension(loader, arg) {
4194    return loader.defaultJSExtensions && arg.substr(arg.length - 3, 3) != '.js'; 
4195  }
4196
4197  function createNormalizeSync(normalizeSync) {
4198    return function(name, parentName, isPlugin) {
4199      var loader = this;
4200      
4201      parentName = getParentName(this, parentName);
4202      var parsed = parsePlugin(loader, name);
4203
4204      if (!parsed)
4205        return normalizeSync.call(this, name, parentName, isPlugin);
4206
4207      // if this is a plugin, normalize the plugin name and the argument
4208      var argumentName = loader.normalizeSync(parsed.argument, parentName, true);
4209      var pluginName = loader.normalizeSync(parsed.plugin, parentName, true);
4210      return combinePluginParts(loader, argumentName, pluginName, checkDefaultExtension(loader, parsed.argument));
4211    };
4212  }
4213  
4214  hook('decanonicalize', createNormalizeSync);
4215  hook('normalizeSync', createNormalizeSync);
4216
4217  hook('normalize', function(normalize) {
4218    return function(name, parentName, isPlugin) {
4219      var loader = this;
4220
4221      parentName = getParentName(this, parentName);
4222
4223      var parsed = parsePlugin(loader, name);
4224
4225      if (!parsed)
4226        return normalize.call(loader, name, parentName, isPlugin);
4227
4228      return Promise.all([
4229        loader.normalize(parsed.argument, parentName, true),
4230        loader.normalize(parsed.plugin, parentName)
4231      ])
4232      .then(function(normalized) {
4233        return combinePluginParts(loader, normalized[0], normalized[1], checkDefaultExtension(loader, parsed.argument));
4234      });
4235    }
4236  });
4237
4238  hook('locate', function(locate) {
4239    return function(load) {
4240      var loader = this;
4241
4242      var name = load.name;
4243
4244      // plugin syntax
4245      var pluginSyntaxIndex;
4246      if (loader.pluginFirst) {
4247        if ((pluginSyntaxIndex = name.indexOf('!')) != -1) {
4248          load.metadata.loader = name.substr(0, pluginSyntaxIndex);
4249          load.name = name.substr(pluginSyntaxIndex + 1);
4250        }
4251      }
4252      else {
4253        if ((pluginSyntaxIndex = name.lastIndexOf('!')) != -1) {
4254          load.metadata.loader = name.substr(pluginSyntaxIndex + 1);
4255          load.name = name.substr(0, pluginSyntaxIndex);
4256        }
4257      }
4258
4259      return locate.call(loader, load)
4260      .then(function(address) {
4261        var plugin = load.metadata.loader;
4262
4263        if (!plugin)
4264          return address;
4265
4266        // only fetch the plugin itself if this name isn't defined
4267        if (loader.defined && loader.defined[name])
4268          return address;
4269
4270        var pluginLoader = loader.pluginLoader || loader;
4271
4272        // load the plugin module and run standard locate
4273        return pluginLoader['import'](plugin)
4274        .then(function(loaderModule) {
4275          // store the plugin module itself on the metadata
4276          load.metadata.loaderModule = loaderModule;
4277
4278          load.address = address;
4279          if (loaderModule.locate)
4280            return loaderModule.locate.call(loader, load);
4281
4282          return address;
4283        });
4284      });
4285    };
4286  });
4287
4288  hook('fetch', function(fetch) {
4289    return function(load) {
4290      var loader = this;
4291      if (load.metadata.loaderModule && load.metadata.loaderModule.fetch && load.metadata.format != 'defined') {
4292        load.metadata.scriptLoad = false;
4293        return load.metadata.loaderModule.fetch.call(loader, load, function(load) {
4294          return fetch.call(loader, load);
4295        });
4296      }
4297      else {
4298        return fetch.call(loader, load);
4299      }
4300    };
4301  });
4302
4303  hook('translate', function(translate) {
4304    return function(load) {
4305      var loader = this;
4306      if (load.metadata.loaderModule && load.metadata.loaderModule.translate && load.metadata.format != 'defined') {
4307        return Promise.resolve(load.metadata.loaderModule.translate.call(loader, load)).then(function(result) {
4308          var sourceMap = load.metadata.sourceMap;
4309
4310          // sanitize sourceMap if an object not a JSON string
4311          if (sourceMap) {
4312            if (typeof sourceMap != 'object')
4313              throw new Error('load.metadata.sourceMap must be set to an object.');
4314
4315            var originalName = load.name.split('!')[0];
4316            
4317            // force set the filename of the original file
4318            sourceMap.file = originalName + '!transpiled';
4319
4320            // force set the sources list if only one source
4321            if (!sourceMap.sources || sourceMap.sources.length <= 1)
4322              sourceMap.sources = [originalName];
4323          }
4324
4325          // if running on file:/// URLs, sourcesContent is necessary
4326          // load.metadata.sourceMap.sourcesContent = [load.source];
4327
4328          if (typeof result == 'string')
4329            load.source = result;
4330          else
4331            warn.call(this, 'Plugin ' + load.metadata.loader + ' should return the source in translate, instead of setting load.source directly. This support will be deprecated.');
4332
4333          return translate.call(loader, load);
4334        });
4335      }
4336      else {
4337        return translate.call(loader, load);
4338      }
4339    };
4340  });
4341
4342  hook('instantiate', function(instantiate) {
4343    return function(load) {
4344      var loader = this;
4345
4346      if (load.metadata.loaderModule && load.metadata.loaderModule.instantiate && !loader.builder && load.metadata.format != 'defined')
4347        return Promise.resolve(load.metadata.loaderModule.instantiate.call(loader, load)).then(function(result) {
4348          load.metadata.entry = createEntry();
4349          load.metadata.entry.execute = function() {
4350            return result;
4351          }
4352          load.metadata.entry.deps = load.metadata.deps;
4353          load.metadata.format = 'defined';
4354          return instantiate.call(loader, load);
4355        });
4356      else
4357        return instantiate.call(loader, load);
4358    };
4359  });
4360
4361})();/*
4362 * Conditions Extension
4363 *
4364 *   Allows a condition module to alter the resolution of an import via syntax:
4365 *
4366 *     import $ from 'jquery/#{browser}';
4367 *
4368 *   Will first load the module 'browser' via `SystemJS.import('browser')` and 
4369 *   take the default export of that module.
4370 *   If the default export is not a string, an error is thrown.
4371 * 
4372 *   We then substitute the string into the require to get the conditional resolution
4373 *   enabling environment-specific variations like:
4374 * 
4375 *     import $ from 'jquery/ie'
4376 *     import $ from 'jquery/firefox'
4377 *     import $ from 'jquery/chrome'
4378 *     import $ from 'jquery/safari'
4379 *
4380 *   It can be useful for a condition module to define multiple conditions.
4381 *   This can be done via the `|` modifier to specify an export member expression:
4382 *
4383 *     import 'jquery/#{./browser.js|grade.version}'
4384 *
4385 *   Where the `grade` export `version` member in the `browser.js` module  is substituted.
4386 *
4387 *
4388 * Boolean Conditionals
4389 *
4390 *   For polyfill modules, that are used as imports but have no module value,
4391 *   a binary conditional allows a module not to be loaded at all if not needed:
4392 *
4393 *     import 'es5-shim#?./conditions.js|needs-es5shim'
4394 *
4395 *   These conditions can also be negated via:
4396 *     
4397 *     import 'es5-shim#?~./conditions.js|es6'
4398 *
4399 */
4400
4401  function parseCondition(condition) {
4402    var conditionExport, conditionModule, negation;
4403
4404    var negation = condition[0] == '~';
4405    var conditionExportIndex = condition.lastIndexOf('|');
4406    if (conditionExportIndex != -1) {
4407      conditionExport = condition.substr(conditionExportIndex + 1);
4408      conditionModule = condition.substr(negation, conditionExportIndex - negation) || '@system-env';
4409    }
4410    else {
4411      conditionExport = null;
4412      conditionModule = condition.substr(negation);
4413    }
4414
4415    return {
4416      module: conditionModule,
4417      prop: conditionExport,
4418      negate: negation
4419    };
4420  }
4421
4422  function serializeCondition(conditionObj) {
4423    return (conditionObj.negate ? '~' : '') + conditionObj.module + (conditionObj.prop ? '|' + conditionObj.prop : '');
4424  }
4425
4426  function resolveCondition(conditionObj, parentName, bool) {
4427    return this['import'](conditionObj.module, parentName)
4428    .then(function(m) {
4429      if (conditionObj.prop)
4430        m = readMemberExpression(conditionObj.prop, m);
4431      else if (typeof m == 'object' && m + '' == 'Module')
4432        m = m['default'];
4433
4434      if (bool && typeof m != 'boolean')
4435        throw new TypeError('Condition ' + serializeCondition(conditionObj) + ' did not resolve to a boolean.');
4436
4437      return conditionObj.negate ? !m : m;
4438    });
4439  }
4440
4441  var interpolationRegEx = /#\{[^\}]+\}/;
4442  function interpolateConditional(name, parentName) {
4443    // first we normalize the conditional
4444    var conditionalMatch = name.match(interpolationRegEx);
4445
4446    if (!conditionalMatch)
4447      return Promise.resolve(name);
4448
4449    var conditionObj = parseCondition(conditionalMatch[0].substr(2, conditionalMatch[0].length - 3));
4450
4451    // in builds, return normalized conditional
4452    if (this.builder)
4453      return this['normalize'](conditionObj.module, parentName)
4454      .then(function(conditionModule) {
4455        conditionObj.module = conditionModule;
4456        return name.replace(interpolationRegEx, '#{' + serializeCondition(conditionObj) + '}');
4457      });
4458
4459    return resolveCondition.call(this, conditionObj, parentName, false)
4460    .then(function(conditionValue) {
4461      if (typeof conditionValue !== 'string')
4462        throw new TypeError('The condition value for ' + name + ' doesn\'t resolve to a string.');
4463
4464      if (conditionValue.indexOf('/') != -1)
4465        throw new TypeError('Unabled to interpolate conditional ' + name + (parentName ? ' in ' + parentName : '') + '\n\tThe condition value ' + conditionValue + ' cannot contain a "/" separator.');
4466
4467      return name.replace(interpolationRegEx, conditionValue);
4468    });
4469  }
4470
4471  function booleanConditional(name, parentName) {
4472    // first we normalize the conditional
4473    var booleanIndex = name.lastIndexOf('#?');
4474
4475    if (booleanIndex == -1)
4476      return Promise.resolve(name);
4477
4478    var conditionObj = parseCondition(name.substr(booleanIndex + 2));
4479
4480    // in builds, return normalized conditional
4481    if (this.builder)
4482      return this['normalize'](conditionObj.module, parentName)
4483      .then(function(conditionModule) {
4484        conditionObj.module = conditionModule;
4485        return name.substr(0, booleanIndex) + '#?' + serializeCondition(conditionObj);
4486      });
4487
4488    return resolveCondition.call(this, conditionObj, parentName, true)
4489    .then(function(conditionValue) {
4490      return conditionValue ? name.substr(0, booleanIndex) : '@empty';
4491    });
4492  }
4493
4494  // normalizeSync does not parse conditionals at all although it could
4495  hook('normalize', function(normalize) {
4496    return function(name, parentName, parentAddress) {
4497      var loader = this;
4498      return booleanConditional.call(loader, name, parentName)
4499      .then(function(name) {
4500        return normalize.call(loader, name, parentName, parentAddress);
4501      })
4502      .then(function(normalized) {
4503        return interpolateConditional.call(loader, normalized, parentName);
4504      });
4505    };
4506  });
4507/*
4508 * Alias Extension
4509 *
4510 * Allows a module to be a plain copy of another module by module name
4511 *
4512 * SystemJS.meta['mybootstrapalias'] = { alias: 'bootstrap' };
4513 *
4514 */
4515(function() {
4516  // aliases
4517  hook('fetch', function(fetch) {
4518    return function(load) {
4519      var alias = load.metadata.alias;
4520      var aliasDeps = load.metadata.deps || [];
4521      if (alias) {
4522        load.metadata.format = 'defined';
4523        var entry = createEntry();
4524        this.defined[load.name] = entry;
4525        entry.declarative = true;
4526        entry.deps = aliasDeps.concat([alias]);
4527        entry.declare = function(_export) {
4528          return {
4529            setters: [function(module) {
4530              for (var p in module)
4531                _export(p, module[p]);
4532              if (module.__useDefault)
4533                entry.module.exports.__useDefault = true;
4534            }],
4535            execute: function() {}
4536          };
4537        };
4538        return '';
4539      }
4540
4541      return fetch.call(this, load);
4542    };
4543  });
4544})();/*
4545 * Meta Extension
4546 *
4547 * Sets default metadata on a load record (load.metadata) from
4548 * loader.metadata via SystemJS.meta function.
4549 *
4550 *
4551 * Also provides an inline meta syntax for module meta in source.
4552 *
4553 * Eg:
4554 *
4555 * loader.meta({
4556 *   'my/module': { deps: ['jquery'] }
4557 *   'my/*': { format: 'amd' }
4558 * });
4559 *
4560 * Which in turn populates loader.metadata.
4561 *
4562 * load.metadata.deps and load.metadata.format will then be set
4563 * for 'my/module'
4564 *
4565 * The same meta could be set with a my/module.js file containing:
4566 *
4567 * my/module.js
4568 *   "format amd";
4569 *   "deps[] jquery";
4570 *   "globals.some value"
4571 *   console.log('this is my/module');
4572 *
4573 * Configuration meta always takes preference to inline meta.
4574 *
4575 * Multiple matches in wildcards are supported and ammend the meta.
4576 *
4577 *
4578 * The benefits of the function form is that paths are URL-normalized
4579 * supporting say
4580 *
4581 * loader.meta({ './app': { format: 'cjs' } });
4582 *
4583 * Instead of needing to set against the absolute URL (https://site.com/app.js)
4584 *
4585 */
4586
4587(function() {
4588
4589  hookConstructor(function(constructor) {
4590    return function() {
4591      this.meta = {};
4592      constructor.call(this);
4593    };
4594  });
4595
4596  hook('locate', function(locate) {
4597    return function(load) {
4598      var meta = this.meta;
4599      var name = load.name;
4600
4601      // NB for perf, maybe introduce a fast-path wildcard lookup cache here
4602      // which is checked first
4603
4604      // apply wildcard metas
4605      var bestDepth = 0;
4606      var wildcardIndex;
4607      for (var module in meta) {
4608        wildcardIndex = module.indexOf('*');
4609        if (wildcardIndex === -1)
4610          continue;
4611        if (module.substr(0, wildcardIndex) === name.substr(0, wildcardIndex)
4612            && module.substr(wildcardIndex + 1) === name.substr(name.length - module.length + wildcardIndex + 1)) {
4613          var depth = module.split('/').length;
4614          if (depth > bestDepth)
4615            bestDepth = depth;
4616          extendMeta(load.metadata, meta[module], bestDepth != depth);
4617        }
4618      }
4619
4620      // apply exact meta
4621      if (meta[name])
4622        extendMeta(load.metadata, meta[name]);
4623
4624      return locate.call(this, load);
4625    };
4626  });
4627
4628  // detect any meta header syntax
4629  // only set if not already set
4630  var metaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/;
4631  var metaPartRegEx = /\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;
4632
4633  function setMetaProperty(target, p, value) {
4634    var pParts = p.split('.');
4635    var curPart;
4636    while (pParts.length > 1) {
4637      curPart = pParts.shift();
4638      target = target[curPart] = target[curPart] || {};
4639    }
4640    curPart = pParts.shift();
4641    if (!(curPart in target))
4642      target[curPart] = value;
4643  }
4644
4645  hook('translate', function(translate) {
4646    return function(load) {
4647      // NB meta will be post-translate pending transpiler conversion to plugins
4648      var meta = load.source.match(metaRegEx);
4649      if (meta) {
4650        var metaParts = meta[0].match(metaPartRegEx);
4651
4652        for (var i = 0; i < metaParts.length; i++) {
4653          var curPart = metaParts[i];
4654          var len = curPart.length;
4655
4656          var firstChar = curPart.substr(0, 1);
4657          if (curPart.substr(len - 1, 1) == ';')
4658            len--;
4659
4660          if (firstChar != '"' && firstChar != "'")
4661            continue;
4662
4663          var metaString = curPart.substr(1, curPart.length - 3);
4664          var metaName = metaString.substr(0, metaString.indexOf(' '));
4665
4666          if (metaName) {
4667            var metaValue = metaString.substr(metaName.length + 1, metaString.length - metaName.length - 1);
4668
4669            if (metaName.substr(metaName.length - 2, 2) == '[]') {
4670              metaName = metaName.substr(0, metaName.length - 2);
4671              load.metadata[metaName] = load.metadata[metaName] || [];
4672              load.metadata[metaName].push(metaValue);
4673            }
4674            else if (load.metadata[metaName] instanceof Array) {
4675              // temporary backwards compat for previous "deps" syntax
4676              warn.call(this, 'Module ' + load.name + ' contains deprecated "deps ' + metaValue + '" meta syntax.\nThis should be updated to "deps[] ' + metaValue + '" for pushing to array meta.');
4677              load.metadata[metaName].push(metaValue);
4678            }
4679            else {
4680              setMetaProperty(load.metadata, metaName, metaValue);
4681            }
4682          }
4683          else {
4684            load.metadata[metaString] = true;
4685          }
4686        }
4687      }
4688
4689      return translate.call(this, load);
4690    };
4691  });
4692})();
4693/*
4694  System bundles
4695
4696  Allows a bundle module to be specified which will be dynamically 
4697  loaded before trying to load a given module.
4698
4699  For example:
4700  SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
4701
4702  Will result in a load to "mybundle" whenever a load to "jquery"
4703  or "bootstrap/js/bootstrap" is made.
4704
4705  In this way, the bundle becomes the request that provides the module
4706*/
4707
4708(function() {
4709  // bundles support (just like RequireJS)
4710  // bundle name is module name of bundle itself
4711  // bundle is array of modules defined by the bundle
4712  // when a module in the bundle is requested, the bundle is loaded instead
4713  // of the form SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
4714  hookConstructor(function(constructor) {
4715    return function() {
4716      constructor.call(this);
4717      this.bundles = {};
4718      this._loader.loadedBundles = {};
4719    };
4720  });
4721
4722  // assign bundle metadata for bundle loads
4723  hook('locate', function(locate) {
4724    return function(load) {
4725      var loader = this;
4726      var matched = false;
4727
4728      if (!(load.name in loader.defined))
4729        for (var b in loader.bundles) {
4730          for (var i = 0; i < loader.bundles[b].length; i++) {
4731            var curModule = loader.bundles[b][i];
4732
4733            if (curModule == load.name) {
4734              matched = true;
4735              break;
4736            }
4737
4738            // wildcard in bundles does not include / boundaries
4739            if (curModule.indexOf('*') != -1) {
4740              var parts = curModule.split('*');
4741              if (parts.length != 2) {
4742                loader.bundles[b].splice(i--, 1);
4743                continue;
4744              }
4745              
4746              if (load.name.substring(0, parts[0].length) == parts[0] &&
4747                  load.name.substr(load.name.length - parts[1].length, parts[1].length) == parts[1] &&
4748                  load.name.substr(parts[0].length, load.name.length - parts[1].length - parts[0].length).indexOf('/') == -1) {
4749                matched = true;
4750                break;
4751              }
4752            }
4753          }
4754
4755          if (matched)
4756            return loader['import'](b)
4757            .then(function() {
4758              return locate.call(loader, load);
4759            });
4760        }
4761
4762      return locate.call(loader, load);
4763    };
4764  });
4765})();
4766/*
4767 * Dependency Tree Cache
4768 * 
4769 * Allows a build to pre-populate a dependency trace tree on the loader of 
4770 * the expected dependency tree, to be loaded upfront when requesting the
4771 * module, avoinding the n round trips latency of module loading, where 
4772 * n is the dependency tree depth.
4773 *
4774 * eg:
4775 * SystemJS.depCache = {
4776 *  'app': ['normalized', 'deps'],
4777 *  'normalized': ['another'],
4778 *  'deps': ['tree']
4779 * };
4780 * 
4781 * SystemJS.import('app') 
4782 * // simultaneously starts loading all of:
4783 * // 'normalized', 'deps', 'another', 'tree'
4784 * // before "app" source is even loaded
4785 *
4786 */
4787
4788(function() {
4789  hookConstructor(function(constructor) {
4790    return function() {
4791      constructor.call(this);
4792      this.depCache = {};
4793    }
4794  });
4795
4796  hook('locate', function(locate) {
4797    return function(load) {
4798      var loader = this;
4799      // load direct deps, in turn will pick up their trace trees
4800      var deps = loader.depCache[load.name];
4801      if (deps)
4802        for (var i = 0; i < deps.length; i++)
4803          loader['import'](deps[i], load.name);
4804
4805      return locate.call(loader, load);
4806    };
4807  });
4808})();
4809  
4810System = new SystemJSLoader();
4811
4812__global.SystemJS = System;
4813System.version = '0.19.22 Standard';
4814  // -- exporting --
4815
4816  if (typeof exports === 'object')
4817    module.exports = Loader;
4818
4819  __global.Reflect = __global.Reflect || {};
4820  __global.Reflect.Loader = __global.Reflect.Loader || Loader;
4821  __global.Reflect.global = __global.Reflect.global || __global;
4822  __global.LoaderPolyfill = Loader;
4823
4824  if (!System) {
4825    System = new SystemLoader();
4826    System.constructor = SystemLoader;
4827  }
4828
4829  if (typeof exports === 'object')
4830    module.exports = System;
4831
4832  __global.System = System;
4833
4834})(typeof self != 'undefined' ? self : global);}
4835
4836// auto-load Promise and URL polyfills if needed in the browser
4837try {
4838  var hasURL = typeof URLPolyfill != 'undefined' || new URL('test:///').protocol == 'test:';
4839}
4840catch(e) {}
4841
4842if (typeof Promise === 'undefined' || !hasURL) {
4843  // document.write
4844  if (typeof document !== 'undefined') {
4845    var scripts = document.getElementsByTagName('script');
4846    $__curScript = scripts[scripts.length - 1];
4847    var curPath = $__curScript.src;
4848    var basePath = curPath.substr(0, curPath.lastIndexOf('/') + 1);
4849    window.systemJSBootstrap = bootstrap;
4850    document.write(
4851      '<' + 'script type="text/javascript" src="' + basePath + 'system-polyfills.js">' + '<' + '/script>'
4852    );
4853  }
4854  // importScripts
4855  else if (typeof importScripts !== 'undefined') {
4856    var basePath = '';
4857    try {
4858      throw new Error('_');
4859    } catch (e) {
4860      e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/, function(m, url) {
4861        basePath = url.replace(/\/[^\/]*$/, '/');
4862      });
4863    }
4864    importScripts(basePath + 'system-polyfills.js');
4865    bootstrap();
4866  }
4867  else {
4868    bootstrap();
4869  }
4870}
4871else {
4872  bootstrap();
4873}
4874
4875
4876})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.