Add v2 UI for the perf dashboard
[WebKit-https.git] / Websites / perf.webkit.org / public / v2 / js / ember.js
1 /*!
2  * @overview  Ember - JavaScript Application Framework
3  * @copyright Copyright 2011-2014 Tilde Inc. and contributors
4  *            Portions Copyright 2006-2011 Strobe Inc.
5  *            Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6  * @license   Licensed under MIT license
7  *            See https://raw.github.com/emberjs/ember.js/master/LICENSE
8  * @version   1.7.0-beta.4+pre.4b6ff143
9  */
10
11 (function() {
12     var define, requireModule, require, requirejs, Ember;
13
14     (function() {
15         Ember = this.Ember = this.Ember || {};
16         if (typeof Ember === 'undefined') {
17             Ember = {}
18         };
19
20         if (typeof Ember.__loader === 'undefined') {
21             var registry = {}, seen = {};
22
23             define = function(name, deps, callback) {
24                 registry[name] = {
25                     deps: deps,
26                     callback: callback 
27                 };
28             };
29
30             requirejs = require = requireModule = function(name) {
31                 if (seen.hasOwnProperty(name)) {
32                     return seen[name];
33                 }
34                 seen[name] = {};
35
36                 if (!registry[name]) {
37                     throw new Error("Could not find module " + name);
38                 }
39
40                 var mod = registry[name],
41                 deps = mod.deps,
42                 callback = mod.callback,
43                 reified = [],
44                 exports;
45
46                 for (var i = 0, l = deps.length; i < l; i++) {
47                     if (deps[i] === 'exports') {
48                         reified.push(exports = {});
49                     } else {
50                         reified.push(requireModule(resolve(deps[i])));
51                     }
52                 }
53
54                 var value = callback.apply(this, reified);
55                 return seen[name] = exports || value;
56
57                 function resolve(child) {
58                     if (child.charAt(0) !== '.') {
59                         return child;
60                     }
61                     var parts = child.split("/");
62                     var parentBase = name.split("/").slice(0, -1);
63
64                     for (var i = 0, l = parts.length; i < l; i++) {
65                         var part = parts[i];
66
67                         if (part === '..') {
68                             parentBase.pop();
69                         } else if (part === '.') {
70                             continue;
71                         } else {
72                             parentBase.push(part);
73                         }
74                     }
75
76                     return parentBase.join("/");
77                 }
78             };
79             requirejs._eak_seen = registry;
80
81             Ember.__loader = {
82                 define: define,
83                 require: require,
84                 registry: registry
85             };
86         } else {
87             define = Ember.__loader.define;
88             requirejs = require = requireModule = Ember.__loader.require;
89         }
90     })();
91
92     define("backburner",
93     ["backburner/utils", "backburner/deferred_action_queues", "exports"],
94     function(__dependency1__, __dependency2__, __exports__) {
95         "use strict";
96         var Utils = __dependency1__["default"];
97         var DeferredActionQueues = __dependency2__.DeferredActionQueues;
98
99         var slice = [].slice,
100         pop = [].pop,
101         each = Utils.each,
102         isString = Utils.isString,
103         isFunction = Utils.isFunction,
104         isNumber = Utils.isNumber,
105         timers = [],
106         global = this,
107         NUMBER = /\d+/;
108
109         // In IE 6-8, try/finally doesn't work without a catch.
110         // Unfortunately, this is impossible to test for since wrapping it in a parent try/catch doesn't trigger the bug.
111         // This tests for another broken try/catch behavior that only exhibits in the same versions of IE.
112         var needsIETryCatchFix = (function(e, x) {
113             try {
114                 x();
115             } catch (e) {}
116             // jshint ignore:line
117             return !!e;
118         })();
119
120         function isCoercableNumber(number) {
121             return isNumber(number) || NUMBER.test(number);
122         }
123
124         function Backburner(queueNames, options) {
125             this.queueNames = queueNames;
126             this.options = options || {};
127             if (!this.options.defaultQueue) {
128                 this.options.defaultQueue = queueNames[0];
129             }
130             this.instanceStack = [];
131             this._debouncees = [];
132             this._throttlers = [];
133         }
134
135         Backburner.prototype = {
136             queueNames: null,
137             options: null,
138             currentInstance: null,
139             instanceStack: null,
140
141             begin: function() {
142                 var options = this.options,
143                 onBegin = options && options.onBegin,
144                 previousInstance = this.currentInstance;
145
146                 if (previousInstance) {
147                     this.instanceStack.push(previousInstance);
148                 }
149
150                 this.currentInstance = new DeferredActionQueues(this.queueNames, options);
151                 if (onBegin) {
152                     onBegin(this.currentInstance, previousInstance);
153                 }
154             },
155
156             end: function() {
157                 var options = this.options,
158                 onEnd = options && options.onEnd,
159                 currentInstance = this.currentInstance,
160                 nextInstance = null;
161
162                 // Prevent double-finally bug in Safari 6.0.2 and iOS 6
163                 // This bug appears to be resolved in Safari 6.0.5 and iOS 7
164                 var finallyAlreadyCalled = false;
165                 try {
166                     currentInstance.flush();
167                 } finally {
168                     if (!finallyAlreadyCalled) {
169                         finallyAlreadyCalled = true;
170
171                         this.currentInstance = null;
172
173                         if (this.instanceStack.length) {
174                             nextInstance = this.instanceStack.pop();
175                             this.currentInstance = nextInstance;
176                         }
177
178                         if (onEnd) {
179                             onEnd(currentInstance, nextInstance);
180                         }
181                     }
182                 }
183             },
184
185             run: function(target, method /*, args */
186             ) {
187                 var onError = getOnError(this.options);
188
189                 this.begin();
190
191                 if (!method) {
192                     method = target;
193                     target = null;
194                 }
195
196                 if (isString(method)) {
197                     method = target[method];
198                 }
199
200                 var args = slice.call(arguments, 2);
201
202                 // guard against Safari 6's double-finally bug
203                 var didFinally = false;
204
205                 if (onError) {
206                     try {
207                         return method.apply(target, args);
208                     } catch (error) {
209                         onError(error);
210                     } finally {
211                         if (!didFinally) {
212                             didFinally = true;
213                             this.end();
214                         }
215                     }
216                 } else {
217                     try {
218                         return method.apply(target, args);
219                     } finally {
220                         if (!didFinally) {
221                             didFinally = true;
222                             this.end();
223                         }
224                     }
225                 }
226             },
227
228             defer: function(queueName, target, method /* , args */
229             ) {
230                 if (!method) {
231                     method = target;
232                     target = null;
233                 }
234
235                 if (isString(method)) {
236                     method = target[method];
237                 }
238
239                 var stack = this.DEBUG ? new Error() : undefined,
240                 args = arguments.length > 3 ? slice.call(arguments, 3) : undefined;
241                 if (!this.currentInstance) {
242                     createAutorun(this);
243                 }
244                 return this.currentInstance.schedule(queueName, target, method, args, false, stack);
245             },
246
247             deferOnce: function(queueName, target, method /* , args */
248             ) {
249                 if (!method) {
250                     method = target;
251                     target = null;
252                 }
253
254                 if (isString(method)) {
255                     method = target[method];
256                 }
257
258                 var stack = this.DEBUG ? new Error() : undefined,
259                 args = arguments.length > 3 ? slice.call(arguments, 3) : undefined;
260                 if (!this.currentInstance) {
261                     createAutorun(this);
262                 }
263                 return this.currentInstance.schedule(queueName, target, method, args, true, stack);
264             },
265
266             setTimeout: function() {
267                 var args = slice.call(arguments),
268                 length = args.length,
269                 method, wait, target,
270                 methodOrTarget, methodOrWait, methodOrArgs;
271
272                 if (length === 0) {
273                     return;
274                 } else if (length === 1) {
275                     method = args.shift();
276                     wait = 0;
277                 } else if (length === 2) {
278                     methodOrTarget = args[0];
279                     methodOrWait = args[1];
280
281                     if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) {
282                         target = args.shift();
283                         method = args.shift();
284                         wait = 0;
285                     } else if (isCoercableNumber(methodOrWait)) {
286                         method = args.shift();
287                         wait = args.shift();
288                     } else {
289                         method = args.shift();
290                         wait = 0;
291                     }
292                 } else {
293                     var last = args[args.length - 1];
294
295                     if (isCoercableNumber(last)) {
296                         wait = args.pop();
297                     } else {
298                         wait = 0;
299                     }
300
301                     methodOrTarget = args[0];
302                     methodOrArgs = args[1];
303
304                     if (isFunction(methodOrArgs) || (isString(methodOrArgs) &&
305                     methodOrTarget !== null &&
306                     methodOrArgs in methodOrTarget)) {
307                         target = args.shift();
308                         method = args.shift();
309                     } else {
310                         method = args.shift();
311                     }
312                 }
313
314                 var executeAt = ( + new Date()) + parseInt(wait, 10);
315
316                 if (isString(method)) {
317                     method = target[method];
318                 }
319
320                 var onError = getOnError(this.options);
321
322                 function fn() {
323                     if (onError) {
324                         try {
325                             method.apply(target, args);
326                         } catch (e) {
327                             onError(e);
328                         }
329                     } else {
330                         method.apply(target, args);
331                     }
332                 }
333
334                 // find position to insert
335                 var i = searchTimer(executeAt, timers);
336
337                 timers.splice(i, 0, executeAt, fn);
338
339                 updateLaterTimer(this, executeAt, wait);
340
341                 return fn;
342             },
343
344             throttle: function(target, method /* , args, wait, [immediate] */
345             ) {
346                 var self = this,
347                 args = arguments,
348                 immediate = pop.call(args),
349                 wait,
350                 throttler,
351                 index,
352                 timer;
353
354                 if (isNumber(immediate) || isString(immediate)) {
355                     wait = immediate;
356                     immediate = true;
357                 } else {
358                     wait = pop.call(args);
359                 }
360
361                 wait = parseInt(wait, 10);
362
363                 index = findThrottler(target, method, this._throttlers);
364                 if (index > -1) {
365                     return this._throttlers[index];
366                 }
367                 // throttled
368
369                 timer = global.setTimeout(function() {
370                     if (!immediate) {
371                         self.run.apply(self, args);
372                     }
373                     var index = findThrottler(target, method, self._throttlers);
374                     if (index > -1) {
375                         self._throttlers.splice(index, 1);
376                     }
377                 }, wait);
378
379                 if (immediate) {
380                     self.run.apply(self, args);
381                 }
382
383                 throttler = [target, method, timer];
384
385                 this._throttlers.push(throttler);
386
387                 return throttler;
388             },
389
390             debounce: function(target, method /* , args, wait, [immediate] */
391             ) {
392                 var self = this,
393                 args = arguments,
394                 immediate = pop.call(args),
395                 wait,
396                 index,
397                 debouncee,
398                 timer;
399
400                 if (isNumber(immediate) || isString(immediate)) {
401                     wait = immediate;
402                     immediate = false;
403                 } else {
404                     wait = pop.call(args);
405                 }
406
407                 wait = parseInt(wait, 10);
408                 // Remove debouncee
409                 index = findDebouncee(target, method, this._debouncees);
410
411                 if (index > -1) {
412                     debouncee = this._debouncees[index];
413                     this._debouncees.splice(index, 1);
414                     clearTimeout(debouncee[2]);
415                 }
416
417                 timer = global.setTimeout(function() {
418                     if (!immediate) {
419                         self.run.apply(self, args);
420                     }
421                     var index = findDebouncee(target, method, self._debouncees);
422                     if (index > -1) {
423                         self._debouncees.splice(index, 1);
424                     }
425                 }, wait);
426
427                 if (immediate && index === -1) {
428                     self.run.apply(self, args);
429                 }
430
431                 debouncee = [target, method, timer];
432
433                 self._debouncees.push(debouncee);
434
435                 return debouncee;
436             },
437
438             cancelTimers: function() {
439                 var clearItems = function(item) {
440                     clearTimeout(item[2]);
441                 };
442
443                 each(this._throttlers, clearItems);
444                 this._throttlers = [];
445
446                 each(this._debouncees, clearItems);
447                 this._debouncees = [];
448
449                 if (this._laterTimer) {
450                     clearTimeout(this._laterTimer);
451                     this._laterTimer = null;
452                 }
453                 timers = [];
454
455                 if (this._autorun) {
456                     clearTimeout(this._autorun);
457                     this._autorun = null;
458                 }
459             },
460
461             hasTimers: function() {
462                 return !!timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun;
463             },
464
465             cancel: function(timer) {
466                 var timerType = typeof timer;
467
468                 if (timer && timerType === 'object' && timer.queue && timer.method) {
469                     // we're cancelling a deferOnce
470                     return timer.queue.cancel(timer);
471                 } else if (timerType === 'function') {
472                     // we're cancelling a setTimeout
473                     for (var i = 0, l = timers.length; i < l; i += 2) {
474                         if (timers[i + 1] === timer) {
475                             timers.splice(i, 2); // remove the two elements
476                             return true;
477                         }
478                     }
479                 } else if (Object.prototype.toString.call(timer) === "[object Array]") {
480                     // we're cancelling a throttle or debounce
481                     return this._cancelItem(findThrottler, this._throttlers, timer) ||
482                     this._cancelItem(findDebouncee, this._debouncees, timer);
483                 } else {
484                     return; // timer was null or not a timer
485                 }
486             },
487
488             _cancelItem: function(findMethod, array, timer) {
489                 var item,
490                 index;
491
492                 if (timer.length < 3) {
493                     return false;
494                 }
495
496                 index = findMethod(timer[0], timer[1], array);
497
498                 if (index > -1) {
499
500                     item = array[index];
501
502                     if (item[2] === timer[2]) {
503                         array.splice(index, 1);
504                         clearTimeout(timer[2]);
505                         return true;
506                     }
507                 }
508
509                 return false;
510             }
511         };
512
513         Backburner.prototype.schedule = Backburner.prototype.defer;
514         Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce;
515         Backburner.prototype.later = Backburner.prototype.setTimeout;
516
517         if (needsIETryCatchFix) {
518             var originalRun = Backburner.prototype.run;
519             Backburner.prototype.run = wrapInTryCatch(originalRun);
520
521             var originalEnd = Backburner.prototype.end;
522             Backburner.prototype.end = wrapInTryCatch(originalEnd);
523         }
524
525         function wrapInTryCatch(func) {
526             return function () {
527                 try {
528                     return func.apply(this, arguments);
529                 } catch (e) {
530                     throw e;
531                 }
532             };
533         }
534
535         function getOnError(options) {
536             return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]);
537         }
538
539
540         function createAutorun(backburner) {
541             backburner.begin();
542             backburner._autorun = global.setTimeout(function() {
543                 backburner._autorun = null;
544                 backburner.end();
545             });
546         }
547
548         function updateLaterTimer(self, executeAt, wait) {
549             if (!self._laterTimer || executeAt < self._laterTimerExpiresAt) {
550                 self._laterTimer = global.setTimeout(function() {
551                     self._laterTimer = null;
552                     self._laterTimerExpiresAt = null;
553                     executeTimers(self);
554                 }, wait);
555                 self._laterTimerExpiresAt = executeAt;
556             }
557         }
558
559         function executeTimers(self) {
560             var now = + new Date(),
561             time, fns, i, l;
562
563             self.run(function() {
564                 i = searchTimer(now, timers);
565
566                 fns = timers.splice(0, i);
567
568                 for (i = 1, l = fns.length; i < l; i += 2) {
569                     self.schedule(self.options.defaultQueue, null, fns[i]);
570                 }
571             });
572
573             if (timers.length) {
574                 updateLaterTimer(self, timers[0], timers[0] - now);
575             }
576         }
577
578         function findDebouncee(target, method, debouncees) {
579             return findItem(target, method, debouncees);
580         }
581
582         function findThrottler(target, method, throttlers) {
583             return findItem(target, method, throttlers);
584         }
585
586         function findItem(target, method, collection) {
587             var item,
588             index = -1;
589
590             for (var i = 0, l = collection.length; i < l; i++) {
591                 item = collection[i];
592                 if (item[0] === target && item[1] === method) {
593                     index = i;
594                     break;
595                 }
596             }
597
598             return index;
599         }
600
601         function searchTimer(time, timers) {
602             var start = 0,
603             end = timers.length - 2,
604             middle, l;
605
606             while (start < end) {
607                 // since timers is an array of pairs 'l' will always
608                 // be an integer
609                 l = (end - start) / 2;
610
611                 // compensate for the index in case even number
612                 // of pairs inside timers
613                 middle = start + l - (l % 2);
614
615                 if (time >= timers[middle]) {
616                     start = middle + 2;
617                 } else {
618                     end = middle;
619                 }
620             }
621
622             return (time >= timers[start]) ? start + 2 : start;
623         }
624
625         __exports__.Backburner = Backburner;
626     });
627     define("backburner/deferred_action_queues",
628     ["backburner/utils", "backburner/queue", "exports"],
629     function(__dependency1__, __dependency2__, __exports__) {
630         "use strict";
631         var Utils = __dependency1__["default"];
632         var Queue = __dependency2__.Queue;
633
634         var each = Utils.each,
635         isString = Utils.isString;
636
637         function DeferredActionQueues(queueNames, options) {
638             var queues = this.queues = {};
639             this.queueNames = queueNames = queueNames || [];
640
641             this.options = options;
642
643             each(queueNames, function(queueName) {
644                 queues[queueName] = new Queue(this, queueName, options);
645             });
646         }
647
648         DeferredActionQueues.prototype = {
649             queueNames: null,
650             queues: null,
651             options: null,
652
653             schedule: function(queueName, target, method, args, onceFlag, stack) {
654                 var queues = this.queues,
655                 queue = queues[queueName];
656
657                 if (!queue) {
658                     throw new Error("You attempted to schedule an action in a queue (" + queueName + ") that doesn't exist");
659                 }
660
661                 if (onceFlag) {
662                     return queue.pushUnique(target, method, args, stack);
663                 } else {
664                     return queue.push(target, method, args, stack);
665                 }
666             },
667
668             invoke: function(target, method, args, _) {
669                 if (args && args.length > 0) {
670                     method.apply(target, args);
671                 } else {
672                     method.call(target);
673                 }
674             },
675
676             invokeWithOnError: function(target, method, args, onError) {
677                 try {
678                     if (args && args.length > 0) {
679                         method.apply(target, args);
680                     } else {
681                         method.call(target);
682                     }
683                 } catch (error) {
684                     onError(error);
685                 }
686             },
687
688             flush: function() {
689                 var queues = this.queues,
690                 queueNames = this.queueNames,
691                 queueName, queue, queueItems, priorQueueNameIndex,
692                 queueNameIndex = 0, numberOfQueues = queueNames.length,
693                 options = this.options,
694                 onError = options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]),
695                 invoke = onError ? this.invokeWithOnError : this.invoke;
696
697                 outerloop:
698                 while (queueNameIndex < numberOfQueues) {
699                     queueName = queueNames[queueNameIndex];
700                     queue = queues[queueName];
701                     queueItems = queue._queueBeingFlushed = queue._queue.slice();
702                     queue._queue = [];
703
704                     var queueOptions = queue.options, // TODO: write a test for this
705                     before = queueOptions && queueOptions.before,
706                     after = queueOptions && queueOptions.after,
707                     target, method, args, stack,
708                     queueIndex = 0, numberOfQueueItems = queueItems.length;
709
710                     if (numberOfQueueItems && before) {
711                         before();
712                     }
713
714                     while (queueIndex < numberOfQueueItems) {
715                         target = queueItems[queueIndex];
716                         method = queueItems[queueIndex + 1];
717                         args = queueItems[queueIndex + 2];
718                         stack = queueItems[queueIndex + 3]; // Debugging assistance
719
720                         if (isString(method)) {
721                             method = target[method];
722                         }
723
724                         // method could have been nullified / canceled during flush
725                         if (method) {
726                             invoke(target, method, args, onError);
727                         }
728
729                         queueIndex += 4;
730                     }
731
732                     queue._queueBeingFlushed = null;
733                     if (numberOfQueueItems && after) {
734                         after();
735                     }
736
737                     if ((priorQueueNameIndex = indexOfPriorQueueWithActions(this, queueNameIndex)) !== -1) {
738                         queueNameIndex = priorQueueNameIndex;
739                         continue outerloop;
740                     }
741
742                     queueNameIndex++;
743                 }
744             }
745         };
746
747         function indexOfPriorQueueWithActions(daq, currentQueueIndex) {
748             var queueName, queue;
749
750             for (var i = 0, l = currentQueueIndex; i <= l; i++) {
751                 queueName = daq.queueNames[i];
752                 queue = daq.queues[queueName];
753                 if (queue._queue.length) {
754                     return i;
755                 }
756             }
757
758             return -1;
759         }
760
761         __exports__.DeferredActionQueues = DeferredActionQueues;
762     });
763     define("backburner/queue",
764     ["exports"],
765     function(__exports__) {
766         "use strict";
767         function Queue(daq, name, options) {
768             this.daq = daq;
769             this.name = name;
770             this.globalOptions = options;
771             this.options = options[name];
772             this._queue = [];
773         }
774
775         Queue.prototype = {
776             daq: null,
777             name: null,
778             options: null,
779             onError: null,
780             _queue: null,
781
782             push: function(target, method, args, stack) {
783                 var queue = this._queue;
784                 queue.push(target, method, args, stack);
785                 return {
786                     queue: this,
787                     target: target,
788                     method: method
789                 };
790             },
791
792             pushUnique: function(target, method, args, stack) {
793                 var queue = this._queue, currentTarget, currentMethod, i, l;
794
795                 for (i = 0, l = queue.length; i < l; i += 4) {
796                     currentTarget = queue[i];
797                     currentMethod = queue[i + 1];
798
799                     if (currentTarget === target && currentMethod === method) {
800                         queue[i + 2] = args; // replace args
801                         queue[i + 3] = stack; // replace stack
802                         return {
803                             queue: this,
804                             target: target,
805                             method: method
806                         };
807                     }
808                 }
809
810                 queue.push(target, method, args, stack);
811                 return {
812                     queue: this,
813                     target: target,
814                     method: method
815                 };
816             },
817
818             // TODO: remove me, only being used for Ember.run.sync
819             flush: function() {
820                 var queue = this._queue,
821                 globalOptions = this.globalOptions,
822                 options = this.options,
823                 before = options && options.before,
824                 after = options && options.after,
825                 onError = globalOptions.onError || (globalOptions.onErrorTarget && globalOptions.onErrorTarget[globalOptions.onErrorMethod]),
826                 target, method, args, stack, i, l = queue.length;
827
828                 if (l && before) {
829                     before();
830                 }
831                 for (i = 0; i < l; i += 4) {
832                     target = queue[i];
833                     method = queue[i + 1];
834                     args = queue[i + 2];
835                     stack = queue[i + 3]; // Debugging assistance
836
837                     // TODO: error handling
838                     if (args && args.length > 0) {
839                         if (onError) {
840                             try {
841                                 method.apply(target, args);
842                             } catch (e) {
843                                 onError(e);
844                             }
845                         } else {
846                             method.apply(target, args);
847                         }
848                     } else {
849                         if (onError) {
850                             try {
851                                 method.call(target);
852                             } catch (e) {
853                                 onError(e);
854                             }
855                         } else {
856                             method.call(target);
857                         }
858                     }
859                 }
860                 if (l && after) {
861                     after();
862                 }
863
864                 // check if new items have been added
865                 if (queue.length > l) {
866                     this._queue = queue.slice(l);
867                     this.flush();
868                 } else {
869                     this._queue.length = 0;
870                 }
871             },
872
873             cancel: function(actionToCancel) {
874                 var queue = this._queue, currentTarget, currentMethod, i, l;
875
876                 for (i = 0, l = queue.length; i < l; i += 4) {
877                     currentTarget = queue[i];
878                     currentMethod = queue[i + 1];
879
880                     if (currentTarget === actionToCancel.target && currentMethod === actionToCancel.method) {
881                         queue.splice(i, 4);
882                         return true;
883                     }
884                 }
885
886                 // if not found in current queue
887                 // could be in the queue that is being flushed
888                 queue = this._queueBeingFlushed;
889                 if (!queue) {
890                     return;
891                 }
892                 for (i = 0, l = queue.length; i < l; i += 4) {
893                     currentTarget = queue[i];
894                     currentMethod = queue[i + 1];
895
896                     if (currentTarget === actionToCancel.target && currentMethod === actionToCancel.method) {
897                         // don't mess with array during flush
898                         // just nullify the method
899                         queue[i + 1] = null;
900                         return true;
901                     }
902                 }
903             }
904         };
905
906         __exports__.Queue = Queue;
907     });
908     define("backburner/utils",
909     ["exports"],
910     function(__exports__) {
911         "use strict";
912         __exports__["default"] = {
913             each: function(collection, callback) {
914                 for (var i = 0; i < collection.length; i++) {
915                     callback(collection[i]);
916                 }
917             },
918
919             isString: function(suspect) {
920                 return typeof suspect === 'string';
921             },
922
923             isFunction: function(suspect) {
924                 return typeof suspect === 'function';
925             },
926
927             isNumber: function(suspect) {
928                 return typeof suspect === 'number';
929             }
930         };
931     });
932
933     define("container",
934     ["container/container", "exports"],
935     function(__dependency1__, __exports__) {
936         "use strict";
937         /*
938             Public api for the container is still in flux.
939             The public api, specified on the application namespace should be considered the stable api.
940             // @module container
941               @private
942             */
943
944         /*
945              Flag to enable/disable model factory injections (disabled by default)
946              If model factory injections are enabled, models should not be
947              accessed globally (only through `container.lookupFactory('model:modelName'))`);
948             */
949         Ember.MODEL_FACTORY_INJECTIONS = false;
950
951         if (Ember.ENV && typeof Ember.ENV.MODEL_FACTORY_INJECTIONS !== 'undefined') {
952             Ember.MODEL_FACTORY_INJECTIONS = !!Ember.ENV.MODEL_FACTORY_INJECTIONS;
953         }
954
955
956         var Container = __dependency1__["default"];
957
958         __exports__["default"] = Container;
959     });
960     define("container/container",
961     ["container/inheriting_dict", "ember-metal/core", "exports"],
962     function(__dependency1__, __dependency2__, __exports__) {
963         "use strict";
964         var InheritingDict = __dependency1__["default"];
965         var Ember = __dependency2__["default"];
966         // Ember.assert
967
968         // A lightweight container that helps to assemble and decouple components.
969         // Public api for the container is still in flux.
970         // The public api, specified on the application namespace should be considered the stable api.
971         function Container(parent) {
972             this.parent = parent;
973             this.children = [];
974
975             this.resolver = parent && parent.resolver || function() {};
976
977             this.registry = new InheritingDict(parent && parent.registry);
978             this.cache = new InheritingDict(parent && parent.cache);
979             this.factoryCache = new InheritingDict(parent && parent.factoryCache);
980             this.resolveCache = new InheritingDict(parent && parent.resolveCache);
981             this.typeInjections = new InheritingDict(parent && parent.typeInjections);
982             this.injections = {};
983
984             this.factoryTypeInjections = new InheritingDict(parent && parent.factoryTypeInjections);
985             this.factoryInjections = {};
986
987             this._options = new InheritingDict(parent && parent._options);
988             this._typeOptions = new InheritingDict(parent && parent._typeOptions);
989         }
990
991         Container.prototype = {
992
993             /**
994                     @property parent
995                     @type Container
996                     @default null
997                   */
998             parent: null,
999
1000             /**
1001                     @property children
1002                     @type Array
1003                     @default []
1004                   */
1005             children: null,
1006
1007             /**
1008                     @property resolver
1009                     @type function
1010                   */
1011             resolver: null,
1012
1013             /**
1014                     @property registry
1015                     @type InheritingDict
1016                   */
1017             registry: null,
1018
1019             /**
1020                     @property cache
1021                     @type InheritingDict
1022                   */
1023             cache: null,
1024
1025             /**
1026                     @property typeInjections
1027                     @type InheritingDict
1028                   */
1029             typeInjections: null,
1030
1031             /**
1032                     @property injections
1033                     @type Object
1034                     @default {}
1035                   */
1036             injections: null,
1037
1038             /**
1039                     @private
1040
1041                     @property _options
1042                     @type InheritingDict
1043                     @default null
1044                   */
1045             _options: null,
1046
1047             /**
1048                     @private
1049
1050                     @property _typeOptions
1051                     @type InheritingDict
1052                   */
1053             _typeOptions: null,
1054
1055             /**
1056                     Returns a new child of the current container. These children are configured
1057                     to correctly inherit from the current container.
1058
1059                     @method child
1060                     @return {Container}
1061                   */
1062             child: function() {
1063                 var container = new Container(this);
1064                 this.children.push(container);
1065                 return container;
1066             },
1067
1068             /**
1069                     Sets a key-value pair on the current container. If a parent container,
1070                     has the same key, once set on a child, the parent and child will diverge
1071                     as expected.
1072
1073                     @method set
1074                     @param {Object} object
1075                     @param {String} key
1076                     @param {any} value
1077                   */
1078             set: function(object, key, value) {
1079                 object[key] = value;
1080             },
1081
1082             /**
1083                     Registers a factory for later injection.
1084
1085                     Example:
1086
1087                     ```javascript
1088                     var container = new Container();
1089
1090                     container.register('model:user', Person, {singleton: false });
1091                     container.register('fruit:favorite', Orange);
1092                     container.register('communication:main', Email, {singleton: false});
1093                     ```
1094
1095                     @method register
1096                     @param {String} fullName
1097                     @param {Function} factory
1098                     @param {Object} options
1099                   */
1100             register: function(fullName, factory, options) {
1101                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1102
1103                 if (factory === undefined) {
1104                     throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`');
1105                 }
1106
1107                 var normalizedName = this.normalize(fullName);
1108
1109                 if (this.cache.has(normalizedName)) {
1110                     throw new Error('Cannot re-register: `' + fullName + '`, as it has already been looked up.');
1111                 }
1112
1113                 this.registry.set(normalizedName, factory);
1114                 this._options.set(normalizedName, options || {});
1115             },
1116
1117             /**
1118                     Unregister a fullName
1119
1120                     ```javascript
1121                     var container = new Container();
1122                     container.register('model:user', User);
1123
1124                     container.lookup('model:user') instanceof User //=> true
1125
1126                     container.unregister('model:user')
1127                     container.lookup('model:user') === undefined //=> true
1128                     ```
1129
1130                     @method unregister
1131                     @param {String} fullName
1132                    */
1133             unregister: function(fullName) {
1134                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1135
1136                 var normalizedName = this.normalize(fullName);
1137
1138                 this.registry.remove(normalizedName);
1139                 this.cache.remove(normalizedName);
1140                 this.factoryCache.remove(normalizedName);
1141                 this.resolveCache.remove(normalizedName);
1142                 this._options.remove(normalizedName);
1143             },
1144
1145             /**
1146                     Given a fullName return the corresponding factory.
1147
1148                     By default `resolve` will retrieve the factory from
1149                     its container's registry.
1150
1151                     ```javascript
1152                     var container = new Container();
1153                     container.register('api:twitter', Twitter);
1154
1155                     container.resolve('api:twitter') // => Twitter
1156                     ```
1157
1158                     Optionally the container can be provided with a custom resolver.
1159                     If provided, `resolve` will first provide the custom resolver
1160                     the opportunity to resolve the fullName, otherwise it will fallback
1161                     to the registry.
1162
1163                     ```javascript
1164                     var container = new Container();
1165                     container.resolver = function(fullName) {
1166                       // lookup via the module system of choice
1167                     };
1168
1169                     // the twitter factory is added to the module system
1170                     container.resolve('api:twitter') // => Twitter
1171                     ```
1172
1173                     @method resolve
1174                     @param {String} fullName
1175                     @return {Function} fullName's factory
1176                   */
1177             resolve: function(fullName) {
1178                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1179                 return resolve(this, this.normalize(fullName));
1180             },
1181
1182             /**
1183                     A hook that can be used to describe how the resolver will
1184                     attempt to find the factory.
1185
1186                     For example, the default Ember `.describe` returns the full
1187                     class name (including namespace) where Ember's resolver expects
1188                     to find the `fullName`.
1189
1190                     @method describe
1191                     @param {String} fullName
1192                     @return {string} described fullName
1193                   */
1194             describe: function(fullName) {
1195                 return fullName;
1196             },
1197
1198             /**
1199                     A hook to enable custom fullName normalization behaviour
1200
1201                     @method normalize
1202                     @param {String} fullName
1203                     @return {string} normalized fullName
1204                   */
1205             normalize: function(fullName) {
1206                 return fullName;
1207             },
1208
1209             /**
1210                     @method makeToString
1211
1212                     @param {any} factory
1213                     @param {string} fullName
1214                     @return {function} toString function
1215                   */
1216             makeToString: function(factory, fullName) {
1217                 return factory.toString();
1218             },
1219
1220             /**
1221                     Given a fullName return a corresponding instance.
1222
1223                     The default behaviour is for lookup to return a singleton instance.
1224                     The singleton is scoped to the container, allowing multiple containers
1225                     to all have their own locally scoped singletons.
1226
1227                     ```javascript
1228                     var container = new Container();
1229                     container.register('api:twitter', Twitter);
1230
1231                     var twitter = container.lookup('api:twitter');
1232
1233                     twitter instanceof Twitter; // => true
1234
1235                     // by default the container will return singletons
1236                     var twitter2 = container.lookup('api:twitter');
1237                     twitter2 instanceof Twitter; // => true
1238
1239                     twitter === twitter2; //=> true
1240                     ```
1241
1242                     If singletons are not wanted an optional flag can be provided at lookup.
1243
1244                     ```javascript
1245                     var container = new Container();
1246                     container.register('api:twitter', Twitter);
1247
1248                     var twitter = container.lookup('api:twitter', { singleton: false });
1249                     var twitter2 = container.lookup('api:twitter', { singleton: false });
1250
1251                     twitter === twitter2; //=> false
1252                     ```
1253
1254                     @method lookup
1255                     @param {String} fullName
1256                     @param {Object} options
1257                     @return {any}
1258                   */
1259             lookup: function(fullName, options) {
1260                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1261                 return lookup(this, this.normalize(fullName), options);
1262             },
1263
1264             /**
1265                     Given a fullName return the corresponding factory.
1266
1267                     @method lookupFactory
1268                     @param {String} fullName
1269                     @return {any}
1270                   */
1271             lookupFactory: function(fullName) {
1272                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1273                 return factoryFor(this, this.normalize(fullName));
1274             },
1275
1276             /**
1277                     Given a fullName check if the container is aware of its factory
1278                     or singleton instance.
1279
1280                     @method has
1281                     @param {String} fullName
1282                     @return {Boolean}
1283                   */
1284             has: function(fullName) {
1285                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1286                 return has(this, this.normalize(fullName));
1287             },
1288
1289             /**
1290                     Allow registering options for all factories of a type.
1291
1292                     ```javascript
1293                     var container = new Container();
1294
1295                     // if all of type `connection` must not be singletons
1296                     container.optionsForType('connection', { singleton: false });
1297
1298                     container.register('connection:twitter', TwitterConnection);
1299                     container.register('connection:facebook', FacebookConnection);
1300
1301                     var twitter = container.lookup('connection:twitter');
1302                     var twitter2 = container.lookup('connection:twitter');
1303
1304                     twitter === twitter2; // => false
1305
1306                     var facebook = container.lookup('connection:facebook');
1307                     var facebook2 = container.lookup('connection:facebook');
1308
1309                     facebook === facebook2; // => false
1310                     ```
1311
1312                     @method optionsForType
1313                     @param {String} type
1314                     @param {Object} options
1315                   */
1316             optionsForType: function(type, options) {
1317                 if (this.parent) {
1318                     illegalChildOperation('optionsForType');
1319                 }
1320
1321                 this._typeOptions.set(type, options);
1322             },
1323
1324             /**
1325                     @method options
1326                     @param {String} type
1327                     @param {Object} options
1328                   */
1329             options: function(type, options) {
1330                 this.optionsForType(type, options);
1331             },
1332
1333             /**
1334                     Used only via `injection`.
1335
1336                     Provides a specialized form of injection, specifically enabling
1337                     all objects of one type to be injected with a reference to another
1338                     object.
1339
1340                     For example, provided each object of type `controller` needed a `router`.
1341                     one would do the following:
1342
1343                     ```javascript
1344                     var container = new Container();
1345
1346                     container.register('router:main', Router);
1347                     container.register('controller:user', UserController);
1348                     container.register('controller:post', PostController);
1349
1350                     container.typeInjection('controller', 'router', 'router:main');
1351
1352                     var user = container.lookup('controller:user');
1353                     var post = container.lookup('controller:post');
1354
1355                     user.router instanceof Router; //=> true
1356                     post.router instanceof Router; //=> true
1357
1358                     // both controllers share the same router
1359                     user.router === post.router; //=> true
1360                     ```
1361
1362                     @private
1363                     @method typeInjection
1364                     @param {String} type
1365                     @param {String} property
1366                     @param {String} fullName
1367                   */
1368             typeInjection: function(type, property, fullName) {
1369                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1370                 if (this.parent) {
1371                     illegalChildOperation('typeInjection');
1372                 }
1373
1374                 var fullNameType = fullName.split(':')[0];
1375                 if (fullNameType === type) {
1376                     throw new Error('Cannot inject a `' + fullName + '` on other ' + type + '(s). Register the `' + fullName + '` as a different type and perform the typeInjection.');
1377                 }
1378                 addTypeInjection(this.typeInjections, type, property, fullName);
1379             },
1380
1381             /**
1382                     Defines injection rules.
1383
1384                     These rules are used to inject dependencies onto objects when they
1385                     are instantiated.
1386
1387                     Two forms of injections are possible:
1388
1389                     * Injecting one fullName on another fullName
1390                     * Injecting one fullName on a type
1391
1392                     Example:
1393
1394                     ```javascript
1395                     var container = new Container();
1396
1397                     container.register('source:main', Source);
1398                     container.register('model:user', User);
1399                     container.register('model:post', Post);
1400
1401                     // injecting one fullName on another fullName
1402                     // eg. each user model gets a post model
1403                     container.injection('model:user', 'post', 'model:post');
1404
1405                     // injecting one fullName on another type
1406                     container.injection('model', 'source', 'source:main');
1407
1408                     var user = container.lookup('model:user');
1409                     var post = container.lookup('model:post');
1410
1411                     user.source instanceof Source; //=> true
1412                     post.source instanceof Source; //=> true
1413
1414                     user.post instanceof Post; //=> true
1415
1416                     // and both models share the same source
1417                     user.source === post.source; //=> true
1418                     ```
1419
1420                     @method injection
1421                     @param {String} factoryName
1422                     @param {String} property
1423                     @param {String} injectionName
1424                   */
1425             injection: function(fullName, property, injectionName) {
1426                 if (this.parent) {
1427                     illegalChildOperation('injection');
1428                 }
1429
1430                 validateFullName(injectionName);
1431                 var normalizedInjectionName = this.normalize(injectionName);
1432
1433                 if (fullName.indexOf(':') === -1) {
1434                     return this.typeInjection(fullName, property, normalizedInjectionName);
1435                 }
1436
1437                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1438                 var normalizedName = this.normalize(fullName);
1439
1440                 if (this.cache.has(normalizedName)) {
1441                     throw new Error("Attempted to register an injection for a type that has already been looked up. ('" + normalizedName + "', '" + property + "', '" + injectionName + "')");
1442                 }
1443                 addInjection(this.injections, normalizedName, property, normalizedInjectionName);
1444             },
1445
1446
1447             /**
1448                     Used only via `factoryInjection`.
1449
1450                     Provides a specialized form of injection, specifically enabling
1451                     all factory of one type to be injected with a reference to another
1452                     object.
1453
1454                     For example, provided each factory of type `model` needed a `store`.
1455                     one would do the following:
1456
1457                     ```javascript
1458                     var container = new Container();
1459
1460                     container.register('store:main', SomeStore);
1461
1462                     container.factoryTypeInjection('model', 'store', 'store:main');
1463
1464                     var store = container.lookup('store:main');
1465                     var UserFactory = container.lookupFactory('model:user');
1466
1467                     UserFactory.store instanceof SomeStore; //=> true
1468                     ```
1469
1470                     @private
1471                     @method factoryTypeInjection
1472                     @param {String} type
1473                     @param {String} property
1474                     @param {String} fullName
1475                   */
1476             factoryTypeInjection: function(type, property, fullName) {
1477                 if (this.parent) {
1478                     illegalChildOperation('factoryTypeInjection');
1479                 }
1480
1481                 addTypeInjection(this.factoryTypeInjections, type, property, this.normalize(fullName));
1482             },
1483
1484             /**
1485                     Defines factory injection rules.
1486
1487                     Similar to regular injection rules, but are run against factories, via
1488                     `Container#lookupFactory`.
1489
1490                     These rules are used to inject objects onto factories when they
1491                     are looked up.
1492
1493                     Two forms of injections are possible:
1494
1495                   * Injecting one fullName on another fullName
1496                   * Injecting one fullName on a type
1497
1498                     Example:
1499
1500                     ```javascript
1501                     var container = new Container();
1502
1503                     container.register('store:main', Store);
1504                     container.register('store:secondary', OtherStore);
1505                     container.register('model:user', User);
1506                     container.register('model:post', Post);
1507
1508                     // injecting one fullName on another type
1509                     container.factoryInjection('model', 'store', 'store:main');
1510
1511                     // injecting one fullName on another fullName
1512                     container.factoryInjection('model:post', 'secondaryStore', 'store:secondary');
1513
1514                     var UserFactory = container.lookupFactory('model:user');
1515                     var PostFactory = container.lookupFactory('model:post');
1516                     var store = container.lookup('store:main');
1517
1518                     UserFactory.store instanceof Store; //=> true
1519                     UserFactory.secondaryStore instanceof OtherStore; //=> false
1520
1521                     PostFactory.store instanceof Store; //=> true
1522                     PostFactory.secondaryStore instanceof OtherStore; //=> true
1523
1524                     // and both models share the same source instance
1525                     UserFactory.store === PostFactory.store; //=> true
1526                     ```
1527
1528                     @method factoryInjection
1529                     @param {String} factoryName
1530                     @param {String} property
1531                     @param {String} injectionName
1532                   */
1533             factoryInjection: function(fullName, property, injectionName) {
1534                 if (this.parent) {
1535                     illegalChildOperation('injection');
1536                 }
1537
1538                 var normalizedName = this.normalize(fullName);
1539                 var normalizedInjectionName = this.normalize(injectionName);
1540
1541                 validateFullName(injectionName);
1542
1543                 if (fullName.indexOf(':') === -1) {
1544                     return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName);
1545                 }
1546
1547                 Ember.assert('fullName must be a proper full name', validateFullName(fullName));
1548
1549                 if (this.factoryCache.has(normalizedName)) {
1550                     throw new Error('Attempted to register a factoryInjection for a type that has already ' +
1551                     'been looked up. (\'' + normalizedName + '\', \'' + property + '\', \'' + injectionName + '\')');
1552                 }
1553
1554                 addInjection(this.factoryInjections, normalizedName, property, normalizedInjectionName);
1555             },
1556
1557             /**
1558                     A depth first traversal, destroying the container, its descendant containers and all
1559                     their managed objects.
1560
1561                     @method destroy
1562                   */
1563             destroy: function() {
1564                 for (var i = 0, length = this.children.length; i < length; i++) {
1565                     this.children[i].destroy();
1566                 }
1567
1568                 this.children = [];
1569
1570                 eachDestroyable(this, function(item) {
1571                     item.destroy();
1572                 });
1573
1574                 this.parent = undefined;
1575                 this.isDestroyed = true;
1576             },
1577
1578             /**
1579                     @method reset
1580                   */
1581             reset: function() {
1582                 for (var i = 0, length = this.children.length; i < length; i++) {
1583                     resetCache(this.children[i]);
1584                 }
1585
1586                 resetCache(this);
1587             }
1588         };
1589
1590         function resolve(container, normalizedName) {
1591             var cached = container.resolveCache.get(normalizedName);
1592             if (cached) {
1593                 return cached;
1594             }
1595
1596             var resolved = container.resolver(normalizedName) || container.registry.get(normalizedName);
1597             container.resolveCache.set(normalizedName, resolved);
1598
1599             return resolved;
1600         }
1601
1602         function has(container, fullName) {
1603             if (container.cache.has(fullName)) {
1604                 return true;
1605             }
1606
1607             return !!container.resolve(fullName);
1608         }
1609
1610         function lookup(container, fullName, options) {
1611             options = options || {};
1612
1613             if (container.cache.has(fullName) && options.singleton !== false) {
1614                 return container.cache.get(fullName);
1615             }
1616
1617             var value = instantiate(container, fullName);
1618
1619             if (value === undefined) {
1620                 return;
1621             }
1622
1623             if (isSingleton(container, fullName) && options.singleton !== false) {
1624                 container.cache.set(fullName, value);
1625             }
1626
1627             return value;
1628         }
1629
1630         function illegalChildOperation(operation) {
1631             throw new Error(operation + ' is not currently supported on child containers');
1632         }
1633
1634         function isSingleton(container, fullName) {
1635             var singleton = option(container, fullName, 'singleton');
1636
1637             return singleton !== false;
1638         }
1639
1640         function buildInjections(container, injections) {
1641             var hash = {};
1642
1643             if (!injections) {
1644                 return hash;
1645             }
1646
1647             var injection, injectable;
1648
1649             for (var i = 0, length = injections.length; i < length; i++) {
1650                 injection = injections[i];
1651                 injectable = lookup(container, injection.fullName);
1652
1653                 if (injectable !== undefined) {
1654                     hash[injection.property] = injectable;
1655                 } else {
1656                     throw new Error('Attempting to inject an unknown injection: `' + injection.fullName + '`');
1657                 }
1658             }
1659
1660             return hash;
1661         }
1662
1663         function option(container, fullName, optionName) {
1664             var options = container._options.get(fullName);
1665
1666             if (options && options[optionName] !== undefined) {
1667                 return options[optionName];
1668             }
1669
1670             var type = fullName.split(':')[0];
1671             options = container._typeOptions.get(type);
1672
1673             if (options) {
1674                 return options[optionName];
1675             }
1676         }
1677
1678         function factoryFor(container, fullName) {
1679             var cache = container.factoryCache;
1680             if (cache.has(fullName)) {
1681                 return cache.get(fullName);
1682             }
1683             var factory = container.resolve(fullName);
1684             if (factory === undefined) {
1685                 return;
1686             }
1687
1688             var type = fullName.split(':')[0];
1689             if (!factory || typeof factory.extend !== 'function' || (!Ember.MODEL_FACTORY_INJECTIONS && type === 'model')) {
1690                 // TODO: think about a 'safe' merge style extension
1691                 // for now just fallback to create time injection
1692                 return factory;
1693             } else {
1694                 var injections = injectionsFor(container, fullName);
1695                 var factoryInjections = factoryInjectionsFor(container, fullName);
1696
1697                 factoryInjections._toString = container.makeToString(factory, fullName);
1698
1699                 var injectedFactory = factory.extend(injections);
1700                 injectedFactory.reopenClass(factoryInjections);
1701
1702                 cache.set(fullName, injectedFactory);
1703
1704                 return injectedFactory;
1705             }
1706         }
1707
1708         function injectionsFor(container, fullName) {
1709             var splitName = fullName.split(':'),
1710             type = splitName[0],
1711             injections = [];
1712
1713             injections = injections.concat(container.typeInjections.get(type) || []);
1714             injections = injections.concat(container.injections[fullName] || []);
1715
1716             injections = buildInjections(container, injections);
1717             injections._debugContainerKey = fullName;
1718             injections.container = container;
1719
1720             return injections;
1721         }
1722
1723         function factoryInjectionsFor(container, fullName) {
1724             var splitName = fullName.split(':'),
1725             type = splitName[0],
1726             factoryInjections = [];
1727
1728             factoryInjections = factoryInjections.concat(container.factoryTypeInjections.get(type) || []);
1729             factoryInjections = factoryInjections.concat(container.factoryInjections[fullName] || []);
1730
1731             factoryInjections = buildInjections(container, factoryInjections);
1732             factoryInjections._debugContainerKey = fullName;
1733
1734             return factoryInjections;
1735         }
1736
1737         function instantiate(container, fullName) {
1738             var factory = factoryFor(container, fullName);
1739
1740             if (option(container, fullName, 'instantiate') === false) {
1741                 return factory;
1742             }
1743
1744             if (factory) {
1745                 if (typeof factory.create !== 'function') {
1746                     throw new Error('Failed to create an instance of \'' + fullName + '\'. ' +
1747                     'Most likely an improperly defined class or an invalid module export.');
1748                 }
1749
1750                 if (typeof factory.extend === 'function') {
1751                     // assume the factory was extendable and is already injected
1752                     return factory.create();
1753                 } else {
1754                     // assume the factory was extendable
1755                     // to create time injections
1756                     // TODO: support new'ing for instantiation and merge injections for pure JS Functions
1757                     return factory.create(injectionsFor(container, fullName));
1758                 }
1759             }
1760         }
1761
1762         function eachDestroyable(container, callback) {
1763             container.cache.eachLocal(function(key, value) {
1764                 if (option(container, key, 'instantiate') === false) {
1765                     return;
1766                 }
1767                 callback(value);
1768             });
1769         }
1770
1771         function resetCache(container) {
1772             container.cache.eachLocal(function(key, value) {
1773                 if (option(container, key, 'instantiate') === false) {
1774                     return;
1775                 }
1776                 value.destroy();
1777             });
1778             container.cache.dict = {};
1779         }
1780
1781         function addTypeInjection(rules, type, property, fullName) {
1782             var injections = rules.get(type);
1783
1784             if (!injections) {
1785                 injections = [];
1786                 rules.set(type, injections);
1787             }
1788
1789             injections.push({
1790                 property: property,
1791                 fullName: fullName
1792             });
1793         }
1794
1795         var VALID_FULL_NAME_REGEXP = /^[^:]+.+:[^:]+$/;
1796         function validateFullName(fullName) {
1797             if (!VALID_FULL_NAME_REGEXP.test(fullName)) {
1798                 throw new TypeError('Invalid Fullname, expected: `type:name` got: ' + fullName);
1799             }
1800             return true;
1801         }
1802
1803         function addInjection(rules, factoryName, property, injectionName) {
1804             var injections = rules[factoryName] = rules[factoryName] || [];
1805             injections.push({
1806                 property: property,
1807                 fullName: injectionName 
1808             });
1809         }
1810
1811         __exports__["default"] = Container;
1812     });
1813     define("container/inheriting_dict",
1814     ["exports"],
1815     function(__exports__) {
1816         "use strict";
1817         // A safe and simple inheriting object.
1818         function InheritingDict(parent) {
1819             this.parent = parent;
1820             this.dict = {};
1821         }
1822
1823         InheritingDict.prototype = {
1824
1825             /**
1826                     @property parent
1827                     @type InheritingDict
1828                     @default null
1829                   */
1830
1831             parent: null,
1832
1833             /**
1834                     Object used to store the current nodes data.
1835
1836                     @property dict
1837                     @type Object
1838                     @default Object
1839                   */
1840             dict: null,
1841
1842             /**
1843                     Retrieve the value given a key, if the value is present at the current
1844                     level use it, otherwise walk up the parent hierarchy and try again. If
1845                     no matching key is found, return undefined.
1846
1847                     @method get
1848                     @param {String} key
1849                     @return {any}
1850                   */
1851             get: function(key) {
1852                 var dict = this.dict;
1853
1854                 if (dict.hasOwnProperty(key)) {
1855                     return dict[key];
1856                 }
1857
1858                 if (this.parent) {
1859                     return this.parent.get(key);
1860                 }
1861             },
1862
1863             /**
1864                     Set the given value for the given key, at the current level.
1865
1866                     @method set
1867                     @param {String} key
1868                     @param {Any} value
1869                   */
1870             set: function(key, value) {
1871                 this.dict[key] = value;
1872             },
1873
1874             /**
1875                     Delete the given key
1876
1877                     @method remove
1878                     @param {String} key
1879                   */
1880             remove: function(key) {
1881                 delete this.dict[key];
1882             },
1883
1884             /**
1885                     Check for the existence of given a key, if the key is present at the current
1886                     level return true, otherwise walk up the parent hierarchy and try again. If
1887                     no matching key is found, return false.
1888
1889                     @method has
1890                     @param {String} key
1891                     @return {Boolean}
1892                   */
1893             has: function(key) {
1894                 var dict = this.dict;
1895
1896                 if (dict.hasOwnProperty(key)) {
1897                     return true;
1898                 }
1899
1900                 if (this.parent) {
1901                     return this.parent.has(key);
1902                 }
1903
1904                 return false;
1905             },
1906
1907             /**
1908                     Iterate and invoke a callback for each local key-value pair.
1909
1910                     @method eachLocal
1911                     @param {Function} callback
1912                     @param {Object} binding
1913                   */
1914             eachLocal: function(callback, binding) {
1915                 var dict = this.dict;
1916
1917                 for (var prop in dict) {
1918                     if (dict.hasOwnProperty(prop)) {
1919                         callback.call(binding, prop, dict[prop]);
1920                     }
1921                 }
1922             }
1923         };
1924
1925         __exports__["default"] = InheritingDict;
1926     });
1927     define("ember-application",
1928     ["ember-metal/core", "ember-runtime/system/lazy_load", "ember-application/system/dag", "ember-application/system/resolver", "ember-application/system/application", "ember-application/ext/controller"],
1929     function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {
1930         "use strict";
1931         var Ember = __dependency1__["default"];
1932         var runLoadHooks = __dependency2__.runLoadHooks;
1933
1934         /**
1935             Ember Application
1936
1937             @module ember
1938             @submodule ember-application
1939             @requires ember-views, ember-routing
1940             */
1941
1942         var DAG = __dependency3__["default"];
1943         var Resolver = __dependency4__.Resolver;
1944         var DefaultResolver = __dependency4__["default"];
1945         var Application = __dependency5__["default"];
1946         // side effect of extending ControllerMixin
1947
1948         Ember.Application = Application;
1949         Ember.DAG = DAG;
1950         Ember.Resolver = Resolver;
1951         Ember.DefaultResolver = DefaultResolver;
1952
1953         runLoadHooks('Ember.Application', Application);
1954     });
1955     define("ember-application/ext/controller",
1956     ["ember-metal/core", "ember-metal/property_get", "ember-metal/property_set", "ember-metal/error", "ember-metal/utils", "ember-metal/computed", "ember-runtime/mixins/controller", "ember-routing/system/controller_for", "exports"],
1957     function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) {
1958         "use strict";
1959         /**
1960             @module ember
1961             @submodule ember-application
1962             */
1963
1964         var Ember = __dependency1__["default"];
1965         // Ember.assert
1966         var get = __dependency2__.get;
1967         var set = __dependency3__.set;
1968         var EmberError = __dependency4__["default"];
1969         var inspect = __dependency5__.inspect;
1970         var computed = __dependency6__.computed;
1971         var ControllerMixin = __dependency7__["default"];
1972         var meta = __dependency5__.meta;
1973         var controllerFor = __dependency8__["default"];
1974
1975         function verifyNeedsDependencies(controller, container, needs) {
1976             var dependency, i, l, missing = [];
1977
1978             for (i = 0, l = needs.length; i < l; i++) {
1979                 dependency = needs[i];
1980
1981                 Ember.assert(inspect(controller) + "#needs must not specify dependencies with periods in their names (" + dependency + ")", dependency.indexOf('.') === -1);
1982
1983                 if (dependency.indexOf(':') === -1) {
1984                     dependency = "controller:" + dependency;
1985                 }
1986
1987                 // Structure assert to still do verification but not string concat in production
1988                 if (!container.has(dependency)) {
1989                     missing.push(dependency);
1990                 }
1991             }
1992             if (missing.length) {
1993                 throw new EmberError(inspect(controller) + " needs [ " + missing.join(', ') + " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
1994             }
1995         }
1996
1997         var defaultControllersComputedProperty = computed(function() {
1998             var controller = this;
1999
2000             return {
2001                 needs: get(controller, 'needs'),
2002                 container: get(controller, 'container'),
2003                 unknownProperty: function(controllerName) {
2004                     var needs = this.needs,
2005                     dependency, i, l;
2006                     for (i = 0, l = needs.length; i < l; i++) {
2007                         dependency = needs[i];
2008                         if (dependency === controllerName) {
2009                             return this.container.lookup('controller:' + controllerName);
2010                         }
2011                     }
2012
2013                     var errorMessage = inspect(controller) + '#needs does not include `' + controllerName + '`. To access the ' + controllerName + ' controller from ' + inspect(controller) + ', ' + inspect(controller) + ' should have a `needs` property that is an array of the controllers it has access to.';
2014                     throw new ReferenceError(errorMessage);
2015                 },
2016                 setUnknownProperty: function (key, value) {
2017                     throw new Error("You cannot overwrite the value of `controllers." + key + "` of " + inspect(controller));
2018                 }
2019             };
2020         });
2021
2022         /**
2023               @class ControllerMixin
2024               @namespace Ember
2025             */
2026         ControllerMixin.reopen({
2027             concatenatedProperties: ['needs'],
2028
2029             /**
2030                     An array of other controller objects available inside
2031                     instances of this controller via the `controllers`
2032                     property:
2033
2034                     For example, when you define a controller:
2035
2036                     ```javascript
2037                     App.CommentsController = Ember.ArrayController.extend({
2038                       needs: ['post']
2039                     });
2040                     ```
2041
2042                     The application's single instance of these other
2043                     controllers are accessible by name through the
2044                     `controllers` property:
2045
2046                     ```javascript
2047                     this.get('controllers.post'); // instance of App.PostController
2048                     ```
2049
2050                     Given that you have a nested controller (nested resource):
2051
2052                     ```javascript
2053                     App.CommentsNewController = Ember.ObjectController.extend({
2054                     });
2055                     ```
2056
2057                     When you define a controller that requires access to a nested one:
2058
2059                     ```javascript
2060                     App.IndexController = Ember.ObjectController.extend({
2061                       needs: ['commentsNew']
2062                     });
2063                     ```
2064
2065                     You will be able to get access to it:
2066
2067                     ```javascript
2068                     this.get('controllers.commentsNew'); // instance of App.CommentsNewController
2069                     ```
2070
2071                     This is only available for singleton controllers.
2072
2073                     @property {Array} needs
2074                     @default []
2075                   */
2076             needs: [],
2077
2078             init: function() {
2079                 var needs = get(this, 'needs');
2080                 var length = get(needs, 'length');
2081
2082                 if (length > 0) {
2083                     Ember.assert(' `' + inspect(this) + ' specifies `needs`, but does ' +
2084                     "not have a container. Please ensure this controller was " +
2085                     "instantiated with a container.",
2086                     this.container || meta(this, false).descs.controllers !== defaultControllersComputedProperty);
2087
2088                     if (this.container) {
2089                         verifyNeedsDependencies(this, this.container, needs);
2090                     }
2091
2092                     // if needs then initialize controllers proxy
2093                     get(this, 'controllers');
2094                 }
2095
2096                 this._super.apply(this, arguments);
2097             },
2098
2099             /**
2100                     @method controllerFor
2101                     @see {Ember.Route#controllerFor}
2102                     @deprecated Use `needs` instead
2103                   */
2104             controllerFor: function(controllerName) {
2105                 Ember.deprecate("Controller#controllerFor is deprecated, please use Controller#needs instead");
2106                 return controllerFor(get(this, 'container'), controllerName);
2107             },
2108
2109             /**
2110                     Stores the instances of other controllers available from within
2111                     this controller. Any controller listed by name in the `needs`
2112                     property will be accessible by name through this property.
2113
2114                     ```javascript
2115                     App.CommentsController = Ember.ArrayController.extend({
2116                       needs: ['post'],
2117                       postTitle: function(){
2118                         var currentPost = this.get('controllers.post'); // instance of App.PostController
2119                         return currentPost.get('title');
2120                       }.property('controllers.post.title')
2121                     });
2122                     ```
2123
2124                     @see {Ember.ControllerMixin#needs}
2125                     @property {Object} controllers
2126                     @default null
2127                   */
2128             controllers: defaultControllersComputedProperty
2129         });
2130
2131         __exports__["default"] = ControllerMixin;
2132     });
2133     define("ember-application/system/application",
2134     ["ember-metal", "ember-metal/property_get", "ember-metal/property_set", "ember-runtime/system/lazy_load", "ember-application/system/dag", "ember-runtime/system/namespace", "ember-runtime/mixins/deferred", "ember-application/system/resolver", "ember-metal/platform", "ember-metal/run_loop", "ember-metal/utils", "container/container", "ember-runtime/controllers/controller", "ember-metal/enumerable_utils", "ember-runtime/controllers/object_controller", "ember-runtime/controllers/array_controller", "ember-views/system/event_dispatcher", "ember-views/system/jquery", "ember-routing/system/route", "ember-routing/system/router", "ember-routing/location/hash_location", "ember-routing/location/history_location", "ember-routing/location/auto_location", "ember-routing/location/none_location", "ember-routing/system/cache", "ember-metal/core", "ember-handlebars-compiler", "ember-application/system/deprecated-container", "exports"],
2135     function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __dependency23__, __dependency24__, __dependency25__, __dependency26__, __dependency27__, __dependency28__, __exports__) {
2136         "use strict";
2137         /**
2138             @module ember
2139             @submodule ember-application
2140             */
2141
2142         var Ember = __dependency1__["default"];
2143         // Ember.FEATURES, Ember.deprecate, Ember.assert, Ember.libraries, LOG_VERSION, Namespace, BOOTED
2144         var get = __dependency2__.get;
2145         var set = __dependency3__.set;
2146         var runLoadHooks = __dependency4__.runLoadHooks;
2147         var DAG = __dependency5__["default"];
2148         var Namespace = __dependency6__["default"];
2149         var DeferredMixin = __dependency7__["default"];
2150         var DefaultResolver = __dependency8__["default"];
2151         var create = __dependency9__.create;
2152         var run = __dependency10__["default"];
2153         var canInvoke = __dependency11__.canInvoke;
2154         var Container = __dependency12__["default"];
2155         var Controller = __dependency13__["default"];
2156         var EnumerableUtils = __dependency14__["default"];
2157         var ObjectController = __dependency15__["default"];
2158         var ArrayController = __dependency16__["default"];
2159         var EventDispatcher = __dependency17__["default"];
2160         //import ContainerDebugAdapter from "ember-extension-support/container_debug_adapter";
2161         var jQuery = __dependency18__["default"];
2162         var Route = __dependency19__["default"];
2163         var Router = __dependency20__["default"];
2164         var HashLocation = __dependency21__["default"];
2165         var HistoryLocation = __dependency22__["default"];
2166         var AutoLocation = __dependency23__["default"];
2167         var NoneLocation = __dependency24__["default"];
2168         var BucketCache = __dependency25__["default"];
2169
2170         var K = __dependency26__.K;
2171         var EmberHandlebars = __dependency27__["default"];
2172         var DeprecatedContainer = __dependency28__["default"];
2173
2174         var ContainerDebugAdapter;
2175
2176         /**
2177               An instance of `Ember.Application` is the starting point for every Ember
2178               application. It helps to instantiate, initialize and coordinate the many
2179               objects that make up your app.
2180
2181               Each Ember app has one and only one `Ember.Application` object. In fact, the
2182               very first thing you should do in your application is create the instance:
2183
2184               ```javascript
2185               window.App = Ember.Application.create();
2186               ```
2187
2188               Typically, the application object is the only global variable. All other
2189               classes in your app should be properties on the `Ember.Application` instance,
2190               which highlights its first role: a global namespace.
2191
2192               For example, if you define a view class, it might look like this:
2193
2194               ```javascript
2195               App.MyView = Ember.View.extend();
2196               ```
2197
2198               By default, calling `Ember.Application.create()` will automatically initialize
2199               your application by calling the `Ember.Application.initialize()` method. If
2200               you need to delay initialization, you can call your app's `deferReadiness()`
2201               method. When you are ready for your app to be initialized, call its
2202               `advanceReadiness()` method.
2203
2204               You can define a `ready` method on the `Ember.Application` instance, which
2205               will be run by Ember when the application is initialized.
2206
2207               Because `Ember.Application` inherits from `Ember.Namespace`, any classes
2208               you create will have useful string representations when calling `toString()`.
2209               See the `Ember.Namespace` documentation for more information.
2210
2211               While you can think of your `Ember.Application` as a container that holds the
2212               other classes in your application, there are several other responsibilities
2213               going on under-the-hood that you may want to understand.
2214
2215               ### Event Delegation
2216
2217               Ember uses a technique called _event delegation_. This allows the framework
2218               to set up a global, shared event listener instead of requiring each view to
2219               do it manually. For example, instead of each view registering its own
2220               `mousedown` listener on its associated element, Ember sets up a `mousedown`
2221               listener on the `body`.
2222
2223               If a `mousedown` event occurs, Ember will look at the target of the event and
2224               start walking up the DOM node tree, finding corresponding views and invoking
2225               their `mouseDown` method as it goes.
2226
2227               `Ember.Application` has a number of default events that it listens for, as
2228               well as a mapping from lowercase events to camel-cased view method names. For
2229               example, the `keypress` event causes the `keyPress` method on the view to be
2230               called, the `dblclick` event causes `doubleClick` to be called, and so on.
2231
2232               If there is a bubbling browser event that Ember does not listen for by
2233               default, you can specify custom events and their corresponding view method
2234               names by setting the application's `customEvents` property:
2235
2236               ```javascript
2237               App = Ember.Application.create({
2238                 customEvents: {
2239                   // add support for the paste event
2240                   paste: "paste"
2241                 }
2242               });
2243               ```
2244
2245               By default, the application sets up these event listeners on the document
2246               body. However, in cases where you are embedding an Ember application inside
2247               an existing page, you may want it to set up the listeners on an element
2248               inside the body.
2249
2250               For example, if only events inside a DOM element with the ID of `ember-app`
2251               should be delegated, set your application's `rootElement` property:
2252
2253               ```javascript
2254               window.App = Ember.Application.create({
2255                 rootElement: '#ember-app'
2256               });
2257               ```
2258
2259               The `rootElement` can be either a DOM element or a jQuery-compatible selector
2260               string. Note that *views appended to the DOM outside the root element will
2261               not receive events.* If you specify a custom root element, make sure you only
2262               append views inside it!
2263
2264               To learn more about the advantages of event delegation and the Ember view
2265               layer, and a list of the event listeners that are setup by default, visit the
2266               [Ember View Layer guide](http://emberjs.com/guides/understanding-ember/the-view-layer/#toc_event-delegation).
2267
2268               ### Initializers
2269
2270               Libraries on top of Ember can add initializers, like so:
2271
2272               ```javascript
2273               Ember.Application.initializer({
2274                 name: 'api-adapter',
2275
2276                 initialize: function(container, application) {
2277                   application.register('api-adapter:main', ApiAdapter);
2278                 }
2279               });
2280               ```
2281
2282               Initializers provide an opportunity to access the container, which
2283               organizes the different components of an Ember application. Additionally
2284               they provide a chance to access the instantiated application. Beyond
2285               being used for libraries, initializers are also a great way to organize
2286               dependency injection or setup in your own application.
2287
2288               ### Routing
2289
2290               In addition to creating your application's router, `Ember.Application` is
2291               also responsible for telling the router when to start routing. Transitions
2292               between routes can be logged with the `LOG_TRANSITIONS` flag, and more
2293               detailed intra-transition logging can be logged with
2294               the `LOG_TRANSITIONS_INTERNAL` flag:
2295
2296               ```javascript
2297               window.App = Ember.Application.create({
2298                 LOG_TRANSITIONS: true, // basic logging of successful transitions
2299                 LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps
2300               });
2301               ```
2302
2303               By default, the router will begin trying to translate the current URL into
2304               application state once the browser emits the `DOMContentReady` event. If you
2305               need to defer routing, you can call the application's `deferReadiness()`
2306               method. Once routing can begin, call the `advanceReadiness()` method.
2307
2308               If there is any setup required before routing begins, you can implement a
2309               `ready()` method on your app that will be invoked immediately before routing
2310               begins.
2311               ```
2312
2313               @class Application
2314               @namespace Ember
2315               @extends Ember.Namespace
2316             */
2317
2318         var Application = Namespace.extend(DeferredMixin, {
2319             _suppressDeferredDeprecation: true,
2320
2321             /**
2322                     The root DOM element of the Application. This can be specified as an
2323                     element or a
2324                     [jQuery-compatible selector string](http://api.jquery.com/category/selectors/).
2325
2326                     This is the element that will be passed to the Application's,
2327                     `eventDispatcher`, which sets up the listeners for event delegation. Every
2328                     view in your application should be a child of the element you specify here.
2329
2330                     @property rootElement
2331                     @type DOMElement
2332                     @default 'body'
2333                   */
2334             rootElement: 'body',
2335
2336             /**
2337                     The `Ember.EventDispatcher` responsible for delegating events to this
2338                     application's views.
2339
2340                     The event dispatcher is created by the application at initialization time
2341                     and sets up event listeners on the DOM element described by the
2342                     application's `rootElement` property.
2343
2344                     See the documentation for `Ember.EventDispatcher` for more information.
2345
2346                     @property eventDispatcher
2347                     @type Ember.EventDispatcher
2348                     @default null
2349                   */
2350             eventDispatcher: null,
2351
2352             /**
2353                     The DOM events for which the event dispatcher should listen.
2354
2355                     By default, the application's `Ember.EventDispatcher` listens
2356                     for a set of standard DOM events, such as `mousedown` and
2357                     `keyup`, and delegates them to your application's `Ember.View`
2358                     instances.
2359
2360                     If you would like additional bubbling events to be delegated to your
2361                     views, set your `Ember.Application`'s `customEvents` property
2362                     to a hash containing the DOM event name as the key and the
2363                     corresponding view method name as the value. For example:
2364
2365                     ```javascript
2366                     App = Ember.Application.create({
2367                       customEvents: {
2368                         // add support for the paste event
2369                         paste: "paste"
2370                       }
2371                     });
2372                     ```
2373
2374                     @property customEvents
2375                     @type Object
2376                     @default null
2377                   */
2378             customEvents: null,
2379
2380             // Start off the number of deferrals at 1. This will be
2381             // decremented by the Application's own `initialize` method.
2382             _readinessDeferrals: 1,
2383
2384             init: function() {
2385                 if (!this.$) {
2386                     this.$ = jQuery;
2387                 }
2388                 this.__container__ = this.buildContainer();
2389
2390                 this.Router = this.defaultRouter();
2391
2392                 this._super();
2393
2394                 this.scheduleInitialize();
2395
2396                 Ember.libraries.registerCoreLibrary('Handlebars', EmberHandlebars.VERSION);
2397                 Ember.libraries.registerCoreLibrary('jQuery', jQuery().jquery);
2398
2399                 if ( Ember.LOG_VERSION ) {
2400                     Ember.LOG_VERSION = false; // we only need to see this once per Application#init
2401
2402                     var nameLengths = EnumerableUtils.map(Ember.libraries, function(item) {
2403                         return get(item, "name.length");
2404                     });
2405
2406                     var maxNameLength = Math.max.apply(this, nameLengths);
2407
2408                     Ember.debug('-------------------------------');
2409                     Ember.libraries.each(function(name, version) {
2410                         var spaces = new Array(maxNameLength - name.length + 1).join(" ");
2411                         Ember.debug([name, spaces, ' : ', version].join(""));
2412                     });
2413                     Ember.debug('-------------------------------');
2414                 }
2415             },
2416
2417             /**
2418                     Build the container for the current application.
2419
2420                     Also register a default application view in case the application
2421                     itself does not.
2422
2423                     @private
2424                     @method buildContainer
2425                     @return {Ember.Container} the configured container
2426                   */
2427             buildContainer: function() {
2428                 var container = this.__container__ = Application.buildContainer(this);
2429
2430                 return container;
2431             },
2432
2433             /**
2434                     If the application has not opted out of routing and has not explicitly
2435                     defined a router, supply a default router for the application author
2436                     to configure.
2437
2438                     This allows application developers to do:
2439
2440                     ```javascript
2441                     var App = Ember.Application.create();
2442
2443                     App.Router.map(function() {
2444                       this.resource('posts');
2445                     });
2446                     ```
2447
2448                     @private
2449                     @method defaultRouter
2450                     @return {Ember.Router} the default router
2451                   */
2452
2453             defaultRouter: function() {
2454                 if (this.Router === false) {
2455                     return;
2456                 }
2457                 var container = this.__container__;
2458
2459                 if (this.Router) {
2460                     container.unregister('router:main');
2461                     container.register('router:main', this.Router);
2462                 }
2463
2464                 return container.lookupFactory('router:main');
2465             },
2466
2467             /**
2468                     Automatically initialize the application once the DOM has
2469                     become ready.
2470
2471                     The initialization itself is scheduled on the actions queue
2472                     which ensures that application loading finishes before
2473                     booting.
2474
2475                     If you are asynchronously loading code, you should call
2476                     `deferReadiness()` to defer booting, and then call
2477                     `advanceReadiness()` once all of your code has finished
2478                     loading.
2479
2480                     @private
2481                     @method scheduleInitialize
2482                   */
2483             scheduleInitialize: function() {
2484                 var self = this;
2485
2486                 if (!this.$ || this.$.isReady) {
2487                     run.schedule('actions', self, '_initialize');
2488                 } else {
2489                     this.$().ready(function runInitialize() {
2490                         run(self, '_initialize');
2491                     });
2492                 }
2493             },
2494
2495             /**
2496                     Use this to defer readiness until some condition is true.
2497
2498                     Example:
2499
2500                     ```javascript
2501                     App = Ember.Application.create();
2502                     App.deferReadiness();
2503
2504                     jQuery.getJSON("/auth-token", function(token) {
2505                       App.token = token;
2506                       App.advanceReadiness();
2507                     });
2508                     ```
2509
2510                     This allows you to perform asynchronous setup logic and defer
2511                     booting your application until the setup has finished.
2512
2513                     However, if the setup requires a loading UI, it might be better
2514                     to use the router for this purpose.
2515
2516                     @method deferReadiness
2517                   */
2518             deferReadiness: function() {
2519                 Ember.assert("You must call deferReadiness on an instance of Ember.Application", this instanceof Application);
2520                 Ember.assert("You cannot defer readiness since the `ready()` hook has already been called.", this._readinessDeferrals > 0);
2521                 this._readinessDeferrals++;
2522             },
2523
2524             /**
2525                     Call `advanceReadiness` after any asynchronous setup logic has completed.
2526                     Each call to `deferReadiness` must be matched by a call to `advanceReadiness`
2527                     or the application will never become ready and routing will not begin.
2528
2529                     @method advanceReadiness
2530                     @see {Ember.Application#deferReadiness}
2531                   */
2532             advanceReadiness: function() {
2533                 Ember.assert("You must call advanceReadiness on an instance of Ember.Application", this instanceof Application);
2534                 this._readinessDeferrals--;
2535
2536                 if (this._readinessDeferrals === 0) {
2537                     run.once(this, this.didBecomeReady);
2538                 }
2539             },
2540
2541             /**
2542                     Registers a factory that can be used for dependency injection (with
2543                     `App.inject`) or for service lookup. Each factory is registered with
2544                     a full name including two parts: `type:name`.
2545
2546                     A simple example:
2547
2548                     ```javascript
2549                     var App = Ember.Application.create();
2550                     App.Orange  = Ember.Object.extend();
2551                     App.register('fruit:favorite', App.Orange);
2552                     ```
2553
2554                     Ember will resolve factories from the `App` namespace automatically.
2555                     For example `App.CarsController` will be discovered and returned if
2556                     an application requests `controller:cars`.
2557
2558                     An example of registering a controller with a non-standard name:
2559
2560                     ```javascript
2561                     var App = Ember.Application.create(),
2562                         Session  = Ember.Controller.extend();
2563
2564                     App.register('controller:session', Session);
2565
2566                     // The Session controller can now be treated like a normal controller,
2567                     // despite its non-standard name.
2568                     App.ApplicationController = Ember.Controller.extend({
2569                       needs: ['session']
2570                     });
2571                     ```
2572
2573                     Registered factories are **instantiated** by having `create`
2574                     called on them. Additionally they are **singletons**, each time
2575                     they are looked up they return the same instance.
2576
2577                     Some examples modifying that default behavior:
2578
2579                     ```javascript
2580                     var App = Ember.Application.create();
2581
2582                     App.Person  = Ember.Object.extend();
2583                     App.Orange  = Ember.Object.extend();
2584                     App.Email   = Ember.Object.extend();
2585                     App.session = Ember.Object.create();
2586
2587                     App.register('model:user', App.Person, {singleton: false });
2588                     App.register('fruit:favorite', App.Orange);
2589                     App.register('communication:main', App.Email, {singleton: false});
2590                     App.register('session', App.session, {instantiate: false});
2591                     ```
2592
2593                     @method register
2594                     @param  fullName {String} type:name (e.g., 'model:user')
2595                     @param  factory {Function} (e.g., App.Person)
2596                     @param  options {Object} (optional) disable instantiation or singleton usage
2597                   **/
2598             register: function() {
2599                 var container = this.__container__;
2600                 container.register.apply(container, arguments);
2601             },
2602
2603             /**
2604                     Define a dependency injection onto a specific factory or all factories
2605                     of a type.
2606
2607                     When Ember instantiates a controller, view, or other framework component
2608                     it can attach a dependency to that component. This is often used to
2609                     provide services to a set of framework components.
2610
2611                     An example of providing a session object to all controllers:
2612
2613                     ```javascript
2614                     var App = Ember.Application.create(),
2615                         Session = Ember.Object.extend({ isAuthenticated: false });
2616
2617                     // A factory must be registered before it can be injected
2618                     App.register('session:main', Session);
2619
2620                     // Inject 'session:main' onto all factories of the type 'controller'
2621                     // with the name 'session'
2622                     App.inject('controller', 'session', 'session:main');
2623
2624                     App.IndexController = Ember.Controller.extend({
2625                       isLoggedIn: Ember.computed.alias('session.isAuthenticated')
2626                     });
2627                     ```
2628
2629                     Injections can also be performed on specific factories.
2630
2631                     ```javascript
2632                     App.inject(<full_name or type>, <property name>, <full_name>)
2633                     App.inject('route', 'source', 'source:main')
2634                     App.inject('route:application', 'email', 'model:email')
2635                     ```
2636
2637                     It is important to note that injections can only be performed on
2638                     classes that are instantiated by Ember itself. Instantiating a class
2639                     directly (via `create` or `new`) bypasses the dependency injection
2640                     system.
2641
2642                     Ember-Data instantiates its models in a unique manner, and consequently
2643                     injections onto models (or all models) will not work as expected. Injections
2644                     on models can be enabled by setting `Ember.MODEL_FACTORY_INJECTIONS`
2645                     to `true`.
2646
2647                     @method inject
2648                     @param  factoryNameOrType {String}
2649                     @param  property {String}
2650                     @param  injectionName {String}
2651                   **/
2652             inject: function() {
2653                 var container = this.__container__;
2654                 container.injection.apply(container, arguments);
2655             },
2656
2657             /**
2658                     Calling initialize manually is not supported.
2659
2660                     Please see Ember.Application#advanceReadiness and
2661                     Ember.Application#deferReadiness.
2662
2663                     @private
2664                     @deprecated
2665                     @method initialize
2666                    **/
2667             initialize: function() {
2668                 Ember.deprecate('Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness');
2669             },
2670
2671             /**
2672                     Initialize the application. This happens automatically.
2673
2674                     Run any initializers and run the application load hook. These hooks may
2675                     choose to defer readiness. For example, an authentication hook might want
2676                     to defer readiness until the auth token has been retrieved.
2677
2678                     @private
2679                     @method _initialize
2680                   */
2681             _initialize: function() {
2682                 if (this.isDestroyed) {
2683                     return;
2684                 }
2685
2686                 // At this point, the App.Router must already be assigned
2687                 if (this.Router) {
2688                     var container = this.__container__;
2689                     container.unregister('router:main');
2690                     container.register('router:main', this.Router);
2691                 }
2692
2693                 this.runInitializers();
2694                 runLoadHooks('application', this);
2695
2696                 // At this point, any initializers or load hooks that would have wanted
2697                 // to defer readiness have fired. In general, advancing readiness here
2698                 // will proceed to didBecomeReady.
2699                 this.advanceReadiness();
2700
2701                 return this;
2702             },
2703
2704             /**
2705                     Reset the application. This is typically used only in tests. It cleans up
2706                     the application in the following order:
2707
2708                     1. Deactivate existing routes
2709                     2. Destroy all objects in the container
2710                     3. Create a new application container
2711                     4. Re-route to the existing url
2712
2713                     Typical Example:
2714
2715                     ```javascript
2716
2717                     var App;
2718
2719                     run(function() {
2720                       App = Ember.Application.create();
2721                     });
2722
2723                     module("acceptance test", {
2724                       setup: function() {
2725                         App.reset();
2726                       }
2727                     });
2728
2729                     test("first test", function() {
2730                       // App is freshly reset
2731                     });
2732
2733                     test("first test", function() {
2734                       // App is again freshly reset
2735                     });
2736                     ```
2737
2738                     Advanced Example:
2739
2740                     Occasionally you may want to prevent the app from initializing during
2741                     setup. This could enable extra configuration, or enable asserting prior
2742                     to the app becoming ready.
2743
2744                     ```javascript
2745
2746                     var App;
2747
2748                     run(function() {
2749                       App = Ember.Application.create();
2750                     });
2751
2752                     module("acceptance test", {
2753                       setup: function() {
2754                         run(function() {
2755                           App.reset();
2756                           App.deferReadiness();
2757                         });
2758                       }
2759                     });
2760
2761                     test("first test", function() {
2762                       ok(true, 'something before app is initialized');
2763
2764                       run(function() {
2765                         App.advanceReadiness();
2766                       });
2767                       ok(true, 'something after app is initialized');
2768                     });
2769                     ```
2770
2771                     @method reset
2772                   **/
2773             reset: function() {
2774                 this._readinessDeferrals = 1;
2775
2776                 function handleReset() {
2777                     var router = this.__container__.lookup('router:main');
2778                     router.reset();
2779
2780                     run(this.__container__, 'destroy');
2781
2782                     this.buildContainer();
2783
2784                     run.schedule('actions', this, function() {
2785                         this._initialize();
2786                     });
2787                 }
2788
2789                 run.join(this, handleReset);
2790             },
2791
2792             /**
2793                     @private
2794                     @method runInitializers
2795                   */
2796             runInitializers: function() {
2797                 var initializers = get(this.constructor, 'initializers');
2798                 var container = this.__container__;
2799                 var graph = new DAG();
2800                 var namespace = this;
2801                 var name, initializer;
2802
2803                 for (name in initializers) {
2804                     initializer = initializers[name];
2805                     graph.addEdges(initializer.name, initializer.initialize, initializer.before, initializer.after);
2806                 }
2807
2808                 graph.topsort(function (vertex) {
2809                     var initializer = vertex.value;
2810                     Ember.assert("No application initializer named '" + vertex.name + "'", initializer);
2811                     initializer(container, namespace);
2812                 });
2813             },
2814
2815             /**
2816                     @private
2817                     @method didBecomeReady
2818                   */
2819             didBecomeReady: function() {
2820                 this.setupEventDispatcher();
2821                 this.ready(); // user hook
2822                 this.startRouting();
2823
2824                 if (!Ember.testing) {
2825                     // Eagerly name all classes that are already loaded
2826                     Ember.Namespace.processAll();
2827                     Ember.BOOTED = true;
2828                 }
2829
2830                 this.resolve(this);
2831             },
2832
2833             /**
2834                     Setup up the event dispatcher to receive events on the
2835                     application's `rootElement` with any registered
2836                     `customEvents`.
2837
2838                     @private
2839                     @method setupEventDispatcher
2840                   */
2841             setupEventDispatcher: function() {
2842                 var customEvents = get(this, 'customEvents');
2843                 var rootElement = get(this, 'rootElement');
2844                 var dispatcher = this.__container__.lookup('event_dispatcher:main');
2845
2846                 set(this, 'eventDispatcher', dispatcher);
2847                 dispatcher.setup(customEvents, rootElement);
2848             },
2849
2850             /**
2851                     If the application has a router, use it to route to the current URL, and
2852                     trigger a new call to `route` whenever the URL changes.
2853
2854                     @private
2855                     @method startRouting
2856                     @property router {Ember.Router}
2857                   */
2858             startRouting: function() {
2859                 var router = this.__container__.lookup('router:main');
2860                 if (!router) {
2861                     return;
2862                 }
2863
2864                 router.startRouting();
2865             },
2866
2867             handleURL: function(url) {
2868                 var router = this.__container__.lookup('router:main');
2869
2870                 router.handleURL(url);
2871             },
2872
2873             /**
2874                     Called when the Application has become ready.
2875                     The call will be delayed until the DOM has become ready.
2876
2877                     @event ready
2878                   */
2879             ready: K,
2880
2881             /**
2882                     @deprecated Use 'Resolver' instead
2883                     Set this to provide an alternate class to `Ember.DefaultResolver`
2884
2885
2886                     @property resolver
2887                   */
2888             resolver: null,
2889
2890             /**
2891                     Set this to provide an alternate class to `Ember.DefaultResolver`
2892
2893                     @property resolver
2894                   */
2895             Resolver: null,
2896
2897             willDestroy: function() {
2898                 Ember.BOOTED = false;
2899                 // Ensure deactivation of routes before objects are destroyed
2900                 this.__container__.lookup('router:main').reset();
2901
2902                 this.__container__.destroy();
2903             },
2904
2905             initializer: function(options) {
2906                 this.constructor.initializer(options);
2907             },
2908
2909             /**
2910                     @method then
2911                     @private
2912                     @deprecated
2913                   */
2914             then: function() {
2915                 Ember.deprecate('Do not use `.then` on an instance of Ember.Application.  Please use the `.ready` hook instead.');
2916
2917                 this._super.apply(this, arguments);
2918             }
2919         });
2920
2921         Application.reopenClass({
2922             initializers: {},
2923
2924             /**
2925                     Initializer receives an object which has the following attributes:
2926                     `name`, `before`, `after`, `initialize`. The only required attribute is
2927                     `initialize, all others are optional.
2928
2929                     * `name` allows you to specify under which name the initializer is registered.
2930                     This must be a unique name, as trying to register two initializers with the
2931                     same name will result in an error.
2932
2933                     ```javascript
2934                     Ember.Application.initializer({
2935                       name: 'namedInitializer',
2936                       initialize: function(container, application) {
2937                         Ember.debug("Running namedInitializer!");
2938                       }
2939                     });
2940                     ```
2941
2942                     * `before` and `after` are used to ensure that this initializer is ran prior
2943                     or after the one identified by the value. This value can be a single string
2944                     or an array of strings, referencing the `name` of other initializers.
2945
2946                     An example of ordering initializers, we create an initializer named `first`:
2947
2948                     ```javascript
2949                     Ember.Application.initializer({
2950                       name: 'first',
2951                       initialize: function(container, application) {
2952                         Ember.debug("First initializer!");
2953                       }
2954                     });
2955
2956                     // DEBUG: First initializer!
2957                     ```
2958
2959                     We add another initializer named `second`, specifying that it should run
2960                     after the initializer named `first`:
2961
2962                     ```javascript
2963                     Ember.Application.initializer({
2964                       name: 'second',
2965                       after: 'first',
2966
2967                       initialize: function(container, application) {
2968     &