diff --git a/bower.json b/bower.json index db32fd3c1..a21ce7f5d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ember", - "version": "2.11.0-beta.2", + "version": "2.10.0-intercom", "license": "MIT", "homepage": "https://github.com/emberjs/ember.js", "main": [ diff --git a/component.json b/component.json index e1096c62e..7b009bc70 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "ember", "repo": "components/ember", - "version": "2.11.0-beta.2", + "version": "2.10.0-intercom", "license": "MIT", "homepage": "https://github.com/emberjs/ember.js", "main": "ember.debug.js", diff --git a/composer.json b/composer.json index 73f8310a9..e90a93698 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,5 @@ } } }, - "version": "2.11.0-beta.2" + "version": "2.10.0-intercom" } diff --git a/ember-runtime.js b/ember-runtime.js index 815220803..f443c2e07 100644 --- a/ember-runtime.js +++ b/ember-runtime.js @@ -6,10 +6,11 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.10.0-intercom */ var enifed, requireModule, Ember; +var mainContext = this; (function() { var isNode = typeof window === 'undefined' && @@ -111,6 +112,8 @@ var enifed, requireModule, Ember; } })(); +var babelHelpers; + function inherits(subClass, superClass) { subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { @@ -1458,7 +1461,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e var factoryInjections = factoryInjectionsFor(container, fullName); var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + factoryInjections._toString = registry.makeToString(factory, fullName); var injectedFactory = factory.extend(injections); @@ -5337,6 +5340,7 @@ enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-me exports.removeObserver = _emberMetalObserver.removeObserver; exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.NAME_KEY = _emberMetalMixin.NAME_KEY; exports.Mixin = _emberMetalMixin.Mixin; exports.aliasMethod = _emberMetalMixin.aliasMethod; exports._immediateObserver = _emberMetalMixin._immediateObserver; @@ -7375,32 +7379,20 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function applyConcatenatedProperties(obj, key, value, values) { var baseValue = values[key] || obj[key]; - var ret = undefined; if (baseValue) { if ('function' === typeof baseValue.concat) { if (value === null || value === undefined) { - ret = baseValue; + return baseValue; } else { - ret = baseValue.concat(value); + return baseValue.concat(value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + return _emberUtils.makeArray(baseValue).concat(value); } } else { - ret = _emberUtils.makeArray(value); + return _emberUtils.makeArray(value); } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; } function applyMergedProperties(obj, key, value, values) { @@ -7676,6 +7668,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb return obj; } + var NAME_KEY = _emberUtils.GUID_KEY + '_name'; + + exports.NAME_KEY = NAME_KEY; /** The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, @@ -7758,7 +7753,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb this.ownerConstructor = undefined; this._without = undefined; this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; + this[NAME_KEY] = null; _emberMetalDebug.debugSeal(this); } @@ -10145,7 +10140,7 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; + return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; })(), false); shouldReflush = true; @@ -13200,6 +13195,8 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi args[_key - 1] = arguments[_key]; } + var target = undefined; + if (this.actions && this.actions[actionName]) { var shouldBubble = this.actions[actionName].apply(this, args) === true; if (!shouldBubble) { @@ -13207,10 +13204,11 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi } } - var target = _emberMetal.get(this, 'target'); - if (target) { + if (target = _emberMetal.get(this, 'target')) { + var _target; + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + (_target = target).send.apply(_target, arguments); } }, @@ -13631,7 +13629,7 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' /** This returns the objects at the specified indexes, using `objectAt`. ```javascript - let arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] ``` @@ -14571,8 +14569,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta for (var idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - if (found) { + if (found = callback.call(target, next, idx, this)) { ret = next; } @@ -17365,7 +17362,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met // using ember-metal/lib/main here to ensure that ember-debug is setup // if present - var _Mixin$create, _ClassMixinProps; + var _Mixin$create; var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); @@ -17624,7 +17621,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met CoreObject.__super__ = null; - var ClassMixinProps = (_ClassMixinProps = { + var ClassMixinProps = { ClassMixin: _emberMetal.REQUIRED, @@ -17632,95 +17629,310 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met isClass: true, - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + isMethod: false, + /** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + var name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public + */ + extend: function () { + var Class = makeCtor(); + var proto; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - reopen.apply(Class.PrototypeMixin, arguments); + reopen.apply(Class.PrototypeMixin, arguments); - Class.superclass = this; - Class.__super__ = this.prototype; + Class.superclass = this; + Class.__super__ = this.prototype; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + Class.ClassMixin.apply(Class); + return Class; + }, - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + /** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public + */ + create: function () { + var C = this; - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, - for (var name in proto) { - property = proto[name]; + /** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public + */ + reopen: function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); + /** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public + */ + reopenClass: function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, + + detect: function (obj) { + if ('function' !== typeof obj) { + return false; } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, - var properties = _emberMetal.get(this, '_computedProperties'); + detectInstance: function (obj) { + return obj instanceof this; + }, - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + /** + In some cases, you may want to annotate computed properties with additional + metadata about how they function or what values they operate on. For + example, computed property functions may close over variables that are then + no longer available for introspection. + You can pass a hash of these values to a computed property like this: + ```javascript + person: Ember.computed(function() { + var personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private + */ + metaForProperty: function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + return desc._meta || {}; + }, + + _computedProperties: _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property; + var properties = []; + + for (var name in proto) { + property = proto[name]; + + if (property && property.isDescriptor) { + properties.push({ + name: name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), + + /** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private + */ + eachComputedProperty: function (callback, binding) { + var property; + var empty = {}; + + var properties = _emberMetal.get(this, '_computedProperties'); + + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } } - }, _ClassMixinProps); + }; function injectedPropertyAssertion() { _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); @@ -17978,210 +18190,6 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met @return {String} string representation @public */ - -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); - } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); - } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); - } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); - } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ - -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); - } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ - -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); - } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ - -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); - } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); - } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ - -/** - In some cases, you may want to annotate computed properties with additional - metadata about how they function or what values they operate on. For - example, computed property functions may close over variables that are then - no longer available for introspection. - You can pass a hash of these values to a computed property like this: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ - -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { 'use strict'; @@ -18434,7 +18442,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } findNamespaces(); - return this[_emberUtils.NAME_KEY]; + return this[_emberMetal.NAME_KEY]; }, nameClasses: function () { @@ -18494,10 +18502,10 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal paths[idx] = key; // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + if (obj && obj.toString === classToString && !obj[_emberMetal.NAME_KEY]) { // Replace the class' `toString` with the dot-separated path // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + obj[_emberMetal.NAME_KEY] = paths.join('.'); // Support nested namespaces } else if (obj && obj.isNamespace) { @@ -18543,7 +18551,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } var obj = tryIsNamespace(lookup, key); if (obj) { - obj[_emberUtils.NAME_KEY] = key; + obj[_emberMetal.NAME_KEY] = key; } } } @@ -18551,41 +18559,35 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal function superClassString(mixin) { var superclass = mixin.superclass; if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + if (superclass[_emberMetal.NAME_KEY]) { + return superclass[_emberMetal.NAME_KEY]; } return superClassString(superclass); } } - function calculateToString(target) { - var str = undefined; - - if (!searchDisabled) { + function classToString() { + if (!searchDisabled && !this[_emberMetal.NAME_KEY]) { processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; + } + + var ret = undefined; + + if (this[_emberMetal.NAME_KEY]) { + ret = this[_emberMetal.NAME_KEY]; + } else if (this._toString) { + ret = this._toString; + } else { + var str = superClassString(this); if (str) { - return str; + ret = '(subclass of ' + str + ')'; } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + ret = '(unknown mixin)'; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; + this.toString = makeToString(ret); } - return this[_emberUtils.NAME_KEY] = calculateToString(this); + return ret; } function processAllNamespaces() { @@ -18610,6 +18612,12 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } } + function makeToString(ret) { + return function () { + return ret; + }; + } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. exports.default = Namespace; @@ -19396,2540 +19404,2513 @@ enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-r enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; + exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": true, "ember-testing-resume-test": false, "ember-glimmer-detect-backtracking-rerender": true, "mandatory-setter": true }; }); enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.10.0-intercom"; }); -enifed('rsvp', ['exports'], function (exports) { - 'use strict'; - - var _rsvp; +/*! + * @overview RSVP - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE + * @version 3.2.1 + */ - function indexOf(callbacks, callback) { - for (var i = 0, l = callbacks.length; i < l; i++) { - if (callbacks[i] === callback) { - return i; - } - } +enifed('rsvp', ['exports'], function (exports) { 'use strict'; - return -1; +function indexOf(callbacks, callback) { + for (var i=0, l=callbacks.length; i 1) { - throw new Error('Second argument not supported'); - } - if (typeof o !== 'object') { - throw new TypeError('Argument must be an object'); - } - F.prototype = o; - return new F(); - }; + object.trigger('stuff'); // callback1 and callback2 will be executed. - var queue = []; + object.off('stuff'); + object.trigger('stuff'); // callback1 and callback2 will not be executed! + ``` - function scheduleFlush() { - setTimeout(function () { - for (var i = 0; i < queue.length; i++) { - var entry = queue[i]; + @method off + @for RSVP.EventTarget + @private + @param {String} eventName event to stop listening to + @param {Function} callback optional argument. If given, only the function + given will be removed from the event's callback queue. If no `callback` + argument is given, all callbacks will be removed from the event's callback + queue. + */ + 'off': function(eventName, callback) { + var allCallbacks = callbacksFor(this), callbacks, index; - var payload = entry.payload; + if (!callback) { + allCallbacks[eventName] = []; + return; + } - payload.guid = payload.key + payload.id; - payload.childGuid = payload.key + payload.childId; - if (payload.error) { - payload.stack = payload.error.stack; - } + callbacks = allCallbacks[eventName]; - config['trigger'](entry.name, entry.payload); - } - queue.length = 0; - }, 50); - } + index = indexOf(callbacks, callback); - function instrument(eventName, promise, child) { - if (1 === queue.push({ - name: eventName, - payload: { - key: promise._guidKey, - id: promise._id, - eventName: eventName, - detail: promise._result, - childId: child && child._id, - label: promise._label, - timeStamp: now(), - error: config["instrument-with-stack"] ? new Error(promise._label) : null - } })) { - scheduleFlush(); - } - } + if (index !== -1) { callbacks.splice(index, 1); } + }, /** - `RSVP.Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - + Use `trigger` to fire custom events. For example: + ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(){ + console.log('foo event happened!'); }); + object.trigger('foo'); + // 'foo event happened!' logged to the console ``` - - Instead of writing the above, your code now simply becomes the following: - + + You can also pass a value as a second argument to `trigger` that will be + passed as an argument to all event listeners for the event: + ```javascript - let promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(value){ + console.log(value.name); }); + + object.trigger('foo', { name: 'bar' }); + // 'bar' logged to the console ``` - - @method resolve - @static - @param {*} object value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - function resolve$1(object, label) { - /*jshint validthis:true */ - var Constructor = this; - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } + @method trigger + @for RSVP.EventTarget + @private + @param {String} eventName name of the event to be triggered + @param {*} options optional value to be passed to any event handlers for + the given `eventName` + */ + 'trigger': function(eventName, options, label) { + var allCallbacks = callbacksFor(this), callbacks, callback; - var promise = new Constructor(noop, label); - resolve(promise, object); - return promise; - } + if (callbacks = allCallbacks[eventName]) { + // Don't cache the callbacks.length since it may grow + for (var i=0; i 1) { + throw new Error('Second argument not supported'); } + if (typeof o !== 'object') { + throw new TypeError('Argument must be an object'); + } + F.prototype = o; + return new F(); +}); - function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } +var queue = []; - promise._result = value; - promise._state = FULFILLED; +function scheduleFlush() { + setTimeout(function() { + var entry; + for (var i = 0; i < queue.length; i++) { + entry = queue[i]; - if (promise._subscribers.length === 0) { - if (config.instrument) { - instrument('fulfilled', promise); + var payload = entry.payload; + + payload.guid = payload.key + payload.id; + payload.childGuid = payload.key + payload.childId; + if (payload.error) { + payload.stack = payload.error.stack; } - } else { - config.async(publish, promise); + + config['trigger'](entry.name, entry.payload); } - } + queue.length = 0; + }, 50); +} - function reject(promise, reason) { - if (promise._state !== PENDING) { - return; +function instrument(eventName, promise, child) { + if (1 === queue.push({ + name: eventName, + payload: { + key: promise._guidKey, + id: promise._id, + eventName: eventName, + detail: promise._result, + childId: child && child._id, + label: promise._label, + timeStamp: now(), + error: config["instrument-with-stack"] ? new Error(promise._label) : null + }})) { + scheduleFlush(); } - promise._state = REJECTED; - promise._result = reason; - config.async(publishRejection, promise); } - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; +/** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: - parent._onError = null; + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + resolve(1); + }); - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; + promise.then(function(value){ + // value === 1 + }); + ``` - if (length === 0 && parent._state) { - config.async(publish, parent); - } - } + Instead of writing the above, your code now simply becomes the following: - function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; + ```javascript + var promise = RSVP.Promise.resolve(1); - if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); - } + promise.then(function(value){ + // value === 1 + }); + ``` - if (subscribers.length === 0) { - return; - } + @method resolve + @static + @param {*} object value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object, label) { + /*jshint validthis:true */ + var Constructor = this; - var child = undefined, - callback = undefined, - detail = promise._result; + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; + var promise = new Constructor(noop, label); + resolve(promise, object); + return promise; +} - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } +function withOwnPromise() { + return new TypeError('A promises callback cannot return that same promise.'); +} - promise._subscribers.length = 0; - } +function noop() {} - function ErrorObject() { - this.error = null; - } +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; - var TRY_CATCH_ERROR = new ErrorObject(); +var GET_THEN_ERROR = new ErrorObject(); - function tryCatch(callback, detail) { - try { - return callback(detail); - } catch (e) { - TRY_CATCH_ERROR.error = e; - return TRY_CATCH_ERROR; - } +function getThen(promise) { + try { + return promise.then; + } catch(error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; } +} - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; - - if (hasCallback) { - value = tryCatch(callback, detail); +function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch(e) { + return e; + } +} - if (value === TRY_CATCH_ERROR) { - failed = true; - error = value.error; - value = null; +function handleForeignThenable(promise, thenable, then) { + config.async(function(promise) { + var sealed = false; + var error = tryThen(then, thenable, function(value) { + if (sealed) { return; } + sealed = true; + if (thenable !== value) { + resolve(promise, value, undefined); } else { - succeeded = true; + fulfill(promise, value); } + }, function(reason) { + if (sealed) { return; } + sealed = true; - if (promise === value) { - reject(promise, withOwnPromise()); - return; - } - } else { - value = detail; - succeeded = true; + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); } + }, promise); +} - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + thenable._onError = null; + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function(value) { + if (thenable !== value) { + resolve(promise, value, undefined); + } else { fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); } + }, function(reason) { + reject(promise, reason); + }); } +} - function initializePromise(promise, resolver) { - var resolved = false; - try { - resolver(function (value) { - if (resolved) { - return; - } - resolved = true; - resolve(promise, value); - }, function (reason) { - if (resolved) { - return; - } - resolved = true; - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); +function handleMaybeThenable(promise, maybeThenable, then$$) { + if (maybeThenable.constructor === promise.constructor && + then$$ === then && + constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$ === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + } else if (then$$ === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$)) { + handleForeignThenable(promise, maybeThenable, then$$); + } else { + fulfill(promise, maybeThenable); } } +} - function then(onFulfillment, onRejection, label) { - var _arguments = arguments; - - var parent = this; - var state = parent._state; +function resolve(promise, value) { + if (promise === value) { + fulfill(promise, value); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} - if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { - config.instrument && instrument('chained', parent, parent); - return parent; - } +function publishRejection(promise) { + if (promise._onError) { + promise._onError(promise._result); + } - parent._onError = null; + publish(promise); +} - var child = new parent.constructor(noop, label); - var result = parent._result; +function fulfill(promise, value) { + if (promise._state !== PENDING) { return; } - config.instrument && instrument('chained', parent, child); + promise._result = value; + promise._state = FULFILLED; - if (state) { - (function () { - var callback = _arguments[state - 1]; - config.async(function () { - return invokeCallback(state, child, callback, result); - }); - })(); - } else { - subscribe(parent, child, onFulfillment, onRejection); + if (promise._subscribers.length === 0) { + if (config.instrument) { + instrument('fulfilled', promise); } - - return child; + } else { + config.async(publish, promise); } +} - function makeSettledResult(state, position, value) { - if (state === FULFILLED) { - return { - state: 'fulfilled', - value: value - }; - } else { - return { - state: 'rejected', - reason: value - }; - } +function reject(promise, reason) { + if (promise._state !== PENDING) { return; } + promise._state = REJECTED; + promise._result = reason; + config.async(publishRejection, promise); +} + +function subscribe(parent, child, onFulfillment, onRejection) { + var subscribers = parent._subscribers; + var length = subscribers.length; + + parent._onError = null; + + subscribers[length] = child; + subscribers[length + FULFILLED] = onFulfillment; + subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + config.async(publish, parent); } +} - function Enumerator(Constructor, input, abortOnReject, label) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop, label); - this._abortOnReject = abortOnReject; +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; - if (this._validateInput(input)) { - this._input = input; - this.length = input.length; - this._remaining = input.length; + if (config.instrument) { + instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); + } - this._init(); + if (subscribers.length === 0) { return; } - if (this.length === 0) { - fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } - } + var child, callback, detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); } else { - reject(this.promise, this._validationError()); + callback(detail); } } - Enumerator.prototype._validateInput = function (input) { - return isArray(input); - }; + promise._subscribers.length = 0; +} - Enumerator.prototype._validationError = function () { - return new Error('Array Methods must be provided an Array'); - }; +function ErrorObject() { + this.error = null; +} - Enumerator.prototype._init = function () { - this._result = new Array(this.length); - }; +var TRY_CATCH_ERROR = new ErrorObject(); + +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch(e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} - Enumerator.prototype._enumerate = function () { - var length = this.length; - var promise = this.promise; - var input = this._input; +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value, error, succeeded, failed; - for (var i = 0; promise._state === PENDING && i < length; i++) { - this._eachEntry(input[i], i); - } - }; + if (hasCallback) { + value = tryCatch(callback, detail); - Enumerator.prototype._settleMaybeThenable = function (entry, i) { - var c = this._instanceConstructor; - var resolve = c.resolve; - - if (resolve === resolve$1) { - var then$$ = getThen(entry); - - if (then$$ === then && entry._state !== PENDING) { - entry._onError = null; - this._settledAt(entry._state, i, entry._result); - } else if (typeof then$$ !== 'function') { - this._remaining--; - this._result[i] = this._makeResult(FULFILLED, i, entry); - } else if (c === Promise) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, then$$); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve) { - return resolve(entry); - }), i); - } + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value = null; } else { - this._willSettleAt(resolve(entry), i); + succeeded = true; } - }; - Enumerator.prototype._eachEntry = function (entry, i) { - if (isMaybeThenable(entry)) { - this._settleMaybeThenable(entry, i); - } else { - this._remaining--; - this._result[i] = this._makeResult(FULFILLED, i, entry); + if (promise === value) { + reject(promise, withOwnPromise()); + return; } - }; - Enumerator.prototype._settledAt = function (state, i, value) { - var promise = this.promise; + } else { + value = detail; + succeeded = true; + } - if (promise._state === PENDING) { - this._remaining--; + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} - if (this._abortOnReject && state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = this._makeResult(state, i, value); - } - } +function initializePromise(promise, resolver) { + var resolved = false; + try { + resolver(function resolvePromise(value){ + if (resolved) { return; } + resolved = true; + resolve(promise, value); + }, function rejectPromise(reason) { + if (resolved) { return; } + resolved = true; + reject(promise, reason); + }); + } catch(e) { + reject(promise, e); + } +} - if (this._remaining === 0) { - fulfill(promise, this._result); - } - }; +function then(onFulfillment, onRejection, label) { + var parent = this; + var state = parent._state; - Enumerator.prototype._makeResult = function (state, i, value) { - return value; - }; + if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { + config.instrument && instrument('chained', parent, parent); + return parent; + } - Enumerator.prototype._willSettleAt = function (promise, i) { - var enumerator = this; + parent._onError = null; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; + var child = new parent.constructor(noop, label); + var result = parent._result; - /** - `RSVP.Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error("2")); - let promise3 = RSVP.reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" + config.instrument && instrument('chained', parent, child); + + if (state) { + var callback = arguments[state - 1]; + config.async(function(){ + invokeCallback(state, child, callback, result); }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static - */ - function all(entries, label) { - return new Enumerator(this, entries, true, /* abort on reject */label).promise; + } else { + subscribe(parent, child, onFulfillment, onRejection); } - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} entries array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this; + return child; +} - var promise = new Constructor(noop, label); +function makeSettledResult(state, position, value) { + if (state === FULFILLED) { + return { + state: 'fulfilled', + value: value + }; + } else { + return { + state: 'rejected', + reason: value + }; + } +} - if (!isArray(entries)) { - reject(promise, new TypeError('You must pass an array to race.')); - return promise; - } +function Enumerator(Constructor, input, abortOnReject, label) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop, label); + this._abortOnReject = abortOnReject; - for (var i = 0; promise._state === PENDING && i < entries.length; i++) { - subscribe(Constructor.resolve(entries[i]), undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } + if (this._validateInput(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; - return promise; + this._init(); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + reject(this.promise, this._validationError()); } +} - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$1(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop, label); - reject(promise, reason); - return promise; +Enumerator.prototype._validateInput = function(input) { + return isArray(input); +}; + +Enumerator.prototype._validationError = function() { + return new Error('Array Methods must be provided an Array'); +}; + +Enumerator.prototype._init = function() { + this._result = new Array(this.length); +}; + +Enumerator.prototype._enumerate = function() { + var length = this.length; + var promise = this.promise; + var input = this._input; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + this._eachEntry(input[i], i); } +}; + +Enumerator.prototype._settleMaybeThenable = function(entry, i) { + var c = this._instanceConstructor; + var resolve = c.resolve; - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; + if (resolve === resolve$1) { + var then$$ = getThen(entry); - function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); + if (then$$ === then && + entry._state !== PENDING) { + entry._onError = null; + this._settledAt(entry._state, i, entry._result); + } else if (typeof then$$ !== 'function') { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); + } else if (c === Promise) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, then$$); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); + } + } else { + this._willSettleAt(resolve(entry), i); } +}; - function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +Enumerator.prototype._eachEntry = function(entry, i) { + if (isMaybeThenable(entry)) { + this._settleMaybeThenable(entry, i); + } else { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); } +}; - /** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } - } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class RSVP.Promise - @param {function} resolver - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - this._id = counter++; - this._label = label; - this._state = undefined; - this._result = undefined; - this._subscribers = []; +Enumerator.prototype._settledAt = function(state, i, value) { + var promise = this.promise; - config.instrument && instrument('created', this); + if (promise._state === PENDING) { + this._remaining--; - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + if (this._abortOnReject && state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = this._makeResult(state, i, value); } } - Promise.cast = resolve$1; // deprecated - Promise.all = all; - Promise.race = race; - Promise.resolve = resolve$1; - Promise.reject = reject$1; + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; - Promise.prototype = { - constructor: Promise, +Enumerator.prototype._makeResult = function(state, i, value) { + return value; +}; - _guidKey: guidKey, +Enumerator.prototype._willSettleAt = function(promise, i) { + var enumerator = this; - _onError: function (reason) { - var promise = this; - config.after(function () { - if (promise._onError) { - config['trigger']('error', reason, promise._label); - } - }); - }, + subscribe(promise, undefined, function(value) { + enumerator._settledAt(FULFILLED, i, value); + }, function(reason) { + enumerator._settledAt(REJECTED, i, reason); + }); +}; - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we\'re unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we\'re unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); +/** + `RSVP.Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `RSVP.all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error("2")); + var promise3 = RSVP.reject(new Error("3")); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all(entries, label) { + return new Enumerator(this, entries, true /* abort on reject */, label).promise; +} + +/** + `RSVP.Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `RSVP.Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} entries array of promises to observe + @param {String} label optional string for describing the promise returned. + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race(entries, label) { + /*jshint validthis:true */ + var Constructor = this; + + var promise = new Constructor(noop, label); + + if (!isArray(entries)) { + reject(promise, new TypeError('You must pass an array to race.')); + return promise; + } + + var length = entries.length; + + function onFulfillment(value) { + resolve(promise, value); + } + + function onRejection(reason) { + reject(promise, reason); + } + + for (var i = 0; promise._state === PENDING && i < length; i++) { + subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); + } + + return promise; +} + +/** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason, label) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop, label); + reject(promise, reason); + return promise; +} + +var guidKey = 'rsvp_' + now() + '-'; +var counter = 0; + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise’s eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + var promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + var xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); } - // success } - }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: then, + }; + }); + } - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn\'t find that author'); + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class RSVP.Promise + @param {function} resolver + @param {String} label optional string for labeling the promise. + Useful for tooling. + @constructor +*/ +function Promise(resolver, label) { + this._id = counter++; + this._label = label; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + config.instrument && instrument('created', this); + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise.cast = resolve$1; // deprecated +Promise.all = all; +Promise.race = race; +Promise.resolve = resolve$1; +Promise.reject = reject$1; + +Promise.prototype = { + constructor: Promise, + + _guidKey: guidKey, + + _onError: function (reason) { + var promise = this; + config.after(function() { + if (promise._onError) { + config['trigger']('error', reason, promise._label); } - - // synchronous + }); + }, + +/** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { try { - findAuthor(); - } catch(reason) { - // something went wrong + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfillment + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + then: then, + +/** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'catch': function(onRejection, label) { + return this.then(undefined, onRejection, label); + }, + +/** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves + + Synchronous example: + + ```js + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); + } + + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value + } + ``` + + Asynchronous example: + + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not + }); + ``` + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'finally': function(callback, label) { + var promise = this; + var constructor = promise.constructor; + + return promise.then(function(value) { + return constructor.resolve(callback()).then(function() { + return value; }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - catch: function (onRejection, label) { - return this.then(undefined, onRejection, label); - }, + }, function(reason) { + return constructor.resolve(callback()).then(function() { + return constructor.reject(reason); + }); + }, label); + } +}; - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); +function Result() { + this.value = undefined; +} + +var ERROR = new Result(); +var GET_THEN_ERROR$1 = new Result(); + +function getThen$1(obj) { + try { + return obj.then; + } catch(error) { + ERROR.value= error; + return ERROR; + } +} + + +function tryApply(f, s, a) { + try { + f.apply(s, a); + } catch(error) { + ERROR.value = error; + return ERROR; + } +} + +function makeObject(_, argumentNames) { + var obj = {}; + var name; + var i; + var length = _.length; + var args = new Array(length); + + for (var x = 0; x < length; x++) { + args[x] = _[x]; + } + + for (i = 0; i < argumentNames.length; i++) { + name = argumentNames[i]; + obj[name] = args[i + 1]; + } + + return obj; +} + +function arrayResult(_) { + var length = _.length; + var args = new Array(length - 1); + + for (var i = 1; i < length; i++) { + args[i - 1] = _[i]; + } + + return args; +} + +function wrapThenable(then, promise) { + return { + then: function(onFulFillment, onRejection) { + return then.call(promise, onFulFillment, onRejection); + } + }; +} + +/** + `RSVP.denodeify` takes a 'node-style' function and returns a function that + will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + browser when you'd prefer to use promises over using callbacks. For example, + `denodeify` transforms the following: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) return handleError(err); + handleData(data); + }); + ``` + + into: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + + readFile('myfile.txt').then(handleData, handleError); + ``` + + If the node function has multiple success parameters, then `denodeify` + just returns the first one: + + ```javascript + var request = RSVP.denodeify(require('request')); + + request('http://example.com').then(function(res) { + // ... + }); + ``` + + However, if you need all success parameters, setting `denodeify`'s + second parameter to `true` causes it to return all success parameters + as an array: + + ```javascript + var request = RSVP.denodeify(require('request'), true); + + request('http://example.com').then(function(result) { + // result[0] -> res + // result[1] -> body + }); + ``` + + Or if you pass it an array with names it returns the parameters as a hash: + + ```javascript + var request = RSVP.denodeify(require('request'), ['res', 'body']); + + request('http://example.com').then(function(result) { + // result.res + // result.body + }); + ``` + + Sometimes you need to retain the `this`: + + ```javascript + var app = require('express')(); + var render = RSVP.denodeify(app.render.bind(app)); + ``` + + The denodified function inherits from the original function. It works in all + environments, except IE 10 and below. Consequently all properties of the original + function are available to you. However, any properties you change on the + denodeified function won't be changed on the original function. Example: + + ```javascript + var request = RSVP.denodeify(require('request')), + cookieJar = request.jar(); // <- Inheritance is used here + + request('http://example.com', {jar: cookieJar}).then(function(res) { + // cookieJar.cookies holds now the cookies returned by example.com + }); + ``` + + Using `denodeify` makes it easier to compose asynchronous operations instead + of using callbacks. For example, instead of: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) { ... } // Handle error + fs.writeFile('myfile2.txt', data, function(err){ + if (err) { ... } // Handle error + console.log('done') + }); + }); + ``` + + you can chain the operations together using `then` from the returned promise: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + var writeFile = RSVP.denodeify(fs.writeFile); + + readFile('myfile.txt').then(function(data){ + return writeFile('myfile2.txt', data); + }).then(function(){ + console.log('done') + }).catch(function(error){ + // Handle error + }); + ``` + + @method denodeify + @static + @for RSVP + @param {Function} nodeFunc a 'node-style' function that takes a callback as + its last argument. The callback expects an error to be passed as its first + argument (if an error occurred, otherwise null), and the value from the + operation as its second argument ('function(err, value){ }'). + @param {Boolean|Array} [options] An optional paramter that if set + to `true` causes the promise to fulfill with the callback's success arguments + as an array. This is useful if the node function has multiple success + paramters. If you set this paramter to an array with names, the promise will + fulfill with a hash with these names as keys and the success parameters as + values. + @return {Function} a function that wraps `nodeFunc` to return an + `RSVP.Promise` + @static +*/ +function denodeify(nodeFunc, options) { + var fn = function() { + var self = this; + var l = arguments.length; + var args = new Array(l + 1); + var arg; + var promiseInput = false; + + for (var i = 0; i < l; ++i) { + arg = arguments[i]; + + if (!promiseInput) { + // TODO: clean this up + promiseInput = needsPromiseInput(arg); + if (promiseInput === GET_THEN_ERROR$1) { + var p = new Promise(noop); + reject(p, GET_THEN_ERROR$1.value); + return p; + } else if (promiseInput && promiseInput !== true) { + arg = wrapThenable(promiseInput, arg); } - return new Author(); } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value - } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - finally: function (callback, label) { - var promise = this; - var constructor = promise.constructor; + args[i] = arg; + } - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }, label); + var promise = new Promise(noop); + + args[l] = function(err, val) { + if (err) + reject(promise, err); + else if (options === undefined) + resolve(promise, val); + else if (options === true) + resolve(promise, arrayResult(arguments)); + else if (isArray(options)) + resolve(promise, makeObject(arguments, options)); + else + resolve(promise, val); + }; + + if (promiseInput) { + return handlePromiseInput(promise, args, nodeFunc, self); + } else { + return handleValueInput(promise, args, nodeFunc, self); + } + }; + + fn.__proto__ = nodeFunc; + + return fn; +} + +function handleValueInput(promise, args, nodeFunc, self) { + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; +} + +function handlePromiseInput(promise, args, nodeFunc, self){ + return Promise.all(args).then(function(args){ + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + }); +} + +function needsPromiseInput(arg) { + if (arg && typeof arg === 'object') { + if (arg.constructor === Promise) { + return true; + } else { + return getThen$1(arg); + } + } else { + return false; + } +} + +/** + This is a convenient alias for `RSVP.Promise.all`. + + @method all + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. +*/ +function all$1(array, label) { + return Promise.all(array, label); +} + +function AllSettled(Constructor, entries, label) { + this._superConstructor(Constructor, entries, false /* don't abort on reject */, label); +} + +AllSettled.prototype = o_create(Enumerator.prototype); +AllSettled.prototype._superConstructor = Enumerator; +AllSettled.prototype._makeResult = makeSettledResult; +AllSettled.prototype._validationError = function() { + return new Error('allSettled must be called with an array'); +}; + +/** + `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + a fail-fast method, it waits until all the promises have returned and + shows you all the results. This is useful if you want to handle multiple + promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled. The return promise is fulfilled with an array of the states of + the promises passed into the `promises` array argument. + + Each state object will either indicate fulfillment or rejection, and + provide the corresponding value or reason. The states will take one of + the following formats: + + ```javascript + { state: 'fulfilled', value: value } + or + { state: 'rejected', reason: reason } + ``` + + Example: + + ```javascript + var promise1 = RSVP.Promise.resolve(1); + var promise2 = RSVP.Promise.reject(new Error('2')); + var promise3 = RSVP.Promise.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.allSettled(promises).then(function(array){ + // array == [ + // { state: 'fulfilled', value: 1 }, + // { state: 'rejected', reason: Error }, + // { state: 'rejected', reason: Error } + // ] + // Note that for the second item, reason.message will be '2', and for the + // third item, reason.message will be '3'. + }, function(error) { + // Not run. (This block would only be called if allSettled had failed, + // for instance if passed an incorrect argument type.) + }); + ``` + + @method allSettled + @static + @for RSVP + @param {Array} entries + @param {String} label - optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with an array of the settled + states of the constituent promises. +*/ + +function allSettled(entries, label) { + return new AllSettled(Promise, entries, label).promise; +} + +/** + This is a convenient alias for `RSVP.Promise.race`. + + @method race + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ +function race$1(array, label) { + return Promise.race(array, label); +} + +function PromiseHash(Constructor, object, label) { + this._superConstructor(Constructor, object, true, label); +} + +PromiseHash.prototype = o_create(Enumerator.prototype); +PromiseHash.prototype._superConstructor = Enumerator; +PromiseHash.prototype._init = function() { + this._result = {}; +}; + +PromiseHash.prototype._validateInput = function(input) { + return input && typeof input === 'object'; +}; + +PromiseHash.prototype._validationError = function() { + return new Error('Promise.hash must be called with an object'); +}; + +PromiseHash.prototype._enumerate = function() { + var enumerator = this; + var promise = enumerator.promise; + var input = enumerator._input; + var results = []; + + for (var key in input) { + if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { + results.push({ + position: key, + entry: input[key] + }); } + } + + var length = results.length; + enumerator._remaining = length; + var result; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + result = results[i]; + enumerator._eachEntry(result.entry, result.position); + } +}; + +/** + `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array + for its `promises` argument. + + Returns a promise that is fulfilled when all the given promises have been + fulfilled, or rejected if any of them become rejected. The returned promise + is fulfilled with a hash that has the same key names as the `promises` object + argument. If any of the values in the object are not promises, they will + simply be copied over to the fulfilled object. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + yourPromise: RSVP.resolve(2), + theirPromise: RSVP.resolve(3), + notAPromise: 4 + }; + + RSVP.hash(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: 1, + // yourPromise: 2, + // theirPromise: 3, + // notAPromise: 4 + // } + }); + ```` + + If any of the `promises` given to `RSVP.hash` are rejected, the first promise + that is rejected will be given as the reason to the rejection handler. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + rejectedPromise: RSVP.reject(new Error('rejectedPromise')), + anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), }; - function Result() { - this.value = undefined; - } + RSVP.hash(promises).then(function(hash){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === 'rejectedPromise' + }); + ``` - var ERROR = new Result(); - var GET_THEN_ERROR$1 = new Result(); + An important note: `RSVP.hash` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hash` will NOT preserve prototype + chains. - function getThen$1(obj) { - try { - return obj.then; - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + Example: - function tryApply(f, s, a) { - try { - f.apply(s, a); - } catch (error) { - ERROR.value = error; - return ERROR; - } + ```javascript + function MyConstructor(){ + this.example = RSVP.resolve('Example'); } - function makeObject(_, argumentNames) { - var obj = {}; - var length = _.length; - var args = new Array(length); + MyConstructor.prototype = { + protoProperty: RSVP.resolve('Proto Property') + }; - for (var x = 0; x < length; x++) { - args[x] = _[x]; - } + var myObject = new MyConstructor(); - for (var i = 0; i < argumentNames.length; i++) { - var _name = argumentNames[i]; - obj[_name] = args[i + 1]; - } + RSVP.hash(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: 'Example' + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` - return obj; - } + @method hash + @static + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all properties of `promises` + have been fulfilled, or rejected if any of them become rejected. +*/ +function hash(object, label) { + return new PromiseHash(Promise, object, label).promise; +} - function arrayResult(_) { - var length = _.length; - var args = new Array(length - 1); +function HashSettled(Constructor, object, label) { + this._superConstructor(Constructor, object, false, label); +} - for (var i = 1; i < length; i++) { - args[i - 1] = _[i]; - } +HashSettled.prototype = o_create(PromiseHash.prototype); +HashSettled.prototype._superConstructor = Enumerator; +HashSettled.prototype._makeResult = makeSettledResult; - return args; - } +HashSettled.prototype._validationError = function() { + return new Error('hashSettled must be called with an object'); +}; - function wrapThenable(then, promise) { - return { - then: function (onFulFillment, onRejection) { - return then.call(promise, onFulFillment, onRejection); - } - }; - } +/** + `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + instead of an array for its `promises` argument. - /** - `RSVP.denodeify` takes a 'node-style' function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - If the node function has multiple success parameters, then `denodeify` - just returns the first one: - - ```javascript - let request = RSVP.denodeify(require('request')); - - request('http://example.com').then(function(res) { - // ... - }); - ``` - - However, if you need all success parameters, setting `denodeify`'s - second parameter to `true` causes it to return all success parameters - as an array: - - ```javascript - let request = RSVP.denodeify(require('request'), true); - - request('http://example.com').then(function(result) { - // result[0] -> res - // result[1] -> body - }); - ``` - - Or if you pass it an array with names it returns the parameters as a hash: - - ```javascript - let request = RSVP.denodeify(require('request'), ['res', 'body']); - - request('http://example.com').then(function(result) { - // result.res - // result.body - }); - ``` - - Sometimes you need to retain the `this`: - - ```javascript - let app = require('express')(); - let render = RSVP.denodeify(app.render.bind(app)); - ``` - - The denodified function inherits from the original function. It works in all - environments, except IE 10 and below. Consequently all properties of the original - function are available to you. However, any properties you change on the - denodeified function won't be changed on the original function. Example: - - ```javascript - let request = RSVP.denodeify(require('request')), - cookieJar = request.jar(); // <- Inheritance is used here - - request('http://example.com', {jar: cookieJar}).then(function(res) { - // cookieJar.cookies holds now the cookies returned by example.com - }); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) { ... } // Handle error - fs.writeFile('myfile2.txt', data, function(err){ - if (err) { ... } // Handle error - console.log('done') - }); - }); - ``` - - you can chain the operations together using `then` from the returned promise: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - let writeFile = RSVP.denodeify(fs.writeFile); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - console.log('done') - }).catch(function(error){ - // Handle error - }); - ``` - - @method denodeify - @static - @for RSVP - @param {Function} nodeFunc a 'node-style' function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ('function(err, value){ }'). - @param {Boolean|Array} [options] An optional paramter that if set - to `true` causes the promise to fulfill with the callback's success arguments - as an array. This is useful if the node function has multiple success - paramters. If you set this paramter to an array with names, the promise will - fulfill with a hash with these names as keys and the success parameters as - values. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - @static - */ - function denodeify(nodeFunc, options) { - var fn = function () { - var self = this; - var l = arguments.length; - var args = new Array(l + 1); - var promiseInput = false; - - for (var i = 0; i < l; ++i) { - var arg = arguments[i]; - - if (!promiseInput) { - // TODO: clean this up - promiseInput = needsPromiseInput(arg); - if (promiseInput === GET_THEN_ERROR$1) { - var p = new Promise(noop); - reject(p, GET_THEN_ERROR$1.value); - return p; - } else if (promiseInput && promiseInput !== true) { - arg = wrapThenable(promiseInput, arg); - } - } - args[i] = arg; - } + Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + but like `RSVP.allSettled`, `hashSettled` waits until all the + constituent promises have returned and then shows you all the results + with their states and values/reasons. This is useful if you want to + handle multiple promises' failure states together as a set. - var promise = new Promise(noop); + Returns a promise that is fulfilled when all the given promises have been + settled, or rejected if the passed parameters are invalid. - args[l] = function (err, val) { - if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val); - }; + The returned promise is fulfilled with a hash that has the same key names as + the `promises` object argument. If any of the values in the object are not + promises, they will be copied over to the fulfilled object and marked with state + 'fulfilled'. - if (promiseInput) { - return handlePromiseInput(promise, args, nodeFunc, self); - } else { - return handleValueInput(promise, args, nodeFunc, self); - } - }; + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + yourPromise: RSVP.Promise.resolve(2), + theirPromise: RSVP.Promise.resolve(3), + notAPromise: 4 + }; - babelHelpers.defaults(fn, nodeFunc); + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // yourPromise: { state: 'fulfilled', value: 2 }, + // theirPromise: { state: 'fulfilled', value: 3 }, + // notAPromise: { state: 'fulfilled', value: 4 } + // } + }); + ``` - return fn; - } + If any of the `promises` given to `RSVP.hash` are rejected, the state will + be set to 'rejected' and the reason for rejection provided. - function handleValueInput(promise, args, nodeFunc, self) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - } + Example: - function handlePromiseInput(promise, args, nodeFunc, self) { - return Promise.all(args).then(function (args) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - }); - } + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + rejectedPromise: RSVP.Promise.reject(new Error('rejection')), + anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), + }; - function needsPromiseInput(arg) { - if (arg && typeof arg === 'object') { - if (arg.constructor === Promise) { - return true; - } else { - return getThen$1(arg); - } - } else { - return false; - } - } + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // rejectedPromise: { state: 'rejected', reason: Error }, + // anotherRejectedPromise: { state: 'rejected', reason: Error }, + // } + // Note that for rejectedPromise, reason.message == 'rejection', + // and for anotherRejectedPromise, reason.message == 'more rejection'. + }); + ``` - /** - This is a convenient alias for `RSVP.Promise.all`. - - @method all - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function all$1(array, label) { - return Promise.all(array, label); - } + An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype + chains. + + Example: - function AllSettled(Constructor, entries, label) { - this._superConstructor(Constructor, entries, false, /* don't abort on reject */label); + ```javascript + function MyConstructor(){ + this.example = RSVP.Promise.resolve('Example'); } - AllSettled.prototype = o_create(Enumerator.prototype); - AllSettled.prototype._superConstructor = Enumerator; - AllSettled.prototype._makeResult = makeSettledResult; - AllSettled.prototype._validationError = function () { - return new Error('allSettled must be called with an array'); + MyConstructor.prototype = { + protoProperty: RSVP.Promise.resolve('Proto Property') }; - /** - `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing - a fail-fast method, it waits until all the promises have returned and - shows you all the results. This is useful if you want to handle multiple - promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled. The return promise is fulfilled with an array of the states of - the promises passed into the `promises` array argument. - - Each state object will either indicate fulfillment or rejection, and - provide the corresponding value or reason. The states will take one of - the following formats: - - ```javascript - { state: 'fulfilled', value: value } - or - { state: 'rejected', reason: reason } - ``` - - Example: - - ```javascript - let promise1 = RSVP.Promise.resolve(1); - let promise2 = RSVP.Promise.reject(new Error('2')); - let promise3 = RSVP.Promise.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.allSettled(promises).then(function(array){ - // array == [ - // { state: 'fulfilled', value: 1 }, - // { state: 'rejected', reason: Error }, - // { state: 'rejected', reason: Error } - // ] - // Note that for the second item, reason.message will be '2', and for the - // third item, reason.message will be '3'. - }, function(error) { - // Not run. (This block would only be called if allSettled had failed, - // for instance if passed an incorrect argument type.) - }); - ``` - - @method allSettled - @static - @for RSVP - @param {Array} entries - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with an array of the settled - states of the constituent promises. - */ + var myObject = new MyConstructor(); - function allSettled(entries, label) { - return new AllSettled(Promise, entries, label).promise; - } + RSVP.hashSettled(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: { state: 'fulfilled', value: 'Example' } + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` - /** - This is a convenient alias for `RSVP.Promise.race`. - - @method race - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function race$1(array, label) { - return Promise.race(array, label); - } + @method hashSettled + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when when all properties of `promises` + have been settled. + @static +*/ +function hashSettled(object, label) { + return new HashSettled(Promise, object, label).promise; +} - function PromiseHash(Constructor, object, label) { - this._superConstructor(Constructor, object, true, label); +/** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + + ```javascript + function throws(){ + throw new Error('Whoops!'); } - PromiseHash.prototype = o_create(Enumerator.prototype); - PromiseHash.prototype._superConstructor = Enumerator; - PromiseHash.prototype._init = function () { - this._result = {}; - }; + var promise = new RSVP.Promise(function(resolve, reject){ + throws(); + }); - PromiseHash.prototype._validateInput = function (input) { - return input && typeof input === 'object'; - }; + promise.catch(RSVP.rethrow).then(function(){ + // Code here doesn't run because the promise became rejected due to an + // error! + }, function (err){ + // handle the error here + }); + ``` - PromiseHash.prototype._validationError = function () { - return new Error('Promise.hash must be called with an object'); - }; + The 'Whoops' error will be thrown on the next turn of the event loop + and you can watch for it in your console. You can also handle it using a + rejection handler given to `.then` or `.catch` on the returned promise. - PromiseHash.prototype._enumerate = function () { - var enumerator = this; - var promise = enumerator.promise; - var input = enumerator._input; - var results = []; - - for (var key in input) { - if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { - results.push({ - position: key, - entry: input[key] - }); - } - } + @method rethrow + @static + @for RSVP + @param {Error} reason reason the promise became rejected. + @throws Error + @static +*/ +function rethrow(reason) { + setTimeout(function() { + throw reason; + }); + throw reason; +} - var length = results.length; - enumerator._remaining = length; - var result = undefined; +/** + `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. + `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s + interface. New code should use the `RSVP.Promise` constructor instead. - for (var i = 0; promise._state === PENDING && i < length; i++) { - result = results[i]; - enumerator._eachEntry(result.entry, result.position); - } - }; + The object returned from `RSVP.defer` is a plain object with three properties: - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as the reason to the rejection handler. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error('rejectedPromise')), - anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === 'rejectedPromise' - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve('Example'); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: 'Example' - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @static - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - function hash(object, label) { - return new PromiseHash(Promise, object, label).promise; - } + * promise - an `RSVP.Promise`. + * reject - a function that causes the `promise` property on this object to + become rejected + * resolve - a function that causes the `promise` property on this object to + become fulfilled. - function HashSettled(Constructor, object, label) { - this._superConstructor(Constructor, object, false, label); - } + Example: - HashSettled.prototype = o_create(PromiseHash.prototype); - HashSettled.prototype._superConstructor = Enumerator; - HashSettled.prototype._makeResult = makeSettledResult; + ```javascript + var deferred = RSVP.defer(); - HashSettled.prototype._validationError = function () { - return new Error('hashSettled must be called with an object'); - }; + deferred.resolve("Success!"); - /** - `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object - instead of an array for its `promises` argument. - - Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, - but like `RSVP.allSettled`, `hashSettled` waits until all the - constituent promises have returned and then shows you all the results - with their states and values/reasons. This is useful if you want to - handle multiple promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled, or rejected if the passed parameters are invalid. - - The returned promise is fulfilled with a hash that has the same key names as - the `promises` object argument. If any of the values in the object are not - promises, they will be copied over to the fulfilled object and marked with state - 'fulfilled'. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - yourPromise: RSVP.Promise.resolve(2), - theirPromise: RSVP.Promise.resolve(3), - notAPromise: 4 - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // yourPromise: { state: 'fulfilled', value: 2 }, - // theirPromise: { state: 'fulfilled', value: 3 }, - // notAPromise: { state: 'fulfilled', value: 4 } - // } - }); - ``` - - If any of the `promises` given to `RSVP.hash` are rejected, the state will - be set to 'rejected' and the reason for rejection provided. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - rejectedPromise: RSVP.Promise.reject(new Error('rejection')), - anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // rejectedPromise: { state: 'rejected', reason: Error }, - // anotherRejectedPromise: { state: 'rejected', reason: Error }, - // } - // Note that for rejectedPromise, reason.message == 'rejection', - // and for anotherRejectedPromise, reason.message == 'more rejection'. - }); - ``` - - An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.Promise.resolve('Example'); + deferred.promise.then(function(value){ + // value here is "Success!" + }); + ``` + + @method defer + @static + @for RSVP + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Object} + */ + +function defer(label) { + var deferred = {}; + + deferred['promise'] = new Promise(function(resolve, reject) { + deferred['resolve'] = resolve; + deferred['reject'] = reject; + }, label); + + return deferred; +} + +/** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. + + For example: + + ```javascript + + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; + }; + + RSVP.map(promises, mapFn).then(function(result){ + // result is [ 2, 3, 4 ] + }); + ``` + + If any of the `promises` given to `RSVP.map` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; + }; + + RSVP.map(promises, mapFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` + + `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, + say you want to get all comments from a set of blog posts, but you need + the blog posts first because they contain a url to those comments. + + ```javscript + + var mapFn = function(blogPost){ + // getComments does some ajax and returns an RSVP.Promise that is fulfilled + // with some comments data + return getComments(blogPost.comments_url); + }; + + // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled + // with some blog post data + RSVP.map(getBlogPosts(), mapFn).then(function(comments){ + // comments is the result of asking the server for the comments + // of all blog posts returned from getBlogPosts() + }); + ``` + + @method map + @static + @for RSVP + @param {Array} promises + @param {Function} mapFn function to be called on each fulfilled promise. + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with the result of calling + `mapFn` on each fulfilled promise or value when they become fulfilled. + The promise will be rejected if any of the given `promises` become rejected. + @static +*/ +function map(promises, mapFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(mapFn)) { + throw new TypeError("You must pass a function as map's second argument."); } - - MyConstructor.prototype = { - protoProperty: RSVP.Promise.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hashSettled(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: { state: 'fulfilled', value: 'Example' } - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hashSettled - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when when all properties of `promises` - have been settled. - @static - */ - function hashSettled(object, label) { - return new HashSettled(Promise, object, label).promise; - } - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will also throw the - error again so the error can be handled by the promise per the spec. - - ```javascript - function throws(){ - throw new Error('Whoops!'); + var length = values.length; + var results = new Array(length); + + for (var i = 0; i < length; i++) { + results[i] = mapFn(values[i]); } - - let promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @static - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - @static - */ - function rethrow(reason) { - setTimeout(function () { - throw reason; - }); - throw reason; - } - /** - `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. - `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s - interface. New code should use the `RSVP.Promise` constructor instead. - - The object returned from `RSVP.defer` is a plain object with three properties: - - * promise - an `RSVP.Promise`. - * reject - a function that causes the `promise` property on this object to - become rejected - * resolve - a function that causes the `promise` property on this object to - become fulfilled. - - Example: - - ```javascript - let deferred = RSVP.defer(); - - deferred.resolve("Success!"); - - deferred.promise.then(function(value){ - // value here is "Success!" - }); - ``` - - @method defer - @static - @for RSVP - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Object} - */ + return Promise.all(results, label); + }); +} - function defer(label) { - var deferred = { resolve: undefined, reject: undefined }; +/** + This is a convenient alias for `RSVP.Promise.resolve`. - deferred.promise = new Promise(function (resolve, reject) { - deferred.resolve = resolve; - deferred.reject = reject; - }, label); + @method resolve + @static + @for RSVP + @param {*} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$2(value, label) { + return Promise.resolve(value, label); +} - return deferred; - } +/** + This is a convenient alias for `RSVP.Promise.reject`. - /** - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first because they contain a url to those comments. - - ```javscript - - let mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @static - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - @static - */ - function map(promises, mapFn, label) { - return Promise.all(promises, label).then(function (values) { - if (!isFunction(mapFn)) { - throw new TypeError("You must pass a function as map's second argument."); - } + @method reject + @static + @for RSVP + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$2(reason, label) { + return Promise.reject(reason, label); +} - var length = values.length; - var results = new Array(length); +/** + `RSVP.filter` is similar to JavaScript's native `filter` method, except that it + waits for all promises to become fulfilled before running the `filterFn` on + each item in given to `promises`. `RSVP.filter` returns a promise that will + become fulfilled with the result of running `filterFn` on the values the + promises become fulfilled with. - for (var i = 0; i < length; i++) { - results[i] = mapFn(values[i]); - } + For example: - return Promise.all(results, label); - }); - } + ```javascript - /** - This is a convenient alias for `RSVP.Promise.resolve`. - - @method resolve - @static - @for RSVP - @param {*} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - function resolve$2(value, label) { - return Promise.resolve(value, label); - } + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); - /** - This is a convenient alias for `RSVP.Promise.reject`. - - @method reject - @static - @for RSVP - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$2(reason, label) { - return Promise.reject(reason, label); - } + var promises = [promise1, promise2, promise3]; - /** - `RSVP.filter` is similar to JavaScript's native `filter` method, except that it - waits for all promises to become fulfilled before running the `filterFn` on - each item in given to `promises`. `RSVP.filter` returns a promise that will - become fulfilled with the result of running `filterFn` on the values the - promises become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - - let promises = [promise1, promise2, promise3]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - let alice = { name: 'alice' }; - let bob = { name: 'bob' }; - let users = [ alice, bob ]; - - let promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - let filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @static - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ + var filterFn = function(item){ + return item > 1; + }; - function resolveAll(promises, label) { - return Promise.all(promises, label); - } + RSVP.filter(promises, filterFn).then(function(result){ + // result is [ 2, 3 ] + }); + ``` - function resolveSingle(promise, label) { - return Promise.resolve(promise, label).then(function (promises) { - return resolveAll(promises, label); - }); - } + If any of the `promises` given to `RSVP.filter` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - function filter(promises, filterFn, label) { - var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label); - return promise.then(function (values) { - if (!isFunction(filterFn)) { - throw new TypeError("You must pass a function as filter's second argument."); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; - var length = values.length; - var filtered = new Array(length); + var filterFn = function(item){ + return item > 1; + }; - for (var i = 0; i < length; i++) { - filtered[i] = filterFn(values[i]); - } + RSVP.filter(promises, filterFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - return resolveAll(filtered, label).then(function (filtered) { - var results = new Array(length); - var newLength = 0; + `RSVP.filter` will also wait for any promises returned from `filterFn`. + For instance, you may want to fetch a list of users then return a subset + of those users based on some asynchronous operation: - for (var i = 0; i < length; i++) { - if (filtered[i]) { - results[newLength] = values[i]; - newLength++; - } - } + ```javascript - results.length = newLength; + var alice = { name: 'alice' }; + var bob = { name: 'bob' }; + var users = [ alice, bob ]; - return results; - }); + var promises = users.map(function(user){ + return RSVP.resolve(user); + }); + + var filterFn = function(user){ + // Here, Alice has permissions to create a blog post, but Bob does not. + return getPrivilegesForUser(user).then(function(privs){ + return privs.can_create_blog_post === true; }); - } + }; + RSVP.filter(promises, filterFn).then(function(users){ + // true, because the server told us only Alice can create a blog post. + users.length === 1; + // false, because Alice is the only user present in `users` + users[0] === bob; + }); + ``` - var len = 0; - var vertxNext = undefined; - function asap(callback, arg) { - queue$1[len] = callback; - queue$1[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 1, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - scheduleFlush$1(); + @method filter + @static + @for RSVP + @param {Array} promises + @param {Function} filterFn - function to be called on each resolved value to + filter the final results. + @param {String} label optional string describing the promise. Useful for + tooling. + @return {Promise} +*/ +function filter(promises, filterFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(filterFn)) { + throw new TypeError("You must pass a function as filter's second argument."); } - } - var browserWindow = typeof window !== 'undefined' ? window : undefined; - var browserGlobal = browserWindow || {}; - var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; - var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + var length = values.length; + var filtered = new Array(length); - // test for web worker but not in IE10 - var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; - - // node - function useNextTick() { - var nextTick = process.nextTick; - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // setImmediate should be used instead instead - var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); - if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { - nextTick = setImmediate; + for (var i = 0; i < length; i++) { + filtered[i] = filterFn(values[i]); } - return function () { - return nextTick(flush); - }; - } - // vertx - function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); - }; - } - return useSetTimeout(); - } + return Promise.all(filtered, label).then(function(filtered) { + var results = new Array(length); + var newLength = 0; - function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); + for (var i = 0; i < length; i++) { + if (filtered[i]) { + results[newLength] = values[i]; + newLength++; + } + } - return function () { - return node.data = iterations = ++iterations % 2; - }; - } + results.length = newLength; - // web worker - function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; - } + return results; + }); + }); +} - function useSetTimeout() { - return function () { - return setTimeout(flush, 1); - }; +var len = 0; +var vertxNext; +function asap(callback, arg) { + queue$1[len] = callback; + queue$1[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 1, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + scheduleFlush$1(); } +} - var queue$1 = new Array(1000); +var browserWindow = (typeof window !== 'undefined') ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && + typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + var nextTick = process.nextTick; + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // setImmediate should be used instead instead + var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); + if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { + nextTick = setImmediate; + } + return function() { + nextTick(flush); + }; +} - function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue$1[i]; - var arg = queue$1[i + 1]; +// vertx +function useVertxTimer() { + return function() { + vertxNext(flush); + }; +} - callback(arg); +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); - queue$1[i] = undefined; - queue$1[i + 1] = undefined; - } + return function() { + node.data = (iterations = ++iterations % 2); + }; +} - len = 0; - } +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; +} - function attemptVertex() { - try { - var r = require; - var vertx = r('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } +function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; +} + +var queue$1 = new Array(1000); +function flush() { + for (var i = 0; i < len; i+=2) { + var callback = queue$1[i]; + var arg = queue$1[i+1]; + + callback(arg); + + queue$1[i] = undefined; + queue$1[i+1] = undefined; } - var scheduleFlush$1 = undefined; - // Decide what async method to use to triggering processing of queued callbacks: - if (isNode) { - scheduleFlush$1 = useNextTick(); - } else if (BrowserMutationObserver) { - scheduleFlush$1 = useMutationObserver(); - } else if (isWorker) { - scheduleFlush$1 = useMessageChannel(); - } else if (browserWindow === undefined && typeof require === 'function') { - scheduleFlush$1 = attemptVertex(); - } else { - scheduleFlush$1 = useSetTimeout(); + len = 0; +} + +function attemptVertex() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch(e) { + return useSetTimeout(); } +} + +var scheduleFlush$1; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush$1 = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush$1 = useMutationObserver(); +} else if (isWorker) { + scheduleFlush$1 = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush$1 = attemptVertex(); +} else { + scheduleFlush$1 = useSetTimeout(); +} + +// defaults +config.async = asap; +config.after = function(cb) { + setTimeout(cb, 0); +}; +var cast = resolve$2; +function async(callback, arg) { + config.async(callback, arg); +} - var platform = undefined; +function on() { + config['on'].apply(config, arguments); +} - /* global self */ - if (typeof self === 'object') { - platform = self; +function off() { + config['off'].apply(config, arguments); +} - /* global global */ - } else if (typeof global === 'object') { - platform = global; - } else { - throw new Error('no global: `self` or `global` found'); +// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` +if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { + var callbacks = window['__PROMISE_INSTRUMENTATION__']; + configure('instrument', true); + for (var eventName in callbacks) { + if (callbacks.hasOwnProperty(eventName)) { + on(eventName, callbacks[eventName]); } + } +} - // defaults - config.async = asap; - config.after = function (cb) { - return setTimeout(cb, 0); - }; - var cast = resolve$2; +exports.cast = cast; +exports.Promise = Promise; +exports.EventTarget = EventTarget; +exports.all = all$1; +exports.allSettled = allSettled; +exports.race = race$1; +exports.hash = hash; +exports.hashSettled = hashSettled; +exports.rethrow = rethrow; +exports.defer = defer; +exports.denodeify = denodeify; +exports.configure = configure; +exports.on = on; +exports.off = off; +exports.resolve = resolve$2; +exports.reject = reject$2; +exports.async = async; +exports.map = map; +exports.filter = filter; - var async = function (callback, arg) { - return config.async(callback, arg); - }; +Object.defineProperty(exports, '__esModule', { value: true }); - function on() { - config['on'].apply(config, arguments); - } - - function off() { - config['off'].apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { - var callbacks = window['__PROMISE_INSTRUMENTATION__']; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - // the default export here is for backwards compat: - // https://github.com/tildeio/rsvp.js/issues/434 - var rsvp = (_rsvp = { - cast: cast, - Promise: Promise, - EventTarget: EventTarget, - all: all$1, - allSettled: allSettled, - race: race$1, - hash: hash, - hashSettled: hashSettled, - rethrow: rethrow, - defer: defer, - denodeify: denodeify, - configure: configure, - on: on, - off: off, - resolve: resolve$2, - reject: reject$2, - map: map - }, _rsvp['async'] = async, _rsvp.filter = // babel seems to error if async isn't a computed prop here... - filter, _rsvp); - - exports.cast = cast; - exports.Promise = Promise; - exports.EventTarget = EventTarget; - exports.all = all$1; - exports.allSettled = allSettled; - exports.race = race$1; - exports.hash = hash; - exports.hashSettled = hashSettled; - exports.rethrow = rethrow; - exports.defer = defer; - exports.denodeify = denodeify; - exports.configure = configure; - exports.on = on; - exports.off = off; - exports.resolve = resolve$2; - exports.reject = reject$2; - exports.map = map; - exports.async = async; - exports.filter = filter; - exports.default = rsvp; }); (function (m) { if (typeof module === "object" && module.exports) { module.exports = m } }(requireModule("ember-runtime").default)); diff --git a/ember-template-compiler.js b/ember-template-compiler.js index 3692ca6b9..7891ed999 100644 --- a/ember-template-compiler.js +++ b/ember-template-compiler.js @@ -6,10 +6,11 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.10.0-intercom */ var enifed, requireModule, Ember; +var mainContext = this; (function() { var isNode = typeof window === 'undefined' && @@ -111,6 +112,8 @@ var enifed, requireModule, Ember; } })(); +var babelHelpers; + function classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); @@ -4633,6 +4636,7 @@ enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-me exports.removeObserver = _emberMetalObserver.removeObserver; exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.NAME_KEY = _emberMetalMixin.NAME_KEY; exports.Mixin = _emberMetalMixin.Mixin; exports.aliasMethod = _emberMetalMixin.aliasMethod; exports._immediateObserver = _emberMetalMixin._immediateObserver; @@ -5833,7 +5837,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e var META_DESTROYED = 1 << 3; var IS_PROXY = 1 << 4; - if (true || false) { + if (true || true) { members.lastRendered = ownMap; members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds } @@ -5875,7 +5879,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e // inherited, and we can optimize it much better than JS runtimes. this.parent = parentMeta; - if (true || false) { + if (true || true) { this._lastRendered = undefined; this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds } @@ -6671,32 +6675,20 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function applyConcatenatedProperties(obj, key, value, values) { var baseValue = values[key] || obj[key]; - var ret = undefined; if (baseValue) { if ('function' === typeof baseValue.concat) { if (value === null || value === undefined) { - ret = baseValue; + return baseValue; } else { - ret = baseValue.concat(value); + return baseValue.concat(value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + return _emberUtils.makeArray(baseValue).concat(value); } } else { - ret = _emberUtils.makeArray(value); + return _emberUtils.makeArray(value); } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; } function applyMergedProperties(obj, key, value, values) { @@ -6972,6 +6964,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb return obj; } + var NAME_KEY = _emberUtils.GUID_KEY + '_name'; + + exports.NAME_KEY = NAME_KEY; /** The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, @@ -7054,7 +7049,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb this.ownerConstructor = undefined; this._without = undefined; this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; + this[NAME_KEY] = null; _emberMetalDebug.debugSeal(this); } @@ -8047,7 +8042,7 @@ enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/me _emberMetalTags.markObjectAsDirty(meta, keyName); - if (true || false) { + if (true || true) { _emberMetalTransaction.assertNotRendered(obj, keyName, meta); } } @@ -9376,20 +9371,20 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d assertNotRendered = undefined; var raise = _emberMetalDebug.assert; - if (false) { + if (true) { raise = function (message, test) { _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); }; } var implication = undefined; - if (false) { + if (true) { implication = 'will be removed in Ember 3.0.'; } else if (true) { implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; } - if (true || false) { + if (true || true) { (function () { var counter = 0; var inTransaction = false; @@ -9441,7 +9436,7 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; + return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; })(), false); shouldReflush = true; @@ -9987,64 +9982,10 @@ enifed('ember-template-compiler/plugins/deprecate-render-model', ['exports', 'em return 'Please refactor `' + original + '` to a component and invoke via' + (' `' + preferred + '`. ' + sourceInformation); } }); -enifed('ember-template-compiler/plugins/deprecate-render', ['exports', 'ember-metal', 'ember-template-compiler/system/calculate-location-display'], function (exports, _emberMetal, _emberTemplateCompilerSystemCalculateLocationDisplay) { - 'use strict'; - - exports.default = DeprecateRender; - - function DeprecateRender(options) { - this.syntax = null; - this.options = options; - } - - DeprecateRender.prototype.transform = function DeprecateRender_transform(ast) { - var moduleName = this.options.meta.moduleName; - var walker = new this.syntax.Walker(); - - walker.visit(ast, function (node) { - if (!validate(node)) { - return; - } - - each(node.params, function (param) { - if (param.type !== 'StringLiteral') { - return; - } - - _emberMetal.deprecate(deprecationMessage(moduleName, node), false, { - id: 'ember-template-compiler.deprecate-render', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-render-code-helper' - }); - }); - }); - - return ast; - }; - - function validate(node) { - return node.type === 'MustacheStatement' && node.path.original === 'render' && node.params.length === 1; - } - - function each(list, callback) { - for (var i = 0, l = list.length; i < l; i++) { - callback(list[i]); - } - } - - function deprecationMessage(moduleName, node) { - var sourceInformation = _emberTemplateCompilerSystemCalculateLocationDisplay.default(moduleName, node.loc); - var componentName = node.params[0].original; - var original = '{{render "' + componentName + '"}}'; - var preferred = '{{' + componentName + '}}'; - - return 'Please refactor `' + original + '` to a component and invoke via' + (' `' + preferred + '`. ' + sourceInformation); - } -}); -enifed('ember-template-compiler/plugins/index', ['exports', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/plugins/transform-input-on-to-onEvent', 'ember-template-compiler/plugins/transform-top-level-components', 'ember-template-compiler/plugins/transform-inline-link-to', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings', 'ember-template-compiler/plugins/deprecate-render-model', 'ember-template-compiler/plugins/deprecate-render', 'ember-template-compiler/plugins/assert-reserved-named-arguments', 'ember-template-compiler/plugins/transform-action-syntax', 'ember-template-compiler/plugins/transform-input-type-syntax', 'ember-template-compiler/plugins/transform-attrs-into-args', 'ember-template-compiler/plugins/transform-each-in-into-each', 'ember-template-compiler/plugins/transform-has-block-syntax'], function (exports, _emberTemplateCompilerPluginsTransformOldBindingSyntax, _emberTemplateCompilerPluginsTransformItemClass, _emberTemplateCompilerPluginsTransformAngleBracketComponents, _emberTemplateCompilerPluginsTransformInputOnToOnEvent, _emberTemplateCompilerPluginsTransformTopLevelComponents, _emberTemplateCompilerPluginsTransformInlineLinkTo, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings, _emberTemplateCompilerPluginsDeprecateRenderModel, _emberTemplateCompilerPluginsDeprecateRender, _emberTemplateCompilerPluginsAssertReservedNamedArguments, _emberTemplateCompilerPluginsTransformActionSyntax, _emberTemplateCompilerPluginsTransformInputTypeSyntax, _emberTemplateCompilerPluginsTransformAttrsIntoArgs, _emberTemplateCompilerPluginsTransformEachInIntoEach, _emberTemplateCompilerPluginsTransformHasBlockSyntax) { +enifed('ember-template-compiler/plugins/index', ['exports', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/plugins/transform-input-on-to-onEvent', 'ember-template-compiler/plugins/transform-top-level-components', 'ember-template-compiler/plugins/transform-inline-link-to', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-quoted-bindings-into-just-bindings', 'ember-template-compiler/plugins/deprecate-render-model', 'ember-template-compiler/plugins/assert-reserved-named-arguments', 'ember-template-compiler/plugins/transform-action-syntax', 'ember-template-compiler/plugins/transform-input-type-syntax', 'ember-template-compiler/plugins/transform-attrs-into-args', 'ember-template-compiler/plugins/transform-each-in-into-each', 'ember-template-compiler/plugins/transform-has-block-syntax'], function (exports, _emberTemplateCompilerPluginsTransformOldBindingSyntax, _emberTemplateCompilerPluginsTransformItemClass, _emberTemplateCompilerPluginsTransformAngleBracketComponents, _emberTemplateCompilerPluginsTransformInputOnToOnEvent, _emberTemplateCompilerPluginsTransformTopLevelComponents, _emberTemplateCompilerPluginsTransformInlineLinkTo, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings, _emberTemplateCompilerPluginsDeprecateRenderModel, _emberTemplateCompilerPluginsAssertReservedNamedArguments, _emberTemplateCompilerPluginsTransformActionSyntax, _emberTemplateCompilerPluginsTransformInputTypeSyntax, _emberTemplateCompilerPluginsTransformAttrsIntoArgs, _emberTemplateCompilerPluginsTransformEachInIntoEach, _emberTemplateCompilerPluginsTransformHasBlockSyntax) { 'use strict'; - exports.default = Object.freeze([_emberTemplateCompilerPluginsTransformOldBindingSyntax.default, _emberTemplateCompilerPluginsTransformItemClass.default, _emberTemplateCompilerPluginsTransformAngleBracketComponents.default, _emberTemplateCompilerPluginsTransformInputOnToOnEvent.default, _emberTemplateCompilerPluginsTransformTopLevelComponents.default, _emberTemplateCompilerPluginsTransformInlineLinkTo.default, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax.default, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings.default, _emberTemplateCompilerPluginsDeprecateRenderModel.default, _emberTemplateCompilerPluginsDeprecateRender.default, _emberTemplateCompilerPluginsAssertReservedNamedArguments.default, _emberTemplateCompilerPluginsTransformActionSyntax.default, _emberTemplateCompilerPluginsTransformInputTypeSyntax.default, _emberTemplateCompilerPluginsTransformAttrsIntoArgs.default, _emberTemplateCompilerPluginsTransformEachInIntoEach.default, _emberTemplateCompilerPluginsTransformHasBlockSyntax.default]); + exports.default = Object.freeze([_emberTemplateCompilerPluginsTransformOldBindingSyntax.default, _emberTemplateCompilerPluginsTransformItemClass.default, _emberTemplateCompilerPluginsTransformAngleBracketComponents.default, _emberTemplateCompilerPluginsTransformInputOnToOnEvent.default, _emberTemplateCompilerPluginsTransformTopLevelComponents.default, _emberTemplateCompilerPluginsTransformInlineLinkTo.default, _emberTemplateCompilerPluginsTransformOldClassBindingSyntax.default, _emberTemplateCompilerPluginsTransformQuotedBindingsIntoJustBindings.default, _emberTemplateCompilerPluginsDeprecateRenderModel.default, _emberTemplateCompilerPluginsAssertReservedNamedArguments.default, _emberTemplateCompilerPluginsTransformActionSyntax.default, _emberTemplateCompilerPluginsTransformInputTypeSyntax.default, _emberTemplateCompilerPluginsTransformAttrsIntoArgs.default, _emberTemplateCompilerPluginsTransformEachInIntoEach.default, _emberTemplateCompilerPluginsTransformHasBlockSyntax.default]); }); enifed('ember-template-compiler/plugins/transform-action-syntax', ['exports'], function (exports) { /** @@ -10942,6 +10883,7 @@ enifed('ember-template-compiler/plugins/transform-top-level-components', ['expor } var lastComponentNode = undefined; + var lastIndex = undefined; var nodeCount = 0; for (var i = 0; i < body.length; i++) { @@ -10959,6 +10901,7 @@ enifed('ember-template-compiler/plugins/transform-top-level-components', ['expor if (curr.type === 'ComponentNode' || curr.type === 'ElementNode') { lastComponentNode = curr; + lastIndex = i; } } @@ -11510,7 +11453,7 @@ enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, } } }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsToString) { /* This package will be eagerly parsed and should have no dependencies on external packages. @@ -11546,7 +11489,6 @@ enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner exports.tryInvoke = _emberUtilsInvoke.tryInvoke; exports.makeArray = _emberUtilsMakeArray.default; exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; exports.toString = _emberUtilsToString.default; }); enifed('ember-utils/inspect', ['exports'], function (exports) { @@ -11779,11 +11721,6 @@ enifed("ember-utils/make-array", ["exports"], function (exports) { return Array.isArray(obj) ? obj : [obj]; } }); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { /** @module ember @@ -11946,8 +11883,8 @@ enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); } }); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; +enifed("ember-utils/to-string", ["exports"], function (exports) { + "use strict"; exports.default = toString; var objectToString = Object.prototype.toString; @@ -11958,7 +11895,7 @@ enifed('ember-utils/to-string', ['exports'], function (exports) { */ function toString(obj) { - if (obj && typeof obj.toString === 'function') { + if (obj && obj.toString) { return obj.toString(); } else { return objectToString.call(obj); @@ -11968,12 +11905,12 @@ enifed('ember-utils/to-string', ['exports'], function (exports) { enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; + exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": true, "ember-testing-resume-test": false, "ember-glimmer-detect-backtracking-rerender": true, "mandatory-setter": true }; }); enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.10.0-intercom"; }); enifed("glimmer-compiler/index", ["exports", "glimmer-compiler/lib/compiler", "glimmer-compiler/lib/template-visitor"], function (exports, _glimmerCompilerLibCompiler, _glimmerCompilerLibTemplateVisitor) { "use strict"; @@ -19476,7 +19413,10 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true + autocorrect: true, + // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true + // Safari 9.1.3: 'list' in document.createElement('input') === false + list: true }, // element.form is actually a legitimate readOnly property, that is to be // mutated, but must be mutated by setAttribute... @@ -19493,7 +19433,7 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { return tag && tag[propName.toLowerCase()] || false; } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7U0FDbEI7OztBQUlELGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixnQkFBUSxFQUFFLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixhQUFLLEVBQUssRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtLQUN6QixDQUFDO0FBRUYsYUFBQSxVQUFBLENBQW9CLE9BQU8sRUFBRSxRQUFRLEVBQUE7QUFDbkMsWUFBSSxHQUFHLEdBQUcsY0FBYyxDQUFDLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDO0FBQ2hELGVBQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxRQUFRLENBQUMsV0FBVyxFQUFFLENBQUMsSUFBSSxLQUFLLENBQUM7S0FDcEQiLCJmaWxlIjoicHJvcHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQG1ldGhvZCBub3JtYWxpemVQcm9wZXJ0eVxuICogQHBhcmFtIGVsZW1lbnQge0hUTUxFbGVtZW50fVxuICogQHBhcmFtIHNsb3ROYW1lIHtTdHJpbmd9XG4gKiBAcmV0dXJucyB7T2JqZWN0fSB7IG5hbWUsIHR5cGUgfVxuICovXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHkoZWxlbWVudCwgc2xvdE5hbWUpIHtcbiAgbGV0IHR5cGUsIG5vcm1hbGl6ZWQ7XG5cbiAgaWYgKHNsb3ROYW1lIGluIGVsZW1lbnQpIHtcbiAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgdHlwZSA9ICdwcm9wJztcbiAgfSBlbHNlIHtcbiAgICBsZXQgbG93ZXIgPSBzbG90TmFtZS50b0xvd2VyQ2FzZSgpO1xuICAgIGlmIChsb3dlciBpbiBlbGVtZW50KSB7XG4gICAgICB0eXBlID0gJ3Byb3AnO1xuICAgICAgbm9ybWFsaXplZCA9IGxvd2VyO1xuICAgIH0gZWxzZSB7XG4gICAgICB0eXBlID0gJ2F0dHInO1xuICAgICAgbm9ybWFsaXplZCA9IHNsb3ROYW1lO1xuICAgIH1cbiAgfVxuXG4gIGlmICh0eXBlID09PSAncHJvcCcgJiZcbiAgICAgIChub3JtYWxpemVkLnRvTG93ZXJDYXNlKCkgPT09ICdzdHlsZScgfHxcbiAgICAgICBwcmVmZXJBdHRyKGVsZW1lbnQudGFnTmFtZSwgbm9ybWFsaXplZCkpKSB7XG4gICAgdHlwZSA9ICdhdHRyJztcbiAgfVxuXG4gIHJldHVybiB7IG5vcm1hbGl6ZWQsIHR5cGUgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIG5vcm1hbGl6ZVByb3BlcnR5VmFsdWUodmFsdWUpIHtcbiAgaWYgKHZhbHVlID09PSAnJykge1xuICAgIHJldHVybiB0cnVlO1xuICB9XG5cbiAgcmV0dXJuIHZhbHVlO1xufVxuXG4vLyBwcm9wZXJ0aWVzIHRoYXQgTVVTVCBiZSBzZXQgYXMgYXR0cmlidXRlcywgZHVlIHRvOlxuLy8gKiBicm93c2VyIGJ1Z1xuLy8gKiBzdHJhbmdlIHNwZWMgb3V0bGllclxuY29uc3QgQVRUUl9PVkVSUklERVMgPSB7XG5cbiAgLy8gcGhhbnRvbWpzIDwgMi4wIGxldHMgeW91IHNldCBpdCBhcyBhIHByb3AgYnV0IHdvbid0IHJlZmxlY3QgaXRcbiAgLy8gYmFjayB0byB0aGUgYXR0cmlidXRlLiBidXR0b24uZ2V0QXR0cmlidXRlKCd0eXBlJykgPT09IG51bGxcbiAgQlVUVE9OOiB7IHR5cGU6IHRydWUsIGZvcm06IHRydWUgfSxcblxuICBJTlBVVDoge1xuICAgIC8vIFNvbWUgdmVyc2lvbiBvZiBJRSAobGlrZSBJRTkpIGFjdHVhbGx5IHRocm93IGFuIGV4Y2VwdGlvblxuICAgIC8vIGlmIHlvdSBzZXQgaW5wdXQudHlwZSA9ICdzb21ldGhpbmctdW5rbm93bidcbiAgICB0eXBlOiB0cnVlLFxuICAgIGZvcm06IHRydWUsXG4gICAgLy8gQ2hyb21lIDQ2LjAuMjQ2NC4wOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gU2FmYXJpIDguMC43OiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gTW9iaWxlIFNhZmFyaSAoaU9TIDguNCBzaW11bGF0b3IpOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IHRydWVcbiAgICBhdXRvY29ycmVjdDogdHJ1ZVxuICB9LFxuXG4gIC8vIGVsZW1lbnQuZm9ybSBpcyBhY3R1YWxseSBhIGxlZ2l0aW1hdGUgcmVhZE9ubHkgcHJvcGVydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7OztBQUdqQixnQkFBSSxFQUFFLElBQUk7U0FDWDs7O0FBSUQsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGFBQUssRUFBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsZ0JBQVEsRUFBRSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0tBQ3pCLENBQUM7QUFFRixhQUFBLFVBQUEsQ0FBb0IsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNuQyxZQUFJLEdBQUcsR0FBRyxjQUFjLENBQUMsT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7QUFDaEQsZUFBTyxHQUFHLElBQUksR0FBRyxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxJQUFJLEtBQUssQ0FBQztLQUNwRCIsImZpbGUiOiJwcm9wcy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAbWV0aG9kIG5vcm1hbGl6ZVByb3BlcnR5XG4gKiBAcGFyYW0gZWxlbWVudCB7SFRNTEVsZW1lbnR9XG4gKiBAcGFyYW0gc2xvdE5hbWUge1N0cmluZ31cbiAqIEByZXR1cm5zIHtPYmplY3R9IHsgbmFtZSwgdHlwZSB9XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBub3JtYWxpemVQcm9wZXJ0eShlbGVtZW50LCBzbG90TmFtZSkge1xuICBsZXQgdHlwZSwgbm9ybWFsaXplZDtcblxuICBpZiAoc2xvdE5hbWUgaW4gZWxlbWVudCkge1xuICAgIG5vcm1hbGl6ZWQgPSBzbG90TmFtZTtcbiAgICB0eXBlID0gJ3Byb3AnO1xuICB9IGVsc2Uge1xuICAgIGxldCBsb3dlciA9IHNsb3ROYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgaWYgKGxvd2VyIGluIGVsZW1lbnQpIHtcbiAgICAgIHR5cGUgPSAncHJvcCc7XG4gICAgICBub3JtYWxpemVkID0gbG93ZXI7XG4gICAgfSBlbHNlIHtcbiAgICAgIHR5cGUgPSAnYXR0cic7XG4gICAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgfVxuICB9XG5cbiAgaWYgKHR5cGUgPT09ICdwcm9wJyAmJlxuICAgICAgKG5vcm1hbGl6ZWQudG9Mb3dlckNhc2UoKSA9PT0gJ3N0eWxlJyB8fFxuICAgICAgIHByZWZlckF0dHIoZWxlbWVudC50YWdOYW1lLCBub3JtYWxpemVkKSkpIHtcbiAgICB0eXBlID0gJ2F0dHInO1xuICB9XG5cbiAgcmV0dXJuIHsgbm9ybWFsaXplZCwgdHlwZSB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHlWYWx1ZSh2YWx1ZSkge1xuICBpZiAodmFsdWUgPT09ICcnKSB7XG4gICAgcmV0dXJuIHRydWU7XG4gIH1cblxuICByZXR1cm4gdmFsdWU7XG59XG5cbi8vIHByb3BlcnRpZXMgdGhhdCBNVVNUIGJlIHNldCBhcyBhdHRyaWJ1dGVzLCBkdWUgdG86XG4vLyAqIGJyb3dzZXIgYnVnXG4vLyAqIHN0cmFuZ2Ugc3BlYyBvdXRsaWVyXG5jb25zdCBBVFRSX09WRVJSSURFUyA9IHtcblxuICAvLyBwaGFudG9tanMgPCAyLjAgbGV0cyB5b3Ugc2V0IGl0IGFzIGEgcHJvcCBidXQgd29uJ3QgcmVmbGVjdCBpdFxuICAvLyBiYWNrIHRvIHRoZSBhdHRyaWJ1dGUuIGJ1dHRvbi5nZXRBdHRyaWJ1dGUoJ3R5cGUnKSA9PT0gbnVsbFxuICBCVVRUT046IHsgdHlwZTogdHJ1ZSwgZm9ybTogdHJ1ZSB9LFxuXG4gIElOUFVUOiB7XG4gICAgLy8gU29tZSB2ZXJzaW9uIG9mIElFIChsaWtlIElFOSkgYWN0dWFsbHkgdGhyb3cgYW4gZXhjZXB0aW9uXG4gICAgLy8gaWYgeW91IHNldCBpbnB1dC50eXBlID0gJ3NvbWV0aGluZy11bmtub3duJ1xuICAgIHR5cGU6IHRydWUsXG4gICAgZm9ybTogdHJ1ZSxcbiAgICAvLyBDaHJvbWUgNDYuMC4yNDY0LjA6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBTYWZhcmkgOC4wLjc6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBNb2JpbGUgU2FmYXJpIChpT1MgOC40IHNpbXVsYXRvcik6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gdHJ1ZVxuICAgIGF1dG9jb3JyZWN0OiB0cnVlLFxuICAgIC8vIENocm9tZSA1NC4wLjI4NDAuOTg6ICdsaXN0JyBpbiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdpbnB1dCcpID09PSB0cnVlXG4gICAgLy8gU2FmYXJpIDkuMS4zOiAnbGlzdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICBsaXN0OiB0cnVlXG4gIH0sXG5cbiAgLy8gZWxlbWVudC5mb3JtIGlzIGFjdHVhbGx5IGEgbGVnaXRpbWF0ZSByZWFkT25seSBwcm9wZXJ0eSwgdGhhdCBpcyB0byBiZVxuICAvLyBtdXRhdGVkLCBidXQgbXVzdCBiZSBtdXRhdGVkIGJ5IHNldEF0dHJpYnV0ZS4uLlxuICBTRUxFQ1Q6ICAgeyBmb3JtOiB0cnVlIH0sXG4gIE9QVElPTjogICB7IGZvcm06IHRydWUgfSxcbiAgVEVYVEFSRUE6IHsgZm9ybTogdHJ1ZSB9LFxuICBMQUJFTDogICAgeyBmb3JtOiB0cnVlIH0sXG4gIEZJRUxEU0VUOiB7IGZvcm06IHRydWUgfSxcbiAgTEVHRU5EOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPQkpFQ1Q6ICAgeyBmb3JtOiB0cnVlIH1cbn07XG5cbmZ1bmN0aW9uIHByZWZlckF0dHIodGFnTmFtZSwgcHJvcE5hbWUpIHtcbiAgbGV0IHRhZyA9IEFUVFJfT1ZFUlJJREVTW3RhZ05hbWUudG9VcHBlckNhc2UoKV07XG4gIHJldHVybiB0YWcgJiYgdGFnW3Byb3BOYW1lLnRvTG93ZXJDYXNlKCldIHx8IGZhbHNlO1xufVxuIl19 enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { 'use strict'; diff --git a/ember-testing.js b/ember-testing.js index f833d82e8..43d17628d 100644 --- a/ember-testing.js +++ b/ember-testing.js @@ -6,10 +6,11 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.10.0-intercom */ var enifed, requireModule, Ember; +var mainContext = this; (function() { var isNode = typeof window === 'undefined' && @@ -111,6 +112,8 @@ var enifed, requireModule, Ember; } })(); +var babelHelpers; + function classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); @@ -1754,9 +1757,7 @@ enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exp } }); }); -enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { - /* global self */ - +enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersQunit) { 'use strict'; exports.default = setupForTesting; @@ -1780,7 +1781,7 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-view var adapter = _emberTestingTestAdapter.getAdapter(); // if adapter is not manually set default to QUnit if (!adapter) { - _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + _emberTestingTestAdapter.setAdapter(new _emberTestingAdaptersQunit.default()); } _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); diff --git a/ember.debug.js b/ember.debug.js index 066dd3dbd..7793efb47 100644 --- a/ember.debug.js +++ b/ember.debug.js @@ -6,10 +6,11 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.10.0-intercom */ var enifed, requireModule, Ember; +var mainContext = this; (function() { var isNode = typeof window === 'undefined' && @@ -111,6 +112,8 @@ var enifed, requireModule, Ember; } })(); +var babelHelpers; + function classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); @@ -1469,7 +1472,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e var factoryInjections = factoryInjectionsFor(container, fullName); var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + factoryInjections._toString = registry.makeToString(factory, fullName); var injectedFactory = factory.extend(injections); @@ -3233,10 +3236,22 @@ enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember */ 'use strict'; + exports._resetLegacyAddonWarnings = _resetLegacyAddonWarnings; + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); var librariesRegistered = false; + var warnedAboutLegacyViewAddon = false; + var warnedAboutLegacyControllerAddon = false; + + // For testing + + function _resetLegacyAddonWarnings() { + warnedAboutLegacyViewAddon = false; + warnedAboutLegacyControllerAddon = false; + } + /** An instance of `Ember.Application` is the starting point for every Ember application. It helps to instantiate, initialize and coordinate the many @@ -7144,7 +7159,7 @@ enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'emb @default null @public */ - Component[_emberUtils.NAME_KEY] = 'Ember.Component'; + Component[_emberMetal.NAME_KEY] = 'Ember.Component'; Component.reopenClass({ isComponentFactory: true, @@ -9488,19 +9503,17 @@ enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glim additional information on how a `Component` functions. `{{component}}`'s primary use is for cases where you want to dynamically change which type of component is rendered as the state of your application - changes. This helper has three modes: inline, block, and nested. + changes. The provided block will be applied as the template for the component. + Given an empty `` the following template: - ### Inline Form - - Given the following template: - - ```app/application.hbs + ```handlebars + {{! application.hbs }} {{component infographicComponentName}} ``` And the following application code: - ```app/controllers/application.js + ```javascript export default Ember.Controller.extend({ infographicComponentName: computed('isMarketOpen', { get() { @@ -9521,87 +9534,33 @@ enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glim Note: You should not use this helper when you are consistently rendering the same component. In that case, use standard component syntax, for example: - ```app/templates/application.hbs + ```handlebars + {{! application.hbs }} {{live-updating-chart}} ``` - ### Block Form - - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: - - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} - ``` - - The following controller code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), - - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); - ``` - - And the following component template: - - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} - ``` - - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. - - ### Nested Usage + ## Nested Usage The `component` helper can be used to package a component path with initial attrs. The included attrs can then be merged during the final invocation. For example, given a `person-form` component with the following template: - ```app/templates/components/person-form.hbs + ```handlebars {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} + nameInput=(component "my-input-component" value=model.name placeholder="First Name"))}} ``` - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: + The following snippet: ``` {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} + {{component form.nameInput placeholder="Username"}} {{/person-form}} ``` - Which outputs an input whose value is already bound to `model.name` and `placeholder` + would output an input whose value is already bound to `model.name` and `placeholder` is "Username". - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: - - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} - ``` - - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} - ``` - @method component @since 1.11.0 @for Ember.Templates.helpers @@ -10443,9 +10402,6 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e }); ``` - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - Additionally, the `mut` helper can be combined with the `action` helper to mutate a value. For example: @@ -10459,7 +10415,7 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e // my-child.js export default Component.extend({ click() { - this.get('click-count-change')(this.get('childClickCount') + 1); + this.get('clickCountChange')(this.get('childClickCount') + 1); } }); ``` @@ -11327,7 +11283,7 @@ enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', ' var runInTransaction = undefined; - if (true || false) { + if (true || true) { runInTransaction = _emberMetal.runInTransaction; } else { runInTransaction = function (context, methodName) { @@ -14258,7 +14214,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var TwoWayFlushDetectionTag = undefined; - if (true || false) { + if (true || true) { TwoWayFlushDetectionTag = (function () { function _class(tag, key, ref) { babelHelpers.classCallCheck(this, _class); @@ -14332,7 +14288,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentValue = parentValue; this._propertyKey = propertyKey; - if (true || false) { + if (true || true) { this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); } else { this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); @@ -14347,7 +14303,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var _parentValue = this._parentValue; var _propertyKey = this._propertyKey; - if (true || false) { + if (true || true) { this.tag.didCompute(_parentValue); } @@ -14378,7 +14334,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentObjectTag = parentObjectTag; this._propertyKey = propertyKey; - if (true || false) { + if (true || true) { var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); } else { @@ -14404,7 +14360,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal _emberMetal.watchKey(parentValue, _propertyKey); } - if (true || false) { + if (true || true) { this.tag.didCompute(parentValue); } @@ -17588,6 +17544,7 @@ enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-me exports.removeObserver = _emberMetalObserver.removeObserver; exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.NAME_KEY = _emberMetalMixin.NAME_KEY; exports.Mixin = _emberMetalMixin.Mixin; exports.aliasMethod = _emberMetalMixin.aliasMethod; exports._immediateObserver = _emberMetalMixin._immediateObserver; @@ -18788,7 +18745,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e var META_DESTROYED = 1 << 3; var IS_PROXY = 1 << 4; - if (true || false) { + if (true || true) { members.lastRendered = ownMap; members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds } @@ -18830,7 +18787,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e // inherited, and we can optimize it much better than JS runtimes. this.parent = parentMeta; - if (true || false) { + if (true || true) { this._lastRendered = undefined; this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds } @@ -19626,32 +19583,20 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function applyConcatenatedProperties(obj, key, value, values) { var baseValue = values[key] || obj[key]; - var ret = undefined; if (baseValue) { if ('function' === typeof baseValue.concat) { if (value === null || value === undefined) { - ret = baseValue; + return baseValue; } else { - ret = baseValue.concat(value); + return baseValue.concat(value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + return _emberUtils.makeArray(baseValue).concat(value); } } else { - ret = _emberUtils.makeArray(value); + return _emberUtils.makeArray(value); } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; } function applyMergedProperties(obj, key, value, values) { @@ -19927,6 +19872,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb return obj; } + var NAME_KEY = _emberUtils.GUID_KEY + '_name'; + + exports.NAME_KEY = NAME_KEY; /** The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, @@ -20009,7 +19957,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb this.ownerConstructor = undefined; this._without = undefined; this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; + this[NAME_KEY] = null; _emberMetalDebug.debugSeal(this); } @@ -21002,7 +20950,7 @@ enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/me _emberMetalTags.markObjectAsDirty(meta, keyName); - if (true || false) { + if (true || true) { _emberMetalTransaction.assertNotRendered(obj, keyName, meta); } } @@ -22331,20 +22279,20 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d assertNotRendered = undefined; var raise = _emberMetalDebug.assert; - if (false) { + if (true) { raise = function (message, test) { _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); }; } var implication = undefined; - if (false) { + if (true) { implication = 'will be removed in Ember 3.0.'; } else if (true) { implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; } - if (true || false) { + if (true || true) { (function () { var counter = 0; var inTransaction = false; @@ -22396,7 +22344,7 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; + return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; })(), false); shouldReflush = true; @@ -24690,8 +24638,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. + For example, a route found at `app/routes/posts/post.js` or + `app/posts/post/route.js` (with pods) will have a `routeName` of + `posts.post`. @property routeName @for Ember.Route @type String @@ -24907,23 +24856,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Returns a hash containing the parameters of an ancestor route. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('member', { path: ':name' }, function() { this.route('interest', { path: ':interest' }); }); }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ + App.MemberRoute = Ember.Route.extend({ queryParams: { memberQp: { refreshModel: true } } }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ + App.MemberInterestRoute = Ember.Route.extend({ queryParams: { interestQp: { refreshModel: true } }, @@ -25016,10 +24960,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can use to reset controller values either when the model changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { + ```javascript + App.ArticlesRoute = Ember.Route.extend({ + // ... + resetController: function(controller, isExiting, transition) { if (isExiting) { controller.set('page', 1); } @@ -25070,19 +25014,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the template to use by default when rendering this routes template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + let PostsList = Ember.Route.extend({ templateName: 'posts/list' }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); + App.PostsIndexRoute = PostsList.extend(); + App.PostsArchivedRoute = PostsList.extend(); ``` @property templateName @type String @@ -25117,11 +25054,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' or decorating the transition from the currently active routes. A good example is preventing navigation when a form is half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ContactFormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData')) { this.controller.displayNavigationConfirm(); transition.abort(); @@ -25155,11 +25091,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' have resolved. The `didTransition` action has no arguments, however, it can be useful for tracking page views or resetting state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.LoginRoute = Ember.Route.extend({ actions: { - didTransition() { + didTransition: function() { this.controller.get('errors.base').clear(); return true; // Bubble the didTransition event } @@ -25176,10 +25111,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' hook returns a promise that is not already resolved. The current `Transition` object is the first parameter and the route that triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - loading(transition, route) { + loading: function(transition, route) { let controller = this.controllerFor('foo'); controller.set('currentlyLoading', true); transition.finally(function() { @@ -25205,14 +25140,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Here is an example of an error handler that will be invoked for rejected promises from the various hooks on the route, as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { + ```javascript + App.AdminRoute = Ember.Route.extend({ + beforeModel: function() { return Ember.RSVP.reject('bad things!'); }, actions: { - error(error, transition) { + error: function(error, transition) { // Assuming we got here due to the error in `beforeModel`, // we can expect that error === "bad things!", // but a promise model rejecting would also @@ -25230,11 +25164,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' will fire a default error handler that logs the error. You can specify your own global default error handler by overriding the `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - error(error, transition) { + error: function(error, transition) { this.controllerFor('banner').displayError(error.message); } } @@ -25250,12 +25183,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router enters the route. It is not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + collectAnalytics: function(){ collectAnalytics(); - }) + }.on('activate') }); ``` @event activate @@ -25266,12 +25198,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router completely exits this route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + ```javascript + App.IndexRoute = Ember.Route.extend({ + trackPageLeaveAnalytics: function(){ trackPageLeaveAnalytics(); - }) + }.on('deactivate') }); ``` @event deactivate @@ -25282,11 +25213,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The controller associated with this route. Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.FormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData') && !confirm('Are you sure you want to abandon progress?')) { transition.abort(); @@ -25458,17 +25388,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Multiple models will be applied last to first recursively up the route tree. - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); }); }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', aPost, aComment); this.transitionTo('blogComment', 1, 13); ``` It is also possible to pass a URL (a string that starts with a @@ -25490,20 +25416,15 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` See also [replaceWith](#method_replaceWith). Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); this.route('fourOhFour', { path: '*:' }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToSecret(context) { + moveToSecret: function(context) { if (authorized()) { this.transitionTo('secret', context); } else { @@ -25514,63 +25435,48 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }); ``` Transition to a nested route - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('articles', { path: '/articles' }, function() { this.route('new'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToNewArticle() { + transitionToNewArticle: function() { this.transitionTo('articles.new'); } } }); ``` Multiple Models Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); + this.route('cereal', { path: ':cerealId', resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToChocolateCereal() { + moveToChocolateCereal: function() { let cereal = { cerealId: 'ChocolateYumminess' }; let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); + this.transitionTo('cereal', breakfast, cereal); } } }); ``` Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('fruits', function() { this.route('apples'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToApples() { + transitionToApples: function() { this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); } } @@ -25641,18 +25547,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Beside that, it is identical to `transitionTo` in all other respects. See 'transitionTo' for additional information regarding multiple models. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.SecretRoute = Ember.Route.extend({ + afterModel: function() { if (!authorized()){ this.replaceWith('index'); } @@ -25677,28 +25578,20 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Sends an action to the router, which will delegate it to the currently active route hierarchy per the bubbling rules explained under `actions`. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.ApplicationRoute = Ember.Route.extend({ actions: { - track(arg) { + track: function(arg) { console.log(arg, 'was clicked'); } } }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - trackIfDebug(arg) { + trackIfDebug: function(arg) { if (debug) { this.send('track', arg); } @@ -25817,7 +25710,6 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' cache.stash(cacheKey, prop, value); } }, - /** This hook is the first of the route entry validation hooks called when an attempt is made to transition into a route @@ -25837,6 +25729,46 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' transition until the promise resolves (or rejects). This could be useful, for instance, for retrieving async code from the server that is required to enter a route. + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + return Ember.$.getScript('/models/post.js'); + } + } + }); + ``` + If `App.Post` doesn't exist in the above example, + `beforeModel` will use jQuery's `getScript`, which + returns a promise that resolves after the server has + successfully retrieved and executed the code from the + server. Note that if an error were to occur, it would + be passed to the `error` hook on `Ember.Route`, but + it's also possible to handle errors specific to + `beforeModel` right from within the hook (to distinguish + from the shared error handling behavior of the `error` + hook): + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + let self = this; + return Ember.$.getScript('post.js').then(null, function(e) { + self.transitionTo('help'); + // Note that the above transitionTo will implicitly + // halt the transition. If you were to return + // nothing from this promise reject handler, + // according to promise semantics, that would + // convert the reject into a resolve and the + // transition would continue. To propagate the + // error so that it'd be handled by the `error` + // hook, you would have to + return Ember.RSVP.reject(e); + }); + } + } + }); + ``` @method beforeModel @param {Transition} transition @return {Promise} if the value returned from this hook is @@ -25855,10 +25787,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' the `transition`, and is therefore suited to performing logic that can only take place after the model has already resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + afterModel: function(posts, transition) { if (posts.get('length') === 1) { this.transitionTo('post.show', posts.get('firstObject')); } @@ -25918,12 +25849,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the URL into the model for this route. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` The model for the `post` route is `store.findRecord('post', params.post_id)`. By default, if your route has a dynamic segment ending in `_id`: @@ -25957,10 +25886,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' if a promise returned from `model` fails, the error will be handled by the `error` hook on `Ember.Route`. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + ```javascript + App.PostRoute = Ember.Route.extend({ + model: function(params) { return this.store.findRecord('post', params.post_id); } }); @@ -25976,7 +25904,8 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' @public */ model: function (params, transition) { - var name = undefined, + var match = undefined, + name = undefined, sawParams = undefined, value = undefined; var queryParams = _emberMetal.get(this, '_qp.map'); @@ -25986,8 +25915,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' continue; } - var match = prop.match(/^(.*)_id$/); - if (match) { + if (match = prop.match(/^(.*)_id$/)) { name = match[1]; value = params[prop]; } @@ -26067,20 +25995,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the route's model into parameters for the URL. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + App.PostRoute = Ember.Route.extend({ + model: function(params) { // the server returns `{ id: 12 }` return Ember.$.getJSON('/posts/' + params.post_id); }, - serialize(model) { + serialize: function(model) { // this will make the URL `/posts/12` return { post_id: model.id }; } @@ -26112,13 +26036,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' prevent this default behavior. If you want to preserve that behavior when implementing your `setupController` function, make sure to call `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { + ```javascript + App.PhotosRoute = Ember.Route.extend({ + model: function() { return this.store.findAll('photo'); }, - setupController(controller, model) { + setupController: function(controller, model) { // Call _super for default behavior this._super(controller, model); // Implement your custom setup after @@ -26130,21 +26053,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' of this route. If no explicit controller is defined, Ember will automatically create one. As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` For the `post` route, a controller named `App.PostController` would be used if it is defined. If it is not defined, a basic `Ember.Controller` instance would be used. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, model) { controller.set('model', model); } }); @@ -26162,14 +26082,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }, /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. + Returns the controller for a particular route or name. The controller instance must already have been created, either through entering the associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.controllerFor('posts').set('currentPost', post); } @@ -26203,10 +26121,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Generates a controller for a route. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.generateController('posts'); } @@ -26232,19 +26149,14 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' retrieve it. If the ancestor route's model was a promise, its resolved result is returned. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/post/:post_id' }, function() { this.route('comments', { resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.CommentsRoute = Ember.Route.extend({ + afterModel: function() { this.set('post', this.modelFor('post')); } }); @@ -26289,10 +26201,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' template, configured with the controller for the route. This method can be overridden to set up and render additional or alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + renderTemplate: function(controller, model) { let favController = this.controllerFor('favoritePost'); // Render the `favoritePost` template into // the outlet `posts`, and display the `favoritePost` @@ -26320,12 +26231,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' phase of routing (via the `renderTemplate` hook) and later in response to user interaction. For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { + ```javascript + Router.map(function() { this.route('photos'); }); - export default Router; ``` ```handlebars @@ -26339,10 +26248,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` You can render `photos.hbs` into the `"anOutletName"` outlet of `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function() { this.render('photos', { into: 'application', outlet: 'anOutletName' @@ -26352,10 +26261,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` `render` additionally allows you to supply which `controller` and `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function(controller, model){ this.render('posts', { // the template to render, referenced by name into: 'application', // the template to render into, referenced by name outlet: 'anOutletName', // the outlet inside `options.template` to render into. @@ -26374,26 +26283,26 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' based on the name of the route specified in the router or the Route's `controllerName` and `templateName` properties. For example: - ```app/router.js - // ... - Router.map(function() { + ```javascript + // router + Router.map(function() { this.route('index'); this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // post route + PostRoute = App.Route.extend({ + renderTemplate: function() { this.render(); // all defaults apply } }); ``` - The name of the route, defined by the router, is `post`. + The name of the `PostRoute`, defined by the router, is `post`. The following equivalent default options will be applied when the Route calls `render`: ```javascript + // this.render('post', { // the template name associated with 'post' Route into: 'application', // the parent route to 'post' Route outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, @@ -26442,17 +26351,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' * `parentView`: the name of the view containing the outlet to clear (default: the view rendered by the parent route) Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ + ```javascript + App.ApplicationRoute = App.Route.extend({ actions: { - showModal(evt) { + showModal: function(evt) { this.render(evt.modalName, { outlet: 'modal', into: 'application' }); }, - hideModal(evt) { + hideModal: function(evt) { this.disconnectOutlet({ outlet: 'modal', parentView: 'application' @@ -26463,18 +26371,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Alternatively, you can pass the `outlet` name directly as a string. Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } - }); + ```javascript + hideModal: function(evt) { + this.disconnectOutlet('modal'); + } + ``` @method disconnectOutlet @param {Object|String} options the options hash or outlet name @since 1.0.0 @@ -26618,7 +26519,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' var template = owner.lookup('template:' + templateName); var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { + if (into && (parent = parentRoute(route)) && into === parentRoute(route).routeName) { into = undefined; } @@ -28200,12 +28101,6 @@ enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console' _emberMetal.set(target.outlets, renderOptions.outlet, myState); } else { if (renderOptions.into) { - _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { - id: 'ember-routing.top-level-render-helper', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' - }); - // Megahax time. Post-3.0-breaking-changes, we will just assert // right here that the user tried to target a nonexistent // thing. But for now we still need to support the `render` @@ -28451,7 +28346,11 @@ enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], functio */ function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; + if (queryParams._qpMap) { + return queryParams._qpMap; + } + + var qpMap = queryParams._qpMap = {}; for (var i = 0; i < queryParams.length; ++i) { accumulateQueryParamDescriptors(queryParams[i], qpMap); @@ -31152,6 +31051,8 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi args[_key - 1] = arguments[_key]; } + var target = undefined; + if (this.actions && this.actions[actionName]) { var shouldBubble = this.actions[actionName].apply(this, args) === true; if (!shouldBubble) { @@ -31159,10 +31060,11 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi } } - var target = _emberMetal.get(this, 'target'); - if (target) { + if (target = _emberMetal.get(this, 'target')) { + var _target; + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + (_target = target).send.apply(_target, arguments); } }, @@ -31583,7 +31485,7 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' /** This returns the objects at the specified indexes, using `objectAt`. ```javascript - let arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] ``` @@ -32523,8 +32425,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta for (var idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - if (found) { + if (found = callback.call(target, next, idx, this)) { ret = next; } @@ -35317,7 +35218,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met // using ember-metal/lib/main here to ensure that ember-debug is setup // if present - var _Mixin$create, _ClassMixinProps; + var _Mixin$create; var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); @@ -35576,7 +35477,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met CoreObject.__super__ = null; - var ClassMixinProps = (_ClassMixinProps = { + var ClassMixinProps = { ClassMixin: _emberMetal.REQUIRED, @@ -35584,95 +35485,310 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met isClass: true, - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + isMethod: false, + /** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + var name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public + */ + extend: function () { + var Class = makeCtor(); + var proto; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - reopen.apply(Class.PrototypeMixin, arguments); + reopen.apply(Class.PrototypeMixin, arguments); - Class.superclass = this; - Class.__super__ = this.prototype; + Class.superclass = this; + Class.__super__ = this.prototype; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + Class.ClassMixin.apply(Class); + return Class; + }, - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + /** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public + */ + create: function () { + var C = this; - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, - for (var name in proto) { - property = proto[name]; + /** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public + */ + reopen: function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); + /** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public + */ + reopenClass: function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, + + detect: function (obj) { + if ('function' !== typeof obj) { + return false; } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, - var properties = _emberMetal.get(this, '_computedProperties'); + detectInstance: function (obj) { + return obj instanceof this; + }, - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + /** + In some cases, you may want to annotate computed properties with additional + metadata about how they function or what values they operate on. For + example, computed property functions may close over variables that are then + no longer available for introspection. + You can pass a hash of these values to a computed property like this: + ```javascript + person: Ember.computed(function() { + var personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private + */ + metaForProperty: function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + return desc._meta || {}; + }, + + _computedProperties: _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property; + var properties = []; + + for (var name in proto) { + property = proto[name]; + + if (property && property.isDescriptor) { + properties.push({ + name: name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), + + /** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private + */ + eachComputedProperty: function (callback, binding) { + var property; + var empty = {}; + + var properties = _emberMetal.get(this, '_computedProperties'); + + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } } - }, _ClassMixinProps); + }; function injectedPropertyAssertion() { _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); @@ -35930,210 +36046,6 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met @return {String} string representation @public */ - -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); - } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); - } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); - } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); - } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ - -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); - } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ - -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); - } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ - -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); - } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); - } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ - -/** - In some cases, you may want to annotate computed properties with additional - metadata about how they function or what values they operate on. For - example, computed property functions may close over variables that are then - no longer available for introspection. - You can pass a hash of these values to a computed property like this: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ - -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { 'use strict'; @@ -36386,7 +36298,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } findNamespaces(); - return this[_emberUtils.NAME_KEY]; + return this[_emberMetal.NAME_KEY]; }, nameClasses: function () { @@ -36446,10 +36358,10 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal paths[idx] = key; // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + if (obj && obj.toString === classToString && !obj[_emberMetal.NAME_KEY]) { // Replace the class' `toString` with the dot-separated path // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + obj[_emberMetal.NAME_KEY] = paths.join('.'); // Support nested namespaces } else if (obj && obj.isNamespace) { @@ -36495,7 +36407,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } var obj = tryIsNamespace(lookup, key); if (obj) { - obj[_emberUtils.NAME_KEY] = key; + obj[_emberMetal.NAME_KEY] = key; } } } @@ -36503,41 +36415,35 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal function superClassString(mixin) { var superclass = mixin.superclass; if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + if (superclass[_emberMetal.NAME_KEY]) { + return superclass[_emberMetal.NAME_KEY]; } return superClassString(superclass); } } - function calculateToString(target) { - var str = undefined; - - if (!searchDisabled) { + function classToString() { + if (!searchDisabled && !this[_emberMetal.NAME_KEY]) { processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; + } + + var ret = undefined; + + if (this[_emberMetal.NAME_KEY]) { + ret = this[_emberMetal.NAME_KEY]; + } else if (this._toString) { + ret = this._toString; + } else { + var str = superClassString(this); if (str) { - return str; + ret = '(subclass of ' + str + ')'; } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + ret = '(unknown mixin)'; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; + this.toString = makeToString(ret); } - return this[_emberUtils.NAME_KEY] = calculateToString(this); + return ret; } function processAllNamespaces() { @@ -36562,6 +36468,12 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } } + function makeToString(ret) { + return function () { + return ret; + }; + } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. exports.default = Namespace; @@ -38356,9 +38268,7 @@ enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exp } }); }); -enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { - /* global self */ - +enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersQunit) { 'use strict'; exports.default = setupForTesting; @@ -38382,7 +38292,7 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-view var adapter = _emberTestingTestAdapter.getAdapter(); // if adapter is not manually set default to QUnit if (!adapter) { - _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + _emberTestingTestAdapter.setAdapter(new _emberTestingAdaptersQunit.default()); } _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); @@ -39324,7 +39234,7 @@ enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, } } }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsToString) { /* This package will be eagerly parsed and should have no dependencies on external packages. @@ -39360,7 +39270,6 @@ enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner exports.tryInvoke = _emberUtilsInvoke.tryInvoke; exports.makeArray = _emberUtilsMakeArray.default; exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; exports.toString = _emberUtilsToString.default; }); enifed('ember-utils/inspect', ['exports'], function (exports) { @@ -39593,11 +39502,6 @@ enifed("ember-utils/make-array", ["exports"], function (exports) { return Array.isArray(obj) ? obj : [obj]; } }); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { /** @module ember @@ -39760,8 +39664,8 @@ enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); } }); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; +enifed("ember-utils/to-string", ["exports"], function (exports) { + "use strict"; exports.default = toString; var objectToString = Object.prototype.toString; @@ -39772,7 +39676,7 @@ enifed('ember-utils/to-string', ['exports'], function (exports) { */ function toString(obj) { - if (obj && typeof obj.toString === 'function') { + if (obj && obj.toString) { return obj.toString(); } else { return objectToString.call(obj); @@ -39970,6 +39874,7 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me args[_key2 - 1] = arguments[_key2]; } + var target = undefined; var action = this.actions && this.actions[actionName]; if (action) { @@ -39979,10 +39884,13 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me } } - var target = _emberMetal.get(this, 'target'); + target = _emberMetal.get(this, 'target'); + if (target) { + var _target; + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + (_target = target).send.apply(_target, arguments); } else { _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); } @@ -40051,7 +39959,10 @@ enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], fun this._super.apply(this, arguments); _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); + this.classNameBindings = this.classNameBindings.slice(); + _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + this.classNames = this.classNames.slice(); }, /** @@ -40530,12 +40441,6 @@ enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-meta }, _Mixin$create.renderToElement = function (tagName) { tagName = tagName || 'body'; - _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { - id: 'ember-views.render-to-element', - until: '2.12.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' - }); - var element = this.renderer.createElement(tagName); this.renderer.appendTo(this, element); @@ -40687,7 +40592,6 @@ enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-meta @method renderToElement @param {String} tagName The tag of the element to create and render into. Defaults to "body". @return {HTMLBodyElement} element - @deprecated Use appendTo instead. @private */ @@ -42235,7 +42139,7 @@ enifed("ember-views/views/view", ["exports"], function (exports) { enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; + exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": true, "ember-testing-resume-test": false, "ember-glimmer-detect-backtracking-rerender": true, "mandatory-setter": true }; }); enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { 'use strict'; @@ -42341,7 +42245,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', _emberMetal.default.getProperties = _emberMetal.getProperties; _emberMetal.default.setProperties = _emberMetal.setProperties; _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.NAME_KEY = _emberMetal.NAME_KEY; _emberMetal.default.addObserver = _emberMetal.addObserver; _emberMetal.default.observersFor = _emberMetal.observersFor; _emberMetal.default.removeObserver = _emberMetal.removeObserver; @@ -42770,7 +42674,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.10.0-intercom"; }); enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; @@ -50433,7 +50337,10 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true + autocorrect: true, + // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true + // Safari 9.1.3: 'list' in document.createElement('input') === false + list: true }, // element.form is actually a legitimate readOnly property, that is to be // mutated, but must be mutated by setAttribute... @@ -50450,7 +50357,7 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { return tag && tag[propName.toLowerCase()] || false; } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7U0FDbEI7OztBQUlELGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixnQkFBUSxFQUFFLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixhQUFLLEVBQUssRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtLQUN6QixDQUFDO0FBRUYsYUFBQSxVQUFBLENBQW9CLE9BQU8sRUFBRSxRQUFRLEVBQUE7QUFDbkMsWUFBSSxHQUFHLEdBQUcsY0FBYyxDQUFDLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDO0FBQ2hELGVBQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxRQUFRLENBQUMsV0FBVyxFQUFFLENBQUMsSUFBSSxLQUFLLENBQUM7S0FDcEQiLCJmaWxlIjoicHJvcHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQG1ldGhvZCBub3JtYWxpemVQcm9wZXJ0eVxuICogQHBhcmFtIGVsZW1lbnQge0hUTUxFbGVtZW50fVxuICogQHBhcmFtIHNsb3ROYW1lIHtTdHJpbmd9XG4gKiBAcmV0dXJucyB7T2JqZWN0fSB7IG5hbWUsIHR5cGUgfVxuICovXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHkoZWxlbWVudCwgc2xvdE5hbWUpIHtcbiAgbGV0IHR5cGUsIG5vcm1hbGl6ZWQ7XG5cbiAgaWYgKHNsb3ROYW1lIGluIGVsZW1lbnQpIHtcbiAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgdHlwZSA9ICdwcm9wJztcbiAgfSBlbHNlIHtcbiAgICBsZXQgbG93ZXIgPSBzbG90TmFtZS50b0xvd2VyQ2FzZSgpO1xuICAgIGlmIChsb3dlciBpbiBlbGVtZW50KSB7XG4gICAgICB0eXBlID0gJ3Byb3AnO1xuICAgICAgbm9ybWFsaXplZCA9IGxvd2VyO1xuICAgIH0gZWxzZSB7XG4gICAgICB0eXBlID0gJ2F0dHInO1xuICAgICAgbm9ybWFsaXplZCA9IHNsb3ROYW1lO1xuICAgIH1cbiAgfVxuXG4gIGlmICh0eXBlID09PSAncHJvcCcgJiZcbiAgICAgIChub3JtYWxpemVkLnRvTG93ZXJDYXNlKCkgPT09ICdzdHlsZScgfHxcbiAgICAgICBwcmVmZXJBdHRyKGVsZW1lbnQudGFnTmFtZSwgbm9ybWFsaXplZCkpKSB7XG4gICAgdHlwZSA9ICdhdHRyJztcbiAgfVxuXG4gIHJldHVybiB7IG5vcm1hbGl6ZWQsIHR5cGUgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIG5vcm1hbGl6ZVByb3BlcnR5VmFsdWUodmFsdWUpIHtcbiAgaWYgKHZhbHVlID09PSAnJykge1xuICAgIHJldHVybiB0cnVlO1xuICB9XG5cbiAgcmV0dXJuIHZhbHVlO1xufVxuXG4vLyBwcm9wZXJ0aWVzIHRoYXQgTVVTVCBiZSBzZXQgYXMgYXR0cmlidXRlcywgZHVlIHRvOlxuLy8gKiBicm93c2VyIGJ1Z1xuLy8gKiBzdHJhbmdlIHNwZWMgb3V0bGllclxuY29uc3QgQVRUUl9PVkVSUklERVMgPSB7XG5cbiAgLy8gcGhhbnRvbWpzIDwgMi4wIGxldHMgeW91IHNldCBpdCBhcyBhIHByb3AgYnV0IHdvbid0IHJlZmxlY3QgaXRcbiAgLy8gYmFjayB0byB0aGUgYXR0cmlidXRlLiBidXR0b24uZ2V0QXR0cmlidXRlKCd0eXBlJykgPT09IG51bGxcbiAgQlVUVE9OOiB7IHR5cGU6IHRydWUsIGZvcm06IHRydWUgfSxcblxuICBJTlBVVDoge1xuICAgIC8vIFNvbWUgdmVyc2lvbiBvZiBJRSAobGlrZSBJRTkpIGFjdHVhbGx5IHRocm93IGFuIGV4Y2VwdGlvblxuICAgIC8vIGlmIHlvdSBzZXQgaW5wdXQudHlwZSA9ICdzb21ldGhpbmctdW5rbm93bidcbiAgICB0eXBlOiB0cnVlLFxuICAgIGZvcm06IHRydWUsXG4gICAgLy8gQ2hyb21lIDQ2LjAuMjQ2NC4wOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gU2FmYXJpIDguMC43OiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gTW9iaWxlIFNhZmFyaSAoaU9TIDguNCBzaW11bGF0b3IpOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IHRydWVcbiAgICBhdXRvY29ycmVjdDogdHJ1ZVxuICB9LFxuXG4gIC8vIGVsZW1lbnQuZm9ybSBpcyBhY3R1YWxseSBhIGxlZ2l0aW1hdGUgcmVhZE9ubHkgcHJvcGVydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7OztBQUdqQixnQkFBSSxFQUFFLElBQUk7U0FDWDs7O0FBSUQsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGFBQUssRUFBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsZ0JBQVEsRUFBRSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0tBQ3pCLENBQUM7QUFFRixhQUFBLFVBQUEsQ0FBb0IsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNuQyxZQUFJLEdBQUcsR0FBRyxjQUFjLENBQUMsT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7QUFDaEQsZUFBTyxHQUFHLElBQUksR0FBRyxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxJQUFJLEtBQUssQ0FBQztLQUNwRCIsImZpbGUiOiJwcm9wcy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAbWV0aG9kIG5vcm1hbGl6ZVByb3BlcnR5XG4gKiBAcGFyYW0gZWxlbWVudCB7SFRNTEVsZW1lbnR9XG4gKiBAcGFyYW0gc2xvdE5hbWUge1N0cmluZ31cbiAqIEByZXR1cm5zIHtPYmplY3R9IHsgbmFtZSwgdHlwZSB9XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBub3JtYWxpemVQcm9wZXJ0eShlbGVtZW50LCBzbG90TmFtZSkge1xuICBsZXQgdHlwZSwgbm9ybWFsaXplZDtcblxuICBpZiAoc2xvdE5hbWUgaW4gZWxlbWVudCkge1xuICAgIG5vcm1hbGl6ZWQgPSBzbG90TmFtZTtcbiAgICB0eXBlID0gJ3Byb3AnO1xuICB9IGVsc2Uge1xuICAgIGxldCBsb3dlciA9IHNsb3ROYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgaWYgKGxvd2VyIGluIGVsZW1lbnQpIHtcbiAgICAgIHR5cGUgPSAncHJvcCc7XG4gICAgICBub3JtYWxpemVkID0gbG93ZXI7XG4gICAgfSBlbHNlIHtcbiAgICAgIHR5cGUgPSAnYXR0cic7XG4gICAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgfVxuICB9XG5cbiAgaWYgKHR5cGUgPT09ICdwcm9wJyAmJlxuICAgICAgKG5vcm1hbGl6ZWQudG9Mb3dlckNhc2UoKSA9PT0gJ3N0eWxlJyB8fFxuICAgICAgIHByZWZlckF0dHIoZWxlbWVudC50YWdOYW1lLCBub3JtYWxpemVkKSkpIHtcbiAgICB0eXBlID0gJ2F0dHInO1xuICB9XG5cbiAgcmV0dXJuIHsgbm9ybWFsaXplZCwgdHlwZSB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHlWYWx1ZSh2YWx1ZSkge1xuICBpZiAodmFsdWUgPT09ICcnKSB7XG4gICAgcmV0dXJuIHRydWU7XG4gIH1cblxuICByZXR1cm4gdmFsdWU7XG59XG5cbi8vIHByb3BlcnRpZXMgdGhhdCBNVVNUIGJlIHNldCBhcyBhdHRyaWJ1dGVzLCBkdWUgdG86XG4vLyAqIGJyb3dzZXIgYnVnXG4vLyAqIHN0cmFuZ2Ugc3BlYyBvdXRsaWVyXG5jb25zdCBBVFRSX09WRVJSSURFUyA9IHtcblxuICAvLyBwaGFudG9tanMgPCAyLjAgbGV0cyB5b3Ugc2V0IGl0IGFzIGEgcHJvcCBidXQgd29uJ3QgcmVmbGVjdCBpdFxuICAvLyBiYWNrIHRvIHRoZSBhdHRyaWJ1dGUuIGJ1dHRvbi5nZXRBdHRyaWJ1dGUoJ3R5cGUnKSA9PT0gbnVsbFxuICBCVVRUT046IHsgdHlwZTogdHJ1ZSwgZm9ybTogdHJ1ZSB9LFxuXG4gIElOUFVUOiB7XG4gICAgLy8gU29tZSB2ZXJzaW9uIG9mIElFIChsaWtlIElFOSkgYWN0dWFsbHkgdGhyb3cgYW4gZXhjZXB0aW9uXG4gICAgLy8gaWYgeW91IHNldCBpbnB1dC50eXBlID0gJ3NvbWV0aGluZy11bmtub3duJ1xuICAgIHR5cGU6IHRydWUsXG4gICAgZm9ybTogdHJ1ZSxcbiAgICAvLyBDaHJvbWUgNDYuMC4yNDY0LjA6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBTYWZhcmkgOC4wLjc6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBNb2JpbGUgU2FmYXJpIChpT1MgOC40IHNpbXVsYXRvcik6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gdHJ1ZVxuICAgIGF1dG9jb3JyZWN0OiB0cnVlLFxuICAgIC8vIENocm9tZSA1NC4wLjI4NDAuOTg6ICdsaXN0JyBpbiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdpbnB1dCcpID09PSB0cnVlXG4gICAgLy8gU2FmYXJpIDkuMS4zOiAnbGlzdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICBsaXN0OiB0cnVlXG4gIH0sXG5cbiAgLy8gZWxlbWVudC5mb3JtIGlzIGFjdHVhbGx5IGEgbGVnaXRpbWF0ZSByZWFkT25seSBwcm9wZXJ0eSwgdGhhdCBpcyB0byBiZVxuICAvLyBtdXRhdGVkLCBidXQgbXVzdCBiZSBtdXRhdGVkIGJ5IHNldEF0dHJpYnV0ZS4uLlxuICBTRUxFQ1Q6ICAgeyBmb3JtOiB0cnVlIH0sXG4gIE9QVElPTjogICB7IGZvcm06IHRydWUgfSxcbiAgVEVYVEFSRUE6IHsgZm9ybTogdHJ1ZSB9LFxuICBMQUJFTDogICAgeyBmb3JtOiB0cnVlIH0sXG4gIEZJRUxEU0VUOiB7IGZvcm06IHRydWUgfSxcbiAgTEVHRU5EOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPQkpFQ1Q6ICAgeyBmb3JtOiB0cnVlIH1cbn07XG5cbmZ1bmN0aW9uIHByZWZlckF0dHIodGFnTmFtZSwgcHJvcE5hbWUpIHtcbiAgbGV0IHRhZyA9IEFUVFJfT1ZFUlJJREVTW3RhZ05hbWUudG9VcHBlckNhc2UoKV07XG4gIHJldHVybiB0YWcgJiYgdGFnW3Byb3BOYW1lLnRvTG93ZXJDYXNlKCldIHx8IGZhbHNlO1xufVxuIl19 enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { 'use strict'; @@ -55910,30 +55817,6 @@ TransitionState.prototype = { } }; -function TransitionAbortedError(message) { - if (!(this instanceof TransitionAbortedError)) { - return new TransitionAbortedError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, TransitionAbortedError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'TransitionAborted'; - this.name = 'TransitionAborted'; - this.number = error.number; - this.code = error.code; -} - -TransitionAbortedError.prototype = oCreate(Error.prototype); - /** A Transition is a thennable (a promise-like object) that represents an attempt to transition to another route. It can be aborted, either @@ -56258,11 +56141,16 @@ Transition.prototype.send = Transition.prototype.trigger; /** @private - Logs and returns an instance of TransitionAbortedError. + Logs and returns a TransitionAborted error. */ function logAbort(transition) { log(transition.router, transition.sequence, "detected abort."); - return new TransitionAbortedError(); + return new TransitionAborted(); +} + +function TransitionAborted(message) { + this.message = (message || "TransitionAborted"); + this.name = "TransitionAborted"; } function TransitionIntent(props) { @@ -56822,26 +56710,14 @@ var NamedTransitionIntent = subclass(TransitionIntent, { } }); +/** + Promise reject reasons passed to promise rejection + handlers for failed transitions. + */ function UnrecognizedURLError(message) { - if (!(this instanceof UnrecognizedURLError)) { - return new UnrecognizedURLError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, UnrecognizedURLError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'UnrecognizedURL'; - this.name = 'UnrecognizedURLError'; - this.number = error.number; - this.code = error.code; + this.message = (message || "UnrecognizedURLError"); + this.name = "UnrecognizedURLError"; + Error.call(this); } UnrecognizedURLError.prototype = oCreate(Error.prototype); @@ -57398,7 +57274,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi } if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } handler.context = context; @@ -57406,7 +57282,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi callHook(handler, 'setup', context, transition); if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } currentHandlerInfos.push(handlerInfo); @@ -57598,7 +57474,7 @@ function finalizeTransition(transition, newState) { // Resolve with the final handler. return handlerInfos[handlerInfos.length - 1].handler; } catch(e) { - if (!(e instanceof TransitionAbortedError)) { + if (!(e instanceof TransitionAborted)) { //var erroneousHandler = handlerInfos.pop(); var infos = transition.state.handlerInfos; transition.trigger(true, 'error', e, transition, infos[infos.length-1].handler); @@ -57755,2533 +57631,2506 @@ exports.Transition = Transition; Object.defineProperty(exports, '__esModule', { value: true }); }); -enifed('rsvp', ['exports'], function (exports) { - 'use strict'; - - var _rsvp; +/*! + * @overview RSVP - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE + * @version 3.2.1 + */ - function indexOf(callbacks, callback) { - for (var i = 0, l = callbacks.length; i < l; i++) { - if (callbacks[i] === callback) { - return i; - } - } +enifed('rsvp', ['exports'], function (exports) { 'use strict'; - return -1; +function indexOf(callbacks, callback) { + for (var i=0, l=callbacks.length; i 1) { - throw new Error('Second argument not supported'); - } - if (typeof o !== 'object') { - throw new TypeError('Argument must be an object'); - } - F.prototype = o; - return new F(); - }; + object.trigger('stuff'); // callback1 and callback2 will be executed. - var queue = []; + object.off('stuff'); + object.trigger('stuff'); // callback1 and callback2 will not be executed! + ``` - function scheduleFlush() { - setTimeout(function () { - for (var i = 0; i < queue.length; i++) { - var entry = queue[i]; + @method off + @for RSVP.EventTarget + @private + @param {String} eventName event to stop listening to + @param {Function} callback optional argument. If given, only the function + given will be removed from the event's callback queue. If no `callback` + argument is given, all callbacks will be removed from the event's callback + queue. + */ + 'off': function(eventName, callback) { + var allCallbacks = callbacksFor(this), callbacks, index; - var payload = entry.payload; + if (!callback) { + allCallbacks[eventName] = []; + return; + } - payload.guid = payload.key + payload.id; - payload.childGuid = payload.key + payload.childId; - if (payload.error) { - payload.stack = payload.error.stack; - } + callbacks = allCallbacks[eventName]; - config['trigger'](entry.name, entry.payload); - } - queue.length = 0; - }, 50); - } + index = indexOf(callbacks, callback); - function instrument(eventName, promise, child) { - if (1 === queue.push({ - name: eventName, - payload: { - key: promise._guidKey, - id: promise._id, - eventName: eventName, - detail: promise._result, - childId: child && child._id, - label: promise._label, - timeStamp: now(), - error: config["instrument-with-stack"] ? new Error(promise._label) : null - } })) { - scheduleFlush(); - } - } + if (index !== -1) { callbacks.splice(index, 1); } + }, /** - `RSVP.Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - + Use `trigger` to fire custom events. For example: + ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(){ + console.log('foo event happened!'); }); + object.trigger('foo'); + // 'foo event happened!' logged to the console ``` - - Instead of writing the above, your code now simply becomes the following: - + + You can also pass a value as a second argument to `trigger` that will be + passed as an argument to all event listeners for the event: + ```javascript - let promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(value){ + console.log(value.name); }); + + object.trigger('foo', { name: 'bar' }); + // 'bar' logged to the console ``` - - @method resolve - @static - @param {*} object value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` + + @method trigger + @for RSVP.EventTarget + @private + @param {String} eventName name of the event to be triggered + @param {*} options optional value to be passed to any event handlers for + the given `eventName` */ - function resolve$1(object, label) { - /*jshint validthis:true */ - var Constructor = this; + 'trigger': function(eventName, options, label) { + var allCallbacks = callbacksFor(this), callbacks, callback; - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; + if (callbacks = allCallbacks[eventName]) { + // Don't cache the callbacks.length since it may grow + for (var i=0; i 1) { + throw new Error('Second argument not supported'); } - - function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - thenable._onError = null; - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - if (thenable !== value) { - resolve(promise, value, undefined); - } else { - fulfill(promise, value); - } - }, function (reason) { - return reject(promise, reason); - }); - } + if (typeof o !== 'object') { + throw new TypeError('Argument must be an object'); } + F.prototype = o; + return new F(); +}); - function handleMaybeThenable(promise, maybeThenable, then$$) { - if (maybeThenable.constructor === promise.constructor && then$$ === then && promise.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$ === GET_THEN_ERROR) { - reject(promise, GET_THEN_ERROR.error); - } else if (then$$ === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$)) { - handleForeignThenable(promise, maybeThenable, then$$); - } else { - fulfill(promise, maybeThenable); +var queue = []; + +function scheduleFlush() { + setTimeout(function() { + var entry; + for (var i = 0; i < queue.length; i++) { + entry = queue[i]; + + var payload = entry.payload; + + payload.guid = payload.key + payload.id; + payload.childGuid = payload.key + payload.childId; + if (payload.error) { + payload.stack = payload.error.stack; } + + config['trigger'](entry.name, entry.payload); } - } + queue.length = 0; + }, 50); +} - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (objectOrFunction(value)) { - handleMaybeThenable(promise, value, getThen(value)); - } else { - fulfill(promise, value); +function instrument(eventName, promise, child) { + if (1 === queue.push({ + name: eventName, + payload: { + key: promise._guidKey, + id: promise._id, + eventName: eventName, + detail: promise._result, + childId: child && child._id, + label: promise._label, + timeStamp: now(), + error: config["instrument-with-stack"] ? new Error(promise._label) : null + }})) { + scheduleFlush(); } } - function publishRejection(promise) { - if (promise._onError) { - promise._onError(promise._result); - } +/** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` - publish(promise); + @method resolve + @static + @param {*} object value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object, label) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; } - function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } + var promise = new Constructor(noop, label); + resolve(promise, object); + return promise; +} + +function withOwnPromise() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function getThen(promise) { + try { + return promise.then; + } catch(error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} - promise._result = value; - promise._state = FULFILLED; +function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch(e) { + return e; + } +} - if (promise._subscribers.length === 0) { - if (config.instrument) { - instrument('fulfilled', promise); +function handleForeignThenable(promise, thenable, then) { + config.async(function(promise) { + var sealed = false; + var error = tryThen(then, thenable, function(value) { + if (sealed) { return; } + sealed = true; + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); } - } else { - config.async(publish, promise); + }, function(reason) { + if (sealed) { return; } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + thenable._onError = null; + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function(value) { + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); + } + }, function(reason) { + reject(promise, reason); + }); } +} - function reject(promise, reason) { - if (promise._state !== PENDING) { - return; +function handleMaybeThenable(promise, maybeThenable, then$$) { + if (maybeThenable.constructor === promise.constructor && + then$$ === then && + constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$ === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + } else if (then$$ === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$)) { + handleForeignThenable(promise, maybeThenable, then$$); + } else { + fulfill(promise, maybeThenable); } - promise._state = REJECTED; - promise._result = reason; - config.async(publishRejection, promise); } +} - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; +function resolve(promise, value) { + if (promise === value) { + fulfill(promise, value); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} - parent._onError = null; +function publishRejection(promise) { + if (promise._onError) { + promise._onError(promise._result); + } - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; + publish(promise); +} - if (length === 0 && parent._state) { - config.async(publish, parent); - } - } +function fulfill(promise, value) { + if (promise._state !== PENDING) { return; } - function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; + promise._result = value; + promise._state = FULFILLED; + if (promise._subscribers.length === 0) { if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); + instrument('fulfilled', promise); } + } else { + config.async(publish, promise); + } +} - if (subscribers.length === 0) { - return; - } +function reject(promise, reason) { + if (promise._state !== PENDING) { return; } + promise._state = REJECTED; + promise._result = reason; + config.async(publishRejection, promise); +} - var child = undefined, - callback = undefined, - detail = promise._result; +function subscribe(parent, child, onFulfillment, onRejection) { + var subscribers = parent._subscribers; + var length = subscribers.length; - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; + parent._onError = null; - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } + subscribers[length] = child; + subscribers[length + FULFILLED] = onFulfillment; + subscribers[length + REJECTED] = onRejection; - promise._subscribers.length = 0; + if (length === 0 && parent._state) { + config.async(publish, parent); } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; - function ErrorObject() { - this.error = null; + if (config.instrument) { + instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); } - var TRY_CATCH_ERROR = new ErrorObject(); + if (subscribers.length === 0) { return; } - function tryCatch(callback, detail) { - try { - return callback(detail); - } catch (e) { - TRY_CATCH_ERROR.error = e; - return TRY_CATCH_ERROR; + var child, callback, detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); } } - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; + promise._subscribers.length = 0; +} - if (hasCallback) { - value = tryCatch(callback, detail); +function ErrorObject() { + this.error = null; +} - if (value === TRY_CATCH_ERROR) { - failed = true; - error = value.error; - value = null; - } else { - succeeded = true; - } +var TRY_CATCH_ERROR = new ErrorObject(); - if (promise === value) { - reject(promise, withOwnPromise()); - return; - } +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch(e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value, error, succeeded, failed; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value = null; } else { - value = detail; succeeded = true; } - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function initializePromise(promise, resolver) { - var resolved = false; - try { - resolver(function (value) { - if (resolved) { - return; - } - resolved = true; - resolve(promise, value); - }, function (reason) { - if (resolved) { - return; - } - resolved = true; - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); + if (promise === value) { + reject(promise, withOwnPromise()); + return; } + + } else { + value = detail; + succeeded = true; } - function then(onFulfillment, onRejection, label) { - var _arguments = arguments; + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} - var parent = this; - var state = parent._state; +function initializePromise(promise, resolver) { + var resolved = false; + try { + resolver(function resolvePromise(value){ + if (resolved) { return; } + resolved = true; + resolve(promise, value); + }, function rejectPromise(reason) { + if (resolved) { return; } + resolved = true; + reject(promise, reason); + }); + } catch(e) { + reject(promise, e); + } +} - if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { - config.instrument && instrument('chained', parent, parent); - return parent; - } +function then(onFulfillment, onRejection, label) { + var parent = this; + var state = parent._state; - parent._onError = null; + if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { + config.instrument && instrument('chained', parent, parent); + return parent; + } - var child = new parent.constructor(noop, label); - var result = parent._result; + parent._onError = null; - config.instrument && instrument('chained', parent, child); + var child = new parent.constructor(noop, label); + var result = parent._result; - if (state) { - (function () { - var callback = _arguments[state - 1]; - config.async(function () { - return invokeCallback(state, child, callback, result); - }); - })(); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } + config.instrument && instrument('chained', parent, child); - return child; + if (state) { + var callback = arguments[state - 1]; + config.async(function(){ + invokeCallback(state, child, callback, result); + }); + } else { + subscribe(parent, child, onFulfillment, onRejection); } - function makeSettledResult(state, position, value) { - if (state === FULFILLED) { - return { - state: 'fulfilled', - value: value - }; - } else { - return { - state: 'rejected', - reason: value - }; - } + return child; +} + +function makeSettledResult(state, position, value) { + if (state === FULFILLED) { + return { + state: 'fulfilled', + value: value + }; + } else { + return { + state: 'rejected', + reason: value + }; } +} - function Enumerator(Constructor, input, abortOnReject, label) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop, label); - this._abortOnReject = abortOnReject; +function Enumerator(Constructor, input, abortOnReject, label) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop, label); + this._abortOnReject = abortOnReject; - if (this._validateInput(input)) { - this._input = input; - this.length = input.length; - this._remaining = input.length; + if (this._validateInput(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; - this._init(); + this._init(); - if (this.length === 0) { + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } } - } else { - reject(this.promise, this._validationError()); } + } else { + reject(this.promise, this._validationError()); } +} - Enumerator.prototype._validateInput = function (input) { - return isArray(input); - }; +Enumerator.prototype._validateInput = function(input) { + return isArray(input); +}; - Enumerator.prototype._validationError = function () { - return new Error('Array Methods must be provided an Array'); - }; +Enumerator.prototype._validationError = function() { + return new Error('Array Methods must be provided an Array'); +}; - Enumerator.prototype._init = function () { - this._result = new Array(this.length); - }; +Enumerator.prototype._init = function() { + this._result = new Array(this.length); +}; - Enumerator.prototype._enumerate = function () { - var length = this.length; - var promise = this.promise; - var input = this._input; +Enumerator.prototype._enumerate = function() { + var length = this.length; + var promise = this.promise; + var input = this._input; - for (var i = 0; promise._state === PENDING && i < length; i++) { - this._eachEntry(input[i], i); - } - }; + for (var i = 0; promise._state === PENDING && i < length; i++) { + this._eachEntry(input[i], i); + } +}; - Enumerator.prototype._settleMaybeThenable = function (entry, i) { - var c = this._instanceConstructor; - var resolve = c.resolve; - - if (resolve === resolve$1) { - var then$$ = getThen(entry); - - if (then$$ === then && entry._state !== PENDING) { - entry._onError = null; - this._settledAt(entry._state, i, entry._result); - } else if (typeof then$$ !== 'function') { - this._remaining--; - this._result[i] = this._makeResult(FULFILLED, i, entry); - } else if (c === Promise) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, then$$); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve) { - return resolve(entry); - }), i); - } - } else { - this._willSettleAt(resolve(entry), i); - } - }; +Enumerator.prototype._settleMaybeThenable = function(entry, i) { + var c = this._instanceConstructor; + var resolve = c.resolve; - Enumerator.prototype._eachEntry = function (entry, i) { - if (isMaybeThenable(entry)) { - this._settleMaybeThenable(entry, i); - } else { + if (resolve === resolve$1) { + var then$$ = getThen(entry); + + if (then$$ === then && + entry._state !== PENDING) { + entry._onError = null; + this._settledAt(entry._state, i, entry._result); + } else if (typeof then$$ !== 'function') { this._remaining--; this._result[i] = this._makeResult(FULFILLED, i, entry); + } else if (c === Promise) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, then$$); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); } - }; + } else { + this._willSettleAt(resolve(entry), i); + } +}; - Enumerator.prototype._settledAt = function (state, i, value) { - var promise = this.promise; +Enumerator.prototype._eachEntry = function(entry, i) { + if (isMaybeThenable(entry)) { + this._settleMaybeThenable(entry, i); + } else { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); + } +}; - if (promise._state === PENDING) { - this._remaining--; +Enumerator.prototype._settledAt = function(state, i, value) { + var promise = this.promise; - if (this._abortOnReject && state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = this._makeResult(state, i, value); - } - } + if (promise._state === PENDING) { + this._remaining--; - if (this._remaining === 0) { - fulfill(promise, this._result); + if (this._abortOnReject && state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = this._makeResult(state, i, value); } - }; + } - Enumerator.prototype._makeResult = function (state, i, value) { - return value; - }; + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; - Enumerator.prototype._willSettleAt = function (promise, i) { - var enumerator = this; +Enumerator.prototype._makeResult = function(state, i, value) { + return value; +}; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; +Enumerator.prototype._willSettleAt = function(promise, i) { + var enumerator = this; - /** - `RSVP.Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error("2")); - let promise3 = RSVP.reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static - */ - function all(entries, label) { - return new Enumerator(this, entries, true, /* abort on reject */label).promise; - } + subscribe(promise, undefined, function(value) { + enumerator._settledAt(FULFILLED, i, value); + }, function(reason) { + enumerator._settledAt(REJECTED, i, reason); + }); +}; - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} entries array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this; +/** + `RSVP.Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. - var promise = new Constructor(noop, label); + Example: - if (!isArray(entries)) { - reject(promise, new TypeError('You must pass an array to race.')); - return promise; - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; - for (var i = 0; promise._state === PENDING && i < entries.length; i++) { - subscribe(Constructor.resolve(entries[i]), undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } + RSVP.Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` - return promise; - } + If any of the `promises` given to `RSVP.all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$1(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop, label); - reject(promise, reason); + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error("2")); + var promise3 = RSVP.reject(new Error("3")); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all(entries, label) { + return new Enumerator(this, entries, true /* abort on reject */, label).promise; +} + +/** + `RSVP.Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `RSVP.Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} entries array of promises to observe + @param {String} label optional string for describing the promise returned. + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race(entries, label) { + /*jshint validthis:true */ + var Constructor = this; + + var promise = new Constructor(noop, label); + + if (!isArray(entries)) { + reject(promise, new TypeError('You must pass an array to race.')); return promise; } - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; + var length = entries.length; - function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); + function onFulfillment(value) { + resolve(promise, value); } - function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); + function onRejection(reason) { + reject(promise, reason); } - /** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } + for (var i = 0; promise._state === PENDING && i < length; i++) { + subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); + } + + return promise; +} + +/** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason, label) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop, label); + reject(promise, reason); + return promise; +} + +var guidKey = 'rsvp_' + now() + '-'; +var counter = 0; + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise’s eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + var promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + var xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection + } + }; }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class RSVP.Promise + @param {function} resolver + @param {String} label optional string for labeling the promise. + Useful for tooling. + @constructor +*/ +function Promise(resolver, label) { + this._id = counter++; + this._label = label; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + config.instrument && instrument('created', this); + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise.cast = resolve$1; // deprecated +Promise.all = all; +Promise.race = race; +Promise.resolve = resolve$1; +Promise.reject = reject$1; + +Promise.prototype = { + constructor: Promise, + + _guidKey: guidKey, + + _onError: function (reason) { + var promise = this; + config.after(function() { + if (promise._onError) { + config['trigger']('error', reason, promise._label); + } }); - ``` - - @class RSVP.Promise - @param {function} resolver - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - this._id = counter++; - this._label = label; - this._state = undefined; - this._result = undefined; - this._subscribers = []; + }, + +/** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` - config.instrument && instrument('created', this); + Assimilation + ------------ - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure } + ``` - Promise.cast = resolve$1; // deprecated - Promise.all = all; - Promise.race = race; - Promise.resolve = resolve$1; - Promise.reject = reject$1; + Errback Example - Promise.prototype = { - constructor: Promise, + ```js - _guidKey: guidKey, + function foundBooks(books) { - _onError: function (reason) { - var promise = this; - config.after(function () { - if (promise._onError) { - config['trigger']('error', reason, promise._label); - } - }); - }, + } - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we\'re unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we\'re unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { + findBoooksByAuthor(author, function(books, err) { + if (err) { failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } } - // success - } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfillment + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + then: then, + +/** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'catch': function(onRejection, label) { + return this.then(undefined, onRejection, label); + }, + +/** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves + + Synchronous example: + + ```js + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); + } + + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value + } + ``` + + Asynchronous example: + + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not + }); + ``` + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'finally': function(callback, label) { + var promise = this; + var constructor = promise.constructor; + + return promise.then(function(value) { + return constructor.resolve(callback()).then(function() { + return value; }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong + }, function(reason) { + return constructor.resolve(callback()).then(function() { + return constructor.reject(reason); }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: then, + }, label); + } +}; - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn\'t find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - catch: function (onRejection, label) { - return this.then(undefined, onRejection, label); - }, +function Result() { + this.value = undefined; +} - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); +var ERROR = new Result(); +var GET_THEN_ERROR$1 = new Result(); + +function getThen$1(obj) { + try { + return obj.then; + } catch(error) { + ERROR.value= error; + return ERROR; + } +} + + +function tryApply(f, s, a) { + try { + f.apply(s, a); + } catch(error) { + ERROR.value = error; + return ERROR; + } +} + +function makeObject(_, argumentNames) { + var obj = {}; + var name; + var i; + var length = _.length; + var args = new Array(length); + + for (var x = 0; x < length; x++) { + args[x] = _[x]; + } + + for (i = 0; i < argumentNames.length; i++) { + name = argumentNames[i]; + obj[name] = args[i + 1]; + } + + return obj; +} + +function arrayResult(_) { + var length = _.length; + var args = new Array(length - 1); + + for (var i = 1; i < length; i++) { + args[i - 1] = _[i]; + } + + return args; +} + +function wrapThenable(then, promise) { + return { + then: function(onFulFillment, onRejection) { + return then.call(promise, onFulFillment, onRejection); + } + }; +} + +/** + `RSVP.denodeify` takes a 'node-style' function and returns a function that + will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + browser when you'd prefer to use promises over using callbacks. For example, + `denodeify` transforms the following: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) return handleError(err); + handleData(data); + }); + ``` + + into: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + + readFile('myfile.txt').then(handleData, handleError); + ``` + + If the node function has multiple success parameters, then `denodeify` + just returns the first one: + + ```javascript + var request = RSVP.denodeify(require('request')); + + request('http://example.com').then(function(res) { + // ... + }); + ``` + + However, if you need all success parameters, setting `denodeify`'s + second parameter to `true` causes it to return all success parameters + as an array: + + ```javascript + var request = RSVP.denodeify(require('request'), true); + + request('http://example.com').then(function(result) { + // result[0] -> res + // result[1] -> body + }); + ``` + + Or if you pass it an array with names it returns the parameters as a hash: + + ```javascript + var request = RSVP.denodeify(require('request'), ['res', 'body']); + + request('http://example.com').then(function(result) { + // result.res + // result.body + }); + ``` + + Sometimes you need to retain the `this`: + + ```javascript + var app = require('express')(); + var render = RSVP.denodeify(app.render.bind(app)); + ``` + + The denodified function inherits from the original function. It works in all + environments, except IE 10 and below. Consequently all properties of the original + function are available to you. However, any properties you change on the + denodeified function won't be changed on the original function. Example: + + ```javascript + var request = RSVP.denodeify(require('request')), + cookieJar = request.jar(); // <- Inheritance is used here + + request('http://example.com', {jar: cookieJar}).then(function(res) { + // cookieJar.cookies holds now the cookies returned by example.com + }); + ``` + + Using `denodeify` makes it easier to compose asynchronous operations instead + of using callbacks. For example, instead of: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) { ... } // Handle error + fs.writeFile('myfile2.txt', data, function(err){ + if (err) { ... } // Handle error + console.log('done') + }); + }); + ``` + + you can chain the operations together using `then` from the returned promise: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + var writeFile = RSVP.denodeify(fs.writeFile); + + readFile('myfile.txt').then(function(data){ + return writeFile('myfile2.txt', data); + }).then(function(){ + console.log('done') + }).catch(function(error){ + // Handle error + }); + ``` + + @method denodeify + @static + @for RSVP + @param {Function} nodeFunc a 'node-style' function that takes a callback as + its last argument. The callback expects an error to be passed as its first + argument (if an error occurred, otherwise null), and the value from the + operation as its second argument ('function(err, value){ }'). + @param {Boolean|Array} [options] An optional paramter that if set + to `true` causes the promise to fulfill with the callback's success arguments + as an array. This is useful if the node function has multiple success + paramters. If you set this paramter to an array with names, the promise will + fulfill with a hash with these names as keys and the success parameters as + values. + @return {Function} a function that wraps `nodeFunc` to return an + `RSVP.Promise` + @static +*/ +function denodeify(nodeFunc, options) { + var fn = function() { + var self = this; + var l = arguments.length; + var args = new Array(l + 1); + var arg; + var promiseInput = false; + + for (var i = 0; i < l; ++i) { + arg = arguments[i]; + + if (!promiseInput) { + // TODO: clean this up + promiseInput = needsPromiseInput(arg); + if (promiseInput === GET_THEN_ERROR$1) { + var p = new Promise(noop); + reject(p, GET_THEN_ERROR$1.value); + return p; + } else if (promiseInput && promiseInput !== true) { + arg = wrapThenable(promiseInput, arg); } - return new Author(); } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value - } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not + args[i] = arg; + } + + var promise = new Promise(noop); + + args[l] = function(err, val) { + if (err) + reject(promise, err); + else if (options === undefined) + resolve(promise, val); + else if (options === true) + resolve(promise, arrayResult(arguments)); + else if (isArray(options)) + resolve(promise, makeObject(arguments, options)); + else + resolve(promise, val); + }; + + if (promiseInput) { + return handlePromiseInput(promise, args, nodeFunc, self); + } else { + return handleValueInput(promise, args, nodeFunc, self); + } + }; + + fn.__proto__ = nodeFunc; + + return fn; +} + +function handleValueInput(promise, args, nodeFunc, self) { + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; +} + +function handlePromiseInput(promise, args, nodeFunc, self){ + return Promise.all(args).then(function(args){ + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + }); +} + +function needsPromiseInput(arg) { + if (arg && typeof arg === 'object') { + if (arg.constructor === Promise) { + return true; + } else { + return getThen$1(arg); + } + } else { + return false; + } +} + +/** + This is a convenient alias for `RSVP.Promise.all`. + + @method all + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. +*/ +function all$1(array, label) { + return Promise.all(array, label); +} + +function AllSettled(Constructor, entries, label) { + this._superConstructor(Constructor, entries, false /* don't abort on reject */, label); +} + +AllSettled.prototype = o_create(Enumerator.prototype); +AllSettled.prototype._superConstructor = Enumerator; +AllSettled.prototype._makeResult = makeSettledResult; +AllSettled.prototype._validationError = function() { + return new Error('allSettled must be called with an array'); +}; + +/** + `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + a fail-fast method, it waits until all the promises have returned and + shows you all the results. This is useful if you want to handle multiple + promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled. The return promise is fulfilled with an array of the states of + the promises passed into the `promises` array argument. + + Each state object will either indicate fulfillment or rejection, and + provide the corresponding value or reason. The states will take one of + the following formats: + + ```javascript + { state: 'fulfilled', value: value } + or + { state: 'rejected', reason: reason } + ``` + + Example: + + ```javascript + var promise1 = RSVP.Promise.resolve(1); + var promise2 = RSVP.Promise.reject(new Error('2')); + var promise3 = RSVP.Promise.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.allSettled(promises).then(function(array){ + // array == [ + // { state: 'fulfilled', value: 1 }, + // { state: 'rejected', reason: Error }, + // { state: 'rejected', reason: Error } + // ] + // Note that for the second item, reason.message will be '2', and for the + // third item, reason.message will be '3'. + }, function(error) { + // Not run. (This block would only be called if allSettled had failed, + // for instance if passed an incorrect argument type.) + }); + ``` + + @method allSettled + @static + @for RSVP + @param {Array} entries + @param {String} label - optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with an array of the settled + states of the constituent promises. +*/ + +function allSettled(entries, label) { + return new AllSettled(Promise, entries, label).promise; +} + +/** + This is a convenient alias for `RSVP.Promise.race`. + + @method race + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ +function race$1(array, label) { + return Promise.race(array, label); +} + +function PromiseHash(Constructor, object, label) { + this._superConstructor(Constructor, object, true, label); +} + +PromiseHash.prototype = o_create(Enumerator.prototype); +PromiseHash.prototype._superConstructor = Enumerator; +PromiseHash.prototype._init = function() { + this._result = {}; +}; + +PromiseHash.prototype._validateInput = function(input) { + return input && typeof input === 'object'; +}; + +PromiseHash.prototype._validationError = function() { + return new Error('Promise.hash must be called with an object'); +}; + +PromiseHash.prototype._enumerate = function() { + var enumerator = this; + var promise = enumerator.promise; + var input = enumerator._input; + var results = []; + + for (var key in input) { + if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { + results.push({ + position: key, + entry: input[key] }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - finally: function (callback, label) { - var promise = this; - var constructor = promise.constructor; + } + } + + var length = results.length; + enumerator._remaining = length; + var result; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + result = results[i]; + enumerator._eachEntry(result.entry, result.position); + } +}; + +/** + `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array + for its `promises` argument. + + Returns a promise that is fulfilled when all the given promises have been + fulfilled, or rejected if any of them become rejected. The returned promise + is fulfilled with a hash that has the same key names as the `promises` object + argument. If any of the values in the object are not promises, they will + simply be copied over to the fulfilled object. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + yourPromise: RSVP.resolve(2), + theirPromise: RSVP.resolve(3), + notAPromise: 4 + }; + + RSVP.hash(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: 1, + // yourPromise: 2, + // theirPromise: 3, + // notAPromise: 4 + // } + }); + ```` + + If any of the `promises` given to `RSVP.hash` are rejected, the first promise + that is rejected will be given as the reason to the rejection handler. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + rejectedPromise: RSVP.reject(new Error('rejectedPromise')), + anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), + }; + + RSVP.hash(promises).then(function(hash){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === 'rejectedPromise' + }); + ``` + + An important note: `RSVP.hash` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hash` will NOT preserve prototype + chains. + + Example: + + ```javascript + function MyConstructor(){ + this.example = RSVP.resolve('Example'); + } + + MyConstructor.prototype = { + protoProperty: RSVP.resolve('Proto Property') + }; + + var myObject = new MyConstructor(); + + RSVP.hash(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: 'Example' + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` + + @method hash + @static + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all properties of `promises` + have been fulfilled, or rejected if any of them become rejected. +*/ +function hash(object, label) { + return new PromiseHash(Promise, object, label).promise; +} + +function HashSettled(Constructor, object, label) { + this._superConstructor(Constructor, object, false, label); +} + +HashSettled.prototype = o_create(PromiseHash.prototype); +HashSettled.prototype._superConstructor = Enumerator; +HashSettled.prototype._makeResult = makeSettledResult; + +HashSettled.prototype._validationError = function() { + return new Error('hashSettled must be called with an object'); +}; + +/** + `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + instead of an array for its `promises` argument. - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }, label); - } + Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + but like `RSVP.allSettled`, `hashSettled` waits until all the + constituent promises have returned and then shows you all the results + with their states and values/reasons. This is useful if you want to + handle multiple promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled, or rejected if the passed parameters are invalid. + + The returned promise is fulfilled with a hash that has the same key names as + the `promises` object argument. If any of the values in the object are not + promises, they will be copied over to the fulfilled object and marked with state + 'fulfilled'. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + yourPromise: RSVP.Promise.resolve(2), + theirPromise: RSVP.Promise.resolve(3), + notAPromise: 4 }; - function Result() { - this.value = undefined; - } + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // yourPromise: { state: 'fulfilled', value: 2 }, + // theirPromise: { state: 'fulfilled', value: 3 }, + // notAPromise: { state: 'fulfilled', value: 4 } + // } + }); + ``` - var ERROR = new Result(); - var GET_THEN_ERROR$1 = new Result(); + If any of the `promises` given to `RSVP.hash` are rejected, the state will + be set to 'rejected' and the reason for rejection provided. - function getThen$1(obj) { - try { - return obj.then; - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + Example: - function tryApply(f, s, a) { - try { - f.apply(s, a); - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + rejectedPromise: RSVP.Promise.reject(new Error('rejection')), + anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), + }; - function makeObject(_, argumentNames) { - var obj = {}; - var length = _.length; - var args = new Array(length); + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // rejectedPromise: { state: 'rejected', reason: Error }, + // anotherRejectedPromise: { state: 'rejected', reason: Error }, + // } + // Note that for rejectedPromise, reason.message == 'rejection', + // and for anotherRejectedPromise, reason.message == 'more rejection'. + }); + ``` - for (var x = 0; x < length; x++) { - args[x] = _[x]; - } + An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype + chains. - for (var i = 0; i < argumentNames.length; i++) { - var _name = argumentNames[i]; - obj[_name] = args[i + 1]; - } + Example: - return obj; + ```javascript + function MyConstructor(){ + this.example = RSVP.Promise.resolve('Example'); } - function arrayResult(_) { - var length = _.length; - var args = new Array(length - 1); + MyConstructor.prototype = { + protoProperty: RSVP.Promise.resolve('Proto Property') + }; - for (var i = 1; i < length; i++) { - args[i - 1] = _[i]; - } + var myObject = new MyConstructor(); - return args; - } + RSVP.hashSettled(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: { state: 'fulfilled', value: 'Example' } + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` - function wrapThenable(then, promise) { - return { - then: function (onFulFillment, onRejection) { - return then.call(promise, onFulFillment, onRejection); - } - }; + @method hashSettled + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when when all properties of `promises` + have been settled. + @static +*/ +function hashSettled(object, label) { + return new HashSettled(Promise, object, label).promise; +} + +/** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + + ```javascript + function throws(){ + throw new Error('Whoops!'); } - /** - `RSVP.denodeify` takes a 'node-style' function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - If the node function has multiple success parameters, then `denodeify` - just returns the first one: - - ```javascript - let request = RSVP.denodeify(require('request')); - - request('http://example.com').then(function(res) { - // ... - }); - ``` - - However, if you need all success parameters, setting `denodeify`'s - second parameter to `true` causes it to return all success parameters - as an array: - - ```javascript - let request = RSVP.denodeify(require('request'), true); - - request('http://example.com').then(function(result) { - // result[0] -> res - // result[1] -> body - }); - ``` - - Or if you pass it an array with names it returns the parameters as a hash: - - ```javascript - let request = RSVP.denodeify(require('request'), ['res', 'body']); - - request('http://example.com').then(function(result) { - // result.res - // result.body - }); - ``` - - Sometimes you need to retain the `this`: - - ```javascript - let app = require('express')(); - let render = RSVP.denodeify(app.render.bind(app)); - ``` - - The denodified function inherits from the original function. It works in all - environments, except IE 10 and below. Consequently all properties of the original - function are available to you. However, any properties you change on the - denodeified function won't be changed on the original function. Example: - - ```javascript - let request = RSVP.denodeify(require('request')), - cookieJar = request.jar(); // <- Inheritance is used here - - request('http://example.com', {jar: cookieJar}).then(function(res) { - // cookieJar.cookies holds now the cookies returned by example.com - }); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) { ... } // Handle error - fs.writeFile('myfile2.txt', data, function(err){ - if (err) { ... } // Handle error - console.log('done') - }); - }); - ``` - - you can chain the operations together using `then` from the returned promise: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - let writeFile = RSVP.denodeify(fs.writeFile); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - console.log('done') - }).catch(function(error){ - // Handle error - }); - ``` - - @method denodeify - @static - @for RSVP - @param {Function} nodeFunc a 'node-style' function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ('function(err, value){ }'). - @param {Boolean|Array} [options] An optional paramter that if set - to `true` causes the promise to fulfill with the callback's success arguments - as an array. This is useful if the node function has multiple success - paramters. If you set this paramter to an array with names, the promise will - fulfill with a hash with these names as keys and the success parameters as - values. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - @static - */ - function denodeify(nodeFunc, options) { - var fn = function () { - var self = this; - var l = arguments.length; - var args = new Array(l + 1); - var promiseInput = false; - - for (var i = 0; i < l; ++i) { - var arg = arguments[i]; - - if (!promiseInput) { - // TODO: clean this up - promiseInput = needsPromiseInput(arg); - if (promiseInput === GET_THEN_ERROR$1) { - var p = new Promise(noop); - reject(p, GET_THEN_ERROR$1.value); - return p; - } else if (promiseInput && promiseInput !== true) { - arg = wrapThenable(promiseInput, arg); - } - } - args[i] = arg; - } + var promise = new RSVP.Promise(function(resolve, reject){ + throws(); + }); - var promise = new Promise(noop); + promise.catch(RSVP.rethrow).then(function(){ + // Code here doesn't run because the promise became rejected due to an + // error! + }, function (err){ + // handle the error here + }); + ``` - args[l] = function (err, val) { - if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val); - }; + The 'Whoops' error will be thrown on the next turn of the event loop + and you can watch for it in your console. You can also handle it using a + rejection handler given to `.then` or `.catch` on the returned promise. - if (promiseInput) { - return handlePromiseInput(promise, args, nodeFunc, self); - } else { - return handleValueInput(promise, args, nodeFunc, self); - } - }; + @method rethrow + @static + @for RSVP + @param {Error} reason reason the promise became rejected. + @throws Error + @static +*/ +function rethrow(reason) { + setTimeout(function() { + throw reason; + }); + throw reason; +} - babelHelpers.defaults(fn, nodeFunc); +/** + `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. + `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s + interface. New code should use the `RSVP.Promise` constructor instead. - return fn; - } + The object returned from `RSVP.defer` is a plain object with three properties: - function handleValueInput(promise, args, nodeFunc, self) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - } + * promise - an `RSVP.Promise`. + * reject - a function that causes the `promise` property on this object to + become rejected + * resolve - a function that causes the `promise` property on this object to + become fulfilled. - function handlePromiseInput(promise, args, nodeFunc, self) { - return Promise.all(args).then(function (args) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - }); - } + Example: - function needsPromiseInput(arg) { - if (arg && typeof arg === 'object') { - if (arg.constructor === Promise) { - return true; - } else { - return getThen$1(arg); - } - } else { - return false; - } - } + ```javascript + var deferred = RSVP.defer(); - /** - This is a convenient alias for `RSVP.Promise.all`. - - @method all - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function all$1(array, label) { - return Promise.all(array, label); - } + deferred.resolve("Success!"); - function AllSettled(Constructor, entries, label) { - this._superConstructor(Constructor, entries, false, /* don't abort on reject */label); - } + deferred.promise.then(function(value){ + // value here is "Success!" + }); + ``` - AllSettled.prototype = o_create(Enumerator.prototype); - AllSettled.prototype._superConstructor = Enumerator; - AllSettled.prototype._makeResult = makeSettledResult; - AllSettled.prototype._validationError = function () { - return new Error('allSettled must be called with an array'); - }; + @method defer + @static + @for RSVP + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Object} + */ - /** - `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing - a fail-fast method, it waits until all the promises have returned and - shows you all the results. This is useful if you want to handle multiple - promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled. The return promise is fulfilled with an array of the states of - the promises passed into the `promises` array argument. - - Each state object will either indicate fulfillment or rejection, and - provide the corresponding value or reason. The states will take one of - the following formats: - - ```javascript - { state: 'fulfilled', value: value } - or - { state: 'rejected', reason: reason } - ``` - - Example: - - ```javascript - let promise1 = RSVP.Promise.resolve(1); - let promise2 = RSVP.Promise.reject(new Error('2')); - let promise3 = RSVP.Promise.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.allSettled(promises).then(function(array){ - // array == [ - // { state: 'fulfilled', value: 1 }, - // { state: 'rejected', reason: Error }, - // { state: 'rejected', reason: Error } - // ] - // Note that for the second item, reason.message will be '2', and for the - // third item, reason.message will be '3'. - }, function(error) { - // Not run. (This block would only be called if allSettled had failed, - // for instance if passed an incorrect argument type.) - }); - ``` - - @method allSettled - @static - @for RSVP - @param {Array} entries - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with an array of the settled - states of the constituent promises. - */ +function defer(label) { + var deferred = {}; - function allSettled(entries, label) { - return new AllSettled(Promise, entries, label).promise; - } + deferred['promise'] = new Promise(function(resolve, reject) { + deferred['resolve'] = resolve; + deferred['reject'] = reject; + }, label); - /** - This is a convenient alias for `RSVP.Promise.race`. - - @method race - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function race$1(array, label) { - return Promise.race(array, label); - } + return deferred; +} - function PromiseHash(Constructor, object, label) { - this._superConstructor(Constructor, object, true, label); - } +/** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. - PromiseHash.prototype = o_create(Enumerator.prototype); - PromiseHash.prototype._superConstructor = Enumerator; - PromiseHash.prototype._init = function () { - this._result = {}; - }; + For example: - PromiseHash.prototype._validateInput = function (input) { - return input && typeof input === 'object'; - }; + ```javascript + + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; - PromiseHash.prototype._validationError = function () { - return new Error('Promise.hash must be called with an object'); + var mapFn = function(item){ + return item + 1; }; - PromiseHash.prototype._enumerate = function () { - var enumerator = this; - var promise = enumerator.promise; - var input = enumerator._input; - var results = []; - - for (var key in input) { - if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { - results.push({ - position: key, - entry: input[key] - }); - } - } + RSVP.map(promises, mapFn).then(function(result){ + // result is [ 2, 3, 4 ] + }); + ``` - var length = results.length; - enumerator._remaining = length; - var result = undefined; + If any of the `promises` given to `RSVP.map` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - for (var i = 0; promise._state === PENDING && i < length; i++) { - result = results[i]; - enumerator._eachEntry(result.entry, result.position); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; }; - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as the reason to the rejection handler. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error('rejectedPromise')), - anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === 'rejectedPromise' - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve('Example'); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: 'Example' - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @static - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - function hash(object, label) { - return new PromiseHash(Promise, object, label).promise; - } + RSVP.map(promises, mapFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - function HashSettled(Constructor, object, label) { - this._superConstructor(Constructor, object, false, label); - } + `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, + say you want to get all comments from a set of blog posts, but you need + the blog posts first because they contain a url to those comments. - HashSettled.prototype = o_create(PromiseHash.prototype); - HashSettled.prototype._superConstructor = Enumerator; - HashSettled.prototype._makeResult = makeSettledResult; + ```javscript - HashSettled.prototype._validationError = function () { - return new Error('hashSettled must be called with an object'); + var mapFn = function(blogPost){ + // getComments does some ajax and returns an RSVP.Promise that is fulfilled + // with some comments data + return getComments(blogPost.comments_url); }; - /** - `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object - instead of an array for its `promises` argument. - - Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, - but like `RSVP.allSettled`, `hashSettled` waits until all the - constituent promises have returned and then shows you all the results - with their states and values/reasons. This is useful if you want to - handle multiple promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled, or rejected if the passed parameters are invalid. - - The returned promise is fulfilled with a hash that has the same key names as - the `promises` object argument. If any of the values in the object are not - promises, they will be copied over to the fulfilled object and marked with state - 'fulfilled'. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - yourPromise: RSVP.Promise.resolve(2), - theirPromise: RSVP.Promise.resolve(3), - notAPromise: 4 - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // yourPromise: { state: 'fulfilled', value: 2 }, - // theirPromise: { state: 'fulfilled', value: 3 }, - // notAPromise: { state: 'fulfilled', value: 4 } - // } - }); - ``` - - If any of the `promises` given to `RSVP.hash` are rejected, the state will - be set to 'rejected' and the reason for rejection provided. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - rejectedPromise: RSVP.Promise.reject(new Error('rejection')), - anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // rejectedPromise: { state: 'rejected', reason: Error }, - // anotherRejectedPromise: { state: 'rejected', reason: Error }, - // } - // Note that for rejectedPromise, reason.message == 'rejection', - // and for anotherRejectedPromise, reason.message == 'more rejection'. - }); - ``` - - An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.Promise.resolve('Example'); + // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled + // with some blog post data + RSVP.map(getBlogPosts(), mapFn).then(function(comments){ + // comments is the result of asking the server for the comments + // of all blog posts returned from getBlogPosts() + }); + ``` + + @method map + @static + @for RSVP + @param {Array} promises + @param {Function} mapFn function to be called on each fulfilled promise. + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with the result of calling + `mapFn` on each fulfilled promise or value when they become fulfilled. + The promise will be rejected if any of the given `promises` become rejected. + @static +*/ +function map(promises, mapFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(mapFn)) { + throw new TypeError("You must pass a function as map's second argument."); } - - MyConstructor.prototype = { - protoProperty: RSVP.Promise.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hashSettled(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: { state: 'fulfilled', value: 'Example' } - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hashSettled - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when when all properties of `promises` - have been settled. - @static - */ - function hashSettled(object, label) { - return new HashSettled(Promise, object, label).promise; - } - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will also throw the - error again so the error can be handled by the promise per the spec. - - ```javascript - function throws(){ - throw new Error('Whoops!'); + var length = values.length; + var results = new Array(length); + + for (var i = 0; i < length; i++) { + results[i] = mapFn(values[i]); } - - let promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @static - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - @static - */ - function rethrow(reason) { - setTimeout(function () { - throw reason; - }); - throw reason; - } - /** - `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. - `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s - interface. New code should use the `RSVP.Promise` constructor instead. - - The object returned from `RSVP.defer` is a plain object with three properties: - - * promise - an `RSVP.Promise`. - * reject - a function that causes the `promise` property on this object to - become rejected - * resolve - a function that causes the `promise` property on this object to - become fulfilled. - - Example: - - ```javascript - let deferred = RSVP.defer(); - - deferred.resolve("Success!"); - - deferred.promise.then(function(value){ - // value here is "Success!" - }); - ``` - - @method defer - @static - @for RSVP - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Object} - */ + return Promise.all(results, label); + }); +} - function defer(label) { - var deferred = { resolve: undefined, reject: undefined }; +/** + This is a convenient alias for `RSVP.Promise.resolve`. - deferred.promise = new Promise(function (resolve, reject) { - deferred.resolve = resolve; - deferred.reject = reject; - }, label); + @method resolve + @static + @for RSVP + @param {*} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$2(value, label) { + return Promise.resolve(value, label); +} - return deferred; - } +/** + This is a convenient alias for `RSVP.Promise.reject`. - /** - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first because they contain a url to those comments. - - ```javscript - - let mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @static - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - @static - */ - function map(promises, mapFn, label) { - return Promise.all(promises, label).then(function (values) { - if (!isFunction(mapFn)) { - throw new TypeError("You must pass a function as map's second argument."); - } + @method reject + @static + @for RSVP + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$2(reason, label) { + return Promise.reject(reason, label); +} - var length = values.length; - var results = new Array(length); +/** + `RSVP.filter` is similar to JavaScript's native `filter` method, except that it + waits for all promises to become fulfilled before running the `filterFn` on + each item in given to `promises`. `RSVP.filter` returns a promise that will + become fulfilled with the result of running `filterFn` on the values the + promises become fulfilled with. - for (var i = 0; i < length; i++) { - results[i] = mapFn(values[i]); - } + For example: - return Promise.all(results, label); - }); - } + ```javascript - /** - This is a convenient alias for `RSVP.Promise.resolve`. - - @method resolve - @static - @for RSVP - @param {*} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - function resolve$2(value, label) { - return Promise.resolve(value, label); - } + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); - /** - This is a convenient alias for `RSVP.Promise.reject`. - - @method reject - @static - @for RSVP - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$2(reason, label) { - return Promise.reject(reason, label); - } + var promises = [promise1, promise2, promise3]; - /** - `RSVP.filter` is similar to JavaScript's native `filter` method, except that it - waits for all promises to become fulfilled before running the `filterFn` on - each item in given to `promises`. `RSVP.filter` returns a promise that will - become fulfilled with the result of running `filterFn` on the values the - promises become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - - let promises = [promise1, promise2, promise3]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - let alice = { name: 'alice' }; - let bob = { name: 'bob' }; - let users = [ alice, bob ]; - - let promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - let filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @static - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ + var filterFn = function(item){ + return item > 1; + }; - function resolveAll(promises, label) { - return Promise.all(promises, label); - } + RSVP.filter(promises, filterFn).then(function(result){ + // result is [ 2, 3 ] + }); + ``` - function resolveSingle(promise, label) { - return Promise.resolve(promise, label).then(function (promises) { - return resolveAll(promises, label); - }); - } + If any of the `promises` given to `RSVP.filter` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - function filter(promises, filterFn, label) { - var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label); - return promise.then(function (values) { - if (!isFunction(filterFn)) { - throw new TypeError("You must pass a function as filter's second argument."); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; - var length = values.length; - var filtered = new Array(length); + var filterFn = function(item){ + return item > 1; + }; - for (var i = 0; i < length; i++) { - filtered[i] = filterFn(values[i]); - } + RSVP.filter(promises, filterFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - return resolveAll(filtered, label).then(function (filtered) { - var results = new Array(length); - var newLength = 0; + `RSVP.filter` will also wait for any promises returned from `filterFn`. + For instance, you may want to fetch a list of users then return a subset + of those users based on some asynchronous operation: - for (var i = 0; i < length; i++) { - if (filtered[i]) { - results[newLength] = values[i]; - newLength++; - } - } + ```javascript - results.length = newLength; + var alice = { name: 'alice' }; + var bob = { name: 'bob' }; + var users = [ alice, bob ]; - return results; - }); + var promises = users.map(function(user){ + return RSVP.resolve(user); + }); + + var filterFn = function(user){ + // Here, Alice has permissions to create a blog post, but Bob does not. + return getPrivilegesForUser(user).then(function(privs){ + return privs.can_create_blog_post === true; }); - } + }; + RSVP.filter(promises, filterFn).then(function(users){ + // true, because the server told us only Alice can create a blog post. + users.length === 1; + // false, because Alice is the only user present in `users` + users[0] === bob; + }); + ``` - var len = 0; - var vertxNext = undefined; - function asap(callback, arg) { - queue$1[len] = callback; - queue$1[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 1, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - scheduleFlush$1(); - } - } - - var browserWindow = typeof window !== 'undefined' ? window : undefined; - var browserGlobal = browserWindow || {}; - var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; - var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; - - // test for web worker but not in IE10 - var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; - - // node - function useNextTick() { - var nextTick = process.nextTick; - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // setImmediate should be used instead instead - var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); - if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { - nextTick = setImmediate; + @method filter + @static + @for RSVP + @param {Array} promises + @param {Function} filterFn - function to be called on each resolved value to + filter the final results. + @param {String} label optional string describing the promise. Useful for + tooling. + @return {Promise} +*/ +function filter(promises, filterFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(filterFn)) { + throw new TypeError("You must pass a function as filter's second argument."); } - return function () { - return nextTick(flush); - }; - } - // vertx - function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); - }; + var length = values.length; + var filtered = new Array(length); + + for (var i = 0; i < length; i++) { + filtered[i] = filterFn(values[i]); } - return useSetTimeout(); - } - function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); + return Promise.all(filtered, label).then(function(filtered) { + var results = new Array(length); + var newLength = 0; - return function () { - return node.data = iterations = ++iterations % 2; - }; - } + for (var i = 0; i < length; i++) { + if (filtered[i]) { + results[newLength] = values[i]; + newLength++; + } + } - // web worker - function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; - } + results.length = newLength; - function useSetTimeout() { - return function () { - return setTimeout(flush, 1); - }; + return results; + }); + }); +} + +var len = 0; +var vertxNext; +function asap(callback, arg) { + queue$1[len] = callback; + queue$1[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 1, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + scheduleFlush$1(); } +} - var queue$1 = new Array(1000); +var browserWindow = (typeof window !== 'undefined') ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && + typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + var nextTick = process.nextTick; + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // setImmediate should be used instead instead + var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); + if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { + nextTick = setImmediate; + } + return function() { + nextTick(flush); + }; +} - function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue$1[i]; - var arg = queue$1[i + 1]; +// vertx +function useVertxTimer() { + return function() { + vertxNext(flush); + }; +} - callback(arg); +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); - queue$1[i] = undefined; - queue$1[i + 1] = undefined; - } + return function() { + node.data = (iterations = ++iterations % 2); + }; +} - len = 0; - } +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; +} - function attemptVertex() { - try { - var r = require; - var vertx = r('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } +function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; +} + +var queue$1 = new Array(1000); +function flush() { + for (var i = 0; i < len; i+=2) { + var callback = queue$1[i]; + var arg = queue$1[i+1]; + + callback(arg); + + queue$1[i] = undefined; + queue$1[i+1] = undefined; } - var scheduleFlush$1 = undefined; - // Decide what async method to use to triggering processing of queued callbacks: - if (isNode) { - scheduleFlush$1 = useNextTick(); - } else if (BrowserMutationObserver) { - scheduleFlush$1 = useMutationObserver(); - } else if (isWorker) { - scheduleFlush$1 = useMessageChannel(); - } else if (browserWindow === undefined && typeof require === 'function') { - scheduleFlush$1 = attemptVertex(); - } else { - scheduleFlush$1 = useSetTimeout(); + len = 0; +} + +function attemptVertex() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch(e) { + return useSetTimeout(); } +} + +var scheduleFlush$1; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush$1 = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush$1 = useMutationObserver(); +} else if (isWorker) { + scheduleFlush$1 = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush$1 = attemptVertex(); +} else { + scheduleFlush$1 = useSetTimeout(); +} + +// defaults +config.async = asap; +config.after = function(cb) { + setTimeout(cb, 0); +}; +var cast = resolve$2; +function async(callback, arg) { + config.async(callback, arg); +} - var platform = undefined; +function on() { + config['on'].apply(config, arguments); +} - /* global self */ - if (typeof self === 'object') { - platform = self; +function off() { + config['off'].apply(config, arguments); +} - /* global global */ - } else if (typeof global === 'object') { - platform = global; - } else { - throw new Error('no global: `self` or `global` found'); +// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` +if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { + var callbacks = window['__PROMISE_INSTRUMENTATION__']; + configure('instrument', true); + for (var eventName in callbacks) { + if (callbacks.hasOwnProperty(eventName)) { + on(eventName, callbacks[eventName]); } + } +} - // defaults - config.async = asap; - config.after = function (cb) { - return setTimeout(cb, 0); - }; - var cast = resolve$2; +exports.cast = cast; +exports.Promise = Promise; +exports.EventTarget = EventTarget; +exports.all = all$1; +exports.allSettled = allSettled; +exports.race = race$1; +exports.hash = hash; +exports.hashSettled = hashSettled; +exports.rethrow = rethrow; +exports.defer = defer; +exports.denodeify = denodeify; +exports.configure = configure; +exports.on = on; +exports.off = off; +exports.resolve = resolve$2; +exports.reject = reject$2; +exports.async = async; +exports.map = map; +exports.filter = filter; - var async = function (callback, arg) { - return config.async(callback, arg); - }; +Object.defineProperty(exports, '__esModule', { value: true }); - function on() { - config['on'].apply(config, arguments); - } - - function off() { - config['off'].apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { - var callbacks = window['__PROMISE_INSTRUMENTATION__']; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - // the default export here is for backwards compat: - // https://github.com/tildeio/rsvp.js/issues/434 - var rsvp = (_rsvp = { - cast: cast, - Promise: Promise, - EventTarget: EventTarget, - all: all$1, - allSettled: allSettled, - race: race$1, - hash: hash, - hashSettled: hashSettled, - rethrow: rethrow, - defer: defer, - denodeify: denodeify, - configure: configure, - on: on, - off: off, - resolve: resolve$2, - reject: reject$2, - map: map - }, _rsvp['async'] = async, _rsvp.filter = // babel seems to error if async isn't a computed prop here... - filter, _rsvp); - - exports.cast = cast; - exports.Promise = Promise; - exports.EventTarget = EventTarget; - exports.all = all$1; - exports.allSettled = allSettled; - exports.race = race$1; - exports.hash = hash; - exports.hashSettled = hashSettled; - exports.rethrow = rethrow; - exports.defer = defer; - exports.denodeify = denodeify; - exports.configure = configure; - exports.on = on; - exports.off = off; - exports.resolve = resolve$2; - exports.reject = reject$2; - exports.map = map; - exports.async = async; - exports.filter = filter; - exports.default = rsvp; }); requireModule("ember"); diff --git a/ember.js b/ember.js index 8ff25b735..77ae75e1e 100644 --- a/ember.js +++ b/ember.js @@ -6,10 +6,11 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.11.0-beta.2 + * @version 2.10.0-intercom */ var enifed, requireModule, Ember; +var mainContext = this; (function() { var isNode = typeof window === 'undefined' && @@ -111,6 +112,8 @@ var enifed, requireModule, Ember; } })(); +var babelHelpers; + function classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); @@ -1469,7 +1472,7 @@ enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'e var factoryInjections = factoryInjectionsFor(container, fullName); var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); - factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + factoryInjections._toString = registry.makeToString(factory, fullName); var injectedFactory = factory.extend(injections); @@ -3233,10 +3236,22 @@ enifed('ember-application/system/application', ['exports', 'ember-utils', 'ember */ 'use strict'; + exports._resetLegacyAddonWarnings = _resetLegacyAddonWarnings; + var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['-bucket-cache:main'], ['-bucket-cache:main']); var librariesRegistered = false; + var warnedAboutLegacyViewAddon = false; + var warnedAboutLegacyControllerAddon = false; + + // For testing + + function _resetLegacyAddonWarnings() { + warnedAboutLegacyViewAddon = false; + warnedAboutLegacyControllerAddon = false; + } + /** An instance of `Ember.Application` is the starting point for every Ember application. It helps to instantiate, initialize and coordinate the many @@ -7144,7 +7159,7 @@ enifed('ember-glimmer/component', ['exports', 'ember-utils', 'ember-views', 'emb @default null @public */ - Component[_emberUtils.NAME_KEY] = 'Ember.Component'; + Component[_emberMetal.NAME_KEY] = 'Ember.Component'; Component.reopenClass({ isComponentFactory: true, @@ -9488,19 +9503,17 @@ enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glim additional information on how a `Component` functions. `{{component}}`'s primary use is for cases where you want to dynamically change which type of component is rendered as the state of your application - changes. This helper has three modes: inline, block, and nested. + changes. The provided block will be applied as the template for the component. + Given an empty `` the following template: - ### Inline Form - - Given the following template: - - ```app/application.hbs + ```handlebars + {{! application.hbs }} {{component infographicComponentName}} ``` And the following application code: - ```app/controllers/application.js + ```javascript export default Ember.Controller.extend({ infographicComponentName: computed('isMarketOpen', { get() { @@ -9521,87 +9534,33 @@ enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glim Note: You should not use this helper when you are consistently rendering the same component. In that case, use standard component syntax, for example: - ```app/templates/application.hbs + ```handlebars + {{! application.hbs }} {{live-updating-chart}} ``` - ### Block Form - - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: - - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} - ``` - - The following controller code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), - - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); - ``` - - And the following component template: - - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} - ``` - - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. - - ### Nested Usage + ## Nested Usage The `component` helper can be used to package a component path with initial attrs. The included attrs can then be merged during the final invocation. For example, given a `person-form` component with the following template: - ```app/templates/components/person-form.hbs + ```handlebars {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} + nameInput=(component "my-input-component" value=model.name placeholder="First Name"))}} ``` - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: + The following snippet: ``` {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} + {{component form.nameInput placeholder="Username"}} {{/person-form}} ``` - Which outputs an input whose value is already bound to `model.name` and `placeholder` + would output an input whose value is already bound to `model.name` and `placeholder` is "Username". - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: - - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} - ``` - - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} - ``` - @method component @since 1.11.0 @for Ember.Templates.helpers @@ -10443,9 +10402,6 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e }); ``` - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - Additionally, the `mut` helper can be combined with the `action` helper to mutate a value. For example: @@ -10459,7 +10415,7 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e // my-child.js export default Component.extend({ click() { - this.get('click-count-change')(this.get('childClickCount') + 1); + this.get('clickCountChange')(this.get('childClickCount') + 1); } }); ``` @@ -11327,7 +11283,7 @@ enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', ' var runInTransaction = undefined; - if (true || false) { + if (true || true) { runInTransaction = _emberMetal.runInTransaction; } else { runInTransaction = function (context, methodName) { @@ -14258,7 +14214,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var TwoWayFlushDetectionTag = undefined; - if (true || false) { + if (true || true) { TwoWayFlushDetectionTag = (function () { function _class(tag, key, ref) { babelHelpers.classCallCheck(this, _class); @@ -14332,7 +14288,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentValue = parentValue; this._propertyKey = propertyKey; - if (true || false) { + if (true || true) { this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); } else { this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); @@ -14347,7 +14303,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var _parentValue = this._parentValue; var _propertyKey = this._propertyKey; - if (true || false) { + if (true || true) { this.tag.didCompute(_parentValue); } @@ -14378,7 +14334,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentObjectTag = parentObjectTag; this._propertyKey = propertyKey; - if (true || false) { + if (true || true) { var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); } else { @@ -14404,7 +14360,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal _emberMetal.watchKey(parentValue, _propertyKey); } - if (true || false) { + if (true || true) { this.tag.didCompute(parentValue); } @@ -17588,6 +17544,7 @@ enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-me exports.removeObserver = _emberMetalObserver.removeObserver; exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.NAME_KEY = _emberMetalMixin.NAME_KEY; exports.Mixin = _emberMetalMixin.Mixin; exports.aliasMethod = _emberMetalMixin.aliasMethod; exports._immediateObserver = _emberMetalMixin._immediateObserver; @@ -18788,7 +18745,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e var META_DESTROYED = 1 << 3; var IS_PROXY = 1 << 4; - if (true || false) { + if (true || true) { members.lastRendered = ownMap; members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds } @@ -18830,7 +18787,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e // inherited, and we can optimize it much better than JS runtimes. this.parent = parentMeta; - if (true || false) { + if (true || true) { this._lastRendered = undefined; this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds } @@ -19626,32 +19583,20 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function applyConcatenatedProperties(obj, key, value, values) { var baseValue = values[key] || obj[key]; - var ret = undefined; if (baseValue) { if ('function' === typeof baseValue.concat) { if (value === null || value === undefined) { - ret = baseValue; + return baseValue; } else { - ret = baseValue.concat(value); + return baseValue.concat(value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + return _emberUtils.makeArray(baseValue).concat(value); } } else { - ret = _emberUtils.makeArray(value); + return _emberUtils.makeArray(value); } - - _emberMetalDebug.runInDebug(function () { - // it is possible to use concatenatedProperties with strings (which cannot be frozen) - // only freeze objects... - if (typeof ret === 'object' && ret !== null) { - // prevent mutating `concatenatedProperties` array after it is applied - Object.freeze(ret); - } - }); - - return ret; } function applyMergedProperties(obj, key, value, values) { @@ -19927,6 +19872,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb return obj; } + var NAME_KEY = _emberUtils.GUID_KEY + '_name'; + + exports.NAME_KEY = NAME_KEY; /** The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, @@ -20009,7 +19957,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb this.ownerConstructor = undefined; this._without = undefined; this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; + this[NAME_KEY] = null; _emberMetalDebug.debugSeal(this); } @@ -21002,7 +20950,7 @@ enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/me _emberMetalTags.markObjectAsDirty(meta, keyName); - if (true || false) { + if (true || true) { _emberMetalTransaction.assertNotRendered(obj, keyName, meta); } } @@ -22331,20 +22279,20 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d assertNotRendered = undefined; var raise = _emberMetalDebug.assert; - if (false) { + if (true) { raise = function (message, test) { _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' }); }; } var implication = undefined; - if (false) { + if (true) { implication = 'will be removed in Ember 3.0.'; } else if (true) { implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; } - if (true || false) { + if (true || true) { (function () { var counter = 0; var inTransaction = false; @@ -22396,7 +22344,7 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; + return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; })(), false); shouldReflush = true; @@ -24690,8 +24638,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. + For example, a route found at `app/routes/posts/post.js` or + `app/posts/post/route.js` (with pods) will have a `routeName` of + `posts.post`. @property routeName @for Ember.Route @type String @@ -24907,23 +24856,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Returns a hash containing the parameters of an ancestor route. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('member', { path: ':name' }, function() { this.route('interest', { path: ':interest' }); }); }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ + App.MemberRoute = Ember.Route.extend({ queryParams: { memberQp: { refreshModel: true } } }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ + App.MemberInterestRoute = Ember.Route.extend({ queryParams: { interestQp: { refreshModel: true } }, @@ -25016,10 +24960,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can use to reset controller values either when the model changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { + ```javascript + App.ArticlesRoute = Ember.Route.extend({ + // ... + resetController: function(controller, isExiting, transition) { if (isExiting) { controller.set('page', 1); } @@ -25070,19 +25014,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the template to use by default when rendering this routes template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + let PostsList = Ember.Route.extend({ templateName: 'posts/list' }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); + App.PostsIndexRoute = PostsList.extend(); + App.PostsArchivedRoute = PostsList.extend(); ``` @property templateName @type String @@ -25117,11 +25054,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' or decorating the transition from the currently active routes. A good example is preventing navigation when a form is half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ContactFormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData')) { this.controller.displayNavigationConfirm(); transition.abort(); @@ -25155,11 +25091,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' have resolved. The `didTransition` action has no arguments, however, it can be useful for tracking page views or resetting state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.LoginRoute = Ember.Route.extend({ actions: { - didTransition() { + didTransition: function() { this.controller.get('errors.base').clear(); return true; // Bubble the didTransition event } @@ -25176,10 +25111,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' hook returns a promise that is not already resolved. The current `Transition` object is the first parameter and the route that triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - loading(transition, route) { + loading: function(transition, route) { let controller = this.controllerFor('foo'); controller.set('currentlyLoading', true); transition.finally(function() { @@ -25205,14 +25140,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Here is an example of an error handler that will be invoked for rejected promises from the various hooks on the route, as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { + ```javascript + App.AdminRoute = Ember.Route.extend({ + beforeModel: function() { return Ember.RSVP.reject('bad things!'); }, actions: { - error(error, transition) { + error: function(error, transition) { // Assuming we got here due to the error in `beforeModel`, // we can expect that error === "bad things!", // but a promise model rejecting would also @@ -25230,11 +25164,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' will fire a default error handler that logs the error. You can specify your own global default error handler by overriding the `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - error(error, transition) { + error: function(error, transition) { this.controllerFor('banner').displayError(error.message); } } @@ -25250,12 +25183,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router enters the route. It is not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + collectAnalytics: function(){ collectAnalytics(); - }) + }.on('activate') }); ``` @event activate @@ -25266,12 +25198,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router completely exits this route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + ```javascript + App.IndexRoute = Ember.Route.extend({ + trackPageLeaveAnalytics: function(){ trackPageLeaveAnalytics(); - }) + }.on('deactivate') }); ``` @event deactivate @@ -25282,11 +25213,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The controller associated with this route. Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.FormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData') && !confirm('Are you sure you want to abandon progress?')) { transition.abort(); @@ -25458,17 +25388,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Multiple models will be applied last to first recursively up the route tree. - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); }); }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', aPost, aComment); this.transitionTo('blogComment', 1, 13); ``` It is also possible to pass a URL (a string that starts with a @@ -25490,20 +25416,15 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` See also [replaceWith](#method_replaceWith). Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); this.route('fourOhFour', { path: '*:' }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToSecret(context) { + moveToSecret: function(context) { if (authorized()) { this.transitionTo('secret', context); } else { @@ -25514,63 +25435,48 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }); ``` Transition to a nested route - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('articles', { path: '/articles' }, function() { this.route('new'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToNewArticle() { + transitionToNewArticle: function() { this.transitionTo('articles.new'); } } }); ``` Multiple Models Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); + this.route('cereal', { path: ':cerealId', resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToChocolateCereal() { + moveToChocolateCereal: function() { let cereal = { cerealId: 'ChocolateYumminess' }; let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); + this.transitionTo('cereal', breakfast, cereal); } } }); ``` Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('fruits', function() { this.route('apples'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToApples() { + transitionToApples: function() { this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); } } @@ -25641,18 +25547,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Beside that, it is identical to `transitionTo` in all other respects. See 'transitionTo' for additional information regarding multiple models. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.SecretRoute = Ember.Route.extend({ + afterModel: function() { if (!authorized()){ this.replaceWith('index'); } @@ -25677,28 +25578,20 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Sends an action to the router, which will delegate it to the currently active route hierarchy per the bubbling rules explained under `actions`. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.ApplicationRoute = Ember.Route.extend({ actions: { - track(arg) { + track: function(arg) { console.log(arg, 'was clicked'); } } }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - trackIfDebug(arg) { + trackIfDebug: function(arg) { if (debug) { this.send('track', arg); } @@ -25817,7 +25710,6 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' cache.stash(cacheKey, prop, value); } }, - /** This hook is the first of the route entry validation hooks called when an attempt is made to transition into a route @@ -25837,6 +25729,46 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' transition until the promise resolves (or rejects). This could be useful, for instance, for retrieving async code from the server that is required to enter a route. + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + return Ember.$.getScript('/models/post.js'); + } + } + }); + ``` + If `App.Post` doesn't exist in the above example, + `beforeModel` will use jQuery's `getScript`, which + returns a promise that resolves after the server has + successfully retrieved and executed the code from the + server. Note that if an error were to occur, it would + be passed to the `error` hook on `Ember.Route`, but + it's also possible to handle errors specific to + `beforeModel` right from within the hook (to distinguish + from the shared error handling behavior of the `error` + hook): + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + let self = this; + return Ember.$.getScript('post.js').then(null, function(e) { + self.transitionTo('help'); + // Note that the above transitionTo will implicitly + // halt the transition. If you were to return + // nothing from this promise reject handler, + // according to promise semantics, that would + // convert the reject into a resolve and the + // transition would continue. To propagate the + // error so that it'd be handled by the `error` + // hook, you would have to + return Ember.RSVP.reject(e); + }); + } + } + }); + ``` @method beforeModel @param {Transition} transition @return {Promise} if the value returned from this hook is @@ -25855,10 +25787,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' the `transition`, and is therefore suited to performing logic that can only take place after the model has already resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + afterModel: function(posts, transition) { if (posts.get('length') === 1) { this.transitionTo('post.show', posts.get('firstObject')); } @@ -25918,12 +25849,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the URL into the model for this route. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` The model for the `post` route is `store.findRecord('post', params.post_id)`. By default, if your route has a dynamic segment ending in `_id`: @@ -25957,10 +25886,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' if a promise returned from `model` fails, the error will be handled by the `error` hook on `Ember.Route`. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + ```javascript + App.PostRoute = Ember.Route.extend({ + model: function(params) { return this.store.findRecord('post', params.post_id); } }); @@ -25976,7 +25904,8 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' @public */ model: function (params, transition) { - var name = undefined, + var match = undefined, + name = undefined, sawParams = undefined, value = undefined; var queryParams = _emberMetal.get(this, '_qp.map'); @@ -25986,8 +25915,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' continue; } - var match = prop.match(/^(.*)_id$/); - if (match) { + if (match = prop.match(/^(.*)_id$/)) { name = match[1]; value = params[prop]; } @@ -26067,20 +25995,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the route's model into parameters for the URL. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + App.PostRoute = Ember.Route.extend({ + model: function(params) { // the server returns `{ id: 12 }` return Ember.$.getJSON('/posts/' + params.post_id); }, - serialize(model) { + serialize: function(model) { // this will make the URL `/posts/12` return { post_id: model.id }; } @@ -26112,13 +26036,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' prevent this default behavior. If you want to preserve that behavior when implementing your `setupController` function, make sure to call `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { + ```javascript + App.PhotosRoute = Ember.Route.extend({ + model: function() { return this.store.findAll('photo'); }, - setupController(controller, model) { + setupController: function(controller, model) { // Call _super for default behavior this._super(controller, model); // Implement your custom setup after @@ -26130,21 +26053,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' of this route. If no explicit controller is defined, Ember will automatically create one. As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` For the `post` route, a controller named `App.PostController` would be used if it is defined. If it is not defined, a basic `Ember.Controller` instance would be used. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, model) { controller.set('model', model); } }); @@ -26162,14 +26082,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }, /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. + Returns the controller for a particular route or name. The controller instance must already have been created, either through entering the associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.controllerFor('posts').set('currentPost', post); } @@ -26203,10 +26121,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Generates a controller for a route. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.generateController('posts'); } @@ -26232,19 +26149,14 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' retrieve it. If the ancestor route's model was a promise, its resolved result is returned. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/post/:post_id' }, function() { this.route('comments', { resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.CommentsRoute = Ember.Route.extend({ + afterModel: function() { this.set('post', this.modelFor('post')); } }); @@ -26289,10 +26201,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' template, configured with the controller for the route. This method can be overridden to set up and render additional or alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + renderTemplate: function(controller, model) { let favController = this.controllerFor('favoritePost'); // Render the `favoritePost` template into // the outlet `posts`, and display the `favoritePost` @@ -26320,12 +26231,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' phase of routing (via the `renderTemplate` hook) and later in response to user interaction. For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { + ```javascript + Router.map(function() { this.route('photos'); }); - export default Router; ``` ```handlebars @@ -26339,10 +26248,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` You can render `photos.hbs` into the `"anOutletName"` outlet of `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function() { this.render('photos', { into: 'application', outlet: 'anOutletName' @@ -26352,10 +26261,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` `render` additionally allows you to supply which `controller` and `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function(controller, model){ this.render('posts', { // the template to render, referenced by name into: 'application', // the template to render into, referenced by name outlet: 'anOutletName', // the outlet inside `options.template` to render into. @@ -26374,26 +26283,26 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' based on the name of the route specified in the router or the Route's `controllerName` and `templateName` properties. For example: - ```app/router.js - // ... - Router.map(function() { + ```javascript + // router + Router.map(function() { this.route('index'); this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // post route + PostRoute = App.Route.extend({ + renderTemplate: function() { this.render(); // all defaults apply } }); ``` - The name of the route, defined by the router, is `post`. + The name of the `PostRoute`, defined by the router, is `post`. The following equivalent default options will be applied when the Route calls `render`: ```javascript + // this.render('post', { // the template name associated with 'post' Route into: 'application', // the parent route to 'post' Route outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, @@ -26442,17 +26351,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' * `parentView`: the name of the view containing the outlet to clear (default: the view rendered by the parent route) Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ + ```javascript + App.ApplicationRoute = App.Route.extend({ actions: { - showModal(evt) { + showModal: function(evt) { this.render(evt.modalName, { outlet: 'modal', into: 'application' }); }, - hideModal(evt) { + hideModal: function(evt) { this.disconnectOutlet({ outlet: 'modal', parentView: 'application' @@ -26463,18 +26371,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Alternatively, you can pass the `outlet` name directly as a string. Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } - }); + ```javascript + hideModal: function(evt) { + this.disconnectOutlet('modal'); + } + ``` @method disconnectOutlet @param {Object|String} options the options hash or outlet name @since 1.0.0 @@ -26618,7 +26519,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' var template = owner.lookup('template:' + templateName); var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { + if (into && (parent = parentRoute(route)) && into === parentRoute(route).routeName) { into = undefined; } @@ -28200,12 +28101,6 @@ enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console' _emberMetal.set(target.outlets, renderOptions.outlet, myState); } else { if (renderOptions.into) { - _emberMetal.deprecate('Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.', false, { - id: 'ember-routing.top-level-render-helper', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' - }); - // Megahax time. Post-3.0-breaking-changes, we will just assert // right here that the user tried to target a nonexistent // thing. But for now we still need to support the `render` @@ -28451,7 +28346,11 @@ enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], functio */ function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; + if (queryParams._qpMap) { + return queryParams._qpMap; + } + + var qpMap = queryParams._qpMap = {}; for (var i = 0; i < queryParams.length; ++i) { accumulateQueryParamDescriptors(queryParams[i], qpMap); @@ -31152,6 +31051,8 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi args[_key - 1] = arguments[_key]; } + var target = undefined; + if (this.actions && this.actions[actionName]) { var shouldBubble = this.actions[actionName].apply(this, args) === true; if (!shouldBubble) { @@ -31159,10 +31060,11 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi } } - var target = _emberMetal.get(this, 'target'); - if (target) { + if (target = _emberMetal.get(this, 'target')) { + var _target; + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + (_target = target).send.apply(_target, arguments); } }, @@ -31583,7 +31485,7 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' /** This returns the objects at the specified indexes, using `objectAt`. ```javascript - let arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] ``` @@ -32523,8 +32425,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta for (var idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - if (found) { + if (found = callback.call(target, next, idx, this)) { ret = next; } @@ -35317,7 +35218,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met // using ember-metal/lib/main here to ensure that ember-debug is setup // if present - var _Mixin$create, _ClassMixinProps; + var _Mixin$create; var _templateObject = babelHelpers.taggedTemplateLiteralLoose(['.'], ['.']); @@ -35576,7 +35477,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met CoreObject.__super__ = null; - var ClassMixinProps = (_ClassMixinProps = { + var ClassMixinProps = { ClassMixin: _emberMetal.REQUIRED, @@ -35584,95 +35485,310 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met isClass: true, - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + isMethod: false, + /** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + var name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public + */ + extend: function () { + var Class = makeCtor(); + var proto; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - reopen.apply(Class.PrototypeMixin, arguments); + reopen.apply(Class.PrototypeMixin, arguments); - Class.superclass = this; - Class.__super__ = this.prototype; + Class.superclass = this; + Class.__super__ = this.prototype; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + Class.ClassMixin.apply(Class); + return Class; + }, - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + /** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public + */ + create: function () { + var C = this; - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, - for (var name in proto) { - property = proto[name]; + /** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public + */ + reopen: function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); + /** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public + */ + reopenClass: function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, + + detect: function (obj) { + if ('function' !== typeof obj) { + return false; } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, - var properties = _emberMetal.get(this, '_computedProperties'); + detectInstance: function (obj) { + return obj instanceof this; + }, - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + /** + In some cases, you may want to annotate computed properties with additional + metadata about how they function or what values they operate on. For + example, computed property functions may close over variables that are then + no longer available for introspection. + You can pass a hash of these values to a computed property like this: + ```javascript + person: Ember.computed(function() { + var personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private + */ + metaForProperty: function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); + return desc._meta || {}; + }, + + _computedProperties: _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property; + var properties = []; + + for (var name in proto) { + property = proto[name]; + + if (property && property.isDescriptor) { + properties.push({ + name: name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), + + /** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private + */ + eachComputedProperty: function (callback, binding) { + var property; + var empty = {}; + + var properties = _emberMetal.get(this, '_computedProperties'); + + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } } - }, _ClassMixinProps); + }; function injectedPropertyAssertion() { _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this)); @@ -35930,210 +36046,6 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met @return {String} string representation @public */ - -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); - } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); - } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); - } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); - } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ - -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); - } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ - -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); - } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ - -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); - } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); - } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ - -/** - In some cases, you may want to annotate computed properties with additional - metadata about how they function or what values they operate on. For - example, computed property functions may close over variables that are then - no longer available for introspection. - You can pass a hash of these values to a computed property like this: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ - -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) { 'use strict'; @@ -36386,7 +36298,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } findNamespaces(); - return this[_emberUtils.NAME_KEY]; + return this[_emberMetal.NAME_KEY]; }, nameClasses: function () { @@ -36446,10 +36358,10 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal paths[idx] = key; // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + if (obj && obj.toString === classToString && !obj[_emberMetal.NAME_KEY]) { // Replace the class' `toString` with the dot-separated path // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + obj[_emberMetal.NAME_KEY] = paths.join('.'); // Support nested namespaces } else if (obj && obj.isNamespace) { @@ -36495,7 +36407,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } var obj = tryIsNamespace(lookup, key); if (obj) { - obj[_emberUtils.NAME_KEY] = key; + obj[_emberMetal.NAME_KEY] = key; } } } @@ -36503,41 +36415,35 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal function superClassString(mixin) { var superclass = mixin.superclass; if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + if (superclass[_emberMetal.NAME_KEY]) { + return superclass[_emberMetal.NAME_KEY]; } return superClassString(superclass); } } - function calculateToString(target) { - var str = undefined; - - if (!searchDisabled) { + function classToString() { + if (!searchDisabled && !this[_emberMetal.NAME_KEY]) { processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; + } + + var ret = undefined; + + if (this[_emberMetal.NAME_KEY]) { + ret = this[_emberMetal.NAME_KEY]; + } else if (this._toString) { + ret = this._toString; + } else { + var str = superClassString(this); if (str) { - return str; + ret = '(subclass of ' + str + ')'; } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + ret = '(unknown mixin)'; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; + this.toString = makeToString(ret); } - return this[_emberUtils.NAME_KEY] = calculateToString(this); + return ret; } function processAllNamespaces() { @@ -36562,6 +36468,12 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } } + function makeToString(ret) { + return function () { + return ret; + }; + } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. exports.default = Namespace; @@ -38356,9 +38268,7 @@ enifed('ember-testing/initializers', ['exports', 'ember-runtime'], function (exp } }); }); -enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersAdapter, _emberTestingAdaptersQunit) { - /* global self */ - +enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-views', 'ember-testing/test/adapter', 'ember-testing/test/pending_requests', 'ember-testing/adapters/qunit'], function (exports, _emberMetal, _emberViews, _emberTestingTestAdapter, _emberTestingTestPending_requests, _emberTestingAdaptersQunit) { 'use strict'; exports.default = setupForTesting; @@ -38382,7 +38292,7 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal', 'ember-view var adapter = _emberTestingTestAdapter.getAdapter(); // if adapter is not manually set default to QUnit if (!adapter) { - _emberTestingTestAdapter.setAdapter(typeof self.QUnit === 'undefined' ? new _emberTestingAdaptersAdapter.default() : new _emberTestingAdaptersQunit.default()); + _emberTestingTestAdapter.setAdapter(new _emberTestingAdaptersQunit.default()); } _emberViews.jQuery(document).off('ajaxSend', _emberTestingTestPending_requests.incrementPendingRequests); @@ -39324,7 +39234,7 @@ enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, } } }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsToString) { /* This package will be eagerly parsed and should have no dependencies on external packages. @@ -39360,7 +39270,6 @@ enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner exports.tryInvoke = _emberUtilsInvoke.tryInvoke; exports.makeArray = _emberUtilsMakeArray.default; exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; exports.toString = _emberUtilsToString.default; }); enifed('ember-utils/inspect', ['exports'], function (exports) { @@ -39593,11 +39502,6 @@ enifed("ember-utils/make-array", ["exports"], function (exports) { return Array.isArray(obj) ? obj : [obj]; } }); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { /** @module ember @@ -39760,8 +39664,8 @@ enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); } }); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; +enifed("ember-utils/to-string", ["exports"], function (exports) { + "use strict"; exports.default = toString; var objectToString = Object.prototype.toString; @@ -39772,7 +39676,7 @@ enifed('ember-utils/to-string', ['exports'], function (exports) { */ function toString(obj) { - if (obj && typeof obj.toString === 'function') { + if (obj && obj.toString) { return obj.toString(); } else { return objectToString.call(obj); @@ -39970,6 +39874,7 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me args[_key2 - 1] = arguments[_key2]; } + var target = undefined; var action = this.actions && this.actions[actionName]; if (action) { @@ -39979,10 +39884,13 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me } } - var target = _emberMetal.get(this, 'target'); + target = _emberMetal.get(this, 'target'); + if (target) { + var _target; + _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function'); - target.send.apply(target, arguments); + (_target = target).send.apply(_target, arguments); } else { _emberMetal.assert(_emberUtils.inspect(this) + ' had no action handler for: ' + actionName, action); } @@ -40051,7 +39959,10 @@ enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], fun this._super.apply(this, arguments); _emberMetal.assert('Only arrays are allowed for \'classNameBindings\'', Array.isArray(this.classNameBindings)); + this.classNameBindings = this.classNameBindings.slice(); + _emberMetal.assert('Only arrays of static class strings are allowed for \'classNames\'. For dynamic classes, use \'classNameBindings\'.', Array.isArray(this.classNames)); + this.classNames = this.classNames.slice(); }, /** @@ -40530,12 +40441,6 @@ enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-meta }, _Mixin$create.renderToElement = function (tagName) { tagName = tagName || 'body'; - _emberMetal.deprecate('Using the `renderToElement` is deprecated in favor of `appendTo`. Called in ' + this.toString(), false, { - id: 'ember-views.render-to-element', - until: '2.12.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_code-rendertoelement-code' - }); - var element = this.renderer.createElement(tagName); this.renderer.appendTo(this, element); @@ -40687,7 +40592,6 @@ enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-meta @method renderToElement @param {String} tagName The tag of the element to create and render into. Defaults to "body". @return {HTMLBodyElement} element - @deprecated Use appendTo instead. @private */ @@ -42235,7 +42139,7 @@ enifed("ember-views/views/view", ["exports"], function (exports) { enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true }; + exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": true, "ember-testing-resume-test": false, "ember-glimmer-detect-backtracking-rerender": true, "mandatory-setter": true }; }); enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { 'use strict'; @@ -42341,7 +42245,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', _emberMetal.default.getProperties = _emberMetal.getProperties; _emberMetal.default.setProperties = _emberMetal.setProperties; _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.NAME_KEY = _emberMetal.NAME_KEY; _emberMetal.default.addObserver = _emberMetal.addObserver; _emberMetal.default.observersFor = _emberMetal.observersFor; _emberMetal.default.removeObserver = _emberMetal.removeObserver; @@ -42770,7 +42674,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.10.0-intercom"; }); enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; @@ -50433,7 +50337,10 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true + autocorrect: true, + // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true + // Safari 9.1.3: 'list' in document.createElement('input') === false + list: true }, // element.form is actually a legitimate readOnly property, that is to be // mutated, but must be mutated by setAttribute... @@ -50450,7 +50357,7 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { return tag && tag[propName.toLowerCase()] || false; } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7U0FDbEI7OztBQUlELGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixnQkFBUSxFQUFFLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixhQUFLLEVBQUssRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtLQUN6QixDQUFDO0FBRUYsYUFBQSxVQUFBLENBQW9CLE9BQU8sRUFBRSxRQUFRLEVBQUE7QUFDbkMsWUFBSSxHQUFHLEdBQUcsY0FBYyxDQUFDLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDO0FBQ2hELGVBQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxRQUFRLENBQUMsV0FBVyxFQUFFLENBQUMsSUFBSSxLQUFLLENBQUM7S0FDcEQiLCJmaWxlIjoicHJvcHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQG1ldGhvZCBub3JtYWxpemVQcm9wZXJ0eVxuICogQHBhcmFtIGVsZW1lbnQge0hUTUxFbGVtZW50fVxuICogQHBhcmFtIHNsb3ROYW1lIHtTdHJpbmd9XG4gKiBAcmV0dXJucyB7T2JqZWN0fSB7IG5hbWUsIHR5cGUgfVxuICovXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHkoZWxlbWVudCwgc2xvdE5hbWUpIHtcbiAgbGV0IHR5cGUsIG5vcm1hbGl6ZWQ7XG5cbiAgaWYgKHNsb3ROYW1lIGluIGVsZW1lbnQpIHtcbiAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgdHlwZSA9ICdwcm9wJztcbiAgfSBlbHNlIHtcbiAgICBsZXQgbG93ZXIgPSBzbG90TmFtZS50b0xvd2VyQ2FzZSgpO1xuICAgIGlmIChsb3dlciBpbiBlbGVtZW50KSB7XG4gICAgICB0eXBlID0gJ3Byb3AnO1xuICAgICAgbm9ybWFsaXplZCA9IGxvd2VyO1xuICAgIH0gZWxzZSB7XG4gICAgICB0eXBlID0gJ2F0dHInO1xuICAgICAgbm9ybWFsaXplZCA9IHNsb3ROYW1lO1xuICAgIH1cbiAgfVxuXG4gIGlmICh0eXBlID09PSAncHJvcCcgJiZcbiAgICAgIChub3JtYWxpemVkLnRvTG93ZXJDYXNlKCkgPT09ICdzdHlsZScgfHxcbiAgICAgICBwcmVmZXJBdHRyKGVsZW1lbnQudGFnTmFtZSwgbm9ybWFsaXplZCkpKSB7XG4gICAgdHlwZSA9ICdhdHRyJztcbiAgfVxuXG4gIHJldHVybiB7IG5vcm1hbGl6ZWQsIHR5cGUgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIG5vcm1hbGl6ZVByb3BlcnR5VmFsdWUodmFsdWUpIHtcbiAgaWYgKHZhbHVlID09PSAnJykge1xuICAgIHJldHVybiB0cnVlO1xuICB9XG5cbiAgcmV0dXJuIHZhbHVlO1xufVxuXG4vLyBwcm9wZXJ0aWVzIHRoYXQgTVVTVCBiZSBzZXQgYXMgYXR0cmlidXRlcywgZHVlIHRvOlxuLy8gKiBicm93c2VyIGJ1Z1xuLy8gKiBzdHJhbmdlIHNwZWMgb3V0bGllclxuY29uc3QgQVRUUl9PVkVSUklERVMgPSB7XG5cbiAgLy8gcGhhbnRvbWpzIDwgMi4wIGxldHMgeW91IHNldCBpdCBhcyBhIHByb3AgYnV0IHdvbid0IHJlZmxlY3QgaXRcbiAgLy8gYmFjayB0byB0aGUgYXR0cmlidXRlLiBidXR0b24uZ2V0QXR0cmlidXRlKCd0eXBlJykgPT09IG51bGxcbiAgQlVUVE9OOiB7IHR5cGU6IHRydWUsIGZvcm06IHRydWUgfSxcblxuICBJTlBVVDoge1xuICAgIC8vIFNvbWUgdmVyc2lvbiBvZiBJRSAobGlrZSBJRTkpIGFjdHVhbGx5IHRocm93IGFuIGV4Y2VwdGlvblxuICAgIC8vIGlmIHlvdSBzZXQgaW5wdXQudHlwZSA9ICdzb21ldGhpbmctdW5rbm93bidcbiAgICB0eXBlOiB0cnVlLFxuICAgIGZvcm06IHRydWUsXG4gICAgLy8gQ2hyb21lIDQ2LjAuMjQ2NC4wOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gU2FmYXJpIDguMC43OiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gTW9iaWxlIFNhZmFyaSAoaU9TIDguNCBzaW11bGF0b3IpOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IHRydWVcbiAgICBhdXRvY29ycmVjdDogdHJ1ZVxuICB9LFxuXG4gIC8vIGVsZW1lbnQuZm9ybSBpcyBhY3R1YWxseSBhIGxlZ2l0aW1hdGUgcmVhZE9ubHkgcHJvcGVydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7OztBQUdqQixnQkFBSSxFQUFFLElBQUk7U0FDWDs7O0FBSUQsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGFBQUssRUFBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsZ0JBQVEsRUFBRSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0tBQ3pCLENBQUM7QUFFRixhQUFBLFVBQUEsQ0FBb0IsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNuQyxZQUFJLEdBQUcsR0FBRyxjQUFjLENBQUMsT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7QUFDaEQsZUFBTyxHQUFHLElBQUksR0FBRyxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxJQUFJLEtBQUssQ0FBQztLQUNwRCIsImZpbGUiOiJwcm9wcy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAbWV0aG9kIG5vcm1hbGl6ZVByb3BlcnR5XG4gKiBAcGFyYW0gZWxlbWVudCB7SFRNTEVsZW1lbnR9XG4gKiBAcGFyYW0gc2xvdE5hbWUge1N0cmluZ31cbiAqIEByZXR1cm5zIHtPYmplY3R9IHsgbmFtZSwgdHlwZSB9XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBub3JtYWxpemVQcm9wZXJ0eShlbGVtZW50LCBzbG90TmFtZSkge1xuICBsZXQgdHlwZSwgbm9ybWFsaXplZDtcblxuICBpZiAoc2xvdE5hbWUgaW4gZWxlbWVudCkge1xuICAgIG5vcm1hbGl6ZWQgPSBzbG90TmFtZTtcbiAgICB0eXBlID0gJ3Byb3AnO1xuICB9IGVsc2Uge1xuICAgIGxldCBsb3dlciA9IHNsb3ROYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgaWYgKGxvd2VyIGluIGVsZW1lbnQpIHtcbiAgICAgIHR5cGUgPSAncHJvcCc7XG4gICAgICBub3JtYWxpemVkID0gbG93ZXI7XG4gICAgfSBlbHNlIHtcbiAgICAgIHR5cGUgPSAnYXR0cic7XG4gICAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgfVxuICB9XG5cbiAgaWYgKHR5cGUgPT09ICdwcm9wJyAmJlxuICAgICAgKG5vcm1hbGl6ZWQudG9Mb3dlckNhc2UoKSA9PT0gJ3N0eWxlJyB8fFxuICAgICAgIHByZWZlckF0dHIoZWxlbWVudC50YWdOYW1lLCBub3JtYWxpemVkKSkpIHtcbiAgICB0eXBlID0gJ2F0dHInO1xuICB9XG5cbiAgcmV0dXJuIHsgbm9ybWFsaXplZCwgdHlwZSB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHlWYWx1ZSh2YWx1ZSkge1xuICBpZiAodmFsdWUgPT09ICcnKSB7XG4gICAgcmV0dXJuIHRydWU7XG4gIH1cblxuICByZXR1cm4gdmFsdWU7XG59XG5cbi8vIHByb3BlcnRpZXMgdGhhdCBNVVNUIGJlIHNldCBhcyBhdHRyaWJ1dGVzLCBkdWUgdG86XG4vLyAqIGJyb3dzZXIgYnVnXG4vLyAqIHN0cmFuZ2Ugc3BlYyBvdXRsaWVyXG5jb25zdCBBVFRSX09WRVJSSURFUyA9IHtcblxuICAvLyBwaGFudG9tanMgPCAyLjAgbGV0cyB5b3Ugc2V0IGl0IGFzIGEgcHJvcCBidXQgd29uJ3QgcmVmbGVjdCBpdFxuICAvLyBiYWNrIHRvIHRoZSBhdHRyaWJ1dGUuIGJ1dHRvbi5nZXRBdHRyaWJ1dGUoJ3R5cGUnKSA9PT0gbnVsbFxuICBCVVRUT046IHsgdHlwZTogdHJ1ZSwgZm9ybTogdHJ1ZSB9LFxuXG4gIElOUFVUOiB7XG4gICAgLy8gU29tZSB2ZXJzaW9uIG9mIElFIChsaWtlIElFOSkgYWN0dWFsbHkgdGhyb3cgYW4gZXhjZXB0aW9uXG4gICAgLy8gaWYgeW91IHNldCBpbnB1dC50eXBlID0gJ3NvbWV0aGluZy11bmtub3duJ1xuICAgIHR5cGU6IHRydWUsXG4gICAgZm9ybTogdHJ1ZSxcbiAgICAvLyBDaHJvbWUgNDYuMC4yNDY0LjA6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBTYWZhcmkgOC4wLjc6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBNb2JpbGUgU2FmYXJpIChpT1MgOC40IHNpbXVsYXRvcik6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gdHJ1ZVxuICAgIGF1dG9jb3JyZWN0OiB0cnVlLFxuICAgIC8vIENocm9tZSA1NC4wLjI4NDAuOTg6ICdsaXN0JyBpbiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdpbnB1dCcpID09PSB0cnVlXG4gICAgLy8gU2FmYXJpIDkuMS4zOiAnbGlzdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICBsaXN0OiB0cnVlXG4gIH0sXG5cbiAgLy8gZWxlbWVudC5mb3JtIGlzIGFjdHVhbGx5IGEgbGVnaXRpbWF0ZSByZWFkT25seSBwcm9wZXJ0eSwgdGhhdCBpcyB0byBiZVxuICAvLyBtdXRhdGVkLCBidXQgbXVzdCBiZSBtdXRhdGVkIGJ5IHNldEF0dHJpYnV0ZS4uLlxuICBTRUxFQ1Q6ICAgeyBmb3JtOiB0cnVlIH0sXG4gIE9QVElPTjogICB7IGZvcm06IHRydWUgfSxcbiAgVEVYVEFSRUE6IHsgZm9ybTogdHJ1ZSB9LFxuICBMQUJFTDogICAgeyBmb3JtOiB0cnVlIH0sXG4gIEZJRUxEU0VUOiB7IGZvcm06IHRydWUgfSxcbiAgTEVHRU5EOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPQkpFQ1Q6ICAgeyBmb3JtOiB0cnVlIH1cbn07XG5cbmZ1bmN0aW9uIHByZWZlckF0dHIodGFnTmFtZSwgcHJvcE5hbWUpIHtcbiAgbGV0IHRhZyA9IEFUVFJfT1ZFUlJJREVTW3RhZ05hbWUudG9VcHBlckNhc2UoKV07XG4gIHJldHVybiB0YWcgJiYgdGFnW3Byb3BOYW1lLnRvTG93ZXJDYXNlKCldIHx8IGZhbHNlO1xufVxuIl19 enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { 'use strict'; @@ -55910,30 +55817,6 @@ TransitionState.prototype = { } }; -function TransitionAbortedError(message) { - if (!(this instanceof TransitionAbortedError)) { - return new TransitionAbortedError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, TransitionAbortedError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'TransitionAborted'; - this.name = 'TransitionAborted'; - this.number = error.number; - this.code = error.code; -} - -TransitionAbortedError.prototype = oCreate(Error.prototype); - /** A Transition is a thennable (a promise-like object) that represents an attempt to transition to another route. It can be aborted, either @@ -56258,11 +56141,16 @@ Transition.prototype.send = Transition.prototype.trigger; /** @private - Logs and returns an instance of TransitionAbortedError. + Logs and returns a TransitionAborted error. */ function logAbort(transition) { log(transition.router, transition.sequence, "detected abort."); - return new TransitionAbortedError(); + return new TransitionAborted(); +} + +function TransitionAborted(message) { + this.message = (message || "TransitionAborted"); + this.name = "TransitionAborted"; } function TransitionIntent(props) { @@ -56822,26 +56710,14 @@ var NamedTransitionIntent = subclass(TransitionIntent, { } }); +/** + Promise reject reasons passed to promise rejection + handlers for failed transitions. + */ function UnrecognizedURLError(message) { - if (!(this instanceof UnrecognizedURLError)) { - return new UnrecognizedURLError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, UnrecognizedURLError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'UnrecognizedURL'; - this.name = 'UnrecognizedURLError'; - this.number = error.number; - this.code = error.code; + this.message = (message || "UnrecognizedURLError"); + this.name = "UnrecognizedURLError"; + Error.call(this); } UnrecognizedURLError.prototype = oCreate(Error.prototype); @@ -57398,7 +57274,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi } if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } handler.context = context; @@ -57406,7 +57282,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi callHook(handler, 'setup', context, transition); if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } currentHandlerInfos.push(handlerInfo); @@ -57598,7 +57474,7 @@ function finalizeTransition(transition, newState) { // Resolve with the final handler. return handlerInfos[handlerInfos.length - 1].handler; } catch(e) { - if (!(e instanceof TransitionAbortedError)) { + if (!(e instanceof TransitionAborted)) { //var erroneousHandler = handlerInfos.pop(); var infos = transition.state.handlerInfos; transition.trigger(true, 'error', e, transition, infos[infos.length-1].handler); @@ -57755,2533 +57631,2506 @@ exports.Transition = Transition; Object.defineProperty(exports, '__esModule', { value: true }); }); -enifed('rsvp', ['exports'], function (exports) { - 'use strict'; - - var _rsvp; +/*! + * @overview RSVP - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE + * @version 3.2.1 + */ - function indexOf(callbacks, callback) { - for (var i = 0, l = callbacks.length; i < l; i++) { - if (callbacks[i] === callback) { - return i; - } - } +enifed('rsvp', ['exports'], function (exports) { 'use strict'; - return -1; +function indexOf(callbacks, callback) { + for (var i=0, l=callbacks.length; i 1) { - throw new Error('Second argument not supported'); - } - if (typeof o !== 'object') { - throw new TypeError('Argument must be an object'); - } - F.prototype = o; - return new F(); - }; + object.trigger('stuff'); // callback1 and callback2 will be executed. - var queue = []; + object.off('stuff'); + object.trigger('stuff'); // callback1 and callback2 will not be executed! + ``` - function scheduleFlush() { - setTimeout(function () { - for (var i = 0; i < queue.length; i++) { - var entry = queue[i]; + @method off + @for RSVP.EventTarget + @private + @param {String} eventName event to stop listening to + @param {Function} callback optional argument. If given, only the function + given will be removed from the event's callback queue. If no `callback` + argument is given, all callbacks will be removed from the event's callback + queue. + */ + 'off': function(eventName, callback) { + var allCallbacks = callbacksFor(this), callbacks, index; - var payload = entry.payload; + if (!callback) { + allCallbacks[eventName] = []; + return; + } - payload.guid = payload.key + payload.id; - payload.childGuid = payload.key + payload.childId; - if (payload.error) { - payload.stack = payload.error.stack; - } + callbacks = allCallbacks[eventName]; - config['trigger'](entry.name, entry.payload); - } - queue.length = 0; - }, 50); - } + index = indexOf(callbacks, callback); - function instrument(eventName, promise, child) { - if (1 === queue.push({ - name: eventName, - payload: { - key: promise._guidKey, - id: promise._id, - eventName: eventName, - detail: promise._result, - childId: child && child._id, - label: promise._label, - timeStamp: now(), - error: config["instrument-with-stack"] ? new Error(promise._label) : null - } })) { - scheduleFlush(); - } - } + if (index !== -1) { callbacks.splice(index, 1); } + }, /** - `RSVP.Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - + Use `trigger` to fire custom events. For example: + ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(){ + console.log('foo event happened!'); }); + object.trigger('foo'); + // 'foo event happened!' logged to the console ``` - - Instead of writing the above, your code now simply becomes the following: - + + You can also pass a value as a second argument to `trigger` that will be + passed as an argument to all event listeners for the event: + ```javascript - let promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(value){ + console.log(value.name); }); + + object.trigger('foo', { name: 'bar' }); + // 'bar' logged to the console ``` - - @method resolve - @static - @param {*} object value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` + + @method trigger + @for RSVP.EventTarget + @private + @param {String} eventName name of the event to be triggered + @param {*} options optional value to be passed to any event handlers for + the given `eventName` */ - function resolve$1(object, label) { - /*jshint validthis:true */ - var Constructor = this; + 'trigger': function(eventName, options, label) { + var allCallbacks = callbacksFor(this), callbacks, callback; - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; + if (callbacks = allCallbacks[eventName]) { + // Don't cache the callbacks.length since it may grow + for (var i=0; i 1) { + throw new Error('Second argument not supported'); } - - function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - thenable._onError = null; - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - if (thenable !== value) { - resolve(promise, value, undefined); - } else { - fulfill(promise, value); - } - }, function (reason) { - return reject(promise, reason); - }); - } + if (typeof o !== 'object') { + throw new TypeError('Argument must be an object'); } + F.prototype = o; + return new F(); +}); - function handleMaybeThenable(promise, maybeThenable, then$$) { - if (maybeThenable.constructor === promise.constructor && then$$ === then && promise.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$ === GET_THEN_ERROR) { - reject(promise, GET_THEN_ERROR.error); - } else if (then$$ === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$)) { - handleForeignThenable(promise, maybeThenable, then$$); - } else { - fulfill(promise, maybeThenable); +var queue = []; + +function scheduleFlush() { + setTimeout(function() { + var entry; + for (var i = 0; i < queue.length; i++) { + entry = queue[i]; + + var payload = entry.payload; + + payload.guid = payload.key + payload.id; + payload.childGuid = payload.key + payload.childId; + if (payload.error) { + payload.stack = payload.error.stack; } + + config['trigger'](entry.name, entry.payload); } - } + queue.length = 0; + }, 50); +} - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (objectOrFunction(value)) { - handleMaybeThenable(promise, value, getThen(value)); - } else { - fulfill(promise, value); +function instrument(eventName, promise, child) { + if (1 === queue.push({ + name: eventName, + payload: { + key: promise._guidKey, + id: promise._id, + eventName: eventName, + detail: promise._result, + childId: child && child._id, + label: promise._label, + timeStamp: now(), + error: config["instrument-with-stack"] ? new Error(promise._label) : null + }})) { + scheduleFlush(); } } - function publishRejection(promise) { - if (promise._onError) { - promise._onError(promise._result); - } +/** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` - publish(promise); + @method resolve + @static + @param {*} object value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object, label) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; } - function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } + var promise = new Constructor(noop, label); + resolve(promise, object); + return promise; +} + +function withOwnPromise() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function getThen(promise) { + try { + return promise.then; + } catch(error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} - promise._result = value; - promise._state = FULFILLED; +function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch(e) { + return e; + } +} - if (promise._subscribers.length === 0) { - if (config.instrument) { - instrument('fulfilled', promise); +function handleForeignThenable(promise, thenable, then) { + config.async(function(promise) { + var sealed = false; + var error = tryThen(then, thenable, function(value) { + if (sealed) { return; } + sealed = true; + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); } - } else { - config.async(publish, promise); + }, function(reason) { + if (sealed) { return; } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + thenable._onError = null; + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function(value) { + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); + } + }, function(reason) { + reject(promise, reason); + }); } +} - function reject(promise, reason) { - if (promise._state !== PENDING) { - return; +function handleMaybeThenable(promise, maybeThenable, then$$) { + if (maybeThenable.constructor === promise.constructor && + then$$ === then && + constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$ === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + } else if (then$$ === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$)) { + handleForeignThenable(promise, maybeThenable, then$$); + } else { + fulfill(promise, maybeThenable); } - promise._state = REJECTED; - promise._result = reason; - config.async(publishRejection, promise); } +} - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; +function resolve(promise, value) { + if (promise === value) { + fulfill(promise, value); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} - parent._onError = null; +function publishRejection(promise) { + if (promise._onError) { + promise._onError(promise._result); + } - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; + publish(promise); +} - if (length === 0 && parent._state) { - config.async(publish, parent); - } - } +function fulfill(promise, value) { + if (promise._state !== PENDING) { return; } - function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; + promise._result = value; + promise._state = FULFILLED; + if (promise._subscribers.length === 0) { if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); + instrument('fulfilled', promise); } + } else { + config.async(publish, promise); + } +} - if (subscribers.length === 0) { - return; - } +function reject(promise, reason) { + if (promise._state !== PENDING) { return; } + promise._state = REJECTED; + promise._result = reason; + config.async(publishRejection, promise); +} - var child = undefined, - callback = undefined, - detail = promise._result; +function subscribe(parent, child, onFulfillment, onRejection) { + var subscribers = parent._subscribers; + var length = subscribers.length; - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; + parent._onError = null; - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } + subscribers[length] = child; + subscribers[length + FULFILLED] = onFulfillment; + subscribers[length + REJECTED] = onRejection; - promise._subscribers.length = 0; + if (length === 0 && parent._state) { + config.async(publish, parent); } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; - function ErrorObject() { - this.error = null; + if (config.instrument) { + instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); } - var TRY_CATCH_ERROR = new ErrorObject(); + if (subscribers.length === 0) { return; } - function tryCatch(callback, detail) { - try { - return callback(detail); - } catch (e) { - TRY_CATCH_ERROR.error = e; - return TRY_CATCH_ERROR; + var child, callback, detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); } } - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; + promise._subscribers.length = 0; +} - if (hasCallback) { - value = tryCatch(callback, detail); +function ErrorObject() { + this.error = null; +} - if (value === TRY_CATCH_ERROR) { - failed = true; - error = value.error; - value = null; - } else { - succeeded = true; - } +var TRY_CATCH_ERROR = new ErrorObject(); - if (promise === value) { - reject(promise, withOwnPromise()); - return; - } +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch(e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value, error, succeeded, failed; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value = null; } else { - value = detail; succeeded = true; } - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function initializePromise(promise, resolver) { - var resolved = false; - try { - resolver(function (value) { - if (resolved) { - return; - } - resolved = true; - resolve(promise, value); - }, function (reason) { - if (resolved) { - return; - } - resolved = true; - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); + if (promise === value) { + reject(promise, withOwnPromise()); + return; } + + } else { + value = detail; + succeeded = true; } - function then(onFulfillment, onRejection, label) { - var _arguments = arguments; + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} - var parent = this; - var state = parent._state; +function initializePromise(promise, resolver) { + var resolved = false; + try { + resolver(function resolvePromise(value){ + if (resolved) { return; } + resolved = true; + resolve(promise, value); + }, function rejectPromise(reason) { + if (resolved) { return; } + resolved = true; + reject(promise, reason); + }); + } catch(e) { + reject(promise, e); + } +} - if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { - config.instrument && instrument('chained', parent, parent); - return parent; - } +function then(onFulfillment, onRejection, label) { + var parent = this; + var state = parent._state; - parent._onError = null; + if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { + config.instrument && instrument('chained', parent, parent); + return parent; + } - var child = new parent.constructor(noop, label); - var result = parent._result; + parent._onError = null; - config.instrument && instrument('chained', parent, child); + var child = new parent.constructor(noop, label); + var result = parent._result; - if (state) { - (function () { - var callback = _arguments[state - 1]; - config.async(function () { - return invokeCallback(state, child, callback, result); - }); - })(); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } + config.instrument && instrument('chained', parent, child); - return child; + if (state) { + var callback = arguments[state - 1]; + config.async(function(){ + invokeCallback(state, child, callback, result); + }); + } else { + subscribe(parent, child, onFulfillment, onRejection); } - function makeSettledResult(state, position, value) { - if (state === FULFILLED) { - return { - state: 'fulfilled', - value: value - }; - } else { - return { - state: 'rejected', - reason: value - }; - } + return child; +} + +function makeSettledResult(state, position, value) { + if (state === FULFILLED) { + return { + state: 'fulfilled', + value: value + }; + } else { + return { + state: 'rejected', + reason: value + }; } +} - function Enumerator(Constructor, input, abortOnReject, label) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop, label); - this._abortOnReject = abortOnReject; +function Enumerator(Constructor, input, abortOnReject, label) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop, label); + this._abortOnReject = abortOnReject; - if (this._validateInput(input)) { - this._input = input; - this.length = input.length; - this._remaining = input.length; + if (this._validateInput(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; - this._init(); + this._init(); - if (this.length === 0) { + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } } - } else { - reject(this.promise, this._validationError()); } + } else { + reject(this.promise, this._validationError()); } +} - Enumerator.prototype._validateInput = function (input) { - return isArray(input); - }; +Enumerator.prototype._validateInput = function(input) { + return isArray(input); +}; - Enumerator.prototype._validationError = function () { - return new Error('Array Methods must be provided an Array'); - }; +Enumerator.prototype._validationError = function() { + return new Error('Array Methods must be provided an Array'); +}; - Enumerator.prototype._init = function () { - this._result = new Array(this.length); - }; +Enumerator.prototype._init = function() { + this._result = new Array(this.length); +}; - Enumerator.prototype._enumerate = function () { - var length = this.length; - var promise = this.promise; - var input = this._input; +Enumerator.prototype._enumerate = function() { + var length = this.length; + var promise = this.promise; + var input = this._input; - for (var i = 0; promise._state === PENDING && i < length; i++) { - this._eachEntry(input[i], i); - } - }; + for (var i = 0; promise._state === PENDING && i < length; i++) { + this._eachEntry(input[i], i); + } +}; - Enumerator.prototype._settleMaybeThenable = function (entry, i) { - var c = this._instanceConstructor; - var resolve = c.resolve; - - if (resolve === resolve$1) { - var then$$ = getThen(entry); - - if (then$$ === then && entry._state !== PENDING) { - entry._onError = null; - this._settledAt(entry._state, i, entry._result); - } else if (typeof then$$ !== 'function') { - this._remaining--; - this._result[i] = this._makeResult(FULFILLED, i, entry); - } else if (c === Promise) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, then$$); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve) { - return resolve(entry); - }), i); - } - } else { - this._willSettleAt(resolve(entry), i); - } - }; +Enumerator.prototype._settleMaybeThenable = function(entry, i) { + var c = this._instanceConstructor; + var resolve = c.resolve; - Enumerator.prototype._eachEntry = function (entry, i) { - if (isMaybeThenable(entry)) { - this._settleMaybeThenable(entry, i); - } else { + if (resolve === resolve$1) { + var then$$ = getThen(entry); + + if (then$$ === then && + entry._state !== PENDING) { + entry._onError = null; + this._settledAt(entry._state, i, entry._result); + } else if (typeof then$$ !== 'function') { this._remaining--; this._result[i] = this._makeResult(FULFILLED, i, entry); + } else if (c === Promise) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, then$$); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); } - }; + } else { + this._willSettleAt(resolve(entry), i); + } +}; - Enumerator.prototype._settledAt = function (state, i, value) { - var promise = this.promise; +Enumerator.prototype._eachEntry = function(entry, i) { + if (isMaybeThenable(entry)) { + this._settleMaybeThenable(entry, i); + } else { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); + } +}; - if (promise._state === PENDING) { - this._remaining--; +Enumerator.prototype._settledAt = function(state, i, value) { + var promise = this.promise; - if (this._abortOnReject && state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = this._makeResult(state, i, value); - } - } + if (promise._state === PENDING) { + this._remaining--; - if (this._remaining === 0) { - fulfill(promise, this._result); + if (this._abortOnReject && state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = this._makeResult(state, i, value); } - }; + } - Enumerator.prototype._makeResult = function (state, i, value) { - return value; - }; + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; - Enumerator.prototype._willSettleAt = function (promise, i) { - var enumerator = this; +Enumerator.prototype._makeResult = function(state, i, value) { + return value; +}; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; +Enumerator.prototype._willSettleAt = function(promise, i) { + var enumerator = this; - /** - `RSVP.Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error("2")); - let promise3 = RSVP.reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static - */ - function all(entries, label) { - return new Enumerator(this, entries, true, /* abort on reject */label).promise; - } + subscribe(promise, undefined, function(value) { + enumerator._settledAt(FULFILLED, i, value); + }, function(reason) { + enumerator._settledAt(REJECTED, i, reason); + }); +}; - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} entries array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this; +/** + `RSVP.Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. - var promise = new Constructor(noop, label); + Example: - if (!isArray(entries)) { - reject(promise, new TypeError('You must pass an array to race.')); - return promise; - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; - for (var i = 0; promise._state === PENDING && i < entries.length; i++) { - subscribe(Constructor.resolve(entries[i]), undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } + RSVP.Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` - return promise; - } + If any of the `promises` given to `RSVP.all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$1(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop, label); - reject(promise, reason); + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error("2")); + var promise3 = RSVP.reject(new Error("3")); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all(entries, label) { + return new Enumerator(this, entries, true /* abort on reject */, label).promise; +} + +/** + `RSVP.Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `RSVP.Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} entries array of promises to observe + @param {String} label optional string for describing the promise returned. + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race(entries, label) { + /*jshint validthis:true */ + var Constructor = this; + + var promise = new Constructor(noop, label); + + if (!isArray(entries)) { + reject(promise, new TypeError('You must pass an array to race.')); return promise; } - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; + var length = entries.length; - function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); + function onFulfillment(value) { + resolve(promise, value); } - function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); + function onRejection(reason) { + reject(promise, reason); } - /** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } + for (var i = 0; promise._state === PENDING && i < length; i++) { + subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); + } + + return promise; +} + +/** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason, label) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop, label); + reject(promise, reason); + return promise; +} + +var guidKey = 'rsvp_' + now() + '-'; +var counter = 0; + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise’s eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + var promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + var xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection + } + }; }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class RSVP.Promise + @param {function} resolver + @param {String} label optional string for labeling the promise. + Useful for tooling. + @constructor +*/ +function Promise(resolver, label) { + this._id = counter++; + this._label = label; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + config.instrument && instrument('created', this); + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise.cast = resolve$1; // deprecated +Promise.all = all; +Promise.race = race; +Promise.resolve = resolve$1; +Promise.reject = reject$1; + +Promise.prototype = { + constructor: Promise, + + _guidKey: guidKey, + + _onError: function (reason) { + var promise = this; + config.after(function() { + if (promise._onError) { + config['trigger']('error', reason, promise._label); + } }); - ``` - - @class RSVP.Promise - @param {function} resolver - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - this._id = counter++; - this._label = label; - this._state = undefined; - this._result = undefined; - this._subscribers = []; + }, + +/** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` - config.instrument && instrument('created', this); + Assimilation + ------------ - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure } + ``` - Promise.cast = resolve$1; // deprecated - Promise.all = all; - Promise.race = race; - Promise.resolve = resolve$1; - Promise.reject = reject$1; + Errback Example - Promise.prototype = { - constructor: Promise, + ```js - _guidKey: guidKey, + function foundBooks(books) { - _onError: function (reason) { - var promise = this; - config.after(function () { - if (promise._onError) { - config['trigger']('error', reason, promise._label); - } - }); - }, + } - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we\'re unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we\'re unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { + findBoooksByAuthor(author, function(books, err) { + if (err) { failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } } - // success - } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfillment + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + then: then, + +/** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'catch': function(onRejection, label) { + return this.then(undefined, onRejection, label); + }, + +/** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves + + Synchronous example: + + ```js + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); + } + + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value + } + ``` + + Asynchronous example: + + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not + }); + ``` + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'finally': function(callback, label) { + var promise = this; + var constructor = promise.constructor; + + return promise.then(function(value) { + return constructor.resolve(callback()).then(function() { + return value; }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong + }, function(reason) { + return constructor.resolve(callback()).then(function() { + return constructor.reject(reason); }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: then, + }, label); + } +}; - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn\'t find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - catch: function (onRejection, label) { - return this.then(undefined, onRejection, label); - }, +function Result() { + this.value = undefined; +} - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); +var ERROR = new Result(); +var GET_THEN_ERROR$1 = new Result(); + +function getThen$1(obj) { + try { + return obj.then; + } catch(error) { + ERROR.value= error; + return ERROR; + } +} + + +function tryApply(f, s, a) { + try { + f.apply(s, a); + } catch(error) { + ERROR.value = error; + return ERROR; + } +} + +function makeObject(_, argumentNames) { + var obj = {}; + var name; + var i; + var length = _.length; + var args = new Array(length); + + for (var x = 0; x < length; x++) { + args[x] = _[x]; + } + + for (i = 0; i < argumentNames.length; i++) { + name = argumentNames[i]; + obj[name] = args[i + 1]; + } + + return obj; +} + +function arrayResult(_) { + var length = _.length; + var args = new Array(length - 1); + + for (var i = 1; i < length; i++) { + args[i - 1] = _[i]; + } + + return args; +} + +function wrapThenable(then, promise) { + return { + then: function(onFulFillment, onRejection) { + return then.call(promise, onFulFillment, onRejection); + } + }; +} + +/** + `RSVP.denodeify` takes a 'node-style' function and returns a function that + will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + browser when you'd prefer to use promises over using callbacks. For example, + `denodeify` transforms the following: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) return handleError(err); + handleData(data); + }); + ``` + + into: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + + readFile('myfile.txt').then(handleData, handleError); + ``` + + If the node function has multiple success parameters, then `denodeify` + just returns the first one: + + ```javascript + var request = RSVP.denodeify(require('request')); + + request('http://example.com').then(function(res) { + // ... + }); + ``` + + However, if you need all success parameters, setting `denodeify`'s + second parameter to `true` causes it to return all success parameters + as an array: + + ```javascript + var request = RSVP.denodeify(require('request'), true); + + request('http://example.com').then(function(result) { + // result[0] -> res + // result[1] -> body + }); + ``` + + Or if you pass it an array with names it returns the parameters as a hash: + + ```javascript + var request = RSVP.denodeify(require('request'), ['res', 'body']); + + request('http://example.com').then(function(result) { + // result.res + // result.body + }); + ``` + + Sometimes you need to retain the `this`: + + ```javascript + var app = require('express')(); + var render = RSVP.denodeify(app.render.bind(app)); + ``` + + The denodified function inherits from the original function. It works in all + environments, except IE 10 and below. Consequently all properties of the original + function are available to you. However, any properties you change on the + denodeified function won't be changed on the original function. Example: + + ```javascript + var request = RSVP.denodeify(require('request')), + cookieJar = request.jar(); // <- Inheritance is used here + + request('http://example.com', {jar: cookieJar}).then(function(res) { + // cookieJar.cookies holds now the cookies returned by example.com + }); + ``` + + Using `denodeify` makes it easier to compose asynchronous operations instead + of using callbacks. For example, instead of: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) { ... } // Handle error + fs.writeFile('myfile2.txt', data, function(err){ + if (err) { ... } // Handle error + console.log('done') + }); + }); + ``` + + you can chain the operations together using `then` from the returned promise: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + var writeFile = RSVP.denodeify(fs.writeFile); + + readFile('myfile.txt').then(function(data){ + return writeFile('myfile2.txt', data); + }).then(function(){ + console.log('done') + }).catch(function(error){ + // Handle error + }); + ``` + + @method denodeify + @static + @for RSVP + @param {Function} nodeFunc a 'node-style' function that takes a callback as + its last argument. The callback expects an error to be passed as its first + argument (if an error occurred, otherwise null), and the value from the + operation as its second argument ('function(err, value){ }'). + @param {Boolean|Array} [options] An optional paramter that if set + to `true` causes the promise to fulfill with the callback's success arguments + as an array. This is useful if the node function has multiple success + paramters. If you set this paramter to an array with names, the promise will + fulfill with a hash with these names as keys and the success parameters as + values. + @return {Function} a function that wraps `nodeFunc` to return an + `RSVP.Promise` + @static +*/ +function denodeify(nodeFunc, options) { + var fn = function() { + var self = this; + var l = arguments.length; + var args = new Array(l + 1); + var arg; + var promiseInput = false; + + for (var i = 0; i < l; ++i) { + arg = arguments[i]; + + if (!promiseInput) { + // TODO: clean this up + promiseInput = needsPromiseInput(arg); + if (promiseInput === GET_THEN_ERROR$1) { + var p = new Promise(noop); + reject(p, GET_THEN_ERROR$1.value); + return p; + } else if (promiseInput && promiseInput !== true) { + arg = wrapThenable(promiseInput, arg); } - return new Author(); } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value - } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not + args[i] = arg; + } + + var promise = new Promise(noop); + + args[l] = function(err, val) { + if (err) + reject(promise, err); + else if (options === undefined) + resolve(promise, val); + else if (options === true) + resolve(promise, arrayResult(arguments)); + else if (isArray(options)) + resolve(promise, makeObject(arguments, options)); + else + resolve(promise, val); + }; + + if (promiseInput) { + return handlePromiseInput(promise, args, nodeFunc, self); + } else { + return handleValueInput(promise, args, nodeFunc, self); + } + }; + + fn.__proto__ = nodeFunc; + + return fn; +} + +function handleValueInput(promise, args, nodeFunc, self) { + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; +} + +function handlePromiseInput(promise, args, nodeFunc, self){ + return Promise.all(args).then(function(args){ + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + }); +} + +function needsPromiseInput(arg) { + if (arg && typeof arg === 'object') { + if (arg.constructor === Promise) { + return true; + } else { + return getThen$1(arg); + } + } else { + return false; + } +} + +/** + This is a convenient alias for `RSVP.Promise.all`. + + @method all + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. +*/ +function all$1(array, label) { + return Promise.all(array, label); +} + +function AllSettled(Constructor, entries, label) { + this._superConstructor(Constructor, entries, false /* don't abort on reject */, label); +} + +AllSettled.prototype = o_create(Enumerator.prototype); +AllSettled.prototype._superConstructor = Enumerator; +AllSettled.prototype._makeResult = makeSettledResult; +AllSettled.prototype._validationError = function() { + return new Error('allSettled must be called with an array'); +}; + +/** + `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + a fail-fast method, it waits until all the promises have returned and + shows you all the results. This is useful if you want to handle multiple + promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled. The return promise is fulfilled with an array of the states of + the promises passed into the `promises` array argument. + + Each state object will either indicate fulfillment or rejection, and + provide the corresponding value or reason. The states will take one of + the following formats: + + ```javascript + { state: 'fulfilled', value: value } + or + { state: 'rejected', reason: reason } + ``` + + Example: + + ```javascript + var promise1 = RSVP.Promise.resolve(1); + var promise2 = RSVP.Promise.reject(new Error('2')); + var promise3 = RSVP.Promise.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.allSettled(promises).then(function(array){ + // array == [ + // { state: 'fulfilled', value: 1 }, + // { state: 'rejected', reason: Error }, + // { state: 'rejected', reason: Error } + // ] + // Note that for the second item, reason.message will be '2', and for the + // third item, reason.message will be '3'. + }, function(error) { + // Not run. (This block would only be called if allSettled had failed, + // for instance if passed an incorrect argument type.) + }); + ``` + + @method allSettled + @static + @for RSVP + @param {Array} entries + @param {String} label - optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with an array of the settled + states of the constituent promises. +*/ + +function allSettled(entries, label) { + return new AllSettled(Promise, entries, label).promise; +} + +/** + This is a convenient alias for `RSVP.Promise.race`. + + @method race + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ +function race$1(array, label) { + return Promise.race(array, label); +} + +function PromiseHash(Constructor, object, label) { + this._superConstructor(Constructor, object, true, label); +} + +PromiseHash.prototype = o_create(Enumerator.prototype); +PromiseHash.prototype._superConstructor = Enumerator; +PromiseHash.prototype._init = function() { + this._result = {}; +}; + +PromiseHash.prototype._validateInput = function(input) { + return input && typeof input === 'object'; +}; + +PromiseHash.prototype._validationError = function() { + return new Error('Promise.hash must be called with an object'); +}; + +PromiseHash.prototype._enumerate = function() { + var enumerator = this; + var promise = enumerator.promise; + var input = enumerator._input; + var results = []; + + for (var key in input) { + if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { + results.push({ + position: key, + entry: input[key] }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - finally: function (callback, label) { - var promise = this; - var constructor = promise.constructor; + } + } + + var length = results.length; + enumerator._remaining = length; + var result; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + result = results[i]; + enumerator._eachEntry(result.entry, result.position); + } +}; + +/** + `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array + for its `promises` argument. + + Returns a promise that is fulfilled when all the given promises have been + fulfilled, or rejected if any of them become rejected. The returned promise + is fulfilled with a hash that has the same key names as the `promises` object + argument. If any of the values in the object are not promises, they will + simply be copied over to the fulfilled object. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + yourPromise: RSVP.resolve(2), + theirPromise: RSVP.resolve(3), + notAPromise: 4 + }; + + RSVP.hash(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: 1, + // yourPromise: 2, + // theirPromise: 3, + // notAPromise: 4 + // } + }); + ```` + + If any of the `promises` given to `RSVP.hash` are rejected, the first promise + that is rejected will be given as the reason to the rejection handler. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + rejectedPromise: RSVP.reject(new Error('rejectedPromise')), + anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), + }; + + RSVP.hash(promises).then(function(hash){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === 'rejectedPromise' + }); + ``` + + An important note: `RSVP.hash` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hash` will NOT preserve prototype + chains. + + Example: + + ```javascript + function MyConstructor(){ + this.example = RSVP.resolve('Example'); + } + + MyConstructor.prototype = { + protoProperty: RSVP.resolve('Proto Property') + }; + + var myObject = new MyConstructor(); + + RSVP.hash(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: 'Example' + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` + + @method hash + @static + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all properties of `promises` + have been fulfilled, or rejected if any of them become rejected. +*/ +function hash(object, label) { + return new PromiseHash(Promise, object, label).promise; +} + +function HashSettled(Constructor, object, label) { + this._superConstructor(Constructor, object, false, label); +} + +HashSettled.prototype = o_create(PromiseHash.prototype); +HashSettled.prototype._superConstructor = Enumerator; +HashSettled.prototype._makeResult = makeSettledResult; + +HashSettled.prototype._validationError = function() { + return new Error('hashSettled must be called with an object'); +}; + +/** + `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + instead of an array for its `promises` argument. - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }, label); - } + Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + but like `RSVP.allSettled`, `hashSettled` waits until all the + constituent promises have returned and then shows you all the results + with their states and values/reasons. This is useful if you want to + handle multiple promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled, or rejected if the passed parameters are invalid. + + The returned promise is fulfilled with a hash that has the same key names as + the `promises` object argument. If any of the values in the object are not + promises, they will be copied over to the fulfilled object and marked with state + 'fulfilled'. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + yourPromise: RSVP.Promise.resolve(2), + theirPromise: RSVP.Promise.resolve(3), + notAPromise: 4 }; - function Result() { - this.value = undefined; - } + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // yourPromise: { state: 'fulfilled', value: 2 }, + // theirPromise: { state: 'fulfilled', value: 3 }, + // notAPromise: { state: 'fulfilled', value: 4 } + // } + }); + ``` - var ERROR = new Result(); - var GET_THEN_ERROR$1 = new Result(); + If any of the `promises` given to `RSVP.hash` are rejected, the state will + be set to 'rejected' and the reason for rejection provided. - function getThen$1(obj) { - try { - return obj.then; - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + Example: - function tryApply(f, s, a) { - try { - f.apply(s, a); - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + rejectedPromise: RSVP.Promise.reject(new Error('rejection')), + anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), + }; - function makeObject(_, argumentNames) { - var obj = {}; - var length = _.length; - var args = new Array(length); + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // rejectedPromise: { state: 'rejected', reason: Error }, + // anotherRejectedPromise: { state: 'rejected', reason: Error }, + // } + // Note that for rejectedPromise, reason.message == 'rejection', + // and for anotherRejectedPromise, reason.message == 'more rejection'. + }); + ``` - for (var x = 0; x < length; x++) { - args[x] = _[x]; - } + An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype + chains. - for (var i = 0; i < argumentNames.length; i++) { - var _name = argumentNames[i]; - obj[_name] = args[i + 1]; - } + Example: - return obj; + ```javascript + function MyConstructor(){ + this.example = RSVP.Promise.resolve('Example'); } - function arrayResult(_) { - var length = _.length; - var args = new Array(length - 1); + MyConstructor.prototype = { + protoProperty: RSVP.Promise.resolve('Proto Property') + }; - for (var i = 1; i < length; i++) { - args[i - 1] = _[i]; - } + var myObject = new MyConstructor(); - return args; - } + RSVP.hashSettled(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: { state: 'fulfilled', value: 'Example' } + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` - function wrapThenable(then, promise) { - return { - then: function (onFulFillment, onRejection) { - return then.call(promise, onFulFillment, onRejection); - } - }; + @method hashSettled + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when when all properties of `promises` + have been settled. + @static +*/ +function hashSettled(object, label) { + return new HashSettled(Promise, object, label).promise; +} + +/** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + + ```javascript + function throws(){ + throw new Error('Whoops!'); } - /** - `RSVP.denodeify` takes a 'node-style' function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - If the node function has multiple success parameters, then `denodeify` - just returns the first one: - - ```javascript - let request = RSVP.denodeify(require('request')); - - request('http://example.com').then(function(res) { - // ... - }); - ``` - - However, if you need all success parameters, setting `denodeify`'s - second parameter to `true` causes it to return all success parameters - as an array: - - ```javascript - let request = RSVP.denodeify(require('request'), true); - - request('http://example.com').then(function(result) { - // result[0] -> res - // result[1] -> body - }); - ``` - - Or if you pass it an array with names it returns the parameters as a hash: - - ```javascript - let request = RSVP.denodeify(require('request'), ['res', 'body']); - - request('http://example.com').then(function(result) { - // result.res - // result.body - }); - ``` - - Sometimes you need to retain the `this`: - - ```javascript - let app = require('express')(); - let render = RSVP.denodeify(app.render.bind(app)); - ``` - - The denodified function inherits from the original function. It works in all - environments, except IE 10 and below. Consequently all properties of the original - function are available to you. However, any properties you change on the - denodeified function won't be changed on the original function. Example: - - ```javascript - let request = RSVP.denodeify(require('request')), - cookieJar = request.jar(); // <- Inheritance is used here - - request('http://example.com', {jar: cookieJar}).then(function(res) { - // cookieJar.cookies holds now the cookies returned by example.com - }); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) { ... } // Handle error - fs.writeFile('myfile2.txt', data, function(err){ - if (err) { ... } // Handle error - console.log('done') - }); - }); - ``` - - you can chain the operations together using `then` from the returned promise: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - let writeFile = RSVP.denodeify(fs.writeFile); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - console.log('done') - }).catch(function(error){ - // Handle error - }); - ``` - - @method denodeify - @static - @for RSVP - @param {Function} nodeFunc a 'node-style' function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ('function(err, value){ }'). - @param {Boolean|Array} [options] An optional paramter that if set - to `true` causes the promise to fulfill with the callback's success arguments - as an array. This is useful if the node function has multiple success - paramters. If you set this paramter to an array with names, the promise will - fulfill with a hash with these names as keys and the success parameters as - values. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - @static - */ - function denodeify(nodeFunc, options) { - var fn = function () { - var self = this; - var l = arguments.length; - var args = new Array(l + 1); - var promiseInput = false; - - for (var i = 0; i < l; ++i) { - var arg = arguments[i]; - - if (!promiseInput) { - // TODO: clean this up - promiseInput = needsPromiseInput(arg); - if (promiseInput === GET_THEN_ERROR$1) { - var p = new Promise(noop); - reject(p, GET_THEN_ERROR$1.value); - return p; - } else if (promiseInput && promiseInput !== true) { - arg = wrapThenable(promiseInput, arg); - } - } - args[i] = arg; - } + var promise = new RSVP.Promise(function(resolve, reject){ + throws(); + }); - var promise = new Promise(noop); + promise.catch(RSVP.rethrow).then(function(){ + // Code here doesn't run because the promise became rejected due to an + // error! + }, function (err){ + // handle the error here + }); + ``` - args[l] = function (err, val) { - if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val); - }; + The 'Whoops' error will be thrown on the next turn of the event loop + and you can watch for it in your console. You can also handle it using a + rejection handler given to `.then` or `.catch` on the returned promise. - if (promiseInput) { - return handlePromiseInput(promise, args, nodeFunc, self); - } else { - return handleValueInput(promise, args, nodeFunc, self); - } - }; + @method rethrow + @static + @for RSVP + @param {Error} reason reason the promise became rejected. + @throws Error + @static +*/ +function rethrow(reason) { + setTimeout(function() { + throw reason; + }); + throw reason; +} - babelHelpers.defaults(fn, nodeFunc); +/** + `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. + `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s + interface. New code should use the `RSVP.Promise` constructor instead. - return fn; - } + The object returned from `RSVP.defer` is a plain object with three properties: - function handleValueInput(promise, args, nodeFunc, self) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - } + * promise - an `RSVP.Promise`. + * reject - a function that causes the `promise` property on this object to + become rejected + * resolve - a function that causes the `promise` property on this object to + become fulfilled. - function handlePromiseInput(promise, args, nodeFunc, self) { - return Promise.all(args).then(function (args) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - }); - } + Example: - function needsPromiseInput(arg) { - if (arg && typeof arg === 'object') { - if (arg.constructor === Promise) { - return true; - } else { - return getThen$1(arg); - } - } else { - return false; - } - } + ```javascript + var deferred = RSVP.defer(); - /** - This is a convenient alias for `RSVP.Promise.all`. - - @method all - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function all$1(array, label) { - return Promise.all(array, label); - } + deferred.resolve("Success!"); - function AllSettled(Constructor, entries, label) { - this._superConstructor(Constructor, entries, false, /* don't abort on reject */label); - } + deferred.promise.then(function(value){ + // value here is "Success!" + }); + ``` - AllSettled.prototype = o_create(Enumerator.prototype); - AllSettled.prototype._superConstructor = Enumerator; - AllSettled.prototype._makeResult = makeSettledResult; - AllSettled.prototype._validationError = function () { - return new Error('allSettled must be called with an array'); - }; + @method defer + @static + @for RSVP + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Object} + */ - /** - `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing - a fail-fast method, it waits until all the promises have returned and - shows you all the results. This is useful if you want to handle multiple - promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled. The return promise is fulfilled with an array of the states of - the promises passed into the `promises` array argument. - - Each state object will either indicate fulfillment or rejection, and - provide the corresponding value or reason. The states will take one of - the following formats: - - ```javascript - { state: 'fulfilled', value: value } - or - { state: 'rejected', reason: reason } - ``` - - Example: - - ```javascript - let promise1 = RSVP.Promise.resolve(1); - let promise2 = RSVP.Promise.reject(new Error('2')); - let promise3 = RSVP.Promise.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.allSettled(promises).then(function(array){ - // array == [ - // { state: 'fulfilled', value: 1 }, - // { state: 'rejected', reason: Error }, - // { state: 'rejected', reason: Error } - // ] - // Note that for the second item, reason.message will be '2', and for the - // third item, reason.message will be '3'. - }, function(error) { - // Not run. (This block would only be called if allSettled had failed, - // for instance if passed an incorrect argument type.) - }); - ``` - - @method allSettled - @static - @for RSVP - @param {Array} entries - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with an array of the settled - states of the constituent promises. - */ +function defer(label) { + var deferred = {}; - function allSettled(entries, label) { - return new AllSettled(Promise, entries, label).promise; - } + deferred['promise'] = new Promise(function(resolve, reject) { + deferred['resolve'] = resolve; + deferred['reject'] = reject; + }, label); - /** - This is a convenient alias for `RSVP.Promise.race`. - - @method race - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function race$1(array, label) { - return Promise.race(array, label); - } + return deferred; +} - function PromiseHash(Constructor, object, label) { - this._superConstructor(Constructor, object, true, label); - } +/** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. - PromiseHash.prototype = o_create(Enumerator.prototype); - PromiseHash.prototype._superConstructor = Enumerator; - PromiseHash.prototype._init = function () { - this._result = {}; - }; + For example: - PromiseHash.prototype._validateInput = function (input) { - return input && typeof input === 'object'; - }; + ```javascript + + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; - PromiseHash.prototype._validationError = function () { - return new Error('Promise.hash must be called with an object'); + var mapFn = function(item){ + return item + 1; }; - PromiseHash.prototype._enumerate = function () { - var enumerator = this; - var promise = enumerator.promise; - var input = enumerator._input; - var results = []; - - for (var key in input) { - if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { - results.push({ - position: key, - entry: input[key] - }); - } - } + RSVP.map(promises, mapFn).then(function(result){ + // result is [ 2, 3, 4 ] + }); + ``` - var length = results.length; - enumerator._remaining = length; - var result = undefined; + If any of the `promises` given to `RSVP.map` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - for (var i = 0; promise._state === PENDING && i < length; i++) { - result = results[i]; - enumerator._eachEntry(result.entry, result.position); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; }; - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as the reason to the rejection handler. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error('rejectedPromise')), - anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === 'rejectedPromise' - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve('Example'); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: 'Example' - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @static - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - function hash(object, label) { - return new PromiseHash(Promise, object, label).promise; - } + RSVP.map(promises, mapFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - function HashSettled(Constructor, object, label) { - this._superConstructor(Constructor, object, false, label); - } + `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, + say you want to get all comments from a set of blog posts, but you need + the blog posts first because they contain a url to those comments. - HashSettled.prototype = o_create(PromiseHash.prototype); - HashSettled.prototype._superConstructor = Enumerator; - HashSettled.prototype._makeResult = makeSettledResult; + ```javscript - HashSettled.prototype._validationError = function () { - return new Error('hashSettled must be called with an object'); + var mapFn = function(blogPost){ + // getComments does some ajax and returns an RSVP.Promise that is fulfilled + // with some comments data + return getComments(blogPost.comments_url); }; - /** - `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object - instead of an array for its `promises` argument. - - Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, - but like `RSVP.allSettled`, `hashSettled` waits until all the - constituent promises have returned and then shows you all the results - with their states and values/reasons. This is useful if you want to - handle multiple promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled, or rejected if the passed parameters are invalid. - - The returned promise is fulfilled with a hash that has the same key names as - the `promises` object argument. If any of the values in the object are not - promises, they will be copied over to the fulfilled object and marked with state - 'fulfilled'. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - yourPromise: RSVP.Promise.resolve(2), - theirPromise: RSVP.Promise.resolve(3), - notAPromise: 4 - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // yourPromise: { state: 'fulfilled', value: 2 }, - // theirPromise: { state: 'fulfilled', value: 3 }, - // notAPromise: { state: 'fulfilled', value: 4 } - // } - }); - ``` - - If any of the `promises` given to `RSVP.hash` are rejected, the state will - be set to 'rejected' and the reason for rejection provided. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - rejectedPromise: RSVP.Promise.reject(new Error('rejection')), - anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // rejectedPromise: { state: 'rejected', reason: Error }, - // anotherRejectedPromise: { state: 'rejected', reason: Error }, - // } - // Note that for rejectedPromise, reason.message == 'rejection', - // and for anotherRejectedPromise, reason.message == 'more rejection'. - }); - ``` - - An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.Promise.resolve('Example'); + // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled + // with some blog post data + RSVP.map(getBlogPosts(), mapFn).then(function(comments){ + // comments is the result of asking the server for the comments + // of all blog posts returned from getBlogPosts() + }); + ``` + + @method map + @static + @for RSVP + @param {Array} promises + @param {Function} mapFn function to be called on each fulfilled promise. + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with the result of calling + `mapFn` on each fulfilled promise or value when they become fulfilled. + The promise will be rejected if any of the given `promises` become rejected. + @static +*/ +function map(promises, mapFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(mapFn)) { + throw new TypeError("You must pass a function as map's second argument."); } - - MyConstructor.prototype = { - protoProperty: RSVP.Promise.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hashSettled(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: { state: 'fulfilled', value: 'Example' } - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hashSettled - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when when all properties of `promises` - have been settled. - @static - */ - function hashSettled(object, label) { - return new HashSettled(Promise, object, label).promise; - } - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will also throw the - error again so the error can be handled by the promise per the spec. - - ```javascript - function throws(){ - throw new Error('Whoops!'); + var length = values.length; + var results = new Array(length); + + for (var i = 0; i < length; i++) { + results[i] = mapFn(values[i]); } - - let promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @static - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - @static - */ - function rethrow(reason) { - setTimeout(function () { - throw reason; - }); - throw reason; - } - /** - `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. - `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s - interface. New code should use the `RSVP.Promise` constructor instead. - - The object returned from `RSVP.defer` is a plain object with three properties: - - * promise - an `RSVP.Promise`. - * reject - a function that causes the `promise` property on this object to - become rejected - * resolve - a function that causes the `promise` property on this object to - become fulfilled. - - Example: - - ```javascript - let deferred = RSVP.defer(); - - deferred.resolve("Success!"); - - deferred.promise.then(function(value){ - // value here is "Success!" - }); - ``` - - @method defer - @static - @for RSVP - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Object} - */ + return Promise.all(results, label); + }); +} - function defer(label) { - var deferred = { resolve: undefined, reject: undefined }; +/** + This is a convenient alias for `RSVP.Promise.resolve`. - deferred.promise = new Promise(function (resolve, reject) { - deferred.resolve = resolve; - deferred.reject = reject; - }, label); + @method resolve + @static + @for RSVP + @param {*} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$2(value, label) { + return Promise.resolve(value, label); +} - return deferred; - } +/** + This is a convenient alias for `RSVP.Promise.reject`. - /** - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first because they contain a url to those comments. - - ```javscript - - let mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @static - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - @static - */ - function map(promises, mapFn, label) { - return Promise.all(promises, label).then(function (values) { - if (!isFunction(mapFn)) { - throw new TypeError("You must pass a function as map's second argument."); - } + @method reject + @static + @for RSVP + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$2(reason, label) { + return Promise.reject(reason, label); +} - var length = values.length; - var results = new Array(length); +/** + `RSVP.filter` is similar to JavaScript's native `filter` method, except that it + waits for all promises to become fulfilled before running the `filterFn` on + each item in given to `promises`. `RSVP.filter` returns a promise that will + become fulfilled with the result of running `filterFn` on the values the + promises become fulfilled with. - for (var i = 0; i < length; i++) { - results[i] = mapFn(values[i]); - } + For example: - return Promise.all(results, label); - }); - } + ```javascript - /** - This is a convenient alias for `RSVP.Promise.resolve`. - - @method resolve - @static - @for RSVP - @param {*} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - function resolve$2(value, label) { - return Promise.resolve(value, label); - } + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); - /** - This is a convenient alias for `RSVP.Promise.reject`. - - @method reject - @static - @for RSVP - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$2(reason, label) { - return Promise.reject(reason, label); - } + var promises = [promise1, promise2, promise3]; - /** - `RSVP.filter` is similar to JavaScript's native `filter` method, except that it - waits for all promises to become fulfilled before running the `filterFn` on - each item in given to `promises`. `RSVP.filter` returns a promise that will - become fulfilled with the result of running `filterFn` on the values the - promises become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - - let promises = [promise1, promise2, promise3]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - let alice = { name: 'alice' }; - let bob = { name: 'bob' }; - let users = [ alice, bob ]; - - let promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - let filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @static - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ + var filterFn = function(item){ + return item > 1; + }; - function resolveAll(promises, label) { - return Promise.all(promises, label); - } + RSVP.filter(promises, filterFn).then(function(result){ + // result is [ 2, 3 ] + }); + ``` - function resolveSingle(promise, label) { - return Promise.resolve(promise, label).then(function (promises) { - return resolveAll(promises, label); - }); - } + If any of the `promises` given to `RSVP.filter` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - function filter(promises, filterFn, label) { - var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label); - return promise.then(function (values) { - if (!isFunction(filterFn)) { - throw new TypeError("You must pass a function as filter's second argument."); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; - var length = values.length; - var filtered = new Array(length); + var filterFn = function(item){ + return item > 1; + }; - for (var i = 0; i < length; i++) { - filtered[i] = filterFn(values[i]); - } + RSVP.filter(promises, filterFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - return resolveAll(filtered, label).then(function (filtered) { - var results = new Array(length); - var newLength = 0; + `RSVP.filter` will also wait for any promises returned from `filterFn`. + For instance, you may want to fetch a list of users then return a subset + of those users based on some asynchronous operation: - for (var i = 0; i < length; i++) { - if (filtered[i]) { - results[newLength] = values[i]; - newLength++; - } - } + ```javascript - results.length = newLength; + var alice = { name: 'alice' }; + var bob = { name: 'bob' }; + var users = [ alice, bob ]; - return results; - }); + var promises = users.map(function(user){ + return RSVP.resolve(user); + }); + + var filterFn = function(user){ + // Here, Alice has permissions to create a blog post, but Bob does not. + return getPrivilegesForUser(user).then(function(privs){ + return privs.can_create_blog_post === true; }); - } + }; + RSVP.filter(promises, filterFn).then(function(users){ + // true, because the server told us only Alice can create a blog post. + users.length === 1; + // false, because Alice is the only user present in `users` + users[0] === bob; + }); + ``` - var len = 0; - var vertxNext = undefined; - function asap(callback, arg) { - queue$1[len] = callback; - queue$1[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 1, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - scheduleFlush$1(); - } - } - - var browserWindow = typeof window !== 'undefined' ? window : undefined; - var browserGlobal = browserWindow || {}; - var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; - var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; - - // test for web worker but not in IE10 - var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; - - // node - function useNextTick() { - var nextTick = process.nextTick; - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // setImmediate should be used instead instead - var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); - if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { - nextTick = setImmediate; + @method filter + @static + @for RSVP + @param {Array} promises + @param {Function} filterFn - function to be called on each resolved value to + filter the final results. + @param {String} label optional string describing the promise. Useful for + tooling. + @return {Promise} +*/ +function filter(promises, filterFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(filterFn)) { + throw new TypeError("You must pass a function as filter's second argument."); } - return function () { - return nextTick(flush); - }; - } - // vertx - function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); - }; + var length = values.length; + var filtered = new Array(length); + + for (var i = 0; i < length; i++) { + filtered[i] = filterFn(values[i]); } - return useSetTimeout(); - } - function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); + return Promise.all(filtered, label).then(function(filtered) { + var results = new Array(length); + var newLength = 0; - return function () { - return node.data = iterations = ++iterations % 2; - }; - } + for (var i = 0; i < length; i++) { + if (filtered[i]) { + results[newLength] = values[i]; + newLength++; + } + } - // web worker - function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; - } + results.length = newLength; - function useSetTimeout() { - return function () { - return setTimeout(flush, 1); - }; + return results; + }); + }); +} + +var len = 0; +var vertxNext; +function asap(callback, arg) { + queue$1[len] = callback; + queue$1[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 1, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + scheduleFlush$1(); } +} - var queue$1 = new Array(1000); +var browserWindow = (typeof window !== 'undefined') ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && + typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + var nextTick = process.nextTick; + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // setImmediate should be used instead instead + var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); + if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { + nextTick = setImmediate; + } + return function() { + nextTick(flush); + }; +} - function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue$1[i]; - var arg = queue$1[i + 1]; +// vertx +function useVertxTimer() { + return function() { + vertxNext(flush); + }; +} - callback(arg); +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); - queue$1[i] = undefined; - queue$1[i + 1] = undefined; - } + return function() { + node.data = (iterations = ++iterations % 2); + }; +} - len = 0; - } +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; +} - function attemptVertex() { - try { - var r = require; - var vertx = r('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } +function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; +} + +var queue$1 = new Array(1000); +function flush() { + for (var i = 0; i < len; i+=2) { + var callback = queue$1[i]; + var arg = queue$1[i+1]; + + callback(arg); + + queue$1[i] = undefined; + queue$1[i+1] = undefined; } - var scheduleFlush$1 = undefined; - // Decide what async method to use to triggering processing of queued callbacks: - if (isNode) { - scheduleFlush$1 = useNextTick(); - } else if (BrowserMutationObserver) { - scheduleFlush$1 = useMutationObserver(); - } else if (isWorker) { - scheduleFlush$1 = useMessageChannel(); - } else if (browserWindow === undefined && typeof require === 'function') { - scheduleFlush$1 = attemptVertex(); - } else { - scheduleFlush$1 = useSetTimeout(); + len = 0; +} + +function attemptVertex() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch(e) { + return useSetTimeout(); } +} + +var scheduleFlush$1; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush$1 = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush$1 = useMutationObserver(); +} else if (isWorker) { + scheduleFlush$1 = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush$1 = attemptVertex(); +} else { + scheduleFlush$1 = useSetTimeout(); +} + +// defaults +config.async = asap; +config.after = function(cb) { + setTimeout(cb, 0); +}; +var cast = resolve$2; +function async(callback, arg) { + config.async(callback, arg); +} - var platform = undefined; +function on() { + config['on'].apply(config, arguments); +} - /* global self */ - if (typeof self === 'object') { - platform = self; +function off() { + config['off'].apply(config, arguments); +} - /* global global */ - } else if (typeof global === 'object') { - platform = global; - } else { - throw new Error('no global: `self` or `global` found'); +// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` +if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { + var callbacks = window['__PROMISE_INSTRUMENTATION__']; + configure('instrument', true); + for (var eventName in callbacks) { + if (callbacks.hasOwnProperty(eventName)) { + on(eventName, callbacks[eventName]); } + } +} - // defaults - config.async = asap; - config.after = function (cb) { - return setTimeout(cb, 0); - }; - var cast = resolve$2; +exports.cast = cast; +exports.Promise = Promise; +exports.EventTarget = EventTarget; +exports.all = all$1; +exports.allSettled = allSettled; +exports.race = race$1; +exports.hash = hash; +exports.hashSettled = hashSettled; +exports.rethrow = rethrow; +exports.defer = defer; +exports.denodeify = denodeify; +exports.configure = configure; +exports.on = on; +exports.off = off; +exports.resolve = resolve$2; +exports.reject = reject$2; +exports.async = async; +exports.map = map; +exports.filter = filter; - var async = function (callback, arg) { - return config.async(callback, arg); - }; +Object.defineProperty(exports, '__esModule', { value: true }); - function on() { - config['on'].apply(config, arguments); - } - - function off() { - config['off'].apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { - var callbacks = window['__PROMISE_INSTRUMENTATION__']; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - // the default export here is for backwards compat: - // https://github.com/tildeio/rsvp.js/issues/434 - var rsvp = (_rsvp = { - cast: cast, - Promise: Promise, - EventTarget: EventTarget, - all: all$1, - allSettled: allSettled, - race: race$1, - hash: hash, - hashSettled: hashSettled, - rethrow: rethrow, - defer: defer, - denodeify: denodeify, - configure: configure, - on: on, - off: off, - resolve: resolve$2, - reject: reject$2, - map: map - }, _rsvp['async'] = async, _rsvp.filter = // babel seems to error if async isn't a computed prop here... - filter, _rsvp); - - exports.cast = cast; - exports.Promise = Promise; - exports.EventTarget = EventTarget; - exports.all = all$1; - exports.allSettled = allSettled; - exports.race = race$1; - exports.hash = hash; - exports.hashSettled = hashSettled; - exports.rethrow = rethrow; - exports.defer = defer; - exports.denodeify = denodeify; - exports.configure = configure; - exports.on = on; - exports.off = off; - exports.resolve = resolve$2; - exports.reject = reject$2; - exports.map = map; - exports.async = async; - exports.filter = filter; - exports.default = rsvp; }); requireModule("ember"); diff --git a/ember.min.js b/ember.min.js index 9549714d4..e70bf9445 100644 --- a/ember.min.js +++ b/ember.min.js @@ -1,17 +1,17 @@ -!function(){function e(e,t){e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):o(e,t))}function t(e,t){return e.raw=t,e}function n(e,t){for(var n=0;n=t[n]?i=n+2:o=n;return e>=t[i]?i+2:i}function a(e,t,n){this.name=e,this.globalOptions=n||{},this.options=t,this._queue=[],this.targetQueues={},this._queueBeingFlushed=void 0}function u(e,n){var r=this.queues={};this.queueNames=e=e||[],this.options=n,t(e,function(e){r[e]=new a(e,n[e],n)})}function l(e){throw new Error("You attempted to schedule an action in a queue ("+e+") that doesn't exist")}function c(e){throw new Error("You attempted to schedule an action in a queue ("+e+") for a method that doesn't exist")}function p(e,t){this.queueNames=e,this.options=t||{},this.options.defaultQueue||(this.options.defaultQueue=e[0]),this.instanceStack=[],this._debouncees=[],this._throttlers=[],this._eventCallbacks={end:[],begin:[]};var n=this;this._boundClearItems=function(){v()},this._timerTimeoutId=void 0,this._timers=[],this._platform=this.options._platform||{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){clearTimeout(e)}},this._boundRunExpiredTimers=function(){n._runExpiredTimers()}}function h(e){return e.onError||e.onErrorTarget&&e.onErrorTarget[e.onErrorMethod]}function f(e){var t=e._platform.setTimeout;e.begin(),e._autorun=t(function(){e._autorun=null,e.end()},0)}function m(e,t,n){return g(e,t,n)}function d(e,t,n){return g(e,t,n)}function g(e,t,n){for(var r,i=-1,o=0,s=n.length;o0?t.apply(e,n):t.call(e)},invokeWithOnError:function(e,t,n,r,i){try{n&&n.length>0?t.apply(e,n):t.call(e)}catch(e){r(e,i)}},flush:function(e){var t=this._queue,r=t.length;if(0!==r){var i,o,s,a,u=this.globalOptions,l=this.options,c=l&&l.before,p=l&&l.after,h=u.onError||u.onErrorTarget&&u.onErrorTarget[u.onErrorMethod],f=h?this.invokeWithOnError:this.invoke;this.targetQueues=Object.create(null);var m=this._queueBeingFlushed=this._queue.slice();this._queue=[],c&&c();for(var d=0;d0&&this.flush(!0)}},cancel:function(e){var t,n,r,i,o=this._queue,s=e.target,a=e.method,u=this.globalOptions.GUID_KEY;if(u&&this.targetQueues&&s){var l=this.targetQueues[s[u]];if(l)for(r=0,i=l.length;r2){r=new Array(i-2);for(var o=0,s=i-2;o3){i=new Array(o-3);for(var a=3;a3){i=new Array(o-3);for(var a=3;a-1?this._throttlers[l]:(c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=d(e,t,r._throttlers);n>-1&&r._throttlers.splice(n,1)},a),p&&this.run.apply(this,o),u=[e,t,c],this._throttlers.push(u),u)},debounce:function(e,t){for(var r=this,o=new Array(arguments.length),s=0;s-1&&(l=this._debouncees[u],this._debouncees.splice(u,1),this._platform.clearTimeout(l[2])),c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=m(e,t,r._debouncees);n>-1&&r._debouncees.splice(n,1)},a),p&&u===-1&&r.run.apply(r,o),l=[e,t,c],r._debouncees.push(l),l},cancelTimers:function(){t(this._throttlers,this._boundClearItems),this._throttlers=[],t(this._debouncees,this._boundClearItems),this._debouncees=[],this._clearTimerTimeout(),this._timers=[],this._autorun&&(this._platform.clearTimeout(this._autorun),this._autorun=null)},hasTimers:function(){return!!this._timers.length||!!this._debouncees.length||!!this._throttlers.length||this._autorun},cancel:function(e){var t=typeof e;if(e&&"object"===t&&e.queue&&e.method)return e.queue.cancel(e);if("function"!==t)return"[object Array]"===Object.prototype.toString.call(e)?this._cancelItem(d,this._throttlers,e)||this._cancelItem(m,this._debouncees,e):void 0;for(var n=0,r=this._timers.length;n-1&&(r=t[i],r[2]===n[2])&&(t.splice(i,1),this._platform.clearTimeout(n[2]),!0))},_runExpiredTimers:function(){this._timerTimeoutId=void 0,this.run(this,this._scheduleExpiredTimers)},_scheduleExpiredTimers:function(){for(var e=Date.now(),t=this._timers,n=0,r=t.length;n1){for(var t=arguments[0],n=[],r=void 0,i=1;i0?v(this,this.registry.normalize(e)):g(this)},ownerInjection:function(){var e;return e={},e[t.OWNER]=this.owner,e}}}),s("container/index",["exports","container/registry","container/container"],function(e,t,n){"use strict";e.Registry=t.default,e.privatize=t.privatize,e.Container=n.default,e.buildFakeContainerWithDeprecations=n.buildFakeContainerWithDeprecations}),s("container/registry",["exports","ember-utils","ember-metal","container/container"],function(e,t,n,r){"use strict";function i(e){this.fallback=e&&e.fallback?e.fallback:null,e&&e.resolver&&(this.resolver=e.resolver,"function"==typeof this.resolver&&o(this)),this.registrations=t.dictionary(e&&e.registrations?e.registrations:null),this._typeInjections=t.dictionary(null),this._injections=t.dictionary(null),this._factoryTypeInjections=t.dictionary(null),this._factoryInjections=t.dictionary(null),this._localLookupCache=new t.EmptyObject,this._normalizeCache=t.dictionary(null),this._resolveCache=t.dictionary(null),this._failCache=t.dictionary(null),this._options=t.dictionary(null),this._typeOptions=t.dictionary(null)}function o(e){e.resolver={resolve:e.resolver}}function s(e,n,r){var i=e._localLookupCache,o=i[n];o||(o=i[n]=new t.EmptyObject);var s=o[r];if(void 0!==s)return s;var a=e.resolver.expandLocalLookup(n,r);return o[r]=a}function a(e,t,n){if(!n||!n.source||(t=e.expandLocalLookup(t,n))){var r=e._resolveCache[t];if(void 0!==r)return r;if(!e._failCache[t]){var i=void 0;return e.resolver&&(i=e.resolver.resolve(t)),void 0===i&&(i=e.registrations[t]),void 0===i?e._failCache[t]=!0:e._resolveCache[t]=i,i}}}function u(e,t,n){return void 0!==e.resolve(t,{source:n})}function l(e){var n=e[0],r=p[n];if(r)return r;var i=n.split(":"),o=i[0],s=i[1];return p[n]=t.intern(o+":"+s+"-"+h)}e.default=i,e.privatize=l;var c=/^[^:]+:[^:]+$/;i.prototype={fallback:null,resolver:null,registrations:null,_typeInjections:null,_injections:null,_factoryTypeInjections:null,_factoryInjections:null,_normalizeCache:null,_resolveCache:null,_options:null,_typeOptions:null,container:function(e){return new r.default(this,e)},register:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(void 0===t)throw new TypeError("Attempting to register an unknown factory: '"+e+"'");var r=this.normalize(e);if(this._resolveCache[r])throw new Error("Cannot re-register: '"+e+"', as it has already been resolved.");delete this._failCache[r],this.registrations[r]=t,this._options[r]=n},unregister:function(e){var n=this.normalize(e);this._localLookupCache=new t.EmptyObject,delete this.registrations[n],delete this._resolveCache[n],delete this._failCache[n],delete this._options[n]},resolve:function(e,t){var n=a(this,this.normalize(e),t);if(void 0===n&&this.fallback){var r;n=(r=this.fallback).resolve.apply(r,arguments)}return n},describe:function(e){return this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(e):this.fallback?this.fallback.describe(e):e},normalizeFullName:function(e){return this.resolver&&this.resolver.normalize?this.resolver.normalize(e):this.fallback?this.fallback.normalizeFullName(e):e},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this.normalizeFullName(e))},makeToString:function(e,t){return this.resolver&&this.resolver.makeToString?this.resolver.makeToString(e,t):this.fallback?this.fallback.makeToString(e,t):e.toString()},has:function(e,t){if(!this.isValidFullName(e))return!1;var n=t&&t.source&&this.normalize(t.source);return u(this,this.normalize(e),n)},optionsForType:function(e,t){this._typeOptions[e]=t},getOptionsForType:function(e){var t=this._typeOptions[e];return void 0===t&&this.fallback&&(t=this.fallback.getOptionsForType(e)),t},options:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=this.normalize(e);this._options[n]=t},getOptions:function(e){var t=this.normalize(e),n=this._options[t];return void 0===n&&this.fallback&&(n=this.fallback.getOptions(e)),n},getOption:function(e,t){var n=this._options[e];if(n&&void 0!==n[t])return n[t];var r=e.split(":")[0];return n=this._typeOptions[r],n&&void 0!==n[t]?n[t]:this.fallback?this.fallback.getOption(e,t):void 0},typeInjection:function(e,t,n){var r=n.split(":")[0];if(r===e)throw new Error("Cannot inject a '"+n+"' on other "+e+"(s).");var i=this._typeInjections[e]||(this._typeInjections[e]=[]);i.push({property:t,fullName:n})},injection:function(e,t,n){this.validateFullName(n);var r=this.normalize(n);if(e.indexOf(":")===-1)return this.typeInjection(e,t,r);var i=this.normalize(e),o=this._injections[i]||(this._injections[i]=[]);o.push({property:t,fullName:r})},factoryTypeInjection:function(e,t,n){var r=this._factoryTypeInjections[e]||(this._factoryTypeInjections[e]=[]);r.push({property:t,fullName:this.normalize(n)})},factoryInjection:function(e,t,n){var r=this.normalize(e),i=this.normalize(n);if(this.validateFullName(n),e.indexOf(":")===-1)return this.factoryTypeInjection(r,t,i);var o=this._factoryInjections[r]||(this._factoryInjections[r]=[]);o.push({property:t,fullName:i})},knownForType:function(e){for(var n=void 0,r=void 0,i=t.dictionary(null),o=Object.keys(this.registrations),s=0;s0){var s="cycle detected: "+t;throw this.each(function(e){s+=" <- "+e}),new Error(s)}}},e.prototype.each=function(e){for(var t=this,n=t.result,r=t.vertices,i=0;i-1&&(i=i.replace(/\.(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("_")>-1&&(i=i.replace(/_(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("-")>-1&&(i=i.replace(/-(.)/g,function(e){return e.charAt(1).toUpperCase()})),n+":"+i}return e},resolve:function(e){var t,n=this.parseName(e),r=n.resolveMethodName;return this[r]&&(t=this[r](n)),t=t||this.resolveOther(n),n.root&&n.root.LOG_RESOLVER&&this._logLookup(t,n),t&&i.default(t,n),t},parseName:function(e){return this._parseNameCache[e]||(this._parseNameCache[e]=this._parseName(e))},_parseName:function(e){var t=e.split(":"),i=t[0],o=t[1],s=o,a=n.get(this,"namespace"),u=a,l=s.lastIndexOf("/"),c=l!==-1?s.slice(0,l):null;if("template"!==i&&l!==-1){var p=s.split("/");s=p[p.length-1];var h=r.String.capitalize(p.slice(0,-1).join("."));u=r.Namespace.byName(h)}var f="main"===o?"Main":r.String.classify(i);if(!s||!i)throw new TypeError("Invalid fullName: `"+e+"`, must be of the form `type:name` ");return{fullName:e,type:i,fullNameWithoutType:o,dirname:c,name:s,root:u,resolveMethodName:"resolve"+f}},lookupDescription:function(e){var t=this.parseName(e),n=void 0;return"template"===t.type?"template at "+t.fullNameWithoutType.replace(/\./g,"/"):(n=t.root+"."+r.String.classify(t.name).replace(/\./g,""),"model"!==t.type&&(n+=r.String.classify(t.type)),n)},makeToString:function(e,t){return e.toString()},useRouterNaming:function(e){e.name=e.name.replace(/\./g,"_"),"basic"===e.name&&(e.name="")},resolveTemplate:function(e){var t=e.fullNameWithoutType.replace(/\./g,"/");return o.getTemplate(t)||o.getTemplate(r.String.decamelize(t))},resolveView:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveController:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveRoute:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveModel:function(e){var t=r.String.classify(e.name),i=n.get(e.root,t);return i},resolveHelper:function(e){return this.resolveOther(e)},resolveOther:function(e){var t=r.String.classify(e.name)+r.String.classify(e.type),i=n.get(e.root,t);return i},resolveMain:function(e){var t=r.String.classify(e.type);return n.get(e.root,t)},_logLookup:function(e,t){var n=void 0,r=void 0;n=e?"[✓]":"[ ]",r=t.fullName.length>60?".":new Array(60-t.fullName.length).join(".")},knownForType:function(e){for(var i=n.get(this,"namespace"),o=r.String.classify(e),s=new RegExp(o+"$"),a=t.dictionary(null),u=Object.keys(i),l=0;l1?this.set("models",this._getModels(t)):this.set("models",[])}});a.toString=function(){return"LinkComponent"},a.reopenClass({positionalParams:"params"}),e.default=a}),s("ember-glimmer/components/text_area",["exports","ember-glimmer/component","ember-views","ember-glimmer/templates/empty"],function(e,t,n,r){"use strict";e.default=t.default.extend(n.TextSupport,{classNames:["ember-text-area"],layout:r.default,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","wrap","lang","dir","value"],rows:null,cols:null})}),s("ember-glimmer/components/text_field",["exports","ember-utils","ember-metal","ember-environment","ember-glimmer/component","ember-glimmer/templates/empty","ember-views"],function(e,t,n,r,i,o,s){"use strict";function a(e){if(e in l)return l[e];if(!r.environment.hasDOM)return l[e]=e,e;u||(u=document.createElement("input"));try{u.type=e}catch(e){}return l[e]=u.type===e}var u=void 0,l=new t.EmptyObject;e.default=i.default.extend(s.TextSupport,{layout:o.default,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","max","min","multiple","name","pattern","size","step","type","value","width"],value:"",type:n.computed({get:function(){return"text"},set:function(e,t){var n="text";return a(t)&&(n=t),n}}),size:null,pattern:null,min:null,max:null})}),s("ember-glimmer/dom",["exports","glimmer-runtime","glimmer-node"],function(e,t,n){"use strict";e.DOMChanges=t.DOMChanges,e.DOMTreeConstruction=t.DOMTreeConstruction,e.NodeDOMTreeConstruction=n.NodeDOMTreeConstruction}),s("ember-glimmer/environment",["exports","ember-utils","ember-metal","ember-views","glimmer-runtime","ember-glimmer/syntax/curly-component","ember-glimmer/syntax","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/iterable","ember-glimmer/utils/references","ember-glimmer/helpers/if-unless","ember-glimmer/utils/bindings","ember-glimmer/helpers/action","ember-glimmer/helpers/component","ember-glimmer/helpers/concat","ember-glimmer/helpers/debugger","ember-glimmer/helpers/get","ember-glimmer/helpers/hash","ember-glimmer/helpers/loc","ember-glimmer/helpers/log","ember-glimmer/helpers/mut","ember-glimmer/helpers/readonly","ember-glimmer/helpers/unbound","ember-glimmer/helpers/-class","ember-glimmer/helpers/-input-type","ember-glimmer/helpers/query-param","ember-glimmer/helpers/each-in","ember-glimmer/helpers/-normalize-class","ember-glimmer/helpers/-html-safe","ember-glimmer/protocol-for-url","ember-glimmer/modifiers/action"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v,y,b,_,w,E,O,S,x,C,A,k,T,N){"use strict";var R={textarea:"-text-area"},P=function(e){function P(s){var a=this,u=s[t.OWNER];e.apply(this,arguments),this.owner=u,this.isInteractive=u.lookup("-environment:main").isInteractive,this.destroyedComponents=void 0,T.default(this),this._definitionCache=new n.Cache(2e3,function(e){var t=e.name,n=e.source,i=e.owner,s=r.lookupComponent(i,t,{source:n}),a=s.component,u=s.layout;if(a||u)return new o.CurlyComponentDefinition(t,a,u)},function(e){var n=e.name,r=e.source,i=e.owner,o=r&&i._resolveLocalLookupName(n,r)||n,s=t.guidFor(i);return s+"|"+o}),this._templateCache=new n.Cache(1e3,function(e){var n=e.Template,r=e.owner;if(n.create){var i;return n.create((i={env:a},i[t.OWNER]=r,i))}return n},function(e){var n=e.Template,r=e.owner;return t.guidFor(r)+"|"+n.id}),this._compilerCache=new n.Cache(10,function(e){return new n.Cache(2e3,function(t){var n=new e(t);return i.compileLayout(n,a)},function(e){var n=e.meta.owner;return t.guidFor(n)+"|"+e.id})},function(e){return e.id}),this.builtInModifiers={action:new N.default},this.builtInHelpers={if:c.inlineIf,action:h.default,component:f.default,concat:m.default,debugger:d.default,get:g.default,hash:v.default,loc:y.default,log:b.default,mut:_.default,"query-params":x.default,readonly:w.default,unbound:E.default,unless:c.inlineUnless,"-class":O.default,"-each-in":C.default,"-input-type":S.default,"-normalize-class":A.default,"-html-safe":k.default,"-get-dynamic-var":i.getDynamicVar}}return babelHelpers.inherits(P,e),P.create=function(e){return new P(e)},P.prototype.refineStatement=function(t,n){var r=e.prototype.refineStatement.call(this,t,n);if(r)return r;var i=t.appendType,u=t.isSimple,l=t.isInline,c=t.isBlock,h=(t.isModifier,t.key),f=t.path,m=t.args;if(u&&(l||c)&&"get"!==i){var d=s.findSyntaxBuilder(h);if(d)return d.create(this,m,n);var g=R[h],v=null;if(g?v=this.getComponentDefinition([g],n):h.indexOf("-")>=0&&(v=this.getComponentDefinition(f,n)),v)return p.wrapComponentClassAttribute(m),new o.CurlyComponentSyntax(m,v,n)}return l&&!u&&"helper"!==i?t.original.deopt():!u&&f?a.DynamicComponentSyntax.fromPath(this,f,m,n):void 0},P.prototype.hasComponentDefinition=function(){return!1},P.prototype.getComponentDefinition=function(e,t){var n=e[0],r=t.getMeta(),i=r.owner,o=r.moduleName&&"template:"+r.moduleName;return this._definitionCache.get({name:n,source:o,owner:i})},P.prototype.getTemplate=function(e,t){return this._templateCache.get({Template:e,owner:t})},P.prototype.getCompiledBlock=function(e,t){var n=this._compilerCache.get(e);return n.get(t)},P.prototype.hasPartial=function(e,t){var n=t.getMeta(),i=n.owner;return r.hasPartial(e,i)},P.prototype.lookupPartial=function(e,t){var n=t.getMeta(),i=n.owner,o={template:r.lookupPartial(e,i)};if(o.template)return o;throw new Error(e+" is not a partial")},P.prototype.hasHelper=function(e,t){if(e.length>1)return!1;var n=e[0];if(this.builtInHelpers[n])return!0;var r=t.getMeta(),i=r.owner,o={source:"template:"+r.moduleName};return i.hasRegistration("helper:"+n,o)||i.hasRegistration("helper:"+n)},P.prototype.lookupHelper=function(e,t){var n=e[0],r=this.builtInHelpers[n];if(r)return r;var i=t.getMeta(),o=i.owner,s=i.moduleName&&{source:"template:"+i.moduleName}||{};if(r=o.lookup("helper:"+n,s)||o.lookup("helper:"+n),r.isHelperInstance)return function(e,t){return l.SimpleHelperReference.create(r.compute,t)};if(r.isHelperFactory)return function(e,t){return l.ClassBasedHelperReference.create(r,e,t)};throw new Error(e+" is not a helper")},P.prototype.hasModifier=function(e){return!(e.length>1)&&!!this.builtInModifiers[e[0]]},P.prototype.lookupModifier=function(e){var t=this.builtInModifiers[e[0]];if(t)return t;throw new Error(e+" is not a modifier")},P.prototype.toConditionalReference=function(e){return l.ConditionalReference.create(e)},P.prototype.iterableFor=function(e,t){var n=t.named.get("key").value();return u.default(e,n)},P.prototype.scheduleInstallModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleInstallModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},P.prototype.scheduleUpdateModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleUpdateModifier).call.apply(t,[this].concat(babelHelpers.slice.call(arguments)))}},P.prototype.didDestroy=function(e){e.destroy()},P.prototype.begin=function(){this.inTransaction=!0,e.prototype.begin.call(this),this.destroyedComponents=[]},P.prototype.commit=function(){for(var t=0;t1?n.String.dasherize(t.at(1).value()):null:o===!1?i>2?n.String.dasherize(t.at(2).value()):null:o}e.default=function(e,n){return new t.InternalHelperReference(r,n); -}}),s("ember-glimmer/helpers/-html-safe",["exports","ember-glimmer/utils/references","ember-glimmer/utils/string"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=t.at(0);return new n.SafeString(r.value())}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/-input-type",["exports","ember-glimmer/utils/references"],function(e,t){"use strict";function n(e){var t=e.positional,n=(e.named,t.at(0).value());return"checkbox"===n?"-checkbox":"-text-field"}e.default=function(e,r){return new t.InternalHelperReference(n,r)}}),s("ember-glimmer/helpers/-normalize-class",["exports","ember-glimmer/utils/references","ember-runtime"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=(e.named,t.at(0).value().split(".")),i=r[r.length-1],o=t.at(1).value();return o===!0?n.String.dasherize(i):o||0===o?String(o):""}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/action",["exports","ember-utils","ember-glimmer/utils/references","ember-metal"],function(e,t,n,r){"use strict";function i(e,t,n,i){var o=void 0,a=i.length;return o=a>0?function(){for(var o=arguments.length,s=Array(o),u=0;u0&&(l[0]=r.get(l[0],n));var p={target:e,args:l,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",p,function(){return r.run.join.apply(r.run,[e,t].concat(l))})}:function(){for(var i=arguments.length,o=Array(i),s=0;s0&&(o[0]=r.get(o[0],n));var a={target:e,args:o,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",a,function(){return r.run.join.apply(r.run,[e,t].concat(o))})},o[s]=!0,o}e.createClosureAction=i;var o=t.symbol("INVOKE");e.INVOKE=o;var s=t.symbol("ACTION");e.ACTION=s;var a=function(e){function t(t){e.call(this),this.args=t,this.tag=t.tag}return babelHelpers.inherits(t,e),t.create=function(e){return new t(e)},t.prototype.compute=function(){var e=this.args,t=e.named,n=e.positional,s=n.value(),a=s[0],u=n.at(1),l=s[1],c=s.slice(2),p=typeof l,h=l;if(u[o])a=u,h=u[o];else{if(r.isNone(l))throw new r.Error("Action passed is null or undefined in (action) from "+a+".");if("string"===p){var f=l;if(h=null,t.has("target")&&(a=t.get("target").value()),a.actions&&(h=a.actions[f]),!h)throw new r.Error("An action named '"+f+"' was not found in "+a)}else if(h&&"function"==typeof h[o])a=h,h=h[o];else if("function"!==p){var m=u._propertyKey||l;throw new r.Error("An action could not be made for `"+m+"` in "+a+". Please confirm that you are using either a quoted action name (i.e. `(action '"+m+"')`) or a function available in "+a+".")}}var d=t.get("value").value();return i(a,h,d,c)},t}(n.CachedReference);e.ClosureActionReference=a,e.default=function(e,t){return a.create(t)}}),s("ember-glimmer/helpers/component",["exports","ember-utils","ember-glimmer/utils/references","ember-glimmer/syntax/curly-component","glimmer-runtime","ember-metal"],function(e,t,n,r,i,o){"use strict";function s(e,t){var n=a(e,t);return new r.CurlyComponentDefinition(e.name,e.ComponentClass,e.template,n)}function a(e,n){var o=e.args,s=e.ComponentClass,a=s.positionalParams,u=n.positional.values,l=u.slice(1);a&&l.length&&r.validatePositionalParameters(n.named,l,a);var c="string"==typeof a,p={};if(!c&&a&&a.length>0){for(var h=Math.min(a.length,l.length),f=0;f=0)return!0;for(var n=0;n1)if(u=a.at(0),p=a.at(1),p[i.INVOKE])c=p;else{p._propertyKey;c=p.value()}for(var h=[],f=2;f10)throw y=0,v[n].destroy(),new Error("infinite rendering invalidation detected");return y++,m.join(null,p)}y=0}var f=void 0;f=function(e,t){return e[t](),!1};var m=n.run.backburner,d=function(){function e(e,t,n,r){this.view=e,this.outletState=t,this.rootOutletState=n}return e.prototype.child=function(){return new e(this.view,this.outletState,this.rootOutletState)},e.prototype.get=function(e){return this.outletState},e.prototype.set=function(e,t){return this.outletState=t,t},e}(),g=function(){function e(e,t,n,r,o,s){var a=this;this.id=i.getViewId(e),this.env=t,this.root=e,this.result=void 0,this.shouldReflush=!1,this.destroyed=!1,this._removing=!1;var u=this.options={alwaysRevalidate:!1};this.render=function(){var e=a.result=n.render(r,o,s);a.render=function(){e.rerender(u)}}}return e.prototype.isFor=function(e){return this.root===e},e.prototype.destroy=function(){var e=this.result,t=this.env;if(this.destroyed=!0,this.env=null,this.root=null,this.result=null,this.render=null,e){var n=!t.inTransaction;n&&t.begin(),e.destroy(),n&&t.commit()}},e}(),v=[];n.setHasViews(function(){return v.length>0});var y=0;m.on("begin",c),m.on("end",h);var b=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?i.fallbackViewRegistry:arguments[2],r=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];this._env=e,this._rootTemplate=t,this._viewRegistry=n,this._destinedForDOM=r,this._destroyed=!1,this._roots=[],this._lastRevision=null,this._isRenderingRoots=!1,this._removedRoots=[]}return e.prototype.appendOutletView=function(e,t){var n=new a.TopLevelOutletComponentDefinition(e),r=e.toReference(),i=e.outletState.render.controller;this._appendDefinition(e,n,t,r,i)},e.prototype.appendTo=function(e,t){var n=new s.RootComponentDefinition(e);this._appendDefinition(e,n,t)},e.prototype._appendDefinition=function(e,n,i){var o=arguments.length<=3||void 0===arguments[3]?r.UNDEFINED_REFERENCE:arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4],a=new t.RootReference(n),u=new d(null,o,o,!0,s),l=new g(e,this._env,this._rootTemplate,a,i,u);this._renderRoot(l)},e.prototype.rerender=function(e){this._scheduleRevalidate()},e.prototype.register=function(e){var t=i.getViewId(e);this._viewRegistry[t]=e},e.prototype.unregister=function(e){delete this._viewRegistry[i.getViewId(e)]},e.prototype.remove=function(e){e._transitionTo("destroying"),this.cleanupRootFor(e),i.setViewElement(e,null),this._destinedForDOM&&e.trigger("didDestroyElement"),e.isDestroying||e.destroy()},e.prototype.cleanupRootFor=function(e){if(!this._destroyed)for(var t=this._roots,n=this._roots.length;n--;){var r=t[n];r.isFor(e)&&r.destroy()}},e.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this._clearAllRoots())},e.prototype.getElement=function(e){},e.prototype.getBounds=function(e){var t=e[o.BOUNDS],n=t.parentElement(),r=t.firstNode(),i=t.lastNode();return{parentElement:n,firstNode:r,lastNode:i}},e.prototype.createElement=function(e){return this._env.getAppendOperations().createElement(e)},e.prototype._renderRoot=function(e){var t=this._roots;t.push(e),1===t.length&&u(this),this._renderRootsTransaction()},e.prototype._renderRoots=function(){var e=this._roots,t=this._env,n=this._removedRoots,i=void 0,o=void 0;do{t.begin(),o=e.length,i=!1;for(var s=0;s=o&&!u||(a.options.alwaysRevalidate=u,u=a.shouldReflush=f(a,"render"),i=i||u)}}this._lastRevision=r.CURRENT_TAG.value(),t.commit()}while(i||e.length>o);for(;n.length;){var a=n.pop(),c=e.indexOf(a);e.splice(c,1)}0===this._roots.length&&l(this)},e.prototype._renderRootsTransaction=function(){if(!this._isRenderingRoots){this._isRenderingRoots=!0;var e=!1;try{this._renderRoots(),e=!0}finally{e||(this._lastRevision=r.CURRENT_TAG.value()),this._isRenderingRoots=!1}}},e.prototype._clearAllRoots=function(){for(var e=this._roots,t=0;t-1)return c[t]}e.registerSyntax=a,e.findSyntaxBuilder=u;var l=[],c=[];a("render",t.RenderSyntax),a("outlet",n.OutletSyntax),a("mount",r.MountSyntax),a("component",i.DynamicComponentSyntax),a("input",o.InputSyntax),a("-with-dynamic-vars",function(){function e(){}return e.create=function(e,t,n){return new s.WithDynamicVarsSyntax(t)},e}()),a("-in-element",function(){function e(){}return e.create=function(e,t,n){return new s.InElementSyntax(t)},e}())}),s("ember-glimmer/syntax/curly-component",["exports","ember-utils","glimmer-runtime","ember-glimmer/utils/bindings","ember-glimmer/component","ember-metal","ember-views","ember-glimmer/utils/process-args","container"],function(e,t,n,r,i,o,s,a,u){"use strict";function l(e,t){}function c(e,t,n){}function p(e,t){e.named.has("id")&&(t.elementId=t.id)}function h(e,t,n,i){for(var o=[],s=t.length-1;s!==-1;){var a=t[s],u=r.AttributeBinding.parse(a),l=u[1];o.indexOf(l)===-1&&(o.push(l),r.AttributeBinding.install(e,n,u,i)),s--}o.indexOf("id")===-1&&i.addStaticAttribute(e,"id",n.elementId),o.indexOf("style")===-1&&r.IsVisibleBinding.install(e,n,i)}function f(){}function m(e){return e.instrumentDetails({initialRender:!0})}function d(e){return e.instrumentDetails({initialRender:!1})}function g(e){var t=e.dynamicScope().view.tagName;return n.PrimitiveReference.create(""===t?null:t||"div")}function v(e){return e.getSelf().get("ariaRole")}e.validatePositionalParameters=c;var y=babelHelpers.taggedTemplateLiteralLoose(["template:components/-default"],["template:components/-default"]),b=u.privatize(y),_=function(e){function t(t,n,r){e.call(this),this.args=t,this.definition=n,this.symbolTable=r,this.shadow=null}return babelHelpers.inherits(t,e),t.prototype.compile=function(e){e.component.static(this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.CurlyComponentSyntax=_;var w=function(){function e(e,t,n,r){this.environment=e,this.component=t,this.classRef=null,this.args=n,this.argsRevision=n.tag.value(),this.finalizer=r}return e.prototype.destroy=function(){var e=this.component,t=this.environment;t.isInteractive&&(e.trigger("willDestroyElement"),e.trigger("willClearRender")),t.destroyedComponents.push(e)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=f},e}(),E=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return c(t.named,t.positional.values,e.ComponentClass.positionalParams),a.gatherArgs(t,e)},e.prototype.create=function(e,t,n,r,s,u){var c=r.view,h=t.ComponentClass,f=a.ComponentArgs.create(n),d=f.value(),g=d.props;p(n,g),g.parentView=c,g[i.HAS_BLOCK]=u,g._targetObject=s.value();var v=h.create(g),y=o._instrumentStart("render.component",m,v);r.view=v,null!==c&&c.appendChild(v),""===v.tagName&&(e.isInteractive&&v.trigger("willRender"),v._transitionTo("hasElement"),e.isInteractive&&v.trigger("willInsertElement"));var b=new w(e,v,f,y);return n.named.has("class")&&(b.classRef=n.named.get("class")),l(v,g),e.isInteractive&&""!==v.tagName&&v.trigger("willRender"),b},e.prototype.layoutFor=function(e,t,n){var r=e.template;if(!r){var i=t.component;r=this.templateFor(i,n)}return n.getCompiledBlock(k,r)},e.prototype.templateFor=function(e,n){var r=o.get(e,"layout"),i=e[t.OWNER];if(r)return n.getTemplate(r,i);var s=o.get(e,"layoutName");if(s){var a=i.lookup("template:"+s);if(a)return a}return i.lookup(b)},e.prototype.getSelf=function(e){var t=e.component;return t[i.ROOT_REF]},e.prototype.didCreateElement=function(e,t,n){var i=e.component,o=e.classRef,a=e.environment;s.setViewElement(i,t);var u=i.attributeBindings,l=i.classNames,c=i.classNameBindings;u&&u.length?h(t,u,i,n):(n.addStaticAttribute(t,"id",i.elementId),r.IsVisibleBinding.install(t,i,n)),o&&n.addDynamicAttribute(t,"class",o),l&&l.length&&l.forEach(function(e){n.addStaticAttribute(t,"class",e)}),c&&c.length&&c.forEach(function(e){r.ClassNameBinding.install(t,i,e,n)}),i._transitionTo("hasElement"),a.isInteractive&&i.trigger("willInsertElement")},e.prototype.didRenderLayout=function(e,t){e.component[i.BOUNDS]=t,e.finalize()},e.prototype.getTag=function(e){var t=e.component;return t[i.DIRTY_TAG]},e.prototype.didCreate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t._transitionTo("inDOM"),t.trigger("didInsertElement"),t.trigger("didRender"))},e.prototype.update=function(e,t,n){var r=e.component,s=e.args,a=e.argsRevision,u=e.environment;if(e.finalizer=o._instrumentStart("render.component",d,r),!s.tag.validate(a)){var l=s.value(),c=l.attrs,p=l.props;e.argsRevision=s.tag.value();var h=r.attrs,f=c;r[i.IS_DISPATCHING_ATTRS]=!0,r.setProperties(p),r[i.IS_DISPATCHING_ATTRS]=!1,r.trigger("didUpdateAttrs",{oldAttrs:h,newAttrs:f}),r.trigger("didReceiveAttrs",{oldAttrs:h,newAttrs:f})}u.isInteractive&&(r.trigger("willUpdate"),r.trigger("willRender"))},e.prototype.didUpdateLayout=function(e){e.finalize()},e.prototype.didUpdate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t.trigger("didUpdate"),t.trigger("didRender"))},e.prototype.getDestructor=function(e){return e},e}(),O=new E,S=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r,i,s){var a=t.ComponentClass,u=o._instrumentStart("render.component",m,a);return r.view=a,""===a.tagName&&(e.isInteractive&&a.trigger("willRender"),a._transitionTo("hasElement"),e.isInteractive&&a.trigger("willInsertElement")),l(a,{}),new w(e,a,n,u)},t}(E),x=new S,C=function(e){function t(t,n,r,i){e.call(this,t,O,n),this.template=r,this.args=i}return babelHelpers.inherits(t,e),t}(n.ComponentDefinition);e.CurlyComponentDefinition=C;var A=function(e){function t(t){e.call(this,"-root",x,t),this.template=void 0,this.args=void 0}return babelHelpers.inherits(t,e),t}(n.ComponentDefinition);e.RootComponentDefinition=A;var k=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.dynamic(g),e.attrs.dynamic("role",v),e.attrs.static("class","ember-view")},e}();k.id="curly"}),s("ember-glimmer/syntax/dynamic-component",["exports","glimmer-runtime","glimmer-reference","ember-metal"],function(e,t,n,r){"use strict";function i(e,t){var n=e.env,r=e.getArgs(),i=r.positional.at(0);return new s({nameRef:i,env:n,symbolTable:t})}var o=function(e){function n(t,n,r){e.call(this),this.definition=i,this.definitionArgs=t,this.args=n,this.symbolTable=r,this.shadow=null}return babelHelpers.inherits(n,e),n.create=function(e,n,r){var i=t.ArgsSyntax.fromPositionalArgs(n.positional.slice(0,1)),o=t.ArgsSyntax.build(n.positional.slice(1),n.named,n.blocks);return new this(i,o,r)},n.fromPath=function(e,n,r,i){var o=t.ArgsSyntax.fromPositionalArgs(t.PositionalArgsSyntax.build([t.GetSyntax.build(n.join("."))]));return new this(o,r,i)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.DynamicComponentSyntax=o;var s=function(){function e(e){var t=e.nameRef,n=e.env,r=e.symbolTable,i=e.args;this.tag=t.tag,this.nameRef=t,this.env=n,this.symbolTable=r,this.args=i}return e.prototype.value=function(){var e=this.env,n=this.nameRef,r=this.symbolTable,i=n.value();if("string"==typeof i){var o=e.getComponentDefinition([i],r);return o}return t.isComponentDefinition(i)?i:null},e.prototype.get=function(){return n.UNDEFINED_REFERENCE},e}()}),s("ember-glimmer/syntax/input",["exports","ember-metal","ember-glimmer/syntax/curly-component","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/bindings"],function(e,t,n,r,i){"use strict";function o(e,t,r){var o=t("-text-field");return i.wrapComponentClassAttribute(e),new n.CurlyComponentSyntax(e,o,r)}var s={create:function(e,t,s){var a=function(t){return e.getComponentDefinition([t],s)};if(!t.named.has("type"))return o(t,a,s);var u=t.named.at("type");if("value"===u.type){if("checkbox"===u.value){i.wrapComponentClassAttribute(t);var l=a("-checkbox");return new n.CurlyComponentSyntax(t,l,s)}return o(t,a,s)}return r.DynamicComponentSyntax.create(e,t,s)}};e.InputSyntax=s}),s("ember-glimmer/syntax/mount",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";var a=function(e){function n(t,n){e.call(this),this.definition=t,this.symbolTable=n}return babelHelpers.inherits(n,e),n.create=function(e,t,r){var i=t.positional.at(0).inner(),o=new c(i,e);return new n(o,r)},n.prototype.compile=function(e){e.component.static(this.definition,t.ArgsSyntax.empty(),null,this.symbolTable,null)},n}(t.StatementSyntax);e.MountSyntax=a;var u=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,r,i){var o=t.name,s=t.env;i.outletState=n.UNDEFINED_REFERENCE;var a=s.owner.buildChildEngineInstance(o);return a.boot(),{engine:a}},e.prototype.layoutFor=function(e,t,n){var r=t.engine,i=r.lookup("template:application");return n.getCompiledBlock(s.OutletLayoutCompiler,i)},e.prototype.getSelf=function(e){var t=e.engine,n=t._lookupFactory("controller:application")||o.generateControllerFactory(t,"application"); -return new i.RootReference(n.create())},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(e){var t=e.engine;return t},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e,t,n){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(e){},e}(),l=new u,c=function(e){function t(t,n){e.call(this,t,l,null),this.env=n}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/syntax/outlet",["exports","ember-utils","glimmer-runtime","ember-metal","ember-glimmer/utils/references","glimmer-reference"],function(e,t,n,r,i,o){"use strict";function s(e){var t=e.dynamicScope(),n=t.outletState,r=e.getArgs(),i=void 0;return i=0===r.positional.length?new o.ConstReference("main"):r.positional.at(0),new p(i,n)}function a(e,t,n){return t||n?!t&&n||t&&!n?null:n.render.template===t.render.template&&n.render.controller===t.render.controller?e:null:e}function u(e){var t=e.render,n=t.name,r=t.outlet;return{object:n+":"+r}}function l(){}var c=function(e){function t(t,r,i){e.call(this),this.definitionArgs=r,this.definition=s,this.args=n.ArgsSyntax.empty(),this.symbolTable=i,this.shadow=null}return babelHelpers.inherits(t,e),t.create=function(e,t,r){var i=n.ArgsSyntax.fromPositionalArgs(t.positional.slice(0,1));return new this(e,i,r)},t.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.OutletSyntax=c;var p=function(){function e(e,t){this.outletNameRef=e,this.parentOutletStateRef=t,this.definition=null,this.lastState=null;var n=this.outletStateTag=new o.UpdatableTag(t.tag);this.tag=o.combine([n.tag,e.tag])}return e.prototype.value=function(){var e=this.outletNameRef,t=this.parentOutletStateRef,n=this.definition,r=this.lastState,i=e.value(),o=t.get("outlets").get(i),s=this.lastState=o.value();this.outletStateTag.update(o.tag),n=a(n,r,s);var u=s&&s.render.template;return n?n:u?this.definition=new b(i,s.render.template):this.definition=null},e}(),h=function(){function e(e){this.outletState=e,this.instrument()}return e.prototype.instrument=function(){this.finalizer=r._instrumentStart("render.outlet",u,this.outletState)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=l},e}(),f=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,n,r){var i=r.outletState=r.outletState.get("outlets").get(t.outletName),o=i.value();return new h(o)},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(_,e.template)},e.prototype.getSelf=function(e){var t=e.outletState;return new i.RootReference(t.render.controller)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didRenderLayout=function(e){e.finalize()},e.prototype.didCreateElement=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e){},e.prototype.didUpdateLayout=function(e){},e.prototype.didUpdate=function(e){},e}(),m=new f,d=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){return new h(r.outletState.value())},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(y,e.template)},t}(f),g=new d,v=function(e){function n(n){e.call(this,"outlet",g,n),this.template=n.template,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition);e.TopLevelOutletComponentDefinition=v;var y=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.static("div"),e.attrs.static("id",t.guidFor(this)),e.attrs.static("class","ember-view")},e}();y.id="top-level-outlet";var b=function(e){function n(n,r){e.call(this,"outlet",m,null),this.outletName=n,this.template=r,t.generateGuid(this)}return babelHelpers.inherits(n,e),n}(n.ComponentDefinition),_=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout())},e}();e.OutletLayoutCompiler=_,_.id="outlet"}),s("ember-glimmer/syntax/render",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";function a(e){var t=e.env,r=e.getArgs(),i=r.positional.at(0),o=i.value(),s=t.owner.lookup("template:"+o),a=void 0;if(r.named.has("controller")){var u=r.named.get("controller");a=u.value()}else a=o;return 1===r.positional.length?new n.ConstReference(new m(a,s,t,p)):new n.ConstReference(new m(a,s,t,f))}var u=function(e){function n(n,r,i){e.call(this),this.definitionArgs=r,this.definition=a,this.args=t.ArgsSyntax.fromPositionalArgs(r.positional.slice(1,2)),this.symbolTable=i,this.shadow=null}return babelHelpers.inherits(n,e),n.create=function(e,t,n){return new this(e,t,n)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.RenderSyntax=u;var l=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(s.OutletLayoutCompiler,e.template)},e.prototype.getSelf=function(e){var t=e.controller;return new i.RootReference(t)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(){},e.prototype.update=function(){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(){},e}(),c=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=s.owner.lookup("controller:"+i)||o.generateController(s.owner,i);return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:a}},t}(l),p=new c,h=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=n.positional.at(0),u=s.owner._lookupFactory("controller:"+i)||o.generateControllerFactory(s.owner,i),l=u.create({model:a.value()});return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:l}},t.prototype.update=function(e,t,n){var r=e.controller;r.set("model",t.positional.at(0).value())},t.prototype.getDestructor=function(e){var t=e.controller;return t},t}(l),f=new h,m=function(e){function t(t,n,r,i){e.call(this,"render",i,null),this.name=t,this.template=n,this.env=r}return babelHelpers.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/template",["exports","ember-utils","glimmer-runtime"],function(e,t,n){"use strict";function r(e){var r=n.templateFactory(e);return{id:r.id,meta:r.meta,create:function(e){return r.create(e.env,{owner:e[t.OWNER]})}}}e.default=r}),s("ember-glimmer/template_registry",["exports"],function(e){"use strict";function t(e){s=e}function n(){return s}function r(e){if(s.hasOwnProperty(e))return s[e]}function i(e){return s.hasOwnProperty(e)}function o(e,t){return s[e]=t}e.setTemplates=t,e.getTemplates=n,e.getTemplate=r,e.hasTemplate=i,e.setTemplate=o;var s={}}),s("ember-glimmer/templates/component",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"ZoGfVsSJ",block:'{"statements":[["yield","default"]],"locals":[],"named":[],"yields":["default"],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/component.hbs"}})}),s("ember-glimmer/templates/empty",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"qEHL4OLi",block:'{"statements":[],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/empty.hbs"}})}),s("ember-glimmer/templates/link-to",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Ca7iQMR7",block:'{"statements":[["block",["if"],[["get",["linkTitle"]]],null,1,0]],"locals":[],"named":[],"yields":["default"],"blocks":[{"statements":[["yield","default"]],"locals":[]},{"statements":[["append",["unknown",["linkTitle"]],false]],"locals":[]}],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/link-to.hbs"}})}),s("ember-glimmer/templates/outlet",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"sYQo9vi/",block:'{"statements":[["append",["unknown",["outlet"]],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/outlet.hbs"}})}),s("ember-glimmer/templates/root",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Eaf3RPY3",block:'{"statements":[["append",["helper",["component"],[["get",[null]]],null],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/root.hbs"}})}),s("ember-glimmer/utils/bindings",["exports","glimmer-reference","glimmer-runtime","ember-metal","ember-runtime","ember-glimmer/component","ember-glimmer/utils/string"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return e[o.ROOT_REF].get(t)}function u(e,n){var r="attrs"===n[0];return r&&(n.shift(),1===n.length)?a(e,n[0]):t.referenceFromParts(e[o.ROOT_REF],n)}function l(e){var t=e.named,r=t.keys.indexOf("class");if(r!==-1){var i=t.values[r],o=i.ref,s=i.type;if("get"===s){var a=o.parts[o.parts.length-1];t.values[r]=n.HelperSyntax.fromSpec(["helper",["-class"],[["get",o.parts],a],null])}}return e}e.wrapComponentClassAttribute=l;var c={parse:function(e){var t=e.indexOf(":");if(t===-1)return[e,e,!0];var n=e.substring(0,t),r=e.substring(t+1);return[n,r,!1]},install:function(e,t,n,i){var o=n[0],s=n[1];n[2];if("id"===s){var l=r.get(t,o);return void 0!==l&&null!==l||(l=t.elementId),void i.addStaticAttribute(e,"id",l)}var c=o.indexOf(".")>-1,p=c?u(t,o.split(".")):a(t,o);"style"===s&&(p=new f(p,a(t,"isVisible"))),i.addDynamicAttribute(e,s,p)}};e.AttributeBinding=c;var p="display: none;",h=s.htmlSafe(p),f=function(e){function n(n,r){e.call(this),this.tag=t.combine([n.tag,r.tag]),this.inner=n,this.isVisible=r}return babelHelpers.inherits(n,e),n.prototype.compute=function(){var e=this.inner.value(),t=this.isVisible.value();if(t!==!1)return e;if(e||0===e){var n=e+" "+p;return s.isHTMLSafe(e)?s.htmlSafe(n):n}return h},n}(t.CachedReference),m={install:function(e,n,r){r.addDynamicAttribute(e,"style",t.map(a(n,"isVisible"),this.mapStyleValue))},mapStyleValue:function(e){return e===!1?h:null}};e.IsVisibleBinding=m;var d={install:function(e,t,n,r){var i=n.split(":"),o=i[0],s=i[1],l=i[2],c=""===o;if(c)r.addStaticAttribute(e,"class",s);else{var p=o.indexOf(".")>-1,h=p&&o.split("."),f=p?u(t,h):a(t,o),m=void 0;m=void 0===s?new g(f,p?h[h.length-1]:o):new v(f,s,l),r.addDynamicAttribute(e,"class",m)}}};e.ClassNameBinding=d;var g=function(e){function t(t,n){e.call(this),this.tag=t.tag,this.inner=t,this.path=n,this.dasherizedPath=null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner.value();if(e===!0){var t=this.path,n=this.dasherizedPath;return n||(this.dasherizedPath=i.String.dasherize(t))}return e||0===e?e:null},t}(t.CachedReference),v=function(e){function t(t,n,r){e.call(this),this.tag=t.tag,this.inner=t,this.truthy=n||null,this.falsy=r||null}return babelHelpers.inherits(t,e),t.prototype.compute=function(){var e=this.inner,t=this.truthy,n=this.falsy;return e.value()?t:n},t}(t.CachedReference)}),s("ember-glimmer/utils/iterable",["exports","ember-utils","ember-metal","ember-runtime","ember-glimmer/utils/references","ember-glimmer/helpers/each-in","glimmer-reference"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return o.isEachIn(e)?new b(e,u(t)):new _(e,l(t))}function u(e){switch(e){case"@index":case void 0:case null:return c;case"@identity":return p;default:return function(t){return n.get(t,e)}}}function l(e){switch(e){case"@index":return c;case"@identity":case void 0:case null:return p;default:return function(t){return n.get(t,e)}}}function c(e,t){return String(t)}function p(e){switch(typeof e){case"string":case"number":return String(e);default:return t.guidFor(e)}}function h(e,t){var n=e[t];return n?(e[t]++,""+t+f+n):(e[t]=1,t)}e.default=a;var f="be277757-bbbe-4620-9fcb-213ef433cca2",m=function(){function e(e,n){this.array=e,this.length=e.length,this.keyFor=n,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return!1},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,r=this.position,i=this.seen;if(r>=t)return null;var o=e[r],s=r,a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),d=function(){function e(e,r){this.array=e,this.length=n.get(e,"length"),this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.length},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,i=this.position,o=this.seen;if(i>=t)return null;var s=r.objectAt(e,i),a=i,u=h(o,n(s,a));return this.position++,{key:u,value:s,memo:a}},e}(),g=function(){function e(e,n,r){this.keys=e,this.values=n,this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.keys.length},e.prototype.next=function(){var e=this.keys,t=this.values,n=this.keyFor,r=this.position,i=this.seen;if(r>=e.length)return null;var o=t[r],s=e[r],a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),v=function(){function e(){}return e.prototype.isEmpty=function(){return!0},e.prototype.next=function(){throw new Error("Cannot call next() on an empty iterator")},e}(),y=new v,b=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,r=this.valueTag,i=e.value();r.update(n.tagFor(i)),n.isProxy(i)&&(i=n.get(i,"content"));var o=typeof i;if(!i||"object"!==o&&"function"!==o)return y;var s=Object.keys(i),a=s.map(function(e){return i[e]});return s.length>0?new g(s,a,t):y},e.prototype.valueReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateValueReference=function(e,t){e.update(t.memo)},e.prototype.memoReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateMemoReference=function(e,t){e.update(t.value)},e}(),_=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,i=this.valueTag,o=e.value();if(i.update(n.tagForProperty(o,"[]")),!o||"object"!=typeof o)return y;if(Array.isArray(o))return o.length>0?new m(o,t):y;if(r.isEmberArray(o))return n.get(o,"length")>0?new d(o,t):y;if("function"!=typeof o.forEach)return y;var s=function(){var e=[];return o.forEach(function(t){e.push(t)}),{v:e.length>0?new m(e,t):y}}();return"object"==typeof s?s.v:void 0},e.prototype.valueReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateValueReference=function(e,t){e.update(t.value)},e.prototype.memoReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateMemoReference=function(e,t){e.update(t.memo)},e}()}),s("ember-glimmer/utils/process-args",["exports","ember-utils","glimmer-reference","ember-glimmer/component","ember-glimmer/utils/references","ember-views","ember-glimmer/helpers/action","glimmer-runtime"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t){var n=l(e,t),r=c(e,t);return p(n,r,e.blocks,t.ComponentClass)}function l(e,n){var r=e.named.map;return n.args?t.assign({},n.args.named.map,r):r}function c(e,t){var n=e.positional.values;if(t.args){var r=t.args.positional.values,i=[];return i.push.apply(i,r),i.splice.apply(i,[0,n.length].concat(n)),i}return n}function p(e,t,n,r){var i=r.positionalParams;return i&&i.length>0&&t.length>0&&(e="string"==typeof i?h(e,t,i):f(e,t,i)),a.EvaluatedArgs.named(e,n)}function h(e,n,r){var i=t.assign({},e);return i[r]=a.EvaluatedPositionalArgs.create(n),i}function f(e,n,r){for(var i=t.assign({},e),o=Math.min(n.length,r.length),s=0;s":">",'"':""","'":"'","`":"`","=":"="},l=/[&<>"'`=]/,c=/[&<>"'`=]/g}),s("ember-glimmer/utils/to-bool",["exports","ember-runtime","ember-metal"],function(e,t,n){"use strict";function r(e){return!!e&&(e===!0||(!t.isArray(e)||0!==n.get(e,"length")))}e.default=r}),s("ember-glimmer/views/outlet",["exports","ember-utils","glimmer-reference","ember-environment","ember-metal"],function(e,t,n,r,i){"use strict";var o=function(){function e(e){this.outletView=e,this.tag=e._tag}return e.prototype.get=function(e){return new a(this,e)},e.prototype.value=function(){return this.outletView.outletState},e.prototype.getOrphan=function(e){return new s(this,e)},e.prototype.update=function(e){this.outletView.setOutletState(e)},e}(),s=function(e){function n(t,n){e.call(this,t.outletView),this.root=t,this.name=n}return babelHelpers.inherits(n,e),n.prototype.value=function(){var e=this.root.value(),n=e.outlets.main.outlets.__ember_orphans__;if(!n)return null;var r=n.outlets[this.name];if(!r)return null;var i=new t.EmptyObject;return i[r.render.outlet]=r,r.wasUsed=!0,{outlets:i}},n}(o),a=function(){function e(e,t){this.parent=e,this.key=t,this.tag=e.tag}return e.prototype.get=function(t){return new e(this,t)},e.prototype.value=function(){return this.parent.value()[this.key]},e}(),u=function(){function e(e,t,r,i){this._environment=e,this.renderer=t,this.owner=r,this.template=i,this.outletState=null,this._tag=new n.DirtyableTag}return e.extend=function(n){return function(e){function r(){e.apply(this,arguments)}return babelHelpers.inherits(r,e),r.create=function(r){return r?e.create.call(this,t.assign({},n,r)):e.create.call(this,n)},r}(e)},e.reopenClass=function(e){t.assign(this,e)},e.create=function(n){var r=n._environment,i=n.renderer,o=n.template,s=n[t.OWNER];return new e(r,i,s,o)},e.prototype.appendTo=function(e){var t=this._environment||r.environment,n=void 0;n=t.hasDOM&&"string"==typeof e?document.querySelector(e):e,i.run.schedule("render",this.renderer,"appendOutletView",this,n)},e.prototype.rerender=function(){},e.prototype.setOutletState=function(e){this.outletState={outlets:{main:e},render:{owner:void 0,into:void 0,outlet:"main",name:"-top-level",controller:void 0,ViewClass:void 0,template:void 0}},this._tag.dirty()},e.prototype.toReference=function(){return new o(this)},e.prototype.destroy=function(){},e}();e.default=u}),s("ember-metal/alias",["exports","ember-utils","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/properties","ember-metal/computed","ember-metal/meta","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e){return new p(e)}function p(e){this.isDescriptor=!0,this.altKey=e,this._dependentKeys=[e]}function h(e,n,r){throw new o.default("Cannot set read-only property '"+n+"' on object: "+t.inspect(e))}function f(e,t,n){return s.defineProperty(e,t,null),i.set(e,t,n)}e.default=c,e.AliasedProperty=p,p.prototype=Object.create(s.Descriptor.prototype),p.prototype.setup=function(e,t){var n=u.meta(e);n.peekWatching(t)&&l.addDependentKeys(this,e,t,n)},p.prototype._addDependentKeyIfMissing=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)||l.addDependentKeys(this,e,t,n)},p.prototype._removeDependentKeyIfAdded=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)&&l.removeDependentKeys(this,e,t,n)},p.prototype.willWatch=p.prototype._addDependentKeyIfMissing,p.prototype.didUnwatch=p.prototype._removeDependentKeyIfAdded,p.prototype.teardown=p.prototype._removeDependentKeyIfAdded,p.prototype.get=function(e,t){return this._addDependentKeyIfMissing(e,t),r.get(e,this.altKey)},p.prototype.set=function(e,t,n){return i.set(e,this.altKey,n)},p.prototype.readOnly=function(){return this.set=h,this},p.prototype.oneWay=function(){return this.set=f,this},p.prototype._meta=void 0,p.prototype.meta=a.ComputedProperty.prototype.meta}),s("ember-metal/binding",["exports","ember-utils","ember-console","ember-environment","ember-metal/run_loop","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/events","ember-metal/observer","ember-metal/path_cache"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(e,t){this._from=t,this._to=e,this._oneWay=void 0,this._direction=void 0,this._readyToSync=void 0,this._fromObj=void 0,this._fromPath=void 0,this._toObj=void 0}function h(e,t,n,r,i,o){}function f(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function m(e,t,n){return new p(t,n).connect(e)}e.bind=m,p.prototype={copy:function(){var e=new p(this._to,this._from);return this._oneWay&&(e._oneWay=!0),e},from:function(e){return this._from=e,this},to:function(e){return this._to=e,this},oneWay:function(){return this._oneWay=!0,this},toString:function(){var e=this._oneWay?"[oneWay]":"";return"Ember.Binding<"+t.guidFor(this)+">("+this._from+" -> "+this._to+")"+e},connect:function(e){var t=void 0,n=void 0,i=void 0;if(c.isGlobalPath(this._from)){var o=c.getFirstKey(this._from);i=r.context.lookup[o],i&&(t=i,n=c.getTailPath(this._from))}return void 0===t&&(t=e,n=this._from),a.trySet(e,this._to,s.get(t,n)),l.addObserver(t,n,this,"fromDidChange"),this._oneWay||l.addObserver(e,this._to,this,"toDidChange"),u.addListener(e,"willDestroy",this,"disconnect"),h(e,this._to,this._from,i,this._oneWay,!i&&!this._oneWay),this._readyToSync=!0,this._fromObj=t,this._fromPath=n,this._toObj=e,this},disconnect:function(){return l.removeObserver(this._fromObj,this._fromPath,this,"fromDidChange"),this._oneWay||l.removeObserver(this._toObj,this._to,this,"toDidChange"),this._readyToSync=!1,this},fromDidChange:function(e){this._scheduleSync("fwd")},toDidChange:function(e){this._scheduleSync("back")},_scheduleSync:function(e){var t=this._direction;void 0===t&&(i.default.schedule("sync",this,"_sync"),this._direction=e),"back"===t&&"fwd"===e&&(this._direction="fwd")},_sync:function(){var e=r.ENV.LOG_BINDINGS,t=this._toObj;if(!t.isDestroyed&&this._readyToSync){var i=this._direction,o=this._fromObj,u=this._fromPath;if(this._direction=void 0,"fwd"===i){var c=s.get(o,u);e&&n.default.log(" ",this.toString(),"->",c,o),this._oneWay?a.trySet(t,this._to,c):l._suspendObserver(t,this._to,this,"toDidChange",function(){a.trySet(t,this._to,c)})}else if("back"===i){var p=s.get(t,this._to);e&&n.default.log(" ",this.toString(),"<-",p,t),l._suspendObserver(o,u,this,"fromDidChange",function(){a.trySet(o,u,p)})}}}},f(p,{from:function(e){var t=this;return new t(void 0,e)},to:function(e){var t=this;return new t(e,void 0)}}),e.Binding=p}),s("ember-metal/cache",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";var r=function(){function e(e,t,n,r){this.size=0,this.misses=0,this.hits=0,this.limit=e,this.func=t,this.key=n,this.store=r||new i}return e.prototype.get=function(e){var t=void 0===this.key?e:this.key(e),r=this.store.get(t);return void 0===r?(this.misses++,r=this._set(t,this.func(e))):r===n.UNDEFINED?(this.hits++,r=void 0):this.hits++,r},e.prototype.set=function(e,t){var n=void 0===this.key?e:this.key(e);return this._set(n,t)},e.prototype._set=function(e,t){return this.limit>this.size&&(this.size++,void 0===t?this.store.set(e,n.UNDEFINED):this.store.set(e,t)),t},e.prototype.purge=function(){this.store.clear(),this.size=0,this.hits=0,this.misses=0},e}();e.default=r;var i=function(){function e(){this.data=new t.EmptyObject}return e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e.prototype.clear=function(){this.data=new t.EmptyObject},e}()}),s("ember-metal/chains",["exports","ember-utils","ember-metal/property_get","ember-metal/meta","ember-metal/watch_key","ember-metal/watch_path"],function(e,t,n,r,i,o){"use strict";function s(e){return e.match(g)[0]}function a(e){return"object"==typeof e&&e}function u(e){return!(a(e)&&e.isDescriptor&&e._volatile===!1)}function l(){this.chains=new t.EmptyObject}function c(){return new l}function p(e,t,n){var o=r.meta(e);o.writableChainWatchers(c).add(t,n),i.watchKey(e,t,o)}function h(e,t,n,o){if(a(e)){var s=o||r.peekMeta(e);s&&s.readableChainWatchers()&&(s=r.meta(e),s.readableChainWatchers().remove(t,n),i.unwatchKey(e,t,s))}}function f(e,t,n){if(this._parent=e,this._key=t,this._watching=void 0===n,this._chains=void 0,this._object=void 0,this.count=0,this._value=n,this._paths={},this._watching){var r=e.value();if(!a(r))return;this._object=r,p(this._object,this._key,this)}}function m(e,t){if(a(e)){var i=r.peekMeta(e);if(!i||i.proto!==e){if(u(e[t]))return n.get(e,t);var o=i.readableCache();return o&&t in o?o[t]:void 0}}}function d(e){var t=r.peekMeta(e);if(t){t=r.meta(e);var n=t.readableChainWatchers();n&&n.revalidateAll(),t.readableChains()&&t.writableChains(o.makeChainNode)}}e.finishChains=d;var g=/^([^\.]+)/;l.prototype={add:function(e,t){var n=this.chains[e];void 0===n?this.chains[e]=[t]:n.push(t)},remove:function(e,t){var n=this.chains[e];if(n)for(var r=0;r0&&t[e]--;var n=s(e),r=e.slice(n.length+1);this.unchain(n,r)},chain:function(e,n){var r=this._chains,i=void 0;void 0===r?r=this._chains=new t.EmptyObject:i=r[e],void 0===i&&(i=r[e]=new f(this,e,void 0)),i.count++,n&&(e=s(n),n=n.slice(e.length+1),i.chain(e,n))},unchain:function(e,t){var n=this._chains,r=n[e];if(t&&t.length>1){var i=s(t),o=t.slice(i.length+1);r.unchain(i,o)}r.count--,r.count<=0&&(n[r._key]=void 0,r.destroy())},notify:function(e,t){if(e&&this._watching){var n=this._parent.value();n!==this._object&&(this._object&&h(this._object,this._key,this),a(n)?(this._object=n,p(n,this._key,this)):this._object=void 0),this._value=void 0}var r=this._chains,i=void 0;if(r)for(var o in r)i=r[o],void 0!==i&&i.notify(e,t);t&&this._parent&&this._parent.populateAffected(this._key,1,t)},populateAffected:function(e,t,n){this._key&&(e=this._key+"."+e),this._parent?this._parent.populateAffected(e,t+1,n):t>1&&n.push(this.value(),e)}},e.removeChainWatcher=h,e.ChainNode=f}),s("ember-metal/computed",["exports","ember-utils","ember-metal/debug","ember-metal/property_set","ember-metal/meta","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e,t){this.isDescriptor=!0,"function"==typeof e?this._getter=e:(this._getter=e.get,this._setter=e.set),this._dependentKeys=void 0,this._suspended=void 0,this._meta=void 0,this._volatile=!1,this._dependentKeys=t&&t.dependentKeys,this._readOnly=!1}function p(e){var t=void 0;arguments.length>1&&(t=[].slice.call(arguments),e=t.pop());var n=new c(e);return t&&n.property.apply(n,t),n}function h(e,t){var n=i.peekMeta(e),r=n&&n.source===e&&n.readableCache(),o=r&&r[t];if(o!==i.UNDEFINED)return o}e.default=p;c.prototype=new a.Descriptor,c.prototype.constructor=c;var f=c.prototype;f.volatile=function(){return this._volatile=!0,this},f.readOnly=function(){return this._readOnly=!0,this},f.property=function(){function e(e){t.push(e)}for(var t=[],n=0;n=0;i-=3)if(t===e[i]&&n===e[i+1]){r=i;break}return r}function s(e,t,n){var i=r.peekMeta(e);if(i){for(var s=i.matchingListeners(t),a=[],u=s.length-3;u>=0;u-=3){var l=s[u],c=s[u+1],p=s[u+2],h=o(n,l,c);h===-1&&(n.push(l,c,p),a.push(l,c,p))}return a}}function a(e,t,n,o,s){o||"function"!=typeof n||(o=n,n=null);var a=0;s&&(a|=i.ONCE),r.meta(e).addToListeners(t,n,o,a),"function"==typeof e.didAddListener&&e.didAddListener(t,n,o)}function u(e,t,n,i){i||"function"!=typeof n||(i=n,n=null),r.meta(e).removeFromListeners(t,n,i,function(){"function"==typeof e.didRemoveListener&&e.didRemoveListener.apply(e,arguments)})}function l(e,t,n,r,i){return c(e,[t],n,r,i)}function c(e,t,n,i,o){return i||"function"!=typeof n||(i=n,n=null),r.meta(e).suspendListeners(t,n,i,o)}function p(e){return r.meta(e).watchedEvents()}function h(e,n,o,s){if(!s){var a=r.peekMeta(e);s=a&&a.matchingListeners(n)}if(s&&0!==s.length){for(var l=s.length-3;l>=0;l-=3){var c=s[l],p=s[l+1],h=s[l+2];p&&(h&i.SUSPENDED||(h&i.ONCE&&u(e,n,c,p),c||(c=e),"string"==typeof p?o?t.applyStr(c,p,o):c[p]():o?p.apply(c,o):p.call(c)))}return!0}}function f(e,t){var n=r.peekMeta(e);return!!n&&n.matchingListeners(t).length>0}function m(e,t){var n=[],i=r.peekMeta(e),o=i&&i.matchingListeners(t);if(!o)return n;for(var s=0;s=0&&(s=r(s,u.split(","),a))}for(var a=0;a-1&&o.splice(s,1),this.size=o.length,!0}return!1},isEmpty:function(){return 0===this.size},has:function(e){if(0===this.size)return!1;var n=t.guidFor(e),r=this.presenceSet;return r[n]===!0},forEach:function(e){if("function"!=typeof e&&n(e),0!==this.size){var t=this.list;if(2===arguments.length)for(var r=0;r0;){if(e=O.pop(),t=e._chains)for(n in t)void 0!==t[n]&&O.push(t[n]);if(e._watching&&(r=e._object)){var i=N(r);i&&!i.isSourceDestroying()&&o.removeChainWatcher(r,e._key,e,i)}}this.setMetaDestroyed()}};for(var S in r.protoMethods)s.prototype[S]=r.protoMethods[S];w.forEach(function(e){return g[e](e,s)}),s.prototype.isSourceDestroying=function(){return 0!==(this._flags&v)},s.prototype.setSourceDestroying=function(){this._flags|=v},s.prototype.isSourceDestroyed=function(){return 0!==(this._flags&y)},s.prototype.setSourceDestroyed=function(){this._flags|=y},s.prototype.isMetaDestroyed=function(){return 0!==(this._flags&b)},s.prototype.setMetaDestroyed=function(){this._flags|=b},s.prototype.isProxy=function(){return 0!==(this._flags&_)},s.prototype.setProxy=function(){this._flags|=_},s.prototype._getOrCreateOwnMap=function(e){var n=this[e];return n||(n=this[e]=new t.EmptyObject),n},s.prototype._getInherited=function(e){for(var t=this;void 0!==t;){if(t[e])return t[e];t=t.parent}},s.prototype._findInherited=function(e,t){for(var n=this;void 0!==n;){var r=n[e];if(r){var i=r[t];if(void 0!==i)return i}n=n.parent}};var x=t.symbol("undefined");e.UNDEFINED=x,s.prototype.writeDeps=function(e,n,r){var i=this._getOrCreateOwnMap("_deps"),o=i[e];o||(o=i[e]=new t.EmptyObject),o[n]=r},s.prototype.peekDeps=function(e,t){for(var n=this;void 0!==n;){var r=n._deps;if(r){var i=r[e];if(i&&void 0!==i[t])return i[t]}n=n.parent}},s.prototype.hasDeps=function(e){for(var t=this;void 0!==t;){if(t._deps&&t._deps[e])return!0;t=t.parent}return!1},s.prototype.forEachInDeps=function(e,t){return this._forEachIn("_deps",e,t)},s.prototype._forEachIn=function(e,n,r){for(var i=this,o=new t.EmptyObject,s=[];void 0!==i;){var a=i[e];if(a){var u=a[n];if(u)for(var l in u)o[l]||(o[l]=!0,s.push([l,u[l]]))}i=i.parent}for(var c=0;c=0;s-=4)if(o[s]===e&&(!n||o[s+1]===t&&o[s+2]===n)){if(i!==this)return this._finalizeListeners(),this.removeFromListeners(e,t,n);"function"==typeof r&&r(e,t,o[s+2]),o.splice(s,4)}if(i._listenersFinalized)break;i=i.parent}},matchingListeners:function(e){for(var n=this,i=[];n;){var o=n._listeners;if(o)for(var s=0;s=0;o-=3)i[o+1]===t&&i[o+2]===n&&e.indexOf(i[o])!==-1&&i.splice(o,3)}},watchedEvents:function(){for(var e=this,t={};e;){var n=e._listeners;if(n)for(var r=0;r=0||"concatenatedProperties"===t||"mergedProperties"===t?n=v(e,t,n,o):u&&u.indexOf(t)>=0?n=y(e,t,n,o):h(n)&&(n=g(e,t,n,o,i)),i[t]=void 0,o[t]=n}function _(e,t,n,r,i,o){function s(e){delete n[e],delete r[e]}for(var a=void 0,u=void 0,l=void 0,c=void 0,p=void 0,h=0;h7&&66===e.charCodeAt(t-7)&&e.indexOf("inding",t-6)!==-1}function E(e,t){t.forEachBindings(function(t,n){if(n){var r=t.slice(0,-7);n instanceof u.Binding?(n=n.copy(),n.to(r)):n=new u.Binding(r,n),n.connect(e),e[t]=n}}),t.clearBindings()}function O(e,t){return E(e,t||i.meta(e)),e}function S(e,t,n,r,i){var o=t.methodName,s=void 0,a=void 0;return r[o]||i[o]?(s=i[o],t=r[o]):(a=e[o])&&null!==a&&"object"==typeof a&&a.isDescriptor?(t=a,s=void 0):(t=void 0,s=e[o]),{desc:t,value:s}}function x(e,t,n,r,i){var o=n[r];if(o)for(var s=0;s1?t-1:0),r=1;r0){for(var i=new Array(r),o=0;o=0;)if(P(o[s],n,r))return!0;return!1}function D(e,n,r){if(!r[t.guidFor(n)])if(r[t.guidFor(n)]=!0,n.properties)for(var i=Object.keys(n.properties),o=0;o0,l&&l.teardown(e,t),n instanceof o)p=n,e[t]=p,n.setup&&n.setup(e,t);else if(null==n){p=s;e[t]=s}else p=n,Object.defineProperty(e,t,n);return c&&i.overrideChains(e,t,a),e.didDefineProperty&&e.didDefineProperty(e,t,p),this}e.Descriptor=o,e.MANDATORY_SETTER_FUNCTION=s,e.DEFAULT_GETTER_FUNCTION=a,e.INHERITING_GETTER_FUNCTION=u,e.defineProperty=l;(function(){var e=Object.create(Object.prototype,{prop:{configurable:!0,value:1}});return Object.defineProperty(e,"prop",{configurable:!0,value:2}),2===e.prop})()}),s("ember-metal/property_events",["exports","ember-utils","ember-metal/meta","ember-metal/events","ember-metal/tags","ember-metal/observer_set","ember-metal/features","ember-metal/transaction"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t,r){var i=r||n.peekMeta(e);if(!i||i.isInitialized(e)){var o=i&&i.peekWatching(t)>0,s=e[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0;a&&a.willChange&&a.willChange(e,t),o&&(c(e,t,i),f(e,t,i),b(e,t,i))}}function l(e,t,r){var o=r||n.peekMeta(e);if(!o||o.isInitialized(e)){var s=o&&o.peekWatching(t)>0,a=e[t],u=null!==a&&"object"==typeof a&&a.isDescriptor?a:void 0;u&&u.didChange&&u.didChange(e,t),s&&(o.hasDeps(t)&&p(e,t,o),m(e,t,o,!1),_(e,t,o)),e[w]&&e[w](t),o&&o.isSourceDestroying()||i.markObjectAsDirty(o,t)}}function c(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=x,i=!r;i&&(r=x={}),h(u,e,t,r,n),i&&(x=null)}}function p(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=C,i=!r;i&&(r=C={}),h(l,e,t,r,n),i&&(C=null)}}function h(e,n,r,i,o){var s=void 0,a=void 0,u=t.guidFor(n),l=i[u];l||(l=i[u]={}),l[r]||(l[r]=!0,o.forEachInDeps(r,function(t,r){r&&(s=n[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0,a&&a._suspended===n||e(n,t,o))}))}function f(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!1,u)}function m(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!0,l)}function d(e,t,n){var r=n.readableChainWatchers();r&&r.revalidate(t)}function g(){S++}function v(){S--,S<=0&&(E.clear(),O.flush())}function y(e,t){g();try{e.call(t)}finally{v.call(t)}}function b(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":before",o=void 0,s=void 0;S?(o=E.add(e,t,i),s=r.accumulateListeners(e,i,o),r.sendEvent(e,i,[e,t],s)):r.sendEvent(e,i,[e,t])}}function _(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":change",o=void 0;S?(o=O.add(e,t,i),r.accumulateListeners(e,i,o)):r.sendEvent(e,i,[e,t])}}var w=t.symbol("PROPERTY_DID_CHANGE");e.PROPERTY_DID_CHANGE=w;var E=new o.default,O=new o.default,S=0,x=void 0,C=void 0;e.propertyWillChange=u,e.propertyDidChange=l,e.overrideChains=d,e.beginPropertyChanges=g,e.endPropertyChanges=v,e.changeProperties=y}),s("ember-metal/property_get",["exports","ember-metal/debug","ember-metal/path_cache"],function(e,t,n){"use strict";function r(e,t){var r=e[t],o=null!==r&&"object"==typeof r&&r.isDescriptor?r:void 0,s=void 0;return void 0===o&&n.isPath(t)?i(e,t):o?o.get(e,t):(s=r,void 0!==s||"object"!=typeof e||t in e||"function"!=typeof e.unknownProperty?s:e.unknownProperty(t))}function i(e,t){for(var n=e,i=t.split("."),s=0;sa?a:l,c<=0&&(c=0),p=o.splice(0,a),p=[u,c].concat(p),u+=a,l-=c,s=s.concat(n.apply(e,p));return s}e.default=t;var n=Array.prototype.splice}),s("ember-metal/run_loop",["exports","ember-utils","ember-metal/debug","ember-metal/testing","ember-metal/error_handler","ember-metal/property_events","backburner"],function(e,t,n,r,i,o,s){"use strict";function a(e){l.currentRunLoop=e}function u(e,t){l.currentRunLoop=t}function l(){return p.run.apply(p,arguments)}e.default=l;var c={get onerror(){return i.getOnerror()},set onerror(e){return i.setOnerror(e)}},p=new s.default(["sync","actions","destroy"],{GUID_KEY:t.GUID_KEY,sync:{before:o.beginPropertyChanges,after:o.endPropertyChanges},defaultQueue:"actions",onBegin:a,onEnd:u,onErrorTarget:c,onErrorMethod:"onerror"});l.join=function(){return p.join.apply(p,arguments)},l.bind=function(){for(var e=arguments.length,t=Array(e),n=0;n1&&i.writeWatching(t,o-1)}}}e.watchKey=o,e.unwatchKey=s}),s("ember-metal/watch_path",["exports","ember-metal/meta","ember-metal/chains"],function(e,t,n){"use strict";function r(e,n){return(n||t.meta(e)).writableChains(i)}function i(e){return new n.ChainNode(null,null,e)}function o(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;s?o.writeWatching(n,s+1):(o.writeWatching(n,1),r(e,o).add(n))}}function s(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;1===s?(o.writeWatching(n,0),r(e,o).remove(n)):s>1&&o.writeWatching(n,s-1)}}e.makeChainNode=i,e.watchPath=o,e.unwatchPath=s}),s("ember-metal/watching",["exports","ember-metal/watch_key","ember-metal/watch_path","ember-metal/path_cache","ember-metal/meta"],function(e,t,n,r,i){"use strict";function o(e,i,o){r.isPath(i)?n.watchPath(e,i,o):t.watchKey(e,i,o)}function s(e,t){if("object"!=typeof e||null===e)return!1;var n=i.peekMeta(e);return(n&&n.peekWatching(t))>0}function a(e,t){var n=i.peekMeta(e);return n&&n.peekWatching(t)||0}function u(e,i,o){r.isPath(i)?n.unwatchPath(e,i,o):t.unwatchKey(e,i,o)}function l(e){i.deleteMeta(e)}e.isWatching=s,e.watcherCount=a,e.unwatch=u,e.destroy=l,e.watch=o}),s("ember-metal/weak_map",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";function r(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e){if(!(this instanceof i))throw new TypeError("Constructor WeakMap requires 'new'");if(this._id=t.GUID_KEY+o++,null!==e&&void 0!==e){if(!Array.isArray(e))throw new TypeError("The weak map constructor polyfill only supports an array argument");for(var n=0;n7)}function a(e,t){return(e.indexOf("Android 2.")===-1&&e.indexOf("Android 4.0")===-1||e.indexOf("Mobile Safari")===-1||e.indexOf("Chrome")!==-1||e.indexOf("Windows Phone")!==-1)&&!!(t&&"pushState"in t)}function u(e,t){e.replace(o(e)+t)}e.getPath=t,e.getQuery=n,e.getHash=r,e.getFullPath=i,e.getOrigin=o,e.supportsHashChange=s,e.supportsHistory=a,e.replacePath=u}),s("ember-routing/services/routing",["exports","ember-utils","ember-runtime","ember-metal","ember-routing/utils"],function(e,t,n,r,i){"use strict";function o(e,t){for(var n=0,r=0;rc&&(n=l),i.isActiveIntent(n,e,t,!s)}})}),s("ember-routing/system/cache",["exports","ember-utils","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({init:function(){this.cache=new t.EmptyObject},has:function(e){return!!this.cache[e]},stash:function(e,n,r){var i=this.cache[e];i||(i=this.cache[e]=new t.EmptyObject),i[n]=r},lookup:function(e,t,n){var r=this.cache;if(!this.has(e))return n;var i=r[e];return t in i&&void 0!==i[t]?i[t]:n}})}),s("ember-routing/system/controller_for",["exports"],function(e){"use strict";function t(e,t,n){return e.lookup("controller:"+t,n)}e.default=t}),s("ember-routing/system/dsl",["exports","ember-utils","ember-metal"],function(e,t,n){"use strict";function r(e,t){this.parent=e,this.enableLoadingSubstates=t&&t.enableLoadingSubstates,this.matches=[],this.explicitIndex=void 0,this.options=t}function i(e){return e.parent&&"application"!==e.parent}function o(e,t,n){return i(e)&&n!==!0?e.parent+"."+t:t}function s(e,t,n,r){n=n||{};var i=o(e,t,n.resetNamespace);"string"!=typeof n.path&&(n.path="/"+t),e.push(n.path,i,r,n.serialize)}e.default=r,r.prototype={route:function(e,t,n){var i="/_unused_dummy_error_path_route_"+e+"/:error";if(2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),this.enableLoadingSubstates&&(s(this,e+"_loading",{resetNamespace:t.resetNamespace}),s(this,e+"_error",{resetNamespace:t.resetNamespace,path:i})),n){var a=o(this,e,t.resetNamespace),u=new r(a,this.options);s(u,"loading"),s(u,"error",{path:i}),n.call(u),s(this,e,t,u.generate())}else s(this,e,t)},push:function(e,n,r,i){var o=n.split(".");if(this.options.engineInfo){var s=n.slice(this.options.engineInfo.fullName.length+1),a=t.assign({localFullName:s},this.options.engineInfo);i&&(a.serializeMethod=i),this.options.addRouteForEngine(n,a)}else if(i)throw new Error("Defining a route serializer on route '"+n+"' outside an Engine is not allowed.");""!==e&&"/"!==e&&"index"!==o[o.length-1]||(this.explicitIndex=!0),this.matches.push([e,n,r])},resource:function(e,t,n){2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),t.resetNamespace=!0,this.route(e,t,n)},generate:function(){var e=this.matches;return this.explicitIndex||this.route("index",{path:"/"}),function(t){for(var n=0;n0&&(this.connections=[],n.run.once(this.router,"_setOutlets"))}});r.deprecateUnderscoreActions(_),_.reopenClass({isRouteFactory:!0}),e.default=_}),s("ember-routing/system/router",["exports","ember-utils","ember-console","ember-metal","ember-runtime","ember-routing/system/route","ember-routing/system/dsl","ember-routing/location/api","ember-routing/utils","ember-routing/system/router_state","router"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(){return this}function h(e,t,n){for(var r=!1,i=t.length-1;i>=0;--i){var o=t[i],s=o.handler;if(e===s&&(r=!0),r&&n(s)!==!0)return}}function f(e,t){var r=[],i=void 0;i=e&&"object"==typeof e&&"object"==typeof e.errorThrown?e.errorThrown:e,t&&r.push(t),i&&(i.message&&r.push(i.message),i.stack&&r.push(i.stack),"string"==typeof i&&r.push(i)),n.default.error.apply(this,r)}function m(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s=o+"_"+n,a=e.fullRouteName,u=a+"_"+n;return g(i,r,s,u)?u:""}function d(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s="application"===o?n:o+"."+n,a=e.fullRouteName,u="application"===a?n:a+"."+n;return g(i,r,s,u)?u:""}function g(e,t,n,r){var i=t.hasRoute(r),o=e.hasRegistration("template:"+n)||e.hasRegistration("route:"+n);return i&&o}function v(e,n,i){var o=i.shift();if(!e){if(n)return;throw new r.Error("Can't trigger action '"+o+"' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.")}for(var s=!1,a=void 0,u=void 0,l=e.length-1;l>=0;l--)if(a=e[l],u=a.handler,u&&u.actions&&u.actions[o]){if(u.actions[o].apply(u,i)!==!0){if("error"===o){var c=t.guidFor(i[0]);u.router._markErrorAsHandled(c)}return}s=!0}if(T[o])return void T[o].apply(null,i);if(!s&&!n)throw new r.Error("Nothing handled the action '"+o+"'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.")}function y(e,t,n){for(var r=e.router,i=r.applyIntent(t,n),o=i.handlerInfos,s=i.params,a=0;a0;){var r=n.shift();if(r.render.name===t)return r;var i=r.outlets;for(var o in i)n.push(i[o])}}function S(e,n,i){var o=void 0,s={render:i,outlets:new t.EmptyObject,wasUsed:!1};return o=i.into?O(e,i.into):n,o?r.set(o.outlets,i.outlet,s):i.into?x(e,i.into,s):e=s,{liveRoutes:e,ownState:s}}function x(e,n,i){e.outlets.__ember_orphans__||(e.outlets.__ember_orphans__={render:{name:"__ember_orphans__"},outlets:new t.EmptyObject}),e.outlets.__ember_orphans__.outlets[n]=i,r.run.schedule("afterRender",function(){})}function C(e,t,n){var r=O(e,n.routeName);return r?r:(t.outlets.main={render:{name:n.routeName,outlet:"main"},outlets:{}},t)}e.triggerEvent=v;var A=Array.prototype.slice,k=i.Object.extend(i.Evented,{location:"hash",rootURL:"/",_initRouterJs:function(){var e=this.router=new c.default;e.triggerEvent=v,e._triggerWillChangeContext=p,e._triggerWillLeave=p;var t=this.constructor.dslCallbacks||[p],i=this._buildDSL();i.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(var e=0;e0)-(n<0)}function i(e,s){if(e===s)return 0;var a=t.typeOf(e),u=t.typeOf(s);if(n.default){if("instance"===a&&n.default.detect(e)&&e.constructor.compare)return e.constructor.compare(e,s);if("instance"===u&&n.default.detect(s)&&s.constructor.compare)return s.constructor.compare(s,e)*-1}var l=r(o[a],o[u]);if(0!==l)return l;switch(a){case"boolean":case"number":return r(e,s);case"string":return r(e.localeCompare(s),0);case"array":for(var c=e.length,p=s.length,h=Math.min(c,p),f=0;fn})}function h(e,n){return t.computed(e,function(){return t.get(this,e)>=n})}function f(e,n){return t.computed(e,function(){return t.get(this,e)=0)return o[a];if(Array.isArray(e)){if(s=e.slice(),t)for(a=s.length;--a>=0;)s[a]=i(s[a],t,n,o)}else if(r.default&&r.default.detect(e))s=e.copy(t,n,o);else if(e instanceof Date)s=new Date(e.getTime());else{s={};for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&"__"!==u.substring(0,2)&&(s[u]=t?i(e[u],t,n,o):e[u])}return t&&(n.push(e),o.push(s)),s}function o(e,t){return"object"!=typeof e||null===e?e:r.default&&r.default.detect(e)?e.copy(t):i(e,t,t?[]:null,t?[]:null)}e.default=o}),s("ember-runtime/ext/function",["exports","ember-environment","ember-metal"],function(e,t,n){"use strict";var r=Array.prototype.slice,i=Function.prototype;t.ENV.EXTEND_PROTOTYPES.Function&&(i.property=function(){var e=n.computed(this);return e.property.apply(e,arguments)},i.observes=function(){for(var e=arguments.length,t=Array(e),r=0;r1?n-1:0),i=1;i=0&&r>=0&&n.get(e,"hasEnumerableObservers")){o=[],s=t+r;for(var a=t;a=0&&i>=0&&n.get(e,"hasEnumerableObservers")){o=[];for(var s=t+i,a=t;a=n.get(this,"length")))return n.get(this,e)},h.objectsAt=function(e){var t=this;return e.map(function(e){return u(t,e)})},h.nextObject=function(e){return u(this,e)},h["[]"]=n.computed({get:function(e){return this},set:function(e,t){return this.replace(0,n.get(this,"length"),t),this}}),h.firstObject=n.computed(function(){return u(this,0)}).readOnly(),h.lastObject=n.computed(function(){return u(this,n.get(this,"length")-1)}).readOnly(),h.contains=function(e){return this.indexOf(e)>=0},h.slice=function(e,t){var r=n.default.A(),i=n.get(this,"length");for(n.isNone(e)&&(e=0),(n.isNone(t)||t>i)&&(t=i),e<0&&(e=i+e),t<0&&(t=i+t);e=r)&&(t=r-1),t<0&&(t+=r);for(var i=t;i>=0;i--)if(u(this,i)===e)return i;return-1},h.addArrayObserver=function(e,t){return s(this,e,t)},h.removeArrayObserver=function(e,t){return a(this,e,t)},h.hasArrayObservers=n.computed(function(){return n.hasListeners(this,"@array:change")||n.hasListeners(this,"@array:before")}),h.arrayContentWillChange=function(e,t,n){return l(this,e,t,n)},h.arrayContentDidChange=function(e,t,n){return c(this,e,t,n)},h["@each"]=n.computed(function(){return this.__each||(this.__each=new i.default(this)),this.__each}).volatile().readOnly(),h));m.reopen({includes:function(e,t){var r=n.get(this,"length");void 0===t&&(t=0),t<0&&(t+=r);for(var i=t;i1?t-1:0),r=1;r1?n-1:0),i=1;i=t.get(e,"length"))throw new t.Error(s);void 0===r&&(r=1),e.replace(n,r,a)}return e}e.removeAt=o;var s="Index out of range",a=[];e.default=t.Mixin.create(n.default,r.default,{replace:null,clear:function(){var e=t.get(this,"length");return 0===e?this:(this.replace(0,e,a),this)},insertAt:function(e,n){if(e>t.get(this,"length"))throw new t.Error(s);return this.replace(e,0,[n]),this},removeAt:function(e,t){return o(this,e,t)},pushObject:function(e){return this.insertAt(t.get(this,"length"),e),e},pushObjects:function(e){if(!i.default.detect(e)&&!Array.isArray(e))throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");return this.replace(t.get(this,"length"),0,e),this},popObject:function(){var e=t.get(this,"length");if(0===e)return null;var r=n.objectAt(this,e-1);return this.removeAt(e-1,1),r},shiftObject:function(){if(0===t.get(this,"length"))return null;var e=n.objectAt(this,0);return this.removeAt(0),e},unshiftObject:function(e){return this.insertAt(0,e),e},unshiftObjects:function(e){return this.replace(0,0,e),this},reverseObjects:function(){var e=t.get(this,"length");if(0===e)return this;var n=this.toArray().reverse();return this.replace(0,e,n),this},setObjects:function(e){if(0===e.length)return this.clear();var n=t.get(this,"length");return this.replace(0,n,e),this},removeObject:function(e){for(var r=t.get(this,"length")||0;--r>=0;){var i=n.objectAt(this,r);i===e&&this.removeAt(r)}return this},addObject:function(e){var t=void 0;return t=this.includes(e),t||this.pushObject(e),this}})}),s("ember-runtime/mixins/mutable_enumerable",["exports","ember-runtime/mixins/enumerable","ember-metal"],function(e,t,n){"use strict";e.default=n.Mixin.create(t.default,{addObject:null,addObjects:function(e){var t=this;return n.beginPropertyChanges(this),e.forEach(function(e){return t.addObject(e)}),n.endPropertyChanges(this),this},removeObject:null,removeObjects:function(e){n.beginPropertyChanges(this);for(var t=e.length-1;t>=0;t--)this.removeObject(e[t]);return n.endPropertyChanges(this),this}})}),s("ember-runtime/mixins/observable",["exports","ember-metal"],function(e,t){"use strict";e.default=t.Mixin.create({get:function(e){return t.get(this,e)},getProperties:function(){for(var e=arguments.length,n=Array(e),r=0;rt.get(this,"content.length"))throw new t.Error(u);return this._replace(e,0,[n]),this},insertAt:function(e,n){if(t.get(this,"arrangedContent")===t.get(this,"content"))return this._insertAt(e,n);throw new t.Error("Using insertAt on an arranged ArrayProxy is not allowed.")},removeAt:function(e,n){if("number"==typeof e){var r=t.get(this,"content"),i=t.get(this,"arrangedContent"),o=[];if(e<0||e>=t.get(this,"length"))throw new t.Error(u);void 0===n&&(n=1);for(var a=e;a0&&(e=[arguments[0]]),this.__defineNonEnumerable(t.GUID_KEY_PROPERTY);var o=n.meta(this),s=o.proto;if(o.proto=this,e){var a=e;e=null;for(var u=this.concatenatedProperties,l=this.mergedProperties,p=0;p0&&u.indexOf(g)>=0){var _=this[g];v=_?"function"==typeof _.concat?_.concat(v):t.makeArray(_).concat(v):t.makeArray(v)}if(l&&l.length&&l.indexOf(g)>=0){var w=this[g];v=t.assign({},w,v)}b?b.set(this,g,v):"function"!=typeof this.setUnknownProperty||g in this?this[g]=v:this.setUnknownProperty(g,v)}}}c(this,o),this.init.apply(this,arguments),this[f](),o.proto=s,n.finishChains(this),n.sendEvent(this,"init")};return i.toString=n.Mixin.prototype.toString,i.willReopen=function(){r&&(i.PrototypeMixin=n.Mixin.create(i.PrototypeMixin)),r=!1},i._initProperties=function(t){e=t},i.proto=function(){var e=i.superclass;return e&&e.proto(),r||(r=!0,i.PrototypeMixin.applyPartial(i.prototype)),this.prototype},i}var s,a,u=n.run.schedule,l=n.Mixin._apply,c=n.Mixin.finishPartial,p=n.Mixin.prototype.reopen,h=!1,f=t.symbol("POST_INIT");e.POST_INIT=f;var m=o();m.toString=function(){return"Ember.CoreObject"},m.PrototypeMixin=n.Mixin.create((s={reopen:function(){for(var e=arguments.length,t=Array(e),n=0;n";return r},s)),m.PrototypeMixin.ownerConstructor=m,m.__super__=null;var d=(a={ClassMixin:n.REQUIRED,PrototypeMixin:n.REQUIRED,isClass:!0,isMethod:!1},a[t.NAME_KEY]=null,a[t.GUID_KEY]=null,a.extend=function(){var e,r=o();return r.ClassMixin=n.Mixin.create(this.ClassMixin),r.PrototypeMixin=n.Mixin.create(this.PrototypeMixin),r.ClassMixin.ownerConstructor=r,r.PrototypeMixin.ownerConstructor=r,p.apply(r.PrototypeMixin,arguments),r.superclass=this,r.__super__=this.prototype,e=r.prototype=Object.create(this.prototype),e.constructor=r,t.generateGuid(e),n.meta(e).proto=e,r.ClassMixin.apply(r),r},a.create=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r0&&this._initProperties(n),new e},a.reopen=function(){return this.willReopen(),p.apply(this.PrototypeMixin,arguments),this},a.reopenClass=function(){return p.apply(this.ClassMixin,arguments),l(this,arguments,!1),this},a.detect=function(e){if("function"!=typeof e)return!1;for(;e;){if(e===this)return!0;e=e.superclass}return!1},a.detectInstance=function(e){return e instanceof this},a.metaForProperty=function(e){var t=this.proto(),n=t[e],r=null!==n&&"object"==typeof n&&n.isDescriptor?n:void 0;return r._meta||{}},a._computedProperties=n.computed(function(){h=!0;var e,t=this.proto(),n=[];for(var r in t)e=t[r],e&&e.isDescriptor&&n.push({name:r,meta:e._meta});return n}).readOnly(),a.eachComputedProperty=function(e,t){for(var r,i={},o=n.get(this,"_computedProperties"),s=0;s=o;){var a=r.objectAt(e,s);a&&(n._addBeforeObserver(a,t,i,"contentKeyWillChange"),n.addObserver(a,t,i,"contentKeyDidChange"))}}function s(e,t,i,o,s){for(;--s>=o;){var a=r.objectAt(e,s);a&&(n._removeBeforeObserver(a,t,i,"contentKeyWillChange"),n.removeObserver(a,t,i,"contentKeyDidChange"))}}e.default=i,i.prototype={__defineNonEnumerable:function(e){this[e.name]=e.descriptor.value},arrayWillChange:function(e,t,r,i){var o=this._keys,a=r>0?t+r:-1;for(var u in o)a>0&&s(e,u,this,t,a),n.propertyWillChange(this,u)},arrayDidChange:function(e,t,r,i){var s=this._keys,a=i>0?t+i:-1;for(var u in s)a>0&&o(e,u,this,t,a),n.propertyDidChange(this,u)},willWatchProperty:function(e){this.beginObservingContentKey(e)},didUnwatchProperty:function(e){this.stopObservingContentKey(e)},beginObservingContentKey:function(e){var r=this._keys;if(r||(r=this._keys=new t.EmptyObject),r[e])r[e]++;else{r[e]=1;var i=this._content,s=n.get(i,"length");o(i,e,this,0,s)}},stopObservingContentKey:function(e){var t=this._keys;if(t&&t[e]>0&&--t[e]<=0){var r=this._content,i=n.get(r,"length");s(r,e,this,0,i)}},contentKeyWillChange:function(e,t){n.propertyWillChange(this,t)},contentKeyDidChange:function(e,t){n.propertyDidChange(this,t)}}}),s("ember-runtime/system/lazy_load",["exports","ember-environment"],function(e,t){"use strict";function n(e,t){var n=o[e];i[e]=i[e]||[],i[e].push(t),n&&t(n)}function r(e,n){o[e]=n;var r=t.environment.window;if(r&&"function"==typeof CustomEvent){var s=new CustomEvent(e,{detail:n,name:e});r.dispatchEvent(s)}i[e]&&i[e].forEach(function(e){return e(n)})}e.onLoad=n,e.runLoadHooks=r;var i=t.ENV.EMBER_LOAD_HOOKS||{},o={},s=o;e._loaded=s}),s("ember-runtime/system/namespace",["exports","ember-utils","ember-metal","ember-environment","ember-runtime/system/object"],function(e,t,n,r,i){"use strict";function o(){return d}function s(e){d=!!e}function a(e,n,r){var i=e.length;v[e.join(".")]=n;for(var o in n)if(y.call(n,o)){var s=n[o];if(e[i]=o,s&&s.toString===f&&!s[t.NAME_KEY])s[t.NAME_KEY]=e.join(".");else if(s&&s.isNamespace){if(r[t.guidFor(s)])continue;r[t.guidFor(s)]=!0,a(e,s,r)}}e.length=i}function u(e){return e>=65&&e<=90}function l(e,t){try{var n=e[t];return n&&n.isNamespace&&n}catch(e){}}function c(){if(!g.PROCESSED)for(var e=r.context.lookup,n=Object.keys(e),i=0;i2){i=new Array(arguments.length-1);for(var o=1;o2)&&(t=Array.prototype.slice.call(arguments,1)),e=i.get(e)||e,o(e,t)}function u(e){return e.split(/\s+/)}function l(e){return N.get(e)}function c(e){return g.get(e)}function p(e){return b.get(e)}function h(e){return O.get(e)}function f(e){return C.get(e)}function m(e){return k.get(e)}var d=/[ _]/g,g=new t.Cache(1e3,function(e){return l(e).replace(d,"-")}),v=/(\-|\_|\.|\s)+(.)?/g,y=/(^|\/)([A-Z])/g,b=new t.Cache(1e3,function(e){return e.replace(v,function(e,t,n){return n?n.toUpperCase():""}).replace(y,function(e,t,n){return e.toLowerCase()})}),_=/^(\-|_)+(.)?/,w=/(.)(\-|\_|\.|\s)+(.)?/g,E=/(^|\/|\.)([a-z])/g,O=new t.Cache(1e3,function(e){for(var t=function(e,t,n){return n?"_"+n.toUpperCase():""},n=function(e,t,n,r){return t+(r?r.toUpperCase():"")},r=e.split("/"),i=0;i-1;return e?function(e){return o.test(s.call(e))}:function(){return!0}}();e.checkHasSuper=a,t.__hasSuper=!1}),s("ember-utils/symbol",["exports","ember-utils/guid","ember-utils/intern"],function(e,t,n){"use strict";function r(e){return n.default(e+" [id="+t.GUID_KEY+Math.floor(Math.random()*new Date)+"]")}e.default=r}),s("ember-utils/to-string",["exports"],function(e){"use strict";function t(e){return e&&"function"==typeof e.toString?e.toString():n.call(e)}e.default=t;var n=Object.prototype.toString}),s("ember-views/compat/attrs",["exports","ember-utils"],function(e,t){"use strict";var n=t.symbol("MUTABLE_CELL");e.MUTABLE_CELL=n});s("ember-views/compat/fallback-view-registry",["exports","ember-utils"],function(e,t){"use strict";e.default=t.dictionary(null)});s("ember-views/component_lookup",["exports","ember-metal","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({componentFor:function(e,t,n){var r="component:"+e;return t._lookupFactory(r,n)},layoutFor:function(e,t,n){var r="template:components/"+e;return t.lookup(r,n)}})}),s("ember-views/index",["exports","ember-views/system/ext","ember-views/system/jquery","ember-views/system/utils","ember-views/system/event_dispatcher","ember-views/component_lookup","ember-views/mixins/text_support","ember-views/views/core_view","ember-views/mixins/class_names_support","ember-views/mixins/child_views_support","ember-views/mixins/view_state_support","ember-views/mixins/view_support","ember-views/mixins/action_support","ember-views/compat/attrs","ember-views/system/lookup_partial","ember-views/utils/lookup-component","ember-views/system/action_manager","ember-views/compat/fallback-view-registry"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.jQuery=n.default,e.isSimpleClick=r.isSimpleClick,e.getViewBounds=r.getViewBounds,e.getViewClientRects=r.getViewClientRects,e.getViewBoundingClientRect=r.getViewBoundingClientRect,e.getRootViews=r.getRootViews,e.getChildViews=r.getChildViews,e.getViewId=r.getViewId,e.getViewElement=r.getViewElement,e.setViewElement=r.setViewElement,e.STYLE_WARNING=r.STYLE_WARNING,e.EventDispatcher=i.default,e.ComponentLookup=o.default,e.TextSupport=s.default,e.CoreView=a.default,e.ClassNamesSupport=u.default,e.ChildViewsSupport=l.default,e.ViewStateSupport=c.default,e.ViewMixin=p.default,e.ActionSupport=h.default,e.MUTABLE_CELL=f.MUTABLE_CELL,e.lookupPartial=m.default,e.hasPartial=m.hasPartial,e.lookupComponent=d.default,e.ActionManager=g.default,e.fallbackViewRegistry=v.default}),s("ember-views/mixins/action_support",["exports","ember-utils","ember-metal","ember-views/compat/attrs"],function(e,t,n,r){"use strict";function i(e,t){return t&&t[r.MUTABLE_CELL]&&(t=t.value),t}e.default=n.Mixin.create({sendAction:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o1?t-1:0),i=1;i1;return!t&&!n}function r(e){var t=e.lookup("-view-registry:main"),n=[];return Object.keys(t).forEach(function(e){var r=t[e];null===r.parentView&&n.push(r)}),n}function i(e){return""===e.tagName?t.guidFor(e):e.elementId||t.guidFor(e)}function o(e){return e[y]}function s(e){e[y]=null}function a(e,t){return e[y]=t}function u(e){var n=t.getOwner(e),r=n.lookup("-view-registry:main");return p(e,r)}function l(e){e[b]=[]}function c(e,t){e[b].push(i(t))}function p(e,t){var n=[],r=[];return e[b].forEach(function(e){var i=t[e];!i||i.isDestroying||i.isDestroyed||n.indexOf(e)!==-1||(n.push(e),r.push(i))}),e[b]=n,r}function h(e){return e.renderer.getBounds(e)}function f(e){var t=h(e),n=document.createRange();return n.setStartBefore(t.firstNode),n.setEndAfter(t.lastNode),n}function m(e){var t=f(e);return t.getClientRects()}function d(e){var t=f(e);return t.getBoundingClientRect()}function g(e,t){return _.call(e,t)}e.isSimpleClick=n,e.getRootViews=r,e.getViewId=i,e.getViewElement=o,e.initViewElement=s,e.setViewElement=a,e.getChildViews=u,e.initChildViews=l,e.addChildView=c,e.collectChildViews=p,e.getViewBounds=h,e.getViewRange=f,e.getViewClientRects=m,e.getViewBoundingClientRect=d,e.matches=g;var v="Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.";e.STYLE_WARNING=v;var y=t.symbol("VIEW_ELEMENT"),b=t.symbol("CHILD_VIEW_IDS"),_="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector);e.elMatches=_}),s("ember-views/utils/lookup-component",["exports","container"],function(e,t){"use strict";function n(e,n,r,o){var s=e.componentFor(r,n,o),a=e.layoutFor(r,n,o),u={layout:a,component:s};return a&&!s&&(u.component=n._lookupFactory(t.privatize(i))),u}function r(e,t,r){var i=e.lookup("component-lookup:main"),o=r&&r.source;if(o){var s=n(i,e,t,r);if(s.component||s.layout)return s}return n(i,e,t)}e.default=r;var i=babelHelpers.taggedTemplateLiteralLoose(["component:-default"],["component:-default"])}),s("ember-views/views/core_view",["exports","ember-runtime","ember-views/system/utils","ember-views/views/states"],function(e,t,n,r){"use strict";var i=t.FrameworkObject.extend(t.Evented,t.ActionHandler,{isView:!0,_states:r.cloneStates(r.states),init:function(){if(this._super.apply(this,arguments),this._state="preRender",this._currentState=this._states.preRender,n.initViewElement(this),!this.renderer)throw new Error("Cannot instantiate a component without a renderer. Please ensure that you are creating "+this+" with a proper container/registry.")},parentView:null,instrumentDetails:function(e){return e.object=this.toString(),e.containerKey=this._debugContainerKey,e.view=this,e},trigger:function(){this._super.apply(this,arguments);var e=arguments[0],t=this[e];if(t){for(var n=new Array(arguments.length-1),r=1;r1?r-1:0),o=1;o]+) [^\/>]*\/>/gi,function(e,t){return e.slice(0,e.length-3)+">"})),e}function n(e,n){var r=t(e.innerHTML);QUnit.push(r===n,r,n)}e.default=n;var r=function(){if(!document.createElementNS)return!1;var e=document.createElement("div"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(t);var n=e.cloneNode(!0);return''===n.innerHTML}()}),s("internal-test-helpers/equal-tokens",["exports","simple-html-tokenizer"],function(e,t){"use strict";function n(e){return"string"==typeof e?{tokens:t.tokenize(e),html:e}:{tokens:t.tokenize(e.innerHTML),html:e.innerHTML}}function r(e){e.forEach(function(e){"StartTag"===e.type&&(e.attributes=e.attributes.sort(function(e,t){return e[0]>t[0]?1:e[0]"},e.create=n,e.extend=o,e.reopen=o,e.reopenClass=i,e}e.default=n;var r=0}),s("internal-test-helpers/index",["exports","internal-test-helpers/factory","internal-test-helpers/build-owner","internal-test-helpers/confirm-export","internal-test-helpers/equal-inner-html","internal-test-helpers/equal-tokens","internal-test-helpers/module-for","internal-test-helpers/strip","internal-test-helpers/apply-mixins","internal-test-helpers/matchers","internal-test-helpers/run","internal-test-helpers/test-groups","internal-test-helpers/test-cases/abstract","internal-test-helpers/test-cases/abstract-application","internal-test-helpers/test-cases/application","internal-test-helpers/test-cases/query-param","internal-test-helpers/test-cases/abstract-rendering","internal-test-helpers/test-cases/rendering"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.factory=t.default,e.buildOwner=n.default,e.confirmExport=r.default,e.equalInnerHTML=i.default,e.equalTokens=o.default,e.moduleFor=s.default,e.strip=a.default,e.applyMixins=u.default,e.equalsElement=l.equalsElement,e.classes=l.classes,e.styles=l.styles,e.regex=l.regex,e.runAppend=c.runAppend,e.runDestroy=c.runDestroy,e.testBoth=p.testBoth,e.testWithDefault=p.testWithDefault,e.AbstractTestCase=h.default,e.AbstractApplicationTestCase=f.default,e.ApplicationTestCase=m.default,e.QueryParamTestCase=d.default,e.AbstractRenderingTestCase=g.default,e.RenderingTestCase=v.default}),s("internal-test-helpers/matchers",["exports"],function(e){"use strict";function t(e){return"object"==typeof e&&null!==e&&u in e}function n(e){var t;return t={},t[u]=!0,t.match=function(t){return e===t},t.expected=function(){return e},t.message=function(){return"should equal "+this.expected()},t}function r(e){var t;return t={},t[u]=!0,t.match=function(t){return e.test(t)},t.expected=function(){return e.toString()},t.message=function(){return"should match "+this.expected()},t}function i(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t.trim(),t&&e.split(/\s+/).sort().join(" ")===t.trim().split(/\s+/).sort().join(" ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function o(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t||"",t=t.trim(),e.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")===t.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function s(e,r,i,o){QUnit.push(e.tagName===r.toUpperCase(),e.tagName.toLowerCase(),r,"expect tagName to be "+r);var s={},u=0;for(var l in i){var c=i[l];null!==c&&u++;var p=t(c)?c:n(c);s[l]=p,QUnit.push(s[l].match(e.getAttribute(l)),e.getAttribute(l),p.expected(),"Element's "+l+" attribute "+p.message())}for(var h={},f=0,m=e.attributes.length;f2?o-2:0),a=2;a1?t-1:0),r=1;re));)n=n.nextSibling; -return n},e.prototype.$=function(e){return e?r.jQuery(e,this.element):r.jQuery(this.element)},e.prototype.textValue=function(){return this.$().text()},e.prototype.takeSnapshot=function(){for(var e=this.snapshot=[],t=this.element.firstChild;t;)a(t)||e.push(t),t=t.nextSibling;return e},e.prototype.assertText=function(e){this.assert.strictEqual(this.textValue(),e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertInnerHTML=function(e){i.default(this.element,e)},e.prototype.assertHTML=function(e){o.default(this.element,e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertElement=function(e,t){var n=t.ElementType,r=void 0===n?l:n,i=t.tagName,o=t.attrs,a=void 0===o?null:o,u=t.content,c=void 0===u?null:u;if(!(e instanceof r))throw new Error("Expecting a "+r.name+", but got "+e);s.equalsElement(e,i,a,c)},e.prototype.assertComponentElement=function(e,n){var r=n.ElementType,i=void 0===r?l:r,o=n.tagName,a=void 0===o?"div":o,u=n.attrs,c=void 0===u?null:u,p=n.content,h=void 0===p?null:p;c=t.assign({},{id:s.regex(/^ember\d*$/),class:s.classes("ember-view")},c||{}),this.assertElement(e,{ElementType:i,tagName:a,attrs:c,content:h})},e.prototype.assertSameNode=function(e,t){this.assert.strictEqual(e,t,"DOM node stability")},e.prototype.assertInvariants=function(e,t){e=e||this.snapshot,t=t||this.takeSnapshot(),this.assert.strictEqual(t.length,e.length,"Same number of nodes");for(var n=0;n"}catch(e){}finally{if(0!==t.childNodes.length)return!1}return!0}e.domChanges=r,e.treeConstruction=i;var a={colgroup:{depth:2,before:"",after:"
"},table:{depth:1,before:"",after:"
"},tbody:{depth:2,before:"",after:"
"},tfoot:{depth:2,before:"",after:"
"},thead:{depth:2,before:"",after:"
"},tr:{depth:3,before:"",after:"
"}}}),s("glimmer-runtime/lib/compat/svg-inner-html-fix",["exports","glimmer-runtime/lib/bounds","glimmer-runtime/lib/dom/helper"],function(e,t,n){"use strict";function r(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===s||""===s?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,s,i)},t}(t)}function i(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===i||""===i?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,i,s)},t}(t)}function o(e,r,i,o){var s=""+i+"";r.innerHTML=s;var a=n.moveNodesBefore(r.firstChild,e,o),u=a[0],l=a[1];return new t.ConcreteBounds(e,u,l)}function s(e,t){var n=e.createElementNS(t,"svg");try{n.insertAdjacentHTML("beforeEnd","")}catch(e){}finally{return(1!==n.childNodes.length||n.firstChild.namespaceURI!==a)&&(n=null,!0)}}e.domChanges=r,e.treeConstruction=i;var a="http://www.w3.org/2000/svg"}),s("glimmer-runtime/lib/compat/text-node-merging-fix",["exports"],function(e){"use strict";function t(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=t.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===r)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=n?n.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,n));var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function n(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=this.createComment("")}return babelHelpers.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===n)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=r?r.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,r));var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function r(e){var t=e.createElement("div");return t.innerHTML="first", -t.insertAdjacentHTML("beforeEnd","second"),2===t.childNodes.length?(t=null,!1):(t=null,!0)}e.domChanges=t,e.treeConstruction=n}),s("glimmer-runtime/lib/compiled/blocks",["exports","glimmer-runtime/lib/utils","glimmer-runtime/lib/compiler"],function(e,t,n){"use strict";var r=function(e,t){this.ops=e,this.symbols=t};e.CompiledBlock=r;var i=function(e,t){this.program=e,this.symbolTable=t,this.compiled=null};e.Block=i;var o=function(e){function i(n,r){var i=arguments.length<=2||void 0===arguments[2]?t.EMPTY_ARRAY:arguments[2];e.call(this,n,r),this.locals=i}return babelHelpers.inherits(i,e),i.prototype.hasPositionalParameters=function(){return!!this.locals.length},i.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.InlineBlockCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},i}(i);e.InlineBlock=o;var s=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t}(o);e.PartialBlock=s;var a=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t}(i);e.TopLevelTemplate=a;var u=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.EntryPointCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},t}(a);e.EntryPoint=u;var l=function(e){function t(t,n,r,i,o){e.call(this,t,n),this.named=r,this.yields=i,this.hasPartials=o,this.hasNamedParameters=!!this.named.length,this.hasYields=!!this.yields.length}return babelHelpers.inherits(t,e),t}(a);e.Layout=l}),s("glimmer-runtime/lib/compiled/expressions",["exports"],function(e){"use strict";var t=function(){function e(){}return e.prototype.toJSON=function(){return"UNIMPL: "+this.type.toUpperCase()},e}();e.CompiledExpression=t}),s("glimmer-runtime/lib/compiled/expressions/args",["exports","glimmer-runtime/lib/compiled/expressions/positional-args","glimmer-runtime/lib/compiled/expressions/named-args","glimmer-runtime/lib/syntax/core","glimmer-reference"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n}return e.create=function(e,i,o){return e===t.COMPILED_EMPTY_POSITIONAL_ARGS&&i===n.COMPILED_EMPTY_NAMED_ARGS&&o===r.EMPTY_BLOCKS?this.empty():new this(e,i,o)},e.empty=function(){return s},e.prototype.evaluate=function(e){var t=this.positional,n=this.named,r=this.blocks;return a.create(t.evaluate(e),n.evaluate(e),r)},e}();e.CompiledArgs=o;var s=new(function(e){function i(){e.call(this,t.COMPILED_EMPTY_POSITIONAL_ARGS,n.COMPILED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS)}return babelHelpers.inherits(i,e),i.prototype.evaluate=function(e){return u},i}(o)),a=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.tag=i.combineTagged([e,t])}return e.empty=function(){return u},e.create=function(e,t,n){return new this(e,t,n)},e.positional=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EvaluatedPositionalArgs.create(e),n.EVALUATED_EMPTY_NAMED_ARGS,i)},e.named=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EvaluatedNamedArgs.create(e),i)},e}();e.EvaluatedArgs=a;var u=new a(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EVALUATED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS);e.CompiledPositionalArgs=t.CompiledPositionalArgs,e.EvaluatedPositionalArgs=t.EvaluatedPositionalArgs,e.CompiledNamedArgs=n.CompiledNamedArgs,e.EvaluatedNamedArgs=n.EvaluatedNamedArgs}),s("glimmer-runtime/lib/compiled/expressions/concat",["exports","glimmer-reference"],function(e,t){"use strict";function n(e){return"function"!=typeof e.toString?"":String(e)}var r=function(){function e(e){this.parts=e,this.type="concat"}return e.prototype.evaluate=function(e){for(var t=new Array(this.parts.length),n=0;n0?e.join(""):null},r}(t.CachedReference)}),s("glimmer-runtime/lib/compiled/expressions/function",["exports","glimmer-runtime/lib/syntax","glimmer-runtime/lib/compiled/expressions"],function(e,t,n){"use strict";function r(e){return new i(e)}e.default=r;var i=function(e){function t(t){e.call(this),this.type="function-expression",this.func=t}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t,n){return new o(this.func,n)},t}(t.Expression),o=function(e){function t(t,n){e.call(this),this.func=t,this.symbolTable=n,this.type="function",this.func=t}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.func,n=this.symbolTable;return t(e,n)},t.prototype.toJSON=function(){var e=this.func;return e.name?"`"+e.name+"(...)`":"`func(...)`"},t}(n.CompiledExpression)}),s("glimmer-runtime/lib/compiled/expressions/has-block",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-runtime/lib/references"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!t)},t.prototype.toJSON=function(){return"has-block("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block-params"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!(t&&t.locals.length>0))},t.prototype.toJSON=function(){return"has-block-params("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.CompiledHasBlockParams=i;var o=function(){function e(e,t){this.symbol=e,this.debug=t}return e.prototype.evaluate=function(e){return e.scope().getBlock(this.symbol)},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"("+this.debug+"))"},e}();e.CompiledGetBlockBySymbol=o;var s=function(){function e(e,t){this.symbol=e,this.name=t}return e.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.blocks[n]},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"($ARGS)."+this.name+"))"},e}();e.CompiledInPartialGetBlock=s}),s("glimmer-runtime/lib/compiled/expressions/helper",["exports","glimmer-runtime/lib/compiled/expressions"],function(e,t){"use strict";var n=function(e){function t(t,n,r,i){e.call(this),this.name=t,this.helper=n,this.args=r,this.symbolTable=i,this.type="helper"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.helper;return t(e,this.args.evaluate(e),this.symbolTable)},t.prototype.toJSON=function(){return"`"+this.name.join(".")+"($ARGS)`"},t}(t.CompiledExpression);e.default=n}),s("glimmer-runtime/lib/compiled/expressions/lookups",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-reference"],function(e,t,n){"use strict";var r=function(e){function t(t,n){e.call(this),this.base=t,this.path=n,this.type="lookup"}return babelHelpers.inherits(t,e),t.create=function(e,t){return 0===t.length?e:new this(e,t)},t.prototype.evaluate=function(e){var t=this.base,r=this.path;return n.referenceFromParts(t.evaluate(e),r)},t.prototype.toJSON=function(){return this.base.toJSON()+"."+this.path.join(".")},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){return e.getSelf()},t.prototype.toJSON=function(){return"self"},t}(t.CompiledExpression);e.CompiledSelf=i;var o=function(e){function t(t,n){e.call(this),this.symbol=t,this.debug=n}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){return e.referenceForSymbol(this.symbol)},t.prototype.toJSON=function(){return"$"+this.symbol+"("+this.debug+")"},t}(t.CompiledExpression);e.CompiledSymbol=o;var s=function(e){function t(t,n){e.call(this),this.symbol=t,this.name=n}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.named.get(n)},t.prototype.toJSON=function(){return"$"+this.symbol+"($ARGS)."+this.name},t}(t.CompiledExpression);e.CompiledInPartialName=s}),s("glimmer-runtime/lib/compiled/expressions/named-args",["exports","glimmer-runtime/lib/references","glimmer-runtime/lib/utils","glimmer-reference","glimmer-util"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t){this.keys=e,this.values=t,this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.empty=function(){return s},e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=[],i=0;i"},t}(o));e.COMPILED_EMPTY_NAMED_ARGS=s;var a=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?void 0:arguments[2];this.keys=e,this.values=t,this._map=n,this.tag=r.combineTagged(t),this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=new Array(n),i=0;i"},t}(i));e.COMPILED_EMPTY_POSITIONAL_ARGS=o;var s=function(){function e(e){this.values=e,this.tag=r.combineTagged(e),this.length=e.length}return e.create=function(e){return new this(e)},e.empty=function(){return a},e.prototype.at=function(e){var n=this.values,r=this.length;return e")}var u=function(e){function t(t){e.call(this),this.text=t,this.type="text"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().appendText(this.text)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.text)]}},t}(t.Opcode);e.TextOpcode=u;var l=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenPrimitiveElementOpcode=l; -var c=function(e){function t(){e.apply(this,arguments),this.type="push-remote-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand(),n=r.isConst(t)?void 0:new r.ReferenceCache(t),i=n?n.peek():t.value();e.stack().pushRemoteElement(i),n&&e.updateWith(new o.Assert(n))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:["$OPERAND"]}},t}(t.Opcode);e.PushRemoteElementOpcode=c;var p=function(e){function t(){e.apply(this,arguments),this.type="pop-remote-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().popRemoteElement()},t}(t.Opcode);e.PopRemoteElementOpcode=p;var h=function(e){function t(t){e.call(this),this.tag=t,this.type="open-component-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag,new v(e.env))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenComponentElementOpcode=h;var f=function(e){function t(){e.apply(this,arguments),this.type="open-dynamic-primitive-element"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand().value();e.stack().openElement(t)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:["$OPERAND"]}},t}(t.Opcode);e.OpenDynamicPrimitiveElementOpcode=f;var m=function(){function e(){this.list=null,this.isConst=!0}return e.prototype.append=function(e){var t=this.list,n=this.isConst;null===t&&(t=this.list=[]),t.push(e),this.isConst=n&&r.isConst(e)},e.prototype.toReference=function(){var e=this.list,t=this.isConst;return e?t?i.PrimitiveReference.create(s(e)):new d(e):i.NULL_REFERENCE},e}(),d=function(e){function t(t){e.call(this),this.list=[],this.tag=r.combineTagged(t),this.list=t}return babelHelpers.inherits(t,e),t.prototype.compute=function(){return s(this.list)},t}(r.CachedReference),g=function(){function e(e){this.env=e,this.opcodes=null,this.classList=null}return e.prototype.addStaticAttribute=function(e,t,n){"class"===t?this.addClass(i.PrimitiveReference.create(n)):this.env.getAppendOperations().setAttribute(e,t,n)},e.prototype.addStaticAttributeNS=function(e,t,n,r){this.env.getAppendOperations().setAttribute(e,n,r,t)},e.prototype.addDynamicAttribute=function(e,t,n,r){if("class"===t)this.addClass(n);else{var i=this.env.attributeFor(e,t,r),o=new x(e,i,t,n);this.addAttribute(o)}},e.prototype.addDynamicAttributeNS=function(e,t,n,r,i){var o=this.env.attributeFor(e,n,i,t),s=new x(e,o,n,r,t);this.addAttribute(s)},e.prototype.flush=function(e,t){for(var n=t.env,r=this.opcodes,i=this.classList,o=0;r&&o.')},t.prototype.valueSyntax=function(){return F.build(this.value)},t}(t.Argument);e.StaticArg=O;var S=function(e){function t(t,n){var r=arguments.length<=2||void 0===arguments[2]?null:arguments[2];e.call(this),this.name=t,this.value=n,this.namespace=r,this.type="dynamic-arg"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2];return new t(n,a.default(r))},t.build=function(e,t){return new this(e,t)},t.prototype.compile=function(){throw new Error('Cannot compile DynamicArg for "'+this.name+'" as it is delegate for ExpressionSyntax.')},t.prototype.valueSyntax=function(){return this.value},t}(t.Argument);e.DynamicArg=S;var x=function(){function e(){}return e.fromSpec=function(e){var t=e[1],n=e[2],r=e[3];return new A(t,a.default(n),r,!0)},e.build=function(e,t,n){var r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new A(e,t,r,n)},e.prototype.compile=function(){throw new Error("Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.")},e}();e.TrustingAttr=x;var C=function(e){function t(t,n,r){e.call(this),this.name=t,this.value=n,this.namespace=r,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="static-attr",this.isTrusting=!1}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,r,i)},t.build=function(e,t){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];return new this(e,t,n)},t.prototype.compile=function(e){e.append(new s.StaticAttrOpcode(this.namespace,this.name,this.value))},t.prototype.valueSyntax=function(){return F.build(this.value)},t}(t.Attribute);e.StaticAttr=C;var A=function(e){function t(t,n,r,i){void 0===r&&(r=void 0),e.call(this),this.name=t,this.value=n,this.namespace=r,this.isTrusting=i,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="dynamic-attr"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,a.default(r),i)},t.build=function(e,t){var n=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new this(e,t,r,n)},t.prototype.compile=function(e,t,n){var r=this.namespace,o=this.value;e.append(new i.PutValueOpcode(o.compile(e,t,n))),r?e.append(new s.DynamicAttrNSOpcode(this.name,this.namespace,this.isTrusting)):e.append(new s.DynamicAttrOpcode(this.name,this.isTrusting))},t.prototype.valueSyntax=function(){return this.value},t}(t.Attribute);e.DynamicAttr=A;var k=function(e){function t(){e.apply(this,arguments),this.type="flush-element"}return babelHelpers.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.FlushElementOpcode)},t}(t.Statement);e.FlushElement=k;var T=function(e){function t(){e.apply(this,arguments),this.type="close-element"}return babelHelpers.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.CloseElementOpcode)},t}(t.Statement);e.CloseElement=T;var N=function(e){function t(t){e.call(this),this.content=t,this.type="text"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.text(this.content)},t}(t.Statement);e.Text=N;var R=function(e){function t(t){e.call(this),this.comment=t,this.type="comment"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.comment(this.comment)},t}(t.Statement);e.Comment=R;var P=function(e){function n(t,n,r){e.call(this),this.tag=t,this.blockParams=n,this.symbolTable=r,this.type="open-element"}return babelHelpers.inherits(n,e),n.fromSpec=function(e,t){var r=e[1],i=e[2];return new n(r,i,t)},n.build=function(e,t,n){return new this(e,t,n)},n.prototype.scan=function(e){var t=this.tag;if(e.env.hasComponentDefinition([t],this.symbolTable)){var n=this.parameters(e),r=n.args,i=n.attrs;e.startBlock(this.blockParams),this.tagContents(e);var o=e.endBlock(this.blockParams);return r.blocks=Y.fromSpec(o),new D(t,i,r)}return new I(t)},n.prototype.compile=function(e,t){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},n.prototype.toIdentity=function(){var e=this.tag;return new I(e)},n.prototype.parameters=function(e){for(var n=e.next(),r=[],i=[],o=[];!(n instanceof k);){if(n[w])throw new Error("Compile Error: Element modifiers are not allowed in components");var s=n;if(n[t.ATTRIBUTE])r.push(s.name),i.push(s.name),o.push(s.valueSyntax());else{if(!n[t.ARGUMENT])throw new Error("Expected FlushElement, but got ${current}");i.push(s.name),o.push(s.valueSyntax())}n=e.next()}return{args:J.fromNamedArgs(X.build(i,o)),attrs:r}},n.prototype.tagContents=function(e){for(var t=1;;){var r=e.next();if(r instanceof T&&0===--t)break;e.addStatement(r),(r instanceof n||r instanceof I)&&t++}},n}(t.Statement);e.OpenElement=P;var D=function(e){function t(t,n,r){e.call(this),this.tag=t,this.attrs=n,this.args=r,this.type="component"}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t,n){var r=t.getComponentDefinition([this.tag],n),i=this.args.compile(e,t,n),s=this.attrs; -e.append(new o.PutComponentDefinitionOpcode(r)),e.append(new o.OpenComponentOpcode(i,s)),e.append(new o.CloseComponentOpcode)},t}(t.Statement);e.Component=D;var I=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return babelHelpers.inherits(t,e),t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},t}(t.Statement);e.OpenPrimitiveElement=I;var L=function(e){function t(t,n){e.call(this),this.to=t,this.args=n,this.type="yield"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=J.fromSpec(r,null,Q);return new t(n,i)},t.build=function(e,t){var n=J.fromPositionalArgs($.build(e));return new this(t,n)},t.prototype.compile=function(e,t,n){var r=this.to,i=this.args.compile(e,t,n);if(e.hasBlockSymbol(r)){var o=e.getBlockSymbol(r),s=new p.CompiledGetBlockBySymbol(o,r);e.append(new j(s,i)),e.append(new H)}else{if(!e.hasPartialArgsSymbol())throw new Error("[BUG] ${to} is not a valid block name.");var o=e.getPartialArgsSymbol(),s=new p.CompiledInPartialGetBlock(o,r);e.append(new j(s,i)),e.append(new H)}},t}(t.Statement);e.Yield=L;var M=function(e){function t(){e.apply(this,arguments)}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1],r=a.default(t);return g(r)?new n.StaticPartialSyntax(r):new n.DynamicPartialSyntax(r)},t}(t.Statement);e.Partial=M;var j=function(e){function t(t,n){e.call(this),this.inner=t,this.args=n,this.type="open-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e),n=void 0;t&&(n=this.args.evaluate(e)),e.pushCallerScope(),t&&e.invokeBlock(t,n)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,details:{block:this.inner.toJSON(),positional:this.args.positional.toJSON(),named:this.args.named.toJSON()}}},t}(r.Opcode),H=function(e){function t(){e.apply(this,arguments),this.type="close-block"}return babelHelpers.inherits(t,e),t.prototype.evaluate=function(e){e.popScope()},t}(r.Opcode);e.CloseBlockOpcode=H;var F=function(e){function t(t){e.call(this),this.value=t,this.type="value"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){return new t(e)},t.build=function(e){return new this(e)},t.prototype.inner=function(){return this.value},t.prototype.compile=function(e){return new l.default(this.value)},t}(t.Expression);e.Value=F;var U=function(e){function t(t){e.call(this),this.parts=t,this.type="get-argument"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e.split("."))},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(e.hasNamedSymbol(n)){var r=e.getNamedSymbol(n),i=t.slice(1),o=new c.CompiledSymbol(r,n);return c.default.create(o,i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=t.slice(1),o=new c.CompiledInPartialName(r,n);return c.default.create(o,i)}throw new Error("[BUG] @"+this.parts.join(".")+" is not a valid lookup path.")},t}(t.Expression);e.GetArgument=U;var B=function(e){function t(t){e.call(this),this.parts=t,this.type="ref"}return babelHelpers.inherits(t,e),t.build=function(e){var t=e.split(".");return"this"===t[0]&&(t[0]=null),new this(t)},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(null===n){var r=new c.CompiledSelf,i=t.slice(1);return c.default.create(r,i)}if(e.hasLocalSymbol(n)){var o=e.getLocalSymbol(n),i=t.slice(1),r=new c.CompiledSymbol(o,n);return c.default.create(r,i)}var r=new c.CompiledSelf;return c.default.create(r,t)},t}(t.Expression);e.Ref=B;var z=function(e){function t(t){e.call(this),this.ref=t,this.type="get"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new B(t))},t.build=function(e){return new this(B.build(e))},t.prototype.compile=function(e){return this.ref.compile(e)},t}(t.Expression);e.Get=z;var V=function(e){function t(t){e.call(this),this.ref=t,this.type="unknown"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new B(t))},t.build=function(e){return new this(B.build(e))},t.prototype.compile=function(e,t,n){var r=this.ref;return t.hasHelper(r.parts,n)?new h.default(r.parts,t.lookupHelper(r.parts,n),u.CompiledArgs.empty(),n):this.ref.compile(e)},t}(t.Expression);e.Unknown=V;var q=function(e){function t(t,n){e.call(this),this.ref=t,this.args=n,this.type="helper"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(new B(n),J.fromSpec(r,i,Q))},t.build=function(e,t,n){return new this(B.build(e),J.build(t,n,Q))},t.prototype.compile=function(e,t,n){if(t.hasHelper(this.ref.parts,n)){var r=this.args,i=this.ref;return new h.default(i.parts,t.lookupHelper(i.parts,n),r.compile(e,t,n),n)}throw new Error("Compile Error: "+this.ref.parts.join(".")+" is not a helper")},t}(t.Expression);e.Helper=q;var G=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new p.CompiledGetBlockBySymbol(r,n);return new p.default(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new p.CompiledInPartialGetBlock(r,n);return new p.default(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlock=G;var W=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block-params"}return babelHelpers.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new p.CompiledGetBlockBySymbol(r,n);return new p.CompiledHasBlockParams(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new p.CompiledInPartialGetBlock(r,n);return new p.CompiledHasBlockParams(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlockParams=W;var K=function(){function e(e){this.parts=e,this.type="concat"}return e.fromSpec=function(t){var n=t[1];return new e(n.map(a.default))},e.build=function(e){return new this(e)},e.prototype.compile=function(e,t,n){return new f.default(this.parts.map(function(r){return r.compile(e,t,n)}))},e}();e.Concat=K;var Y=function(){function e(e){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1];this.type="blocks",this.default=e,this.inverse=t}return e.fromSpec=function(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];return new e(t,n)},e.empty=function(){return Q},e}();e.Blocks=Y;var Q=new(function(e){function t(){e.call(this,null,null)}return babelHelpers.inherits(t,e),t}(Y));e.EMPTY_BLOCKS=Q;var J=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.type="args"}return e.empty=function(){return te},e.fromSpec=function(t,n,r){return new e($.fromSpec(t),X.fromSpec(n),r)},e.fromPositionalArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?Q:arguments[1];return new e(t,ee,n)},e.fromNamedArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?Q:arguments[1];return new e(Z,t,n)},e.build=function(e,t,n){return e===Z&&t===ee&&n===Q?te:new this(e,t,n)},e.prototype.compile=function(e,t,n){var r=this.positional,i=this.named,o=this.blocks;return u.CompiledArgs.create(r.compile(e,t,n),i.compile(e,t,n),o)},e}();e.Args=J;var $=function(){function e(e){this.values=e,this.type="positional",this.length=e.length}return e.empty=function(){return Z},e.fromSpec=function(t){return t&&0!==t.length?new e(t.map(a.default)):Z},e.build=function(e){return 0===e.length?Z:new this(e)},e.prototype.slice=function(t,n){return e.build(this.values.slice(t,n))},e.prototype.at=function(e){return this.values[e]},e.prototype.compile=function(e,t,n){return u.CompiledPositionalArgs.create(this.values.map(function(r){return r.compile(e,t,n)}))},e}();e.PositionalArgs=$;var Z=new(function(e){function t(){e.call(this,m.EMPTY_ARRAY)}return babelHelpers.inherits(t,e),t.prototype.slice=function(e,t){return this},t.prototype.at=function(e){},t.prototype.compile=function(e,t){return u.CompiledPositionalArgs.empty()},t}($)),X=function(){function e(e,t){this.keys=e,this.values=t,this.type="named",this.length=e.length}return e.empty=function(){return ee},e.fromSpec=function(e){if(null===e||void 0===e)return ee;var t=e[0],n=e[1];return 0===t.length?ee:new this(t,n.map(function(e){return a.default(e)}))},e.build=function(e,t){return 0===e.length?ee:new this(e,t)},e.prototype.at=function(e){var t=this.keys,n=this.values,r=t.indexOf(e);return n[r]},e.prototype.has=function(e){return this.keys.indexOf(e)!==-1},e.prototype.compile=function(e,t,n){var r=this.keys,i=this.values;return new u.CompiledNamedArgs(r,i.map(function(r){return r.compile(e,t,n)}))},e}();e.NamedArgs=X;var ee=new(function(e){function t(){e.call(this,m.EMPTY_ARRAY,m.EMPTY_ARRAY)}return babelHelpers.inherits(t,e),t.prototype.at=function(e){},t.prototype.has=function(e){return!1},t.prototype.compile=function(e,t){return u.CompiledNamedArgs.empty()},t}(X)),te=new(function(e){function t(){e.call(this,Z,ee,Q)}return babelHelpers.inherits(t,e),t.prototype.compile=function(e,t){return u.CompiledArgs.empty()},t}(J))}),s("glimmer-runtime/lib/syntax/expressions",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Expressions.isArg,i=n.Expressions.isConcat,o=n.Expressions.isGet,s=n.Expressions.isHasBlock,a=n.Expressions.isHasBlockParams,u=n.Expressions.isHelper,l=n.Expressions.isUnknown,c=n.Expressions.isPrimitiveValue,p=n.Expressions.isUndefined;e.default=function(e){if(c(e))return t.Value.fromSpec(e);if(p(e))return t.Value.build(void 0);if(r(e))return t.GetArgument.fromSpec(e);if(i(e))return t.Concat.fromSpec(e);if(o(e))return t.Get.fromSpec(e);if(u(e))return t.Helper.fromSpec(e);if(l(e))return t.Unknown.fromSpec(e);if(s(e))return t.HasBlock.fromSpec(e);if(a(e))return t.HasBlockParams.fromSpec(e);throw new Error("Unexpected wire format: "+JSON.stringify(e))}}),s("glimmer-runtime/lib/syntax/statements",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Statements.isYield,i=n.Statements.isBlock,o=n.Statements.isPartial,s=n.Statements.isAppend,a=n.Statements.isDynamicAttr,u=n.Statements.isText,l=n.Statements.isComment,c=n.Statements.isOpenElement,p=n.Statements.isFlushElement,h=n.Statements.isCloseElement,f=n.Statements.isStaticAttr,m=n.Statements.isModifier,d=n.Statements.isDynamicArg,g=n.Statements.isStaticArg,v=n.Statements.isTrustingAttr;e.default=function(e,n,y){return r(e)?t.Yield.fromSpec(e):o(e)?t.Partial.fromSpec(e):i(e)?t.Block.fromSpec(e,n,y):s(e)?t.OptimizedAppend.fromSpec(e):a(e)?t.DynamicAttr.fromSpec(e):d(e)?t.DynamicArg.fromSpec(e):v(e)?t.TrustingAttr.fromSpec(e):u(e)?t.Text.fromSpec(e):l(e)?t.Comment.fromSpec(e):c(e)?t.OpenElement.fromSpec(e,n):p(e)?t.FlushElement.fromSpec():h(e)?t.CloseElement.fromSpec():f(e)?t.StaticAttr.fromSpec(e):g(e)?t.StaticArg.fromSpec(e):m(e)?t.Modifier.fromSpec(e):void 0}}),s("glimmer-runtime/lib/template",["exports","glimmer-util","glimmer-runtime/lib/builder","glimmer-runtime/lib/vm","glimmer-runtime/lib/scanner"],function(e,t,n,r,i){"use strict";function o(e){var n=e.id,r=e.meta,i=e.block,o=void 0;n||(n="client-"+a++);var u=function(e,a){var u=a?t.assign({},a,r):r;return o||(o=JSON.parse(i)),s(o,n,u,e)};return{id:n,meta:r,create:u}}function s(e,t,o,s){var a=new i.default(e,o,s),u=void 0,l=function(){return u||(u=a.scanEntryPoint()),u},c=void 0,p=function(){return c||(c=a.scanLayout()),c},h=function(e){return a.scanPartial(e)},f=function(e,t,i){var o=n.ElementStack.forInitialRender(s,t,null),a=l().compile(s),u=r.VM.initial(s,e,i,o,a.symbols);return u.execute(a.ops)};return{id:t,meta:o,_block:e,asEntryPoint:l,asLayout:p,asPartial:h,render:f}}e.default=o;var a=0}),s("glimmer-runtime/lib/upsert",["exports","glimmer-runtime/lib/bounds"],function(e,t){"use strict";function n(e){return e&&"function"==typeof e.toHTML}function r(e){return null!==e&&"object"==typeof e&&"number"==typeof e.nodeType}function i(e){return"string"==typeof e}function o(e,t,o){return i(o)?u.insert(e,t,o):n(o)?c.insert(e,t,o):r(o)?p.insert(e,t,o):void 0}function s(e,t,n){return i(n)?l.insert(e,t,n):r(n)?p.insert(e,t,n):void 0}e.isSafeString=n,e.isNode=r,e.isString=i,e.cautiousInsert=o,e.trustingInsert=s;var a=function(e){this.bounds=e};e.default=a;var u=function(e){function n(t,n){e.call(this,t),this.textNode=n}return babelHelpers.inherits(n,e),n.insert=function(e,r,i){var o=e.createTextNode(i);e.insertBefore(r.element,o,r.nextSibling);var s=new t.SingleNodeBounds(r.element,o);return new n(s,o)},n.prototype.update=function(e,t){if(i(t)){var n=this.textNode;return n.nodeValue=t,!0}return!1},n}(a),l=function(e){function n(){e.apply(this,arguments)}return babelHelpers.inherits(n,e),n.insert=function(e,t,r){var i=e.insertHTMLBefore(t.element,r,t.nextSibling);return new n(i)},n.prototype.update=function(e,n){if(i(n)){var r=this.bounds,o=r.parentElement(),s=t.clear(r);return this.bounds=e.insertHTMLBefore(o,s,n),!0}return!1},n}(a),c=function(e){function r(t,n){e.call(this,t),this.lastStringValue=n}return babelHelpers.inherits(r,e),r.insert=function(e,t,n){var i=n.toHTML(),o=e.insertHTMLBefore(t.element,i,t.nextSibling);return new r(o,i)},r.prototype.update=function(e,r){if(n(r)){var i=r.toHTML();if(i!==this.lastStringValue){var o=this.bounds,s=o.parentElement(),a=t.clear(o);this.bounds=e.insertHTMLBefore(s,a,i),this.lastStringValue=i}return!0}return!1},r}(a),p=function(e){function n(){e.apply(this,arguments)}return babelHelpers.inherits(n,e),n.insert=function(e,r,i){return e.insertBefore(r.element,i,r.nextSibling),new n(t.single(r.element,i))},n.prototype.update=function(e,n){if(r(n)){var i=this.bounds,o=i.parentElement(),s=t.clear(i);return this.bounds=e.insertNodeBefore(o,n,s),!0}return!1},n}(a)}),s("glimmer-runtime/lib/utils",["exports","glimmer-util"],function(e,t){"use strict";var n=Object.freeze([]);e.EMPTY_ARRAY=n;var r=Object.freeze(t.dict());e.EMPTY_DICT=r;var i=function(){function e(e,t,n){this.list=e,this.start=t,this.end=n}return e.prototype.at=function(e){return e>=this.list.length?null:this.list[e]},e.prototype.min=function(){return this.start},e.prototype.max=function(){return this.end},e}();e.ListRange=i}),s("glimmer-runtime/lib/vm",["exports","glimmer-runtime/lib/vm/append","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result"],function(e,t,n,r){"use strict";e.VM=t.default,e.PublicVM=t.PublicVM,e.UpdatingVM=n.default,e.RenderResult=r.default}),s("glimmer-runtime/lib/vm/append",["exports","glimmer-runtime/lib/environment","glimmer-util","glimmer-reference","glimmer-runtime/lib/compiled/opcodes/vm","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result","glimmer-runtime/lib/vm/frame"],function(e,t,n,r,i,o,s,a){"use strict";var u=function(){function e(e,t,r,i){this.env=e,this.elementStack=i,this.dynamicScopeStack=new n.Stack,this.scopeStack=new n.Stack,this.updatingOpcodeStack=new n.Stack,this.cacheGroups=new n.Stack,this.listBlockStack=new n.Stack,this.frame=new a.FrameStack,this.env=e,this.elementStack=i,this.scopeStack.push(t),this.dynamicScopeStack.push(r)}return e.initial=function(n,r,i,o,s){var a=t.Scope.root(r,s);return new e(n,a,i,o)},e.prototype.capture=function(){return{env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()}},e.prototype.goto=function(e){this.frame.goto(e)},e.prototype.beginCacheGroup=function(){this.cacheGroups.push(this.updatingOpcodeStack.current.tail())},e.prototype.commitCacheGroup=function(){var e=new i.LabelOpcode("END"),t=this.updatingOpcodeStack.current,o=this.cacheGroups.pop(),s=o?t.nextNode(o):t.head(),a=t.tail(),u=r.combineSlice(new n.ListSlice(s,a)),l=new i.JumpIfNotModifiedOpcode(u,e);t.insertBefore(l,s),t.append(new i.DidModifyOpcode(l)),t.append(e)},e.prototype.enter=function(e){var t=new n.LinkedList,r=this.stack().pushUpdatableBlock(),i=this.capture(),s=new o.TryOpcode(e,i,r,t);this.didEnter(s,t)},e.prototype.enterWithKey=function(e,t){var r=new n.LinkedList,i=this.stack().pushUpdatableBlock(),s=this.capture(),a=new o.TryOpcode(t,s,i,r);this.listBlockStack.current.map[e]=a,this.didEnter(a,r)},e.prototype.enterList=function(e){var t=new n.LinkedList,r=this.stack().pushBlockList(t),i=this.capture(),s=this.frame.getIterator().artifacts,a=new o.ListBlockOpcode(e,i,r,t,s);this.listBlockStack.push(a),this.didEnter(a,t)},e.prototype.didEnter=function(e,t){this.updateWith(e),this.updatingOpcodeStack.push(t)},e.prototype.exit=function(){this.stack().popBlock(),this.updatingOpcodeStack.pop();var e=this.updatingOpcodeStack.current.tail();e.didInitializeChildren()},e.prototype.exitList=function(){this.exit(),this.listBlockStack.pop()},e.prototype.updateWith=function(e){this.updatingOpcodeStack.current.append(e)},e.prototype.stack=function(){return this.elementStack},e.prototype.scope=function(){return this.scopeStack.current},e.prototype.dynamicScope=function(){return this.dynamicScopeStack.current},e.prototype.pushFrame=function(e,t,n){this.frame.push(e.ops),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushComponentFrame=function(e,t,n,r,i,o){this.frame.push(e.ops,r,i,o),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushEvalFrame=function(e){this.frame.push(e)},e.prototype.pushChildScope=function(){this.scopeStack.push(this.scopeStack.current.child())},e.prototype.pushCallerScope=function(){this.scopeStack.push(this.scope().getCallerScope())},e.prototype.pushDynamicScope=function(){var e=this.dynamicScopeStack.current.child();return this.dynamicScopeStack.push(e),e},e.prototype.pushRootScope=function(e,n){var r=t.Scope.root(e,n);return this.scopeStack.push(r),r},e.prototype.popScope=function(){this.scopeStack.pop()},e.prototype.popDynamicScope=function(){this.dynamicScopeStack.pop()},e.prototype.newDestroyable=function(e){this.stack().newDestroyable(e)},e.prototype.getSelf=function(){return this.scope().getSelf()},e.prototype.referenceForSymbol=function(e){return this.scope().getSymbol(e)},e.prototype.getArgs=function(){return this.frame.getArgs()},e.prototype.resume=function(e,t){return this.execute(e,function(e){return e.frame.restore(t)})},e.prototype.execute=function(e,t){n.LOGGER.debug("[VM] Begin program execution");var r=this.elementStack,i=this.frame,o=this.updatingOpcodeStack,a=this.env;r.pushSimpleBlock(),o.push(new n.LinkedList),i.push(e),t&&t(this);for(var u=void 0;i.hasOpcodes();)(u=i.nextStatement())&&(n.LOGGER.debug("[VM] OP "+u.type),n.LOGGER.trace(u),u.evaluate(this));return n.LOGGER.debug("[VM] Completed program execution"),new s.default(a,o.pop(),r.popBlock())},e.prototype.evaluateOpcode=function(e){e.evaluate(this)},e.prototype.invokeBlock=function(e,t){var n=e.compile(this.env);this.pushFrame(n,t)},e.prototype.invokePartial=function(e){var t=e.compile(this.env);this.pushFrame(t)},e.prototype.invokeLayout=function(e,t,n,r,i,o){this.pushComponentFrame(t,e,n,r,i,o)},e.prototype.evaluateOperand=function(e){this.frame.setOperand(e.evaluate(this))},e.prototype.evaluateArgs=function(e){var t=this.frame.setArgs(e.evaluate(this));this.frame.setOperand(t.positional.at(0))},e.prototype.bindPositionalArgs=function(e){var t=this.frame.getArgs();n.assert(t,"Cannot bind positional args");for(var r=t.positional,i=this.scope(),o=0;o2&&"[]"===s.slice(a-2)&&(u=!0,s=s.slice(0,a-2),n[s]||(n[s]=[])),i=o[1]?O(o[1]):""),u?n[s].push(i):n[s]=i}return n},recognize:function(e){var t,n,r,i,o=[this.rootState],s={},u=!1;if(i=e.indexOf("#"),i!==-1&&(e=e.substr(0,i)),r=e.indexOf("?"),r!==-1){var l=e.substr(r+1,e.length);e=e.substr(0,r),s=this.parseQueryString(l)}"/"!==e.charAt(0)&&(e="/"+e);var c=e;for(T.ENCODE_AND_DECODE_PATH_SEGMENTS?e=a(e):(e=decodeURI(e),c=decodeURI(c)),t=e.length,t>1&&"/"===e.charAt(t-1)&&(e=e.substr(0,t-1),c=c.substr(0,c.length-1),u=!0),n=0;n0&&e[r-1]&&e[r-1].hasOwnProperty("queryParams")?(n=e[r-1].queryParams,t=B.call(e,0,r-1),[t,n]):[e,null]}function s(e){for(var t in e)if("number"==typeof e[t])e[t]=""+e[t];else if(z(e[t]))for(var n=0,r=e[t].length;n=0;a--){var l=t[a],c=l.handler;if(c){if(c.events&&c.events[o]){if(c.events[o].apply(c,r)!==!0)return;s=!0}}else l.handlerPromise.then(u(null,i,o,r))}if("error"===o&&"UnrecognizedURLError"===r[0].name)throw r[0];if(!s&&!n)throw new Error("Nothing handled the event '"+o+"'.")}function h(e,t){var n,r={all:{},changed:{},removed:{}};i(r.all,t);var o=!1;s(e),s(t);for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(o=!0,r.removed[n]=e[n]));for(n in t)if(t.hasOwnProperty(n))if(z(e[n])&&z(t[n]))if(e[n].length!==t[n].length)r.changed[n]=t[n],o=!0;else for(var a=0,u=e[n].length;a=0;--u){var l=o[u];i(a,l.params),l.handler.inaccessibleByURL&&(n=null)}if(n){a.queryParams=e._visibleQueryParams||t.queryParams;var c=r.recognizer.generate(s,a),p=e.isCausedByInitialTransition,h="replace"===n&&!e.isCausedByAbortingTransition;p||h?r.replaceURL(c):r.updateURL(c)}}}function L(e,t){try{a(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var r=e.router,i=t.handlerInfos;return R(r,t,e),e.isAborted?(r.state.handlerInfos=r.currentHandlerInfos,n.Promise.reject(E(e))):(I(e,t,e.intent.url),e.isActive=!1,r.activeTransition=null,p(r,r.currentHandlerInfos,!0,["didTransition"]),r.didTransition&&r.didTransition(r.currentHandlerInfos),a(r,e.sequence,"TRANSITION COMPLETE."),i[i.length-1].handler)}catch(t){if(!(t instanceof b)){var o=e.state.handlerInfos;e.trigger(!0,"error",t,e,o[o.length-1].handler),e.abort()}throw t}}function M(e,t,n){var r=t[0]||"/",i=t[t.length-1],o={};i&&i.hasOwnProperty("queryParams")&&(o=J.call(t).queryParams);var s;if(0===t.length){a(e,"Updating query params");var u=e.state.handlerInfos;s=new Y({name:u[u.length-1].name,contexts:[],queryParams:o})}else"/"===r.charAt(0)?(a(e,"Attempting URL transition to "+r),s=new Q({url:r})):(a(e,"Attempting transition to "+r),s=new Y({name:t[0],contexts:B.call(t,1),queryParams:o}));return e.transitionByIntent(s,n)}function j(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n=r.length?r.length-1:t.resolveIndex;return n.Promise.reject({error:e,handlerWithError:u.handlerInfos[i].handler,wasAborted:l,state:u})}function o(e){var n=u.handlerInfos[t.resolveIndex].isResolved;if(u.handlerInfos[t.resolveIndex++]=e,!n){var i=e.handler;g(i,"redirect",e.context,t)}return r().then(s,null,u.promiseLabel("Resolve handler"))}function s(){if(t.resolveIndex===u.handlerInfos.length)return{error:null,state:u};var e=u.handlerInfos[t.resolveIndex];return e.resolve(r,t).then(o,null,u.promiseLabel("Proceed"))}var a=this.params;c(this.handlerInfos,function(e){a[e.name]=e.params||{}}),t=t||{},t.resolveIndex=0;var u=this,l=!1;return n.Promise.resolve(null,this.promiseLabel("Start transition")).then(s,null,this.promiseLabel("Resolve handler")).catch(i,this.promiseLabel("Handle error"))}},b.prototype=V(Error.prototype),_.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:!1,isTransition:!0,isExiting:function(e){for(var t=this.handlerInfos,n=0,r=t.length;n=0;--u){var f=t[u],m=f.handler,d=e.handlerInfos[u],g=null;if(f.names.length>0)if(u>=h)g=this.createParamHandlerInfo(m,n,f.names,p,d);else{var v=a(m);g=this.getHandlerInfoForDynamicSegment(m,n,f.names,p,d,r,u,v); -}else g=this.createParamHandlerInfo(m,n,f.names,p,d);if(s){g=g.becomeResolved(null,g.context);var b=d&&d.context;f.names.length>0&&g.context===b&&(g.params=d&&d.params),g.context=b}var _=d;(u>=h||g.shouldSupercede(d))&&(h=Math.min(u,h),_=g),o&&!s&&(_=_.becomeResolved(null,_.context)),c.handlerInfos.unshift(_)}if(p.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+r);return o||this.invalidateChildren(c.handlerInfos,h),i(c.queryParams,this.queryParams||{}),c},invalidateChildren:function(e,t){for(var n=t,r=e.length;n0){if(u=r[r.length-1],l(u))return this.createParamHandlerInfo(e,t,n,r,i);r.pop()}else{if(i&&i.name===e)return i;if(!this.preTransitionState)return i;var c=this.preTransitionState.handlerInfos[s];u=c&&c.context}return C("object",{name:e,getHandler:t,serializer:a,context:u,names:n})},createParamHandlerInfo:function(e,t,n,r,i){for(var o={},s=n.length;s--;){var a=i&&e===i.name&&i.params||{},u=r[r.length-1],c=n[s];if(l(u))o[c]=""+r.pop();else{if(!a.hasOwnProperty(c))throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e);o[c]=a[c]}}return C("param",{name:e,getHandler:t,params:o})}});A.prototype=V(Error.prototype);var Q=m(O,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,t,n){function r(e){if(e&&e.inaccessibleByURL)throw new A(c);return e}var o,s,a=new y,u=t.recognize(this.url);if(!u)throw new A(this.url);var l=!1,c=this.url;for(o=0,s=u.length;o=0&&r;--n){var i=t[n];e.add(t,{as:i.handler}),r="/"===i.path||""===i.path||".index"===i.handler.slice(-6)}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,t,n,r){var i=this;if(N(this,r,e),!t&&this.activeTransition)return this.activeTransition;var o=new _(this);return o.queryParamsOnly=!0,n.queryParams=H(this,r.handlerInfos,r.queryParams,o),o.promise=o.promise.then(function(e){return I(o,n,!0),i.didTransition&&i.didTransition(i.currentHandlerInfos),e},null,f("Transition complete")),o},transitionByIntent:function(e){try{return T.apply(this,arguments)}catch(t){return new _(this,e,null,t)}},reset:function(){this.state&&c(this.state.handlerInfos.slice().reverse(),function(e){var t=e.handler;g(t,"exit")}),this.oldState=void 0,this.state=new y,this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var t=B.call(arguments);return"/"!==e.charAt(0)&&(t[0]="/"+e),M(this,t).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return M(this,arguments)},intermediateTransitionTo:function(){return M(this,arguments,!0)},refresh:function(e){for(var t=this.activeTransition?this.activeTransition.state:this.state,n=t.handlerInfos,r={},i=0,o=n.length;i1)throw new Error("Second argument not supported");if("object"!=typeof e)throw new TypeError("Argument must be an object");return a.prototype=e,new a},Ce=[],Ae=void 0,ke=1,Te=2,Ne=new S,Re=new S;N.prototype._validateInput=function(e){return Oe(e)},N.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},N.prototype._init=function(){this._result=new Array(this.length)},N.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===Ae&&r=t[n]?i=n+2:o=n;return e>=t[i]?i+2:i}function a(e,t,n){this.name=e,this.globalOptions=n||{},this.options=t,this._queue=[],this.targetQueues={},this._queueBeingFlushed=void 0}function u(e,n){var r=this.queues={};this.queueNames=e=e||[],this.options=n,t(e,function(e){r[e]=new a(e,n[e],n)})}function l(e){throw new Error("You attempted to schedule an action in a queue ("+e+") that doesn't exist")}function c(e){throw new Error("You attempted to schedule an action in a queue ("+e+") for a method that doesn't exist")}function p(e,t){this.queueNames=e,this.options=t||{},this.options.defaultQueue||(this.options.defaultQueue=e[0]),this.instanceStack=[],this._debouncees=[],this._throttlers=[],this._eventCallbacks={end:[],begin:[]};var n=this;this._boundClearItems=function(){v()},this._timerTimeoutId=void 0,this._timers=[],this._platform=this.options._platform||{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){clearTimeout(e)}},this._boundRunExpiredTimers=function(){n._runExpiredTimers()}}function h(e){return e.onError||e.onErrorTarget&&e.onErrorTarget[e.onErrorMethod]}function f(e){var t=e._platform.setTimeout;e.begin(),e._autorun=t(function(){e._autorun=null,e.end()},0)}function m(e,t,n){return g(e,t,n)}function d(e,t,n){return g(e,t,n)}function g(e,t,n){for(var r,i=-1,o=0,s=n.length;o0?t.apply(e,n):t.call(e)},invokeWithOnError:function(e,t,n,r,i){try{n&&n.length>0?t.apply(e,n):t.call(e)}catch(e){r(e,i)}},flush:function(e){var t=this._queue,r=t.length;if(0!==r){var i,o,s,a,u=this.globalOptions,l=this.options,c=l&&l.before,p=l&&l.after,h=u.onError||u.onErrorTarget&&u.onErrorTarget[u.onErrorMethod],f=h?this.invokeWithOnError:this.invoke;this.targetQueues=Object.create(null);var m=this._queueBeingFlushed=this._queue.slice();this._queue=[],c&&c();for(var d=0;d0&&this.flush(!0)}},cancel:function(e){var t,n,r,i,o=this._queue,s=e.target,a=e.method,u=this.globalOptions.GUID_KEY;if(u&&this.targetQueues&&s){var l=this.targetQueues[s[u]];if(l)for(r=0,i=l.length;r2){r=new Array(i-2);for(var o=0,s=i-2;o3){i=new Array(o-3);for(var a=3;a3){i=new Array(o-3);for(var a=3;a-1?this._throttlers[l]:(c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=d(e,t,r._throttlers);n>-1&&r._throttlers.splice(n,1)},a),p&&this.run.apply(this,o),u=[e,t,c],this._throttlers.push(u),u)},debounce:function(e,t){for(var r=this,o=new Array(arguments.length),s=0;s-1&&(l=this._debouncees[u],this._debouncees.splice(u,1),this._platform.clearTimeout(l[2])),c=this._platform.setTimeout(function(){p||r.run.apply(r,o);var n=m(e,t,r._debouncees);n>-1&&r._debouncees.splice(n,1)},a),p&&u===-1&&r.run.apply(r,o),l=[e,t,c],r._debouncees.push(l),l},cancelTimers:function(){t(this._throttlers,this._boundClearItems),this._throttlers=[],t(this._debouncees,this._boundClearItems),this._debouncees=[],this._clearTimerTimeout(),this._timers=[],this._autorun&&(this._platform.clearTimeout(this._autorun),this._autorun=null)},hasTimers:function(){return!!this._timers.length||!!this._debouncees.length||!!this._throttlers.length||this._autorun},cancel:function(e){var t=typeof e;if(e&&"object"===t&&e.queue&&e.method)return e.queue.cancel(e);if("function"!==t)return"[object Array]"===Object.prototype.toString.call(e)?this._cancelItem(d,this._throttlers,e)||this._cancelItem(m,this._debouncees,e):void 0;for(var n=0,r=this._timers.length;n-1&&(r=t[i],r[2]===n[2])&&(t.splice(i,1),this._platform.clearTimeout(n[2]),!0))},_runExpiredTimers:function(){this._timerTimeoutId=void 0,this.run(this,this._scheduleExpiredTimers)},_scheduleExpiredTimers:function(){for(var e=Date.now(),t=this._timers,n=0,r=t.length;n1){for(var t=arguments[0],n=[],r=void 0,i=1;i0?v(this,this.registry.normalize(e)):g(this)},ownerInjection:function(){var e;return e={},e[t.OWNER]=this.owner,e}}}),s("container/index",["exports","container/registry","container/container"],function(e,t,n){"use strict";e.Registry=t.default,e.privatize=t.privatize,e.Container=n.default,e.buildFakeContainerWithDeprecations=n.buildFakeContainerWithDeprecations}),s("container/registry",["exports","ember-utils","ember-metal","container/container"],function(e,t,n,r){"use strict";function i(e){this.fallback=e&&e.fallback?e.fallback:null,e&&e.resolver&&(this.resolver=e.resolver,"function"==typeof this.resolver&&o(this)),this.registrations=t.dictionary(e&&e.registrations?e.registrations:null),this._typeInjections=t.dictionary(null),this._injections=t.dictionary(null),this._factoryTypeInjections=t.dictionary(null),this._factoryInjections=t.dictionary(null),this._localLookupCache=new t.EmptyObject,this._normalizeCache=t.dictionary(null),this._resolveCache=t.dictionary(null),this._failCache=t.dictionary(null),this._options=t.dictionary(null),this._typeOptions=t.dictionary(null)}function o(e){e.resolver={resolve:e.resolver}}function s(e,n,r){var i=e._localLookupCache,o=i[n];o||(o=i[n]=new t.EmptyObject);var s=o[r];if(void 0!==s)return s;var a=e.resolver.expandLocalLookup(n,r);return o[r]=a}function a(e,t,n){if(!n||!n.source||(t=e.expandLocalLookup(t,n))){var r=e._resolveCache[t];if(void 0!==r)return r;if(!e._failCache[t]){var i=void 0;return e.resolver&&(i=e.resolver.resolve(t)),void 0===i&&(i=e.registrations[t]),void 0===i?e._failCache[t]=!0:e._resolveCache[t]=i,i}}}function u(e,t,n){return void 0!==e.resolve(t,{source:n})}function l(e){var n=e[0],r=p[n];if(r)return r;var i=n.split(":"),o=i[0],s=i[1];return p[n]=t.intern(o+":"+s+"-"+h)}e.default=i,e.privatize=l;var c=/^[^:]+:[^:]+$/;i.prototype={fallback:null,resolver:null,registrations:null,_typeInjections:null,_injections:null,_factoryTypeInjections:null,_factoryInjections:null,_normalizeCache:null,_resolveCache:null,_options:null,_typeOptions:null,container:function(e){return new r.default(this,e)},register:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(void 0===t)throw new TypeError("Attempting to register an unknown factory: '"+e+"'");var r=this.normalize(e);if(this._resolveCache[r])throw new Error("Cannot re-register: '"+e+"', as it has already been resolved.");delete this._failCache[r],this.registrations[r]=t,this._options[r]=n},unregister:function(e){var n=this.normalize(e);this._localLookupCache=new t.EmptyObject,delete this.registrations[n],delete this._resolveCache[n],delete this._failCache[n],delete this._options[n]},resolve:function(e,t){var n=a(this,this.normalize(e),t);if(void 0===n&&this.fallback){var r;n=(r=this.fallback).resolve.apply(r,arguments)}return n},describe:function(e){return this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(e):this.fallback?this.fallback.describe(e):e},normalizeFullName:function(e){return this.resolver&&this.resolver.normalize?this.resolver.normalize(e):this.fallback?this.fallback.normalizeFullName(e):e},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this.normalizeFullName(e))},makeToString:function(e,t){return this.resolver&&this.resolver.makeToString?this.resolver.makeToString(e,t):this.fallback?this.fallback.makeToString(e,t):e.toString()},has:function(e,t){if(!this.isValidFullName(e))return!1;var n=t&&t.source&&this.normalize(t.source);return u(this,this.normalize(e),n)},optionsForType:function(e,t){this._typeOptions[e]=t},getOptionsForType:function(e){var t=this._typeOptions[e];return void 0===t&&this.fallback&&(t=this.fallback.getOptionsForType(e)),t},options:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=this.normalize(e);this._options[n]=t},getOptions:function(e){var t=this.normalize(e),n=this._options[t];return void 0===n&&this.fallback&&(n=this.fallback.getOptions(e)),n},getOption:function(e,t){var n=this._options[e];if(n&&void 0!==n[t])return n[t];var r=e.split(":")[0];return n=this._typeOptions[r],n&&void 0!==n[t]?n[t]:this.fallback?this.fallback.getOption(e,t):void 0},typeInjection:function(e,t,n){var r=n.split(":")[0];if(r===e)throw new Error("Cannot inject a '"+n+"' on other "+e+"(s).");var i=this._typeInjections[e]||(this._typeInjections[e]=[]);i.push({property:t,fullName:n})},injection:function(e,t,n){this.validateFullName(n);var r=this.normalize(n);if(e.indexOf(":")===-1)return this.typeInjection(e,t,r);var i=this.normalize(e),o=this._injections[i]||(this._injections[i]=[]);o.push({property:t,fullName:r})},factoryTypeInjection:function(e,t,n){var r=this._factoryTypeInjections[e]||(this._factoryTypeInjections[e]=[]);r.push({property:t,fullName:this.normalize(n)})},factoryInjection:function(e,t,n){var r=this.normalize(e),i=this.normalize(n);if(this.validateFullName(n),e.indexOf(":")===-1)return this.factoryTypeInjection(r,t,i);var o=this._factoryInjections[r]||(this._factoryInjections[r]=[]);o.push({property:t,fullName:i})},knownForType:function(e){for(var n=void 0,r=void 0,i=t.dictionary(null),o=Object.keys(this.registrations),s=0;s0){var s="cycle detected: "+t;throw this.each(function(e){s+=" <- "+e}),new Error(s)}}},e.prototype.each=function(e){for(var t=this,n=t.result,r=t.vertices,i=0;i-1&&(i=i.replace(/\.(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("_")>-1&&(i=i.replace(/_(.)/g,function(e){return e.charAt(1).toUpperCase()})),r.indexOf("-")>-1&&(i=i.replace(/-(.)/g,function(e){return e.charAt(1).toUpperCase()})),n+":"+i}return e},resolve:function(e){var t,n=this.parseName(e),r=n.resolveMethodName;return this[r]&&(t=this[r](n)),t=t||this.resolveOther(n),n.root&&n.root.LOG_RESOLVER&&this._logLookup(t,n),t&&i.default(t,n),t},parseName:function(e){return this._parseNameCache[e]||(this._parseNameCache[e]=this._parseName(e))},_parseName:function(e){var t=e.split(":"),i=t[0],o=t[1],s=o,a=n.get(this,"namespace"),u=a,l=s.lastIndexOf("/"),c=l!==-1?s.slice(0,l):null;if("template"!==i&&l!==-1){var p=s.split("/");s=p[p.length-1];var h=r.String.capitalize(p.slice(0,-1).join("."));u=r.Namespace.byName(h)}var f="main"===o?"Main":r.String.classify(i);if(!s||!i)throw new TypeError("Invalid fullName: `"+e+"`, must be of the form `type:name` ");return{fullName:e,type:i,fullNameWithoutType:o,dirname:c,name:s,root:u,resolveMethodName:"resolve"+f}},lookupDescription:function(e){var t=this.parseName(e),n=void 0;return"template"===t.type?"template at "+t.fullNameWithoutType.replace(/\./g,"/"):(n=t.root+"."+r.String.classify(t.name).replace(/\./g,""),"model"!==t.type&&(n+=r.String.classify(t.type)),n)},makeToString:function(e,t){return e.toString()},useRouterNaming:function(e){e.name=e.name.replace(/\./g,"_"),"basic"===e.name&&(e.name="")},resolveTemplate:function(e){var t=e.fullNameWithoutType.replace(/\./g,"/");return o.getTemplate(t)||o.getTemplate(r.String.decamelize(t))},resolveView:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveController:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveRoute:function(e){return this.useRouterNaming(e),this.resolveOther(e)},resolveModel:function(e){var t=r.String.classify(e.name),i=n.get(e.root,t);return i},resolveHelper:function(e){return this.resolveOther(e)},resolveOther:function(e){var t=r.String.classify(e.name)+r.String.classify(e.type),i=n.get(e.root,t);return i},resolveMain:function(e){var t=r.String.classify(e.type);return n.get(e.root,t)},_logLookup:function(e,t){var n=void 0,r=void 0;n=e?"[✓]":"[ ]",r=t.fullName.length>60?".":new Array(60-t.fullName.length).join(".")},knownForType:function(e){for(var i=n.get(this,"namespace"),o=r.String.classify(e),s=new RegExp(o+"$"),a=t.dictionary(null),u=Object.keys(i),l=0;l1?this.set("models",this._getModels(t)):this.set("models",[])}});a.toString=function(){return"LinkComponent"},a.reopenClass({positionalParams:"params"}),e.default=a}),s("ember-glimmer/components/text_area",["exports","ember-glimmer/component","ember-views","ember-glimmer/templates/empty"],function(e,t,n,r){"use strict";e.default=t.default.extend(n.TextSupport,{classNames:["ember-text-area"],layout:r.default,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","wrap","lang","dir","value"],rows:null,cols:null})}),s("ember-glimmer/components/text_field",["exports","ember-utils","ember-metal","ember-environment","ember-glimmer/component","ember-glimmer/templates/empty","ember-views"],function(e,t,n,r,i,o,s){"use strict";function a(e){if(e in l)return l[e];if(!r.environment.hasDOM)return l[e]=e,e;u||(u=document.createElement("input"));try{u.type=e}catch(e){}return l[e]=u.type===e}var u=void 0,l=new t.EmptyObject;e.default=i.default.extend(s.TextSupport,{layout:o.default,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","max","min","multiple","name","pattern","size","step","type","value","width"],value:"",type:n.computed({get:function(){return"text"},set:function(e,t){var n="text";return a(t)&&(n=t),n}}),size:null,pattern:null,min:null,max:null})}),s("ember-glimmer/dom",["exports","glimmer-runtime","glimmer-node"],function(e,t,n){"use strict";e.DOMChanges=t.DOMChanges,e.DOMTreeConstruction=t.DOMTreeConstruction,e.NodeDOMTreeConstruction=n.NodeDOMTreeConstruction}),s("ember-glimmer/environment",["exports","ember-utils","ember-metal","ember-views","glimmer-runtime","ember-glimmer/syntax/curly-component","ember-glimmer/syntax","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/iterable","ember-glimmer/utils/references","ember-glimmer/helpers/if-unless","ember-glimmer/utils/bindings","ember-glimmer/helpers/action","ember-glimmer/helpers/component","ember-glimmer/helpers/concat","ember-glimmer/helpers/debugger","ember-glimmer/helpers/get","ember-glimmer/helpers/hash","ember-glimmer/helpers/loc","ember-glimmer/helpers/log","ember-glimmer/helpers/mut","ember-glimmer/helpers/readonly","ember-glimmer/helpers/unbound","ember-glimmer/helpers/-class","ember-glimmer/helpers/-input-type","ember-glimmer/helpers/query-param","ember-glimmer/helpers/each-in","ember-glimmer/helpers/-normalize-class","ember-glimmer/helpers/-html-safe","ember-glimmer/protocol-for-url","ember-glimmer/modifiers/action"],function(e,t,n,r,i,o,s,a,u,l,p,h,f,m,d,g,v,y,b,_,w,E,O,S,x,C,A,k,T,N,R){"use strict";var P={textarea:"-text-area"},D=function(e){function D(s){var a=this,u=s[t.OWNER];e.apply(this,arguments),this.owner=u,this.isInteractive=u.lookup("-environment:main").isInteractive,this.destroyedComponents=void 0,N.default(this),this._definitionCache=new n.Cache(2e3,function(e){var t=e.name,n=e.source,i=e.owner,s=r.lookupComponent(i,t,{source:n}),a=s.component,u=s.layout;if(a||u)return new o.CurlyComponentDefinition(t,a,u)},function(e){var n=e.name,r=e.source,i=e.owner,o=r&&i._resolveLocalLookupName(n,r)||n,s=t.guidFor(i);return s+"|"+o}),this._templateCache=new n.Cache(1e3,function(e){var n=e.Template,r=e.owner;if(n.create){var i;return n.create((i={env:a},i[t.OWNER]=r,i))}return n},function(e){var n=e.Template,r=e.owner;return t.guidFor(r)+"|"+n.id}),this._compilerCache=new n.Cache(10,function(e){return new n.Cache(2e3,function(t){var n=new e(t);return i.compileLayout(n,a)},function(e){var n=e.meta.owner;return t.guidFor(n)+"|"+e.id})},function(e){return e.id}),this.builtInModifiers={action:new R.default},this.builtInHelpers={if:p.inlineIf,action:f.default,component:m.default,concat:d.default,debugger:g.default,get:v.default,hash:y.default,loc:b.default,log:_.default,mut:w.default,"query-params":C.default,readonly:E.default,unbound:O.default,unless:p.inlineUnless,"-class":S.default,"-each-in":A.default,"-input-type":x.default,"-normalize-class":k.default,"-html-safe":T.default,"-get-dynamic-var":i.getDynamicVar}}return c.inherits(D,e),D.create=function(e){return new D(e)},D.prototype.refineStatement=function(t,n){var r=e.prototype.refineStatement.call(this,t,n);if(r)return r;var i=t.appendType,u=t.isSimple,l=t.isInline,c=t.isBlock,p=(t.isModifier,t.key),f=t.path,m=t.args;if(u&&(l||c)&&"get"!==i){var d=s.findSyntaxBuilder(p);if(d)return d.create(this,m,n);var g=P[p],v=null;if(g?v=this.getComponentDefinition([g],n):p.indexOf("-")>=0&&(v=this.getComponentDefinition(f,n)),v)return h.wrapComponentClassAttribute(m),new o.CurlyComponentSyntax(m,v,n)}return l&&!u&&"helper"!==i?t.original.deopt():!u&&f?a.DynamicComponentSyntax.fromPath(this,f,m,n):void 0},D.prototype.hasComponentDefinition=function(){return!1},D.prototype.getComponentDefinition=function(e,t){var n=e[0],r=t.getMeta(),i=r.owner,o=r.moduleName&&"template:"+r.moduleName;return this._definitionCache.get({name:n,source:o,owner:i})},D.prototype.getTemplate=function(e,t){return this._templateCache.get({Template:e,owner:t})},D.prototype.getCompiledBlock=function(e,t){var n=this._compilerCache.get(e);return n.get(t)},D.prototype.hasPartial=function(e,t){var n=t.getMeta(),i=n.owner;return r.hasPartial(e,i)},D.prototype.lookupPartial=function(e,t){var n=t.getMeta(),i=n.owner,o={template:r.lookupPartial(e,i)};if(o.template)return o;throw new Error(e+" is not a partial")},D.prototype.hasHelper=function(e,t){if(e.length>1)return!1;var n=e[0];if(this.builtInHelpers[n])return!0;var r=t.getMeta(),i=r.owner,o={source:"template:"+r.moduleName};return i.hasRegistration("helper:"+n,o)||i.hasRegistration("helper:"+n)},D.prototype.lookupHelper=function(e,t){var n=e[0],r=this.builtInHelpers[n];if(r)return r;var i=t.getMeta(),o=i.owner,s=i.moduleName&&{source:"template:"+i.moduleName}||{};if(r=o.lookup("helper:"+n,s)||o.lookup("helper:"+n),r.isHelperInstance)return function(e,t){return l.SimpleHelperReference.create(r.compute,t)};if(r.isHelperFactory)return function(e,t){return l.ClassBasedHelperReference.create(r,e,t)};throw new Error(e+" is not a helper")},D.prototype.hasModifier=function(e){return!(e.length>1)&&!!this.builtInModifiers[e[0]]},D.prototype.lookupModifier=function(e){var t=this.builtInModifiers[e[0]];if(t)return t;throw new Error(e+" is not a modifier")},D.prototype.toConditionalReference=function(e){return l.ConditionalReference.create(e)},D.prototype.iterableFor=function(e,t){var n=t.named.get("key").value();return u.default(e,n)},D.prototype.scheduleInstallModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleInstallModifier).call.apply(t,[this].concat(c.slice.call(arguments)))}},D.prototype.scheduleUpdateModifier=function(){if(this.isInteractive){var t;(t=e.prototype.scheduleUpdateModifier).call.apply(t,[this].concat(c.slice.call(arguments)))}},D.prototype.didDestroy=function(e){e.destroy()},D.prototype.begin=function(){this.inTransaction=!0,e.prototype.begin.call(this),this.destroyedComponents=[]},D.prototype.commit=function(){for(var t=0;t1?n.String.dasherize(t.at(1).value()):null:o===!1?i>2?n.String.dasherize(t.at(2).value()):null:o}e.default=function(e,n){return new t.InternalHelperReference(r,n); +}}),s("ember-glimmer/helpers/-html-safe",["exports","ember-glimmer/utils/references","ember-glimmer/utils/string"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=t.at(0);return new n.SafeString(r.value())}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/-input-type",["exports","ember-glimmer/utils/references"],function(e,t){"use strict";function n(e){var t=e.positional,n=(e.named,t.at(0).value());return"checkbox"===n?"-checkbox":"-text-field"}e.default=function(e,r){return new t.InternalHelperReference(n,r)}}),s("ember-glimmer/helpers/-normalize-class",["exports","ember-glimmer/utils/references","ember-runtime"],function(e,t,n){"use strict";function r(e){var t=e.positional,r=(e.named,t.at(0).value().split(".")),i=r[r.length-1],o=t.at(1).value();return o===!0?n.String.dasherize(i):o||0===o?String(o):""}e.default=function(e,n){return new t.InternalHelperReference(r,n)}}),s("ember-glimmer/helpers/action",["exports","ember-utils","ember-glimmer/utils/references","ember-metal"],function(e,t,n,r){"use strict";function i(e,t,n,i){var o=void 0,a=i.length;return o=a>0?function(){for(var o=arguments.length,s=Array(o),u=0;u0&&(l[0]=r.get(l[0],n));var p={target:e,args:l,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",p,function(){return r.run.join.apply(r.run,[e,t].concat(l))})}:function(){for(var i=arguments.length,o=Array(i),s=0;s0&&(o[0]=r.get(o[0],n));var a={target:e,args:o,label:"glimmer-closure-action"};return r.flaggedInstrument("interaction.ember-action",a,function(){return r.run.join.apply(r.run,[e,t].concat(o))})},o[s]=!0,o}e.createClosureAction=i;var o=t.symbol("INVOKE");e.INVOKE=o;var s=t.symbol("ACTION");e.ACTION=s;var a=function(e){function t(t){e.call(this),this.args=t,this.tag=t.tag}return c.inherits(t,e),t.create=function(e){return new t(e)},t.prototype.compute=function(){var e=this.args,t=e.named,n=e.positional,s=n.value(),a=s[0],u=n.at(1),l=s[1],c=s.slice(2),p=typeof l,h=l;if(u[o])a=u,h=u[o];else{if(r.isNone(l))throw new r.Error("Action passed is null or undefined in (action) from "+a+".");if("string"===p){var f=l;if(h=null,t.has("target")&&(a=t.get("target").value()),a.actions&&(h=a.actions[f]),!h)throw new r.Error("An action named '"+f+"' was not found in "+a)}else if(h&&"function"==typeof h[o])a=h,h=h[o];else if("function"!==p){var m=u._propertyKey||l;throw new r.Error("An action could not be made for `"+m+"` in "+a+". Please confirm that you are using either a quoted action name (i.e. `(action '"+m+"')`) or a function available in "+a+".")}}var d=t.get("value").value();return i(a,h,d,c)},t}(n.CachedReference);e.ClosureActionReference=a,e.default=function(e,t){return a.create(t)}}),s("ember-glimmer/helpers/component",["exports","ember-utils","ember-glimmer/utils/references","ember-glimmer/syntax/curly-component","glimmer-runtime","ember-metal"],function(e,t,n,r,i,o){"use strict";function s(e,t){var n=a(e,t);return new r.CurlyComponentDefinition(e.name,e.ComponentClass,e.template,n)}function a(e,n){var o=e.args,s=e.ComponentClass,a=s.positionalParams,u=n.positional.values,l=u.slice(1);a&&l.length&&r.validatePositionalParameters(n.named,l,a);var c="string"==typeof a,p={};if(!c&&a&&a.length>0){for(var h=Math.min(a.length,l.length),f=0;f=0)return!0;for(var n=0;n1)if(u=a.at(0),p=a.at(1),p[i.INVOKE])c=p;else{p._propertyKey;c=p.value()}for(var h=[],f=2;f10)throw b=0,y[n].destroy(),new Error("infinite rendering invalidation detected");return b++,d.join(null,h)}b=0}var m=void 0;m=n.runInTransaction;var d=n.run.backburner,g=function(){function e(e,t,n,r){this.view=e,this.outletState=t,this.rootOutletState=n}return e.prototype.child=function(){return new e(this.view,this.outletState,this.rootOutletState)},e.prototype.get=function(e){return this.outletState},e.prototype.set=function(e,t){return this.outletState=t,t},e}(),v=function(){function e(e,t,n,r,o,s){var a=this;this.id=i.getViewId(e),this.env=t,this.root=e,this.result=void 0,this.shouldReflush=!1,this.destroyed=!1,this._removing=!1;var u=this.options={alwaysRevalidate:!1};this.render=function(){var e=a.result=n.render(r,o,s);a.render=function(){e.rerender(u)}}}return e.prototype.isFor=function(e){return this.root===e},e.prototype.destroy=function(){var e=this.result,t=this.env;if(this.destroyed=!0,this.env=null,this.root=null,this.result=null,this.render=null,e){var n=!t.inTransaction;n&&t.begin(),e.destroy(),n&&t.commit()}},e}(),y=[];n.setHasViews(function(){return y.length>0});var b=0;d.on("begin",p),d.on("end",f);var _=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?i.fallbackViewRegistry:arguments[2],r=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];this._env=e,this._rootTemplate=t,this._viewRegistry=n,this._destinedForDOM=r,this._destroyed=!1,this._roots=[],this._lastRevision=null,this._isRenderingRoots=!1,this._removedRoots=[]}return e.prototype.appendOutletView=function(e,t){var n=new a.TopLevelOutletComponentDefinition(e),r=e.toReference(),i=e.outletState.render.controller;this._appendDefinition(e,n,t,r,i)},e.prototype.appendTo=function(e,t){var n=new s.RootComponentDefinition(e);this._appendDefinition(e,n,t)},e.prototype._appendDefinition=function(e,n,i){var o=arguments.length<=3||void 0===arguments[3]?r.UNDEFINED_REFERENCE:arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4],a=new t.RootReference(n),u=new g(null,o,o,!0,s),l=new v(e,this._env,this._rootTemplate,a,i,u);this._renderRoot(l)},e.prototype.rerender=function(e){this._scheduleRevalidate()},e.prototype.register=function(e){var t=i.getViewId(e);this._viewRegistry[t]=e},e.prototype.unregister=function(e){delete this._viewRegistry[i.getViewId(e)]},e.prototype.remove=function(e){e._transitionTo("destroying"),this.cleanupRootFor(e),i.setViewElement(e,null),this._destinedForDOM&&e.trigger("didDestroyElement"),e.isDestroying||e.destroy()},e.prototype.cleanupRootFor=function(e){if(!this._destroyed)for(var t=this._roots,n=this._roots.length;n--;){var r=t[n];r.isFor(e)&&r.destroy()}},e.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this._clearAllRoots())},e.prototype.getElement=function(e){},e.prototype.getBounds=function(e){var t=e[o.BOUNDS],n=t.parentElement(),r=t.firstNode(),i=t.lastNode();return{parentElement:n,firstNode:r,lastNode:i}},e.prototype.createElement=function(e){return this._env.getAppendOperations().createElement(e)},e.prototype._renderRoot=function(e){var t=this._roots;t.push(e),1===t.length&&u(this),this._renderRootsTransaction()},e.prototype._renderRoots=function(){var e=this._roots,t=this._env,n=this._removedRoots,i=void 0,o=void 0;do{t.begin(),o=e.length,i=!1;for(var s=0;s=o&&!u||(a.options.alwaysRevalidate=u,u=a.shouldReflush=m(a,"render"),i=i||u)}}this._lastRevision=r.CURRENT_TAG.value(),t.commit()}while(i||e.length>o);for(;n.length;){var a=n.pop(),c=e.indexOf(a);e.splice(c,1)}0===this._roots.length&&l(this)},e.prototype._renderRootsTransaction=function(){if(!this._isRenderingRoots){this._isRenderingRoots=!0;var e=!1;try{this._renderRoots(),e=!0}finally{e||(this._lastRevision=r.CURRENT_TAG.value()),this._isRenderingRoots=!1}}},e.prototype._clearAllRoots=function(){for(var e=this._roots,t=0;t-1)return c[t]}e.registerSyntax=a,e.findSyntaxBuilder=u;var l=[],c=[];a("render",t.RenderSyntax),a("outlet",n.OutletSyntax),a("mount",r.MountSyntax),a("component",i.DynamicComponentSyntax),a("input",o.InputSyntax),a("-with-dynamic-vars",function(){function e(){}return e.create=function(e,t,n){return new s.WithDynamicVarsSyntax(t)},e}()),a("-in-element",function(){function e(){}return e.create=function(e,t,n){return new s.InElementSyntax(t)},e}())}),s("ember-glimmer/syntax/curly-component",["exports","ember-utils","glimmer-runtime","ember-glimmer/utils/bindings","ember-glimmer/component","ember-metal","ember-views","ember-glimmer/utils/process-args","container"],function(e,t,n,r,i,o,s,a,u){"use strict";function l(e,t){}function p(e,t,n){}function h(e,t){e.named.has("id")&&(t.elementId=t.id)}function f(e,t,n,i){for(var o=[],s=t.length-1;s!==-1;){var a=t[s],u=r.AttributeBinding.parse(a),l=u[1];o.indexOf(l)===-1&&(o.push(l),r.AttributeBinding.install(e,n,u,i)),s--}o.indexOf("id")===-1&&i.addStaticAttribute(e,"id",n.elementId),o.indexOf("style")===-1&&r.IsVisibleBinding.install(e,n,i)}function m(){}function d(e){return e.instrumentDetails({initialRender:!0})}function g(e){return e.instrumentDetails({initialRender:!1})}function v(e){var t=e.dynamicScope().view.tagName;return n.PrimitiveReference.create(""===t?null:t||"div")}function y(e){return e.getSelf().get("ariaRole")}e.validatePositionalParameters=p;var b=c.taggedTemplateLiteralLoose(["template:components/-default"],["template:components/-default"]),_=u.privatize(b),w=function(e){function t(t,n,r){e.call(this),this.args=t,this.definition=n,this.symbolTable=r,this.shadow=null}return c.inherits(t,e),t.prototype.compile=function(e){e.component.static(this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.CurlyComponentSyntax=w;var E=function(){function e(e,t,n,r){this.environment=e,this.component=t,this.classRef=null,this.args=n,this.argsRevision=n.tag.value(),this.finalizer=r}return e.prototype.destroy=function(){var e=this.component,t=this.environment;t.isInteractive&&(e.trigger("willDestroyElement"),e.trigger("willClearRender")),t.destroyedComponents.push(e)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=m},e}(),O=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return p(t.named,t.positional.values,e.ComponentClass.positionalParams),a.gatherArgs(t,e)},e.prototype.create=function(e,t,n,r,s,u){var c=r.view,p=t.ComponentClass,f=a.ComponentArgs.create(n),m=f.value(),g=m.props;h(n,g),g.parentView=c,g[i.HAS_BLOCK]=u,g._targetObject=s.value();var v=p.create(g),y=o._instrumentStart("render.component",d,v);r.view=v,null!==c&&c.appendChild(v),""===v.tagName&&(e.isInteractive&&v.trigger("willRender"),v._transitionTo("hasElement"),e.isInteractive&&v.trigger("willInsertElement"));var b=new E(e,v,f,y);return n.named.has("class")&&(b.classRef=n.named.get("class")),l(v,g),e.isInteractive&&""!==v.tagName&&v.trigger("willRender"),b},e.prototype.layoutFor=function(e,t,n){var r=e.template;if(!r){var i=t.component;r=this.templateFor(i,n)}return n.getCompiledBlock(T,r)},e.prototype.templateFor=function(e,n){var r=o.get(e,"layout"),i=e[t.OWNER];if(r)return n.getTemplate(r,i);var s=o.get(e,"layoutName");if(s){var a=i.lookup("template:"+s);if(a)return a}return i.lookup(_)},e.prototype.getSelf=function(e){var t=e.component;return t[i.ROOT_REF]},e.prototype.didCreateElement=function(e,t,n){var i=e.component,o=e.classRef,a=e.environment;s.setViewElement(i,t);var u=i.attributeBindings,l=i.classNames,c=i.classNameBindings;u&&u.length?f(t,u,i,n):(n.addStaticAttribute(t,"id",i.elementId),r.IsVisibleBinding.install(t,i,n)),o&&n.addDynamicAttribute(t,"class",o),l&&l.length&&l.forEach(function(e){n.addStaticAttribute(t,"class",e)}),c&&c.length&&c.forEach(function(e){r.ClassNameBinding.install(t,i,e,n)}),i._transitionTo("hasElement"),a.isInteractive&&i.trigger("willInsertElement")},e.prototype.didRenderLayout=function(e,t){e.component[i.BOUNDS]=t,e.finalize()},e.prototype.getTag=function(e){var t=e.component;return t[i.DIRTY_TAG]},e.prototype.didCreate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t._transitionTo("inDOM"),t.trigger("didInsertElement"),t.trigger("didRender"))},e.prototype.update=function(e,t,n){var r=e.component,s=e.args,a=e.argsRevision,u=e.environment;if(e.finalizer=o._instrumentStart("render.component",g,r),!s.tag.validate(a)){var l=s.value(),c=l.attrs,p=l.props;e.argsRevision=s.tag.value();var h=r.attrs,f=c;r[i.IS_DISPATCHING_ATTRS]=!0,r.setProperties(p),r[i.IS_DISPATCHING_ATTRS]=!1,r.trigger("didUpdateAttrs",{oldAttrs:h,newAttrs:f}),r.trigger("didReceiveAttrs",{oldAttrs:h,newAttrs:f})}u.isInteractive&&(r.trigger("willUpdate"),r.trigger("willRender"))},e.prototype.didUpdateLayout=function(e){e.finalize()},e.prototype.didUpdate=function(e){var t=e.component,n=e.environment;n.isInteractive&&(t.trigger("didUpdate"),t.trigger("didRender"))},e.prototype.getDestructor=function(e){return e},e}(),S=new O,x=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.create=function(e,t,n,r,i,s){var a=t.ComponentClass,u=o._instrumentStart("render.component",d,a);return r.view=a,""===a.tagName&&(e.isInteractive&&a.trigger("willRender"),a._transitionTo("hasElement"),e.isInteractive&&a.trigger("willInsertElement")),l(a,{}),new E(e,a,n,u)},t}(O),C=new x,A=function(e){function t(t,n,r,i){e.call(this,t,S,n),this.template=r,this.args=i}return c.inherits(t,e),t}(n.ComponentDefinition);e.CurlyComponentDefinition=A;var k=function(e){function t(t){e.call(this,"-root",C,t),this.template=void 0,this.args=void 0}return c.inherits(t,e),t}(n.ComponentDefinition);e.RootComponentDefinition=k;var T=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.dynamic(v),e.attrs.dynamic("role",y),e.attrs.static("class","ember-view")},e}();T.id="curly"}),s("ember-glimmer/syntax/dynamic-component",["exports","glimmer-runtime","glimmer-reference","ember-metal"],function(e,t,n,r){"use strict";function i(e,t){var n=e.env,r=e.getArgs(),i=r.positional.at(0);return new s({nameRef:i,env:n,symbolTable:t})}var o=function(e){function n(t,n,r){e.call(this),this.definition=i,this.definitionArgs=t,this.args=n,this.symbolTable=r,this.shadow=null}return c.inherits(n,e),n.create=function(e,n,r){var i=t.ArgsSyntax.fromPositionalArgs(n.positional.slice(0,1)),o=t.ArgsSyntax.build(n.positional.slice(1),n.named,n.blocks);return new this(i,o,r)},n.fromPath=function(e,n,r,i){var o=t.ArgsSyntax.fromPositionalArgs(t.PositionalArgsSyntax.build([t.GetSyntax.build(n.join("."))]));return new this(o,r,i)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.DynamicComponentSyntax=o;var s=function(){function e(e){var t=e.nameRef,n=e.env,r=e.symbolTable,i=e.args;this.tag=t.tag,this.nameRef=t,this.env=n,this.symbolTable=r,this.args=i}return e.prototype.value=function(){var e=this.env,n=this.nameRef,r=this.symbolTable,i=n.value();if("string"==typeof i){var o=e.getComponentDefinition([i],r);return o}return t.isComponentDefinition(i)?i:null},e.prototype.get=function(){return n.UNDEFINED_REFERENCE},e}()}),s("ember-glimmer/syntax/input",["exports","ember-metal","ember-glimmer/syntax/curly-component","ember-glimmer/syntax/dynamic-component","ember-glimmer/utils/bindings"],function(e,t,n,r,i){"use strict";function o(e,t,r){var o=t("-text-field");return i.wrapComponentClassAttribute(e),new n.CurlyComponentSyntax(e,o,r)}var s={create:function(e,t,s){var a=function(t){return e.getComponentDefinition([t],s)};if(!t.named.has("type"))return o(t,a,s);var u=t.named.at("type");if("value"===u.type){if("checkbox"===u.value){i.wrapComponentClassAttribute(t);var l=a("-checkbox");return new n.CurlyComponentSyntax(t,l,s)}return o(t,a,s)}return r.DynamicComponentSyntax.create(e,t,s)}};e.InputSyntax=s}),s("ember-glimmer/syntax/mount",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";var a=function(e){function n(t,n){e.call(this),this.definition=t,this.symbolTable=n}return c.inherits(n,e),n.create=function(e,t,r){var i=t.positional.at(0).inner(),o=new p(i,e);return new n(o,r)},n.prototype.compile=function(e){e.component.static(this.definition,t.ArgsSyntax.empty(),null,this.symbolTable,null)},n}(t.StatementSyntax);e.MountSyntax=a;var u=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,r,i){var o=t.name,s=t.env;i.outletState=n.UNDEFINED_REFERENCE;var a=s.owner.buildChildEngineInstance(o);return a.boot(),{engine:a}},e.prototype.layoutFor=function(e,t,n){var r=t.engine,i=r.lookup("template:application");return n.getCompiledBlock(s.OutletLayoutCompiler,i)},e.prototype.getSelf=function(e){var t=e.engine,n=t._lookupFactory("controller:application")||o.generateControllerFactory(t,"application");return new i.RootReference(n.create())},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(e){var t=e.engine;return t; +},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e,t,n){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(e){},e}(),l=new u,p=function(e){function t(t,n){e.call(this,t,l,null),this.env=n}return c.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/syntax/outlet",["exports","ember-utils","glimmer-runtime","ember-metal","ember-glimmer/utils/references","glimmer-reference"],function(e,t,n,r,i,o){"use strict";function s(e){var t=e.dynamicScope(),n=t.outletState,r=e.getArgs(),i=void 0;return i=0===r.positional.length?new o.ConstReference("main"):r.positional.at(0),new h(i,n)}function a(e,t,n){return t||n?!t&&n||t&&!n?null:n.render.template===t.render.template&&n.render.controller===t.render.controller?e:null:e}function u(e){var t=e.render,n=t.name,r=t.outlet;return{object:n+":"+r}}function l(){}var p=function(e){function t(t,r,i){e.call(this),this.definitionArgs=r,this.definition=s,this.args=n.ArgsSyntax.empty(),this.symbolTable=i,this.shadow=null}return c.inherits(t,e),t.create=function(e,t,r){var i=n.ArgsSyntax.fromPositionalArgs(t.positional.slice(0,1));return new this(e,i,r)},t.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},t}(n.StatementSyntax);e.OutletSyntax=p;var h=function(){function e(e,t){this.outletNameRef=e,this.parentOutletStateRef=t,this.definition=null,this.lastState=null;var n=this.outletStateTag=new o.UpdatableTag(t.tag);this.tag=o.combine([n.tag,e.tag])}return e.prototype.value=function(){var e=this.outletNameRef,t=this.parentOutletStateRef,n=this.definition,r=this.lastState,i=e.value(),o=t.get("outlets").get(i),s=this.lastState=o.value();this.outletStateTag.update(o.tag),n=a(n,r,s);var u=s&&s.render.template;return n?n:u?this.definition=new _(i,s.render.template):this.definition=null},e}(),f=function(){function e(e){this.outletState=e,this.instrument()}return e.prototype.instrument=function(){this.finalizer=r._instrumentStart("render.outlet",u,this.outletState)},e.prototype.finalize=function(){var e=this.finalizer;e(),this.finalizer=l},e}(),m=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.create=function(e,t,n,r){var i=r.outletState=r.outletState.get("outlets").get(t.outletName),o=i.value();return new f(o)},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(w,e.template)},e.prototype.getSelf=function(e){var t=e.outletState;return new i.RootReference(t.render.controller)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didRenderLayout=function(e){e.finalize()},e.prototype.didCreateElement=function(){},e.prototype.didCreate=function(e){},e.prototype.update=function(e){},e.prototype.didUpdateLayout=function(e){},e.prototype.didUpdate=function(e){},e}(),d=new m,g=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.create=function(e,t,n,r){return new f(r.outletState.value())},t.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(b,e.template)},t}(m),v=new g,y=function(e){function n(n){e.call(this,"outlet",v,n),this.template=n.template,t.generateGuid(this)}return c.inherits(n,e),n}(n.ComponentDefinition);e.TopLevelOutletComponentDefinition=y;var b=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout()),e.tag.static("div"),e.attrs.static("id",t.guidFor(this)),e.attrs.static("class","ember-view")},e}();b.id="top-level-outlet";var _=function(e){function n(n,r){e.call(this,"outlet",d,null),this.outletName=n,this.template=r,t.generateGuid(this)}return c.inherits(n,e),n}(n.ComponentDefinition),w=function(){function e(e){this.template=e}return e.prototype.compile=function(e){e.wrapLayout(this.template.asLayout())},e}();e.OutletLayoutCompiler=w,w.id="outlet"}),s("ember-glimmer/syntax/render",["exports","glimmer-runtime","glimmer-reference","ember-metal","ember-glimmer/utils/references","ember-routing","ember-glimmer/syntax/outlet"],function(e,t,n,r,i,o,s){"use strict";function a(e){var t=e.env,r=e.getArgs(),i=r.positional.at(0),o=i.value(),s=t.owner.lookup("template:"+o),a=void 0;if(r.named.has("controller")){var u=r.named.get("controller");a=u.value()}else a=o;return 1===r.positional.length?new n.ConstReference(new d(a,s,t,h)):new n.ConstReference(new d(a,s,t,m))}var u=function(e){function n(n,r,i){e.call(this),this.definitionArgs=r,this.definition=a,this.args=t.ArgsSyntax.fromPositionalArgs(r.positional.slice(1,2)),this.symbolTable=i,this.shadow=null}return c.inherits(n,e),n.create=function(e,t,n){return new this(e,t,n)},n.prototype.compile=function(e){e.component.dynamic(this.definitionArgs,this.definition,this.args,this.symbolTable,this.shadow)},n}(t.StatementSyntax);e.RenderSyntax=u;var l=function(){function e(){}return e.prototype.prepareArgs=function(e,t){return t},e.prototype.layoutFor=function(e,t,n){return n.getCompiledBlock(s.OutletLayoutCompiler,e.template)},e.prototype.getSelf=function(e){var t=e.controller;return new i.RootReference(t)},e.prototype.getTag=function(){return null},e.prototype.getDestructor=function(){return null},e.prototype.didCreateElement=function(){},e.prototype.didRenderLayout=function(){},e.prototype.didCreate=function(){},e.prototype.update=function(){},e.prototype.didUpdateLayout=function(){},e.prototype.didUpdate=function(){},e}(),p=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=s.owner.lookup("controller:"+i)||o.generateController(s.owner,i);return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:a}},t}(l),h=new p,f=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.create=function(e,t,n,r){var i=t.name,s=t.env,a=n.positional.at(0),u=s.owner._lookupFactory("controller:"+i)||o.generateControllerFactory(s.owner,i),l=u.create({model:a.value()});return r.rootOutletState&&(r.outletState=r.rootOutletState.getOrphan(i)),{controller:l}},t.prototype.update=function(e,t,n){var r=e.controller;r.set("model",t.positional.at(0).value())},t.prototype.getDestructor=function(e){var t=e.controller;return t},t}(l),m=new f,d=function(e){function t(t,n,r,i){e.call(this,"render",i,null),this.name=t,this.template=n,this.env=r}return c.inherits(t,e),t}(t.ComponentDefinition)}),s("ember-glimmer/template",["exports","ember-utils","glimmer-runtime"],function(e,t,n){"use strict";function r(e){var r=n.templateFactory(e);return{id:r.id,meta:r.meta,create:function(e){return r.create(e.env,{owner:e[t.OWNER]})}}}e.default=r}),s("ember-glimmer/template_registry",["exports"],function(e){"use strict";function t(e){s=e}function n(){return s}function r(e){if(s.hasOwnProperty(e))return s[e]}function i(e){return s.hasOwnProperty(e)}function o(e,t){return s[e]=t}e.setTemplates=t,e.getTemplates=n,e.getTemplate=r,e.hasTemplate=i,e.setTemplate=o;var s={}}),s("ember-glimmer/templates/component",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"ZoGfVsSJ",block:'{"statements":[["yield","default"]],"locals":[],"named":[],"yields":["default"],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/component.hbs"}})}),s("ember-glimmer/templates/empty",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"qEHL4OLi",block:'{"statements":[],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/empty.hbs"}})}),s("ember-glimmer/templates/link-to",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Ca7iQMR7",block:'{"statements":[["block",["if"],[["get",["linkTitle"]]],null,1,0]],"locals":[],"named":[],"yields":["default"],"blocks":[{"statements":[["yield","default"]],"locals":[]},{"statements":[["append",["unknown",["linkTitle"]],false]],"locals":[]}],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/link-to.hbs"}})}),s("ember-glimmer/templates/outlet",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"sYQo9vi/",block:'{"statements":[["append",["unknown",["outlet"]],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/outlet.hbs"}})}),s("ember-glimmer/templates/root",["exports","ember-glimmer/template"],function(e,t){"use strict";e.default=t.default({id:"Eaf3RPY3",block:'{"statements":[["append",["helper",["component"],[["get",[null]]],null],false]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}',meta:{moduleName:"ember-glimmer/templates/root.hbs"}})}),s("ember-glimmer/utils/bindings",["exports","glimmer-reference","glimmer-runtime","ember-metal","ember-runtime","ember-glimmer/component","ember-glimmer/utils/string"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return e[o.ROOT_REF].get(t)}function u(e,n){var r="attrs"===n[0];return r&&(n.shift(),1===n.length)?a(e,n[0]):t.referenceFromParts(e[o.ROOT_REF],n)}function l(e){var t=e.named,r=t.keys.indexOf("class");if(r!==-1){var i=t.values[r],o=i.ref,s=i.type;if("get"===s){var a=o.parts[o.parts.length-1];t.values[r]=n.HelperSyntax.fromSpec(["helper",["-class"],[["get",o.parts],a],null])}}return e}e.wrapComponentClassAttribute=l;var p={parse:function(e){var t=e.indexOf(":");if(t===-1)return[e,e,!0];var n=e.substring(0,t),r=e.substring(t+1);return[n,r,!1]},install:function(e,t,n,i){var o=n[0],s=n[1];n[2];if("id"===s){var l=r.get(t,o);return void 0!==l&&null!==l||(l=t.elementId),void i.addStaticAttribute(e,"id",l)}var c=o.indexOf(".")>-1,p=c?u(t,o.split(".")):a(t,o);"style"===s&&(p=new m(p,a(t,"isVisible"))),i.addDynamicAttribute(e,s,p)}};e.AttributeBinding=p;var h="display: none;",f=s.htmlSafe(h),m=function(e){function n(n,r){e.call(this),this.tag=t.combine([n.tag,r.tag]),this.inner=n,this.isVisible=r}return c.inherits(n,e),n.prototype.compute=function(){var e=this.inner.value(),t=this.isVisible.value();if(t!==!1)return e;if(e||0===e){var n=e+" "+h;return s.isHTMLSafe(e)?s.htmlSafe(n):n}return f},n}(t.CachedReference),d={install:function(e,n,r){r.addDynamicAttribute(e,"style",t.map(a(n,"isVisible"),this.mapStyleValue))},mapStyleValue:function(e){return e===!1?f:null}};e.IsVisibleBinding=d;var g={install:function(e,t,n,r){var i=n.split(":"),o=i[0],s=i[1],l=i[2],c=""===o;if(c)r.addStaticAttribute(e,"class",s);else{var p=o.indexOf(".")>-1,h=p&&o.split("."),f=p?u(t,h):a(t,o),m=void 0;m=void 0===s?new v(f,p?h[h.length-1]:o):new y(f,s,l),r.addDynamicAttribute(e,"class",m)}}};e.ClassNameBinding=g;var v=function(e){function t(t,n){e.call(this),this.tag=t.tag,this.inner=t,this.path=n,this.dasherizedPath=null}return c.inherits(t,e),t.prototype.compute=function(){var e=this.inner.value();if(e===!0){var t=this.path,n=this.dasherizedPath;return n||(this.dasherizedPath=i.String.dasherize(t))}return e||0===e?e:null},t}(t.CachedReference),y=function(e){function t(t,n,r){e.call(this),this.tag=t.tag,this.inner=t,this.truthy=n||null,this.falsy=r||null}return c.inherits(t,e),t.prototype.compute=function(){var e=this.inner,t=this.truthy,n=this.falsy;return e.value()?t:n},t}(t.CachedReference)}),s("ember-glimmer/utils/iterable",["exports","ember-utils","ember-metal","ember-runtime","ember-glimmer/utils/references","ember-glimmer/helpers/each-in","glimmer-reference"],function(e,t,n,r,i,o,s){"use strict";function a(e,t){return o.isEachIn(e)?new b(e,u(t)):new _(e,l(t))}function u(e){switch(e){case"@index":case void 0:case null:return c;case"@identity":return p;default:return function(t){return n.get(t,e)}}}function l(e){switch(e){case"@index":return c;case"@identity":case void 0:case null:return p;default:return function(t){return n.get(t,e)}}}function c(e,t){return String(t)}function p(e){switch(typeof e){case"string":case"number":return String(e);default:return t.guidFor(e)}}function h(e,t){var n=e[t];return n?(e[t]++,""+t+f+n):(e[t]=1,t)}e.default=a;var f="be277757-bbbe-4620-9fcb-213ef433cca2",m=function(){function e(e,n){this.array=e,this.length=e.length,this.keyFor=n,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return!1},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,r=this.position,i=this.seen;if(r>=t)return null;var o=e[r],s=r,a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),d=function(){function e(e,r){this.array=e,this.length=n.get(e,"length"),this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.length},e.prototype.next=function(){var e=this.array,t=this.length,n=this.keyFor,i=this.position,o=this.seen;if(i>=t)return null;var s=r.objectAt(e,i),a=i,u=h(o,n(s,a));return this.position++,{key:u,value:s,memo:a}},e}(),g=function(){function e(e,n,r){this.keys=e,this.values=n,this.keyFor=r,this.position=0,this.seen=new t.EmptyObject}return e.prototype.isEmpty=function(){return 0===this.keys.length},e.prototype.next=function(){var e=this.keys,t=this.values,n=this.keyFor,r=this.position,i=this.seen;if(r>=e.length)return null;var o=t[r],s=e[r],a=h(i,n(o,s));return this.position++,{key:a,value:o,memo:s}},e}(),v=function(){function e(){}return e.prototype.isEmpty=function(){return!0},e.prototype.next=function(){throw new Error("Cannot call next() on an empty iterator")},e}(),y=new v,b=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,r=this.valueTag,i=e.value();r.update(n.tagFor(i)),n.isProxy(i)&&(i=n.get(i,"content"));var o=typeof i;if(!i||"object"!==o&&"function"!==o)return y;var s=Object.keys(i),a=s.map(function(e){return i[e]});return s.length>0?new g(s,a,t):y},e.prototype.valueReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateValueReference=function(e,t){e.update(t.memo)},e.prototype.memoReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateMemoReference=function(e,t){e.update(t.value)},e}(),_=function(){function e(e,t){this.ref=e,this.keyFor=t;var n=this.valueTag=new s.UpdatableTag(s.CONSTANT_TAG);this.tag=s.combine([e.tag,n])}return e.prototype.iterate=function(){var e=this.ref,t=this.keyFor,i=this.valueTag,o=e.value();if(i.update(n.tagForProperty(o,"[]")),!o||"object"!=typeof o)return y;if(Array.isArray(o))return o.length>0?new m(o,t):y;if(r.isEmberArray(o))return n.get(o,"length")>0?new d(o,t):y;if("function"!=typeof o.forEach)return y;var s=function(){var e=[];return o.forEach(function(t){e.push(t)}),{v:e.length>0?new m(e,t):y}}();return"object"==typeof s?s.v:void 0},e.prototype.valueReferenceFor=function(e){return new i.UpdatableReference(e.value)},e.prototype.updateValueReference=function(e,t){e.update(t.value)},e.prototype.memoReferenceFor=function(e){return new i.UpdatablePrimitiveReference(e.memo)},e.prototype.updateMemoReference=function(e,t){e.update(t.memo)},e}()}),s("ember-glimmer/utils/process-args",["exports","ember-utils","glimmer-reference","ember-glimmer/component","ember-glimmer/utils/references","ember-views","ember-glimmer/helpers/action","glimmer-runtime"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t){var n=l(e,t),r=c(e,t);return p(n,r,e.blocks,t.ComponentClass)}function l(e,n){var r=e.named.map;return n.args?t.assign({},n.args.named.map,r):r}function c(e,t){var n=e.positional.values;if(t.args){var r=t.args.positional.values,i=[];return i.push.apply(i,r),i.splice.apply(i,[0,n.length].concat(n)),i}return n}function p(e,t,n,r){var i=r.positionalParams;return i&&i.length>0&&t.length>0&&(e="string"==typeof i?h(e,t,i):f(e,t,i)),a.EvaluatedArgs.named(e,n)}function h(e,n,r){var i=t.assign({},e);return i[r]=a.EvaluatedPositionalArgs.create(n),i}function f(e,n,r){for(var i=t.assign({},e),o=Math.min(n.length,r.length),s=0;s":">",'"':""","'":"'","`":"`","=":"="},l=/[&<>"'`=]/,c=/[&<>"'`=]/g}),s("ember-glimmer/utils/to-bool",["exports","ember-runtime","ember-metal"],function(e,t,n){"use strict";function r(e){return!!e&&(e===!0||(!t.isArray(e)||0!==n.get(e,"length")))}e.default=r}),s("ember-glimmer/views/outlet",["exports","ember-utils","glimmer-reference","ember-environment","ember-metal"],function(e,t,n,r,i){"use strict";var o=function(){function e(e){this.outletView=e,this.tag=e._tag}return e.prototype.get=function(e){return new a(this,e)},e.prototype.value=function(){return this.outletView.outletState},e.prototype.getOrphan=function(e){return new s(this,e)},e.prototype.update=function(e){this.outletView.setOutletState(e)},e}(),s=function(e){function n(t,n){e.call(this,t.outletView),this.root=t,this.name=n}return c.inherits(n,e),n.prototype.value=function(){var e=this.root.value(),n=e.outlets.main.outlets.__ember_orphans__;if(!n)return null;var r=n.outlets[this.name];if(!r)return null;var i=new t.EmptyObject;return i[r.render.outlet]=r,r.wasUsed=!0,{outlets:i}},n}(o),a=function(){function e(e,t){this.parent=e,this.key=t,this.tag=e.tag}return e.prototype.get=function(t){return new e(this,t)},e.prototype.value=function(){return this.parent.value()[this.key]},e}(),u=function(){function e(e,t,r,i){this._environment=e,this.renderer=t,this.owner=r,this.template=i,this.outletState=null,this._tag=new n.DirtyableTag}return e.extend=function(n){return function(e){function r(){e.apply(this,arguments)}return c.inherits(r,e),r.create=function(r){return r?e.create.call(this,t.assign({},n,r)):e.create.call(this,n)},r}(e)},e.reopenClass=function(e){t.assign(this,e)},e.create=function(n){var r=n._environment,i=n.renderer,o=n.template,s=n[t.OWNER];return new e(r,i,s,o)},e.prototype.appendTo=function(e){var t=this._environment||r.environment,n=void 0;n=t.hasDOM&&"string"==typeof e?document.querySelector(e):e,i.run.schedule("render",this.renderer,"appendOutletView",this,n)},e.prototype.rerender=function(){},e.prototype.setOutletState=function(e){this.outletState={outlets:{main:e},render:{owner:void 0,into:void 0,outlet:"main",name:"-top-level",controller:void 0,ViewClass:void 0,template:void 0}},this._tag.dirty()},e.prototype.toReference=function(){return new o(this)},e.prototype.destroy=function(){},e}();e.default=u}),s("ember-metal/alias",["exports","ember-utils","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/properties","ember-metal/computed","ember-metal/meta","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e){return new p(e)}function p(e){this.isDescriptor=!0,this.altKey=e,this._dependentKeys=[e]}function h(e,n,r){throw new o.default("Cannot set read-only property '"+n+"' on object: "+t.inspect(e))}function f(e,t,n){return s.defineProperty(e,t,null),i.set(e,t,n)}e.default=c,e.AliasedProperty=p,p.prototype=Object.create(s.Descriptor.prototype),p.prototype.setup=function(e,t){var n=u.meta(e);n.peekWatching(t)&&l.addDependentKeys(this,e,t,n)},p.prototype._addDependentKeyIfMissing=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)||l.addDependentKeys(this,e,t,n)},p.prototype._removeDependentKeyIfAdded=function(e,t){var n=u.meta(e);n.peekDeps(this.altKey,t)&&l.removeDependentKeys(this,e,t,n)},p.prototype.willWatch=p.prototype._addDependentKeyIfMissing,p.prototype.didUnwatch=p.prototype._removeDependentKeyIfAdded,p.prototype.teardown=p.prototype._removeDependentKeyIfAdded,p.prototype.get=function(e,t){return this._addDependentKeyIfMissing(e,t),r.get(e,this.altKey)},p.prototype.set=function(e,t,n){return i.set(e,this.altKey,n)},p.prototype.readOnly=function(){return this.set=h,this},p.prototype.oneWay=function(){return this.set=f,this},p.prototype._meta=void 0,p.prototype.meta=a.ComputedProperty.prototype.meta}),s("ember-metal/binding",["exports","ember-utils","ember-console","ember-environment","ember-metal/run_loop","ember-metal/debug","ember-metal/property_get","ember-metal/property_set","ember-metal/events","ember-metal/observer","ember-metal/path_cache"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(e,t){this._from=t,this._to=e,this._oneWay=void 0,this._direction=void 0,this._readyToSync=void 0,this._fromObj=void 0,this._fromPath=void 0,this._toObj=void 0}function h(e,t,n,r,i,o){}function f(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function m(e,t,n){return new p(t,n).connect(e)}e.bind=m,p.prototype={copy:function(){var e=new p(this._to,this._from);return this._oneWay&&(e._oneWay=!0),e},from:function(e){return this._from=e,this},to:function(e){return this._to=e,this},oneWay:function(){return this._oneWay=!0,this},toString:function(){var e=this._oneWay?"[oneWay]":"";return"Ember.Binding<"+t.guidFor(this)+">("+this._from+" -> "+this._to+")"+e},connect:function(e){var t=void 0,n=void 0,i=void 0;if(c.isGlobalPath(this._from)){var o=c.getFirstKey(this._from);i=r.context.lookup[o],i&&(t=i,n=c.getTailPath(this._from))}return void 0===t&&(t=e,n=this._from),a.trySet(e,this._to,s.get(t,n)),l.addObserver(t,n,this,"fromDidChange"),this._oneWay||l.addObserver(e,this._to,this,"toDidChange"),u.addListener(e,"willDestroy",this,"disconnect"),h(e,this._to,this._from,i,this._oneWay,!i&&!this._oneWay),this._readyToSync=!0,this._fromObj=t,this._fromPath=n,this._toObj=e,this},disconnect:function(){return l.removeObserver(this._fromObj,this._fromPath,this,"fromDidChange"),this._oneWay||l.removeObserver(this._toObj,this._to,this,"toDidChange"),this._readyToSync=!1,this},fromDidChange:function(e){this._scheduleSync("fwd")},toDidChange:function(e){this._scheduleSync("back")},_scheduleSync:function(e){var t=this._direction;void 0===t&&(i.default.schedule("sync",this,"_sync"),this._direction=e),"back"===t&&"fwd"===e&&(this._direction="fwd")},_sync:function(){var e=r.ENV.LOG_BINDINGS,t=this._toObj;if(!t.isDestroyed&&this._readyToSync){var i=this._direction,o=this._fromObj,u=this._fromPath;if(this._direction=void 0,"fwd"===i){var c=s.get(o,u);e&&n.default.log(" ",this.toString(),"->",c,o),this._oneWay?a.trySet(t,this._to,c):l._suspendObserver(t,this._to,this,"toDidChange",function(){a.trySet(t,this._to,c)})}else if("back"===i){var p=s.get(t,this._to);e&&n.default.log(" ",this.toString(),"<-",p,t),l._suspendObserver(o,u,this,"fromDidChange",function(){a.trySet(o,u,p)})}}}},f(p,{from:function(e){var t=this;return new t(void 0,e)},to:function(e){var t=this;return new t(e,void 0)}}),e.Binding=p}),s("ember-metal/cache",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";var r=function(){function e(e,t,n,r){this.size=0,this.misses=0,this.hits=0,this.limit=e,this.func=t,this.key=n,this.store=r||new i}return e.prototype.get=function(e){var t=void 0===this.key?e:this.key(e),r=this.store.get(t);return void 0===r?(this.misses++,r=this._set(t,this.func(e))):r===n.UNDEFINED?(this.hits++,r=void 0):this.hits++,r},e.prototype.set=function(e,t){var n=void 0===this.key?e:this.key(e);return this._set(n,t)},e.prototype._set=function(e,t){return this.limit>this.size&&(this.size++,void 0===t?this.store.set(e,n.UNDEFINED):this.store.set(e,t)),t},e.prototype.purge=function(){this.store.clear(),this.size=0,this.hits=0,this.misses=0},e}();e.default=r;var i=function(){function e(){this.data=new t.EmptyObject}return e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e.prototype.clear=function(){this.data=new t.EmptyObject},e}()}),s("ember-metal/chains",["exports","ember-utils","ember-metal/property_get","ember-metal/meta","ember-metal/watch_key","ember-metal/watch_path"],function(e,t,n,r,i,o){"use strict";function s(e){return e.match(g)[0]}function a(e){return"object"==typeof e&&e}function u(e){return!(a(e)&&e.isDescriptor&&e._volatile===!1)}function l(){this.chains=new t.EmptyObject}function c(){return new l}function p(e,t,n){var o=r.meta(e);o.writableChainWatchers(c).add(t,n),i.watchKey(e,t,o)}function h(e,t,n,o){if(a(e)){var s=o||r.peekMeta(e);s&&s.readableChainWatchers()&&(s=r.meta(e),s.readableChainWatchers().remove(t,n),i.unwatchKey(e,t,s))}}function f(e,t,n){if(this._parent=e,this._key=t,this._watching=void 0===n,this._chains=void 0,this._object=void 0,this.count=0,this._value=n,this._paths={},this._watching){var r=e.value();if(!a(r))return;this._object=r,p(this._object,this._key,this)}}function m(e,t){if(a(e)){var i=r.peekMeta(e);if(!i||i.proto!==e){if(u(e[t]))return n.get(e,t);var o=i.readableCache();return o&&t in o?o[t]:void 0}}}function d(e){var t=r.peekMeta(e);if(t){t=r.meta(e);var n=t.readableChainWatchers();n&&n.revalidateAll(),t.readableChains()&&t.writableChains(o.makeChainNode)}}e.finishChains=d;var g=/^([^\.]+)/;l.prototype={add:function(e,t){var n=this.chains[e];void 0===n?this.chains[e]=[t]:n.push(t)},remove:function(e,t){var n=this.chains[e];if(n)for(var r=0;r0&&t[e]--;var n=s(e),r=e.slice(n.length+1);this.unchain(n,r)},chain:function(e,n){var r=this._chains,i=void 0;void 0===r?r=this._chains=new t.EmptyObject:i=r[e],void 0===i&&(i=r[e]=new f(this,e,void 0)),i.count++,n&&(e=s(n),n=n.slice(e.length+1),i.chain(e,n))},unchain:function(e,t){var n=this._chains,r=n[e];if(t&&t.length>1){var i=s(t),o=t.slice(i.length+1);r.unchain(i,o)}r.count--,r.count<=0&&(n[r._key]=void 0,r.destroy())},notify:function(e,t){if(e&&this._watching){var n=this._parent.value();n!==this._object&&(this._object&&h(this._object,this._key,this),a(n)?(this._object=n,p(n,this._key,this)):this._object=void 0),this._value=void 0}var r=this._chains,i=void 0;if(r)for(var o in r)i=r[o],void 0!==i&&i.notify(e,t);t&&this._parent&&this._parent.populateAffected(this._key,1,t)},populateAffected:function(e,t,n){this._key&&(e=this._key+"."+e),this._parent?this._parent.populateAffected(e,t+1,n):t>1&&n.push(this.value(),e)}},e.removeChainWatcher=h,e.ChainNode=f}),s("ember-metal/computed",["exports","ember-utils","ember-metal/debug","ember-metal/property_set","ember-metal/meta","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/dependent_keys"],function(e,t,n,r,i,o,s,a,u,l){"use strict";function c(e,t){this.isDescriptor=!0,"function"==typeof e?this._getter=e:(this._getter=e.get,this._setter=e.set),this._dependentKeys=void 0,this._suspended=void 0,this._meta=void 0,this._volatile=!1,this._dependentKeys=t&&t.dependentKeys,this._readOnly=!1}function p(e){var t=void 0;arguments.length>1&&(t=[].slice.call(arguments),e=t.pop());var n=new c(e);return t&&n.property.apply(n,t),n}function h(e,t){var n=i.peekMeta(e),r=n&&n.source===e&&n.readableCache(),o=r&&r[t];if(o!==i.UNDEFINED)return o}e.default=p;c.prototype=new a.Descriptor,c.prototype.constructor=c;var f=c.prototype;f.volatile=function(){return this._volatile=!0,this},f.readOnly=function(){return this._readOnly=!0,this},f.property=function(){function e(e){t.push(e)}for(var t=[],n=0;n=0;i-=3)if(t===e[i]&&n===e[i+1]){r=i;break}return r}function s(e,t,n){var i=r.peekMeta(e);if(i){for(var s=i.matchingListeners(t),a=[],u=s.length-3;u>=0;u-=3){var l=s[u],c=s[u+1],p=s[u+2],h=o(n,l,c);h===-1&&(n.push(l,c,p),a.push(l,c,p))}return a}}function a(e,t,n,o,s){o||"function"!=typeof n||(o=n,n=null);var a=0;s&&(a|=i.ONCE),r.meta(e).addToListeners(t,n,o,a),"function"==typeof e.didAddListener&&e.didAddListener(t,n,o)}function u(e,t,n,i){i||"function"!=typeof n||(i=n,n=null),r.meta(e).removeFromListeners(t,n,i,function(){"function"==typeof e.didRemoveListener&&e.didRemoveListener.apply(e,arguments)})}function l(e,t,n,r,i){return c(e,[t],n,r,i)}function c(e,t,n,i,o){return i||"function"!=typeof n||(i=n,n=null),r.meta(e).suspendListeners(t,n,i,o)}function p(e){return r.meta(e).watchedEvents()}function h(e,n,o,s){if(!s){var a=r.peekMeta(e);s=a&&a.matchingListeners(n)}if(s&&0!==s.length){for(var l=s.length-3;l>=0;l-=3){var c=s[l],p=s[l+1],h=s[l+2];p&&(h&i.SUSPENDED||(h&i.ONCE&&u(e,n,c,p),c||(c=e),"string"==typeof p?o?t.applyStr(c,p,o):c[p]():o?p.apply(c,o):p.call(c)))}return!0}}function f(e,t){var n=r.peekMeta(e);return!!n&&n.matchingListeners(t).length>0}function m(e,t){var n=[],i=r.peekMeta(e),o=i&&i.matchingListeners(t);if(!o)return n;for(var s=0;s=0&&(s=r(s,u.split(","),a))}for(var a=0;a-1&&o.splice(s,1),this.size=o.length,!0}return!1},isEmpty:function(){return 0===this.size},has:function(e){if(0===this.size)return!1;var n=t.guidFor(e),r=this.presenceSet;return r[n]===!0},forEach:function(e){if("function"!=typeof e&&n(e),0!==this.size){var t=this.list;if(2===arguments.length)for(var r=0;r0;){if(e=O.pop(),t=e._chains)for(n in t)void 0!==t[n]&&O.push(t[n]);if(e._watching&&(r=e._object)){var i=N(r);i&&!i.isSourceDestroying()&&o.removeChainWatcher(r,e._key,e,i)}}this.setMetaDestroyed()}};for(var S in r.protoMethods)s.prototype[S]=r.protoMethods[S];w.forEach(function(e){return g[e](e,s)}),s.prototype.isSourceDestroying=function(){return 0!==(this._flags&v)},s.prototype.setSourceDestroying=function(){this._flags|=v},s.prototype.isSourceDestroyed=function(){return 0!==(this._flags&y)},s.prototype.setSourceDestroyed=function(){this._flags|=y},s.prototype.isMetaDestroyed=function(){return 0!==(this._flags&b)},s.prototype.setMetaDestroyed=function(){this._flags|=b},s.prototype.isProxy=function(){return 0!==(this._flags&_)},s.prototype.setProxy=function(){this._flags|=_},s.prototype._getOrCreateOwnMap=function(e){var n=this[e];return n||(n=this[e]=new t.EmptyObject),n},s.prototype._getInherited=function(e){for(var t=this;void 0!==t;){if(t[e])return t[e];t=t.parent}},s.prototype._findInherited=function(e,t){for(var n=this;void 0!==n;){var r=n[e];if(r){var i=r[t];if(void 0!==i)return i}n=n.parent}};var x=t.symbol("undefined");e.UNDEFINED=x,s.prototype.writeDeps=function(e,n,r){var i=this._getOrCreateOwnMap("_deps"),o=i[e];o||(o=i[e]=new t.EmptyObject),o[n]=r},s.prototype.peekDeps=function(e,t){for(var n=this;void 0!==n;){var r=n._deps;if(r){var i=r[e];if(i&&void 0!==i[t])return i[t]}n=n.parent}},s.prototype.hasDeps=function(e){for(var t=this;void 0!==t;){if(t._deps&&t._deps[e])return!0;t=t.parent}return!1},s.prototype.forEachInDeps=function(e,t){return this._forEachIn("_deps",e,t)},s.prototype._forEachIn=function(e,n,r){for(var i=this,o=new t.EmptyObject,s=[];void 0!==i;){var a=i[e];if(a){var u=a[n];if(u)for(var l in u)o[l]||(o[l]=!0,s.push([l,u[l]]))}i=i.parent}for(var c=0;c=0;s-=4)if(o[s]===e&&(!n||o[s+1]===t&&o[s+2]===n)){if(i!==this)return this._finalizeListeners(),this.removeFromListeners(e,t,n);"function"==typeof r&&r(e,t,o[s+2]),o.splice(s,4)}if(i._listenersFinalized)break;i=i.parent}},matchingListeners:function(e){for(var n=this,i=[];n;){var o=n._listeners;if(o)for(var s=0;s=0;o-=3)i[o+1]===t&&i[o+2]===n&&e.indexOf(i[o])!==-1&&i.splice(o,3)}},watchedEvents:function(){for(var e=this,t={};e;){var n=e._listeners;if(n)for(var r=0;r=0||"concatenatedProperties"===t||"mergedProperties"===t?n=v(e,t,n,o):u&&u.indexOf(t)>=0?n=y(e,t,n,o):h(n)&&(n=g(e,t,n,o,i)),i[t]=void 0,o[t]=n}function _(e,t,n,r,i,o){function s(e){delete n[e],delete r[e]}for(var a=void 0,u=void 0,l=void 0,c=void 0,p=void 0,h=0;h7&&66===e.charCodeAt(t-7)&&e.indexOf("inding",t-6)!==-1}function E(e,t){t.forEachBindings(function(t,n){if(n){var r=t.slice(0,-7);n instanceof u.Binding?(n=n.copy(),n.to(r)):n=new u.Binding(r,n),n.connect(e),e[t]=n}}),t.clearBindings()}function O(e,t){return E(e,t||i.meta(e)),e}function S(e,t,n,r,i){var o=t.methodName,s=void 0,a=void 0;return r[o]||i[o]?(s=i[o],t=r[o]):(a=e[o])&&null!==a&&"object"==typeof a&&a.isDescriptor?(t=a,s=void 0):(t=void 0,s=e[o]),{desc:t,value:s}}function x(e,t,n,r,i){ +var o=n[r];if(o)for(var s=0;s1?t-1:0),r=1;r0){for(var i=new Array(r),o=0;o=0;)if(P(o[s],n,r))return!0;return!1}function D(e,n,r){if(!r[t.guidFor(n)])if(r[t.guidFor(n)]=!0,n.properties)for(var i=Object.keys(n.properties),o=0;o0,l&&l.teardown(e,t),n instanceof o)p=n,e[t]=p,n.setup&&n.setup(e,t);else if(null==n){p=s;e[t]=s}else p=n,Object.defineProperty(e,t,n);return c&&i.overrideChains(e,t,a),e.didDefineProperty&&e.didDefineProperty(e,t,p),this}e.Descriptor=o,e.MANDATORY_SETTER_FUNCTION=s,e.DEFAULT_GETTER_FUNCTION=a,e.INHERITING_GETTER_FUNCTION=u,e.defineProperty=l;(function(){var e=Object.create(Object.prototype,{prop:{configurable:!0,value:1}});return Object.defineProperty(e,"prop",{configurable:!0,value:2}),2===e.prop})()}),s("ember-metal/property_events",["exports","ember-utils","ember-metal/meta","ember-metal/events","ember-metal/tags","ember-metal/observer_set","ember-metal/features","ember-metal/transaction"],function(e,t,n,r,i,o,s,a){"use strict";function u(e,t,r){var i=r||n.peekMeta(e);if(!i||i.isInitialized(e)){var o=i&&i.peekWatching(t)>0,s=e[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0;a&&a.willChange&&a.willChange(e,t),o&&(c(e,t,i),f(e,t,i),b(e,t,i))}}function l(e,t,r){var o=r||n.peekMeta(e);if(!o||o.isInitialized(e)){var s=o&&o.peekWatching(t)>0,u=e[t],l=null!==u&&"object"==typeof u&&u.isDescriptor?u:void 0;l&&l.didChange&&l.didChange(e,t),s&&(o.hasDeps(t)&&p(e,t,o),m(e,t,o,!1),_(e,t,o)),e[w]&&e[w](t),o&&o.isSourceDestroying()||(i.markObjectAsDirty(o,t),a.assertNotRendered(e,t,o))}}function c(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=x,i=!r;i&&(r=x={}),h(u,e,t,r,n),i&&(x=null)}}function p(e,t,n){if((!n||!n.isSourceDestroying())&&n&&n.hasDeps(t)){var r=C,i=!r;i&&(r=C={}),h(l,e,t,r,n),i&&(C=null)}}function h(e,n,r,i,o){var s=void 0,a=void 0,u=t.guidFor(n),l=i[u];l||(l=i[u]={}),l[r]||(l[r]=!0,o.forEachInDeps(r,function(t,r){r&&(s=n[t],a=null!==s&&"object"==typeof s&&s.isDescriptor?s:void 0,a&&a._suspended===n||e(n,t,o))}))}function f(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!1,u)}function m(e,t,n){var r=n.readableChainWatchers();r&&r.notify(t,!0,l)}function d(e,t,n){var r=n.readableChainWatchers();r&&r.revalidate(t)}function g(){S++}function v(){S--,S<=0&&(E.clear(),O.flush())}function y(e,t){g();try{e.call(t)}finally{v.call(t)}}function b(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":before",o=void 0,s=void 0;S?(o=E.add(e,t,i),s=r.accumulateListeners(e,i,o),r.sendEvent(e,i,[e,t],s)):r.sendEvent(e,i,[e,t])}}function _(e,t,n){if(!n||!n.isSourceDestroying()){var i=t+":change",o=void 0;S?(o=O.add(e,t,i),r.accumulateListeners(e,i,o)):r.sendEvent(e,i,[e,t])}}var w=t.symbol("PROPERTY_DID_CHANGE");e.PROPERTY_DID_CHANGE=w;var E=new o.default,O=new o.default,S=0,x=void 0,C=void 0;e.propertyWillChange=u,e.propertyDidChange=l,e.overrideChains=d,e.beginPropertyChanges=g,e.endPropertyChanges=v,e.changeProperties=y}),s("ember-metal/property_get",["exports","ember-metal/debug","ember-metal/path_cache"],function(e,t,n){"use strict";function r(e,t){var r=e[t],o=null!==r&&"object"==typeof r&&r.isDescriptor?r:void 0,s=void 0;return void 0===o&&n.isPath(t)?i(e,t):o?o.get(e,t):(s=r,void 0!==s||"object"!=typeof e||t in e||"function"!=typeof e.unknownProperty?s:e.unknownProperty(t))}function i(e,t){for(var n=e,i=t.split("."),s=0;sa?a:l,c<=0&&(c=0),p=o.splice(0,a),p=[u,c].concat(p),u+=a,l-=c,s=s.concat(n.apply(e,p));return s}e.default=t;var n=Array.prototype.splice}),s("ember-metal/run_loop",["exports","ember-utils","ember-metal/debug","ember-metal/testing","ember-metal/error_handler","ember-metal/property_events","backburner"],function(e,t,n,r,i,o,s){"use strict";function a(e){l.currentRunLoop=e}function u(e,t){l.currentRunLoop=t}function l(){return p.run.apply(p,arguments)}e.default=l;var c={get onerror(){return i.getOnerror()},set onerror(e){return i.setOnerror(e)}},p=new s.default(["sync","actions","destroy"],{GUID_KEY:t.GUID_KEY,sync:{before:o.beginPropertyChanges,after:o.endPropertyChanges},defaultQueue:"actions",onBegin:a,onEnd:u,onErrorTarget:c,onErrorMethod:"onerror"});l.join=function(){return p.join.apply(p,arguments)},l.bind=function(){for(var e=arguments.length,t=Array(e),n=0;n1&&i.writeWatching(t,o-1)}}}e.watchKey=o,e.unwatchKey=s}),s("ember-metal/watch_path",["exports","ember-metal/meta","ember-metal/chains"],function(e,t,n){"use strict";function r(e,n){return(n||t.meta(e)).writableChains(i)}function i(e){return new n.ChainNode(null,null,e)}function o(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;s?o.writeWatching(n,s+1):(o.writeWatching(n,1),r(e,o).add(n))}}function s(e,n,i){if("object"==typeof e&&null!==e){var o=i||t.meta(e),s=o.peekWatching(n)||0;1===s?(o.writeWatching(n,0),r(e,o).remove(n)):s>1&&o.writeWatching(n,s-1)}}e.makeChainNode=i,e.watchPath=o,e.unwatchPath=s}),s("ember-metal/watching",["exports","ember-metal/watch_key","ember-metal/watch_path","ember-metal/path_cache","ember-metal/meta"],function(e,t,n,r,i){"use strict";function o(e,i,o){r.isPath(i)?n.watchPath(e,i,o):t.watchKey(e,i,o)}function s(e,t){if("object"!=typeof e||null===e)return!1;var n=i.peekMeta(e);return(n&&n.peekWatching(t))>0}function a(e,t){var n=i.peekMeta(e);return n&&n.peekWatching(t)||0}function u(e,i,o){r.isPath(i)?n.unwatchPath(e,i,o):t.unwatchKey(e,i,o)}function l(e){i.deleteMeta(e)}e.isWatching=s,e.watcherCount=a,e.unwatch=u,e.destroy=l,e.watch=o}),s("ember-metal/weak_map",["exports","ember-utils","ember-metal/meta"],function(e,t,n){"use strict";function r(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e){if(!(this instanceof i))throw new TypeError("Constructor WeakMap requires 'new'");if(this._id=t.GUID_KEY+o++,null!==e&&void 0!==e){if(!Array.isArray(e))throw new TypeError("The weak map constructor polyfill only supports an array argument");for(var n=0;n7)}function a(e,t){return(e.indexOf("Android 2.")===-1&&e.indexOf("Android 4.0")===-1||e.indexOf("Mobile Safari")===-1||e.indexOf("Chrome")!==-1||e.indexOf("Windows Phone")!==-1)&&!!(t&&"pushState"in t)}function u(e,t){e.replace(o(e)+t)}e.getPath=t,e.getQuery=n,e.getHash=r,e.getFullPath=i,e.getOrigin=o,e.supportsHashChange=s,e.supportsHistory=a,e.replacePath=u}),s("ember-routing/services/routing",["exports","ember-utils","ember-runtime","ember-metal","ember-routing/utils"],function(e,t,n,r,i){"use strict";function o(e,t){for(var n=0,r=0;rc&&(n=l),i.isActiveIntent(n,e,t,!s)}})}),s("ember-routing/system/cache",["exports","ember-utils","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({init:function(){this.cache=new t.EmptyObject},has:function(e){return!!this.cache[e]},stash:function(e,n,r){var i=this.cache[e];i||(i=this.cache[e]=new t.EmptyObject),i[n]=r},lookup:function(e,t,n){var r=this.cache;if(!this.has(e))return n;var i=r[e];return t in i&&void 0!==i[t]?i[t]:n}})}),s("ember-routing/system/controller_for",["exports"],function(e){"use strict";function t(e,t,n){return e.lookup("controller:"+t,n)}e.default=t}),s("ember-routing/system/dsl",["exports","ember-utils","ember-metal"],function(e,t,n){"use strict";function r(e,t){this.parent=e,this.enableLoadingSubstates=t&&t.enableLoadingSubstates,this.matches=[],this.explicitIndex=void 0,this.options=t}function i(e){return e.parent&&"application"!==e.parent}function o(e,t,n){return i(e)&&n!==!0?e.parent+"."+t:t}function s(e,t,n,r){n=n||{};var i=o(e,t,n.resetNamespace);"string"!=typeof n.path&&(n.path="/"+t),e.push(n.path,i,r,n.serialize)}e.default=r,r.prototype={route:function(e,t,n){var i="/_unused_dummy_error_path_route_"+e+"/:error";if(2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),this.enableLoadingSubstates&&(s(this,e+"_loading",{resetNamespace:t.resetNamespace}),s(this,e+"_error",{resetNamespace:t.resetNamespace,path:i})),n){var a=o(this,e,t.resetNamespace),u=new r(a,this.options);s(u,"loading"),s(u,"error",{path:i}),n.call(u),s(this,e,t,u.generate())}else s(this,e,t)},push:function(e,n,r,i){var o=n.split(".");if(this.options.engineInfo){var s=n.slice(this.options.engineInfo.fullName.length+1),a=t.assign({localFullName:s},this.options.engineInfo);i&&(a.serializeMethod=i),this.options.addRouteForEngine(n,a)}else if(i)throw new Error("Defining a route serializer on route '"+n+"' outside an Engine is not allowed.");""!==e&&"/"!==e&&"index"!==o[o.length-1]||(this.explicitIndex=!0),this.matches.push([e,n,r])},resource:function(e,t,n){2===arguments.length&&"function"==typeof t&&(n=t,t={}),1===arguments.length&&(t={}),t.resetNamespace=!0,this.route(e,t,n)},generate:function(){var e=this.matches;return this.explicitIndex||this.route("index",{path:"/"}),function(t){for(var n=0;n0&&(this.connections=[],n.run.once(this.router,"_setOutlets"))}});r.deprecateUnderscoreActions(_),_.reopenClass({isRouteFactory:!0}),e.default=_}),s("ember-routing/system/router",["exports","ember-utils","ember-console","ember-metal","ember-runtime","ember-routing/system/route","ember-routing/system/dsl","ember-routing/location/api","ember-routing/utils","ember-routing/system/router_state","router"],function(e,t,n,r,i,o,s,a,u,l,c){"use strict";function p(){return this}function h(e,t,n){for(var r=!1,i=t.length-1;i>=0;--i){var o=t[i],s=o.handler;if(e===s&&(r=!0),r&&n(s)!==!0)return}}function f(e,t){var r=[],i=void 0;i=e&&"object"==typeof e&&"object"==typeof e.errorThrown?e.errorThrown:e,t&&r.push(t),i&&(i.message&&r.push(i.message),i.stack&&r.push(i.stack),"string"==typeof i&&r.push(i)),n.default.error.apply(this,r)}function m(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s=o+"_"+n,a=e.fullRouteName,u=a+"_"+n;return g(i,r,s,u)?u:""}function d(e,n){var r=e.router,i=t.getOwner(e),o=e.routeName,s="application"===o?n:o+"."+n,a=e.fullRouteName,u="application"===a?n:a+"."+n;return g(i,r,s,u)?u:""}function g(e,t,n,r){var i=t.hasRoute(r),o=e.hasRegistration("template:"+n)||e.hasRegistration("route:"+n);return i&&o}function v(e,n,i){var o=i.shift();if(!e){if(n)return;throw new r.Error("Can't trigger action '"+o+"' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.")}for(var s=!1,a=void 0,u=void 0,l=e.length-1;l>=0;l--)if(a=e[l],u=a.handler,u&&u.actions&&u.actions[o]){if(u.actions[o].apply(u,i)!==!0){if("error"===o){var c=t.guidFor(i[0]);u.router._markErrorAsHandled(c)}return}s=!0}if(T[o])return void T[o].apply(null,i);if(!s&&!n)throw new r.Error("Nothing handled the action '"+o+"'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.")}function y(e,t,n){for(var r=e.router,i=r.applyIntent(t,n),o=i.handlerInfos,s=i.params,a=0;a0;){var r=n.shift();if(r.render.name===t)return r;var i=r.outlets;for(var o in i)n.push(i[o])}}function S(e,n,i){var o=void 0,s={render:i,outlets:new t.EmptyObject,wasUsed:!1};return o=i.into?O(e,i.into):n,o?r.set(o.outlets,i.outlet,s):i.into?x(e,i.into,s):e=s,{liveRoutes:e,ownState:s}}function x(e,n,i){e.outlets.__ember_orphans__||(e.outlets.__ember_orphans__={render:{name:"__ember_orphans__"},outlets:new t.EmptyObject}),e.outlets.__ember_orphans__.outlets[n]=i,r.run.schedule("afterRender",function(){})}function C(e,t,n){var r=O(e,n.routeName);return r?r:(t.outlets.main={render:{name:n.routeName,outlet:"main"},outlets:{}},t)}e.triggerEvent=v;var A=Array.prototype.slice,k=i.Object.extend(i.Evented,{location:"hash",rootURL:"/",_initRouterJs:function(){var e=this.router=new c.default;e.triggerEvent=v,e._triggerWillChangeContext=p,e._triggerWillLeave=p;var t=this.constructor.dslCallbacks||[p],i=this._buildDSL();i.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(var e=0;e0)-(n<0)}function i(e,s){if(e===s)return 0;var a=t.typeOf(e),u=t.typeOf(s);if(n.default){if("instance"===a&&n.default.detect(e)&&e.constructor.compare)return e.constructor.compare(e,s);if("instance"===u&&n.default.detect(s)&&s.constructor.compare)return s.constructor.compare(s,e)*-1}var l=r(o[a],o[u]);if(0!==l)return l;switch(a){case"boolean":case"number":return r(e,s);case"string":return r(e.localeCompare(s),0);case"array":for(var c=e.length,p=s.length,h=Math.min(c,p),f=0;fn})}function h(e,n){return t.computed(e,function(){return t.get(this,e)>=n})}function f(e,n){return t.computed(e,function(){return t.get(this,e)=0)return o[a];if(Array.isArray(e)){if(s=e.slice(),t)for(a=s.length;--a>=0;)s[a]=i(s[a],t,n,o)}else if(r.default&&r.default.detect(e))s=e.copy(t,n,o);else if(e instanceof Date)s=new Date(e.getTime());else{s={};for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&"__"!==u.substring(0,2)&&(s[u]=t?i(e[u],t,n,o):e[u])}return t&&(n.push(e),o.push(s)),s}function o(e,t){return"object"!=typeof e||null===e?e:r.default&&r.default.detect(e)?e.copy(t):i(e,t,t?[]:null,t?[]:null)}e.default=o}),s("ember-runtime/ext/function",["exports","ember-environment","ember-metal"],function(e,t,n){"use strict";var r=Array.prototype.slice,i=Function.prototype;t.ENV.EXTEND_PROTOTYPES.Function&&(i.property=function(){var e=n.computed(this);return e.property.apply(e,arguments)},i.observes=function(){for(var e=arguments.length,t=Array(e),r=0;r1?n-1:0),i=1;i=0&&r>=0&&n.get(e,"hasEnumerableObservers")){o=[],s=t+r;for(var a=t;a=0&&i>=0&&n.get(e,"hasEnumerableObservers")){o=[];for(var s=t+i,a=t;a=n.get(this,"length")))return n.get(this,e)},h.objectsAt=function(e){var t=this;return e.map(function(e){return u(t,e)})},h.nextObject=function(e){return u(this,e)},h["[]"]=n.computed({get:function(e){return this},set:function(e,t){return this.replace(0,n.get(this,"length"),t),this}}),h.firstObject=n.computed(function(){return u(this,0)}).readOnly(),h.lastObject=n.computed(function(){return u(this,n.get(this,"length")-1)}).readOnly(),h.contains=function(e){return this.indexOf(e)>=0},h.slice=function(e,t){var r=n.default.A(),i=n.get(this,"length");for(n.isNone(e)&&(e=0),(n.isNone(t)||t>i)&&(t=i),e<0&&(e=i+e),t<0&&(t=i+t);e=r)&&(t=r-1),t<0&&(t+=r);for(var i=t;i>=0;i--)if(u(this,i)===e)return i;return-1},h.addArrayObserver=function(e,t){return s(this,e,t)},h.removeArrayObserver=function(e,t){return a(this,e,t)},h.hasArrayObservers=n.computed(function(){return n.hasListeners(this,"@array:change")||n.hasListeners(this,"@array:before")}),h.arrayContentWillChange=function(e,t,n){return l(this,e,t,n)},h.arrayContentDidChange=function(e,t,n){return c(this,e,t,n)},h["@each"]=n.computed(function(){return this.__each||(this.__each=new i.default(this)),this.__each}).volatile().readOnly(),h));m.reopen({includes:function(e,t){var r=n.get(this,"length");void 0===t&&(t=0),t<0&&(t+=r);for(var i=t;i1?t-1:0),r=1;r1?n-1:0),i=1;i=t.get(e,"length"))throw new t.Error(s);void 0===r&&(r=1),e.replace(n,r,a)}return e}e.removeAt=o;var s="Index out of range",a=[];e.default=t.Mixin.create(n.default,r.default,{replace:null,clear:function(){var e=t.get(this,"length");return 0===e?this:(this.replace(0,e,a),this)},insertAt:function(e,n){if(e>t.get(this,"length"))throw new t.Error(s);return this.replace(e,0,[n]),this},removeAt:function(e,t){return o(this,e,t)},pushObject:function(e){return this.insertAt(t.get(this,"length"),e),e},pushObjects:function(e){if(!i.default.detect(e)&&!Array.isArray(e))throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");return this.replace(t.get(this,"length"),0,e),this},popObject:function(){var e=t.get(this,"length");if(0===e)return null;var r=n.objectAt(this,e-1);return this.removeAt(e-1,1),r},shiftObject:function(){if(0===t.get(this,"length"))return null;var e=n.objectAt(this,0);return this.removeAt(0),e},unshiftObject:function(e){return this.insertAt(0,e),e},unshiftObjects:function(e){return this.replace(0,0,e),this},reverseObjects:function(){var e=t.get(this,"length");if(0===e)return this;var n=this.toArray().reverse();return this.replace(0,e,n),this},setObjects:function(e){if(0===e.length)return this.clear();var n=t.get(this,"length");return this.replace(0,n,e),this},removeObject:function(e){for(var r=t.get(this,"length")||0;--r>=0;){var i=n.objectAt(this,r);i===e&&this.removeAt(r)}return this},addObject:function(e){var t=void 0;return t=this.includes(e),t||this.pushObject(e),this}})}),s("ember-runtime/mixins/mutable_enumerable",["exports","ember-runtime/mixins/enumerable","ember-metal"],function(e,t,n){"use strict";e.default=n.Mixin.create(t.default,{addObject:null,addObjects:function(e){var t=this;return n.beginPropertyChanges(this),e.forEach(function(e){return t.addObject(e)}),n.endPropertyChanges(this),this},removeObject:null,removeObjects:function(e){n.beginPropertyChanges(this);for(var t=e.length-1;t>=0;t--)this.removeObject(e[t]);return n.endPropertyChanges(this),this}})}),s("ember-runtime/mixins/observable",["exports","ember-metal"],function(e,t){"use strict";e.default=t.Mixin.create({get:function(e){return t.get(this,e)},getProperties:function(){for(var e=arguments.length,n=Array(e),r=0;rt.get(this,"content.length"))throw new t.Error(u);return this._replace(e,0,[n]),this},insertAt:function(e,n){if(t.get(this,"arrangedContent")===t.get(this,"content"))return this._insertAt(e,n);throw new t.Error("Using insertAt on an arranged ArrayProxy is not allowed.")},removeAt:function(e,n){if("number"==typeof e){var r=t.get(this,"content"),i=t.get(this,"arrangedContent"),o=[];if(e<0||e>=t.get(this,"length"))throw new t.Error(u);void 0===n&&(n=1);for(var a=e;a0&&(e=[arguments[0]]),this.__defineNonEnumerable(t.GUID_KEY_PROPERTY);var o=n.meta(this),s=o.proto;if(o.proto=this,e){var a=e;e=null;for(var u=this.concatenatedProperties,c=this.mergedProperties,p=0;p0&&u.indexOf(g)>=0){var _=this[g];v=_?"function"==typeof _.concat?_.concat(v):t.makeArray(_).concat(v):t.makeArray(v)}if(c&&c.length&&c.indexOf(g)>=0){var w=this[g];v=t.assign({},w,v)}b?b.set(this,g,v):"function"!=typeof this.setUnknownProperty||g in this?this[g]=v:this.setUnknownProperty(g,v)}}}l(this,o),this.init.apply(this,arguments),this[h](),o.proto=s,n.finishChains(this),n.sendEvent(this,"init")};return i.toString=n.Mixin.prototype.toString,i.willReopen=function(){r&&(i.PrototypeMixin=n.Mixin.create(i.PrototypeMixin)),r=!1},i._initProperties=function(t){e=t},i.proto=function(){var e=i.superclass;return e&&e.proto(),r||(r=!0,i.PrototypeMixin.applyPartial(i.prototype)),this.prototype},i}var s,a=n.run.schedule,u=n.Mixin._apply,l=n.Mixin.finishPartial,c=n.Mixin.prototype.reopen,p=!1,h=t.symbol("POST_INIT");e.POST_INIT=h;var f=o();f.toString=function(){return"Ember.CoreObject"},f.PrototypeMixin=n.Mixin.create((s={reopen:function(){for(var e=arguments.length,t=Array(e),n=0;n";return r},s)),f.PrototypeMixin.ownerConstructor=f,f.__super__=null;var m={ClassMixin:n.REQUIRED,PrototypeMixin:n.REQUIRED,isClass:!0,isMethod:!1,extend:function(){var e,r=o();return r.ClassMixin=n.Mixin.create(this.ClassMixin),r.PrototypeMixin=n.Mixin.create(this.PrototypeMixin),r.ClassMixin.ownerConstructor=r,r.PrototypeMixin.ownerConstructor=r,c.apply(r.PrototypeMixin,arguments),r.superclass=this,r.__super__=this.prototype,e=r.prototype=Object.create(this.prototype),e.constructor=r,t.generateGuid(e),n.meta(e).proto=e,r.ClassMixin.apply(r),r},create:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r0&&this._initProperties(n),new e},reopen:function(){return this.willReopen(),c.apply(this.PrototypeMixin,arguments),this},reopenClass:function(){return c.apply(this.ClassMixin,arguments),u(this,arguments,!1),this},detect:function(e){if("function"!=typeof e)return!1;for(;e;){if(e===this)return!0;e=e.superclass}return!1},detectInstance:function(e){return e instanceof this},metaForProperty:function(e){var t=this.proto(),n=t[e],r=null!==n&&"object"==typeof n&&n.isDescriptor?n:void 0;return r._meta||{}},_computedProperties:n.computed(function(){p=!0;var e,t=this.proto(),n=[];for(var r in t)e=t[r],e&&e.isDescriptor&&n.push({name:r,meta:e._meta});return n}).readOnly(),eachComputedProperty:function(e,t){for(var r,i={},o=n.get(this,"_computedProperties"),s=0;s=o;){var a=r.objectAt(e,s);a&&(n._addBeforeObserver(a,t,i,"contentKeyWillChange"),n.addObserver(a,t,i,"contentKeyDidChange"))}}function s(e,t,i,o,s){for(;--s>=o;){var a=r.objectAt(e,s);a&&(n._removeBeforeObserver(a,t,i,"contentKeyWillChange"),n.removeObserver(a,t,i,"contentKeyDidChange"))}}e.default=i,i.prototype={__defineNonEnumerable:function(e){this[e.name]=e.descriptor.value},arrayWillChange:function(e,t,r,i){var o=this._keys,a=r>0?t+r:-1;for(var u in o)a>0&&s(e,u,this,t,a),n.propertyWillChange(this,u)},arrayDidChange:function(e,t,r,i){var s=this._keys,a=i>0?t+i:-1;for(var u in s)a>0&&o(e,u,this,t,a),n.propertyDidChange(this,u)},willWatchProperty:function(e){this.beginObservingContentKey(e)},didUnwatchProperty:function(e){this.stopObservingContentKey(e)},beginObservingContentKey:function(e){var r=this._keys;if(r||(r=this._keys=new t.EmptyObject),r[e])r[e]++;else{r[e]=1;var i=this._content,s=n.get(i,"length");o(i,e,this,0,s)}},stopObservingContentKey:function(e){var t=this._keys;if(t&&t[e]>0&&--t[e]<=0){var r=this._content,i=n.get(r,"length");s(r,e,this,0,i)}},contentKeyWillChange:function(e,t){n.propertyWillChange(this,t)},contentKeyDidChange:function(e,t){n.propertyDidChange(this,t)}}}),s("ember-runtime/system/lazy_load",["exports","ember-environment"],function(e,t){"use strict";function n(e,t){var n=o[e];i[e]=i[e]||[],i[e].push(t),n&&t(n)}function r(e,n){o[e]=n;var r=t.environment.window;if(r&&"function"==typeof CustomEvent){var s=new CustomEvent(e,{detail:n,name:e});r.dispatchEvent(s)}i[e]&&i[e].forEach(function(e){return e(n)})}e.onLoad=n,e.runLoadHooks=r;var i=t.ENV.EMBER_LOAD_HOOKS||{},o={},s=o;e._loaded=s}),s("ember-runtime/system/namespace",["exports","ember-utils","ember-metal","ember-environment","ember-runtime/system/object"],function(e,t,n,r,i){"use strict";function o(){return d}function s(e){d=!!e}function a(e,r,i){var o=e.length;v[e.join(".")]=r;for(var s in r)if(y.call(r,s)){var u=r[s];if(e[o]=s,u&&u.toString===h&&!u[n.NAME_KEY])u[n.NAME_KEY]=e.join(".");else if(u&&u.isNamespace){if(i[t.guidFor(u)])continue;i[t.guidFor(u)]=!0,a(e,u,i)}}e.length=o}function u(e){return e>=65&&e<=90}function l(e,t){try{var n=e[t];return n&&n.isNamespace&&n}catch(e){}}function c(){if(!g.PROCESSED)for(var e=r.context.lookup,t=Object.keys(e),i=0;i2){i=new Array(arguments.length-1);for(var o=1;o2)&&(t=Array.prototype.slice.call(arguments,1)),e=i.get(e)||e,o(e,t)}function u(e){return e.split(/\s+/)}function l(e){return N.get(e)}function c(e){return g.get(e)}function p(e){return b.get(e)}function h(e){return O.get(e)}function f(e){return C.get(e)}function m(e){return k.get(e)}var d=/[ _]/g,g=new t.Cache(1e3,function(e){return l(e).replace(d,"-")}),v=/(\-|\_|\.|\s)+(.)?/g,y=/(^|\/)([A-Z])/g,b=new t.Cache(1e3,function(e){return e.replace(v,function(e,t,n){return n?n.toUpperCase():""}).replace(y,function(e,t,n){return e.toLowerCase()})}),_=/^(\-|_)+(.)?/,w=/(.)(\-|\_|\.|\s)+(.)?/g,E=/(^|\/|\.)([a-z])/g,O=new t.Cache(1e3,function(e){for(var t=function(e,t,n){return n?"_"+n.toUpperCase():""},n=function(e,t,n,r){return t+(r?r.toUpperCase():"")},r=e.split("/"),i=0;i-1;return e?function(e){return o.test(s.call(e))}:function(){return!0}}();e.checkHasSuper=a,t.__hasSuper=!1}),s("ember-utils/symbol",["exports","ember-utils/guid","ember-utils/intern"],function(e,t,n){"use strict";function r(e){return n.default(e+" [id="+t.GUID_KEY+Math.floor(Math.random()*new Date)+"]")}e.default=r}),s("ember-utils/to-string",["exports"],function(e){"use strict";function t(e){return e&&e.toString?e.toString():n.call(e)}e.default=t;var n=Object.prototype.toString}),s("ember-views/compat/attrs",["exports","ember-utils"],function(e,t){"use strict";var n=t.symbol("MUTABLE_CELL");e.MUTABLE_CELL=n}),s("ember-views/compat/fallback-view-registry",["exports","ember-utils"],function(e,t){"use strict";e.default=t.dictionary(null)}),s("ember-views/component_lookup",["exports","ember-metal","ember-runtime"],function(e,t,n){"use strict";e.default=n.Object.extend({componentFor:function(e,t,n){var r="component:"+e;return t._lookupFactory(r,n)},layoutFor:function(e,t,n){var r="template:components/"+e;return t.lookup(r,n)}})});s("ember-views/index",["exports","ember-views/system/ext","ember-views/system/jquery","ember-views/system/utils","ember-views/system/event_dispatcher","ember-views/component_lookup","ember-views/mixins/text_support","ember-views/views/core_view","ember-views/mixins/class_names_support","ember-views/mixins/child_views_support","ember-views/mixins/view_state_support","ember-views/mixins/view_support","ember-views/mixins/action_support","ember-views/compat/attrs","ember-views/system/lookup_partial","ember-views/utils/lookup-component","ember-views/system/action_manager","ember-views/compat/fallback-view-registry"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.jQuery=n.default,e.isSimpleClick=r.isSimpleClick,e.getViewBounds=r.getViewBounds,e.getViewClientRects=r.getViewClientRects,e.getViewBoundingClientRect=r.getViewBoundingClientRect,e.getRootViews=r.getRootViews,e.getChildViews=r.getChildViews,e.getViewId=r.getViewId,e.getViewElement=r.getViewElement,e.setViewElement=r.setViewElement,e.STYLE_WARNING=r.STYLE_WARNING,e.EventDispatcher=i.default,e.ComponentLookup=o.default,e.TextSupport=s.default,e.CoreView=a.default,e.ClassNamesSupport=u.default,e.ChildViewsSupport=l.default,e.ViewStateSupport=c.default,e.ViewMixin=p.default,e.ActionSupport=h.default,e.MUTABLE_CELL=f.MUTABLE_CELL,e.lookupPartial=m.default,e.hasPartial=m.hasPartial,e.lookupComponent=d.default,e.ActionManager=g.default,e.fallbackViewRegistry=v.default});s("ember-views/mixins/action_support",["exports","ember-utils","ember-metal","ember-views/compat/attrs"],function(e,t,n,r){"use strict";function i(e,t){return t&&t[r.MUTABLE_CELL]&&(t=t.value),t}e.default=n.Mixin.create({sendAction:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o1?t-1:0),i=1;i1;return!t&&!n}function r(e){var t=e.lookup("-view-registry:main"),n=[];return Object.keys(t).forEach(function(e){var r=t[e];null===r.parentView&&n.push(r)}),n}function i(e){return""===e.tagName?t.guidFor(e):e.elementId||t.guidFor(e)}function o(e){return e[y]}function s(e){e[y]=null}function a(e,t){return e[y]=t}function u(e){var n=t.getOwner(e),r=n.lookup("-view-registry:main");return p(e,r)}function l(e){e[b]=[]}function c(e,t){e[b].push(i(t))}function p(e,t){var n=[],r=[];return e[b].forEach(function(e){var i=t[e];!i||i.isDestroying||i.isDestroyed||n.indexOf(e)!==-1||(n.push(e),r.push(i))}),e[b]=n,r}function h(e){return e.renderer.getBounds(e)}function f(e){var t=h(e),n=document.createRange();return n.setStartBefore(t.firstNode),n.setEndAfter(t.lastNode),n}function m(e){var t=f(e);return t.getClientRects()}function d(e){var t=f(e);return t.getBoundingClientRect()}function g(e,t){return _.call(e,t)}e.isSimpleClick=n,e.getRootViews=r,e.getViewId=i,e.getViewElement=o,e.initViewElement=s,e.setViewElement=a,e.getChildViews=u,e.initChildViews=l,e.addChildView=c,e.collectChildViews=p,e.getViewBounds=h,e.getViewRange=f,e.getViewClientRects=m,e.getViewBoundingClientRect=d,e.matches=g;var v="Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.";e.STYLE_WARNING=v;var y=t.symbol("VIEW_ELEMENT"),b=t.symbol("CHILD_VIEW_IDS"),_="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector);e.elMatches=_}),s("ember-views/utils/lookup-component",["exports","container"],function(e,t){"use strict";function n(e,n,r,o){var s=e.componentFor(r,n,o),a=e.layoutFor(r,n,o),u={layout:a,component:s};return a&&!s&&(u.component=n._lookupFactory(t.privatize(i))),u}function r(e,t,r){var i=e.lookup("component-lookup:main"),o=r&&r.source;if(o){var s=n(i,e,t,r);if(s.component||s.layout)return s}return n(i,e,t)}e.default=r;var i=c.taggedTemplateLiteralLoose(["component:-default"],["component:-default"])}),s("ember-views/views/core_view",["exports","ember-runtime","ember-views/system/utils","ember-views/views/states"],function(e,t,n,r){"use strict";var i=t.FrameworkObject.extend(t.Evented,t.ActionHandler,{isView:!0,_states:r.cloneStates(r.states),init:function(){if(this._super.apply(this,arguments),this._state="preRender",this._currentState=this._states.preRender,n.initViewElement(this),!this.renderer)throw new Error("Cannot instantiate a component without a renderer. Please ensure that you are creating "+this+" with a proper container/registry.")},parentView:null,instrumentDetails:function(e){return e.object=this.toString(),e.containerKey=this._debugContainerKey,e.view=this,e},trigger:function(){this._super.apply(this,arguments);var e=arguments[0],t=this[e];if(t){for(var n=new Array(arguments.length-1),r=1;r1?r-1:0),o=1;o]+) [^\/>]*\/>/gi,function(e,t){return e.slice(0,e.length-3)+">"})),e}function n(e,n){var r=t(e.innerHTML);QUnit.push(r===n,r,n)}e.default=n;var r=function(){if(!document.createElementNS)return!1;var e=document.createElement("div"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(t);var n=e.cloneNode(!0);return''===n.innerHTML}()}),s("internal-test-helpers/equal-tokens",["exports","simple-html-tokenizer"],function(e,t){"use strict";function n(e){return"string"==typeof e?{tokens:t.tokenize(e),html:e}:{tokens:t.tokenize(e.innerHTML),html:e.innerHTML}}function r(e){e.forEach(function(e){"StartTag"===e.type&&(e.attributes=e.attributes.sort(function(e,t){return e[0]>t[0]?1:e[0]"},e.create=n,e.extend=o,e.reopen=o,e.reopenClass=i,e}e.default=n;var r=0}),s("internal-test-helpers/index",["exports","internal-test-helpers/factory","internal-test-helpers/build-owner","internal-test-helpers/confirm-export","internal-test-helpers/equal-inner-html","internal-test-helpers/equal-tokens","internal-test-helpers/module-for","internal-test-helpers/strip","internal-test-helpers/apply-mixins","internal-test-helpers/matchers","internal-test-helpers/run","internal-test-helpers/test-groups","internal-test-helpers/test-cases/abstract","internal-test-helpers/test-cases/abstract-application","internal-test-helpers/test-cases/application","internal-test-helpers/test-cases/query-param","internal-test-helpers/test-cases/abstract-rendering","internal-test-helpers/test-cases/rendering"],function(e,t,n,r,i,o,s,a,u,l,c,p,h,f,m,d,g,v){"use strict";e.factory=t.default,e.buildOwner=n.default,e.confirmExport=r.default,e.equalInnerHTML=i.default,e.equalTokens=o.default,e.moduleFor=s.default,e.strip=a.default,e.applyMixins=u.default,e.equalsElement=l.equalsElement,e.classes=l.classes,e.styles=l.styles,e.regex=l.regex,e.runAppend=c.runAppend,e.runDestroy=c.runDestroy,e.testBoth=p.testBoth,e.testWithDefault=p.testWithDefault,e.AbstractTestCase=h.default,e.AbstractApplicationTestCase=f.default,e.ApplicationTestCase=m.default,e.QueryParamTestCase=d.default,e.AbstractRenderingTestCase=g.default,e.RenderingTestCase=v.default}),s("internal-test-helpers/matchers",["exports"],function(e){"use strict";function t(e){return"object"==typeof e&&null!==e&&u in e}function n(e){var t;return t={},t[u]=!0,t.match=function(t){return e===t},t.expected=function(){return e},t.message=function(){return"should equal "+this.expected()},t}function r(e){var t;return t={},t[u]=!0,t.match=function(t){return e.test(t)},t.expected=function(){return e.toString()},t.message=function(){return"should match "+this.expected()},t}function i(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t.trim(),t&&e.split(/\s+/).sort().join(" ")===t.trim().split(/\s+/).sort().join(" ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function o(e){var t;return t={},t[u]=!0,t.match=function(t){return t=t||"",t=t.trim(),e.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")===t.split(";").map(function(e){return e.trim()}).filter(function(e){return e}).sort().join("; ")},t.expected=function(){return e},t.message=function(){return"should match "+this.expected()},t}function s(e,r,i,o){QUnit.push(e.tagName===r.toUpperCase(),e.tagName.toLowerCase(),r,"expect tagName to be "+r);var s={},u=0;for(var l in i){var c=i[l];null!==c&&u++;var p=t(c)?c:n(c);s[l]=p,QUnit.push(s[l].match(e.getAttribute(l)),e.getAttribute(l),p.expected(),"Element's "+l+" attribute "+p.message())}for(var h={},f=0,m=e.attributes.length;f2?o-2:0),a=2;a1?t-1:0),r=1;re));)n=n.nextSibling;return n},e.prototype.$=function(e){return e?r.jQuery(e,this.element):r.jQuery(this.element)},e.prototype.textValue=function(){return this.$().text()},e.prototype.takeSnapshot=function(){for(var e=this.snapshot=[],t=this.element.firstChild;t;)a(t)||e.push(t),t=t.nextSibling;return e},e.prototype.assertText=function(e){this.assert.strictEqual(this.textValue(),e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertInnerHTML=function(e){i.default(this.element,e)},e.prototype.assertHTML=function(e){o.default(this.element,e,"#qunit-fixture content should be: `"+e+"`")},e.prototype.assertElement=function(e,t){var n=t.ElementType,r=void 0===n?l:n,i=t.tagName,o=t.attrs,a=void 0===o?null:o,u=t.content,c=void 0===u?null:u;if(!(e instanceof r))throw new Error("Expecting a "+r.name+", but got "+e);s.equalsElement(e,i,a,c)},e.prototype.assertComponentElement=function(e,n){var r=n.ElementType,i=void 0===r?l:r,o=n.tagName,a=void 0===o?"div":o,u=n.attrs,c=void 0===u?null:u,p=n.content,h=void 0===p?null:p;c=t.assign({},{id:s.regex(/^ember\d*$/),class:s.classes("ember-view")},c||{}),this.assertElement(e,{ElementType:i,tagName:a,attrs:c,content:h})},e.prototype.assertSameNode=function(e,t){this.assert.strictEqual(e,t,"DOM node stability")},e.prototype.assertInvariants=function(e,t){e=e||this.snapshot,t=t||this.takeSnapshot(),this.assert.strictEqual(t.length,e.length,"Same number of nodes");for(var n=0;n"}catch(e){}finally{if(0!==t.childNodes.length)return!1}return!0}e.domChanges=r,e.treeConstruction=i;var a={colgroup:{depth:2,before:"",after:"
"},table:{depth:1,before:"",after:"
"},tbody:{depth:2,before:"",after:"
"},tfoot:{depth:2,before:"",after:"
"},thead:{depth:2,before:"",after:"
"},tr:{depth:3,before:"",after:"
"}}}),s("glimmer-runtime/lib/compat/svg-inner-html-fix",["exports","glimmer-runtime/lib/bounds","glimmer-runtime/lib/dom/helper"],function(e,t,n){"use strict";function r(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===s||""===s?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,s,i)},t}(t)}function i(e,t,n){if(!e)return t;if(!s(e,n))return t;var r=e.createElement("div");return function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.insertHTMLBefore=function(t,i,s){return null===i||""===i?e.prototype.insertHTMLBefore.call(this,t,i,s):t.namespaceURI!==n?e.prototype.insertHTMLBefore.call(this,t,i,s):o(t,r,i,s)},t}(t)}function o(e,r,i,o){var s=""+i+"";r.innerHTML=s;var a=n.moveNodesBefore(r.firstChild,e,o),u=a[0],l=a[1];return new t.ConcreteBounds(e,u,l)}function s(e,t){var n=e.createElementNS(t,"svg");try{n.insertAdjacentHTML("beforeEnd","")}catch(e){}finally{return(1!==n.childNodes.length||n.firstChild.namespaceURI!==a)&&(n=null,!0)}}e.domChanges=r,e.treeConstruction=i;var a="http://www.w3.org/2000/svg"}),s("glimmer-runtime/lib/compat/text-node-merging-fix",["exports"],function(e){"use strict";function t(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=t.createComment("")}return c.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===r)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=n?n.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,n));var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function n(e,t){return e&&r(e)?function(e){function t(t){e.call(this,t),this.uselessComment=this.createComment("")}return c.inherits(t,e),t.prototype.insertHTMLBefore=function(t,n,r){if(null===n)return e.prototype.insertHTMLBefore.call(this,t,n,r);var i=!1,o=r?r.previousSibling:t.lastChild;o&&o instanceof Text&&(i=!0,t.insertBefore(this.uselessComment,r)); +var s=e.prototype.insertHTMLBefore.call(this,t,n,r);return i&&t.removeChild(this.uselessComment),s},t}(t):t}function r(e){var t=e.createElement("div");return t.innerHTML="first",t.insertAdjacentHTML("beforeEnd","second"),2===t.childNodes.length?(t=null,!1):(t=null,!0)}e.domChanges=t,e.treeConstruction=n}),s("glimmer-runtime/lib/compiled/blocks",["exports","glimmer-runtime/lib/utils","glimmer-runtime/lib/compiler"],function(e,t,n){"use strict";var r=function(e,t){this.ops=e,this.symbols=t};e.CompiledBlock=r;var i=function(e,t){this.program=e,this.symbolTable=t,this.compiled=null};e.Block=i;var o=function(e){function i(n,r){var i=arguments.length<=2||void 0===arguments[2]?t.EMPTY_ARRAY:arguments[2];e.call(this,n,r),this.locals=i}return c.inherits(i,e),i.prototype.hasPositionalParameters=function(){return!!this.locals.length},i.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.InlineBlockCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},i}(i);e.InlineBlock=o;var s=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t}(o);e.PartialBlock=s;var a=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t}(i);e.TopLevelTemplate=a;var u=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.compile=function(e){var t=this.compiled;if(t)return t;var i=new n.EntryPointCompiler(this,e).compile();return this.compiled=new r(i,this.symbolTable.size)},t}(a);e.EntryPoint=u;var l=function(e){function t(t,n,r,i,o){e.call(this,t,n),this.named=r,this.yields=i,this.hasPartials=o,this.hasNamedParameters=!!this.named.length,this.hasYields=!!this.yields.length}return c.inherits(t,e),t}(a);e.Layout=l}),s("glimmer-runtime/lib/compiled/expressions",["exports"],function(e){"use strict";var t=function(){function e(){}return e.prototype.toJSON=function(){return"UNIMPL: "+this.type.toUpperCase()},e}();e.CompiledExpression=t}),s("glimmer-runtime/lib/compiled/expressions/args",["exports","glimmer-runtime/lib/compiled/expressions/positional-args","glimmer-runtime/lib/compiled/expressions/named-args","glimmer-runtime/lib/syntax/core","glimmer-reference"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n}return e.create=function(e,i,o){return e===t.COMPILED_EMPTY_POSITIONAL_ARGS&&i===n.COMPILED_EMPTY_NAMED_ARGS&&o===r.EMPTY_BLOCKS?this.empty():new this(e,i,o)},e.empty=function(){return s},e.prototype.evaluate=function(e){var t=this.positional,n=this.named,r=this.blocks;return a.create(t.evaluate(e),n.evaluate(e),r)},e}();e.CompiledArgs=o;var s=new(function(e){function i(){e.call(this,t.COMPILED_EMPTY_POSITIONAL_ARGS,n.COMPILED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS)}return c.inherits(i,e),i.prototype.evaluate=function(e){return u},i}(o)),a=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.tag=i.combineTagged([e,t])}return e.empty=function(){return u},e.create=function(e,t,n){return new this(e,t,n)},e.positional=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EvaluatedPositionalArgs.create(e),n.EVALUATED_EMPTY_NAMED_ARGS,i)},e.named=function(e){var i=arguments.length<=1||void 0===arguments[1]?r.EMPTY_BLOCKS:arguments[1];return new this(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EvaluatedNamedArgs.create(e),i)},e}();e.EvaluatedArgs=a;var u=new a(t.EVALUATED_EMPTY_POSITIONAL_ARGS,n.EVALUATED_EMPTY_NAMED_ARGS,r.EMPTY_BLOCKS);e.CompiledPositionalArgs=t.CompiledPositionalArgs,e.EvaluatedPositionalArgs=t.EvaluatedPositionalArgs,e.CompiledNamedArgs=n.CompiledNamedArgs,e.EvaluatedNamedArgs=n.EvaluatedNamedArgs}),s("glimmer-runtime/lib/compiled/expressions/concat",["exports","glimmer-reference"],function(e,t){"use strict";function n(e){return"function"!=typeof e.toString?"":String(e)}var r=function(){function e(e){this.parts=e,this.type="concat"}return e.prototype.evaluate=function(e){for(var t=new Array(this.parts.length),n=0;n0?e.join(""):null},r}(t.CachedReference)}),s("glimmer-runtime/lib/compiled/expressions/function",["exports","glimmer-runtime/lib/syntax","glimmer-runtime/lib/compiled/expressions"],function(e,t,n){"use strict";function r(e){return new i(e)}e.default=r;var i=function(e){function t(t){e.call(this),this.type="function-expression",this.func=t}return c.inherits(t,e),t.prototype.compile=function(e,t,n){return new o(this.func,n)},t}(t.Expression),o=function(e){function t(t,n){e.call(this),this.func=t,this.symbolTable=n,this.type="function",this.func=t}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.func,n=this.symbolTable;return t(e,n)},t.prototype.toJSON=function(){var e=this.func;return e.name?"`"+e.name+"(...)`":"`func(...)`"},t}(n.CompiledExpression)}),s("glimmer-runtime/lib/compiled/expressions/has-block",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-runtime/lib/references"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!t)},t.prototype.toJSON=function(){return"has-block("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(t){e.call(this),this.inner=t,this.type="has-block-params"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e);return n.PrimitiveReference.create(!!(t&&t.locals.length>0))},t.prototype.toJSON=function(){return"has-block-params("+this.inner.toJSON()+")"},t}(t.CompiledExpression);e.CompiledHasBlockParams=i;var o=function(){function e(e,t){this.symbol=e,this.debug=t}return e.prototype.evaluate=function(e){return e.scope().getBlock(this.symbol)},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"("+this.debug+"))"},e}();e.CompiledGetBlockBySymbol=o;var s=function(){function e(e,t){this.symbol=e,this.name=t}return e.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.blocks[n]},e.prototype.toJSON=function(){return"get-block($"+this.symbol+"($ARGS)."+this.name+"))"},e}();e.CompiledInPartialGetBlock=s}),s("glimmer-runtime/lib/compiled/expressions/helper",["exports","glimmer-runtime/lib/compiled/expressions"],function(e,t){"use strict";var n=function(e){function t(t,n,r,i){e.call(this),this.name=t,this.helper=n,this.args=r,this.symbolTable=i,this.type="helper"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.helper;return t(e,this.args.evaluate(e),this.symbolTable)},t.prototype.toJSON=function(){return"`"+this.name.join(".")+"($ARGS)`"},t}(t.CompiledExpression);e.default=n}),s("glimmer-runtime/lib/compiled/expressions/lookups",["exports","glimmer-runtime/lib/compiled/expressions","glimmer-reference"],function(e,t,n){"use strict";var r=function(e){function t(t,n){e.call(this),this.base=t,this.path=n,this.type="lookup"}return c.inherits(t,e),t.create=function(e,t){return 0===t.length?e:new this(e,t)},t.prototype.evaluate=function(e){var t=this.base,r=this.path;return n.referenceFromParts(t.evaluate(e),r)},t.prototype.toJSON=function(){return this.base.toJSON()+"."+this.path.join(".")},t}(t.CompiledExpression);e.default=r;var i=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.prototype.evaluate=function(e){return e.getSelf()},t.prototype.toJSON=function(){return"self"},t}(t.CompiledExpression);e.CompiledSelf=i;var o=function(e){function t(t,n){e.call(this),this.symbol=t,this.debug=n}return c.inherits(t,e),t.prototype.evaluate=function(e){return e.referenceForSymbol(this.symbol)},t.prototype.toJSON=function(){return"$"+this.symbol+"("+this.debug+")"},t}(t.CompiledExpression);e.CompiledSymbol=o;var s=function(e){function t(t,n){e.call(this),this.symbol=t,this.name=n}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.symbol,n=this.name,r=e.scope().getPartialArgs(t);return r.named.get(n)},t.prototype.toJSON=function(){return"$"+this.symbol+"($ARGS)."+this.name},t}(t.CompiledExpression);e.CompiledInPartialName=s}),s("glimmer-runtime/lib/compiled/expressions/named-args",["exports","glimmer-runtime/lib/references","glimmer-runtime/lib/utils","glimmer-reference","glimmer-util"],function(e,t,n,r,i){"use strict";var o=function(){function e(e,t){this.keys=e,this.values=t,this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.empty=function(){return s},e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=[],i=0;i"},t}(o));e.COMPILED_EMPTY_NAMED_ARGS=s;var a=function(){function e(e,t){var n=arguments.length<=2||void 0===arguments[2]?void 0:arguments[2];this.keys=e,this.values=t,this._map=n,this.tag=r.combineTagged(t),this.length=e.length,i.assert(e.length===t.length,"Keys and values do not have the same length")}return e.create=function(e){var t=Object.keys(e),n=t.length;if(n>0){for(var r=new Array(n),i=0;i"},t}(i));e.COMPILED_EMPTY_POSITIONAL_ARGS=o;var s=function(){function e(e){this.values=e,this.tag=r.combineTagged(e),this.length=e.length}return e.create=function(e){return new this(e)},e.empty=function(){return a},e.prototype.at=function(e){var n=this.values,r=this.length;return e")}var u=function(e){function t(t){e.call(this),this.text=t,this.type="text"}return c.inherits(t,e),t.prototype.evaluate=function(e){e.stack().appendText(this.text)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.text)]}},t}(t.Opcode);e.TextOpcode=u;var l=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return c.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenPrimitiveElementOpcode=l;var p=function(e){function t(){e.apply(this,arguments),this.type="push-remote-element"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand(),n=r.isConst(t)?void 0:new r.ReferenceCache(t),i=n?n.peek():t.value();e.stack().pushRemoteElement(i),n&&e.updateWith(new o.Assert(n))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type, +args:["$OPERAND"]}},t}(t.Opcode);e.PushRemoteElementOpcode=p;var h=function(e){function t(){e.apply(this,arguments),this.type="pop-remote-element"}return c.inherits(t,e),t.prototype.evaluate=function(e){e.stack().popRemoteElement()},t}(t.Opcode);e.PopRemoteElementOpcode=h;var f=function(e){function t(t){e.call(this),this.tag=t,this.type="open-component-element"}return c.inherits(t,e),t.prototype.evaluate=function(e){e.stack().openElement(this.tag,new y(e.env))},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:[JSON.stringify(this.tag)]}},t}(t.Opcode);e.OpenComponentElementOpcode=f;var m=function(e){function t(){e.apply(this,arguments),this.type="open-dynamic-primitive-element"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=e.frame.getOperand().value();e.stack().openElement(t)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,args:["$OPERAND"]}},t}(t.Opcode);e.OpenDynamicPrimitiveElementOpcode=m;var d=function(){function e(){this.list=null,this.isConst=!0}return e.prototype.append=function(e){var t=this.list,n=this.isConst;null===t&&(t=this.list=[]),t.push(e),this.isConst=n&&r.isConst(e)},e.prototype.toReference=function(){var e=this.list,t=this.isConst;return e?t?i.PrimitiveReference.create(s(e)):new g(e):i.NULL_REFERENCE},e}(),g=function(e){function t(t){e.call(this),this.list=[],this.tag=r.combineTagged(t),this.list=t}return c.inherits(t,e),t.prototype.compute=function(){return s(this.list)},t}(r.CachedReference),v=function(){function e(e){this.env=e,this.opcodes=null,this.classList=null}return e.prototype.addStaticAttribute=function(e,t,n){"class"===t?this.addClass(i.PrimitiveReference.create(n)):this.env.getAppendOperations().setAttribute(e,t,n)},e.prototype.addStaticAttributeNS=function(e,t,n,r){this.env.getAppendOperations().setAttribute(e,n,r,t)},e.prototype.addDynamicAttribute=function(e,t,n,r){if("class"===t)this.addClass(n);else{var i=this.env.attributeFor(e,t,r),o=new C(e,i,t,n);this.addAttribute(o)}},e.prototype.addDynamicAttributeNS=function(e,t,n,r,i){var o=this.env.attributeFor(e,n,i,t),s=new C(e,o,n,r,t);this.addAttribute(s)},e.prototype.flush=function(e,t){for(var n=t.env,r=this.opcodes,i=this.classList,o=0;r&&o.')},t.prototype.valueSyntax=function(){return B.build(this.value)},t}(t.Argument);e.StaticArg=S;var x=function(e){function t(t,n){var r=arguments.length<=2||void 0===arguments[2]?null:arguments[2];e.call(this),this.name=t,this.value=n,this.namespace=r,this.type="dynamic-arg"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2];return new t(n,a.default(r))},t.build=function(e,t){return new this(e,t)},t.prototype.compile=function(){throw new Error('Cannot compile DynamicArg for "'+this.name+'" as it is delegate for ExpressionSyntax.')},t.prototype.valueSyntax=function(){return this.value},t}(t.Argument);e.DynamicArg=x;var C=function(){function e(){}return e.fromSpec=function(e){var t=e[1],n=e[2],r=e[3];return new k(t,a.default(n),r,!0)},e.build=function(e,t,n){var r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new k(e,t,r,n)},e.prototype.compile=function(){throw new Error("Attempting to compile a TrustingAttr which is just a delegate for DynamicAttr.")},e}();e.TrustingAttr=C;var A=function(e){function t(t,n,r){e.call(this),this.name=t,this.value=n,this.namespace=r,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="static-attr",this.isTrusting=!1}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,r,i)},t.build=function(e,t){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];return new this(e,t,n)},t.prototype.compile=function(e){e.append(new s.StaticAttrOpcode(this.namespace,this.name,this.value))},t.prototype.valueSyntax=function(){return B.build(this.value)},t}(t.Attribute);e.StaticAttr=A;var k=function(e){function t(t,n,r,i){void 0===r&&(r=void 0),e.call(this),this.name=t,this.value=n,this.namespace=r,this.isTrusting=i,this["e1185d30-7cac-4b12-b26a-35327d905d92"]=!0,this.type="dynamic-attr"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(n,a.default(r),i)},t.build=function(e,t){var n=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],r=arguments.length<=3||void 0===arguments[3]?null:arguments[3];return new this(e,t,r,n)},t.prototype.compile=function(e,t,n){var r=this.namespace,o=this.value;e.append(new i.PutValueOpcode(o.compile(e,t,n))),r?e.append(new s.DynamicAttrNSOpcode(this.name,this.namespace,this.isTrusting)):e.append(new s.DynamicAttrOpcode(this.name,this.isTrusting))},t.prototype.valueSyntax=function(){return this.value},t}(t.Attribute);e.DynamicAttr=k;var T=function(e){function t(){e.apply(this,arguments),this.type="flush-element"}return c.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.FlushElementOpcode)},t}(t.Statement);e.FlushElement=T;var N=function(e){function t(){e.apply(this,arguments),this.type="close-element"}return c.inherits(t,e),t.fromSpec=function(){return new t},t.build=function(){return new this},t.prototype.compile=function(e){e.append(new s.CloseElementOpcode)},t}(t.Statement);e.CloseElement=N;var R=function(e){function t(t){e.call(this),this.content=t,this.type="text"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.text(this.content)},t}(t.Statement);e.Text=R;var P=function(e){function t(t){e.call(this),this.comment=t,this.type="comment"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.comment(this.comment)},t}(t.Statement);e.Comment=P;var D=function(e){function n(t,n,r){e.call(this),this.tag=t,this.blockParams=n,this.symbolTable=r,this.type="open-element"}return c.inherits(n,e),n.fromSpec=function(e,t){var r=e[1],i=e[2];return new n(r,i,t)},n.build=function(e,t,n){return new this(e,t,n)},n.prototype.scan=function(e){var t=this.tag;if(e.env.hasComponentDefinition([t],this.symbolTable)){var n=this.parameters(e),r=n.args,i=n.attrs;e.startBlock(this.blockParams),this.tagContents(e);var o=e.endBlock(this.blockParams);return r.blocks=Q.fromSpec(o),new I(t,i,r)}return new L(t)},n.prototype.compile=function(e,t){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},n.prototype.toIdentity=function(){var e=this.tag;return new L(e)},n.prototype.parameters=function(e){for(var n=e.next(),r=[],i=[],o=[];!(n instanceof T);){if(n[E])throw new Error("Compile Error: Element modifiers are not allowed in components");var s=n;if(n[t.ATTRIBUTE])r.push(s.name),i.push(s.name),o.push(s.valueSyntax());else{if(!n[t.ARGUMENT])throw new Error("Expected FlushElement, but got ${current}");i.push(s.name),o.push(s.valueSyntax())}n=e.next()}return{args:$.fromNamedArgs(ee.build(i,o)),attrs:r}},n.prototype.tagContents=function(e){for(var t=1;;){var r=e.next();if(r instanceof N&&0===--t)break;e.addStatement(r),(r instanceof n||r instanceof L)&&t++}},n}(t.Statement);e.OpenElement=D;var I=function(e){function t(t,n,r){e.call(this),this.tag=t,this.attrs=n,this.args=r,this.type="component"}return c.inherits(t,e),t.prototype.compile=function(e,t,n){var r=t.getComponentDefinition([this.tag],n),i=this.args.compile(e,t,n),s=this.attrs;e.append(new o.PutComponentDefinitionOpcode(r)),e.append(new o.OpenComponentOpcode(i,s)),e.append(new o.CloseComponentOpcode)},t}(t.Statement);e.Component=I;var L=function(e){function t(t){e.call(this),this.tag=t,this.type="open-primitive-element"}return c.inherits(t,e),t.build=function(e){return new this(e)},t.prototype.compile=function(e){e.append(new s.OpenPrimitiveElementOpcode(this.tag))},t}(t.Statement);e.OpenPrimitiveElement=L;var M=function(e){function t(t,n){e.call(this),this.to=t,this.args=n,this.type="yield"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=$.fromSpec(r,null,J);return new t(n,i)},t.build=function(e,t){var n=$.fromPositionalArgs(Z.build(e));return new this(t,n)},t.prototype.compile=function(e,t,n){var r=this.to,i=this.args.compile(e,t,n);if(e.hasBlockSymbol(r)){var o=e.getBlockSymbol(r),s=new h.CompiledGetBlockBySymbol(o,r);e.append(new F(s,i)),e.append(new U)}else{if(!e.hasPartialArgsSymbol())throw new Error("[BUG] ${to} is not a valid block name.");var o=e.getPartialArgsSymbol(),s=new h.CompiledInPartialGetBlock(o,r);e.append(new F(s,i)),e.append(new U)}},t}(t.Statement);e.Yield=M;var j=function(e){function t(){e.apply(this,arguments)}return c.inherits(t,e),t.fromSpec=function(e){var t=e[1],r=a.default(t);return v(r)?new n.StaticPartialSyntax(r):new n.DynamicPartialSyntax(r); +},t}(t.Statement);e.Partial=j;var F=function(e){function t(t,n){e.call(this),this.inner=t,this.args=n,this.type="open-block"}return c.inherits(t,e),t.prototype.evaluate=function(e){var t=this.inner.evaluate(e),n=void 0;t&&(n=this.args.evaluate(e)),e.pushCallerScope(),t&&e.invokeBlock(t,n)},t.prototype.toJSON=function(){return{guid:this._guid,type:this.type,details:{block:this.inner.toJSON(),positional:this.args.positional.toJSON(),named:this.args.named.toJSON()}}},t}(r.Opcode),U=function(e){function t(){e.apply(this,arguments),this.type="close-block"}return c.inherits(t,e),t.prototype.evaluate=function(e){e.popScope()},t}(r.Opcode);e.CloseBlockOpcode=U;var B=function(e){function t(t){e.call(this),this.value=t,this.type="value"}return c.inherits(t,e),t.fromSpec=function(e){return new t(e)},t.build=function(e){return new this(e)},t.prototype.inner=function(){return this.value},t.prototype.compile=function(e){return new l.default(this.value)},t}(t.Expression);e.Value=B;var z=function(e){function t(t){e.call(this),this.parts=t,this.type="get-argument"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e.split("."))},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(e.hasNamedSymbol(n)){var r=e.getNamedSymbol(n),i=t.slice(1),o=new p.CompiledSymbol(r,n);return p.default.create(o,i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=t.slice(1),o=new p.CompiledInPartialName(r,n);return p.default.create(o,i)}throw new Error("[BUG] @"+this.parts.join(".")+" is not a valid lookup path.")},t}(t.Expression);e.GetArgument=z;var V=function(e){function t(t){e.call(this),this.parts=t,this.type="ref"}return c.inherits(t,e),t.build=function(e){var t=e.split(".");return"this"===t[0]&&(t[0]=null),new this(t)},t.prototype.compile=function(e){var t=this.parts,n=t[0];if(null===n){var r=new p.CompiledSelf,i=t.slice(1);return p.default.create(r,i)}if(e.hasLocalSymbol(n)){var o=e.getLocalSymbol(n),i=t.slice(1),r=new p.CompiledSymbol(o,n);return p.default.create(r,i)}var r=new p.CompiledSelf;return p.default.create(r,t)},t}(t.Expression);e.Ref=V;var q=function(e){function t(t){e.call(this),this.ref=t,this.type="get"}return c.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new V(t))},t.build=function(e){return new this(V.build(e))},t.prototype.compile=function(e){return this.ref.compile(e)},t}(t.Expression);e.Get=q;var H=function(e){function t(t){e.call(this),this.ref=t,this.type="unknown"}return c.inherits(t,e),t.fromSpec=function(e){var t=e[1];return new this(new V(t))},t.build=function(e){return new this(V.build(e))},t.prototype.compile=function(e,t,n){var r=this.ref;return t.hasHelper(r.parts,n)?new f.default(r.parts,t.lookupHelper(r.parts,n),u.CompiledArgs.empty(),n):this.ref.compile(e)},t}(t.Expression);e.Unknown=H;var G=function(e){function t(t,n){e.call(this),this.ref=t,this.args=n,this.type="helper"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1],r=e[2],i=e[3];return new t(new V(n),$.fromSpec(r,i,J))},t.build=function(e,t,n){return new this(V.build(e),$.build(t,n,J))},t.prototype.compile=function(e,t,n){if(t.hasHelper(this.ref.parts,n)){var r=this.args,i=this.ref;return new f.default(i.parts,t.lookupHelper(i.parts,n),r.compile(e,t,n),n)}throw new Error("Compile Error: "+this.ref.parts.join(".")+" is not a helper")},t}(t.Expression);e.Helper=G;var W=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new h.CompiledGetBlockBySymbol(r,n);return new h.default(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new h.CompiledInPartialGetBlock(r,n);return new h.default(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlock=W;var K=function(e){function t(t){e.call(this),this.blockName=t,this.type="has-block-params"}return c.inherits(t,e),t.fromSpec=function(e){var n=e[1];return new t(n)},t.build=function(e){return new this(e)},t.prototype.compile=function(e,t){var n=this.blockName;if(e.hasBlockSymbol(n)){var r=e.getBlockSymbol(n),i=new h.CompiledGetBlockBySymbol(r,n);return new h.CompiledHasBlockParams(i)}if(e.hasPartialArgsSymbol()){var r=e.getPartialArgsSymbol(),i=new h.CompiledInPartialGetBlock(r,n);return new h.CompiledHasBlockParams(i)}throw new Error("[BUG] ${blockName} is not a valid block name.")},t}(t.Expression);e.HasBlockParams=K;var Y=function(){function e(e){this.parts=e,this.type="concat"}return e.fromSpec=function(t){var n=t[1];return new e(n.map(a.default))},e.build=function(e){return new this(e)},e.prototype.compile=function(e,t,n){return new m.default(this.parts.map(function(r){return r.compile(e,t,n)}))},e}();e.Concat=Y;var Q=function(){function e(e){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1];this.type="blocks",this.default=e,this.inverse=t}return e.fromSpec=function(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];return new e(t,n)},e.empty=function(){return J},e}();e.Blocks=Q;var J=new(function(e){function t(){e.call(this,null,null)}return c.inherits(t,e),t}(Q));e.EMPTY_BLOCKS=J;var $=function(){function e(e,t,n){this.positional=e,this.named=t,this.blocks=n,this.type="args"}return e.empty=function(){return ne},e.fromSpec=function(t,n,r){return new e(Z.fromSpec(t),ee.fromSpec(n),r)},e.fromPositionalArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?J:arguments[1];return new e(t,te,n)},e.fromNamedArgs=function(t){var n=arguments.length<=1||void 0===arguments[1]?J:arguments[1];return new e(X,t,n)},e.build=function(e,t,n){return e===X&&t===te&&n===J?ne:new this(e,t,n)},e.prototype.compile=function(e,t,n){var r=this.positional,i=this.named,o=this.blocks;return u.CompiledArgs.create(r.compile(e,t,n),i.compile(e,t,n),o)},e}();e.Args=$;var Z=function(){function e(e){this.values=e,this.type="positional",this.length=e.length}return e.empty=function(){return X},e.fromSpec=function(t){return t&&0!==t.length?new e(t.map(a.default)):X},e.build=function(e){return 0===e.length?X:new this(e)},e.prototype.slice=function(t,n){return e.build(this.values.slice(t,n))},e.prototype.at=function(e){return this.values[e]},e.prototype.compile=function(e,t,n){return u.CompiledPositionalArgs.create(this.values.map(function(r){return r.compile(e,t,n)}))},e}();e.PositionalArgs=Z;var X=new(function(e){function t(){e.call(this,d.EMPTY_ARRAY)}return c.inherits(t,e),t.prototype.slice=function(e,t){return this},t.prototype.at=function(e){},t.prototype.compile=function(e,t){return u.CompiledPositionalArgs.empty()},t}(Z)),ee=function(){function e(e,t){this.keys=e,this.values=t,this.type="named",this.length=e.length}return e.empty=function(){return te},e.fromSpec=function(e){if(null===e||void 0===e)return te;var t=e[0],n=e[1];return 0===t.length?te:new this(t,n.map(function(e){return a.default(e)}))},e.build=function(e,t){return 0===e.length?te:new this(e,t)},e.prototype.at=function(e){var t=this.keys,n=this.values,r=t.indexOf(e);return n[r]},e.prototype.has=function(e){return this.keys.indexOf(e)!==-1},e.prototype.compile=function(e,t,n){var r=this.keys,i=this.values;return new u.CompiledNamedArgs(r,i.map(function(r){return r.compile(e,t,n)}))},e}();e.NamedArgs=ee;var te=new(function(e){function t(){e.call(this,d.EMPTY_ARRAY,d.EMPTY_ARRAY)}return c.inherits(t,e),t.prototype.at=function(e){},t.prototype.has=function(e){return!1},t.prototype.compile=function(e,t){return u.CompiledNamedArgs.empty()},t}(ee)),ne=new(function(e){function t(){e.call(this,X,te,J)}return c.inherits(t,e),t.prototype.compile=function(e,t){return u.CompiledArgs.empty()},t}($))}),s("glimmer-runtime/lib/syntax/expressions",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Expressions.isArg,i=n.Expressions.isConcat,o=n.Expressions.isGet,s=n.Expressions.isHasBlock,a=n.Expressions.isHasBlockParams,u=n.Expressions.isHelper,l=n.Expressions.isUnknown,c=n.Expressions.isPrimitiveValue,p=n.Expressions.isUndefined;e.default=function(e){if(c(e))return t.Value.fromSpec(e);if(p(e))return t.Value.build(void 0);if(r(e))return t.GetArgument.fromSpec(e);if(i(e))return t.Concat.fromSpec(e);if(o(e))return t.Get.fromSpec(e);if(u(e))return t.Helper.fromSpec(e);if(l(e))return t.Unknown.fromSpec(e);if(s(e))return t.HasBlock.fromSpec(e);if(a(e))return t.HasBlockParams.fromSpec(e);throw new Error("Unexpected wire format: "+JSON.stringify(e))}}),s("glimmer-runtime/lib/syntax/statements",["exports","glimmer-runtime/lib/syntax/core","glimmer-wire-format"],function(e,t,n){"use strict";var r=n.Statements.isYield,i=n.Statements.isBlock,o=n.Statements.isPartial,s=n.Statements.isAppend,a=n.Statements.isDynamicAttr,u=n.Statements.isText,l=n.Statements.isComment,c=n.Statements.isOpenElement,p=n.Statements.isFlushElement,h=n.Statements.isCloseElement,f=n.Statements.isStaticAttr,m=n.Statements.isModifier,d=n.Statements.isDynamicArg,g=n.Statements.isStaticArg,v=n.Statements.isTrustingAttr;e.default=function(e,n,y){return r(e)?t.Yield.fromSpec(e):o(e)?t.Partial.fromSpec(e):i(e)?t.Block.fromSpec(e,n,y):s(e)?t.OptimizedAppend.fromSpec(e):a(e)?t.DynamicAttr.fromSpec(e):d(e)?t.DynamicArg.fromSpec(e):v(e)?t.TrustingAttr.fromSpec(e):u(e)?t.Text.fromSpec(e):l(e)?t.Comment.fromSpec(e):c(e)?t.OpenElement.fromSpec(e,n):p(e)?t.FlushElement.fromSpec():h(e)?t.CloseElement.fromSpec():f(e)?t.StaticAttr.fromSpec(e):g(e)?t.StaticArg.fromSpec(e):m(e)?t.Modifier.fromSpec(e):void 0}}),s("glimmer-runtime/lib/template",["exports","glimmer-util","glimmer-runtime/lib/builder","glimmer-runtime/lib/vm","glimmer-runtime/lib/scanner"],function(e,t,n,r,i){"use strict";function o(e){var n=e.id,r=e.meta,i=e.block,o=void 0;n||(n="client-"+a++);var u=function(e,a){var u=a?t.assign({},a,r):r;return o||(o=JSON.parse(i)),s(o,n,u,e)};return{id:n,meta:r,create:u}}function s(e,t,o,s){var a=new i.default(e,o,s),u=void 0,l=function(){return u||(u=a.scanEntryPoint()),u},c=void 0,p=function(){return c||(c=a.scanLayout()),c},h=function(e){return a.scanPartial(e)},f=function(e,t,i){var o=n.ElementStack.forInitialRender(s,t,null),a=l().compile(s),u=r.VM.initial(s,e,i,o,a.symbols);return u.execute(a.ops)};return{id:t,meta:o,_block:e,asEntryPoint:l,asLayout:p,asPartial:h,render:f}}e.default=o;var a=0}),s("glimmer-runtime/lib/upsert",["exports","glimmer-runtime/lib/bounds"],function(e,t){"use strict";function n(e){return e&&"function"==typeof e.toHTML}function r(e){return null!==e&&"object"==typeof e&&"number"==typeof e.nodeType}function i(e){return"string"==typeof e}function o(e,t,o){return i(o)?u.insert(e,t,o):n(o)?p.insert(e,t,o):r(o)?h.insert(e,t,o):void 0}function s(e,t,n){return i(n)?l.insert(e,t,n):r(n)?h.insert(e,t,n):void 0}e.isSafeString=n,e.isNode=r,e.isString=i,e.cautiousInsert=o,e.trustingInsert=s;var a=function(e){this.bounds=e};e.default=a;var u=function(e){function n(t,n){e.call(this,t),this.textNode=n}return c.inherits(n,e),n.insert=function(e,r,i){var o=e.createTextNode(i);e.insertBefore(r.element,o,r.nextSibling);var s=new t.SingleNodeBounds(r.element,o);return new n(s,o)},n.prototype.update=function(e,t){if(i(t)){var n=this.textNode;return n.nodeValue=t,!0}return!1},n}(a),l=function(e){function n(){e.apply(this,arguments)}return c.inherits(n,e),n.insert=function(e,t,r){var i=e.insertHTMLBefore(t.element,r,t.nextSibling);return new n(i)},n.prototype.update=function(e,n){if(i(n)){var r=this.bounds,o=r.parentElement(),s=t.clear(r);return this.bounds=e.insertHTMLBefore(o,s,n),!0}return!1},n}(a),p=function(e){function r(t,n){e.call(this,t),this.lastStringValue=n}return c.inherits(r,e),r.insert=function(e,t,n){var i=n.toHTML(),o=e.insertHTMLBefore(t.element,i,t.nextSibling);return new r(o,i)},r.prototype.update=function(e,r){if(n(r)){var i=r.toHTML();if(i!==this.lastStringValue){var o=this.bounds,s=o.parentElement(),a=t.clear(o);this.bounds=e.insertHTMLBefore(s,a,i),this.lastStringValue=i}return!0}return!1},r}(a),h=function(e){function n(){e.apply(this,arguments)}return c.inherits(n,e),n.insert=function(e,r,i){return e.insertBefore(r.element,i,r.nextSibling),new n(t.single(r.element,i))},n.prototype.update=function(e,n){if(r(n)){var i=this.bounds,o=i.parentElement(),s=t.clear(i);return this.bounds=e.insertNodeBefore(o,n,s),!0}return!1},n}(a)}),s("glimmer-runtime/lib/utils",["exports","glimmer-util"],function(e,t){"use strict";var n=Object.freeze([]);e.EMPTY_ARRAY=n;var r=Object.freeze(t.dict());e.EMPTY_DICT=r;var i=function(){function e(e,t,n){this.list=e,this.start=t,this.end=n}return e.prototype.at=function(e){return e>=this.list.length?null:this.list[e]},e.prototype.min=function(){return this.start},e.prototype.max=function(){return this.end},e}();e.ListRange=i}),s("glimmer-runtime/lib/vm",["exports","glimmer-runtime/lib/vm/append","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result"],function(e,t,n,r){"use strict";e.VM=t.default,e.PublicVM=t.PublicVM,e.UpdatingVM=n.default,e.RenderResult=r.default}),s("glimmer-runtime/lib/vm/append",["exports","glimmer-runtime/lib/environment","glimmer-util","glimmer-reference","glimmer-runtime/lib/compiled/opcodes/vm","glimmer-runtime/lib/vm/update","glimmer-runtime/lib/vm/render-result","glimmer-runtime/lib/vm/frame"],function(e,t,n,r,i,o,s,a){"use strict";var u=function(){function e(e,t,r,i){this.env=e,this.elementStack=i,this.dynamicScopeStack=new n.Stack,this.scopeStack=new n.Stack,this.updatingOpcodeStack=new n.Stack,this.cacheGroups=new n.Stack,this.listBlockStack=new n.Stack,this.frame=new a.FrameStack,this.env=e,this.elementStack=i,this.scopeStack.push(t),this.dynamicScopeStack.push(r)}return e.initial=function(n,r,i,o,s){var a=t.Scope.root(r,s);return new e(n,a,i,o)},e.prototype.capture=function(){return{env:this.env,scope:this.scope(),dynamicScope:this.dynamicScope(),frame:this.frame.capture()}},e.prototype.goto=function(e){this.frame.goto(e)},e.prototype.beginCacheGroup=function(){this.cacheGroups.push(this.updatingOpcodeStack.current.tail())},e.prototype.commitCacheGroup=function(){var e=new i.LabelOpcode("END"),t=this.updatingOpcodeStack.current,o=this.cacheGroups.pop(),s=o?t.nextNode(o):t.head(),a=t.tail(),u=r.combineSlice(new n.ListSlice(s,a)),l=new i.JumpIfNotModifiedOpcode(u,e);t.insertBefore(l,s),t.append(new i.DidModifyOpcode(l)),t.append(e)},e.prototype.enter=function(e){var t=new n.LinkedList,r=this.stack().pushUpdatableBlock(),i=this.capture(),s=new o.TryOpcode(e,i,r,t);this.didEnter(s,t)},e.prototype.enterWithKey=function(e,t){var r=new n.LinkedList,i=this.stack().pushUpdatableBlock(),s=this.capture(),a=new o.TryOpcode(t,s,i,r);this.listBlockStack.current.map[e]=a,this.didEnter(a,r)},e.prototype.enterList=function(e){var t=new n.LinkedList,r=this.stack().pushBlockList(t),i=this.capture(),s=this.frame.getIterator().artifacts,a=new o.ListBlockOpcode(e,i,r,t,s);this.listBlockStack.push(a),this.didEnter(a,t)},e.prototype.didEnter=function(e,t){this.updateWith(e),this.updatingOpcodeStack.push(t)},e.prototype.exit=function(){this.stack().popBlock(),this.updatingOpcodeStack.pop();var e=this.updatingOpcodeStack.current.tail();e.didInitializeChildren()},e.prototype.exitList=function(){this.exit(),this.listBlockStack.pop()},e.prototype.updateWith=function(e){this.updatingOpcodeStack.current.append(e)},e.prototype.stack=function(){return this.elementStack},e.prototype.scope=function(){return this.scopeStack.current},e.prototype.dynamicScope=function(){return this.dynamicScopeStack.current},e.prototype.pushFrame=function(e,t,n){this.frame.push(e.ops),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushComponentFrame=function(e,t,n,r,i,o){this.frame.push(e.ops,r,i,o),t&&this.frame.setArgs(t),t&&t.blocks&&this.frame.setBlocks(t.blocks),n&&this.frame.setCallerScope(n)},e.prototype.pushEvalFrame=function(e){this.frame.push(e)},e.prototype.pushChildScope=function(){this.scopeStack.push(this.scopeStack.current.child())},e.prototype.pushCallerScope=function(){this.scopeStack.push(this.scope().getCallerScope())},e.prototype.pushDynamicScope=function(){var e=this.dynamicScopeStack.current.child();return this.dynamicScopeStack.push(e),e},e.prototype.pushRootScope=function(e,n){var r=t.Scope.root(e,n);return this.scopeStack.push(r),r},e.prototype.popScope=function(){this.scopeStack.pop()},e.prototype.popDynamicScope=function(){this.dynamicScopeStack.pop()},e.prototype.newDestroyable=function(e){this.stack().newDestroyable(e)},e.prototype.getSelf=function(){return this.scope().getSelf()},e.prototype.referenceForSymbol=function(e){return this.scope().getSymbol(e)},e.prototype.getArgs=function(){return this.frame.getArgs()},e.prototype.resume=function(e,t){return this.execute(e,function(e){return e.frame.restore(t)})},e.prototype.execute=function(e,t){n.LOGGER.debug("[VM] Begin program execution");var r=this.elementStack,i=this.frame,o=this.updatingOpcodeStack,a=this.env;r.pushSimpleBlock(),o.push(new n.LinkedList),i.push(e),t&&t(this);for(var u=void 0;i.hasOpcodes();)(u=i.nextStatement())&&(n.LOGGER.debug("[VM] OP "+u.type),n.LOGGER.trace(u),u.evaluate(this));return n.LOGGER.debug("[VM] Completed program execution"),new s.default(a,o.pop(),r.popBlock())},e.prototype.evaluateOpcode=function(e){e.evaluate(this)},e.prototype.invokeBlock=function(e,t){var n=e.compile(this.env);this.pushFrame(n,t)},e.prototype.invokePartial=function(e){var t=e.compile(this.env);this.pushFrame(t)},e.prototype.invokeLayout=function(e,t,n,r,i,o){this.pushComponentFrame(t,e,n,r,i,o)},e.prototype.evaluateOperand=function(e){this.frame.setOperand(e.evaluate(this))},e.prototype.evaluateArgs=function(e){var t=this.frame.setArgs(e.evaluate(this));this.frame.setOperand(t.positional.at(0))},e.prototype.bindPositionalArgs=function(e){var t=this.frame.getArgs();n.assert(t,"Cannot bind positional args");for(var r=t.positional,i=this.scope(),o=0;o2&&"[]"===s.slice(a-2)&&(u=!0,s=s.slice(0,a-2),n[s]||(n[s]=[])),i=o[1]?O(o[1]):""),u?n[s].push(i):n[s]=i}return n},recognize:function(e){var t,n,r,i,o=[this.rootState],s={},u=!1;if(i=e.indexOf("#"),i!==-1&&(e=e.substr(0,i)),r=e.indexOf("?"),r!==-1){var l=e.substr(r+1,e.length);e=e.substr(0,r),s=this.parseQueryString(l)}"/"!==e.charAt(0)&&(e="/"+e);var c=e;for(T.ENCODE_AND_DECODE_PATH_SEGMENTS?e=a(e):(e=decodeURI(e),c=decodeURI(c)),t=e.length,t>1&&"/"===e.charAt(t-1)&&(e=e.substr(0,t-1),c=c.substr(0,c.length-1),u=!0),n=0;n0&&e[r-1]&&e[r-1].hasOwnProperty("queryParams")?(n=e[r-1].queryParams,t=z.call(e,0,r-1),[t,n]):[e,null]}function s(e){for(var t in e)if("number"==typeof e[t])e[t]=""+e[t];else if(V(e[t]))for(var n=0,r=e[t].length;n=0;a--){var l=t[a],c=l.handler;if(c){if(c.events&&c.events[o]){if(c.events[o].apply(c,r)!==!0)return;s=!0}}else l.handlerPromise.then(u(null,i,o,r))}if("error"===o&&"UnrecognizedURLError"===r[0].name)throw r[0];if(!s&&!n)throw new Error("Nothing handled the event '"+o+"'.")}function h(e,t){var n,r={all:{},changed:{},removed:{}};i(r.all,t);var o=!1;s(e),s(t);for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(o=!0,r.removed[n]=e[n]));for(n in t)if(t.hasOwnProperty(n))if(V(e[n])&&V(t[n]))if(e[n].length!==t[n].length)r.changed[n]=t[n],o=!0;else for(var a=0,u=e[n].length;a=0;--u){var l=o[u];i(a,l.params),l.handler.inaccessibleByURL&&(n=null)}if(n){a.queryParams=e._visibleQueryParams||t.queryParams;var c=r.recognizer.generate(s,a),p=e.isCausedByInitialTransition,h="replace"===n&&!e.isCausedByAbortingTransition;p||h?r.replaceURL(c):r.updateURL(c)}}}function L(e,t){try{a(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var r=e.router,i=t.handlerInfos;return R(r,t,e),e.isAborted?(r.state.handlerInfos=r.currentHandlerInfos,n.Promise.reject(w(e))):(I(e,t,e.intent.url),e.isActive=!1,r.activeTransition=null,p(r,r.currentHandlerInfos,!0,["didTransition"]),r.didTransition&&r.didTransition(r.currentHandlerInfos),a(r,e.sequence,"TRANSITION COMPLETE."),i[i.length-1].handler)}catch(t){if(!(t instanceof E)){var o=e.state.handlerInfos;e.trigger(!0,"error",t,e,o[o.length-1].handler),e.abort()}throw t}}function M(e,t,n){var r=t[0]||"/",i=t[t.length-1],o={};i&&i.hasOwnProperty("queryParams")&&(o=J.call(t).queryParams);var s;if(0===t.length){a(e,"Updating query params");var u=e.state.handlerInfos;s=new Y({name:u[u.length-1].name,contexts:[],queryParams:o})}else"/"===r.charAt(0)?(a(e,"Attempting URL transition to "+r),s=new Q({url:r})):(a(e,"Attempting transition to "+r),s=new Y({name:t[0],contexts:z.call(t,1),queryParams:o}));return e.transitionByIntent(s,n)}function j(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n=r.length?r.length-1:t.resolveIndex;return n.Promise.reject({error:e,handlerWithError:u.handlerInfos[i].handler,wasAborted:l,state:u})}function o(e){var n=u.handlerInfos[t.resolveIndex].isResolved;if(u.handlerInfos[t.resolveIndex++]=e,!n){var i=e.handler;g(i,"redirect",e.context,t)}return r().then(s,null,u.promiseLabel("Resolve handler"))}function s(){if(t.resolveIndex===u.handlerInfos.length)return{error:null,state:u};var e=u.handlerInfos[t.resolveIndex];return e.resolve(r,t).then(o,null,u.promiseLabel("Proceed"))}var a=this.params;c(this.handlerInfos,function(e){a[e.name]=e.params||{}}),t=t||{},t.resolveIndex=0;var u=this,l=!1;return n.Promise.resolve(null,this.promiseLabel("Start transition")).then(s,null,this.promiseLabel("Resolve handler")).catch(i,this.promiseLabel("Handle error"))}},b.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:!1,isTransition:!0,isExiting:function(e){for(var t=this.handlerInfos,n=0,r=t.length;n=0;--u){var f=t[u],m=f.handler,d=e.handlerInfos[u],g=null;if(f.names.length>0)if(u>=h)g=this.createParamHandlerInfo(m,n,f.names,p,d);else{var v=a(m);g=this.getHandlerInfoForDynamicSegment(m,n,f.names,p,d,r,u,v)}else g=this.createParamHandlerInfo(m,n,f.names,p,d);if(s){g=g.becomeResolved(null,g.context);var b=d&&d.context;f.names.length>0&&g.context===b&&(g.params=d&&d.params),g.context=b}var _=d;(u>=h||g.shouldSupercede(d))&&(h=Math.min(u,h),_=g),o&&!s&&(_=_.becomeResolved(null,_.context)),c.handlerInfos.unshift(_)}if(p.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+r);return o||this.invalidateChildren(c.handlerInfos,h),i(c.queryParams,this.queryParams||{}),c},invalidateChildren:function(e,t){for(var n=t,r=e.length;n0){if(u=r[r.length-1],l(u))return this.createParamHandlerInfo(e,t,n,r,i);r.pop()}else{if(i&&i.name===e)return i;if(!this.preTransitionState)return i;var c=this.preTransitionState.handlerInfos[s];u=c&&c.context}return C("object",{name:e,getHandler:t,serializer:a,context:u,names:n})},createParamHandlerInfo:function(e,t,n,r,i){for(var o={},s=n.length;s--;){var a=i&&e===i.name&&i.params||{},u=r[r.length-1],c=n[s];if(l(u))o[c]=""+r.pop();else{if(!a.hasOwnProperty(c))throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e);o[c]=a[c]}}return C("param",{name:e,getHandler:t,params:o})}});A.prototype=q(Error.prototype);var Q=m(O,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,t,n){function r(e){if(e&&e.inaccessibleByURL)throw new A(c);return e}var o,s,a=new y,u=t.recognize(this.url);if(!u)throw new A(this.url);var l=!1,c=this.url;for(o=0,s=u.length;o=0&&r;--n){var i=t[n];e.add(t,{as:i.handler +}),r="/"===i.path||""===i.path||".index"===i.handler.slice(-6)}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,t,n,r){var i=this;if(N(this,r,e),!t&&this.activeTransition)return this.activeTransition;var o=new b(this);return o.queryParamsOnly=!0,n.queryParams=F(this,r.handlerInfos,r.queryParams,o),o.promise=o.promise.then(function(e){return I(o,n,!0),i.didTransition&&i.didTransition(i.currentHandlerInfos),e},null,f("Transition complete")),o},transitionByIntent:function(e){try{return T.apply(this,arguments)}catch(t){return new b(this,e,null,t)}},reset:function(){this.state&&c(this.state.handlerInfos.slice().reverse(),function(e){var t=e.handler;g(t,"exit")}),this.oldState=void 0,this.state=new y,this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var t=z.call(arguments);return"/"!==e.charAt(0)&&(t[0]="/"+e),M(this,t).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return M(this,arguments)},intermediateTransitionTo:function(){return M(this,arguments,!0)},refresh:function(e){for(var t=this.activeTransition?this.activeTransition.state:this.state,n=t.handlerInfos,r={},i=0,o=n.length;i1)throw new Error("Second argument not supported");if("object"!=typeof e)throw new TypeError("Argument must be an object");return a.prototype=e,new a},Se=[],xe=void 0,Ce=1,Ae=2,ke=new S,Te=new S;N.prototype._validateInput=function(e){return we(e)},N.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},N.prototype._init=function(){this._result=new Array(this.length)},N.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===xe&&r` the following template: - ### Inline Form - - Given the following template: - - ```app/application.hbs + ```handlebars + {{! application.hbs }} {{component infographicComponentName}} ``` And the following application code: - ```app/controllers/application.js + ```javascript export default Ember.Controller.extend({ infographicComponentName: computed('isMarketOpen', { get() { @@ -8775,87 +8788,33 @@ enifed('ember-glimmer/helpers/component', ['exports', 'ember-utils', 'ember-glim Note: You should not use this helper when you are consistently rendering the same component. In that case, use standard component syntax, for example: - ```app/templates/application.hbs + ```handlebars + {{! application.hbs }} {{live-updating-chart}} ``` - ### Block Form - - Using the block form of this helper is similar to using the block form - of a component. Given the following application template: - - ```app/templates/application.hbs - {{#component infographicComponentName}} - Last update: {{lastUpdateTimestamp}} - {{/component}} - ``` - - The following controller code: - - ```app/controllers/application.js - export default Ember.Controller.extend({ - lastUpdateTimestamp: computed(function() { - return new Date(); - }), - - infographicComponentName: computed('isMarketOpen', { - get() { - if (this.get('isMarketOpen')) { - return 'live-updating-chart'; - } else { - return 'market-close-summary'; - } - } - }) - }); - ``` - - And the following component template: - - ```app/templates/components/live-updating-chart.hbs - {{! chart }} - {{yield}} - ``` - - The `Last Update: {{lastUpdateTimestamp}}` will be rendered in place of the `{{yield}}`. - - ### Nested Usage + ## Nested Usage The `component` helper can be used to package a component path with initial attrs. The included attrs can then be merged during the final invocation. For example, given a `person-form` component with the following template: - ```app/templates/components/person-form.hbs + ```handlebars {{yield (hash - nameInput=(component "my-input-component" value=model.name placeholder="First Name") - )}} + nameInput=(component "my-input-component" value=model.name placeholder="First Name"))}} ``` - When yielding the component via the `hash` helper, the component is invocked directly. - See the following snippet: + The following snippet: ``` {{#person-form as |form|}} - {{form.nameInput placeholder="Username"}} + {{component form.nameInput placeholder="Username"}} {{/person-form}} ``` - Which outputs an input whose value is already bound to `model.name` and `placeholder` + would output an input whose value is already bound to `model.name` and `placeholder` is "Username". - When yielding the component without the hash helper use the `component` helper. - For example, below is a `full-name` component template: - - ```handlebars - {{yield (component "my-input-component" value=model.name placeholder="Name")}} - ``` - - ``` - {{#full-name as |field|}} - {{component field placeholder="Full name"}} - {{/full-name}} - ``` - @method component @since 1.11.0 @for Ember.Templates.helpers @@ -9686,9 +9645,6 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e }); ``` - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - Additionally, the `mut` helper can be combined with the `action` helper to mutate a value. For example: @@ -9702,7 +9658,7 @@ enifed('ember-glimmer/helpers/mut', ['exports', 'ember-utils', 'ember-metal', 'e // my-child.js export default Component.extend({ click() { - this.get('click-count-change')(this.get('childClickCount') + 1); + this.get('clickCountChange')(this.get('childClickCount') + 1); } }); ``` @@ -10558,7 +10514,7 @@ enifed('ember-glimmer/renderer', ['exports', 'ember-glimmer/utils/references', ' var runInTransaction = undefined; - if (false || false) { + if (false || true) { runInTransaction = _emberMetal.runInTransaction; } else { runInTransaction = function (context, methodName) { @@ -13314,7 +13270,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var TwoWayFlushDetectionTag = undefined; - if (false || false) { + if (false || true) { TwoWayFlushDetectionTag = (function () { function _class(tag, key, ref) { this.tag = tag; @@ -13382,7 +13338,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentValue = parentValue; this._propertyKey = propertyKey; - if (false || false) { + if (false || true) { this.tag = new TwoWayFlushDetectionTag(_emberMetal.tagForProperty(parentValue, propertyKey), propertyKey, this); } else { this.tag = _emberMetal.tagForProperty(parentValue, propertyKey); @@ -13397,7 +13353,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal var _parentValue = this._parentValue; var _propertyKey = this._propertyKey; - if (false || false) { + if (false || true) { this.tag.didCompute(_parentValue); } @@ -13426,7 +13382,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal this._parentObjectTag = parentObjectTag; this._propertyKey = propertyKey; - if (false || false) { + if (false || true) { var tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]); this.tag = new TwoWayFlushDetectionTag(tag, propertyKey, this); } else { @@ -13452,7 +13408,7 @@ enifed('ember-glimmer/utils/references', ['exports', 'ember-utils', 'ember-metal _emberMetal.watchKey(parentValue, _propertyKey); } - if (false || false) { + if (false || true) { this.tag.didCompute(parentValue); } @@ -16512,6 +16468,7 @@ enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-me exports.removeObserver = _emberMetalObserver.removeObserver; exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver; exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver; + exports.NAME_KEY = _emberMetalMixin.NAME_KEY; exports.Mixin = _emberMetalMixin.Mixin; exports.aliasMethod = _emberMetalMixin.aliasMethod; exports._immediateObserver = _emberMetalMixin._immediateObserver; @@ -17707,7 +17664,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e var META_DESTROYED = 1 << 3; var IS_PROXY = 1 << 4; - if (false || false) { + if (false || true) { members.lastRendered = ownMap; members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds } @@ -17746,7 +17703,7 @@ enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'e // inherited, and we can optimize it much better than JS runtimes. this.parent = parentMeta; - if (false || false) { + if (false || true) { this._lastRendered = undefined; this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds } @@ -18520,23 +18477,20 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb function applyConcatenatedProperties(obj, key, value, values) { var baseValue = values[key] || obj[key]; - var ret = undefined; if (baseValue) { if ('function' === typeof baseValue.concat) { if (value === null || value === undefined) { - ret = baseValue; + return baseValue; } else { - ret = baseValue.concat(value); + return baseValue.concat(value); } } else { - ret = _emberUtils.makeArray(baseValue).concat(value); + return _emberUtils.makeArray(baseValue).concat(value); } } else { - ret = _emberUtils.makeArray(value); + return _emberUtils.makeArray(value); } - - return ret; } function applyMergedProperties(obj, key, value, values) { @@ -18804,6 +18758,9 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb return obj; } + var NAME_KEY = _emberUtils.GUID_KEY + '_name'; + + exports.NAME_KEY = NAME_KEY; /** The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, @@ -18886,7 +18843,7 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb this.ownerConstructor = undefined; this._without = undefined; this[_emberUtils.GUID_KEY] = null; - this[_emberUtils.NAME_KEY] = null; + this[NAME_KEY] = null; } Mixin._apply = applyMixin; @@ -19278,11 +19235,6 @@ enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'emb exports.required = required; exports.REQUIRED = REQUIRED; }); - -// it is possible to use concatenatedProperties with strings (which cannot be frozen) -// only freeze objects... - -// prevent mutating `concatenatedProperties` array after it is applied // use conditional to avoid stringifying every time enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/events'], function (exports, _emberMetalWatching, _emberMetalEvents) { 'use strict'; @@ -19876,7 +19828,7 @@ enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/me _emberMetalTags.markObjectAsDirty(meta, keyName); - if (false || false) { + if (false || true) { _emberMetalTransaction.assertNotRendered(obj, keyName, meta); } } @@ -21190,18 +21142,18 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d assertNotRendered = undefined; var raise = _emberMetalDebug.assert; - if (false) { + if (true) { raise = function (message, test) {}; } var implication = undefined; - if (false) { + if (true) { implication = 'will be removed in Ember 3.0.'; } else if (false) { implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.'; } - if (false || false) { + if (false || true) { (function () { var counter = 0; var inTransaction = false; @@ -21248,7 +21200,7 @@ enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/d label = 'the same value'; } - return 'You modified ' + label + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; + return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication; })(), false); shouldReflush = true; @@ -23521,8 +23473,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the route, dot-delimited. - For example, a route found at `app/routes/posts/post.js` will have - a `routeName` of `posts.post`. + For example, a route found at `app/routes/posts/post.js` or + `app/posts/post/route.js` (with pods) will have a `routeName` of + `posts.post`. @property routeName @for Ember.Route @type String @@ -23738,23 +23691,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Returns a hash containing the parameters of an ancestor route. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('member', { path: ':name' }, function() { this.route('interest', { path: ':interest' }); }); }); - ``` - ```app/routes/member.js - export default Ember.Route.extend({ + App.MemberRoute = Ember.Route.extend({ queryParams: { memberQp: { refreshModel: true } } }); - ``` - ```app/routes/member/interest.js - export default Ember.Route.extend({ + App.MemberInterestRoute = Ember.Route.extend({ queryParams: { interestQp: { refreshModel: true } }, @@ -23844,10 +23792,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can use to reset controller values either when the model changes or the route is exiting. - ```app/routes/articles.js - import Ember from 'ember'; - export default Ember.Route.extend({ - resetController(controller, isExiting, transition) { + ```javascript + App.ArticlesRoute = Ember.Route.extend({ + // ... + resetController: function(controller, isExiting, transition) { if (isExiting) { controller.set('page', 1); } @@ -23898,19 +23846,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The name of the template to use by default when rendering this routes template. - ```app/routes/posts/list.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + let PostsList = Ember.Route.extend({ templateName: 'posts/list' }); - ``` - ```app/routes/posts/index.js - import PostsList from '../posts/list'; - export default PostsList.extend(); - ``` - ```app/routes/posts/archived.js - import PostsList from '../posts/list'; - export default PostsList.extend(); + App.PostsIndexRoute = PostsList.extend(); + App.PostsArchivedRoute = PostsList.extend(); ``` @property templateName @type String @@ -23945,11 +23886,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' or decorating the transition from the currently active routes. A good example is preventing navigation when a form is half-filled out: - ```app/routes/contact-form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ContactFormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData')) { this.controller.displayNavigationConfirm(); transition.abort(); @@ -23983,11 +23923,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' have resolved. The `didTransition` action has no arguments, however, it can be useful for tracking page views or resetting state on the controller. - ```app/routes/login.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.LoginRoute = Ember.Route.extend({ actions: { - didTransition() { + didTransition: function() { this.controller.get('errors.base').clear(); return true; // Bubble the didTransition event } @@ -24004,10 +23943,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' hook returns a promise that is not already resolved. The current `Transition` object is the first parameter and the route that triggered the loading event is the second parameter. - ```app/routes/application.js - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - loading(transition, route) { + loading: function(transition, route) { let controller = this.controllerFor('foo'); controller.set('currentlyLoading', true); transition.finally(function() { @@ -24033,14 +23972,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Here is an example of an error handler that will be invoked for rejected promises from the various hooks on the route, as well as any unhandled errors from child routes: - ```app/routes/admin.js - import Ember from 'ember'; - export default Ember.Route.extend({ - beforeModel() { + ```javascript + App.AdminRoute = Ember.Route.extend({ + beforeModel: function() { return Ember.RSVP.reject('bad things!'); }, actions: { - error(error, transition) { + error: function(error, transition) { // Assuming we got here due to the error in `beforeModel`, // we can expect that error === "bad things!", // but a promise model rejecting would also @@ -24058,11 +23996,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' will fire a default error handler that logs the error. You can specify your own global default error handler by overriding the `error` handler on `ApplicationRoute`: - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ actions: { - error(error, transition) { + error: function(error, transition) { this.controllerFor('banner').displayError(error.message); } } @@ -24078,12 +24015,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router enters the route. It is not executed when the model for the route changes. - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ - collectAnalytics: Ember.on('activate', function(){ + ```javascript + App.ApplicationRoute = Ember.Route.extend({ + collectAnalytics: function(){ collectAnalytics(); - }) + }.on('activate') }); ``` @event activate @@ -24094,12 +24030,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** This event is triggered when the router completely exits this route. It is not executed when the model for the route changes. - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ - trackPageLeaveAnalytics: Ember.on('deactivate', function(){ + ```javascript + App.IndexRoute = Ember.Route.extend({ + trackPageLeaveAnalytics: function(){ trackPageLeaveAnalytics(); - }) + }.on('deactivate') }); ``` @event deactivate @@ -24110,11 +24045,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** The controller associated with this route. Example - ```app/routes/form.js - import Ember from 'ember'; - export default Ember.Route.extend({ + ```javascript + App.FormRoute = Ember.Route.extend({ actions: { - willTransition(transition) { + willTransition: function(transition) { if (this.controller.get('userHasEnteredData') && !confirm('Are you sure you want to abandon progress?')) { transition.abort(); @@ -24286,17 +24220,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Multiple models will be applied last to first recursively up the route tree. - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('blogPost', { path:':blogPostId' }, function() { - this.route('blogComment', { path: ':blogCommentId' }); + this.route('blogComment', { path: ':blogCommentId', resetNamespace: true }); }); }); - export default Router; - ``` - ```javascript - this.transitionTo('blogComment', aPost, aComment); + this.transitionTo('blogComment', aPost, aComment); this.transitionTo('blogComment', 1, 13); ``` It is also possible to pass a URL (a string that starts with a @@ -24318,20 +24248,15 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` See also [replaceWith](#method_replaceWith). Simple Transition Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); this.route('fourOhFour', { path: '*:' }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember': - export Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToSecret(context) { + moveToSecret: function(context) { if (authorized()) { this.transitionTo('secret', context); } else { @@ -24342,63 +24267,48 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }); ``` Transition to a nested route - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('articles', { path: '/articles' }, function() { this.route('new'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToNewArticle() { + transitionToNewArticle: function() { this.transitionTo('articles.new'); } } }); ``` Multiple Models Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('breakfast', { path: ':breakfastId' }, function() { - this.route('cereal', { path: ':cerealId' }); + this.route('cereal', { path: ':cerealId', resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - moveToChocolateCereal() { + moveToChocolateCereal: function() { let cereal = { cerealId: 'ChocolateYumminess' }; let breakfast = { breakfastId: 'CerealAndMilk' }; - this.transitionTo('breakfast.cereal', breakfast, cereal); + this.transitionTo('cereal', breakfast, cereal); } } }); ``` Nested Route with Query String Example - ```app/routes.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('fruits', function() { this.route('apples'); }); }); - export default Router; - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - transitionToApples() { + transitionToApples: function() { this.transitionTo('fruits.apples', { queryParams: { color: 'red' } }); } } @@ -24469,18 +24379,13 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Beside that, it is identical to `transitionTo` in all other respects. See 'transitionTo' for additional information regarding multiple models. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); this.route('secret'); }); - export default Router; - ``` - ```app/routes/secret.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.SecretRoute = Ember.Route.extend({ + afterModel: function() { if (!authorized()){ this.replaceWith('index'); } @@ -24505,28 +24410,20 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' Sends an action to the router, which will delegate it to the currently active route hierarchy per the bubbling rules explained under `actions`. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('index'); }); - export default Router; - ``` - ```app/routes/application.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.ApplicationRoute = Ember.Route.extend({ actions: { - track(arg) { + track: function(arg) { console.log(arg, 'was clicked'); } } }); - ``` - ```app/routes/index.js - import Ember from 'ember'; - export default Ember.Route.extend({ + App.IndexRoute = Ember.Route.extend({ actions: { - trackIfDebug(arg) { + trackIfDebug: function(arg) { if (debug) { this.send('track', arg); } @@ -24645,7 +24542,6 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' cache.stash(cacheKey, prop, value); } }, - /** This hook is the first of the route entry validation hooks called when an attempt is made to transition into a route @@ -24665,6 +24561,46 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' transition until the promise resolves (or rejects). This could be useful, for instance, for retrieving async code from the server that is required to enter a route. + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + return Ember.$.getScript('/models/post.js'); + } + } + }); + ``` + If `App.Post` doesn't exist in the above example, + `beforeModel` will use jQuery's `getScript`, which + returns a promise that resolves after the server has + successfully retrieved and executed the code from the + server. Note that if an error were to occur, it would + be passed to the `error` hook on `Ember.Route`, but + it's also possible to handle errors specific to + `beforeModel` right from within the hook (to distinguish + from the shared error handling behavior of the `error` + hook): + ```javascript + App.PostRoute = Ember.Route.extend({ + beforeModel: function(transition) { + if (!App.Post) { + let self = this; + return Ember.$.getScript('post.js').then(null, function(e) { + self.transitionTo('help'); + // Note that the above transitionTo will implicitly + // halt the transition. If you were to return + // nothing from this promise reject handler, + // according to promise semantics, that would + // convert the reject into a resolve and the + // transition would continue. To propagate the + // error so that it'd be handled by the `error` + // hook, you would have to + return Ember.RSVP.reject(e); + }); + } + } + }); + ``` @method beforeModel @param {Transition} transition @return {Promise} if the value returned from this hook is @@ -24683,10 +24619,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' the `transition`, and is therefore suited to performing logic that can only take place after the model has already resolved. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel(posts, transition) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + afterModel: function(posts, transition) { if (posts.get('length') === 1) { this.transitionTo('post.show', posts.get('firstObject')); } @@ -24746,12 +24681,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the URL into the model for this route. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` The model for the `post` route is `store.findRecord('post', params.post_id)`. By default, if your route has a dynamic segment ending in `_id`: @@ -24785,10 +24718,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' if a promise returned from `model` fails, the error will be handled by the `error` hook on `Ember.Route`. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + ```javascript + App.PostRoute = Ember.Route.extend({ + model: function(params) { return this.store.findRecord('post', params.post_id); } }); @@ -24804,7 +24736,8 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' @public */ model: function (params, transition) { - var name = undefined, + var match = undefined, + name = undefined, sawParams = undefined, value = undefined; var queryParams = _emberMetal.get(this, '_qp.map'); @@ -24814,8 +24747,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' continue; } - var match = prop.match(/^(.*)_id$/); - if (match) { + if (match = prop.match(/^(.*)_id$/)) { name = match[1]; value = params[prop]; } @@ -24891,20 +24823,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** A hook you can implement to convert the route's model into parameters for the URL. - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - model(params) { + App.PostRoute = Ember.Route.extend({ + model: function(params) { // the server returns `{ id: 12 }` return Ember.$.getJSON('/posts/' + params.post_id); }, - serialize(model) { + serialize: function(model) { // this will make the URL `/posts/12` return { post_id: model.id }; } @@ -24936,13 +24864,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' prevent this default behavior. If you want to preserve that behavior when implementing your `setupController` function, make sure to call `_super`: - ```app/routes/photos.js - import Ember from 'ebmer'; - export default Ember.Route.extend({ - model() { + ```javascript + App.PhotosRoute = Ember.Route.extend({ + model: function() { return this.store.findAll('photo'); }, - setupController(controller, model) { + setupController: function(controller, model) { // Call _super for default behavior this._super(controller, model); // Implement your custom setup after @@ -24954,21 +24881,18 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' of this route. If no explicit controller is defined, Ember will automatically create one. As an example, consider the router: - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` For the `post` route, a controller named `App.PostController` would be used if it is defined. If it is not defined, a basic `Ember.Controller` instance would be used. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, model) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, model) { controller.set('model', model); } }); @@ -24986,14 +24910,12 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' }, /** - Returns the resolved model of the current route, or a parent (or any ancestor) - route in a route hierarchy. + Returns the controller for a particular route or name. The controller instance must already have been created, either through entering the associated route or using `generateController`. - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.controllerFor('posts').set('currentPost', post); } @@ -25026,10 +24948,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' /** Generates a controller for a route. Example - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - setupController(controller, post) { + ```javascript + App.PostRoute = Ember.Route.extend({ + setupController: function(controller, post) { this._super(controller, post); this.generateController('posts'); } @@ -25055,19 +24976,14 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' retrieve it. If the ancestor route's model was a promise, its resolved result is returned. Example - ```app/router.js - // ... - Router.map(function() { + ```javascript + App.Router.map(function() { this.route('post', { path: '/post/:post_id' }, function() { this.route('comments', { resetNamespace: true }); }); }); - export default Router; - ``` - ```app/routes/comments.js - import Ember from 'ember'; - export default Ember.Route.extend({ - afterModel() { + App.CommentsRoute = Ember.Route.extend({ + afterModel: function() { this.set('post', this.modelFor('post')); } }); @@ -25112,10 +25028,9 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' template, configured with the controller for the route. This method can be overridden to set up and render additional or alternative templates. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model) { + ```javascript + App.PostsRoute = Ember.Route.extend({ + renderTemplate: function(controller, model) { let favController = this.controllerFor('favoritePost'); // Render the `favoritePost` template into // the outlet `posts`, and display the `favoritePost` @@ -25143,12 +25058,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' phase of routing (via the `renderTemplate` hook) and later in response to user interaction. For example, given the following minimal router and templates: - ```app/router.js - // ... - Router.map(function() { + ```javascript + Router.map(function() { this.route('photos'); }); - export default Router; ``` ```handlebars @@ -25162,10 +25075,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` You can render `photos.hbs` into the `"anOutletName"` outlet of `application.hbs` by calling `render`: - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function() { this.render('photos', { into: 'application', outlet: 'anOutletName' @@ -25175,10 +25088,10 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` `render` additionally allows you to supply which `controller` and `model` objects should be loaded and associated with the rendered template. - ```app/routes/posts.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate(controller, model){ + ```javascript + // posts route + Ember.Route.extend({ + renderTemplate: function(controller, model){ this.render('posts', { // the template to render, referenced by name into: 'application', // the template to render into, referenced by name outlet: 'anOutletName', // the outlet inside `options.template` to render into. @@ -25197,26 +25110,26 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' based on the name of the route specified in the router or the Route's `controllerName` and `templateName` properties. For example: - ```app/router.js - // ... - Router.map(function() { + ```javascript + // router + Router.map(function() { this.route('index'); this.route('post', { path: '/posts/:post_id' }); }); - export default Router; ``` - ```app/routes/post.js - import Ember from 'ember'; - export default Ember.Route.extend({ - renderTemplate() { + ```javascript + // post route + PostRoute = App.Route.extend({ + renderTemplate: function() { this.render(); // all defaults apply } }); ``` - The name of the route, defined by the router, is `post`. + The name of the `PostRoute`, defined by the router, is `post`. The following equivalent default options will be applied when the Route calls `render`: ```javascript + // this.render('post', { // the template name associated with 'post' Route into: 'application', // the parent route to 'post' Route outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous, @@ -25264,17 +25177,16 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' * `parentView`: the name of the view containing the outlet to clear (default: the view rendered by the parent route) Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ + ```javascript + App.ApplicationRoute = App.Route.extend({ actions: { - showModal(evt) { + showModal: function(evt) { this.render(evt.modalName, { outlet: 'modal', into: 'application' }); }, - hideModal(evt) { + hideModal: function(evt) { this.disconnectOutlet({ outlet: 'modal', parentView: 'application' @@ -25285,18 +25197,11 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' ``` Alternatively, you can pass the `outlet` name directly as a string. Example: - ```app/routes/application.js - import Ember from 'ember'; - export default App.Route.extend({ - actions: { - showModal(evt) { - // ... - }, - hideModal(evt) { - this.disconnectOutlet('modal'); - } - } - }); + ```javascript + hideModal: function(evt) { + this.disconnectOutlet('modal'); + } + ``` @method disconnectOutlet @param {Object|String} options the options hash or outlet name @since 1.0.0 @@ -25440,7 +25345,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-utils', 'ember-metal', ' var template = owner.lookup('template:' + templateName); var parent = undefined; - if (into && (parent = parentRoute(route)) && into === parent.routeName) { + if (into && (parent = parentRoute(route)) && into === parentRoute(route).routeName) { into = undefined; } @@ -27012,7 +26917,6 @@ enifed('ember-routing/system/router', ['exports', 'ember-utils', 'ember-console' _emberMetal.set(target.outlets, renderOptions.outlet, myState); } else { if (renderOptions.into) { - // Megahax time. Post-3.0-breaking-changes, we will just assert // right here that the user tried to target a nonexistent // thing. But for now we still need to support the `render` @@ -27257,7 +27161,11 @@ enifed('ember-routing/utils', ['exports', 'ember-utils', 'ember-metal'], functio */ function normalizeControllerQueryParams(queryParams) { - var qpMap = {}; + if (queryParams._qpMap) { + return queryParams._qpMap; + } + + var qpMap = queryParams._qpMap = {}; for (var i = 0; i < queryParams.length; ++i) { accumulateQueryParamDescriptors(queryParams[i], qpMap); @@ -29928,6 +29836,8 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi args[_key - 1] = arguments[_key]; } + var target = undefined; + if (this.actions && this.actions[actionName]) { var shouldBubble = this.actions[actionName].apply(this, args) === true; if (!shouldBubble) { @@ -29935,9 +29845,10 @@ enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], functi } } - var target = _emberMetal.get(this, 'target'); - if (target) { - target.send.apply(target, arguments); + if (target = _emberMetal.get(this, 'target')) { + var _target; + + (_target = target).send.apply(_target, arguments); } }, @@ -30351,7 +30262,7 @@ enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', ' /** This returns the objects at the specified indexes, using `objectAt`. ```javascript - let arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] ``` @@ -31286,8 +31197,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-meta for (var idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); - found = callback.call(target, next, idx, this); - if (found) { + if (found = callback.call(target, next, idx, this)) { ret = next; } @@ -34066,7 +33976,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met // using ember-metal/lib/main here to ensure that ember-debug is setup // if present - var _Mixin$create, _ClassMixinProps; + var _Mixin$create; var schedule = _emberMetal.run.schedule; var applyMixin = _emberMetal.Mixin._apply; @@ -34313,7 +34223,7 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met CoreObject.__super__ = null; - var ClassMixinProps = (_ClassMixinProps = { + var ClassMixinProps = { ClassMixin: _emberMetal.REQUIRED, @@ -34321,94 +34231,309 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met isClass: true, - isMethod: false - }, _ClassMixinProps[_emberUtils.NAME_KEY] = null, _ClassMixinProps[_emberUtils.GUID_KEY] = null, _ClassMixinProps.extend = function () { - var Class = makeCtor(); - var proto; - Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); - Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); + isMethod: false, + /** + Creates a new subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(thing); + } + }); + ``` + This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. + You can also create a subclass from any existing class by calling its `extend()` method. + For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: + ```javascript + const PersonComponent = Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isAdministrator'] + }); + ``` + When defining a subclass, you can override methods but still access the + implementation of your parent class by calling the special `_super()` method: + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + var name = this.get('name'); + alert(`${name} says: ${thing}`); + } + }); + const Soldier = Person.extend({ + say(thing) { + this._super(`${thing}, sir!`); + }, + march(numberOfHours) { + alert(`${this.get('name')} marches for ${numberOfHours} hours.`); + } + }); + let yehuda = Soldier.create({ + name: "Yehuda Katz" + }); + yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" + ``` + The `create()` on line #17 creates an *instance* of the `Soldier` class. + The `extend()` on line #8 creates a *subclass* of `Person`. Any instance + of the `Person` class will *not* have the `march()` method. + You can also pass `Mixin` classes to add additional properties to the subclass. + ```javascript + const Person = Ember.Object.extend({ + say(thing) { + alert(`${this.get('name')} says: ${thing}`); + } + }); + const SingingMixin = Mixin.create({ + sing(thing){ + alert(`${this.get('name')} sings: la la la ${thing}`); + } + }); + const BroadwayStar = Person.extend(SingingMixin, { + dance() { + alert(`${this.get('name')} dances: tap tap tap tap `); + } + }); + ``` + The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. + @method extend + @static + @param {Mixin} [mixins]* One or more Mixin classes + @param {Object} [arguments]* Object containing values to use within the new class + @public + */ + extend: function () { + var Class = makeCtor(); + var proto; + Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin); + Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin); - Class.ClassMixin.ownerConstructor = Class; - Class.PrototypeMixin.ownerConstructor = Class; + Class.ClassMixin.ownerConstructor = Class; + Class.PrototypeMixin.ownerConstructor = Class; - reopen.apply(Class.PrototypeMixin, arguments); + reopen.apply(Class.PrototypeMixin, arguments); - Class.superclass = this; - Class.__super__ = this.prototype; + Class.superclass = this; + Class.__super__ = this.prototype; - proto = Class.prototype = Object.create(this.prototype); - proto.constructor = Class; - _emberUtils.generateGuid(proto); - _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype + proto = Class.prototype = Object.create(this.prototype); + proto.constructor = Class; + _emberUtils.generateGuid(proto); + _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype - Class.ClassMixin.apply(Class); - return Class; - }, _ClassMixinProps.create = function () { - var C = this; + Class.ClassMixin.apply(Class); + return Class; + }, - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } + /** + Creates an instance of a class. Accepts either no arguments, or an object + containing values to initialize the newly instantiated object with. + ```javascript + const Person = Ember.Object.extend({ + helloWorld() { + alert(`Hi, my name is ${this.get('name')}`); + } + }); + let tom = Person.create({ + name: 'Tom Dale' + }); + tom.helloWorld(); // alerts "Hi, my name is Tom Dale". + ``` + `create` will call the `init` function if defined during + `Ember.AnyObject.extend` + If no arguments are passed to `create`, it will not set values to the new + instance during initialization: + ```javascript + let noName = Person.create(); + noName.helloWorld(); // alerts undefined + ``` + NOTE: For performance reasons, you cannot declare methods or computed + properties during `create`. You should instead declare methods and computed + properties when using `extend`. + @method create + @static + @param [arguments]* + @public + */ + create: function () { + var C = this; - if (args.length > 0) { - this._initProperties(args); - } - return new C(); - }, _ClassMixinProps.reopen = function () { - this.willReopen(); - reopen.apply(this.PrototypeMixin, arguments); - return this; - }, _ClassMixinProps.reopenClass = function () { - reopen.apply(this.ClassMixin, arguments); - applyMixin(this, arguments, false); - return this; - }, _ClassMixinProps.detect = function (obj) { - if ('function' !== typeof obj) { - return false; - } - while (obj) { - if (obj === this) { - return true; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - obj = obj.superclass; - } - return false; - }, _ClassMixinProps.detectInstance = function (obj) { - return obj instanceof this; - }, _ClassMixinProps.metaForProperty = function (key) { - var proto = this.proto(); - var possibleDesc = proto[key]; - var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - return desc._meta || {}; - }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; - var proto = this.proto(); - var property; - var properties = []; + if (args.length > 0) { + this._initProperties(args); + } + return new C(); + }, - for (var name in proto) { - property = proto[name]; + /** + Augments a constructor's prototype with additional + properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + o = MyObject.create(); + o.get('name'); // 'an object' + MyObject.reopen({ + say(msg){ + console.log(msg); + } + }) + o2 = MyObject.create(); + o2.say("hello"); // logs "hello" + o.say("goodbye"); // logs "goodbye" + ``` + To add functions and properties to the constructor itself, + see `reopenClass` + @method reopen + @public + */ + reopen: function () { + this.willReopen(); + reopen.apply(this.PrototypeMixin, arguments); + return this; + }, - if (property && property.isDescriptor) { - properties.push({ - name: name, - meta: property._meta - }); + /** + Augments a constructor's own properties and functions: + ```javascript + const MyObject = Ember.Object.extend({ + name: 'an object' + }); + MyObject.reopenClass({ + canBuild: false + }); + MyObject.canBuild; // false + o = MyObject.create(); + ``` + In other words, this creates static properties and functions for the class. + These are only available on the class and not on any instance of that class. + ```javascript + const Person = Ember.Object.extend({ + name: "", + sayHello() { + alert("Hello. My name is " + this.get('name')); + } + }); + Person.reopenClass({ + species: "Homo sapiens", + createPerson(newPersonsName){ + return Person.create({ + name:newPersonsName + }); + } + }); + let tom = Person.create({ + name: "Tom Dale" + }); + let yehuda = Person.createPerson("Yehuda Katz"); + tom.sayHello(); // "Hello. My name is Tom Dale" + yehuda.sayHello(); // "Hello. My name is Yehuda Katz" + alert(Person.species); // "Homo sapiens" + ``` + Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` + variables. They are only valid on `Person`. + To add functions and properties to instances of + a constructor by extending the constructor's prototype + see `reopen` + @method reopenClass + @public + */ + reopenClass: function () { + reopen.apply(this.ClassMixin, arguments); + applyMixin(this, arguments, false); + return this; + }, + + detect: function (obj) { + if ('function' !== typeof obj) { + return false; } - } - return properties; - }).readOnly(), _ClassMixinProps.eachComputedProperty = function (callback, binding) { - var property; - var empty = {}; + while (obj) { + if (obj === this) { + return true; + } + obj = obj.superclass; + } + return false; + }, - var properties = _emberMetal.get(this, '_computedProperties'); + detectInstance: function (obj) { + return obj instanceof this; + }, - for (var i = 0; i < properties.length; i++) { - property = properties[i]; - callback.call(binding || this, property.name, property.meta || empty); + /** + In some cases, you may want to annotate computed properties with additional + metadata about how they function or what values they operate on. For + example, computed property functions may close over variables that are then + no longer available for introspection. + You can pass a hash of these values to a computed property like this: + ```javascript + person: Ember.computed(function() { + var personId = this.get('personId'); + return Person.create({ id: personId }); + }).meta({ type: Person }) + ``` + Once you've done this, you can retrieve the values saved to the computed + property from your class like this: + ```javascript + MyClass.metaForProperty('person'); + ``` + This will return the original hash that was passed to `meta()`. + @static + @method metaForProperty + @param key {String} property name + @private + */ + metaForProperty: function (key) { + var proto = this.proto(); + var possibleDesc = proto[key]; + var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + + return desc._meta || {}; + }, + + _computedProperties: _emberMetal.computed(function () { + hasCachedComputedProperties = true; + var proto = this.proto(); + var property; + var properties = []; + + for (var name in proto) { + property = proto[name]; + + if (property && property.isDescriptor) { + properties.push({ + name: name, + meta: property._meta + }); + } + } + return properties; + }).readOnly(), + + /** + Iterate over each computed property for the class, passing its name + and any associated metadata (see `metaForProperty`) to the callback. + @static + @method eachComputedProperty + @param {Function} callback + @param {Object} binding + @private + */ + eachComputedProperty: function (callback, binding) { + var property; + var empty = {}; + + var properties = _emberMetal.get(this, '_computedProperties'); + + for (var i = 0; i < properties.length; i++) { + property = properties[i]; + callback.call(binding || this, property.name, property.meta || empty); + } } - }, _ClassMixinProps); + }; function injectedPropertyAssertion() {} @@ -34656,210 +34781,6 @@ enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-met @public */ -/** - Creates a new subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(thing); - } - }); - ``` - This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`. - You can also create a subclass from any existing class by calling its `extend()` method. - For example, you might want to create a subclass of Ember's built-in `Ember.Component` class: - ```javascript - const PersonComponent = Ember.Component.extend({ - tagName: 'li', - classNameBindings: ['isAdministrator'] - }); - ``` - When defining a subclass, you can override methods but still access the - implementation of your parent class by calling the special `_super()` method: - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - var name = this.get('name'); - alert(`${name} says: ${thing}`); - } - }); - const Soldier = Person.extend({ - say(thing) { - this._super(`${thing}, sir!`); - }, - march(numberOfHours) { - alert(`${this.get('name')} marches for ${numberOfHours} hours.`); - } - }); - let yehuda = Soldier.create({ - name: "Yehuda Katz" - }); - yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!" - ``` - The `create()` on line #17 creates an *instance* of the `Soldier` class. - The `extend()` on line #8 creates a *subclass* of `Person`. Any instance - of the `Person` class will *not* have the `march()` method. - You can also pass `Mixin` classes to add additional properties to the subclass. - ```javascript - const Person = Ember.Object.extend({ - say(thing) { - alert(`${this.get('name')} says: ${thing}`); - } - }); - const SingingMixin = Mixin.create({ - sing(thing){ - alert(`${this.get('name')} sings: la la la ${thing}`); - } - }); - const BroadwayStar = Person.extend(SingingMixin, { - dance() { - alert(`${this.get('name')} dances: tap tap tap tap `); - } - }); - ``` - The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. - @method extend - @static - @param {Mixin} [mixins]* One or more Mixin classes - @param {Object} [arguments]* Object containing values to use within the new class - @public -*/ - -/** - Creates an instance of a class. Accepts either no arguments, or an object - containing values to initialize the newly instantiated object with. - ```javascript - const Person = Ember.Object.extend({ - helloWorld() { - alert(`Hi, my name is ${this.get('name')}`); - } - }); - let tom = Person.create({ - name: 'Tom Dale' - }); - tom.helloWorld(); // alerts "Hi, my name is Tom Dale". - ``` - `create` will call the `init` function if defined during - `Ember.AnyObject.extend` - If no arguments are passed to `create`, it will not set values to the new - instance during initialization: - ```javascript - let noName = Person.create(); - noName.helloWorld(); // alerts undefined - ``` - NOTE: For performance reasons, you cannot declare methods or computed - properties during `create`. You should instead declare methods and computed - properties when using `extend`. - @method create - @static - @param [arguments]* - @public -*/ - -/** - Augments a constructor's prototype with additional - properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - o = MyObject.create(); - o.get('name'); // 'an object' - MyObject.reopen({ - say(msg){ - console.log(msg); - } - }) - o2 = MyObject.create(); - o2.say("hello"); // logs "hello" - o.say("goodbye"); // logs "goodbye" - ``` - To add functions and properties to the constructor itself, - see `reopenClass` - @method reopen - @public -*/ - -/** - Augments a constructor's own properties and functions: - ```javascript - const MyObject = Ember.Object.extend({ - name: 'an object' - }); - MyObject.reopenClass({ - canBuild: false - }); - MyObject.canBuild; // false - o = MyObject.create(); - ``` - In other words, this creates static properties and functions for the class. - These are only available on the class and not on any instance of that class. - ```javascript - const Person = Ember.Object.extend({ - name: "", - sayHello() { - alert("Hello. My name is " + this.get('name')); - } - }); - Person.reopenClass({ - species: "Homo sapiens", - createPerson(newPersonsName){ - return Person.create({ - name:newPersonsName - }); - } - }); - let tom = Person.create({ - name: "Tom Dale" - }); - let yehuda = Person.createPerson("Yehuda Katz"); - tom.sayHello(); // "Hello. My name is Tom Dale" - yehuda.sayHello(); // "Hello. My name is Yehuda Katz" - alert(Person.species); // "Homo sapiens" - ``` - Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` - variables. They are only valid on `Person`. - To add functions and properties to instances of - a constructor by extending the constructor's prototype - see `reopen` - @method reopenClass - @public -*/ - -/** - In some cases, you may want to annotate computed properties with additional - metadata about how they function or what values they operate on. For - example, computed property functions may close over variables that are then - no longer available for introspection. - You can pass a hash of these values to a computed property like this: - ```javascript - person: Ember.computed(function() { - var personId = this.get('personId'); - return Person.create({ id: personId }); - }).meta({ type: Person }) - ``` - Once you've done this, you can retrieve the values saved to the computed - property from your class like this: - ```javascript - MyClass.metaForProperty('person'); - ``` - This will return the original hash that was passed to `meta()`. - @static - @method metaForProperty - @param key {String} property name - @private -*/ - -/** - Iterate over each computed property for the class, passing its name - and any associated metadata (see `metaForProperty`) to the callback. - @static - @method eachComputedProperty - @param {Function} callback - @param {Object} binding - @private -*/ - /** Provides lookup-time type validation for injected properties. @private @@ -35116,7 +35037,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } findNamespaces(); - return this[_emberUtils.NAME_KEY]; + return this[_emberMetal.NAME_KEY]; }, nameClasses: function () { @@ -35176,10 +35097,10 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal paths[idx] = key; // If we have found an unprocessed class - if (obj && obj.toString === classToString && !obj[_emberUtils.NAME_KEY]) { + if (obj && obj.toString === classToString && !obj[_emberMetal.NAME_KEY]) { // Replace the class' `toString` with the dot-separated path // and set its `NAME_KEY` - obj[_emberUtils.NAME_KEY] = paths.join('.'); + obj[_emberMetal.NAME_KEY] = paths.join('.'); // Support nested namespaces } else if (obj && obj.isNamespace) { @@ -35225,7 +35146,7 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } var obj = tryIsNamespace(lookup, key); if (obj) { - obj[_emberUtils.NAME_KEY] = key; + obj[_emberMetal.NAME_KEY] = key; } } } @@ -35233,41 +35154,35 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal function superClassString(mixin) { var superclass = mixin.superclass; if (superclass) { - if (superclass[_emberUtils.NAME_KEY]) { - return superclass[_emberUtils.NAME_KEY]; + if (superclass[_emberMetal.NAME_KEY]) { + return superclass[_emberMetal.NAME_KEY]; } return superClassString(superclass); } } - function calculateToString(target) { - var str = undefined; - - if (!searchDisabled) { + function classToString() { + if (!searchDisabled && !this[_emberMetal.NAME_KEY]) { processAllNamespaces(); - // can also be set by processAllNamespaces - str = target[_emberUtils.NAME_KEY]; + } + + var ret = undefined; + + if (this[_emberMetal.NAME_KEY]) { + ret = this[_emberMetal.NAME_KEY]; + } else if (this._toString) { + ret = this._toString; + } else { + var str = superClassString(this); if (str) { - return str; + ret = '(subclass of ' + str + ')'; } else { - str = superClassString(target); - str = str ? '(subclass of ' + str + ')' : str; + ret = '(unknown mixin)'; } - } - if (str) { - return str; - } else { - return '(unknown mixin)'; - } - } - - function classToString() { - var name = this[_emberUtils.NAME_KEY]; - if (name) { - return name; + this.toString = makeToString(ret); } - return this[_emberUtils.NAME_KEY] = calculateToString(this); + return ret; } function processAllNamespaces() { @@ -35292,6 +35207,12 @@ enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal } } + function makeToString(ret) { + return function () { + return ret; + }; + } + _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. exports.default = Namespace; @@ -36379,7 +36300,7 @@ enifed('ember-utils/guid', ['exports', 'ember-utils/intern'], function (exports, } } }); -enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/name', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsName, _emberUtilsToString) { +enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner', 'ember-utils/assign', 'ember-utils/empty-object', 'ember-utils/dictionary', 'ember-utils/guid', 'ember-utils/intern', 'ember-utils/super', 'ember-utils/inspect', 'ember-utils/lookup-descriptor', 'ember-utils/invoke', 'ember-utils/make-array', 'ember-utils/apply-str', 'ember-utils/to-string'], function (exports, _emberUtilsSymbol, _emberUtilsOwner, _emberUtilsAssign, _emberUtilsEmptyObject, _emberUtilsDictionary, _emberUtilsGuid, _emberUtilsIntern, _emberUtilsSuper, _emberUtilsInspect, _emberUtilsLookupDescriptor, _emberUtilsInvoke, _emberUtilsMakeArray, _emberUtilsApplyStr, _emberUtilsToString) { /* This package will be eagerly parsed and should have no dependencies on external packages. @@ -36415,7 +36336,6 @@ enifed('ember-utils/index', ['exports', 'ember-utils/symbol', 'ember-utils/owner exports.tryInvoke = _emberUtilsInvoke.tryInvoke; exports.makeArray = _emberUtilsMakeArray.default; exports.applyStr = _emberUtilsApplyStr.default; - exports.NAME_KEY = _emberUtilsName.default; exports.toString = _emberUtilsToString.default; }); enifed('ember-utils/inspect', ['exports'], function (exports) { @@ -36648,11 +36568,6 @@ enifed("ember-utils/make-array", ["exports"], function (exports) { return Array.isArray(obj) ? obj : [obj]; } }); -enifed('ember-utils/name', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { - 'use strict'; - - exports.default = _emberUtilsSymbol.default('NAME_KEY'); -}); enifed('ember-utils/owner', ['exports', 'ember-utils/symbol'], function (exports, _emberUtilsSymbol) { /** @module ember @@ -36815,8 +36730,8 @@ enifed('ember-utils/symbol', ['exports', 'ember-utils/guid', 'ember-utils/intern return _emberUtilsIntern.default(debugName + ' [id=' + _emberUtilsGuid.GUID_KEY + Math.floor(Math.random() * new Date()) + ']'); } }); -enifed('ember-utils/to-string', ['exports'], function (exports) { - 'use strict'; +enifed("ember-utils/to-string", ["exports"], function (exports) { + "use strict"; exports.default = toString; var objectToString = Object.prototype.toString; @@ -36827,7 +36742,7 @@ enifed('ember-utils/to-string', ['exports'], function (exports) { */ function toString(obj) { - if (obj && typeof obj.toString === 'function') { + if (obj && obj.toString) { return obj.toString(); } else { return objectToString.call(obj); @@ -37022,6 +36937,7 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me args[_key2 - 1] = arguments[_key2]; } + var target = undefined; var action = this.actions && this.actions[actionName]; if (action) { @@ -37031,9 +36947,12 @@ enifed('ember-views/mixins/action_support', ['exports', 'ember-utils', 'ember-me } } - var target = _emberMetal.get(this, 'target'); + target = _emberMetal.get(this, 'target'); + if (target) { - target.send.apply(target, arguments); + var _target; + + (_target = target).send.apply(_target, arguments); } else {} } }); @@ -37098,6 +37017,10 @@ enifed('ember-views/mixins/class_names_support', ['exports', 'ember-metal'], fun init: function () { this._super.apply(this, arguments); + + this.classNameBindings = this.classNameBindings.slice(); + + this.classNames = this.classNames.slice(); }, /** @@ -37697,7 +37620,6 @@ enifed('ember-views/mixins/view_support', ['exports', 'ember-utils', 'ember-meta @method renderToElement @param {String} tagName The tag of the element to create and render into. Defaults to "body". @return {HTMLBodyElement} element - @deprecated Use appendTo instead. @private */ @@ -39231,7 +39153,7 @@ enifed("ember-views/views/view", ["exports"], function (exports) { enifed("ember/features", ["exports"], function (exports) { "use strict"; - exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-testing-resume-test": false, "mandatory-setter": false, "ember-glimmer-detect-backtracking-rerender": false }; + exports.default = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": true, "ember-testing-resume-test": false, "ember-glimmer-detect-backtracking-rerender": false, "mandatory-setter": false }; }); enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', 'container', 'ember-metal', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require, _emberEnvironment, _emberUtils, _container, _emberMetal, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _emberVersion, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) { 'use strict'; @@ -39337,7 +39259,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', _emberMetal.default.getProperties = _emberMetal.getProperties; _emberMetal.default.setProperties = _emberMetal.setProperties; _emberMetal.default.expandProperties = _emberMetal.expandProperties; - _emberMetal.default.NAME_KEY = _emberUtils.NAME_KEY; + _emberMetal.default.NAME_KEY = _emberMetal.NAME_KEY; _emberMetal.default.addObserver = _emberMetal.addObserver; _emberMetal.default.observersFor = _emberMetal.observersFor; _emberMetal.default.removeObserver = _emberMetal.removeObserver; @@ -39761,7 +39683,7 @@ enifed('ember/index', ['exports', 'require', 'ember-environment', 'ember-utils', enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.11.0-beta.2"; + exports.default = "2.10.0-intercom"; }); enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; @@ -47412,7 +47334,10 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true + autocorrect: true, + // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true + // Safari 9.1.3: 'list' in document.createElement('input') === false + list: true }, // element.form is actually a legitimate readOnly property, that is to be // mutated, but must be mutated by setAttribute... @@ -47429,7 +47354,7 @@ enifed('glimmer-runtime/lib/dom/props', ['exports'], function (exports) { return tag && tag[propName.toLowerCase()] || false; } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7U0FDbEI7OztBQUlELGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixnQkFBUSxFQUFFLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixhQUFLLEVBQUssRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGNBQU0sRUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtLQUN6QixDQUFDO0FBRUYsYUFBQSxVQUFBLENBQW9CLE9BQU8sRUFBRSxRQUFRLEVBQUE7QUFDbkMsWUFBSSxHQUFHLEdBQUcsY0FBYyxDQUFDLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDO0FBQ2hELGVBQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxRQUFRLENBQUMsV0FBVyxFQUFFLENBQUMsSUFBSSxLQUFLLENBQUM7S0FDcEQiLCJmaWxlIjoicHJvcHMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQG1ldGhvZCBub3JtYWxpemVQcm9wZXJ0eVxuICogQHBhcmFtIGVsZW1lbnQge0hUTUxFbGVtZW50fVxuICogQHBhcmFtIHNsb3ROYW1lIHtTdHJpbmd9XG4gKiBAcmV0dXJucyB7T2JqZWN0fSB7IG5hbWUsIHR5cGUgfVxuICovXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHkoZWxlbWVudCwgc2xvdE5hbWUpIHtcbiAgbGV0IHR5cGUsIG5vcm1hbGl6ZWQ7XG5cbiAgaWYgKHNsb3ROYW1lIGluIGVsZW1lbnQpIHtcbiAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgdHlwZSA9ICdwcm9wJztcbiAgfSBlbHNlIHtcbiAgICBsZXQgbG93ZXIgPSBzbG90TmFtZS50b0xvd2VyQ2FzZSgpO1xuICAgIGlmIChsb3dlciBpbiBlbGVtZW50KSB7XG4gICAgICB0eXBlID0gJ3Byb3AnO1xuICAgICAgbm9ybWFsaXplZCA9IGxvd2VyO1xuICAgIH0gZWxzZSB7XG4gICAgICB0eXBlID0gJ2F0dHInO1xuICAgICAgbm9ybWFsaXplZCA9IHNsb3ROYW1lO1xuICAgIH1cbiAgfVxuXG4gIGlmICh0eXBlID09PSAncHJvcCcgJiZcbiAgICAgIChub3JtYWxpemVkLnRvTG93ZXJDYXNlKCkgPT09ICdzdHlsZScgfHxcbiAgICAgICBwcmVmZXJBdHRyKGVsZW1lbnQudGFnTmFtZSwgbm9ybWFsaXplZCkpKSB7XG4gICAgdHlwZSA9ICdhdHRyJztcbiAgfVxuXG4gIHJldHVybiB7IG5vcm1hbGl6ZWQsIHR5cGUgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIG5vcm1hbGl6ZVByb3BlcnR5VmFsdWUodmFsdWUpIHtcbiAgaWYgKHZhbHVlID09PSAnJykge1xuICAgIHJldHVybiB0cnVlO1xuICB9XG5cbiAgcmV0dXJuIHZhbHVlO1xufVxuXG4vLyBwcm9wZXJ0aWVzIHRoYXQgTVVTVCBiZSBzZXQgYXMgYXR0cmlidXRlcywgZHVlIHRvOlxuLy8gKiBicm93c2VyIGJ1Z1xuLy8gKiBzdHJhbmdlIHNwZWMgb3V0bGllclxuY29uc3QgQVRUUl9PVkVSUklERVMgPSB7XG5cbiAgLy8gcGhhbnRvbWpzIDwgMi4wIGxldHMgeW91IHNldCBpdCBhcyBhIHByb3AgYnV0IHdvbid0IHJlZmxlY3QgaXRcbiAgLy8gYmFjayB0byB0aGUgYXR0cmlidXRlLiBidXR0b24uZ2V0QXR0cmlidXRlKCd0eXBlJykgPT09IG51bGxcbiAgQlVUVE9OOiB7IHR5cGU6IHRydWUsIGZvcm06IHRydWUgfSxcblxuICBJTlBVVDoge1xuICAgIC8vIFNvbWUgdmVyc2lvbiBvZiBJRSAobGlrZSBJRTkpIGFjdHVhbGx5IHRocm93IGFuIGV4Y2VwdGlvblxuICAgIC8vIGlmIHlvdSBzZXQgaW5wdXQudHlwZSA9ICdzb21ldGhpbmctdW5rbm93bidcbiAgICB0eXBlOiB0cnVlLFxuICAgIGZvcm06IHRydWUsXG4gICAgLy8gQ2hyb21lIDQ2LjAuMjQ2NC4wOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gU2FmYXJpIDguMC43OiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IGZhbHNlXG4gICAgLy8gTW9iaWxlIFNhZmFyaSAoaU9TIDguNCBzaW11bGF0b3IpOiAnYXV0b2NvcnJlY3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2lucHV0JykgPT09IHRydWVcbiAgICBhdXRvY29ycmVjdDogdHJ1ZVxuICB9LFxuXG4gIC8vIGVsZW1lbnQuZm9ybSBpcyBhY3R1YWxseSBhIGxlZ2l0aW1hdGUgcmVhZE9ubHkgcHJvcGVydHksIHRoYXQgaXMgdG8gYmVcbiAgLy8gbXV0YXRlZCwgYnV0IG11c3QgYmUgbXV0YXRlZCBieSBzZXRBdHRyaWJ1dGUuLi5cbiAgU0VMRUNUOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPUFRJT046ICAgeyBmb3JtOiB0cnVlIH0sXG4gIFRFWFRBUkVBOiB7IGZvcm06IHRydWUgfSxcbiAgTEFCRUw6ICAgIHsgZm9ybTogdHJ1ZSB9LFxuICBGSUVMRFNFVDogeyBmb3JtOiB0cnVlIH0sXG4gIExFR0VORDogICB7IGZvcm06IHRydWUgfSxcbiAgT0JKRUNUOiAgIHsgZm9ybTogdHJ1ZSB9XG59O1xuXG5mdW5jdGlvbiBwcmVmZXJBdHRyKHRhZ05hbWUsIHByb3BOYW1lKSB7XG4gIGxldCB0YWcgPSBBVFRSX09WRVJSSURFU1t0YWdOYW1lLnRvVXBwZXJDYXNlKCldO1xuICByZXR1cm4gdGFnICYmIHRhZ1twcm9wTmFtZS50b0xvd2VyQ2FzZSgpXSB8fCBmYWxzZTtcbn1cbiJdfQ== +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdsaW1tZXItcnVudGltZS9saWIvZG9tL3Byb3BzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQU1BLGFBQUEsaUJBQUEsQ0FBa0MsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNqRCxZQUFJLElBQUksWUFBQTtZQUFFLFVBQVUsWUFBQSxDQUFDO0FBRXJCLFlBQUksUUFBUSxJQUFJLE9BQU8sRUFBRTtBQUN2QixzQkFBVSxHQUFHLFFBQVEsQ0FBQztBQUN0QixnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmLE1BQU07QUFDTCxnQkFBSSxLQUFLLEdBQUcsUUFBUSxDQUFDLFdBQVcsRUFBRSxDQUFDO0FBQ25DLGdCQUFJLEtBQUssSUFBSSxPQUFPLEVBQUU7QUFDcEIsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLEtBQUssQ0FBQzthQUNwQixNQUFNO0FBQ0wsb0JBQUksR0FBRyxNQUFNLENBQUM7QUFDZCwwQkFBVSxHQUFHLFFBQVEsQ0FBQzthQUN2QjtTQUNGO0FBRUQsWUFBSSxJQUFJLEtBQUssTUFBTSxLQUNkLFVBQVUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxPQUFPLElBQ3BDLFVBQVUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBLEFBQUMsRUFBRTtBQUM3QyxnQkFBSSxHQUFHLE1BQU0sQ0FBQztTQUNmO0FBRUQsZUFBTyxFQUFFLFVBQVUsRUFBVixVQUFVLEVBQUUsSUFBSSxFQUFKLElBQUksRUFBRSxDQUFDO0tBQzdCOztBQUVELGFBQUEsc0JBQUEsQ0FBdUMsS0FBSyxFQUFBO0FBQzFDLFlBQUksS0FBSyxLQUFLLEVBQUUsRUFBRTtBQUNoQixtQkFBTyxJQUFJLENBQUM7U0FDYjtBQUVELGVBQU8sS0FBSyxDQUFDO0tBQ2Q7Ozs7O0FBS0QsUUFBTSxjQUFjLEdBQUc7OztBQUlyQixjQUFNLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFFbEMsYUFBSyxFQUFFOzs7QUFHTCxnQkFBSSxFQUFFLElBQUk7QUFDVixnQkFBSSxFQUFFLElBQUk7Ozs7QUFJVix1QkFBVyxFQUFFLElBQUk7OztBQUdqQixnQkFBSSxFQUFFLElBQUk7U0FDWDs7O0FBSUQsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGdCQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0FBQ3hCLGFBQUssRUFBSyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsZ0JBQVEsRUFBRSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUU7QUFDeEIsY0FBTSxFQUFJLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRTtBQUN4QixjQUFNLEVBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFO0tBQ3pCLENBQUM7QUFFRixhQUFBLFVBQUEsQ0FBb0IsT0FBTyxFQUFFLFFBQVEsRUFBQTtBQUNuQyxZQUFJLEdBQUcsR0FBRyxjQUFjLENBQUMsT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7QUFDaEQsZUFBTyxHQUFHLElBQUksR0FBRyxDQUFDLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxJQUFJLEtBQUssQ0FBQztLQUNwRCIsImZpbGUiOiJwcm9wcy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBAbWV0aG9kIG5vcm1hbGl6ZVByb3BlcnR5XG4gKiBAcGFyYW0gZWxlbWVudCB7SFRNTEVsZW1lbnR9XG4gKiBAcGFyYW0gc2xvdE5hbWUge1N0cmluZ31cbiAqIEByZXR1cm5zIHtPYmplY3R9IHsgbmFtZSwgdHlwZSB9XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBub3JtYWxpemVQcm9wZXJ0eShlbGVtZW50LCBzbG90TmFtZSkge1xuICBsZXQgdHlwZSwgbm9ybWFsaXplZDtcblxuICBpZiAoc2xvdE5hbWUgaW4gZWxlbWVudCkge1xuICAgIG5vcm1hbGl6ZWQgPSBzbG90TmFtZTtcbiAgICB0eXBlID0gJ3Byb3AnO1xuICB9IGVsc2Uge1xuICAgIGxldCBsb3dlciA9IHNsb3ROYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgaWYgKGxvd2VyIGluIGVsZW1lbnQpIHtcbiAgICAgIHR5cGUgPSAncHJvcCc7XG4gICAgICBub3JtYWxpemVkID0gbG93ZXI7XG4gICAgfSBlbHNlIHtcbiAgICAgIHR5cGUgPSAnYXR0cic7XG4gICAgICBub3JtYWxpemVkID0gc2xvdE5hbWU7XG4gICAgfVxuICB9XG5cbiAgaWYgKHR5cGUgPT09ICdwcm9wJyAmJlxuICAgICAgKG5vcm1hbGl6ZWQudG9Mb3dlckNhc2UoKSA9PT0gJ3N0eWxlJyB8fFxuICAgICAgIHByZWZlckF0dHIoZWxlbWVudC50YWdOYW1lLCBub3JtYWxpemVkKSkpIHtcbiAgICB0eXBlID0gJ2F0dHInO1xuICB9XG5cbiAgcmV0dXJuIHsgbm9ybWFsaXplZCwgdHlwZSB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gbm9ybWFsaXplUHJvcGVydHlWYWx1ZSh2YWx1ZSkge1xuICBpZiAodmFsdWUgPT09ICcnKSB7XG4gICAgcmV0dXJuIHRydWU7XG4gIH1cblxuICByZXR1cm4gdmFsdWU7XG59XG5cbi8vIHByb3BlcnRpZXMgdGhhdCBNVVNUIGJlIHNldCBhcyBhdHRyaWJ1dGVzLCBkdWUgdG86XG4vLyAqIGJyb3dzZXIgYnVnXG4vLyAqIHN0cmFuZ2Ugc3BlYyBvdXRsaWVyXG5jb25zdCBBVFRSX09WRVJSSURFUyA9IHtcblxuICAvLyBwaGFudG9tanMgPCAyLjAgbGV0cyB5b3Ugc2V0IGl0IGFzIGEgcHJvcCBidXQgd29uJ3QgcmVmbGVjdCBpdFxuICAvLyBiYWNrIHRvIHRoZSBhdHRyaWJ1dGUuIGJ1dHRvbi5nZXRBdHRyaWJ1dGUoJ3R5cGUnKSA9PT0gbnVsbFxuICBCVVRUT046IHsgdHlwZTogdHJ1ZSwgZm9ybTogdHJ1ZSB9LFxuXG4gIElOUFVUOiB7XG4gICAgLy8gU29tZSB2ZXJzaW9uIG9mIElFIChsaWtlIElFOSkgYWN0dWFsbHkgdGhyb3cgYW4gZXhjZXB0aW9uXG4gICAgLy8gaWYgeW91IHNldCBpbnB1dC50eXBlID0gJ3NvbWV0aGluZy11bmtub3duJ1xuICAgIHR5cGU6IHRydWUsXG4gICAgZm9ybTogdHJ1ZSxcbiAgICAvLyBDaHJvbWUgNDYuMC4yNDY0LjA6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBTYWZhcmkgOC4wLjc6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICAvLyBNb2JpbGUgU2FmYXJpIChpT1MgOC40IHNpbXVsYXRvcik6ICdhdXRvY29ycmVjdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gdHJ1ZVxuICAgIGF1dG9jb3JyZWN0OiB0cnVlLFxuICAgIC8vIENocm9tZSA1NC4wLjI4NDAuOTg6ICdsaXN0JyBpbiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdpbnB1dCcpID09PSB0cnVlXG4gICAgLy8gU2FmYXJpIDkuMS4zOiAnbGlzdCcgaW4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKSA9PT0gZmFsc2VcbiAgICBsaXN0OiB0cnVlXG4gIH0sXG5cbiAgLy8gZWxlbWVudC5mb3JtIGlzIGFjdHVhbGx5IGEgbGVnaXRpbWF0ZSByZWFkT25seSBwcm9wZXJ0eSwgdGhhdCBpcyB0byBiZVxuICAvLyBtdXRhdGVkLCBidXQgbXVzdCBiZSBtdXRhdGVkIGJ5IHNldEF0dHJpYnV0ZS4uLlxuICBTRUxFQ1Q6ICAgeyBmb3JtOiB0cnVlIH0sXG4gIE9QVElPTjogICB7IGZvcm06IHRydWUgfSxcbiAgVEVYVEFSRUE6IHsgZm9ybTogdHJ1ZSB9LFxuICBMQUJFTDogICAgeyBmb3JtOiB0cnVlIH0sXG4gIEZJRUxEU0VUOiB7IGZvcm06IHRydWUgfSxcbiAgTEVHRU5EOiAgIHsgZm9ybTogdHJ1ZSB9LFxuICBPQkpFQ1Q6ICAgeyBmb3JtOiB0cnVlIH1cbn07XG5cbmZ1bmN0aW9uIHByZWZlckF0dHIodGFnTmFtZSwgcHJvcE5hbWUpIHtcbiAgbGV0IHRhZyA9IEFUVFJfT1ZFUlJJREVTW3RhZ05hbWUudG9VcHBlckNhc2UoKV07XG4gIHJldHVybiB0YWcgJiYgdGFnW3Byb3BOYW1lLnRvTG93ZXJDYXNlKCldIHx8IGZhbHNlO1xufVxuIl19 enifed('glimmer-runtime/lib/dom/sanitized-values', ['exports', 'glimmer-runtime/lib/compiled/opcodes/content', 'glimmer-runtime/lib/upsert'], function (exports, _glimmerRuntimeLibCompiledOpcodesContent, _glimmerRuntimeLibUpsert) { 'use strict'; @@ -52889,30 +52814,6 @@ TransitionState.prototype = { } }; -function TransitionAbortedError(message) { - if (!(this instanceof TransitionAbortedError)) { - return new TransitionAbortedError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, TransitionAbortedError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'TransitionAborted'; - this.name = 'TransitionAborted'; - this.number = error.number; - this.code = error.code; -} - -TransitionAbortedError.prototype = oCreate(Error.prototype); - /** A Transition is a thennable (a promise-like object) that represents an attempt to transition to another route. It can be aborted, either @@ -53237,11 +53138,16 @@ Transition.prototype.send = Transition.prototype.trigger; /** @private - Logs and returns an instance of TransitionAbortedError. + Logs and returns a TransitionAborted error. */ function logAbort(transition) { log(transition.router, transition.sequence, "detected abort."); - return new TransitionAbortedError(); + return new TransitionAborted(); +} + +function TransitionAborted(message) { + this.message = (message || "TransitionAborted"); + this.name = "TransitionAborted"; } function TransitionIntent(props) { @@ -53801,26 +53707,14 @@ var NamedTransitionIntent = subclass(TransitionIntent, { } }); +/** + Promise reject reasons passed to promise rejection + handlers for failed transitions. + */ function UnrecognizedURLError(message) { - if (!(this instanceof UnrecognizedURLError)) { - return new UnrecognizedURLError(message); - } - - var error = Error.call(this, message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, UnrecognizedURLError); - } else { - this.stack = error.stack; - } - - this.description = error.description; - this.fileName = error.fileName; - this.lineNumber = error.lineNumber; - this.message = error.message || 'UnrecognizedURL'; - this.name = 'UnrecognizedURLError'; - this.number = error.number; - this.code = error.code; + this.message = (message || "UnrecognizedURLError"); + this.name = "UnrecognizedURLError"; + Error.call(this); } UnrecognizedURLError.prototype = oCreate(Error.prototype); @@ -54377,7 +54271,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi } if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } handler.context = context; @@ -54385,7 +54279,7 @@ function handlerEnteredOrUpdated(currentHandlerInfos, handlerInfo, enter, transi callHook(handler, 'setup', context, transition); if (transition && transition.isAborted) { - throw new TransitionAbortedError(); + throw new TransitionAborted(); } currentHandlerInfos.push(handlerInfo); @@ -54577,7 +54471,7 @@ function finalizeTransition(transition, newState) { // Resolve with the final handler. return handlerInfos[handlerInfos.length - 1].handler; } catch(e) { - if (!(e instanceof TransitionAbortedError)) { + if (!(e instanceof TransitionAborted)) { //var erroneousHandler = handlerInfos.pop(); var infos = transition.state.handlerInfos; transition.trigger(true, 'error', e, transition, infos[infos.length-1].handler); @@ -54734,2533 +54628,2506 @@ exports.Transition = Transition; Object.defineProperty(exports, '__esModule', { value: true }); }); -enifed('rsvp', ['exports'], function (exports) { - 'use strict'; - - var _rsvp; +/*! + * @overview RSVP - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE + * @version 3.2.1 + */ - function indexOf(callbacks, callback) { - for (var i = 0, l = callbacks.length; i < l; i++) { - if (callbacks[i] === callback) { - return i; - } - } +enifed('rsvp', ['exports'], function (exports) { 'use strict'; - return -1; +function indexOf(callbacks, callback) { + for (var i=0, l=callbacks.length; i 1) { - throw new Error('Second argument not supported'); - } - if (typeof o !== 'object') { - throw new TypeError('Argument must be an object'); - } - F.prototype = o; - return new F(); - }; + object.trigger('stuff'); // callback1 and callback2 will be executed. - var queue = []; + object.off('stuff'); + object.trigger('stuff'); // callback1 and callback2 will not be executed! + ``` - function scheduleFlush() { - setTimeout(function () { - for (var i = 0; i < queue.length; i++) { - var entry = queue[i]; + @method off + @for RSVP.EventTarget + @private + @param {String} eventName event to stop listening to + @param {Function} callback optional argument. If given, only the function + given will be removed from the event's callback queue. If no `callback` + argument is given, all callbacks will be removed from the event's callback + queue. + */ + 'off': function(eventName, callback) { + var allCallbacks = callbacksFor(this), callbacks, index; - var payload = entry.payload; + if (!callback) { + allCallbacks[eventName] = []; + return; + } - payload.guid = payload.key + payload.id; - payload.childGuid = payload.key + payload.childId; - if (payload.error) { - payload.stack = payload.error.stack; - } + callbacks = allCallbacks[eventName]; - config['trigger'](entry.name, entry.payload); - } - queue.length = 0; - }, 50); - } + index = indexOf(callbacks, callback); - function instrument(eventName, promise, child) { - if (1 === queue.push({ - name: eventName, - payload: { - key: promise._guidKey, - id: promise._id, - eventName: eventName, - detail: promise._result, - childId: child && child._id, - label: promise._label, - timeStamp: now(), - error: config["instrument-with-stack"] ? new Error(promise._label) : null - } })) { - scheduleFlush(); - } - } + if (index !== -1) { callbacks.splice(index, 1); } + }, /** - `RSVP.Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - + Use `trigger` to fire custom events. For example: + ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(){ + console.log('foo event happened!'); }); + object.trigger('foo'); + // 'foo event happened!' logged to the console ``` - - Instead of writing the above, your code now simply becomes the following: - + + You can also pass a value as a second argument to `trigger` that will be + passed as an argument to all event listeners for the event: + ```javascript - let promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 + object.on('foo', function(value){ + console.log(value.name); }); + + object.trigger('foo', { name: 'bar' }); + // 'bar' logged to the console ``` - - @method resolve - @static - @param {*} object value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` + + @method trigger + @for RSVP.EventTarget + @private + @param {String} eventName name of the event to be triggered + @param {*} options optional value to be passed to any event handlers for + the given `eventName` */ - function resolve$1(object, label) { - /*jshint validthis:true */ - var Constructor = this; + 'trigger': function(eventName, options, label) { + var allCallbacks = callbacksFor(this), callbacks, callback; - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; + if (callbacks = allCallbacks[eventName]) { + // Don't cache the callbacks.length since it may grow + for (var i=0; i 1) { + throw new Error('Second argument not supported'); } - - function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - thenable._onError = null; - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - if (thenable !== value) { - resolve(promise, value, undefined); - } else { - fulfill(promise, value); - } - }, function (reason) { - return reject(promise, reason); - }); - } + if (typeof o !== 'object') { + throw new TypeError('Argument must be an object'); } + F.prototype = o; + return new F(); +}); - function handleMaybeThenable(promise, maybeThenable, then$$) { - if (maybeThenable.constructor === promise.constructor && then$$ === then && promise.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$ === GET_THEN_ERROR) { - reject(promise, GET_THEN_ERROR.error); - } else if (then$$ === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$)) { - handleForeignThenable(promise, maybeThenable, then$$); - } else { - fulfill(promise, maybeThenable); +var queue = []; + +function scheduleFlush() { + setTimeout(function() { + var entry; + for (var i = 0; i < queue.length; i++) { + entry = queue[i]; + + var payload = entry.payload; + + payload.guid = payload.key + payload.id; + payload.childGuid = payload.key + payload.childId; + if (payload.error) { + payload.stack = payload.error.stack; } + + config['trigger'](entry.name, entry.payload); } - } + queue.length = 0; + }, 50); +} - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (objectOrFunction(value)) { - handleMaybeThenable(promise, value, getThen(value)); - } else { - fulfill(promise, value); +function instrument(eventName, promise, child) { + if (1 === queue.push({ + name: eventName, + payload: { + key: promise._guidKey, + id: promise._id, + eventName: eventName, + detail: promise._result, + childId: child && child._id, + label: promise._label, + timeStamp: now(), + error: config["instrument-with-stack"] ? new Error(promise._label) : null + }})) { + scheduleFlush(); } } - function publishRejection(promise) { - if (promise._onError) { - promise._onError(promise._result); - } +/** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: - publish(promise); + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {*} object value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object, label) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; } - function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } + var promise = new Constructor(noop, label); + resolve(promise, object); + return promise; +} + +function withOwnPromise() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); - promise._result = value; - promise._state = FULFILLED; +function getThen(promise) { + try { + return promise.then; + } catch(error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} + +function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch(e) { + return e; + } +} - if (promise._subscribers.length === 0) { - if (config.instrument) { - instrument('fulfilled', promise); +function handleForeignThenable(promise, thenable, then) { + config.async(function(promise) { + var sealed = false; + var error = tryThen(then, thenable, function(value) { + if (sealed) { return; } + sealed = true; + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); } - } else { - config.async(publish, promise); + }, function(reason) { + if (sealed) { return; } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + thenable._onError = null; + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function(value) { + if (thenable !== value) { + resolve(promise, value, undefined); + } else { + fulfill(promise, value); + } + }, function(reason) { + reject(promise, reason); + }); } +} - function reject(promise, reason) { - if (promise._state !== PENDING) { - return; +function handleMaybeThenable(promise, maybeThenable, then$$) { + if (maybeThenable.constructor === promise.constructor && + then$$ === then && + constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$ === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + } else if (then$$ === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$)) { + handleForeignThenable(promise, maybeThenable, then$$); + } else { + fulfill(promise, maybeThenable); } - promise._state = REJECTED; - promise._result = reason; - config.async(publishRejection, promise); } +} - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; +function resolve(promise, value) { + if (promise === value) { + fulfill(promise, value); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} - parent._onError = null; +function publishRejection(promise) { + if (promise._onError) { + promise._onError(promise._result); + } - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; + publish(promise); +} - if (length === 0 && parent._state) { - config.async(publish, parent); - } - } +function fulfill(promise, value) { + if (promise._state !== PENDING) { return; } - function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; + promise._result = value; + promise._state = FULFILLED; + if (promise._subscribers.length === 0) { if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); + instrument('fulfilled', promise); } + } else { + config.async(publish, promise); + } +} - if (subscribers.length === 0) { - return; - } +function reject(promise, reason) { + if (promise._state !== PENDING) { return; } + promise._state = REJECTED; + promise._result = reason; + config.async(publishRejection, promise); +} - var child = undefined, - callback = undefined, - detail = promise._result; +function subscribe(parent, child, onFulfillment, onRejection) { + var subscribers = parent._subscribers; + var length = subscribers.length; - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; + parent._onError = null; - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } + subscribers[length] = child; + subscribers[length + FULFILLED] = onFulfillment; + subscribers[length + REJECTED] = onRejection; - promise._subscribers.length = 0; + if (length === 0 && parent._state) { + config.async(publish, parent); } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; - function ErrorObject() { - this.error = null; + if (config.instrument) { + instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); } - var TRY_CATCH_ERROR = new ErrorObject(); + if (subscribers.length === 0) { return; } - function tryCatch(callback, detail) { - try { - return callback(detail); - } catch (e) { - TRY_CATCH_ERROR.error = e; - return TRY_CATCH_ERROR; + var child, callback, detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); } } - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; + promise._subscribers.length = 0; +} - if (hasCallback) { - value = tryCatch(callback, detail); +function ErrorObject() { + this.error = null; +} - if (value === TRY_CATCH_ERROR) { - failed = true; - error = value.error; - value = null; - } else { - succeeded = true; - } +var TRY_CATCH_ERROR = new ErrorObject(); - if (promise === value) { - reject(promise, withOwnPromise()); - return; - } +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch(e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value, error, succeeded, failed; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value = null; } else { - value = detail; succeeded = true; } - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function initializePromise(promise, resolver) { - var resolved = false; - try { - resolver(function (value) { - if (resolved) { - return; - } - resolved = true; - resolve(promise, value); - }, function (reason) { - if (resolved) { - return; - } - resolved = true; - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); + if (promise === value) { + reject(promise, withOwnPromise()); + return; } + + } else { + value = detail; + succeeded = true; } - function then(onFulfillment, onRejection, label) { - var _arguments = arguments; + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} - var parent = this; - var state = parent._state; +function initializePromise(promise, resolver) { + var resolved = false; + try { + resolver(function resolvePromise(value){ + if (resolved) { return; } + resolved = true; + resolve(promise, value); + }, function rejectPromise(reason) { + if (resolved) { return; } + resolved = true; + reject(promise, reason); + }); + } catch(e) { + reject(promise, e); + } +} - if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { - config.instrument && instrument('chained', parent, parent); - return parent; - } +function then(onFulfillment, onRejection, label) { + var parent = this; + var state = parent._state; - parent._onError = null; + if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) { + config.instrument && instrument('chained', parent, parent); + return parent; + } - var child = new parent.constructor(noop, label); - var result = parent._result; + parent._onError = null; - config.instrument && instrument('chained', parent, child); + var child = new parent.constructor(noop, label); + var result = parent._result; - if (state) { - (function () { - var callback = _arguments[state - 1]; - config.async(function () { - return invokeCallback(state, child, callback, result); - }); - })(); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } + config.instrument && instrument('chained', parent, child); - return child; + if (state) { + var callback = arguments[state - 1]; + config.async(function(){ + invokeCallback(state, child, callback, result); + }); + } else { + subscribe(parent, child, onFulfillment, onRejection); } - function makeSettledResult(state, position, value) { - if (state === FULFILLED) { - return { - state: 'fulfilled', - value: value - }; - } else { - return { - state: 'rejected', - reason: value - }; - } + return child; +} + +function makeSettledResult(state, position, value) { + if (state === FULFILLED) { + return { + state: 'fulfilled', + value: value + }; + } else { + return { + state: 'rejected', + reason: value + }; } +} - function Enumerator(Constructor, input, abortOnReject, label) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop, label); - this._abortOnReject = abortOnReject; +function Enumerator(Constructor, input, abortOnReject, label) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop, label); + this._abortOnReject = abortOnReject; - if (this._validateInput(input)) { - this._input = input; - this.length = input.length; - this._remaining = input.length; + if (this._validateInput(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; - this._init(); + this._init(); - if (this.length === 0) { + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } } - } else { - reject(this.promise, this._validationError()); } + } else { + reject(this.promise, this._validationError()); } +} - Enumerator.prototype._validateInput = function (input) { - return isArray(input); - }; +Enumerator.prototype._validateInput = function(input) { + return isArray(input); +}; - Enumerator.prototype._validationError = function () { - return new Error('Array Methods must be provided an Array'); - }; +Enumerator.prototype._validationError = function() { + return new Error('Array Methods must be provided an Array'); +}; - Enumerator.prototype._init = function () { - this._result = new Array(this.length); - }; +Enumerator.prototype._init = function() { + this._result = new Array(this.length); +}; - Enumerator.prototype._enumerate = function () { - var length = this.length; - var promise = this.promise; - var input = this._input; +Enumerator.prototype._enumerate = function() { + var length = this.length; + var promise = this.promise; + var input = this._input; - for (var i = 0; promise._state === PENDING && i < length; i++) { - this._eachEntry(input[i], i); - } - }; + for (var i = 0; promise._state === PENDING && i < length; i++) { + this._eachEntry(input[i], i); + } +}; - Enumerator.prototype._settleMaybeThenable = function (entry, i) { - var c = this._instanceConstructor; - var resolve = c.resolve; - - if (resolve === resolve$1) { - var then$$ = getThen(entry); - - if (then$$ === then && entry._state !== PENDING) { - entry._onError = null; - this._settledAt(entry._state, i, entry._result); - } else if (typeof then$$ !== 'function') { - this._remaining--; - this._result[i] = this._makeResult(FULFILLED, i, entry); - } else if (c === Promise) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, then$$); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve) { - return resolve(entry); - }), i); - } - } else { - this._willSettleAt(resolve(entry), i); - } - }; +Enumerator.prototype._settleMaybeThenable = function(entry, i) { + var c = this._instanceConstructor; + var resolve = c.resolve; - Enumerator.prototype._eachEntry = function (entry, i) { - if (isMaybeThenable(entry)) { - this._settleMaybeThenable(entry, i); - } else { + if (resolve === resolve$1) { + var then$$ = getThen(entry); + + if (then$$ === then && + entry._state !== PENDING) { + entry._onError = null; + this._settledAt(entry._state, i, entry._result); + } else if (typeof then$$ !== 'function') { this._remaining--; this._result[i] = this._makeResult(FULFILLED, i, entry); + } else if (c === Promise) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, then$$); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); } - }; + } else { + this._willSettleAt(resolve(entry), i); + } +}; - Enumerator.prototype._settledAt = function (state, i, value) { - var promise = this.promise; +Enumerator.prototype._eachEntry = function(entry, i) { + if (isMaybeThenable(entry)) { + this._settleMaybeThenable(entry, i); + } else { + this._remaining--; + this._result[i] = this._makeResult(FULFILLED, i, entry); + } +}; - if (promise._state === PENDING) { - this._remaining--; +Enumerator.prototype._settledAt = function(state, i, value) { + var promise = this.promise; - if (this._abortOnReject && state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = this._makeResult(state, i, value); - } - } + if (promise._state === PENDING) { + this._remaining--; - if (this._remaining === 0) { - fulfill(promise, this._result); + if (this._abortOnReject && state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = this._makeResult(state, i, value); } - }; + } - Enumerator.prototype._makeResult = function (state, i, value) { - return value; - }; + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; - Enumerator.prototype._willSettleAt = function (promise, i) { - var enumerator = this; +Enumerator.prototype._makeResult = function(state, i, value) { + return value; +}; - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; +Enumerator.prototype._willSettleAt = function(promise, i) { + var enumerator = this; - /** - `RSVP.Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error("2")); - let promise3 = RSVP.reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static - */ - function all(entries, label) { - return new Enumerator(this, entries, true, /* abort on reject */label).promise; - } + subscribe(promise, undefined, function(value) { + enumerator._settledAt(FULFILLED, i, value); + }, function(reason) { + enumerator._settledAt(REJECTED, i, reason); + }); +}; - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} entries array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this; +/** + `RSVP.Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. - var promise = new Constructor(noop, label); + Example: - if (!isArray(entries)) { - reject(promise, new TypeError('You must pass an array to race.')); - return promise; - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; - for (var i = 0; promise._state === PENDING && i < entries.length; i++) { - subscribe(Constructor.resolve(entries[i]), undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } + RSVP.Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` - return promise; - } + If any of the `promises` given to `RSVP.all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$1(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop, label); - reject(promise, reason); + Example: + + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error("2")); + var promise3 = RSVP.reject(new Error("3")); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all(entries, label) { + return new Enumerator(this, entries, true /* abort on reject */, label).promise; +} + +/** + `RSVP.Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `RSVP.Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + var promise1 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + var promise2 = new RSVP.Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + RSVP.Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} entries array of promises to observe + @param {String} label optional string for describing the promise returned. + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race(entries, label) { + /*jshint validthis:true */ + var Constructor = this; + + var promise = new Constructor(noop, label); + + if (!isArray(entries)) { + reject(promise, new TypeError('You must pass an array to race.')); return promise; } - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; + var length = entries.length; - function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); + function onFulfillment(value) { + resolve(promise, value); } - function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); + function onRejection(reason) { + reject(promise, reason); } - /** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } + for (var i = 0; promise._state === PENDING && i < length; i++) { + subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); + } + + return promise; +} + +/** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + var promise = new RSVP.Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + var promise = RSVP.Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason, label) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop, label); + reject(promise, reason); + return promise; +} + +var guidKey = 'rsvp_' + now() + '-'; +var counter = 0; + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise’s eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + var promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + var xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection + } + }; }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class RSVP.Promise + @param {function} resolver + @param {String} label optional string for labeling the promise. + Useful for tooling. + @constructor +*/ +function Promise(resolver, label) { + this._id = counter++; + this._label = label; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + config.instrument && instrument('created', this); + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise.cast = resolve$1; // deprecated +Promise.all = all; +Promise.race = race; +Promise.resolve = resolve$1; +Promise.reject = reject$1; + +Promise.prototype = { + constructor: Promise, + + _guidKey: guidKey, + + _onError: function (reason) { + var promise = this; + config.after(function() { + if (promise._onError) { + config['trigger']('error', reason, promise._label); + } }); - ``` - - @class RSVP.Promise - @param {function} resolver - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - this._id = counter++; - this._label = label; - this._state = undefined; - this._result = undefined; - this._subscribers = []; + }, + +/** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` - config.instrument && instrument('created', this); + Assimilation + ------------ - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure } + ``` - Promise.cast = resolve$1; // deprecated - Promise.all = all; - Promise.race = race; - Promise.resolve = resolve$1; - Promise.reject = reject$1; + Errback Example - Promise.prototype = { - constructor: Promise, + ```js - _guidKey: guidKey, + function foundBooks(books) { - _onError: function (reason) { - var promise = this; - config.after(function () { - if (promise._onError) { - config['trigger']('error', reason, promise._label); - } - }); - }, + } - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we\'re unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we\'re unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { + findBoooksByAuthor(author, function(books, err) { + if (err) { failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } } - // success - } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfillment + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + then: then, + +/** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'catch': function(onRejection, label) { + return this.then(undefined, onRejection, label); + }, + +/** + `finally` will be invoked regardless of the promise's fate just as native + try/catch/finally behaves + + Synchronous example: + + ```js + findAuthor() { + if (Math.random() > 0.5) { + throw new Error(); + } + return new Author(); + } + + try { + return findAuthor(); // succeed or fail + } catch(error) { + return findOtherAuther(); + } finally { + // always runs + // doesn't affect the return value + } + ``` + + Asynchronous example: + + ```js + findAuthor().catch(function(reason){ + return findOtherAuther(); + }).finally(function(){ + // author was either found, or not + }); + ``` + + @method finally + @param {Function} callback + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} +*/ + 'finally': function(callback, label) { + var promise = this; + var constructor = promise.constructor; + + return promise.then(function(value) { + return constructor.resolve(callback()).then(function() { + return value; }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong + }, function(reason) { + return constructor.resolve(callback()).then(function() { + return constructor.reject(reason); }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: then, + }, label); + } +}; - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn\'t find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - catch: function (onRejection, label) { - return this.then(undefined, onRejection, label); - }, +function Result() { + this.value = undefined; +} - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); +var ERROR = new Result(); +var GET_THEN_ERROR$1 = new Result(); + +function getThen$1(obj) { + try { + return obj.then; + } catch(error) { + ERROR.value= error; + return ERROR; + } +} + + +function tryApply(f, s, a) { + try { + f.apply(s, a); + } catch(error) { + ERROR.value = error; + return ERROR; + } +} + +function makeObject(_, argumentNames) { + var obj = {}; + var name; + var i; + var length = _.length; + var args = new Array(length); + + for (var x = 0; x < length; x++) { + args[x] = _[x]; + } + + for (i = 0; i < argumentNames.length; i++) { + name = argumentNames[i]; + obj[name] = args[i + 1]; + } + + return obj; +} + +function arrayResult(_) { + var length = _.length; + var args = new Array(length - 1); + + for (var i = 1; i < length; i++) { + args[i - 1] = _[i]; + } + + return args; +} + +function wrapThenable(then, promise) { + return { + then: function(onFulFillment, onRejection) { + return then.call(promise, onFulFillment, onRejection); + } + }; +} + +/** + `RSVP.denodeify` takes a 'node-style' function and returns a function that + will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + browser when you'd prefer to use promises over using callbacks. For example, + `denodeify` transforms the following: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) return handleError(err); + handleData(data); + }); + ``` + + into: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + + readFile('myfile.txt').then(handleData, handleError); + ``` + + If the node function has multiple success parameters, then `denodeify` + just returns the first one: + + ```javascript + var request = RSVP.denodeify(require('request')); + + request('http://example.com').then(function(res) { + // ... + }); + ``` + + However, if you need all success parameters, setting `denodeify`'s + second parameter to `true` causes it to return all success parameters + as an array: + + ```javascript + var request = RSVP.denodeify(require('request'), true); + + request('http://example.com').then(function(result) { + // result[0] -> res + // result[1] -> body + }); + ``` + + Or if you pass it an array with names it returns the parameters as a hash: + + ```javascript + var request = RSVP.denodeify(require('request'), ['res', 'body']); + + request('http://example.com').then(function(result) { + // result.res + // result.body + }); + ``` + + Sometimes you need to retain the `this`: + + ```javascript + var app = require('express')(); + var render = RSVP.denodeify(app.render.bind(app)); + ``` + + The denodified function inherits from the original function. It works in all + environments, except IE 10 and below. Consequently all properties of the original + function are available to you. However, any properties you change on the + denodeified function won't be changed on the original function. Example: + + ```javascript + var request = RSVP.denodeify(require('request')), + cookieJar = request.jar(); // <- Inheritance is used here + + request('http://example.com', {jar: cookieJar}).then(function(res) { + // cookieJar.cookies holds now the cookies returned by example.com + }); + ``` + + Using `denodeify` makes it easier to compose asynchronous operations instead + of using callbacks. For example, instead of: + + ```javascript + var fs = require('fs'); + + fs.readFile('myfile.txt', function(err, data){ + if (err) { ... } // Handle error + fs.writeFile('myfile2.txt', data, function(err){ + if (err) { ... } // Handle error + console.log('done') + }); + }); + ``` + + you can chain the operations together using `then` from the returned promise: + + ```javascript + var fs = require('fs'); + var readFile = RSVP.denodeify(fs.readFile); + var writeFile = RSVP.denodeify(fs.writeFile); + + readFile('myfile.txt').then(function(data){ + return writeFile('myfile2.txt', data); + }).then(function(){ + console.log('done') + }).catch(function(error){ + // Handle error + }); + ``` + + @method denodeify + @static + @for RSVP + @param {Function} nodeFunc a 'node-style' function that takes a callback as + its last argument. The callback expects an error to be passed as its first + argument (if an error occurred, otherwise null), and the value from the + operation as its second argument ('function(err, value){ }'). + @param {Boolean|Array} [options] An optional paramter that if set + to `true` causes the promise to fulfill with the callback's success arguments + as an array. This is useful if the node function has multiple success + paramters. If you set this paramter to an array with names, the promise will + fulfill with a hash with these names as keys and the success parameters as + values. + @return {Function} a function that wraps `nodeFunc` to return an + `RSVP.Promise` + @static +*/ +function denodeify(nodeFunc, options) { + var fn = function() { + var self = this; + var l = arguments.length; + var args = new Array(l + 1); + var arg; + var promiseInput = false; + + for (var i = 0; i < l; ++i) { + arg = arguments[i]; + + if (!promiseInput) { + // TODO: clean this up + promiseInput = needsPromiseInput(arg); + if (promiseInput === GET_THEN_ERROR$1) { + var p = new Promise(noop); + reject(p, GET_THEN_ERROR$1.value); + return p; + } else if (promiseInput && promiseInput !== true) { + arg = wrapThenable(promiseInput, arg); } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not + args[i] = arg; + } + + var promise = new Promise(noop); + + args[l] = function(err, val) { + if (err) + reject(promise, err); + else if (options === undefined) + resolve(promise, val); + else if (options === true) + resolve(promise, arrayResult(arguments)); + else if (isArray(options)) + resolve(promise, makeObject(arguments, options)); + else + resolve(promise, val); + }; + + if (promiseInput) { + return handlePromiseInput(promise, args, nodeFunc, self); + } else { + return handleValueInput(promise, args, nodeFunc, self); + } + }; + + fn.__proto__ = nodeFunc; + + return fn; +} + +function handleValueInput(promise, args, nodeFunc, self) { + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; +} + +function handlePromiseInput(promise, args, nodeFunc, self){ + return Promise.all(args).then(function(args){ + var result = tryApply(nodeFunc, self, args); + if (result === ERROR) { + reject(promise, result.value); + } + return promise; + }); +} + +function needsPromiseInput(arg) { + if (arg && typeof arg === 'object') { + if (arg.constructor === Promise) { + return true; + } else { + return getThen$1(arg); + } + } else { + return false; + } +} + +/** + This is a convenient alias for `RSVP.Promise.all`. + + @method all + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. +*/ +function all$1(array, label) { + return Promise.all(array, label); +} + +function AllSettled(Constructor, entries, label) { + this._superConstructor(Constructor, entries, false /* don't abort on reject */, label); +} + +AllSettled.prototype = o_create(Enumerator.prototype); +AllSettled.prototype._superConstructor = Enumerator; +AllSettled.prototype._makeResult = makeSettledResult; +AllSettled.prototype._validationError = function() { + return new Error('allSettled must be called with an array'); +}; + +/** + `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + a fail-fast method, it waits until all the promises have returned and + shows you all the results. This is useful if you want to handle multiple + promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled. The return promise is fulfilled with an array of the states of + the promises passed into the `promises` array argument. + + Each state object will either indicate fulfillment or rejection, and + provide the corresponding value or reason. The states will take one of + the following formats: + + ```javascript + { state: 'fulfilled', value: value } + or + { state: 'rejected', reason: reason } + ``` + + Example: + + ```javascript + var promise1 = RSVP.Promise.resolve(1); + var promise2 = RSVP.Promise.reject(new Error('2')); + var promise3 = RSVP.Promise.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + RSVP.allSettled(promises).then(function(array){ + // array == [ + // { state: 'fulfilled', value: 1 }, + // { state: 'rejected', reason: Error }, + // { state: 'rejected', reason: Error } + // ] + // Note that for the second item, reason.message will be '2', and for the + // third item, reason.message will be '3'. + }, function(error) { + // Not run. (This block would only be called if allSettled had failed, + // for instance if passed an incorrect argument type.) + }); + ``` + + @method allSettled + @static + @for RSVP + @param {Array} entries + @param {String} label - optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with an array of the settled + states of the constituent promises. +*/ + +function allSettled(entries, label) { + return new AllSettled(Promise, entries, label).promise; +} + +/** + This is a convenient alias for `RSVP.Promise.race`. + + @method race + @static + @for RSVP + @param {Array} array Array of promises. + @param {String} label An optional label. This is useful + for tooling. + */ +function race$1(array, label) { + return Promise.race(array, label); +} + +function PromiseHash(Constructor, object, label) { + this._superConstructor(Constructor, object, true, label); +} + +PromiseHash.prototype = o_create(Enumerator.prototype); +PromiseHash.prototype._superConstructor = Enumerator; +PromiseHash.prototype._init = function() { + this._result = {}; +}; + +PromiseHash.prototype._validateInput = function(input) { + return input && typeof input === 'object'; +}; + +PromiseHash.prototype._validationError = function() { + return new Error('Promise.hash must be called with an object'); +}; + +PromiseHash.prototype._enumerate = function() { + var enumerator = this; + var promise = enumerator.promise; + var input = enumerator._input; + var results = []; + + for (var key in input) { + if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { + results.push({ + position: key, + entry: input[key] }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - finally: function (callback, label) { - var promise = this; - var constructor = promise.constructor; + } + } + + var length = results.length; + enumerator._remaining = length; + var result; + + for (var i = 0; promise._state === PENDING && i < length; i++) { + result = results[i]; + enumerator._eachEntry(result.entry, result.position); + } +}; + +/** + `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array + for its `promises` argument. + + Returns a promise that is fulfilled when all the given promises have been + fulfilled, or rejected if any of them become rejected. The returned promise + is fulfilled with a hash that has the same key names as the `promises` object + argument. If any of the values in the object are not promises, they will + simply be copied over to the fulfilled object. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + yourPromise: RSVP.resolve(2), + theirPromise: RSVP.resolve(3), + notAPromise: 4 + }; + + RSVP.hash(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: 1, + // yourPromise: 2, + // theirPromise: 3, + // notAPromise: 4 + // } + }); + ```` + + If any of the `promises` given to `RSVP.hash` are rejected, the first promise + that is rejected will be given as the reason to the rejection handler. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.resolve(1), + rejectedPromise: RSVP.reject(new Error('rejectedPromise')), + anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), + }; + + RSVP.hash(promises).then(function(hash){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === 'rejectedPromise' + }); + ``` + + An important note: `RSVP.hash` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hash` will NOT preserve prototype + chains. + + Example: + + ```javascript + function MyConstructor(){ + this.example = RSVP.resolve('Example'); + } + + MyConstructor.prototype = { + protoProperty: RSVP.resolve('Proto Property') + }; + + var myObject = new MyConstructor(); + + RSVP.hash(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: 'Example' + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` + + @method hash + @static + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all properties of `promises` + have been fulfilled, or rejected if any of them become rejected. +*/ +function hash(object, label) { + return new PromiseHash(Promise, object, label).promise; +} - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }, label); - } +function HashSettled(Constructor, object, label) { + this._superConstructor(Constructor, object, false, label); +} + +HashSettled.prototype = o_create(PromiseHash.prototype); +HashSettled.prototype._superConstructor = Enumerator; +HashSettled.prototype._makeResult = makeSettledResult; + +HashSettled.prototype._validationError = function() { + return new Error('hashSettled must be called with an object'); +}; + +/** + `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + instead of an array for its `promises` argument. + + Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + but like `RSVP.allSettled`, `hashSettled` waits until all the + constituent promises have returned and then shows you all the results + with their states and values/reasons. This is useful if you want to + handle multiple promises' failure states together as a set. + + Returns a promise that is fulfilled when all the given promises have been + settled, or rejected if the passed parameters are invalid. + + The returned promise is fulfilled with a hash that has the same key names as + the `promises` object argument. If any of the values in the object are not + promises, they will be copied over to the fulfilled object and marked with state + 'fulfilled'. + + Example: + + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + yourPromise: RSVP.Promise.resolve(2), + theirPromise: RSVP.Promise.resolve(3), + notAPromise: 4 }; - function Result() { - this.value = undefined; - } + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // yourPromise: { state: 'fulfilled', value: 2 }, + // theirPromise: { state: 'fulfilled', value: 3 }, + // notAPromise: { state: 'fulfilled', value: 4 } + // } + }); + ``` - var ERROR = new Result(); - var GET_THEN_ERROR$1 = new Result(); + If any of the `promises` given to `RSVP.hash` are rejected, the state will + be set to 'rejected' and the reason for rejection provided. - function getThen$1(obj) { - try { - return obj.then; - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + Example: - function tryApply(f, s, a) { - try { - f.apply(s, a); - } catch (error) { - ERROR.value = error; - return ERROR; - } - } + ```javascript + var promises = { + myPromise: RSVP.Promise.resolve(1), + rejectedPromise: RSVP.Promise.reject(new Error('rejection')), + anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), + }; - function makeObject(_, argumentNames) { - var obj = {}; - var length = _.length; - var args = new Array(length); + RSVP.hashSettled(promises).then(function(hash){ + // hash here is an object that looks like: + // { + // myPromise: { state: 'fulfilled', value: 1 }, + // rejectedPromise: { state: 'rejected', reason: Error }, + // anotherRejectedPromise: { state: 'rejected', reason: Error }, + // } + // Note that for rejectedPromise, reason.message == 'rejection', + // and for anotherRejectedPromise, reason.message == 'more rejection'. + }); + ``` - for (var x = 0; x < length; x++) { - args[x] = _[x]; - } + An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that + are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype + chains. - for (var i = 0; i < argumentNames.length; i++) { - var _name = argumentNames[i]; - obj[_name] = args[i + 1]; - } + Example: - return obj; + ```javascript + function MyConstructor(){ + this.example = RSVP.Promise.resolve('Example'); } - function arrayResult(_) { - var length = _.length; - var args = new Array(length - 1); + MyConstructor.prototype = { + protoProperty: RSVP.Promise.resolve('Proto Property') + }; - for (var i = 1; i < length; i++) { - args[i - 1] = _[i]; - } + var myObject = new MyConstructor(); - return args; - } + RSVP.hashSettled(myObject).then(function(hash){ + // protoProperty will not be present, instead you will just have an + // object that looks like: + // { + // example: { state: 'fulfilled', value: 'Example' } + // } + // + // hash.hasOwnProperty('protoProperty'); // false + // 'undefined' === typeof hash.protoProperty + }); + ``` - function wrapThenable(then, promise) { - return { - then: function (onFulFillment, onRejection) { - return then.call(promise, onFulFillment, onRejection); - } - }; + @method hashSettled + @for RSVP + @param {Object} object + @param {String} label optional string that describes the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when when all properties of `promises` + have been settled. + @static +*/ +function hashSettled(object, label) { + return new HashSettled(Promise, object, label).promise; +} + +/** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + + ```javascript + function throws(){ + throw new Error('Whoops!'); } - /** - `RSVP.denodeify` takes a 'node-style' function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - If the node function has multiple success parameters, then `denodeify` - just returns the first one: - - ```javascript - let request = RSVP.denodeify(require('request')); - - request('http://example.com').then(function(res) { - // ... - }); - ``` - - However, if you need all success parameters, setting `denodeify`'s - second parameter to `true` causes it to return all success parameters - as an array: - - ```javascript - let request = RSVP.denodeify(require('request'), true); - - request('http://example.com').then(function(result) { - // result[0] -> res - // result[1] -> body - }); - ``` - - Or if you pass it an array with names it returns the parameters as a hash: - - ```javascript - let request = RSVP.denodeify(require('request'), ['res', 'body']); - - request('http://example.com').then(function(result) { - // result.res - // result.body - }); - ``` - - Sometimes you need to retain the `this`: - - ```javascript - let app = require('express')(); - let render = RSVP.denodeify(app.render.bind(app)); - ``` - - The denodified function inherits from the original function. It works in all - environments, except IE 10 and below. Consequently all properties of the original - function are available to you. However, any properties you change on the - denodeified function won't be changed on the original function. Example: - - ```javascript - let request = RSVP.denodeify(require('request')), - cookieJar = request.jar(); // <- Inheritance is used here - - request('http://example.com', {jar: cookieJar}).then(function(res) { - // cookieJar.cookies holds now the cookies returned by example.com - }); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - let fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) { ... } // Handle error - fs.writeFile('myfile2.txt', data, function(err){ - if (err) { ... } // Handle error - console.log('done') - }); - }); - ``` - - you can chain the operations together using `then` from the returned promise: - - ```javascript - let fs = require('fs'); - let readFile = RSVP.denodeify(fs.readFile); - let writeFile = RSVP.denodeify(fs.writeFile); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - console.log('done') - }).catch(function(error){ - // Handle error - }); - ``` - - @method denodeify - @static - @for RSVP - @param {Function} nodeFunc a 'node-style' function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ('function(err, value){ }'). - @param {Boolean|Array} [options] An optional paramter that if set - to `true` causes the promise to fulfill with the callback's success arguments - as an array. This is useful if the node function has multiple success - paramters. If you set this paramter to an array with names, the promise will - fulfill with a hash with these names as keys and the success parameters as - values. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - @static - */ - function denodeify(nodeFunc, options) { - var fn = function () { - var self = this; - var l = arguments.length; - var args = new Array(l + 1); - var promiseInput = false; - - for (var i = 0; i < l; ++i) { - var arg = arguments[i]; - - if (!promiseInput) { - // TODO: clean this up - promiseInput = needsPromiseInput(arg); - if (promiseInput === GET_THEN_ERROR$1) { - var p = new Promise(noop); - reject(p, GET_THEN_ERROR$1.value); - return p; - } else if (promiseInput && promiseInput !== true) { - arg = wrapThenable(promiseInput, arg); - } - } - args[i] = arg; - } + var promise = new RSVP.Promise(function(resolve, reject){ + throws(); + }); - var promise = new Promise(noop); + promise.catch(RSVP.rethrow).then(function(){ + // Code here doesn't run because the promise became rejected due to an + // error! + }, function (err){ + // handle the error here + }); + ``` - args[l] = function (err, val) { - if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val); - }; + The 'Whoops' error will be thrown on the next turn of the event loop + and you can watch for it in your console. You can also handle it using a + rejection handler given to `.then` or `.catch` on the returned promise. - if (promiseInput) { - return handlePromiseInput(promise, args, nodeFunc, self); - } else { - return handleValueInput(promise, args, nodeFunc, self); - } - }; + @method rethrow + @static + @for RSVP + @param {Error} reason reason the promise became rejected. + @throws Error + @static +*/ +function rethrow(reason) { + setTimeout(function() { + throw reason; + }); + throw reason; +} - babelHelpers.defaults(fn, nodeFunc); +/** + `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. + `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s + interface. New code should use the `RSVP.Promise` constructor instead. - return fn; - } + The object returned from `RSVP.defer` is a plain object with three properties: - function handleValueInput(promise, args, nodeFunc, self) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - } + * promise - an `RSVP.Promise`. + * reject - a function that causes the `promise` property on this object to + become rejected + * resolve - a function that causes the `promise` property on this object to + become fulfilled. - function handlePromiseInput(promise, args, nodeFunc, self) { - return Promise.all(args).then(function (args) { - var result = tryApply(nodeFunc, self, args); - if (result === ERROR) { - reject(promise, result.value); - } - return promise; - }); - } + Example: - function needsPromiseInput(arg) { - if (arg && typeof arg === 'object') { - if (arg.constructor === Promise) { - return true; - } else { - return getThen$1(arg); - } - } else { - return false; - } - } + ```javascript + var deferred = RSVP.defer(); - /** - This is a convenient alias for `RSVP.Promise.all`. - - @method all - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function all$1(array, label) { - return Promise.all(array, label); - } + deferred.resolve("Success!"); - function AllSettled(Constructor, entries, label) { - this._superConstructor(Constructor, entries, false, /* don't abort on reject */label); - } + deferred.promise.then(function(value){ + // value here is "Success!" + }); + ``` - AllSettled.prototype = o_create(Enumerator.prototype); - AllSettled.prototype._superConstructor = Enumerator; - AllSettled.prototype._makeResult = makeSettledResult; - AllSettled.prototype._validationError = function () { - return new Error('allSettled must be called with an array'); - }; + @method defer + @static + @for RSVP + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Object} + */ - /** - `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing - a fail-fast method, it waits until all the promises have returned and - shows you all the results. This is useful if you want to handle multiple - promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled. The return promise is fulfilled with an array of the states of - the promises passed into the `promises` array argument. - - Each state object will either indicate fulfillment or rejection, and - provide the corresponding value or reason. The states will take one of - the following formats: - - ```javascript - { state: 'fulfilled', value: value } - or - { state: 'rejected', reason: reason } - ``` - - Example: - - ```javascript - let promise1 = RSVP.Promise.resolve(1); - let promise2 = RSVP.Promise.reject(new Error('2')); - let promise3 = RSVP.Promise.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - RSVP.allSettled(promises).then(function(array){ - // array == [ - // { state: 'fulfilled', value: 1 }, - // { state: 'rejected', reason: Error }, - // { state: 'rejected', reason: Error } - // ] - // Note that for the second item, reason.message will be '2', and for the - // third item, reason.message will be '3'. - }, function(error) { - // Not run. (This block would only be called if allSettled had failed, - // for instance if passed an incorrect argument type.) - }); - ``` - - @method allSettled - @static - @for RSVP - @param {Array} entries - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with an array of the settled - states of the constituent promises. - */ +function defer(label) { + var deferred = {}; - function allSettled(entries, label) { - return new AllSettled(Promise, entries, label).promise; - } + deferred['promise'] = new Promise(function(resolve, reject) { + deferred['resolve'] = resolve; + deferred['reject'] = reject; + }, label); - /** - This is a convenient alias for `RSVP.Promise.race`. - - @method race - @static - @for RSVP - @param {Array} array Array of promises. - @param {String} label An optional label. This is useful - for tooling. - */ - function race$1(array, label) { - return Promise.race(array, label); - } + return deferred; +} - function PromiseHash(Constructor, object, label) { - this._superConstructor(Constructor, object, true, label); - } +/** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. - PromiseHash.prototype = o_create(Enumerator.prototype); - PromiseHash.prototype._superConstructor = Enumerator; - PromiseHash.prototype._init = function () { - this._result = {}; - }; + For example: - PromiseHash.prototype._validateInput = function (input) { - return input && typeof input === 'object'; - }; + ```javascript - PromiseHash.prototype._validationError = function () { - return new Error('Promise.hash must be called with an object'); + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; }; - PromiseHash.prototype._enumerate = function () { - var enumerator = this; - var promise = enumerator.promise; - var input = enumerator._input; - var results = []; - - for (var key in input) { - if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) { - results.push({ - position: key, - entry: input[key] - }); - } - } + RSVP.map(promises, mapFn).then(function(result){ + // result is [ 2, 3, 4 ] + }); + ``` - var length = results.length; - enumerator._remaining = length; - var result = undefined; + If any of the `promises` given to `RSVP.map` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - for (var i = 0; promise._state === PENDING && i < length; i++) { - result = results[i]; - enumerator._eachEntry(result.entry, result.position); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; + + var mapFn = function(item){ + return item + 1; }; - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as the reason to the rejection handler. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error('rejectedPromise')), - anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === 'rejectedPromise' - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve('Example'); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: 'Example' - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @static - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - function hash(object, label) { - return new PromiseHash(Promise, object, label).promise; - } + RSVP.map(promises, mapFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - function HashSettled(Constructor, object, label) { - this._superConstructor(Constructor, object, false, label); - } + `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, + say you want to get all comments from a set of blog posts, but you need + the blog posts first because they contain a url to those comments. - HashSettled.prototype = o_create(PromiseHash.prototype); - HashSettled.prototype._superConstructor = Enumerator; - HashSettled.prototype._makeResult = makeSettledResult; + ```javscript - HashSettled.prototype._validationError = function () { - return new Error('hashSettled must be called with an object'); + var mapFn = function(blogPost){ + // getComments does some ajax and returns an RSVP.Promise that is fulfilled + // with some comments data + return getComments(blogPost.comments_url); }; - /** - `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object - instead of an array for its `promises` argument. - - Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, - but like `RSVP.allSettled`, `hashSettled` waits until all the - constituent promises have returned and then shows you all the results - with their states and values/reasons. This is useful if you want to - handle multiple promises' failure states together as a set. - - Returns a promise that is fulfilled when all the given promises have been - settled, or rejected if the passed parameters are invalid. - - The returned promise is fulfilled with a hash that has the same key names as - the `promises` object argument. If any of the values in the object are not - promises, they will be copied over to the fulfilled object and marked with state - 'fulfilled'. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - yourPromise: RSVP.Promise.resolve(2), - theirPromise: RSVP.Promise.resolve(3), - notAPromise: 4 - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // yourPromise: { state: 'fulfilled', value: 2 }, - // theirPromise: { state: 'fulfilled', value: 3 }, - // notAPromise: { state: 'fulfilled', value: 4 } - // } - }); - ``` - - If any of the `promises` given to `RSVP.hash` are rejected, the state will - be set to 'rejected' and the reason for rejection provided. - - Example: - - ```javascript - let promises = { - myPromise: RSVP.Promise.resolve(1), - rejectedPromise: RSVP.Promise.reject(new Error('rejection')), - anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')), - }; - - RSVP.hashSettled(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: { state: 'fulfilled', value: 1 }, - // rejectedPromise: { state: 'rejected', reason: Error }, - // anotherRejectedPromise: { state: 'rejected', reason: Error }, - // } - // Note that for rejectedPromise, reason.message == 'rejection', - // and for anotherRejectedPromise, reason.message == 'more rejection'. - }); - ``` - - An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.Promise.resolve('Example'); + // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled + // with some blog post data + RSVP.map(getBlogPosts(), mapFn).then(function(comments){ + // comments is the result of asking the server for the comments + // of all blog posts returned from getBlogPosts() + }); + ``` + + @method map + @static + @for RSVP + @param {Array} promises + @param {Function} mapFn function to be called on each fulfilled promise. + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled with the result of calling + `mapFn` on each fulfilled promise or value when they become fulfilled. + The promise will be rejected if any of the given `promises` become rejected. + @static +*/ +function map(promises, mapFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(mapFn)) { + throw new TypeError("You must pass a function as map's second argument."); } - - MyConstructor.prototype = { - protoProperty: RSVP.Promise.resolve('Proto Property') - }; - - let myObject = new MyConstructor(); - - RSVP.hashSettled(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: { state: 'fulfilled', value: 'Example' } - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hashSettled - @for RSVP - @param {Object} object - @param {String} label optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when when all properties of `promises` - have been settled. - @static - */ - function hashSettled(object, label) { - return new HashSettled(Promise, object, label).promise; - } - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will also throw the - error again so the error can be handled by the promise per the spec. - - ```javascript - function throws(){ - throw new Error('Whoops!'); + var length = values.length; + var results = new Array(length); + + for (var i = 0; i < length; i++) { + results[i] = mapFn(values[i]); } - - let promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @static - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - @static - */ - function rethrow(reason) { - setTimeout(function () { - throw reason; - }); - throw reason; - } - /** - `RSVP.defer` returns an object similar to jQuery's `$.Deferred`. - `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s - interface. New code should use the `RSVP.Promise` constructor instead. - - The object returned from `RSVP.defer` is a plain object with three properties: - - * promise - an `RSVP.Promise`. - * reject - a function that causes the `promise` property on this object to - become rejected - * resolve - a function that causes the `promise` property on this object to - become fulfilled. - - Example: - - ```javascript - let deferred = RSVP.defer(); - - deferred.resolve("Success!"); - - deferred.promise.then(function(value){ - // value here is "Success!" - }); - ``` - - @method defer - @static - @for RSVP - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Object} - */ + return Promise.all(results, label); + }); +} - function defer(label) { - var deferred = { resolve: undefined, reject: undefined }; +/** + This is a convenient alias for `RSVP.Promise.resolve`. - deferred.promise = new Promise(function (resolve, reject) { - deferred.resolve = resolve; - deferred.reject = reject; - }, label); + @method resolve + @static + @for RSVP + @param {*} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$2(value, label) { + return Promise.resolve(value, label); +} - return deferred; - } +/** + This is a convenient alias for `RSVP.Promise.reject`. - /** - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first because they contain a url to those comments. - - ```javscript - - let mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @static - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - @static - */ - function map(promises, mapFn, label) { - return Promise.all(promises, label).then(function (values) { - if (!isFunction(mapFn)) { - throw new TypeError("You must pass a function as map's second argument."); - } + @method reject + @static + @for RSVP + @param {*} reason value that the returned promise will be rejected with. + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$2(reason, label) { + return Promise.reject(reason, label); +} - var length = values.length; - var results = new Array(length); +/** + `RSVP.filter` is similar to JavaScript's native `filter` method, except that it + waits for all promises to become fulfilled before running the `filterFn` on + each item in given to `promises`. `RSVP.filter` returns a promise that will + become fulfilled with the result of running `filterFn` on the values the + promises become fulfilled with. - for (var i = 0; i < length; i++) { - results[i] = mapFn(values[i]); - } + For example: - return Promise.all(results, label); - }); - } + ```javascript - /** - This is a convenient alias for `RSVP.Promise.resolve`. - - @method resolve - @static - @for RSVP - @param {*} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - function resolve$2(value, label) { - return Promise.resolve(value, label); - } + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.resolve(2); + var promise3 = RSVP.resolve(3); - /** - This is a convenient alias for `RSVP.Promise.reject`. - - @method reject - @static - @for RSVP - @param {*} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - function reject$2(reason, label) { - return Promise.reject(reason, label); - } + var promises = [promise1, promise2, promise3]; - /** - `RSVP.filter` is similar to JavaScript's native `filter` method, except that it - waits for all promises to become fulfilled before running the `filterFn` on - each item in given to `promises`. `RSVP.filter` returns a promise that will - become fulfilled with the result of running `filterFn` on the values the - promises become fulfilled with. - - For example: - - ```javascript - - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.resolve(2); - let promise3 = RSVP.resolve(3); - - let promises = [promise1, promise2, promise3]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promise's - rejection handler. For example: - - ```javascript - let promise1 = RSVP.resolve(1); - let promise2 = RSVP.reject(new Error('2')); - let promise3 = RSVP.reject(new Error('3')); - let promises = [ promise1, promise2, promise3 ]; - - let filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === '2' - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - let alice = { name: 'alice' }; - let bob = { name: 'bob' }; - let users = [ alice, bob ]; - - let promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - let filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @static - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ + var filterFn = function(item){ + return item > 1; + }; - function resolveAll(promises, label) { - return Promise.all(promises, label); - } + RSVP.filter(promises, filterFn).then(function(result){ + // result is [ 2, 3 ] + }); + ``` - function resolveSingle(promise, label) { - return Promise.resolve(promise, label).then(function (promises) { - return resolveAll(promises, label); - }); - } + If any of the `promises` given to `RSVP.filter` are rejected, the first promise + that is rejected will be given as an argument to the returned promise's + rejection handler. For example: - function filter(promises, filterFn, label) { - var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label); - return promise.then(function (values) { - if (!isFunction(filterFn)) { - throw new TypeError("You must pass a function as filter's second argument."); - } + ```javascript + var promise1 = RSVP.resolve(1); + var promise2 = RSVP.reject(new Error('2')); + var promise3 = RSVP.reject(new Error('3')); + var promises = [ promise1, promise2, promise3 ]; - var length = values.length; - var filtered = new Array(length); + var filterFn = function(item){ + return item > 1; + }; - for (var i = 0; i < length; i++) { - filtered[i] = filterFn(values[i]); - } + RSVP.filter(promises, filterFn).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(reason) { + // reason.message === '2' + }); + ``` - return resolveAll(filtered, label).then(function (filtered) { - var results = new Array(length); - var newLength = 0; + `RSVP.filter` will also wait for any promises returned from `filterFn`. + For instance, you may want to fetch a list of users then return a subset + of those users based on some asynchronous operation: - for (var i = 0; i < length; i++) { - if (filtered[i]) { - results[newLength] = values[i]; - newLength++; - } - } + ```javascript - results.length = newLength; + var alice = { name: 'alice' }; + var bob = { name: 'bob' }; + var users = [ alice, bob ]; - return results; - }); + var promises = users.map(function(user){ + return RSVP.resolve(user); + }); + + var filterFn = function(user){ + // Here, Alice has permissions to create a blog post, but Bob does not. + return getPrivilegesForUser(user).then(function(privs){ + return privs.can_create_blog_post === true; }); - } + }; + RSVP.filter(promises, filterFn).then(function(users){ + // true, because the server told us only Alice can create a blog post. + users.length === 1; + // false, because Alice is the only user present in `users` + users[0] === bob; + }); + ``` - var len = 0; - var vertxNext = undefined; - function asap(callback, arg) { - queue$1[len] = callback; - queue$1[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 1, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - scheduleFlush$1(); - } - } - - var browserWindow = typeof window !== 'undefined' ? window : undefined; - var browserGlobal = browserWindow || {}; - var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; - var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; - - // test for web worker but not in IE10 - var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; - - // node - function useNextTick() { - var nextTick = process.nextTick; - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // setImmediate should be used instead instead - var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); - if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { - nextTick = setImmediate; + @method filter + @static + @for RSVP + @param {Array} promises + @param {Function} filterFn - function to be called on each resolved value to + filter the final results. + @param {String} label optional string describing the promise. Useful for + tooling. + @return {Promise} +*/ +function filter(promises, filterFn, label) { + return Promise.all(promises, label).then(function(values) { + if (!isFunction(filterFn)) { + throw new TypeError("You must pass a function as filter's second argument."); } - return function () { - return nextTick(flush); - }; - } - // vertx - function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); - }; + var length = values.length; + var filtered = new Array(length); + + for (var i = 0; i < length; i++) { + filtered[i] = filterFn(values[i]); } - return useSetTimeout(); - } - function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); + return Promise.all(filtered, label).then(function(filtered) { + var results = new Array(length); + var newLength = 0; - return function () { - return node.data = iterations = ++iterations % 2; - }; - } + for (var i = 0; i < length; i++) { + if (filtered[i]) { + results[newLength] = values[i]; + newLength++; + } + } - // web worker - function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; - } + results.length = newLength; - function useSetTimeout() { - return function () { - return setTimeout(flush, 1); - }; + return results; + }); + }); +} + +var len = 0; +var vertxNext; +function asap(callback, arg) { + queue$1[len] = callback; + queue$1[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 1, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + scheduleFlush$1(); } +} - var queue$1 = new Array(1000); +var browserWindow = (typeof window !== 'undefined') ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && + typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + var nextTick = process.nextTick; + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // setImmediate should be used instead instead + var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/); + if (Array.isArray(version) && version[1] === '0' && version[2] === '10') { + nextTick = setImmediate; + } + return function() { + nextTick(flush); + }; +} - function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue$1[i]; - var arg = queue$1[i + 1]; +// vertx +function useVertxTimer() { + return function() { + vertxNext(flush); + }; +} - callback(arg); +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); - queue$1[i] = undefined; - queue$1[i + 1] = undefined; - } + return function() { + node.data = (iterations = ++iterations % 2); + }; +} - len = 0; - } +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; +} - function attemptVertex() { - try { - var r = require; - var vertx = r('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } +function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; +} + +var queue$1 = new Array(1000); +function flush() { + for (var i = 0; i < len; i+=2) { + var callback = queue$1[i]; + var arg = queue$1[i+1]; + + callback(arg); + + queue$1[i] = undefined; + queue$1[i+1] = undefined; } - var scheduleFlush$1 = undefined; - // Decide what async method to use to triggering processing of queued callbacks: - if (isNode) { - scheduleFlush$1 = useNextTick(); - } else if (BrowserMutationObserver) { - scheduleFlush$1 = useMutationObserver(); - } else if (isWorker) { - scheduleFlush$1 = useMessageChannel(); - } else if (browserWindow === undefined && typeof require === 'function') { - scheduleFlush$1 = attemptVertex(); - } else { - scheduleFlush$1 = useSetTimeout(); + len = 0; +} + +function attemptVertex() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch(e) { + return useSetTimeout(); } +} + +var scheduleFlush$1; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush$1 = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush$1 = useMutationObserver(); +} else if (isWorker) { + scheduleFlush$1 = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush$1 = attemptVertex(); +} else { + scheduleFlush$1 = useSetTimeout(); +} + +// defaults +config.async = asap; +config.after = function(cb) { + setTimeout(cb, 0); +}; +var cast = resolve$2; +function async(callback, arg) { + config.async(callback, arg); +} - var platform = undefined; +function on() { + config['on'].apply(config, arguments); +} - /* global self */ - if (typeof self === 'object') { - platform = self; +function off() { + config['off'].apply(config, arguments); +} - /* global global */ - } else if (typeof global === 'object') { - platform = global; - } else { - throw new Error('no global: `self` or `global` found'); +// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` +if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { + var callbacks = window['__PROMISE_INSTRUMENTATION__']; + configure('instrument', true); + for (var eventName in callbacks) { + if (callbacks.hasOwnProperty(eventName)) { + on(eventName, callbacks[eventName]); } + } +} - // defaults - config.async = asap; - config.after = function (cb) { - return setTimeout(cb, 0); - }; - var cast = resolve$2; +exports.cast = cast; +exports.Promise = Promise; +exports.EventTarget = EventTarget; +exports.all = all$1; +exports.allSettled = allSettled; +exports.race = race$1; +exports.hash = hash; +exports.hashSettled = hashSettled; +exports.rethrow = rethrow; +exports.defer = defer; +exports.denodeify = denodeify; +exports.configure = configure; +exports.on = on; +exports.off = off; +exports.resolve = resolve$2; +exports.reject = reject$2; +exports.async = async; +exports.map = map; +exports.filter = filter; - var async = function (callback, arg) { - return config.async(callback, arg); - }; +Object.defineProperty(exports, '__esModule', { value: true }); - function on() { - config['on'].apply(config, arguments); - } - - function off() { - config['off'].apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') { - var callbacks = window['__PROMISE_INSTRUMENTATION__']; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - // the default export here is for backwards compat: - // https://github.com/tildeio/rsvp.js/issues/434 - var rsvp = (_rsvp = { - cast: cast, - Promise: Promise, - EventTarget: EventTarget, - all: all$1, - allSettled: allSettled, - race: race$1, - hash: hash, - hashSettled: hashSettled, - rethrow: rethrow, - defer: defer, - denodeify: denodeify, - configure: configure, - on: on, - off: off, - resolve: resolve$2, - reject: reject$2, - map: map - }, _rsvp['async'] = async, _rsvp.filter = // babel seems to error if async isn't a computed prop here... - filter, _rsvp); - - exports.cast = cast; - exports.Promise = Promise; - exports.EventTarget = EventTarget; - exports.all = all$1; - exports.allSettled = allSettled; - exports.race = race$1; - exports.hash = hash; - exports.hashSettled = hashSettled; - exports.rethrow = rethrow; - exports.defer = defer; - exports.denodeify = denodeify; - exports.configure = configure; - exports.on = on; - exports.off = off; - exports.resolve = resolve$2; - exports.reject = reject$2; - exports.map = map; - exports.async = async; - exports.filter = filter; - exports.default = rsvp; }); requireModule("ember"); diff --git a/package.json b/package.json index 87b761863..f5d25164b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "components-ember", - "version": "2.11.0-beta.2", + "version": "2.10.0-intercom", "description": "Ember Application Framework", "license": "MIT", "homepage": "https://github.com/emberjs/ember.js",