mes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +32 -0
  5. data/Rakefile +1 -0
  6. data/bin/mes +11 -0
  7. data/lib/middleman_ember_scaffold/cli/generators.rb +21 -0
  8. data/lib/middleman_ember_scaffold/cli.rb +91 -0
  9. data/lib/middleman_ember_scaffold/generators/scaffold.rb +22 -0
  10. data/lib/middleman_ember_scaffold/load_paths.rb +1 -0
  11. data/lib/middleman_ember_scaffold/template/Capfile +4 -0
  12. data/lib/middleman_ember_scaffold/template/Gemfile +10 -0
  13. data/lib/middleman_ember_scaffold/template/README.md +30 -0
  14. data/lib/middleman_ember_scaffold/template/component.json +14 -0
  15. data/lib/middleman_ember_scaffold/template/components/ember/component.json +20 -0
  16. data/lib/middleman_ember_scaffold/template/components/ember/ember.js +27755 -0
  17. data/lib/middleman_ember_scaffold/template/components/ember/ember.min.js +20 -0
  18. data/lib/middleman_ember_scaffold/template/components/ember-data/README.md +4 -0
  19. data/lib/middleman_ember_scaffold/template/components/ember-data/component.json +22 -0
  20. data/lib/middleman_ember_scaffold/template/components/ember-data/ember-data-spade.js +1 -0
  21. data/lib/middleman_ember_scaffold/template/components/ember-data/ember-data.amd.js +7819 -0
  22. data/lib/middleman_ember_scaffold/template/components/ember-data/ember-data.js +8769 -0
  23. data/lib/middleman_ember_scaffold/template/components/ember-data/ember-data.min.js +12 -0
  24. data/lib/middleman_ember_scaffold/template/components/ember-data/ember-data.prod.js +7802 -0
  25. data/lib/middleman_ember_scaffold/template/components/handlebars/component.json +17 -0
  26. data/lib/middleman_ember_scaffold/template/components/handlebars/handlebars.js +2201 -0
  27. data/lib/middleman_ember_scaffold/template/components/handlebars/handlebars.runtime.js +321 -0
  28. data/lib/middleman_ember_scaffold/template/components/jquery/component.json +14 -0
  29. data/lib/middleman_ember_scaffold/template/components/jquery/composer.json +26 -0
  30. data/lib/middleman_ember_scaffold/template/components/jquery/jquery-migrate.js +496 -0
  31. data/lib/middleman_ember_scaffold/template/components/jquery/jquery-migrate.min.js +3 -0
  32. data/lib/middleman_ember_scaffold/template/components/jquery/jquery.js +9597 -0
  33. data/lib/middleman_ember_scaffold/template/components/jquery/jquery.min.js +5 -0
  34. data/lib/middleman_ember_scaffold/template/config/deploy.rb +66 -0
  35. data/lib/middleman_ember_scaffold/template/config.rb +91 -0
  36. data/lib/middleman_ember_scaffold/template/source/app/application.coffee +15 -0
  37. data/lib/middleman_ember_scaffold/template/source/app/controllers/application_controller.coffee +1 -0
  38. data/lib/middleman_ember_scaffold/template/source/app/controllers/index_controller.coffee +1 -0
  39. data/lib/middleman_ember_scaffold/template/source/app/main.coffee +17 -0
  40. data/lib/middleman_ember_scaffold/template/source/app/models/foo.coffee +1 -0
  41. data/lib/middleman_ember_scaffold/template/source/app/routes.coffee +11 -0
  42. data/lib/middleman_ember_scaffold/template/source/app/views/application_view.coffee +2 -0
  43. data/lib/middleman_ember_scaffold/template/source/app/views/index_view.coffee +2 -0
  44. data/lib/middleman_ember_scaffold/template/source/index.html.haml +1 -0
  45. data/lib/middleman_ember_scaffold/template/source/layout.haml +8 -0
  46. data/lib/middleman_ember_scaffold/template/source/stylesheets/application.css.scss +2 -0
  47. data/lib/middleman_ember_scaffold/template/source/stylesheets/variables.scss +279 -0
  48. data/lib/middleman_ember_scaffold/template/source/templates_emblem/application/index.emblem +2 -0
  49. data/lib/middleman_ember_scaffold/template/source/templates_emblem/application.emblem +4 -0
  50. data/lib/middleman_ember_scaffold/template/vendor/javascripts/.gitkeep +0 -0
  51. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-dropdown.js +165 -0
  52. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-modal.js +374 -0
  53. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-modalmanager.js +412 -0
  54. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-popover.js +114 -0
  55. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-tabs.js +144 -0
  56. data/lib/middleman_ember_scaffold/template/vendor/javascripts/bootstrap-tooltip.js +361 -0
  57. data/lib/middleman_ember_scaffold/template/vendor/javascripts/date.js +104 -0
  58. data/lib/middleman_ember_scaffold/template/vendor/javascripts/ember-data.js +8769 -0
  59. data/lib/middleman_ember_scaffold/template/vendor/javascripts/ember.js +27755 -0
  60. data/lib/middleman_ember_scaffold/template/vendor/javascripts/handlebars.js +2201 -0
  61. data/lib/middleman_ember_scaffold/template/vendor/javascripts/jquery.js +9597 -0
  62. data/lib/middleman_ember_scaffold/template/vendor/javascripts/jquery.validate.min.js +2 -0
  63. data/lib/middleman_ember_scaffold/template/vendor/javascripts/json2.js +480 -0
  64. data/lib/middleman_ember_scaffold/template/vendor/javascripts/underscore.js +1 -0
  65. data/lib/middleman_ember_scaffold/template/vendor/javascripts/utils.js +19 -0
  66. data/lib/middleman_ember_scaffold/template/vendor/stylesheets/.gitkeep +0 -0
  67. data/lib/middleman_ember_scaffold/template/watch +2 -0
  68. data/lib/middleman_ember_scaffold/version.rb +3 -0
  69. data/lib/middleman_ember_scaffold.rb +5 -0
  70. data/mes.gemspec +24 -0
  71. metadata +167 -0
@@ -0,0 +1 @@
1
+ minispade.register('ember-data/adapters', "(function() {minispade.require(\"ember-data/adapters/fixture_adapter\");\nminispade.require(\"ember-data/adapters/rest_adapter\");\n\n})();\n//@ sourceURL=ember-data/adapters");minispade.register('ember-data/adapters/fixture_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/system/adapter\");\n\nvar get = Ember.get;\n\nDS.FixtureAdapter = DS.Adapter.extend({\n\n simulateRemoteResponse: true,\n\n latency: 50,\n\n /*\n Implement this method in order to provide data associated with a type\n */\n fixturesForType: function(type) {\n if (type.FIXTURES) {\n var fixtures = Ember.A(type.FIXTURES);\n return fixtures.map(function(fixture){\n if(!fixture.id){\n throw new Error('the id property must be defined for fixture %@'.fmt(fixture));\n }\n fixture.id = fixture.id + '';\n return fixture;\n });\n }\n return null;\n },\n\n /*\n Implement this method in order to query fixtures data\n */\n queryFixtures: function(fixtures, query, type) {\n return fixtures;\n },\n\n /*\n Implement this method in order to provide provide json for CRUD methods\n */\n mockJSON: function(type, record) {\n return this.serialize(record, { includeId: true });\n },\n\n /*\n Adapter methods\n */\n generateIdForRecord: function(store, record) {\n return Ember.guidFor(record);\n },\n\n find: function(store, type, id) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), !!fixtures);\n\n if (fixtures) {\n fixtures = fixtures.findProperty('id', id);\n }\n\n if (fixtures) {\n this.simulateRemoteCall(function() {\n store.load(type, fixtures);\n }, store, type);\n }\n },\n\n findMany: function(store, type, ids) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), !!fixtures);\n\n if (fixtures) {\n fixtures = fixtures.filter(function(item) {\n return ids.indexOf(item.id) !== -1;\n });\n }\n\n if (fixtures) {\n this.simulateRemoteCall(function() {\n store.loadMany(type, fixtures);\n }, store, type);\n }\n },\n\n findAll: function(store, type) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), !!fixtures);\n\n this.simulateRemoteCall(function() {\n store.loadMany(type, fixtures);\n store.didUpdateAll(type);\n }, store, type);\n },\n\n findQuery: function(store, type, query, array) {\n var fixtures = this.fixturesForType(type);\n\n Ember.assert(\"Unable to find fixtures for model type \"+type.toString(), !!fixtures);\n\n fixtures = this.queryFixtures(fixtures, query, type);\n\n if (fixtures) {\n this.simulateRemoteCall(function() {\n array.load(fixtures);\n }, store, type);\n }\n },\n\n createRecord: function(store, type, record) {\n var fixture = this.mockJSON(type, record);\n\n fixture.id = this.generateIdForRecord(store, record);\n\n this.simulateRemoteCall(function() {\n store.didSaveRecord(record, fixture);\n }, store, type, record);\n },\n\n updateRecord: function(store, type, record) {\n var fixture = this.mockJSON(type, record);\n\n this.simulateRemoteCall(function() {\n store.didSaveRecord(record, fixture);\n }, store, type, record);\n },\n\n deleteRecord: function(store, type, record) {\n this.simulateRemoteCall(function() {\n store.didSaveRecord(record);\n }, store, type, record);\n },\n\n /*\n @private\n */\n simulateRemoteCall: function(callback, store, type, record) {\n if (get(this, 'simulateRemoteResponse')) {\n setTimeout(callback, get(this, 'latency'));\n } else {\n callback();\n }\n }\n});\n\n})();\n//@ sourceURL=ember-data/adapters/fixture_adapter");minispade.register('ember-data/adapters/rest_adapter', "(function() {minispade.require(\"ember-data/core\");\nminispade.require('ember-data/system/adapter');\nminispade.require('ember-data/serializers/rest_serializer');\n/*global jQuery*/\n\nvar get = Ember.get, set = Ember.set, merge = Ember.merge;\n\n/**\n The REST adapter allows your store to communicate with an HTTP server by\n transmitting JSON via XHR. Most Ember.js apps that consume a JSON API\n should use the REST adapter.\n\n This adapter is designed around the idea that the JSON exchanged with\n the server should be conventional.\n\n ## JSON Structure\n\n The REST adapter expects the JSON returned from your server to follow\n these conventions.\n\n ### Object Root\n\n The JSON payload should be an object that contains the record inside a\n root property. For example, in response to a `GET` request for\n `/posts/1`, the JSON should look like this:\n\n ```js\n {\n \"post\": {\n title: \"I'm Running to Reform the W3C's Tag\",\n author: \"Yehuda Katz\"\n }\n }\n ```\n\n ### Conventional Names\n\n Attribute names in your JSON payload should be the underscored versions of\n the attributes in your Ember.js models.\n\n For example, if you have a `Person` model:\n\n ```js\n App.Person = DS.Model.extend({\n firstName: DS.attr('string'),\n lastName: DS.attr('string'),\n occupation: DS.attr('string')\n });\n ```\n\n The JSON returned should look like this:\n\n ```js\n {\n \"person\": {\n \"first_name\": \"Barack\",\n \"last_name\": \"Obama\",\n \"occupation\": \"President\"\n }\n }\n ```\n*/\nDS.RESTAdapter = DS.Adapter.extend({\n bulkCommit: false,\n since: 'since',\n\n serializer: DS.RESTSerializer,\n\n init: function() {\n this._super.apply(this, arguments);\n },\n\n shouldSave: function(record) {\n var reference = get(record, '_reference');\n\n return !reference.parent;\n },\n\n createRecord: function(store, type, record) {\n var root = this.rootForType(type);\n\n var data = {};\n data[root] = this.serialize(record, { includeId: true });\n\n this.ajax(this.buildURL(root), \"POST\", {\n data: data,\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didCreateRecord(store, type, record, json);\n });\n },\n error: function(xhr) {\n this.didError(store, type, record, xhr);\n }\n });\n },\n\n dirtyRecordsForRecordChange: function(dirtySet, record) {\n this._dirtyTree(dirtySet, record);\n },\n\n dirtyRecordsForHasManyChange: function(dirtySet, record, relationship) {\n var embeddedType = get(this, 'serializer').embeddedType(record.constructor, relationship.secondRecordName);\n\n if (embeddedType === 'always') {\n relationship.childReference.parent = relationship.parentReference;\n this._dirtyTree(dirtySet, record);\n }\n },\n\n _dirtyTree: function(dirtySet, record) {\n dirtySet.add(record);\n\n get(this, 'serializer').eachEmbeddedRecord(record, function(embeddedRecord, embeddedType) {\n if (embeddedType !== 'always') { return; }\n if (dirtySet.has(embeddedRecord)) { return; }\n this._dirtyTree(dirtySet, embeddedRecord);\n }, this);\n\n var reference = record.get('_reference');\n\n if (reference.parent) {\n var store = get(record, 'store');\n var parent = store.recordForReference(reference.parent);\n this._dirtyTree(dirtySet, parent);\n }\n },\n\n createRecords: function(store, type, records) {\n if (get(this, 'bulkCommit') === false) {\n return this._super(store, type, records);\n }\n\n var root = this.rootForType(type),\n plural = this.pluralize(root);\n\n var data = {};\n data[plural] = [];\n records.forEach(function(record) {\n data[plural].push(this.serialize(record, { includeId: true }));\n }, this);\n\n this.ajax(this.buildURL(root), \"POST\", {\n data: data,\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didCreateRecords(store, type, records, json);\n });\n }\n });\n },\n\n updateRecord: function(store, type, record) {\n var id = get(record, 'id');\n var root = this.rootForType(type);\n\n var data = {};\n data[root] = this.serialize(record);\n\n this.ajax(this.buildURL(root, id), \"PUT\", {\n data: data,\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didSaveRecord(store, type, record, json);\n });\n },\n error: function(xhr) {\n this.didError(store, type, record, xhr);\n }\n });\n },\n\n updateRecords: function(store, type, records) {\n if (get(this, 'bulkCommit') === false) {\n return this._super(store, type, records);\n }\n\n var root = this.rootForType(type),\n plural = this.pluralize(root);\n\n var data = {};\n data[plural] = [];\n records.forEach(function(record) {\n data[plural].push(this.serialize(record, { includeId: true }));\n }, this);\n\n this.ajax(this.buildURL(root, \"bulk\"), \"PUT\", {\n data: data,\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didSaveRecords(store, type, records, json);\n });\n }\n });\n },\n\n deleteRecord: function(store, type, record) {\n var id = get(record, 'id');\n var root = this.rootForType(type);\n\n this.ajax(this.buildURL(root, id), \"DELETE\", {\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didSaveRecord(store, type, record, json);\n });\n }\n });\n },\n\n deleteRecords: function(store, type, records) {\n if (get(this, 'bulkCommit') === false) {\n return this._super(store, type, records);\n }\n\n var root = this.rootForType(type),\n plural = this.pluralize(root),\n serializer = get(this, 'serializer');\n\n var data = {};\n data[plural] = [];\n records.forEach(function(record) {\n data[plural].push(serializer.serializeId( get(record, 'id') ));\n });\n\n this.ajax(this.buildURL(root, 'bulk'), \"DELETE\", {\n data: data,\n context: this,\n success: function(json) {\n Ember.run(this, function(){\n this.didSaveRecords(store, type, records, json);\n });\n }\n });\n },\n\n find: function(store, type, id) {\n var root = this.rootForType(type);\n\n this.ajax(this.buildURL(root, id), \"GET\", {\n success: function(json) {\n Ember.run(this, function(){\n this.didFindRecord(store, type, json, id);\n });\n }\n });\n },\n\n findAll: function(store, type, since) {\n var root = this.rootForType(type);\n\n this.ajax(this.buildURL(root), \"GET\", {\n data: this.sinceQuery(since),\n success: function(json) {\n Ember.run(this, function(){\n this.didFindAll(store, type, json);\n });\n }\n });\n },\n\n findQuery: function(store, type, query, recordArray) {\n var root = this.rootForType(type);\n\n this.ajax(this.buildURL(root), \"GET\", {\n data: query,\n success: function(json) {\n Ember.run(this, function(){\n this.didFindQuery(store, type, json, recordArray);\n });\n }\n });\n },\n\n findMany: function(store, type, ids, owner) {\n var root = this.rootForType(type);\n ids = this.serializeIds(ids);\n\n this.ajax(this.buildURL(root), \"GET\", {\n data: {ids: ids},\n success: function(json) {\n Ember.run(this, function(){\n this.didFindMany(store, type, json);\n });\n }\n });\n },\n\n /**\n @private\n\n This method serializes a list of IDs using `serializeId`\n\n @returns {Array} an array of serialized IDs\n */\n serializeIds: function(ids) {\n var serializer = get(this, 'serializer');\n\n return Ember.EnumerableUtils.map(ids, function(id) {\n return serializer.serializeId(id);\n });\n },\n\n didError: function(store, type, record, xhr) {\n if (xhr.status === 422) {\n var data = JSON.parse(xhr.responseText);\n store.recordWasInvalid(record, data['errors']);\n } else {\n this._super.apply(this, arguments);\n }\n },\n\n ajax: function(url, type, hash) {\n hash.url = url;\n hash.type = type;\n hash.dataType = 'json';\n hash.contentType = 'application/json; charset=utf-8';\n hash.context = this;\n\n if (hash.data && type !== 'GET') {\n hash.data = JSON.stringify(hash.data);\n }\n\n jQuery.ajax(hash);\n },\n\n url: \"\",\n\n rootForType: function(type) {\n var serializer = get(this, 'serializer');\n return serializer.rootForType(type);\n },\n\n pluralize: function(string) {\n var serializer = get(this, 'serializer');\n return serializer.pluralize(string);\n },\n\n buildURL: function(record, suffix) {\n var url = [this.url];\n\n Ember.assert(\"Namespace URL (\" + this.namespace + \") must not start with slash\", !this.namespace || this.namespace.toString().charAt(0) !== \"/\");\n Ember.assert(\"Record URL (\" + record + \") must not start with slash\", !record || record.toString().charAt(0) !== \"/\");\n Ember.assert(\"URL suffix (\" + suffix + \") must not start with slash\", !suffix || suffix.toString().charAt(0) !== \"/\");\n\n if (this.namespace !== undefined) {\n url.push(this.namespace);\n }\n\n url.push(this.pluralize(record));\n if (suffix !== undefined) {\n url.push(suffix);\n }\n\n return url.join(\"/\");\n },\n\n sinceQuery: function(since) {\n var query = {};\n query[get(this, 'since')] = since;\n return since ? query : null;\n }\n});\n\n\n})();\n//@ sourceURL=ember-data/adapters/rest_adapter");minispade.register('ember-data/core', "(function() {window.DS = Ember.Namespace.create({\n // this one goes to 11\n CURRENT_API_REVISION: 11\n});\n\n})();\n//@ sourceURL=ember-data/core");minispade.register('ember-data', "(function() {//Copyright (C) 2011 by Living Social, Inc.\n\n//Permission is hereby granted, free of charge, to any person obtaining a copy of\n//this software and associated documentation files (the \"Software\"), to deal in\n//the Software without restriction, including without limitation the rights to\n//use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n//of the Software, and to permit persons to whom the Software is furnished to do\n//so, subject to the following conditions:\n\n//The above copyright notice and this permission notice shall be included in all\n//copies or substantial portions of the Software.\n\n//THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n//SOFTWARE.\nminispade.require(\"ember-data/core\");\nminispade.require(\"ember-data/system/store\");\nminispade.require(\"ember-data/system/record_arrays\");\nminispade.require(\"ember-data/system/model\");\nminispade.require(\"ember-data/system/relationships\");\nminispade.require(\"ember-data/system/application_ext\");\nminispade.require(\"ember-data/system/serializer\");\nminispade.require(\"ember-data/system/adapter\");\nminispade.require(\"ember-data/adapters\");\n\n})();\n//@ sourceURL=ember-data");minispade.register('ember-data/serializers/json_serializer', "(function() {minispade.require('ember-data/system/serializer');\nminispade.require('ember-data/transforms/json_transforms');\n\nvar get = Ember.get, set = Ember.set;\n\nvar generatedId = 0;\n\nDS.JSONSerializer = DS.Serializer.extend({\n init: function() {\n this._super();\n\n if (!get(this, 'transforms')) {\n this.set('transforms', DS.JSONTransforms);\n }\n\n this.sideloadMapping = Ember.Map.create();\n\n this.configure({\n meta: 'meta',\n since: 'since'\n });\n },\n\n configure: function(type, configuration) {\n if (type && !configuration) {\n return this._super(type);\n }\n\n var sideloadAs = configuration.sideloadAs;\n\n if (sideloadAs) {\n this.sideloadMapping.set(sideloadAs, type);\n delete configuration.sideloadAs;\n }\n\n this._super.apply(this, arguments);\n },\n\n addId: function(data, key, id) {\n data[key] = id;\n },\n\n /**\n A hook you can use to customize how the key/value pair is added to\n the serialized data.\n\n @param {any} hash the JSON hash being built\n @param {String} key the key to add to the serialized data\n @param {any} value the value to add to the serialized data\n */\n addAttribute: function(hash, key, value) {\n hash[key] = value;\n },\n\n /**\n @private\n\n Creates an empty hash that will be filled in by the hooks called from the\n `serialize()` method.\n\n @return {Object}\n */\n createSerializedForm: function() {\n return {};\n },\n\n extractAttribute: function(type, hash, attributeName) {\n var key = this._keyForAttributeName(type, attributeName);\n return hash[key];\n },\n\n extractId: function(type, hash) {\n var primaryKey = this._primaryKey(type);\n\n if (hash.hasOwnProperty(primaryKey)) {\n // Ensure that we coerce IDs to strings so that record\n // IDs remain consistent between application runs; especially\n // if the ID is serialized and later deserialized from the URL,\n // when type information will have been lost.\n return hash[primaryKey]+'';\n } else {\n return null;\n }\n },\n\n extractHasMany: function(type, hash, key) {\n return hash[key];\n },\n\n extractBelongsTo: function(type, hash, key) {\n return hash[key];\n },\n\n addBelongsTo: function(hash, record, key, relationship) {\n var type = record.constructor,\n name = relationship.key,\n value = null,\n embeddedChild;\n\n if (this.embeddedType(type, name)) {\n if (embeddedChild = get(record, name)) {\n value = this.serialize(embeddedChild, { includeId: true });\n }\n\n hash[key] = value;\n } else {\n var id = get(record, relationship.key+'.id');\n if (!Ember.isNone(id)) { hash[key] = id; }\n }\n },\n\n /**\n Adds a has-many relationship to the JSON hash being built.\n\n The default REST semantics are to only add a has-many relationship if it\n is embedded. If the relationship was initially loaded by ID, we assume that\n that was done as a performance optimization, and that changes to the\n has-many should be saved as foreign key changes on the child's belongs-to\n relationship.\n\n @param {Object} hash the JSON being built\n @param {DS.Model} record the record being serialized\n @param {String} key the JSON key into which the serialized relationship\n should be saved\n @param {Object} relationship metadata about the relationship being serialized\n */\n addHasMany: function(hash, record, key, relationship) {\n var type = record.constructor,\n name = relationship.key,\n serializedHasMany = [],\n manyArray, embeddedType;\n\n // If the has-many is not embedded, there is nothing to do.\n embeddedType = this.embeddedType(type, name);\n if (embeddedType !== 'always') { return; }\n\n // Get the DS.ManyArray for the relationship off the record\n manyArray = get(record, name);\n\n // Build up the array of serialized records\n manyArray.forEach(function (record) {\n serializedHasMany.push(this.serialize(record, { includeId: true }));\n }, this);\n\n // Set the appropriate property of the serialized JSON to the\n // array of serialized embedded records\n hash[key] = serializedHasMany;\n },\n\n // EXTRACTION\n\n extract: function(loader, json, type, record) {\n var root = this.rootForType(type);\n\n this.sideload(loader, type, json, root);\n this.extractMeta(loader, type, json);\n\n if (json[root]) {\n if (record) { loader.updateId(record, json[root]); }\n this.extractRecordRepresentation(loader, type, json[root]);\n }\n },\n\n extractMany: function(loader, json, type, records) {\n var root = this.rootForType(type);\n root = this.pluralize(root);\n\n this.sideload(loader, type, json, root);\n this.extractMeta(loader, type, json);\n\n if (json[root]) {\n var objects = json[root], references = [];\n if (records) { records = records.toArray(); }\n\n for (var i = 0; i < objects.length; i++) {\n if (records) { loader.updateId(records[i], objects[i]); }\n var reference = this.extractRecordRepresentation(loader, type, objects[i]);\n references.push(reference);\n }\n\n loader.populateArray(references);\n }\n },\n\n extractMeta: function(loader, type, json) {\n var meta = json[this.configOption(type, 'meta')], since;\n if (!meta) { return; }\n\n if (since = meta[this.configOption(type, 'since')]) {\n loader.sinceForType(type, since);\n }\n },\n\n sideload: function(loader, type, json, root) {\n var sideloadedType, mappings, loaded = {};\n\n loaded[root] = true;\n\n for (var prop in json) {\n if (!json.hasOwnProperty(prop)) { continue; }\n if (prop === root) { continue; }\n if (prop === this.configOption(type, 'meta')) { continue; }\n\n sideloadedType = type.typeForRelationship(prop);\n\n if (!sideloadedType) {\n sideloadedType = this.sideloadMapping.get(prop);\n\n if (typeof sideloadedType === 'string') {\n sideloadedType = get(Ember.lookup, sideloadedType);\n }\n\n Ember.assert(\"Your server returned a hash with the key \" + prop + \" but you have no mapping for it\", !!sideloadedType);\n }\n\n this.sideloadRelationships(loader, sideloadedType, json, prop, loaded);\n }\n },\n\n sideloadRelationships: function(loader, type, json, prop, loaded) {\n if (loaded[prop]) { return; }\n loaded[prop] = true;\n\n get(type, 'relationshipsByName').forEach(function(key, meta) {\n key = meta.key || key;\n if (meta.kind === 'belongsTo') {\n key = this.pluralize(key);\n }\n if (json[key]) {\n this.sideloadRelationships(loader, meta.type, json, key, loaded);\n }\n }, this);\n\n this.loadValue(loader, type, json[prop]);\n },\n\n loadValue: function(loader, type, value) {\n if (value instanceof Array) {\n for (var i=0; i < value.length; i++) {\n loader.sideload(type, value[i]);\n }\n } else {\n loader.sideload(type, value);\n }\n },\n\n // HELPERS\n\n // define a plurals hash in your subclass to define\n // special-case pluralization\n pluralize: function(name) {\n var plurals = this.configurations.get('plurals');\n return (plurals && plurals[name]) || name + \"s\";\n },\n\n rootForType: function(type) {\n var typeString = type.toString();\n\n Ember.assert(\"Your model must not be anonymous. It was \" + type, typeString.charAt(0) !== '(');\n\n // use the last part of the name as the URL\n var parts = typeString.split(\".\");\n var name = parts[parts.length - 1];\n return name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1);\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/json_serializer");minispade.register('ember-data/serializers/rest_serializer', "(function() {minispade.require('ember-data/serializers/json_serializer');\n\nDS.RESTSerializer = DS.JSONSerializer.extend({\n keyForAttributeName: function(type, name) {\n return Ember.String.decamelize(name);\n },\n\n keyForBelongsTo: function(type, name) {\n var key = this.keyForAttributeName(type, name);\n\n if (this.embeddedType(type, name)) {\n return key;\n }\n\n return key + \"_id\";\n }\n});\n\n})();\n//@ sourceURL=ember-data/serializers/rest_serializer");minispade.register('ember-data/system/adapter', "(function() {minispade.require('ember-data/serializers/json_serializer');\n\nfunction loaderFor(store) {\n return {\n load: function(type, data, prematerialized) {\n return store.load(type, data, prematerialized);\n },\n\n loadMany: function(type, array) {\n return store.loadMany(type, array);\n },\n\n updateId: function(record, data) {\n return store.updateId(record, data);\n },\n\n populateArray: Ember.K,\n\n sideload: function(type, data) {\n return store.load(type, data);\n },\n\n sideloadMany: function(type, array) {\n return store.loadMany(type, array);\n },\n\n prematerialize: function(reference, prematerialized) {\n store.prematerialize(reference, prematerialized);\n },\n\n sinceForType: function(type, since) {\n store.sinceForType(type, since);\n }\n };\n}\n\nDS.loaderFor = loaderFor;\n\n/**\n An adapter is an object that receives requests from a store and\n translates them into the appropriate action to take against your\n persistence layer. The persistence layer is usually an HTTP API, but may\n be anything, such as the browser's local storage.\n\n ### Creating an Adapter\n\n First, create a new subclass of `DS.Adapter`:\n\n App.MyAdapter = DS.Adapter.extend({\n // ...your code here\n });\n\n To tell your store which adapter to use, set its `adapter` property:\n\n App.store = DS.Store.create({\n revision: 3,\n adapter: App.MyAdapter.create()\n });\n\n `DS.Adapter` is an abstract base class that you should override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `find()`\n * `createRecord()`\n * `updateRecord()`\n * `deleteRecord()`\n\n To improve the network performance of your application, you can optimize\n your adapter by overriding these lower-level methods:\n\n * `findMany()`\n * `createRecords()`\n * `updateRecords()`\n * `deleteRecords()`\n * `commit()`\n*/\n\nvar get = Ember.get, set = Ember.set, merge = Ember.merge;\n\nDS.Adapter = Ember.Object.extend(DS._Mappable, {\n\n init: function() {\n var serializer = get(this, 'serializer');\n\n if (Ember.Object.detect(serializer)) {\n serializer = serializer.create();\n set(this, 'serializer', serializer);\n }\n\n this._attributesMap = this.createInstanceMapFor('attributes');\n this._configurationsMap = this.createInstanceMapFor('configurations');\n\n this._outstandingOperations = new Ember.MapWithDefault({\n defaultValue: function() { return 0; }\n });\n\n this._dependencies = new Ember.MapWithDefault({\n defaultValue: function() { return new Ember.OrderedSet(); }\n });\n\n this.registerSerializerTransforms(this.constructor, serializer, {});\n this.registerSerializerMappings(serializer);\n },\n\n /**\n Loads a payload for a record into the store.\n\n This method asks the serializer to break the payload into\n constituent parts, and then loads them into the store. For example,\n if you have a payload that contains embedded records, they will be\n extracted by the serializer and loaded into the store.\n\n For example:\n\n ```javascript\n adapter.load(store, App.Person, {\n id: 123,\n firstName: \"Yehuda\",\n lastName: \"Katz\",\n occupations: [{\n id: 345,\n title: \"Tricycle Mechanic\"\n }] \n });\n ```\n\n This will load the payload for the `App.Person` with ID `123` and\n the embedded `App.Occupation` with ID `345`.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {any} payload\n */\n load: function(store, type, payload) {\n var loader = loaderFor(store);\n get(this, 'serializer').extractRecordRepresentation(loader, type, payload);\n },\n\n /**\n Acknowledges that the adapter has finished creating a record.\n\n Your adapter should call this method from `createRecord` when\n it has saved a new record to its persistent storage and received\n an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n creation, and you want to update the existing record with the\n new information, pass the payload as the fourth parameter.\n\n For example, the `RESTAdapter` saves newly created records by\n making an Ajax request. When the server returns, the adapter\n calls didCreateRecord. If the server returns a response body,\n it is passed as the payload. \n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {any} payload \n */\n didCreateRecord: function(store, type, record, payload) {\n store.didSaveRecord(record);\n\n if (payload) {\n var loader = DS.loaderFor(store);\n var serializer = get(this, 'serializer');\n\n loader.load = function(type, data, prematerialized) {\n store.updateId(record, data);\n return store.load(type, data, prematerialized);\n };\n\n get(this, 'serializer').extract(loader, payload, type);\n }\n },\n\n /**\n Acknowledges that the adapter has finished creating several records.\n\n Your adapter should call this method from `createRecords` when it\n has saved multiple created records to its persistent storage \n received an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n creation, and you want to update the existing record with the\n new information, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {any} payload \n */\n didCreateRecords: function(store, type, records, payload) {\n records.forEach(function(record) {\n store.didSaveRecord(record);\n }, this);\n\n if (payload) {\n var loader = DS.loaderFor(store);\n get(this, 'serializer').extractMany(loader, payload, type, records);\n }\n },\n\n /**\n @private\n\n Acknowledges that the adapter has finished updating or deleting a record.\n\n Your adapter should call this method from `updateRecord` or `deleteRecord`\n when it has updated or deleted a record to its persistent storage and\n received an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n update or delete, and you want to update the existing record with the\n new information, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {any} payload \n */\n didSaveRecord: function(store, type, record, payload) {\n store.didSaveRecord(record);\n\n var serializer = get(this, 'serializer'),\n mappings = serializer.mappingForType(type);\n\n serializer.eachEmbeddedRecord(record, function(embeddedRecord, embeddedType) {\n if (embeddedType === 'load') { return; }\n\n this.didSaveRecord(store, embeddedRecord.constructor, embeddedRecord);\n }, this);\n\n if (payload) {\n var loader = DS.loaderFor(store);\n serializer.extract(loader, payload, type);\n }\n },\n\n /**\n Acknowledges that the adapter has finished updating a record.\n\n Your adapter should call this method from `updateRecord` when it\n has updated a record to its persistent storage and received an\n acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n update, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {any} payload \n */\n didUpdateRecord: function() {\n this.didSaveRecord.apply(this, arguments);\n },\n\n /**\n Acknowledges that the adapter has finished deleting a record.\n\n Your adapter should call this method from `deleteRecord` when it\n has deleted a record from its persistent storage and received an\n acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n deletion, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n @param {any} payload \n */\n didDeleteRecord: function() {\n this.didSaveRecord.apply(this, arguments);\n },\n\n /**\n Acknowledges that the adapter has finished updating or deleting \n multiple records.\n\n Your adapter should call this method from its `updateRecords` or\n `deleteRecords` when it has updated or deleted multiple records\n to its persistent storage and received an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n creation, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} records\n @param {any} payload \n */\n didSaveRecords: function(store, type, records, payload) {\n records.forEach(function(record) {\n store.didSaveRecord(record);\n }, this);\n\n if (payload) {\n var loader = DS.loaderFor(store);\n get(this, 'serializer').extractMany(loader, payload, type);\n }\n },\n\n /**\n Acknowledges that the adapter has finished updating multiple records.\n\n Your adapter should call this method from its `updateRecords` when\n it has updated multiple records to its persistent storage and\n received an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n update, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} records\n @param {any} payload \n */\n didUpdateRecords: function() {\n this.didSaveRecords.apply(this, arguments);\n },\n\n /**\n Acknowledges that the adapter has finished updating multiple records.\n\n Your adapter should call this method from its `deleteRecords` when\n it has deleted multiple records to its persistent storage and\n received an acknowledgement.\n\n If the persistent storage returns a new payload in response to the\n deletion, pass the payload as the fourth parameter.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} records\n @param {any} payload \n */\n didDeleteRecords: function() {\n this.didSaveRecords.apply(this, arguments);\n },\n\n /**\n Loads the response to a request for a record by ID.\n\n Your adapter should call this method from its `find` method\n with the response from the backend.\n\n You should pass the same ID to this method that was given\n to your find method so that the store knows which record\n to associate the new data with.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {any} payload \n @param {String} id\n */\n didFindRecord: function(store, type, payload, id) {\n var loader = DS.loaderFor(store);\n\n loader.load = function(type, data, prematerialized) {\n prematerialized = prematerialized || {};\n prematerialized.id = id;\n\n return store.load(type, data, prematerialized);\n };\n\n get(this, 'serializer').extract(loader, payload, type);\n },\n\n /**\n Loads the response to a request for all records by type.\n\n You adapter should call this method from its `findAll`\n method with the response from the backend.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {any} payload \n */\n didFindAll: function(store, type, payload) {\n var loader = DS.loaderFor(store),\n serializer = get(this, 'serializer');\n\n store.didUpdateAll(type);\n\n serializer.extractMany(loader, payload, type);\n },\n\n /**\n Loads the response to a request for records by query.\n\n Your adapter should call this method from its `findQuery`\n method with the response from the backend.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {any} payload \n @param {DS.AdapterPopulatedRecordArray} recordArray\n */\n didFindQuery: function(store, type, payload, recordArray) {\n var loader = DS.loaderFor(store);\n\n loader.populateArray = function(data) {\n recordArray.load(data);\n };\n\n get(this, 'serializer').extractMany(loader, payload, type);\n },\n\n /**\n Loads the response to a request for many records by ID.\n\n You adapter should call this method from its `findMany`\n method with the response from the backend.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {any} payload \n */\n didFindMany: function(store, type, payload) {\n var loader = DS.loaderFor(store);\n\n get(this, 'serializer').extractMany(loader, payload, type);\n },\n\n /**\n Notifies the store that a request to the backend returned\n an error.\n\n Your adapter should call this method to indicate that the\n backend returned an error for a request.\n\n @param {DS.Store} store\n @param {subclass of DS.Model} type\n @param {DS.Model} record\n */\n didError: function(store, type, record) {\n store.recordWasError(record);\n },\n\n dirtyRecordsForAttributeChange: function(dirtySet, record, attributeName, newValue, oldValue) {\n if (newValue !== oldValue) {\n // If this record is embedded, add its parent\n // to the dirty set.\n this.dirtyRecordsForRecordChange(dirtySet, record);\n }\n },\n\n dirtyRecordsForRecordChange: function(dirtySet, record) {\n dirtySet.add(record);\n },\n\n dirtyRecordsForBelongsToChange: function(dirtySet, child) {\n this.dirtyRecordsForRecordChange(dirtySet, child);\n },\n\n dirtyRecordsForHasManyChange: function(dirtySet, parent) {\n this.dirtyRecordsForRecordChange(dirtySet, parent);\n },\n\n /**\n @private\n\n This method recursively climbs the superclass hierarchy and\n registers any class-registered transforms on the adapter's\n serializer.\n\n Once it registers a transform for a given type, it ignores\n subsequent transforms for the same attribute type.\n\n @param {Class} klass the DS.Adapter subclass to extract the\n transforms from\n @param {DS.Serializer} serializer the serializer to register\n the transforms onto\n @param {Object} seen a hash of attributes already seen\n */\n registerSerializerTransforms: function(klass, serializer, seen) {\n var transforms = klass._registeredTransforms, superclass, prop;\n\n for (prop in transforms) {\n if (!transforms.hasOwnProperty(prop) || prop in seen) { continue; }\n seen[prop] = true;\n\n serializer.registerTransform(prop, transforms[prop]);\n }\n\n if (superclass = klass.superclass) {\n this.registerSerializerTransforms(superclass, serializer, seen);\n }\n },\n\n /**\n @private\n\n This method recursively climbs the superclass hierarchy and\n registers any class-registered mappings on the adapter's\n serializer.\n\n @param {Class} klass the DS.Adapter subclass to extract the\n transforms from\n @param {DS.Serializer} serializer the serializer to register the\n mappings onto\n */\n registerSerializerMappings: function(serializer) {\n var mappings = this._attributesMap,\n configurations = this._configurationsMap;\n\n mappings.forEach(serializer.map, serializer);\n configurations.forEach(serializer.configure, serializer);\n },\n\n /**\n The `find()` method is invoked when the store is asked for a record that\n has not previously been loaded. In response to `find()` being called, you\n should query your persistence layer for a record with the given ID. Once\n found, you can asynchronously call the store's `load()` method to load\n the record.\n\n Here is an example `find` implementation:\n\n find: function(store, type, id) {\n var url = type.url;\n url = url.fmt(id);\n\n jQuery.getJSON(url, function(data) {\n // data is a hash of key/value pairs. If your server returns a\n // root, simply do something like:\n // store.load(type, id, data.person)\n store.load(type, id, data);\n });\n }\n */\n find: null,\n\n serializer: DS.JSONSerializer,\n\n registerTransform: function(attributeType, transform) {\n get(this, 'serializer').registerTransform(attributeType, transform);\n },\n\n /**\n A public method that allows you to register an enumerated \n type on your adapter. This is useful if you want to utilize\n a text representation of an integer value.\n\n Eg: Say you want to utilize \"low\",\"medium\",\"high\" text strings\n in your app, but you want to persist those as 0,1,2 in your backend.\n You would first register the transform on your adapter instance:\n\n adapter.registerEnumTransform('priority', ['low', 'medium', 'high']);\n\n You would then refer to the 'priority' DS.attr in your model:\n App.Task = DS.Model.extend({\n priority: DS.attr('priority') \n });\n\n And lastly, you would set/get the text representation on your model instance,\n but the transformed result will be the index number of the type.\n\n App: myTask.get('priority') => 'low'\n Server Response / Load: { myTask: {priority: 0} }\n\n @param {String} type of the transform\n @param {Array} array of String objects to use for the enumerated values. \n This is an ordered list and the index values will be used for the transform.\n */\n registerEnumTransform: function(attributeType, objects) {\n get(this, 'serializer').registerEnumTransform(attributeType, objects);\n },\n\n /**\n If the globally unique IDs for your records should be generated on the client,\n implement the `generateIdForRecord()` method. This method will be invoked\n each time you create a new record, and the value returned from it will be\n assigned to the record's `primaryKey`.\n\n Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\n of the record will be set by the server, and your adapter will update the store\n with the new ID when it calls `didCreateRecord()`. Only implement this method if\n you intend to generate record IDs on the client-side.\n\n The `generateIdForRecord()` method will be invoked with the requesting store as\n the first parameter and the newly created record as the second parameter:\n\n generateIdForRecord: function(store, record) {\n var uuid = App.generateUUIDWithStatisticallyLowOddsOfCollision();\n return uuid;\n }\n */\n generateIdForRecord: null,\n\n materialize: function(record, data, prematerialized) {\n get(this, 'serializer').materialize(record, data, prematerialized);\n },\n\n serialize: function(record, options) {\n return get(this, 'serializer').serialize(record, options);\n },\n\n extractId: function(type, data) {\n return get(this, 'serializer').extractId(type, data);\n },\n\n groupByType: function(enumerable) {\n var map = Ember.MapWithDefault.create({\n defaultValue: function() { return Ember.OrderedSet.create(); }\n });\n\n enumerable.forEach(function(item) {\n map.get(item.constructor).add(item);\n });\n\n return map;\n },\n\n commit: function(store, commitDetails) {\n this.save(store, commitDetails);\n },\n\n save: function(store, commitDetails) {\n var adapter = this;\n\n function filter(records) {\n var filteredSet = Ember.OrderedSet.create();\n\n records.forEach(function(record) {\n if (adapter.shouldSave(record)) {\n filteredSet.add(record);\n }\n });\n\n return filteredSet;\n }\n\n this.groupByType(commitDetails.created).forEach(function(type, set) {\n this.createRecords(store, type, filter(set));\n }, this);\n\n this.groupByType(commitDetails.updated).forEach(function(type, set) {\n this.updateRecords(store, type, filter(set));\n }, this);\n\n this.groupByType(commitDetails.deleted).forEach(function(type, set) {\n this.deleteRecords(store, type, filter(set));\n }, this);\n },\n\n shouldSave: Ember.K,\n\n createRecords: function(store, type, records) {\n records.forEach(function(record) {\n this.createRecord(store, type, record);\n }, this);\n },\n\n updateRecords: function(store, type, records) {\n records.forEach(function(record) {\n this.updateRecord(store, type, record);\n }, this);\n },\n\n deleteRecords: function(store, type, records) {\n records.forEach(function(record) {\n this.deleteRecord(store, type, record);\n }, this);\n },\n\n findMany: function(store, type, ids) {\n ids.forEach(function(id) {\n this.find(store, type, id);\n }, this);\n }\n});\n\nDS.Adapter.reopenClass({\n registerTransform: function(attributeType, transform) {\n var registeredTransforms = this._registeredTransforms || {};\n\n registeredTransforms[attributeType] = transform;\n\n this._registeredTransforms = registeredTransforms;\n },\n\n map: DS._Mappable.generateMapFunctionFor('attributes', function(key, newValue, map) {\n var existingValue = map.get(key);\n\n merge(existingValue, newValue);\n }),\n\n configure: DS._Mappable.generateMapFunctionFor('configurations', function(key, newValue, map) {\n var existingValue = map.get(key);\n\n // If a mapping configuration is provided, peel it off and apply it\n // using the DS.Adapter.map API.\n var mappings = newValue && newValue.mappings;\n if (mappings) {\n this.map(key, mappings);\n delete newValue.mappings;\n }\n\n merge(existingValue, newValue);\n }),\n\n resolveMapConflict: function(oldValue, newValue, mappingsKey) {\n merge(newValue, oldValue);\n\n return newValue;\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/adapter");minispade.register('ember-data/system/application_ext', "(function() {var set = Ember.set;\n\n/**\n This code registers an injection for Ember.Application.\n\n If an Ember.js developer defines a subclass of DS.Store on their application,\n this code will automatically instantiate it and make it available on the\n router.\n\n Additionally, after an application's controllers have been injected, they will\n each have the store made available to them.\n\n For example, imagine an Ember.js application with the following classes:\n\n App.Store = DS.Store.extend({\n adapter: 'App.MyCustomAdapter'\n });\n\n App.PostsController = Ember.ArrayController.extend({\n // ...\n });\n\n When the application is initialized, `App.Store` will automatically be\n instantiated, and the instance of `App.PostsController` will have its `store`\n property set to that instance.\n\n Note that this code will only be run if the `ember-application` package is\n loaded. If Ember Data is being used in an environment other than a\n typical application (e.g., node.js where only `ember-runtime` is available),\n this code will be ignored.\n*/\n\nEmber.onLoad('Ember.Application', function(Application) {\n if (Application.registerInjection) {\n Application.registerInjection({\n name: \"store\",\n before: \"controllers\",\n\n // If a store subclass is defined, like App.Store,\n // instantiate it and inject it into the router.\n injection: function(app, stateManager, property) {\n if (!stateManager) { return; }\n if (property === 'Store') {\n set(stateManager, 'store', app[property].create());\n }\n }\n });\n\n Application.registerInjection({\n name: \"giveStoreToControllers\",\n after: ['store','controllers'],\n\n // For each controller, set its `store` property\n // to the DS.Store instance we created above.\n injection: function(app, stateManager, property) {\n if (!stateManager) { return; }\n if (/^[A-Z].*Controller$/.test(property)) {\n var controllerName = property.charAt(0).toLowerCase() + property.substr(1);\n var store = stateManager.get('store');\n var controller = stateManager.get(controllerName);\n if(!controller) { return; }\n\n controller.set('store', store);\n }\n }\n });\n } else if (Application.initializer) {\n Application.initializer({\n name: \"store\",\n\n initialize: function(container, application) {\n container.register('store', 'main', application.Store);\n\n // Eagerly generate the store so defaultStore is populated.\n // TODO: Do this in a finisher hook\n container.lookup('store:main');\n }\n });\n\n Application.initializer({\n name: \"injectStore\",\n\n initialize: function(container) {\n container.typeInjection('controller', 'store', 'store:main');\n container.typeInjection('route', 'store', 'store:main');\n }\n });\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/application_ext");minispade.register('ember-data/system/mixins/load_promise', "(function() {var DeferredMixin = Ember.DeferredMixin, // ember-runtime/mixins/deferred\n Evented = Ember.Evented, // ember-runtime/mixins/evented\n run = Ember.run, // ember-metal/run-loop\n get = Ember.get; // ember-metal/accessors\n\nvar LoadPromise = Ember.Mixin.create(Evented, DeferredMixin, {\n init: function() {\n this._super.apply(this, arguments);\n this.one('didLoad', function() {\n run(this, 'resolve', this);\n });\n\n if (get(this, 'isLoaded')) {\n this.trigger('didLoad');\n }\n }\n});\n\nDS.LoadPromise = LoadPromise;\n\n})();\n//@ sourceURL=ember-data/system/mixins/load_promise");minispade.register('ember-data/system/mixins/mappable', "(function() {var classify = Ember.String.classify, get = Ember.get;\n\n/**\n@private\n\n The Mappable mixin is designed for classes that would like to\n behave as a map for configuration purposes.\n\n For example, the DS.Adapter class can behave like a map, with\n more semantic API, via the `map` API:\n\n DS.Adapter.map('App.Person', { firstName: { keyName: 'FIRST' } });\n\n Class configuration via a map-like API has a few common requirements\n that differentiate it from the standard Ember.Map implementation.\n\n First, values often are provided as strings that should be normalized\n into classes the first time the configuration options are used.\n\n Second, the values configured on parent classes should also be taken\n into account.\n\n Finally, setting the value of a key sometimes should merge with the\n previous value, rather than replacing it.\n\n This mixin provides a instance method, `createInstanceMapFor`, that\n will reify all of the configuration options set on an instance's\n constructor and provide it for the instance to use.\n\n Classes can implement certain hooks that allow them to customize\n the requirements listed above:\n\n * `resolveMapConflict` - called when a value is set for an existing\n value\n * `transformMapKey` - allows a key name (for example, a global path\n to a class) to be normalized\n * `transformMapValue` - allows a value (for example, a class that\n should be instantiated) to be normalized\n\n Classes that implement this mixin should also implement a class\n method built using the `generateMapFunctionFor` method:\n\n DS.Adapter.reopenClass({\n map: DS.Mappable.generateMapFunctionFor('attributes', function(key, newValue, map) {\n var existingValue = map.get(key);\n\n for (var prop in newValue) {\n if (!newValue.hasOwnProperty(prop)) { continue; }\n existingValue[prop] = newValue[prop];\n }\n })\n });\n\n The function passed to `generateMapFunctionFor` is invoked every time a\n new value is added to the map.\n**/\n\nvar resolveMapConflict = function(oldValue, newValue, mappingsKey) {\n return oldValue;\n};\n\nvar transformMapKey = function(key, value) {\n return key;\n};\n\nvar transformMapValue = function(key, value) {\n return value;\n};\n\nDS._Mappable = Ember.Mixin.create({\n createInstanceMapFor: function(mapName) {\n var instanceMeta = Ember.metaPath(this, ['DS.Mappable'], true);\n\n instanceMeta.values = instanceMeta.values || {};\n\n if (instanceMeta.values[mapName]) { return instanceMeta.values[mapName]; }\n\n var instanceMap = instanceMeta.values[mapName] = new Ember.Map();\n\n var klass = this.constructor;\n\n while (klass && klass !== DS.Store) {\n this._copyMap(mapName, klass, instanceMap);\n klass = klass.superclass;\n }\n\n instanceMeta.values[mapName] = instanceMap;\n return instanceMap;\n },\n\n _copyMap: function(mapName, klass, instanceMap) {\n var classMeta = Ember.metaPath(klass, ['DS.Mappable'], true);\n\n var classMap = classMeta[mapName];\n if (classMap) {\n classMap.forEach(eachMap, this);\n }\n\n function eachMap(key, value) {\n var transformedKey = (klass.transformMapKey || transformMapKey)(key, value);\n var transformedValue = (klass.transformMapValue || transformMapValue)(key, value);\n\n var oldValue = instanceMap.get(transformedKey);\n var newValue = transformedValue;\n\n if (oldValue) {\n newValue = (this.constructor.resolveMapConflict || resolveMapConflict)(oldValue, newValue, mapName);\n }\n\n instanceMap.set(transformedKey, newValue);\n }\n },\n\n\n});\n\nDS._Mappable.generateMapFunctionFor = function(mapName, transform) {\n return function(key, value) {\n var meta = Ember.metaPath(this, ['DS.Mappable'], true);\n var map = meta[mapName] || Ember.MapWithDefault.create({\n defaultValue: function() { return {}; }\n });\n\n transform.call(this, key, value, map);\n\n meta[mapName] = map;\n };\n};\n\n})();\n//@ sourceURL=ember-data/system/mixins/mappable");minispade.register('ember-data/system/model', "(function() {minispade.require(\"ember-data/system/model/model\");\nminispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/model/attributes\");\n\n})();\n//@ sourceURL=ember-data/system/model");minispade.register('ember-data/system/model/attributes', "(function() {var get = Ember.get;\nminispade.require(\"ember-data/system/model/model\");\n\nDS.Model.reopenClass({\n attributes: Ember.computed(function() {\n var map = Ember.Map.create();\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isAttribute) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.toString(), name !== 'id');\n\n meta.name = name;\n map.set(name, meta);\n }\n });\n\n return map;\n })\n});\n\nvar AttributeChange = DS.AttributeChange = function(options) {\n this.reference = options.reference;\n this.store = options.store;\n this.name = options.name;\n this.oldValue = options.oldValue;\n};\n\nAttributeChange.createChange = function(options) {\n return new AttributeChange(options);\n};\n\nAttributeChange.prototype = {\n sync: function() {\n this.store.recordAttributeDidChange(this.reference, this.name, this.value, this.oldValue);\n\n // TODO: Use this object in the commit process\n this.destroy();\n },\n\n destroy: function() {\n delete this.store.recordForReference(this.reference)._changesToSync[this.name];\n }\n};\n\nDS.Model.reopen({\n eachAttribute: function(callback, binding) {\n get(this.constructor, 'attributes').forEach(function(name, meta) {\n callback.call(binding, name, meta);\n }, binding);\n },\n\n attributeWillChange: Ember.beforeObserver(function(record, key) {\n var reference = get(record, '_reference'),\n store = get(record, 'store');\n\n record.send('willSetProperty', { reference: reference, store: store, name: key });\n }),\n\n attributeDidChange: Ember.observer(function(record, key) {\n record.send('didSetProperty', { name: key });\n })\n});\n\nfunction getAttr(record, options, key) {\n var attributes = get(record, 'data').attributes;\n var value = attributes[key];\n\n if (value === undefined) {\n value = options.defaultValue;\n }\n\n return value;\n}\n\nDS.attr = function(type, options) {\n options = options || {};\n\n var meta = {\n type: type,\n isAttribute: true,\n options: options\n };\n\n return Ember.computed(function(key, value, oldValue) {\n var data;\n\n if (arguments.length > 1) {\n Ember.assert(\"You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from \" + this.constructor.toString(), key !== 'id');\n } else {\n value = getAttr(this, options, key);\n }\n\n return value;\n // `data` is never set directly. However, it may be\n // invalidated from the state manager's setData\n // event.\n }).property('data').meta(meta);\n};\n\n\n})();\n//@ sourceURL=ember-data/system/model/attributes");minispade.register('ember-data/system/model/model', "(function() {minispade.require(\"ember-data/system/model/states\");\nminispade.require(\"ember-data/system/mixins/load_promise\");\n\nvar LoadPromise = DS.LoadPromise; // system/mixins/load_promise\n\nvar get = Ember.get, set = Ember.set, none = Ember.isNone, map = Ember.EnumerableUtils.map;\n\nvar retrieveFromCurrentState = Ember.computed(function(key) {\n return get(get(this, 'stateManager.currentState'), key);\n}).property('stateManager.currentState');\n\nDS.Model = Ember.Object.extend(Ember.Evented, LoadPromise, {\n isLoaded: retrieveFromCurrentState,\n isReloading: retrieveFromCurrentState,\n isDirty: retrieveFromCurrentState,\n isSaving: retrieveFromCurrentState,\n isDeleted: retrieveFromCurrentState,\n isError: retrieveFromCurrentState,\n isNew: retrieveFromCurrentState,\n isValid: retrieveFromCurrentState,\n\n clientId: null,\n id: null,\n transaction: null,\n stateManager: null,\n errors: null,\n\n /**\n Create a JSON representation of the record, using the serialization\n strategy of the store's adapter.\n\n Available options:\n\n * `includeId`: `true` if the record's ID should be included in the\n JSON representation.\n\n @param {Object} options\n @returns {Object} an object whose values are primitive JSON values only\n */\n serialize: function(options) {\n var store = get(this, 'store');\n return store.serialize(this, options);\n },\n\n didLoad: Ember.K,\n didReload: Ember.K,\n didUpdate: Ember.K,\n didCreate: Ember.K,\n didDelete: Ember.K,\n becameInvalid: Ember.K,\n becameError: Ember.K,\n\n data: Ember.computed(function() {\n if (!this._data) {\n this.materializeData();\n }\n\n return this._data;\n }).property(),\n\n materializeData: function() {\n this.send('materializingData');\n\n get(this, 'store').materializeData(this);\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n _data: null,\n\n init: function() {\n this._super();\n\n var stateManager = DS.StateManager.create({ record: this });\n set(this, 'stateManager', stateManager);\n\n this._setup();\n\n stateManager.goToState('empty');\n },\n\n _setup: function() {\n this._relationshipChanges = {};\n this._changesToSync = {};\n },\n\n send: function(name, context) {\n return get(this, 'stateManager').send(name, context);\n },\n\n withTransaction: function(fn) {\n var transaction = get(this, 'transaction');\n if (transaction) { fn(transaction); }\n },\n\n loadingData: function() {\n this.send('loadingData');\n },\n\n loadedData: function() {\n this.send('loadedData');\n },\n\n didChangeData: function() {\n this.send('didChangeData');\n },\n\n setProperty: function(key, value, oldValue) {\n this.send('setProperty', { key: key, value: value, oldValue: oldValue });\n },\n\n /**\n Reload the record from the adapter.\n\n This will only work if the record has already finished loading\n and has not yet been modified (`isLoaded` but not `isDirty`,\n or `isSaving`).\n */\n reload: function() {\n this.send('reloadRecord');\n },\n\n deleteRecord: function() {\n this.send('deleteRecord');\n },\n\n unloadRecord: function() {\n Ember.assert(\"You can only unload a loaded, non-dirty record.\", !get(this, 'isDirty'));\n\n this.send('unloadRecord');\n },\n\n clearRelationships: function() {\n this.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'belongsTo') {\n set(this, name, null);\n } else if (relationship.kind === 'hasMany') {\n get(this, name).clear();\n }\n }, this);\n },\n\n updateRecordArrays: function() {\n var store = get(this, 'store');\n if (store) {\n store.dataWasUpdated(this.constructor, get(this, '_reference'), this);\n }\n },\n\n /**\n If the adapter did not return a hash in response to a commit,\n merge the changed attributes and relationships into the existing\n saved data.\n */\n adapterDidCommit: function() {\n var attributes = get(this, 'data').attributes;\n\n get(this.constructor, 'attributes').forEach(function(name, meta) {\n attributes[name] = get(this, name);\n }, this);\n\n this.send('didCommit');\n this.updateRecordArraysLater();\n },\n\n adapterDidDirty: function() {\n this.send('becomeDirty');\n this.updateRecordArraysLater();\n },\n\n dataDidChange: Ember.observer(function() {\n var relationships = get(this.constructor, 'relationshipsByName');\n\n this.updateRecordArraysLater();\n\n relationships.forEach(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n this.hasManyDidChange(relationship.key);\n }\n }, this);\n\n this.send('finishedMaterializing');\n }, 'data'),\n\n hasManyDidChange: function(key) {\n var cachedValue = this.cacheFor(key);\n\n if (cachedValue) {\n var type = get(this.constructor, 'relationshipsByName').get(key).type;\n var store = get(this, 'store');\n var ids = this._data.hasMany[key] || [];\n\n var references = map(ids, function(id) {\n // if it was already a reference, return the reference\n if (typeof id === 'object') { return id; }\n return store.referenceForId(type, id);\n });\n\n set(cachedValue, 'content', Ember.A(references));\n }\n },\n\n updateRecordArraysLater: function() {\n Ember.run.once(this, this.updateRecordArrays);\n },\n\n setupData: function(prematerialized) {\n this._data = {\n attributes: {},\n belongsTo: {},\n hasMany: {},\n id: null\n };\n },\n\n materializeId: function(id) {\n set(this, 'id', id);\n },\n\n materializeAttributes: function(attributes) {\n Ember.assert(\"Must pass a hash of attributes to materializeAttributes\", !!attributes);\n this._data.attributes = attributes;\n },\n\n materializeAttribute: function(name, value) {\n this._data.attributes[name] = value;\n },\n\n materializeHasMany: function(name, ids) {\n this._data.hasMany[name] = ids;\n },\n\n materializeBelongsTo: function(name, id) {\n this._data.belongsTo[name] = id;\n },\n\n rollback: function() {\n this._setup();\n this.send('becameClean');\n\n this.suspendRelationshipObservers(function() {\n this.notifyPropertyChange('data');\n });\n },\n\n toStringExtension: function() {\n return get(this, 'id');\n },\n\n /**\n @private\n\n The goal of this method is to temporarily disable specific observers\n that take action in response to application changes.\n\n This allows the system to make changes (such as materialization and\n rollback) that should not trigger secondary behavior (such as setting an\n inverse relationship or marking records as dirty).\n\n The specific implementation will likely change as Ember proper provides\n better infrastructure for suspending groups of observers, and if Array\n observation becomes more unified with regular observers.\n */\n suspendRelationshipObservers: function(callback, binding) {\n var observers = get(this.constructor, 'relationshipNames').belongsTo;\n var self = this;\n\n try {\n this._suspendedRelationships = true;\n Ember._suspendObservers(self, observers, null, 'belongsToDidChange', function() {\n Ember._suspendBeforeObservers(self, observers, null, 'belongsToWillChange', function() {\n callback.call(binding || self);\n });\n });\n } finally {\n this._suspendedRelationships = false;\n }\n },\n\n becameInFlight: function() {\n },\n\n // FOR USE DURING COMMIT PROCESS\n\n adapterDidUpdateAttribute: function(attributeName, value) {\n\n // If a value is passed in, update the internal attributes and clear\n // the attribute cache so it picks up the new value. Otherwise,\n // collapse the current value into the internal attributes because\n // the adapter has acknowledged it.\n if (value !== undefined) {\n get(this, 'data.attributes')[attributeName] = value;\n this.notifyPropertyChange(attributeName);\n } else {\n value = get(this, attributeName);\n get(this, 'data.attributes')[attributeName] = value;\n }\n\n this.updateRecordArraysLater();\n },\n\n _reference: Ember.computed(function() {\n return get(this, 'store').referenceForClientId(get(this, 'clientId'));\n }),\n\n adapterDidInvalidate: function(errors) {\n this.send('becameInvalid', errors);\n },\n\n adapterDidError: function() {\n this.send('becameError');\n },\n\n /**\n @private\n\n Override the default event firing from Ember.Evented to\n also call methods with the given name.\n */\n trigger: function(name) {\n Ember.tryInvoke(this, name, [].slice.call(arguments, 1));\n this._super.apply(this, arguments);\n }\n});\n\n// Helper function to generate store aliases.\n// This returns a function that invokes the named alias\n// on the default store, but injects the class as the\n// first parameter.\nvar storeAlias = function(methodName) {\n return function() {\n var store = get(DS, 'defaultStore'),\n args = [].slice.call(arguments);\n\n args.unshift(this);\n return store[methodName].apply(store, args);\n };\n};\n\nDS.Model.reopenClass({\n isLoaded: storeAlias('recordIsLoaded'),\n find: storeAlias('find'),\n all: storeAlias('all'),\n filter: storeAlias('filter'),\n\n _create: DS.Model.create,\n\n create: function() {\n throw new Ember.Error(\"You should not call `create` on a model. Instead, call `createRecord` with the attributes you would like to set.\");\n },\n\n createRecord: storeAlias('createRecord')\n});\n\n})();\n//@ sourceURL=ember-data/system/model/model");minispade.register('ember-data/system/model/states', "(function() {var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor,\n once = Ember.run.once, arrayMap = Ember.ArrayPolyfills.map;\n\n/**\n This file encapsulates the various states that a record can transition\n through during its lifecycle.\n\n ### State Manager\n\n A record's state manager explicitly tracks what state a record is in\n at any given time. For instance, if a record is newly created and has\n not yet been sent to the adapter to be saved, it would be in the\n `created.uncommitted` state. If a record has had local modifications\n made to it that are in the process of being saved, the record would be\n in the `updated.inFlight` state. (These state paths will be explained\n in more detail below.)\n\n Events are sent by the record or its store to the record's state manager.\n How the state manager reacts to these events is dependent on which state\n it is in. In some states, certain events will be invalid and will cause\n an exception to be raised.\n\n States are hierarchical. For example, a record can be in the\n `deleted.start` state, then transition into the `deleted.inFlight` state.\n If a child state does not implement an event handler, the state manager\n will attempt to invoke the event on all parent states until the root state is\n reached. The state hierarchy of a record is described in terms of a path\n string. You can determine a record's current state by getting its manager's\n current state path:\n\n record.get('stateManager.currentPath');\n //=> \"created.uncommitted\"\n\n The `DS.Model` states are themselves stateless. What we mean is that,\n though each instance of a record also has a unique instance of a\n `DS.StateManager`, the hierarchical states that each of *those* points\n to is a shared data structure. For performance reasons, instead of each\n record getting its own copy of the hierarchy of states, each state\n manager points to this global, immutable shared instance. How does a\n state know which record it should be acting on? We pass a reference to\n the current state manager as the first parameter to every method invoked\n on a state.\n\n The state manager passed as the first parameter is where you should stash\n state about the record if needed; you should never store data on the state\n object itself. If you need access to the record being acted on, you can\n retrieve the state manager's `record` property. For example, if you had\n an event handler `myEvent`:\n\n myEvent: function(manager) {\n var record = manager.get('record');\n record.doSomething();\n }\n\n For more information about state managers in general, see the Ember.js\n documentation on `Ember.StateManager`.\n\n ### Events, Flags, and Transitions\n\n A state may implement zero or more events, flags, or transitions.\n\n #### Events\n\n Events are named functions that are invoked when sent to a record. The\n state manager will first look for a method with the given name on the\n current state. If no method is found, it will search the current state's\n parent, and then its grandparent, and so on until reaching the top of\n the hierarchy. If the root is reached without an event handler being found,\n an exception will be raised. This can be very helpful when debugging new\n features.\n\n Here's an example implementation of a state with a `myEvent` event handler:\n\n aState: DS.State.create({\n myEvent: function(manager, param) {\n console.log(\"Received myEvent with \"+param);\n }\n })\n\n To trigger this event:\n\n record.send('myEvent', 'foo');\n //=> \"Received myEvent with foo\"\n\n Note that an optional parameter can be sent to a record's `send()` method,\n which will be passed as the second parameter to the event handler.\n\n Events should transition to a different state if appropriate. This can be\n done by calling the state manager's `transitionTo()` method with a path to the\n desired state. The state manager will attempt to resolve the state path\n relative to the current state. If no state is found at that path, it will\n attempt to resolve it relative to the current state's parent, and then its\n parent, and so on until the root is reached. For example, imagine a hierarchy\n like this:\n\n * created\n * start <-- currentState\n * inFlight\n * updated\n * inFlight\n\n If we are currently in the `start` state, calling\n `transitionTo('inFlight')` would transition to the `created.inFlight` state,\n while calling `transitionTo('updated.inFlight')` would transition to\n the `updated.inFlight` state.\n\n Remember that *only events* should ever cause a state transition. You should\n never call `transitionTo()` from outside a state's event handler. If you are\n tempted to do so, create a new event and send that to the state manager.\n\n #### Flags\n\n Flags are Boolean values that can be used to introspect a record's current\n state in a more user-friendly way than examining its state path. For example,\n instead of doing this:\n\n var statePath = record.get('stateManager.currentPath');\n if (statePath === 'created.inFlight') {\n doSomething();\n }\n\n You can say:\n\n if (record.get('isNew') && record.get('isSaving')) {\n doSomething();\n }\n\n If your state does not set a value for a given flag, the value will\n be inherited from its parent (or the first place in the state hierarchy\n where it is defined).\n\n The current set of flags are defined below. If you want to add a new flag,\n in addition to the area below, you will also need to declare it in the\n `DS.Model` class.\n\n #### Transitions\n\n Transitions are like event handlers but are called automatically upon\n entering or exiting a state. To implement a transition, just call a method\n either `enter` or `exit`:\n\n myState: DS.State.create({\n // Gets called automatically when entering\n // this state.\n enter: function(manager) {\n console.log(\"Entered myState\");\n }\n })\n\n Note that enter and exit events are called once per transition. If the\n current state changes, but changes to another child state of the parent,\n the transition event on the parent will not be triggered.\n*/\n\nvar stateProperty = Ember.computed(function(key) {\n var parent = get(this, 'parentState');\n if (parent) {\n return get(parent, key);\n }\n}).property();\n\nvar isEmptyObject = function(object) {\n for (var name in object) {\n if (object.hasOwnProperty(name)) { return false; }\n }\n\n return true;\n};\n\nvar hasDefinedProperties = function(object) {\n for (var name in object) {\n if (object.hasOwnProperty(name) && object[name]) { return true; }\n }\n\n return false;\n};\n\nvar didChangeData = function(manager) {\n var record = get(manager, 'record');\n record.materializeData();\n};\n\nvar willSetProperty = function(manager, context) {\n context.oldValue = get(get(manager, 'record'), context.name);\n\n var change = DS.AttributeChange.createChange(context);\n get(manager, 'record')._changesToSync[context.attributeName] = change;\n};\n\nvar didSetProperty = function(manager, context) {\n var change = get(manager, 'record')._changesToSync[context.attributeName];\n change.value = get(get(manager, 'record'), context.name);\n change.sync();\n};\n\n// Whenever a property is set, recompute all dependent filters\nvar updateRecordArrays = function(manager) {\n var record = manager.get('record');\n record.updateRecordArraysLater();\n};\n\nDS.State = Ember.State.extend({\n isLoaded: stateProperty,\n isReloading: stateProperty,\n isDirty: stateProperty,\n isSaving: stateProperty,\n isDeleted: stateProperty,\n isError: stateProperty,\n isNew: stateProperty,\n isValid: stateProperty,\n\n // For states that are substates of a\n // DirtyState (updated or created), it is\n // useful to be able to determine which\n // type of dirty state it is.\n dirtyType: stateProperty\n});\n\n// Implementation notes:\n//\n// Each state has a boolean value for all of the following flags:\n//\n// * isLoaded: The record has a populated `data` property. When a\n// record is loaded via `store.find`, `isLoaded` is false\n// until the adapter sets it. When a record is created locally,\n// its `isLoaded` property is always true.\n// * isDirty: The record has local changes that have not yet been\n// saved by the adapter. This includes records that have been\n// created (but not yet saved) or deleted.\n// * isSaving: The record's transaction has been committed, but\n// the adapter has not yet acknowledged that the changes have\n// been persisted to the backend.\n// * isDeleted: The record was marked for deletion. When `isDeleted`\n// is true and `isDirty` is true, the record is deleted locally\n// but the deletion was not yet persisted. When `isSaving` is\n// true, the change is in-flight. When both `isDirty` and\n// `isSaving` are false, the change has persisted.\n// * isError: The adapter reported that it was unable to save\n// local changes to the backend. This may also result in the\n// record having its `isValid` property become false if the\n// adapter reported that server-side validations failed.\n// * isNew: The record was created on the client and the adapter\n// did not yet report that it was successfully saved.\n// * isValid: No client-side validations have failed and the\n// adapter did not report any server-side validation failures.\n\n// The dirty state is a abstract state whose functionality is\n// shared between the `created` and `updated` states.\n//\n// The deleted state shares the `isDirty` flag with the\n// subclasses of `DirtyState`, but with a very different\n// implementation.\n//\n// Dirty states have three child states:\n//\n// `uncommitted`: the store has not yet handed off the record\n// to be saved.\n// `inFlight`: the store has handed off the record to be saved,\n// but the adapter has not yet acknowledged success.\n// `invalid`: the record has invalid information and cannot be\n// send to the adapter yet.\nvar DirtyState = DS.State.extend({\n initialState: 'uncommitted',\n\n // FLAGS\n isDirty: true,\n\n // SUBSTATES\n\n // When a record first becomes dirty, it is `uncommitted`.\n // This means that there are local pending changes, but they\n // have not yet begun to be saved, and are not invalid.\n uncommitted: DS.State.extend({\n // TRANSITIONS\n enter: function(manager) {\n var dirtyType = get(this, 'dirtyType'),\n record = get(manager, 'record');\n\n record.withTransaction(function (t) {\n t.recordBecameDirty(dirtyType, record);\n });\n },\n\n // EVENTS\n willSetProperty: willSetProperty,\n didSetProperty: didSetProperty,\n\n becomeDirty: Ember.K,\n\n willCommit: function(manager) {\n manager.transitionTo('inFlight');\n },\n\n becameClean: function(manager) {\n var record = get(manager, 'record'),\n dirtyType = get(this, 'dirtyType');\n\n record.withTransaction(function(t) {\n t.recordBecameClean(dirtyType, record);\n });\n\n manager.transitionTo('loaded.materializing');\n },\n\n becameInvalid: function(manager) {\n var dirtyType = get(this, 'dirtyType'),\n record = get(manager, 'record');\n\n record.withTransaction(function (t) {\n t.recordBecameInFlight(dirtyType, record);\n });\n\n manager.transitionTo('invalid');\n },\n\n rollback: function(manager) {\n get(manager, 'record').rollback();\n }\n }),\n\n // Once a record has been handed off to the adapter to be\n // saved, it is in the 'in flight' state. Changes to the\n // record cannot be made during this window.\n inFlight: DS.State.extend({\n // FLAGS\n isSaving: true,\n\n // TRANSITIONS\n enter: function(manager) {\n var dirtyType = get(this, 'dirtyType'),\n record = get(manager, 'record');\n\n record.becameInFlight();\n\n record.withTransaction(function (t) {\n t.recordBecameInFlight(dirtyType, record);\n });\n },\n\n // EVENTS\n didCommit: function(manager) {\n var dirtyType = get(this, 'dirtyType'),\n record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordBecameClean('inflight', record);\n });\n\n manager.transitionTo('saved');\n manager.send('invokeLifecycleCallbacks', dirtyType);\n },\n\n becameInvalid: function(manager, errors) {\n var record = get(manager, 'record');\n\n set(record, 'errors', errors);\n\n manager.transitionTo('invalid');\n manager.send('invokeLifecycleCallbacks');\n },\n\n becameError: function(manager) {\n manager.transitionTo('error');\n manager.send('invokeLifecycleCallbacks');\n }\n }),\n\n // A record is in the `invalid` state when its client-side\n // invalidations have failed, or if the adapter has indicated\n // the the record failed server-side invalidations.\n invalid: DS.State.extend({\n // FLAGS\n isValid: false,\n\n exit: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function (t) {\n t.recordBecameClean('inflight', record);\n });\n },\n\n // EVENTS\n deleteRecord: function(manager) {\n manager.transitionTo('deleted');\n get(manager, 'record').clearRelationships();\n },\n\n willSetProperty: willSetProperty,\n\n didSetProperty: function(manager, context) {\n var record = get(manager, 'record'),\n errors = get(record, 'errors'),\n key = context.name;\n\n set(errors, key, null);\n\n if (!hasDefinedProperties(errors)) {\n manager.send('becameValid');\n }\n\n didSetProperty(manager, context);\n },\n\n becomeDirty: Ember.K,\n\n rollback: function(manager) {\n manager.send('becameValid');\n manager.send('rollback');\n },\n\n becameValid: function(manager) {\n manager.transitionTo('uncommitted');\n },\n\n invokeLifecycleCallbacks: function(manager) {\n var record = get(manager, 'record');\n record.trigger('becameInvalid', record);\n }\n })\n});\n\n// The created and updated states are created outside the state\n// chart so we can reopen their substates and add mixins as\n// necessary.\n\nvar createdState = DirtyState.create({\n dirtyType: 'created',\n\n // FLAGS\n isNew: true\n});\n\nvar updatedState = DirtyState.create({\n dirtyType: 'updated'\n});\n\ncreatedState.states.uncommitted.reopen({\n deleteRecord: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordIsMoving('created', record);\n });\n\n record.clearRelationships();\n manager.transitionTo('deleted.saved');\n }\n});\n\ncreatedState.states.uncommitted.reopen({\n rollback: function(manager) {\n this._super(manager);\n manager.transitionTo('deleted.saved');\n }\n});\n\nupdatedState.states.uncommitted.reopen({\n deleteRecord: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordIsMoving('updated', record);\n });\n\n manager.transitionTo('deleted');\n get(manager, 'record').clearRelationships();\n }\n});\n\nvar states = {\n rootState: Ember.State.create({\n // FLAGS\n isLoaded: false,\n isReloading: false,\n isDirty: false,\n isSaving: false,\n isDeleted: false,\n isError: false,\n isNew: false,\n isValid: true,\n\n // SUBSTATES\n\n // A record begins its lifecycle in the `empty` state.\n // If its data will come from the adapter, it will\n // transition into the `loading` state. Otherwise, if\n // the record is being created on the client, it will\n // transition into the `created` state.\n empty: DS.State.create({\n // EVENTS\n loadingData: function(manager) {\n manager.transitionTo('loading');\n },\n\n loadedData: function(manager) {\n manager.transitionTo('loaded.created');\n }\n }),\n\n // A record enters this state when the store askes\n // the adapter for its data. It remains in this state\n // until the adapter provides the requested data.\n //\n // Usually, this process is asynchronous, using an\n // XHR to retrieve the data.\n loading: DS.State.create({\n // EVENTS\n loadedData: didChangeData,\n\n materializingData: function(manager) {\n manager.transitionTo('loaded.materializing.firstTime');\n }\n }),\n\n // A record enters this state when its data is populated.\n // Most of a record's lifecycle is spent inside substates\n // of the `loaded` state.\n loaded: DS.State.create({\n initialState: 'saved',\n\n // FLAGS\n isLoaded: true,\n\n // SUBSTATES\n\n materializing: DS.State.create({\n // FLAGS\n isLoaded: false,\n\n // EVENTS\n willSetProperty: Ember.K,\n didSetProperty: Ember.K,\n\n didChangeData: didChangeData,\n\n finishedMaterializing: function(manager) {\n manager.transitionTo('loaded.saved');\n },\n\n // SUBSTATES\n firstTime: DS.State.create({\n exit: function(manager) {\n var record = get(manager, 'record');\n\n Ember.run.once(function() {\n record.trigger('didLoad');\n });\n }\n })\n }),\n\n reloading: DS.State.create({\n // FLAGS\n isReloading: true,\n\n // TRANSITIONS\n enter: function(manager) {\n var record = get(manager, 'record'),\n store = get(record, 'store');\n\n store.reloadRecord(record);\n },\n\n exit: function(manager) {\n var record = get(manager, 'record');\n\n once(record, 'trigger', 'didReload');\n },\n\n // EVENTS\n loadedData: didChangeData,\n\n materializingData: function(manager) {\n manager.transitionTo('loaded.materializing');\n }\n }),\n\n // If there are no local changes to a record, it remains\n // in the `saved` state.\n saved: DS.State.create({\n // EVENTS\n willSetProperty: willSetProperty,\n didSetProperty: didSetProperty,\n\n didChangeData: didChangeData,\n loadedData: didChangeData,\n\n reloadRecord: function(manager) {\n manager.transitionTo('loaded.reloading');\n },\n\n materializingData: function(manager) {\n manager.transitionTo('loaded.materializing');\n },\n\n becomeDirty: function(manager) {\n manager.transitionTo('updated');\n },\n\n deleteRecord: function(manager) {\n manager.transitionTo('deleted');\n get(manager, 'record').clearRelationships();\n },\n\n unloadRecord: function(manager) {\n manager.transitionTo('deleted.saved');\n get(manager, 'record').clearRelationships();\n },\n\n invokeLifecycleCallbacks: function(manager, dirtyType) {\n var record = get(manager, 'record');\n if (dirtyType === 'created') {\n record.trigger('didCreate', record);\n } else {\n record.trigger('didUpdate', record);\n }\n }\n }),\n\n // A record is in this state after it has been locally\n // created but before the adapter has indicated that\n // it has been saved.\n created: createdState,\n\n // A record is in this state if it has already been\n // saved to the server, but there are new local changes\n // that have not yet been saved.\n updated: updatedState\n }),\n\n // A record is in this state if it was deleted from the store.\n deleted: DS.State.create({\n initialState: 'uncommitted',\n dirtyType: 'deleted',\n\n // FLAGS\n isDeleted: true,\n isLoaded: true,\n isDirty: true,\n\n // TRANSITIONS\n setup: function(manager) {\n var record = get(manager, 'record'),\n store = get(record, 'store');\n\n store.removeFromRecordArrays(record);\n },\n\n // SUBSTATES\n\n // When a record is deleted, it enters the `start`\n // state. It will exit this state when the record's\n // transaction starts to commit.\n uncommitted: DS.State.create({\n // TRANSITIONS\n enter: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordBecameDirty('deleted', record);\n });\n },\n\n // EVENTS\n willCommit: function(manager) {\n manager.transitionTo('inFlight');\n },\n\n rollback: function(manager) {\n get(manager, 'record').rollback();\n },\n\n becomeDirty: Ember.K,\n\n becameClean: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordBecameClean('deleted', record);\n });\n\n manager.transitionTo('loaded.materializing');\n }\n }),\n\n // After a record's transaction is committing, but\n // before the adapter indicates that the deletion\n // has saved to the server, a record is in the\n // `inFlight` substate of `deleted`.\n inFlight: DS.State.create({\n // FLAGS\n isSaving: true,\n\n // TRANSITIONS\n enter: function(manager) {\n var record = get(manager, 'record');\n\n record.becameInFlight();\n\n record.withTransaction(function (t) {\n t.recordBecameInFlight('deleted', record);\n });\n },\n\n // EVENTS\n didCommit: function(manager) {\n var record = get(manager, 'record');\n\n record.withTransaction(function(t) {\n t.recordBecameClean('inflight', record);\n });\n\n manager.transitionTo('saved');\n\n manager.send('invokeLifecycleCallbacks');\n }\n }),\n\n // Once the adapter indicates that the deletion has\n // been saved, the record enters the `saved` substate\n // of `deleted`.\n saved: DS.State.create({\n // FLAGS\n isDirty: false,\n\n setup: function(manager) {\n var record = get(manager, 'record'),\n store = get(record, 'store');\n\n store.dematerializeRecord(record);\n },\n\n invokeLifecycleCallbacks: function(manager) {\n var record = get(manager, 'record');\n record.trigger('didDelete', record);\n }\n })\n }),\n\n // If the adapter indicates that there was an unknown\n // error saving a record, the record enters the `error`\n // state.\n error: DS.State.create({\n isError: true,\n\n // EVENTS\n\n invokeLifecycleCallbacks: function(manager) {\n var record = get(manager, 'record');\n record.trigger('becameError', record);\n }\n })\n })\n};\n\nDS.StateManager = Ember.StateManager.extend({\n record: null,\n initialState: 'rootState',\n states: states,\n unhandledEvent: function(manager, originalEvent) {\n var record = manager.get('record'),\n contexts = [].slice.call(arguments, 2),\n errorMessage;\n errorMessage = \"Attempted to handle event `\" + originalEvent + \"` \";\n errorMessage += \"on \" + record.toString() + \" while in state \";\n errorMessage += get(manager, 'currentState.path') + \". Called with \";\n errorMessage += arrayMap.call(contexts, function(context){\n return Ember.inspect(context);\n }).join(', ');\n throw new Ember.Error(errorMessage);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/model/states");minispade.register('ember-data/system/record_arrays', "(function() {minispade.require('ember-data/system/record_arrays/record_array');\nminispade.require('ember-data/system/record_arrays/filtered_record_array');\nminispade.require('ember-data/system/record_arrays/adapter_populated_record_array');\nminispade.require('ember-data/system/record_arrays/many_array');\n\n})();\n//@ sourceURL=ember-data/system/record_arrays");minispade.register('ember-data/system/record_arrays/adapter_populated_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\nvar get = Ember.get, set = Ember.set;\n\nDS.AdapterPopulatedRecordArray = DS.RecordArray.extend({\n query: null,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a server query (on \" + type + \") is immutable.\");\n },\n\n load: function(references) {\n var store = get(this, 'store'), type = get(this, 'type');\n\n this.beginPropertyChanges();\n set(this, 'content', Ember.A(references));\n set(this, 'isLoaded', true);\n this.endPropertyChanges();\n\n var self = this; \n // TODO: does triggering didLoad event should be the last action of the runLoop?\n Ember.run.once(function() {\n self.trigger('didLoad');\n });\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/adapter_populated_record_array");minispade.register('ember-data/system/record_arrays/filtered_record_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\nvar get = Ember.get;\n\nDS.FilteredRecordArray = DS.RecordArray.extend({\n filterFunction: null,\n isLoaded: true,\n\n replace: function() {\n var type = get(this, 'type').toString();\n throw new Error(\"The result of a client-side filter (on \" + type + \") is immutable.\");\n },\n\n updateFilter: Ember.observer(function() {\n var store = get(this, 'store');\n store.updateRecordArrayFilter(this, get(this, 'type'), get(this, 'filterFunction'));\n }, 'filterFunction')\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/filtered_record_array");minispade.register('ember-data/system/record_arrays/many_array', "(function() {minispade.require(\"ember-data/system/record_arrays/record_array\");\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n A ManyArray is a RecordArray that represents the contents of a has-many\n relationship.\n\n The ManyArray is instantiated lazily the first time the relationship is\n requested.\n\n ### Inverses\n\n Often, the relationships in Ember Data applications will have\n an inverse. For example, imagine the following models are\n defined:\n\n App.Post = DS.Model.extend({\n comments: DS.hasMany('App.Comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('App.Post')\n });\n\n If you created a new instance of `App.Post` and added\n a `App.Comment` record to its `comments` has-many\n relationship, you would expect the comment's `post`\n property to be set to the post that contained\n the has-many.\n\n We call the record to which a relationship belongs the\n relationship's _owner_.\n*/\nDS.ManyArray = DS.RecordArray.extend({\n init: function() {\n this._super.apply(this, arguments);\n this._changesToSync = Ember.OrderedSet.create();\n },\n\n /**\n @private\n\n The record to which this relationship belongs.\n\n @property {DS.Model}\n */\n owner: null,\n\n // LOADING STATE\n\n isLoaded: false,\n\n loadingRecordsCount: function(count) {\n this.loadingRecordsCount = count;\n },\n\n loadedRecord: function() {\n this.loadingRecordsCount--;\n if (this.loadingRecordsCount === 0) {\n set(this, 'isLoaded', true);\n this.trigger('didLoad');\n }\n },\n\n fetch: function() {\n var references = get(this, 'content'),\n store = get(this, 'store'),\n type = get(this, 'type'),\n owner = get(this, 'owner');\n\n store.fetchUnloadedReferences(type, references, owner);\n },\n\n // Overrides Ember.Array's replace method to implement\n replaceContent: function(index, removed, added) {\n // Map the array of record objects into an array of client ids.\n added = added.map(function(record) {\n Ember.assert(\"You can only add records of \" + (get(this, 'type') && get(this, 'type').toString()) + \" to this relationship.\", !get(this, 'type') || (get(this, 'type') === record.constructor));\n return get(record, '_reference');\n }, this);\n\n this._super(index, removed, added);\n },\n\n arrangedContentDidChange: function() {\n this.fetch();\n },\n\n arrayContentWillChange: function(index, removed, added) {\n var owner = get(this, 'owner'),\n name = get(this, 'name');\n\n if (!owner._suspendedRelationships) {\n // This code is the first half of code that continues inside\n // of arrayContentDidChange. It gets or creates a change from\n // the child object, adds the current owner as the old\n // parent if this is the first time the object was removed\n // from a ManyArray, and sets `newParent` to null.\n //\n // Later, if the object is added to another ManyArray,\n // the `arrayContentDidChange` will set `newParent` on\n // the change.\n for (var i=index; i<index+removed; i++) {\n var reference = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner.get('_reference'), reference, get(this, 'store'), {\n parentType: owner.constructor,\n changeType: \"remove\",\n kind: \"hasMany\",\n key: name\n });\n\n this._changesToSync.add(change);\n }\n }\n\n return this._super.apply(this, arguments);\n },\n\n arrayContentDidChange: function(index, removed, added) {\n this._super.apply(this, arguments);\n\n var owner = get(this, 'owner'),\n name = get(this, 'name'),\n store = get(this, 'store');\n\n if (!owner._suspendedRelationships) {\n // This code is the second half of code that started in\n // `arrayContentWillChange`. It gets or creates a change\n // from the child object, and adds the current owner as\n // the new parent.\n for (var i=index; i<index+added; i++) {\n var reference = get(this, 'content').objectAt(i);\n\n var change = DS.RelationshipChange.createChange(owner.get('_reference'), reference, store, {\n parentType: owner.constructor,\n changeType: \"add\",\n kind:\"hasMany\",\n key: name\n });\n change.hasManyName = name;\n\n this._changesToSync.add(change);\n }\n\n // We wait until the array has finished being\n // mutated before syncing the OneToManyChanges created\n // in arrayContentWillChange, so that the array\n // membership test in the sync() logic operates\n // on the final results.\n this._changesToSync.forEach(function(change) {\n change.sync();\n });\n DS.OneToManyChange.ensureSameTransaction(this._changesToSync, store);\n this._changesToSync.clear();\n }\n },\n\n // Create a child record within the owner\n createRecord: function(hash, transaction) {\n var owner = get(this, 'owner'),\n store = get(owner, 'store'),\n type = get(this, 'type'),\n record;\n\n transaction = transaction || get(owner, 'transaction');\n\n record = store.createRecord.call(store, type, hash, transaction);\n this.pushObject(record);\n\n return record;\n }\n\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/many_array");minispade.register('ember-data/system/record_arrays/record_array', "(function() {minispade.require(\"ember-data/system/mixins/load_promise\");\n\nvar get = Ember.get, set = Ember.set;\n\nvar LoadPromise = DS.LoadPromise; // system/mixins/load_promise\n\n/**\n A record array is an array that contains records of a certain type. The record\n array materializes records as needed when they are retrieved for the first\n time. You should not create record arrays yourself. Instead, an instance of\n DS.RecordArray or its subclasses will be returned by your application's store\n in response to queries.\n*/\n\nDS.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, LoadPromise, {\n /**\n The model type contained by this record array.\n\n @type DS.Model\n */\n type: null,\n\n // The array of client ids backing the record array. When a\n // record is requested from the record array, the record\n // for the client id at the same index is materialized, if\n // necessary, by the store.\n content: null,\n\n isLoaded: false,\n isUpdating: false,\n\n // The store that created this record array.\n store: null,\n\n objectAtContent: function(index) {\n var content = get(this, 'content'),\n reference = content.objectAt(index),\n store = get(this, 'store');\n\n if (reference) {\n return store.recordForReference(reference);\n }\n },\n\n materializedObjectAt: function(index) {\n var reference = get(this, 'content').objectAt(index);\n if (!reference) { return; }\n\n if (get(this, 'store').recordIsMaterialized(reference)) {\n return this.objectAt(index);\n }\n },\n\n update: function() {\n if (get(this, 'isUpdating')) { return; }\n\n var store = get(this, 'store'),\n type = get(this, 'type');\n\n store.fetchAll(type, this);\n },\n\n addReference: function(reference) {\n get(this, 'content').addObject(reference);\n },\n\n removeReference: function(reference) {\n get(this, 'content').removeObject(reference);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/record_arrays/record_array");minispade.register('ember-data/system/relationships', "(function() {minispade.require(\"ember-data/system/relationships/belongs_to\");\nminispade.require(\"ember-data/system/relationships/has_many\");\nminispade.require(\"ember-data/system/relationships/ext\");\nminispade.require(\"ember-data/system/relationships/one_to_many_change\");\n\n})();\n//@ sourceURL=ember-data/system/relationships");minispade.register('ember-data/system/relationships/belongs_to', "(function() {var get = Ember.get, set = Ember.set,\n none = Ember.isNone;\n\nDS.belongsTo = function(type, options) {\n Ember.assert(\"The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)\", !!type && (typeof type === 'string' || DS.Model.detect(type)));\n\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' };\n\n return Ember.computed(function(key, value) {\n if (arguments.length === 2) {\n return value === undefined ? null : value;\n }\n\n var data = get(this, 'data').belongsTo,\n store = get(this, 'store'), id;\n\n if (typeof type === 'string') {\n type = get(this, type, false) || get(Ember.lookup, type);\n }\n\n id = data[key];\n\n if(!id) {\n return null;\n } else if (typeof id === 'object') {\n return store.recordForReference(id);\n } else {\n return store.find(type, id);\n }\n }).property('data').meta(meta);\n};\n\n/**\n These observers observe all `belongsTo` relationships on the record. See\n `relationships/ext` to see how these observers get their dependencies.\n\n*/\n\nDS.Model.reopen({\n /** @private */\n belongsToWillChange: Ember.beforeObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var oldParent = get(record, key);\n\n var childReference = get(record, '_reference'),\n store = get(record, 'store');\n if (oldParent){\n var change = DS.RelationshipChange.createChange(childReference, get(oldParent, '_reference'), store, { key: key, kind:\"belongsTo\", changeType: \"remove\" });\n change.sync();\n this._changesToSync[key] = change;\n }\n }\n }),\n\n /** @private */\n belongsToDidChange: Ember.immediateObserver(function(record, key) {\n if (get(record, 'isLoaded')) {\n var newParent = get(record, key);\n if(newParent){\n var childReference = get(record, '_reference'),\n store = get(record, 'store');\n var change = DS.RelationshipChange.createChange(childReference, get(newParent, '_reference'), store, { key: key, kind:\"belongsTo\", changeType: \"add\" });\n change.sync();\n if(this._changesToSync[key]){\n DS.OneToManyChange.ensureSameTransaction([change, this._changesToSync[key]], store);\n }\n }\n }\n delete this._changesToSync[key];\n })\n});\n\n})();\n//@ sourceURL=ember-data/system/relationships/belongs_to");minispade.register('ember-data/system/relationships/ext', "(function() {var get = Ember.get, set = Ember.set;\n\n/**\n @private\n\n This file defines several extensions to the base `DS.Model` class that\n add support for one-to-many relationships.\n*/\n\nDS.Model.reopen({\n // This Ember.js hook allows an object to be notified when a property\n // is defined.\n //\n // In this case, we use it to be notified when an Ember Data user defines a\n // belongs-to relationship. In that case, we need to set up observers for\n // each one, allowing us to track relationship changes and automatically\n // reflect changes in the inverse has-many array.\n //\n // This hook passes the class being set up, as well as the key and value\n // being defined. So, for example, when the user does this:\n //\n // DS.Model.extend({\n // parent: DS.belongsTo(App.User)\n // });\n //\n // This hook would be called with \"parent\" as the key and the computed\n // property returned by `DS.belongsTo` as the value.\n didDefineProperty: function(proto, key, value) {\n // Check if the value being set is a computed property.\n if (value instanceof Ember.Descriptor) {\n\n // If it is, get the metadata for the relationship. This is\n // populated by the `DS.belongsTo` helper when it is creating\n // the computed property.\n var meta = value.meta();\n\n if (meta.isRelationship && meta.kind === 'belongsTo') {\n Ember.addObserver(proto, key, null, 'belongsToDidChange');\n Ember.addBeforeObserver(proto, key, null, 'belongsToWillChange');\n }\n\n if (meta.isAttribute) {\n Ember.addObserver(proto, key, null, 'attributeDidChange');\n Ember.addBeforeObserver(proto, key, null, 'attributeWillChange');\n }\n\n meta.parentType = proto.constructor;\n }\n }\n});\n\n/**\n These DS.Model extensions add class methods that provide relationship\n introspection abilities about relationships.\n\n A note about the computed properties contained here:\n\n **These properties are effectively sealed once called for the first time.**\n To avoid repeatedly doing expensive iteration over a model's fields, these\n values are computed once and then cached for the remainder of the runtime of\n your application.\n\n If your application needs to modify a class after its initial definition\n (for example, using `reopen()` to add additional attributes), make sure you\n do it before using your model with the store, which uses these properties\n extensively.\n*/\n\nDS.Model.reopenClass({\n /**\n For a given relationship name, returns the model type of the relationship.\n\n For example, if you define a model like this:\n\n App.Post = DS.Model.extend({\n comments: DS.hasMany(App.Comment)\n });\n\n Calling `App.Post.typeForRelationship('comments')` will return `App.Comment`.\n\n @param {String} name the name of the relationship\n @return {subclass of DS.Model} the type of the relationship, or undefined\n */\n typeForRelationship: function(name) {\n var relationship = get(this, 'relationshipsByName').get(name);\n return relationship && relationship.type;\n },\n\n /**\n The model's relationships as a map, keyed on the type of the\n relationship. The value of each entry is an array containing a descriptor\n for each relationship with that type, describing the name of the relationship\n as well as the type.\n\n For example, given the following model definition:\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany(App.User),\n owner: DS.belongsTo(App.User),\n\n posts: DS.hasMany(App.Post)\n });\n\n This computed property would return a map describing these\n relationships, like this:\n\n var relationships = Ember.get(App.Blog, 'relationships');\n associatons.get(App.User);\n //=> [ { name: 'users', kind: 'hasMany' },\n // { name: 'owner', kind: 'belongsTo' } ]\n relationships.get(App.Post);\n //=> [ { name: 'posts', kind: 'hasMany' } ]\n\n @type Ember.Map\n @readOnly\n */\n relationships: Ember.computed(function() {\n var map = new Ember.MapWithDefault({\n defaultValue: function() { return []; }\n });\n\n // Loop through each computed property on the class\n this.eachComputedProperty(function(name, meta) {\n\n // If the computed property is a relationship, add\n // it to the map.\n if (meta.isRelationship) {\n if (typeof meta.type === 'string') {\n meta.type = Ember.get(Ember.lookup, meta.type);\n }\n\n var relationshipsForType = map.get(meta.type);\n\n relationshipsForType.push({ name: name, kind: meta.kind });\n }\n });\n\n return map;\n }),\n\n /**\n A hash containing lists of the model's relationships, grouped\n by the relationship kind. For example, given a model with this\n definition:\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany(App.User),\n owner: DS.belongsTo(App.User),\n\n posts: DS.hasMany(App.Post)\n });\n\n This property would contain the following:\n\n var relationshipNames = Ember.get(App.Blog, 'relationshipNames');\n relationshipNames.hasMany;\n //=> ['users', 'posts']\n relationshipNames.belongsTo;\n //=> ['owner']\n\n @type Object\n @readOnly\n */\n relationshipNames: Ember.computed(function() {\n var names = { hasMany: [], belongsTo: [] };\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n names[meta.kind].push(name);\n }\n });\n\n return names;\n }),\n\n /**\n A map whose keys are the relationships of a model and whose values are\n relationship descriptors.\n\n For example, given a model with this\n definition:\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany(App.User),\n owner: DS.belongsTo(App.User),\n\n posts: DS.hasMany(App.Post)\n });\n\n This property would contain the following:\n\n var relationshipsByName = Ember.get(App.Blog, 'relationshipsByName');\n relationshipsByName.get('users');\n //=> { key: 'users', kind: 'hasMany', type: App.User }\n relationshipsByName.get('owner');\n //=> { key: 'owner', kind: 'belongsTo', type: App.User }\n\n @type Ember.Map\n @readOnly\n */\n relationshipsByName: Ember.computed(function() {\n var map = Ember.Map.create(), type;\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n meta.key = name;\n type = meta.type;\n\n if (typeof type === 'string') {\n type = get(this, type, false) || get(Ember.lookup, type);\n meta.type = type;\n }\n\n map.set(name, meta);\n }\n });\n\n return map;\n }),\n\n /**\n A map whose keys are the fields of the model and whose values are strings\n describing the kind of the field. A model's fields are the union of all of its\n attributes and relationships.\n\n For example:\n\n App.Blog = DS.Model.extend({\n users: DS.hasMany(App.User),\n owner: DS.belongsTo(App.User),\n\n posts: DS.hasMany(App.Post),\n\n title: DS.attr('string')\n });\n\n var fields = Ember.get(App.Blog, 'fields');\n fields.forEach(function(field, kind) {\n console.log(field, kind);\n });\n\n // prints:\n // users, hasMany\n // owner, belongsTo\n // posts, hasMany\n // title, attribute\n\n @type Ember.Map\n @readOnly\n */\n fields: Ember.computed(function() {\n var map = Ember.Map.create(), type;\n\n this.eachComputedProperty(function(name, meta) {\n if (meta.isRelationship) {\n map.set(name, meta.kind);\n } else if (meta.isAttribute) {\n map.set(name, 'attribute');\n }\n });\n\n return map;\n }),\n\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n get(this, 'relationshipsByName').forEach(function(name, relationship) {\n callback.call(binding, name, relationship);\n });\n }\n});\n\nDS.Model.reopen({\n /**\n Given a callback, iterates over each of the relationships in the model,\n invoking the callback with the name of each relationship and its relationship\n descriptor.\n\n @param {Function} callback the callback to invoke\n @param {any} binding the value to which the callback's `this` should be bound\n */\n eachRelationship: function(callback, binding) {\n this.constructor.eachRelationship(callback, binding);\n }\n});\n\n/**\n @private\n\n Helper method to look up the name of the inverse of a relationship.\n\n In a has-many relationship, there are always two sides: the `belongsTo` side\n and the `hasMany` side. When one side changes, the other side should be updated\n automatically.\n\n Given a model, the model of the inverse, and the kind of the relationship, this\n helper returns the name of the relationship on the inverse.\n\n For example, imagine the following two associated models:\n\n App.Post = DS.Model.extend({\n comments: DS.hasMany('App.Comment')\n });\n\n App.Comment = DS.Model.extend({\n post: DS.belongsTo('App.Post')\n });\n\n If the `post` property of a `Comment` was modified, Ember Data would invoke\n this helper like this:\n\n DS._inverseNameFor(App.Comment, App.Post, 'hasMany');\n //=> 'comments'\n\n Ember Data uses the name of the relationship returned to reflect the changed\n relationship on the other side.\n*/\nDS._inverseRelationshipFor = function(modelType, inverseModelType) {\n var relationshipMap = get(modelType, 'relationships'),\n possibleRelationships = relationshipMap.get(inverseModelType),\n possible, actual, oldValue;\n\n if (!possibleRelationships) { return; }\n if (possibleRelationships.length > 1) { return; }\n return possibleRelationships[0];\n};\n\n/**\n @private\n\n Given a model and a relationship name, returns the model type of\n the named relationship.\n\n App.Post = DS.Model.extend({\n comments: DS.hasMany('App.Comment')\n });\n\n DS._inverseTypeFor(App.Post, 'comments');\n //=> App.Comment\n @param {DS.Model class} modelType\n @param {String} relationshipName\n @return {DS.Model class}\n*/\nDS._inverseTypeFor = function(modelType, relationshipName) {\n var relationships = get(modelType, 'relationshipsByName'),\n relationship = relationships.get(relationshipName);\n\n if (relationship) { return relationship.type; }\n};\n\n})();\n//@ sourceURL=ember-data/system/relationships/ext");minispade.register('ember-data/system/relationships/has_many', "(function() {var get = Ember.get, set = Ember.set;\nminispade.require(\"ember-data/system/model/model\");\n\nvar hasRelationship = function(type, options) {\n options = options || {};\n\n var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' };\n\n return Ember.computed(function(key, value) {\n var data = get(this, 'data').hasMany,\n store = get(this, 'store'),\n ids, relationship;\n\n if (typeof type === 'string') {\n type = get(this, type, false) || get(Ember.lookup, type);\n }\n\n ids = data[key];\n relationship = store.findMany(type, ids || [], this, meta);\n set(relationship, 'owner', this);\n set(relationship, 'name', key);\n\n return relationship;\n }).property().meta(meta);\n};\n\nDS.hasMany = function(type, options) {\n Ember.assert(\"The type passed to DS.hasMany must be defined\", !!type);\n return hasRelationship(type, options);\n};\n\n})();\n//@ sourceURL=ember-data/system/relationships/has_many");minispade.register('ember-data/system/relationships/one_to_many_change', "(function() {var get = Ember.get, set = Ember.set;\nvar forEach = Ember.EnumerableUtils.forEach;\n\nDS.RelationshipChange = function(options) {\n this.parentReference = options.parentReference;\n this.childReference = options.childReference;\n this.firstRecordReference = options.firstRecordReference;\n this.firstRecordKind = options.firstRecordKind;\n this.firstRecordName = options.firstRecordName;\n this.secondRecordReference = options.secondRecordReference;\n this.secondRecordKind = options.secondRecordKind;\n this.secondRecordName = options.secondRecordName;\n this.store = options.store;\n this.committed = {};\n this.changeType = options.changeType;\n};\n\nDS.RelationshipChangeAdd = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\nDS.RelationshipChangeRemove = function(options){\n DS.RelationshipChange.call(this, options);\n};\n\n/** @private */\nDS.RelationshipChange.create = function(options) {\n return new DS.RelationshipChange(options);\n};\n\n/** @private */\nDS.RelationshipChangeAdd.create = function(options) {\n return new DS.RelationshipChangeAdd(options);\n};\n\n/** @private */\nDS.RelationshipChangeRemove.create = function(options) {\n return new DS.RelationshipChangeRemove(options);\n};\n\nDS.OneToManyChange = {};\nDS.OneToNoneChange = {};\nDS.ManyToNoneChange = {};\nDS.OneToOneChange = {};\nDS.ManyToManyChange = {};\n\nDS.RelationshipChange._createChange = function(options){\n if(options.changeType === \"add\"){\n return DS.RelationshipChangeAdd.create(options);\n }\n if(options.changeType === \"remove\"){\n return DS.RelationshipChangeRemove.create(options);\n }\n};\n\n\nDS.RelationshipChange.determineRelationshipType = function(recordType, knownSide){\n var knownKey = knownSide.key, key, type, otherContainerType,assoc;\n var knownContainerType = knownSide.kind;\n var options = recordType.metaForProperty(knownKey).options;\n var otherType = DS._inverseTypeFor(recordType, knownKey);\n\n if(options.inverse){\n key = options.inverse;\n otherContainerType = get(otherType, 'relationshipsByName').get(key).kind; \n } \n else if(assoc = DS._inverseRelationshipFor(otherType, recordType)){\n key = assoc.name;\n otherContainerType = assoc.kind;\n } \n if(!key){\n return knownContainerType === \"belongsTo\" ? \"oneToNone\" : \"manyToNone\";\n }\n else{\n if(otherContainerType === \"belongsTo\"){\n return knownContainerType === \"belongsTo\" ? \"oneToOne\" : \"manyToOne\";\n }\n else{\n return knownContainerType === \"belongsTo\" ? \"oneToMany\" : \"manyToMany\";\n }\n } \n \n};\n\nDS.RelationshipChange.createChange = function(firstRecordReference, secondRecordReference, store, options){\n // Get the type of the child based on the child's client ID\n var firstRecordType = firstRecordReference.type, key, changeType;\n changeType = DS.RelationshipChange.determineRelationshipType(firstRecordType, options);\n if (changeType === \"oneToMany\"){\n return DS.OneToManyChange.createChange(firstRecordReference, secondRecordReference, store, options);\n }\n else if (changeType === \"manyToOne\"){\n return DS.OneToManyChange.createChange(secondRecordReference, firstRecordReference, store, options);\n }\n else if (changeType === \"oneToNone\"){\n return DS.OneToNoneChange.createChange(firstRecordReference, secondRecordReference, store, options);\n }\n else if (changeType === \"manyToNone\"){\n return DS.ManyToNoneChange.createChange(firstRecordReference, secondRecordReference, store, options);\n }\n else if (changeType === \"oneToOne\"){\n return DS.OneToOneChange.createChange(firstRecordReference, secondRecordReference, store, options);\n }\n else if (changeType === \"manyToMany\"){\n return DS.ManyToManyChange.createChange(firstRecordReference, secondRecordReference, store, options);\n }\n};\n\n/** @private */\nDS.OneToNoneChange.createChange = function(childReference, parentReference, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentReference: parentReference,\n childReference: childReference,\n firstRecordReference: childReference,\n store: store,\n changeType: options.changeType,\n firstRecordName: key,\n firstRecordKind: \"belongsTo\"\n });\n\n store.addRelationshipChangeFor(childReference, key, parentReference, null, change);\n\n return change;\n};\n\n/** @private */\nDS.ManyToNoneChange.createChange = function(childReference, parentReference, store, options) {\n var key = options.key;\n var change = DS.RelationshipChange._createChange({\n parentReference: childReference,\n childReference: parentReference,\n secondRecordReference: childReference,\n store: store,\n changeType: options.changeType,\n secondRecordName: options.key,\n secondRecordKind: \"hasMany\"\n });\n\n store.addRelationshipChangeFor(childReference, key, parentReference, null, change);\n return change;\n};\n\n\n/** @private */\nDS.ManyToManyChange.createChange = function(childReference, parentReference, store, options) {\n // Get the type of the child based on the child's client ID\n var childType = childReference.type, key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n key = options.key;\n\n var change = DS.RelationshipChange._createChange({\n parentReference: parentReference,\n childReference: childReference,\n firstRecordReference: childReference,\n secondRecordReference: parentReference,\n firstRecordKind: \"hasMany\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childReference, key, parentReference, null, change);\n\n\n return change;\n};\n\n/** @private */\nDS.OneToOneChange.createChange = function(childReference, parentReference, store, options) {\n // Get the type of the child based on the child's client ID\n var childType = childReference.type, key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = inverseBelongsToName(options.parentType, childType, options.key);\n //DS.OneToOneChange.maintainInvariant( options, store, childReference, key );\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentReference: parentReference,\n childReference: childReference,\n firstRecordReference: childReference,\n secondRecordReference: parentReference,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"belongsTo\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childReference, key, parentReference, null, change);\n\n\n return change;\n};\n\nDS.OneToOneChange.maintainInvariant = function(options, store, childReference, key){\n if (options.changeType === \"add\" && store.recordIsMaterialized(childReference)) {\n var child = store.recordForReference(childReference);\n var oldParent = get(child, key);\n if (oldParent){\n var correspondingChange = DS.OneToOneChange.createChange(childReference, oldParent.get('_reference'), store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childReference, key, options.parentReference , null, correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\n/** @private */\nDS.OneToManyChange.createChange = function(childReference, parentReference, store, options) {\n // Get the type of the child based on the child's client ID\n var childType = childReference.type, key;\n\n // If the name of the belongsTo side of the relationship is specified,\n // use that\n // If the type of the parent is specified, look it up on the child's type\n // definition.\n if (options.parentType) {\n key = inverseBelongsToName(options.parentType, childType, options.key);\n DS.OneToManyChange.maintainInvariant( options, store, childReference, key );\n } else if (options.key) {\n key = options.key;\n } else {\n Ember.assert(\"You must pass either a parentType or belongsToName option to OneToManyChange.forChildAndParent\", false);\n }\n\n var change = DS.RelationshipChange._createChange({\n parentReference: parentReference,\n childReference: childReference,\n firstRecordReference: childReference,\n secondRecordReference: parentReference,\n firstRecordKind: \"belongsTo\",\n secondRecordKind: \"hasMany\",\n store: store,\n changeType: options.changeType,\n firstRecordName: key\n });\n\n store.addRelationshipChangeFor(childReference, key, parentReference, null, change);\n\n\n return change;\n};\n\n\nDS.OneToManyChange.maintainInvariant = function(options, store, childReference, key){\n if (options.changeType === \"add\" && store.recordIsMaterialized(childReference)) {\n var child = store.recordForReference(childReference);\n var oldParent = get(child, key);\n if (oldParent){\n var correspondingChange = DS.OneToManyChange.createChange(childReference, oldParent.get('_reference'), store, {\n parentType: options.parentType,\n hasManyName: options.hasManyName,\n changeType: \"remove\",\n key: options.key\n });\n store.addRelationshipChangeFor(childReference, key, options.parentReference , null, correspondingChange);\n correspondingChange.sync();\n }\n }\n};\n\nDS.OneToManyChange.ensureSameTransaction = function(changes, store){\n var records = Ember.A();\n forEach(changes, function(change){\n records.addObject(change.getSecondRecord());\n records.addObject(change.getFirstRecord());\n });\n var transaction = store.ensureSameTransaction(records);\n forEach(changes, function(change){\n change.transaction = transaction;\n });\n};\n\nDS.RelationshipChange.prototype = {\n\n getSecondRecordName: function() {\n var name = this.secondRecordName, store = this.store, parent;\n\n if (!name) {\n parent = this.secondRecordReference;\n if (!parent) { return; }\n\n var childType = this.firstRecordReference.type;\n var inverseType = DS._inverseTypeFor(childType, this.firstRecordName);\n name = inverseHasManyName(inverseType, childType, this.firstRecordName);\n this.secondRecordName = name;\n }\n\n return name;\n },\n\n /**\n Get the name of the relationship on the belongsTo side.\n\n @returns {String}\n */\n getFirstRecordName: function() {\n var name = this.firstRecordName, store = this.store, parent, child;\n\n if (!name) {\n parent = this.secondRecordReference;\n child = this.firstRecordReference;\n if (!(child && parent)) { return; }\n\n name = DS._inverseRelationshipFor(child.type, parent.type).name;\n\n this.firstRecordName = name;\n }\n\n return name;\n },\n\n /** @private */\n destroy: function() {\n var childReference = this.childReference,\n belongsToName = this.getFirstRecordName(),\n hasManyName = this.getSecondRecordName(),\n store = this.store,\n child, oldParent, newParent, lastParent, transaction;\n\n store.removeRelationshipChangeFor(childReference, belongsToName, this.parentReference, hasManyName, this.changeType);\n\n if (transaction = this.transaction) {\n transaction.relationshipBecameClean(this);\n }\n },\n\n /** @private */\n getByReference: function(reference) {\n var store = this.store;\n\n // return null or undefined if the original reference was null or undefined\n if (!reference) { return reference; }\n\n if (store.recordIsMaterialized(reference)) {\n return store.recordForReference(reference);\n }\n },\n\n getSecondRecord: function(){\n return this.getByReference(this.secondRecordReference);\n },\n\n /** @private */\n getFirstRecord: function() {\n return this.getByReference(this.firstRecordReference);\n },\n\n /**\n @private\n\n Make sure that all three parts of the relationship change are part of\n the same transaction. If any of the three records is clean and in the\n default transaction, and the rest are in a different transaction, move\n them all into that transaction.\n */\n ensureSameTransaction: function() {\n var child = this.getFirstRecord(),\n parentRecord = this.getSecondRecord();\n\n var transaction = this.store.ensureSameTransaction([child, parentRecord]);\n\n this.transaction = transaction;\n return transaction;\n },\n\n callChangeEvents: function(){\n var hasManyName = this.getSecondRecordName(),\n belongsToName = this.getFirstRecordName(),\n child = this.getFirstRecord(),\n parentRecord = this.getSecondRecord();\n\n var dirtySet = new Ember.OrderedSet();\n\n // TODO: This implementation causes a race condition in key-value\n // stores. The fix involves buffering changes that happen while\n // a record is loading. A similar fix is required for other parts\n // of ember-data, and should be done as new infrastructure, not\n // a one-off hack. [tomhuda]\n if (parentRecord && get(parentRecord, 'isLoaded')) {\n this.store.recordHasManyDidChange(dirtySet, parentRecord, this);\n }\n\n if (child) {\n this.store.recordBelongsToDidChange(dirtySet, child, this);\n }\n\n dirtySet.forEach(function(record) {\n record.adapterDidDirty();\n });\n },\n\n coalesce: function(){\n var relationshipPairs = this.store.relationshipChangePairsFor(this.firstRecordReference);\n forEach(relationshipPairs, function(pair){\n var addedChange = pair[\"add\"];\n var removedChange = pair[\"remove\"];\n if(addedChange && removedChange) {\n addedChange.destroy();\n removedChange.destroy();\n }\n });\n }\n};\n\nDS.RelationshipChangeAdd.prototype = Ember.create(DS.RelationshipChange.create({}));\nDS.RelationshipChangeRemove.prototype = Ember.create(DS.RelationshipChange.create({}));\n\nDS.RelationshipChangeAdd.prototype.changeType = \"add\";\nDS.RelationshipChangeAdd.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n var transaction = this.ensureSameTransaction();\n transaction.relationshipBecameDirty(this);\n\n this.callChangeEvents();\n\n if (secondRecord && firstRecord) {\n if(this.secondRecordKind === \"belongsTo\"){\n secondRecord.suspendRelationshipObservers(function(){\n set(secondRecord, secondRecordName, firstRecord);\n });\n\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n get(secondRecord, secondRecordName).addObject(firstRecord);\n });\n }\n }\n\n if (firstRecord && secondRecord && get(firstRecord, firstRecordName) !== secondRecord) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, secondRecord);\n });\n }\n else if(this.firstdRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n get(firstRecord, firstRecordName).addObject(secondRecord);\n });\n }\n }\n\n this.coalesce();\n};\n\nDS.RelationshipChangeRemove.prototype.changeType = \"remove\";\nDS.RelationshipChangeRemove.prototype.sync = function() {\n var secondRecordName = this.getSecondRecordName(),\n firstRecordName = this.getFirstRecordName(),\n firstRecord = this.getFirstRecord(),\n secondRecord = this.getSecondRecord();\n\n //Ember.assert(\"You specified a hasMany (\" + hasManyName + \") on \" + (!belongsToName && (newParent || oldParent || this.lastParent).constructor) + \" but did not specify an inverse belongsTo on \" + child.constructor, belongsToName);\n //Ember.assert(\"You specified a belongsTo (\" + belongsToName + \") on \" + child.constructor + \" but did not specify an inverse hasMany on \" + (!hasManyName && (newParent || oldParent || this.lastParentRecord).constructor), hasManyName);\n\n var transaction = this.ensureSameTransaction(firstRecord, secondRecord, secondRecordName, firstRecordName);\n transaction.relationshipBecameDirty(this);\n\n this.callChangeEvents();\n\n if (secondRecord && firstRecord) {\n if(this.secondRecordKind === \"belongsTo\"){\n set(secondRecord, secondRecordName, null);\n }\n else if(this.secondRecordKind === \"hasMany\"){\n secondRecord.suspendRelationshipObservers(function(){\n get(secondRecord, secondRecordName).removeObject(firstRecord);\n });\n }\n }\n\n if (firstRecord && get(firstRecord, firstRecordName)) {\n if(this.firstRecordKind === \"belongsTo\"){\n firstRecord.suspendRelationshipObservers(function(){\n set(firstRecord, firstRecordName, null);\n });\n }\n else if(this.firstdRecordKind === \"hasMany\"){\n firstRecord.suspendRelationshipObservers(function(){\n get(firstRecord, firstRecordName).removeObject(secondRecord);\n });\n }\n }\n\n this.coalesce();\n};\n\nfunction inverseBelongsToName(parentType, childType, hasManyName) {\n // Get the options passed to the parent's DS.hasMany()\n var options = parentType.metaForProperty(hasManyName).options;\n var belongsToName;\n\n if (belongsToName = options.inverse) {\n return belongsToName;\n }\n\n return DS._inverseRelationshipFor(childType, parentType).name;\n}\n\nfunction inverseHasManyName(parentType, childType, belongsToName) {\n var options = childType.metaForProperty(belongsToName).options;\n var hasManyName;\n\n if (hasManyName = options.inverse) {\n return hasManyName;\n }\n\n return DS._inverseRelationshipFor(parentType, childType).name;\n}\n\n})();\n//@ sourceURL=ember-data/system/relationships/one_to_many_change");minispade.register('ember-data/system/serializer', "(function() {var get = Ember.get, set = Ember.set, map = Ember.ArrayPolyfills.map, isNone = Ember.isNone;\n\nfunction mustImplement(name) {\n return function() {\n throw new Ember.Error(\"Your serializer \" + this.toString() + \" does not implement the required method \" + name);\n };\n}\n\n/**\n A serializer is responsible for serializing and deserializing a group of\n records.\n\n `DS.Serializer` is an abstract base class designed to help you build a\n serializer that can read to and write from any serialized form. While most\n applications will use `DS.JSONSerializer`, which reads and writes JSON, the\n serializer architecture allows your adapter to transmit things like XML,\n strings, or custom binary data.\n\n Typically, your application's `DS.Adapter` is responsible for both creating a\n serializer as well as calling the appropriate methods when it needs to\n materialize data or serialize a record.\n\n The serializer API is designed as a series of layered hooks that you can\n override to customize any of the individual steps of serialization and\n deserialization.\n\n The hooks are organized by the three responsibilities of the serializer:\n\n 1. Determining naming conventions\n 2. Serializing records into a serialized form\n 3. Deserializing records from a serialized form\n\n Because Ember Data lazily materializes records, the deserialization\n step, and therefore the hooks you implement, are split into two phases:\n\n 1. Extraction, where the serialized forms for multiple records are\n extracted from a single payload. The IDs of each record are also\n extracted for indexing.\n 2. Materialization, where a newly-created record has its attributes\n and relationships initialized based on the serialized form loaded\n by the adapter.\n\n Additionally, a serializer can convert values from their JavaScript\n versions into their serialized versions via a declarative API.\n\n ## Naming Conventions\n\n One of the most common uses of the serializer is to map attribute names\n from the serialized form to your `DS.Model`. For example, in your model,\n you may have an attribute called `firstName`:\n\n ```javascript\n App.Person = DS.Model.extend({\n firstName: DS.attr('string')\n });\n ```\n\n However, because the web API your adapter is communicating with is\n legacy, it calls this attribute `FIRST_NAME`.\n\n You can determine the attribute name used in the serialized form\n by implementing `keyForAttributeName`:\n\n ```javascript\n keyForAttributeName: function(type, name) {\n return name.underscore.toUpperCase();\n }\n ```\n\n If your attribute names are not predictable, you can re-map them\n one-by-one using the `map` API:\n\n ```javascript\n App.Person.map('App.Person', {\n firstName: { key: '*API_USER_FIRST_NAME*' }\n });\n ```\n\n ## Serialization\n\n During the serialization process, a record or records are converted\n from Ember.js objects into their serialized form.\n\n These methods are designed in layers, like a delicious 7-layer\n cake (but with fewer layers).\n\n The main entry point for serialization is the `serialize`\n method, which takes the record and options.\n\n The `serialize` method is responsible for:\n\n * turning the record's attributes (`DS.attr`) into\n attributes on the JSON object.\n * optionally adding the record's ID onto the hash\n * adding relationships (`DS.hasMany` and `DS.belongsTo`)\n to the JSON object.\n\n Depending on the backend, the serializer can choose\n whether to include the `hasMany` or `belongsTo`\n relationships on the JSON hash.\n\n For very custom serialization, you can implement your\n own `serialize` method. In general, however, you will want\n to override the hooks described below.\n\n ### Adding the ID\n\n The default `serialize` will optionally call your serializer's\n `addId` method with the JSON hash it is creating, the\n record's type, and the record's ID. The `serialize` method\n will not call `addId` if the record's ID is undefined.\n\n Your adapter must specifically request ID inclusion by\n passing `{ includeId: true }` as an option to `serialize`.\n\n NOTE: You may not want to include the ID when updating an\n existing record, because your server will likely disallow\n changing an ID after it is created, and the PUT request\n itself will include the record's identification.\n\n By default, `addId` will:\n\n 1. Get the primary key name for the record by calling\n the serializer's `primaryKey` with the record's type.\n Unless you override the `primaryKey` method, this\n will be `'id'`.\n 2. Assign the record's ID to the primary key in the\n JSON hash being built.\n\n If your backend expects a JSON object with the primary\n key at the root, you can just override the `primaryKey`\n method on your serializer subclass.\n\n Otherwise, you can override the `addId` method for\n more specialized handling.\n\n ### Adding Attributes\n\n By default, the serializer's `serialize` method will call\n `addAttributes` with the JSON object it is creating\n and the record to serialize.\n\n The `addAttributes` method will then call `addAttribute`\n in turn, with the JSON object, the record to serialize,\n the attribute's name and its type.\n\n Finally, the `addAttribute` method will serialize the\n attribute:\n\n 1. It will call `keyForAttributeName` to determine\n the key to use in the JSON hash.\n 2. It will get the value from the record.\n 3. It will call `serializeValue` with the attribute's\n value and attribute type to convert it into a\n JSON-compatible value. For example, it will convert a\n Date into a String.\n\n If your backend expects a JSON object with attributes as\n keys at the root, you can just override the `serializeValue`\n and `keyForAttributeName` methods in your serializer\n subclass and let the base class do the heavy lifting.\n\n If you need something more specialized, you can probably\n override `addAttribute` and let the default `addAttributes`\n handle the nitty gritty.\n\n ### Adding Relationships\n\n By default, `serialize` will call your serializer's\n `addRelationships` method with the JSON object that is\n being built and the record being serialized. The default\n implementation of this method is to loop over all of the\n relationships defined on your record type and:\n\n * If the relationship is a `DS.hasMany` relationship,\n call `addHasMany` with the JSON object, the record\n and a description of the relationship.\n * If the relationship is a `DS.belongsTo` relationship,\n call `addBelongsTo` with the JSON object, the record\n and a description of the relationship.\n\n The relationship description has the following keys:\n\n * `type`: the class of the associated information (the\n first parameter to `DS.hasMany` or `DS.belongsTo`)\n * `kind`: either `hasMany` or `belongsTo`\n\n The relationship description may get additional\n information in the future if more capabilities or\n relationship types are added. However, it will\n remain backwards-compatible, so the mere existence\n of new features should not break existing adapters.\n*/\nDS.Serializer = Ember.Object.extend({\n init: function() {\n this.mappings = Ember.Map.create();\n this.configurations = Ember.Map.create();\n this.globalConfigurations = {};\n },\n\n extract: mustImplement('extract'),\n extractMany: mustImplement('extractMany'),\n\n extractRecordRepresentation: function(loader, type, json, shouldSideload) {\n var mapping = this.mappingForType(type);\n var embeddedData, prematerialized = {}, reference;\n\n if (shouldSideload) {\n reference = loader.sideload(type, json);\n } else {\n reference = loader.load(type, json);\n }\n\n this.eachEmbeddedHasMany(type, function(name, relationship) {\n var embeddedData = json[this.keyFor(relationship)];\n if (!isNone(embeddedData)) {\n this.extractEmbeddedHasMany(loader, relationship, embeddedData, reference, prematerialized);\n }\n }, this);\n\n this.eachEmbeddedBelongsTo(type, function(name, relationship) {\n var embeddedData = json[this.keyFor(relationship)];\n if (!isNone(embeddedData)) {\n this.extractEmbeddedBelongsTo(loader, relationship, embeddedData, reference, prematerialized);\n }\n }, this);\n\n loader.prematerialize(reference, prematerialized);\n\n return reference;\n },\n\n extractEmbeddedHasMany: function(loader, relationship, array, parent, prematerialized) {\n var references = map.call(array, function(item) {\n if (!item) { return; }\n\n var reference = this.extractRecordRepresentation(loader, relationship.type, item, true);\n\n // If the embedded record should also be saved back when serializing the parent,\n // make sure we set its parent since it will not have an ID.\n var embeddedType = this.embeddedType(parent.type, relationship.key);\n if (embeddedType === 'always') {\n reference.parent = parent;\n }\n\n return reference;\n }, this);\n\n prematerialized[relationship.key] = references;\n },\n\n extractEmbeddedBelongsTo: function(loader, relationship, data, parent, prematerialized) {\n var reference = this.extractRecordRepresentation(loader, relationship.type, data, true);\n prematerialized[relationship.key] = reference;\n\n // If the embedded record should also be saved back when serializing the parent,\n // make sure we set its parent since it will not have an ID.\n var embeddedType = this.embeddedType(parent.type, relationship.key);\n if (embeddedType === 'always') {\n reference.parent = parent;\n }\n },\n\n //.......................\n //. SERIALIZATION HOOKS\n //.......................\n\n /**\n The main entry point for serializing a record. While you can consider this\n a hook that can be overridden in your serializer, you will have to manually\n handle serialization. For most cases, there are more granular hooks that you\n can override.\n\n If overriding this method, these are the responsibilities that you will need\n to implement yourself:\n\n * If the option hash contains `includeId`, add the record's ID to the serialized form.\n By default, `serialize` calls `addId` if appropriate.\n * Add the record's attributes to the serialized form. By default, `serialize` calls\n `addAttributes`.\n * Add the record's relationships to the serialized form. By default, `serialize` calls\n `addRelationships`.\n\n @param {DS.Model} record the record to serialize\n @param {Object} [options] a hash of options\n @returns {any} the serialized form of the record\n */\n serialize: function(record, options) {\n options = options || {};\n\n var serialized = this.createSerializedForm(), id;\n\n if (options.includeId) {\n if (id = get(record, 'id')) {\n this._addId(serialized, record.constructor, id);\n }\n }\n\n this.addAttributes(serialized, record);\n this.addRelationships(serialized, record);\n\n return serialized;\n },\n\n /**\n @private\n\n Given an attribute type and value, convert the value into the\n serialized form using the transform registered for that type.\n\n @param {any} value the value to convert to the serialized form\n @param {String} attributeType the registered type (e.g. `string`\n or `boolean`)\n @returns {any} the serialized form of the value\n */\n serializeValue: function(value, attributeType) {\n var transform = this.transforms ? this.transforms[attributeType] : null;\n\n Ember.assert(\"You tried to use an attribute type (\" + attributeType + \") that has not been registered\", transform);\n return transform.serialize(value);\n },\n\n /**\n A hook you can use to normalize IDs before adding them to the\n serialized representation.\n\n Because the store coerces all IDs to strings for consistency,\n this is the opportunity for the serializer to, for example,\n convert numerical IDs back into number form.\n\n @param {String} id the id from the record\n @returns {any} the serialized representation of the id\n */\n serializeId: function(id) {\n if (isNaN(id)) { return id; }\n return +id;\n },\n\n /**\n A hook you can use to change how attributes are added to the serialized\n representation of a record.\n\n By default, `addAttributes` simply loops over all of the attributes of the\n passed record, maps the attribute name to the key for the serialized form,\n and invokes any registered transforms on the value. It then invokes the\n more granular `addAttribute` with the key and transformed value.\n\n Since you can override `keyForAttributeName`, `addAttribute`, and register\n custom tranforms, you should rarely need to override this hook.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n */\n addAttributes: function(data, record) {\n record.eachAttribute(function(name, attribute) {\n this._addAttribute(data, record, name, attribute.type);\n }, this);\n },\n\n /**\n A hook you can use to customize how the key/value pair is added to\n the serialized data.\n\n @param {any} serialized the serialized form being built\n @param {String} key the key to add to the serialized data\n @param {any} value the value to add to the serialized data\n */\n addAttribute: Ember.K,\n\n /**\n A hook you can use to customize how the record's id is added to\n the serialized data.\n\n The `addId` hook is called with:\n\n * the serialized representation being built\n * the resolved primary key (taking configurations and the\n `primaryKey` hook into consideration)\n * the serialized id (after calling the `serializeId` hook)\n\n @param {any} data the serialized representation that is being built\n @param {String} key the resolved primary key\n @param {id} id the serialized id\n */\n addId: Ember.K,\n\n /**\n A hook you can use to change how relationships are added to the serialized\n representation of a record.\n\n By default, `addAttributes` loops over all of the relationships of the\n passed record, maps the relationship names to the key for the serialized form,\n and then invokes the public `addBelongsTo` and `addHasMany` hooks.\n\n Since you can override `keyForBelongsTo`, `keyForHasMany`, `addBelongsTo`,\n `addHasMany`, and register mappings, you should rarely need to override this\n hook.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n */\n addRelationships: function(data, record) {\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'belongsTo') {\n this._addBelongsTo(data, record, name, relationship);\n } else if (relationship.kind === 'hasMany') {\n this._addHasMany(data, record, name, relationship);\n }\n }, this);\n },\n\n /**\n A hook you can use to add a `belongsTo` relationship to the\n serialized representation.\n\n The specifics of this hook are very adapter-specific, so there\n is no default implementation. You can see `DS.JSONSerializer`\n for an example of an implementation of the `addBelongsTo` hook.\n\n The `belongsTo` relationship object has the following properties:\n\n * **type** a subclass of DS.Model that is the type of the\n relationship. This is the first parameter to DS.belongsTo\n * **options** the options passed to the call to DS.belongsTo\n * **kind** always `belongsTo`\n\n Additional properties may be added in the future.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n @param {String} key the key for the serialized object\n @param {Object} relationship an object representing the relationship\n */\n addBelongsTo: Ember.K,\n\n /**\n A hook you can use to add a `hasMany` relationship to the\n serialized representation.\n\n The specifics of this hook are very adapter-specific, so there\n is no default implementation. You may not need to implement this,\n for example, if your backend only expects relationships on the\n child of a one to many relationship.\n\n The `hasMany` relationship object has the following properties:\n\n * **type** a subclass of DS.Model that is the type of the\n relationship. This is the first parameter to DS.hasMany\n * **options** the options passed to the call to DS.hasMany\n * **kind** always `hasMany`\n\n Additional properties may be added in the future.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n @param {String} key the key for the serialized object\n @param {Object} relationship an object representing the relationship\n */\n addHasMany: Ember.K,\n\n /**\n NAMING CONVENTIONS\n\n The most commonly overridden APIs of the serializer are\n the naming convention methods:\n\n * `keyForAttributeName`: converts a camelized attribute name\n into a key in the adapter-provided data hash. For example,\n if the model's attribute name was `firstName`, and the\n server used underscored names, you would return `first_name`.\n * `primaryKey`: returns the key that should be used to\n extract the id from the adapter-provided data hash. It is\n also used when serializing a record.\n */\n\n /**\n A hook you can use in your serializer subclass to customize\n how an unmapped attribute name is converted into a key.\n\n By default, this method returns the `name` parameter.\n\n For example, if the attribute names in your JSON are underscored,\n you will want to convert them into JavaScript conventional\n camelcase:\n\n ```javascript\n App.MySerializer = DS.Serializer.extend({\n // ...\n\n keyForAttributeName: function(type, name) {\n return name.camelize();\n }\n });\n ```\n\n @param {DS.Model subclass} type the type of the record with\n the attribute name `name`\n @param {String} name the attribute name to convert into a key\n\n @returns {String} the key\n */\n keyForAttributeName: function(type, name) {\n return name;\n },\n\n /**\n A hook you can use in your serializer to specify a conventional\n primary key.\n\n By default, this method will return the string `id`.\n\n In general, you should not override this hook to specify a special\n primary key for an individual type; use `configure` instead.\n\n For example, if your primary key is always `__id__`:\n\n ```javascript\n App.MySerializer = DS.Serializer.extend({\n // ...\n primaryKey: function(type) {\n return '__id__';\n }\n });\n ```\n\n In another example, if the primary key always includes the\n underscored version of the type before the string `id`:\n\n ```javascript\n App.MySerializer = DS.Serializer.extend({\n // ...\n primaryKey: function(type) {\n // If the type is `BlogPost`, this will return\n // `blog_post_id`.\n var typeString = type.toString.split(\".\")[1].underscore();\n return typeString + \"_id\";\n }\n });\n ```\n\n @param {DS.Model subclass} type\n @returns {String} the primary key for the type\n */\n primaryKey: function(type) {\n return \"id\";\n },\n\n /**\n A hook you can use in your serializer subclass to customize\n how an unmapped `belongsTo` relationship is converted into\n a key.\n\n By default, this method calls `keyForAttributeName`, so if\n your naming convention is uniform across attributes and\n relationships, you can use the default here and override\n just `keyForAttributeName` as needed.\n\n For example, if the `belongsTo` names in your JSON always\n begin with `BT_` (e.g. `BT_posts`), you can strip out the\n `BT_` prefix:\"\n\n ```javascript\n App.MySerializer = DS.Serializer.extend({\n // ...\n keyForBelongsTo: function(type, name) {\n return name.match(/^BT_(.*)$/)[1].camelize();\n }\n });\n ```\n\n @param {DS.Model subclass} type the type of the record with\n the `belongsTo` relationship.\n @param {String} name the relationship name to convert into a key\n\n @returns {String} the key\n */\n keyForBelongsTo: function(type, name) {\n return this.keyForAttributeName(type, name);\n },\n\n /**\n A hook you can use in your serializer subclass to customize\n how an unmapped `hasMany` relationship is converted into\n a key.\n\n By default, this method calls `keyForAttributeName`, so if\n your naming convention is uniform across attributes and\n relationships, you can use the default here and override\n just `keyForAttributeName` as needed.\n\n For example, if the `hasMany` names in your JSON always\n begin with the \"table name\" for the current type (e.g.\n `post_comments`), you can strip out the prefix:\"\n\n ```javascript\n App.MySerializer = DS.Serializer.extend({\n // ...\n keyForHasMany: function(type, name) {\n // if your App.BlogPost has many App.BlogComment, the key from\n // the server would look like: `blog_post_blog_comments`\n //\n // 1. Convert the type into a string and underscore the\n // second part (App.BlogPost -> blog_post)\n // 2. Extract the part after `blog_post_` (`blog_comments`)\n // 3. Underscore it, to become `blogComments`\n var typeString = type.toString().split(\".\")[1].underscore();\n return name.match(new RegExp(\"^\" + typeString + \"_(.*)$\"))[1].camelize();\n }\n });\n ```\n\n @param {DS.Model subclass} type the type of the record with\n the `belongsTo` relationship.\n @param {String} name the relationship name to convert into a key\n\n @returns {String} the key\n */\n keyForHasMany: function(type, name) {\n return this.keyForAttributeName(type, name);\n },\n\n //.........................\n //. MATERIALIZATION HOOKS\n //.........................\n\n materialize: function(record, serialized, prematerialized) {\n var id;\n if (Ember.isNone(get(record, 'id'))) {\n if (prematerialized && prematerialized.hasOwnProperty('id')) {\n id = prematerialized.id;\n } else {\n id = this.extractId(record.constructor, serialized);\n }\n record.materializeId(id);\n }\n\n this.materializeAttributes(record, serialized, prematerialized);\n this.materializeRelationships(record, serialized, prematerialized);\n },\n\n deserializeValue: function(value, attributeType) {\n var transform = this.transforms ? this.transforms[attributeType] : null;\n\n Ember.assert(\"You tried to use a attribute type (\" + attributeType + \") that has not been registered\", transform);\n return transform.deserialize(value);\n },\n\n materializeAttributes: function(record, serialized, prematerialized) {\n record.eachAttribute(function(name, attribute) {\n if (prematerialized && prematerialized.hasOwnProperty(name)) {\n record.materializeAttribute(name, prematerialized[name]);\n } else {\n this.materializeAttribute(record, serialized, name, attribute.type);\n }\n }, this);\n },\n\n materializeAttribute: function(record, serialized, attributeName, attributeType) {\n var value = this.extractAttribute(record.constructor, serialized, attributeName);\n value = this.deserializeValue(value, attributeType);\n\n record.materializeAttribute(attributeName, value);\n },\n\n materializeRelationships: function(record, hash, prematerialized) {\n record.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n if (prematerialized && prematerialized.hasOwnProperty(name)) {\n record.materializeHasMany(name, prematerialized[name]);\n } else {\n this.materializeHasMany(name, record, hash, relationship, prematerialized);\n }\n } else if (relationship.kind === 'belongsTo') {\n if (prematerialized && prematerialized.hasOwnProperty(name)) {\n record.materializeBelongsTo(name, prematerialized[name]);\n } else {\n this.materializeBelongsTo(name, record, hash, relationship, prematerialized);\n }\n }\n }, this);\n },\n\n materializeHasMany: function(name, record, hash, relationship) {\n var key = this._keyForHasMany(record.constructor, relationship.key);\n record.materializeHasMany(name, this.extractHasMany(record.constructor, hash, key));\n },\n\n materializeBelongsTo: function(name, record, hash, relationship) {\n var key = this._keyForBelongsTo(record.constructor, relationship.key);\n record.materializeBelongsTo(name, this.extractBelongsTo(record.constructor, hash, key));\n },\n\n _extractEmbeddedRelationship: function(type, hash, name, relationshipType) {\n var key = this['_keyFor' + relationshipType](type, name);\n\n if (this.embeddedType(type, name)) {\n return this['extractEmbedded' + relationshipType](type, hash, key);\n }\n },\n\n _extractEmbeddedBelongsTo: function(type, hash, name) {\n return this._extractEmbeddedRelationship(type, hash, name, 'BelongsTo');\n },\n\n _extractEmbeddedHasMany: function(type, hash, name) {\n return this._extractEmbeddedRelationship(type, hash, name, 'HasMany');\n },\n\n /**\n @private\n\n This method is called to get the primary key for a given\n type.\n\n If a primary key configuration exists for this type, this\n method will return the configured value. Otherwise, it will\n call the public `primaryKey` hook.\n\n @param {DS.Model subclass} type\n @returns {String} the primary key for the type\n */\n _primaryKey: function(type) {\n var config = this.configurationForType(type),\n primaryKey = config && config.primaryKey;\n\n if (primaryKey) {\n return primaryKey;\n } else {\n return this.primaryKey(type);\n }\n },\n\n /**\n @private\n\n This method looks up the key for the attribute name and transforms the\n attribute's value using registered transforms.\n\n Specifically:\n\n 1. Look up the key for the attribute name. If available, this will use\n any registered mappings. Otherwise, it will invoke the public\n `keyForAttributeName` hook.\n 2. Get the value from the record using the `attributeName`.\n 3. Transform the value using registered transforms for the `attributeType`.\n 4. Invoke the public `addAttribute` hook with the hash, key, and\n transformed value.\n\n @param {any} data the serialized representation being built\n @param {DS.Model} record the record to serialize\n @param {String} attributeName the name of the attribute on the record\n @param {String} attributeType the type of the attribute (e.g. `string`\n or `boolean`)\n */\n _addAttribute: function(data, record, attributeName, attributeType) {\n var key = this._keyForAttributeName(record.constructor, attributeName);\n var value = get(record, attributeName);\n\n this.addAttribute(data, key, this.serializeValue(value, attributeType));\n },\n\n /**\n @private\n\n This method looks up the primary key for the `type` and invokes\n `serializeId` on the `id`.\n\n It then invokes the public `addId` hook with the primary key and\n the serialized id.\n\n @param {any} data the serialized representation that is being built\n @param {Ember.Model subclass} type\n @param {any} id the materialized id from the record\n */\n _addId: function(hash, type, id) {\n var primaryKey = this._primaryKey(type);\n\n this.addId(hash, primaryKey, this.serializeId(id));\n },\n\n /**\n @private\n\n This method is called to get a key used in the data from\n an attribute name. It first checks for any mappings before\n calling the public hook `keyForAttributeName`.\n\n @param {DS.Model subclass} type the type of the record with\n the attribute name `name`\n @param {String} name the attribute name to convert into a key\n\n @returns {String} the key\n */\n _keyForAttributeName: function(type, name) {\n return this._keyFromMappingOrHook('keyForAttributeName', type, name);\n },\n\n /**\n @private\n\n This method is called to get a key used in the data from\n a belongsTo relationship. It first checks for any mappings before\n calling the public hook `keyForBelongsTo`.\n\n @param {DS.Model subclass} type the type of the record with\n the `belongsTo` relationship.\n @param {String} name the relationship name to convert into a key\n\n @returns {String} the key\n */\n _keyForBelongsTo: function(type, name) {\n return this._keyFromMappingOrHook('keyForBelongsTo', type, name);\n },\n\n keyFor: function(description) {\n var type = description.parentType,\n name = description.key;\n\n switch (description.kind) {\n case 'belongsTo':\n return this._keyForBelongsTo(type, name);\n case 'hasMany':\n return this._keyForHasMany(type, name);\n }\n },\n\n /**\n @private\n\n This method is called to get a key used in the data from\n a hasMany relationship. It first checks for any mappings before\n calling the public hook `keyForHasMany`.\n\n @param {DS.Model subclass} type the type of the record with\n the `hasMany` relationship.\n @param {String} name the relationship name to convert into a key\n\n @returns {String} the key\n */\n _keyForHasMany: function(type, name) {\n return this._keyFromMappingOrHook('keyForHasMany', type, name);\n },\n /**\n @private\n\n This method converts the relationship name to a key for serialization,\n and then invokes the public `addBelongsTo` hook.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n @param {String} name the relationship name\n @param {Object} relationship an object representing the relationship\n */\n _addBelongsTo: function(data, record, name, relationship) {\n var key = this._keyForBelongsTo(record.constructor, name);\n this.addBelongsTo(data, record, key, relationship);\n },\n\n /**\n @private\n\n This method converts the relationship name to a key for serialization,\n and then invokes the public `addHasMany` hook.\n\n @param {any} data the serialized representation that is being built\n @param {DS.Model} record the record to serialize\n @param {String} name the relationship name\n @param {Object} relationship an object representing the relationship\n */\n _addHasMany: function(data, record, name, relationship) {\n var key = this._keyForHasMany(record.constructor, name);\n this.addHasMany(data, record, key, relationship);\n },\n\n /**\n @private\n\n An internal method that handles checking whether a mapping\n exists for a particular attribute or relationship name before\n calling the public hooks.\n\n If a mapping is found, and the mapping has a key defined,\n use that instead of invoking the hook.\n\n @param {String} publicMethod the public hook to invoke if\n a mapping is not found (e.g. `keyForAttributeName`)\n @param {DS.Model subclass} type the type of the record with\n the attribute or relationship name.\n @param {String} name the attribute or relationship name to\n convert into a key\n */\n _keyFromMappingOrHook: function(publicMethod, type, name) {\n var key = this.mappingOption(type, name, 'key');\n\n if (key) {\n return key;\n } else {\n return this[publicMethod](type, name);\n }\n },\n\n /**\n TRANSFORMS\n */\n\n registerTransform: function(type, transform) {\n this.transforms[type] = transform;\n },\n\n registerEnumTransform: function(type, objects) {\n var transform = {\n deserialize: function(deserialized) {\n return objects.objectAt(deserialized);\n },\n serialize: function(serialized) {\n return objects.indexOf(serialized);\n },\n values: objects\n };\n this.registerTransform(type, transform);\n },\n\n /**\n MAPPING CONVENIENCE\n */\n\n map: function(type, mappings) {\n this.mappings.set(type, mappings);\n },\n\n configure: function(type, configuration) {\n if (type && !configuration) {\n Ember.merge(this.globalConfigurations, type);\n return;\n }\n\n var config = Ember.create(this.globalConfigurations);\n Ember.merge(config, configuration);\n\n this.configurations.set(type, config);\n },\n\n mappingForType: function(type) {\n this._reifyMappings();\n return this.mappings.get(type) || {};\n },\n\n configurationForType: function(type) {\n this._reifyConfigurations();\n return this.configurations.get(type) || this.globalConfigurations;\n },\n\n _reifyMappings: function() {\n if (this._didReifyMappings) { return; }\n\n var mappings = this.mappings,\n reifiedMappings = Ember.Map.create();\n\n mappings.forEach(function(key, mapping) {\n if (typeof key === 'string') {\n var type = Ember.get(Ember.lookup, key);\n Ember.assert(\"Could not find model at path \" + key, type);\n\n reifiedMappings.set(type, mapping);\n } else {\n reifiedMappings.set(key, mapping);\n }\n });\n\n this.mappings = reifiedMappings;\n\n this._didReifyMappings = true;\n },\n\n _reifyConfigurations: function() {\n if (this._didReifyConfigurations) { return; }\n\n var configurations = this.configurations,\n reifiedConfigurations = Ember.Map.create();\n\n configurations.forEach(function(key, mapping) {\n if (typeof key === 'string' && key !== 'plurals') {\n var type = Ember.get(Ember.lookup, key);\n Ember.assert(\"Could not find model at path \" + key, type);\n\n reifiedConfigurations.set(type, mapping);\n } else {\n reifiedConfigurations.set(key, mapping);\n }\n });\n\n this.configurations = reifiedConfigurations;\n\n this._didReifyConfigurations = true;\n },\n\n mappingOption: function(type, name, option) {\n var mapping = this.mappingForType(type)[name];\n\n return mapping && mapping[option];\n },\n\n configOption: function(type, option) {\n var config = this.configurationForType(type);\n\n return config[option];\n },\n\n // EMBEDDED HELPERS\n\n embeddedType: function(type, name) {\n return this.mappingOption(type, name, 'embedded');\n },\n\n eachEmbeddedRecord: function(record, callback, binding) {\n this.eachEmbeddedBelongsToRecord(record, callback, binding);\n this.eachEmbeddedHasManyRecord(record, callback, binding);\n },\n\n eachEmbeddedBelongsToRecord: function(record, callback, binding) {\n var type = record.constructor;\n\n this.eachEmbeddedBelongsTo(record.constructor, function(name, relationship, embeddedType) {\n var embeddedRecord = get(record, name);\n if (embeddedRecord) { callback.call(binding, embeddedRecord, embeddedType); }\n });\n },\n\n eachEmbeddedHasManyRecord: function(record, callback, binding) {\n var type = record.constructor;\n\n this.eachEmbeddedHasMany(record.constructor, function(name, relationship, embeddedType) {\n var array = get(record, name);\n for (var i=0, l=get(array, 'length'); i<l; i++) {\n callback.call(binding, array.objectAt(i), embeddedType);\n }\n });\n },\n\n eachEmbeddedHasMany: function(type, callback, binding) {\n this.eachEmbeddedRelationship(type, 'hasMany', callback, binding);\n },\n\n eachEmbeddedBelongsTo: function(type, callback, binding) {\n this.eachEmbeddedRelationship(type, 'belongsTo', callback, binding);\n },\n\n eachEmbeddedRelationship: function(type, kind, callback, binding) {\n type.eachRelationship(function(name, relationship) {\n var embeddedType = this.embeddedType(type, name);\n\n if (embeddedType) {\n if (relationship.kind === kind) {\n callback.call(binding, name, relationship, embeddedType);\n }\n }\n }, this);\n }\n});\n\n\n})();\n//@ sourceURL=ember-data/system/serializer");minispade.register('ember-data/system/store', "(function() {/*globals Ember*/\n/*jshint eqnull:true*/\nminispade.require(\"ember-data/system/record_arrays\");\nminispade.require(\"ember-data/system/transaction\");\nminispade.require(\"ember-data/system/mixins/mappable\");\n\nvar get = Ember.get, set = Ember.set, fmt = Ember.String.fmt, once = Ember.run.once;\nvar forEach = Ember.EnumerableUtils.forEach;\n// These values are used in the data cache when clientIds are\n// needed but the underlying data has not yet been loaded by\n// the server.\nvar UNLOADED = 'unloaded';\nvar LOADING = 'loading';\nvar MATERIALIZED = { materialized: true };\nvar CREATED = { created: true };\n\n// Implementors Note:\n//\n// The variables in this file are consistently named according to the following\n// scheme:\n//\n// * +id+ means an identifier managed by an external source, provided inside\n// the data provided by that source.\n// * +clientId+ means a transient numerical identifier generated at runtime by\n// the data store. It is important primarily because newly created objects may\n// not yet have an externally generated id.\n// * +type+ means a subclass of DS.Model.\n\n// Used by the store to normalize IDs entering the store. Despite the fact\n// that developers may provide IDs as numbers (e.g., `store.find(Person, 1)`),\n// it is important that internally we use strings, since IDs may be serialized\n// and lose type information. For example, Ember's router may put a record's\n// ID into the URL, and if we later try to deserialize that URL and find the\n// corresponding record, we will not know if it is a string or a number.\nvar coerceId = function(id) {\n return id == null ? null : id+'';\n};\n\nvar map = Ember.EnumerableUtils.map;\n\n/**\n The store contains all of the data for records loaded from the server.\n It is also responsible for creating instances of DS.Model that wraps\n the individual data for a record, so that they can be bound to in your\n Handlebars templates.\n\n Create a new store like this:\n\n MyApp.store = DS.Store.create();\n\n You can retrieve DS.Model instances from the store in several ways. To retrieve\n a record for a specific id, use the `find()` method:\n\n var record = MyApp.store.find(MyApp.Contact, 123);\n\n By default, the store will talk to your backend using a standard REST mechanism.\n You can customize how the store talks to your backend by specifying a custom adapter:\n\n MyApp.store = DS.Store.create({\n adapter: 'MyApp.CustomAdapter'\n });\n\n You can learn more about writing a custom adapter by reading the `DS.Adapter`\n documentation.\n*/\nDS.Store = Ember.Object.extend(DS._Mappable, {\n\n /**\n Many methods can be invoked without specifying which store should be used.\n In those cases, the first store created will be used as the default. If\n an application has multiple stores, it should specify which store to use\n when performing actions, such as finding records by id.\n\n The init method registers this store as the default if none is specified.\n */\n init: function() {\n // Enforce API revisioning. See BREAKING_CHANGES.md for more.\n var revision = get(this, 'revision');\n\n if (revision !== DS.CURRENT_API_REVISION && !Ember.ENV.TESTING) {\n throw new Error(\"Error: The Ember Data library has had breaking API changes since the last time you updated the library. Please review the list of breaking changes at https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md, then update your store's `revision` property to \" + DS.CURRENT_API_REVISION);\n }\n\n if (!get(DS, 'defaultStore') || get(this, 'isDefaultStore')) {\n set(DS, 'defaultStore', this);\n }\n\n // internal bookkeeping; not observable\n this.typeMaps = {};\n this.recordCache = [];\n this.clientIdToId = {};\n this.clientIdToType = {};\n this.clientIdToData = {};\n this.clientIdToPrematerializedData = {};\n this.recordArraysByClientId = {};\n this.relationshipChanges = {};\n this.recordReferences = {};\n\n // Internally, we maintain a map of all unloaded IDs requested by\n // a ManyArray. As the adapter loads data into the store, the\n // store notifies any interested ManyArrays. When the ManyArray's\n // total number of loading records drops to zero, it becomes\n // `isLoaded` and fires a `didLoad` event.\n this.loadingRecordArrays = {};\n\n set(this, 'defaultTransaction', this.transaction());\n },\n\n /**\n Returns a new transaction scoped to this store. This delegates\n responsibility for invoking the adapter's commit mechanism to\n a transaction.\n\n Transaction are responsible for tracking changes to records\n added to them, and supporting `commit` and `rollback`\n functionality. Committing a transaction invokes the store's\n adapter, while rolling back a transaction reverses all\n changes made to records added to the transaction.\n\n A store has an implicit (default) transaction, which tracks changes\n made to records not explicitly added to a transaction.\n\n @see {DS.Transaction}\n @returns DS.Transaction\n */\n transaction: function() {\n return DS.Transaction.create({ store: this });\n },\n\n ensureSameTransaction: function(records){\n var transactions = Ember.A();\n forEach( records, function(record){\n if (record){ transactions.pushObject(get(record, 'transaction')); }\n });\n\n var transaction = transactions.reduce(function(prev, t) {\n if (!get(t, 'isDefault')) {\n if (prev === null) { return t; }\n Ember.assert(\"All records in a changed relationship must be in the same transaction. You tried to change the relationship between records when one is in \" + t + \" and the other is in \" + prev, t === prev);\n }\n\n return prev;\n }, null);\n\n if (transaction) {\n forEach( records, function(record){\n if (record){ transaction.add(record); }\n });\n } else {\n transaction = transactions.objectAt(0);\n }\n return transaction;\n\n },\n /**\n @private\n\n Instructs the store to materialize the data for a given record.\n\n To materialize a record, the store first retrieves the opaque data that was\n passed to either `load()` or `loadMany()`. Then, the data and the record\n are passed to the adapter's `materialize()` method, which allows the adapter\n to translate arbitrary data structures from the adapter into the normalized\n form the record expects.\n\n The adapter's `materialize()` method will invoke `materializeAttribute()`,\n `materializeHasMany()` and `materializeBelongsTo()` on the record to\n populate it with normalized values.\n\n @param {DS.Model} record\n */\n materializeData: function(record) {\n var clientId = get(record, 'clientId'),\n cidToData = this.clientIdToData,\n adapter = this.adapterForType(record.constructor),\n data = cidToData[clientId];\n\n cidToData[clientId] = MATERIALIZED;\n\n var prematerialized = this.clientIdToPrematerializedData[clientId];\n\n // Ensures the record's data structures are setup\n // before being populated by the adapter.\n record.setupData();\n\n if (data !== CREATED) {\n // Instructs the adapter to extract information from the\n // opaque data and materialize the record's attributes and\n // relationships.\n adapter.materialize(record, data, prematerialized);\n }\n },\n\n /**\n @private\n\n Returns true if there is already a record for this clientId.\n\n This is used to determine whether cleanup is required, so that\n \"changes\" to unmaterialized records do not trigger mass\n materialization.\n\n For example, if a parent record in a relationship with a large\n number of children is deleted, we want to avoid materializing\n those children.\n\n @param {Object} reference\n @return {Boolean}\n */\n recordIsMaterialized: function(reference) {\n return !!this.recordCache[reference.clientId];\n },\n\n /**\n The adapter to use to communicate to a backend server or other persistence layer.\n\n This can be specified as an instance, a class, or a property path that specifies\n where the adapter can be located.\n\n @property {DS.Adapter|String}\n */\n adapter: 'DS.RESTAdapter',\n\n /**\n @private\n\n Returns a JSON representation of the record using the adapter's\n serialization strategy. This method exists primarily to enable\n a record, which has access to its store (but not the store's\n adapter) to provide a `serialize()` convenience.\n\n The available options are:\n\n * `includeId`: `true` if the record's ID should be included in\n the JSON representation\n\n @param {DS.Model} record the record to serialize\n @param {Object} options an options hash\n */\n serialize: function(record, options) {\n return this.adapterForType(record.constructor).serialize(record, options);\n },\n\n /**\n @private\n\n This property returns the adapter, after resolving a possible\n property path.\n\n If the supplied `adapter` was a class, or a String property\n path resolved to a class, this property will instantiate the\n class.\n\n This property is cacheable, so the same instance of a specified\n adapter class should be used for the lifetime of the store.\n\n @returns DS.Adapter\n */\n _adapter: Ember.computed(function() {\n var adapter = get(this, 'adapter');\n if (typeof adapter === 'string') {\n adapter = get(this, adapter, false) || get(Ember.lookup, adapter);\n }\n\n if (DS.Adapter.detect(adapter)) {\n adapter = adapter.create();\n }\n\n return adapter;\n }).property('adapter'),\n\n /**\n @private\n\n A monotonically increasing number to be used to uniquely identify\n data and records.\n\n It starts at 1 so other parts of the code can test for truthiness\n when provided a `clientId` instead of having to explicitly test\n for undefined.\n */\n clientIdCounter: 1,\n\n // .....................\n // . CREATE NEW RECORD .\n // .....................\n\n /**\n Create a new record in the current store. The properties passed\n to this method are set on the newly created record.\n\n Note: The third `transaction` property is for internal use only.\n If you want to create a record inside of a given transaction,\n use `transaction.createRecord()` instead of `store.createRecord()`.\n\n @param {subclass of DS.Model} type\n @param {Object} properties a hash of properties to set on the\n newly created record.\n @returns DS.Model\n */\n createRecord: function(type, properties, transaction) {\n properties = properties || {};\n\n // Create a new instance of the model `type` and put it\n // into the specified `transaction`. If no transaction is\n // specified, the default transaction will be used.\n var record = type._create({\n store: this\n });\n\n transaction = transaction || get(this, 'defaultTransaction');\n\n // adoptRecord is an internal API that allows records to move\n // into a transaction without assertions designed for app\n // code. It is used here to ensure that regardless of new\n // restrictions on the use of the public `transaction.add()`\n // API, we will always be able to insert new records into\n // their transaction.\n transaction.adoptRecord(record);\n\n // `id` is a special property that may not be a `DS.attr`\n var id = properties.id;\n\n // If the passed properties do not include a primary key,\n // give the adapter an opportunity to generate one. Typically,\n // client-side ID generators will use something like uuid.js\n // to avoid conflicts.\n var adapter;\n if (Ember.isNone(id)) {\n adapter = this.adapterForType(type);\n if (adapter && adapter.generateIdForRecord) {\n id = coerceId(adapter.generateIdForRecord(this, record));\n properties.id = id;\n }\n }\n\n id = coerceId(id);\n\n // Create a new `clientId` and associate it with the\n // specified (or generated) `id`. Since we don't have\n // any data for the server yet (by definition), store\n // the sentinel value CREATED as the data for this\n // clientId. If we see this value later, we will skip\n // materialization.\n var clientId = this.pushData(CREATED, id, type);\n\n // Now that we have a clientId, attach it to the record we\n // just created.\n set(record, 'clientId', clientId);\n\n // Move the record out of its initial `empty` state into\n // the `loaded` state.\n record.loadedData();\n\n // Make sure the data is set up so the record doesn't\n // try to materialize its nonexistent data.\n record.setupData();\n\n // Store the record we just created in the record cache for\n // this clientId.\n this.recordCache[clientId] = record;\n\n // Set the properties specified on the record.\n record.setProperties(properties);\n\n // Resolve record promise\n Ember.run(record, 'resolve', record);\n\n return record;\n },\n\n // .................\n // . DELETE RECORD .\n // .................\n\n /**\n For symmetry, a record can be deleted via the store.\n\n @param {DS.Model} record\n */\n deleteRecord: function(record) {\n record.deleteRecord();\n },\n\n /**\n For symmetry, a record can be unloaded via the store.\n\n @param {DS.Model} record\n */\n unloadRecord: function(record) {\n record.unloadRecord();\n },\n\n // ................\n // . FIND RECORDS .\n // ................\n\n /**\n This is the main entry point into finding records. The first parameter to\n this method is always a subclass of `DS.Model`.\n\n You can use the `find` method on a subclass of `DS.Model` directly if your\n application only has one store. For example, instead of\n `store.find(App.Person, 1)`, you could say `App.Person.find(1)`.\n\n ---\n\n To find a record by ID, pass the `id` as the second parameter:\n\n store.find(App.Person, 1);\n App.Person.find(1);\n\n If the record with that `id` had not previously been loaded, the store will\n return an empty record immediately and ask the adapter to find the data by\n calling the adapter's `find` method.\n\n The `find` method will always return the same object for a given type and\n `id`. To check whether the adapter has populated a record, you can check\n its `isLoaded` property.\n\n ---\n\n To find all records for a type, call `find` with no additional parameters:\n\n store.find(App.Person);\n App.Person.find();\n\n This will return a `RecordArray` representing all known records for the\n given type and kick off a request to the adapter's `findAll` method to load\n any additional records for the type.\n\n The `RecordArray` returned by `find()` is live. If any more records for the\n type are added at a later time through any mechanism, it will automatically\n update to reflect the change.\n\n ---\n\n To find a record by a query, call `find` with a hash as the second\n parameter:\n\n store.find(App.Person, { page: 1 });\n App.Person.find({ page: 1 });\n\n This will return a `RecordArray` immediately, but it will always be an\n empty `RecordArray` at first. It will call the adapter's `findQuery`\n method, which will populate the `RecordArray` once the server has returned\n results.\n\n You can check whether a query results `RecordArray` has loaded by checking\n its `isLoaded` property.\n */\n find: function(type, id) {\n if (id === undefined) {\n return this.findAll(type);\n }\n\n // We are passed a query instead of an id.\n if (Ember.typeOf(id) === 'object') {\n return this.findQuery(type, id);\n }\n\n return this.findById(type, coerceId(id));\n },\n\n /**\n @private\n\n This method returns a record for a given type and id combination.\n\n If the store has never seen this combination of type and id before, it\n creates a new `clientId` with the LOADING sentinel and asks the adapter to\n load the data.\n\n If the store has seen the combination, this method delegates to\n `getByReference`.\n */\n findById: function(type, id) {\n var clientId = this.typeMapFor(type).idToCid[id];\n\n if (clientId) {\n return this.findByClientId(type, clientId);\n }\n\n clientId = this.pushData(LOADING, id, type);\n\n // create a new instance of the model type in the\n // 'isLoading' state\n var record = this.materializeRecord(type, clientId, id);\n\n // let the adapter set the data, possibly async\n var adapter = this.adapterForType(type);\n if (adapter && adapter.find) { adapter.find(this, type, id); }\n else { throw \"Adapter is either null or does not implement `find` method\"; }\n\n return record;\n },\n\n reloadRecord: function(record) {\n var type = record.constructor,\n adapter = this.adapterForType(type),\n id = get(record, 'id');\n\n Ember.assert(\"You cannot update a record without an ID\", id);\n Ember.assert(\"You tried to update a record but you have no adapter (for \" + type + \")\", adapter);\n Ember.assert(\"You tried to update a record but your adapter does not implement `find`\", adapter.find);\n\n adapter.find(this, type, id);\n },\n\n /**\n @private\n\n This method returns a record for a given clientId.\n\n If there is no record object yet for the clientId, this method materializes\n a new record object. This allows adapters to eagerly load large amounts of\n data into the store, and avoid incurring the cost to create the objects\n until they are requested.\n\n Several parts of Ember Data call this method:\n\n * findById, if a clientId already exists for a given type and\n id combination\n * OneToManyChange, which is backed by clientIds, when getChild,\n getOldParent or getNewParent are called\n * RecordArray, which is backed by clientIds, when an object at\n a particular index is looked up\n\n In short, it's a convenient way to get a record for a known\n clientId, materializing it if necessary.\n\n @param {Class} type\n @param {Number|String} clientId\n */\n findByClientId: function(type, clientId) {\n var cidToData, record, id;\n\n record = this.recordCache[clientId];\n\n if (!record) {\n // create a new instance of the model type in the\n // 'isLoading' state\n id = this.clientIdToId[clientId];\n record = this.materializeRecord(type, clientId, id);\n\n cidToData = this.clientIdToData;\n\n if (typeof cidToData[clientId] === 'object') {\n record.loadedData();\n }\n }\n\n return record;\n },\n\n /**\n @private\n\n Given a type and array of `clientId`s, determines which of those\n `clientId`s has not yet been loaded.\n\n In preparation for loading, this method also marks any unloaded\n `clientId`s as loading.\n */\n neededReferences: function(type, references) {\n var neededReferences = [],\n cidToData = this.clientIdToData,\n reference;\n\n for (var i=0, l=references.length; i<l; i++) {\n reference = references[i];\n\n if (cidToData[reference.clientId] === UNLOADED) {\n neededReferences.push(reference);\n cidToData[reference.clientId] = LOADING;\n }\n }\n\n return neededReferences;\n },\n\n /**\n @private\n\n This method is the entry point that relationships use to update\n themselves when their underlying data changes.\n\n First, it determines which of its `clientId`s are still unloaded,\n then converts the needed `clientId`s to IDs and invokes `findMany`\n on the adapter.\n */\n fetchUnloadedReferences: function(type, references, owner) {\n var neededReferences = this.neededReferences(type, references);\n this.fetchMany(type, neededReferences, owner);\n },\n\n /**\n @private\n\n This method takes a type and list of `clientId`s, converts the\n `clientId`s into IDs, and then invokes the adapter's `findMany`\n method.\n\n It is used both by a brand new relationship (via the `findMany`\n method) or when the data underlying an existing relationship\n changes (via the `fetchUnloadedReferences` method).\n */\n fetchMany: function(type, references, owner) {\n if (!references.length) { return; }\n\n var ids = map(references, function(reference) {\n return reference.id;\n });\n\n var adapter = this.adapterForType(type);\n if (adapter && adapter.findMany) { adapter.findMany(this, type, ids, owner); }\n else { throw \"Adapter is either null or does not implement `findMany` method\"; }\n },\n\n referenceForId: function(type, id) {\n var clientId = this.clientIdForId(type, id);\n return this.referenceForClientId(clientId);\n },\n\n referenceForClientId: function(clientId) {\n var references = this.recordReferences;\n\n if (references[clientId]) {\n return references[clientId];\n }\n\n var type = this.clientIdToType[clientId];\n\n return references[clientId] = {\n id: this.idForClientId(clientId),\n clientId: clientId,\n type: type\n };\n },\n\n recordForReference: function(reference) {\n return this.findByClientId(reference.type, reference.clientId);\n },\n\n /**\n @private\n\n `findMany` is the entry point that relationships use to generate a\n new `ManyArray` for the list of IDs specified by the server for\n the relationship.\n\n Its responsibilities are:\n\n * convert the IDs into clientIds\n * determine which of the clientIds still need to be loaded\n * create a new ManyArray whose content is *all* of the clientIds\n * notify the ManyArray of the number of its elements that are\n already loaded\n * insert the unloaded clientIds into the `loadingRecordArrays`\n bookkeeping structure, which will allow the `ManyArray` to know\n when all of its loading elements are loaded from the server.\n * ask the adapter to load the unloaded elements, by invoking\n findMany with the still-unloaded IDs.\n */\n findMany: function(type, ids, record, relationship) {\n // 1. Convert ids to client ids\n // 2. Determine which of the client ids need to be loaded\n // 3. Create a new ManyArray whose content is ALL of the clientIds\n // 4. Decrement the ManyArray's counter by the number of loaded clientIds\n // 5. Put the ManyArray into our bookkeeping data structure, keyed on\n // the needed clientIds\n // 6. Ask the adapter to load the records for the unloaded clientIds (but\n // convert them back to ids)\n\n if (!Ember.isArray(ids)) {\n var adapter = this.adapterForType(type);\n if (adapter && adapter.findHasMany) { adapter.findHasMany(this, record, relationship, ids); }\n else { throw fmt(\"Adapter is either null or does not implement `findHasMany` method\", this); }\n\n return this.createManyArray(type, Ember.A());\n }\n\n // Coerce server IDs into Record Reference\n var references = map(ids, function(reference) {\n if (typeof reference !== 'object' && reference !== null) {\n return this.referenceForId(type, reference);\n }\n\n return reference;\n }, this);\n\n var neededReferences = this.neededReferences(type, references),\n manyArray = this.createManyArray(type, Ember.A(references)),\n loadingRecordArrays = this.loadingRecordArrays,\n reference, clientId, i, l;\n\n // Start the decrementing counter on the ManyArray at the number of\n // records we need to load from the adapter\n manyArray.loadingRecordsCount(neededReferences.length);\n\n if (neededReferences.length) {\n for (i=0, l=neededReferences.length; i<l; i++) {\n reference = neededReferences[i];\n clientId = reference.clientId;\n\n // keep track of the record arrays that a given loading record\n // is part of. This way, if the same record is in multiple\n // ManyArrays, all of their loading records counters will be\n // decremented when the adapter provides the data.\n if (loadingRecordArrays[clientId]) {\n loadingRecordArrays[clientId].push(manyArray);\n } else {\n this.loadingRecordArrays[clientId] = [ manyArray ];\n }\n }\n\n this.fetchMany(type, neededReferences, record);\n } else {\n // all requested records are available\n manyArray.set('isLoaded', true);\n\n Ember.run.once(function() {\n manyArray.trigger('didLoad');\n });\n }\n\n return manyArray;\n },\n\n /**\n @private\n\n This method delegates a query to the adapter. This is the one place where\n adapter-level semantics are exposed to the application.\n\n Exposing queries this way seems preferable to creating an abstract query\n language for all server-side queries, and then require all adapters to\n implement them.\n\n @param {Class} type\n @param {Object} query an opaque query to be used by the adapter\n @return {DS.AdapterPopulatedRecordArray}\n */\n findQuery: function(type, query) {\n var array = DS.AdapterPopulatedRecordArray.create({ type: type, query: query, content: Ember.A([]), store: this });\n var adapter = this.adapterForType(type);\n if (adapter && adapter.findQuery) { adapter.findQuery(this, type, query, array); }\n else { throw \"Adapter is either null or does not implement `findQuery` method\"; }\n return array;\n },\n\n /**\n @private\n\n This method returns an array of all records adapter can find.\n It triggers the adapter's `findAll` method to give it an opportunity to populate\n the array with records of that type.\n\n @param {Class} type\n @return {DS.AdapterPopulatedRecordArray}\n */\n findAll: function(type) {\n var array = this.all(type);\n this.fetchAll(type, array);\n return array;\n },\n\n /**\n @private\n */\n fetchAll: function(type, array) {\n var sinceToken = this.typeMapFor(type).sinceToken,\n adapter = this.adapterForType(type);\n\n set(array, 'isUpdating', true);\n\n if (adapter && adapter.findAll) { adapter.findAll(this, type, sinceToken); }\n else { throw \"Adapter is either null or does not implement `findAll` method\"; }\n },\n\n /**\n */\n sinceForType: function(type, sinceToken) {\n this.typeMapFor(type).sinceToken = sinceToken;\n },\n\n /**\n */\n didUpdateAll: function(type) {\n var findAllCache = this.typeMapFor(type).findAllCache;\n set(findAllCache, 'isUpdating', false);\n },\n\n /**\n This method returns a filtered array that contains all of the known records\n for a given type.\n\n Note that because it's just a filter, it will have any locally\n created records of the type.\n\n Also note that multiple calls to `all` for a given type will always\n return the same RecordArray.\n\n @param {Class} type\n @return {DS.RecordArray}\n */\n all: function(type) {\n var typeMap = this.typeMapFor(type),\n findAllCache = typeMap.findAllCache;\n\n if (findAllCache) { return findAllCache; }\n\n var array = DS.RecordArray.create({ type: type, content: Ember.A([]), store: this, isLoaded: true });\n this.registerRecordArray(array, type);\n\n typeMap.findAllCache = array;\n return array;\n },\n\n /**\n Takes a type and filter function, and returns a live RecordArray that\n remains up to date as new records are loaded into the store or created\n locally.\n\n The callback function takes a materialized record, and returns true\n if the record should be included in the filter and false if it should\n not.\n\n The filter function is called once on all records for the type when\n it is created, and then once on each newly loaded or created record.\n\n If any of a record's properties change, or if it changes state, the\n filter function will be invoked again to determine whether it should\n still be in the array.\n\n Note that the existence of a filter on a type will trigger immediate\n materialization of all loaded data for a given type, so you might\n not want to use filters for a type if you are loading many records\n into the store, many of which are not active at any given time.\n\n In this scenario, you might want to consider filtering the raw\n data before loading it into the store.\n\n @param {Class} type\n @param {Function} filter\n\n @return {DS.FilteredRecordArray}\n */\n filter: function(type, query, filter) {\n // allow an optional server query\n if (arguments.length === 3) {\n this.findQuery(type, query);\n } else if (arguments.length === 2) {\n filter = query;\n }\n\n var array = DS.FilteredRecordArray.create({ type: type, content: Ember.A([]), store: this, filterFunction: filter });\n\n this.registerRecordArray(array, type, filter);\n\n return array;\n },\n\n /**\n This method returns if a certain record is already loaded\n in the store. Use this function to know beforehand if a find()\n will result in a request or that it will be a cache hit.\n\n @param {Class} type\n @param {string} id\n @return {boolean}\n */\n recordIsLoaded: function(type, id) {\n return !Ember.isNone(this.typeMapFor(type).idToCid[id]);\n },\n\n // ............\n // . UPDATING .\n // ............\n\n /**\n @private\n\n If the adapter updates attributes or acknowledges creation\n or deletion, the record will notify the store to update its\n membership in any filters.\n\n To avoid thrashing, this method is invoked only once per\n run loop per record.\n\n @param {Class} type\n @param {Number|String} clientId\n @param {DS.Model} record\n */\n dataWasUpdated: function(type, reference, record) {\n // Because data updates are invoked at the end of the run loop,\n // it is possible that a record might be deleted after its data\n // has been modified and this method was scheduled to be called.\n //\n // If that's the case, the record would have already been removed\n // from all record arrays; calling updateRecordArrays would just\n // add it back. If the record is deleted, just bail. It shouldn't\n // give us any more trouble after this.\n\n if (get(record, 'isDeleted')) { return; }\n\n var cidToData = this.clientIdToData,\n clientId = reference.clientId,\n data = cidToData[clientId];\n\n if (typeof data === \"object\") {\n this.updateRecordArrays(type, clientId);\n }\n },\n\n // ..............\n // . PERSISTING .\n // ..............\n\n /**\n This method delegates committing to the store's implicit\n transaction.\n\n Calling this method is essentially a request to persist\n any changes to records that were not explicitly added to\n a transaction.\n */\n commit: function() {\n get(this, 'defaultTransaction').commit();\n },\n\n /**\n Adapters should call this method if they would like to acknowledge\n that all changes related to a record (other than relationship\n changes) have persisted.\n\n Because relationship changes affect multiple records, the adapter\n is responsible for acknowledging the change to the relationship\n directly (using `store.didUpdateRelationship`) when all aspects\n of the relationship change have persisted.\n\n It can be called for created, deleted or updated records.\n\n If the adapter supplies new data, that data will become the new\n canonical data for the record. That will result in blowing away\n all local changes and rematerializing the record with the new\n data (the \"sledgehammer\" approach).\n\n Alternatively, if the adapter does not supply new data, the record\n will collapse all local changes into its saved data. Subsequent\n rollbacks of the record will roll back to this point.\n\n If an adapter is acknowledging receipt of a newly created record\n that did not generate an id in the client, it *must* either\n provide data or explicitly invoke `store.didReceiveId` with\n the server-provided id.\n\n Note that an adapter may not supply new data when acknowledging\n a deleted record.\n\n @see DS.Store#didUpdateRelationship\n\n @param {DS.Model} record the in-flight record\n @param {Object} data optional data (see above)\n */\n didSaveRecord: function(record, data) {\n record.adapterDidCommit();\n\n if (data) {\n this.updateId(record, data);\n this.updateRecordData(record, data);\n } else {\n this.didUpdateAttributes(record);\n }\n },\n\n /**\n For convenience, if an adapter is performing a bulk commit, it can also\n acknowledge all of the records at once.\n\n If the adapter supplies an array of data, they must be in the same order as\n the array of records passed in as the first parameter.\n\n @param {#forEach} list a list of records whose changes the\n adapter is acknowledging. You can pass any object that\n has an ES5-like `forEach` method, including the\n `OrderedSet` objects passed into the adapter at commit\n time.\n @param {Array[Object]} dataList an Array of data. This\n parameter must be an integer-indexed Array-like.\n */\n didSaveRecords: function(list, dataList) {\n var i = 0;\n list.forEach(function(record) {\n this.didSaveRecord(record, dataList && dataList[i++]);\n }, this);\n },\n\n /**\n This method allows the adapter to specify that a record\n could not be saved because it had backend-supplied validation\n errors.\n\n The errors object must have keys that correspond to the\n attribute names. Once each of the specified attributes have\n changed, the record will automatically move out of the\n invalid state and be ready to commit again.\n\n TODO: We should probably automate the process of converting\n server names to attribute names using the existing serializer\n infrastructure.\n\n @param {DS.Model} record\n @param {Object} errors\n */\n recordWasInvalid: function(record, errors) {\n record.adapterDidInvalidate(errors);\n },\n\n /**\n This method allows the adapter to specify that a record\n could not be saved because the server returned an unhandled\n error.\n\n @param {DS.Model} record\n */\n recordWasError: function(record) {\n record.adapterDidError();\n },\n\n /**\n This is a lower-level API than `didSaveRecord` that allows an\n adapter to acknowledge the persistence of a single attribute.\n\n This is useful if an adapter needs to make multiple asynchronous\n calls to fully persist a record. The record will keep track of\n which attributes and relationships are still outstanding and\n automatically move into the `saved` state once the adapter has\n acknowledged everything.\n\n If a value is provided, it clobbers the locally specified value.\n Otherwise, the local value becomes the record's last known\n saved value (which is used when rolling back a record).\n\n Note that the specified attributeName is the normalized name\n specified in the definition of the `DS.Model`, not a key in\n the server-provided data.\n\n Also note that the adapter is responsible for performing any\n transformations on the value using the serializer API.\n\n @param {DS.Model} record\n @param {String} attributeName\n @param {Object} value\n */\n didUpdateAttribute: function(record, attributeName, value) {\n record.adapterDidUpdateAttribute(attributeName, value);\n },\n\n /**\n This method allows an adapter to acknowledge persistence\n of all attributes of a record but not relationships or\n other factors.\n\n It loops through the record's defined attributes and\n notifies the record that they are all acknowledged.\n\n This method does not take optional values, because\n the adapter is unlikely to have a hash of normalized\n keys and transformed values, and instead of building\n one up, it should just call `didUpdateAttribute` as\n needed.\n\n This method is intended as a middle-ground between\n `didSaveRecord`, which acknowledges all changes to\n a record, and `didUpdateAttribute`, which allows an\n adapter fine-grained control over updates.\n\n @param {DS.Model} record\n */\n didUpdateAttributes: function(record) {\n record.eachAttribute(function(attributeName) {\n this.didUpdateAttribute(record, attributeName);\n }, this);\n },\n\n /**\n This allows an adapter to acknowledge that it has saved all\n necessary aspects of a relationship change.\n\n This is separated from acknowledging the record itself\n (via `didSaveRecord`) because a relationship change can\n involve as many as three separate records. Records should\n only move out of the in-flight state once the server has\n acknowledged all of their relationships, and this differs\n based upon the adapter's semantics.\n\n There are three basic scenarios by which an adapter can\n save a relationship.\n\n ### Foreign Key\n\n An adapter can save all relationship changes by updating\n a foreign key on the child record. If it does this, it\n should acknowledge the changes when the child record is\n saved.\n\n record.eachRelationship(function(name, meta) {\n if (meta.kind === 'belongsTo') {\n store.didUpdateRelationship(record, name);\n }\n });\n\n store.didSaveRecord(record, data);\n\n ### Embedded in Parent\n\n An adapter can save one-to-many relationships by embedding\n IDs (or records) in the parent object. In this case, the\n relationship is not considered acknowledged until both the\n old parent and new parent have acknowledged the change.\n\n In this case, the adapter should keep track of the old\n parent and new parent, and acknowledge the relationship\n change once both have acknowledged. If one of the two\n sides does not exist (e.g. the new parent does not exist\n because of nulling out the belongs-to relationship),\n the adapter should acknowledge the relationship once\n the other side has acknowledged.\n\n ### Separate Entity\n\n An adapter can save relationships as separate entities\n on the server. In this case, they should acknowledge\n the relationship as saved once the server has\n acknowledged the entity.\n\n @see DS.Store#didSaveRecord\n\n @param {DS.Model} record\n @param {DS.Model} relationshipName\n */\n didUpdateRelationship: function(record, relationshipName) {\n var relationship = this.relationshipChangeFor(get(record, 'clientId'), relationshipName);\n //TODO(Igor)\n if (relationship) { relationship.adapterDidUpdate(); }\n },\n\n /**\n This allows an adapter to acknowledge all relationship changes\n for a given record.\n\n Like `didUpdateAttributes`, this is intended as a middle ground\n between `didSaveRecord` and fine-grained control via the\n `didUpdateRelationship` API.\n */\n didUpdateRelationships: function(record) {\n var changes = this.relationshipChangesFor(get(record, '_reference'));\n\n for (var name in changes) {\n if (!changes.hasOwnProperty(name)) { continue; }\n changes[name].adapterDidUpdate();\n }\n },\n\n /**\n When acknowledging the creation of a locally created record,\n adapters must supply an id (if they did not implement\n `generateIdForRecord` to generate an id locally).\n\n If an adapter does not use `didSaveRecord` and supply a hash\n (for example, if it needs to make multiple HTTP requests to\n create and then update the record), it will need to invoke\n `didReceiveId` with the backend-supplied id.\n\n When not using `didSaveRecord`, an adapter will need to\n invoke:\n\n * didReceiveId (unless the id was generated locally)\n * didCreateRecord\n * didUpdateAttribute(s)\n * didUpdateRelationship(s)\n\n @param {DS.Model} record\n @param {Number|String} id\n */\n didReceiveId: function(record, id) {\n var typeMap = this.typeMapFor(record.constructor),\n clientId = get(record, 'clientId'),\n oldId = get(record, 'id');\n\n Ember.assert(\"An adapter cannot assign a new id to a record that already has an id. \" + record + \" had id: \" + oldId + \" and you tried to update it with \" + id + \". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.\", oldId === undefined || id === oldId);\n\n typeMap.idToCid[id] = clientId;\n this.clientIdToId[clientId] = id;\n },\n\n /**\n @private\n\n This method re-indexes the data by its clientId in the store\n and then notifies the record that it should rematerialize\n itself.\n\n @param {DS.Model} record\n @param {Object} data\n */\n updateRecordData: function(record, data) {\n var clientId = get(record, 'clientId'),\n cidToData = this.clientIdToData;\n\n cidToData[clientId] = data;\n\n record.didChangeData();\n },\n\n /**\n @private\n\n If an adapter invokes `didSaveRecord` with data, this method\n extracts the id from the supplied data (using the adapter's\n `extractId()` method) and indexes the clientId with that id.\n\n @param {DS.Model} record\n @param {Object} data\n */\n updateId: function(record, data) {\n var typeMap = this.typeMapFor(record.constructor),\n clientId = get(record, 'clientId'),\n oldId = get(record, 'id'),\n type = record.constructor,\n id = this.preprocessData(type, data);\n\n Ember.assert(\"An adapter cannot assign a new id to a record that already has an id. \" + record + \" had id: \" + oldId + \" and you tried to update it with \" + id + \". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.\", oldId === null || id === oldId);\n\n typeMap.idToCid[id] = clientId;\n this.clientIdToId[clientId] = id;\n this.referenceForClientId(clientId).id = id;\n },\n\n /**\n @private\n\n This method receives opaque data provided by the adapter and\n preprocesses it, returning an ID.\n\n The actual preprocessing takes place in the adapter. If you would\n like to change the default behavior, you should override the\n appropriate hooks in `DS.Serializer`.\n\n @see {DS.Serializer}\n @return {String} id the id represented by the data\n */\n preprocessData: function(type, data) {\n return this.adapterForType(type).extractId(type, data);\n },\n\n // .................\n // . RECORD ARRAYS .\n // .................\n\n /**\n @private\n\n Register a RecordArray for a given type to be backed by\n a filter function. This will cause the array to update\n automatically when records of that type change attribute\n values or states.\n\n @param {DS.RecordArray} array\n @param {Class} type\n @param {Function} filter\n */\n registerRecordArray: function(array, type, filter) {\n var recordArrays = this.typeMapFor(type).recordArrays;\n\n recordArrays.push(array);\n\n this.updateRecordArrayFilter(array, type, filter);\n },\n\n /**\n @private\n\n Create a `DS.ManyArray` for a type and list of clientIds\n and index the `ManyArray` under each clientId. This allows\n us to efficiently remove records from `ManyArray`s when\n they are deleted.\n\n @param {Class} type\n @param {Array} clientIds\n\n @return {DS.ManyArray}\n */\n createManyArray: function(type, clientIds) {\n var array = DS.ManyArray.create({ type: type, content: clientIds, store: this });\n\n clientIds.forEach(function(clientId) {\n var recordArrays = this.recordArraysForClientId(clientId);\n recordArrays.add(array);\n }, this);\n\n return array;\n },\n\n /**\n @private\n\n This method is invoked if the `filterFunction` property is\n changed on a `DS.FilteredRecordArray`.\n\n It essentially re-runs the filter from scratch. This same\n method is invoked when the filter is created in th first place.\n */\n updateRecordArrayFilter: function(array, type, filter) {\n var typeMap = this.typeMapFor(type),\n cidToData = this.clientIdToData,\n clientIds = typeMap.clientIds,\n clientId, data, shouldFilter, record;\n\n for (var i=0, l=clientIds.length; i<l; i++) {\n clientId = clientIds[i];\n shouldFilter = false;\n\n data = cidToData[clientId];\n\n if (typeof data === 'object') {\n if (record = this.recordCache[clientId]) {\n if (!get(record, 'isDeleted')) { shouldFilter = true; }\n } else {\n shouldFilter = true;\n }\n\n if (shouldFilter) {\n this.updateRecordArray(array, filter, type, clientId);\n }\n }\n }\n },\n\n updateRecordArraysLater: function(type, clientId) {\n Ember.run.once(this, function() {\n this.updateRecordArrays(type, clientId);\n });\n },\n\n /**\n @private\n\n This method is invoked whenever data is loaded into the store\n by the adapter or updated by the adapter, or when an attribute\n changes on a record.\n\n It updates all filters that a record belongs to.\n\n To avoid thrashing, it only runs once per run loop per record.\n\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArrays: function(type, clientId) {\n var recordArrays = this.typeMapFor(type).recordArrays,\n filter;\n\n recordArrays.forEach(function(array) {\n filter = get(array, 'filterFunction');\n this.updateRecordArray(array, filter, type, clientId);\n }, this);\n\n // loop through all manyArrays containing an unloaded copy of this\n // clientId and notify them that the record was loaded.\n var manyArrays = this.loadingRecordArrays[clientId];\n\n if (manyArrays) {\n for (var i=0, l=manyArrays.length; i<l; i++) {\n manyArrays[i].loadedRecord();\n }\n\n this.loadingRecordArrays[clientId] = null;\n }\n },\n\n /**\n @private\n\n Update an individual filter.\n\n @param {DS.FilteredRecordArray} array\n @param {Function} filter\n @param {Class} type\n @param {Number|String} clientId\n */\n updateRecordArray: function(array, filter, type, clientId) {\n var shouldBeInArray, record;\n\n if (!filter) {\n shouldBeInArray = true;\n } else {\n record = this.findByClientId(type, clientId);\n shouldBeInArray = filter(record);\n }\n\n var content = get(array, 'content');\n var alreadyInArray = content.indexOf(clientId) !== -1;\n\n var recordArrays = this.recordArraysForClientId(clientId);\n var reference = this.referenceForClientId(clientId);\n\n if (shouldBeInArray) {\n recordArrays.add(array);\n array.addReference(reference);\n } else if (!shouldBeInArray) {\n recordArrays.remove(array);\n array.removeReference(reference);\n }\n },\n\n /**\n @private\n\n When a record is deleted, it is removed from all its\n record arrays.\n\n @param {DS.Model} record\n */\n removeFromRecordArrays: function(record) {\n var reference = get(record, '_reference');\n var recordArrays = this.recordArraysForClientId(reference.clientId);\n\n recordArrays.forEach(function(array) {\n array.removeReference(reference);\n });\n },\n\n // ............\n // . INDEXING .\n // ............\n\n /**\n @private\n\n Return a list of all `DS.RecordArray`s a clientId is\n part of.\n\n @return {Object(clientId: Ember.OrderedSet)}\n */\n recordArraysForClientId: function(clientId) {\n var recordArrays = get(this, 'recordArraysByClientId');\n var ret = recordArrays[clientId];\n\n if (!ret) {\n ret = recordArrays[clientId] = Ember.OrderedSet.create();\n }\n\n return ret;\n },\n\n typeMapFor: function(type) {\n var typeMaps = get(this, 'typeMaps');\n var guidForType = Ember.guidFor(type);\n\n var typeMap = typeMaps[guidForType];\n\n if (typeMap) {\n return typeMap;\n } else {\n return (typeMaps[guidForType] =\n {\n idToCid: {},\n clientIds: [],\n recordArrays: []\n });\n }\n },\n\n /** @private\n\n For a given type and id combination, returns the client id used by the store.\n If no client id has been assigned yet, one will be created and returned.\n\n @param {DS.Model} type\n @param {String|Number} id\n */\n clientIdForId: function(type, id) {\n id = coerceId(id);\n\n var clientId = this.typeMapFor(type).idToCid[id];\n if (clientId !== undefined) { return clientId; }\n\n return this.pushData(UNLOADED, id, type);\n },\n\n /**\n @private\n\n This method works exactly like `clientIdForId`, but does not\n require looking up the `typeMap` for every `clientId` and\n invoking a method per `clientId`.\n */\n clientIdsForIds: function(type, ids) {\n var typeMap = this.typeMapFor(type),\n idToClientIdMap = typeMap.idToCid;\n\n return map(ids, function(id) {\n id = coerceId(id);\n\n var clientId = idToClientIdMap[id];\n if (clientId) { return clientId; }\n return this.pushData(UNLOADED, id, type);\n }, this);\n },\n\n typeForClientId: function(clientId) {\n return this.clientIdToType[clientId];\n },\n\n idForClientId: function(clientId) {\n return this.clientIdToId[clientId];\n },\n\n // ................\n // . LOADING DATA .\n // ................\n\n /**\n Load new data into the store for a given id and type combination.\n If data for that record had been loaded previously, the new information\n overwrites the old.\n\n If the record you are loading data for has outstanding changes that have not\n yet been saved, an exception will be thrown.\n\n @param {DS.Model} type\n @param {String|Number} id\n @param {Object} data the data to load\n */\n load: function(type, data, prematerialized) {\n var id;\n\n if (typeof data === 'number' || typeof data === 'string') {\n id = data;\n data = prematerialized;\n prematerialized = null;\n }\n\n if (prematerialized && prematerialized.id) {\n id = prematerialized.id;\n } else if (id === undefined) {\n var adapter = this.adapterForType(type);\n id = this.preprocessData(type, data);\n }\n\n id = coerceId(id);\n\n var typeMap = this.typeMapFor(type),\n cidToData = this.clientIdToData,\n clientId = typeMap.idToCid[id],\n cidToPrematerialized = this.clientIdToPrematerializedData;\n\n if (clientId !== undefined) {\n cidToData[clientId] = data;\n cidToPrematerialized[clientId] = prematerialized;\n\n var record = this.recordCache[clientId];\n if (record) {\n once(record, 'loadedData');\n }\n } else {\n clientId = this.pushData(data, id, type);\n cidToPrematerialized[clientId] = prematerialized;\n }\n\n this.updateRecordArraysLater(type, clientId);\n\n return this.referenceForClientId(clientId);\n },\n\n prematerialize: function(reference, prematerialized) {\n this.clientIdToPrematerializedData[reference.clientId] = prematerialized;\n },\n\n loadMany: function(type, ids, dataList) {\n if (dataList === undefined) {\n dataList = ids;\n ids = map(dataList, function(data) {\n return this.preprocessData(type, data);\n }, this);\n }\n\n return map(ids, function(id, i) {\n return this.load(type, id, dataList[i]);\n }, this);\n },\n\n loadHasMany: function(record, key, ids) {\n record.materializeHasMany(key, ids);\n\n // Update any existing many arrays that use the previous IDs,\n // if necessary.\n record.hasManyDidChange(key);\n\n var relationship = record.cacheFor(key);\n\n // TODO (tomdale) this assumes that loadHasMany *always* means\n // that the records for the provided IDs are loaded.\n if (relationship) { set(relationship, 'isLoaded', true); }\n },\n\n /** @private\n\n Stores data for the specified type and id combination and returns\n the client id.\n\n @param {Object} data\n @param {String|Number} id\n @param {DS.Model} type\n @returns {Number}\n */\n pushData: function(data, id, type) {\n var typeMap = this.typeMapFor(type);\n\n var idToClientIdMap = typeMap.idToCid,\n clientIdToIdMap = this.clientIdToId,\n clientIdToTypeMap = this.clientIdToType,\n clientIds = typeMap.clientIds,\n cidToData = this.clientIdToData;\n\n var clientId = ++this.clientIdCounter;\n\n cidToData[clientId] = data;\n clientIdToTypeMap[clientId] = type;\n\n // if we're creating an item, this process will be done\n // later, once the object has been persisted.\n if (id) {\n idToClientIdMap[id] = clientId;\n clientIdToIdMap[clientId] = id;\n }\n\n clientIds.push(clientId);\n\n return clientId;\n },\n\n // ..........................\n // . RECORD MATERIALIZATION .\n // ..........................\n\n materializeRecord: function(type, clientId, id) {\n var record;\n\n this.recordCache[clientId] = record = type._create({\n store: this,\n clientId: clientId,\n });\n\n set(record, 'id', id);\n\n get(this, 'defaultTransaction').adoptRecord(record);\n\n record.loadingData();\n return record;\n },\n\n dematerializeRecord: function(record) {\n var id = get(record, 'id'),\n clientId = get(record, 'clientId'),\n type = this.typeForClientId(clientId),\n typeMap = this.typeMapFor(type);\n\n record.updateRecordArrays();\n\n delete this.recordCache[clientId];\n delete this.clientIdToId[clientId];\n delete this.clientIdToType[clientId];\n delete this.clientIdToData[clientId];\n delete this.recordArraysByClientId[clientId];\n\n if (id) { delete typeMap.idToCid[id]; }\n },\n\n willDestroy: function() {\n if (get(DS, 'defaultStore') === this) {\n set(DS, 'defaultStore', null);\n }\n },\n\n // ........................\n // . RELATIONSHIP CHANGES .\n // ........................\n\n addRelationshipChangeFor: function(clientReference, childKey, parentReference, parentKey, change) {\n var clientId = clientReference.clientId,\n parentClientId = parentReference ? parentReference.clientId : parentReference;\n var key = childKey + parentKey;\n var changes = this.relationshipChanges;\n if (!(clientId in changes)) {\n changes[clientId] = {};\n }\n if (!(parentClientId in changes[clientId])) {\n changes[clientId][parentClientId] = {};\n }\n if (!(key in changes[clientId][parentClientId])) {\n changes[clientId][parentClientId][key] = {};\n }\n changes[clientId][parentClientId][key][change.changeType] = change;\n },\n\n removeRelationshipChangeFor: function(clientReference, childKey, parentReference, parentKey, type) {\n var clientId = clientReference.clientId,\n parentClientId = parentReference ? parentReference.clientId : parentReference;\n var changes = this.relationshipChanges;\n var key = childKey + parentKey;\n if (!(clientId in changes) || !(parentClientId in changes[clientId]) || !(key in changes[clientId][parentClientId])){\n return;\n }\n delete changes[clientId][parentClientId][key][type];\n },\n\n relationshipChangeFor: function(clientId, childKey, parentClientId, parentKey, type) {\n var changes = this.relationshipChanges;\n var key = childKey + parentKey;\n if (!(clientId in changes) || !(parentClientId in changes[clientId])){\n return;\n }\n if(type){\n return changes[clientId][parentClientId][key][type];\n }\n else{\n //TODO(Igor) what if both present\n return changes[clientId][parentClientId][key][\"add\"] || changes[clientId][parentClientId][key][\"remove\"];\n }\n },\n\n relationshipChangePairsFor: function(reference){\n var toReturn = [];\n\n if( !reference ) { return toReturn; }\n\n //TODO(Igor) What about the other side\n var changesObject = this.relationshipChanges[reference.clientId];\n for (var objKey in changesObject){\n if(changesObject.hasOwnProperty(objKey)){\n for (var changeKey in changesObject[objKey]){\n if(changesObject[objKey].hasOwnProperty(changeKey)){\n toReturn.push(changesObject[objKey][changeKey]);\n }\n }\n }\n }\n return toReturn;\n },\n\n relationshipChangesFor: function(reference) {\n var toReturn = [];\n\n if( !reference ) { return toReturn; }\n\n var relationshipPairs = this.relationshipChangePairsFor(reference);\n forEach(relationshipPairs, function(pair){\n var addedChange = pair[\"add\"];\n var removedChange = pair[\"remove\"];\n if(addedChange){\n toReturn.push(addedChange);\n }\n if(removedChange){\n toReturn.push(removedChange);\n }\n });\n return toReturn;\n },\n // ......................\n // . PER-TYPE ADAPTERS\n // ......................\n\n adapterForType: function(type) {\n this._adaptersMap = this.createInstanceMapFor('adapters');\n\n var adapter = this._adaptersMap.get(type);\n if (adapter) { return adapter; }\n\n return this.get('_adapter');\n },\n\n // ..............................\n // . RECORD CHANGE NOTIFICATION .\n // ..............................\n\n recordAttributeDidChange: function(reference, attributeName, newValue, oldValue) {\n var record = this.recordForReference(reference),\n dirtySet = new Ember.OrderedSet(),\n adapter = this.adapterForType(record.constructor);\n\n if (adapter.dirtyRecordsForAttributeChange) {\n adapter.dirtyRecordsForAttributeChange(dirtySet, record, attributeName, newValue, oldValue);\n }\n\n dirtySet.forEach(function(record) {\n record.adapterDidDirty();\n });\n },\n\n recordBelongsToDidChange: function(dirtySet, child, relationship) {\n var adapter = this.adapterForType(child.constructor);\n\n if (adapter.dirtyRecordsForBelongsToChange) {\n adapter.dirtyRecordsForBelongsToChange(dirtySet, child, relationship);\n }\n\n // adapterDidDirty is called by the RelationshipChange that created\n // the dirtySet.\n },\n\n recordHasManyDidChange: function(dirtySet, parent, relationship) {\n var adapter = this.adapterForType(parent.constructor);\n\n if (adapter.dirtyRecordsForHasManyChange) {\n adapter.dirtyRecordsForHasManyChange(dirtySet, parent, relationship);\n }\n\n // adapterDidDirty is called by the RelationshipChange that created\n // the dirtySet.\n }\n});\n\nDS.Store.reopenClass({\n registerAdapter: DS._Mappable.generateMapFunctionFor('adapters', function(type, adapter, map) {\n map.set(type, adapter);\n }),\n\n transformMapKey: function(key) {\n if (typeof key === 'string') {\n var transformedKey;\n transformedKey = get(Ember.lookup, key);\n Ember.assert(\"Could not find model at path \" + key, transformedKey);\n return transformedKey;\n } else {\n return key;\n }\n },\n\n transformMapValue: function(key, value) {\n if (Ember.Object.detect(value)) {\n return value.create();\n }\n\n return value;\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/store");minispade.register('ember-data/system/transaction', "(function() {var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt,\n removeObject = Ember.EnumerableUtils.removeObject, forEach = Ember.EnumerableUtils.forEach;\n\n/**\n A transaction allows you to collect multiple records into a unit of work\n that can be committed or rolled back as a group.\n\n For example, if a record has local modifications that have not yet\n been saved, calling `commit()` on its transaction will cause those\n modifications to be sent to the adapter to be saved. Calling\n `rollback()` on its transaction would cause all of the modifications to\n be discarded and the record to return to the last known state before\n changes were made.\n\n If a newly created record's transaction is rolled back, it will\n immediately transition to the deleted state.\n\n If you do not explicitly create a transaction, a record is assigned to\n an implicit transaction called the default transaction. In these cases,\n you can treat your application's instance of `DS.Store` as a transaction\n and call the `commit()` and `rollback()` methods on the store itself.\n\n Once a record has been successfully committed or rolled back, it will\n be moved back to the implicit transaction. Because it will now be in\n a clean state, it can be moved to a new transaction if you wish.\n\n ### Creating a Transaction\n\n To create a new transaction, call the `transaction()` method of your\n application's `DS.Store` instance:\n\n var transaction = App.store.transaction();\n\n This will return a new instance of `DS.Transaction` with no records\n yet assigned to it.\n\n ### Adding Existing Records\n\n Add records to a transaction using the `add()` method:\n\n record = App.store.find(App.Person, 1);\n transaction.add(record);\n\n Note that only records whose `isDirty` flag is `false` may be added\n to a transaction. Once modifications to a record have been made\n (its `isDirty` flag is `true`), it is not longer able to be added to\n a transaction.\n\n ### Creating New Records\n\n Because newly created records are dirty from the time they are created,\n and because dirty records can not be added to a transaction, you must\n use the `createRecord()` method to assign new records to a transaction.\n\n For example, instead of this:\n\n var transaction = store.transaction();\n var person = App.Person.createRecord({ name: \"Steve\" });\n\n // won't work because person is dirty\n transaction.add(person);\n\n Call `createRecord()` on the transaction directly:\n\n var transaction = store.transaction();\n transaction.createRecord(App.Person, { name: \"Steve\" });\n\n ### Asynchronous Commits\n\n Typically, all of the records in a transaction will be committed\n together. However, new records that have a dependency on other new\n records need to wait for their parent record to be saved and assigned an\n ID. In that case, the child record will continue to live in the\n transaction until its parent is saved, at which time the transaction will\n attempt to commit again.\n\n For this reason, you should not re-use transactions once you have committed\n them. Always make a new transaction and move the desired records to it before\n calling commit.\n*/\n\nvar arrayDefault = function() { return []; };\n\nDS.Transaction = Ember.Object.extend({\n /**\n @private\n\n Creates the bucket data structure used to segregate records by\n type.\n */\n init: function() {\n set(this, 'buckets', {\n clean: Ember.OrderedSet.create(),\n created: Ember.OrderedSet.create(),\n updated: Ember.OrderedSet.create(),\n deleted: Ember.OrderedSet.create(),\n inflight: Ember.OrderedSet.create()\n });\n\n set(this, 'relationships', Ember.OrderedSet.create());\n },\n\n /**\n Creates a new record of the given type and assigns it to the transaction\n on which the method was called.\n\n This is useful as only clean records can be added to a transaction and\n new records created using other methods immediately become dirty.\n\n @param {DS.Model} type the model type to create\n @param {Object} hash the data hash to assign the new record\n */\n createRecord: function(type, hash) {\n var store = get(this, 'store');\n\n return store.createRecord(type, hash, this);\n },\n\n isEqualOrDefault: function(other) {\n if (this === other || other === get(this, 'store.defaultTransaction')) {\n return true;\n }\n },\n\n isDefault: Ember.computed(function() {\n return this === get(this, 'store.defaultTransaction');\n }),\n\n /**\n Adds an existing record to this transaction. Only records without\n modficiations (i.e., records whose `isDirty` property is `false`)\n can be added to a transaction.\n\n @param {DS.Model} record the record to add to the transaction\n */\n add: function(record) {\n Ember.assert(\"You must pass a record into transaction.add()\", record instanceof DS.Model);\n\n var recordTransaction = get(record, 'transaction'),\n defaultTransaction = get(this, 'store.defaultTransaction');\n\n // Make `add` idempotent\n if (recordTransaction === this) { return; }\n\n // XXX it should be possible to move a dirty transaction from the default transaction\n\n // we could probably make this work if someone has a valid use case. Do you?\n Ember.assert(\"Once a record has changed, you cannot move it into a different transaction\", !get(record, 'isDirty'));\n\n Ember.assert(\"Models cannot belong to more than one transaction at a time.\", recordTransaction === defaultTransaction);\n\n this.adoptRecord(record);\n },\n\n relationshipBecameDirty: function(relationship) {\n get(this, 'relationships').add(relationship);\n },\n\n relationshipBecameClean: function(relationship) {\n get(this, 'relationships').remove(relationship);\n },\n\n /**\n Commits the transaction, which causes all of the modified records that\n belong to the transaction to be sent to the adapter to be saved.\n\n Once you call `commit()` on a transaction, you should not re-use it.\n\n When a record is saved, it will be removed from this transaction and\n moved back to the store's default transaction.\n */\n commit: function() {\n var store = get(this, 'store');\n var adapter = get(store, '_adapter');\n var defaultTransaction = get(store, 'defaultTransaction');\n\n var iterate = function(records) {\n var set = records.copy();\n set.forEach(function (record) {\n record.send('willCommit');\n });\n return set;\n };\n\n var relationships = get(this, 'relationships');\n\n var commitDetails = {\n created: iterate(this.bucketForType('created')),\n updated: iterate(this.bucketForType('updated')),\n deleted: iterate(this.bucketForType('deleted')),\n relationships: relationships\n };\n\n if (this === defaultTransaction) {\n set(store, 'defaultTransaction', store.transaction());\n }\n\n this.removeCleanRecords();\n\n if (!commitDetails.created.isEmpty() || !commitDetails.updated.isEmpty() || !commitDetails.deleted.isEmpty() || !relationships.isEmpty()) {\n if (adapter && adapter.commit) { adapter.commit(store, commitDetails); }\n else { throw fmt(\"Adapter is either null or does not implement `commit` method\", this); }\n }\n\n // Once we've committed the transaction, there is no need to\n // keep the OneToManyChanges around. Destroy them so they\n // can be garbage collected.\n relationships.forEach(function(relationship) {\n relationship.destroy();\n });\n },\n\n /**\n Rolling back a transaction resets the records that belong to\n that transaction.\n\n Updated records have their properties reset to the last known\n value from the persistence layer. Deleted records are reverted\n to a clean, non-deleted state. Newly created records immediately\n become deleted, and are not sent to the adapter to be persisted.\n\n After the transaction is rolled back, any records that belong\n to it will return to the store's default transaction, and the\n current transaction should not be used again.\n */\n rollback: function() {\n // Loop through all of the records in each of the dirty states\n // and initiate a rollback on them. As a side effect of telling\n // the record to roll back, it should also move itself out of\n // the dirty bucket and into the clean bucket.\n ['created', 'updated', 'deleted', 'inflight'].forEach(function(bucketType) {\n var records = this.bucketForType(bucketType);\n forEach(records, function(record) {\n record.send('rollback');\n });\n records.clear();\n }, this);\n\n // Now that all records in the transaction are guaranteed to be\n // clean, migrate them all to the store's default transaction.\n this.removeCleanRecords();\n },\n\n /**\n @private\n\n Removes a record from this transaction and back to the store's\n default transaction.\n\n Note: This method is private for now, but should probably be exposed\n in the future once we have stricter error checking (for example, in the\n case of the record being dirty).\n\n @param {DS.Model} record\n */\n remove: function(record) {\n var defaultTransaction = get(this, 'store.defaultTransaction');\n defaultTransaction.adoptRecord(record);\n },\n\n /**\n @private\n\n Removes all of the records in the transaction's clean bucket.\n */\n removeCleanRecords: function() {\n var clean = this.bucketForType('clean');\n clean.forEach(function(record) {\n this.remove(record);\n }, this);\n clean.clear();\n },\n\n /**\n @private\n\n Returns the bucket for the given bucket type. For example, you might call\n `this.bucketForType('updated')` to get the `Ember.Map` that contains all\n of the records that have changes pending.\n\n @param {String} bucketType the type of bucket\n @returns Ember.Map\n */\n bucketForType: function(bucketType) {\n var buckets = get(this, 'buckets');\n\n return get(buckets, bucketType);\n },\n\n /**\n @private\n\n This method moves a record into a different transaction without the normal\n checks that ensure that the user is not doing something weird, like moving\n a dirty record into a new transaction.\n\n It is designed for internal use, such as when we are moving a clean record\n into a new transaction when the transaction is committed.\n\n This method must not be called unless the record is clean.\n\n @param {DS.Model} record\n */\n adoptRecord: function(record) {\n var oldTransaction = get(record, 'transaction');\n\n if (oldTransaction) {\n oldTransaction.removeFromBucket('clean', record);\n }\n\n this.addToBucket('clean', record);\n set(record, 'transaction', this);\n },\n\n /**\n @private\n\n Adds a record to the named bucket.\n\n @param {String} bucketType one of `clean`, `created`, `updated`, or `deleted`\n */\n addToBucket: function(bucketType, record) {\n this.bucketForType(bucketType).add(record);\n },\n\n /**\n @private\n\n Removes a record from the named bucket.\n\n @param {String} bucketType one of `clean`, `created`, `updated`, or `deleted`\n */\n removeFromBucket: function(bucketType, record) {\n this.bucketForType(bucketType).remove(record);\n },\n\n /**\n @private\n\n Called by a record's state manager to indicate that the record has entered\n a dirty state. The record will be moved from the `clean` bucket and into\n the appropriate dirty bucket.\n\n @param {String} bucketType one of `created`, `updated`, or `deleted`\n */\n recordBecameDirty: function(bucketType, record) {\n this.removeFromBucket('clean', record);\n this.addToBucket(bucketType, record);\n },\n\n /**\n @private\n\n Called by a record's state manager to indicate that the record has entered\n inflight state. The record will be moved from its current dirty bucket and into\n the `inflight` bucket.\n\n @param {String} bucketType one of `created`, `updated`, or `deleted`\n */\n recordBecameInFlight: function(kind, record) {\n this.removeFromBucket(kind, record);\n this.addToBucket('inflight', record);\n },\n\n recordIsMoving: function(kind, record) {\n this.removeFromBucket(kind, record);\n this.addToBucket('clean', record);\n },\n\n /**\n @private\n\n Called by a record's state manager to indicate that the record has entered\n a clean state. The record will be moved from its current dirty or inflight bucket and into\n the `clean` bucket.\n\n @param {String} bucketType one of `created`, `updated`, or `deleted`\n */\n recordBecameClean: function(kind, record) {\n this.removeFromBucket(kind, record);\n this.remove(record);\n }\n});\n\n})();\n//@ sourceURL=ember-data/system/transaction");minispade.register('ember-data/transforms/json_transforms', "(function() {var none = Ember.isNone;\n\n/**\n DS.Transforms is a hash of transforms used by DS.Serializer.\n*/\nDS.JSONTransforms = {\n string: {\n deserialize: function(serialized) {\n return none(serialized) ? null : String(serialized);\n },\n\n serialize: function(deserialized) {\n return none(deserialized) ? null : String(deserialized);\n }\n },\n\n number: {\n deserialize: function(serialized) {\n return none(serialized) ? null : Number(serialized);\n },\n\n serialize: function(deserialized) {\n return none(deserialized) ? null : Number(deserialized);\n }\n },\n\n // Handles the following boolean inputs:\n // \"TrUe\", \"t\", \"f\", \"FALSE\", 0, (non-zero), or boolean true/false\n 'boolean': {\n deserialize: function(serialized) {\n var type = typeof serialized;\n\n if (type === \"boolean\") {\n return serialized;\n } else if (type === \"string\") {\n return serialized.match(/^true$|^t$|^1$/i) !== null;\n } else if (type === \"number\") {\n return serialized === 1;\n } else {\n return false;\n }\n },\n\n serialize: function(deserialized) {\n return Boolean(deserialized);\n }\n },\n\n date: {\n deserialize: function(serialized) {\n var type = typeof serialized;\n var date = null;\n\n if (type === \"string\" || type === \"number\") {\n // this is a fix for Safari 5.1.5 on Mac which does not accept timestamps as yyyy-mm-dd\n if (type === \"string\" && serialized.search(/^\\d{4}-\\d{2}-\\d{2}$/) !== -1) {\n serialized += \"T00:00:00Z\";\n }\n\n date = new Date(serialized);\n\n // this is a fix for IE8 which does not accept timestamps in ISO 8601 format\n if (type === \"string\" && isNaN(date)) {\n date = new Date(Date.parse(serialized.replace(/\\-/ig, '/').replace(/Z$/, '').split('.')[0]));\n }\n\n return date;\n } else if (serialized === null || serialized === undefined) {\n // if the value is not present in the data,\n // return undefined, not null.\n return serialized;\n } else {\n return null;\n }\n },\n\n serialize: function(date) {\n if (date instanceof Date) {\n var days = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n var months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n var pad = function(num) {\n return num < 10 ? \"0\"+num : \"\"+num;\n };\n\n var utcYear = date.getUTCFullYear(),\n utcMonth = date.getUTCMonth(),\n utcDayOfMonth = date.getUTCDate(),\n utcDay = date.getUTCDay(),\n utcHours = date.getUTCHours(),\n utcMinutes = date.getUTCMinutes(),\n utcSeconds = date.getUTCSeconds();\n\n\n var dayOfWeek = days[utcDay];\n var dayOfMonth = pad(utcDayOfMonth);\n var month = months[utcMonth];\n\n return dayOfWeek + \", \" + dayOfMonth + \" \" + month + \" \" + utcYear + \" \" +\n pad(utcHours) + \":\" + pad(utcMinutes) + \":\" + pad(utcSeconds) + \" GMT\";\n } else if (date === undefined) {\n return undefined;\n } else {\n return null;\n }\n }\n }\n};\n\n})();\n//@ sourceURL=ember-data/transforms/json_transforms");minispade.register('ember', "(function() {// Version: v1.0.0-pre.2-154-g4eb5f08\n// Last commit: 4eb5f08 (2012-12-16 23:32:56 -0800)\n\n\n(function() {\n/*global __fail__*/\n\n/**\nEmber Debug\n\n@module ember\n@submodule ember-debug\n*/\n\n/**\n@class Ember\n*/\n\nif ('undefined' === typeof Ember) {\n Ember = {};\n\n if ('undefined' !== typeof window) {\n window.Em = window.Ember = Em = Ember;\n }\n}\n\nEmber.ENV = 'undefined' === typeof ENV ? {} : ENV;\n\nif (!('MANDATORY_SETTER' in Ember.ENV)) {\n Ember.ENV.MANDATORY_SETTER = true; // default to true for debug dist\n}\n\n/**\n Define an assertion that will throw an exception if the condition is not\n met. Ember build tools will remove any calls to `Ember.assert()` when\n doing a production build. Example:\n\n ```javascript\n // Test for truthiness\n Ember.assert('Must pass a valid object', obj);\n // Fail unconditionally\n Ember.assert('This code path should never be run')\n ```\n\n @method assert\n @param {String} desc A description of the assertion. This will become\n the text of the Error thrown if the assertion fails.\n @param {Boolean} test Must be truthy for the assertion to pass. If\n falsy, an exception will be thrown.\n*/\nEmber.assert = function(desc, test) {\n if (!test) throw new Error(\"assertion failed: \"+desc);\n};\n\n\n/**\n Display a warning with the provided message. Ember build tools will\n remove any calls to `Ember.warn()` when doing a production build.\n\n @method warn\n @param {String} message A warning to display.\n @param {Boolean} test An optional boolean. If falsy, the warning\n will be displayed.\n*/\nEmber.warn = function(message, test) {\n if (!test) {\n Ember.Logger.warn(\"WARNING: \"+message);\n if ('trace' in Ember.Logger) Ember.Logger.trace();\n }\n};\n\n/**\n Display a deprecation warning with the provided message and a stack trace\n (Chrome and Firefox only). Ember build tools will remove any calls to\n `Ember.deprecate()` when doing a production build.\n\n @method deprecate\n @param {String} message A description of the deprecation.\n @param {Boolean} test An optional boolean. If falsy, the deprecation\n will be displayed.\n*/\nEmber.deprecate = function(message, test) {\n if (Ember && Ember.TESTING_DEPRECATION) { return; }\n\n if (arguments.length === 1) { test = false; }\n if (test) { return; }\n\n if (Ember && Ember.ENV.RAISE_ON_DEPRECATION) { throw new Error(message); }\n\n var error;\n\n // When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome\n try { __fail__.fail(); } catch (e) { error = e; }\n\n if (Ember.LOG_STACKTRACE_ON_DEPRECATION && error.stack) {\n var stack, stackStr = '';\n if (error['arguments']) {\n // Chrome\n stack = error.stack.replace(/^\\s+at\\s+/gm, '').\n replace(/^([^\\(]+?)([\\n$])/gm, '{anonymous}($1)$2').\n replace(/^Object.<anonymous>\\s*\\(([^\\)]+)\\)/gm, '{anonymous}($1)').split('\\n');\n stack.shift();\n } else {\n // Firefox\n stack = error.stack.replace(/(?:\\n@:0)?\\s+$/m, '').\n replace(/^\\(/gm, '{anonymous}(').split('\\n');\n }\n\n stackStr = \"\\n \" + stack.slice(2).join(\"\\n \");\n message = message + stackStr;\n }\n\n Ember.Logger.warn(\"DEPRECATION: \"+message);\n};\n\n\n\n/**\n Display a deprecation warning with the provided message and a stack trace\n (Chrome and Firefox only) when the wrapped method is called.\n\n Ember build tools will not remove calls to `Ember.deprecateFunc()`, though\n no warnings will be shown in production.\n\n @method deprecateFunc\n @param {String} message A description of the deprecation.\n @param {Function} func The function to be deprecated.\n*/\nEmber.deprecateFunc = function(message, func) {\n return function() {\n Ember.deprecate(message);\n return func.apply(this, arguments);\n };\n};\n\nif ('undefined' !== typeof window) {\n window.ember_assert = Ember.deprecateFunc(\"ember_assert is deprecated. Please use Ember.assert instead.\", Ember.assert);\n window.ember_warn = Ember.deprecateFunc(\"ember_warn is deprecated. Please use Ember.warn instead.\", Ember.warn);\n window.ember_deprecate = Ember.deprecateFunc(\"ember_deprecate is deprecated. Please use Ember.deprecate instead.\", Ember.deprecate);\n window.ember_deprecateFunc = Ember.deprecateFunc(\"ember_deprecateFunc is deprecated. Please use Ember.deprecateFunc instead.\", Ember.deprecateFunc);\n}\n\n})();\n\n// Version: v1.0.0-pre.2-233-g2db13c3\n// Last commit: 2db13c3 (2012-12-30 16:18:06 -0800)\n\n\n(function() {\nvar define, requireModule;\n\n(function() {\n var registry = {}, seen = {};\n\n define = function(name, deps, callback) {\n registry[name] = { deps: deps, callback: callback };\n };\n\n requireModule = function(name) {\n if (seen[name]) { return seen[name]; }\n seen[name] = {};\n\n var mod = registry[name],\n deps = mod.deps,\n callback = mod.callback,\n reified = [],\n exports;\n\n for (var i=0, l=deps.length; i<l; i++) {\n if (deps[i] === 'exports') {\n reified.push(exports = {});\n } else {\n reified.push(requireModule(deps[i]));\n }\n }\n\n var value = callback.apply(this, reified);\n return seen[name] = exports || value;\n };\n})();\n(function() {\n/*globals Em:true ENV */\n\n/**\n@module ember\n@submodule ember-metal\n*/\n\n/**\n All Ember methods and functions are defined inside of this namespace. You\n generally should not add new properties to this namespace as it may be\n overwritten by future versions of Ember.\n\n You can also use the shorthand `Em` instead of `Ember`.\n\n Ember-Runtime is a framework that provides core functions for Ember including\n cross-platform functions, support for property observing and objects. Its\n focus is on small size and performance. You can use this in place of or\n along-side other cross-platform libraries such as jQuery.\n\n The core Runtime framework is based on the jQuery API with a number of\n performance optimizations.\n\n @class Ember\n @static\n @version 1.0.0-pre.2\n*/\n\nif ('undefined' === typeof Ember) {\n // Create core object. Make it act like an instance of Ember.Namespace so that\n // objects assigned to it are given a sane string representation.\n Ember = {};\n}\n\n// Default imports, exports and lookup to the global object;\nvar imports = Ember.imports = Ember.imports || this;\nvar exports = Ember.exports = Ember.exports || this;\nvar lookup = Ember.lookup = Ember.lookup || this;\n\n// aliases needed to keep minifiers from removing the global context\nexports.Em = exports.Ember = Em = Ember;\n\n// Make sure these are set whether Ember was already defined or not\n\nEmber.isNamespace = true;\n\nEmber.toString = function() { return \"Ember\"; };\n\n\n/**\n @property VERSION\n @type String\n @default '1.0.0-pre.2'\n @final\n*/\nEmber.VERSION = '1.0.0-pre.2';\n\n/**\n Standard environmental variables. You can define these in a global `ENV`\n variable before loading Ember to control various configuration\n settings.\n\n @property ENV\n @type Hash\n*/\nEmber.ENV = Ember.ENV || ('undefined' === typeof ENV ? {} : ENV);\n\nEmber.config = Ember.config || {};\n\n// ..........................................................\n// BOOTSTRAP\n//\n\n/**\n Determines whether Ember should enhances some built-in object prototypes to\n provide a more friendly API. If enabled, a few methods will be added to\n `Function`, `String`, and `Array`. `Object.prototype` will not be enhanced,\n which is the one that causes most trouble for people.\n\n In general we recommend leaving this option set to true since it rarely\n conflicts with other code. If you need to turn it off however, you can\n define an `ENV.EXTEND_PROTOTYPES` config to disable it.\n\n @property EXTEND_PROTOTYPES\n @type Boolean\n @default true\n*/\nEmber.EXTEND_PROTOTYPES = Ember.ENV.EXTEND_PROTOTYPES;\n\nif (typeof Ember.EXTEND_PROTOTYPES === 'undefined') {\n Ember.EXTEND_PROTOTYPES = true;\n}\n\n/**\n Determines whether Ember logs a full stack trace during deprecation warnings\n\n @property LOG_STACKTRACE_ON_DEPRECATION\n @type Boolean\n @default true\n*/\nEmber.LOG_STACKTRACE_ON_DEPRECATION = (Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false);\n\n/**\n Determines whether Ember should add ECMAScript 5 shims to older browsers.\n\n @property SHIM_ES5\n @type Boolean\n @default Ember.EXTEND_PROTOTYPES\n*/\nEmber.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPES;\n\n/**\n Empty function. Useful for some operations.\n\n @method K\n @private\n @return {Object}\n*/\nEmber.K = function() { return this; };\n\n\n// Stub out the methods defined by the ember-debug package in case it's not loaded\n\nif ('undefined' === typeof Ember.assert) { Ember.assert = Ember.K; }\nif ('undefined' === typeof Ember.warn) { Ember.warn = Ember.K; }\nif ('undefined' === typeof Ember.deprecate) { Ember.deprecate = Ember.K; }\nif ('undefined' === typeof Ember.deprecateFunc) {\n Ember.deprecateFunc = function(_, func) { return func; };\n}\n\n// These are deprecated but still supported\n\nif ('undefined' === typeof ember_assert) { exports.ember_assert = Ember.K; }\nif ('undefined' === typeof ember_warn) { exports.ember_warn = Ember.K; }\nif ('undefined' === typeof ember_deprecate) { exports.ember_deprecate = Ember.K; }\nif ('undefined' === typeof ember_deprecateFunc) {\n exports.ember_deprecateFunc = function(_, func) { return func; };\n}\n\n/**\n Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from\n jQuery master. We'll just bootstrap our own uuid now.\n\n @property uuid\n @type Number\n @private\n*/\nEmber.uuid = 0;\n\n// ..........................................................\n// LOGGER\n//\n\n/**\n Inside Ember-Metal, simply uses the `imports.console` object.\n Override this to provide more robust logging functionality.\n\n @class Logger\n @namespace Ember\n*/\nEmber.Logger = imports.console || { log: Ember.K, warn: Ember.K, error: Ember.K, info: Ember.K, debug: Ember.K };\n\n\n// ..........................................................\n// ERROR HANDLING\n//\n\n/**\n A function may be assigned to `Ember.onerror` to be called when Ember\n internals encounter an error. This is useful for specialized error handling\n and reporting code.\n\n @event onerror\n @for Ember\n @param {Exception} error the error object\n*/\nEmber.onerror = null;\n\n/**\n @private\n\n Wrap code block in a try/catch if {{#crossLink \"Ember/onerror\"}}{{/crossLink}} is set.\n\n @method handleErrors\n @for Ember\n @param {Function} func\n @param [context]\n*/\nEmber.handleErrors = function(func, context) {\n // Unfortunately in some browsers we lose the backtrace if we rethrow the existing error,\n // so in the event that we don't have an `onerror` handler we don't wrap in a try/catch\n if ('function' === typeof Ember.onerror) {\n try {\n return func.apply(context || this);\n } catch (error) {\n Ember.onerror(error);\n }\n } else {\n return func.apply(context || this);\n }\n};\n\nEmber.merge = function(original, updates) {\n for (var prop in updates) {\n if (!updates.hasOwnProperty(prop)) { continue; }\n original[prop] = updates[prop];\n }\n};\n\n})();\n\n\n\n(function() {\n/*globals Node */\n/**\n@module ember-metal\n*/\n\n/**\n Platform specific methods and feature detectors needed by the framework.\n\n @class platform\n @namespace Ember\n @static\n*/\nvar platform = Ember.platform = {};\n\n\n/**\n Identical to `Object.create()`. Implements if not available natively.\n\n @method create\n @for Ember\n*/\nEmber.create = Object.create;\n\n// STUB_OBJECT_CREATE allows us to override other libraries that stub\n// Object.create different than we would prefer\nif (!Ember.create || Ember.ENV.STUB_OBJECT_CREATE) {\n var K = function() {};\n\n Ember.create = function(obj, props) {\n K.prototype = obj;\n obj = new K();\n if (props) {\n K.prototype = obj;\n for (var prop in props) {\n K.prototype[prop] = props[prop].value;\n }\n obj = new K();\n }\n K.prototype = null;\n\n return obj;\n };\n\n Ember.create.isSimulated = true;\n}\n\nvar defineProperty = Object.defineProperty;\nvar canRedefineProperties, canDefinePropertyOnDOM;\n\n// Catch IE8 where Object.defineProperty exists but only works on DOM elements\nif (defineProperty) {\n try {\n defineProperty({}, 'a',{get:function(){}});\n } catch (e) {\n defineProperty = null;\n }\n}\n\nif (defineProperty) {\n // Detects a bug in Android <3.2 where you cannot redefine a property using\n // Object.defineProperty once accessors have already been set.\n canRedefineProperties = (function() {\n var obj = {};\n\n defineProperty(obj, 'a', {\n configurable: true,\n enumerable: true,\n get: function() { },\n set: function() { }\n });\n\n defineProperty(obj, 'a', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: true\n });\n\n return obj.a === true;\n })();\n\n // This is for Safari 5.0, which supports Object.defineProperty, but not\n // on DOM nodes.\n canDefinePropertyOnDOM = (function(){\n try {\n defineProperty(document.createElement('div'), 'definePropertyOnDOM', {});\n return true;\n } catch(e) { }\n\n return false;\n })();\n\n if (!canRedefineProperties) {\n defineProperty = null;\n } else if (!canDefinePropertyOnDOM) {\n defineProperty = function(obj, keyName, desc){\n var isNode;\n\n if (typeof Node === \"object\") {\n isNode = obj instanceof Node;\n } else {\n isNode = typeof obj === \"object\" && typeof obj.nodeType === \"number\" && typeof obj.nodeName === \"string\";\n }\n\n if (isNode) {\n // TODO: Should we have a warning here?\n return (obj[keyName] = desc.value);\n } else {\n return Object.defineProperty(obj, keyName, desc);\n }\n };\n }\n}\n\n/**\n@class platform\n@namespace Ember\n*/\n\n/**\n Identical to `Object.defineProperty()`. Implements as much functionality\n as possible if not available natively.\n\n @method defineProperty\n @param {Object} obj The object to modify\n @param {String} keyName property name to modify\n @param {Object} desc descriptor hash\n @return {void}\n*/\nplatform.defineProperty = defineProperty;\n\n/**\n Set to true if the platform supports native getters and setters.\n\n @property hasPropertyAccessors\n @final\n*/\nplatform.hasPropertyAccessors = true;\n\nif (!platform.defineProperty) {\n platform.hasPropertyAccessors = false;\n\n platform.defineProperty = function(obj, keyName, desc) {\n if (!desc.get) { obj[keyName] = desc.value; }\n };\n\n platform.defineProperty.isSimulated = true;\n}\n\nif (Ember.ENV.MANDATORY_SETTER && !platform.hasPropertyAccessors) {\n Ember.ENV.MANDATORY_SETTER = false;\n}\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar o_defineProperty = Ember.platform.defineProperty,\n o_create = Ember.create,\n // Used for guid generation...\n GUID_KEY = '__ember'+ (+ new Date()),\n uuid = 0,\n numberCache = [],\n stringCache = {};\n\nvar MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;\n\n/**\n @private\n\n A unique key used to assign guids and other private metadata to objects.\n If you inspect an object in your browser debugger you will often see these.\n They can be safely ignored.\n\n On browsers that support it, these properties are added with enumeration\n disabled so they won't show up when you iterate over your properties.\n\n @property GUID_KEY\n @for Ember\n @type String\n @final\n*/\nEmber.GUID_KEY = GUID_KEY;\n\nvar GUID_DESC = {\n writable: false,\n configurable: false,\n enumerable: false,\n value: null\n};\n\n/**\n @private\n\n Generates a new guid, optionally saving the guid to the object that you\n pass in. You will rarely need to use this method. Instead you should\n call `Ember.guidFor(obj)`, which return an existing guid if available.\n\n @method generateGuid\n @for Ember\n @param {Object} [obj] Object the guid will be used for. If passed in, the guid will\n be saved on the object and reused whenever you pass the same object\n again.\n\n If no object is passed, just generate a new guid.\n @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to\n separate the guid into separate namespaces.\n @return {String} the guid\n*/\nEmber.generateGuid = function generateGuid(obj, prefix) {\n if (!prefix) prefix = 'ember';\n var ret = (prefix + (uuid++));\n if (obj) {\n GUID_DESC.value = ret;\n o_defineProperty(obj, GUID_KEY, GUID_DESC);\n }\n return ret ;\n};\n\n/**\n @private\n\n Returns a unique id for the object. If the object does not yet have a guid,\n one will be assigned to it. You can call this on any object,\n `Ember.Object`-based or not, but be aware that it will add a `_guid`\n property.\n\n You can also use this method on DOM Element objects.\n\n @method guidFor\n @for Ember\n @param obj {Object} any object, string, number, Element, or primitive\n @return {String} the unique guid for this instance.\n*/\nEmber.guidFor = function guidFor(obj) {\n\n // special cases where we don't want to add a key to object\n if (obj === undefined) return \"(undefined)\";\n if (obj === null) return \"(null)\";\n\n var cache, ret;\n var type = typeof obj;\n\n // Don't allow prototype changes to String etc. to change the guidFor\n switch(type) {\n case 'number':\n ret = numberCache[obj];\n if (!ret) ret = numberCache[obj] = 'nu'+obj;\n return ret;\n\n case 'string':\n ret = stringCache[obj];\n if (!ret) ret = stringCache[obj] = 'st'+(uuid++);\n return ret;\n\n case 'boolean':\n return obj ? '(true)' : '(false)';\n\n default:\n if (obj[GUID_KEY]) return obj[GUID_KEY];\n if (obj === Object) return '(Object)';\n if (obj === Array) return '(Array)';\n ret = 'ember'+(uuid++);\n GUID_DESC.value = ret;\n o_defineProperty(obj, GUID_KEY, GUID_DESC);\n return ret;\n }\n};\n\n// ..........................................................\n// META\n//\n\nvar META_DESC = {\n writable: true,\n configurable: false,\n enumerable: false,\n value: null\n};\n\nvar META_KEY = Ember.GUID_KEY+'_meta';\n\n/**\n The key used to store meta information on object for property observing.\n\n @property META_KEY\n @for Ember\n @private\n @final\n @type String\n*/\nEmber.META_KEY = META_KEY;\n\n// Placeholder for non-writable metas.\nvar EMPTY_META = {\n descs: {},\n watching: {}\n};\n\nif (MANDATORY_SETTER) { EMPTY_META.values = {}; }\n\nEmber.EMPTY_META = EMPTY_META;\n\nif (Object.freeze) Object.freeze(EMPTY_META);\n\nvar isDefinePropertySimulated = Ember.platform.defineProperty.isSimulated;\n\nfunction Meta(obj) {\n this.descs = {};\n this.watching = {};\n this.cache = {};\n this.source = obj;\n}\n\nif (isDefinePropertySimulated) {\n // on platforms that don't support enumerable false\n // make meta fail jQuery.isPlainObject() to hide from\n // jQuery.extend() by having a property that fails\n // hasOwnProperty check.\n Meta.prototype.__preventPlainObject__ = true;\n\n // Without non-enumerable properties, meta objects will be output in JSON\n // unless explicitly suppressed\n Meta.prototype.toJSON = function () { };\n}\n\n/**\n Retrieves the meta hash for an object. If `writable` is true ensures the\n hash is writable for this object as well.\n\n The meta object contains information about computed property descriptors as\n well as any watched properties and other information. You generally will\n not access this information directly but instead work with higher level\n methods that manipulate this hash indirectly.\n\n @method meta\n @for Ember\n @private\n\n @param {Object} obj The object to retrieve meta for\n @param {Boolean} [writable=true] Pass `false` if you do not intend to modify\n the meta hash, allowing the method to avoid making an unnecessary copy.\n @return {Hash}\n*/\nEmber.meta = function meta(obj, writable) {\n\n var ret = obj[META_KEY];\n if (writable===false) return ret || EMPTY_META;\n\n if (!ret) {\n if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC);\n\n ret = new Meta(obj);\n\n if (MANDATORY_SETTER) { ret.values = {}; }\n\n obj[META_KEY] = ret;\n\n // make sure we don't accidentally try to create constructor like desc\n ret.descs.constructor = null;\n\n } else if (ret.source !== obj) {\n if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC);\n\n ret = o_create(ret);\n ret.descs = o_create(ret.descs);\n ret.watching = o_create(ret.watching);\n ret.cache = {};\n ret.source = obj;\n\n if (MANDATORY_SETTER) { ret.values = o_create(ret.values); }\n\n obj[META_KEY] = ret;\n }\n return ret;\n};\n\nEmber.getMeta = function getMeta(obj, property) {\n var meta = Ember.meta(obj, false);\n return meta[property];\n};\n\nEmber.setMeta = function setMeta(obj, property, value) {\n var meta = Ember.meta(obj, true);\n meta[property] = value;\n return value;\n};\n\n/**\n @private\n\n In order to store defaults for a class, a prototype may need to create\n a default meta object, which will be inherited by any objects instantiated\n from the class's constructor.\n\n However, the properties of that meta object are only shallow-cloned,\n so if a property is a hash (like the event system's `listeners` hash),\n it will by default be shared across all instances of that class.\n\n This method allows extensions to deeply clone a series of nested hashes or\n other complex objects. For instance, the event system might pass\n `['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will\n walk down the keys provided.\n\n For each key, if the key does not exist, it is created. If it already\n exists and it was inherited from its constructor, the constructor's\n key is cloned.\n\n You can also pass false for `writable`, which will simply return\n undefined if `prepareMetaPath` discovers any part of the path that\n shared or undefined.\n\n @method metaPath\n @for Ember\n @param {Object} obj The object whose meta we are examining\n @param {Array} path An array of keys to walk down\n @param {Boolean} writable whether or not to create a new meta\n (or meta property) if one does not already exist or if it's\n shared with its constructor\n*/\nEmber.metaPath = function metaPath(obj, path, writable) {\n var meta = Ember.meta(obj, writable), keyName, value;\n\n for (var i=0, l=path.length; i<l; i++) {\n keyName = path[i];\n value = meta[keyName];\n\n if (!value) {\n if (!writable) { return undefined; }\n value = meta[keyName] = { __ember_source__: obj };\n } else if (value.__ember_source__ !== obj) {\n if (!writable) { return undefined; }\n value = meta[keyName] = o_create(value);\n value.__ember_source__ = obj;\n }\n\n meta = value;\n }\n\n return value;\n};\n\n/**\n @private\n\n Wraps the passed function so that `this._super` will point to the superFunc\n when the function is invoked. This is the primitive we use to implement\n calls to super.\n\n @method wrap\n @for Ember\n @param {Function} func The function to call\n @param {Function} superFunc The super function.\n @return {Function} wrapped function.\n*/\nEmber.wrap = function(func, superFunc) {\n function K() {}\n\n function superWrapper() {\n var ret, sup = this._super;\n this._super = superFunc || K;\n ret = func.apply(this, arguments);\n this._super = sup;\n return ret;\n }\n\n superWrapper.__ember_observes__ = func.__ember_observes__;\n superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__;\n\n return superWrapper;\n};\n\n/**\n Returns true if the passed object is an array or Array-like.\n\n Ember Array Protocol:\n\n - the object has an objectAt property\n - the object is a native Array\n - the object is an Object, and has a length property\n\n Unlike `Ember.typeOf` this method returns true even if the passed object is\n not formally array but appears to be array-like (i.e. implements `Ember.Array`)\n\n ```javascript\n Ember.isArray(); // false\n Ember.isArray([]); // true\n Ember.isArray( Ember.ArrayProxy.create({ content: [] }) ); // true\n ```\n\n @method isArray\n @for Ember\n @param {Object} obj The object to test\n @return {Boolean}\n*/\nEmber.isArray = function(obj) {\n if (!obj || obj.setInterval) { return false; }\n if (Array.isArray && Array.isArray(obj)) { return true; }\n if (Ember.Array && Ember.Array.detect(obj)) { return true; }\n if ((obj.length !== undefined) && 'object'===typeof obj) { return true; }\n return false;\n};\n\n/**\n Forces the passed object to be part of an array. If the object is already\n an array or array-like, returns the object. Otherwise adds the object to\n an array. If obj is `null` or `undefined`, returns an empty array.\n\n ```javascript\n Ember.makeArray(); // []\n Ember.makeArray(null); // []\n Ember.makeArray(undefined); // []\n Ember.makeArray('lindsay'); // ['lindsay']\n Ember.makeArray([1,2,42]); // [1,2,42]\n\n var controller = Ember.ArrayProxy.create({ content: [] });\n Ember.makeArray(controller) === controller; // true\n ```\n\n @method makeArray\n @for Ember\n @param {Object} obj the object\n @return {Array}\n*/\nEmber.makeArray = function(obj) {\n if (obj === null || obj === undefined) { return []; }\n return Ember.isArray(obj) ? obj : [obj];\n};\n\nfunction canInvoke(obj, methodName) {\n return !!(obj && typeof obj[methodName] === 'function');\n}\n\n/**\n Checks to see if the `methodName` exists on the `obj`.\n\n @method canInvoke\n @for Ember\n @param {Object} obj The object to check for the method\n @param {String} methodName The method name to check for\n*/\nEmber.canInvoke = canInvoke;\n\n/**\n Checks to see if the `methodName` exists on the `obj`,\n and if it does, invokes it with the arguments passed.\n\n @method tryInvoke\n @for Ember\n @param {Object} obj The object to check for the method\n @param {String} methodName The method name to check for\n @param {Array} [args] The arguments to pass to the method\n @return {anything} the return value of the invoked method or undefined if it cannot be invoked\n*/\nEmber.tryInvoke = function(obj, methodName, args) {\n if (canInvoke(obj, methodName)) {\n return obj[methodName].apply(obj, args || []);\n }\n};\n\n// https://github.com/emberjs/ember.js/pull/1617\nvar needsFinallyFix = (function() {\n var count = 0;\n try{\n try { }\n finally {\n count++;\n throw new Error('needsFinallyFixTest');\n }\n } catch (e) {}\n\n return count !== 1;\n})();\n\n/**\n Provides try { } finally { } functionality, while working\n around Safari's double finally bug.\n\n @method tryFinally\n @for Ember\n @param {Function} function The function to run the try callback\n @param {Function} function The function to run the finally callback\n @param [binding]\n @return {anything} The return value is the that of the finalizer,\n unless that valueis undefined, in which case it is the return value\n of the tryable\n*/\n\nif (needsFinallyFix) {\n Ember.tryFinally = function(tryable, finalizer, binding) {\n var result, finalResult, finalError;\n\n binding = binding || this;\n\n try {\n result = tryable.call(binding);\n } finally {\n try {\n finalResult = finalizer.call(binding);\n } catch (e){\n finalError = e;\n }\n }\n\n if (finalError) { throw finalError; }\n\n return (finalResult === undefined) ? result : finalResult;\n };\n} else {\n Ember.tryFinally = function(tryable, finalizer, binding) {\n var result, finalResult;\n\n binding = binding || this;\n\n try {\n result = tryable.call(binding);\n } finally {\n finalResult = finalizer.call(binding);\n }\n\n return (finalResult === undefined) ? result : finalResult;\n };\n}\n\n/**\n Provides try { } catch finally { } functionality, while working\n around Safari's double finally bug.\n\n @method tryCatchFinally\n @for Ember\n @param {Function} function The function to run the try callback\n @param {Function} function The function to run the catchable callback\n @param {Function} function The function to run the finally callback\n @param [binding]\n @return {anything} The return value is the that of the finalizer,\n unless that value is undefined, in which case it is the return value\n of the tryable.\n*/\nif (needsFinallyFix) {\n Ember.tryCatchFinally = function(tryable, catchable, finalizer, binding) {\n var result, finalResult, finalError, finalReturn;\n\n binding = binding || this;\n\n try {\n result = tryable.call(binding);\n } catch(error) {\n result = catchable.call(binding, error);\n } finally {\n try {\n finalResult = finalizer.call(binding);\n } catch (e){\n finalError = e;\n }\n }\n\n if (finalError) { throw finalError; }\n\n return (finalResult === undefined) ? result : finalResult;\n };\n} else {\n Ember.tryCatchFinally = function(tryable, catchable, finalizer, binding) {\n var result, finalResult;\n\n binding = binding || this;\n\n try {\n result = tryable.call(binding);\n } catch(error) {\n result = catchable.call(binding, error);\n } finally {\n finalResult = finalizer.call(binding);\n }\n\n return (finalResult === undefined) ? result : finalResult;\n };\n}\n\n})();\n\n\n\n(function() {\n// Ember.tryCatchFinally\n\n/**\n The purpose of the Ember Instrumentation module is\n to provide efficient, general-purpose instrumentation\n for Ember.\n\n Subscribe to a listener by using `Ember.subscribe`:\n\n ```javascript\n Ember.subscribe(\"render\", {\n before: function(name, timestamp, payload) {\n\n },\n\n after: function(name, timestamp, payload) {\n\n }\n });\n ```\n\n If you return a value from the `before` callback, that same\n value will be passed as a fourth parameter to the `after`\n callback.\n\n Instrument a block of code by using `Ember.instrument`:\n\n ```javascript\n Ember.instrument(\"render.handlebars\", payload, function() {\n // rendering logic\n }, binding);\n ```\n\n Event names passed to `Ember.instrument` are namespaced\n by periods, from more general to more specific. Subscribers\n can listen for events by whatever level of granularity they\n are interested in.\n\n In the above example, the event is `render.handlebars`,\n and the subscriber listened for all events beginning with\n `render`. It would receive callbacks for events named\n `render`, `render.handlebars`, `render.container`, or\n even `render.handlebars.layout`.\n\n @class Instrumentation\n @namespace Ember\n @static\n*/\nEmber.Instrumentation = {};\n\nvar subscribers = [], cache = {};\n\nvar populateListeners = function(name) {\n var listeners = [], subscriber;\n\n for (var i=0, l=subscribers.length; i<l; i++) {\n subscriber = subscribers[i];\n if (subscriber.regex.test(name)) {\n listeners.push(subscriber.object);\n }\n }\n\n cache[name] = listeners;\n return listeners;\n};\n\nvar time = (function() {\n\tvar perf = 'undefined' !== typeof window ? window.performance || {} : {};\n\tvar fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow;\n\t// fn.bind will be available in all the browsers that support the advanced window.performance... ;-)\n\treturn fn ? fn.bind(perf) : function() { return +new Date(); };\n})();\n\n\nEmber.Instrumentation.instrument = function(name, payload, callback, binding) {\n var listeners = cache[name], timeName, ret;\n\n if (Ember.STRUCTURED_PROFILE) {\n timeName = name + \": \" + payload.object;\n console.time(timeName);\n }\n\n if (!listeners) {\n listeners = populateListeners(name);\n }\n\n if (listeners.length === 0) {\n ret = callback.call(binding);\n if (Ember.STRUCTURED_PROFILE) { console.timeEnd(timeName); }\n return ret;\n }\n\n var beforeValues = [], listener, i, l;\n\n function tryable(){\n for (i=0, l=listeners.length; i<l; i++) {\n listener = listeners[i];\n beforeValues[i] = listener.before(name, time(), payload);\n }\n\n return callback.call(binding);\n }\n\n function catchable(e){\n payload = payload || {};\n payload.exception = e;\n }\n\n function finalizer() {\n for (i=0, l=listeners.length; i<l; i++) {\n listener = listeners[i];\n listener.after(name, time(), payload, beforeValues[i]);\n }\n\n if (Ember.STRUCTURED_PROFILE) {\n console.timeEnd(timeName);\n }\n }\n\n return Ember.tryCatchFinally(tryable, catchable, finalizer);\n};\n\nEmber.Instrumentation.subscribe = function(pattern, object) {\n var paths = pattern.split(\".\"), path, regex = [];\n\n for (var i=0, l=paths.length; i<l; i++) {\n path = paths[i];\n if (path === \"*\") {\n regex.push(\"[^\\\\.]*\");\n } else {\n regex.push(path);\n }\n }\n\n regex = regex.join(\"\\\\.\");\n regex = regex + \"(\\\\..*)?\";\n\n var subscriber = {\n pattern: pattern,\n regex: new RegExp(\"^\" + regex + \"$\"),\n object: object\n };\n\n subscribers.push(subscriber);\n cache = {};\n\n return subscriber;\n};\n\nEmber.Instrumentation.unsubscribe = function(subscriber) {\n var index;\n\n for (var i=0, l=subscribers.length; i<l; i++) {\n if (subscribers[i] === subscriber) {\n index = i;\n }\n }\n\n subscribers.splice(index, 1);\n cache = {};\n};\n\nEmber.Instrumentation.reset = function() {\n subscribers = [];\n cache = {};\n};\n\nEmber.instrument = Ember.Instrumentation.instrument;\nEmber.subscribe = Ember.Instrumentation.subscribe;\n\n})();\n\n\n\n(function() {\n/*jshint newcap:false*/\n\n/**\n@module ember-metal\n*/\n\n// NOTE: There is a bug in jshint that doesn't recognize `Object()` without `new`\n// as being ok unless both `newcap:false` and not `use strict`.\n// https://github.com/jshint/jshint/issues/392\n\n// Testing this is not ideal, but we want to use native functions\n// if available, but not to use versions created by libraries like Prototype\nvar isNativeFunc = function(func) {\n // This should probably work in all browsers likely to have ES5 array methods\n return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1;\n};\n\n// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map\nvar arrayMap = isNativeFunc(Array.prototype.map) ? Array.prototype.map : function(fun /*, thisp */) {\n //\"use strict\";\n\n if (this === void 0 || this === null) {\n throw new TypeError();\n }\n\n var t = Object(this);\n var len = t.length >>> 0;\n if (typeof fun !== \"function\") {\n throw new TypeError();\n }\n\n var res = new Array(len);\n var thisp = arguments[1];\n for (var i = 0; i < len; i++) {\n if (i in t) {\n res[i] = fun.call(thisp, t[i], i, t);\n }\n }\n\n return res;\n};\n\n// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach\nvar arrayForEach = isNativeFunc(Array.prototype.forEach) ? Array.prototype.forEach : function(fun /*, thisp */) {\n //\"use strict\";\n\n if (this === void 0 || this === null) {\n throw new TypeError();\n }\n\n var t = Object(this);\n var len = t.length >>> 0;\n if (typeof fun !== \"function\") {\n throw new TypeError();\n }\n\n var thisp = arguments[1];\n for (var i = 0; i < len; i++) {\n if (i in t) {\n fun.call(thisp, t[i], i, t);\n }\n }\n};\n\nvar arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? Array.prototype.indexOf : function (obj, fromIndex) {\n if (fromIndex === null || fromIndex === undefined) { fromIndex = 0; }\n else if (fromIndex < 0) { fromIndex = Math.max(0, this.length + fromIndex); }\n for (var i = fromIndex, j = this.length; i < j; i++) {\n if (this[i] === obj) { return i; }\n }\n return -1;\n};\n\nEmber.ArrayPolyfills = {\n map: arrayMap,\n forEach: arrayForEach,\n indexOf: arrayIndexOf\n};\n\nvar utils = Ember.EnumerableUtils = {\n map: function(obj, callback, thisArg) {\n return obj.map ? obj.map.call(obj, callback, thisArg) : arrayMap.call(obj, callback, thisArg);\n },\n\n forEach: function(obj, callback, thisArg) {\n return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : arrayForEach.call(obj, callback, thisArg);\n },\n\n indexOf: function(obj, element, index) {\n return obj.indexOf ? obj.indexOf.call(obj, element, index) : arrayIndexOf.call(obj, element, index);\n },\n\n indexesOf: function(obj, elements) {\n return elements === undefined ? [] : utils.map(elements, function(item) {\n return utils.indexOf(obj, item);\n });\n },\n\n addObject: function(array, item) {\n var index = utils.indexOf(array, item);\n if (index === -1) { array.push(item); }\n },\n\n removeObject: function(array, item) {\n var index = utils.indexOf(array, item);\n if (index !== -1) { array.splice(index, 1); }\n },\n\n replace: function(array, idx, amt, objects) {\n if (array.replace) {\n return array.replace(idx, amt, objects);\n } else {\n var args = Array.prototype.concat.apply([idx, amt], objects);\n return array.splice.apply(array, args);\n }\n }\n};\n\n\nif (Ember.SHIM_ES5) {\n if (!Array.prototype.map) {\n Array.prototype.map = arrayMap;\n }\n\n if (!Array.prototype.forEach) {\n Array.prototype.forEach = arrayForEach;\n }\n\n if (!Array.prototype.indexOf) {\n Array.prototype.indexOf = arrayIndexOf;\n }\n}\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\n/*\n JavaScript (before ES6) does not have a Map implementation. Objects,\n which are often used as dictionaries, may only have Strings as keys.\n\n Because Ember has a way to get a unique identifier for every object\n via `Ember.guidFor`, we can implement a performant Map with arbitrary\n keys. Because it is commonly used in low-level bookkeeping, Map is\n implemented as a pure JavaScript object for performance.\n\n This implementation follows the current iteration of the ES6 proposal for\n maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets),\n with two exceptions. First, because we need our implementation to be pleasant\n on older browsers, we do not use the `delete` name (using `remove` instead).\n Second, as we do not have the luxury of in-VM iteration, we implement a\n forEach method for iteration.\n\n Map is mocked out to look like an Ember object, so you can do\n `Ember.Map.create()` for symmetry with other Ember classes.\n*/\nvar guidFor = Ember.guidFor,\n indexOf = Ember.ArrayPolyfills.indexOf;\n\nvar copy = function(obj) {\n var output = {};\n\n for (var prop in obj) {\n if (obj.hasOwnProperty(prop)) { output[prop] = obj[prop]; }\n }\n\n return output;\n};\n\nvar copyMap = function(original, newObject) {\n var keys = original.keys.copy(),\n values = copy(original.values);\n\n newObject.keys = keys;\n newObject.values = values;\n\n return newObject;\n};\n\n/**\n This class is used internally by Ember and Ember Data.\n Please do not use it at this time. We plan to clean it up\n and add many tests soon.\n\n @class OrderedSet\n @namespace Ember\n @constructor\n @private\n*/\nvar OrderedSet = Ember.OrderedSet = function() {\n this.clear();\n};\n\n/**\n @method create\n @static\n @return {Ember.OrderedSet}\n*/\nOrderedSet.create = function() {\n return new OrderedSet();\n};\n\n\nOrderedSet.prototype = {\n /**\n @method clear\n */\n clear: function() {\n this.presenceSet = {};\n this.list = [];\n },\n\n /**\n @method add\n @param obj\n */\n add: function(obj) {\n var guid = guidFor(obj),\n presenceSet = this.presenceSet,\n list = this.list;\n\n if (guid in presenceSet) { return; }\n\n presenceSet[guid] = true;\n list.push(obj);\n },\n\n /**\n @method remove\n @param obj\n */\n remove: function(obj) {\n var guid = guidFor(obj),\n presenceSet = this.presenceSet,\n list = this.list;\n\n delete presenceSet[guid];\n\n var index = indexOf.call(list, obj);\n if (index > -1) {\n list.splice(index, 1);\n }\n },\n\n /**\n @method isEmpty\n @return {Boolean}\n */\n isEmpty: function() {\n return this.list.length === 0;\n },\n\n /**\n @method has\n @param obj\n @return {Boolean}\n */\n has: function(obj) {\n var guid = guidFor(obj),\n presenceSet = this.presenceSet;\n\n return guid in presenceSet;\n },\n\n /**\n @method forEach\n @param {Function} function\n @param target\n */\n forEach: function(fn, self) {\n // allow mutation during iteration\n var list = this.list.slice();\n\n for (var i = 0, j = list.length; i < j; i++) {\n fn.call(self, list[i]);\n }\n },\n\n /**\n @method toArray\n @return {Array}\n */\n toArray: function() {\n return this.list.slice();\n },\n\n /**\n @method copy\n @return {Ember.OrderedSet}\n */\n copy: function() {\n var set = new OrderedSet();\n\n set.presenceSet = copy(this.presenceSet);\n set.list = this.list.slice();\n\n return set;\n }\n};\n\n/**\n A Map stores values indexed by keys. Unlike JavaScript's\n default Objects, the keys of a Map can be any JavaScript\n object.\n\n Internally, a Map has two data structures:\n\n 1. `keys`: an OrderedSet of all of the existing keys\n 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)`\n\n When a key/value pair is added for the first time, we\n add the key to the `keys` OrderedSet, and create or\n replace an entry in `values`. When an entry is deleted,\n we delete its entry in `keys` and `values`.\n\n @class Map\n @namespace Ember\n @private\n @constructor\n*/\nvar Map = Ember.Map = function() {\n this.keys = Ember.OrderedSet.create();\n this.values = {};\n};\n\n/**\n @method create\n @static\n*/\nMap.create = function() {\n return new Map();\n};\n\nMap.prototype = {\n /**\n Retrieve the value associated with a given key.\n\n @method get\n @param {anything} key\n @return {anything} the value associated with the key, or `undefined`\n */\n get: function(key) {\n var values = this.values,\n guid = guidFor(key);\n\n return values[guid];\n },\n\n /**\n Adds a value to the map. If a value for the given key has already been\n provided, the new value will replace the old value.\n\n @method set\n @param {anything} key\n @param {anything} value\n */\n set: function(key, value) {\n var keys = this.keys,\n values = this.values,\n guid = guidFor(key);\n\n keys.add(key);\n values[guid] = value;\n },\n\n /**\n Removes a value from the map for an associated key.\n\n @method remove\n @param {anything} key\n @return {Boolean} true if an item was removed, false otherwise\n */\n remove: function(key) {\n // don't use ES6 \"delete\" because it will be annoying\n // to use in browsers that are not ES6 friendly;\n var keys = this.keys,\n values = this.values,\n guid = guidFor(key),\n value;\n\n if (values.hasOwnProperty(guid)) {\n keys.remove(key);\n value = values[guid];\n delete values[guid];\n return true;\n } else {\n return false;\n }\n },\n\n /**\n Check whether a key is present.\n\n @method has\n @param {anything} key\n @return {Boolean} true if the item was present, false otherwise\n */\n has: function(key) {\n var values = this.values,\n guid = guidFor(key);\n\n return values.hasOwnProperty(guid);\n },\n\n /**\n Iterate over all the keys and values. Calls the function once\n for each key, passing in the key and value, in that order.\n\n The keys are guaranteed to be iterated over in insertion order.\n\n @method forEach\n @param {Function} callback\n @param {anything} self if passed, the `this` value inside the\n callback. By default, `this` is the map.\n */\n forEach: function(callback, self) {\n var keys = this.keys,\n values = this.values;\n\n keys.forEach(function(key) {\n var guid = guidFor(key);\n callback.call(self, key, values[guid]);\n });\n },\n\n /**\n @method copy\n @return {Ember.Map}\n */\n copy: function() {\n return copyMap(this, new Map());\n }\n};\n\n/**\n @class MapWithDefault\n @namespace Ember\n @extends Ember.Map\n @private\n @constructor\n @param [options]\n @param {anything} [options.defaultValue]\n*/\nvar MapWithDefault = Ember.MapWithDefault = function(options) {\n Map.call(this);\n this.defaultValue = options.defaultValue;\n};\n\n/**\n @method create\n @static\n @param [options]\n @param {anything} [options.defaultValue]\n @return {Ember.MapWithDefault|Ember.Map} If options are passed, returns \n `Ember.MapWithDefault` otherwise returns `Ember.Map`\n*/\nMapWithDefault.create = function(options) {\n if (options) {\n return new MapWithDefault(options);\n } else {\n return new Map();\n }\n};\n\nMapWithDefault.prototype = Ember.create(Map.prototype);\n\n/**\n Retrieve the value associated with a given key.\n\n @method get\n @param {anything} key\n @return {anything} the value associated with the key, or the default value\n*/\nMapWithDefault.prototype.get = function(key) {\n var hasValue = this.has(key);\n\n if (hasValue) {\n return Map.prototype.get.call(this, key);\n } else {\n var defaultValue = this.defaultValue(key);\n this.set(key, defaultValue);\n return defaultValue;\n }\n};\n\n/**\n @method copy\n @return {Ember.MapWithDefault}\n*/\nMapWithDefault.prototype.copy = function() {\n return copyMap(this, new MapWithDefault({\n defaultValue: this.defaultValue\n }));\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar META_KEY = Ember.META_KEY, get, set;\n\nvar MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;\n\nvar IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/;\nvar IS_GLOBAL_PATH = /^([A-Z$]|([0-9][A-Z$])).*[\\.\\*]/;\nvar HAS_THIS = /^this[\\.\\*]/;\nvar FIRST_KEY = /^([^\\.\\*]+)/;\n\n// ..........................................................\n// GET AND SET\n//\n// If we are on a platform that supports accessors we can get use those.\n// Otherwise simulate accessors by looking up the property directly on the\n// object.\n\n/**\n Gets the value of a property on an object. If the property is computed,\n the function will be invoked. If the property is not defined but the\n object implements the `unknownProperty` method then that will be invoked.\n\n If you plan to run on IE8 and older browsers then you should use this\n method anytime you want to retrieve a property on an object that you don't\n know for sure is private. (Properties beginning with an underscore '_' \n are considered private.)\n\n On all newer browsers, you only need to use this method to retrieve\n properties if the property might not be defined on the object and you want\n to respect the `unknownProperty` handler. Otherwise you can ignore this\n method.\n\n Note that if the object itself is `undefined`, this method will throw\n an error.\n\n @method get\n @for Ember\n @param {Object} obj The object to retrieve from.\n @param {String} keyName The property key to retrieve\n @return {Object} the property value or `null`.\n*/\nget = function get(obj, keyName) {\n // Helpers that operate with 'this' within an #each\n if (keyName === '') {\n return obj;\n }\n\n if (!keyName && 'string'===typeof obj) {\n keyName = obj;\n obj = null;\n }\n\n if (!obj || keyName.indexOf('.') !== -1) {\n Ember.assert(\"Cannot call get with '\"+ keyName +\"' on an undefined object.\", obj !== undefined);\n return getPath(obj, keyName);\n }\n\n Ember.assert(\"You need to provide an object and key to `get`.\", !!obj && keyName);\n\n var meta = obj[META_KEY], desc = meta && meta.descs[keyName], ret;\n if (desc) {\n return desc.get(obj, keyName);\n } else {\n if (MANDATORY_SETTER && meta && meta.watching[keyName] > 0) {\n ret = meta.values[keyName];\n } else {\n ret = obj[keyName];\n }\n\n if (ret === undefined &&\n 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) {\n return obj.unknownProperty(keyName);\n }\n\n return ret;\n }\n};\n\n/**\n Sets the value of a property on an object, respecting computed properties\n and notifying observers and other listeners of the change. If the\n property is not defined but the object implements the `unknownProperty`\n method then that will be invoked as well.\n\n If you plan to run on IE8 and older browsers then you should use this\n method anytime you want to set a property on an object that you don't\n know for sure is private. (Properties beginning with an underscore '_' \n are considered private.)\n\n On all newer browsers, you only need to use this method to set\n properties if the property might not be defined on the object and you want\n to respect the `unknownProperty` handler. Otherwise you can ignore this\n method.\n\n @method set\n @for Ember\n @param {Object} obj The object to modify.\n @param {String} keyName The property key to set\n @param {Object} value The value to set\n @return {Object} the passed value.\n*/\nset = function set(obj, keyName, value, tolerant) {\n if (typeof obj === 'string') {\n Ember.assert(\"Path '\" + obj + \"' must be global if no obj is given.\", IS_GLOBAL.test(obj));\n value = keyName;\n keyName = obj;\n obj = null;\n }\n\n if (!obj || keyName.indexOf('.') !== -1) {\n return setPath(obj, keyName, value, tolerant);\n }\n\n Ember.assert(\"You need to provide an object and key to `set`.\", !!obj && keyName !== undefined);\n Ember.assert('calling set on destroyed object', !obj.isDestroyed);\n\n var meta = obj[META_KEY], desc = meta && meta.descs[keyName],\n isUnknown, currentValue;\n if (desc) {\n desc.set(obj, keyName, value);\n } else {\n isUnknown = 'object' === typeof obj && !(keyName in obj);\n\n // setUnknownProperty is called if `obj` is an object,\n // the property does not already exist, and the\n // `setUnknownProperty` method exists on the object\n if (isUnknown && 'function' === typeof obj.setUnknownProperty) {\n obj.setUnknownProperty(keyName, value);\n } else if (meta && meta.watching[keyName] > 0) {\n if (MANDATORY_SETTER) {\n currentValue = meta.values[keyName];\n } else {\n currentValue = obj[keyName];\n }\n // only trigger a change if the value has changed\n if (value !== currentValue) {\n Ember.propertyWillChange(obj, keyName);\n if (MANDATORY_SETTER) {\n if (currentValue === undefined && !(keyName in obj)) {\n Ember.defineProperty(obj, keyName, null, value); // setup mandatory setter\n } else {\n meta.values[keyName] = value;\n }\n } else {\n obj[keyName] = value;\n }\n Ember.propertyDidChange(obj, keyName);\n }\n } else {\n obj[keyName] = value;\n }\n }\n return value;\n};\n\n// Currently used only by Ember Data tests\nif (Ember.config.overrideAccessors) {\n Ember.get = get;\n Ember.set = set;\n Ember.config.overrideAccessors();\n get = Ember.get;\n set = Ember.set;\n}\n\nfunction firstKey(path) {\n return path.match(FIRST_KEY)[0];\n}\n\n// assumes path is already normalized\nfunction normalizeTuple(target, path) {\n var hasThis = HAS_THIS.test(path),\n isGlobal = !hasThis && IS_GLOBAL_PATH.test(path),\n key;\n\n if (!target || isGlobal) target = Ember.lookup;\n if (hasThis) path = path.slice(5);\n\n if (target === Ember.lookup) {\n key = firstKey(path);\n target = get(target, key);\n path = path.slice(key.length+1);\n }\n\n // must return some kind of path to be valid else other things will break.\n if (!path || path.length===0) throw new Error('Invalid Path');\n\n return [ target, path ];\n}\n\nfunction getPath(root, path) {\n var hasThis, parts, tuple, idx, len;\n\n // If there is no root and path is a key name, return that\n // property from the global object.\n // E.g. get('Ember') -> Ember\n if (root === null && path.indexOf('.') === -1) { return get(Ember.lookup, path); }\n\n // detect complicated paths and normalize them\n hasThis = HAS_THIS.test(path);\n\n if (!root || hasThis) {\n tuple = normalizeTuple(root, path);\n root = tuple[0];\n path = tuple[1];\n tuple.length = 0;\n }\n\n parts = path.split(\".\");\n len = parts.length;\n for (idx=0; root && idx<len; idx++) {\n root = get(root, parts[idx], true);\n if (root && root.isDestroyed) { return undefined; }\n }\n return root;\n}\n\nfunction setPath(root, path, value, tolerant) {\n var keyName;\n\n // get the last part of the path\n keyName = path.slice(path.lastIndexOf('.') + 1);\n\n // get the first part of the part\n path = path.slice(0, path.length-(keyName.length+1));\n\n // unless the path is this, look up the first part to\n // get the root\n if (path !== 'this') {\n root = getPath(root, path);\n }\n\n if (!keyName || keyName.length === 0) {\n throw new Error('You passed an empty path');\n }\n\n if (!root) {\n if (tolerant) { return; }\n else { throw new Error('Object in path '+path+' could not be found or was destroyed.'); }\n }\n\n return set(root, keyName, value);\n}\n\n/**\n @private\n\n Normalizes a target/path pair to reflect that actual target/path that should\n be observed, etc. This takes into account passing in global property\n paths (i.e. a path beginning with a captial letter not defined on the\n target) and * separators.\n\n @method normalizeTuple\n @for Ember\n @param {Object} target The current target. May be `null`.\n @param {String} path A path on the target or a global property path.\n @return {Array} a temporary array with the normalized target/path pair.\n*/\nEmber.normalizeTuple = function(target, path) {\n return normalizeTuple(target, path);\n};\n\nEmber.getWithDefault = function(root, key, defaultValue) {\n var value = get(root, key);\n\n if (value === undefined) { return defaultValue; }\n return value;\n};\n\n\nEmber.get = get;\nEmber.getPath = Ember.deprecateFunc('getPath is deprecated since get now supports paths', Ember.get);\n\nEmber.set = set;\nEmber.setPath = Ember.deprecateFunc('setPath is deprecated since set now supports paths', Ember.set);\n\n/**\n Error-tolerant form of `Ember.set`. Will not blow up if any part of the\n chain is `undefined`, `null`, or destroyed.\n\n This is primarily used when syncing bindings, which may try to update after\n an object has been destroyed.\n\n @method trySet\n @for Ember\n @param {Object} obj The object to modify.\n @param {String} keyName The property key to set\n @param {Object} value The value to set\n*/\nEmber.trySet = function(root, path, value) {\n return set(root, path, value, true);\n};\nEmber.trySetPath = Ember.deprecateFunc('trySetPath has been renamed to trySet', Ember.trySet);\n\n/**\n Returns true if the provided path is global (e.g., `MyApp.fooController.bar`)\n instead of local (`foo.bar.baz`).\n\n @method isGlobalPath\n @for Ember\n @private\n @param {String} path\n @return Boolean\n*/\nEmber.isGlobalPath = function(path) {\n return IS_GLOBAL.test(path);\n};\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar GUID_KEY = Ember.GUID_KEY,\n META_KEY = Ember.META_KEY,\n EMPTY_META = Ember.EMPTY_META,\n metaFor = Ember.meta,\n o_create = Ember.create,\n objectDefineProperty = Ember.platform.defineProperty;\n\nvar MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;\n\n// ..........................................................\n// DESCRIPTOR\n//\n\n/**\n Objects of this type can implement an interface to responds requests to\n get and set. The default implementation handles simple properties.\n\n You generally won't need to create or subclass this directly.\n\n @class Descriptor\n @namespace Ember\n @private\n @constructor\n*/\nvar Descriptor = Ember.Descriptor = function() {};\n\n// ..........................................................\n// DEFINING PROPERTIES API\n//\n\n/**\n @private\n\n NOTE: This is a low-level method used by other parts of the API. You almost\n never want to call this method directly. Instead you should use\n `Ember.mixin()` to define new properties.\n\n Defines a property on an object. This method works much like the ES5\n `Object.defineProperty()` method except that it can also accept computed\n properties and other special descriptors.\n\n Normally this method takes only three parameters. However if you pass an\n instance of `Ember.Descriptor` as the third param then you can pass an\n optional value as the fourth parameter. This is often more efficient than\n creating new descriptor hashes for each property.\n\n ## Examples\n\n ```javascript\n // ES5 compatible mode\n Ember.defineProperty(contact, 'firstName', {\n writable: true,\n configurable: false,\n enumerable: true,\n value: 'Charles'\n });\n\n // define a simple property\n Ember.defineProperty(contact, 'lastName', undefined, 'Jolley');\n\n // define a computed property\n Ember.defineProperty(contact, 'fullName', Ember.computed(function() {\n return this.firstName+' '+this.lastName;\n }).property('firstName', 'lastName'));\n ```\n\n @method defineProperty\n @for Ember\n @param {Object} obj the object to define this property on. This may be a prototype.\n @param {String} keyName the name of the property\n @param {Ember.Descriptor} [desc] an instance of `Ember.Descriptor` (typically a\n computed property) or an ES5 descriptor.\n You must provide this or `data` but not both.\n @param {anything} [data] something other than a descriptor, that will\n become the explicit value of this property.\n*/\nEmber.defineProperty = function(obj, keyName, desc, data, meta) {\n var descs, existingDesc, watching, value;\n\n if (!meta) meta = metaFor(obj);\n descs = meta.descs;\n existingDesc = meta.descs[keyName];\n watching = meta.watching[keyName] > 0;\n\n if (existingDesc instanceof Ember.Descriptor) {\n existingDesc.teardown(obj, keyName);\n }\n\n if (desc instanceof Ember.Descriptor) {\n value = desc;\n\n descs[keyName] = desc;\n if (MANDATORY_SETTER && watching) {\n objectDefineProperty(obj, keyName, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: undefined // make enumerable\n });\n } else {\n obj[keyName] = undefined; // make enumerable\n }\n desc.setup(obj, keyName);\n } else {\n descs[keyName] = undefined; // shadow descriptor in proto\n if (desc == null) {\n value = data;\n\n if (MANDATORY_SETTER && watching) {\n meta.values[keyName] = data;\n objectDefineProperty(obj, keyName, {\n configurable: true,\n enumerable: true,\n set: function() {\n Ember.assert('Must use Ember.set() to access this property', false);\n },\n get: function() {\n var meta = this[META_KEY];\n return meta && meta.values[keyName];\n }\n });\n } else {\n obj[keyName] = data;\n }\n } else {\n value = desc;\n\n // compatibility with ES5\n objectDefineProperty(obj, keyName, desc);\n }\n }\n\n // if key is being watched, override chains that\n // were initialized with the prototype\n if (watching) { Ember.overrideChains(obj, keyName, meta); }\n\n // The `value` passed to the `didDefineProperty` hook is\n // either the descriptor or data, whichever was passed.\n if (obj.didDefineProperty) { obj.didDefineProperty(obj, keyName, value); }\n\n return this;\n};\n\n\n})();\n\n\n\n(function() {\n// Ember.tryFinally\n/**\n@module ember-metal\n*/\n\nvar AFTER_OBSERVERS = ':change';\nvar BEFORE_OBSERVERS = ':before';\n\nvar guidFor = Ember.guidFor;\n\nvar deferred = 0;\n\n/*\n this.observerSet = {\n [senderGuid]: { // variable name: `keySet`\n [keyName]: listIndex\n }\n },\n this.observers = [\n {\n sender: obj,\n keyName: keyName,\n eventName: eventName,\n listeners: [\n [target, method, onceFlag, suspendedFlag]\n ]\n },\n ...\n ]\n*/\nfunction ObserverSet() {\n this.clear();\n}\n\nObserverSet.prototype.add = function(sender, keyName, eventName) {\n var observerSet = this.observerSet,\n observers = this.observers,\n senderGuid = Ember.guidFor(sender),\n keySet = observerSet[senderGuid],\n index;\n\n if (!keySet) {\n observerSet[senderGuid] = keySet = {};\n }\n index = keySet[keyName];\n if (index === undefined) {\n index = observers.push({\n sender: sender,\n keyName: keyName,\n eventName: eventName,\n listeners: []\n }) - 1;\n keySet[keyName] = index;\n }\n return observers[index].listeners;\n};\n\nObserverSet.prototype.flush = function() {\n var observers = this.observers, i, len, observer, sender;\n this.clear();\n for (i=0, len=observers.length; i < len; ++i) {\n observer = observers[i];\n sender = observer.sender;\n if (sender.isDestroying || sender.isDestroyed) { continue; }\n Ember.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);\n }\n};\n\nObserverSet.prototype.clear = function() {\n this.observerSet = {};\n this.observers = [];\n};\n\nvar beforeObserverSet = new ObserverSet(), observerSet = new ObserverSet();\n\n/**\n @method beginPropertyChanges\n @chainable\n*/\nEmber.beginPropertyChanges = function() {\n deferred++;\n};\n\n/**\n @method endPropertyChanges\n*/\nEmber.endPropertyChanges = function() {\n deferred--;\n if (deferred<=0) {\n beforeObserverSet.clear();\n observerSet.flush();\n }\n};\n\n/**\n Make a series of property changes together in an\n exception-safe way.\n\n ```javascript\n Ember.changeProperties(function() {\n obj1.set('foo', mayBlowUpWhenSet);\n obj2.set('bar', baz);\n });\n ```\n\n @method changeProperties\n @param {Function} callback\n @param [binding]\n*/\nEmber.changeProperties = function(cb, binding){\n Ember.beginPropertyChanges();\n Ember.tryFinally(cb, Ember.endPropertyChanges, binding);\n};\n\n/**\n Set a list of properties on an object. These properties are set inside\n a single `beginPropertyChanges` and `endPropertyChanges` batch, so\n observers will be buffered.\n\n @method setProperties\n @param target\n @param {Hash} properties\n @return target\n*/\nEmber.setProperties = function(self, hash) {\n Ember.changeProperties(function(){\n for(var prop in hash) {\n if (hash.hasOwnProperty(prop)) Ember.set(self, prop, hash[prop]);\n }\n });\n return self;\n};\n\n\nfunction changeEvent(keyName) {\n return keyName+AFTER_OBSERVERS;\n}\n\nfunction beforeEvent(keyName) {\n return keyName+BEFORE_OBSERVERS;\n}\n\n/**\n @method addObserver\n @param obj\n @param {String} path\n @param {Object|Function} targetOrMethod\n @param {Function|String} [method]\n*/\nEmber.addObserver = function(obj, path, target, method) {\n Ember.addListener(obj, changeEvent(path), target, method);\n Ember.watch(obj, path);\n return this;\n};\n\nEmber.observersFor = function(obj, path) {\n return Ember.listenersFor(obj, changeEvent(path));\n};\n\n/**\n @method removeObserver\n @param obj\n @param {String} path\n @param {Object|Function} targetOrMethod\n @param {Function|String} [method]\n*/\nEmber.removeObserver = function(obj, path, target, method) {\n Ember.unwatch(obj, path);\n Ember.removeListener(obj, changeEvent(path), target, method);\n return this;\n};\n\n/**\n @method addBeforeObserver\n @param obj\n @param {String} path\n @param {Object|Function} targetOrMethod\n @param {Function|String} [method]\n*/\nEmber.addBeforeObserver = function(obj, path, target, method) {\n Ember.addListener(obj, beforeEvent(path), target, method);\n Ember.watch(obj, path);\n return this;\n};\n\n// Suspend observer during callback.\n//\n// This should only be used by the target of the observer\n// while it is setting the observed path.\nEmber._suspendBeforeObserver = function(obj, path, target, method, callback) {\n return Ember._suspendListener(obj, beforeEvent(path), target, method, callback);\n};\n\nEmber._suspendObserver = function(obj, path, target, method, callback) {\n return Ember._suspendListener(obj, changeEvent(path), target, method, callback);\n};\n\nvar map = Ember.ArrayPolyfills.map;\n\nEmber._suspendBeforeObservers = function(obj, paths, target, method, callback) {\n var events = map.call(paths, beforeEvent);\n return Ember._suspendListeners(obj, events, target, method, callback);\n};\n\nEmber._suspendObservers = function(obj, paths, target, method, callback) {\n var events = map.call(paths, changeEvent);\n return Ember._suspendListeners(obj, events, target, method, callback);\n};\n\nEmber.beforeObserversFor = function(obj, path) {\n return Ember.listenersFor(obj, beforeEvent(path));\n};\n\n/**\n @method removeBeforeObserver\n @param obj\n @param {String} path\n @param {Object|Function} targetOrMethod\n @param {Function|String} [method]\n*/\nEmber.removeBeforeObserver = function(obj, path, target, method) {\n Ember.unwatch(obj, path);\n Ember.removeListener(obj, beforeEvent(path), target, method);\n return this;\n};\n\nEmber.notifyBeforeObservers = function(obj, keyName) {\n if (obj.isDestroying) { return; }\n\n var eventName = beforeEvent(keyName), listeners, listenersDiff;\n if (deferred) {\n listeners = beforeObserverSet.add(obj, keyName, eventName);\n listenersDiff = Ember.listenersDiff(obj, eventName, listeners);\n Ember.sendEvent(obj, eventName, [obj, keyName], listenersDiff);\n } else {\n Ember.sendEvent(obj, eventName, [obj, keyName]);\n }\n};\n\nEmber.notifyObservers = function(obj, keyName) {\n if (obj.isDestroying) { return; }\n\n var eventName = changeEvent(keyName), listeners;\n if (deferred) {\n listeners = observerSet.add(obj, keyName, eventName);\n Ember.listenersUnion(obj, eventName, listeners);\n } else {\n Ember.sendEvent(obj, eventName, [obj, keyName]);\n }\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar guidFor = Ember.guidFor, // utils.js\n metaFor = Ember.meta, // utils.js\n get = Ember.get, // accessors.js\n set = Ember.set, // accessors.js\n normalizeTuple = Ember.normalizeTuple, // accessors.js\n GUID_KEY = Ember.GUID_KEY, // utils.js\n META_KEY = Ember.META_KEY, // utils.js\n // circular reference observer depends on Ember.watch\n // we should move change events to this file or its own property_events.js\n notifyObservers = Ember.notifyObservers, // observer.js\n forEach = Ember.ArrayPolyfills.forEach, // array.js\n FIRST_KEY = /^([^\\.\\*]+)/,\n IS_PATH = /[\\.\\*]/;\n\nvar MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER,\no_defineProperty = Ember.platform.defineProperty;\n\nfunction firstKey(path) {\n return path.match(FIRST_KEY)[0];\n}\n\n// returns true if the passed path is just a keyName\nfunction isKeyName(path) {\n return path==='*' || !IS_PATH.test(path);\n}\n\n// ..........................................................\n// DEPENDENT KEYS\n//\n\nfunction iterDeps(method, obj, depKey, seen, meta) {\n\n var guid = guidFor(obj);\n if (!seen[guid]) seen[guid] = {};\n if (seen[guid][depKey]) return;\n seen[guid][depKey] = true;\n\n var deps = meta.deps;\n deps = deps && deps[depKey];\n if (deps) {\n for(var key in deps) {\n var desc = meta.descs[key];\n if (desc && desc._suspended === obj) continue;\n method(obj, key);\n }\n }\n}\n\n\nvar WILL_SEEN, DID_SEEN;\n\n// called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...)\nfunction dependentKeysWillChange(obj, depKey, meta) {\n if (obj.isDestroying) { return; }\n\n var seen = WILL_SEEN, top = !seen;\n if (top) { seen = WILL_SEEN = {}; }\n iterDeps(propertyWillChange, obj, depKey, seen, meta);\n if (top) { WILL_SEEN = null; }\n}\n\n// called whenever a property has just changed to update dependent keys\nfunction dependentKeysDidChange(obj, depKey, meta) {\n if (obj.isDestroying) { return; }\n\n var seen = DID_SEEN, top = !seen;\n if (top) { seen = DID_SEEN = {}; }\n iterDeps(propertyDidChange, obj, depKey, seen, meta);\n if (top) { DID_SEEN = null; }\n}\n\n// ..........................................................\n// CHAIN\n//\n\nfunction addChainWatcher(obj, keyName, node) {\n if (!obj || ('object' !== typeof obj)) { return; } // nothing to do\n\n var m = metaFor(obj), nodes = m.chainWatchers;\n\n if (!m.hasOwnProperty('chainWatchers')) {\n nodes = m.chainWatchers = {};\n }\n\n if (!nodes[keyName]) { nodes[keyName] = []; }\n nodes[keyName].push(node);\n Ember.watch(obj, keyName);\n}\n\nfunction removeChainWatcher(obj, keyName, node) {\n if (!obj || 'object' !== typeof obj) { return; } // nothing to do\n\n var m = metaFor(obj, false);\n if (!m.hasOwnProperty('chainWatchers')) { return; } // nothing to do\n\n var nodes = m.chainWatchers;\n\n if (nodes[keyName]) {\n nodes = nodes[keyName];\n for (var i = 0, l = nodes.length; i < l; i++) {\n if (nodes[i] === node) { nodes.splice(i, 1); }\n }\n }\n Ember.unwatch(obj, keyName);\n}\n\nvar pendingQueue = [];\n\n// attempts to add the pendingQueue chains again. If some of them end up\n// back in the queue and reschedule is true, schedules a timeout to try\n// again.\nfunction flushPendingChains() {\n if (pendingQueue.length === 0) { return; } // nothing to do\n\n var queue = pendingQueue;\n pendingQueue = [];\n\n forEach.call(queue, function(q) { q[0].add(q[1]); });\n\n Ember.warn('Watching an undefined global, Ember expects watched globals to be setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0);\n}\n\nfunction isProto(pvalue) {\n return metaFor(pvalue, false).proto === pvalue;\n}\n\n// A ChainNode watches a single key on an object. If you provide a starting\n// value for the key then the node won't actually watch it. For a root node\n// pass null for parent and key and object for value.\nvar ChainNode = function(parent, key, value) {\n var obj;\n this._parent = parent;\n this._key = key;\n\n // _watching is true when calling get(this._parent, this._key) will\n // return the value of this node.\n //\n // It is false for the root of a chain (because we have no parent)\n // and for global paths (because the parent node is the object with\n // the observer on it)\n this._watching = value===undefined;\n\n this._value = value;\n this._paths = {};\n if (this._watching) {\n this._object = parent.value();\n if (this._object) { addChainWatcher(this._object, this._key, this); }\n }\n\n // Special-case: the EachProxy relies on immediate evaluation to\n // establish its observers.\n //\n // TODO: Replace this with an efficient callback that the EachProxy\n // can implement.\n if (this._parent && this._parent._key === '@each') {\n this.value();\n }\n};\n\nvar ChainNodePrototype = ChainNode.prototype;\n\nChainNodePrototype.value = function() {\n if (this._value === undefined && this._watching) {\n var obj = this._parent.value();\n this._value = (obj && !isProto(obj)) ? get(obj, this._key) : undefined;\n }\n return this._value;\n};\n\nChainNodePrototype.destroy = function() {\n if (this._watching) {\n var obj = this._object;\n if (obj) { removeChainWatcher(obj, this._key, this); }\n this._watching = false; // so future calls do nothing\n }\n};\n\n// copies a top level object only\nChainNodePrototype.copy = function(obj) {\n var ret = new ChainNode(null, null, obj),\n paths = this._paths, path;\n for (path in paths) {\n if (paths[path] <= 0) { continue; } // this check will also catch non-number vals.\n ret.add(path);\n }\n return ret;\n};\n\n// called on the root node of a chain to setup watchers on the specified\n// path.\nChainNodePrototype.add = function(path) {\n var obj, tuple, key, src, paths;\n\n paths = this._paths;\n paths[path] = (paths[path] || 0) + 1;\n\n obj = this.value();\n tuple = normalizeTuple(obj, path);\n\n // the path was a local path\n if (tuple[0] && tuple[0] === obj) {\n path = tuple[1];\n key = firstKey(path);\n path = path.slice(key.length+1);\n\n // global path, but object does not exist yet.\n // put into a queue and try to connect later.\n } else if (!tuple[0]) {\n pendingQueue.push([this, path]);\n tuple.length = 0;\n return;\n\n // global path, and object already exists\n } else {\n src = tuple[0];\n key = path.slice(0, 0-(tuple[1].length+1));\n path = tuple[1];\n }\n\n tuple.length = 0;\n this.chain(key, path, src);\n};\n\n// called on the root node of a chain to teardown watcher on the specified\n// path\nChainNodePrototype.remove = function(path) {\n var obj, tuple, key, src, paths;\n\n paths = this._paths;\n if (paths[path] > 0) { paths[path]--; }\n\n obj = this.value();\n tuple = normalizeTuple(obj, path);\n if (tuple[0] === obj) {\n path = tuple[1];\n key = firstKey(path);\n path = path.slice(key.length+1);\n } else {\n src = tuple[0];\n key = path.slice(0, 0-(tuple[1].length+1));\n path = tuple[1];\n }\n\n tuple.length = 0;\n this.unchain(key, path);\n};\n\nChainNodePrototype.count = 0;\n\nChainNodePrototype.chain = function(key, path, src) {\n var chains = this._chains, node;\n if (!chains) { chains = this._chains = {}; }\n\n node = chains[key];\n if (!node) { node = chains[key] = new ChainNode(this, key, src); }\n node.count++; // count chains...\n\n // chain rest of path if there is one\n if (path && path.length>0) {\n key = firstKey(path);\n path = path.slice(key.length+1);\n node.chain(key, path); // NOTE: no src means it will observe changes...\n }\n};\n\nChainNodePrototype.unchain = function(key, path) {\n var chains = this._chains, node = chains[key];\n\n // unchain rest of path first...\n if (path && path.length>1) {\n key = firstKey(path);\n path = path.slice(key.length+1);\n node.unchain(key, path);\n }\n\n // delete node if needed.\n node.count--;\n if (node.count<=0) {\n delete chains[node._key];\n node.destroy();\n }\n\n};\n\nChainNodePrototype.willChange = function() {\n var chains = this._chains;\n if (chains) {\n for(var key in chains) {\n if (!chains.hasOwnProperty(key)) { continue; }\n chains[key].willChange();\n }\n }\n\n if (this._parent) { this._parent.chainWillChange(this, this._key, 1); }\n};\n\nChainNodePrototype.chainWillChange = function(chain, path, depth) {\n if (this._key) { path = this._key + '.' + path; }\n\n if (this._parent) {\n this._parent.chainWillChange(this, path, depth+1);\n } else {\n if (depth > 1) { Ember.propertyWillChange(this.value(), path); }\n path = 'this.' + path;\n if (this._paths[path] > 0) { Ember.propertyWillChange(this.value(), path); }\n }\n};\n\nChainNodePrototype.chainDidChange = function(chain, path, depth) {\n if (this._key) { path = this._key + '.' + path; }\n if (this._parent) {\n this._parent.chainDidChange(this, path, depth+1);\n } else {\n if (depth > 1) { Ember.propertyDidChange(this.value(), path); }\n path = 'this.' + path;\n if (this._paths[path] > 0) { Ember.propertyDidChange(this.value(), path); }\n }\n};\n\nChainNodePrototype.didChange = function(suppressEvent) {\n // invalidate my own value first.\n if (this._watching) {\n var obj = this._parent.value();\n if (obj !== this._object) {\n removeChainWatcher(this._object, this._key, this);\n this._object = obj;\n addChainWatcher(obj, this._key, this);\n }\n this._value = undefined;\n\n // Special-case: the EachProxy relies on immediate evaluation to\n // establish its observers.\n if (this._parent && this._parent._key === '@each')\n this.value();\n }\n\n // then notify chains...\n var chains = this._chains;\n if (chains) {\n for(var key in chains) {\n if (!chains.hasOwnProperty(key)) { continue; }\n chains[key].didChange(suppressEvent);\n }\n }\n\n if (suppressEvent) { return; }\n\n // and finally tell parent about my path changing...\n if (this._parent) { this._parent.chainDidChange(this, this._key, 1); }\n};\n\n// get the chains for the current object. If the current object has\n// chains inherited from the proto they will be cloned and reconfigured for\n// the current object.\nfunction chainsFor(obj) {\n var m = metaFor(obj), ret = m.chains;\n if (!ret) {\n ret = m.chains = new ChainNode(null, null, obj);\n } else if (ret.value() !== obj) {\n ret = m.chains = ret.copy(obj);\n }\n return ret;\n}\n\nEmber.overrideChains = function(obj, keyName, m) {\n chainsDidChange(obj, keyName, m, true);\n};\n\nfunction chainsWillChange(obj, keyName, m, arg) {\n if (!m.hasOwnProperty('chainWatchers')) { return; } // nothing to do\n\n var nodes = m.chainWatchers;\n\n nodes = nodes[keyName];\n if (!nodes) { return; }\n\n for(var i = 0, l = nodes.length; i < l; i++) {\n nodes[i].willChange(arg);\n }\n}\n\nfunction chainsDidChange(obj, keyName, m, arg) {\n if (!m.hasOwnProperty('chainWatchers')) { return; } // nothing to do\n\n var nodes = m.chainWatchers;\n\n nodes = nodes[keyName];\n if (!nodes) { return; }\n\n // looping in reverse because the chainWatchers array can be modified inside didChange\n for (var i = nodes.length - 1; i >= 0; i--) {\n nodes[i].didChange(arg);\n }\n}\n\n// ..........................................................\n// WATCH\n//\n\n/**\n @private\n\n Starts watching a property on an object. Whenever the property changes,\n invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the\n primitive used by observers and dependent keys; usually you will never call\n this method directly but instead use higher level methods like\n `Ember.addObserver()`\n\n @method watch\n @for Ember\n @param obj\n @param {String} keyName\n*/\nEmber.watch = function(obj, keyName) {\n // can't watch length on Array - it is special...\n if (keyName === 'length' && Ember.typeOf(obj) === 'array') { return this; }\n\n var m = metaFor(obj), watching = m.watching, desc;\n\n // activate watching first time\n if (!watching[keyName]) {\n watching[keyName] = 1;\n if (isKeyName(keyName)) {\n desc = m.descs[keyName];\n if (desc && desc.willWatch) { desc.willWatch(obj, keyName); }\n\n if ('function' === typeof obj.willWatchProperty) {\n obj.willWatchProperty(keyName);\n }\n\n if (MANDATORY_SETTER && keyName in obj) {\n m.values[keyName] = obj[keyName];\n o_defineProperty(obj, keyName, {\n configurable: true,\n enumerable: true,\n set: function() {\n Ember.assert('Must use Ember.set() to access this property', false);\n },\n get: function() {\n var meta = this[META_KEY];\n return meta && meta.values[keyName];\n }\n });\n }\n } else {\n chainsFor(obj).add(keyName);\n }\n\n } else {\n watching[keyName] = (watching[keyName] || 0) + 1;\n }\n return this;\n};\n\nEmber.isWatching = function isWatching(obj, key) {\n var meta = obj[META_KEY];\n return (meta && meta.watching[key]) > 0;\n};\n\nEmber.watch.flushPending = flushPendingChains;\n\nEmber.unwatch = function(obj, keyName) {\n // can't watch length on Array - it is special...\n if (keyName === 'length' && Ember.typeOf(obj) === 'array') { return this; }\n\n var m = metaFor(obj), watching = m.watching, desc;\n\n if (watching[keyName] === 1) {\n watching[keyName] = 0;\n\n if (isKeyName(keyName)) {\n desc = m.descs[keyName];\n if (desc && desc.didUnwatch) { desc.didUnwatch(obj, keyName); }\n\n if ('function' === typeof obj.didUnwatchProperty) {\n obj.didUnwatchProperty(keyName);\n }\n\n if (MANDATORY_SETTER && keyName in obj) {\n o_defineProperty(obj, keyName, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: m.values[keyName]\n });\n delete m.values[keyName];\n }\n } else {\n chainsFor(obj).remove(keyName);\n }\n\n } else if (watching[keyName]>1) {\n watching[keyName]--;\n }\n\n return this;\n};\n\n/**\n @private\n\n Call on an object when you first beget it from another object. This will\n setup any chained watchers on the object instance as needed. This method is\n safe to call multiple times.\n\n @method rewatch\n @for Ember\n @param obj\n*/\nEmber.rewatch = function(obj) {\n var m = metaFor(obj, false), chains = m.chains;\n\n // make sure the object has its own guid.\n if (GUID_KEY in obj && !obj.hasOwnProperty(GUID_KEY)) {\n Ember.generateGuid(obj, 'ember');\n }\n\n // make sure any chained watchers update.\n if (chains && chains.value() !== obj) {\n m.chains = chains.copy(obj);\n }\n\n return this;\n};\n\nEmber.finishChains = function(obj) {\n var m = metaFor(obj, false), chains = m.chains;\n if (chains) {\n if (chains.value() !== obj) {\n m.chains = chains = chains.copy(obj);\n }\n chains.didChange(true);\n }\n};\n\n// ..........................................................\n// PROPERTY CHANGES\n//\n\n/**\n This function is called just before an object property is about to change.\n It will notify any before observers and prepare caches among other things.\n\n Normally you will not need to call this method directly but if for some\n reason you can't directly watch a property you can invoke this method\n manually along with `Ember.propertyDidChange()` which you should call just\n after the property value changes.\n\n @method propertyWillChange\n @for Ember\n @param {Object} obj The object with the property that will change\n @param {String} keyName The property key (or path) that will change.\n @return {void}\n*/\nfunction propertyWillChange(obj, keyName, value) {\n var m = metaFor(obj, false),\n watching = m.watching[keyName] > 0 || keyName === 'length',\n proto = m.proto,\n desc = m.descs[keyName];\n\n if (!watching) { return; }\n if (proto === obj) { return; }\n if (desc && desc.willChange) { desc.willChange(obj, keyName); }\n dependentKeysWillChange(obj, keyName, m);\n chainsWillChange(obj, keyName, m);\n Ember.notifyBeforeObservers(obj, keyName);\n}\n\nEmber.propertyWillChange = propertyWillChange;\n\n/**\n This function is called just after an object property has changed.\n It will notify any observers and clear caches among other things.\n\n Normally you will not need to call this method directly but if for some\n reason you can't directly watch a property you can invoke this method\n manually along with `Ember.propertyWilLChange()` which you should call just\n before the property value changes.\n\n @method propertyDidChange\n @for Ember\n @param {Object} obj The object with the property that will change\n @param {String} keyName The property key (or path) that will change.\n @return {void}\n*/\nfunction propertyDidChange(obj, keyName) {\n var m = metaFor(obj, false),\n watching = m.watching[keyName] > 0 || keyName === 'length',\n proto = m.proto,\n desc = m.descs[keyName];\n\n if (proto === obj) { return; }\n\n // shouldn't this mean that we're watching this key?\n if (desc && desc.didChange) { desc.didChange(obj, keyName); }\n if (!watching && keyName !== 'length') { return; }\n\n dependentKeysDidChange(obj, keyName, m);\n chainsDidChange(obj, keyName, m);\n Ember.notifyObservers(obj, keyName);\n}\n\nEmber.propertyDidChange = propertyDidChange;\n\nvar NODE_STACK = [];\n\n/**\n Tears down the meta on an object so that it can be garbage collected.\n Multiple calls will have no effect.\n\n @method destroy\n @for Ember\n @param {Object} obj the object to destroy\n @return {void}\n*/\nEmber.destroy = function (obj) {\n var meta = obj[META_KEY], node, nodes, key, nodeObject;\n if (meta) {\n obj[META_KEY] = null;\n // remove chainWatchers to remove circular references that would prevent GC\n node = meta.chains;\n if (node) {\n NODE_STACK.push(node);\n // process tree\n while (NODE_STACK.length > 0) {\n node = NODE_STACK.pop();\n // push children\n nodes = node._chains;\n if (nodes) {\n for (key in nodes) {\n if (nodes.hasOwnProperty(key)) {\n NODE_STACK.push(nodes[key]);\n }\n }\n }\n // remove chainWatcher in node object\n if (node._watching) {\n nodeObject = node._object;\n if (nodeObject) {\n removeChainWatcher(nodeObject, node._key, node);\n }\n }\n }\n }\n }\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nEmber.warn(\"The CP_DEFAULT_CACHEABLE flag has been removed and computed properties are always cached by default. Use `volatile` if you don't want caching.\", Ember.ENV.CP_DEFAULT_CACHEABLE !== false);\n\n\nvar get = Ember.get,\n metaFor = Ember.meta,\n guidFor = Ember.guidFor,\n a_slice = [].slice,\n o_create = Ember.create,\n META_KEY = Ember.META_KEY,\n watch = Ember.watch,\n unwatch = Ember.unwatch;\n\n// ..........................................................\n// DEPENDENT KEYS\n//\n\n// data structure:\n// meta.deps = {\n// 'depKey': {\n// 'keyName': count,\n// }\n// }\n\n/*\n This function returns a map of unique dependencies for a\n given object and key.\n*/\nfunction keysForDep(obj, depsMeta, depKey) {\n var keys = depsMeta[depKey];\n if (!keys) {\n // if there are no dependencies yet for a the given key\n // create a new empty list of dependencies for the key\n keys = depsMeta[depKey] = {};\n } else if (!depsMeta.hasOwnProperty(depKey)) {\n // otherwise if the dependency list is inherited from\n // a superclass, clone the hash\n keys = depsMeta[depKey] = o_create(keys);\n }\n return keys;\n}\n\n/* return obj[META_KEY].deps */\nfunction metaForDeps(obj, meta) {\n var deps = meta.deps;\n // If the current object has no dependencies...\n if (!deps) {\n // initialize the dependencies with a pointer back to\n // the current object\n deps = meta.deps = {};\n } else if (!meta.hasOwnProperty('deps')) {\n // otherwise if the dependencies are inherited from the\n // object's superclass, clone the deps\n deps = meta.deps = o_create(deps);\n }\n return deps;\n}\n\nfunction addDependentKeys(desc, obj, keyName, meta) {\n // the descriptor has a list of dependent keys, so\n // add all of its dependent keys.\n var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys;\n if (!depKeys) return;\n\n depsMeta = metaForDeps(obj, meta);\n\n for(idx = 0, len = depKeys.length; idx < len; idx++) {\n depKey = depKeys[idx];\n // Lookup keys meta for depKey\n keys = keysForDep(obj, depsMeta, depKey);\n // Increment the number of times depKey depends on keyName.\n keys[keyName] = (keys[keyName] || 0) + 1;\n // Watch the depKey\n watch(obj, depKey);\n }\n}\n\nfunction removeDependentKeys(desc, obj, keyName, meta) {\n // the descriptor has a list of dependent keys, so\n // add all of its dependent keys.\n var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys;\n if (!depKeys) return;\n\n depsMeta = metaForDeps(obj, meta);\n\n for(idx = 0, len = depKeys.length; idx < len; idx++) {\n depKey = depKeys[idx];\n // Lookup keys meta for depKey\n keys = keysForDep(obj, depsMeta, depKey);\n // Increment the number of times depKey depends on keyName.\n keys[keyName] = (keys[keyName] || 0) - 1;\n // Watch the depKey\n unwatch(obj, depKey);\n }\n}\n\n// ..........................................................\n// COMPUTED PROPERTY\n//\n\n/**\n @class ComputedProperty\n @namespace Ember\n @extends Ember.Descriptor\n @constructor\n*/\nfunction ComputedProperty(func, opts) {\n this.func = func;\n this._cacheable = (opts && opts.cacheable !== undefined) ? opts.cacheable : true;\n this._dependentKeys = opts && opts.dependentKeys;\n}\n\nEmber.ComputedProperty = ComputedProperty;\nComputedProperty.prototype = new Ember.Descriptor();\n\nvar ComputedPropertyPrototype = ComputedProperty.prototype;\n\n/**\n Call on a computed property to set it into cacheable mode. When in this\n mode the computed property will automatically cache the return value of\n your function until one of the dependent keys changes.\n\n ```javascript\n MyApp.president = Ember.Object.create({\n fullName: function() {\n return this.get('firstName') + ' ' + this.get('lastName');\n\n // After calculating the value of this function, Ember will\n // return that value without re-executing this function until\n // one of the dependent properties change.\n }.property('firstName', 'lastName')\n });\n ```\n\n Properties are cacheable by default.\n\n @method cacheable\n @param {Boolean} aFlag optional set to `false` to disable caching\n @chainable\n*/\nComputedPropertyPrototype.cacheable = function(aFlag) {\n this._cacheable = aFlag !== false;\n return this;\n};\n\n/**\n Call on a computed property to set it into non-cached mode. When in this\n mode the computed property will not automatically cache the return value.\n\n ```javascript\n MyApp.outsideService = Ember.Object.create({\n value: function() {\n return OutsideService.getValue();\n }.property().volatile()\n });\n ```\n\n @method volatile\n @chainable\n*/\nComputedPropertyPrototype.volatile = function() {\n return this.cacheable(false);\n};\n\n/**\n Sets the dependent keys on this computed property. Pass any number of\n arguments containing key paths that this computed property depends on.\n\n ```javascript\n MyApp.president = Ember.Object.create({\n fullName: Ember.computed(function() {\n return this.get('firstName') + ' ' + this.get('lastName');\n\n // Tell Ember that this computed property depends on firstName\n // and lastName\n }).property('firstName', 'lastName')\n });\n ```\n\n @method property\n @param {String} path* zero or more property paths\n @chainable\n*/\nComputedPropertyPrototype.property = function() {\n var args = [];\n for (var i = 0, l = arguments.length; i < l; i++) {\n args.push(arguments[i]);\n }\n this._dependentKeys = args;\n return this;\n};\n\n/**\n In some cases, you may want to annotate computed properties with additional\n metadata about how they function or what values they operate on. For example,\n computed property functions may close over variables that are then no longer\n available for introspection.\n\n You can pass a hash of these values to a computed property like this:\n\n ```\n person: function() {\n var personId = this.get('personId');\n return App.Person.create({ id: personId });\n }.property().meta({ type: App.Person })\n ```\n\n The hash that you pass to the `meta()` function will be saved on the\n computed property descriptor under the `_meta` key. Ember runtime\n exposes a public API for retrieving these values from classes,\n via the `metaForProperty()` function.\n\n @method meta\n @param {Hash} meta\n @chainable\n*/\n\nComputedPropertyPrototype.meta = function(meta) {\n if (arguments.length === 0) {\n return this._meta || {};\n } else {\n this._meta = meta;\n return this;\n }\n};\n\n/* impl descriptor API */\nComputedPropertyPrototype.willWatch = function(obj, keyName) {\n // watch already creates meta for this instance\n var meta = obj[META_KEY];\n Ember.assert('watch should have setup meta to be writable', meta.source === obj);\n if (!(keyName in meta.cache)) {\n addDependentKeys(this, obj, keyName, meta);\n }\n};\n\nComputedPropertyPrototype.didUnwatch = function(obj, keyName) {\n var meta = obj[META_KEY];\n Ember.assert('unwatch should have setup meta to be writable', meta.source === obj);\n if (!(keyName in meta.cache)) {\n // unwatch already creates meta for this instance\n removeDependentKeys(this, obj, keyName, meta);\n }\n};\n\n/* impl descriptor API */\nComputedPropertyPrototype.didChange = function(obj, keyName) {\n // _suspended is set via a CP.set to ensure we don't clear\n // the cached value set by the setter\n if (this._cacheable && this._suspended !== obj) {\n var meta = metaFor(obj);\n if (keyName in meta.cache) {\n delete meta.cache[keyName];\n if (!meta.watching[keyName]) {\n removeDependentKeys(this, obj, keyName, meta);\n }\n }\n }\n};\n\n/* impl descriptor API */\nComputedPropertyPrototype.get = function(obj, keyName) {\n var ret, cache, meta;\n if (this._cacheable) {\n meta = metaFor(obj);\n cache = meta.cache;\n if (keyName in cache) { return cache[keyName]; }\n ret = cache[keyName] = this.func.call(obj, keyName);\n if (!meta.watching[keyName]) {\n addDependentKeys(this, obj, keyName, meta);\n }\n } else {\n ret = this.func.call(obj, keyName);\n }\n return ret;\n};\n\n/* impl descriptor API */\nComputedPropertyPrototype.set = function(obj, keyName, value) {\n var cacheable = this._cacheable,\n func = this.func,\n meta = metaFor(obj, cacheable),\n watched = meta.watching[keyName],\n oldSuspended = this._suspended,\n hadCachedValue = false,\n cache = meta.cache,\n cachedValue, ret;\n\n this._suspended = obj;\n\n try {\n if (cacheable && cache.hasOwnProperty(keyName)) {\n cachedValue = cache[keyName];\n hadCachedValue = true;\n }\n\n // For backwards-compatibility with computed properties\n // that check for arguments.length === 2 to determine if\n // they are being get or set, only pass the old cached\n // value if the computed property opts into a third\n // argument.\n if (func.length === 3) {\n ret = func.call(obj, keyName, value, cachedValue);\n } else if (func.length === 2) {\n ret = func.call(obj, keyName, value);\n } else {\n Ember.defineProperty(obj, keyName, null, cachedValue);\n Ember.set(obj, keyName, value);\n return;\n }\n\n if (hadCachedValue && cachedValue === ret) { return; }\n\n if (watched) { Ember.propertyWillChange(obj, keyName); }\n\n if (hadCachedValue) {\n delete cache[keyName];\n }\n\n if (cacheable) {\n if (!watched && !hadCachedValue) {\n addDependentKeys(this, obj, keyName, meta);\n }\n cache[keyName] = ret;\n }\n\n if (watched) { Ember.propertyDidChange(obj, keyName); }\n } finally {\n this._suspended = oldSuspended;\n }\n return ret;\n};\n\n/* called when property is defined */\nComputedPropertyPrototype.setup = function(obj, keyName) {\n var meta = obj[META_KEY];\n if (meta && meta.watching[keyName]) {\n addDependentKeys(this, obj, keyName, metaFor(obj));\n }\n};\n\n/* called before property is overridden */\nComputedPropertyPrototype.teardown = function(obj, keyName) {\n var meta = metaFor(obj);\n\n if (meta.watching[keyName] || keyName in meta.cache) {\n removeDependentKeys(this, obj, keyName, meta);\n }\n\n if (this._cacheable) { delete meta.cache[keyName]; }\n\n return null; // no value to restore\n};\n\n\n/**\n This helper returns a new property descriptor that wraps the passed\n computed property function. You can use this helper to define properties\n with mixins or via `Ember.defineProperty()`.\n\n The function you pass will be used to both get and set property values.\n The function should accept two parameters, key and value. If value is not\n undefined you should set the value first. In either case return the\n current value of the property.\n\n @method computed\n @for Ember\n @param {Function} func The computed property function.\n @return {Ember.ComputedProperty} property descriptor instance\n*/\nEmber.computed = function(func) {\n var args;\n\n if (arguments.length > 1) {\n args = a_slice.call(arguments, 0, -1);\n func = a_slice.call(arguments, -1)[0];\n }\n\n var cp = new ComputedProperty(func);\n\n if (args) {\n cp.property.apply(cp, args);\n }\n\n return cp;\n};\n\n/**\n Returns the cached value for a property, if one exists.\n This can be useful for peeking at the value of a computed\n property that is generated lazily, without accidentally causing\n it to be created.\n\n @method cacheFor\n @for Ember\n @param {Object} obj the object whose property you want to check\n @param {String} key the name of the property whose cached value you want\n to return\n*/\nEmber.cacheFor = function cacheFor(obj, key) {\n var cache = metaFor(obj, false).cache;\n\n if (cache && key in cache) {\n return cache[key];\n }\n};\n\n/**\n @method computed.not\n @for Ember\n @param {String} dependentKey\n*/\nEmber.computed.not = function(dependentKey) {\n return Ember.computed(dependentKey, function(key) {\n return !get(this, dependentKey);\n });\n};\n\n/**\n @method computed.empty\n @for Ember\n @param {String} dependentKey\n*/\nEmber.computed.empty = function(dependentKey) {\n return Ember.computed(dependentKey, function(key) {\n var val = get(this, dependentKey);\n return val === undefined || val === null || val === '' || (Ember.isArray(val) && get(val, 'length') === 0);\n });\n};\n\n/**\n @method computed.bool\n @for Ember\n @param {String} dependentKey\n*/\nEmber.computed.bool = function(dependentKey) {\n return Ember.computed(dependentKey, function(key) {\n return !!get(this, dependentKey);\n });\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar o_create = Ember.create,\n metaFor = Ember.meta,\n metaPath = Ember.metaPath,\n META_KEY = Ember.META_KEY;\n\n/*\n The event system uses a series of nested hashes to store listeners on an\n object. When a listener is registered, or when an event arrives, these\n hashes are consulted to determine which target and action pair to invoke.\n\n The hashes are stored in the object's meta hash, and look like this:\n\n // Object's meta hash\n {\n listeners: { // variable name: `listenerSet`\n \"foo:changed\": [ // variable name: `actions`\n [target, method, onceFlag, suspendedFlag]\n ]\n }\n }\n\n*/\n\nfunction indexOf(array, target, method) {\n var index = -1;\n for (var i = 0, l = array.length; i < l; i++) {\n if (target === array[i][0] && method === array[i][1]) { index = i; break; }\n }\n return index;\n}\n\nfunction actionsFor(obj, eventName) {\n var meta = metaFor(obj, true),\n actions;\n\n if (!meta.listeners) { meta.listeners = {}; }\n\n if (!meta.hasOwnProperty('listeners')) {\n // setup inherited copy of the listeners object\n meta.listeners = o_create(meta.listeners);\n }\n\n actions = meta.listeners[eventName];\n\n // if there are actions, but the eventName doesn't exist in our listeners, then copy them from the prototype\n if (actions && !meta.listeners.hasOwnProperty(eventName)) {\n actions = meta.listeners[eventName] = meta.listeners[eventName].slice();\n } else if (!actions) {\n actions = meta.listeners[eventName] = [];\n }\n\n return actions;\n}\n\nfunction actionsUnion(obj, eventName, otherActions) {\n var meta = obj[META_KEY],\n actions = meta && meta.listeners && meta.listeners[eventName];\n\n if (!actions) { return; }\n for (var i = actions.length - 1; i >= 0; i--) {\n var target = actions[i][0],\n method = actions[i][1],\n once = actions[i][2],\n suspended = actions[i][3],\n actionIndex = indexOf(otherActions, target, method);\n\n if (actionIndex === -1) {\n otherActions.push([target, method, once, suspended]);\n }\n }\n}\n\nfunction actionsDiff(obj, eventName, otherActions) {\n var meta = obj[META_KEY],\n actions = meta && meta.listeners && meta.listeners[eventName],\n diffActions = [];\n\n if (!actions) { return; }\n for (var i = actions.length - 1; i >= 0; i--) {\n var target = actions[i][0],\n method = actions[i][1],\n once = actions[i][2],\n suspended = actions[i][3],\n actionIndex = indexOf(otherActions, target, method);\n\n if (actionIndex !== -1) { continue; }\n\n otherActions.push([target, method, once, suspended]);\n diffActions.push([target, method, once, suspended]);\n }\n\n return diffActions;\n}\n\n/**\n Add an event listener\n\n @method addListener\n @for Ember\n @param obj\n @param {String} eventName\n @param {Object|Function} targetOrMethod A target object or a function\n @param {Function|String} method A function or the name of a function to be called on `target`\n*/\nfunction addListener(obj, eventName, target, method, once) {\n Ember.assert(\"You must pass at least an object and event name to Ember.addListener\", !!obj && !!eventName);\n\n if (!method && 'function' === typeof target) {\n method = target;\n target = null;\n }\n\n var actions = actionsFor(obj, eventName),\n actionIndex = indexOf(actions, target, method);\n\n if (actionIndex !== -1) { return; }\n\n actions.push([target, method, once, undefined]);\n\n if ('function' === typeof obj.didAddListener) {\n obj.didAddListener(eventName, target, method);\n }\n}\n\n/**\n Remove an event listener\n\n Arguments should match those passed to {{#crossLink \"Ember/addListener\"}}{{/crossLink}}\n\n @method removeListener\n @for Ember\n @param obj\n @param {String} eventName\n @param {Object|Function} targetOrMethod A target object or a function\n @param {Function|String} method A function or the name of a function to be called on `target`\n*/\nfunction removeListener(obj, eventName, target, method) {\n Ember.assert(\"You must pass at least an object and event name to Ember.removeListener\", !!obj && !!eventName);\n\n if (!method && 'function' === typeof target) {\n method = target;\n target = null;\n }\n\n function _removeListener(target, method, once) {\n var actions = actionsFor(obj, eventName),\n actionIndex = indexOf(actions, target, method);\n\n // action doesn't exist, give up silently\n if (actionIndex === -1) { return; }\n\n actions.splice(actionIndex, 1);\n\n if ('function' === typeof obj.didRemoveListener) {\n obj.didRemoveListener(eventName, target, method);\n }\n }\n\n if (method) {\n _removeListener(target, method);\n } else {\n var meta = obj[META_KEY],\n actions = meta && meta.listeners && meta.listeners[eventName];\n\n if (!actions) { return; }\n for (var i = actions.length - 1; i >= 0; i--) {\n _removeListener(actions[i][0], actions[i][1]);\n }\n }\n}\n\n/**\n @private\n\n Suspend listener during callback.\n\n This should only be used by the target of the event listener\n when it is taking an action that would cause the event, e.g.\n an object might suspend its property change listener while it is\n setting that property.\n\n @method suspendListener\n @for Ember\n @param obj\n @param {String} eventName\n @param {Object|Function} targetOrMethod A target object or a function\n @param {Function|String} method A function or the name of a function to be called on `target`\n @param {Function} callback\n*/\nfunction suspendListener(obj, eventName, target, method, callback) {\n if (!method && 'function' === typeof target) {\n method = target;\n target = null;\n }\n\n var actions = actionsFor(obj, eventName),\n actionIndex = indexOf(actions, target, method),\n action;\n\n if (actionIndex !== -1) {\n action = actions[actionIndex].slice(); // copy it, otherwise we're modifying a shared object\n action[3] = true; // mark the action as suspended\n actions[actionIndex] = action; // replace the shared object with our copy\n }\n\n function tryable() { return callback.call(target); }\n function finalizer() { if (action) { action[3] = undefined; } }\n\n return Ember.tryFinally(tryable, finalizer);\n}\n\n/**\n @private\n\n Suspend listener during callback.\n\n This should only be used by the target of the event listener\n when it is taking an action that would cause the event, e.g.\n an object might suspend its property change listener while it is\n setting that property.\n\n @method suspendListener\n @for Ember\n @param obj\n @param {Array} eventName Array of event names\n @param {Object|Function} targetOrMethod A target object or a function\n @param {Function|String} method A function or the name of a function to be called on `target`\n @param {Function} callback\n*/\nfunction suspendListeners(obj, eventNames, target, method, callback) {\n if (!method && 'function' === typeof target) {\n method = target;\n target = null;\n }\n\n var suspendedActions = [],\n eventName, actions, action, i, l;\n\n for (i=0, l=eventNames.length; i<l; i++) {\n eventName = eventNames[i];\n actions = actionsFor(obj, eventName);\n var actionIndex = indexOf(actions, target, method);\n\n if (actionIndex !== -1) {\n action = actions[actionIndex].slice();\n action[3] = true;\n actions[actionIndex] = action;\n suspendedActions.push(action);\n }\n }\n\n function tryable() { return callback.call(target); }\n\n function finalizer() {\n for (i = 0, l = suspendedActions.length; i < l; i++) {\n suspendedActions[i][3] = undefined;\n }\n }\n\n return Ember.tryFinally(tryable, finalizer);\n}\n\n/**\n @private\n\n Return a list of currently watched events\n\n @method watchedEvents\n @for Ember\n @param obj\n*/\nfunction watchedEvents(obj) {\n var listeners = obj[META_KEY].listeners, ret = [];\n\n if (listeners) {\n for(var eventName in listeners) {\n if (listeners[eventName]) { ret.push(eventName); }\n }\n }\n return ret;\n}\n\n/**\n @method sendEvent\n @for Ember\n @param obj\n @param {String} eventName\n @param {Array} params\n @return true\n*/\nfunction sendEvent(obj, eventName, params, actions) {\n // first give object a chance to handle it\n if (obj !== Ember && 'function' === typeof obj.sendEvent) {\n obj.sendEvent(eventName, params);\n }\n\n if (!actions) {\n var meta = obj[META_KEY];\n actions = meta && meta.listeners && meta.listeners[eventName];\n }\n\n if (!actions) { return; }\n\n for (var i = actions.length - 1; i >= 0; i--) { // looping in reverse for once listeners\n if (!actions[i] || actions[i][3] === true) { continue; }\n\n var target = actions[i][0],\n method = actions[i][1],\n once = actions[i][2];\n\n if (once) { removeListener(obj, eventName, target, method); }\n if (!target) { target = obj; }\n if ('string' === typeof method) { method = target[method]; }\n if (params) {\n method.apply(target, params);\n } else {\n method.apply(target);\n }\n }\n return true;\n}\n\n/**\n @private\n @method hasListeners\n @for Ember\n @param obj\n @param {String} eventName\n*/\nfunction hasListeners(obj, eventName) {\n var meta = obj[META_KEY],\n actions = meta && meta.listeners && meta.listeners[eventName];\n\n return !!(actions && actions.length);\n}\n\n/**\n @private\n @method listenersFor\n @for Ember\n @param obj\n @param {String} eventName\n*/\nfunction listenersFor(obj, eventName) {\n var ret = [];\n var meta = obj[META_KEY],\n actions = meta && meta.listeners && meta.listeners[eventName];\n\n if (!actions) { return ret; }\n\n for (var i = 0, l = actions.length; i < l; i++) {\n var target = actions[i][0],\n method = actions[i][1];\n ret.push([target, method]);\n }\n\n return ret;\n}\n\nEmber.addListener = addListener;\nEmber.removeListener = removeListener;\nEmber._suspendListener = suspendListener;\nEmber._suspendListeners = suspendListeners;\nEmber.sendEvent = sendEvent;\nEmber.hasListeners = hasListeners;\nEmber.watchedEvents = watchedEvents;\nEmber.listenersFor = listenersFor;\nEmber.listenersDiff = actionsDiff;\nEmber.listenersUnion = actionsUnion;\n\n})();\n\n\n\n(function() {\n// Ember.Logger\n// Ember.watch.flushPending\n// Ember.beginPropertyChanges, Ember.endPropertyChanges\n// Ember.guidFor, Ember.tryFinally\n\n/**\n@module ember-metal\n*/\n\n// ..........................................................\n// HELPERS\n//\n\nvar slice = [].slice,\n forEach = Ember.ArrayPolyfills.forEach;\n\n// invokes passed params - normalizing so you can pass target/func,\n// target/string or just func\nfunction invoke(target, method, args, ignore) {\n\n if (method === undefined) {\n method = target;\n target = undefined;\n }\n\n if ('string' === typeof method) { method = target[method]; }\n if (args && ignore > 0) {\n args = args.length > ignore ? slice.call(args, ignore) : null;\n }\n\n return Ember.handleErrors(function() {\n // IE8's Function.prototype.apply doesn't accept undefined/null arguments.\n return method.apply(target || this, args || []);\n }, this);\n}\n\n\n// ..........................................................\n// RUNLOOP\n//\n\nvar timerMark; // used by timers...\n\n/**\nEmber RunLoop (Private)\n\n@class RunLoop\n@namespace Ember\n@private\n@constructor\n*/\nvar RunLoop = function(prev) {\n this._prev = prev || null;\n this.onceTimers = {};\n};\n\nRunLoop.prototype = {\n /**\n @method end\n */\n end: function() {\n this.flush();\n },\n\n /**\n @method prev\n */\n prev: function() {\n return this._prev;\n },\n\n // ..........................................................\n // Delayed Actions\n //\n\n /**\n @method schedule\n @param {String} queueName\n @param target\n @param method\n */\n schedule: function(queueName, target, method) {\n var queues = this._queues, queue;\n if (!queues) { queues = this._queues = {}; }\n queue = queues[queueName];\n if (!queue) { queue = queues[queueName] = []; }\n\n var args = arguments.length > 3 ? slice.call(arguments, 3) : null;\n queue.push({ target: target, method: method, args: args });\n return this;\n },\n\n /**\n @method flush\n @param {String} queueName\n */\n flush: function(queueName) {\n var queueNames, idx, len, queue, log;\n\n if (!this._queues) { return this; } // nothing to do\n\n function iter(item) {\n invoke(item.target, item.method, item.args);\n }\n\n function tryable() {\n forEach.call(queue, iter);\n }\n\n Ember.watch.flushPending(); // make sure all chained watchers are setup\n\n if (queueName) {\n while (this._queues && (queue = this._queues[queueName])) {\n this._queues[queueName] = null;\n\n // the sync phase is to allow property changes to propagate. don't\n // invoke observers until that is finished.\n if (queueName === 'sync') {\n log = Ember.LOG_BINDINGS;\n if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); }\n\n Ember.beginPropertyChanges();\n\n Ember.tryFinally(tryable, Ember.endPropertyChanges);\n\n if (log) { Ember.Logger.log('End: Flush Sync Queue'); }\n\n } else {\n forEach.call(queue, iter);\n }\n }\n\n } else {\n queueNames = Ember.run.queues;\n len = queueNames.length;\n idx = 0;\n\n outerloop:\n while (idx < len) {\n queueName = queueNames[idx];\n queue = this._queues && this._queues[queueName];\n delete this._queues[queueName];\n\n if (queue) {\n // the sync phase is to allow property changes to propagate. don't\n // invoke observers until that is finished.\n if (queueName === 'sync') {\n log = Ember.LOG_BINDINGS;\n if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); }\n\n Ember.beginPropertyChanges();\n\n Ember.tryFinally(tryable, Ember.endPropertyChanges);\n\n if (log) { Ember.Logger.log('End: Flush Sync Queue'); }\n } else {\n forEach.call(queue, iter);\n }\n }\n\n // Loop through prior queues\n for (var i = 0; i <= idx; i++) {\n if (this._queues && this._queues[queueNames[i]]) {\n // Start over at the first queue with contents\n idx = i;\n continue outerloop;\n }\n }\n\n idx++;\n }\n }\n\n timerMark = null;\n\n return this;\n }\n\n};\n\nEmber.RunLoop = RunLoop;\n\n// ..........................................................\n// Ember.run - this is ideally the only public API the dev sees\n//\n\n/**\n Runs the passed target and method inside of a RunLoop, ensuring any\n deferred actions including bindings and views updates are flushed at the\n end.\n\n Normally you should not need to invoke this method yourself. However if\n you are implementing raw event handlers when interfacing with other\n libraries or plugins, you should probably wrap all of your code inside this\n call.\n\n ```javascript\n Ember.run(function(){\n // code to be execute within a RunLoop \n });\n ```\n\n @class run\n @namespace Ember\n @static\n @constructor\n @param {Object} [target] target of method to call\n @param {Function|String} method Method to invoke.\n May be a function or a string. If you pass a string\n then it will be looked up on the passed target.\n @param {Object} [args*] Any additional arguments you wish to pass to the method.\n @return {Object} return value from invoking the passed function.\n*/\nEmber.run = function(target, method) {\n var loop,\n args = arguments;\n run.begin();\n\n function tryable() {\n if (target || method) {\n return invoke(target, method, args, 2);\n }\n }\n\n return Ember.tryFinally(tryable, run.end);\n};\n\nvar run = Ember.run;\n\n\n/**\n Begins a new RunLoop. Any deferred actions invoked after the begin will\n be buffered until you invoke a matching call to `Ember.run.end()`. This is\n an lower-level way to use a RunLoop instead of using `Ember.run()`.\n\n ```javascript\n Ember.run.begin();\n // code to be execute within a RunLoop \n Ember.run.end();\n ```\n\n @method begin\n @return {void}\n*/\nEmber.run.begin = function() {\n run.currentRunLoop = new RunLoop(run.currentRunLoop);\n};\n\n/**\n Ends a RunLoop. This must be called sometime after you call\n `Ember.run.begin()` to flush any deferred actions. This is a lower-level way\n to use a RunLoop instead of using `Ember.run()`.\n\n ```javascript\n Ember.run.begin();\n // code to be execute within a RunLoop \n Ember.run.end();\n ```\n\n @method end\n @return {void}\n*/\nEmber.run.end = function() {\n Ember.assert('must have a current run loop', run.currentRunLoop);\n\n function tryable() { run.currentRunLoop.end(); }\n function finalizer() { run.currentRunLoop = run.currentRunLoop.prev(); }\n\n Ember.tryFinally(tryable, finalizer);\n};\n\n/**\n Array of named queues. This array determines the order in which queues\n are flushed at the end of the RunLoop. You can define your own queues by\n simply adding the queue name to this array. Normally you should not need\n to inspect or modify this property.\n\n @property queues\n @type Array\n @default ['sync', 'actions', 'destroy', 'timers']\n*/\nEmber.run.queues = ['sync', 'actions', 'destroy', 'timers'];\n\n/**\n Adds the passed target/method and any optional arguments to the named\n queue to be executed at the end of the RunLoop. If you have not already\n started a RunLoop when calling this method one will be started for you\n automatically.\n\n At the end of a RunLoop, any methods scheduled in this way will be invoked.\n Methods will be invoked in an order matching the named queues defined in\n the `run.queues` property.\n\n ```javascript\n Ember.run.schedule('timers', this, function(){\n // this will be executed at the end of the RunLoop, when timers are run\n console.log(\"scheduled on timers queue\");\n });\n\n Ember.run.schedule('sync', this, function(){\n // this will be executed at the end of the RunLoop, when bindings are synced\n console.log(\"scheduled on sync queue\");\n });\n\n // Note the functions will be run in order based on the run queues order. Output would be:\n // scheduled on sync queue\n // scheduled on timers queue\n ```\n\n @method schedule\n @param {String} queue The name of the queue to schedule against.\n Default queues are 'sync' and 'actions'\n @param {Object} [target] target object to use as the context when invoking a method.\n @param {String|Function} method The method to invoke. If you pass a string it\n will be resolved on the target object at the time the scheduled item is\n invoked allowing you to change the target function.\n @param {Object} [arguments*] Optional arguments to be passed to the queued method.\n @return {void}\n*/\nEmber.run.schedule = function(queue, target, method) {\n var loop = run.autorun();\n loop.schedule.apply(loop, arguments);\n};\n\nvar scheduledAutorun;\nfunction autorun() {\n scheduledAutorun = null;\n if (run.currentRunLoop) { run.end(); }\n}\n\n// Used by global test teardown\nEmber.run.hasScheduledTimers = function() {\n return !!(scheduledAutorun || scheduledLater || scheduledNext);\n};\n\n// Used by global test teardown\nEmber.run.cancelTimers = function () {\n if (scheduledAutorun) {\n clearTimeout(scheduledAutorun);\n scheduledAutorun = null;\n }\n if (scheduledLater) {\n clearTimeout(scheduledLater);\n scheduledLater = null;\n }\n if (scheduledNext) {\n clearTimeout(scheduledNext);\n scheduledNext = null;\n }\n timers = {};\n};\n\n/**\n Begins a new RunLoop if necessary and schedules a timer to flush the\n RunLoop at a later time. This method is used by parts of Ember to\n ensure the RunLoop always finishes. You normally do not need to call this\n method directly. Instead use `Ember.run()`\n\n @method autorun\n @example\n Ember.run.autorun();\n @return {Ember.RunLoop} the new current RunLoop\n*/\nEmber.run.autorun = function() {\n if (!run.currentRunLoop) {\n Ember.assert(\"You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run\", !Ember.testing);\n\n run.begin();\n\n if (!scheduledAutorun) {\n scheduledAutorun = setTimeout(autorun, 1);\n }\n }\n\n return run.currentRunLoop;\n};\n\n/**\n Immediately flushes any events scheduled in the 'sync' queue. Bindings\n use this queue so this method is a useful way to immediately force all\n bindings in the application to sync.\n\n You should call this method anytime you need any changed state to propagate\n throughout the app immediately without repainting the UI.\n\n ```javascript\n Ember.run.sync();\n ```\n\n @method sync\n @return {void}\n*/\nEmber.run.sync = function() {\n run.autorun();\n run.currentRunLoop.flush('sync');\n};\n\n// ..........................................................\n// TIMERS\n//\n\nvar timers = {}; // active timers...\n\nvar scheduledLater;\nfunction invokeLaterTimers() {\n scheduledLater = null;\n var now = (+ new Date()), earliest = -1;\n for (var key in timers) {\n if (!timers.hasOwnProperty(key)) { continue; }\n var timer = timers[key];\n if (timer && timer.expires) {\n if (now >= timer.expires) {\n delete timers[key];\n invoke(timer.target, timer.method, timer.args, 2);\n } else {\n if (earliest<0 || (timer.expires < earliest)) earliest=timer.expires;\n }\n }\n }\n\n // schedule next timeout to fire...\n if (earliest > 0) { scheduledLater = setTimeout(invokeLaterTimers, earliest-(+ new Date())); }\n}\n\n/**\n Invokes the passed target/method and optional arguments after a specified\n period if time. The last parameter of this method must always be a number\n of milliseconds.\n\n You should use this method whenever you need to run some action after a\n period of time instead of using `setTimeout()`. This method will ensure that\n items that expire during the same script execution cycle all execute\n together, which is often more efficient than using a real setTimeout.\n\n ```javascript\n Ember.run.later(myContext, function(){\n // code here will execute within a RunLoop in about 500ms with this == myContext\n }, 500);\n ```\n\n @method later\n @param {Object} [target] target of method to invoke\n @param {Function|String} method The method to invoke.\n If you pass a string it will be resolved on the\n target at the time the method is invoked.\n @param {Object} [args*] Optional arguments to pass to the timeout.\n @param {Number} wait\n Number of milliseconds to wait.\n @return {String} a string you can use to cancel the timer in\n {{#crossLink \"Ember/run.cancel\"}}{{/crossLink}} later.\n*/\nEmber.run.later = function(target, method) {\n var args, expires, timer, guid, wait;\n\n // setTimeout compatibility...\n if (arguments.length===2 && 'function' === typeof target) {\n wait = method;\n method = target;\n target = undefined;\n args = [target, method];\n } else {\n args = slice.call(arguments);\n wait = args.pop();\n }\n\n expires = (+ new Date()) + wait;\n timer = { target: target, method: method, expires: expires, args: args };\n guid = Ember.guidFor(timer);\n timers[guid] = timer;\n run.once(timers, invokeLaterTimers);\n return guid;\n};\n\nfunction invokeOnceTimer(guid, onceTimers) {\n if (onceTimers[this.tguid]) { delete onceTimers[this.tguid][this.mguid]; }\n if (timers[guid]) { invoke(this.target, this.method, this.args); }\n delete timers[guid];\n}\n\nfunction scheduleOnce(queue, target, method, args) {\n var tguid = Ember.guidFor(target),\n mguid = Ember.guidFor(method),\n onceTimers = run.autorun().onceTimers,\n guid = onceTimers[tguid] && onceTimers[tguid][mguid],\n timer;\n\n if (guid && timers[guid]) {\n timers[guid].args = args; // replace args\n } else {\n timer = {\n target: target,\n method: method,\n args: args,\n tguid: tguid,\n mguid: mguid\n };\n\n guid = Ember.guidFor(timer);\n timers[guid] = timer;\n if (!onceTimers[tguid]) { onceTimers[tguid] = {}; }\n onceTimers[tguid][mguid] = guid; // so it isn't scheduled more than once\n\n run.schedule(queue, timer, invokeOnceTimer, guid, onceTimers);\n }\n\n return guid;\n}\n\n/**\n Schedules an item to run one time during the current RunLoop. Calling\n this method with the same target/method combination will have no effect.\n\n Note that although you can pass optional arguments these will not be\n considered when looking for duplicates. New arguments will replace previous\n calls.\n\n ```javascript\n Ember.run(function(){\n var doFoo = function() { foo(); }\n Ember.run.once(myContext, doFoo);\n Ember.run.once(myContext, doFoo);\n // doFoo will only be executed once at the end of the RunLoop\n });\n ```\n\n @method once\n @param {Object} [target] target of method to invoke\n @param {Function|String} method The method to invoke.\n If you pass a string it will be resolved on the\n target at the time the method is invoked.\n @param {Object} [args*] Optional arguments to pass to the timeout.\n @return {Object} timer\n*/\nEmber.run.once = function(target, method) {\n return scheduleOnce('actions', target, method, slice.call(arguments, 2));\n};\n\nEmber.run.scheduleOnce = function(queue, target, method, args) {\n return scheduleOnce(queue, target, method, slice.call(arguments, 3));\n};\n\nvar scheduledNext;\nfunction invokeNextTimers() {\n scheduledNext = null;\n for(var key in timers) {\n if (!timers.hasOwnProperty(key)) { continue; }\n var timer = timers[key];\n if (timer.next) {\n delete timers[key];\n invoke(timer.target, timer.method, timer.args, 2);\n }\n }\n}\n\n/**\n Schedules an item to run after control has been returned to the system.\n This is often equivalent to calling `setTimeout(function() {}, 1)`.\n\n ```javascript\n Ember.run.next(myContext, function(){\n // code to be executed in the next RunLoop, which will be scheduled after the current one\n });\n ```\n\n @method next\n @param {Object} [target] target of method to invoke\n @param {Function|String} method The method to invoke.\n If you pass a string it will be resolved on the\n target at the time the method is invoked.\n @param {Object} [args*] Optional arguments to pass to the timeout.\n @return {Object} timer\n*/\nEmber.run.next = function(target, method) {\n var guid,\n timer = {\n target: target,\n method: method,\n args: slice.call(arguments),\n next: true\n };\n\n guid = Ember.guidFor(timer);\n timers[guid] = timer;\n\n if (!scheduledNext) { scheduledNext = setTimeout(invokeNextTimers, 1); }\n return guid;\n};\n\n/**\n Cancels a scheduled item. Must be a value returned by `Ember.run.later()`,\n `Ember.run.once()`, or `Ember.run.next()`.\n\n ```javascript\n var runNext = Ember.run.next(myContext, function(){\n // will not be executed\n });\n Ember.run.cancel(runNext);\n\n var runLater = Ember.run.later(myContext, function(){\n // will not be executed\n }, 500);\n Ember.run.cancel(runLater);\n\n var runOnce = Ember.run.once(myContext, function(){\n // will not be executed\n });\n Ember.run.cancel(runOnce);\n ```\n\n @method cancel\n @param {Object} timer Timer object to cancel\n @return {void}\n*/\nEmber.run.cancel = function(timer) {\n delete timers[timer];\n};\n\n})();\n\n\n\n(function() {\n// Ember.Logger\n// get, set, trySet\n// guidFor, isArray, meta\n// addObserver, removeObserver\n// Ember.run.schedule\n/**\n@module ember-metal\n*/\n\n// ..........................................................\n// CONSTANTS\n//\n\n/**\n Debug parameter you can turn on. This will log all bindings that fire to\n the console. This should be disabled in production code. Note that you\n can also enable this from the console or temporarily.\n\n @property LOG_BINDINGS\n @for Ember\n @type Boolean\n @default false\n*/\nEmber.LOG_BINDINGS = false || !!Ember.ENV.LOG_BINDINGS;\n\nvar get = Ember.get,\n set = Ember.set,\n guidFor = Ember.guidFor,\n isGlobalPath = Ember.isGlobalPath;\n\n\nfunction getWithGlobals(obj, path) {\n return get(isGlobalPath(path) ? Ember.lookup : obj, path);\n}\n\n// ..........................................................\n// BINDING\n//\n\nvar Binding = function(toPath, fromPath) {\n this._direction = 'fwd';\n this._from = fromPath;\n this._to = toPath;\n this._directionMap = Ember.Map.create();\n};\n\n/**\n@class Binding\n@namespace Ember\n*/\n\nBinding.prototype = {\n /**\n This copies the Binding so it can be connected to another object.\n\n @method copy\n @return {Ember.Binding}\n */\n copy: function () {\n var copy = new Binding(this._to, this._from);\n if (this._oneWay) { copy._oneWay = true; }\n return copy;\n },\n\n // ..........................................................\n // CONFIG\n //\n\n /**\n This will set `from` property path to the specified value. It will not\n attempt to resolve this property path to an actual object until you\n connect the binding.\n\n The binding will search for the property path starting at the root object\n you pass when you `connect()` the binding. It follows the same rules as\n `get()` - see that method for more information.\n\n @method from\n @param {String} propertyPath the property path to connect to\n @return {Ember.Binding} `this`\n */\n from: function(path) {\n this._from = path;\n return this;\n },\n\n /**\n This will set the `to` property path to the specified value. It will not\n attempt to resolve this property path to an actual object until you\n connect the binding.\n\n The binding will search for the property path starting at the root object\n you pass when you `connect()` the binding. It follows the same rules as\n `get()` - see that method for more information.\n\n @method to\n @param {String|Tuple} propertyPath A property path or tuple\n @return {Ember.Binding} `this`\n */\n to: function(path) {\n this._to = path;\n return this;\n },\n\n /**\n Configures the binding as one way. A one-way binding will relay changes\n on the `from` side to the `to` side, but not the other way around. This\n means that if you change the `to` side directly, the `from` side may have\n a different value.\n\n @method oneWay\n @return {Ember.Binding} `this`\n */\n oneWay: function() {\n this._oneWay = true;\n return this;\n },\n\n toString: function() {\n var oneWay = this._oneWay ? '[oneWay]' : '';\n return \"Ember.Binding<\" + guidFor(this) + \">(\" + this._from + \" -> \" + this._to + \")\" + oneWay;\n },\n\n // ..........................................................\n // CONNECT AND SYNC\n //\n\n /**\n Attempts to connect this binding instance so that it can receive and relay\n changes. This method will raise an exception if you have not set the\n from/to properties yet.\n\n @method connect\n @param {Object} obj The root object for this binding.\n @return {Ember.Binding} `this`\n */\n connect: function(obj) {\n Ember.assert('Must pass a valid object to Ember.Binding.connect()', !!obj);\n\n var fromPath = this._from, toPath = this._to;\n Ember.trySet(obj, toPath, getWithGlobals(obj, fromPath));\n\n // add an observer on the object to be notified when the binding should be updated\n Ember.addObserver(obj, fromPath, this, this.fromDidChange);\n\n // if the binding is a two-way binding, also set up an observer on the target\n if (!this._oneWay) { Ember.addObserver(obj, toPath, this, this.toDidChange); }\n\n this._readyToSync = true;\n\n return this;\n },\n\n /**\n Disconnects the binding instance. Changes will no longer be relayed. You\n will not usually need to call this method.\n\n @method disconnect\n @param {Object} obj The root object you passed when connecting the binding.\n @return {Ember.Binding} `this`\n */\n disconnect: function(obj) {\n Ember.assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj);\n\n var twoWay = !this._oneWay;\n\n // remove an observer on the object so we're no longer notified of\n // changes that should update bindings.\n Ember.removeObserver(obj, this._from, this, this.fromDidChange);\n\n // if the binding is two-way, remove the observer from the target as well\n if (twoWay) { Ember.removeObserver(obj, this._to, this, this.toDidChange); }\n\n this._readyToSync = false; // disable scheduled syncs...\n return this;\n },\n\n // ..........................................................\n // PRIVATE\n //\n\n /* called when the from side changes */\n fromDidChange: function(target) {\n this._scheduleSync(target, 'fwd');\n },\n\n /* called when the to side changes */\n toDidChange: function(target) {\n this._scheduleSync(target, 'back');\n },\n\n _scheduleSync: function(obj, dir) {\n var directionMap = this._directionMap;\n var existingDir = directionMap.get(obj);\n\n // if we haven't scheduled the binding yet, schedule it\n if (!existingDir) {\n Ember.run.schedule('sync', this, this._sync, obj);\n directionMap.set(obj, dir);\n }\n\n // If both a 'back' and 'fwd' sync have been scheduled on the same object,\n // default to a 'fwd' sync so that it remains deterministic.\n if (existingDir === 'back' && dir === 'fwd') {\n directionMap.set(obj, 'fwd');\n }\n },\n\n _sync: function(obj) {\n var log = Ember.LOG_BINDINGS;\n\n // don't synchronize destroyed objects or disconnected bindings\n if (obj.isDestroyed || !this._readyToSync) { return; }\n\n // get the direction of the binding for the object we are\n // synchronizing from\n var directionMap = this._directionMap;\n var direction = directionMap.get(obj);\n\n var fromPath = this._from, toPath = this._to;\n\n directionMap.remove(obj);\n\n // if we're synchronizing from the remote object...\n if (direction === 'fwd') {\n var fromValue = getWithGlobals(obj, this._from);\n if (log) {\n Ember.Logger.log(' ', this.toString(), '->', fromValue, obj);\n }\n if (this._oneWay) {\n Ember.trySet(obj, toPath, fromValue);\n } else {\n Ember._suspendObserver(obj, toPath, this, this.toDidChange, function () {\n Ember.trySet(obj, toPath, fromValue);\n });\n }\n // if we're synchronizing *to* the remote object\n } else if (direction === 'back') {\n var toValue = get(obj, this._to);\n if (log) {\n Ember.Logger.log(' ', this.toString(), '<-', toValue, obj);\n }\n Ember._suspendObserver(obj, fromPath, this, this.fromDidChange, function () {\n Ember.trySet(Ember.isGlobalPath(fromPath) ? Ember.lookup : obj, fromPath, toValue);\n });\n }\n }\n\n};\n\nfunction mixinProperties(to, from) {\n for (var key in from) {\n if (from.hasOwnProperty(key)) {\n to[key] = from[key];\n }\n }\n}\n\nmixinProperties(Binding, {\n\n /**\n See {{#crossLink \"Ember.Binding/from\"}}{{/crossLink}}\n\n @method from\n @static\n */\n from: function() {\n var C = this, binding = new C();\n return binding.from.apply(binding, arguments);\n },\n\n /**\n See {{#crossLink \"Ember.Binding/to\"}}{{/crossLink}}\n\n @method to\n @static\n */\n to: function() {\n var C = this, binding = new C();\n return binding.to.apply(binding, arguments);\n },\n\n /**\n Creates a new Binding instance and makes it apply in a single direction.\n A one-way binding will relay changes on the `from` side object (supplied\n as the `from` argument) the `to` side, but not the other way around.\n This means that if you change the \"to\" side directly, the \"from\" side may have\n a different value.\n\n See {{#crossLink \"Binding/oneWay\"}}{{/crossLink}}\n\n @method oneWay\n @param {String} from from path.\n @param {Boolean} [flag] (Optional) passing nothing here will make the\n binding `oneWay`. You can instead pass `false` to disable `oneWay`, making the\n binding two way again.\n */\n oneWay: function(from, flag) {\n var C = this, binding = new C(null, from);\n return binding.oneWay(flag);\n }\n\n});\n\n/**\n An `Ember.Binding` connects the properties of two objects so that whenever\n the value of one property changes, the other property will be changed also.\n\n ## Automatic Creation of Bindings with `/^*Binding/`-named Properties\n\n You do not usually create Binding objects directly but instead describe\n bindings in your class or object definition using automatic binding\n detection.\n\n Properties ending in a `Binding` suffix will be converted to `Ember.Binding`\n instances. The value of this property should be a string representing a path\n to another object or a custom binding instanced created using Binding helpers\n (see \"Customizing Your Bindings\"):\n\n ```\n valueBinding: \"MyApp.someController.title\"\n ```\n\n This will create a binding from `MyApp.someController.title` to the `value`\n property of your object instance automatically. Now the two values will be\n kept in sync.\n\n ## One Way Bindings\n\n One especially useful binding customization you can use is the `oneWay()`\n helper. This helper tells Ember that you are only interested in\n receiving changes on the object you are binding from. For example, if you\n are binding to a preference and you want to be notified if the preference\n has changed, but your object will not be changing the preference itself, you\n could do:\n\n ```\n bigTitlesBinding: Ember.Binding.oneWay(\"MyApp.preferencesController.bigTitles\")\n ```\n\n This way if the value of `MyApp.preferencesController.bigTitles` changes the\n `bigTitles` property of your object will change also. However, if you\n change the value of your `bigTitles` property, it will not update the\n `preferencesController`.\n\n One way bindings are almost twice as fast to setup and twice as fast to\n execute because the binding only has to worry about changes to one side.\n\n You should consider using one way bindings anytime you have an object that\n may be created frequently and you do not intend to change a property; only\n to monitor it for changes. (such as in the example above).\n\n ## Adding Bindings Manually\n\n All of the examples above show you how to configure a custom binding, but the\n result of these customizations will be a binding template, not a fully active\n Binding instance. The binding will actually become active only when you\n instantiate the object the binding belongs to. It is useful however, to\n understand what actually happens when the binding is activated.\n\n For a binding to function it must have at least a `from` property and a `to`\n property. The `from` property path points to the object/key that you want to\n bind from while the `to` path points to the object/key you want to bind to.\n\n When you define a custom binding, you are usually describing the property\n you want to bind from (such as `MyApp.someController.value` in the examples\n above). When your object is created, it will automatically assign the value\n you want to bind `to` based on the name of your binding key. In the\n examples above, during init, Ember objects will effectively call\n something like this on your binding:\n\n ```javascript\n binding = Ember.Binding.from(this.valueBinding).to(\"value\");\n ```\n\n This creates a new binding instance based on the template you provide, and\n sets the to path to the `value` property of the new object. Now that the\n binding is fully configured with a `from` and a `to`, it simply needs to be\n connected to become active. This is done through the `connect()` method:\n\n ```javascript\n binding.connect(this);\n ```\n\n Note that when you connect a binding you pass the object you want it to be\n connected to. This object will be used as the root for both the from and\n to side of the binding when inspecting relative paths. This allows the\n binding to be automatically inherited by subclassed objects as well.\n\n Now that the binding is connected, it will observe both the from and to side\n and relay changes.\n\n If you ever needed to do so (you almost never will, but it is useful to\n understand this anyway), you could manually create an active binding by\n using the `Ember.bind()` helper method. (This is the same method used by\n to setup your bindings on objects):\n\n ```javascript\n Ember.bind(MyApp.anotherObject, \"value\", \"MyApp.someController.value\");\n ```\n\n Both of these code fragments have the same effect as doing the most friendly\n form of binding creation like so:\n\n ```javascript\n MyApp.anotherObject = Ember.Object.create({\n valueBinding: \"MyApp.someController.value\",\n\n // OTHER CODE FOR THIS OBJECT...\n });\n ```\n\n Ember's built in binding creation method makes it easy to automatically\n create bindings for you. You should always use the highest-level APIs\n available, even if you understand how it works underneath.\n\n @class Binding\n @namespace Ember\n @since Ember 0.9\n*/\nEmber.Binding = Binding;\n\n\n/**\n Global helper method to create a new binding. Just pass the root object\n along with a `to` and `from` path to create and connect the binding.\n\n @method bind\n @for Ember\n @param {Object} obj The root object of the transform.\n @param {String} to The path to the 'to' side of the binding.\n Must be relative to obj.\n @param {String} from The path to the 'from' side of the binding.\n Must be relative to obj or a global path.\n @return {Ember.Binding} binding instance\n*/\nEmber.bind = function(obj, to, from) {\n return new Ember.Binding(to, from).connect(obj);\n};\n\n/**\n @method oneWay\n @for Ember\n @param {Object} obj The root object of the transform.\n @param {String} to The path to the 'to' side of the binding.\n Must be relative to obj.\n @param {String} from The path to the 'from' side of the binding.\n Must be relative to obj or a global path.\n @return {Ember.Binding} binding instance\n*/\nEmber.oneWay = function(obj, to, from) {\n return new Ember.Binding(to, from).oneWay().connect(obj);\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember-metal\n*/\n\nvar Mixin, REQUIRED, Alias,\n classToString, superClassString,\n a_map = Ember.ArrayPolyfills.map,\n a_indexOf = Ember.ArrayPolyfills.indexOf,\n a_forEach = Ember.ArrayPolyfills.forEach,\n a_slice = [].slice,\n EMPTY_META = {}, // dummy for non-writable meta\n o_create = Ember.create,\n defineProperty = Ember.defineProperty,\n guidFor = Ember.guidFor;\n\nfunction mixinsMeta(obj) {\n var m = Ember.meta(obj, true), ret = m.mixins;\n if (!ret) {\n ret = m.mixins = {};\n } else if (!m.hasOwnProperty('mixins')) {\n ret = m.mixins = o_create(ret);\n }\n return ret;\n}\n\nfunction initMixin(mixin, args) {\n if (args && args.length > 0) {\n mixin.mixins = a_map.call(args, function(x) {\n if (x instanceof Mixin) { return x; }\n\n // Note: Manually setup a primitive mixin here. This is the only\n // way to actually get a primitive mixin. This way normal creation\n // of mixins will give you combined mixins...\n var mixin = new Mixin();\n mixin.properties = x;\n return mixin;\n });\n }\n return mixin;\n}\n\nfunction isMethod(obj) {\n return 'function' === typeof obj &&\n obj.isMethod !== false &&\n obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String;\n}\n\nvar CONTINUE = {};\n\nfunction mixinProperties(mixinsMeta, mixin) {\n var guid;\n\n if (mixin instanceof Mixin) {\n guid = guidFor(mixin);\n if (mixinsMeta[guid]) { return CONTINUE; }\n mixinsMeta[guid] = mixin;\n return mixin.properties;\n } else {\n return mixin; // apply anonymous mixin properties\n }\n}\n\nfunction concatenatedProperties(props, values, base) {\n var concats;\n\n // reset before adding each new mixin to pickup concats from previous\n concats = values.concatenatedProperties || base.concatenatedProperties;\n if (props.concatenatedProperties) {\n concats = concats ? concats.concat(props.concatenatedProperties) : props.concatenatedProperties;\n }\n\n return concats;\n}\n\nfunction giveDescriptorSuper(meta, key, property, values, descs) {\n var superProperty;\n\n // Computed properties override methods, and do not call super to them\n if (values[key] === undefined) {\n // Find the original descriptor in a parent mixin\n superProperty = descs[key];\n }\n\n // If we didn't find the original descriptor in a parent mixin, find\n // it on the original object.\n superProperty = superProperty || meta.descs[key];\n\n if (!superProperty || !(superProperty instanceof Ember.ComputedProperty)) {\n return property;\n }\n\n // Since multiple mixins may inherit from the same parent, we need\n // to clone the computed property so that other mixins do not receive\n // the wrapped version.\n property = o_create(property);\n property.func = Ember.wrap(property.func, superProperty.func);\n\n return property;\n}\n\nfunction giveMethodSuper(obj, key, method, values, descs) {\n var superMethod;\n\n // Methods overwrite computed properties, and do not call super to them.\n if (descs[key] === undefined) {\n // Find the original method in a parent mixin\n superMethod = values[key];\n }\n\n // If we didn't find the original value in a parent mixin, find it in\n // the original object\n superMethod = superMethod || obj[key];\n\n // Only wrap the new method if the original method was a function\n if ('function' !== typeof superMethod) {\n return method;\n }\n\n return Ember.wrap(method, superMethod);\n}\n\nfunction applyConcatenatedProperties(obj, key, value, values) {\n var baseValue = values[key] || obj[key];\n\n if (baseValue) {\n if ('function' === typeof baseValue.concat) {\n return baseValue.concat(value);\n } else {\n return Ember.makeArray(baseValue).concat(value);\n }\n } else {\n return Ember.makeArray(value);\n }\n}\n\nfunction addNormalizedProperty(base, key, value, meta, descs, values, concats) {\n if (value instanceof Ember.Descriptor) {\n if (value === REQUIRED && descs[key]) { return CONTINUE; }\n\n // Wrap descriptor function to implement\n // _super() if needed\n if (value.func) {\n value = giveDescriptorSuper(meta, key, value, values, descs);\n }\n\n descs[key] = value;\n values[key] = undefined;\n } else {\n // impl super if needed...\n if (isMethod(value)) {\n value = giveMethodSuper(base, key, value, values, descs);\n } else if ((concats && a_indexOf.call(concats, key) >= 0) || key === 'concatenatedProperties') {\n value = applyConcatenatedProperties(base, key, value, values);\n }\n\n descs[key] = undefined;\n values[key] = value;\n }\n}\n\nfunction mergeMixins(mixins, m, descs, values, base) {\n var mixin, props, key, concats, meta;\n\n function removeKeys(keyName) {\n delete descs[keyName];\n delete values[keyName];\n }\n\n for(var i=0, l=mixins.length; i<l; i++) {\n mixin = mixins[i];\n Ember.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(mixin), typeof mixin === 'object' && mixin !== null && Object.prototype.toString.call(mixin) !== '[object Array]');\n\n props = mixinProperties(m, mixin);\n if (props === CONTINUE) { continue; }\n\n if (props) {\n meta = Ember.meta(base);\n concats = concatenatedProperties(props, values, base);\n\n for (key in props) {\n if (!props.hasOwnProperty(key)) { continue; }\n addNormalizedProperty(base, key, props[key], meta, descs, values, concats);\n }\n\n // manually copy toString() because some JS engines do not enumerate it\n if (props.hasOwnProperty('toString')) { base.toString = props.toString; }\n } else if (mixin.mixins) {\n mergeMixins(mixin.mixins, m, descs, values, base);\n if (mixin._without) { a_forEach.call(mixin._without, removeKeys); }\n }\n }\n}\n\nfunction writableReq(obj) {\n var m = Ember.meta(obj), req = m.required;\n if (!req || !m.hasOwnProperty('required')) {\n req = m.required = req ? o_create(req) : {};\n }\n return req;\n}\n\nvar IS_BINDING = Ember.IS_BINDING = /^.+Binding$/;\n\nfunction detectBinding(obj, key, value, m) {\n if (IS_BINDING.test(key)) {\n var bindings = m.bindings;\n if (!bindings) {\n bindings = m.bindings = {};\n } else if (!m.hasOwnProperty('bindings')) {\n bindings = m.bindings = o_create(m.bindings);\n }\n bindings[key] = value;\n }\n}\n\nfunction connectBindings(obj, m) {\n // TODO Mixin.apply(instance) should disconnect binding if exists\n var bindings = m.bindings, key, binding, to;\n if (bindings) {\n for (key in bindings) {\n binding = bindings[key];\n if (binding) {\n to = key.slice(0, -7); // strip Binding off end\n if (binding instanceof Ember.Binding) {\n binding = binding.copy(); // copy prototypes' instance\n binding.to(to);\n } else { // binding is string path\n binding = new Ember.Binding(to, binding);\n }\n binding.connect(obj);\n obj[key] = binding;\n }\n }\n // mark as applied\n m.bindings = {};\n }\n}\n\nfunction finishPartial(obj, m) {\n connectBindings(obj, m || Ember.meta(obj));\n return obj;\n}\n\nfunction followAlias(obj, desc, m, descs, values) {\n var altKey = desc.methodName, value;\n if (descs[altKey] || values[altKey]) {\n value = values[altKey];\n desc = descs[altKey];\n } else if (m.descs[altKey]) {\n desc = m.descs[altKey];\n value = undefined;\n } else {\n desc = undefined;\n value = obj[altKey];\n }\n\n return { desc: desc, value: value };\n}\n\nfunction updateObservers(obj, key, observer, observerKey, method) {\n if ('function' !== typeof observer) { return; }\n\n var paths = observer[observerKey];\n\n if (paths) {\n for (var i=0, l=paths.length; i<l; i++) {\n Ember[method](obj, paths[i], null, key);\n }\n }\n}\n\nfunction replaceObservers(obj, key, observer) {\n var prevObserver = obj[key];\n\n updateObservers(obj, key, prevObserver, '__ember_observesBefore__', 'removeBeforeObserver');\n updateObservers(obj, key, prevObserver, '__ember_observes__', 'removeObserver');\n\n updateObservers(obj, key, observer, '__ember_observesBefore__', 'addBeforeObserver');\n updateObservers(obj, key, observer, '__ember_observes__', 'addObserver');\n}\n\nfunction applyMixin(obj, mixins, partial) {\n var descs = {}, values = {}, m = Ember.meta(obj),\n key, value, desc;\n\n // Go through all mixins and hashes passed in, and:\n //\n // * Handle concatenated properties\n // * Set up _super wrapping if necessary\n // * Set up computed property descriptors\n // * Copying `toString` in broken browsers\n mergeMixins(mixins, mixinsMeta(obj), descs, values, obj);\n\n for(key in values) {\n if (key === 'contructor' || !values.hasOwnProperty(key)) { continue; }\n\n desc = descs[key];\n value = values[key];\n\n if (desc === REQUIRED) { continue; }\n\n while (desc && desc instanceof Alias) {\n var followed = followAlias(obj, desc, m, descs, values);\n desc = followed.desc;\n value = followed.value;\n }\n\n if (desc === undefined && value === undefined) { continue; }\n\n replaceObservers(obj, key, value);\n detectBinding(obj, key, value, m);\n defineProperty(obj, key, desc, value, m);\n }\n\n if (!partial) { // don't apply to prototype\n finishPartial(obj, m);\n }\n\n return obj;\n}\n\n/**\n @method mixin\n @for Ember\n @param obj\n @param mixins*\n @return obj\n*/\nEmber.mixin = function(obj) {\n var args = a_slice.call(arguments, 1);\n applyMixin(obj, args, false);\n return obj;\n};\n\n/**\n The `Ember.Mixin` class allows you to create mixins, whose properties can be\n added to other classes. For instance,\n\n ```javascript\n App.Editable = Ember.Mixin.create({\n edit: function() {\n console.log('starting to edit');\n this.set('isEditing', true);\n },\n isEditing: false\n });\n\n // Mix mixins into classes by passing them as the first arguments to\n // .extend or .create.\n App.CommentView = Ember.View.extend(App.Editable, {\n template: Ember.Handlebars.compile('{{#if isEditing}}...{{else}}...{{/if}}')\n });\n\n commentView = App.CommentView.create();\n commentView.edit(); // outputs 'starting to edit'\n ```\n\n Note that Mixins are created with `Ember.Mixin.create`, not\n `Ember.Mixin.extend`.\n\n @class Mixin\n @namespace Ember\n*/\nEmber.Mixin = function() { return initMixin(this, arguments); };\n\nMixin = Ember.Mixin;\n\nMixin._apply = applyMixin;\n\nMixin.applyPartial = function(obj) {\n var args = a_slice.call(arguments, 1);\n return applyMixin(obj, args, true);\n};\n\nMixin.finishPartial = finishPartial;\n\n/**\n @method create\n @static\n @param arguments*\n*/\nMixin.create = function() {\n classToString.processed = false;\n var M = this;\n return initMixin(new M(), arguments);\n};\n\nvar MixinPrototype = Mixin.prototype;\n\n/**\n @method reopen\n @param arguments*\n*/\nMixinPrototype.reopen = function() {\n var mixin, tmp;\n\n if (this.properties) {\n mixin = Mixin.create();\n mixin.properties = this.properties;\n delete this.properties;\n this.mixins = [mixin];\n } else if (!this.mixins) {\n this.mixins = [];\n }\n\n var len = arguments.length, mixins = this.mixins, idx;\n\n for(idx=0; idx < len; idx++) {\n mixin = arguments[idx];\n Ember.assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(mixin), typeof mixin === 'object' && mixin !== null && Object.prototype.toString.call(mixin) !== '[object Array]');\n\n if (mixin instanceof Mixin) {\n mixins.push(mixin);\n } else {\n tmp = Mixin.create();\n tmp.properties = mixin;\n mixins.push(tmp);\n }\n }\n\n return this;\n};\n\n/**\n @method apply\n @param obj\n @return applied object\n*/\nMixinPrototype.apply = function(obj) {\n return applyMixin(obj, [this], false);\n};\n\nMixinPrototype.applyPartial = function(obj) {\n return applyMixin(obj, [this], true);\n};\n\nfunction _detect(curMixin, targetMixin, seen) {\n var guid = guidFor(curMixin);\n\n if (seen[guid]) { return false; }\n seen[guid] = true;\n\n if (curMixin === targetMixin) { return true; }\n var mixins = curMixin.mixins, loc = mixins ? mixins.length : 0;\n while (--loc >= 0) {\n if (_detect(mixins[loc], targetMixin, seen)) { return true; }\n }\n return false;\n}\n\n/**\n @method detect\n @param obj\n @return {Boolean}\n*/\nMixinPrototype.detect = function(obj) {\n if (!obj) { return false; }\n if (obj instanceof Mixin) { return _detect(obj, this, {}); }\n var mixins = Ember.meta(obj, false).mixins;\n if (mixins) {\n return !!mixins[guidFor(this)];\n }\n return false;\n};\n\nMixinPrototype.without = function() {\n var ret = new Mixin(this);\n ret._without = a_slice.call(arguments);\n return ret;\n};\n\nfunction _keys(ret, mixin, seen) {\n if (seen[guidFor(mixin)]) { return; }\n seen[guidFor(mixin)] = true;\n\n if (mixin.properties) {\n var props = mixin.properties;\n for (var key in props) {\n if (props.hasOwnProperty(key)) { ret[key] = true; }\n }\n } else if (mixin.mixins) {\n a_forEach.call(mixin.mixins, function(x) { _keys(ret, x, seen); });\n }\n}\n\nMixinPrototype.keys = function() {\n var keys = {}, seen = {}, ret = [];\n _keys(keys, this, seen);\n for(var key in keys) {\n if (keys.hasOwnProperty(key)) { ret.push(key); }\n }\n return ret;\n};\n\n/* make Mixins have nice displayNames */\n\nvar NAME_KEY = Ember.GUID_KEY+'_name';\nvar get = Ember.get;\n\nfunction processNames(paths, root, seen) {\n var idx = paths.length;\n for(var key in root) {\n if (!root.hasOwnProperty || !root.hasOwnProperty(key)) { continue; }\n var obj = root[key];\n paths[idx] = key;\n\n if (obj && obj.toString === classToString) {\n obj.toString = makeToString(paths.join('.'));\n obj[NAME_KEY] = paths.join('.');\n } else if (obj && obj.isNamespace) {\n if (seen[guidFor(obj)]) { continue; }\n seen[guidFor(obj)] = true;\n processNames(paths, obj, seen);\n }\n }\n paths.length = idx; // cut out last item\n}\n\nfunction findNamespaces() {\n var Namespace = Ember.Namespace, lookup = Ember.lookup, obj, isNamespace;\n\n if (Namespace.PROCESSED) { return; }\n\n for (var prop in lookup) {\n // These don't raise exceptions but can cause warnings\n if (prop === \"parent\" || prop === \"top\" || prop === \"frameElement\") { continue; }\n\n // get(window.globalStorage, 'isNamespace') would try to read the storage for domain isNamespace and cause exception in Firefox.\n // globalStorage is a storage obsoleted by the WhatWG storage specification. See https://developer.mozilla.org/en/DOM/Storage#globalStorage\n if (prop === \"globalStorage\" && lookup.StorageList && lookup.globalStorage instanceof lookup.StorageList) { continue; }\n // Unfortunately, some versions of IE don't support window.hasOwnProperty\n if (lookup.hasOwnProperty && !lookup.hasOwnProperty(prop)) { continue; }\n\n // At times we are not allowed to access certain properties for security reasons.\n // There are also times where even if we can access them, we are not allowed to access their properties.\n try {\n obj = Ember.lookup[prop];\n isNamespace = obj && obj.isNamespace;\n } catch (e) {\n continue;\n }\n\n if (isNamespace) {\n Ember.deprecate(\"Namespaces should not begin with lowercase.\", /^[A-Z]/.test(prop));\n obj[NAME_KEY] = prop;\n }\n }\n}\n\n/**\n @private\n @method identifyNamespaces\n @for Ember\n*/\nEmber.identifyNamespaces = findNamespaces;\n\nsuperClassString = function(mixin) {\n var superclass = mixin.superclass;\n if (superclass) {\n if (superclass[NAME_KEY]) { return superclass[NAME_KEY]; }\n else { return superClassString(superclass); }\n } else {\n return;\n }\n};\n\nclassToString = function() {\n var Namespace = Ember.Namespace, namespace;\n\n // TODO: Namespace should really be in Metal\n if (Namespace && !Ember.BOOTED) {\n if (!this[NAME_KEY] && !classToString.processed) {\n if (!Namespace.PROCESSED) {\n findNamespaces();\n Namespace.PROCESSED = true;\n }\n\n classToString.processed = true;\n\n var namespaces = Namespace.NAMESPACES;\n for (var i=0, l=namespaces.length; i<l; i++) {\n namespace = namespaces[i];\n processNames([namespace.toString()], namespace, {});\n }\n }\n }\n\n var ret;\n\n if (this[NAME_KEY]) {\n ret = this[NAME_KEY];\n } else {\n var str = superClassString(this);\n if (str) {\n ret = \"(subclass of \" + str + \")\";\n } else {\n ret = \"(unknown mixin)\";\n }\n this.toString = makeToString(ret);\n }\n\n return ret;\n};\n\nfunction makeToString(ret) {\n return function() { return ret; };\n}\n\nMixinPrototype.toString = classToString;\n\n// returns the mixins currently applied to the specified object\n// TODO: Make Ember.mixin\nMixin.mixins = function(obj) {\n var mixins = Ember.meta(obj, false).mixins, ret = [];\n\n if (!mixins) { return ret; }\n\n for (var key in mixins) {\n var mixin = mixins[key];\n\n // skip primitive mixins since these are always anonymous\n if (!mixin.properties) { ret.push(mixin); }\n }\n\n return ret;\n};\n\nREQUIRED = new Ember.Descriptor();\nREQUIRED.toString = function() { return '(Required Property)'; };\n\n/**\n Denotes a required property for a mixin\n\n @method required\n @for Ember\n*/\nEmber.required = function() {\n return REQUIRED;\n};\n\nAlias = function(methodName) {\n this.methodName = methodName;\n};\nAlias.prototype = new Ember.Descriptor();\n\n/**\n Makes a property or method available via an additional name.\n\n ```javascript\n App.PaintSample = Ember.Object.extend({\n color: 'red',\n colour: Ember.alias('color'),\n name: function(){\n return \"Zed\";\n },\n moniker: Ember.alias(\"name\")\n });\n\n var paintSample = App.PaintSample.create()\n paintSample.get('colour'); // 'red'\n paintSample.moniker(); // 'Zed'\n ```\n\n @method alias\n @for Ember\n @param {String} methodName name of the method or property to alias\n @return {Ember.Descriptor}\n*/\nEmber.alias = function(methodName) {\n return new Alias(methodName);\n};\n\n// ..........................................................\n// OBSERVER HELPER\n//\n\n/**\n @method observer\n @for Ember\n @param {Function} func\n @param {String} propertyNames*\n @return func\n*/\nEmber.observer = function(func) {\n var paths = a_slice.call(arguments, 1);\n func.__ember_observes__ = paths;\n return func;\n};\n\n// If observers ever become asynchronous, Ember.immediateObserver\n// must remain synchronous.\n/**\n @method immediateObserver\n @for Ember\n @param {Function} func\n @param {String} propertyNames*\n @return func\n*/\nEmber.immediateObserver = function() {\n for (var i=0, l=arguments.length; i<l; i++) {\n var arg = arguments[i];\n Ember.assert(\"Immediate observers must observe internal properties only, not properties on other objects.\", typeof arg !== \"string\" || arg.indexOf('.') === -1);\n }\n\n return Ember.observer.apply(this, arguments);\n};\n\n/**\n @method beforeObserver\n @for Ember\n @param {Function} func\n @param {String} propertyNames*\n @return func\n*/\nEmber.beforeObserver = function(func) {\n var paths = a_slice.call(arguments, 1);\n func.__ember_observesBefore__ = paths;\n return func;\n};\n\n})();\n\n\n\n(function() {\n/**\nEmber Metal\n\n@module ember\n@submodule ember-metal\n*/\n\n})();\n\n(function() {\ndefine(\"rsvp\",\n [],\n function() {\n \"use strict\";\n var browserGlobal = (typeof window !== 'undefined') ? window : {};\n\n var MutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;\n var RSVP, async;\n\n if (typeof process !== 'undefined' &&\n {}.toString.call(process) === '[object process]') {\n async = function(callback, binding) {\n process.nextTick(function() {\n callback.call(binding);\n });\n };\n } else if (MutationObserver) {\n var queue = [];\n\n var observer = new MutationObserver(function() {\n var toProcess = queue.slice();\n queue = [];\n\n toProcess.forEach(function(tuple) {\n var callback = tuple[0], binding = tuple[1];\n callback.call(binding);\n });\n });\n\n var element = document.createElement('div');\n observer.observe(element, { attributes: true });\n\n async = function(callback, binding) {\n queue.push([callback, binding]);\n element.setAttribute('drainQueue', 'drainQueue');\n };\n } else {\n async = function(callback, binding) {\n setTimeout(function() {\n callback.call(binding);\n }, 1);\n };\n }\n\n var Event = function(type, options) {\n this.type = type;\n\n for (var option in options) {\n if (!options.hasOwnProperty(option)) { continue; }\n\n this[option] = options[option];\n }\n };\n\n var indexOf = function(callbacks, callback) {\n for (var i=0, l=callbacks.length; i<l; i++) {\n if (callbacks[i][0] === callback) { return i; }\n }\n\n return -1;\n };\n\n var callbacksFor = function(object) {\n var callbacks = object._promiseCallbacks;\n\n if (!callbacks) {\n callbacks = object._promiseCallbacks = {};\n }\n\n return callbacks;\n };\n\n var EventTarget = {\n mixin: function(object) {\n object.on = this.on;\n object.off = this.off;\n object.trigger = this.trigger;\n return object;\n },\n\n on: function(eventNames, callback, binding) {\n var allCallbacks = callbacksFor(this), callbacks, eventName;\n eventNames = eventNames.split(/\\s+/);\n binding = binding || this;\n\n while (eventName = eventNames.shift()) {\n callbacks = allCallbacks[eventName];\n\n if (!callbacks) {\n callbacks = allCallbacks[eventName] = [];\n }\n\n if (indexOf(callbacks, callback) === -1) {\n callbacks.push([callback, binding]);\n }\n }\n },\n\n off: function(eventNames, callback) {\n var allCallbacks = callbacksFor(this), callbacks, eventName, index;\n eventNames = eventNames.split(/\\s+/);\n\n while (eventName = eventNames.shift()) {\n if (!callback) {\n allCallbacks[eventName] = [];\n continue;\n }\n\n callbacks = allCallbacks[eventName];\n\n index = indexOf(callbacks, callback);\n\n if (index !== -1) { callbacks.splice(index, 1); }\n }\n },\n\n trigger: function(eventName, options) {\n var allCallbacks = callbacksFor(this),\n callbacks, callbackTuple, callback, binding, event;\n\n if (callbacks = allCallbacks[eventName]) {\n for (var i=0, l=callbacks.length; i<l; i++) {\n callbackTuple = callbacks[i];\n callback = callbackTuple[0];\n binding = callbackTuple[1];\n\n if (typeof options !== 'object') {\n options = { detail: options };\n }\n\n event = new Event(eventName, options);\n callback.call(binding, event);\n }\n }\n }\n };\n\n var Promise = function() {\n this.on('promise:resolved', function(event) {\n this.trigger('success', { detail: event.detail });\n }, this);\n\n this.on('promise:failed', function(event) {\n this.trigger('error', { detail: event.detail });\n }, this);\n };\n\n var noop = function() {};\n\n var invokeCallback = function(type, promise, callback, event) {\n var hasCallback = typeof callback === 'function',\n value, error, succeeded, failed;\n\n if (hasCallback) {\n try {\n value = callback(event.detail);\n succeeded = true;\n } catch(e) {\n failed = true;\n error = e;\n }\n } else {\n value = event.detail;\n succeeded = true;\n }\n\n if (value && typeof value.then === 'function') {\n value.then(function(value) {\n promise.resolve(value);\n }, function(error) {\n promise.reject(error);\n });\n } else if (hasCallback && succeeded) {\n promise.resolve(value);\n } else if (failed) {\n promise.reject(error);\n } else {\n promise[type](value);\n }\n };\n\n Promise.prototype = {\n then: function(done, fail) {\n var thenPromise = new Promise();\n\n if (this.isResolved) {\n RSVP.async(function() {\n invokeCallback('resolve', thenPromise, done, { detail: this.resolvedValue });\n }, this);\n }\n\n if (this.isRejected) {\n RSVP.async(function() {\n invokeCallback('reject', thenPromise, fail, { detail: this.rejectedValue });\n }, this);\n }\n\n this.on('promise:resolved', function(event) {\n invokeCallback('resolve', thenPromise, done, event);\n });\n\n this.on('promise:failed', function(event) {\n invokeCallback('reject', thenPromise, fail, event);\n });\n\n return thenPromise;\n },\n\n resolve: function(value) {\n resolve(this, value);\n\n this.resolve = noop;\n this.reject = noop;\n },\n\n reject: function(value) {\n reject(this, value);\n\n this.resolve = noop;\n this.reject = noop;\n }\n };\n\n function resolve(promise, value) {\n RSVP.async(function() {\n promise.trigger('promise:resolved', { detail: value });\n promise.isResolved = true;\n promise.resolvedValue = value;\n });\n }\n\n function reject(promise, value) {\n RSVP.async(function() {\n promise.trigger('promise:failed', { detail: value });\n promise.isRejected = true;\n promise.rejectedValue = value;\n });\n }\n\n EventTarget.mixin(Promise.prototype);\n\n RSVP = { async: async, Promise: Promise, Event: Event, EventTarget: EventTarget };\n return RSVP;\n });\n\n})();\n\n(function() {\nvar get = Ember.get, set = Ember.set;\n\nfunction Container() {\n this.registry = {};\n this.cache = {};\n this.typeInjections = {};\n this.injections = {};\n this.options = {};\n this.typeOptions = {};\n}\n\nContainer.prototype = {\n set: function(object, key, value) {\n object[key] = value;\n },\n\n register: function(type, name, factory, options) {\n this.registry[type + \":\" + name] = factory;\n this.options[type + \":\" + name] = options || {};\n },\n\n resolve: function(fullName) {\n if (this.registry.hasOwnProperty(fullName)) {\n return this.registry[fullName];\n }\n },\n\n lookup: function(fullName) {\n if (this.cache.hasOwnProperty(fullName)) {\n return this.cache[fullName];\n }\n\n var value = instantiate(this, fullName);\n\n if (!value) { return; }\n\n if (isSingleton(this, fullName)) {\n this.cache[fullName] = value;\n }\n\n return value;\n },\n\n optionsForType: function(type, options) {\n this.typeOptions[type] = options;\n },\n\n typeInjection: function(type, property, fullName) {\n var injections = this.typeInjections[type] = this.typeInjections[type] || [];\n injections.push({ property: property, fullName: fullName });\n },\n\n injection: function(factoryName, property, injectionName) {\n var injections = this.injections[factoryName] = this.injections[factoryName] || [];\n injections.push({ property: property, fullName: injectionName });\n },\n\n destroy: function() {\n eachDestroyable(this, function(item) {\n item.isDestroying = true;\n });\n\n eachDestroyable(this, function(item) {\n item.destroy();\n });\n\n this.isDestroyed = true;\n }\n};\n\nfunction isSingleton(container, fullName) {\n var singleton = option(container, fullName, 'singleton');\n\n return singleton !== false;\n}\n\nfunction applyInjections(container, value, injections) {\n if (!injections) { return; }\n\n var injection, lookup;\n\n for (var i=0, l=injections.length; i<l; i++) {\n injection = injections[i];\n lookup = container.lookup(injection.fullName);\n container.set(value, injection.property, lookup);\n }\n}\n\nfunction option(container, fullName, optionName) {\n var options = container.options[fullName];\n\n if (options && options[optionName] !== undefined) {\n return options[optionName];\n }\n\n var type = fullName.split(\":\")[0];\n options = container.typeOptions[type];\n\n if (options) {\n return options[optionName];\n }\n}\n\nfunction instantiate(container, fullName) {\n var splitName = fullName.split(\":\"),\n type = splitName[0], name = splitName[1],\n value;\n\n var factory = container.resolve(fullName);\n\n if (option(container, fullName, 'instantiate') === false) {\n return factory;\n }\n\n if (factory) {\n value = factory.create({ container: container });\n\n var injections = [];\n injections = injections.concat(container.typeInjections[type] || []);\n injections = injections.concat(container.injections[fullName] || []);\n\n applyInjections(container, value, injections);\n\n return value;\n }\n}\n\nfunction eachDestroyable(container, callback) {\n var cache = container.cache;\n\n for (var prop in cache) {\n if (!cache.hasOwnProperty(prop)) { continue; }\n if (option(container, prop, 'instantiate') === false) { continue; }\n callback(cache[prop]);\n }\n}\n\nEmber.Container = Container;\n\n})();\n\n(function() {\n/*globals ENV */\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar indexOf = Ember.EnumerableUtils.indexOf;\n\n// ........................................\n// TYPING & ARRAY MESSAGING\n//\n\nvar TYPE_MAP = {};\nvar t = \"Boolean Number String Function Array Date RegExp Object\".split(\" \");\nEmber.ArrayPolyfills.forEach.call(t, function(name) {\n TYPE_MAP[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n});\n\nvar toString = Object.prototype.toString;\n\n/**\n Returns a consistent type for the passed item.\n\n Use this instead of the built-in `typeof` to get the type of an item.\n It will return the same result across all browsers and includes a bit\n more detail. Here is what will be returned:\n\n | Return Value | Meaning |\n |---------------|------------------------------------------------------|\n | 'string' | String primitive |\n | 'number' | Number primitive |\n | 'boolean' | Boolean primitive |\n | 'null' | Null value |\n | 'undefined' | Undefined value |\n | 'function' | A function |\n | 'array' | An instance of Array |\n | 'class' | A Ember class (created using Ember.Object.extend()) |\n | 'instance' | A Ember object instance |\n | 'error' | An instance of the Error object |\n | 'object' | A JavaScript object not inheriting from Ember.Object |\n\n Examples:\n\n ```javascript\n Ember.typeOf(); // 'undefined'\n Ember.typeOf(null); // 'null'\n Ember.typeOf(undefined); // 'undefined'\n Ember.typeOf('michael'); // 'string'\n Ember.typeOf(101); // 'number'\n Ember.typeOf(true); // 'boolean'\n Ember.typeOf(Ember.makeArray); // 'function'\n Ember.typeOf([1,2,90]); // 'array'\n Ember.typeOf(Ember.Object.extend()); // 'class'\n Ember.typeOf(Ember.Object.create()); // 'instance'\n Ember.typeOf(new Error('teamocil')); // 'error'\n\n // \"normal\" JavaScript object\n Ember.typeOf({a: 'b'}); // 'object'\n ```\n\n @method typeOf\n @for Ember\n @param item {Object} the item to check\n @return {String} the type\n*/\nEmber.typeOf = function(item) {\n var ret;\n\n ret = (item === null || item === undefined) ? String(item) : TYPE_MAP[toString.call(item)] || 'object';\n\n if (ret === 'function') {\n if (Ember.Object && Ember.Object.detect(item)) ret = 'class';\n } else if (ret === 'object') {\n if (item instanceof Error) ret = 'error';\n else if (Ember.Object && item instanceof Ember.Object) ret = 'instance';\n else ret = 'object';\n }\n\n return ret;\n};\n\n/**\n Returns true if the passed value is null or undefined. This avoids errors\n from JSLint complaining about use of ==, which can be technically\n confusing.\n\n ```javascript\n Ember.isNone(); // true\n Ember.isNone(null); // true\n Ember.isNone(undefined); // true\n Ember.isNone(''); // false\n Ember.isNone([]); // false\n Ember.isNone(function(){}); // false\n ```\n\n @method isNone\n @for Ember\n @param {Object} obj Value to test\n @return {Boolean}\n*/\nEmber.isNone = function(obj) {\n return obj === null || obj === undefined;\n};\nEmber.none = Ember.deprecateFunc(\"Ember.none is deprecated. Please use Ember.isNone instead.\", Ember.isNone);\n\n/**\n Verifies that a value is `null` or an empty string, empty array,\n or empty function.\n\n Constrains the rules on `Ember.isNone` by returning false for empty\n string and empty arrays.\n\n ```javascript\n Ember.isEmpty(); // true\n Ember.isEmpty(null); // true\n Ember.isEmpty(undefined); // true\n Ember.isEmpty(''); // true\n Ember.isEmpty([]); // true\n Ember.isEmpty('Adam Hawkins'); // false\n Ember.isEmpty([0,1,2]); // false\n ```\n\n @method isEmpty\n @for Ember\n @param {Object} obj Value to test\n @return {Boolean}\n*/\nEmber.isEmpty = function(obj) {\n return obj === null || obj === undefined || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0);\n};\nEmber.empty = Ember.deprecateFunc(\"Ember.empty is deprecated. Please use Ember.isEmpty instead.\", Ember.isEmpty) ;\n\n/**\n This will compare two javascript values of possibly different types.\n It will tell you which one is greater than the other by returning:\n\n - -1 if the first is smaller than the second,\n - 0 if both are equal,\n - 1 if the first is greater than the second.\n\n The order is calculated based on `Ember.ORDER_DEFINITION`, if types are different.\n In case they have the same type an appropriate comparison for this type is made.\n\n ```javascript\n Ember.compare('hello', 'hello'); // 0\n Ember.compare('abc', 'dfg'); // -1\n Ember.compare(2, 1); // 1\n ```javascript\n\n @method compare\n @for Ember\n @param {Object} v First value to compare\n @param {Object} w Second value to compare\n @return {Number} -1 if v < w, 0 if v = w and 1 if v > w.\n*/\nEmber.compare = function compare(v, w) {\n if (v === w) { return 0; }\n\n var type1 = Ember.typeOf(v);\n var type2 = Ember.typeOf(w);\n\n var Comparable = Ember.Comparable;\n if (Comparable) {\n if (type1==='instance' && Comparable.detect(v.constructor)) {\n return v.constructor.compare(v, w);\n }\n\n if (type2 === 'instance' && Comparable.detect(w.constructor)) {\n return 1-w.constructor.compare(w, v);\n }\n }\n\n // If we haven't yet generated a reverse-mapping of Ember.ORDER_DEFINITION,\n // do so now.\n var mapping = Ember.ORDER_DEFINITION_MAPPING;\n if (!mapping) {\n var order = Ember.ORDER_DEFINITION;\n mapping = Ember.ORDER_DEFINITION_MAPPING = {};\n var idx, len;\n for (idx = 0, len = order.length; idx < len; ++idx) {\n mapping[order[idx]] = idx;\n }\n\n // We no longer need Ember.ORDER_DEFINITION.\n delete Ember.ORDER_DEFINITION;\n }\n\n var type1Index = mapping[type1];\n var type2Index = mapping[type2];\n\n if (type1Index < type2Index) { return -1; }\n if (type1Index > type2Index) { return 1; }\n\n // types are equal - so we have to check values now\n switch (type1) {\n case 'boolean':\n case 'number':\n if (v < w) { return -1; }\n if (v > w) { return 1; }\n return 0;\n\n case 'string':\n var comp = v.localeCompare(w);\n if (comp < 0) { return -1; }\n if (comp > 0) { return 1; }\n return 0;\n\n case 'array':\n var vLen = v.length;\n var wLen = w.length;\n var l = Math.min(vLen, wLen);\n var r = 0;\n var i = 0;\n while (r === 0 && i < l) {\n r = compare(v[i],w[i]);\n i++;\n }\n if (r !== 0) { return r; }\n\n // all elements are equal now\n // shorter array should be ordered first\n if (vLen < wLen) { return -1; }\n if (vLen > wLen) { return 1; }\n // arrays are equal now\n return 0;\n\n case 'instance':\n if (Ember.Comparable && Ember.Comparable.detect(v)) {\n return v.compare(v, w);\n }\n return 0;\n\n case 'date':\n var vNum = v.getTime();\n var wNum = w.getTime();\n if (vNum < wNum) { return -1; }\n if (vNum > wNum) { return 1; }\n return 0;\n\n default:\n return 0;\n }\n};\n\nfunction _copy(obj, deep, seen, copies) {\n var ret, loc, key;\n\n // primitive data types are immutable, just return them.\n if ('object' !== typeof obj || obj===null) return obj;\n\n // avoid cyclical loops\n if (deep && (loc=indexOf(seen, obj))>=0) return copies[loc];\n\n Ember.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof Ember.Object) || (Ember.Copyable && Ember.Copyable.detect(obj)));\n\n // IMPORTANT: this specific test will detect a native array only. Any other\n // object will need to implement Copyable.\n if (Ember.typeOf(obj) === 'array') {\n ret = obj.slice();\n if (deep) {\n loc = ret.length;\n while(--loc>=0) ret[loc] = _copy(ret[loc], deep, seen, copies);\n }\n } else if (Ember.Copyable && Ember.Copyable.detect(obj)) {\n ret = obj.copy(deep, seen, copies);\n } else {\n ret = {};\n for(key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n\n // Prevents browsers that don't respect non-enumerability from\n // copying internal Ember properties\n if (key.substring(0,2) === '__') continue;\n\n ret[key] = deep ? _copy(obj[key], deep, seen, copies) : obj[key];\n }\n }\n\n if (deep) {\n seen.push(obj);\n copies.push(ret);\n }\n\n return ret;\n}\n\n/**\n Creates a clone of the passed object. This function can take just about\n any type of object and create a clone of it, including primitive values\n (which are not actually cloned because they are immutable).\n\n If the passed object implements the `clone()` method, then this function\n will simply call that method and return the result.\n\n @method copy\n @for Ember\n @param {Object} object The object to clone\n @param {Boolean} deep If true, a deep copy of the object is made\n @return {Object} The cloned object\n*/\nEmber.copy = function(obj, deep) {\n // fast paths\n if ('object' !== typeof obj || obj===null) return obj; // can't copy primitives\n if (Ember.Copyable && Ember.Copyable.detect(obj)) return obj.copy(deep);\n return _copy(obj, deep, deep ? [] : null, deep ? [] : null);\n};\n\n/**\n Convenience method to inspect an object. This method will attempt to\n convert the object into a useful string description.\n\n @method inspect\n @for Ember\n @param {Object} obj The object you want to inspect.\n @return {String} A description of the object\n*/\nEmber.inspect = function(obj) {\n var v, ret = [];\n for(var key in obj) {\n if (obj.hasOwnProperty(key)) {\n v = obj[key];\n if (v === 'toString') { continue; } // ignore useless items\n if (Ember.typeOf(v) === 'function') { v = \"function() { ... }\"; }\n ret.push(key + \": \" + v);\n }\n }\n return \"{\" + ret.join(\" , \") + \"}\";\n};\n\n/**\n Compares two objects, returning true if they are logically equal. This is\n a deeper comparison than a simple triple equal. For sets it will compare the\n internal objects. For any other object that implements `isEqual()` it will\n respect that method.\n\n ```javascript\n Ember.isEqual('hello', 'hello'); // true\n Ember.isEqual(1, 2); // false\n Ember.isEqual([4,2], [4,2]); // false\n ```\n\n @method isEqual\n @for Ember\n @param {Object} a first object to compare\n @param {Object} b second object to compare\n @return {Boolean}\n*/\nEmber.isEqual = function(a, b) {\n if (a && 'function'===typeof a.isEqual) return a.isEqual(b);\n return a === b;\n};\n\n// Used by Ember.compare\nEmber.ORDER_DEFINITION = Ember.ENV.ORDER_DEFINITION || [\n 'undefined',\n 'null',\n 'boolean',\n 'number',\n 'string',\n 'array',\n 'object',\n 'instance',\n 'function',\n 'class',\n 'date'\n];\n\n/**\n Returns all of the keys defined on an object or hash. This is useful\n when inspecting objects for debugging. On browsers that support it, this\n uses the native `Object.keys` implementation.\n\n @method keys\n @for Ember\n @param {Object} obj\n @return {Array} Array containing keys of obj\n*/\nEmber.keys = Object.keys;\n\nif (!Ember.keys) {\n Ember.keys = function(obj) {\n var ret = [];\n for(var key in obj) {\n if (obj.hasOwnProperty(key)) { ret.push(key); }\n }\n return ret;\n };\n}\n\n// ..........................................................\n// ERROR\n//\n\nvar errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];\n\n/**\n A subclass of the JavaScript Error object for use in Ember.\n\n @class Error\n @namespace Ember\n @extends Error\n @constructor\n*/\nEmber.Error = function() {\n var tmp = Error.prototype.constructor.apply(this, arguments);\n\n // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.\n for (var idx = 0; idx < errorProps.length; idx++) {\n this[errorProps[idx]] = tmp[errorProps[idx]];\n }\n};\n\nEmber.Error.prototype = Ember.create(Error.prototype);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar STRING_DASHERIZE_REGEXP = (/[ _]/g);\nvar STRING_DASHERIZE_CACHE = {};\nvar STRING_DECAMELIZE_REGEXP = (/([a-z])([A-Z])/g);\nvar STRING_CAMELIZE_REGEXP = (/(\\-|_|\\s)+(.)?/g);\nvar STRING_UNDERSCORE_REGEXP_1 = (/([a-z\\d])([A-Z]+)/g);\nvar STRING_UNDERSCORE_REGEXP_2 = (/\\-|\\s+/g);\n\n/**\n Defines the hash of localized strings for the current language. Used by\n the `Ember.String.loc()` helper. To localize, add string values to this\n hash.\n\n @property STRINGS\n @for Ember\n @type Hash\n*/\nEmber.STRINGS = {};\n\n/**\n Defines string helper methods including string formatting and localization.\n Unless `Ember.EXTEND_PROTOTYPES.String` is `false` these methods will also be\n added to the `String.prototype` as well.\n\n @class String\n @namespace Ember\n @static\n*/\nEmber.String = {\n\n /**\n Apply formatting options to the string. This will look for occurrences\n of \"%@\" in your string and substitute them with the arguments you pass into\n this method. If you want to control the specific order of replacement,\n you can add a number after the key as well to indicate which argument\n you want to insert.\n\n Ordered insertions are most useful when building loc strings where values\n you need to insert may appear in different orders.\n\n ```javascript\n \"Hello %@ %@\".fmt('John', 'Doe'); // \"Hello John Doe\"\n \"Hello %@2, %@1\".fmt('John', 'Doe'); // \"Hello Doe, John\"\n ```\n\n @method fmt\n @param {Object...} [args]\n @return {String} formatted string\n */\n fmt: function(str, formats) {\n // first, replace any ORDERED replacements.\n var idx = 0; // the current index for non-numerical replacements\n return str.replace(/%@([0-9]+)?/g, function(s, argIndex) {\n argIndex = (argIndex) ? parseInt(argIndex,0) - 1 : idx++ ;\n s = formats[argIndex];\n return ((s === null) ? '(null)' : (s === undefined) ? '' : s).toString();\n }) ;\n },\n\n /**\n Formats the passed string, but first looks up the string in the localized\n strings hash. This is a convenient way to localize text. See\n `Ember.String.fmt()` for more information on formatting.\n\n Note that it is traditional but not required to prefix localized string\n keys with an underscore or other character so you can easily identify\n localized strings.\n\n ```javascript\n Ember.STRINGS = {\n '_Hello World': 'Bonjour le monde',\n '_Hello %@ %@': 'Bonjour %@ %@'\n };\n\n Ember.String.loc(\"_Hello World\"); // 'Bonjour le monde';\n Ember.String.loc(\"_Hello %@ %@\", [\"John\", \"Smith\"]); // \"Bonjour John Smith\";\n ```\n\n @method loc\n @param {String} str The string to format\n @param {Array} formats Optional array of parameters to interpolate into string.\n @return {String} formatted string\n */\n loc: function(str, formats) {\n str = Ember.STRINGS[str] || str;\n return Ember.String.fmt(str, formats) ;\n },\n\n /**\n Splits a string into separate units separated by spaces, eliminating any\n empty strings in the process. This is a convenience method for split that\n is mostly useful when applied to the `String.prototype`.\n\n ```javascript\n Ember.String.w(\"alpha beta gamma\").forEach(function(key) {\n console.log(key);\n });\n\n // > alpha\n // > beta\n // > gamma\n ```\n\n @method w\n @param {String} str The string to split\n @return {String} split string\n */\n w: function(str) { return str.split(/\\s+/); },\n\n /**\n Converts a camelized string into all lower case separated by underscores.\n\n ```javascript\n 'innerHTML'.decamelize(); // 'inner_html'\n 'action_name'.decamelize(); // 'action_name'\n 'css-class-name'.decamelize(); // 'css-class-name'\n 'my favorite items'.decamelize(); // 'my favorite items'\n ```\n\n @method decamelize\n @param {String} str The string to decamelize.\n @return {String} the decamelized string.\n */\n decamelize: function(str) {\n return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();\n },\n\n /**\n Replaces underscores or spaces with dashes.\n\n ```javascript\n 'innerHTML'.dasherize(); // 'inner-html'\n 'action_name'.dasherize(); // 'action-name'\n 'css-class-name'.dasherize(); // 'css-class-name'\n 'my favorite items'.dasherize(); // 'my-favorite-items'\n ```\n\n @method dasherize\n @param {String} str The string to dasherize.\n @return {String} the dasherized string.\n */\n dasherize: function(str) {\n var cache = STRING_DASHERIZE_CACHE,\n ret = cache[str];\n\n if (ret) {\n return ret;\n } else {\n ret = Ember.String.decamelize(str).replace(STRING_DASHERIZE_REGEXP,'-');\n cache[str] = ret;\n }\n\n return ret;\n },\n\n /**\n Returns the lowerCaseCamel form of a string.\n\n ```javascript\n 'innerHTML'.camelize(); // 'innerHTML'\n 'action_name'.camelize(); // 'actionName'\n 'css-class-name'.camelize(); // 'cssClassName'\n 'my favorite items'.camelize(); // 'myFavoriteItems'\n ```\n\n @method camelize\n @param {String} str The string to camelize.\n @return {String} the camelized string.\n */\n camelize: function(str) {\n return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {\n return chr ? chr.toUpperCase() : '';\n });\n },\n\n /**\n Returns the UpperCamelCase form of a string.\n\n ```javascript\n 'innerHTML'.classify(); // 'InnerHTML'\n 'action_name'.classify(); // 'ActionName'\n 'css-class-name'.classify(); // 'CssClassName'\n 'my favorite items'.classify(); // 'MyFavoriteItems'\n ``` \n\n @method classify\n @param {String} str the string to classify\n @return {String} the classified string\n */\n classify: function(str) {\n var camelized = Ember.String.camelize(str);\n return camelized.charAt(0).toUpperCase() + camelized.substr(1);\n },\n\n /**\n More general than decamelize. Returns the lower\\_case\\_and\\_underscored\n form of a string.\n\n ```javascript\n 'innerHTML'.underscore(); // 'inner_html'\n 'action_name'.underscore(); // 'action_name'\n 'css-class-name'.underscore(); // 'css_class_name'\n 'my favorite items'.underscore(); // 'my_favorite_items'\n ```\n\n @property underscore\n @param {String} str The string to underscore.\n @return {String} the underscored string.\n */\n underscore: function(str) {\n return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').\n replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase();\n },\n\n /**\n Returns the Capitalized form of a string\n\n 'innerHTML'.capitalize() => 'InnerHTML'\n 'action_name'.capitalize() => 'Action_name'\n 'css-class-name'.capitalize() => 'Css-class-name'\n 'my favorite items'.capitalize() => 'My favorite items'\n\n @param {String} str\n\n @returns {String}\n */\n capitalize: function(str) {\n return str.charAt(0).toUpperCase() + str.substr(1);\n }\n\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\n\nvar fmt = Ember.String.fmt,\n w = Ember.String.w,\n loc = Ember.String.loc,\n camelize = Ember.String.camelize,\n decamelize = Ember.String.decamelize,\n dasherize = Ember.String.dasherize,\n underscore = Ember.String.underscore,\n capitalize = Ember.String.capitalize,\n classify = Ember.String.classify;\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {\n\n /**\n See {{#crossLink \"Ember.String/fmt\"}}{{/crossLink}}\n\n @method fmt\n @for String\n */\n String.prototype.fmt = function() {\n return fmt(this, arguments);\n };\n\n /**\n See {{#crossLink \"Ember.String/w\"}}{{/crossLink}}\n\n @method w\n @for String\n */\n String.prototype.w = function() {\n return w(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/loc\"}}{{/crossLink}}\n\n @method loc\n @for String\n */\n String.prototype.loc = function() {\n return loc(this, arguments);\n };\n\n /**\n See {{#crossLink \"Ember.String/camelize\"}}{{/crossLink}}\n\n @method camelize\n @for String\n */\n String.prototype.camelize = function() {\n return camelize(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/decamelize\"}}{{/crossLink}}\n\n @method decamelize\n @for String\n */\n String.prototype.decamelize = function() {\n return decamelize(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/dasherize\"}}{{/crossLink}}\n\n @method dasherize\n @for String\n */\n String.prototype.dasherize = function() {\n return dasherize(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/underscore\"}}{{/crossLink}}\n\n @method underscore\n @for String\n */\n String.prototype.underscore = function() {\n return underscore(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/classify\"}}{{/crossLink}}\n\n @method classify\n @for String\n */\n String.prototype.classify = function() {\n return classify(this);\n };\n\n /**\n See {{#crossLink \"Ember.String/capitalize\"}}{{/crossLink}}\n\n @method capitalize\n @for String\n */\n String.prototype.capitalize = function() {\n return capitalize(this);\n };\n\n}\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar a_slice = Array.prototype.slice;\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {\n\n /**\n The `property` extension of Javascript's Function prototype is available\n when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is\n `true`, which is the default.\n\n Computed properties allow you to treat a function like a property:\n\n ```javascript\n MyApp.president = Ember.Object.create({\n firstName: \"Barack\",\n lastName: \"Obama\",\n\n fullName: function() {\n return this.get('firstName') + ' ' + this.get('lastName');\n\n // Call this flag to mark the function as a property\n }.property()\n });\n\n MyApp.president.get('fullName'); // \"Barack Obama\"\n ```\n\n Treating a function like a property is useful because they can work with\n bindings, just like any other property.\n\n Many computed properties have dependencies on other properties. For\n example, in the above example, the `fullName` property depends on\n `firstName` and `lastName` to determine its value. You can tell Ember\n about these dependencies like this:\n\n ```javascript\n MyApp.president = Ember.Object.create({\n firstName: \"Barack\",\n lastName: \"Obama\",\n\n fullName: function() {\n return this.get('firstName') + ' ' + this.get('lastName');\n\n // Tell Ember.js that this computed property depends on firstName\n // and lastName\n }.property('firstName', 'lastName')\n });\n ```\n\n Make sure you list these dependencies so Ember knows when to update\n bindings that connect to a computed property. Changing a dependency\n will not immediately trigger an update of the computed property, but\n will instead clear the cache so that it is updated when the next `get`\n is called on the property.\n\n See {{#crossLink \"Ember.ComputedProperty\"}}{{/crossLink}},\n {{#crossLink \"Ember/computed\"}}{{/crossLink}}\n\n @method property\n @for Function\n */\n Function.prototype.property = function() {\n var ret = Ember.computed(this);\n return ret.property.apply(ret, arguments);\n };\n\n /**\n The `observes` extension of Javascript's Function prototype is available\n when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is\n true, which is the default.\n\n You can observe property changes simply by adding the `observes`\n call to the end of your method declarations in classes that you write.\n For example:\n\n ```javascript\n Ember.Object.create({\n valueObserver: function() {\n // Executes whenever the \"value\" property changes\n }.observes('value')\n });\n ```\n\n See {{#crossLink \"Ember.Observable/observes\"}}{{/crossLink}}\n\n @method observes\n @for Function\n */\n Function.prototype.observes = function() {\n this.__ember_observes__ = a_slice.call(arguments);\n return this;\n };\n\n /**\n The `observesBefore` extension of Javascript's Function prototype is\n available when `Ember.EXTEND_PROTOTYPES` or\n `Ember.EXTEND_PROTOTYPES.Function` is true, which is the default.\n\n You can get notified when a property changes is about to happen by\n by adding the `observesBefore` call to the end of your method\n declarations in classes that you write. For example:\n\n ```javascript\n Ember.Object.create({\n valueObserver: function() {\n // Executes whenever the \"value\" property is about to change\n }.observesBefore('value')\n });\n ```\n\n See {{#crossLink \"Ember.Observable/observesBefore\"}}{{/crossLink}}\n\n @method observesBefore\n @for Function\n */\n Function.prototype.observesBefore = function() {\n this.__ember_observesBefore__ = a_slice.call(arguments);\n return this;\n };\n\n}\n\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n// ..........................................................\n// HELPERS\n//\n\nvar get = Ember.get, set = Ember.set;\nvar a_slice = Array.prototype.slice;\nvar a_indexOf = Ember.EnumerableUtils.indexOf;\n\nvar contexts = [];\n\nfunction popCtx() {\n return contexts.length===0 ? {} : contexts.pop();\n}\n\nfunction pushCtx(ctx) {\n contexts.push(ctx);\n return null;\n}\n\nfunction iter(key, value) {\n var valueProvided = arguments.length === 2;\n\n function i(item) {\n var cur = get(item, key);\n return valueProvided ? value===cur : !!cur;\n }\n return i ;\n}\n\n/**\n This mixin defines the common interface implemented by enumerable objects\n in Ember. Most of these methods follow the standard Array iteration\n API defined up to JavaScript 1.8 (excluding language-specific features that\n cannot be emulated in older versions of JavaScript).\n\n This mixin is applied automatically to the Array class on page load, so you\n can use any of these methods on simple arrays. If Array already implements\n one of these methods, the mixin will not override them.\n\n ## Writing Your Own Enumerable\n\n To make your own custom class enumerable, you need two items:\n\n 1. You must have a length property. This property should change whenever\n the number of items in your enumerable object changes. If you using this\n with an `Ember.Object` subclass, you should be sure to change the length\n property using `set().`\n\n 2. If you must implement `nextObject().` See documentation.\n\n Once you have these two methods implement, apply the `Ember.Enumerable` mixin\n to your class and you will be able to enumerate the contents of your object\n like any other collection.\n\n ## Using Ember Enumeration with Other Libraries\n\n Many other libraries provide some kind of iterator or enumeration like\n facility. This is often where the most common API conflicts occur.\n Ember's API is designed to be as friendly as possible with other\n libraries by implementing only methods that mostly correspond to the\n JavaScript 1.8 API.\n\n @class Enumerable\n @namespace Ember\n @extends Ember.Mixin\n @since Ember 0.9\n*/\nEmber.Enumerable = Ember.Mixin.create(\n /** @scope Ember.Enumerable.prototype */ {\n\n // compatibility\n isEnumerable: true,\n\n /**\n Implement this method to make your class enumerable.\n\n This method will be call repeatedly during enumeration. The index value\n will always begin with 0 and increment monotonically. You don't have to\n rely on the index value to determine what object to return, but you should\n always check the value and start from the beginning when you see the\n requested index is 0.\n\n The `previousObject` is the object that was returned from the last call\n to `nextObject` for the current iteration. This is a useful way to\n manage iteration if you are tracing a linked list, for example.\n\n Finally the context parameter will always contain a hash you can use as\n a \"scratchpad\" to maintain any other state you need in order to iterate\n properly. The context object is reused and is not reset between\n iterations so make sure you setup the context with a fresh state whenever\n the index parameter is 0.\n\n Generally iterators will continue to call `nextObject` until the index\n reaches the your current length-1. If you run out of data before this\n time for some reason, you should simply return undefined.\n\n The default implementation of this method simply looks up the index.\n This works great on any Array-like objects.\n\n @method nextObject\n @param {Number} index the current index of the iteration\n @param {Object} previousObject the value returned by the last call to \n `nextObject`.\n @param {Object} context a context object you can use to maintain state.\n @return {Object} the next object in the iteration or undefined\n */\n nextObject: Ember.required(Function),\n\n /**\n Helper method returns the first object from a collection. This is usually\n used by bindings and other parts of the framework to extract a single\n object if the enumerable contains only one item.\n\n If you override this method, you should implement it so that it will\n always return the same value each time it is called. If your enumerable\n contains only one object, this method should always return that object.\n If your enumerable is empty, this method should return `undefined`.\n\n ```javascript\n var arr = [\"a\", \"b\", \"c\"];\n arr.firstObject(); // \"a\"\n\n var arr = [];\n arr.firstObject(); // undefined\n ```\n\n @property firstObject\n @return {Object} the object or undefined\n */\n firstObject: Ember.computed(function() {\n if (get(this, 'length')===0) return undefined ;\n\n // handle generic enumerables\n var context = popCtx(), ret;\n ret = this.nextObject(0, null, context);\n pushCtx(context);\n return ret ;\n }).property('[]'),\n\n /**\n Helper method returns the last object from a collection. If your enumerable\n contains only one object, this method should always return that object.\n If your enumerable is empty, this method should return `undefined`.\n\n ```javascript\n var arr = [\"a\", \"b\", \"c\"];\n arr.lastObject(); // \"c\"\n\n var arr = [];\n arr.lastObject(); // undefined\n ```\n\n @property lastObject\n @return {Object} the last object or undefined\n */\n lastObject: Ember.computed(function() {\n var len = get(this, 'length');\n if (len===0) return undefined ;\n var context = popCtx(), idx=0, cur, last = null;\n do {\n last = cur;\n cur = this.nextObject(idx++, last, context);\n } while (cur !== undefined);\n pushCtx(context);\n return last;\n }).property('[]'),\n\n /**\n Returns `true` if the passed object can be found in the receiver. The\n default version will iterate through the enumerable until the object\n is found. You may want to override this with a more efficient version.\n\n ```javascript\n var arr = [\"a\", \"b\", \"c\"];\n arr.contains(\"a\"); // true\n arr.contains(\"z\"); // false\n ```\n\n @method contains\n @param {Object} obj The object to search for.\n @return {Boolean} `true` if object is found in enumerable.\n */\n contains: function(obj) {\n return this.find(function(item) { return item===obj; }) !== undefined;\n },\n\n /**\n Iterates through the enumerable, calling the passed function on each\n item. This method corresponds to the `forEach()` method defined in\n JavaScript 1.6.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n @method forEach\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Object} receiver\n */\n forEach: function(callback, target) {\n if (typeof callback !== \"function\") throw new TypeError() ;\n var len = get(this, 'length'), last = null, context = popCtx();\n\n if (target === undefined) target = null;\n\n for(var idx=0;idx<len;idx++) {\n var next = this.nextObject(idx, last, context) ;\n callback.call(target, next, idx, this);\n last = next ;\n }\n last = null ;\n context = pushCtx(context);\n return this ;\n },\n\n /**\n Alias for `mapProperty`\n\n @method getEach\n @param {String} key name of the property\n @return {Array} The mapped array.\n */\n getEach: function(key) {\n return this.mapProperty(key);\n },\n\n /**\n Sets the value on the named property for each member. This is more\n efficient than using other methods defined on this helper. If the object\n implements Ember.Observable, the value will be changed to `set(),` otherwise\n it will be set directly. `null` objects are skipped.\n\n @method setEach\n @param {String} key The key to set\n @param {Object} value The object to set\n @return {Object} receiver\n */\n setEach: function(key, value) {\n return this.forEach(function(item) {\n set(item, key, value);\n });\n },\n\n /**\n Maps all of the items in the enumeration to another value, returning\n a new array. This method corresponds to `map()` defined in JavaScript 1.6.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n It should return the mapped value.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n @method map\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Array} The mapped array.\n */\n map: function(callback, target) {\n var ret = [];\n this.forEach(function(x, idx, i) {\n ret[idx] = callback.call(target, x, idx,i);\n });\n return ret ;\n },\n\n /**\n Similar to map, this specialized function returns the value of the named\n property on all items in the enumeration.\n\n @method mapProperty\n @param {String} key name of the property\n @return {Array} The mapped array.\n */\n mapProperty: function(key) {\n return this.map(function(next) {\n return get(next, key);\n });\n },\n\n /**\n Returns an array with all of the items in the enumeration that the passed\n function returns true for. This method corresponds to `filter()` defined in\n JavaScript 1.6.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n It should return the `true` to include the item in the results, `false`\n otherwise.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n @method filter\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Array} A filtered array.\n */\n filter: function(callback, target) {\n var ret = [];\n this.forEach(function(x, idx, i) {\n if (callback.call(target, x, idx, i)) ret.push(x);\n });\n return ret ;\n },\n\n /**\n Returns an array with all of the items in the enumeration where the passed\n function returns false for. This method is the inverse of filter().\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n function(item, index, enumerable);\n\n - *item* is the current item in the iteration.\n - *index* is the current index in the iteration\n - *enumerable* is the enumerable object itself.\n\n It should return the a falsey value to include the item in the results.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as \"this\" on the context. This is a good way\n to give your iterator function access to the current object.\n\n @method reject\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Array} A rejected array.\n */\n reject: function(callback, target) {\n return this.filter(function() {\n return !(callback.apply(target, arguments));\n });\n },\n\n /**\n Returns an array with just the items with the matched property. You\n can pass an optional second argument with the target value. Otherwise\n this will match any property that evaluates to `true`.\n\n @method filterProperty\n @param {String} key the property to test\n @param {String} [value] optional value to test against.\n @return {Array} filtered array\n */\n filterProperty: function(key, value) {\n return this.filter(iter.apply(this, arguments));\n },\n\n /**\n Returns an array with the items that do not have truthy values for\n key. You can pass an optional second argument with the target value. Otherwise\n this will match any property that evaluates to false.\n\n @method rejectProperty\n @param {String} key the property to test\n @param {String} [value] optional value to test against.\n @return {Array} rejected array\n */\n rejectProperty: function(key, value) {\n var exactValue = function(item) { return get(item, key) === value; },\n hasValue = function(item) { return !!get(item, key); },\n use = (arguments.length === 2 ? exactValue : hasValue);\n\n return this.reject(use);\n },\n\n /**\n Returns the first item in the array for which the callback returns true.\n This method works similar to the `filter()` method defined in JavaScript 1.6\n except that it will stop working on the array once a match is found.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n It should return the `true` to include the item in the results, `false`\n otherwise.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n @method find\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Object} Found item or `null`.\n */\n find: function(callback, target) {\n var len = get(this, 'length') ;\n if (target === undefined) target = null;\n\n var last = null, next, found = false, ret ;\n var context = popCtx();\n for(var idx=0;idx<len && !found;idx++) {\n next = this.nextObject(idx, last, context) ;\n if (found = callback.call(target, next, idx, this)) ret = next ;\n last = next ;\n }\n next = last = null ;\n context = pushCtx(context);\n return ret ;\n },\n\n /**\n Returns the first item with a property matching the passed value. You\n can pass an optional second argument with the target value. Otherwise\n this will match any property that evaluates to `true`.\n\n This method works much like the more generic `find()` method.\n\n @method findProperty\n @param {String} key the property to test\n @param {String} [value] optional value to test against.\n @return {Object} found item or `null`\n */\n findProperty: function(key, value) {\n return this.find(iter.apply(this, arguments));\n },\n\n /**\n Returns `true` if the passed function returns true for every item in the\n enumeration. This corresponds with the `every()` method in JavaScript 1.6.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n It should return the `true` or `false`.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n Example Usage:\n\n ```javascript\n if (people.every(isEngineer)) { Paychecks.addBigBonus(); }\n ```\n\n @method every\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Boolean}\n */\n every: function(callback, target) {\n return !this.find(function(x, idx, i) {\n return !callback.call(target, x, idx, i);\n });\n },\n\n /**\n Returns `true` if the passed property resolves to `true` for all items in\n the enumerable. This method is often simpler/faster than using a callback.\n\n @method everyProperty\n @param {String} key the property to test\n @param {String} [value] optional value to test against.\n @return {Boolean}\n */\n everyProperty: function(key, value) {\n return this.every(iter.apply(this, arguments));\n },\n\n\n /**\n Returns `true` if the passed function returns true for any item in the\n enumeration. This corresponds with the `every()` method in JavaScript 1.6.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(item, index, enumerable);\n ```\n\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n It should return the `true` to include the item in the results, `false`\n otherwise.\n\n Note that in addition to a callback, you can also pass an optional target\n object that will be set as `this` on the context. This is a good way\n to give your iterator function access to the current object.\n\n Usage Example:\n\n ```javascript\n if (people.some(isManager)) { Paychecks.addBiggerBonus(); }\n ```\n\n @method some\n @param {Function} callback The callback to execute\n @param {Object} [target] The target object to use\n @return {Array} A filtered array.\n */\n some: function(callback, target) {\n return !!this.find(function(x, idx, i) {\n return !!callback.call(target, x, idx, i);\n });\n },\n\n /**\n Returns `true` if the passed property resolves to `true` for any item in\n the enumerable. This method is often simpler/faster than using a callback.\n\n @method someProperty\n @param {String} key the property to test\n @param {String} [value] optional value to test against.\n @return {Boolean} `true`\n */\n someProperty: function(key, value) {\n return this.some(iter.apply(this, arguments));\n },\n\n /**\n This will combine the values of the enumerator into a single value. It\n is a useful way to collect a summary value from an enumeration. This\n corresponds to the `reduce()` method defined in JavaScript 1.8.\n\n The callback method you provide should have the following signature (all\n parameters are optional):\n\n ```javascript\n function(previousValue, item, index, enumerable);\n ```\n\n - `previousValue` is the value returned by the last call to the iterator.\n - `item` is the current item in the iteration.\n - `index` is the current index in the iteration.\n - `enumerable` is the enumerable object itself.\n\n Return the new cumulative value.\n\n In addition to the callback you can also pass an `initialValue`. An error\n will be raised if you do not pass an initial value and the enumerator is\n empty.\n\n Note that unlike the other methods, this method does not allow you to\n pass a target object to set as this for the callback. It's part of the\n spec. Sorry.\n\n @method reduce\n @param {Function} callback The callback to execute\n @param {Object} initialValue Initial value for the reduce\n @param {String} reducerProperty internal use only.\n @return {Object} The reduced value.\n */\n reduce: function(callback, initialValue, reducerProperty) {\n if (typeof callback !== \"function\") { throw new TypeError(); }\n\n var ret = initialValue;\n\n this.forEach(function(item, i) {\n ret = callback.call(null, ret, item, i, this, reducerProperty);\n }, this);\n\n return ret;\n },\n\n /**\n Invokes the named method on every object in the receiver that\n implements it. This method corresponds to the implementation in\n Prototype 1.6.\n\n @method invoke\n @param {String} methodName the name of the method\n @param {Object...} args optional arguments to pass as well.\n @return {Array} return values from calling invoke.\n */\n invoke: function(methodName) {\n var args, ret = [];\n if (arguments.length>1) args = a_slice.call(arguments, 1);\n\n this.forEach(function(x, idx) {\n var method = x && x[methodName];\n if ('function' === typeof method) {\n ret[idx] = args ? method.apply(x, args) : method.call(x);\n }\n }, this);\n\n return ret;\n },\n\n /**\n Simply converts the enumerable into a genuine array. The order is not\n guaranteed. Corresponds to the method implemented by Prototype.\n\n @method toArray\n @return {Array} the enumerable as an array.\n */\n toArray: function() {\n var ret = [];\n this.forEach(function(o, idx) { ret[idx] = o; });\n return ret ;\n },\n\n /**\n Returns a copy of the array with all null elements removed.\n\n ```javascript\n var arr = [\"a\", null, \"c\", null];\n arr.compact(); // [\"a\", \"c\"]\n ```\n\n @method compact\n @return {Array} the array without null elements.\n */\n compact: function() { return this.without(null); },\n\n /**\n Returns a new enumerable that excludes the passed value. The default\n implementation returns an array regardless of the receiver type unless\n the receiver does not contain the value.\n\n ```javascript\n var arr = [\"a\", \"b\", \"a\", \"c\"];\n arr.without(\"a\"); // [\"b\", \"c\"]\n ```\n\n @method without\n @param {Object} value\n @return {Ember.Enumerable}\n */\n without: function(value) {\n if (!this.contains(value)) return this; // nothing to do\n var ret = [] ;\n this.forEach(function(k) {\n if (k !== value) ret[ret.length] = k;\n }) ;\n return ret ;\n },\n\n /**\n Returns a new enumerable that contains only unique values. The default\n implementation returns an array regardless of the receiver type.\n\n ```javascript\n var arr = [\"a\", \"a\", \"b\", \"b\"];\n arr.uniq(); // [\"a\", \"b\"]\n ```\n\n @method uniq\n @return {Ember.Enumerable}\n */\n uniq: function() {\n var ret = [];\n this.forEach(function(k){\n if (a_indexOf(ret, k)<0) ret.push(k);\n });\n return ret;\n },\n\n /**\n This property will trigger anytime the enumerable's content changes.\n You can observe this property to be notified of changes to the enumerables\n content.\n\n For plain enumerables, this property is read only. `Ember.Array` overrides\n this method.\n\n @property []\n @type Ember.Array\n */\n '[]': Ember.computed(function(key, value) {\n return this;\n }).property(),\n\n // ..........................................................\n // ENUMERABLE OBSERVERS\n //\n\n /**\n Registers an enumerable observer. Must implement `Ember.EnumerableObserver`\n mixin.\n\n @method addEnumerableObserver\n @param target {Object}\n @param opts {Hash}\n */\n addEnumerableObserver: function(target, opts) {\n var willChange = (opts && opts.willChange) || 'enumerableWillChange',\n didChange = (opts && opts.didChange) || 'enumerableDidChange';\n\n var hasObservers = get(this, 'hasEnumerableObservers');\n if (!hasObservers) Ember.propertyWillChange(this, 'hasEnumerableObservers');\n Ember.addListener(this, '@enumerable:before', target, willChange);\n Ember.addListener(this, '@enumerable:change', target, didChange);\n if (!hasObservers) Ember.propertyDidChange(this, 'hasEnumerableObservers');\n return this;\n },\n\n /**\n Removes a registered enumerable observer.\n\n @method removeEnumerableObserver\n @param target {Object}\n @param [opts] {Hash}\n */\n removeEnumerableObserver: function(target, opts) {\n var willChange = (opts && opts.willChange) || 'enumerableWillChange',\n didChange = (opts && opts.didChange) || 'enumerableDidChange';\n\n var hasObservers = get(this, 'hasEnumerableObservers');\n if (hasObservers) Ember.propertyWillChange(this, 'hasEnumerableObservers');\n Ember.removeListener(this, '@enumerable:before', target, willChange);\n Ember.removeListener(this, '@enumerable:change', target, didChange);\n if (hasObservers) Ember.propertyDidChange(this, 'hasEnumerableObservers');\n return this;\n },\n\n /**\n Becomes true whenever the array currently has observers watching changes\n on the array.\n\n @property hasEnumerableObservers\n @type Boolean\n */\n hasEnumerableObservers: Ember.computed(function() {\n return Ember.hasListeners(this, '@enumerable:change') || Ember.hasListeners(this, '@enumerable:before');\n }).property(),\n\n\n /**\n Invoke this method just before the contents of your enumerable will\n change. You can either omit the parameters completely or pass the objects\n to be removed or added if available or just a count.\n\n @method enumerableContentWillChange\n @param {Ember.Enumerable|Number} removing An enumerable of the objects to\n be removed or the number of items to be removed.\n @param {Ember.Enumerable|Number} adding An enumerable of the objects to be\n added or the number of items to be added.\n @chainable\n */\n enumerableContentWillChange: function(removing, adding) {\n\n var removeCnt, addCnt, hasDelta;\n\n if ('number' === typeof removing) removeCnt = removing;\n else if (removing) removeCnt = get(removing, 'length');\n else removeCnt = removing = -1;\n\n if ('number' === typeof adding) addCnt = adding;\n else if (adding) addCnt = get(adding,'length');\n else addCnt = adding = -1;\n\n hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;\n\n if (removing === -1) removing = null;\n if (adding === -1) adding = null;\n\n Ember.propertyWillChange(this, '[]');\n if (hasDelta) Ember.propertyWillChange(this, 'length');\n Ember.sendEvent(this, '@enumerable:before', [this, removing, adding]);\n\n return this;\n },\n\n /**\n Invoke this method when the contents of your enumerable has changed.\n This will notify any observers watching for content changes. If your are\n implementing an ordered enumerable (such as an array), also pass the\n start and end values where the content changed so that it can be used to\n notify range observers.\n\n @method enumerableContentDidChange\n @param {Number} [start] optional start offset for the content change.\n For unordered enumerables, you should always pass -1.\n @param {Ember.Enumerable|Number} removing An enumerable of the objects to\n be removed or the number of items to be removed.\n @param {Ember.Enumerable|Number} adding An enumerable of the objects to\n be added or the number of items to be added.\n @chainable\n */\n enumerableContentDidChange: function(removing, adding) {\n var notify = this.propertyDidChange, removeCnt, addCnt, hasDelta;\n\n if ('number' === typeof removing) removeCnt = removing;\n else if (removing) removeCnt = get(removing, 'length');\n else removeCnt = removing = -1;\n\n if ('number' === typeof adding) addCnt = adding;\n else if (adding) addCnt = get(adding, 'length');\n else addCnt = adding = -1;\n\n hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;\n\n if (removing === -1) removing = null;\n if (adding === -1) adding = null;\n\n Ember.sendEvent(this, '@enumerable:change', [this, removing, adding]);\n if (hasDelta) Ember.propertyDidChange(this, 'length');\n Ember.propertyDidChange(this, '[]');\n\n return this ;\n }\n\n}) ;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n// ..........................................................\n// HELPERS\n//\n\nvar get = Ember.get, set = Ember.set, meta = Ember.meta, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor;\n\nfunction none(obj) { return obj===null || obj===undefined; }\n\n// ..........................................................\n// ARRAY\n//\n/**\n This module implements Observer-friendly Array-like behavior. This mixin is\n picked up by the Array class as well as other controllers, etc. that want to\n appear to be arrays.\n\n Unlike `Ember.Enumerable,` this mixin defines methods specifically for\n collections that provide index-ordered access to their contents. When you\n are designing code that needs to accept any kind of Array-like object, you\n should use these methods instead of Array primitives because these will\n properly notify observers of changes to the array.\n\n Although these methods are efficient, they do add a layer of indirection to\n your application so it is a good idea to use them only when you need the\n flexibility of using both true JavaScript arrays and \"virtual\" arrays such\n as controllers and collections.\n\n You can use the methods defined in this module to access and modify array\n contents in a KVO-friendly way. You can also be notified whenever the\n membership if an array changes by changing the syntax of the property to\n `.observes('*myProperty.[]')`.\n\n To support `Ember.Array` in your own class, you must override two\n primitives to use it: `replace()` and `objectAt()`.\n\n Note that the Ember.Array mixin also incorporates the `Ember.Enumerable`\n mixin. All `Ember.Array`-like objects are also enumerable.\n\n @class Array\n @namespace Ember\n @extends Ember.Mixin\n @uses Ember.Enumerable\n @since Ember 0.9.0\n*/\nEmber.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.prototype */ {\n\n // compatibility\n isSCArray: true,\n\n /**\n Your array must support the `length` property. Your replace methods should\n set this property whenever it changes.\n\n @property {Number} length\n */\n length: Ember.required(),\n\n /**\n Returns the object at the given `index`. If the given `index` is negative\n or is greater or equal than the array length, returns `undefined`.\n\n This is one of the primitives you must implement to support `Ember.Array`.\n If your object supports retrieving the value of an array item using `get()`\n (i.e. `myArray.get(0)`), then you do not need to implement this method\n yourself.\n\n ```javascript\n var arr = ['a', 'b', 'c', 'd'];\n arr.objectAt(0); // \"a\"\n arr.objectAt(3); // \"d\"\n arr.objectAt(-1); // undefined\n arr.objectAt(4); // undefined\n arr.objectAt(5); // undefined\n ```\n\n @method objectAt\n @param {Number} idx The index of the item to return.\n */\n objectAt: function(idx) {\n if ((idx < 0) || (idx>=get(this, 'length'))) return undefined ;\n return get(this, idx);\n },\n\n /**\n This returns the objects at the specified indexes, using `objectAt`.\n\n ```javascript\n var arr = ['a', 'b', 'c', 'd'];\n arr.objectsAt([0, 1, 2]); // [\"a\", \"b\", \"c\"]\n arr.objectsAt([2, 3, 4]); // [\"c\", \"d\", undefined]\n ```\n\n @method objectsAt\n @param {Array} indexes An array of indexes of items to return.\n */\n objectsAt: function(indexes) {\n var self = this;\n return map(indexes, function(idx){ return self.objectAt(idx); });\n },\n\n // overrides Ember.Enumerable version\n nextObject: function(idx) {\n return this.objectAt(idx);\n },\n\n /**\n This is the handler for the special array content property. If you get\n this property, it will return this. If you set this property it a new\n array, it will replace the current content.\n\n This property overrides the default property defined in `Ember.Enumerable`.\n\n @property []\n */\n '[]': Ember.computed(function(key, value) {\n if (value !== undefined) this.replace(0, get(this, 'length'), value) ;\n return this ;\n }).property(),\n\n firstObject: Ember.computed(function() {\n return this.objectAt(0);\n }).property(),\n\n lastObject: Ember.computed(function() {\n return this.objectAt(get(this, 'length')-1);\n }).property(),\n\n // optimized version from Enumerable\n contains: function(obj){\n return this.indexOf(obj) >= 0;\n },\n\n // Add any extra methods to Ember.Array that are native to the built-in Array.\n /**\n Returns a new array that is a slice of the receiver. This implementation\n uses the observable array methods to retrieve the objects for the new\n slice.\n\n ```javascript\n var arr = ['red', 'green', 'blue'];\n arr.slice(0); // ['red', 'green', 'blue']\n arr.slice(0, 2); // ['red', 'green']\n arr.slice(1, 100); // ['green', 'blue']\n ```\n\n @method slice\n @param beginIndex {Integer} (Optional) index to begin slicing from.\n @param endIndex {Integer} (Optional) index to end the slice at.\n @return {Array} New array with specified slice\n */\n slice: function(beginIndex, endIndex) {\n var ret = [];\n var length = get(this, 'length') ;\n if (none(beginIndex)) beginIndex = 0 ;\n if (none(endIndex) || (endIndex > length)) endIndex = length ;\n while(beginIndex < endIndex) {\n ret[ret.length] = this.objectAt(beginIndex++) ;\n }\n return ret ;\n },\n\n /**\n Returns the index of the given object's first occurrence.\n If no `startAt` argument is given, the starting location to\n search is 0. If it's negative, will count backward from\n the end of the array. Returns -1 if no match is found.\n\n ```javascript\n var arr = [\"a\", \"b\", \"c\", \"d\", \"a\"];\n arr.indexOf(\"a\"); // 0\n arr.indexOf(\"z\"); // -1\n arr.indexOf(\"a\", 2); // 4\n arr.indexOf(\"a\", -1); // 4\n arr.indexOf(\"b\", 3); // -1\n arr.indexOf(\"a\", 100); // -1\n ```javascript\n\n @method indexOf\n @param {Object} object the item to search for\n @param {Number} startAt optional starting location to search, default 0\n @return {Number} index or -1 if not found\n */\n indexOf: function(object, startAt) {\n var idx, len = get(this, 'length');\n\n if (startAt === undefined) startAt = 0;\n if (startAt < 0) startAt += len;\n\n for(idx=startAt;idx<len;idx++) {\n if (this.objectAt(idx, true) === object) return idx ;\n }\n return -1;\n },\n\n /**\n Returns the index of the given object's last occurrence.\n If no `startAt` argument is given, the search starts from\n the last position. If it's negative, will count backward\n from the end of the array. Returns -1 if no match is found.\n\n ```javascript\n var arr = [\"a\", \"b\", \"c\", \"d\", \"a\"];\n arr.lastIndexOf(\"a\"); // 4\n arr.lastIndexOf(\"z\"); // -1\n arr.lastIndexOf(\"a\", 2); // 0\n arr.lastIndexOf(\"a\", -1); // 4\n arr.lastIndexOf(\"b\", 3); // 1\n arr.lastIndexOf(\"a\", 100); // 4\n ```\n\n @method lastIndexOf\n @param {Object} object the item to search for\n @param {Number} startAt optional starting location to search, default 0\n @return {Number} index or -1 if not found\n */\n lastIndexOf: function(object, startAt) {\n var idx, len = get(this, 'length');\n\n if (startAt === undefined || startAt >= len) startAt = len-1;\n if (startAt < 0) startAt += len;\n\n for(idx=startAt;idx>=0;idx--) {\n if (this.objectAt(idx) === object) return idx ;\n }\n return -1;\n },\n\n // ..........................................................\n // ARRAY OBSERVERS\n //\n\n /**\n Adds an array observer to the receiving array. The array observer object\n normally must implement two methods:\n\n * `arrayWillChange(start, removeCount, addCount)` - This method will be\n called just before the array is modified.\n * `arrayDidChange(start, removeCount, addCount)` - This method will be\n called just after the array is modified.\n\n Both callbacks will be passed the starting index of the change as well a\n a count of the items to be removed and added. You can use these callbacks\n to optionally inspect the array during the change, clear caches, or do\n any other bookkeeping necessary.\n\n In addition to passing a target, you can also include an options hash\n which you can use to override the method names that will be invoked on the\n target.\n\n @method addArrayObserver\n @param {Object} target The observer object.\n @param {Hash} opts Optional hash of configuration options including\n `willChange`, `didChange`, and a `context` option.\n @return {Ember.Array} receiver\n */\n addArrayObserver: function(target, opts) {\n var willChange = (opts && opts.willChange) || 'arrayWillChange',\n didChange = (opts && opts.didChange) || 'arrayDidChange';\n\n var hasObservers = get(this, 'hasArrayObservers');\n if (!hasObservers) Ember.propertyWillChange(this, 'hasArrayObservers');\n Ember.addListener(this, '@array:before', target, willChange);\n Ember.addListener(this, '@array:change', target, didChange);\n if (!hasObservers) Ember.propertyDidChange(this, 'hasArrayObservers');\n return this;\n },\n\n /**\n Removes an array observer from the object if the observer is current\n registered. Calling this method multiple times with the same object will\n have no effect.\n\n @method removeArrayObserver\n @param {Object} target The object observing the array.\n @return {Ember.Array} receiver\n */\n removeArrayObserver: function(target, opts) {\n var willChange = (opts && opts.willChange) || 'arrayWillChange',\n didChange = (opts && opts.didChange) || 'arrayDidChange';\n\n var hasObservers = get(this, 'hasArrayObservers');\n if (hasObservers) Ember.propertyWillChange(this, 'hasArrayObservers');\n Ember.removeListener(this, '@array:before', target, willChange);\n Ember.removeListener(this, '@array:change', target, didChange);\n if (hasObservers) Ember.propertyDidChange(this, 'hasArrayObservers');\n return this;\n },\n\n /**\n Becomes true whenever the array currently has observers watching changes\n on the array.\n\n @property Boolean\n */\n hasArrayObservers: Ember.computed(function() {\n return Ember.hasListeners(this, '@array:change') || Ember.hasListeners(this, '@array:before');\n }).property(),\n\n /**\n If you are implementing an object that supports `Ember.Array`, call this\n method just before the array content changes to notify any observers and\n invalidate any related properties. Pass the starting index of the change\n as well as a delta of the amounts to change.\n\n @method arrayContentWillChange\n @param {Number} startIdx The starting index in the array that will change.\n @param {Number} removeAmt The number of items that will be removed. If you \n pass `null` assumes 0\n @param {Number} addAmt The number of items that will be added If you \n pass `null` assumes 0.\n @return {Ember.Array} receiver\n */\n arrayContentWillChange: function(startIdx, removeAmt, addAmt) {\n\n // if no args are passed assume everything changes\n if (startIdx===undefined) {\n startIdx = 0;\n removeAmt = addAmt = -1;\n } else {\n if (removeAmt === undefined) removeAmt=-1;\n if (addAmt === undefined) addAmt=-1;\n }\n\n // Make sure the @each proxy is set up if anyone is observing @each\n if (Ember.isWatching(this, '@each')) { get(this, '@each'); }\n\n Ember.sendEvent(this, '@array:before', [this, startIdx, removeAmt, addAmt]);\n\n var removing, lim;\n if (startIdx>=0 && removeAmt>=0 && get(this, 'hasEnumerableObservers')) {\n removing = [];\n lim = startIdx+removeAmt;\n for(var idx=startIdx;idx<lim;idx++) removing.push(this.objectAt(idx));\n } else {\n removing = removeAmt;\n }\n\n this.enumerableContentWillChange(removing, addAmt);\n\n return this;\n },\n\n arrayContentDidChange: function(startIdx, removeAmt, addAmt) {\n\n // if no args are passed assume everything changes\n if (startIdx===undefined) {\n startIdx = 0;\n removeAmt = addAmt = -1;\n } else {\n if (removeAmt === undefined) removeAmt=-1;\n if (addAmt === undefined) addAmt=-1;\n }\n\n var adding, lim;\n if (startIdx>=0 && addAmt>=0 && get(this, 'hasEnumerableObservers')) {\n adding = [];\n lim = startIdx+addAmt;\n for(var idx=startIdx;idx<lim;idx++) adding.push(this.objectAt(idx));\n } else {\n adding = addAmt;\n }\n\n this.enumerableContentDidChange(removeAmt, adding);\n Ember.sendEvent(this, '@array:change', [this, startIdx, removeAmt, addAmt]);\n\n var length = get(this, 'length'),\n cachedFirst = cacheFor(this, 'firstObject'),\n cachedLast = cacheFor(this, 'lastObject');\n if (this.objectAt(0) !== cachedFirst) {\n Ember.propertyWillChange(this, 'firstObject');\n Ember.propertyDidChange(this, 'firstObject');\n }\n if (this.objectAt(length-1) !== cachedLast) {\n Ember.propertyWillChange(this, 'lastObject');\n Ember.propertyDidChange(this, 'lastObject');\n }\n\n return this;\n },\n\n // ..........................................................\n // ENUMERATED PROPERTIES\n //\n\n /**\n Returns a special object that can be used to observe individual properties\n on the array. Just get an equivalent property on this object and it will\n return an enumerable that maps automatically to the named key on the\n member objects.\n\n @property @each\n */\n '@each': Ember.computed(function() {\n if (!this.__each) this.__each = new Ember.EachProxy(this);\n return this.__each;\n }).property()\n\n}) ;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\n/**\n Implements some standard methods for comparing objects. Add this mixin to\n any class you create that can compare its instances.\n\n You should implement the `compare()` method.\n\n @class Comparable\n @namespace Ember\n @extends Ember.Mixin\n @since Ember 0.9\n*/\nEmber.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{\n\n /**\n walk like a duck. Indicates that the object can be compared.\n\n @property isComparable\n @type Boolean\n @default true\n */\n isComparable: true,\n\n /**\n Override to return the result of the comparison of the two parameters. The\n compare method should return:\n\n - `-1` if `a < b`\n - `0` if `a == b`\n - `1` if `a > b`\n\n Default implementation raises an exception.\n\n @method compare\n @param a {Object} the first object to compare\n @param b {Object} the second object to compare\n @return {Integer} the result of the comparison\n */\n compare: Ember.required(Function)\n\n});\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Implements some standard methods for copying an object. Add this mixin to\n any object you create that can create a copy of itself. This mixin is\n added automatically to the built-in array.\n\n You should generally implement the `copy()` method to return a copy of the\n receiver.\n\n Note that `frozenCopy()` will only work if you also implement\n `Ember.Freezable`.\n\n @class Copyable\n @namespace Ember\n @extends Ember.Mixin\n @since Ember 0.9\n*/\nEmber.Copyable = Ember.Mixin.create(\n/** @scope Ember.Copyable.prototype */ {\n\n /**\n Override to return a copy of the receiver. Default implementation raises\n an exception.\n\n @method copy\n @param deep {Boolean} if `true`, a deep copy of the object should be made\n @return {Object} copy of receiver\n */\n copy: Ember.required(Function),\n\n /**\n If the object implements `Ember.Freezable`, then this will return a new\n copy if the object is not frozen and the receiver if the object is frozen.\n\n Raises an exception if you try to call this method on a object that does\n not support freezing.\n\n You should use this method whenever you want a copy of a freezable object\n since a freezable object can simply return itself without actually\n consuming more memory.\n\n @method frozenCopy\n @return {Object} copy of receiver or receiver\n */\n frozenCopy: function() {\n if (Ember.Freezable && Ember.Freezable.detect(this)) {\n return get(this, 'isFrozen') ? this : this.copy().freeze();\n } else {\n throw new Error(Ember.String.fmt(\"%@ does not support freezing\", [this]));\n }\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n The `Ember.Freezable` mixin implements some basic methods for marking an\n object as frozen. Once an object is frozen it should be read only. No changes\n may be made the internal state of the object.\n\n ## Enforcement\n\n To fully support freezing in your subclass, you must include this mixin and\n override any method that might alter any property on the object to instead\n raise an exception. You can check the state of an object by checking the\n `isFrozen` property.\n\n Although future versions of JavaScript may support language-level freezing\n object objects, that is not the case today. Even if an object is freezable,\n it is still technically possible to modify the object, even though it could\n break other parts of your application that do not expect a frozen object to\n change. It is, therefore, very important that you always respect the\n `isFrozen` property on all freezable objects.\n\n ## Example Usage\n\n The example below shows a simple object that implement the `Ember.Freezable`\n protocol.\n\n ```javascript\n Contact = Ember.Object.extend(Ember.Freezable, {\n firstName: null,\n lastName: null,\n\n // swaps the names\n swapNames: function() {\n if (this.get('isFrozen')) throw Ember.FROZEN_ERROR;\n var tmp = this.get('firstName');\n this.set('firstName', this.get('lastName'));\n this.set('lastName', tmp);\n return this;\n }\n\n });\n\n c = Context.create({ firstName: \"John\", lastName: \"Doe\" });\n c.swapNames(); // returns c\n c.freeze();\n c.swapNames(); // EXCEPTION\n ```\n\n ## Copying\n\n Usually the `Ember.Freezable` protocol is implemented in cooperation with the\n `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will\n return a frozen object, if the object implements this method as well.\n\n @class Freezable\n @namespace Ember\n @extends Ember.Mixin\n @since Ember 0.9\n*/\nEmber.Freezable = Ember.Mixin.create(\n/** @scope Ember.Freezable.prototype */ {\n\n /**\n Set to `true` when the object is frozen. Use this property to detect\n whether your object is frozen or not.\n\n @property isFrozen\n @type Boolean\n */\n isFrozen: false,\n\n /**\n Freezes the object. Once this method has been called the object should\n no longer allow any properties to be edited.\n\n @method freeze\n @return {Object} receiver\n */\n freeze: function() {\n if (get(this, 'isFrozen')) return this;\n set(this, 'isFrozen', true);\n return this;\n }\n\n});\n\nEmber.FROZEN_ERROR = \"Frozen object cannot be modified.\";\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar forEach = Ember.EnumerableUtils.forEach;\n\n/**\n This mixin defines the API for modifying generic enumerables. These methods\n can be applied to an object regardless of whether it is ordered or\n unordered.\n\n Note that an Enumerable can change even if it does not implement this mixin.\n For example, a MappedEnumerable cannot be directly modified but if its\n underlying enumerable changes, it will change also.\n\n ## Adding Objects\n\n To add an object to an enumerable, use the `addObject()` method. This\n method will only add the object to the enumerable if the object is not\n already present and the object if of a type supported by the enumerable.\n\n ```javascript\n set.addObject(contact);\n ```\n\n ## Removing Objects\n\n To remove an object form an enumerable, use the `removeObject()` method. This\n will only remove the object if it is already in the enumerable, otherwise\n this method has no effect.\n\n ```javascript\n set.removeObject(contact);\n ```\n\n ## Implementing In Your Own Code\n\n If you are implementing an object and want to support this API, just include\n this mixin in your class and implement the required methods. In your unit\n tests, be sure to apply the Ember.MutableEnumerableTests to your object.\n\n @class MutableEnumerable\n @namespace Ember\n @extends Ember.Mixin\n @uses Ember.Enumerable\n*/\nEmber.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable,\n /** @scope Ember.MutableEnumerable.prototype */ {\n\n /**\n __Required.__ You must implement this method to apply this mixin.\n\n Attempts to add the passed object to the receiver if the object is not\n already present in the collection. If the object is present, this method\n has no effect.\n\n If the passed object is of a type not supported by the receiver\n then this method should raise an exception.\n\n @method addObject\n @param {Object} object The object to add to the enumerable.\n @return {Object} the passed object\n */\n addObject: Ember.required(Function),\n\n /**\n Adds each object in the passed enumerable to the receiver.\n\n @method addObjects\n @param {Ember.Enumerable} objects the objects to add.\n @return {Object} receiver\n */\n addObjects: function(objects) {\n Ember.beginPropertyChanges(this);\n forEach(objects, function(obj) { this.addObject(obj); }, this);\n Ember.endPropertyChanges(this);\n return this;\n },\n\n /**\n __Required.__ You must implement this method to apply this mixin.\n\n Attempts to remove the passed object from the receiver collection if the\n object is in present in the collection. If the object is not present,\n this method has no effect.\n\n If the passed object is of a type not supported by the receiver\n then this method should raise an exception.\n\n @method removeObject\n @param {Object} object The object to remove from the enumerable.\n @return {Object} the passed object\n */\n removeObject: Ember.required(Function),\n\n\n /**\n Removes each objects in the passed enumerable from the receiver.\n\n @method removeObjects\n @param {Ember.Enumerable} objects the objects to remove\n @return {Object} receiver\n */\n removeObjects: function(objects) {\n Ember.beginPropertyChanges(this);\n forEach(objects, function(obj) { this.removeObject(obj); }, this);\n Ember.endPropertyChanges(this);\n return this;\n }\n\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n// ..........................................................\n// CONSTANTS\n//\n\nvar OUT_OF_RANGE_EXCEPTION = \"Index out of range\" ;\nvar EMPTY = [];\n\n// ..........................................................\n// HELPERS\n//\n\nvar get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;\n\n/**\n This mixin defines the API for modifying array-like objects. These methods\n can be applied only to a collection that keeps its items in an ordered set.\n\n Note that an Array can change even if it does not implement this mixin.\n For example, one might implement a SparseArray that cannot be directly\n modified, but if its underlying enumerable changes, it will change also.\n\n @class MutableArray\n @namespace Ember\n @extends Ember.Mixin\n @uses Ember.Array\n @uses Ember.MutableEnumerable\n*/\nEmber.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,\n /** @scope Ember.MutableArray.prototype */ {\n\n /**\n __Required.__ You must implement this method to apply this mixin.\n\n This is one of the primitives you must implement to support `Ember.Array`.\n You should replace amt objects started at idx with the objects in the\n passed array. You should also call `this.enumerableContentDidChange()`\n\n @method replace\n @param {Number} idx Starting index in the array to replace. If \n idx >= length, then append to the end of the array.\n @param {Number} amt Number of elements that should be removed from \n the array, starting at *idx*.\n @param {Array} objects An array of zero or more objects that should be \n inserted into the array at *idx*\n */\n replace: Ember.required(),\n\n /**\n Remove all elements from self. This is useful if you\n want to reuse an existing array without having to recreate it.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n color.length(); // 3\n colors.clear(); // []\n colors.length(); // 0\n ```\n\n @method clear\n @return {Ember.Array} An empty Array.\n */\n clear: function () {\n var len = get(this, 'length');\n if (len === 0) return this;\n this.replace(0, len, EMPTY);\n return this;\n },\n\n /**\n This will use the primitive `replace()` method to insert an object at the\n specified index.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.insertAt(2, \"yellow\"); // [\"red\", \"green\", \"yellow\", \"blue\"]\n colors.insertAt(5, \"orange\"); // Error: Index out of range\n ```javascript\n\n @method insertAt\n @param {Number} idx index of insert the object at.\n @param {Object} object object to insert\n */\n insertAt: function(idx, object) {\n if (idx > get(this, 'length')) throw new Error(OUT_OF_RANGE_EXCEPTION) ;\n this.replace(idx, 0, [object]) ;\n return this ;\n },\n\n /**\n Remove an object at the specified index using the `replace()` primitive\n method. You can pass either a single index, or a start and a length.\n\n If you pass a start and length that is beyond the\n length this method will throw an `Ember.OUT_OF_RANGE_EXCEPTION`\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\", \"yellow\", \"orange\"];\n colors.removeAt(0); // [\"green\", \"blue\", \"yellow\", \"orange\"]\n colors.removeAt(2, 2); // [\"green\", \"blue\"]\n colors.removeAt(4, 2); // Error: Index out of range\n ```\n\n @method removeAt\n @param {Number} start index, start of range\n @param {Number} len length of passing range\n @return {Object} receiver\n */\n removeAt: function(start, len) {\n if ('number' === typeof start) {\n\n if ((start < 0) || (start >= get(this, 'length'))) {\n throw new Error(OUT_OF_RANGE_EXCEPTION);\n }\n\n // fast case\n if (len === undefined) len = 1;\n this.replace(start, len, EMPTY);\n }\n\n return this ;\n },\n\n /**\n Push the object onto the end of the array. Works just like `push()` but it\n is KVO-compliant.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.pushObject(\"black\"); // [\"red\", \"green\", \"blue\", \"black\"]\n colors.pushObject([\"yellow\", \"orange\"]); // [\"red\", \"green\", \"blue\", \"black\", [\"yellow\", \"orange\"]]\n ```\n\n @method pushObject\n @param {anything} obj object to push\n */\n pushObject: function(obj) {\n this.insertAt(get(this, 'length'), obj) ;\n return obj ;\n },\n\n /**\n Add the objects in the passed numerable to the end of the array. Defers\n notifying observers of the change until all objects are added.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.pushObjects(\"black\"); // [\"red\", \"green\", \"blue\", \"black\"]\n colors.pushObjects([\"yellow\", \"orange\"]); // [\"red\", \"green\", \"blue\", \"black\", \"yellow\", \"orange\"]\n ```\n\n @method pushObjects\n @param {Ember.Enumerable} objects the objects to add\n @return {Ember.Array} receiver\n */\n pushObjects: function(objects) {\n this.replace(get(this, 'length'), 0, objects);\n return this;\n },\n\n /**\n Pop object from array or nil if none are left. Works just like `pop()` but\n it is KVO-compliant.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.popObject(); // \"blue\"\n console.log(colors); // [\"red\", \"green\"]\n ```\n\n @method popObject\n @return object\n */\n popObject: function() {\n var len = get(this, 'length') ;\n if (len === 0) return null ;\n\n var ret = this.objectAt(len-1) ;\n this.removeAt(len-1, 1) ;\n return ret ;\n },\n\n /**\n Shift an object from start of array or nil if none are left. Works just\n like `shift()` but it is KVO-compliant.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.shiftObject(); // \"red\"\n console.log(colors); // [\"green\", \"blue\"]\n ```\n\n @method shiftObject\n @return object\n */\n shiftObject: function() {\n if (get(this, 'length') === 0) return null ;\n var ret = this.objectAt(0) ;\n this.removeAt(0) ;\n return ret ;\n },\n\n /**\n Unshift an object to start of array. Works just like `unshift()` but it is\n KVO-compliant.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.unshiftObject(\"yellow\"); // [\"yellow\", \"red\", \"green\", \"blue\"]\n colors.unshiftObject([\"black\", \"white\"]); // [[\"black\", \"white\"], \"yellow\", \"red\", \"green\", \"blue\"]\n ```\n\n @method unshiftObject\n @param {anything} obj object to unshift\n */\n unshiftObject: function(obj) {\n this.insertAt(0, obj) ;\n return obj ;\n },\n\n /**\n Adds the named objects to the beginning of the array. Defers notifying\n observers until all objects have been added.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.unshiftObjects([\"black\", \"white\"]); // [\"black\", \"white\", \"red\", \"green\", \"blue\"]\n colors.unshiftObjects(\"yellow\"); // Type Error: 'undefined' is not a function\n ```\n\n @method unshiftObjects\n @param {Ember.Enumerable} objects the objects to add\n @return {Ember.Array} receiver\n */\n unshiftObjects: function(objects) {\n this.replace(0, 0, objects);\n return this;\n },\n\n /**\n Reverse objects in the array. Works just like `reverse()` but it is\n KVO-compliant.\n\n @method reverseObjects\n @return {Ember.Array} receiver\n */\n reverseObjects: function() {\n var len = get(this, 'length');\n if (len === 0) return this;\n var objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n },\n\n /**\n Replace all the the receiver's content with content of the argument.\n If argument is an empty array receiver will be cleared.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"];\n colors.setObjects([\"black\", \"white\"]); // [\"black\", \"white\"]\n colors.setObjects([]); // []\n ```\n\n @method setObjects\n @param {Ember.Array} objects array whose content will be used for replacing\n the content of the receiver\n @return {Ember.Array} receiver with the new content\n */\n setObjects: function(objects) {\n if (objects.length === 0) return this.clear();\n\n var len = get(this, 'length');\n this.replace(0, len, objects);\n return this;\n },\n\n // ..........................................................\n // IMPLEMENT Ember.MutableEnumerable\n //\n\n removeObject: function(obj) {\n var loc = get(this, 'length') || 0;\n while(--loc >= 0) {\n var curObject = this.objectAt(loc) ;\n if (curObject === obj) this.removeAt(loc) ;\n }\n return this ;\n },\n\n addObject: function(obj) {\n if (!this.contains(obj)) this.pushObject(obj);\n return this ;\n }\n\n});\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty;\n\n/**\n ## Overview\n\n This mixin provides properties and property observing functionality, core\n features of the Ember object model.\n\n Properties and observers allow one object to observe changes to a\n property on another object. This is one of the fundamental ways that\n models, controllers and views communicate with each other in an Ember\n application.\n\n Any object that has this mixin applied can be used in observer\n operations. That includes `Ember.Object` and most objects you will\n interact with as you write your Ember application.\n\n Note that you will not generally apply this mixin to classes yourself,\n but you will use the features provided by this module frequently, so it\n is important to understand how to use it.\n\n ## Using `get()` and `set()`\n\n Because of Ember's support for bindings and observers, you will always\n access properties using the get method, and set properties using the\n set method. This allows the observing objects to be notified and\n computed properties to be handled properly.\n\n More documentation about `get` and `set` are below.\n\n ## Observing Property Changes\n\n You typically observe property changes simply by adding the `observes`\n call to the end of your method declarations in classes that you write.\n For example:\n\n ```javascript\n Ember.Object.create({\n valueObserver: function() {\n // Executes whenever the \"value\" property changes\n }.observes('value')\n });\n ```\n\n Although this is the most common way to add an observer, this capability\n is actually built into the `Ember.Object` class on top of two methods\n defined in this mixin: `addObserver` and `removeObserver`. You can use\n these two methods to add and remove observers yourself if you need to\n do so at runtime.\n\n To add an observer for a property, call:\n\n ```javascript\n object.addObserver('propertyKey', targetObject, targetAction)\n ```\n\n This will call the `targetAction` method on the `targetObject` to be called\n whenever the value of the `propertyKey` changes.\n\n Note that if `propertyKey` is a computed property, the observer will be\n called when any of the property dependencies are changed, even if the\n resulting value of the computed property is unchanged. This is necessary\n because computed properties are not computed until `get` is called.\n\n @class Observable\n @namespace Ember\n @extends Ember.Mixin\n*/\nEmber.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {\n\n // compatibility\n isObserverable: true,\n\n /**\n Retrieves the value of a property from the object.\n\n This method is usually similar to using `object[keyName]` or `object.keyName`,\n however it supports both computed properties and the unknownProperty\n handler.\n\n Because `get` unifies the syntax for accessing all these kinds\n of properties, it can make many refactorings easier, such as replacing a\n simple property with a computed property, or vice versa.\n\n ### Computed Properties\n\n Computed properties are methods defined with the `property` modifier\n declared at the end, such as:\n\n ```javascript\n fullName: function() {\n return this.getEach('firstName', 'lastName').compact().join(' ');\n }.property('firstName', 'lastName')\n ```\n\n When you call `get` on a computed property, the function will be\n called and the return value will be returned instead of the function\n itself.\n\n ### Unknown Properties\n\n Likewise, if you try to call `get` on a property whose value is\n `undefined`, the `unknownProperty()` method will be called on the object.\n If this method returns any value other than `undefined`, it will be returned\n instead. This allows you to implement \"virtual\" properties that are\n not defined upfront.\n\n @method get\n @param {String} key The property to retrieve\n @return {Object} The property value or undefined.\n */\n get: function(keyName) {\n return get(this, keyName);\n },\n\n /**\n To get multiple properties at once, call `getProperties`\n with a list of strings or an array:\n\n ```javascript\n record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }\n ```\n\n is equivalent to:\n\n ```javascript\n record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }\n ```\n\n @method getProperties\n @param {String...|Array} list of keys to get\n @return {Hash}\n */\n getProperties: function() {\n var ret = {};\n var propertyNames = arguments;\n if (arguments.length === 1 && Ember.typeOf(arguments[0]) === 'array') {\n propertyNames = arguments[0];\n }\n for(var i = 0; i < propertyNames.length; i++) {\n ret[propertyNames[i]] = get(this, propertyNames[i]);\n }\n return ret;\n },\n\n /**\n Sets the provided key or path to the value.\n\n This method is generally very similar to calling `object[key] = value` or\n `object.key = value`, except that it provides support for computed\n properties, the `unknownProperty()` method and property observers.\n\n ### Computed Properties\n\n If you try to set a value on a key that has a computed property handler\n defined (see the `get()` method for an example), then `set()` will call\n that method, passing both the value and key instead of simply changing\n the value itself. This is useful for those times when you need to\n implement a property that is composed of one or more member\n properties.\n\n ### Unknown Properties\n\n If you try to set a value on a key that is undefined in the target\n object, then the `unknownProperty()` handler will be called instead. This\n gives you an opportunity to implement complex \"virtual\" properties that\n are not predefined on the object. If `unknownProperty()` returns\n undefined, then `set()` will simply set the value on the object.\n\n ### Property Observers\n\n In addition to changing the property, `set()` will also register a property\n change with the object. Unless you have placed this call inside of a\n `beginPropertyChanges()` and `endPropertyChanges(),` any \"local\" observers\n (i.e. observer methods declared on the same object), will be called\n immediately. Any \"remote\" observers (i.e. observer methods declared on\n another object) will be placed in a queue and called at a later time in a\n coalesced manner.\n\n ### Chaining\n\n In addition to property changes, `set()` returns the value of the object\n itself so you can do chaining like this:\n\n ```javascript\n record.set('firstName', 'Charles').set('lastName', 'Jolley');\n ```\n\n @method set\n @param {String} key The property to set\n @param {Object} value The value to set or `null`.\n @return {Ember.Observable}\n */\n set: function(keyName, value) {\n set(this, keyName, value);\n return this;\n },\n\n /**\n To set multiple properties at once, call `setProperties`\n with a Hash:\n\n ```javascript\n record.setProperties({ firstName: 'Charles', lastName: 'Jolley' });\n ```\n\n @method setProperties\n @param {Hash} hash the hash of keys and values to set\n @return {Ember.Observable}\n */\n setProperties: function(hash) {\n return Ember.setProperties(this, hash);\n },\n\n /**\n Begins a grouping of property changes.\n\n You can use this method to group property changes so that notifications\n will not be sent until the changes are finished. If you plan to make a\n large number of changes to an object at one time, you should call this\n method at the beginning of the changes to begin deferring change\n notifications. When you are done making changes, call\n `endPropertyChanges()` to deliver the deferred change notifications and end\n deferring.\n\n @method beginPropertyChanges\n @return {Ember.Observable}\n */\n beginPropertyChanges: function() {\n Ember.beginPropertyChanges();\n return this;\n },\n\n /**\n Ends a grouping of property changes.\n\n You can use this method to group property changes so that notifications\n will not be sent until the changes are finished. If you plan to make a\n large number of changes to an object at one time, you should call\n `beginPropertyChanges()` at the beginning of the changes to defer change\n notifications. When you are done making changes, call this method to\n deliver the deferred change notifications and end deferring.\n\n @method endPropertyChanges\n @return {Ember.Observable}\n */\n endPropertyChanges: function() {\n Ember.endPropertyChanges();\n return this;\n },\n\n /**\n Notify the observer system that a property is about to change.\n\n Sometimes you need to change a value directly or indirectly without\n actually calling `get()` or `set()` on it. In this case, you can use this\n method and `propertyDidChange()` instead. Calling these two methods\n together will notify all observers that the property has potentially\n changed value.\n\n Note that you must always call `propertyWillChange` and `propertyDidChange`\n as a pair. If you do not, it may get the property change groups out of\n order and cause notifications to be delivered more often than you would\n like.\n\n @method propertyWillChange\n @param {String} key The property key that is about to change.\n @return {Ember.Observable}\n */\n propertyWillChange: function(keyName){\n Ember.propertyWillChange(this, keyName);\n return this;\n },\n\n /**\n Notify the observer system that a property has just changed.\n\n Sometimes you need to change a value directly or indirectly without\n actually calling `get()` or `set()` on it. In this case, you can use this\n method and `propertyWillChange()` instead. Calling these two methods\n together will notify all observers that the property has potentially\n changed value.\n\n Note that you must always call `propertyWillChange` and `propertyDidChange`\n as a pair. If you do not, it may get the property change groups out of\n order and cause notifications to be delivered more often than you would\n like.\n\n @method propertyDidChange\n @param {String} keyName The property key that has just changed.\n @return {Ember.Observable}\n */\n propertyDidChange: function(keyName) {\n Ember.propertyDidChange(this, keyName);\n return this;\n },\n\n /**\n Convenience method to call `propertyWillChange` and `propertyDidChange` in\n succession.\n\n @method notifyPropertyChange\n @param {String} keyName The property key to be notified about.\n @return {Ember.Observable}\n */\n notifyPropertyChange: function(keyName) {\n this.propertyWillChange(keyName);\n this.propertyDidChange(keyName);\n return this;\n },\n\n addBeforeObserver: function(key, target, method) {\n Ember.addBeforeObserver(this, key, target, method);\n },\n\n /**\n Adds an observer on a property.\n\n This is the core method used to register an observer for a property.\n\n Once you call this method, anytime the key's value is set, your observer\n will be notified. Note that the observers are triggered anytime the\n value is set, regardless of whether it has actually changed. Your\n observer should be prepared to handle that.\n\n You can also pass an optional context parameter to this method. The\n context will be passed to your observer method whenever it is triggered.\n Note that if you add the same target/method pair on a key multiple times\n with different context parameters, your observer will only be called once\n with the last context you passed.\n\n ### Observer Methods\n\n Observer methods you pass should generally have the following signature if\n you do not pass a `context` parameter:\n\n ```javascript\n fooDidChange: function(sender, key, value, rev) { };\n ```\n\n The sender is the object that changed. The key is the property that\n changes. The value property is currently reserved and unused. The rev\n is the last property revision of the object when it changed, which you can\n use to detect if the key value has really changed or not.\n\n If you pass a `context` parameter, the context will be passed before the\n revision like so:\n\n ```javascript\n fooDidChange: function(sender, key, value, context, rev) { };\n ```\n\n Usually you will not need the value, context or revision parameters at\n the end. In this case, it is common to write observer methods that take\n only a sender and key value as parameters or, if you aren't interested in\n any of these values, to write an observer that has no parameters at all.\n\n @method addObserver\n @param {String} key The key to observer\n @param {Object} target The target object to invoke\n @param {String|Function} method The method to invoke.\n @return {Ember.Object} self\n */\n addObserver: function(key, target, method) {\n Ember.addObserver(this, key, target, method);\n },\n\n /**\n Remove an observer you have previously registered on this object. Pass\n the same key, target, and method you passed to `addObserver()` and your\n target will no longer receive notifications.\n\n @method removeObserver\n @param {String} key The key to observer\n @param {Object} target The target object to invoke\n @param {String|Function} method The method to invoke.\n @return {Ember.Observable} receiver\n */\n removeObserver: function(key, target, method) {\n Ember.removeObserver(this, key, target, method);\n },\n\n /**\n Returns `true` if the object currently has observers registered for a\n particular key. You can use this method to potentially defer performing\n an expensive action until someone begins observing a particular property\n on the object.\n\n @method hasObserverFor\n @param {String} key Key to check\n @return {Boolean}\n */\n hasObserverFor: function(key) {\n return Ember.hasListeners(this, key+':change');\n },\n\n /**\n @deprecated\n @method getPath\n @param {String} path The property path to retrieve\n @return {Object} The property value or undefined.\n */\n getPath: function(path) {\n Ember.deprecate(\"getPath is deprecated since get now supports paths\");\n return this.get(path);\n },\n\n /**\n @deprecated\n @method setPath\n @param {String} path The path to the property that will be set\n @param {Object} value The value to set or `null`.\n @return {Ember.Observable}\n */\n setPath: function(path, value) {\n Ember.deprecate(\"setPath is deprecated since set now supports paths\");\n return this.set(path, value);\n },\n\n /**\n Retrieves the value of a property, or a default value in the case that the\n property returns `undefined`.\n\n ```javascript\n person.getWithDefault('lastName', 'Doe');\n ```\n\n @method getWithDefault\n @param {String} keyName The name of the property to retrieve\n @param {Object} defaultValue The value to return if the property value is undefined\n @return {Object} The property value or the defaultValue.\n */\n getWithDefault: function(keyName, defaultValue) {\n return Ember.getWithDefault(this, keyName, defaultValue);\n },\n\n /**\n Set the value of a property to the current value plus some amount.\n\n ```javascript\n person.incrementProperty('age');\n team.incrementProperty('score', 2);\n ```\n\n @method incrementProperty\n @param {String} keyName The name of the property to increment\n @param {Object} increment The amount to increment by. Defaults to 1\n @return {Object} The new property value\n */\n incrementProperty: function(keyName, increment) {\n if (!increment) { increment = 1; }\n set(this, keyName, (get(this, keyName) || 0)+increment);\n return get(this, keyName);\n },\n\n /**\n Set the value of a property to the current value minus some amount.\n\n ```javascript\n player.decrementProperty('lives');\n orc.decrementProperty('health', 5);\n ```\n\n @method decrementProperty\n @param {String} keyName The name of the property to decrement\n @param {Object} increment The amount to decrement by. Defaults to 1\n @return {Object} The new property value\n */\n decrementProperty: function(keyName, increment) {\n if (!increment) { increment = 1; }\n set(this, keyName, (get(this, keyName) || 0)-increment);\n return get(this, keyName);\n },\n\n /**\n Set the value of a boolean property to the opposite of it's\n current value.\n\n ```javascript\n starship.toggleProperty('warpDriveEnaged');\n ```\n\n @method toggleProperty\n @param {String} keyName The name of the property to toggle\n @return {Object} The new property value\n */\n toggleProperty: function(keyName) {\n set(this, keyName, !get(this, keyName));\n return get(this, keyName);\n },\n\n /**\n Returns the cached value of a computed property, if it exists.\n This allows you to inspect the value of a computed property\n without accidentally invoking it if it is intended to be\n generated lazily.\n\n @method cacheFor\n @param {String} keyName\n @return {Object} The cached value of the computed property, if any\n */\n cacheFor: function(keyName) {\n return Ember.cacheFor(this, keyName);\n },\n\n // intended for debugging purposes\n observersForKey: function(keyName) {\n return Ember.observersFor(this, keyName);\n }\n});\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n@class TargetActionSupport\n@namespace Ember\n@extends Ember.Mixin\n*/\nEmber.TargetActionSupport = Ember.Mixin.create({\n target: null,\n action: null,\n\n targetObject: Ember.computed(function() {\n var target = get(this, 'target');\n\n if (Ember.typeOf(target) === \"string\") {\n var value = get(this, target);\n if (value === undefined) { value = get(Ember.lookup, target); }\n return value;\n } else {\n return target;\n }\n }).property('target'),\n\n triggerAction: function() {\n var action = get(this, 'action'),\n target = get(this, 'targetObject');\n\n if (target && action) {\n var ret;\n\n if (typeof target.send === 'function') {\n ret = target.send(action, this);\n } else {\n if (typeof action === 'string') {\n action = target[action];\n }\n ret = action.call(target, this);\n }\n if (ret !== false) ret = true;\n\n return ret;\n } else {\n return false;\n }\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n/**\n This mixin allows for Ember objects to subscribe to and emit events.\n\n ```javascript\n App.Person = Ember.Object.extend(Ember.Evented, {\n greet: function() {\n // ...\n this.trigger('greet');\n }\n });\n\n var person = App.Person.create();\n\n person.on('greet', function() {\n console.log('Our person has greeted');\n });\n\n person.greet();\n\n // outputs: 'Our person has greeted'\n ```\n\n @class Evented\n @namespace Ember\n @extends Ember.Mixin\n */\nEmber.Evented = Ember.Mixin.create({\n\n /**\n Subscribes to a named event with given function.\n\n ```javascript\n person.on('didLoad', function() {\n // fired once the person has loaded\n });\n ```\n\n An optional target can be passed in as the 2nd argument that will\n be set as the \"this\" for the callback. This is a good way to give your\n function access to the object triggering the event. When the target\n parameter is used the callback becomes the third argument.\n\n @method on\n @param {String} name The name of the event\n @param {Object} [target] The \"this\" binding for the callback\n @param {Function} method The callback to execute\n */\n on: function(name, target, method) {\n Ember.addListener(this, name, target, method);\n },\n\n /**\n Subscribes a function to a named event and then cancels the subscription\n after the first time the event is triggered. It is good to use ``one`` when\n you only care about the first time an event has taken place.\n\n This function takes an optional 2nd argument that will become the \"this\"\n value for the callback. If this argument is passed then the 3rd argument\n becomes the function.\n\n @method one\n @param {String} name The name of the event\n @param {Object} [target] The \"this\" binding for the callback\n @param {Function} method The callback to execute\n */\n one: function(name, target, method) {\n if (!method) {\n method = target;\n target = null;\n }\n\n Ember.addListener(this, name, target, method, true);\n },\n\n /**\n Triggers a named event for the object. Any additional arguments\n will be passed as parameters to the functions that are subscribed to the\n event.\n\n ```javascript\n person.on('didEat', food) {\n console.log('person ate some ' + food);\n });\n\n person.trigger('didEat', 'broccoli');\n\n // outputs: person ate some broccoli\n ```\n @method trigger\n @param {String} name The name of the event\n @param {Object...} args Optional arguments to pass on\n */\n trigger: function(name) {\n var args = [], i, l;\n for (i = 1, l = arguments.length; i < l; i++) {\n args.push(arguments[i]);\n }\n Ember.sendEvent(this, name, args);\n },\n\n fire: function(name) {\n Ember.deprecate(\"Ember.Evented#fire() has been deprecated in favor of trigger() for compatibility with jQuery. It will be removed in 1.0. Please update your code to call trigger() instead.\");\n this.trigger.apply(this, arguments);\n },\n\n /**\n Cancels subscription for give name, target, and method.\n\n @method off\n @param {String} name The name of the event\n @param {Object} target The target of the subscription\n @param {Function} method The function of the subscription\n */\n off: function(name, target, method) {\n Ember.removeListener(this, name, target, method);\n },\n\n /**\n Checks to see if object has any subscriptions for named event.\n\n @method has\n @param {String} name The name of the event\n @return {Boolean} does the object have a subscription for event\n */\n has: function(name) {\n return Ember.hasListeners(this, name);\n }\n});\n\n})();\n\n\n\n(function() {\nvar RSVP = requireModule(\"rsvp\");\n\nRSVP.async = function(callback, binding) {\n Ember.run.schedule('actions', binding, callback);\n};\n\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get,\n slice = Array.prototype.slice;\n\n/**\n @class Deferred\n @namespace Ember\n @extends Ember.Mixin\n */\nEmber.DeferredMixin = Ember.Mixin.create({\n /**\n Add handlers to be called when the Deferred object is resolved or rejected.\n\n @method then\n @param {Function} doneCallback a callback function to be called when done\n @param {Function} failCallback a callback function to be called when failed\n */\n then: function(doneCallback, failCallback) {\n var promise = get(this, 'promise');\n promise.then.apply(promise, arguments);\n },\n\n /**\n Resolve a Deferred object and call any `doneCallbacks` with the given args.\n\n @method resolve\n */\n resolve: function(value) {\n get(this, 'promise').resolve(value);\n },\n\n /**\n Reject a Deferred object and call any `failCallbacks` with the given args.\n\n @method reject\n */\n reject: function(value) {\n get(this, 'promise').reject(value);\n },\n\n promise: Ember.computed(function() {\n return new RSVP.Promise();\n })\n});\n\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\n// NOTE: this object should never be included directly. Instead use Ember.\n// Ember.Object. We only define this separately so that Ember.Set can depend on it\n\n\nvar set = Ember.set, get = Ember.get,\n o_create = Ember.create,\n o_defineProperty = Ember.platform.defineProperty,\n a_slice = Array.prototype.slice,\n GUID_KEY = Ember.GUID_KEY,\n guidFor = Ember.guidFor,\n generateGuid = Ember.generateGuid,\n meta = Ember.meta,\n rewatch = Ember.rewatch,\n finishChains = Ember.finishChains,\n destroy = Ember.destroy,\n schedule = Ember.run.schedule,\n Mixin = Ember.Mixin,\n applyMixin = Mixin._apply,\n finishPartial = Mixin.finishPartial,\n reopen = Mixin.prototype.reopen,\n classToString = Mixin.prototype.toString,\n MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER,\n indexOf = Ember.EnumerableUtils.indexOf;\n\nvar undefinedDescriptor = {\n configurable: true,\n writable: true,\n enumerable: false,\n value: undefined\n};\n\nfunction makeCtor() {\n\n // Note: avoid accessing any properties on the object since it makes the\n // method a lot faster. This is glue code so we want it to be as fast as\n // possible.\n\n var wasApplied = false, initMixins, initProperties;\n\n var Class = function() {\n if (!wasApplied) {\n Class.proto(); // prepare prototype...\n }\n o_defineProperty(this, GUID_KEY, undefinedDescriptor);\n o_defineProperty(this, '_super', undefinedDescriptor);\n var m = meta(this);\n m.proto = this;\n if (initMixins) {\n // capture locally so we can clear the closed over variable\n var mixins = initMixins;\n initMixins = null;\n this.reopen.apply(this, mixins);\n }\n if (initProperties) {\n // capture locally so we can clear the closed over variable\n var props = initProperties;\n initProperties = null;\n\n var concatenatedProperties = this.concatenatedProperties;\n\n for (var i = 0, l = props.length; i < l; i++) {\n var properties = props[i];\n for (var keyName in properties) {\n if (!properties.hasOwnProperty(keyName)) { continue; }\n\n var value = properties[keyName],\n IS_BINDING = Ember.IS_BINDING;\n\n if (IS_BINDING.test(keyName)) {\n var bindings = m.bindings;\n if (!bindings) {\n bindings = m.bindings = {};\n } else if (!m.hasOwnProperty('bindings')) {\n bindings = m.bindings = o_create(m.bindings);\n }\n bindings[keyName] = value;\n }\n\n var desc = m.descs[keyName];\n\n Ember.assert(\"Ember.Object.create no longer supports defining computed properties.\", !(value instanceof Ember.ComputedProperty));\n Ember.assert(\"Ember.Object.create no longer supports defining methods that call _super.\", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));\n\n if (concatenatedProperties && indexOf(concatenatedProperties, keyName) >= 0) {\n var baseValue = this[keyName];\n\n if (baseValue) {\n if ('function' === typeof baseValue.concat) {\n value = baseValue.concat(value);\n } else {\n value = Ember.makeArray(baseValue).concat(value);\n }\n } else {\n value = Ember.makeArray(value);\n }\n }\n\n if (desc) {\n desc.set(this, keyName, value);\n } else {\n if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {\n this.setUnknownProperty(keyName, value);\n } else if (MANDATORY_SETTER) {\n Ember.defineProperty(this, keyName, null, value); // setup mandatory setter\n } else {\n this[keyName] = value;\n }\n }\n }\n }\n }\n finishPartial(this, m);\n delete m.proto;\n finishChains(this);\n this.init.apply(this, arguments);\n };\n\n Class.toString = classToString;\n Class.willReopen = function() {\n if (wasApplied) {\n Class.PrototypeMixin = Mixin.create(Class.PrototypeMixin);\n }\n\n wasApplied = false;\n };\n Class._initMixins = function(args) { initMixins = args; };\n Class._initProperties = function(args) { initProperties = args; };\n\n Class.proto = function() {\n var superclass = Class.superclass;\n if (superclass) { superclass.proto(); }\n\n if (!wasApplied) {\n wasApplied = true;\n Class.PrototypeMixin.applyPartial(Class.prototype);\n rewatch(Class.prototype);\n }\n\n return this.prototype;\n };\n\n return Class;\n\n}\n\nvar CoreObject = makeCtor();\n\nCoreObject.PrototypeMixin = Mixin.create({\n\n reopen: function() {\n applyMixin(this, arguments, true);\n return this;\n },\n\n isInstance: true,\n\n init: function() {},\n\n /**\n @property isDestroyed\n @default false\n */\n isDestroyed: false,\n\n /**\n @property isDestroying\n @default false\n */\n isDestroying: false,\n\n /**\n Destroys an object by setting the `isDestroyed` flag and removing its\n metadata, which effectively destroys observers and bindings.\n\n If you try to set a property on a destroyed object, an exception will be\n raised.\n\n Note that destruction is scheduled for the end of the run loop and does not\n happen immediately.\n\n @method destroy\n @return {Ember.Object} receiver\n */\n destroy: function() {\n if (this.isDestroying) { return; }\n\n this.isDestroying = true;\n\n if (this.willDestroy) { this.willDestroy(); }\n\n schedule('destroy', this, this._scheduledDestroy);\n return this;\n },\n\n /**\n @private\n\n Invoked by the run loop to actually destroy the object. This is\n scheduled for execution by the `destroy` method.\n\n @method _scheduledDestroy\n */\n _scheduledDestroy: function() {\n destroy(this);\n set(this, 'isDestroyed', true);\n\n if (this.didDestroy) { this.didDestroy(); }\n },\n\n bind: function(to, from) {\n if (!(from instanceof Ember.Binding)) { from = Ember.Binding.from(from); }\n from.to(to).connect(this);\n return from;\n },\n\n /**\n Returns a string representation which attempts to provide more information\n than Javascript's `toString` typically does, in a generic way for all Ember\n objects.\n\n App.Person = Em.Object.extend()\n person = App.Person.create()\n person.toString() //=> \"<App.Person:ember1024>\"\n\n If the object's class is not defined on an Ember namespace, it will\n indicate it is a subclass of the registered superclass:\n\n Student = App.Person.extend()\n student = Student.create()\n student.toString() //=> \"<(subclass of App.Person):ember1025>\"\n\n If the method `toStringExtension` is defined, its return value will be\n included in the output.\n\n App.Teacher = App.Person.extend({\n toStringExtension: function(){\n return this.get('fullName');\n }\n });\n teacher = App.Teacher.create()\n teacher.toString(); // #=> \"<App.Teacher:ember1026:Tom Dale>\"\n\n @method toString\n @return {String} string representation\n */\n toString: function toString() {\n var hasToStringExtension = typeof this.toStringExtension === 'function',\n extension = hasToStringExtension ? \":\" + this.toStringExtension() : '';\n var ret = '<'+this.constructor.toString()+':'+guidFor(this)+extension+'>';\n this.toString = makeToString(ret);\n return ret;\n }\n});\n\nfunction makeToString(ret) {\n return function() { return ret; };\n}\n\nif (Ember.config.overridePrototypeMixin) {\n Ember.config.overridePrototypeMixin(CoreObject.PrototypeMixin);\n}\n\nCoreObject.__super__ = null;\n\nvar ClassMixin = Mixin.create({\n\n ClassMixin: Ember.required(),\n\n PrototypeMixin: Ember.required(),\n\n isClass: true,\n\n isMethod: false,\n\n extend: function() {\n var Class = makeCtor(), proto;\n Class.ClassMixin = Mixin.create(this.ClassMixin);\n Class.PrototypeMixin = Mixin.create(this.PrototypeMixin);\n\n Class.ClassMixin.ownerConstructor = Class;\n Class.PrototypeMixin.ownerConstructor = Class;\n\n reopen.apply(Class.PrototypeMixin, arguments);\n\n Class.superclass = this;\n Class.__super__ = this.prototype;\n\n proto = Class.prototype = o_create(this.prototype);\n proto.constructor = Class;\n generateGuid(proto, 'ember');\n meta(proto).proto = proto; // this will disable observers on prototype\n\n Class.ClassMixin.apply(Class);\n return Class;\n },\n\n createWithMixins: function() {\n var C = this;\n if (arguments.length>0) { this._initMixins(arguments); }\n return new C();\n },\n\n create: function() {\n var C = this;\n if (arguments.length>0) { this._initProperties(arguments); }\n return new C();\n },\n\n reopen: function() {\n this.willReopen();\n reopen.apply(this.PrototypeMixin, arguments);\n return this;\n },\n\n reopenClass: function() {\n reopen.apply(this.ClassMixin, arguments);\n applyMixin(this, arguments, false);\n return this;\n },\n\n detect: function(obj) {\n if ('function' !== typeof obj) { return false; }\n while(obj) {\n if (obj===this) { return true; }\n obj = obj.superclass;\n }\n return false;\n },\n\n detectInstance: function(obj) {\n return obj instanceof this;\n },\n\n /**\n In some cases, you may want to annotate computed properties with additional\n metadata about how they function or what values they operate on. For\n example, computed property functions may close over variables that are then\n no longer available for introspection.\n\n You can pass a hash of these values to a computed property like this:\n\n ```javascript\n person: function() {\n var personId = this.get('personId');\n return App.Person.create({ id: personId });\n }.property().meta({ type: App.Person })\n ```\n\n Once you've done this, you can retrieve the values saved to the computed\n property from your class like this:\n\n ```javascript\n MyClass.metaForProperty('person');\n ```\n\n This will return the original hash that was passed to `meta()`.\n\n @method metaForProperty\n @param key {String} property name\n */\n metaForProperty: function(key) {\n var desc = meta(this.proto(), false).descs[key];\n\n Ember.assert(\"metaForProperty() could not find a computed property with key '\"+key+\"'.\", !!desc && desc instanceof Ember.ComputedProperty);\n return desc._meta || {};\n },\n\n /**\n Iterate over each computed property for the class, passing its name\n and any associated metadata (see `metaForProperty`) to the callback.\n\n @method eachComputedProperty\n @param {Function} callback\n @param {Object} binding\n */\n eachComputedProperty: function(callback, binding) {\n var proto = this.proto(),\n descs = meta(proto).descs,\n empty = {},\n property;\n\n for (var name in descs) {\n property = descs[name];\n\n if (property instanceof Ember.ComputedProperty) {\n callback.call(binding || this, name, property._meta || empty);\n }\n }\n }\n\n});\n\nif (Ember.config.overrideClassMixin) {\n Ember.config.overrideClassMixin(ClassMixin);\n}\n\nCoreObject.ClassMixin = ClassMixin;\nClassMixin.apply(CoreObject);\n\n/**\n @class CoreObject\n @namespace Ember\n*/\nEmber.CoreObject = CoreObject;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, none = Ember.isNone;\n\n/**\n An unordered collection of objects.\n\n A Set works a bit like an array except that its items are not ordered. You\n can create a set to efficiently test for membership for an object. You can\n also iterate through a set just like an array, even accessing objects by\n index, however there is no guarantee as to their order.\n\n All Sets are observable via the Enumerable Observer API - which works\n on any enumerable object including both Sets and Arrays.\n\n ## Creating a Set\n\n You can create a set like you would most objects using\n `new Ember.Set()`. Most new sets you create will be empty, but you can\n also initialize the set with some content by passing an array or other\n enumerable of objects to the constructor.\n\n Finally, you can pass in an existing set and the set will be copied. You\n can also create a copy of a set by calling `Ember.Set#copy()`.\n\n ```javascript\n // creates a new empty set\n var foundNames = new Ember.Set();\n\n // creates a set with four names in it.\n var names = new Ember.Set([\"Charles\", \"Tom\", \"Juan\", \"Alex\"]); // :P\n\n // creates a copy of the names set.\n var namesCopy = new Ember.Set(names);\n\n // same as above.\n var anotherNamesCopy = names.copy();\n ```\n\n ## Adding/Removing Objects\n\n You generally add or remove objects from a set using `add()` or\n `remove()`. You can add any type of object including primitives such as\n numbers, strings, and booleans.\n\n Unlike arrays, objects can only exist one time in a set. If you call `add()`\n on a set with the same object multiple times, the object will only be added\n once. Likewise, calling `remove()` with the same object multiple times will\n remove the object the first time and have no effect on future calls until\n you add the object to the set again.\n\n NOTE: You cannot add/remove `null` or `undefined` to a set. Any attempt to do\n so will be ignored.\n\n In addition to add/remove you can also call `push()`/`pop()`. Push behaves\n just like `add()` but `pop()`, unlike `remove()` will pick an arbitrary\n object, remove it and return it. This is a good way to use a set as a job\n queue when you don't care which order the jobs are executed in.\n\n ## Testing for an Object\n\n To test for an object's presence in a set you simply call\n `Ember.Set#contains()`.\n\n ## Observing changes\n\n When using `Ember.Set`, you can observe the `\"[]\"` property to be\n alerted whenever the content changes. You can also add an enumerable\n observer to the set to be notified of specific objects that are added and\n removed from the set. See `Ember.Enumerable` for more information on\n enumerables.\n\n This is often unhelpful. If you are filtering sets of objects, for instance,\n it is very inefficient to re-filter all of the items each time the set\n changes. It would be better if you could just adjust the filtered set based\n on what was changed on the original set. The same issue applies to merging\n sets, as well.\n\n ## Other Methods\n\n `Ember.Set` primary implements other mixin APIs. For a complete reference\n on the methods you will use with `Ember.Set`, please consult these mixins.\n The most useful ones will be `Ember.Enumerable` and\n `Ember.MutableEnumerable` which implement most of the common iterator\n methods you are used to on Array.\n\n Note that you can also use the `Ember.Copyable` and `Ember.Freezable`\n APIs on `Ember.Set` as well. Once a set is frozen it can no longer be\n modified. The benefit of this is that when you call `frozenCopy()` on it,\n Ember will avoid making copies of the set. This allows you to write\n code that can know with certainty when the underlying set data will or\n will not be modified.\n\n @class Set\n @namespace Ember\n @extends Ember.CoreObject\n @uses Ember.MutableEnumerable\n @uses Ember.Copyable\n @uses Ember.Freezable\n @since Ember 0.9\n*/\nEmber.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Ember.Freezable,\n /** @scope Ember.Set.prototype */ {\n\n // ..........................................................\n // IMPLEMENT ENUMERABLE APIS\n //\n\n /**\n This property will change as the number of objects in the set changes.\n\n @property length\n @type number\n @default 0\n */\n length: 0,\n\n /**\n Clears the set. This is useful if you want to reuse an existing set\n without having to recreate it.\n\n ```javascript\n var colors = new Ember.Set([\"red\", \"green\", \"blue\"]);\n colors.length; // 3\n colors.clear();\n colors.length; // 0\n ```\n\n @method clear\n @return {Ember.Set} An empty Set\n */\n clear: function() {\n if (this.isFrozen) { throw new Error(Ember.FROZEN_ERROR); }\n\n var len = get(this, 'length');\n if (len === 0) { return this; }\n\n var guid;\n\n this.enumerableContentWillChange(len, 0);\n Ember.propertyWillChange(this, 'firstObject');\n Ember.propertyWillChange(this, 'lastObject');\n\n for (var i=0; i < len; i++){\n guid = guidFor(this[i]);\n delete this[guid];\n delete this[i];\n }\n\n set(this, 'length', 0);\n\n Ember.propertyDidChange(this, 'firstObject');\n Ember.propertyDidChange(this, 'lastObject');\n this.enumerableContentDidChange(len, 0);\n\n return this;\n },\n\n /**\n Returns true if the passed object is also an enumerable that contains the\n same objects as the receiver.\n\n ```javascript\n var colors = [\"red\", \"green\", \"blue\"],\n same_colors = new Ember.Set(colors);\n\n same_colors.isEqual(colors); // true\n same_colors.isEqual([\"purple\", \"brown\"]); // false\n ```\n\n @method isEqual\n @param {Ember.Set} obj the other object.\n @return {Boolean}\n */\n isEqual: function(obj) {\n // fail fast\n if (!Ember.Enumerable.detect(obj)) return false;\n\n var loc = get(this, 'length');\n if (get(obj, 'length') !== loc) return false;\n\n while(--loc >= 0) {\n if (!obj.contains(this[loc])) return false;\n }\n\n return true;\n },\n\n /**\n Adds an object to the set. Only non-`null` objects can be added to a set\n and those can only be added once. If the object is already in the set or\n the passed value is null this method will have no effect.\n\n This is an alias for `Ember.MutableEnumerable.addObject()`.\n\n ```javascript\n var colors = new Ember.Set();\n colors.add(\"blue\"); // [\"blue\"]\n colors.add(\"blue\"); // [\"blue\"]\n colors.add(\"red\"); // [\"blue\", \"red\"]\n colors.add(null); // [\"blue\", \"red\"]\n colors.add(undefined); // [\"blue\", \"red\"]\n ```\n\n @method add\n @param {Object} obj The object to add.\n @return {Ember.Set} The set itself.\n */\n add: Ember.alias('addObject'),\n\n /**\n Removes the object from the set if it is found. If you pass a `null` value\n or an object that is already not in the set, this method will have no\n effect. This is an alias for `Ember.MutableEnumerable.removeObject()`.\n\n ```javascript\n var colors = new Ember.Set([\"red\", \"green\", \"blue\"]);\n colors.remove(\"red\"); // [\"blue\", \"green\"]\n colors.remove(\"purple\"); // [\"blue\", \"green\"]\n colors.remove(null); // [\"blue\", \"green\"]\n ```\n\n @method remove\n @param {Object} obj The object to remove\n @return {Ember.Set} The set itself.\n */\n remove: Ember.alias('removeObject'),\n\n /**\n Removes the last element from the set and returns it, or `null` if it's empty.\n\n ```javascript\n var colors = new Ember.Set([\"green\", \"blue\"]);\n colors.pop(); // \"blue\"\n colors.pop(); // \"green\"\n colors.pop(); // null\n ```\n\n @method pop\n @return {Object} The removed object from the set or null.\n */\n pop: function() {\n if (get(this, 'isFrozen')) throw new Error(Ember.FROZEN_ERROR);\n var obj = this.length > 0 ? this[this.length-1] : null;\n this.remove(obj);\n return obj;\n },\n\n /**\n Inserts the given object on to the end of the set. It returns\n the set itself.\n\n This is an alias for `Ember.MutableEnumerable.addObject()`.\n\n ```javascript\n var colors = new Ember.Set();\n colors.push(\"red\"); // [\"red\"]\n colors.push(\"green\"); // [\"red\", \"green\"]\n colors.push(\"blue\"); // [\"red\", \"green\", \"blue\"]\n ```\n\n @method push\n @return {Ember.Set} The set itself.\n */\n push: Ember.alias('addObject'),\n\n /**\n Removes the last element from the set and returns it, or `null` if it's empty.\n\n This is an alias for `Ember.Set.pop()`.\n\n ```javascript\n var colors = new Ember.Set([\"green\", \"blue\"]);\n colors.shift(); // \"blue\"\n colors.shift(); // \"green\"\n colors.shift(); // null\n ```\n\n @method shift\n @return {Object} The removed object from the set or null.\n */\n shift: Ember.alias('pop'),\n\n /**\n Inserts the given object on to the end of the set. It returns\n the set itself.\n\n This is an alias of `Ember.Set.push()`\n\n ```javascript\n var colors = new Ember.Set();\n colors.unshift(\"red\"); // [\"red\"]\n colors.unshift(\"green\"); // [\"red\", \"green\"]\n colors.unshift(\"blue\"); // [\"red\", \"green\", \"blue\"]\n ```\n\n @method unshift\n @return {Ember.Set} The set itself.\n */\n unshift: Ember.alias('push'),\n\n /**\n Adds each object in the passed enumerable to the set.\n\n This is an alias of `Ember.MutableEnumerable.addObjects()`\n\n var colors = new Ember.Set();\n colors.addEach([\"red\", \"green\", \"blue\"]); // [\"red\", \"green\", \"blue\"]\n\n @method addEach\n @param {Ember.Enumerable} objects the objects to add.\n @return {Ember.Set} The set itself.\n */\n addEach: Ember.alias('addObjects'),\n\n /**\n Removes each object in the passed enumerable to the set.\n\n This is an alias of `Ember.MutableEnumerable.removeObjects()`\n\n ```javascript\n var colors = new Ember.Set([\"red\", \"green\", \"blue\"]);\n colors.removeEach([\"red\", \"blue\"]); // [\"green\"]\n ```\n\n @method removeEach\n @param {Ember.Enumerable} objects the objects to remove.\n @return {Ember.Set} The set itself.\n */\n removeEach: Ember.alias('removeObjects'),\n\n // ..........................................................\n // PRIVATE ENUMERABLE SUPPORT\n //\n\n init: function(items) {\n this._super();\n if (items) this.addObjects(items);\n },\n\n // implement Ember.Enumerable\n nextObject: function(idx) {\n return this[idx];\n },\n\n // more optimized version\n firstObject: Ember.computed(function() {\n return this.length > 0 ? this[0] : undefined;\n }).property(),\n\n // more optimized version\n lastObject: Ember.computed(function() {\n return this.length > 0 ? this[this.length-1] : undefined;\n }).property(),\n\n // implements Ember.MutableEnumerable\n addObject: function(obj) {\n if (get(this, 'isFrozen')) throw new Error(Ember.FROZEN_ERROR);\n if (none(obj)) return this; // nothing to do\n\n var guid = guidFor(obj),\n idx = this[guid],\n len = get(this, 'length'),\n added ;\n\n if (idx>=0 && idx<len && (this[idx] === obj)) return this; // added\n\n added = [obj];\n\n this.enumerableContentWillChange(null, added);\n Ember.propertyWillChange(this, 'lastObject');\n\n len = get(this, 'length');\n this[guid] = len;\n this[len] = obj;\n set(this, 'length', len+1);\n\n Ember.propertyDidChange(this, 'lastObject');\n this.enumerableContentDidChange(null, added);\n\n return this;\n },\n\n // implements Ember.MutableEnumerable\n removeObject: function(obj) {\n if (get(this, 'isFrozen')) throw new Error(Ember.FROZEN_ERROR);\n if (none(obj)) return this; // nothing to do\n\n var guid = guidFor(obj),\n idx = this[guid],\n len = get(this, 'length'),\n isFirst = idx === 0,\n isLast = idx === len-1,\n last, removed;\n\n\n if (idx>=0 && idx<len && (this[idx] === obj)) {\n removed = [obj];\n\n this.enumerableContentWillChange(removed, null);\n if (isFirst) { Ember.propertyWillChange(this, 'firstObject'); }\n if (isLast) { Ember.propertyWillChange(this, 'lastObject'); }\n\n // swap items - basically move the item to the end so it can be removed\n if (idx < len-1) {\n last = this[len-1];\n this[idx] = last;\n this[guidFor(last)] = idx;\n }\n\n delete this[guid];\n delete this[len-1];\n set(this, 'length', len-1);\n\n if (isFirst) { Ember.propertyDidChange(this, 'firstObject'); }\n if (isLast) { Ember.propertyDidChange(this, 'lastObject'); }\n this.enumerableContentDidChange(removed, null);\n }\n\n return this;\n },\n\n // optimized version\n contains: function(obj) {\n return this[guidFor(obj)]>=0;\n },\n\n copy: function() {\n var C = this.constructor, ret = new C(), loc = get(this, 'length');\n set(ret, 'length', loc);\n while(--loc>=0) {\n ret[loc] = this[loc];\n ret[guidFor(this[loc])] = loc;\n }\n return ret;\n },\n\n toString: function() {\n var len = this.length, idx, array = [];\n for(idx = 0; idx < len; idx++) {\n array[idx] = this[idx];\n }\n return \"Ember.Set<%@>\".fmt(array.join(','));\n }\n\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n/**\n `Ember.Object` is the main base class for all Ember objects. It is a subclass\n of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details,\n see the documentation for each of these.\n\n @class Object\n @namespace Ember\n @extends Ember.CoreObject\n @uses Ember.Observable\n*/\nEmber.Object = Ember.CoreObject.extend(Ember.Observable);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, indexOf = Ember.ArrayPolyfills.indexOf;\n\n/**\n A Namespace is an object usually used to contain other objects or methods\n such as an application or framework. Create a namespace anytime you want\n to define one of these new containers.\n\n # Example Usage\n\n ```javascript\n MyFramework = Ember.Namespace.create({\n VERSION: '1.0.0'\n });\n ```\n\n @class Namespace\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.Namespace = Ember.Object.extend({\n isNamespace: true,\n\n init: function() {\n Ember.Namespace.NAMESPACES.push(this);\n Ember.Namespace.PROCESSED = false;\n },\n\n toString: function() {\n var name = get(this, 'name');\n if (name) { return name; }\n\n Ember.identifyNamespaces();\n return this[Ember.GUID_KEY+'_name'];\n },\n\n destroy: function() {\n var namespaces = Ember.Namespace.NAMESPACES;\n Ember.lookup[this.toString()] = undefined;\n namespaces.splice(indexOf.call(namespaces, this), 1);\n this._super();\n }\n});\n\nEmber.Namespace.NAMESPACES = [Ember];\nEmber.Namespace.PROCESSED = false;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n/**\n Defines a namespace that will contain an executable application. This is\n very similar to a normal namespace except that it is expected to include at\n least a 'ready' function which can be run to initialize the application.\n\n Currently `Ember.Application` is very similar to `Ember.Namespace.` However,\n this class may be augmented by additional frameworks so it is important to\n use this instance when building new applications.\n\n # Example Usage\n\n ```javascript\n MyApp = Ember.Application.create({\n VERSION: '1.0.0',\n store: Ember.Store.create().from(Ember.fixtures)\n });\n\n MyApp.ready = function() {\n //..init code goes here...\n }\n ```\n\n @class Application\n @namespace Ember\n @extends Ember.Namespace\n*/\nEmber.Application = Ember.Namespace.extend();\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n An ArrayProxy wraps any other object that implements `Ember.Array` and/or\n `Ember.MutableArray,` forwarding all requests. This makes it very useful for\n a number of binding use cases or other cases where being able to swap\n out the underlying array is useful.\n\n A simple example of usage:\n\n ```javascript\n var pets = ['dog', 'cat', 'fish'];\n var ap = Ember.ArrayProxy.create({ content: Ember.A(pets) });\n\n ap.get('firstObject'); // 'dog'\n ap.set('content', ['amoeba', 'paramecium']);\n ap.get('firstObject'); // 'amoeba'\n ```\n\n This class can also be useful as a layer to transform the contents of\n an array, as they are accessed. This can be done by overriding\n `objectAtContent`:\n\n ```javascript\n var pets = ['dog', 'cat', 'fish'];\n var ap = Ember.ArrayProxy.create({\n content: Ember.A(pets),\n objectAtContent: function(idx) {\n return this.get('content').objectAt(idx).toUpperCase();\n }\n });\n\n ap.get('firstObject'); // . 'DOG'\n ```\n\n @class ArrayProxy\n @namespace Ember\n @extends Ember.Object\n @uses Ember.MutableArray\n*/\nEmber.ArrayProxy = Ember.Object.extend(Ember.MutableArray,\n/** @scope Ember.ArrayProxy.prototype */ {\n\n /**\n The content array. Must be an object that implements `Ember.Array` and/or\n `Ember.MutableArray.`\n\n @property content\n @type Ember.Array\n */\n content: null,\n\n /**\n The array that the proxy pretends to be. In the default `ArrayProxy`\n implementation, this and `content` are the same. Subclasses of `ArrayProxy`\n can override this property to provide things like sorting and filtering.\n\n @property arrangedContent\n */\n arrangedContent: Ember.computed('content', function() {\n return get(this, 'content');\n }),\n\n /**\n Should actually retrieve the object at the specified index from the\n content. You can override this method in subclasses to transform the\n content item to something new.\n\n This method will only be called if content is non-`null`.\n\n @method objectAtContent\n @param {Number} idx The index to retrieve.\n @return {Object} the value or undefined if none found\n */\n objectAtContent: function(idx) {\n return get(this, 'arrangedContent').objectAt(idx);\n },\n\n /**\n Should actually replace the specified objects on the content array.\n You can override this method in subclasses to transform the content item\n into something new.\n\n This method will only be called if content is non-`null`.\n\n @method replaceContent\n @param {Number} idx The starting index\n @param {Number} amt The number of items to remove from the content.\n @param {Array} objects Optional array of objects to insert or null if no\n objects.\n @return {void}\n */\n replaceContent: function(idx, amt, objects) {\n get(this, 'content').replace(idx, amt, objects);\n },\n\n /**\n @private\n\n Invoked when the content property is about to change. Notifies observers that the\n entire array content will change.\n\n @method _contentWillChange\n */\n _contentWillChange: Ember.beforeObserver(function() {\n this._teardownContent();\n }, 'content'),\n\n _teardownContent: function() {\n var content = get(this, 'content');\n\n if (content) {\n content.removeArrayObserver(this, {\n willChange: 'contentArrayWillChange',\n didChange: 'contentArrayDidChange'\n });\n }\n },\n\n contentArrayWillChange: Ember.K,\n contentArrayDidChange: Ember.K,\n\n /**\n @private\n\n Invoked when the content property changes. Notifies observers that the\n entire array content has changed.\n\n @method _contentDidChange\n */\n _contentDidChange: Ember.observer(function() {\n var content = get(this, 'content');\n\n Ember.assert(\"Can't set ArrayProxy's content to itself\", content !== this);\n\n this._setupContent();\n }, 'content'),\n\n _setupContent: function() {\n var content = get(this, 'content');\n\n if (content) {\n content.addArrayObserver(this, {\n willChange: 'contentArrayWillChange',\n didChange: 'contentArrayDidChange'\n });\n }\n },\n\n _arrangedContentWillChange: Ember.beforeObserver(function() {\n var arrangedContent = get(this, 'arrangedContent'),\n len = arrangedContent ? get(arrangedContent, 'length') : 0;\n\n this.arrangedContentArrayWillChange(this, 0, len, undefined);\n this.arrangedContentWillChange(this);\n\n this._teardownArrangedContent(arrangedContent);\n }, 'arrangedContent'),\n\n _arrangedContentDidChange: Ember.observer(function() {\n var arrangedContent = get(this, 'arrangedContent'),\n len = arrangedContent ? get(arrangedContent, 'length') : 0;\n\n Ember.assert(\"Can't set ArrayProxy's content to itself\", arrangedContent !== this);\n\n this._setupArrangedContent();\n\n this.arrangedContentDidChange(this);\n this.arrangedContentArrayDidChange(this, 0, undefined, len);\n }, 'arrangedContent'),\n\n _setupArrangedContent: function() {\n var arrangedContent = get(this, 'arrangedContent');\n\n if (arrangedContent) {\n arrangedContent.addArrayObserver(this, {\n willChange: 'arrangedContentArrayWillChange',\n didChange: 'arrangedContentArrayDidChange'\n });\n }\n },\n\n _teardownArrangedContent: function() {\n var arrangedContent = get(this, 'arrangedContent');\n\n if (arrangedContent) {\n arrangedContent.removeArrayObserver(this, {\n willChange: 'arrangedContentArrayWillChange',\n didChange: 'arrangedContentArrayDidChange'\n });\n }\n },\n\n arrangedContentWillChange: Ember.K,\n arrangedContentDidChange: Ember.K,\n\n objectAt: function(idx) {\n return get(this, 'content') && this.objectAtContent(idx);\n },\n\n length: Ember.computed(function() {\n var arrangedContent = get(this, 'arrangedContent');\n return arrangedContent ? get(arrangedContent, 'length') : 0;\n // No dependencies since Enumerable notifies length of change\n }).property(),\n\n replace: function(idx, amt, objects) {\n Ember.assert('The content property of '+ this.constructor + ' should be set before modifying it', this.get('content'));\n if (get(this, 'content')) this.replaceContent(idx, amt, objects);\n return this;\n },\n\n arrangedContentArrayWillChange: function(item, idx, removedCnt, addedCnt) {\n this.arrayContentWillChange(idx, removedCnt, addedCnt);\n },\n\n arrangedContentArrayDidChange: function(item, idx, removedCnt, addedCnt) {\n this.arrayContentDidChange(idx, removedCnt, addedCnt);\n },\n\n init: function() {\n this._super();\n this._setupContent();\n this._setupArrangedContent();\n },\n\n willDestroy: function() {\n this._teardownArrangedContent();\n this._teardownContent();\n }\n});\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get,\n set = Ember.set,\n fmt = Ember.String.fmt,\n addBeforeObserver = Ember.addBeforeObserver,\n addObserver = Ember.addObserver,\n removeBeforeObserver = Ember.removeBeforeObserver,\n removeObserver = Ember.removeObserver,\n propertyWillChange = Ember.propertyWillChange,\n propertyDidChange = Ember.propertyDidChange;\n\nfunction contentPropertyWillChange(content, contentKey) {\n var key = contentKey.slice(8); // remove \"content.\"\n if (key in this) { return; } // if shadowed in proxy\n propertyWillChange(this, key);\n}\n\nfunction contentPropertyDidChange(content, contentKey) {\n var key = contentKey.slice(8); // remove \"content.\"\n if (key in this) { return; } // if shadowed in proxy\n propertyDidChange(this, key);\n}\n\n/**\n `Ember.ObjectProxy` forwards all properties not defined by the proxy itself\n to a proxied `content` object.\n\n ```javascript\n object = Ember.Object.create({\n name: 'Foo'\n });\n\n proxy = Ember.ObjectProxy.create({\n content: object\n });\n\n // Access and change existing properties\n proxy.get('name') // 'Foo'\n proxy.set('name', 'Bar');\n object.get('name') // 'Bar'\n\n // Create new 'description' property on `object`\n proxy.set('description', 'Foo is a whizboo baz');\n object.get('description') // 'Foo is a whizboo baz'\n ```\n\n While `content` is unset, setting a property to be delegated will throw an\n Error.\n\n ```javascript\n proxy = Ember.ObjectProxy.create({\n content: null,\n flag: null\n });\n proxy.set('flag', true);\n proxy.get('flag'); // true\n proxy.get('foo'); // undefined\n proxy.set('foo', 'data'); // throws Error\n ```\n\n Delegated properties can be bound to and will change when content is updated.\n\n Computed properties on the proxy itself can depend on delegated properties.\n\n ```javascript\n ProxyWithComputedProperty = Ember.ObjectProxy.extend({\n fullName: function () {\n var firstName = this.get('firstName'),\n lastName = this.get('lastName');\n if (firstName && lastName) {\n return firstName + ' ' + lastName;\n }\n return firstName || lastName;\n }.property('firstName', 'lastName')\n });\n\n proxy = ProxyWithComputedProperty.create();\n\n proxy.get('fullName'); // undefined\n proxy.set('content', {\n firstName: 'Tom', lastName: 'Dale'\n }); // triggers property change for fullName on proxy\n\n proxy.get('fullName'); // 'Tom Dale'\n ```\n\n @class ObjectProxy\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.ObjectProxy = Ember.Object.extend(\n/** @scope Ember.ObjectProxy.prototype */ {\n /**\n The object whose properties will be forwarded.\n\n @property content\n @type Ember.Object\n @default null\n */\n content: null,\n _contentDidChange: Ember.observer(function() {\n Ember.assert(\"Can't set ObjectProxy's content to itself\", this.get('content') !== this);\n }, 'content'),\n\n willWatchProperty: function (key) {\n var contentKey = 'content.' + key;\n addBeforeObserver(this, contentKey, null, contentPropertyWillChange);\n addObserver(this, contentKey, null, contentPropertyDidChange);\n },\n\n didUnwatchProperty: function (key) {\n var contentKey = 'content.' + key;\n removeBeforeObserver(this, contentKey, null, contentPropertyWillChange);\n removeObserver(this, contentKey, null, contentPropertyDidChange);\n },\n\n unknownProperty: function (key) {\n var content = get(this, 'content');\n if (content) {\n return get(content, key);\n }\n },\n\n setUnknownProperty: function (key, value) {\n var content = get(this, 'content');\n Ember.assert(fmt(\"Cannot delegate set('%@', %@) to the 'content' property of object proxy %@: its 'content' is undefined.\", [key, value, this]), content);\n return set(content, key, value);\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\nvar set = Ember.set, get = Ember.get, guidFor = Ember.guidFor;\nvar forEach = Ember.EnumerableUtils.forEach;\n\nvar EachArray = Ember.Object.extend(Ember.Array, {\n\n init: function(content, keyName, owner) {\n this._super();\n this._keyName = keyName;\n this._owner = owner;\n this._content = content;\n },\n\n objectAt: function(idx) {\n var item = this._content.objectAt(idx);\n return item && get(item, this._keyName);\n },\n\n length: Ember.computed(function() {\n var content = this._content;\n return content ? get(content, 'length') : 0;\n }).property()\n\n});\n\nvar IS_OBSERVER = /^.+:(before|change)$/;\n\nfunction addObserverForContentKey(content, keyName, proxy, idx, loc) {\n var objects = proxy._objects, guid;\n if (!objects) objects = proxy._objects = {};\n\n while(--loc>=idx) {\n var item = content.objectAt(loc);\n if (item) {\n Ember.addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');\n Ember.addObserver(item, keyName, proxy, 'contentKeyDidChange');\n\n // keep track of the indicies each item was found at so we can map\n // it back when the obj changes.\n guid = guidFor(item);\n if (!objects[guid]) objects[guid] = [];\n objects[guid].push(loc);\n }\n }\n}\n\nfunction removeObserverForContentKey(content, keyName, proxy, idx, loc) {\n var objects = proxy._objects;\n if (!objects) objects = proxy._objects = {};\n var indicies, guid;\n\n while(--loc>=idx) {\n var item = content.objectAt(loc);\n if (item) {\n Ember.removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');\n Ember.removeObserver(item, keyName, proxy, 'contentKeyDidChange');\n\n guid = guidFor(item);\n indicies = objects[guid];\n indicies[indicies.indexOf(loc)] = null;\n }\n }\n}\n\n/**\n This is the object instance returned when you get the `@each` property on an\n array. It uses the unknownProperty handler to automatically create\n EachArray instances for property names.\n\n @private\n @class EachProxy\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.EachProxy = Ember.Object.extend({\n\n init: function(content) {\n this._super();\n this._content = content;\n content.addArrayObserver(this);\n\n // in case someone is already observing some keys make sure they are\n // added\n forEach(Ember.watchedEvents(this), function(eventName) {\n this.didAddListener(eventName);\n }, this);\n },\n\n /**\n You can directly access mapped properties by simply requesting them.\n The `unknownProperty` handler will generate an EachArray of each item.\n\n @method unknownProperty\n @param keyName {String}\n @param value {anything}\n */\n unknownProperty: function(keyName, value) {\n var ret;\n ret = new EachArray(this._content, keyName, this);\n Ember.defineProperty(this, keyName, null, ret);\n this.beginObservingContentKey(keyName);\n return ret;\n },\n\n // ..........................................................\n // ARRAY CHANGES\n // Invokes whenever the content array itself changes.\n\n arrayWillChange: function(content, idx, removedCnt, addedCnt) {\n var keys = this._keys, key, array, lim;\n\n lim = removedCnt>0 ? idx+removedCnt : -1;\n Ember.beginPropertyChanges(this);\n\n for(key in keys) {\n if (!keys.hasOwnProperty(key)) { continue; }\n\n if (lim>0) removeObserverForContentKey(content, key, this, idx, lim);\n\n Ember.propertyWillChange(this, key);\n }\n\n Ember.propertyWillChange(this._content, '@each');\n Ember.endPropertyChanges(this);\n },\n\n arrayDidChange: function(content, idx, removedCnt, addedCnt) {\n var keys = this._keys, key, array, lim;\n\n lim = addedCnt>0 ? idx+addedCnt : -1;\n Ember.beginPropertyChanges(this);\n\n for(key in keys) {\n if (!keys.hasOwnProperty(key)) { continue; }\n\n if (lim>0) addObserverForContentKey(content, key, this, idx, lim);\n\n Ember.propertyDidChange(this, key);\n }\n\n Ember.propertyDidChange(this._content, '@each');\n Ember.endPropertyChanges(this);\n },\n\n // ..........................................................\n // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS\n // Start monitoring keys based on who is listening...\n\n didAddListener: function(eventName) {\n if (IS_OBSERVER.test(eventName)) {\n this.beginObservingContentKey(eventName.slice(0, -7));\n }\n },\n\n didRemoveListener: function(eventName) {\n if (IS_OBSERVER.test(eventName)) {\n this.stopObservingContentKey(eventName.slice(0, -7));\n }\n },\n\n // ..........................................................\n // CONTENT KEY OBSERVING\n // Actual watch keys on the source content.\n\n beginObservingContentKey: function(keyName) {\n var keys = this._keys;\n if (!keys) keys = this._keys = {};\n if (!keys[keyName]) {\n keys[keyName] = 1;\n var content = this._content,\n len = get(content, 'length');\n addObserverForContentKey(content, keyName, this, 0, len);\n } else {\n keys[keyName]++;\n }\n },\n\n stopObservingContentKey: function(keyName) {\n var keys = this._keys;\n if (keys && (keys[keyName]>0) && (--keys[keyName]<=0)) {\n var content = this._content,\n len = get(content, 'length');\n removeObserverForContentKey(content, keyName, this, 0, len);\n }\n },\n\n contentKeyWillChange: function(obj, keyName) {\n Ember.propertyWillChange(this, keyName);\n },\n\n contentKeyDidChange: function(obj, keyName) {\n Ember.propertyDidChange(this, keyName);\n }\n\n});\n\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n\nvar get = Ember.get, set = Ember.set;\n\n// Add Ember.Array to Array.prototype. Remove methods with native\n// implementations and supply some more optimized versions of generic methods\n// because they are so common.\nvar NativeArray = Ember.Mixin.create(Ember.MutableArray, Ember.Observable, Ember.Copyable, {\n\n // because length is a built-in property we need to know to just get the\n // original property.\n get: function(key) {\n if (key==='length') return this.length;\n else if ('number' === typeof key) return this[key];\n else return this._super(key);\n },\n\n objectAt: function(idx) {\n return this[idx];\n },\n\n // primitive for array support.\n replace: function(idx, amt, objects) {\n\n if (this.isFrozen) throw Ember.FROZEN_ERROR ;\n\n // if we replaced exactly the same number of items, then pass only the\n // replaced range. Otherwise, pass the full remaining array length\n // since everything has shifted\n var len = objects ? get(objects, 'length') : 0;\n this.arrayContentWillChange(idx, amt, len);\n\n if (!objects || objects.length === 0) {\n this.splice(idx, amt) ;\n } else {\n var args = [idx, amt].concat(objects) ;\n this.splice.apply(this,args) ;\n }\n\n this.arrayContentDidChange(idx, amt, len);\n return this ;\n },\n\n // If you ask for an unknown property, then try to collect the value\n // from member items.\n unknownProperty: function(key, value) {\n var ret;// = this.reducedProperty(key, value) ;\n if ((value !== undefined) && ret === undefined) {\n ret = this[key] = value;\n }\n return ret ;\n },\n\n // If browser did not implement indexOf natively, then override with\n // specialized version\n indexOf: function(object, startAt) {\n var idx, len = this.length;\n\n if (startAt === undefined) startAt = 0;\n else startAt = (startAt < 0) ? Math.ceil(startAt) : Math.floor(startAt);\n if (startAt < 0) startAt += len;\n\n for(idx=startAt;idx<len;idx++) {\n if (this[idx] === object) return idx ;\n }\n return -1;\n },\n\n lastIndexOf: function(object, startAt) {\n var idx, len = this.length;\n\n if (startAt === undefined) startAt = len-1;\n else startAt = (startAt < 0) ? Math.ceil(startAt) : Math.floor(startAt);\n if (startAt < 0) startAt += len;\n\n for(idx=startAt;idx>=0;idx--) {\n if (this[idx] === object) return idx ;\n }\n return -1;\n },\n\n copy: function(deep) {\n if (deep) {\n return this.map(function(item){ return Ember.copy(item, true); });\n }\n\n return this.slice();\n }\n});\n\n// Remove any methods implemented natively so we don't override them\nvar ignore = ['length'];\nEmber.EnumerableUtils.forEach(NativeArray.keys(), function(methodName) {\n if (Array.prototype[methodName]) ignore.push(methodName);\n});\n\nif (ignore.length>0) {\n NativeArray = NativeArray.without.apply(NativeArray, ignore);\n}\n\n/**\n The NativeArray mixin contains the properties needed to to make the native\n Array support Ember.MutableArray and all of its dependent APIs. Unless you\n have `Ember.EXTEND_PROTOTYPES or `Ember.EXTEND_PROTOTYPES.Array` set to\n false, this will be applied automatically. Otherwise you can apply the mixin\n at anytime by calling `Ember.NativeArray.activate`.\n\n @class NativeArray\n @namespace Ember\n @extends Ember.Mixin\n @uses Ember.MutableArray\n @uses Ember.MutableEnumerable\n @uses Ember.Copyable\n @uses Ember.Freezable\n*/\nEmber.NativeArray = NativeArray;\n\n/**\n Creates an `Ember.NativeArray` from an Array like object.\n Does not modify the original object.\n\n @method A\n @for Ember\n @return {Ember.NativeArray}\n*/\nEmber.A = function(arr){\n if (arr === undefined) { arr = []; }\n return Ember.Array.detect(arr) ? arr : Ember.NativeArray.apply(arr);\n};\n\n/**\n Activates the mixin on the Array.prototype if not already applied. Calling\n this method more than once is safe.\n\n @method activate\n @for Ember.NativeArray\n @static\n @return {void}\n*/\nEmber.NativeArray.activate = function() {\n NativeArray.apply(Array.prototype);\n\n Ember.A = function(arr) { return arr || []; };\n};\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) {\n Ember.NativeArray.activate();\n}\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set;\n\nEmber._PromiseChain = Ember.Object.extend({\n promises: null,\n failureCallback: Ember.K,\n successCallback: Ember.K,\n abortCallback: Ember.K,\n promiseSuccessCallback: Ember.K,\n\n runNextPromise: function() {\n if (get(this, 'isDestroyed')) { return; }\n\n var item = get(this, 'promises').shiftObject();\n if (item) {\n var promise = get(item, 'promise') || item;\n Ember.assert(\"Cannot find promise to invoke\", Ember.canInvoke(promise, 'then'));\n\n var self = this;\n\n var successCallback = function() {\n self.promiseSuccessCallback.call(this, item, arguments);\n self.runNextPromise();\n };\n\n var failureCallback = get(self, 'failureCallback');\n\n promise.then(successCallback, failureCallback);\n } else {\n this.successCallback();\n }\n },\n\n start: function() {\n this.runNextPromise();\n return this;\n },\n\n abort: function() {\n this.abortCallback();\n this.destroy();\n },\n\n init: function() {\n set(this, 'promises', Ember.A(get(this, 'promises')));\n this._super();\n }\n});\n\n\n})();\n\n\n\n(function() {\nvar DeferredMixin = Ember.DeferredMixin, // mixins/deferred\n EmberObject = Ember.Object, // system/object\n get = Ember.get;\n\nvar Deferred = Ember.Object.extend(DeferredMixin);\n\nDeferred.reopenClass({\n promise: function(callback, binding) {\n var deferred = Deferred.create();\n callback.call(binding, deferred);\n return get(deferred, 'promise');\n }\n});\n\nEmber.Deferred = Deferred;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar loadHooks = {};\nvar loaded = {};\n\n/**\n@method onLoad\n@for Ember\n@param name {String} name of hook\n@param callback {Function} callback to be called\n*/\nEmber.onLoad = function(name, callback) {\n var object;\n\n loadHooks[name] = loadHooks[name] || Ember.A();\n loadHooks[name].pushObject(callback);\n\n if (object = loaded[name]) {\n callback(object);\n }\n};\n\n/**\n@method runLoadHooks\n@for Ember\n@param name {String} name of hook\n@param object {Object} object to pass to callbacks\n*/\nEmber.runLoadHooks = function(name, object) {\n var hooks;\n\n loaded[name] = object;\n\n if (hooks = loadHooks[name]) {\n loadHooks[name].forEach(function(callback) {\n callback(object);\n });\n }\n};\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\nvar get = Ember.get;\n\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n/**\n `Ember.ControllerMixin` provides a standard interface for all classes that\n compose Ember's controller layer: `Ember.Controller`,\n `Ember.ArrayController`, and `Ember.ObjectController`.\n\n Within an `Ember.Router`-managed application single shared instaces of every\n Controller object in your application's namespace will be added to the\n application's `Ember.Router` instance. See `Ember.Application#initialize`\n for additional information.\n\n ## Views\n\n By default a controller instance will be the rendering context\n for its associated `Ember.View.` This connection is made during calls to\n `Ember.ControllerMixin#connectOutlet`.\n\n Within the view's template, the `Ember.View` instance can be accessed\n through the controller with `{{view}}`.\n\n ## Target Forwarding\n\n By default a controller will target your application's `Ember.Router`\n instance. Calls to `{{action}}` within the template of a controller's view\n are forwarded to the router. See `Ember.Handlebars.helpers.action` for\n additional information.\n\n @class ControllerMixin\n @namespace Ember\n @extends Ember.Mixin\n*/\nEmber.ControllerMixin = Ember.Mixin.create({\n /**\n The object to which events from the view should be sent.\n\n For example, when a Handlebars template uses the `{{action}}` helper,\n it will attempt to send the event to the view's controller's `target`.\n\n By default, a controller's `target` is set to the router after it is\n instantiated by `Ember.Application#initialize`.\n\n @property target\n @default null\n */\n target: null,\n\n store: null,\n\n send: function(actionName, event) {\n var target;\n\n if (this.hasOwnProperty(actionName)) {\n this[actionName](event);\n } else if(target = get(this, 'target')) {\n target.send(actionName, event);\n }\n }\n});\n\n/**\n @class Controller\n @namespace Ember\n @extends Ember.Object\n @uses Ember.ControllerMixin\n*/\nEmber.Controller = Ember.Object.extend(Ember.ControllerMixin);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;\n\n/**\n `Ember.SortableMixin` provides a standard interface for array proxies\n to specify a sort order and maintain this sorting when objects are added,\n removed, or updated without changing the implicit order of their underlying\n content array:\n\n ```javascript\n songs = [\n {trackNumber: 4, title: 'Ob-La-Di, Ob-La-Da'},\n {trackNumber: 2, title: 'Back in the U.S.S.R.'},\n {trackNumber: 3, title: 'Glass Onion'},\n ];\n\n songsController = Ember.ArrayController.create({\n content: songs,\n sortProperties: ['trackNumber']\n });\n\n songsController.get('firstObject'); // {trackNumber: 2, title: 'Back in the U.S.S.R.'}\n\n songsController.addObject({trackNumber: 1, title: 'Dear Prudence'});\n songsController.get('firstObject'); // {trackNumber: 1, title: 'Dear Prudence'}\n ```\n\n @class SortableMixin\n @namespace Ember\n @extends Ember.Mixin\n @uses Ember.MutableEnumerable\n*/\nEmber.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {\n sortProperties: null,\n sortAscending: true,\n\n orderBy: function(item1, item2) {\n var result = 0,\n sortProperties = get(this, 'sortProperties'),\n sortAscending = get(this, 'sortAscending');\n\n Ember.assert(\"you need to define `sortProperties`\", !!sortProperties);\n\n forEach(sortProperties, function(propertyName) {\n if (result === 0) {\n result = Ember.compare(get(item1, propertyName), get(item2, propertyName));\n if ((result !== 0) && !sortAscending) {\n result = (-1) * result;\n }\n }\n });\n\n return result;\n },\n\n destroy: function() {\n var content = get(this, 'content'),\n sortProperties = get(this, 'sortProperties');\n\n if (content && sortProperties) {\n forEach(content, function(item) {\n forEach(sortProperties, function(sortProperty) {\n Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');\n }, this);\n }, this);\n }\n\n return this._super();\n },\n\n isSorted: Ember.computed('sortProperties', function() {\n return !!get(this, 'sortProperties');\n }),\n\n arrangedContent: Ember.computed('content', 'sortProperties.@each', function(key, value) {\n var content = get(this, 'content'),\n isSorted = get(this, 'isSorted'),\n sortProperties = get(this, 'sortProperties'),\n self = this;\n\n if (content && isSorted) {\n content = content.slice();\n content.sort(function(item1, item2) {\n return self.orderBy(item1, item2);\n });\n forEach(content, function(item) {\n forEach(sortProperties, function(sortProperty) {\n Ember.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');\n }, this);\n }, this);\n return Ember.A(content);\n }\n\n return content;\n }),\n\n _contentWillChange: Ember.beforeObserver(function() {\n var content = get(this, 'content'),\n sortProperties = get(this, 'sortProperties');\n\n if (content && sortProperties) {\n forEach(content, function(item) {\n forEach(sortProperties, function(sortProperty) {\n Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');\n }, this);\n }, this);\n }\n\n this._super();\n }, 'content'),\n\n sortAscendingWillChange: Ember.beforeObserver(function() {\n this._lastSortAscending = get(this, 'sortAscending');\n }, 'sortAscending'),\n\n sortAscendingDidChange: Ember.observer(function() {\n if (get(this, 'sortAscending') !== this._lastSortAscending) {\n var arrangedContent = get(this, 'arrangedContent');\n arrangedContent.reverseObjects();\n }\n }, 'sortAscending'),\n\n contentArrayWillChange: function(array, idx, removedCount, addedCount) {\n var isSorted = get(this, 'isSorted');\n\n if (isSorted) {\n var arrangedContent = get(this, 'arrangedContent');\n var removedObjects = array.slice(idx, idx+removedCount);\n var sortProperties = get(this, 'sortProperties');\n\n forEach(removedObjects, function(item) {\n arrangedContent.removeObject(item);\n\n forEach(sortProperties, function(sortProperty) {\n Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');\n }, this);\n });\n }\n\n return this._super(array, idx, removedCount, addedCount);\n },\n\n contentArrayDidChange: function(array, idx, removedCount, addedCount) {\n var isSorted = get(this, 'isSorted'),\n sortProperties = get(this, 'sortProperties');\n\n if (isSorted) {\n var addedObjects = array.slice(idx, idx+addedCount);\n var arrangedContent = get(this, 'arrangedContent');\n\n forEach(addedObjects, function(item) {\n this.insertItemSorted(item);\n\n forEach(sortProperties, function(sortProperty) {\n Ember.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');\n }, this);\n }, this);\n }\n\n return this._super(array, idx, removedCount, addedCount);\n },\n\n insertItemSorted: function(item) {\n var arrangedContent = get(this, 'arrangedContent');\n var length = get(arrangedContent, 'length');\n\n var idx = this._binarySearch(item, 0, length);\n arrangedContent.insertAt(idx, item);\n },\n\n contentItemSortPropertyDidChange: function(item) {\n var arrangedContent = get(this, 'arrangedContent'),\n oldIndex = arrangedContent.indexOf(item),\n leftItem = arrangedContent.objectAt(oldIndex - 1),\n rightItem = arrangedContent.objectAt(oldIndex + 1),\n leftResult = leftItem && this.orderBy(item, leftItem),\n rightResult = rightItem && this.orderBy(item, rightItem);\n\n if (leftResult < 0 || rightResult > 0) {\n arrangedContent.removeObject(item);\n this.insertItemSorted(item);\n }\n },\n\n _binarySearch: function(item, low, high) {\n var mid, midItem, res, arrangedContent;\n\n if (low === high) {\n return low;\n }\n\n arrangedContent = get(this, 'arrangedContent');\n\n mid = low + Math.floor((high - low) / 2);\n midItem = arrangedContent.objectAt(mid);\n\n res = this.orderBy(midItem, item);\n\n if (res < 0) {\n return this._binarySearch(item, mid+1, high);\n } else if (res > 0) {\n return this._binarySearch(item, low, mid);\n }\n\n return mid;\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n `Ember.ArrayController` provides a way for you to publish a collection of\n objects so that you can easily bind to the collection from a Handlebars\n `#each` helper, an `Ember.CollectionView`, or other controllers.\n\n The advantage of using an `ArrayController` is that you only have to set up\n your view bindings once; to change what's displayed, simply swap out the\n `content` property on the controller.\n\n For example, imagine you wanted to display a list of items fetched via an XHR\n request. Create an `Ember.ArrayController` and set its `content` property:\n\n ```javascript\n MyApp.listController = Ember.ArrayController.create();\n\n $.get('people.json', function(data) {\n MyApp.listController.set('content', data);\n });\n ```\n\n Then, create a view that binds to your new controller:\n\n ```handlebars\n {{#each MyApp.listController}}\n {{firstName}} {{lastName}}\n {{/each}}\n ```\n\n Although you are binding to the controller, the behavior of this controller\n is to pass through any methods or properties to the underlying array. This\n capability comes from `Ember.ArrayProxy`, which this class inherits from.\n\n Note: As of this writing, `ArrayController` does not add any functionality\n to its superclass, `ArrayProxy`. The Ember team plans to add additional\n controller-specific functionality in the future, e.g. single or multiple\n selection support. If you are creating something that is conceptually a\n controller, use this class.\n\n @class ArrayController\n @namespace Ember\n @extends Ember.ArrayProxy\n @uses Ember.SortableMixin\n @uses Ember.ControllerMixin\n*/\n\nEmber.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,\n Ember.SortableMixin);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-runtime\n*/\n\n/**\n `Ember.ObjectController` is part of Ember's Controller layer. A single shared\n instance of each `Ember.ObjectController` subclass in your application's\n namespace will be created at application initialization and be stored on your\n application's `Ember.Router` instance.\n\n `Ember.ObjectController` derives its functionality from its superclass\n `Ember.ObjectProxy` and the `Ember.ControllerMixin` mixin.\n\n @class ObjectController\n @namespace Ember\n @extends Ember.ObjectProxy\n @uses Ember.ControllerMixin\n**/\nEmber.ObjectController = Ember.ObjectProxy.extend(Ember.ControllerMixin);\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/**\nEmber Runtime\n\n@module ember\n@submodule ember-runtime\n@requires ember-metal\n*/\n\n})();\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar jQuery = Ember.imports.jQuery;\nEmber.assert(\"Ember Views require jQuery 1.7 or 1.8\", jQuery && (jQuery().jquery.match(/^1\\.(7(?!$)(?!\\.[01])|8)(\\.\\d+)?(pre|rc\\d?)?/) || Ember.ENV.FORCE_JQUERY));\n\n/**\n Alias for jQuery\n\n @method $\n @for Ember\n*/\nEmber.$ = jQuery;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\n// http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents\nvar dragEvents = Ember.String.w('dragstart drag dragenter dragleave dragover drop dragend');\n\n// Copies the `dataTransfer` property from a browser event object onto the\n// jQuery event object for the specified events\nEmber.EnumerableUtils.forEach(dragEvents, function(eventName) {\n Ember.$.event.fixHooks[eventName] = { props: ['dataTransfer'] };\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\n/*** BEGIN METAMORPH HELPERS ***/\n\n// Internet Explorer prior to 9 does not allow setting innerHTML if the first element\n// is a \"zero-scope\" element. This problem can be worked around by making\n// the first node an invisible text node. We, like Modernizr, use &shy;\nvar needsShy = (function(){\n var testEl = document.createElement('div');\n testEl.innerHTML = \"<div></div>\";\n testEl.firstChild.innerHTML = \"<script></script>\";\n return testEl.firstChild.innerHTML === '';\n})();\n\n// IE 8 (and likely earlier) likes to move whitespace preceeding\n// a script tag to appear after it. This means that we can\n// accidentally remove whitespace when updating a morph.\nvar movesWhitespace = (function() {\n var testEl = document.createElement('div');\n testEl.innerHTML = \"Test: <script type='text/x-placeholder'></script>Value\";\n return testEl.childNodes[0].nodeValue === 'Test:' &&\n testEl.childNodes[2].nodeValue === ' Value';\n})();\n\n// Use this to find children by ID instead of using jQuery\nvar findChildById = function(element, id) {\n if (element.getAttribute('id') === id) { return element; }\n\n var len = element.childNodes.length, idx, node, found;\n for (idx=0; idx<len; idx++) {\n node = element.childNodes[idx];\n found = node.nodeType === 1 && findChildById(node, id);\n if (found) { return found; }\n }\n};\n\nvar setInnerHTMLWithoutFix = function(element, html) {\n if (needsShy) {\n html = '&shy;' + html;\n }\n\n var matches = [];\n if (movesWhitespace) {\n // Right now we only check for script tags with ids with the\n // goal of targeting morphs.\n html = html.replace(/(\\s+)(<script id='([^']+)')/g, function(match, spaces, tag, id) {\n matches.push([id, spaces]);\n return tag;\n });\n }\n\n element.innerHTML = html;\n\n // If we have to do any whitespace adjustments do them now\n if (matches.length > 0) {\n var len = matches.length, idx;\n for (idx=0; idx<len; idx++) {\n var script = findChildById(element, matches[idx][0]),\n node = document.createTextNode(matches[idx][1]);\n script.parentNode.insertBefore(node, script);\n }\n }\n\n if (needsShy) {\n var shyElement = element.firstChild;\n while (shyElement.nodeType === 1 && !shyElement.nodeName) {\n shyElement = shyElement.firstChild;\n }\n if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === \"\\u00AD\") {\n shyElement.nodeValue = shyElement.nodeValue.slice(1);\n }\n }\n};\n\n/*** END METAMORPH HELPERS */\n\n\nvar innerHTMLTags = {};\nvar canSetInnerHTML = function(tagName) {\n if (innerHTMLTags[tagName] !== undefined) {\n return innerHTMLTags[tagName];\n }\n\n var canSet = true;\n\n // IE 8 and earlier don't allow us to do innerHTML on select\n if (tagName.toLowerCase() === 'select') {\n var el = document.createElement('select');\n setInnerHTMLWithoutFix(el, '<option value=\"test\">Test</option>');\n canSet = el.options.length === 1;\n }\n\n innerHTMLTags[tagName] = canSet;\n\n return canSet;\n};\n\nvar setInnerHTML = function(element, html) {\n var tagName = element.tagName;\n\n if (canSetInnerHTML(tagName)) {\n setInnerHTMLWithoutFix(element, html);\n } else {\n Ember.assert(\"Can't set innerHTML on \"+element.tagName+\" in this browser\", element.outerHTML);\n\n var startTag = element.outerHTML.match(new RegExp(\"<\"+tagName+\"([^>]*)>\", 'i'))[0],\n endTag = '</'+tagName+'>';\n\n var wrapper = document.createElement('div');\n setInnerHTMLWithoutFix(wrapper, startTag + html + endTag);\n element = wrapper.firstChild;\n while (element.tagName !== tagName) {\n element = element.nextSibling;\n }\n }\n\n return element;\n};\n\nEmber.ViewUtils = {\n setInnerHTML: setInnerHTML\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar indexOf = Ember.ArrayPolyfills.indexOf;\n\n\n\n\n\nvar ClassSet = function() {\n this.seen = {};\n this.list = [];\n};\n\nClassSet.prototype = {\n add: function(string) {\n if (string in this.seen) { return; }\n this.seen[string] = true;\n\n this.list.push(string);\n },\n\n toDOM: function() {\n return this.list.join(\" \");\n }\n};\n\n/**\n `Ember.RenderBuffer` gathers information regarding the a view and generates the\n final representation. `Ember.RenderBuffer` will generate HTML which can be pushed\n to the DOM.\n\n @class RenderBuffer\n @namespace Ember\n @constructor\n*/\nEmber.RenderBuffer = function(tagName) {\n return new Ember._RenderBuffer(tagName);\n};\n\nEmber._RenderBuffer = function(tagName) {\n this.tagNames = [tagName || null];\n this.buffer = [];\n};\n\nEmber._RenderBuffer.prototype =\n/** @scope Ember.RenderBuffer.prototype */ {\n\n // The root view's element\n _element: null,\n\n /**\n @private\n\n An internal set used to de-dupe class names when `addClass()` is\n used. After each call to `addClass()`, the `classes` property\n will be updated.\n\n @property elementClasses\n @type Array\n @default []\n */\n elementClasses: null,\n\n /**\n Array of class names which will be applied in the class attribute.\n\n You can use `setClasses()` to set this property directly. If you\n use `addClass()`, it will be maintained for you.\n\n @property classes\n @type Array\n @default []\n */\n classes: null,\n\n /**\n The id in of the element, to be applied in the id attribute.\n\n You should not set this property yourself, rather, you should use\n the `id()` method of `Ember.RenderBuffer`.\n\n @property elementId\n @type String\n @default null\n */\n elementId: null,\n\n /**\n A hash keyed on the name of the attribute and whose value will be\n applied to that attribute. For example, if you wanted to apply a\n `data-view=\"Foo.bar\"` property to an element, you would set the\n elementAttributes hash to `{'data-view':'Foo.bar'}`.\n\n You should not maintain this hash yourself, rather, you should use\n the `attr()` method of `Ember.RenderBuffer`.\n\n @property elementAttributes\n @type Hash\n @default {}\n */\n elementAttributes: null,\n\n /**\n The tagname of the element an instance of `Ember.RenderBuffer` represents.\n\n Usually, this gets set as the first parameter to `Ember.RenderBuffer`. For\n example, if you wanted to create a `p` tag, then you would call\n\n ```javascript\n Ember.RenderBuffer('p')\n ```\n\n @property elementTag\n @type String\n @default null\n */\n elementTag: null,\n\n /**\n A hash keyed on the name of the style attribute and whose value will\n be applied to that attribute. For example, if you wanted to apply a\n `background-color:black;` style to an element, you would set the\n elementStyle hash to `{'background-color':'black'}`.\n\n You should not maintain this hash yourself, rather, you should use\n the `style()` method of `Ember.RenderBuffer`.\n\n @property elementStyle\n @type Hash\n @default {}\n */\n elementStyle: null,\n\n /**\n Nested `RenderBuffers` will set this to their parent `RenderBuffer`\n instance.\n\n @property parentBuffer\n @type Ember._RenderBuffer\n */\n parentBuffer: null,\n\n /**\n Adds a string of HTML to the `RenderBuffer`.\n\n @method push\n @param {String} string HTML to push into the buffer\n @chainable\n */\n push: function(string) {\n this.buffer.push(string);\n return this;\n },\n\n /**\n Adds a class to the buffer, which will be rendered to the class attribute.\n\n @method addClass\n @param {String} className Class name to add to the buffer\n @chainable\n */\n addClass: function(className) {\n // lazily create elementClasses\n var elementClasses = this.elementClasses = (this.elementClasses || new ClassSet());\n this.elementClasses.add(className);\n this.classes = this.elementClasses.list;\n\n return this;\n },\n\n setClasses: function(classNames) {\n this.classes = classNames;\n },\n\n /**\n Sets the elementID to be used for the element.\n\n @method id\n @param {String} id\n @chainable\n */\n id: function(id) {\n this.elementId = id;\n return this;\n },\n\n // duck type attribute functionality like jQuery so a render buffer\n // can be used like a jQuery object in attribute binding scenarios.\n\n /**\n Adds an attribute which will be rendered to the element.\n\n @method attr\n @param {String} name The name of the attribute\n @param {String} value The value to add to the attribute\n @chainable\n @return {Ember.RenderBuffer|String} this or the current attribute value\n */\n attr: function(name, value) {\n var attributes = this.elementAttributes = (this.elementAttributes || {});\n\n if (arguments.length === 1) {\n return attributes[name];\n } else {\n attributes[name] = value;\n }\n\n return this;\n },\n\n /**\n Remove an attribute from the list of attributes to render.\n\n @method removeAttr\n @param {String} name The name of the attribute\n @chainable\n */\n removeAttr: function(name) {\n var attributes = this.elementAttributes;\n if (attributes) { delete attributes[name]; }\n\n return this;\n },\n\n /**\n Adds a style to the style attribute which will be rendered to the element.\n\n @method style\n @param {String} name Name of the style\n @param {String} value\n @chainable\n */\n style: function(name, value) {\n var style = this.elementStyle = (this.elementStyle || {});\n\n this.elementStyle[name] = value;\n return this;\n },\n\n begin: function(tagName) {\n this.tagNames.push(tagName || null);\n return this;\n },\n\n pushOpeningTag: function() {\n var tagName = this.currentTagName();\n if (!tagName) { return; }\n\n if (!this._element && this.buffer.length === 0) {\n this._element = this.generateElement();\n return;\n }\n\n var buffer = this.buffer,\n id = this.elementId,\n classes = this.classes,\n attrs = this.elementAttributes,\n style = this.elementStyle,\n prop;\n\n buffer.push('<' + tagName);\n\n if (id) {\n buffer.push(' id=\"' + this._escapeAttribute(id) + '\"');\n this.elementId = null;\n }\n if (classes) {\n buffer.push(' class=\"' + this._escapeAttribute(classes.join(' ')) + '\"');\n this.classes = null;\n }\n\n if (style) {\n buffer.push(' style=\"');\n\n for (prop in style) {\n if (style.hasOwnProperty(prop)) {\n buffer.push(prop + ':' + this._escapeAttribute(style[prop]) + ';');\n }\n }\n\n buffer.push('\"');\n\n this.elementStyle = null;\n }\n\n if (attrs) {\n for (prop in attrs) {\n if (attrs.hasOwnProperty(prop)) {\n buffer.push(' ' + prop + '=\"' + this._escapeAttribute(attrs[prop]) + '\"');\n }\n }\n\n this.elementAttributes = null;\n }\n\n buffer.push('>');\n },\n\n pushClosingTag: function() {\n var tagName = this.tagNames.pop();\n if (tagName) { this.buffer.push('</' + tagName + '>'); }\n },\n\n currentTagName: function() {\n return this.tagNames[this.tagNames.length-1];\n },\n\n generateElement: function() {\n var tagName = this.tagNames.pop(), // pop since we don't need to close\n element = document.createElement(tagName),\n $element = Ember.$(element),\n id = this.elementId,\n classes = this.classes,\n attrs = this.elementAttributes,\n style = this.elementStyle,\n styleBuffer = '', prop;\n\n if (id) {\n $element.attr('id', id);\n this.elementId = null;\n }\n if (classes) {\n $element.attr('class', classes.join(' '));\n this.classes = null;\n }\n\n if (style) {\n for (prop in style) {\n if (style.hasOwnProperty(prop)) {\n styleBuffer += (prop + ':' + style[prop] + ';');\n }\n }\n\n $element.attr('style', styleBuffer);\n\n this.elementStyle = null;\n }\n\n if (attrs) {\n for (prop in attrs) {\n if (attrs.hasOwnProperty(prop)) {\n $element.attr(prop, attrs[prop]);\n }\n }\n\n this.elementAttributes = null;\n }\n\n return element;\n },\n\n /**\n @method element\n @return {DOMElement} The element corresponding to the generated HTML\n of this buffer\n */\n element: function() {\n var html = this.innerString();\n\n if (html) {\n this._element = Ember.ViewUtils.setInnerHTML(this._element, html);\n }\n\n return this._element;\n },\n\n /**\n Generates the HTML content for this buffer.\n\n @method string\n @return {String} The generated HTML\n */\n string: function() {\n if (this._element) {\n return this.element().outerHTML;\n } else {\n return this.innerString();\n }\n },\n\n innerString: function() {\n return this.buffer.join('');\n },\n\n _escapeAttribute: function(value) {\n // Stolen shamelessly from Handlebars\n\n var escape = {\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#x27;\",\n \"`\": \"&#x60;\"\n };\n\n var badChars = /&(?!\\w+;)|[<>\"'`]/g;\n var possible = /[&<>\"'`]/;\n\n var escapeChar = function(chr) {\n return escape[chr] || \"&amp;\";\n };\n\n var string = value.toString();\n\n if(!possible.test(string)) { return string; }\n return string.replace(badChars, escapeChar);\n }\n\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;\n\n/**\n `Ember.EventDispatcher` handles delegating browser events to their\n corresponding `Ember.Views.` For example, when you click on a view,\n `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets\n called.\n\n @class EventDispatcher\n @namespace Ember\n @private\n @extends Ember.Object\n*/\nEmber.EventDispatcher = Ember.Object.extend(\n/** @scope Ember.EventDispatcher.prototype */{\n\n /**\n @private\n\n The root DOM element to which event listeners should be attached. Event\n listeners will be attached to the document unless this is overridden.\n\n Can be specified as a DOMElement or a selector string.\n\n The default body is a string since this may be evaluated before document.body\n exists in the DOM.\n\n @property rootElement\n @type DOMElement\n @default 'body'\n */\n rootElement: 'body',\n\n /**\n @private\n\n Sets up event listeners for standard browser events.\n\n This will be called after the browser sends a `DOMContentReady` event. By\n default, it will set up all of the listeners on the document body. If you\n would like to register the listeners on a different element, set the event\n dispatcher's `root` property.\n\n @method setup\n @param addedEvents {Hash}\n */\n setup: function(addedEvents) {\n var event, events = {\n touchstart : 'touchStart',\n touchmove : 'touchMove',\n touchend : 'touchEnd',\n touchcancel : 'touchCancel',\n keydown : 'keyDown',\n keyup : 'keyUp',\n keypress : 'keyPress',\n mousedown : 'mouseDown',\n mouseup : 'mouseUp',\n contextmenu : 'contextMenu',\n click : 'click',\n dblclick : 'doubleClick',\n mousemove : 'mouseMove',\n focusin : 'focusIn',\n focusout : 'focusOut',\n mouseenter : 'mouseEnter',\n mouseleave : 'mouseLeave',\n submit : 'submit',\n input : 'input',\n change : 'change',\n dragstart : 'dragStart',\n drag : 'drag',\n dragenter : 'dragEnter',\n dragleave : 'dragLeave',\n dragover : 'dragOver',\n drop : 'drop',\n dragend : 'dragEnd'\n };\n\n Ember.$.extend(events, addedEvents || {});\n\n var rootElement = Ember.$(get(this, 'rootElement'));\n\n Ember.assert(fmt('You cannot use the same root element (%@) multiple times in an Ember.Application', [rootElement.selector || rootElement[0].tagName]), !rootElement.is('.ember-application'));\n Ember.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest('.ember-application').length);\n Ember.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find('.ember-application').length);\n\n rootElement.addClass('ember-application');\n\n Ember.assert('Unable to add \"ember-application\" class to rootElement. Make sure you set rootElement to the body or an element in the body.', rootElement.is('.ember-application'));\n\n for (event in events) {\n if (events.hasOwnProperty(event)) {\n this.setupHandler(rootElement, event, events[event]);\n }\n }\n },\n\n /**\n @private\n\n Registers an event listener on the document. If the given event is\n triggered, the provided event handler will be triggered on the target view.\n\n If the target view does not implement the event handler, or if the handler\n returns `false`, the parent view will be called. The event will continue to\n bubble to each successive parent view until it reaches the top.\n\n For example, to have the `mouseDown` method called on the target view when\n a `mousedown` event is received from the browser, do the following:\n\n ```javascript\n setupHandler('mousedown', 'mouseDown');\n ```\n\n @method setupHandler\n @param {Element} rootElement\n @param {String} event the browser-originated event to listen to\n @param {String} eventName the name of the method to call on the view\n */\n setupHandler: function(rootElement, event, eventName) {\n var self = this;\n\n rootElement.delegate('.ember-view', event + '.ember', function(evt, triggeringManager) {\n return Ember.handleErrors(function() {\n var view = Ember.View.views[this.id],\n result = true, manager = null;\n\n manager = self._findNearestEventManager(view,eventName);\n\n if (manager && manager !== triggeringManager) {\n result = self._dispatchEvent(manager, evt, eventName, view);\n } else if (view) {\n result = self._bubbleEvent(view,evt,eventName);\n } else {\n evt.stopPropagation();\n }\n\n return result;\n }, this);\n });\n\n rootElement.delegate('[data-ember-action]', event + '.ember', function(evt) {\n return Ember.handleErrors(function() {\n var actionId = Ember.$(evt.currentTarget).attr('data-ember-action'),\n action = Ember.Handlebars.ActionHelper.registeredActions[actionId],\n handler = action.handler;\n\n if (action.eventName === eventName) {\n return handler(evt);\n }\n }, this);\n });\n },\n\n _findNearestEventManager: function(view, eventName) {\n var manager = null;\n\n while (view) {\n manager = get(view, 'eventManager');\n if (manager && manager[eventName]) { break; }\n\n view = get(view, 'parentView');\n }\n\n return manager;\n },\n\n _dispatchEvent: function(object, evt, eventName, view) {\n var result = true;\n\n var handler = object[eventName];\n if (Ember.typeOf(handler) === 'function') {\n result = handler.call(object, evt, view);\n // Do not preventDefault in eventManagers.\n evt.stopPropagation();\n }\n else {\n result = this._bubbleEvent(view, evt, eventName);\n }\n\n return result;\n },\n\n _bubbleEvent: function(view, evt, eventName) {\n return Ember.run(function() {\n return view.handleEvent(eventName, evt);\n });\n },\n\n destroy: function() {\n var rootElement = get(this, 'rootElement');\n Ember.$(rootElement).undelegate('.ember').removeClass('ember-application');\n return this._super();\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\n// Add a new named queue for rendering views that happens\n// after bindings have synced, and a queue for scheduling actions\n// that that should occur after view rendering.\nvar queues = Ember.run.queues;\nqueues.splice(Ember.$.inArray('actions', queues)+1, 0, 'render', 'afterRender');\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n// Original class declaration and documentation in runtime/lib/controllers/controller.js\n// NOTE: It may be possible with YUIDoc to combine docs in two locations\n\n/**\nAdditional methods for the ControllerMixin\n\n@class ControllerMixin\n@namespace Ember\n*/\nEmber.ControllerMixin.reopen({\n\n target: null,\n controllers: null,\n namespace: null,\n view: null,\n container: null,\n\n /**\n Convenience method to connect controllers. This method makes other controllers\n available on the controller the method was invoked on.\n\n For example, to make the `personController` and the `postController` available\n on the `overviewController`, you would call:\n\n ```javascript\n overviewController.connectControllers('person', 'post');\n ```\n\n @method connectControllers\n @param {String...} controllerNames the controllers to make available\n */\n connectControllers: function() {\n var controllers = get(this, 'controllers'),\n controllerNames = Array.prototype.slice.apply(arguments),\n controllerName;\n\n for (var i=0, l=controllerNames.length; i<l; i++) {\n controllerName = controllerNames[i] + 'Controller';\n set(this, controllerName, get(controllers, controllerName));\n }\n }\n});\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\nvar states = {};\n\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, addObserver = Ember.addObserver, removeObserver = Ember.removeObserver;\nvar meta = Ember.meta, guidFor = Ember.guidFor, fmt = Ember.String.fmt;\nvar a_slice = [].slice;\nvar a_forEach = Ember.EnumerableUtils.forEach;\nvar a_addObject = Ember.EnumerableUtils.addObject;\n\nvar childViewsProperty = Ember.computed(function() {\n var childViews = this._childViews;\n\n var ret = Ember.A();\n\n a_forEach(childViews, function(view) {\n if (view.isVirtual) {\n ret.pushObjects(get(view, 'childViews'));\n } else {\n ret.push(view);\n }\n });\n\n return ret;\n}).property();\n\nEmber.warn(\"The VIEW_PRESERVES_CONTEXT flag has been removed and the functionality can no longer be disabled.\", Ember.ENV.VIEW_PRESERVES_CONTEXT !== false);\n\n/**\n Global hash of shared templates. This will automatically be populated\n by the build tools so that you can store your Handlebars templates in\n separate files that get loaded into JavaScript at buildtime.\n\n @property TEMPLATES\n @for Ember\n @type Hash\n*/\nEmber.TEMPLATES = {};\n\nEmber.CoreView = Ember.Object.extend(Ember.Evented, {\n isView: true,\n\n states: states,\n\n init: function() {\n this._super();\n\n // Register the view for event handling. This hash is used by\n // Ember.EventDispatcher to dispatch incoming events.\n if (!this.isVirtual) Ember.View.views[this.elementId] = this;\n\n this.addBeforeObserver('elementId', function() {\n throw new Error(\"Changing a view's elementId after creation is not allowed\");\n });\n\n this.transitionTo('preRender');\n },\n\n /**\n If the view is currently inserted into the DOM of a parent view, this\n property will point to the parent of the view.\n\n @property parentView\n @type Ember.View\n @default null\n */\n parentView: Ember.computed(function() {\n var parent = this._parentView;\n\n if (parent && parent.isVirtual) {\n return get(parent, 'parentView');\n } else {\n return parent;\n }\n }).property('_parentView'),\n\n state: null,\n\n _parentView: null,\n\n // return the current view, not including virtual views\n concreteView: Ember.computed(function() {\n if (!this.isVirtual) { return this; }\n else { return get(this, 'parentView'); }\n }).property('parentView').volatile(),\n\n instrumentName: 'core_view',\n\n instrumentDetails: function(hash) {\n hash.object = this.toString();\n },\n\n /**\n @private\n\n Invoked by the view system when this view needs to produce an HTML\n representation. This method will create a new render buffer, if needed,\n then apply any default attributes, such as class names and visibility.\n Finally, the `render()` method is invoked, which is responsible for\n doing the bulk of the rendering.\n\n You should not need to override this method; instead, implement the\n `template` property, or if you need more control, override the `render`\n method.\n\n @method renderToBuffer\n @param {Ember.RenderBuffer} buffer the render buffer. If no buffer is\n passed, a default buffer, using the current view's `tagName`, will\n be used.\n */\n renderToBuffer: function(parentBuffer, bufferOperation) {\n var name = 'render.' + this.instrumentName,\n details = {};\n\n this.instrumentDetails(details);\n\n return Ember.instrument(name, details, function() {\n return this._renderToBuffer(parentBuffer, bufferOperation);\n }, this);\n },\n\n _renderToBuffer: function(parentBuffer, bufferOperation) {\n Ember.run.sync();\n\n // If this is the top-most view, start a new buffer. Otherwise,\n // create a new buffer relative to the original using the\n // provided buffer operation (for example, `insertAfter` will\n // insert a new buffer after the \"parent buffer\").\n var tagName = this.tagName;\n\n if (tagName === null || tagName === undefined) {\n tagName = 'div';\n }\n\n var buffer = this.buffer = parentBuffer && parentBuffer.begin(tagName) || Ember.RenderBuffer(tagName);\n this.transitionTo('inBuffer', false);\n\n this.beforeRender(buffer);\n this.render(buffer);\n this.afterRender(buffer);\n\n return buffer;\n },\n\n /**\n @private\n\n Override the default event firing from `Ember.Evented` to\n also call methods with the given name.\n\n @method trigger\n @param name {String}\n */\n trigger: function(name) {\n this._super.apply(this, arguments);\n var method = this[name];\n if (method) {\n var args = [], i, l;\n for (i = 1, l = arguments.length; i < l; i++) {\n args.push(arguments[i]);\n }\n return method.apply(this, args);\n }\n },\n\n has: function(name) {\n return Ember.typeOf(this[name]) === 'function' || this._super(name);\n },\n\n willDestroy: function() {\n var parent = this._parentView;\n\n // destroy the element -- this will avoid each child view destroying\n // the element over and over again...\n if (!this.removedFromDOM) { this.destroyElement(); }\n\n // remove from parent if found. Don't call removeFromParent,\n // as removeFromParent will try to remove the element from\n // the DOM again.\n if (parent) { parent.removeChild(this); }\n\n this.transitionTo('destroyed');\n\n // next remove view from global hash\n if (!this.isVirtual) delete Ember.View.views[this.elementId];\n },\n\n clearRenderedChildren: Ember.K,\n triggerRecursively: Ember.K,\n invokeRecursively: Ember.K,\n transitionTo: Ember.K,\n destroyElement: Ember.K\n});\n\n/**\n `Ember.View` is the class in Ember responsible for encapsulating templates of\n HTML content, combining templates with data to render as sections of a page's\n DOM, and registering and responding to user-initiated events.\n\n ## HTML Tag\n\n The default HTML tag name used for a view's DOM representation is `div`. This\n can be customized by setting the `tagName` property. The following view\nclass:\n\n ```javascript\n ParagraphView = Ember.View.extend({\n tagName: 'em'\n });\n ```\n\n Would result in instances with the following HTML:\n\n ```html\n <em id=\"ember1\" class=\"ember-view\"></em>\n ```\n\n ## HTML `class` Attribute\n\n The HTML `class` attribute of a view's tag can be set by providing a\n `classNames` property that is set to an array of strings:\n\n ```javascript\n MyView = Ember.View.extend({\n classNames: ['my-class', 'my-other-class']\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view my-class my-other-class\"></div>\n ```\n\n `class` attribute values can also be set by providing a `classNameBindings`\n property set to an array of properties names for the view. The return value\n of these properties will be added as part of the value for the view's `class`\n attribute. These properties can be computed properties:\n\n ```javascript\n MyView = Ember.View.extend({\n classNameBindings: ['propertyA', 'propertyB'],\n propertyA: 'from-a',\n propertyB: function(){\n if(someLogic){ return 'from-b'; }\n }.property()\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view from-a from-b\"></div>\n ```\n\n If the value of a class name binding returns a boolean the property name\n itself will be used as the class name if the property is true. The class name\n will not be added if the value is `false` or `undefined`.\n\n ```javascript\n MyView = Ember.View.extend({\n classNameBindings: ['hovered'],\n hovered: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view hovered\"></div>\n ```\n\n When using boolean class name bindings you can supply a string value other\n than the property name for use as the `class` HTML attribute by appending the\n preferred value after a \":\" character when defining the binding:\n\n ```javascript\n MyView = Ember.View.extend({\n classNameBindings: ['awesome:so-very-cool'],\n awesome: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view so-very-cool\"></div>\n ```\n\n Boolean value class name bindings whose property names are in a\n camelCase-style format will be converted to a dasherized format:\n\n ```javascript\n MyView = Ember.View.extend({\n classNameBindings: ['isUrgent'],\n isUrgent: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view is-urgent\"></div>\n ```\n\n Class name bindings can also refer to object values that are found by\n traversing a path relative to the view itself:\n\n ```javascript\n MyView = Ember.View.extend({\n classNameBindings: ['messages.empty']\n messages: Ember.Object.create({\n empty: true\n })\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view empty\"></div>\n ```\n\n If you want to add a class name for a property which evaluates to true and\n and a different class name if it evaluates to false, you can pass a binding\n like this:\n\n ```javascript\n // Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false\n Ember.View.create({\n classNameBindings: ['isEnabled:enabled:disabled']\n isEnabled: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view enabled\"></div>\n ```\n\n When isEnabled is `false`, the resulting HTML reprensentation looks like\n this:\n\n ```html\n <div id=\"ember1\" class=\"ember-view disabled\"></div>\n ```\n\n This syntax offers the convenience to add a class if a property is `false`:\n\n ```javascript\n // Applies no class when isEnabled is true and class 'disabled' when isEnabled is false\n Ember.View.create({\n classNameBindings: ['isEnabled::disabled']\n isEnabled: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\"></div>\n ```\n\n When the `isEnabled` property on the view is set to `false`, it will result\n in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view disabled\"></div>\n ```\n\n Updates to the the value of a class name binding will result in automatic\n update of the HTML `class` attribute in the view's rendered HTML\n representation. If the value becomes `false` or `undefined` the class name\n will be removed.\n\n Both `classNames` and `classNameBindings` are concatenated properties. See\n `Ember.Object` documentation for more information about concatenated\n properties.\n\n ## HTML Attributes\n\n The HTML attribute section of a view's tag can be set by providing an\n `attributeBindings` property set to an array of property names on the view.\n The return value of these properties will be used as the value of the view's\n HTML associated attribute:\n\n ```javascript\n AnchorView = Ember.View.extend({\n tagName: 'a',\n attributeBindings: ['href'],\n href: 'http://google.com'\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <a id=\"ember1\" class=\"ember-view\" href=\"http://google.com\"></a>\n ```\n\n If the return value of an `attributeBindings` monitored property is a boolean\n the property will follow HTML's pattern of repeating the attribute's name as\n its value:\n\n ```javascript\n MyTextInput = Ember.View.extend({\n tagName: 'input',\n attributeBindings: ['disabled'],\n disabled: true\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <input id=\"ember1\" class=\"ember-view\" disabled=\"disabled\" />\n ```\n\n `attributeBindings` can refer to computed properties:\n\n ```javascript\n MyTextInput = Ember.View.extend({\n tagName: 'input',\n attributeBindings: ['disabled'],\n disabled: function(){\n if (someLogic) {\n return true;\n } else {\n return false;\n }\n }.property()\n });\n ```\n\n Updates to the the property of an attribute binding will result in automatic\n update of the HTML attribute in the view's rendered HTML representation.\n\n `attributeBindings` is a concatenated property. See `Ember.Object`\n documentation for more information about concatenated properties.\n\n ## Templates\n\n The HTML contents of a view's rendered representation are determined by its\n template. Templates can be any function that accepts an optional context\n parameter and returns a string of HTML that will be inserted within the\n view's tag. Most typically in Ember this function will be a compiled\n `Ember.Handlebars` template.\n\n ```javascript\n AView = Ember.View.extend({\n template: Ember.Handlebars.compile('I am the template')\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">I am the template</div>\n ```\n\n Within an Ember application is more common to define a Handlebars templates as\n part of a page:\n\n ```handlebars\n <script type='text/x-handlebars' data-template-name='some-template'>\n Hello\n </script>\n ```\n\n And associate it by name using a view's `templateName` property:\n\n ```javascript\n AView = Ember.View.extend({\n templateName: 'some-template'\n });\n ```\n\n Using a value for `templateName` that does not have a Handlebars template\n with a matching `data-template-name` attribute will throw an error.\n\n Assigning a value to both `template` and `templateName` properties will throw\n an error.\n\n For views classes that may have a template later defined (e.g. as the block\n portion of a `{{view}}` Handlebars helper call in another template or in\n a subclass), you can provide a `defaultTemplate` property set to compiled\n template function. If a template is not later provided for the view instance\n the `defaultTemplate` value will be used:\n\n ```javascript\n AView = Ember.View.extend({\n defaultTemplate: Ember.Handlebars.compile('I was the default'),\n template: null,\n templateName: null\n });\n ```\n\n Will result in instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">I was the default</div>\n ```\n\n If a `template` or `templateName` is provided it will take precedence over\n `defaultTemplate`:\n\n ```javascript\n AView = Ember.View.extend({\n defaultTemplate: Ember.Handlebars.compile('I was the default')\n });\n\n aView = AView.create({\n template: Ember.Handlebars.compile('I was the template, not default')\n });\n ```\n\n Will result in the following HTML representation when rendered:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">I was the template, not default</div>\n ```\n\n ## View Context\n\n The default context of the compiled template is the view's controller:\n\n ```javascript\n AView = Ember.View.extend({\n template: Ember.Handlebars.compile('Hello {{excitedGreeting}}')\n });\n\n aController = Ember.Object.create({\n firstName: 'Barry',\n excitedGreeting: function(){\n return this.get(\"content.firstName\") + \"!!!\"\n }.property()\n });\n\n aView = AView.create({\n controller: aController,\n });\n ```\n\n Will result in an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">Hello Barry!!!</div>\n ```\n\n A context can also be explicitly supplied through the view's `context`\n property. If the view has neither `context` nor `controller` properties, the\n `parentView`'s context will be used.\n\n ## Layouts\n\n Views can have a secondary template that wraps their main template. Like\n primary templates, layouts can be any function that accepts an optional\n context parameter and returns a string of HTML that will be inserted inside\n view's tag. Views whose HTML element is self closing (e.g. `<input />`)\n cannot have a layout and this property will be ignored.\n\n Most typically in Ember a layout will be a compiled `Ember.Handlebars`\n template.\n\n A view's layout can be set directly with the `layout` property or reference\n an existing Handlebars template by name with the `layoutName` property.\n\n A template used as a layout must contain a single use of the Handlebars\n `{{yield}}` helper. The HTML contents of a view's rendered `template` will be\n inserted at this location:\n\n ```javascript\n AViewWithLayout = Ember.View.extend({\n layout: Ember.Handlebars.compile(\"<div class='my-decorative-class'>{{yield}}</div>\")\n template: Ember.Handlebars.compile(\"I got wrapped\"),\n });\n ```\n\n Will result in view instances with an HTML representation of:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">\n <div class=\"my-decorative-class\">\n I got wrapped\n </div>\n </div>\n ```\n\n See `Handlebars.helpers.yield` for more information.\n\n ## Responding to Browser Events\n\n Views can respond to user-initiated events in one of three ways: method\n implementation, through an event manager, and through `{{action}}` helper use\n in their template or layout.\n\n ### Method Implementation\n\n Views can respond to user-initiated events by implementing a method that\n matches the event name. A `jQuery.Event` object will be passed as the\n argument to this method.\n\n ```javascript\n AView = Ember.View.extend({\n click: function(event){\n // will be called when when an instance's\n // rendered element is clicked\n }\n });\n ```\n\n ### Event Managers\n\n Views can define an object as their `eventManager` property. This object can\n then implement methods that match the desired event names. Matching events\n that occur on the view's rendered HTML or the rendered HTML of any of its DOM\n descendants will trigger this method. A `jQuery.Event` object will be passed\n as the first argument to the method and an `Ember.View` object as the\n second. The `Ember.View` will be the view whose rendered HTML was interacted\n with. This may be the view with the `eventManager` property or one of its\n descendent views.\n\n ```javascript\n AView = Ember.View.extend({\n eventManager: Ember.Object.create({\n doubleClick: function(event, view){\n // will be called when when an instance's\n // rendered element or any rendering\n // of this views's descendent\n // elements is clicked\n }\n })\n });\n ```\n\n An event defined for an event manager takes precedence over events of the\n same name handled through methods on the view.\n\n ```javascript\n AView = Ember.View.extend({\n mouseEnter: function(event){\n // will never trigger.\n },\n eventManager: Ember.Object.create({\n mouseEnter: function(event, view){\n // takes presedence over AView#mouseEnter\n }\n })\n });\n ```\n\n Similarly a view's event manager will take precedence for events of any views\n rendered as a descendent. A method name that matches an event name will not\n be called if the view instance was rendered inside the HTML representation of\n a view that has an `eventManager` property defined that handles events of the\n name. Events not handled by the event manager will still trigger method calls\n on the descendent.\n\n ```javascript\n OuterView = Ember.View.extend({\n template: Ember.Handlebars.compile(\"outer {{#view InnerView}}inner{{/view}} outer\"),\n eventManager: Ember.Object.create({\n mouseEnter: function(event, view){\n // view might be instance of either\n // OutsideView or InnerView depending on\n // where on the page the user interaction occured\n }\n })\n });\n\n InnerView = Ember.View.extend({\n click: function(event){\n // will be called if rendered inside\n // an OuterView because OuterView's\n // eventManager doesn't handle click events\n },\n mouseEnter: function(event){\n // will never be called if rendered inside\n // an OuterView.\n }\n });\n ```\n\n ### Handlebars `{{action}}` Helper\n\n See `Handlebars.helpers.action`.\n\n ### Event Names\n\n Possible events names for any of the responding approaches described above\n are:\n\n Touch events:\n\n * `touchStart`\n * `touchMove`\n * `touchEnd`\n * `touchCancel`\n\n Keyboard events\n\n * `keyDown`\n * `keyUp`\n * `keyPress`\n\n Mouse events\n\n * `mouseDown`\n * `mouseUp`\n * `contextMenu`\n * `click`\n * `doubleClick`\n * `mouseMove`\n * `focusIn`\n * `focusOut`\n * `mouseEnter`\n * `mouseLeave`\n\n Form events: \n\n * `submit`\n * `change`\n * `focusIn`\n * `focusOut`\n * `input`\n\n HTML5 drag and drop events: \n\n * `dragStart`\n * `drag`\n * `dragEnter`\n * `dragLeave`\n * `drop`\n * `dragEnd`\n\n ## Handlebars `{{view}}` Helper\n\n Other `Ember.View` instances can be included as part of a view's template by\n using the `{{view}}` Handlebars helper. See `Handlebars.helpers.view` for\n additional information.\n\n @class View\n @namespace Ember\n @extends Ember.Object\n @uses Ember.Evented\n*/\nEmber.View = Ember.CoreView.extend(\n/** @scope Ember.View.prototype */ {\n\n concatenatedProperties: ['classNames', 'classNameBindings', 'attributeBindings'],\n\n /**\n @property isView\n @type Boolean\n @default true\n @final\n */\n isView: true,\n\n // ..........................................................\n // TEMPLATE SUPPORT\n //\n\n /**\n The name of the template to lookup if no template is provided.\n\n `Ember.View` will look for a template with this name in this view's\n `templates` object. By default, this will be a global object\n shared in `Ember.TEMPLATES`.\n\n @property templateName\n @type String\n @default null\n */\n templateName: null,\n\n /**\n The name of the layout to lookup if no layout is provided.\n\n `Ember.View` will look for a template with this name in this view's\n `templates` object. By default, this will be a global object\n shared in `Ember.TEMPLATES`.\n\n @property layoutName\n @type String\n @default null\n */\n layoutName: null,\n\n /**\n The hash in which to look for `templateName`.\n\n @property templates\n @type Ember.Object\n @default Ember.TEMPLATES\n */\n templates: Ember.TEMPLATES,\n\n /**\n The template used to render the view. This should be a function that\n accepts an optional context parameter and returns a string of HTML that\n will be inserted into the DOM relative to its parent view.\n\n In general, you should set the `templateName` property instead of setting\n the template yourself.\n\n @property template\n @type Function\n */\n template: Ember.computed(function(key, value) {\n if (value !== undefined) { return value; }\n\n var templateName = get(this, 'templateName'),\n template = this.templateForName(templateName, 'template');\n\n return template || get(this, 'defaultTemplate');\n }).property('templateName'),\n\n container: Ember.computed(function() {\n var parentView = get(this, '_parentView');\n\n if (parentView) { return get(parentView, 'container'); }\n\n return Ember.Container && Ember.Container.defaultContainer;\n }),\n\n /**\n The controller managing this view. If this property is set, it will be\n made available for use by the template.\n\n @property controller\n @type Object\n */\n controller: Ember.computed(function(key) {\n var parentView = get(this, '_parentView');\n return parentView ? get(parentView, 'controller') : null;\n }).property('_parentView'),\n\n /**\n A view may contain a layout. A layout is a regular template but\n supersedes the `template` property during rendering. It is the\n responsibility of the layout template to retrieve the `template`\n property from the view (or alternatively, call `Handlebars.helpers.yield`,\n `{{yield}}`) to render it in the correct location.\n\n This is useful for a view that has a shared wrapper, but which delegates\n the rendering of the contents of the wrapper to the `template` property\n on a subclass.\n\n @property layout\n @type Function\n */\n layout: Ember.computed(function(key) {\n var layoutName = get(this, 'layoutName'),\n layout = this.templateForName(layoutName, 'layout');\n\n return layout || get(this, 'defaultLayout');\n }).property('layoutName'),\n\n templateForName: function(name, type) {\n if (!name) { return; }\n\n Ember.assert(\"templateNames are not allowed to contain periods: \"+name, name.indexOf('.') === -1);\n\n var container = get(this, 'container');\n\n if (container) {\n return container.lookup('template:' + name);\n }\n },\n\n /**\n The object from which templates should access properties.\n\n This object will be passed to the template function each time the render\n method is called, but it is up to the individual function to decide what\n to do with it.\n\n By default, this will be the view's controller.\n\n @property context\n @type Object\n */\n context: Ember.computed(function(key, value) {\n if (arguments.length === 2) {\n set(this, '_context', value);\n return value;\n } else {\n return get(this, '_context');\n }\n }).volatile(),\n\n /**\n @private\n\n Private copy of the view's template context. This can be set directly\n by Handlebars without triggering the observer that causes the view\n to be re-rendered.\n\n The context of a view is looked up as follows:\n\n 1. Supplied context (usually by Handlebars)\n 2. Specified controller\n 3. `parentView`'s context (for a child of a ContainerView)\n\n The code in Handlebars that overrides the `_context` property first\n checks to see whether the view has a specified controller. This is\n something of a hack and should be revisited.\n\n @property _context\n */\n _context: Ember.computed(function(key) {\n var parentView, controller;\n\n if (controller = get(this, 'controller')) {\n return controller;\n }\n\n parentView = this._parentView;\n if (parentView) {\n return get(parentView, '_context');\n }\n\n return null;\n }),\n\n /**\n @private\n\n If a value that affects template rendering changes, the view should be\n re-rendered to reflect the new value.\n\n @method _displayPropertyDidChange\n */\n _contextDidChange: Ember.observer(function() {\n this.rerender();\n }, 'context'),\n\n /**\n If `false`, the view will appear hidden in DOM.\n\n @property isVisible\n @type Boolean\n @default null\n */\n isVisible: true,\n\n /**\n @private\n\n Array of child views. You should never edit this array directly.\n Instead, use `appendChild` and `removeFromParent`.\n\n @property childViews\n @type Array\n @default []\n */\n childViews: childViewsProperty,\n\n _childViews: [],\n\n // When it's a virtual view, we need to notify the parent that their\n // childViews will change.\n _childViewsWillChange: Ember.beforeObserver(function() {\n if (this.isVirtual) {\n var parentView = get(this, 'parentView');\n if (parentView) { Ember.propertyWillChange(parentView, 'childViews'); }\n }\n }, 'childViews'),\n\n // When it's a virtual view, we need to notify the parent that their\n // childViews did change.\n _childViewsDidChange: Ember.observer(function() {\n if (this.isVirtual) {\n var parentView = get(this, 'parentView');\n if (parentView) { Ember.propertyDidChange(parentView, 'childViews'); }\n }\n }, 'childViews'),\n\n /**\n Return the nearest ancestor that is an instance of the provided\n class.\n\n @property nearestInstanceOf\n @param {Class} klass Subclass of Ember.View (or Ember.View itself)\n @return Ember.View\n @deprecated\n */\n nearestInstanceOf: function(klass) {\n Ember.deprecate(\"nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType.\");\n var view = get(this, 'parentView');\n\n while (view) {\n if(view instanceof klass) { return view; }\n view = get(view, 'parentView');\n }\n },\n\n /**\n Return the nearest ancestor that is an instance of the provided\n class or mixin.\n\n @property nearestOfType\n @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself),\n or an instance of Ember.Mixin.\n @return Ember.View\n */\n nearestOfType: function(klass) {\n var view = get(this, 'parentView'),\n isOfType = klass instanceof Ember.Mixin ?\n function(view) { return klass.detect(view); } :\n function(view) { return klass.detect(view.constructor); };\n\n while (view) {\n if( isOfType(view) ) { return view; }\n view = get(view, 'parentView');\n }\n },\n\n /**\n Return the nearest ancestor that has a given property.\n\n @property nearestWithProperty\n @param {String} property A property name\n @return Ember.View\n */\n nearestWithProperty: function(property) {\n var view = get(this, 'parentView');\n\n while (view) {\n if (property in view) { return view; }\n view = get(view, 'parentView');\n }\n },\n\n /**\n Return the nearest ancestor whose parent is an instance of\n `klass`.\n\n @property nearestChildOf\n @param {Class} klass Subclass of Ember.View (or Ember.View itself)\n @return Ember.View\n */\n nearestChildOf: function(klass) {\n var view = get(this, 'parentView');\n\n while (view) {\n if(get(view, 'parentView') instanceof klass) { return view; }\n view = get(view, 'parentView');\n }\n },\n\n /**\n @private\n\n When the parent view changes, recursively invalidate `controller`\n\n @method _parentViewDidChange\n */\n _parentViewDidChange: Ember.observer(function() {\n if (this.isDestroying) { return; }\n\n if (get(this, 'parentView.controller') && !get(this, 'controller')) {\n this.notifyPropertyChange('controller');\n }\n }, '_parentView'),\n\n _controllerDidChange: Ember.observer(function() {\n if (this.isDestroying) { return; }\n\n this.rerender();\n\n this.forEachChildView(function(view) {\n view.propertyDidChange('controller');\n });\n }, 'controller'),\n\n cloneKeywords: function() {\n var templateData = get(this, 'templateData');\n\n var keywords = templateData ? Ember.copy(templateData.keywords) : {};\n set(keywords, 'view', get(this, 'concreteView'));\n set(keywords, '_view', this);\n set(keywords, 'controller', get(this, 'controller'));\n\n return keywords;\n },\n\n /**\n Called on your view when it should push strings of HTML into a\n `Ember.RenderBuffer`. Most users will want to override the `template`\n or `templateName` properties instead of this method.\n\n By default, `Ember.View` will look for a function in the `template`\n property and invoke it with the value of `context`. The value of\n `context` will be the view's controller unless you override it.\n\n @method render\n @param {Ember.RenderBuffer} buffer The render buffer\n */\n render: function(buffer) {\n // If this view has a layout, it is the responsibility of the\n // the layout to render the view's template. Otherwise, render the template\n // directly.\n var template = get(this, 'layout') || get(this, 'template');\n\n if (template) {\n var context = get(this, 'context');\n var keywords = this.cloneKeywords();\n var output;\n\n var data = {\n view: this,\n buffer: buffer,\n isRenderData: true,\n keywords: keywords,\n insideGroup: get(this, 'templateData.insideGroup')\n };\n\n // Invoke the template with the provided template context, which\n // is the view's controller by default. A hash of data is also passed that provides\n // the template with access to the view and render buffer.\n\n Ember.assert('template must be a function. Did you mean to call Ember.Handlebars.compile(\"...\") or specify templateName instead?', typeof template === 'function');\n // The template should write directly to the render buffer instead\n // of returning a string.\n output = template(context, { data: data });\n\n // If the template returned a string instead of writing to the buffer,\n // push the string onto the buffer.\n if (output !== undefined) { buffer.push(output); }\n }\n },\n\n /**\n Renders the view again. This will work regardless of whether the\n view is already in the DOM or not. If the view is in the DOM, the\n rendering process will be deferred to give bindings a chance\n to synchronize.\n\n If children were added during the rendering process using `appendChild`,\n `rerender` will remove them, because they will be added again\n if needed by the next `render`.\n\n In general, if the display of your view changes, you should modify\n the DOM element directly instead of manually calling `rerender`, which can\n be slow.\n\n @method rerender\n */\n rerender: function() {\n return this.currentState.rerender(this);\n },\n\n clearRenderedChildren: function() {\n var lengthBefore = this.lengthBeforeRender,\n lengthAfter = this.lengthAfterRender;\n\n // If there were child views created during the last call to render(),\n // remove them under the assumption that they will be re-created when\n // we re-render.\n\n // VIEW-TODO: Unit test this path.\n var childViews = this._childViews;\n for (var i=lengthAfter-1; i>=lengthBefore; i--) {\n if (childViews[i]) { childViews[i].destroy(); }\n }\n },\n\n /**\n @private\n\n Iterates over the view's `classNameBindings` array, inserts the value\n of the specified property into the `classNames` array, then creates an\n observer to update the view's element if the bound property ever changes\n in the future.\n\n @method _applyClassNameBindings\n */\n _applyClassNameBindings: function(classBindings) {\n var classNames = this.classNames,\n elem, newClass, dasherizedClass;\n\n // Loop through all of the configured bindings. These will be either\n // property names ('isUrgent') or property paths relative to the view\n // ('content.isUrgent')\n a_forEach(classBindings, function(binding) {\n\n // Variable in which the old class value is saved. The observer function\n // closes over this variable, so it knows which string to remove when\n // the property changes.\n var oldClass;\n // Extract just the property name from bindings like 'foo:bar'\n var parsedPath = Ember.View._parsePropertyPath(binding);\n\n // Set up an observer on the context. If the property changes, toggle the\n // class name.\n var observer = function() {\n // Get the current value of the property\n newClass = this._classStringForProperty(binding);\n elem = this.$();\n\n // If we had previously added a class to the element, remove it.\n if (oldClass) {\n elem.removeClass(oldClass);\n // Also remove from classNames so that if the view gets rerendered,\n // the class doesn't get added back to the DOM.\n classNames.removeObject(oldClass);\n }\n\n // If necessary, add a new class. Make sure we keep track of it so\n // it can be removed in the future.\n if (newClass) {\n elem.addClass(newClass);\n oldClass = newClass;\n } else {\n oldClass = null;\n }\n };\n\n // Get the class name for the property at its current value\n dasherizedClass = this._classStringForProperty(binding);\n\n if (dasherizedClass) {\n // Ensure that it gets into the classNames array\n // so it is displayed when we render.\n a_addObject(classNames, dasherizedClass);\n\n // Save a reference to the class name so we can remove it\n // if the observer fires. Remember that this variable has\n // been closed over by the observer.\n oldClass = dasherizedClass;\n }\n\n addObserver(this, parsedPath.path, observer);\n\n this.one('willClearRender', function() {\n removeObserver(this, parsedPath.path, observer);\n });\n }, this);\n },\n\n /**\n @private\n\n Iterates through the view's attribute bindings, sets up observers for each,\n then applies the current value of the attributes to the passed render buffer.\n\n @method _applyAttributeBindings\n @param {Ember.RenderBuffer} buffer\n */\n _applyAttributeBindings: function(buffer, attributeBindings) {\n var attributeValue, elem, type;\n\n a_forEach(attributeBindings, function(binding) {\n var split = binding.split(':'),\n property = split[0],\n attributeName = split[1] || property;\n\n // Create an observer to add/remove/change the attribute if the\n // JavaScript property changes.\n var observer = function() {\n elem = this.$();\n if (!elem) { return; }\n\n attributeValue = get(this, property);\n\n Ember.View.applyAttributeBindings(elem, attributeName, attributeValue);\n };\n\n addObserver(this, property, observer);\n\n this.one('willClearRender', function() {\n removeObserver(this, property, observer);\n });\n\n // Determine the current value and add it to the render buffer\n // if necessary.\n attributeValue = get(this, property);\n Ember.View.applyAttributeBindings(buffer, attributeName, attributeValue);\n }, this);\n },\n\n /**\n @private\n\n Given a property name, returns a dasherized version of that\n property name if the property evaluates to a non-falsy value.\n\n For example, if the view has property `isUrgent` that evaluates to true,\n passing `isUrgent` to this method will return `\"is-urgent\"`.\n\n @method _classStringForProperty\n @param property\n */\n _classStringForProperty: function(property) {\n var parsedPath = Ember.View._parsePropertyPath(property);\n var path = parsedPath.path;\n\n var val = get(this, path);\n if (val === undefined && Ember.isGlobalPath(path)) {\n val = get(Ember.lookup, path);\n }\n\n return Ember.View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);\n },\n\n // ..........................................................\n // ELEMENT SUPPORT\n //\n\n /**\n Returns the current DOM element for the view.\n\n @property element\n @type DOMElement\n */\n element: Ember.computed(function(key, value) {\n if (value !== undefined) {\n return this.currentState.setElement(this, value);\n } else {\n return this.currentState.getElement(this);\n }\n }).property('_parentView'),\n\n /**\n Returns a jQuery object for this view's element. If you pass in a selector\n string, this method will return a jQuery object, using the current element\n as its buffer.\n\n For example, calling `view.$('li')` will return a jQuery object containing\n all of the `li` elements inside the DOM element of this view.\n\n @property $\n @param {String} [selector] a jQuery-compatible selector string\n @return {jQuery} the CoreQuery object for the DOM node\n */\n $: function(sel) {\n return this.currentState.$(this, sel);\n },\n\n mutateChildViews: function(callback) {\n var childViews = this._childViews,\n idx = childViews.length,\n view;\n\n while(--idx >= 0) {\n view = childViews[idx];\n callback.call(this, view, idx);\n }\n\n return this;\n },\n\n forEachChildView: function(callback) {\n var childViews = this._childViews;\n\n if (!childViews) { return this; }\n\n var len = childViews.length,\n view, idx;\n\n for(idx = 0; idx < len; idx++) {\n view = childViews[idx];\n callback.call(this, view);\n }\n\n return this;\n },\n\n /**\n Appends the view's element to the specified parent element.\n\n If the view does not have an HTML representation yet, `createElement()`\n will be called automatically.\n\n Note that this method just schedules the view to be appended; the DOM\n element will not be appended to the given element until all bindings have\n finished synchronizing.\n\n This is not typically a function that you will need to call directly when\n building your application. You might consider using `Ember.ContainerView`\n instead. If you do need to use `appendTo`, be sure that the target element\n you are providing is associated with an `Ember.Application` and does not\n have an ancestor element that is associated with an Ember view.\n\n @method appendTo\n @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object\n @return {Ember.View} receiver\n */\n appendTo: function(target) {\n // Schedule the DOM element to be created and appended to the given\n // element after bindings have synchronized.\n this._insertElementLater(function() {\n Ember.assert(\"You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.\", !Ember.$(target).is('.ember-view') && !Ember.$(target).parents().is('.ember-view'));\n this.$().appendTo(target);\n });\n\n return this;\n },\n\n /**\n Replaces the content of the specified parent element with this view's\n element. If the view does not have an HTML representation yet,\n `createElement()` will be called automatically.\n\n Note that this method just schedules the view to be appended; the DOM\n element will not be appended to the given element until all bindings have\n finished synchronizing\n\n @method replaceIn\n @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object\n @return {Ember.View} received\n */\n replaceIn: function(target) {\n Ember.assert(\"You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.\", !Ember.$(target).is('.ember-view') && !Ember.$(target).parents().is('.ember-view'));\n\n this._insertElementLater(function() {\n Ember.$(target).empty();\n this.$().appendTo(target);\n });\n\n return this;\n },\n\n /**\n @private\n\n Schedules a DOM operation to occur during the next render phase. This\n ensures that all bindings have finished synchronizing before the view is\n rendered.\n\n To use, pass a function that performs a DOM operation.\n\n Before your function is called, this view and all child views will receive\n the `willInsertElement` event. After your function is invoked, this view\n and all of its child views will receive the `didInsertElement` event.\n\n ```javascript\n view._insertElementLater(function() {\n this.createElement();\n this.$().appendTo('body');\n });\n ```\n\n @method _insertElementLater\n @param {Function} fn the function that inserts the element into the DOM\n */\n _insertElementLater: function(fn) {\n this._scheduledInsert = Ember.run.scheduleOnce('render', this, '_insertElement', fn);\n },\n\n /**\n @private\n */\n _insertElement: function (fn) {\n this._scheduledInsert = null;\n this.currentState.insertElement(this, fn);\n },\n\n /**\n Appends the view's element to the document body. If the view does\n not have an HTML representation yet, `createElement()` will be called\n automatically.\n\n Note that this method just schedules the view to be appended; the DOM\n element will not be appended to the document body until all bindings have\n finished synchronizing.\n\n @method append\n @return {Ember.View} receiver\n */\n append: function() {\n return this.appendTo(document.body);\n },\n\n /**\n Removes the view's element from the element to which it is attached.\n\n @method remove\n @return {Ember.View} receiver\n */\n remove: function() {\n // What we should really do here is wait until the end of the run loop\n // to determine if the element has been re-appended to a different\n // element.\n // In the interim, we will just re-render if that happens. It is more\n // important than elements get garbage collected.\n this.destroyElement();\n this.invokeRecursively(function(view) {\n if (view.clearRenderedChildren) { view.clearRenderedChildren(); }\n });\n },\n\n elementId: null,\n\n /**\n Attempts to discover the element in the parent element. The default\n implementation looks for an element with an ID of `elementId` (or the\n view's guid if `elementId` is null). You can override this method to\n provide your own form of lookup. For example, if you want to discover your\n element using a CSS class name instead of an ID.\n\n @method findElementInParentElement\n @param {DOMElement} parentElement The parent's DOM element\n @return {DOMElement} The discovered element\n */\n findElementInParentElement: function(parentElem) {\n var id = \"#\" + this.elementId;\n return Ember.$(id)[0] || Ember.$(id, parentElem)[0];\n },\n\n /**\n Creates a DOM representation of the view and all of its\n child views by recursively calling the `render()` method.\n\n After the element has been created, `didInsertElement` will\n be called on this view and all of its child views.\n\n @method createElement\n @return {Ember.View} receiver\n */\n createElement: function() {\n if (get(this, 'element')) { return this; }\n\n var buffer = this.renderToBuffer();\n set(this, 'element', buffer.element());\n\n return this;\n },\n\n /**\n Called when a view is going to insert an element into the DOM.\n\n @event willInsertElement\n */\n willInsertElement: Ember.K,\n\n /**\n Called when the element of the view has been inserted into the DOM.\n Override this function to do any set up that requires an element in the\n document body.\n\n @event didInsertElement\n */\n didInsertElement: Ember.K,\n\n /**\n Called when the view is about to rerender, but before anything has\n been torn down. This is a good opportunity to tear down any manual\n observers you have installed based on the DOM state\n\n @event willClearRender\n */\n willClearRender: Ember.K,\n\n /**\n @private\n\n Run this callback on the current view and recursively on child views.\n\n @method invokeRecursively\n @param fn {Function}\n */\n invokeRecursively: function(fn) {\n var childViews = [this], currentViews, view;\n\n while (childViews.length) {\n currentViews = childViews.slice();\n childViews = [];\n\n for (var i=0, l=currentViews.length; i<l; i++) {\n view = currentViews[i];\n fn.call(view, view);\n if (view._childViews) {\n childViews.push.apply(childViews, view._childViews);\n }\n }\n }\n },\n\n triggerRecursively: function(eventName) {\n var childViews = [this], currentViews, view;\n\n while (childViews.length) {\n currentViews = childViews.slice();\n childViews = [];\n\n for (var i=0, l=currentViews.length; i<l; i++) {\n view = currentViews[i];\n if (view.trigger) { view.trigger(eventName); }\n if (view._childViews) {\n childViews.push.apply(childViews, view._childViews);\n }\n }\n }\n },\n\n /**\n Destroys any existing element along with the element for any child views\n as well. If the view does not currently have a element, then this method\n will do nothing.\n\n If you implement `willDestroyElement()` on your view, then this method will\n be invoked on your view before your element is destroyed to give you a\n chance to clean up any event handlers, etc.\n\n If you write a `willDestroyElement()` handler, you can assume that your\n `didInsertElement()` handler was called earlier for the same element.\n\n Normally you will not call or override this method yourself, but you may\n want to implement the above callbacks when it is run.\n\n @method destroyElement\n @return {Ember.View} receiver\n */\n destroyElement: function() {\n return this.currentState.destroyElement(this);\n },\n\n /**\n Called when the element of the view is going to be destroyed. Override\n this function to do any teardown that requires an element, like removing\n event listeners.\n\n @event willDestroyElement\n */\n willDestroyElement: function() {},\n\n /**\n @private\n\n Triggers the `willDestroyElement` event (which invokes the\n `willDestroyElement()` method if it exists) on this view and all child\n views.\n\n Before triggering `willDestroyElement`, it first triggers the\n `willClearRender` event recursively.\n\n @method _notifyWillDestroyElement\n */\n _notifyWillDestroyElement: function() {\n this.triggerRecursively('willClearRender');\n this.triggerRecursively('willDestroyElement');\n },\n\n _elementWillChange: Ember.beforeObserver(function() {\n this.forEachChildView(function(view) {\n Ember.propertyWillChange(view, 'element');\n });\n }, 'element'),\n\n /**\n @private\n\n If this view's element changes, we need to invalidate the caches of our\n child views so that we do not retain references to DOM elements that are\n no longer needed.\n\n @method _elementDidChange\n */\n _elementDidChange: Ember.observer(function() {\n this.forEachChildView(function(view) {\n Ember.propertyDidChange(view, 'element');\n });\n }, 'element'),\n\n /**\n Called when the parentView property has changed.\n\n @event parentViewDidChange\n */\n parentViewDidChange: Ember.K,\n\n instrumentName: 'view',\n\n instrumentDetails: function(hash) {\n hash.template = get(this, 'templateName');\n this._super(hash);\n },\n\n _renderToBuffer: function(parentBuffer, bufferOperation) {\n this.lengthBeforeRender = this._childViews.length;\n var buffer = this._super(parentBuffer, bufferOperation);\n this.lengthAfterRender = this._childViews.length;\n\n return buffer;\n },\n\n renderToBufferIfNeeded: function () {\n return this.currentState.renderToBufferIfNeeded(this, this);\n },\n\n beforeRender: function(buffer) {\n this.applyAttributesToBuffer(buffer);\n buffer.pushOpeningTag();\n },\n\n afterRender: function(buffer) {\n buffer.pushClosingTag();\n },\n\n applyAttributesToBuffer: function(buffer) {\n // Creates observers for all registered class name and attribute bindings,\n // then adds them to the element.\n var classNameBindings = get(this, 'classNameBindings');\n if (classNameBindings.length) {\n this._applyClassNameBindings(classNameBindings);\n }\n\n // Pass the render buffer so the method can apply attributes directly.\n // This isn't needed for class name bindings because they use the\n // existing classNames infrastructure.\n var attributeBindings = get(this, 'attributeBindings');\n if (attributeBindings.length) {\n this._applyAttributeBindings(buffer, attributeBindings);\n }\n\n buffer.setClasses(this.classNames);\n buffer.id(this.elementId);\n\n var role = get(this, 'ariaRole');\n if (role) {\n buffer.attr('role', role);\n }\n\n if (get(this, 'isVisible') === false) {\n buffer.style('display', 'none');\n }\n },\n\n // ..........................................................\n // STANDARD RENDER PROPERTIES\n //\n\n /**\n Tag name for the view's outer element. The tag name is only used when an\n element is first created. If you change the `tagName` for an element, you\n must destroy and recreate the view element.\n\n By default, the render buffer will use a `<div>` tag for views.\n\n @property tagName\n @type String\n @default null\n */\n\n // We leave this null by default so we can tell the difference between\n // the default case and a user-specified tag.\n tagName: null,\n\n /**\n The WAI-ARIA role of the control represented by this view. For example, a\n button may have a role of type 'button', or a pane may have a role of\n type 'alertdialog'. This property is used by assistive software to help\n visually challenged users navigate rich web applications.\n\n The full list of valid WAI-ARIA roles is available at:\n http://www.w3.org/TR/wai-aria/roles#roles_categorization\n\n @property ariaRole\n @type String\n @default null\n */\n ariaRole: null,\n\n /**\n Standard CSS class names to apply to the view's outer element. This\n property automatically inherits any class names defined by the view's\n superclasses as well.\n\n @property classNames\n @type Array\n @default ['ember-view']\n */\n classNames: ['ember-view'],\n\n /**\n A list of properties of the view to apply as class names. If the property\n is a string value, the value of that string will be applied as a class\n name.\n\n ```javascript\n // Applies the 'high' class to the view element\n Ember.View.create({\n classNameBindings: ['priority']\n priority: 'high'\n });\n ```\n\n If the value of the property is a Boolean, the name of that property is\n added as a dasherized class name.\n\n ```javascript\n // Applies the 'is-urgent' class to the view element\n Ember.View.create({\n classNameBindings: ['isUrgent']\n isUrgent: true\n });\n ```\n\n If you would prefer to use a custom value instead of the dasherized\n property name, you can pass a binding like this:\n\n ```javascript\n // Applies the 'urgent' class to the view element\n Ember.View.create({\n classNameBindings: ['isUrgent:urgent']\n isUrgent: true\n });\n ```\n\n This list of properties is inherited from the view's superclasses as well.\n\n @property classNameBindings\n @type Array\n @default []\n */\n classNameBindings: [],\n\n /**\n A list of properties of the view to apply as attributes. If the property is\n a string value, the value of that string will be applied as the attribute.\n\n ```javascript\n // Applies the type attribute to the element\n // with the value \"button\", like <div type=\"button\">\n Ember.View.create({\n attributeBindings: ['type'],\n type: 'button'\n });\n ```\n\n If the value of the property is a Boolean, the name of that property is\n added as an attribute.\n\n ```javascript\n // Renders something like <div enabled=\"enabled\">\n Ember.View.create({\n attributeBindings: ['enabled'],\n enabled: true\n });\n ```\n\n @property attributeBindings\n */\n attributeBindings: [],\n\n // .......................................................\n // CORE DISPLAY METHODS\n //\n\n /**\n @private\n\n Setup a view, but do not finish waking it up.\n - configure `childViews`\n - register the view with the global views hash, which is used for event\n dispatch\n\n @method init\n */\n init: function() {\n this.elementId = this.elementId || guidFor(this);\n\n this._super();\n\n // setup child views. be sure to clone the child views array first\n this._childViews = this._childViews.slice();\n\n Ember.assert(\"Only arrays are allowed for 'classNameBindings'\", Ember.typeOf(this.classNameBindings) === 'array');\n this.classNameBindings = Ember.A(this.classNameBindings.slice());\n\n Ember.assert(\"Only arrays are allowed for 'classNames'\", Ember.typeOf(this.classNames) === 'array');\n this.classNames = Ember.A(this.classNames.slice());\n\n var viewController = get(this, 'viewController');\n if (viewController) {\n viewController = get(viewController);\n if (viewController) {\n set(viewController, 'view', this);\n }\n }\n },\n\n appendChild: function(view, options) {\n return this.currentState.appendChild(this, view, options);\n },\n\n /**\n Removes the child view from the parent view.\n\n @method removeChild\n @param {Ember.View} view\n @return {Ember.View} receiver\n */\n removeChild: function(view) {\n // If we're destroying, the entire subtree will be\n // freed, and the DOM will be handled separately,\n // so no need to mess with childViews.\n if (this.isDestroying) { return; }\n\n // update parent node\n set(view, '_parentView', null);\n\n // remove view from childViews array.\n var childViews = this._childViews;\n\n Ember.EnumerableUtils.removeObject(childViews, view);\n\n this.propertyDidChange('childViews'); // HUH?! what happened to will change?\n\n return this;\n },\n\n /**\n Removes all children from the `parentView`.\n\n @method removeAllChildren\n @return {Ember.View} receiver\n */\n removeAllChildren: function() {\n return this.mutateChildViews(function(view) {\n this.removeChild(view);\n });\n },\n\n destroyAllChildren: function() {\n return this.mutateChildViews(function(view) {\n view.destroy();\n });\n },\n\n /**\n Removes the view from its `parentView`, if one is found. Otherwise\n does nothing.\n\n @method removeFromParent\n @return {Ember.View} receiver\n */\n removeFromParent: function() {\n var parent = this._parentView;\n\n // Remove DOM element from parent\n this.remove();\n\n if (parent) { parent.removeChild(this); }\n return this;\n },\n\n /**\n You must call `destroy` on a view to destroy the view (and all of its\n child views). This will remove the view from any parent node, then make\n sure that the DOM element managed by the view can be released by the\n memory manager.\n\n @method willDestroy\n */\n willDestroy: function() {\n // calling this._super() will nuke computed properties and observers,\n // so collect any information we need before calling super.\n var childViews = this._childViews,\n parent = this._parentView,\n childLen;\n\n // destroy the element -- this will avoid each child view destroying\n // the element over and over again...\n if (!this.removedFromDOM) { this.destroyElement(); }\n\n // remove from non-virtual parent view if viewName was specified\n if (this.viewName) {\n var nonVirtualParentView = get(this, 'parentView');\n if (nonVirtualParentView) {\n set(nonVirtualParentView, this.viewName, null);\n }\n }\n\n // remove from parent if found. Don't call removeFromParent,\n // as removeFromParent will try to remove the element from\n // the DOM again.\n if (parent) { parent.removeChild(this); }\n\n this.transitionTo('destroyed');\n\n childLen = childViews.length;\n for (var i=childLen-1; i>=0; i--) {\n childViews[i].removedFromDOM = true;\n childViews[i].destroy();\n }\n\n // next remove view from global hash\n if (!this.isVirtual) delete Ember.View.views[get(this, 'elementId')];\n },\n\n /**\n Instantiates a view to be added to the childViews array during view\n initialization. You generally will not call this method directly unless\n you are overriding `createChildViews()`. Note that this method will\n automatically configure the correct settings on the new view instance to\n act as a child of the parent.\n\n @method createChildView\n @param {Class} viewClass\n @param {Hash} [attrs] Attributes to add\n @return {Ember.View} new instance\n */\n createChildView: function(view, attrs) {\n if (view.isView && view._parentView === this) { return view; }\n\n if (Ember.CoreView.detect(view)) {\n attrs = attrs || {};\n attrs._parentView = this;\n attrs.templateData = attrs.templateData || get(this, 'templateData');\n\n view = view.create(attrs);\n\n // don't set the property on a virtual view, as they are invisible to\n // consumers of the view API\n if (view.viewName) { set(get(this, 'concreteView'), view.viewName, view); }\n } else {\n Ember.assert('You must pass instance or subclass of View', view.isView);\n Ember.assert(\"You can only pass attributes when a class is provided\", !attrs);\n\n if (!get(view, 'templateData')) {\n set(view, 'templateData', get(this, 'templateData'));\n }\n\n set(view, '_parentView', this);\n }\n\n return view;\n },\n\n becameVisible: Ember.K,\n becameHidden: Ember.K,\n\n /**\n @private\n\n When the view's `isVisible` property changes, toggle the visibility\n element of the actual DOM element.\n\n @method _isVisibleDidChange\n */\n _isVisibleDidChange: Ember.observer(function() {\n var $el = this.$();\n if (!$el) { return; }\n\n var isVisible = get(this, 'isVisible');\n\n $el.toggle(isVisible);\n\n if (this._isAncestorHidden()) { return; }\n\n if (isVisible) {\n this._notifyBecameVisible();\n } else {\n this._notifyBecameHidden();\n }\n }, 'isVisible'),\n\n _notifyBecameVisible: function() {\n this.trigger('becameVisible');\n\n this.forEachChildView(function(view) {\n var isVisible = get(view, 'isVisible');\n\n if (isVisible || isVisible === null) {\n view._notifyBecameVisible();\n }\n });\n },\n\n _notifyBecameHidden: function() {\n this.trigger('becameHidden');\n this.forEachChildView(function(view) {\n var isVisible = get(view, 'isVisible');\n\n if (isVisible || isVisible === null) {\n view._notifyBecameHidden();\n }\n });\n },\n\n _isAncestorHidden: function() {\n var parent = get(this, 'parentView');\n\n while (parent) {\n if (get(parent, 'isVisible') === false) { return true; }\n\n parent = get(parent, 'parentView');\n }\n\n return false;\n },\n\n clearBuffer: function() {\n this.invokeRecursively(function(view) {\n view.buffer = null;\n });\n },\n\n transitionTo: function(state, children) {\n this.currentState = this.states[state];\n this.state = state;\n\n if (children !== false) {\n this.forEachChildView(function(view) {\n view.transitionTo(state);\n });\n }\n },\n\n // .......................................................\n // EVENT HANDLING\n //\n\n /**\n @private\n\n Handle events from `Ember.EventDispatcher`\n\n @method handleEvent\n @param eventName {String}\n @param evt {Event}\n */\n handleEvent: function(eventName, evt) {\n return this.currentState.handleEvent(this, eventName, evt);\n }\n\n});\n\n/*\n Describe how the specified actions should behave in the various\n states that a view can exist in. Possible states:\n\n * preRender: when a view is first instantiated, and after its\n element was destroyed, it is in the preRender state\n * inBuffer: once a view has been rendered, but before it has\n been inserted into the DOM, it is in the inBuffer state\n * inDOM: once a view has been inserted into the DOM it is in\n the inDOM state. A view spends the vast majority of its\n existence in this state.\n * destroyed: once a view has been destroyed (using the destroy\n method), it is in this state. No further actions can be invoked\n on a destroyed view.\n*/\n\n // in the destroyed state, everything is illegal\n\n // before rendering has begun, all legal manipulations are noops.\n\n // inside the buffer, legal manipulations are done on the buffer\n\n // once the view has been inserted into the DOM, legal manipulations\n // are done on the DOM element.\n\nvar DOMManager = {\n prepend: function(view, html) {\n view.$().prepend(html);\n },\n\n after: function(view, html) {\n view.$().after(html);\n },\n\n html: function(view, html) {\n view.$().html(html);\n },\n\n replace: function(view) {\n var element = get(view, 'element');\n\n set(view, 'element', null);\n\n view._insertElementLater(function() {\n Ember.$(element).replaceWith(get(view, 'element'));\n });\n },\n\n remove: function(view) {\n view.$().remove();\n },\n\n empty: function(view) {\n view.$().empty();\n }\n};\n\nEmber.View.reopen({\n domManager: DOMManager\n});\n\nEmber.View.reopenClass({\n\n /**\n @private\n\n Parse a path and return an object which holds the parsed properties.\n\n For example a path like \"content.isEnabled:enabled:disabled\" wil return the\n following object:\n\n ```javascript\n {\n path: \"content.isEnabled\",\n className: \"enabled\",\n falsyClassName: \"disabled\",\n classNames: \":enabled:disabled\"\n }\n ```\n\n @method _parsePropertyPath\n @static\n */\n _parsePropertyPath: function(path) {\n var split = path.split(':'),\n propertyPath = split[0],\n classNames = \"\",\n className,\n falsyClassName;\n\n // check if the property is defined as prop:class or prop:trueClass:falseClass\n if (split.length > 1) {\n className = split[1];\n if (split.length === 3) { falsyClassName = split[2]; }\n\n classNames = ':' + className;\n if (falsyClassName) { classNames += \":\" + falsyClassName; }\n }\n\n return {\n path: propertyPath,\n classNames: classNames,\n className: (className === '') ? undefined : className,\n falsyClassName: falsyClassName\n };\n },\n\n /**\n @private\n\n Get the class name for a given value, based on the path, optional\n `className` and optional `falsyClassName`.\n\n - if a `className` or `falsyClassName` has been specified:\n - if the value is truthy and `className` has been specified, \n `className` is returned\n - if the value is falsy and `falsyClassName` has been specified, \n `falsyClassName` is returned\n - otherwise `null` is returned\n - if the value is `true`, the dasherized last part of the supplied path \n is returned\n - if the value is not `false`, `undefined` or `null`, the `value` \n is returned\n - if none of the above rules apply, `null` is returned\n\n @method _classStringForValue\n @param path\n @param val\n @param className\n @param falsyClassName\n @static\n */\n _classStringForValue: function(path, val, className, falsyClassName) {\n // When using the colon syntax, evaluate the truthiness or falsiness\n // of the value to determine which className to return\n if (className || falsyClassName) {\n if (className && !!val) {\n return className;\n\n } else if (falsyClassName && !val) {\n return falsyClassName;\n\n } else {\n return null;\n }\n\n // If value is a Boolean and true, return the dasherized property\n // name.\n } else if (val === true) {\n // Normalize property path to be suitable for use\n // as a class name. For exaple, content.foo.barBaz\n // becomes bar-baz.\n var parts = path.split('.');\n return Ember.String.dasherize(parts[parts.length-1]);\n\n // If the value is not false, undefined, or null, return the current\n // value of the property.\n } else if (val !== false && val !== undefined && val !== null) {\n return val;\n\n // Nothing to display. Return null so that the old class is removed\n // but no new class is added.\n } else {\n return null;\n }\n }\n});\n\n/**\n Global views hash\n\n @property views\n @static\n @type Hash\n*/\nEmber.View.views = {};\n\n// If someone overrides the child views computed property when\n// defining their class, we want to be able to process the user's\n// supplied childViews and then restore the original computed property\n// at view initialization time. This happens in Ember.ContainerView's init\n// method.\nEmber.View.childViewsProperty = childViewsProperty;\n\nEmber.View.applyAttributeBindings = function(elem, name, value) {\n var type = Ember.typeOf(value);\n var currentValue = elem.attr(name);\n\n // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js\n if ((type === 'string' || (type === 'number' && !isNaN(value))) && value !== currentValue) {\n elem.attr(name, value);\n } else if (value && type === 'boolean') {\n elem.attr(name, name);\n } else if (!value) {\n elem.removeAttr(name);\n }\n};\n\nEmber.View.states = states;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set;\n\nEmber.View.states._default = {\n // appendChild is only legal while rendering the buffer.\n appendChild: function() {\n throw \"You can't use appendChild outside of the rendering process\";\n },\n\n $: function() {\n return undefined;\n },\n\n getElement: function() {\n return null;\n },\n\n // Handle events from `Ember.EventDispatcher`\n handleEvent: function() {\n return true; // continue event propagation\n },\n\n destroyElement: function(view) {\n set(view, 'element', null);\n if (view._scheduledInsert) {\n Ember.run.cancel(view._scheduledInsert);\n view._scheduledInsert = null;\n }\n return view;\n },\n\n renderToBufferIfNeeded: function () {\n return false;\n },\n\n rerender: Ember.K\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar preRender = Ember.View.states.preRender = Ember.create(Ember.View.states._default);\n\nEmber.merge(preRender, {\n // a view leaves the preRender state once its element has been\n // created (createElement).\n insertElement: function(view, fn) {\n view.createElement();\n view.triggerRecursively('willInsertElement');\n // after createElement, the view will be in the hasElement state.\n fn.call(view);\n view.transitionTo('inDOM');\n view.triggerRecursively('didInsertElement');\n },\n\n renderToBufferIfNeeded: function(view) {\n return view.renderToBuffer();\n },\n\n empty: Ember.K,\n\n setElement: function(view, value) {\n if (value !== null) {\n view.transitionTo('hasElement');\n }\n return value;\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, meta = Ember.meta;\n\nvar inBuffer = Ember.View.states.inBuffer = Ember.create(Ember.View.states._default);\n\nEmber.merge(inBuffer, {\n $: function(view, sel) {\n // if we don't have an element yet, someone calling this.$() is\n // trying to update an element that isn't in the DOM. Instead,\n // rerender the view to allow the render method to reflect the\n // changes.\n view.rerender();\n return Ember.$();\n },\n\n // when a view is rendered in a buffer, rerendering it simply\n // replaces the existing buffer with a new one\n rerender: function(view) {\n throw new Error(\"Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.\");\n },\n\n // when a view is rendered in a buffer, appending a child\n // view will render that view and append the resulting\n // buffer into its buffer.\n appendChild: function(view, childView, options) {\n var buffer = view.buffer;\n\n childView = view.createChildView(childView, options);\n view._childViews.push(childView);\n\n childView.renderToBuffer(buffer);\n\n view.propertyDidChange('childViews');\n\n return childView;\n },\n\n // when a view is rendered in a buffer, destroying the\n // element will simply destroy the buffer and put the\n // state back into the preRender state.\n destroyElement: function(view) {\n view.clearBuffer();\n view._notifyWillDestroyElement();\n view.transitionTo('preRender');\n\n return view;\n },\n\n empty: function() {\n Ember.assert(\"Emptying a view in the inBuffer state is not allowed and should not happen under normal circumstances. Most likely there is a bug in your application. This may be due to excessive property change notifications.\");\n },\n\n renderToBufferIfNeeded: function (view) {\n return view.buffer;\n },\n\n // It should be impossible for a rendered view to be scheduled for\n // insertion.\n insertElement: function() {\n throw \"You can't insert an element that has already been rendered\";\n },\n\n setElement: function(view, value) {\n if (value === null) {\n view.transitionTo('preRender');\n } else {\n view.clearBuffer();\n view.transitionTo('hasElement');\n }\n\n return value;\n }\n});\n\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, meta = Ember.meta;\n\nvar hasElement = Ember.View.states.hasElement = Ember.create(Ember.View.states._default);\n\nEmber.merge(hasElement, {\n $: function(view, sel) {\n var elem = get(view, 'element');\n return sel ? Ember.$(sel, elem) : Ember.$(elem);\n },\n\n getElement: function(view) {\n var parent = get(view, 'parentView');\n if (parent) { parent = get(parent, 'element'); }\n if (parent) { return view.findElementInParentElement(parent); }\n return Ember.$(\"#\" + get(view, 'elementId'))[0];\n },\n\n setElement: function(view, value) {\n if (value === null) {\n view.transitionTo('preRender');\n } else {\n throw \"You cannot set an element to a non-null value when the element is already in the DOM.\";\n }\n\n return value;\n },\n\n // once the view has been inserted into the DOM, rerendering is\n // deferred to allow bindings to synchronize.\n rerender: function(view) {\n view.triggerRecursively('willClearRender');\n\n view.clearRenderedChildren();\n\n view.domManager.replace(view);\n return view;\n },\n\n // once the view is already in the DOM, destroying it removes it\n // from the DOM, nukes its element, and puts it back into the\n // preRender state if inDOM.\n\n destroyElement: function(view) {\n view._notifyWillDestroyElement();\n view.domManager.remove(view);\n set(view, 'element', null);\n if (view._scheduledInsert) {\n Ember.run.cancel(view._scheduledInsert);\n view._scheduledInsert = null;\n }\n return view;\n },\n\n empty: function(view) {\n var _childViews = view._childViews, len, idx;\n if (_childViews) {\n len = _childViews.length;\n for (idx = 0; idx < len; idx++) {\n _childViews[idx]._notifyWillDestroyElement();\n }\n }\n view.domManager.empty(view);\n },\n\n // Handle events from `Ember.EventDispatcher`\n handleEvent: function(view, eventName, evt) {\n if (view.has(eventName)) {\n // Handler should be able to re-dispatch events, so we don't\n // preventDefault or stopPropagation.\n return view.trigger(eventName, evt);\n } else {\n return true; // continue event propagation\n }\n }\n});\n\nvar inDOM = Ember.View.states.inDOM = Ember.create(hasElement);\n\nEmber.merge(inDOM, {\n insertElement: function(view, fn) {\n throw \"You can't insert an element into the DOM that has already been inserted\";\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar destroyedError = \"You can't call %@ on a destroyed view\", fmt = Ember.String.fmt;\n\nvar destroyed = Ember.View.states.destroyed = Ember.create(Ember.View.states._default);\n\nEmber.merge(destroyed, {\n appendChild: function() {\n throw fmt(destroyedError, ['appendChild']);\n },\n rerender: function() {\n throw fmt(destroyedError, ['rerender']);\n },\n destroyElement: function() {\n throw fmt(destroyedError, ['destroyElement']);\n },\n empty: function() {\n throw fmt(destroyedError, ['empty']);\n },\n\n setElement: function() {\n throw fmt(destroyedError, [\"set('element', ...)\"]);\n },\n\n renderToBufferIfNeeded: function() {\n throw fmt(destroyedError, [\"renderToBufferIfNeeded\"]);\n },\n\n // Since element insertion is scheduled, don't do anything if\n // the view has been destroyed between scheduling and execution\n insertElement: Ember.K\n});\n\n\n})();\n\n\n\n(function() {\nEmber.View.cloneStates = function(from) {\n var into = {};\n\n into._default = {};\n into.preRender = Ember.create(into._default);\n into.destroyed = Ember.create(into._default);\n into.inBuffer = Ember.create(into._default);\n into.hasElement = Ember.create(into._default);\n into.inDOM = Ember.create(into.hasElement);\n\n var viewState;\n\n for (var stateName in from) {\n if (!from.hasOwnProperty(stateName)) { continue; }\n Ember.merge(into[stateName], from[stateName]);\n }\n\n return into;\n};\n\n})();\n\n\n\n(function() {\nvar states = Ember.View.cloneStates(Ember.View.states);\n\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, meta = Ember.meta;\nvar forEach = Ember.EnumerableUtils.forEach;\n\nvar childViewsProperty = Ember.computed(function() {\n return get(this, '_childViews');\n}).property('_childViews');\n\n/**\n A `ContainerView` is an `Ember.View` subclass that allows for manual or\n programatic management of a view's `childViews` array that will correctly\n update the `ContainerView` instance's rendered DOM representation.\n\n ## Setting Initial Child Views\n\n The initial array of child views can be set in one of two ways. You can\n provide a `childViews` property at creation time that contains instance of\n `Ember.View`:\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n childViews: [Ember.View.create(), Ember.View.create()]\n });\n ```\n\n You can also provide a list of property names whose values are instances of\n `Ember.View`:\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n childViews: ['aView', 'bView', 'cView'],\n aView: Ember.View.create(),\n bView: Ember.View.create(),\n cView: Ember.View.create()\n });\n ```\n\n The two strategies can be combined:\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n childViews: ['aView', Ember.View.create()],\n aView: Ember.View.create()\n });\n ```\n\n Each child view's rendering will be inserted into the container's rendered\n HTML in the same order as its position in the `childViews` property.\n\n ## Adding and Removing Child Views\n\n The views in a container's `childViews` array should be added and removed by\n manipulating the `childViews` property directly.\n\n To remove a view pass that view into a `removeObject` call on the container's\n `childViews` property.\n\n Given an empty `<body>` the following code\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n classNames: ['the-container'],\n childViews: ['aView', 'bView'],\n aView: Ember.View.create({\n template: Ember.Handlebars.compile(\"A\")\n }),\n bView: Ember.View.create({\n template: Ember.Handlebars.compile(\"B\")\n })\n });\n\n aContainer.appendTo('body');\n ```\n\n Results in the HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">A</div>\n <div class=\"ember-view\">B</div>\n </div>\n ```\n\n Removing a view\n\n ```javascript\n aContainer.get('childViews'); // [aContainer.aView, aContainer.bView]\n aContainer.get('childViews').removeObject(aContainer.get('bView'));\n aContainer.get('childViews'); // [aContainer.aView]\n ```\n\n Will result in the following HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">A</div>\n </div>\n ```\n\n Similarly, adding a child view is accomplished by adding `Ember.View` instances to the\n container's `childViews` property.\n\n Given an empty `<body>` the following code\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n classNames: ['the-container'],\n childViews: ['aView', 'bView'],\n aView: Ember.View.create({\n template: Ember.Handlebars.compile(\"A\")\n }),\n bView: Ember.View.create({\n template: Ember.Handlebars.compile(\"B\")\n })\n });\n\n aContainer.appendTo('body');\n ```\n\n Results in the HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">A</div>\n <div class=\"ember-view\">B</div>\n </div>\n ```\n\n Adding a view\n\n ```javascript\n AnotherViewClass = Ember.View.extend({\n template: Ember.Handlebars.compile(\"Another view\")\n });\n\n aContainer.get('childViews'); // [aContainer.aView, aContainer.bView]\n aContainer.get('childViews').pushObject(AnotherViewClass.create());\n aContainer.get('childViews'); // [aContainer.aView, aContainer.bView, <AnotherViewClass instance>]\n ```\n\n Will result in the following HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">A</div>\n <div class=\"ember-view\">B</div>\n <div class=\"ember-view\">Another view</div>\n </div>\n ```\n\n Direct manipulation of `childViews` presence or absence in the DOM via calls\n to `remove` or `removeFromParent` or calls to a container's `removeChild` may\n not behave correctly.\n\n Calling `remove()` on a child view will remove the view's HTML, but it will\n remain as part of its container's `childView`s property.\n\n Calling `removeChild()` on the container will remove the passed view instance\n from the container's `childView`s but keep its HTML within the container's\n rendered view.\n\n Calling `removeFromParent()` behaves as expected but should be avoided in\n favor of direct manipulation of a container's `childViews` property.\n\n ```javascript\n aContainer = Ember.ContainerView.create({\n classNames: ['the-container'],\n childViews: ['aView', 'bView'],\n aView: Ember.View.create({\n template: Ember.Handlebars.compile(\"A\")\n }),\n bView: Ember.View.create({\n template: Ember.Handlebars.compile(\"B\")\n })\n });\n\n aContainer.appendTo('body');\n ```\n\n Results in the HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">A</div>\n <div class=\"ember-view\">B</div>\n </div>\n ```\n\n Calling `aContainer.get('aView').removeFromParent()` will result in the\n following HTML\n\n ```html\n <div class=\"ember-view the-container\">\n <div class=\"ember-view\">B</div>\n </div>\n ```\n\n And the `Ember.View` instance stored in `aContainer.aView` will be removed from `aContainer`'s\n `childViews` array.\n\n ## Templates and Layout\n\n A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or\n `defaultLayout` property on a container view will not result in the template\n or layout being rendered. The HTML contents of a `Ember.ContainerView`'s DOM\n representation will only be the rendered HTML of its child views.\n\n ## Binding a View to Display\n\n If you would like to display a single view in your ContainerView, you can set\n its `currentView` property. When the `currentView` property is set to a view\n instance, it will be added to the ContainerView's `childViews` array. If the\n `currentView` property is later changed to a different view, the new view\n will replace the old view. If `currentView` is set to `null`, the last\n `currentView` will be removed.\n\n This functionality is useful for cases where you want to bind the display of\n a ContainerView to a controller or state manager. For example, you can bind\n the `currentView` of a container to a controller like this:\n\n ```javascript\n App.appController = Ember.Object.create({\n view: Ember.View.create({\n templateName: 'person_template'\n })\n });\n ```\n\n ```handlebars\n {{view Ember.ContainerView currentViewBinding=\"App.appController.view\"}}\n ```\n\n @class ContainerView\n @namespace Ember\n @extends Ember.View\n*/\n\nEmber.ContainerView = Ember.View.extend({\n states: states,\n\n init: function() {\n this._super();\n\n var childViews = get(this, 'childViews');\n Ember.defineProperty(this, 'childViews', childViewsProperty);\n\n var _childViews = this._childViews;\n\n forEach(childViews, function(viewName, idx) {\n var view;\n\n if ('string' === typeof viewName) {\n view = get(this, viewName);\n view = this.createChildView(view);\n set(this, viewName, view);\n } else {\n view = this.createChildView(viewName);\n }\n\n _childViews[idx] = view;\n }, this);\n\n var currentView = get(this, 'currentView');\n if (currentView) _childViews.push(this.createChildView(currentView));\n\n // Make the _childViews array observable\n Ember.A(_childViews);\n\n // Sets up an array observer on the child views array. This\n // observer will detect when child views are added or removed\n // and update the DOM to reflect the mutation.\n get(this, 'childViews').addArrayObserver(this, {\n willChange: 'childViewsWillChange',\n didChange: 'childViewsDidChange'\n });\n },\n\n /**\n @private\n\n Instructs each child view to render to the passed render buffer.\n\n @method render\n @param {Ember.RenderBuffer} buffer the buffer to render to\n */\n render: function(buffer) {\n this.forEachChildView(function(view) {\n view.renderToBuffer(buffer);\n });\n },\n\n instrumentName: 'render.container',\n\n /**\n @private\n\n When the container view is destroyed, tear down the child views\n array observer.\n\n @method willDestroy\n */\n willDestroy: function() {\n get(this, 'childViews').removeArrayObserver(this, {\n willChange: 'childViewsWillChange',\n didChange: 'childViewsDidChange'\n });\n\n this._super();\n },\n\n /**\n @private\n\n When a child view is removed, destroy its element so that\n it is removed from the DOM.\n\n The array observer that triggers this action is set up in the\n `renderToBuffer` method.\n\n @method childViewsWillChange\n @param {Ember.Array} views the child views array before mutation\n @param {Number} start the start position of the mutation\n @param {Number} removed the number of child views removed\n **/\n childViewsWillChange: function(views, start, removed) {\n if (removed === 0) { return; }\n\n var changedViews = views.slice(start, start+removed);\n this.initializeViews(changedViews, null, null);\n\n this.currentState.childViewsWillChange(this, views, start, removed);\n },\n\n /**\n @private\n\n When a child view is added, make sure the DOM gets updated appropriately.\n\n If the view has already rendered an element, we tell the child view to\n create an element and insert it into the DOM. If the enclosing container\n view has already written to a buffer, but not yet converted that buffer\n into an element, we insert the string representation of the child into the\n appropriate place in the buffer.\n\n @method childViewsDidChange\n @param {Ember.Array} views the array of child views afte the mutation has occurred\n @param {Number} start the start position of the mutation\n @param {Number} removed the number of child views removed\n @param {Number} the number of child views added\n */\n childViewsDidChange: function(views, start, removed, added) {\n var len = get(views, 'length');\n\n // No new child views were added; bail out.\n if (added === 0) return;\n\n var changedViews = views.slice(start, start+added);\n this.initializeViews(changedViews, this, get(this, 'templateData'));\n\n // Let the current state handle the changes\n this.currentState.childViewsDidChange(this, views, start, added);\n },\n\n initializeViews: function(views, parentView, templateData) {\n forEach(views, function(view) {\n set(view, '_parentView', parentView);\n\n if (!get(view, 'templateData')) {\n set(view, 'templateData', templateData);\n }\n });\n },\n\n currentView: null,\n\n _currentViewWillChange: Ember.beforeObserver(function() {\n var childViews = get(this, 'childViews'),\n currentView = get(this, 'currentView');\n\n if (currentView) {\n currentView.destroy();\n childViews.removeObject(currentView);\n }\n }, 'currentView'),\n\n _currentViewDidChange: Ember.observer(function() {\n var childViews = get(this, 'childViews'),\n currentView = get(this, 'currentView');\n\n if (currentView) {\n childViews.pushObject(currentView);\n }\n }, 'currentView'),\n\n _ensureChildrenAreInDOM: function () {\n this.currentState.ensureChildrenAreInDOM(this);\n }\n});\n\nEmber.merge(states._default, {\n childViewsWillChange: Ember.K,\n childViewsDidChange: Ember.K,\n ensureChildrenAreInDOM: Ember.K\n});\n\nEmber.merge(states.inBuffer, {\n childViewsDidChange: function(parentView, views, start, added) {\n throw new Error('You cannot modify child views while in the inBuffer state');\n }\n});\n\nEmber.merge(states.hasElement, {\n childViewsWillChange: function(view, views, start, removed) {\n for (var i=start; i<start+removed; i++) {\n views[i].remove();\n }\n },\n\n childViewsDidChange: function(view, views, start, added) {\n Ember.run.scheduleOnce('render', view, '_ensureChildrenAreInDOM');\n },\n\n ensureChildrenAreInDOM: function(view) {\n var childViews = view.get('childViews'), i, len, childView, previous, buffer;\n for (i = 0, len = childViews.length; i < len; i++) {\n childView = childViews[i];\n buffer = childView.renderToBufferIfNeeded();\n if (buffer) {\n childView.triggerRecursively('willInsertElement');\n if (previous) {\n previous.domManager.after(previous, buffer.string());\n } else {\n view.domManager.prepend(view, buffer.string());\n }\n childView.transitionTo('inDOM');\n childView.propertyDidChange('element');\n childView.triggerRecursively('didInsertElement');\n }\n previous = childView;\n }\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-views\n*/\n\nvar get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;\n\n/**\n `Ember.CollectionView` is an `Ember.View` descendent responsible for managing\n a collection (an array or array-like object) by maintaing a child view object\n and associated DOM representation for each item in the array and ensuring\n that child views and their associated rendered HTML are updated when items in\n the array are added, removed, or replaced.\n\n ## Setting content\n\n The managed collection of objects is referenced as the `Ember.CollectionView`\n instance's `content` property.\n\n ```javascript\n someItemsView = Ember.CollectionView.create({\n content: ['A', 'B','C']\n })\n ```\n\n The view for each item in the collection will have its `content` property set\n to the item.\n\n ## Specifying itemViewClass\n\n By default the view class for each item in the managed collection will be an\n instance of `Ember.View`. You can supply a different class by setting the\n `CollectionView`'s `itemViewClass` property.\n\n Given an empty `<body>` and the following code:\n\n ```javascript \n someItemsView = Ember.CollectionView.create({\n classNames: ['a-collection'],\n content: ['A','B','C'],\n itemViewClass: Ember.View.extend({\n template: Ember.Handlebars.compile(\"the letter: {{view.content}}\")\n })\n });\n\n someItemsView.appendTo('body');\n ```\n\n Will result in the following HTML structure\n\n ```html\n <div class=\"ember-view a-collection\">\n <div class=\"ember-view\">the letter: A</div>\n <div class=\"ember-view\">the letter: B</div>\n <div class=\"ember-view\">the letter: C</div>\n </div>\n ```\n\n ## Automatic matching of parent/child tagNames\n\n Setting the `tagName` property of a `CollectionView` to any of\n \"ul\", \"ol\", \"table\", \"thead\", \"tbody\", \"tfoot\", \"tr\", or \"select\" will result\n in the item views receiving an appropriately matched `tagName` property.\n\n Given an empty `<body>` and the following code:\n\n ```javascript\n anUndorderedListView = Ember.CollectionView.create({\n tagName: 'ul',\n content: ['A','B','C'],\n itemViewClass: Ember.View.extend({\n template: Ember.Handlebars.compile(\"the letter: {{view.content}}\")\n })\n });\n\n anUndorderedListView.appendTo('body');\n ```\n\n Will result in the following HTML structure\n\n ```html\n <ul class=\"ember-view a-collection\">\n <li class=\"ember-view\">the letter: A</li>\n <li class=\"ember-view\">the letter: B</li>\n <li class=\"ember-view\">the letter: C</li>\n </ul>\n ```\n\n Additional `tagName` pairs can be provided by adding to\n `Ember.CollectionView.CONTAINER_MAP `\n\n ```javascript\n Ember.CollectionView.CONTAINER_MAP['article'] = 'section'\n ```\n\n ## Programatic creation of child views\n\n For cases where additional customization beyond the use of a single\n `itemViewClass` or `tagName` matching is required CollectionView's\n `createChildView` method can be overidden:\n\n ```javascript\n CustomCollectionView = Ember.CollectionView.extend({\n createChildView: function(viewClass, attrs) {\n if (attrs.content.kind == 'album') {\n viewClass = App.AlbumView;\n } else {\n viewClass = App.SongView;\n }\n this._super(viewClass, attrs);\n }\n });\n ```\n\n ## Empty View\n\n You can provide an `Ember.View` subclass to the `Ember.CollectionView`\n instance as its `emptyView` property. If the `content` property of a\n `CollectionView` is set to `null` or an empty array, an instance of this view\n will be the `CollectionView`s only child.\n\n ```javascript\n aListWithNothing = Ember.CollectionView.create({\n classNames: ['nothing']\n content: null,\n emptyView: Ember.View.extend({\n template: Ember.Handlebars.compile(\"The collection is empty\")\n })\n });\n\n aListWithNothing.appendTo('body');\n ```\n\n Will result in the following HTML structure\n\n ```html\n <div class=\"ember-view nothing\">\n <div class=\"ember-view\">\n The collection is empty\n </div>\n </div>\n ```\n\n ## Adding and Removing items\n\n The `childViews` property of a `CollectionView` should not be directly\n manipulated. Instead, add, remove, replace items from its `content` property.\n This will trigger appropriate changes to its rendered HTML.\n\n ## Use in templates via the `{{collection}}` `Ember.Handlebars` helper\n\n `Ember.Handlebars` provides a helper specifically for adding\n `CollectionView`s to templates. See `Ember.Handlebars.collection` for more\n details\n\n @class CollectionView\n @namespace Ember\n @extends Ember.ContainerView\n @since Ember 0.9\n*/\nEmber.CollectionView = Ember.ContainerView.extend(\n/** @scope Ember.CollectionView.prototype */ {\n\n /**\n A list of items to be displayed by the `Ember.CollectionView`.\n\n @property content\n @type Ember.Array\n @default null\n */\n content: null,\n\n /**\n @private\n\n This provides metadata about what kind of empty view class this\n collection would like if it is being instantiated from another\n system (like Handlebars)\n\n @property emptyViewClass\n */\n emptyViewClass: Ember.View,\n\n /**\n An optional view to display if content is set to an empty array.\n\n @property emptyView\n @type Ember.View\n @default null\n */\n emptyView: null,\n\n /**\n @property itemViewClass\n @type Ember.View\n @default Ember.View\n */\n itemViewClass: Ember.View,\n\n init: function() {\n var ret = this._super();\n this._contentDidChange();\n return ret;\n },\n\n _contentWillChange: Ember.beforeObserver(function() {\n var content = this.get('content');\n\n if (content) { content.removeArrayObserver(this); }\n var len = content ? get(content, 'length') : 0;\n this.arrayWillChange(content, 0, len);\n }, 'content'),\n\n /**\n @private\n\n Check to make sure that the content has changed, and if so,\n update the children directly. This is always scheduled\n asynchronously, to allow the element to be created before\n bindings have synchronized and vice versa.\n\n @method _contentDidChange\n */\n _contentDidChange: Ember.observer(function() {\n var content = get(this, 'content');\n\n if (content) {\n Ember.assert(fmt(\"an Ember.CollectionView's content must implement Ember.Array. You passed %@\", [content]), Ember.Array.detect(content));\n content.addArrayObserver(this);\n }\n\n var len = content ? get(content, 'length') : 0;\n this.arrayDidChange(content, 0, null, len);\n }, 'content'),\n\n willDestroy: function() {\n var content = get(this, 'content');\n if (content) { content.removeArrayObserver(this); }\n\n this._super();\n },\n\n arrayWillChange: function(content, start, removedCount) {\n // If the contents were empty before and this template collection has an\n // empty view remove it now.\n var emptyView = get(this, 'emptyView');\n if (emptyView && emptyView instanceof Ember.View) {\n emptyView.removeFromParent();\n }\n\n // Loop through child views that correspond with the removed items.\n // Note that we loop from the end of the array to the beginning because\n // we are mutating it as we go.\n var childViews = get(this, 'childViews'), childView, idx, len;\n\n len = get(childViews, 'length');\n\n var removingAll = removedCount === len;\n\n if (removingAll) {\n this.currentState.empty(this);\n }\n\n for (idx = start + removedCount - 1; idx >= start; idx--) {\n childView = childViews[idx];\n if (removingAll) { childView.removedFromDOM = true; }\n childView.destroy();\n }\n },\n\n /**\n Called when a mutation to the underlying content array occurs.\n\n This method will replay that mutation against the views that compose the\n `Ember.CollectionView`, ensuring that the view reflects the model.\n\n This array observer is added in `contentDidChange`.\n\n @method arrayDidChange\n @param {Array} addedObjects the objects that were added to the content\n @param {Array} removedObjects the objects that were removed from the content\n @param {Number} changeIndex the index at which the changes occurred\n */\n arrayDidChange: function(content, start, removed, added) {\n var itemViewClass = get(this, 'itemViewClass'),\n childViews = get(this, 'childViews'),\n addedViews = [], view, item, idx, len, itemTagName;\n\n if ('string' === typeof itemViewClass) {\n itemViewClass = get(itemViewClass);\n }\n\n Ember.assert(fmt(\"itemViewClass must be a subclass of Ember.View, not %@\", [itemViewClass]), Ember.View.detect(itemViewClass));\n\n len = content ? get(content, 'length') : 0;\n if (len) {\n for (idx = start; idx < start+added; idx++) {\n item = content.objectAt(idx);\n\n view = this.createChildView(itemViewClass, {\n content: item,\n contentIndex: idx\n });\n\n addedViews.push(view);\n }\n } else {\n var emptyView = get(this, 'emptyView');\n if (!emptyView) { return; }\n\n emptyView = this.createChildView(emptyView);\n addedViews.push(emptyView);\n set(this, 'emptyView', emptyView);\n }\n childViews.replace(start, 0, addedViews);\n },\n\n createChildView: function(view, attrs) {\n view = this._super(view, attrs);\n\n var itemTagName = get(view, 'tagName');\n var tagName = (itemTagName === null || itemTagName === undefined) ? Ember.CollectionView.CONTAINER_MAP[get(this, 'tagName')] : itemTagName;\n\n set(view, 'tagName', tagName);\n\n return view;\n }\n});\n\n/**\n A map of parent tags to their default child tags. You can add\n additional parent tags if you want collection views that use\n a particular parent tag to default to a child tag.\n\n @property CONTAINER_MAP\n @type Hash\n @static\n @final\n*/\nEmber.CollectionView.CONTAINER_MAP = {\n ul: 'li',\n ol: 'li',\n table: 'tr',\n thead: 'tr',\n tbody: 'tr',\n tfoot: 'tr',\n tr: 'td',\n select: 'option'\n};\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/*globals jQuery*/\n/**\nEmber Views\n\n@module ember\n@submodule ember-views\n@require ember-runtime\n@main ember-views\n*/\n\n})();\n\n(function() {\n// ==========================================================================\n// Project: metamorph\n// Copyright: ©2011 My Company Inc. All rights reserved.\n// ==========================================================================\n\n(function(window) {\n\n var K = function(){},\n guid = 0,\n document = window.document,\n\n // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges\n supportsRange = ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment,\n\n // Internet Explorer prior to 9 does not allow setting innerHTML if the first element\n // is a \"zero-scope\" element. This problem can be worked around by making\n // the first node an invisible text node. We, like Modernizr, use &shy;\n needsShy = (function(){\n var testEl = document.createElement('div');\n testEl.innerHTML = \"<div></div>\";\n testEl.firstChild.innerHTML = \"<script></script>\";\n return testEl.firstChild.innerHTML === '';\n })(),\n\n\n // IE 8 (and likely earlier) likes to move whitespace preceeding\n // a script tag to appear after it. This means that we can\n // accidentally remove whitespace when updating a morph.\n movesWhitespace = (function() {\n var testEl = document.createElement('div');\n testEl.innerHTML = \"Test: <script type='text/x-placeholder'></script>Value\";\n return testEl.childNodes[0].nodeValue === 'Test:' &&\n testEl.childNodes[2].nodeValue === ' Value';\n })();\n\n // Constructor that supports either Metamorph('foo') or new\n // Metamorph('foo');\n //\n // Takes a string of HTML as the argument.\n\n var Metamorph = function(html) {\n var self;\n\n if (this instanceof Metamorph) {\n self = this;\n } else {\n self = new K();\n }\n\n self.innerHTML = html;\n var myGuid = 'metamorph-'+(guid++);\n self.start = myGuid + '-start';\n self.end = myGuid + '-end';\n\n return self;\n };\n\n K.prototype = Metamorph.prototype;\n\n var rangeFor, htmlFunc, removeFunc, outerHTMLFunc, appendToFunc, afterFunc, prependFunc, startTagFunc, endTagFunc;\n\n outerHTMLFunc = function() {\n return this.startTag() + this.innerHTML + this.endTag();\n };\n\n startTagFunc = function() {\n /*\n * We replace chevron by its hex code in order to prevent escaping problems.\n * Check this thread for more explaination:\n * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript\n */\n return \"<script id='\" + this.start + \"' type='text/x-placeholder'>\\x3C/script>\";\n };\n\n endTagFunc = function() {\n /*\n * We replace chevron by its hex code in order to prevent escaping problems.\n * Check this thread for more explaination:\n * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript\n */\n return \"<script id='\" + this.end + \"' type='text/x-placeholder'>\\x3C/script>\";\n };\n\n // If we have the W3C range API, this process is relatively straight forward.\n if (supportsRange) {\n\n // Get a range for the current morph. Optionally include the starting and\n // ending placeholders.\n rangeFor = function(morph, outerToo) {\n var range = document.createRange();\n var before = document.getElementById(morph.start);\n var after = document.getElementById(morph.end);\n\n if (outerToo) {\n range.setStartBefore(before);\n range.setEndAfter(after);\n } else {\n range.setStartAfter(before);\n range.setEndBefore(after);\n }\n\n return range;\n };\n\n htmlFunc = function(html, outerToo) {\n // get a range for the current metamorph object\n var range = rangeFor(this, outerToo);\n\n // delete the contents of the range, which will be the\n // nodes between the starting and ending placeholder.\n range.deleteContents();\n\n // create a new document fragment for the HTML\n var fragment = range.createContextualFragment(html);\n\n // insert the fragment into the range\n range.insertNode(fragment);\n };\n\n removeFunc = function() {\n // get a range for the current metamorph object including\n // the starting and ending placeholders.\n var range = rangeFor(this, true);\n\n // delete the entire range.\n range.deleteContents();\n };\n\n appendToFunc = function(node) {\n var range = document.createRange();\n range.setStart(node);\n range.collapse(false);\n var frag = range.createContextualFragment(this.outerHTML());\n node.appendChild(frag);\n };\n\n afterFunc = function(html) {\n var range = document.createRange();\n var after = document.getElementById(this.end);\n\n range.setStartAfter(after);\n range.setEndAfter(after);\n\n var fragment = range.createContextualFragment(html);\n range.insertNode(fragment);\n };\n\n prependFunc = function(html) {\n var range = document.createRange();\n var start = document.getElementById(this.start);\n\n range.setStartAfter(start);\n range.setEndAfter(start);\n\n var fragment = range.createContextualFragment(html);\n range.insertNode(fragment);\n };\n\n } else {\n /**\n * This code is mostly taken from jQuery, with one exception. In jQuery's case, we\n * have some HTML and we need to figure out how to convert it into some nodes.\n *\n * In this case, jQuery needs to scan the HTML looking for an opening tag and use\n * that as the key for the wrap map. In our case, we know the parent node, and\n * can use its type as the key for the wrap map.\n **/\n var wrapMap = {\n select: [ 1, \"<select multiple='multiple'>\", \"</select>\" ],\n fieldset: [ 1, \"<fieldset>\", \"</fieldset>\" ],\n table: [ 1, \"<table>\", \"</table>\" ],\n tbody: [ 2, \"<table><tbody>\", \"</tbody></table>\" ],\n tr: [ 3, \"<table><tbody><tr>\", \"</tr></tbody></table>\" ],\n colgroup: [ 2, \"<table><tbody></tbody><colgroup>\", \"</colgroup></table>\" ],\n map: [ 1, \"<map>\", \"</map>\" ],\n _default: [ 0, \"\", \"\" ]\n };\n\n var findChildById = function(element, id) {\n if (element.getAttribute('id') === id) { return element; }\n\n var len = element.childNodes.length, idx, node, found;\n for (idx=0; idx<len; idx++) {\n node = element.childNodes[idx];\n found = node.nodeType === 1 && findChildById(node, id);\n if (found) { return found; }\n }\n };\n\n var setInnerHTML = function(element, html) {\n var matches = [];\n if (movesWhitespace) {\n // Right now we only check for script tags with ids with the\n // goal of targeting morphs.\n html = html.replace(/(\\s+)(<script id='([^']+)')/g, function(match, spaces, tag, id) {\n matches.push([id, spaces]);\n return tag;\n });\n }\n\n element.innerHTML = html;\n\n // If we have to do any whitespace adjustments do them now\n if (matches.length > 0) {\n var len = matches.length, idx;\n for (idx=0; idx<len; idx++) {\n var script = findChildById(element, matches[idx][0]),\n node = document.createTextNode(matches[idx][1]);\n script.parentNode.insertBefore(node, script);\n }\n }\n };\n\n /**\n * Given a parent node and some HTML, generate a set of nodes. Return the first\n * node, which will allow us to traverse the rest using nextSibling.\n *\n * We need to do this because innerHTML in IE does not really parse the nodes.\n **/\n var firstNodeFor = function(parentNode, html) {\n var arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default;\n var depth = arr[0], start = arr[1], end = arr[2];\n\n if (needsShy) { html = '&shy;'+html; }\n\n var element = document.createElement('div');\n\n setInnerHTML(element, start + html + end);\n\n for (var i=0; i<=depth; i++) {\n element = element.firstChild;\n }\n\n // Look for &shy; to remove it.\n if (needsShy) {\n var shyElement = element;\n\n // Sometimes we get nameless elements with the shy inside\n while (shyElement.nodeType === 1 && !shyElement.nodeName) {\n shyElement = shyElement.firstChild;\n }\n\n // At this point it's the actual unicode character.\n if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === \"\\u00AD\") {\n shyElement.nodeValue = shyElement.nodeValue.slice(1);\n }\n }\n\n return element;\n };\n\n /**\n * In some cases, Internet Explorer can create an anonymous node in\n * the hierarchy with no tagName. You can create this scenario via:\n *\n * div = document.createElement(\"div\");\n * div.innerHTML = \"<table>&shy<script></script><tr><td>hi</td></tr></table>\";\n * div.firstChild.firstChild.tagName //=> \"\"\n *\n * If our script markers are inside such a node, we need to find that\n * node and use *it* as the marker.\n **/\n var realNode = function(start) {\n while (start.parentNode.tagName === \"\") {\n start = start.parentNode;\n }\n\n return start;\n };\n\n /**\n * When automatically adding a tbody, Internet Explorer inserts the\n * tbody immediately before the first <tr>. Other browsers create it\n * before the first node, no matter what.\n *\n * This means the the following code:\n *\n * div = document.createElement(\"div\");\n * div.innerHTML = \"<table><script id='first'></script><tr><td>hi</td></tr><script id='last'></script></table>\n *\n * Generates the following DOM in IE:\n *\n * + div\n * + table\n * - script id='first'\n * + tbody\n * + tr\n * + td\n * - \"hi\"\n * - script id='last'\n *\n * Which means that the two script tags, even though they were\n * inserted at the same point in the hierarchy in the original\n * HTML, now have different parents.\n *\n * This code reparents the first script tag by making it the tbody's\n * first child.\n **/\n var fixParentage = function(start, end) {\n if (start.parentNode !== end.parentNode) {\n end.parentNode.insertBefore(start, end.parentNode.firstChild);\n }\n };\n\n htmlFunc = function(html, outerToo) {\n // get the real starting node. see realNode for details.\n var start = realNode(document.getElementById(this.start));\n var end = document.getElementById(this.end);\n var parentNode = end.parentNode;\n var node, nextSibling, last;\n\n // make sure that the start and end nodes share the same\n // parent. If not, fix it.\n fixParentage(start, end);\n\n // remove all of the nodes after the starting placeholder and\n // before the ending placeholder.\n node = start.nextSibling;\n while (node) {\n nextSibling = node.nextSibling;\n last = node === end;\n\n // if this is the last node, and we want to remove it as well,\n // set the `end` node to the next sibling. This is because\n // for the rest of the function, we insert the new nodes\n // before the end (note that insertBefore(node, null) is\n // the same as appendChild(node)).\n //\n // if we do not want to remove it, just break.\n if (last) {\n if (outerToo) { end = node.nextSibling; } else { break; }\n }\n\n node.parentNode.removeChild(node);\n\n // if this is the last node and we didn't break before\n // (because we wanted to remove the outer nodes), break\n // now.\n if (last) { break; }\n\n node = nextSibling;\n }\n\n // get the first node for the HTML string, even in cases like\n // tables and lists where a simple innerHTML on a div would\n // swallow some of the content.\n node = firstNodeFor(start.parentNode, html);\n\n // copy the nodes for the HTML between the starting and ending\n // placeholder.\n while (node) {\n nextSibling = node.nextSibling;\n parentNode.insertBefore(node, end);\n node = nextSibling;\n }\n };\n\n // remove the nodes in the DOM representing this metamorph.\n //\n // this includes the starting and ending placeholders.\n removeFunc = function() {\n var start = realNode(document.getElementById(this.start));\n var end = document.getElementById(this.end);\n\n this.html('');\n start.parentNode.removeChild(start);\n end.parentNode.removeChild(end);\n };\n\n appendToFunc = function(parentNode) {\n var node = firstNodeFor(parentNode, this.outerHTML());\n\n while (node) {\n nextSibling = node.nextSibling;\n parentNode.appendChild(node);\n node = nextSibling;\n }\n };\n\n afterFunc = function(html) {\n // get the real starting node. see realNode for details.\n var end = document.getElementById(this.end);\n var insertBefore = end.nextSibling;\n var parentNode = end.parentNode;\n var nextSibling;\n var node;\n\n // get the first node for the HTML string, even in cases like\n // tables and lists where a simple innerHTML on a div would\n // swallow some of the content.\n node = firstNodeFor(parentNode, html);\n\n // copy the nodes for the HTML between the starting and ending\n // placeholder.\n while (node) {\n nextSibling = node.nextSibling;\n parentNode.insertBefore(node, insertBefore);\n node = nextSibling;\n }\n };\n\n prependFunc = function(html) {\n var start = document.getElementById(this.start);\n var parentNode = start.parentNode;\n var nextSibling;\n var node;\n\n node = firstNodeFor(parentNode, html);\n var insertBefore = start.nextSibling;\n\n while (node) {\n nextSibling = node.nextSibling;\n parentNode.insertBefore(node, insertBefore);\n node = nextSibling;\n }\n }\n }\n\n Metamorph.prototype.html = function(html) {\n this.checkRemoved();\n if (html === undefined) { return this.innerHTML; }\n\n htmlFunc.call(this, html);\n\n this.innerHTML = html;\n };\n\n Metamorph.prototype.replaceWith = function(html) {\n this.checkRemoved();\n htmlFunc.call(this, html, true);\n };\n\n Metamorph.prototype.remove = removeFunc;\n Metamorph.prototype.outerHTML = outerHTMLFunc;\n Metamorph.prototype.appendTo = appendToFunc;\n Metamorph.prototype.after = afterFunc;\n Metamorph.prototype.prepend = prependFunc;\n Metamorph.prototype.startTag = startTagFunc;\n Metamorph.prototype.endTag = endTagFunc;\n\n Metamorph.prototype.isRemoved = function() {\n var before = document.getElementById(this.start);\n var after = document.getElementById(this.end);\n\n return !before || !after;\n };\n\n Metamorph.prototype.checkRemoved = function() {\n if (this.isRemoved()) {\n throw new Error(\"Cannot perform operations on a Metamorph that is not in the DOM.\");\n }\n };\n\n window.Metamorph = Metamorph;\n})(this);\n\n\n})();\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar objectCreate = Ember.create;\n\nvar Handlebars = Ember.imports.Handlebars;\nEmber.assert(\"Ember Handlebars requires Handlebars 1.0.beta.5 or greater\", Handlebars && Handlebars.VERSION.match(/^1\\.0\\.beta\\.[56789]$|^1\\.0\\.rc\\.[123456789]+/));\n\n/**\n Prepares the Handlebars templating library for use inside Ember's view\n system.\n\n The `Ember.Handlebars` object is the standard Handlebars library, extended to\n use Ember's `get()` method instead of direct property access, which allows\n computed properties to be used inside templates.\n\n To create an `Ember.Handlebars` template, call `Ember.Handlebars.compile()`.\n This will return a function that can be used by `Ember.View` for rendering.\n\n @class Handlebars\n @namespace Ember\n*/\nEmber.Handlebars = objectCreate(Handlebars);\n\n/**\n@class helpers\n@namespace Ember.Handlebars\n*/\nEmber.Handlebars.helpers = objectCreate(Handlebars.helpers);\n\n/**\n Override the the opcode compiler and JavaScript compiler for Handlebars.\n\n @class Compiler\n @namespace Ember.Handlebars\n @private\n @constructor\n*/\nEmber.Handlebars.Compiler = function() {};\n\n// Handlebars.Compiler doesn't exist in runtime-only\nif (Handlebars.Compiler) {\n Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype);\n}\n\nEmber.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler;\n\n/**\n @class JavaScriptCompiler\n @namespace Ember.Handlebars\n @private\n @constructor\n*/\nEmber.Handlebars.JavaScriptCompiler = function() {};\n\n// Handlebars.JavaScriptCompiler doesn't exist in runtime-only\nif (Handlebars.JavaScriptCompiler) {\n Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype);\n Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler;\n}\n\n\nEmber.Handlebars.JavaScriptCompiler.prototype.namespace = \"Ember.Handlebars\";\n\n\nEmber.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() {\n return \"''\";\n};\n\n/**\n @private\n\n Override the default buffer for Ember Handlebars. By default, Handlebars\n creates an empty String at the beginning of each invocation and appends to\n it. Ember's Handlebars overrides this to append to a single shared buffer.\n\n @method appendToBuffer\n @param string {String}\n*/\nEmber.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) {\n return \"data.buffer.push(\"+string+\");\";\n};\n\n/**\n @private\n\n Rewrite simple mustaches from `{{foo}}` to `{{bind \"foo\"}}`. This means that\n all simple mustaches in Ember's Handlebars will also set up an observer to\n keep the DOM up to date when the underlying property changes.\n\n @method mustache\n @for Ember.Handlebars.Compiler\n @param mustache\n*/\nEmber.Handlebars.Compiler.prototype.mustache = function(mustache) {\n if (mustache.params.length || mustache.hash) {\n return Handlebars.Compiler.prototype.mustache.call(this, mustache);\n } else {\n var id = new Handlebars.AST.IdNode(['_triageMustache']);\n\n // Update the mustache node to include a hash value indicating whether the original node\n // was escaped. This will allow us to properly escape values when the underlying value\n // changes and we need to re-render the value.\n if(!mustache.escaped) {\n mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]);\n mustache.hash.pairs.push([\"unescaped\", new Handlebars.AST.StringNode(\"true\")]);\n }\n mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped);\n return Handlebars.Compiler.prototype.mustache.call(this, mustache);\n }\n};\n\n/**\n Used for precompilation of Ember Handlebars templates. This will not be used\n during normal app execution.\n\n @method precompile\n @for Ember.Handlebars\n @static\n @param {String} string The template to precompile\n*/\nEmber.Handlebars.precompile = function(string) {\n var ast = Handlebars.parse(string);\n\n var options = {\n knownHelpers: {\n action: true,\n unbound: true,\n bindAttr: true,\n template: true,\n view: true,\n _triageMustache: true\n },\n data: true,\n stringParams: true\n };\n\n var environment = new Ember.Handlebars.Compiler().compile(ast, options);\n return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);\n};\n\n// We don't support this for Handlebars runtime-only\nif (Handlebars.compile) {\n /**\n The entry point for Ember Handlebars. This replaces the default\n `Handlebars.compile` and turns on template-local data and String\n parameters.\n\n @method compile\n @for Ember.Handlebars\n @static\n @param {String} string The template to compile\n @return {Function}\n */\n Ember.Handlebars.compile = function(string) {\n var ast = Handlebars.parse(string);\n var options = { data: true, stringParams: true };\n var environment = new Ember.Handlebars.Compiler().compile(ast, options);\n var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);\n\n return Handlebars.template(templateSpec);\n };\n}\n\n/**\n @private\n\n If a path starts with a reserved keyword, returns the root\n that should be used.\n\n @method normalizePath\n @for Ember\n @param root {Object}\n @param path {String}\n @param data {Hash}\n*/\nvar normalizePath = Ember.Handlebars.normalizePath = function(root, path, data) {\n var keywords = (data && data.keywords) || {},\n keyword, isKeyword;\n\n // Get the first segment of the path. For example, if the\n // path is \"foo.bar.baz\", returns \"foo\".\n keyword = path.split('.', 1)[0];\n\n // Test to see if the first path is a keyword that has been\n // passed along in the view's data hash. If so, we will treat\n // that object as the new root.\n if (keywords.hasOwnProperty(keyword)) {\n // Look up the value in the template's data hash.\n root = keywords[keyword];\n isKeyword = true;\n\n // Handle cases where the entire path is the reserved\n // word. In that case, return the object itself.\n if (path === keyword) {\n path = '';\n } else {\n // Strip the keyword from the path and look up\n // the remainder from the newly found root.\n path = path.substr(keyword.length+1);\n }\n }\n\n return { root: root, path: path, isKeyword: isKeyword };\n};\n\n\n/**\n Lookup both on root and on window. If the path starts with\n a keyword, the corresponding object will be looked up in the\n template's data hash and used to resolve the path.\n\n @method get\n @for Ember.Handlebars\n @param {Object} root The object to look up the property on\n @param {String} path The path to be lookedup\n @param {Object} options The template's option hash\n*/\nEmber.Handlebars.get = function(root, path, options) {\n var data = options && options.data,\n normalizedPath = normalizePath(root, path, data),\n value;\n\n // In cases where the path begins with a keyword, change the\n // root to the value represented by that keyword, and ensure\n // the path is relative to it.\n root = normalizedPath.root;\n path = normalizedPath.path;\n\n value = Ember.get(root, path);\n\n // If the path starts with a capital letter, look it up on Ember.lookup,\n // which defaults to the `window` object in browsers.\n if (value === undefined && root !== Ember.lookup && Ember.isGlobalPath(path)) {\n value = Ember.get(Ember.lookup, path);\n }\n return value;\n};\nEmber.Handlebars.getPath = Ember.deprecateFunc('`Ember.Handlebars.getPath` has been changed to `Ember.Handlebars.get` for consistency.', Ember.Handlebars.get);\n\n/**\n @private\n\n Registers a helper in Handlebars that will be called if no property with the\n given name can be found on the current context object, and no helper with\n that name is registered.\n\n This throws an exception with a more helpful error message so the user can\n track down where the problem is happening.\n\n @method helperMissing\n @for Ember.Handlebars.helpers\n @param {String} path\n @param {Hash} options\n*/\nEmber.Handlebars.registerHelper('helperMissing', function(path, options) {\n var error, view = \"\";\n\n error = \"%@ Handlebars error: Could not find property '%@' on object %@.\";\n if (options.data){\n view = options.data.view;\n }\n throw new Ember.Error(Ember.String.fmt(error, [view, path, this]));\n});\n\n/**\n Register a bound handlebars helper. Bound helpers behave similarly to regular\n handlebars helpers, with the added ability to re-render when the underlying data\n changes.\n\n ## Simple example\n\n ```javascript\n Ember.Handlebars.registerBoundHelper('capitalize', function(value) {\n return value.toUpperCase();\n });\n ```\n\n The above bound helper can be used inside of templates as follows:\n\n ```handlebars\n {{capitalize name}}\n ```\n\n In this case, when the `name` property of the template's context changes,\n the rendered value of the helper will update to reflect this change.\n\n ## Example with options\n\n Like normal handlebars helpers, bound helpers have access to the options\n passed into the helper call.\n\n ```javascript\n Ember.Handlebars.registerBoundHelper('repeat', function(value, options) {\n var count = options.hash.count;\n var a = [];\n while(a.length < count){\n a.push(value);\n }\n return a.join('');\n });\n ```\n\n This helper could be used in a template as follows:\n\n ```handlebars\n {{repeat text count=3}}\n ```\n\n ## Example with extra dependencies\n\n The `Ember.Handlebars.registerBoundHelper` method takes a variable length\n third parameter which indicates extra dependencies on the passed in value.\n This allows the handlebars helper to update when these dependencies change.\n\n ```javascript\n Ember.Handlebars.registerBoundHelper('capitalizeName', function(value) {\n return value.get('name').toUpperCase();\n }, 'name');\n ```\n\n @method registerBoundHelper\n @for Ember.Handlebars\n @param {String} name\n @param {Function} function\n @param {String} dependentKeys*\n*/\nEmber.Handlebars.registerBoundHelper = function(name, fn) {\n var dependentKeys = Array.prototype.slice.call(arguments, 2);\n Ember.Handlebars.registerHelper(name, function(property, options) {\n var data = options.data,\n view = data.view,\n currentContext = (options.contexts && options.contexts[0]) || this,\n pathRoot, path, normalized,\n observer, loc;\n\n normalized = Ember.Handlebars.normalizePath(currentContext, property, data);\n\n pathRoot = normalized.root;\n path = normalized.path;\n \n var bindView = new Ember._SimpleHandlebarsView(\n path, pathRoot, !options.hash.unescaped, options.data\n );\n bindView.normalizedValue = function() {\n var value = Ember._SimpleHandlebarsView.prototype.normalizedValue.call(bindView);\n return fn.call(view, value, options);\n };\n\n view.appendChild(bindView);\n\n observer = function() {\n Ember.run.scheduleOnce('render', bindView, 'rerender');\n };\n\n Ember.addObserver(pathRoot, path, observer);\n loc = 0;\n while(loc < dependentKeys.length) {\n Ember.addObserver(pathRoot, path + '.' + dependentKeys[loc], observer);\n loc += 1;\n }\n\n view.one('willClearRender', function() {\n Ember.removeObserver(pathRoot, path, observer);\n loc = 0;\n while(loc < dependentKeys.length) {\n Ember.removeObserver(pathRoot, path + '.' + dependentKeys[loc], observer);\n loc += 1;\n }\n });\n });\n};\n\n})();\n\n\n\n(function() {\n/**\n @method htmlSafe\n @for Ember.String\n @static\n*/\nEmber.String.htmlSafe = function(str) {\n return new Handlebars.SafeString(str);\n};\n\nvar htmlSafe = Ember.String.htmlSafe;\n\nif (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {\n\n /**\n See {{#crossLink \"Ember.String/htmlSafe\"}}{{/crossLink}}\n\n @method htmlSafe\n @for String\n */\n String.prototype.htmlSafe = function() {\n return htmlSafe(this);\n };\n}\n\n})();\n\n\n\n(function() {\n/*jshint newcap:false*/\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar set = Ember.set, get = Ember.get;\n\n// DOMManager should just abstract dom manipulation between jquery and metamorph\nvar DOMManager = {\n remove: function(view) {\n view.morph.remove();\n },\n\n prepend: function(view, html) {\n view.morph.prepend(html);\n },\n\n after: function(view, html) {\n view.morph.after(html);\n },\n\n html: function(view, html) {\n view.morph.html(html);\n },\n\n // This is messed up.\n replace: function(view) {\n var morph = view.morph;\n\n view.transitionTo('preRender');\n\n Ember.run.schedule('render', this, function() {\n view.clearRenderedChildren();\n var buffer = view.renderToBuffer();\n\n if (get(view, 'isDestroyed')) { return; }\n view.invokeRecursively(function(view) {\n view.propertyDidChange('element');\n });\n view.triggerRecursively('willInsertElement');\n morph.replaceWith(buffer.string());\n view.transitionTo('inDOM');\n view.triggerRecursively('didInsertElement');\n });\n },\n\n empty: function(view) {\n view.morph.html(\"\");\n }\n};\n\n// The `morph` and `outerHTML` properties are internal only\n// and not observable.\n\n/**\n @class _Metamorph\n @namespace Ember\n @extends Ember.Mixin\n @private\n*/\nEmber._Metamorph = Ember.Mixin.create({\n isVirtual: true,\n tagName: '',\n\n instrumentName: 'render.metamorph',\n\n init: function() {\n this._super();\n this.morph = Metamorph();\n },\n\n beforeRender: function(buffer) {\n buffer.push(this.morph.startTag());\n buffer.pushOpeningTag();\n },\n\n afterRender: function(buffer) {\n buffer.pushClosingTag();\n buffer.push(this.morph.endTag());\n },\n\n createElement: function() {\n var buffer = this.renderToBuffer();\n this.outerHTML = buffer.string();\n this.clearBuffer();\n },\n\n domManager: DOMManager\n});\n\n/**\n @class _MetamorphView\n @namespace Ember\n @extends Ember.View\n @uses Ember._Metamorph\n @private\n*/\nEmber._MetamorphView = Ember.View.extend(Ember._Metamorph);\n\n/**\n @class _SimpleMetamorphView\n @namespace Ember\n @extends Ember.View\n @uses Ember._Metamorph\n @private\n*/\nEmber._SimpleMetamorphView = Ember.CoreView.extend(Ember._Metamorph);\n\n\n})();\n\n\n\n(function() {\n/*globals Handlebars */\n/*jshint newcap:false*/\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set, handlebarsGet = Ember.Handlebars.get;\nfunction SimpleHandlebarsView(path, pathRoot, isEscaped, templateData) {\n this.path = path;\n this.pathRoot = pathRoot;\n this.isEscaped = isEscaped;\n this.templateData = templateData;\n\n this.morph = Metamorph();\n this.state = 'preRender';\n this.updateId = null;\n}\n\nEmber._SimpleHandlebarsView = SimpleHandlebarsView;\n\nSimpleHandlebarsView.prototype = {\n isVirtual: true,\n isView: true,\n\n destroy: function () {\n if (this.updateId) {\n Ember.run.cancel(this.updateId);\n this.updateId = null;\n }\n this.morph = null;\n },\n\n propertyDidChange: Ember.K,\n\n normalizedValue: function() {\n var path = this.path,\n pathRoot = this.pathRoot,\n result, templateData;\n\n // Use the pathRoot as the result if no path is provided. This\n // happens if the path is `this`, which gets normalized into\n // a `pathRoot` of the current Handlebars context and a path\n // of `''`.\n if (path === '') {\n result = pathRoot;\n } else {\n templateData = this.templateData;\n result = handlebarsGet(pathRoot, path, { data: templateData });\n }\n\n return result;\n },\n\n renderToBuffer: function(buffer) {\n var string = '';\n\n string += this.morph.startTag();\n string += this.render();\n string += this.morph.endTag();\n\n buffer.push(string);\n },\n\n render: function() {\n // If not invoked via a triple-mustache ({{{foo}}}), escape\n // the content of the template.\n var escape = this.isEscaped;\n var result = this.normalizedValue();\n\n if (result === null || result === undefined) {\n result = \"\";\n } else if (!(result instanceof Handlebars.SafeString)) {\n result = String(result);\n }\n\n if (escape) { result = Handlebars.Utils.escapeExpression(result); }\n return result;\n },\n\n rerender: function() {\n switch(this.state) {\n case 'preRender':\n case 'destroyed':\n break;\n case 'inBuffer':\n throw new Error(\"Something you did tried to replace an {{expression}} before it was inserted into the DOM.\");\n case 'hasElement':\n case 'inDOM':\n this.updateId = Ember.run.scheduleOnce('render', this, 'update');\n break;\n }\n\n return this;\n },\n\n update: function () {\n this.updateId = null;\n this.morph.html(this.render());\n },\n\n transitionTo: function(state) {\n this.state = state;\n }\n};\n\nvar states = Ember.View.cloneStates(Ember.View.states), merge = Ember.merge;\n\nmerge(states._default, {\n rerenderIfNeeded: Ember.K\n});\n\nmerge(states.inDOM, {\n rerenderIfNeeded: function(view) {\n if (get(view, 'normalizedValue') !== view._lastNormalizedValue) {\n view.rerender();\n }\n }\n});\n\n/**\n `Ember._HandlebarsBoundView` is a private view created by the Handlebars\n `{{bind}}` helpers that is used to keep track of bound properties.\n\n Every time a property is bound using a `{{mustache}}`, an anonymous subclass\n of `Ember._HandlebarsBoundView` is created with the appropriate sub-template\n and context set up. When the associated property changes, just the template\n for this view will re-render.\n\n @class _HandlebarsBoundView\n @namespace Ember\n @extends Ember._MetamorphView\n @private\n*/\nEmber._HandlebarsBoundView = Ember._MetamorphView.extend({\n instrumentName: 'render.boundHandlebars',\n states: states,\n\n /**\n The function used to determine if the `displayTemplate` or\n `inverseTemplate` should be rendered. This should be a function that takes\n a value and returns a Boolean.\n\n @property shouldDisplayFunc\n @type Function\n @default null\n */\n shouldDisplayFunc: null,\n\n /**\n Whether the template rendered by this view gets passed the context object\n of its parent template, or gets passed the value of retrieving `path`\n from the `pathRoot`.\n\n For example, this is true when using the `{{#if}}` helper, because the\n template inside the helper should look up properties relative to the same\n object as outside the block. This would be `false` when used with `{{#with\n foo}}` because the template should receive the object found by evaluating\n `foo`.\n\n @property preserveContext\n @type Boolean\n @default false\n */\n preserveContext: false,\n\n /**\n If `preserveContext` is true, this is the object that will be used\n to render the template.\n\n @property previousContext\n @type Object\n */\n previousContext: null,\n\n /**\n The template to render when `shouldDisplayFunc` evaluates to `true`.\n\n @property displayTemplate\n @type Function\n @default null\n */\n displayTemplate: null,\n\n /**\n The template to render when `shouldDisplayFunc` evaluates to `false`.\n\n @property inverseTemplate\n @type Function\n @default null\n */\n inverseTemplate: null,\n\n\n /**\n The path to look up on `pathRoot` that is passed to\n `shouldDisplayFunc` to determine which template to render.\n\n In addition, if `preserveContext` is `false,` the object at this path will\n be passed to the template when rendering.\n\n @property path\n @type String\n @default null\n */\n path: null,\n\n /**\n The object from which the `path` will be looked up. Sometimes this is the\n same as the `previousContext`, but in cases where this view has been\n generated for paths that start with a keyword such as `view` or\n `controller`, the path root will be that resolved object.\n\n @property pathRoot\n @type Object\n */\n pathRoot: null,\n\n normalizedValue: Ember.computed(function() {\n var path = get(this, 'path'),\n pathRoot = get(this, 'pathRoot'),\n valueNormalizer = get(this, 'valueNormalizerFunc'),\n result, templateData;\n\n // Use the pathRoot as the result if no path is provided. This\n // happens if the path is `this`, which gets normalized into\n // a `pathRoot` of the current Handlebars context and a path\n // of `''`.\n if (path === '') {\n result = pathRoot;\n } else {\n templateData = get(this, 'templateData');\n result = handlebarsGet(pathRoot, path, { data: templateData });\n }\n\n return valueNormalizer ? valueNormalizer(result) : result;\n }).property('path', 'pathRoot', 'valueNormalizerFunc').volatile(),\n\n rerenderIfNeeded: function() {\n this.currentState.rerenderIfNeeded(this);\n },\n\n /**\n Determines which template to invoke, sets up the correct state based on\n that logic, then invokes the default `Ember.View` `render` implementation.\n\n This method will first look up the `path` key on `pathRoot`,\n then pass that value to the `shouldDisplayFunc` function. If that returns\n `true,` the `displayTemplate` function will be rendered to DOM. Otherwise,\n `inverseTemplate`, if specified, will be rendered.\n\n For example, if this `Ember._HandlebarsBoundView` represented the `{{#with\n foo}}` helper, it would look up the `foo` property of its context, and\n `shouldDisplayFunc` would always return true. The object found by looking\n up `foo` would be passed to `displayTemplate`.\n\n @method render\n @param {Ember.RenderBuffer} buffer\n */\n render: function(buffer) {\n // If not invoked via a triple-mustache ({{{foo}}}), escape\n // the content of the template.\n var escape = get(this, 'isEscaped');\n\n var shouldDisplay = get(this, 'shouldDisplayFunc'),\n preserveContext = get(this, 'preserveContext'),\n context = get(this, 'previousContext');\n\n var inverseTemplate = get(this, 'inverseTemplate'),\n displayTemplate = get(this, 'displayTemplate');\n\n var result = get(this, 'normalizedValue');\n this._lastNormalizedValue = result;\n\n // First, test the conditional to see if we should\n // render the template or not.\n if (shouldDisplay(result)) {\n set(this, 'template', displayTemplate);\n\n // If we are preserving the context (for example, if this\n // is an #if block, call the template with the same object.\n if (preserveContext) {\n set(this, '_context', context);\n } else {\n // Otherwise, determine if this is a block bind or not.\n // If so, pass the specified object to the template\n if (displayTemplate) {\n set(this, '_context', result);\n } else {\n // This is not a bind block, just push the result of the\n // expression to the render context and return.\n if (result === null || result === undefined) {\n result = \"\";\n } else if (!(result instanceof Handlebars.SafeString)) {\n result = String(result);\n }\n\n if (escape) { result = Handlebars.Utils.escapeExpression(result); }\n buffer.push(result);\n return;\n }\n }\n } else if (inverseTemplate) {\n set(this, 'template', inverseTemplate);\n\n if (preserveContext) {\n set(this, '_context', context);\n } else {\n set(this, '_context', result);\n }\n } else {\n set(this, 'template', function() { return ''; });\n }\n\n return this._super(buffer);\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;\nvar handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath;\nvar forEach = Ember.ArrayPolyfills.forEach;\n\nvar EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;\n\n// Binds a property into the DOM. This will create a hook in DOM that the\n// KVO system will look for and update if the property changes.\nfunction bind(property, options, preserveContext, shouldDisplay, valueNormalizer) {\n var data = options.data,\n fn = options.fn,\n inverse = options.inverse,\n view = data.view,\n currentContext = this,\n pathRoot, path, normalized,\n observer;\n\n normalized = normalizePath(currentContext, property, data);\n\n pathRoot = normalized.root;\n path = normalized.path;\n\n // Set up observers for observable objects\n if ('object' === typeof this) {\n if (data.insideGroup) {\n observer = function() {\n Ember.run.once(view, 'rerender');\n };\n\n var template, context, result = handlebarsGet(pathRoot, path, options);\n\n result = valueNormalizer(result);\n\n context = preserveContext ? currentContext : result;\n if (shouldDisplay(result)) {\n template = fn;\n } else if (inverse) {\n template = inverse;\n }\n\n template(context, { data: options.data });\n } else {\n // Create the view that will wrap the output of this template/property\n // and add it to the nearest view's childViews array.\n // See the documentation of Ember._HandlebarsBoundView for more.\n var bindView = view.createChildView(Ember._HandlebarsBoundView, {\n preserveContext: preserveContext,\n shouldDisplayFunc: shouldDisplay,\n valueNormalizerFunc: valueNormalizer,\n displayTemplate: fn,\n inverseTemplate: inverse,\n path: path,\n pathRoot: pathRoot,\n previousContext: currentContext,\n isEscaped: !options.hash.unescaped,\n templateData: options.data\n });\n\n view.appendChild(bindView);\n\n /** @private */\n observer = function() {\n Ember.run.scheduleOnce('render', bindView, 'rerenderIfNeeded');\n };\n }\n\n // Observes the given property on the context and\n // tells the Ember._HandlebarsBoundView to re-render. If property\n // is an empty string, we are printing the current context\n // object ({{this}}) so updating it is not our responsibility.\n if (path !== '') {\n Ember.addObserver(pathRoot, path, observer);\n\n view.one('willClearRender', function() {\n Ember.removeObserver(pathRoot, path, observer);\n });\n }\n } else {\n // The object is not observable, so just render it out and\n // be done with it.\n data.buffer.push(handlebarsGet(pathRoot, path, options));\n }\n}\n\nfunction simpleBind(property, options) {\n var data = options.data,\n view = data.view,\n currentContext = this,\n pathRoot, path, normalized,\n observer;\n\n normalized = normalizePath(currentContext, property, data);\n\n pathRoot = normalized.root;\n path = normalized.path;\n\n // Set up observers for observable objects\n if ('object' === typeof this) {\n if (data.insideGroup) {\n observer = function() {\n Ember.run.once(view, 'rerender');\n };\n\n var result = handlebarsGet(pathRoot, path, options);\n if (result === null || result === undefined) { result = \"\"; }\n data.buffer.push(result);\n } else {\n var bindView = new Ember._SimpleHandlebarsView(\n path, pathRoot, !options.hash.unescaped, options.data\n );\n\n bindView._parentView = view;\n view.appendChild(bindView);\n\n observer = function() {\n Ember.run.scheduleOnce('render', bindView, 'rerender');\n };\n }\n\n // Observes the given property on the context and\n // tells the Ember._HandlebarsBoundView to re-render. If property\n // is an empty string, we are printing the current context\n // object ({{this}}) so updating it is not our responsibility.\n if (path !== '') {\n Ember.addObserver(pathRoot, path, observer);\n\n view.one('willClearRender', function() {\n Ember.removeObserver(pathRoot, path, observer);\n });\n }\n } else {\n // The object is not observable, so just render it out and\n // be done with it.\n data.buffer.push(handlebarsGet(pathRoot, path, options));\n }\n}\n\n/**\n @private\n\n '_triageMustache' is used internally select between a binding and helper for\n the given context. Until this point, it would be hard to determine if the\n mustache is a property reference or a regular helper reference. This triage\n helper resolves that.\n\n This would not be typically invoked by directly.\n\n @method _triageMustache\n @for Ember.Handlebars.helpers\n @param {String} property Property/helperID to triage\n @param {Function} fn Context to provide for rendering\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('_triageMustache', function(property, fn) {\n Ember.assert(\"You cannot pass more than one argument to the _triageMustache helper\", arguments.length <= 2);\n if (helpers[property]) {\n return helpers[property].call(this, fn);\n }\n else {\n return helpers.bind.apply(this, arguments);\n }\n});\n\n/**\n @private\n\n `bind` can be used to display a value, then update that value if it\n changes. For example, if you wanted to print the `title` property of\n `content`:\n\n ```handlebars\n {{bind \"content.title\"}}\n ```\n\n This will return the `title` property as a string, then create a new observer\n at the specified path. If it changes, it will update the value in DOM. Note\n that if you need to support IE7 and IE8 you must modify the model objects\n properties using `Ember.get()` and `Ember.set()` for this to work as it\n relies on Ember's KVO system. For all other browsers this will be handled for\n you automatically.\n\n @method bind\n @for Ember.Handlebars.helpers\n @param {String} property Property to bind\n @param {Function} fn Context to provide for rendering\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('bind', function(property, options) {\n Ember.assert(\"You cannot pass more than one argument to the bind helper\", arguments.length <= 2);\n\n var context = (options.contexts && options.contexts[0]) || this;\n\n if (!options.fn) {\n return simpleBind.call(context, property, options);\n }\n\n return bind.call(context, property, options, false, function(result) {\n return !Ember.isNone(result);\n });\n});\n\n/**\n @private\n\n Use the `boundIf` helper to create a conditional that re-evaluates\n whenever the truthiness of the bound value changes.\n\n ```handlebars\n {{#boundIf \"content.shouldDisplayTitle\"}}\n {{content.title}}\n {{/boundIf}}\n ```\n\n @method boundIf\n @for Ember.Handlebars.helpers\n @param {String} property Property to bind\n @param {Function} fn Context to provide for rendering\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('boundIf', function(property, fn) {\n var context = (fn.contexts && fn.contexts[0]) || this;\n var func = function(result) {\n if (Ember.typeOf(result) === 'array') {\n return get(result, 'length') !== 0;\n } else {\n return !!result;\n }\n };\n\n return bind.call(context, property, fn, true, func, func);\n});\n\n/**\n @method with\n @for Ember.Handlebars.helpers\n @param {Function} context\n @param {Hash} options\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('with', function(context, options) {\n if (arguments.length === 4) {\n var keywordName, path, rootPath, normalized;\n\n Ember.assert(\"If you pass more than one argument to the with helper, it must be in the form #with foo as bar\", arguments[1] === \"as\");\n options = arguments[3];\n keywordName = arguments[2];\n path = arguments[0];\n\n Ember.assert(\"You must pass a block to the with helper\", options.fn && options.fn !== Handlebars.VM.noop);\n\n if (Ember.isGlobalPath(path)) {\n Ember.bind(options.data.keywords, keywordName, path);\n } else {\n normalized = normalizePath(this, path, options.data);\n path = normalized.path;\n rootPath = normalized.root;\n\n // This is a workaround for the fact that you cannot bind separate objects\n // together. When we implement that functionality, we should use it here.\n var contextKey = Ember.$.expando + Ember.guidFor(rootPath);\n options.data.keywords[contextKey] = rootPath;\n\n // if the path is '' (\"this\"), just bind directly to the current context\n var contextPath = path ? contextKey + '.' + path : contextKey;\n Ember.bind(options.data.keywords, keywordName, contextPath);\n }\n\n return bind.call(this, path, options, true, function(result) {\n return !Ember.isNone(result);\n });\n } else {\n Ember.assert(\"You must pass exactly one argument to the with helper\", arguments.length === 2);\n Ember.assert(\"You must pass a block to the with helper\", options.fn && options.fn !== Handlebars.VM.noop);\n return helpers.bind.call(options.contexts[0], context, options);\n }\n});\n\n\n/**\n See `boundIf`\n\n @method if\n @for Ember.Handlebars.helpers\n @param {Function} context\n @param {Hash} options\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('if', function(context, options) {\n Ember.assert(\"You must pass exactly one argument to the if helper\", arguments.length === 2);\n Ember.assert(\"You must pass a block to the if helper\", options.fn && options.fn !== Handlebars.VM.noop);\n\n return helpers.boundIf.call(options.contexts[0], context, options);\n});\n\n/**\n @method unless\n @for Ember.Handlebars.helpers\n @param {Function} context\n @param {Hash} options\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('unless', function(context, options) {\n Ember.assert(\"You must pass exactly one argument to the unless helper\", arguments.length === 2);\n Ember.assert(\"You must pass a block to the unless helper\", options.fn && options.fn !== Handlebars.VM.noop);\n\n var fn = options.fn, inverse = options.inverse;\n\n options.fn = inverse;\n options.inverse = fn;\n\n return helpers.boundIf.call(options.contexts[0], context, options);\n});\n\n/**\n `bindAttr` allows you to create a binding between DOM element attributes and\n Ember objects. For example:\n\n ```handlebars\n <img {{bindAttr src=\"imageUrl\" alt=\"imageTitle\"}}>\n ```\n\n The above handlebars template will fill the `<img>`'s `src` attribute will\n the value of the property referenced with `\"imageUrl\"` and its `alt`\n attribute with the value of the property referenced with `\"imageTitle\"`.\n\n If the rendering context of this template is the following object:\n\n ```javascript\n {\n imageUrl: 'http://lolcats.info/haz-a-funny',\n imageTitle: 'A humorous image of a cat'\n }\n ```\n\n The resulting HTML output will be:\n\n ```html\n <img src=\"http://lolcats.info/haz-a-funny\" alt=\"A humorous image of a cat\">\n ```\n\n `bindAttr` cannot redeclare existing DOM element attributes. The use of `src`\n in the following `bindAttr` example will be ignored and the hard coded value\n of `src=\"/failwhale.gif\"` will take precedence:\n\n ```handlebars\n <img src=\"/failwhale.gif\" {{bindAttr src=\"imageUrl\" alt=\"imageTitle\"}}>\n ```\n\n ### `bindAttr` and the `class` attribute\n\n `bindAttr` supports a special syntax for handling a number of cases unique\n to the `class` DOM element attribute. The `class` attribute combines\n multiple discreet values into a single attribute as a space-delimited\n list of strings. Each string can be:\n\n * a string return value of an object's property.\n * a boolean return value of an object's property\n * a hard-coded value\n\n A string return value works identically to other uses of `bindAttr`. The\n return value of the property will become the value of the attribute. For\n example, the following view and template:\n\n ```javascript\n AView = Ember.View.extend({\n someProperty: function(){\n return \"aValue\";\n }.property()\n })\n ```\n\n ```handlebars\n <img {{bindAttr class=\"view.someProperty}}>\n ```\n\n Result in the following rendered output:\n\n ```html \n <img class=\"aValue\">\n ```\n\n A boolean return value will insert a specified class name if the property\n returns `true` and remove the class name if the property returns `false`.\n\n A class name is provided via the syntax \n `somePropertyName:class-name-if-true`.\n\n ```javascript\n AView = Ember.View.extend({\n someBool: true\n })\n ```\n\n ```handlebars\n <img {{bindAttr class=\"view.someBool:class-name-if-true\"}}>\n ```\n\n Result in the following rendered output:\n\n ```html\n <img class=\"class-name-if-true\">\n ```\n\n An additional section of the binding can be provided if you want to\n replace the existing class instead of removing it when the boolean\n value changes:\n\n ```handlebars\n <img {{bindAttr class=\"view.someBool:class-name-if-true:class-name-if-false\"}}>\n ```\n\n A hard-coded value can be used by prepending `:` to the desired\n class name: `:class-name-to-always-apply`.\n\n ```handlebars\n <img {{bindAttr class=\":class-name-to-always-apply\"}}>\n ```\n\n Results in the following rendered output:\n\n ```html\n <img class=\":class-name-to-always-apply\">\n ```\n\n All three strategies - string return value, boolean return value, and\n hard-coded value – can be combined in a single declaration:\n\n ```handlebars\n <img {{bindAttr class=\":class-name-to-always-apply view.someBool:class-name-if-true view.someProperty\"}}>\n ```\n\n @method bindAttr\n @for Ember.Handlebars.helpers\n @param {Hash} options\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('bindAttr', function(options) {\n\n var attrs = options.hash;\n\n Ember.assert(\"You must specify at least one hash argument to bindAttr\", !!Ember.keys(attrs).length);\n\n var view = options.data.view;\n var ret = [];\n var ctx = this;\n\n // Generate a unique id for this element. This will be added as a\n // data attribute to the element so it can be looked up when\n // the bound property changes.\n var dataId = ++Ember.uuid;\n\n // Handle classes differently, as we can bind multiple classes\n var classBindings = attrs['class'];\n if (classBindings !== null && classBindings !== undefined) {\n var classResults = EmberHandlebars.bindClasses(this, classBindings, view, dataId, options);\n\n ret.push('class=\"' + Handlebars.Utils.escapeExpression(classResults.join(' ')) + '\"');\n delete attrs['class'];\n }\n\n var attrKeys = Ember.keys(attrs);\n\n // For each attribute passed, create an observer and emit the\n // current value of the property as an attribute.\n forEach.call(attrKeys, function(attr) {\n var path = attrs[attr],\n pathRoot, normalized;\n\n Ember.assert(fmt(\"You must provide a String for a bound attribute, not %@\", [path]), typeof path === 'string');\n\n normalized = normalizePath(ctx, path, options.data);\n\n pathRoot = normalized.root;\n path = normalized.path;\n\n var value = (path === 'this') ? pathRoot : handlebarsGet(pathRoot, path, options),\n type = Ember.typeOf(value);\n\n Ember.assert(fmt(\"Attributes must be numbers, strings or booleans, not %@\", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean');\n\n var observer, invoker;\n\n observer = function observer() {\n var result = handlebarsGet(pathRoot, path, options);\n\n Ember.assert(fmt(\"Attributes must be numbers, strings or booleans, not %@\", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean');\n\n var elem = view.$(\"[data-bindattr-\" + dataId + \"='\" + dataId + \"']\");\n\n // If we aren't able to find the element, it means the element\n // to which we were bound has been removed from the view.\n // In that case, we can assume the template has been re-rendered\n // and we need to clean up the observer.\n if (!elem || elem.length === 0) {\n Ember.removeObserver(pathRoot, path, invoker);\n return;\n }\n\n Ember.View.applyAttributeBindings(elem, attr, result);\n };\n\n invoker = function() {\n Ember.run.scheduleOnce('render', observer);\n };\n\n // Add an observer to the view for when the property changes.\n // When the observer fires, find the element using the\n // unique data id and update the attribute to the new value.\n if (path !== 'this') {\n Ember.addObserver(pathRoot, path, invoker);\n\n view.one('willClearRender', function() {\n Ember.removeObserver(pathRoot, path, invoker);\n });\n }\n\n // if this changes, also change the logic in ember-views/lib/views/view.js\n if ((type === 'string' || (type === 'number' && !isNaN(value)))) {\n ret.push(attr + '=\"' + Handlebars.Utils.escapeExpression(value) + '\"');\n } else if (value && type === 'boolean') {\n // The developer controls the attr name, so it should always be safe\n ret.push(attr + '=\"' + attr + '\"');\n }\n }, this);\n\n // Add the unique identifier\n // NOTE: We use all lower-case since Firefox has problems with mixed case in SVG\n ret.push('data-bindattr-' + dataId + '=\"' + dataId + '\"');\n return new EmberHandlebars.SafeString(ret.join(' '));\n});\n\n/**\n @private\n\n Helper that, given a space-separated string of property paths and a context,\n returns an array of class names. Calling this method also has the side\n effect of setting up observers at those property paths, such that if they\n change, the correct class name will be reapplied to the DOM element.\n\n For example, if you pass the string \"fooBar\", it will first look up the\n \"fooBar\" value of the context. If that value is true, it will add the\n \"foo-bar\" class to the current element (i.e., the dasherized form of\n \"fooBar\"). If the value is a string, it will add that string as the class.\n Otherwise, it will not add any new class name.\n\n @method bindClasses\n @for Ember.Handlebars\n @param {Ember.Object} context The context from which to lookup properties\n @param {String} classBindings A string, space-separated, of class bindings \n to use\n @param {Ember.View} view The view in which observers should look for the \n element to update\n @param {Srting} bindAttrId Optional bindAttr id used to lookup elements\n @return {Array} An array of class names to add\n*/\nEmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, options) {\n var ret = [], newClass, value, elem;\n\n // Helper method to retrieve the property from the context and\n // determine which class string to return, based on whether it is\n // a Boolean or not.\n var classStringForPath = function(root, parsedPath, options) {\n var val,\n path = parsedPath.path;\n\n if (path === 'this') {\n val = root;\n } else if (path === '') {\n val = true;\n } else {\n val = handlebarsGet(root, path, options);\n }\n\n return Ember.View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);\n };\n\n // For each property passed, loop through and setup\n // an observer.\n forEach.call(classBindings.split(' '), function(binding) {\n\n // Variable in which the old class value is saved. The observer function\n // closes over this variable, so it knows which string to remove when\n // the property changes.\n var oldClass;\n\n var observer, invoker;\n\n var parsedPath = Ember.View._parsePropertyPath(binding),\n path = parsedPath.path,\n pathRoot = context,\n normalized;\n\n if (path !== '' && path !== 'this') {\n normalized = normalizePath(context, path, options.data);\n\n pathRoot = normalized.root;\n path = normalized.path;\n }\n\n // Set up an observer on the context. If the property changes, toggle the\n // class name.\n observer = function() {\n // Get the current value of the property\n newClass = classStringForPath(pathRoot, parsedPath, options);\n elem = bindAttrId ? view.$(\"[data-bindattr-\" + bindAttrId + \"='\" + bindAttrId + \"']\") : view.$();\n\n // If we can't find the element anymore, a parent template has been\n // re-rendered and we've been nuked. Remove the observer.\n if (!elem || elem.length === 0) {\n Ember.removeObserver(pathRoot, path, invoker);\n } else {\n // If we had previously added a class to the element, remove it.\n if (oldClass) {\n elem.removeClass(oldClass);\n }\n\n // If necessary, add a new class. Make sure we keep track of it so\n // it can be removed in the future.\n if (newClass) {\n elem.addClass(newClass);\n oldClass = newClass;\n } else {\n oldClass = null;\n }\n }\n };\n\n invoker = function() {\n Ember.run.scheduleOnce('render', observer);\n };\n\n if (path !== '' && path !== 'this') {\n Ember.addObserver(pathRoot, path, invoker);\n\n view.one('willClearRender', function() {\n Ember.removeObserver(pathRoot, path, invoker);\n });\n }\n\n // We've already setup the observer; now we just need to figure out the\n // correct behavior right now on the first pass through.\n value = classStringForPath(pathRoot, parsedPath, options);\n\n if (value) {\n ret.push(value);\n\n // Make sure we save the current value so that it can be removed if the\n // observer fires.\n oldClass = value;\n }\n });\n\n return ret;\n};\n\n\n})();\n\n\n\n(function() {\n/*globals Handlebars */\n\n// TODO: Don't require the entire module\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar PARENT_VIEW_PATH = /^parentView\\./;\nvar EmberHandlebars = Ember.Handlebars;\n\nEmberHandlebars.ViewHelper = Ember.Object.create({\n\n propertiesFromHTMLOptions: function(options, thisContext) {\n var hash = options.hash, data = options.data;\n var extensions = {},\n classes = hash['class'],\n dup = false;\n\n if (hash.id) {\n extensions.elementId = hash.id;\n dup = true;\n }\n\n if (classes) {\n classes = classes.split(' ');\n extensions.classNames = classes;\n dup = true;\n }\n\n if (hash.classBinding) {\n extensions.classNameBindings = hash.classBinding.split(' ');\n dup = true;\n }\n\n if (hash.classNameBindings) {\n if (extensions.classNameBindings === undefined) extensions.classNameBindings = [];\n extensions.classNameBindings = extensions.classNameBindings.concat(hash.classNameBindings.split(' '));\n dup = true;\n }\n\n if (hash.attributeBindings) {\n Ember.assert(\"Setting 'attributeBindings' via Handlebars is not allowed. Please subclass Ember.View and set it there instead.\");\n extensions.attributeBindings = null;\n dup = true;\n }\n\n if (dup) {\n hash = Ember.$.extend({}, hash);\n delete hash.id;\n delete hash['class'];\n delete hash.classBinding;\n }\n\n // Set the proper context for all bindings passed to the helper. This applies to regular attribute bindings\n // as well as class name bindings. If the bindings are local, make them relative to the current context\n // instead of the view.\n var path;\n\n // Evaluate the context of regular attribute bindings:\n for (var prop in hash) {\n if (!hash.hasOwnProperty(prop)) { continue; }\n\n // Test if the property ends in \"Binding\"\n if (Ember.IS_BINDING.test(prop) && typeof hash[prop] === 'string') {\n path = this.contextualizeBindingPath(hash[prop], data);\n if (path) { hash[prop] = path; }\n }\n }\n\n // Evaluate the context of class name bindings:\n if (extensions.classNameBindings) {\n for (var b in extensions.classNameBindings) {\n var full = extensions.classNameBindings[b];\n if (typeof full === 'string') {\n // Contextualize the path of classNameBinding so this:\n //\n // classNameBinding=\"isGreen:green\"\n //\n // is converted to this:\n //\n // classNameBinding=\"_parentView.context.isGreen:green\"\n var parsedPath = Ember.View._parsePropertyPath(full);\n path = this.contextualizeBindingPath(parsedPath.path, data);\n if (path) { extensions.classNameBindings[b] = path + parsedPath.classNames; }\n }\n }\n }\n\n return Ember.$.extend(hash, extensions);\n },\n\n // Transform bindings from the current context to a context that can be evaluated within the view.\n // Returns null if the path shouldn't be changed.\n //\n // TODO: consider the addition of a prefix that would allow this method to return `path`.\n contextualizeBindingPath: function(path, data) {\n var normalized = Ember.Handlebars.normalizePath(null, path, data);\n if (normalized.isKeyword) {\n return 'templateData.keywords.' + path;\n } else if (Ember.isGlobalPath(path)) {\n return null;\n } else if (path === 'this') {\n return '_parentView.context';\n } else {\n return '_parentView.context.' + path;\n }\n },\n\n helper: function(thisContext, path, options) {\n var inverse = options.inverse,\n data = options.data,\n view = data.view,\n fn = options.fn,\n hash = options.hash,\n newView;\n\n if ('string' === typeof path) {\n newView = EmberHandlebars.get(thisContext, path, options);\n Ember.assert(\"Unable to find view at path '\" + path + \"'\", !!newView);\n } else {\n newView = path;\n }\n\n Ember.assert(Ember.String.fmt('You must pass a view class to the #view helper, not %@ (%@)', [path, newView]), Ember.View.detect(newView));\n\n var viewOptions = this.propertiesFromHTMLOptions(options, thisContext);\n var currentView = data.view;\n viewOptions.templateData = options.data;\n\n if (fn) {\n Ember.assert(\"You cannot provide a template block if you also specified a templateName\", !get(viewOptions, 'templateName') && !get(newView.proto(), 'templateName'));\n viewOptions.template = fn;\n }\n\n // We only want to override the `_context` computed property if there is\n // no specified controller. See View#_context for more information.\n if (!newView.proto().controller && !newView.proto().controllerBinding && !viewOptions.controller && !viewOptions.controllerBinding) {\n viewOptions._context = thisContext;\n }\n\n currentView.appendChild(newView, viewOptions);\n }\n});\n\n/**\n `{{view}}` inserts a new instance of `Ember.View` into a template passing its\n options to the `Ember.View`'s `create` method and using the supplied block as\n the view's own template.\n\n An empty `<body>` and the following template:\n\n ```handlebars\n A span:\n {{#view tagName=\"span\"}}\n hello.\n {{/view}}\n ```\n\n Will result in HTML structure:\n\n ```html\n <body>\n <!-- Note: the handlebars template script\n also results in a rendered Ember.View\n which is the outer <div> here -->\n\n <div class=\"ember-view\">\n A span:\n <span id=\"ember1\" class=\"ember-view\">\n Hello.\n </span>\n </div>\n </body>\n ```\n\n ### `parentView` setting\n\n The `parentView` property of the new `Ember.View` instance created through\n `{{view}}` will be set to the `Ember.View` instance of the template where\n `{{view}}` was called.\n\n ```javascript\n aView = Ember.View.create({\n template: Ember.Handlebars.compile(\"{{#view}} my parent: {{parentView.elementId}} {{/view}}\")\n });\n\n aView.appendTo('body');\n ```\n\n Will result in HTML structure:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">\n <div id=\"ember2\" class=\"ember-view\">\n my parent: ember1\n </div>\n </div>\n ```\n\n ### Setting CSS id and class attributes\n\n The HTML `id` attribute can be set on the `{{view}}`'s resulting element with\n the `id` option. This option will _not_ be passed to `Ember.View.create`.\n\n ```handlebars\n {{#view tagName=\"span\" id=\"a-custom-id\"}}\n hello.\n {{/view}}\n ```\n\n Results in the following HTML structure:\n\n ```html\n <div class=\"ember-view\">\n <span id=\"a-custom-id\" class=\"ember-view\">\n hello.\n </span>\n </div>\n ```\n\n The HTML `class` attribute can be set on the `{{view}}`'s resulting element\n with the `class` or `classNameBindings` options. The `class` option will\n directly set the CSS `class` attribute and will not be passed to\n `Ember.View.create`. `classNameBindings` will be passed to `create` and use\n `Ember.View`'s class name binding functionality:\n\n ```handlebars\n {{#view tagName=\"span\" class=\"a-custom-class\"}}\n hello.\n {{/view}}\n ```\n\n Results in the following HTML structure:\n\n ```html\n <div class=\"ember-view\">\n <span id=\"ember2\" class=\"ember-view a-custom-class\">\n hello.\n </span>\n </div>\n ```\n\n ### Supplying a different view class\n\n `{{view}}` can take an optional first argument before its supplied options to\n specify a path to a custom view class.\n\n ```handlebars\n {{#view \"MyApp.CustomView\"}}\n hello.\n {{/view}}\n ```\n\n The first argument can also be a relative path. Ember will search for the\n view class starting at the `Ember.View` of the template where `{{view}}` was\n used as the root object:\n\n ```javascript\n MyApp = Ember.Application.create({});\n MyApp.OuterView = Ember.View.extend({\n innerViewClass: Ember.View.extend({\n classNames: ['a-custom-view-class-as-property']\n }),\n template: Ember.Handlebars.compile('{{#view \"innerViewClass\"}} hi {{/view}}')\n });\n\n MyApp.OuterView.create().appendTo('body');\n ```\n\n Will result in the following HTML:\n\n ```html\n <div id=\"ember1\" class=\"ember-view\">\n <div id=\"ember2\" class=\"ember-view a-custom-view-class-as-property\">\n hi\n </div>\n </div>\n ```\n\n ### Blockless use\n\n If you supply a custom `Ember.View` subclass that specifies its own template\n or provide a `templateName` option to `{{view}}` it can be used without\n supplying a block. Attempts to use both a `templateName` option and supply a\n block will throw an error.\n\n ```handlebars\n {{view \"MyApp.ViewWithATemplateDefined\"}}\n ```\n\n ### `viewName` property\n\n You can supply a `viewName` option to `{{view}}`. The `Ember.View` instance\n will be referenced as a property of its parent view by this name.\n\n ```javascript\n aView = Ember.View.create({\n template: Ember.Handlebars.compile('{{#view viewName=\"aChildByName\"}} hi {{/view}}')\n });\n\n aView.appendTo('body');\n aView.get('aChildByName') // the instance of Ember.View created by {{view}} helper\n ```\n\n @method view\n @for Ember.Handlebars.helpers\n @param {String} path\n @param {Hash} options\n @return {String} HTML string\n*/\nEmberHandlebars.registerHelper('view', function(path, options) {\n Ember.assert(\"The view helper only takes a single argument\", arguments.length <= 2);\n\n // If no path is provided, treat path param as options.\n if (path && path.data && path.data.isRenderData) {\n options = path;\n path = \"Ember.View\";\n }\n\n return EmberHandlebars.ViewHelper.helper(this, path, options);\n});\n\n\n})();\n\n\n\n(function() {\n/*globals Handlebars */\n\n// TODO: Don't require all of this module\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, handlebarsGet = Ember.Handlebars.get, fmt = Ember.String.fmt;\n\n/**\n `{{collection}}` is a `Ember.Handlebars` helper for adding instances of\n `Ember.CollectionView` to a template. See `Ember.CollectionView` for\n additional information on how a `CollectionView` functions.\n\n `{{collection}}`'s primary use is as a block helper with a `contentBinding`\n option pointing towards an `Ember.Array`-compatible object. An `Ember.View`\n instance will be created for each item in its `content` property. Each view\n will have its own `content` property set to the appropriate item in the\n collection.\n\n The provided block will be applied as the template for each item's view.\n\n Given an empty `<body>` the following template:\n\n ```handlebars\n {{#collection contentBinding=\"App.items\"}}\n Hi {{view.content.name}}\n {{/collection}}\n ```\n\n And the following application code\n\n ```javascript\n App = Ember.Application.create()\n App.items = [\n Ember.Object.create({name: 'Dave'}),\n Ember.Object.create({name: 'Mary'}),\n Ember.Object.create({name: 'Sara'})\n ]\n ```\n\n Will result in the HTML structure below\n\n ```html\n <div class=\"ember-view\">\n <div class=\"ember-view\">Hi Dave</div>\n <div class=\"ember-view\">Hi Mary</div>\n <div class=\"ember-view\">Hi Sara</div>\n </div>\n ```\n\n ### Blockless Use\n\n If you provide an `itemViewClass` option that has its own `template` you can\n omit the block.\n\n The following template:\n\n ```handlebars\n {{collection contentBinding=\"App.items\" itemViewClass=\"App.AnItemView\"}}\n ```\n\n And application code\n\n ```javascript\n App = Ember.Application.create();\n App.items = [\n Ember.Object.create({name: 'Dave'}),\n Ember.Object.create({name: 'Mary'}),\n Ember.Object.create({name: 'Sara'})\n ];\n\n App.AnItemView = Ember.View.extend({\n template: Ember.Handlebars.compile(\"Greetings {{view.content.name}}\")\n });\n ```\n\n Will result in the HTML structure below\n\n ```html\n <div class=\"ember-view\">\n <div class=\"ember-view\">Greetings Dave</div>\n <div class=\"ember-view\">Greetings Mary</div>\n <div class=\"ember-view\">Greetings Sara</div>\n </div>\n ```\n\n ### Specifying a CollectionView subclass\n\n By default the `{{collection}}` helper will create an instance of\n `Ember.CollectionView`. You can supply a `Ember.CollectionView` subclass to\n the helper by passing it as the first argument:\n\n ```handlebars\n {{#collection App.MyCustomCollectionClass contentBinding=\"App.items\"}}\n Hi {{view.content.name}}\n {{/collection}}\n ```\n\n ### Forwarded `item.*`-named Options\n\n As with the `{{view}}`, helper options passed to the `{{collection}}` will be\n set on the resulting `Ember.CollectionView` as properties. Additionally,\n options prefixed with `item` will be applied to the views rendered for each\n item (note the camelcasing):\n\n ```handlebars\n {{#collection contentBinding=\"App.items\"\n itemTagName=\"p\"\n itemClassNames=\"greeting\"}}\n Howdy {{view.content.name}}\n {{/collection}}\n ```\n\n Will result in the following HTML structure:\n\n ```html\n <div class=\"ember-view\">\n <p class=\"ember-view greeting\">Howdy Dave</p>\n <p class=\"ember-view greeting\">Howdy Mary</p>\n <p class=\"ember-view greeting\">Howdy Sara</p>\n </div>\n ```\n\n @method collection\n @for Ember.Handlebars.helpers\n @param {String} path\n @param {Hash} options\n @return {String} HTML string\n @deprecated Use `{{each}}` helper instead.\n*/\nEmber.Handlebars.registerHelper('collection', function(path, options) {\n Ember.deprecate(\"Using the {{collection}} helper without specifying a class has been deprecated as the {{each}} helper now supports the same functionality.\", path !== 'collection');\n\n // If no path is provided, treat path param as options.\n if (path && path.data && path.data.isRenderData) {\n options = path;\n path = undefined;\n Ember.assert(\"You cannot pass more than one argument to the collection helper\", arguments.length === 1);\n } else {\n Ember.assert(\"You cannot pass more than one argument to the collection helper\", arguments.length === 2);\n }\n\n var fn = options.fn;\n var data = options.data;\n var inverse = options.inverse;\n var view = options.data.view;\n\n // If passed a path string, convert that into an object.\n // Otherwise, just default to the standard class.\n var collectionClass;\n collectionClass = path ? handlebarsGet(this, path, options) : Ember.CollectionView;\n Ember.assert(fmt(\"%@ #collection: Could not find collection class %@\", [data.view, path]), !!collectionClass);\n\n var hash = options.hash, itemHash = {}, match;\n\n // Extract item view class if provided else default to the standard class\n var itemViewClass, itemViewPath = hash.itemViewClass;\n var collectionPrototype = collectionClass.proto();\n delete hash.itemViewClass;\n itemViewClass = itemViewPath ? handlebarsGet(collectionPrototype, itemViewPath, options) : collectionPrototype.itemViewClass;\n Ember.assert(fmt(\"%@ #collection: Could not find itemViewClass %@\", [data.view, itemViewPath]), !!itemViewClass);\n\n // Go through options passed to the {{collection}} helper and extract options\n // that configure item views instead of the collection itself.\n for (var prop in hash) {\n if (hash.hasOwnProperty(prop)) {\n match = prop.match(/^item(.)(.*)$/);\n\n if(match) {\n // Convert itemShouldFoo -> shouldFoo\n itemHash[match[1].toLowerCase() + match[2]] = hash[prop];\n // Delete from hash as this will end up getting passed to the\n // {{view}} helper method.\n delete hash[prop];\n }\n }\n }\n\n var tagName = hash.tagName || collectionPrototype.tagName;\n\n if (fn) {\n itemHash.template = fn;\n delete options.fn;\n }\n\n var emptyViewClass;\n if (inverse && inverse !== Handlebars.VM.noop) {\n emptyViewClass = get(collectionPrototype, 'emptyViewClass');\n emptyViewClass = emptyViewClass.extend({\n template: inverse,\n tagName: itemHash.tagName\n });\n } else if (hash.emptyViewClass) {\n emptyViewClass = handlebarsGet(this, hash.emptyViewClass, options);\n }\n hash.emptyView = emptyViewClass;\n\n if (hash.eachHelper === 'each') {\n itemHash._context = Ember.computed(function() {\n return get(this, 'content');\n }).property('content');\n delete hash.eachHelper;\n }\n\n var viewString = view.toString();\n\n var viewOptions = Ember.Handlebars.ViewHelper.propertiesFromHTMLOptions({ data: data, hash: itemHash }, this);\n hash.itemViewClass = itemViewClass.extend(viewOptions);\n\n return Ember.Handlebars.helpers.view.call(this, collectionClass, options);\n});\n\n\n})();\n\n\n\n(function() {\n/*globals Handlebars */\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar handlebarsGet = Ember.Handlebars.get;\n\n/**\n `unbound` allows you to output a property without binding. *Important:* The\n output will not be updated if the property changes. Use with caution.\n\n ```handlebars\n <div>{{unbound somePropertyThatDoesntChange}}</div>\n ```\n\n @method unbound\n @for Ember.Handlebars.helpers\n @param {String} property\n @return {String} HTML string\n*/\nEmber.Handlebars.registerHelper('unbound', function(property, fn) {\n var context = (fn.contexts && fn.contexts[0]) || this;\n return handlebarsGet(context, property, fn);\n});\n\n})();\n\n\n\n(function() {\n/*jshint debug:true*/\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath;\n\n/**\n `log` allows you to output the value of a value in the current rendering\n context.\n\n ```handlebars\n {{log myVariable}}\n ```\n\n @method log\n @for Ember.Handlebars.helpers\n @param {String} property\n*/\nEmber.Handlebars.registerHelper('log', function(property, options) {\n var context = (options.contexts && options.contexts[0]) || this,\n normalized = normalizePath(context, property, options.data),\n pathRoot = normalized.root,\n path = normalized.path,\n value = (path === 'this') ? pathRoot : handlebarsGet(pathRoot, path, options);\n Ember.Logger.log(value);\n});\n\n/**\n Execute the `debugger` statement in the current context.\n\n ```handlebars\n {{debugger}}\n ```\n\n @method debugger\n @for Ember.Handlebars.helpers\n @param {String} property\n*/\nEmber.Handlebars.registerHelper('debugger', function() {\n debugger;\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\nEmber.Handlebars.EachView = Ember.CollectionView.extend(Ember._Metamorph, {\n itemViewClass: Ember._MetamorphView,\n emptyViewClass: Ember._MetamorphView,\n\n createChildView: function(view, attrs) {\n view = this._super(view, attrs);\n\n // At the moment, if a container view subclass wants\n // to insert keywords, it is responsible for cloning\n // the keywords hash. This will be fixed momentarily.\n var keyword = get(this, 'keyword');\n\n if (keyword) {\n var data = get(view, 'templateData');\n\n data = Ember.copy(data);\n data.keywords = view.cloneKeywords();\n set(view, 'templateData', data);\n\n var content = get(view, 'content');\n\n // In this case, we do not bind, because the `content` of\n // a #each item cannot change.\n data.keywords[keyword] = content;\n }\n\n return view;\n }\n});\n\nvar GroupedEach = Ember.Handlebars.GroupedEach = function(context, path, options) {\n var self = this,\n normalized = Ember.Handlebars.normalizePath(context, path, options.data);\n\n this.context = context;\n this.path = path;\n this.options = options;\n this.template = options.fn;\n this.containingView = options.data.view;\n this.normalizedRoot = normalized.root;\n this.normalizedPath = normalized.path;\n this.content = this.lookupContent();\n\n this.addContentObservers();\n this.addArrayObservers();\n\n this.containingView.on('willClearRender', function() {\n self.destroy();\n });\n};\n\nGroupedEach.prototype = {\n contentWillChange: function() {\n this.removeArrayObservers();\n },\n\n contentDidChange: function() {\n this.content = this.lookupContent();\n this.addArrayObservers();\n this.rerenderContainingView();\n },\n\n contentArrayWillChange: Ember.K,\n\n contentArrayDidChange: function() {\n this.rerenderContainingView();\n },\n\n lookupContent: function() {\n return Ember.Handlebars.get(this.normalizedRoot, this.normalizedPath, this.options);\n },\n\n addArrayObservers: function() {\n this.content.addArrayObserver(this, {\n willChange: 'contentArrayWillChange',\n didChange: 'contentArrayDidChange'\n });\n },\n\n removeArrayObservers: function() {\n this.content.removeArrayObserver(this, {\n willChange: 'contentArrayWillChange',\n didChange: 'contentArrayDidChange'\n });\n },\n\n addContentObservers: function() {\n Ember.addBeforeObserver(this.normalizedRoot, this.normalizedPath, this, this.contentWillChange);\n Ember.addObserver(this.normalizedRoot, this.normalizedPath, this, this.contentDidChange);\n },\n\n removeContentObservers: function() {\n Ember.removeBeforeObserver(this.normalizedRoot, this.normalizedPath, this.contentWillChange);\n Ember.removeObserver(this.normalizedRoot, this.normalizedPath, this.contentDidChange);\n },\n\n render: function() {\n var content = this.content,\n contentLength = get(content, 'length'),\n data = this.options.data,\n template = this.template;\n\n data.insideEach = true;\n for (var i = 0; i < contentLength; i++) {\n template(content.objectAt(i), { data: data });\n }\n },\n\n rerenderContainingView: function() {\n Ember.run.scheduleOnce('render', this.containingView, 'rerender');\n },\n\n destroy: function() {\n this.removeContentObservers();\n this.removeArrayObservers();\n }\n};\n\n/**\n The `{{#each}}` helper loops over elements in a collection, rendering its\n block once for each item:\n\n ```javascript\n Developers = [{name: 'Yehuda'},{name: 'Tom'}, {name: 'Paul'}];\n ```\n\n ```handlebars\n {{#each Developers}}\n {{name}}\n {{/each}}\n ```\n\n `{{each}}` supports an alternative syntax with element naming:\n\n ```handlebars\n {{#each person in Developers}}\n {{person.name}}\n {{/each}}\n ```\n\n When looping over objects that do not have properties, `{{this}}` can be used\n to render the object:\n\n ```javascript\n DeveloperNames = ['Yehuda', 'Tom', 'Paul']\n ```\n\n ```handlebars\n {{#each DeveloperNames}}\n {{this}}\n {{/each}}\n ```\n\n ### Blockless Use\n\n If you provide an `itemViewClass` option that has its own `template` you can\n omit the block in a similar way to how it can be done with the collection\n helper.\n\n The following template:\n\n ```handlebars\n {{#view App.MyView }}\n {{each view.items itemViewClass=\"App.AnItemView\"}} \n {{/view}}\n ```\n\n And application code\n\n ```javascript\n App = Ember.Application.create({\n MyView: Ember.View.extend({\n items: [\n Ember.Object.create({name: 'Dave'}),\n Ember.Object.create({name: 'Mary'}),\n Ember.Object.create({name: 'Sara'})\n ]\n })\n });\n\n App.AnItemView = Ember.View.extend({\n template: Ember.Handlebars.compile(\"Greetings {{name}}\")\n });\n\n App.initialize();\n ```\n\n Will result in the HTML structure below\n\n ```html\n <div class=\"ember-view\">\n <div class=\"ember-view\">Greetings Dave</div>\n <div class=\"ember-view\">Greetings Mary</div>\n <div class=\"ember-view\">Greetings Sara</div>\n </div>\n ```\n\n @method each\n @for Ember.Handlebars.helpers\n @param [name] {String} name for item (used with `in`)\n @param path {String} path\n*/\nEmber.Handlebars.registerHelper('each', function(path, options) {\n if (arguments.length === 4) {\n Ember.assert(\"If you pass more than one argument to the each helper, it must be in the form #each foo in bar\", arguments[1] === \"in\");\n\n var keywordName = arguments[0];\n\n options = arguments[3];\n path = arguments[2];\n if (path === '') { path = \"this\"; }\n\n options.hash.keyword = keywordName;\n } else {\n options.hash.eachHelper = 'each';\n }\n\n options.hash.contentBinding = path;\n // Set up emptyView as a metamorph with no tag\n //options.hash.emptyViewClass = Ember._MetamorphView;\n\n if (options.data.insideGroup && !options.hash.groupedRows && !options.hash.itemViewClass) {\n new Ember.Handlebars.GroupedEach(this, path, options).render();\n } else {\n return Ember.Handlebars.helpers.collection.call(this, 'Ember.Handlebars.EachView', options);\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\n/**\n `template` allows you to render a template from inside another template.\n This allows you to re-use the same template in multiple places. For example:\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name=\"logged_in_user\">\n {{#with loggedInUser}}\n Last Login: {{lastLogin}}\n User Info: {{template \"user_info\"}}\n {{/with}}\n </script>\n ```\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name=\"user_info\">\n Name: <em>{{name}}</em>\n Karma: <em>{{karma}}</em>\n </script>\n ```\n\n This helper looks for templates in the global `Ember.TEMPLATES` hash. If you\n add `<script>` tags to your page with the `data-template-name` attribute set,\n they will be compiled and placed in this hash automatically.\n\n You can also manually register templates by adding them to the hash:\n\n ```javascript\n Ember.TEMPLATES[\"my_cool_template\"] = Ember.Handlebars.compile('<b>{{user}}</b>');\n ```\n\n @method template\n @for Ember.Handlebars.helpers\n @param {String} templateName the template to render\n*/\n\nEmber.Handlebars.registerHelper('template', function(name, options) {\n var template = Ember.TEMPLATES[name];\n\n Ember.assert(\"Unable to find template with name '\"+name+\"'.\", !!template);\n\n Ember.TEMPLATES[name](this, { data: options.data });\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar EmberHandlebars = Ember.Handlebars,\n handlebarsGet = EmberHandlebars.get,\n get = Ember.get,\n a_slice = Array.prototype.slice;\n\nvar ActionHelper = EmberHandlebars.ActionHelper = {\n registeredActions: {}\n};\n\nActionHelper.registerAction = function(actionName, options) {\n var actionId = (++Ember.uuid).toString();\n\n ActionHelper.registeredActions[actionId] = {\n eventName: options.eventName,\n handler: function(event) {\n var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey,\n secondaryClick = event.which > 1, // IE9 may return undefined\n nonStandard = modifier || secondaryClick;\n\n if (options.link && nonStandard) {\n // Allow the browser to handle special link clicks normally\n return;\n }\n\n event.preventDefault();\n\n event.view = options.view;\n\n if (options.hasOwnProperty('context')) {\n event.context = options.context;\n }\n\n if (options.hasOwnProperty('contexts')) {\n event.contexts = options.contexts;\n }\n\n var target = options.target;\n\n // Check for StateManager (or compatible object)\n if (typeof target.send === 'function') {\n return target.send(actionName, event);\n } else {\n Ember.assert(Ember.String.fmt('Target %@ does not have action %@', [target, actionName]), target[actionName]);\n return target[actionName].call(target, event);\n }\n }\n };\n\n options.view.on('willClearRender', function() {\n delete ActionHelper.registeredActions[actionId];\n });\n\n return actionId;\n};\n\n/**\n The `{{action}}` helper registers an HTML element within a template for DOM\n event handling and forwards that interaction to the view's\n `controller.target` or supplied `target` option (see 'Specifying a Target').\n By default the `controller.target` is set to the application's router.\n\n User interaction with that element will invoke the supplied action name on\n the appropriate target.\n\n Given the following Handlebars template on the page\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n <div {{action anActionName target=\"view\"}}>\n click me\n </div>\n </script>\n ```\n\n And application code\n\n ```javascript\n AView = Ember.View.extend({\n templateName: 'a-template',\n anActionName: function(event){}\n });\n\n aView = AView.create();\n aView.appendTo('body');\n ```\n\n Will results in the following rendered HTML\n\n ```html\n <div class=\"ember-view\">\n <div data-ember-action=\"1\">\n click me\n </div>\n </div>\n ```\n\n Clicking \"click me\" will trigger the `anActionName` method of the `aView`\n object with a `jQuery.Event` object as its argument. The `jQuery.Event`\n object will be extended to include a `view` property that is set to the\n original view interacted with (in this case the `aView` object).\n\n ### Event Propagation\n\n Events triggered through the action helper will automatically have\n `.preventDefault()` called on them. You do not need to do so in your event\n handlers. To stop propagation of the event, simply return `false` from your\n handler.\n\n If you need the default handler to trigger you should either register your\n own event handler, or use event methods on your view class. See `Ember.View`\n 'Responding to Browser Events' for more information.\n\n ### Specifying DOM event type\n\n By default the `{{action}}` helper registers for DOM `click` events. You can\n supply an `on` option to the helper to specify a different DOM event name:\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n <div {{action anActionName on=\"doubleClick\"}}>\n click me\n </div>\n </script>\n ```\n\n See `Ember.View` 'Responding to Browser Events' for a list of\n acceptable DOM event names.\n\n Because `{{action}}` depends on Ember's event dispatch system it will only\n function if an `Ember.EventDispatcher` instance is available. An\n `Ember.EventDispatcher` instance will be created when a new\n `Ember.Application` is created. Having an instance of `Ember.Application`\n will satisfy this requirement.\n\n ### Specifying a Target\n\n There are several possible target objects for `{{action}}` helpers:\n\n In a typical `Ember.Router`-backed Application where views are managed\n through use of the `{{outlet}}` helper, actions will be forwarded to the\n current state of the Applications's Router. See `Ember.Router` 'Responding\n to User-initiated Events' for more information.\n\n If you manually set the `target` property on the controller of a template's\n `Ember.View` instance, the specifed `controller.target` will become the\n target for any actions. Likely custom values for a controller's `target` are\n the controller itself or a StateManager other than the Application's\n router.\n\n If the templates's view lacks a controller property the view itself is the\n target.\n\n Finally, a `target` option can be provided to the helper to change which\n object will receive the method call. This option must be a string\n representing a path to an object:\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n <div {{action anActionName target=\"MyApplication.someObject\"}}>\n click me\n </div>\n </script>\n ```\n\n Clicking \"click me\" in the rendered HTML of the above template will trigger\n the `anActionName` method of the object at `MyApplication.someObject`.\n The first argument to this method will be a `jQuery.Event` extended to\n include a `view` property that is set to the original view interacted with.\n\n A path relative to the template's `Ember.View` instance can also be used as\n a target:\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n <div {{action anActionName target=\"parentView\"}}>\n click me\n </div>\n </script>\n ```\n\n Clicking \"click me\" in the rendered HTML of the above template will trigger\n the `anActionName` method of the view's parent view.\n\n The `{{action}}` helper is `Ember.StateManager` aware. If the target of the\n action is an `Ember.StateManager` instance `{{action}}` will use the `send`\n functionality of StateManagers. The documentation for `Ember.StateManager`\n has additional information about this use.\n\n If an action's target does not implement a method that matches the supplied\n action name an error will be thrown.\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n <div {{action aMethodNameThatIsMissing}}>\n click me\n </div>\n </script>\n ```\n\n With the following application code\n\n ```javascript\n AView = Ember.View.extend({\n templateName; 'a-template',\n // note: no method 'aMethodNameThatIsMissing'\n anActionName: function(event){}\n });\n\n aView = AView.create();\n aView.appendTo('body');\n ```\n\n Will throw `Uncaught TypeError: Cannot call method 'call' of undefined` when\n \"click me\" is clicked.\n\n ### Specifying a context\n\n You may optionally specify objects to pass as contexts to the `{{action}}`\n helper by providing property paths as the subsequent parameters. These\n objects are made available as the `contexts` (also `context` if there is only\n one) properties in the `jQuery.Event` object:\n\n ```handlebars\n <script type=\"text/x-handlebars\" data-template-name='a-template'>\n {{#each person in people}}\n <div {{action edit person}}>\n click me\n </div>\n {{/each}}\n </script>\n ```\n\n Clicking \"click me\" will trigger the `edit` method of the view's context with\n a `jQuery.Event` object containing the person object as its context.\n\n @method action\n @for Ember.Handlebars.helpers\n @param {String} actionName\n @param {Object...} contexts\n @param {Hash} options\n*/\nEmberHandlebars.registerHelper('action', function(actionName) {\n var options = arguments[arguments.length - 1],\n contexts = a_slice.call(arguments, 1, -1);\n\n var hash = options.hash,\n view = options.data.view,\n target, controller, link;\n\n // create a hash to pass along to registerAction\n var action = {\n eventName: hash.on || \"click\"\n };\n\n action.view = view = get(view, 'concreteView');\n\n if (hash.target) {\n target = handlebarsGet(this, hash.target, options);\n } else if (controller = options.data.keywords.controller) {\n target = controller;\n }\n\n action.target = target = target || view;\n\n if (contexts.length) {\n action.contexts = contexts = Ember.EnumerableUtils.map(contexts, function(context) {\n return handlebarsGet(this, context, options);\n }, this);\n action.context = contexts[0];\n }\n\n var output = [], url;\n\n if (hash.href && target.urlForEvent) {\n url = target.urlForEvent.apply(target, [actionName].concat(contexts));\n output.push('href=\"' + url + '\"');\n action.link = true;\n }\n\n var actionId = ActionHelper.registerAction(actionName, action);\n output.push('data-ember-action=\"' + actionId + '\"');\n\n return new EmberHandlebars.SafeString(output.join(\" \"));\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n When used in a Handlebars template that is assigned to an `Ember.View`\n instance's `layout` property Ember will render the layout template first,\n inserting the view's own rendered output at the `{{yield}}` location.\n\n An empty `<body>` and the following application code:\n\n ```javascript\n AView = Ember.View.extend({\n classNames: ['a-view-with-layout'],\n layout: Ember.Handlebars.compile('<div class=\"wrapper\">{{yield}}</div>'),\n template: Ember.Handlebars.compile('<span>I am wrapped</span>')\n });\n\n aView = AView.create();\n aView.appendTo('body');\n ```\n\n Will result in the following HTML output:\n\n ```html\n <body>\n <div class='ember-view a-view-with-layout'>\n <div class=\"wrapper\">\n <span>I am wrapped</span>\n </div>\n </div>\n </body>\n ```\n\n The `yield` helper cannot be used outside of a template assigned to an\n `Ember.View`'s `layout` property and will throw an error if attempted.\n\n ```javascript\n BView = Ember.View.extend({\n classNames: ['a-view-with-layout'],\n template: Ember.Handlebars.compile('{{yield}}')\n });\n\n bView = BView.create();\n bView.appendTo('body');\n\n // throws\n // Uncaught Error: assertion failed: You called yield in a template that was not a layout\n ```\n\n @method yield\n @for Ember.Handlebars.helpers\n @param {Hash} options\n @return {String} HTML string\n*/\nEmber.Handlebars.registerHelper('yield', function(options) {\n var view = options.data.view, template;\n\n while (view && !get(view, 'layout')) {\n view = get(view, 'parentView');\n }\n\n Ember.assert(\"You called yield in a template that was not a layout\", !!view);\n\n template = get(view, 'template');\n\n if (template) { template(this, options); }\n});\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar set = Ember.set, get = Ember.get;\n\n/**\n The `Ember.Checkbox` view class renders a checkbox\n [input](https://developer.mozilla.org/en/HTML/Element/Input) element. It\n allows for binding an Ember property (`checked`) to the status of the\n checkbox.\n\n Example:\n\n ```handlebars\n {{view Ember.Checkbox checkedBinding=\"receiveEmail\"}}\n ```\n\n You can add a `label` tag yourself in the template where the `Ember.Checkbox`\n is being used.\n\n ```html\n <label>\n {{view Ember.Checkbox classNames=\"applicaton-specific-checkbox\"}}\n Some Title\n </label>\n ```\n\n The `checked` attribute of an `Ember.Checkbox` object should always be set\n through the Ember object or by interacting with its rendered element\n representation via the mouse, keyboard, or touch. Updating the value of the\n checkbox via jQuery will result in the checked value of the object and its\n element losing synchronization.\n\n ## Layout and LayoutName properties\n\n Because HTML `input` elements are self closing `layout` and `layoutName`\n properties will not be applied. See `Ember.View`'s layout section for more\n information.\n\n @class Checkbox\n @namespace Ember\n @extends Ember.View\n*/\nEmber.Checkbox = Ember.View.extend({\n classNames: ['ember-checkbox'],\n\n tagName: 'input',\n\n attributeBindings: ['type', 'checked', 'disabled', 'tabindex'],\n\n type: \"checkbox\",\n checked: false,\n disabled: false,\n\n init: function() {\n this._super();\n this.on(\"change\", this, this._updateElementValue);\n },\n\n _updateElementValue: function() {\n set(this, 'checked', this.$().prop('checked'));\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Shared mixin used by `Ember.TextField` and `Ember.TextArea`.\n\n @class TextSupport\n @namespace Ember\n @extends Ember.Mixin\n @private\n*/\nEmber.TextSupport = Ember.Mixin.create({\n value: \"\",\n\n attributeBindings: ['placeholder', 'disabled', 'maxlength', 'tabindex'],\n placeholder: null,\n disabled: false,\n maxlength: null,\n\n insertNewline: Ember.K,\n cancel: Ember.K,\n\n init: function() {\n this._super();\n this.on(\"focusOut\", this, this._elementValueDidChange);\n this.on(\"change\", this, this._elementValueDidChange);\n this.on(\"keyUp\", this, this.interpretKeyEvents);\n },\n\n interpretKeyEvents: function(event) {\n var map = Ember.TextSupport.KEY_EVENTS;\n var method = map[event.keyCode];\n\n this._elementValueDidChange();\n if (method) { return this[method](event); }\n },\n\n _elementValueDidChange: function() {\n set(this, 'value', this.$().val());\n }\n\n});\n\nEmber.TextSupport.KEY_EVENTS = {\n 13: 'insertNewline',\n 27: 'cancel'\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n The `Ember.TextField` view class renders a text\n [input](https://developer.mozilla.org/en/HTML/Element/Input) element. It\n allows for binding Ember properties to the text field contents (`value`),\n live-updating as the user inputs text.\n\n Example:\n\n ```handlebars\n {{view Ember.TextField valueBinding=\"firstName\"}}\n ```\n\n ## Layout and LayoutName properties\n\n Because HTML `input` elements are self closing `layout` and `layoutName`\n properties will not be applied. See `Ember.View`'s layout section for more\n information.\n\n ## HTML Attributes\n\n By default `Ember.TextField` provides support for `type`, `value`, `size`,\n `placeholder`, `disabled`, `maxlength` and `tabindex` attributes on a\n test field. If you need to support more attributes have a look at the\n `attributeBindings` property in `Ember.View`'s HTML Attributes section.\n\n To globally add support for additional attributes you can reopen\n `Ember.TextField` or `Ember.TextSupport`.\n\n ```javascript\n Ember.TextSupport.reopen({\n attributeBindings: [\"required\"]\n })\n ```\n\n @class TextField\n @namespace Ember\n @extends Ember.View\n @uses Ember.TextSupport\n*/\nEmber.TextField = Ember.View.extend(Ember.TextSupport,\n /** @scope Ember.TextField.prototype */ {\n\n classNames: ['ember-text-field'],\n tagName: \"input\",\n attributeBindings: ['type', 'value', 'size'],\n\n /**\n The `value` attribute of the input element. As the user inputs text, this\n property is updated live.\n\n @property value\n @type String\n @default \"\"\n */\n value: \"\",\n\n /**\n The `type` attribute of the input element.\n\n @property type\n @type String\n @default \"text\"\n */\n type: \"text\",\n\n /**\n The `size` of the text field in characters.\n\n @property size\n @type String\n @default null\n */\n size: null\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n @class Button\n @namespace Ember\n @extends Ember.View\n @uses Ember.TargetActionSupport\n @deprecated\n*/\nEmber.Button = Ember.View.extend(Ember.TargetActionSupport, {\n classNames: ['ember-button'],\n classNameBindings: ['isActive'],\n\n tagName: 'button',\n\n propagateEvents: false,\n\n attributeBindings: ['type', 'disabled', 'href', 'tabindex'],\n\n /**\n @private\n\n Overrides `TargetActionSupport`'s `targetObject` computed\n property to use Handlebars-specific path resolution.\n\n @property targetObject\n */\n targetObject: Ember.computed(function() {\n var target = get(this, 'target'),\n root = get(this, 'context'),\n data = get(this, 'templateData');\n\n if (typeof target !== 'string') { return target; }\n\n return Ember.Handlebars.get(root, target, { data: data });\n }).property('target'),\n\n // Defaults to 'button' if tagName is 'input' or 'button'\n type: Ember.computed(function(key) {\n var tagName = this.tagName;\n if (tagName === 'input' || tagName === 'button') { return 'button'; }\n }).property(),\n\n disabled: false,\n\n // Allow 'a' tags to act like buttons\n href: Ember.computed(function() {\n return this.tagName === 'a' ? '#' : null;\n }).property(),\n\n mouseDown: function() {\n if (!get(this, 'disabled')) {\n set(this, 'isActive', true);\n this._mouseDown = true;\n this._mouseEntered = true;\n }\n return get(this, 'propagateEvents');\n },\n\n mouseLeave: function() {\n if (this._mouseDown) {\n set(this, 'isActive', false);\n this._mouseEntered = false;\n }\n },\n\n mouseEnter: function() {\n if (this._mouseDown) {\n set(this, 'isActive', true);\n this._mouseEntered = true;\n }\n },\n\n mouseUp: function(event) {\n if (get(this, 'isActive')) {\n // Actually invoke the button's target and action.\n // This method comes from the Ember.TargetActionSupport mixin.\n this.triggerAction();\n set(this, 'isActive', false);\n }\n\n this._mouseDown = false;\n this._mouseEntered = false;\n return get(this, 'propagateEvents');\n },\n\n keyDown: function(event) {\n // Handle space or enter\n if (event.keyCode === 13 || event.keyCode === 32) {\n this.mouseDown();\n }\n },\n\n keyUp: function(event) {\n // Handle space or enter\n if (event.keyCode === 13 || event.keyCode === 32) {\n this.mouseUp();\n }\n },\n\n // TODO: Handle proper touch behavior. Including should make inactive when\n // finger moves more than 20x outside of the edge of the button (vs mouse\n // which goes inactive as soon as mouse goes out of edges.)\n\n touchStart: function(touch) {\n return this.mouseDown(touch);\n },\n\n touchEnd: function(touch) {\n return this.mouseUp(touch);\n },\n\n init: function() {\n Ember.deprecate(\"Ember.Button is deprecated and will be removed from future releases. Consider using the `{{action}}` helper.\");\n this._super();\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n The `Ember.TextArea` view class renders a\n [textarea](https://developer.mozilla.org/en/HTML/Element/textarea) element.\n It allows for binding Ember properties to the text area contents (`value`),\n live-updating as the user inputs text.\n\n ## Layout and LayoutName properties\n\n Because HTML `textarea` elements do not contain inner HTML the `layout` and\n `layoutName` properties will not be applied. See `Ember.View`'s layout\n section for more information.\n\n ## HTML Attributes\n\n By default `Ember.TextArea` provides support for `rows`, `cols`,\n `placeholder`, `disabled`, `maxlength` and `tabindex` attributes on a\n textarea. If you need to support more attributes have a look at the\n `attributeBindings` property in `Ember.View`'s HTML Attributes section.\n\n To globally add support for additional attributes you can reopen\n `Ember.TextArea` or `Ember.TextSupport`.\n\n ```javascript\n Ember.TextSupport.reopen({\n attributeBindings: [\"required\"]\n })\n ```\n\n @class TextArea\n @namespace Ember\n @extends Ember.View\n @uses Ember.TextSupport\n*/\nEmber.TextArea = Ember.View.extend(Ember.TextSupport, {\n classNames: ['ember-text-area'],\n\n tagName: \"textarea\",\n attributeBindings: ['rows', 'cols'],\n rows: null,\n cols: null,\n\n _updateElementValue: Ember.observer(function() {\n // We do this check so cursor position doesn't get affected in IE\n var value = get(this, 'value'),\n $el = this.$();\n if ($el && value !== $el.val()) {\n $el.val(value);\n }\n }, 'value'),\n\n init: function() {\n this._super();\n this.on(\"didInsertElement\", this, this._updateElementValue);\n }\n\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\n/**\n@class TabContainerView\n@namespace Ember\n@deprecated\n@extends Ember.View\n*/\nEmber.TabContainerView = Ember.View.extend({\n init: function() {\n Ember.deprecate(\"Ember.TabContainerView is deprecated and will be removed from future releases.\");\n this._super();\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get;\n\n/**\n @class TabPaneView\n @namespace Ember\n @extends Ember.View\n @deprecated\n*/\nEmber.TabPaneView = Ember.View.extend({\n tabsContainer: Ember.computed(function() {\n return this.nearestOfType(Ember.TabContainerView);\n }).property().volatile(),\n\n isVisible: Ember.computed(function() {\n return get(this, 'viewName') === get(this, 'tabsContainer.currentView');\n }).property('tabsContainer.currentView').volatile(),\n\n init: function() {\n Ember.deprecate(\"Ember.TabPaneView is deprecated and will be removed from future releases.\");\n this._super();\n }\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar get = Ember.get, setPath = Ember.setPath;\n\n/**\n@class TabView\n@namespace Ember\n@extends Ember.View\n@deprecated\n*/\nEmber.TabView = Ember.View.extend({\n tabsContainer: Ember.computed(function() {\n return this.nearestInstanceOf(Ember.TabContainerView);\n }).property().volatile(),\n\n mouseUp: function() {\n setPath(this, 'tabsContainer.currentView', get(this, 'value'));\n },\n\n init: function() {\n Ember.deprecate(\"Ember.TabView is deprecated and will be removed from future releases.\");\n this._super();\n }\n});\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/*jshint eqeqeq:false */\n\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\nvar set = Ember.set,\n get = Ember.get,\n indexOf = Ember.EnumerableUtils.indexOf,\n indexesOf = Ember.EnumerableUtils.indexesOf,\n replace = Ember.EnumerableUtils.replace,\n isArray = Ember.isArray;\n\n/**\n The `Ember.Select` view class renders a\n [select](https://developer.mozilla.org/en/HTML/Element/select) HTML element,\n allowing the user to choose from a list of options.\n\n The text and `value` property of each `<option>` element within the\n `<select>` element are populated from the objects in the `Element.Select`'s\n `content` property. The underlying data object of the selected `<option>` is\n stored in the `Element.Select`'s `value` property.\n\n ### `content` as an array of Strings\n\n The simplest version of an `Ember.Select` takes an array of strings as its\n `content` property. The string will be used as both the `value` property and\n the inner text of each `<option>` element inside the rendered `<select>`.\n\n Example:\n\n ```javascript\n App.names = [\"Yehuda\", \"Tom\"];\n ```\n\n ```handlebars\n {{view Ember.Select contentBinding=\"App.names\"}}\n ```\n\n Would result in the following HTML:\n\n ```html\n <select class=\"ember-select\">\n <option value=\"Yehuda\">Yehuda</option>\n <option value=\"Tom\">Tom</option>\n </select>\n ```\n\n You can control which `<option>` is selected through the `Ember.Select`'s\n `value` property directly or as a binding:\n\n ```javascript\n App.names = Ember.Object.create({\n selected: 'Tom',\n content: [\"Yehuda\", \"Tom\"]\n });\n ```\n\n ```handlebars\n {{view Ember.Select\n contentBinding=\"App.names.content\"\n valueBinding=\"App.names.selected\"\n }}\n ```\n\n Would result in the following HTML with the `<option>` for 'Tom' selected:\n\n ```html\n <select class=\"ember-select\">\n <option value=\"Yehuda\">Yehuda</option>\n <option value=\"Tom\" selected=\"selected\">Tom</option>\n </select>\n ```\n\n A user interacting with the rendered `<select>` to choose \"Yehuda\" would\n update the value of `App.names.selected` to \"Yehuda\".\n\n ### `content` as an Array of Objects\n\n An `Ember.Select` can also take an array of JavaScript or Ember objects as\n its `content` property.\n\n When using objects you need to tell the `Ember.Select` which property should\n be accessed on each object to supply the `value` attribute of the `<option>`\n and which property should be used to supply the element text.\n\n The `optionValuePath` option is used to specify the path on each object to\n the desired property for the `value` attribute. The `optionLabelPath`\n specifies the path on each object to the desired property for the\n element's text. Both paths must reference each object itself as `content`:\n\n ```javascript\n App.programmers = [\n Ember.Object.create({firstName: \"Yehuda\", id: 1}),\n Ember.Object.create({firstName: \"Tom\", id: 2})\n ];\n ```\n\n ```handlebars\n {{view Ember.Select\n contentBinding=\"App.programmers\"\n optionValuePath=\"content.id\"\n optionLabelPath=\"content.firstName\"}}\n ```\n\n Would result in the following HTML:\n\n ```html\n <select class=\"ember-select\">\n <option value>Please Select</option>\n <option value=\"1\">Yehuda</option>\n <option value=\"2\">Tom</option>\n </select>\n ```\n\n The `value` attribute of the selected `<option>` within an `Ember.Select`\n can be bound to a property on another object by providing a\n `valueBinding` option:\n\n ```javascript\n App.programmers = [\n Ember.Object.create({firstName: \"Yehuda\", id: 1}),\n Ember.Object.create({firstName: \"Tom\", id: 2})\n ];\n\n App.currentProgrammer = Ember.Object.create({\n id: 2\n });\n ```\n\n ```handlebars\n {{view Ember.Select\n contentBinding=\"App.programmers\"\n optionValuePath=\"content.id\"\n optionLabelPath=\"content.firstName\"\n valueBinding=\"App.currentProgrammer.id\"}}\n ```\n\n Would result in the following HTML with a selected option:\n\n ```html\n <select class=\"ember-select\">\n <option value>Please Select</option>\n <option value=\"1\">Yehuda</option>\n <option value=\"2\" selected=\"selected\">Tom</option>\n </select>\n ```\n\n Interacting with the rendered element by selecting the first option\n ('Yehuda') will update the `id` value of `App.currentProgrammer`\n to match the `value` property of the newly selected `<option>`.\n\n Alternatively, you can control selection through the underlying objects\n used to render each object providing a `selectionBinding`. When the selected\n `<option>` is changed, the property path provided to `selectionBinding`\n will be updated to match the content object of the rendered `<option>`\n element:\n\n ```javascript\n App.controller = Ember.Object.create({\n selectedPerson: null,\n content: [\n Ember.Object.create({firstName: \"Yehuda\", id: 1}),\n Ember.Object.create({firstName: \"Tom\", id: 2})\n ]\n });\n ```\n\n ```handlebars\n {{view Ember.Select\n contentBinding=\"App.controller.content\"\n optionValuePath=\"content.id\"\n optionLabelPath=\"content.firstName\"\n selectionBinding=\"App.controller.selectedPerson\"}}\n ```\n\n Would result in the following HTML with a selected option:\n\n ```html\n <select class=\"ember-select\">\n <option value>Please Select</option>\n <option value=\"1\">Yehuda</option>\n <option value=\"2\" selected=\"selected\">Tom</option>\n </select>\n ```\n\n Interacting with the rendered element by selecting the first option\n ('Yehuda') will update the `selectedPerson` value of `App.controller`\n to match the content object of the newly selected `<option>`. In this\n case it is the first object in the `App.content.content`\n\n ### Supplying a Prompt\n\n A `null` value for the `Ember.Select`'s `value` or `selection` property\n results in there being no `<option>` with a `selected` attribute:\n\n ```javascript\n App.controller = Ember.Object.create({\n selected: null,\n content: [\n \"Yehuda\",\n \"Tom\"\n ]\n });\n ```\n\n ``` handlebars\n {{view Ember.Select\n contentBinding=\"App.controller.content\"\n valueBinding=\"App.controller.selected\"\n }}\n ```\n\n Would result in the following HTML:\n\n ```html\n <select class=\"ember-select\">\n <option value=\"Yehuda\">Yehuda</option>\n <option value=\"Tom\">Tom</option>\n </select>\n ```\n\n Although `App.controller.selected` is `null` and no `<option>`\n has a `selected` attribute the rendered HTML will display the\n first item as though it were selected. You can supply a string\n value for the `Ember.Select` to display when there is no selection\n with the `prompt` option:\n\n ```javascript\n App.controller = Ember.Object.create({\n selected: null,\n content: [\n \"Yehuda\",\n \"Tom\"\n ]\n });\n ```\n\n ```handlebars\n {{view Ember.Select\n contentBinding=\"App.controller.content\"\n valueBinding=\"App.controller.selected\"\n prompt=\"Please select a name\"\n }}\n ```\n\n Would result in the following HTML:\n\n ```html\n <select class=\"ember-select\">\n <option>Please select a name</option>\n <option value=\"Yehuda\">Yehuda</option>\n <option value=\"Tom\">Tom</option>\n </select>\n ```\n\n @class Select\n @namespace Ember\n @extends Ember.View\n*/\nEmber.Select = Ember.View.extend(\n /** @scope Ember.Select.prototype */ {\n\n tagName: 'select',\n classNames: ['ember-select'],\n defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option value=\"\">{{view.prompt}}</option>{{/if}}{{#each view.content}}{{view Ember.SelectOption contentBinding=\"this\"}}{{/each}}'),\n attributeBindings: ['multiple', 'disabled', 'tabindex'],\n\n /**\n The `multiple` attribute of the select element. Indicates whether multiple\n options can be selected.\n\n @property multiple\n @type Boolean\n @default false\n */\n multiple: false,\n\n disabled: false,\n\n /**\n The list of options.\n\n If `optionLabelPath` and `optionValuePath` are not overridden, this should\n be a list of strings, which will serve simultaneously as labels and values.\n\n Otherwise, this should be a list of objects. For instance:\n\n ```javascript\n Ember.Select.create({\n content: Ember.A([\n { id: 1, firstName: 'Yehuda' },\n { id: 2, firstName: 'Tom' }\n ]),\n optionLabelPath: 'content.firstName',\n optionValuePath: 'content.id'\n });\n ```\n\n @property content\n @type Array\n @default null\n */\n content: null,\n\n /**\n When `multiple` is `false`, the element of `content` that is currently\n selected, if any.\n\n When `multiple` is `true`, an array of such elements.\n\n @property selection\n @type Object or Array\n @default null\n */\n selection: null,\n\n /**\n In single selection mode (when `multiple` is `false`), value can be used to\n get the current selection's value or set the selection by it's value.\n\n It is not currently supported in multiple selection mode.\n\n @property value\n @type String\n @default null\n */\n value: Ember.computed(function(key, value) {\n if (arguments.length === 2) { return value; }\n var valuePath = get(this, 'optionValuePath').replace(/^content\\.?/, '');\n return valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection');\n }).property('selection'),\n\n /**\n If given, a top-most dummy option will be rendered to serve as a user\n prompt.\n\n @property prompt\n @type String\n @default null\n */\n prompt: null,\n\n /**\n The path of the option labels. See `content`.\n\n @property optionLabelPath\n @type String\n @default 'content'\n */\n optionLabelPath: 'content',\n\n /**\n The path of the option values. See `content`.\n\n @property optionValuePath\n @type String\n @default 'content'\n */\n optionValuePath: 'content',\n\n _change: function() {\n if (get(this, 'multiple')) {\n this._changeMultiple();\n } else {\n this._changeSingle();\n }\n },\n\n selectionDidChange: Ember.observer(function() {\n var selection = get(this, 'selection');\n if (get(this, 'multiple')) {\n if (!isArray(selection)) {\n set(this, 'selection', Ember.A([selection]));\n return;\n }\n this._selectionDidChangeMultiple();\n } else {\n this._selectionDidChangeSingle();\n }\n }, 'selection.@each'),\n\n valueDidChange: Ember.observer(function() {\n var content = get(this, 'content'),\n value = get(this, 'value'),\n valuePath = get(this, 'optionValuePath').replace(/^content\\.?/, ''),\n selectedValue = (valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection')),\n selection;\n\n if (value !== selectedValue) {\n selection = content.find(function(obj) {\n return value === (valuePath ? get(obj, valuePath) : obj);\n });\n\n this.set('selection', selection);\n }\n }, 'value'),\n\n\n _triggerChange: function() {\n var selection = get(this, 'selection');\n var value = get(this, 'value');\n\n if (selection) { this.selectionDidChange(); }\n if (value) { this.valueDidChange(); }\n\n this._change();\n },\n\n _changeSingle: function() {\n var selectedIndex = this.$()[0].selectedIndex,\n content = get(this, 'content'),\n prompt = get(this, 'prompt');\n\n if (!content) { return; }\n if (prompt && selectedIndex === 0) { set(this, 'selection', null); return; }\n\n if (prompt) { selectedIndex -= 1; }\n set(this, 'selection', content.objectAt(selectedIndex));\n },\n\n\n _changeMultiple: function() {\n var options = this.$('option:selected'),\n prompt = get(this, 'prompt'),\n offset = prompt ? 1 : 0,\n content = get(this, 'content'),\n selection = get(this, 'selection');\n\n if (!content){ return; }\n if (options) {\n var selectedIndexes = options.map(function(){\n return this.index - offset;\n }).toArray();\n var newSelection = content.objectsAt(selectedIndexes);\n\n if (isArray(selection)) {\n replace(selection, 0, get(selection, 'length'), newSelection);\n } else {\n set(this, 'selection', newSelection);\n }\n }\n },\n\n _selectionDidChangeSingle: function() {\n var el = this.get('element');\n if (!el) { return; }\n\n var content = get(this, 'content'),\n selection = get(this, 'selection'),\n selectionIndex = content ? indexOf(content, selection) : -1,\n prompt = get(this, 'prompt');\n\n if (prompt) { selectionIndex += 1; }\n if (el) { el.selectedIndex = selectionIndex; }\n },\n\n _selectionDidChangeMultiple: function() {\n var content = get(this, 'content'),\n selection = get(this, 'selection'),\n selectedIndexes = content ? indexesOf(content, selection) : [-1],\n prompt = get(this, 'prompt'),\n offset = prompt ? 1 : 0,\n options = this.$('option'),\n adjusted;\n\n if (options) {\n options.each(function() {\n adjusted = this.index > -1 ? this.index - offset : -1;\n this.selected = indexOf(selectedIndexes, adjusted) > -1;\n });\n }\n },\n\n init: function() {\n this._super();\n this.on(\"didInsertElement\", this, this._triggerChange);\n this.on(\"change\", this, this._change);\n }\n});\n\nEmber.SelectOption = Ember.View.extend({\n tagName: 'option',\n attributeBindings: ['value', 'selected'],\n\n defaultTemplate: function(context, options) {\n options = { data: options.data, hash: {} };\n Ember.Handlebars.helpers.bind.call(context, \"view.label\", options);\n },\n\n init: function() {\n this.labelPathDidChange();\n this.valuePathDidChange();\n\n this._super();\n },\n\n selected: Ember.computed(function() {\n var content = get(this, 'content'),\n selection = get(this, 'parentView.selection');\n if (get(this, 'parentView.multiple')) {\n return selection && indexOf(selection, content.valueOf()) > -1;\n } else {\n // Primitives get passed through bindings as objects... since\n // `new Number(4) !== 4`, we use `==` below\n return content == selection;\n }\n }).property('content', 'parentView.selection').volatile(),\n\n labelPathDidChange: Ember.observer(function() {\n var labelPath = get(this, 'parentView.optionLabelPath');\n\n if (!labelPath) { return; }\n\n Ember.defineProperty(this, 'label', Ember.computed(function() {\n return get(this, labelPath);\n }).property(labelPath));\n }, 'parentView.optionLabelPath'),\n\n valuePathDidChange: Ember.observer(function() {\n var valuePath = get(this, 'parentView.optionValuePath');\n\n if (!valuePath) { return; }\n\n Ember.defineProperty(this, 'value', Ember.computed(function() {\n return get(this, valuePath);\n }).property(valuePath));\n }, 'parentView.optionValuePath')\n});\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/*globals Handlebars */\n/**\n@module ember\n@submodule ember-handlebars\n*/\n\n/**\n @private\n\n Find templates stored in the head tag as script tags and make them available\n to `Ember.CoreView` in the global `Ember.TEMPLATES` object. This will be run\n as as jQuery DOM-ready callback.\n\n Script tags with `text/x-handlebars` will be compiled\n with Ember's Handlebars and are suitable for use as a view's template.\n Those with type `text/x-raw-handlebars` will be compiled with regular\n Handlebars and are suitable for use in views' computed properties.\n\n @method bootstrap\n @for Ember.Handlebars\n @static\n @param ctx\n*/\nEmber.Handlebars.bootstrap = function(ctx) {\n var selectors = 'script[type=\"text/x-handlebars\"], script[type=\"text/x-raw-handlebars\"]';\n\n Ember.$(selectors, ctx)\n .each(function() {\n // Get a reference to the script tag\n var script = Ember.$(this),\n type = script.attr('type');\n\n var compile = (script.attr('type') === 'text/x-raw-handlebars') ?\n Ember.$.proxy(Handlebars.compile, Handlebars) :\n Ember.$.proxy(Ember.Handlebars.compile, Ember.Handlebars),\n // Get the name of the script, used by Ember.View's templateName property.\n // First look for data-template-name attribute, then fall back to its\n // id if no name is found.\n templateName = script.attr('data-template-name') || script.attr('id') || 'application',\n template = compile(script.html());\n\n // For templates which have a name, we save them and then remove them from the DOM\n Ember.TEMPLATES[templateName] = template;\n\n // Remove script tag from DOM\n script.remove();\n });\n};\n\nfunction bootstrap() {\n Ember.Handlebars.bootstrap( Ember.$(document) );\n}\n\n/*\n We tie this to application.load to ensure that we've at least\n attempted to bootstrap at the point that the application is loaded.\n\n We also tie this to document ready since we're guaranteed that all\n the inline templates are present at this point.\n\n There's no harm to running this twice, since we remove the templates\n from the DOM after processing.\n*/\n\nEmber.onLoad('application', bootstrap);\n\n})();\n\n\n\n(function() {\n/**\nEmber Handlebars\n\n@module ember\n@submodule ember-handlebars\n@requires ember-views\n*/\n\nEmber.runLoadHooks('Ember.Handlebars', Ember.Handlebars);\n\n})();\n\n(function() {\ndefine(\"route-recognizer\",\n [],\n function() {\n \"use strict\";\n var specials = [\n '/', '.', '*', '+', '?', '|',\n '(', ')', '[', ']', '{', '}', '\\\\'\n ];\n\n var escapeRegex = new RegExp('(\\\\' + specials.join('|\\\\') + ')', 'g');\n\n // A Segment represents a segment in the original route description.\n // Each Segment type provides an `eachChar` and `regex` method.\n //\n // The `eachChar` method invokes the callback with one or more character\n // specifications. A character specification consumes one or more input\n // characters.\n //\n // The `regex` method returns a regex fragment for the segment. If the\n // segment is a dynamic of star segment, the regex fragment also includes\n // a capture.\n //\n // A character specification contains:\n //\n // * `validChars`: a String with a list of all valid characters, or\n // * `invalidChars`: a String with a list of all invalid characters\n // * `repeat`: true if the character specification can repeat\n\n function StaticSegment(string) { this.string = string; }\n StaticSegment.prototype = {\n eachChar: function(callback) {\n var string = this.string, char;\n\n for (var i=0, l=string.length; i<l; i++) {\n char = string.charAt(i);\n callback({ validChars: char });\n }\n },\n\n regex: function() {\n return this.string.replace(escapeRegex, '\\\\$1');\n },\n\n generate: function() {\n return this.string;\n }\n };\n\n function DynamicSegment(name) { this.name = name; }\n DynamicSegment.prototype = {\n eachChar: function(callback) {\n callback({ invalidChars: \"/\", repeat: true });\n },\n\n regex: function() {\n return \"([^/]+)\";\n },\n\n generate: function(params) {\n return params[this.name];\n }\n };\n\n function StarSegment(name) { this.name = name; }\n StarSegment.prototype = {\n eachChar: function(callback) {\n callback({ invalidChars: \"\", repeat: true });\n },\n\n regex: function() {\n return \"(.+)\";\n },\n\n generate: function(params) {\n return params[this.name];\n }\n };\n\n function EpsilonSegment() {}\n EpsilonSegment.prototype = {\n eachChar: function() {},\n regex: function() { return \"\"; },\n generate: function() { return \"\"; }\n };\n\n function parse(route, names, types) {\n // normalize route as not starting with a \"/\". Recognition will\n // also normalize.\n if (route.charAt(0) === \"/\") { route = route.substr(1); }\n\n var segments = route.split(\"/\"), results = [];\n\n for (var i=0, l=segments.length; i<l; i++) {\n var segment = segments[i], match;\n\n if (match = segment.match(/^:([^\\/]+)$/)) {\n results.push(new DynamicSegment(match[1]));\n names.push(match[1]);\n types.dynamics++;\n } else if (match = segment.match(/^\\*([^\\/]+)$/)) {\n results.push(new StarSegment(match[1]));\n names.push(match[1]);\n types.stars++;\n } else if(segment === \"\") {\n results.push(new EpsilonSegment());\n } else {\n results.push(new StaticSegment(segment));\n types.statics++;\n }\n }\n\n return results;\n }\n\n // A State has a character specification and (`charSpec`) and a list of possible\n // subsequent states (`nextStates`).\n //\n // If a State is an accepting state, it will also have several additional\n // properties:\n //\n // * `regex`: A regular expression that is used to extract parameters from paths\n // that reached this accepting state.\n // * `handlers`: Information on how to convert the list of captures into calls\n // to registered handlers with the specified parameters\n // * `types`: How many static, dynamic or star segments in this route. Used to\n // decide which route to use if multiple registered routes match a path.\n //\n // Currently, State is implemented naively by looping over `nextStates` and\n // comparing a character specification against a character. A more efficient\n // implementation would use a hash of keys pointing at one or more next states.\n\n function State(charSpec) {\n this.charSpec = charSpec;\n this.nextStates = [];\n }\n\n State.prototype = {\n get: function(charSpec) {\n var nextStates = this.nextStates;\n\n for (var i=0, l=nextStates.length; i<l; i++) {\n var child = nextStates[i];\n\n var isEqual = child.charSpec.validChars === charSpec.validChars;\n isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars;\n\n if (isEqual) { return child; }\n }\n },\n\n put: function(charSpec) {\n var state;\n\n // If the character specification already exists in a child of the current\n // state, just return that state.\n if (state = this.get(charSpec)) { return state; }\n\n // Make a new state for the character spec\n state = new State(charSpec);\n\n // Insert the new state as a child of the current state\n this.nextStates.push(state);\n\n // If this character specification repeats, insert the new state as a child\n // of itself. Note that this will not trigger an infinite loop because each\n // transition during recognition consumes a character.\n if (charSpec.repeat) {\n state.nextStates.push(state);\n }\n\n // Return the new state\n return state;\n },\n\n // Find a list of child states matching the next character\n match: function(char) {\n // DEBUG \"Processing `\" + char + \"`:\"\n var nextStates = this.nextStates,\n child, charSpec, chars;\n\n // DEBUG \" \" + debugState(this)\n var returned = [];\n\n for (var i=0, l=nextStates.length; i<l; i++) {\n child = nextStates[i];\n\n charSpec = child.charSpec;\n\n if (chars = charSpec.validChars) {\n if (chars.indexOf(char) !== -1) { returned.push(child); }\n } else if (chars = charSpec.invalidChars) {\n if (chars.indexOf(char) === -1) { returned.push(child); }\n }\n }\n\n return returned;\n }\n\n /** IF DEBUG\n , debug: function() {\n var charSpec = this.charSpec,\n debug = \"[\",\n chars = charSpec.validChars || charSpec.invalidChars;\n\n if (charSpec.invalidChars) { debug += \"^\"; }\n debug += chars;\n debug += \"]\";\n\n if (charSpec.repeat) { debug += \"+\"; }\n\n return debug;\n }\n END IF **/\n };\n\n /** IF DEBUG\n function debug(log) {\n console.log(log);\n }\n\n function debugState(state) {\n return state.nextStates.map(function(n) {\n if (n.nextStates.length === 0) { return \"( \" + n.debug() + \" [accepting] )\"; }\n return \"( \" + n.debug() + \" <then> \" + n.nextStates.map(function(s) { return s.debug() }).join(\" or \") + \" )\";\n }).join(\", \")\n }\n END IF **/\n\n // This is a somewhat naive strategy, but should work in a lot of cases\n // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id\n function sortSolutions(states) {\n return states.sort(function(a, b) {\n if (a.types.stars !== b.types.stars) { return a.types.stars - b.types.stars; }\n if (a.types.dynamics !== b.types.dynamics) { return a.types.dynamics - b.types.dynamics; }\n if (a.types.statics !== b.types.statics) { return a.types.statics - b.types.statics; }\n\n return 0;\n });\n }\n\n function recognizeChar(states, char) {\n var nextStates = [];\n\n for (var i=0, l=states.length; i<l; i++) {\n var state = states[i];\n\n nextStates = nextStates.concat(state.match(char));\n }\n\n return nextStates;\n }\n\n function findHandler(state, path) {\n var handlers = state.handlers, regex = state.regex;\n var captures = path.match(regex), currentCapture = 1;\n var result = [];\n\n for (var i=0, l=handlers.length; i<l; i++) {\n var handler = handlers[i], names = handler.names, params = {};\n\n for (var j=0, m=names.length; j<m; j++) {\n params[names[j]] = captures[currentCapture++];\n }\n\n result.push({ handler: handler.handler, params: params, isDynamic: !!names.length });\n }\n\n return result;\n }\n\n function addSegment(currentState, segment) {\n segment.eachChar(function(char) {\n var state;\n\n currentState = currentState.put(char);\n });\n\n return currentState;\n }\n\n // The main interface\n\n var RouteRecognizer = function() {\n this.rootState = new State();\n this.names = {};\n };\n\n\n RouteRecognizer.prototype = {\n add: function(routes, options) {\n var currentState = this.rootState, regex = \"^\",\n types = { statics: 0, dynamics: 0, stars: 0 },\n handlers = [], allSegments = [], name;\n\n var isEmpty = true;\n\n for (var i=0, l=routes.length; i<l; i++) {\n var route = routes[i], names = [];\n\n var segments = parse(route.path, names, types);\n\n allSegments = allSegments.concat(segments);\n\n for (var j=0, m=segments.length; j<m; j++) {\n var segment = segments[j];\n\n if (segment instanceof EpsilonSegment) { continue; }\n\n isEmpty = false;\n\n // Add a \"/\" for the new segment\n currentState = currentState.put({ validChars: \"/\" });\n regex += \"/\";\n\n // Add a representation of the segment to the NFA and regex\n currentState = addSegment(currentState, segment);\n regex += segment.regex();\n }\n\n handlers.push({ handler: route.handler, names: names });\n }\n\n if (isEmpty) {\n currentState = currentState.put({ validChars: \"/\" });\n regex += \"/\";\n }\n\n currentState.handlers = handlers;\n currentState.regex = new RegExp(regex + \"$\");\n currentState.types = types;\n\n if (name = options && options.as) {\n this.names[name] = {\n segments: allSegments,\n handlers: handlers\n };\n }\n },\n\n handlersFor: function(name) {\n var route = this.names[name], result = [];\n if (!route) { throw new Error(\"There is no route named \" + name); }\n\n for (var i=0, l=route.handlers.length; i<l; i++) {\n result.push(route.handlers[i]);\n }\n\n return result;\n },\n\n generate: function(name, params) {\n var route = this.names[name], output = \"\";\n if (!route) { throw new Error(\"There is no route named \" + name); }\n\n var segments = route.segments;\n\n for (var i=0, l=segments.length; i<l; i++) {\n var segment = segments[i];\n\n if (segment instanceof EpsilonSegment) { continue; }\n\n output += \"/\";\n output += segment.generate(params);\n }\n\n if (output.charAt(0) !== '/') { output = '/' + output; }\n\n return output;\n },\n\n recognize: function(path) {\n var states = [ this.rootState ], i, l;\n\n // DEBUG GROUP path\n\n if (path.charAt(0) !== \"/\") { path = \"/\" + path; }\n\n for (i=0, l=path.length; i<l; i++) {\n states = recognizeChar(states, path.charAt(i));\n if (!states.length) { break; }\n }\n\n // END DEBUG GROUP\n\n var solutions = [];\n for (i=0, l=states.length; i<l; i++) {\n if (states[i].handlers) { solutions.push(states[i]); }\n }\n\n states = sortSolutions(solutions);\n\n var state = solutions[0];\n\n if (state && state.handlers) {\n return findHandler(state, path);\n }\n }\n };\n\n function Target(path, matcher) {\n this.path = path;\n this.matcher = matcher;\n }\n\n Target.prototype = {\n to: function(target, callback) {\n this.matcher.add(this.path, target);\n\n if (callback) {\n this.matcher.addChild(this.path, callback);\n }\n }\n };\n\n function Matcher() {\n this.routes = {};\n this.children = {};\n }\n\n Matcher.prototype = {\n add: function(path, handler) {\n this.routes[path] = handler;\n },\n\n addChild: function(path, callback) {\n var matcher = new Matcher();\n this.children[path] = matcher;\n callback(generateMatch(path, matcher));\n }\n };\n\n function generateMatch(startingPath, matcher) {\n return function(path, nestedCallback) {\n var fullPath = startingPath + path;\n\n if (nestedCallback) {\n nestedCallback(generateMatch(fullPath, matcher));\n } else {\n return new Target(startingPath + path, matcher);\n }\n };\n }\n\n function addRoute(routeArray, path, handler) {\n var len = 0;\n for (var i=0, l=routeArray.length; i<l; i++) {\n len += routeArray[i].path.length;\n }\n\n path = path.substr(len);\n routeArray.push({ path: path, handler: handler });\n }\n\n function eachRoute(baseRoute, matcher, callback, binding) {\n var routes = matcher.routes;\n\n for (var path in routes) {\n if (routes.hasOwnProperty(path)) {\n var routeArray = baseRoute.slice();\n addRoute(routeArray, path, routes[path]);\n\n if (matcher.children[path]) {\n eachRoute(routeArray, matcher.children[path], callback, binding);\n } else {\n callback.call(binding, routeArray);\n }\n }\n }\n }\n\n RouteRecognizer.prototype.map = function(callback, addRouteCallback) {\n var matcher = new Matcher();\n\n function match(path, nestedCallback) {\n return new Target(path, matcher);\n }\n\n callback(generateMatch(\"\", matcher));\n\n eachRoute([], matcher, function(route) {\n if (addRouteCallback) { addRouteCallback(this, route); }\n else { this.add(route); }\n }, this);\n };\n return RouteRecognizer;\n });\n\n})();\n\n\n\n(function() {\ndefine(\"router\",\n [\"route-recognizer\"],\n function(RouteRecognizer) {\n \"use strict\";\n /**\n @private\n\n This file references several internal structures:\n\n ## `RecognizedHandler`\n\n * `{String} handler`: A handler name\n * `{Object} params`: A hash of recognized parameters\n\n ## `UnresolvedHandlerInfo`\n\n * `{Boolean} isDynamic`: whether a handler has any dynamic segments\n * `{String} name`: the name of a handler\n * `{Object} context`: the active context for the handler\n\n ## `HandlerInfo`\n\n * `{Boolean} isDynamic`: whether a handler has any dynamic segments\n * `{String} name`: the original unresolved handler name\n * `{Object} handler`: a handler object\n * `{Object} context`: the active context for the handler\n */\n\n\n function Router() {\n this.recognizer = new RouteRecognizer();\n }\n\n\n Router.prototype = {\n /**\n The main entry point into the router. The API is essentially\n the same as the `map` method in `route-recognizer`.\n\n This method extracts the String handler at the last `.to()`\n call and uses it as the name of the whole route.\n\n @param {Function} callback\n */\n map: function(callback) {\n this.recognizer.map(callback, function(recognizer, route) {\n var lastHandler = route[route.length - 1].handler;\n var args = [route, { as: lastHandler }];\n recognizer.add.apply(recognizer, args);\n });\n },\n\n /**\n The entry point for handling a change to the URL (usually\n via the back and forward button).\n\n Returns an Array of handlers and the parameters associated\n with those parameters.\n\n @param {String} url a URL to process\n\n @returns {Array} an Array of `[handler, parameter]` tuples\n */\n handleURL: function(url) {\n var results = this.recognizer.recognize(url),\n objects = [];\n\n if (!results) {\n throw new Error(\"No route matched the URL '\" + url + \"'\");\n }\n\n collectObjects(this, results, 0, []);\n },\n\n /**\n Transition into the specified named route.\n\n If necessary, trigger the exit callback on any handlers\n that are no longer represented by the target route.\n\n @param {String} name the name of the route\n */\n transitionTo: function(name) {\n var output = this._paramsForHandler(name, [].slice.call(arguments, 1), function(handler) {\n if (handler.hasOwnProperty('context')) { return handler.context; }\n if (handler.deserialize) { return handler.deserialize({}); }\n return null;\n });\n\n var params = output.params, toSetup = output.toSetup;\n\n var url = this.recognizer.generate(name, params);\n this.updateURL(url);\n\n setupContexts(this, toSetup);\n },\n\n /**\n @private\n\n This method takes a handler name and a list of contexts and returns\n a serialized parameter hash suitable to pass to `recognizer.generate()`.\n\n @param {String} handlerName\n @param {Array[Object]} contexts\n @returns {Object} a serialized parameter hash\n */\n paramsForHandler: function(handlerName, callback) {\n var output = this._paramsForHandler(handlerName, [].slice.call(arguments, 1));\n return output.params;\n },\n\n /**\n Take a named route and context objects and generate a\n URL.\n\n @param {String} name the name of the route to generate\n a URL for\n @param {...Object} objects a list of objects to serialize\n\n @returns {String} a URL\n */\n generate: function(handlerName) {\n var params = this.paramsForHandler.apply(this, arguments);\n return this.recognizer.generate(handlerName, params);\n },\n\n /**\n @private\n\n Used internally by `generate` and `transitionTo`.\n */\n _paramsForHandler: function(handlerName, objects, callback) {\n var handlers = this.recognizer.handlersFor(handlerName),\n params = {},\n toSetup = [],\n object, handlerObj, handler, names;\n\n for (var i=handlers.length-1; i>=0; i--) {\n handlerObj = handlers[i];\n handler = this.getHandler(handlerObj.handler);\n names = handlerObj.names;\n\n if (names.length) {\n if (objects.length) { object = objects.pop(); }\n else { object = handler.context; }\n\n if (handler.serialize) {\n merge(params, handler.serialize(object, names));\n }\n } else if (callback) {\n object = callback(handler);\n }\n\n toSetup.unshift({\n isDynamic: !!handlerObj.names.length,\n handler: handlerObj.handler,\n name: handlerObj.name,\n context: object\n });\n }\n\n return { params: params, toSetup: toSetup };\n },\n\n isActive: function(handlerName) {\n var contexts = [].slice.call(arguments, 1);\n\n var currentHandlerInfos = this.currentHandlerInfos,\n found = false, names, object, handlerInfo, handlerObj;\n\n for (var i=currentHandlerInfos.length-1; i>=0; i--) {\n handlerInfo = currentHandlerInfos[i];\n if (handlerInfo.name === handlerName) { found = true; }\n\n if (found) {\n if (contexts.length === 0) { break; }\n\n if (handlerInfo.isDynamic) {\n object = contexts.pop();\n if (handlerInfo.context !== object) { return false; }\n }\n }\n }\n\n return contexts.length === 0 && found;\n },\n\n trigger: function(name, context) {\n trigger(this, name, context);\n }\n };\n\n function merge(hash, other) {\n for (var prop in other) {\n if (other.hasOwnProperty(prop)) { hash[prop] = other[prop]; }\n }\n }\n\n function isCurrent(currentHandlerInfos, handlerName) {\n return currentHandlerInfos[currentHandlerInfos.length - 1].name === handlerName;\n }\n\n /**\n @private\n\n This function is called the first time the `collectObjects`\n function encounters a promise while converting URL parameters\n into objects.\n\n It triggers the `enter` and `setup` methods on the `loading`\n handler.\n\n @param {Router} router\n */\n function loading(router) {\n if (!router.isLoading) {\n router.isLoading = true;\n var handler = router.getHandler('loading');\n\n if (handler) {\n if (handler.enter) { handler.enter(); }\n if (handler.setup) { handler.setup(); }\n }\n }\n }\n\n /**\n @private\n\n This function is called if a promise was previously\n encountered once all promises are resolved.\n\n It triggers the `exit` method on the `loading` handler.\n\n @param {Router} router\n */\n function loaded(router) {\n router.isLoading = false;\n var handler = router.getHandler('loading');\n if (handler && handler.exit) { handler.exit(); }\n }\n\n /**\n @private\n\n This function is called if any encountered promise\n is rejected.\n\n It triggers the `exit` method on the `loading` handler,\n the `enter` method on the `failure` handler, and the\n `setup` method on the `failure` handler with the\n `error`.\n\n @param {Router} router\n @param {Object} error the reason for the promise\n rejection, to pass into the failure handler's\n `setup` method.\n */\n function failure(router, error) {\n loaded(router);\n var handler = router.getHandler('failure');\n if (handler && handler.setup) { handler.setup(error); }\n }\n\n /**\n @private\n\n This function is called after a URL change has been handled\n by `router.handleURL`.\n\n Takes an Array of `RecognizedHandler`s, and converts the raw\n params hashes into deserialized objects by calling deserialize\n on the handlers. This process builds up an Array of\n `HandlerInfo`s. It then calls `setupContexts` with the Array.\n\n If the `deserialize` method on a handler returns a promise\n (i.e. has a method called `then`), this function will pause\n building up the `HandlerInfo` Array until the promise is\n resolved. It will use the resolved value as the context of\n `HandlerInfo`.\n */\n function collectObjects(router, results, index, objects) {\n if (results.length === index) {\n loaded(router);\n setupContexts(router, objects);\n return;\n }\n\n var result = results[index];\n var handler = router.getHandler(result.handler);\n var object = handler.deserialize && handler.deserialize(result.params);\n\n if (object && typeof object.then === 'function') {\n loading(router);\n\n object.then(proceed, function(error) {\n failure(router, error);\n });\n } else {\n proceed(object);\n }\n\n function proceed(value) {\n var updatedObjects = objects.concat([{\n context: value,\n handler: result.handler,\n isDynamic: result.isDynamic\n }]);\n collectObjects(router, results, index + 1, updatedObjects);\n }\n }\n\n /**\n @private\n\n Takes an Array of `UnresolvedHandlerInfo`s, resolves the handler names\n into handlers, and then figures out what to do with each of the handlers.\n\n For example, consider the following tree of handlers. Each handler is\n followed by the URL segment it handles.\n\n ```\n |~index (\"/\")\n | |~posts (\"/posts\")\n | | |-showPost (\"/:id\")\n | | |-newPost (\"/new\")\n | | |-editPost (\"/edit\")\n | |~about (\"/about/:id\")\n ```\n\n Consider the following transitions:\n\n 1. A URL transition to `/posts/1`.\n 1. Triggers the `deserialize` callback on the\n `index`, `posts`, and `showPost` handlers\n 2. Triggers the `enter` callback on the same\n 3. Triggers the `setup` callback on the same\n 2. A direct transition to `newPost`\n 1. Triggers the `exit` callback on `showPost`\n 2. Triggers the `enter` callback on `newPost`\n 3. Triggers the `setup` callback on `newPost`\n 3. A direct transition to `about` with a specified\n context object\n 1. Triggers the `exit` callback on `newPost`\n and `posts`\n 2. Triggers the `serialize` callback on `about`\n 3. Triggers the `enter` callback on `about`\n 4. Triggers the `setup` callback on `about`\n\n @param {Router} router\n @param {Array[UnresolvedHandlerInfo]} handlerInfos\n */\n function setupContexts(router, handlerInfos) {\n resolveHandlers(router, handlerInfos);\n\n var partition =\n partitionHandlers(router.currentHandlerInfos || [], handlerInfos);\n\n router.currentHandlerInfos = handlerInfos;\n\n eachHandler(partition.exited, function(handler, context) {\n delete handler.context;\n if (handler.exit) { handler.exit(); }\n });\n\n eachHandler(partition.updatedContext, function(handler, context) {\n handler.context = context;\n if (handler.setup) { handler.setup(context); }\n });\n\n eachHandler(partition.entered, function(handler, context) {\n if (handler.enter) { handler.enter(); }\n handler.context = context;\n if (handler.setup) { handler.setup(context); }\n });\n }\n\n /**\n @private\n\n Iterates over an array of `HandlerInfo`s, passing the handler\n and context into the callback.\n\n @param {Array[HandlerInfo]} handlerInfos\n @param {Function(Object, Object)} callback\n */\n function eachHandler(handlerInfos, callback) {\n for (var i=0, l=handlerInfos.length; i<l; i++) {\n var handlerInfo = handlerInfos[i],\n handler = handlerInfo.handler,\n context = handlerInfo.context;\n\n callback(handler, context);\n }\n }\n\n /**\n @private\n\n Updates the `handler` field in each element in an Array of\n `UnresolvedHandlerInfo`s from a handler name to a resolved handler.\n\n When done, the Array will contain `HandlerInfo` structures.\n\n @param {Router} router\n @param {Array[UnresolvedHandlerInfo]} handlerInfos\n */\n function resolveHandlers(router, handlerInfos) {\n var handlerInfo;\n\n for (var i=0, l=handlerInfos.length; i<l; i++) {\n handlerInfo = handlerInfos[i];\n\n handlerInfo.name = handlerInfo.handler;\n handlerInfo.handler = router.getHandler(handlerInfo.handler);\n }\n }\n\n /**\n @private\n\n This function is called when transitioning from one URL to\n another to determine which handlers are not longer active,\n which handlers are newly active, and which handlers remain\n active but have their context changed.\n\n Take a list of old handlers and new handlers and partition\n them into four buckets:\n\n * unchanged: the handler was active in both the old and\n new URL, and its context remains the same\n * updated context: the handler was active in both the\n old and new URL, but its context changed. The handler's\n `setup` method, if any, will be called with the new\n context.\n * exited: the handler was active in the old URL, but is\n no longer active.\n * entered: the handler was not active in the old URL, but\n is now active.\n\n The PartitionedHandlers structure has three fields:\n\n * `updatedContext`: a list of `HandlerInfo` objects that\n represent handlers that remain active but have a changed\n context\n * `entered`: a list of `HandlerInfo` objects that represent\n handlers that are newly active\n * `exited`: a list of `HandlerInfo` objects that are no\n longer active.\n\n @param {Array[HandlerInfo]} oldHandlers a list of the handler\n information for the previous URL (or `[]` if this is the\n first handled transition)\n @param {Array[HandlerInfo]} newHandlers a list of the handler\n information for the new URL\n\n @returns {Partition}\n */\n function partitionHandlers(oldHandlers, newHandlers) {\n var handlers = {\n updatedContext: [],\n exited: [],\n entered: []\n };\n\n var handlerChanged, contextChanged, i, l;\n\n for (i=0, l=newHandlers.length; i<l; i++) {\n var oldHandler = oldHandlers[i], newHandler = newHandlers[i];\n\n if (!oldHandler || oldHandler.handler !== newHandler.handler) {\n handlerChanged = true;\n }\n\n if (handlerChanged) {\n handlers.entered.push(newHandler);\n if (oldHandler) { handlers.exited.unshift(oldHandler); }\n } else if (contextChanged || oldHandler.context !== newHandler.context) {\n contextChanged = true;\n handlers.updatedContext.push(newHandler);\n }\n }\n\n for (i=newHandlers.length, l=oldHandlers.length; i<l; i++) {\n handlers.exited.unshift(oldHandlers[i]);\n }\n\n return handlers;\n }\n\n function trigger(router, name, context) {\n var currentHandlerInfos = router.currentHandlerInfos;\n\n if (!currentHandlerInfos) {\n throw new Error(\"Could not trigger event. There are no active handlers\");\n }\n\n for (var i=currentHandlerInfos.length-1; i>=0; i--) {\n var handlerInfo = currentHandlerInfos[i],\n handler = handlerInfo.handler;\n\n if (handler.events && handler.events[name]) {\n handler.events[name](handler, context);\n break;\n }\n }\n }\n return Router;\n });\n\n})();\n\n\n\n(function() {\nvar Router = requireModule(\"router\");\nvar get = Ember.get, set = Ember.set, classify = Ember.String.classify;\n\nvar DefaultView = Ember.View.extend(Ember._Metamorph);\n\nfunction setupLocation(router) {\n var location = get(router, 'location'),\n rootURL = get(router, 'rootURL');\n\n if ('string' === typeof location) {\n set(router, 'location', Ember.Location.create({\n implementation: location,\n rootURL: rootURL\n }));\n }\n}\n\nEmber.Router = Ember.Object.extend({\n location: 'hash',\n\n init: function() {\n var router = this.router = new Router();\n this._activeViews = {};\n\n setupLocation(this);\n\n var callback = this.constructor.callback;\n\n router.map(function(match) {\n match(\"/\").to(\"application\", callback);\n });\n },\n\n startRouting: function() {\n var router = this.router,\n location = get(this, 'location'),\n container = this.container;\n\n var lastURL;\n\n function updateURL() {\n location.setURL(lastURL);\n }\n\n router.getHandler = getHandlerFunction(this, this._activeViews);\n router.updateURL = function(path) {\n lastURL = path;\n Ember.run.once(updateURL);\n };\n\n container.register('view', 'default', DefaultView);\n\n router.handleURL(location.getURL());\n location.onUpdateURL(function(url) {\n router.handleURL(url);\n });\n },\n\n handleURL: function(url) {\n this.router.handleURL(url);\n this.notifyPropertyChange('url');\n },\n\n transitionTo: function() {\n this.router.transitionTo.apply(this.router, arguments);\n this.notifyPropertyChange('url');\n },\n\n generate: function() {\n var url = this.router.generate.apply(this.router, arguments);\n return this.location.formatURL(url);\n },\n\n isActive: function(routeName) {\n var router = this.router;\n return router.isActive.apply(router, arguments);\n },\n\n send: function(name, context) {\n if (Ember.$ && context instanceof Ember.$.Event) {\n context = context.context;\n }\n\n this.router.trigger(name, context);\n },\n\n _lookupActiveView: function(templateName) {\n return this._activeViews[templateName];\n },\n\n _connectActiveView: function(templateName, view) {\n this._activeViews[templateName] = view;\n },\n\n _disconnectActiveView: function(view) {\n var activeViews = this._activeViews,\n templateName;\n for (templateName in activeViews) {\n if (!activeViews.hasOwnProperty(templateName)) { continue; }\n if (activeViews[templateName] === view) {\n delete activeViews[templateName];\n break;\n }\n }\n }\n});\n\nfunction getHandlerFunction(router, activeViews) {\n var seen = {}, container = router.container;\n\n return function(name) {\n var handler = container.lookup('route:' + name);\n if (seen[name]) { return handler; }\n\n seen[name] = true;\n\n if (!handler) {\n if (name === 'loading') { return {}; }\n\n container.register('route', name, Ember.Route.extend());\n handler = container.lookup('route:' + name);\n }\n\n handler.templateName = name;\n return handler;\n };\n}\n\nfunction handlerIsActive(router, handlerName) {\n var handler = router.container.lookup('route:' + handlerName),\n currentHandlerInfos = router.router.currentHandlerInfos,\n handlerInfo;\n\n for (var i=0, l=currentHandlerInfos.length; i<l; i++) {\n handlerInfo = currentHandlerInfos[i];\n if (handlerInfo.handler === handler) { return true; }\n }\n\n return false;\n}\n\nEmber.Router.reopenClass({\n map: function(callback) {\n this.callback = callback;\n }\n});\n\n})();\n\n\n\n(function() {\nvar get = Ember.get, set = Ember.set,\n classify = Ember.String.classify,\n decamelize = Ember.String.decamelize;\n\n\nEmber.Route = Ember.Object.extend({\n /**\n Transition into another route. Optionally supply a model for the\n route in question. The model will be serialized into the URL\n using the `serialize` hook.\n\n @param {String} name the name of the route\n @param {...Object} models the\n */\n transitionTo: function() {\n this.transitioned = true;\n return this.router.transitionTo.apply(this.router, arguments);\n },\n\n /**\n @private\n\n This hook is the entry point for router.js\n */\n setup: function(context) {\n var container = this.container;\n\n this.transitioned = false;\n this.redirect(context);\n\n if (this.transitioned) { return; }\n\n var templateName = this.templateName,\n controller = container.lookup('controller:' + templateName);\n\n if (!controller) {\n if (context && Ember.isArray(context)) {\n controller = Ember.ArrayController.extend({ content: context });\n } else if (context) {\n controller = Ember.ObjectController.extend({ content: context });\n } else {\n controller = Ember.Controller.extend();\n }\n\n container.register('controller', templateName, controller);\n controller = container.lookup('controller:' + templateName);\n }\n\n this.setupControllers(controller, context);\n this.renderTemplates(context);\n },\n\n /**\n A hook you can implement to optionally redirect to another route.\n\n If you call `this.transitionTo` from inside of this hook, this route\n will not be entered in favor of the other hook.\n\n @param {Object} model the model for this route\n */\n redirect: Ember.K,\n\n /**\n @private\n\n The hook called by `router.js` to convert parameters into the context\n for this handler. The public Ember hook is `model`.\n */\n deserialize: function(params) {\n var model = this.model(params);\n return this.currentModel = model;\n },\n\n /**\n A hook you can implement to convert the URL into the model for\n this route.\n\n ```js\n App.Route.map(function(match) {\n match(\"/posts/:post_id\").to(\"post\");\n });\n ```\n\n The model for the `post` route is `App.Post.find(params.post_id)`.\n\n By default, if your route has a dynamic segment ending in `_id`:\n\n * The model class is determined from the segment (`post_id`'s\n class is `App.Post`)\n * The find method is called on the model class with the value of\n the dynamic segment.\n\n @param {Object} params the parameters extracted from the URL\n */\n model: function(params) {\n var match, name, value;\n\n for (var prop in params) {\n if (match = prop.match(/^(.*)_id$/)) {\n name = match[1];\n value = params[prop];\n }\n }\n\n if (!name) { return; }\n\n var className = classify(name),\n namespace = this.router.namespace,\n modelClass = namespace[className];\n\n Ember.assert(\"You used the dynamic segment \" + name + \"_id in your router, but \" + namespace + \".\" + className + \" did not exist and you did not override your state's `model` hook.\", modelClass);\n return modelClass.find(value);\n },\n\n /**\n A hook you can implement to convert the route's model into parameters\n for the URL.\n\n ```js\n App.Route.map(function(match) {\n match(\"/posts/:post_id\").to(\"post\");\n });\n\n App.PostRoute = Ember.Route.extend({\n model: function(params) {\n // the server returns `{ id: 12 }`\n return jQuery.getJSON(\"/posts/\" + params.post_id);\n },\n\n serialize: function(model) {\n // this will make the URL `/posts/12`\n return { post_id: model.id };\n }\n });\n ```\n\n The default `serialize` method inserts the model's `id` into the\n route's dynamic segment (in this case, `:post_id`).\n\n This method is called when `transitionTo` is called with a context\n in order to populate the URL.\n\n @param {Object} model the route's model\n @param {Array} params an Array of parameter names for the current\n route (in the example, `['post_id']`.\n @return {Object} the serialized parameters\n */\n serialize: function(model, params) {\n if (params.length !== 1) { return; }\n\n var name = params[0], object = {};\n object[name] = get(model, 'id');\n\n return object;\n },\n\n /**\n A hook you can use to setup the necessary controllers for the current\n route.\n\n This method is called with the controller for the current route and the\n model supplied by the `model` hook.\n\n ```js\n App.Route.map(function(match) {\n match(\"/posts/:post_id\").to(\"post\");\n });\n ```\n\n For the `post` route, the controller is `App.PostController`.\n\n By default, the `setupController` hook sets the `content` property of\n the controller to the `model`.\n\n If no explicit controller is defined, the route will automatically create\n an appropriate controller for the model:\n\n * if the model is an `Ember.Array` (including record arrays from Ember\n Data), the controller is an `Ember.ArrayController`.\n * otherwise, the controller is an `Ember.ObjectController`.\n\n This means that your template will get a proxy for the model as its\n context, and you can act as though the model itself was the context.\n */\n setupControllers: function(controller, model) {\n if (controller) {\n controller.set('content', model);\n }\n },\n\n /**\n Returns the controller for a particular route.\n\n ```js\n App.PostRoute = Ember.Route.extend({\n setupControllers: function(controller, post) {\n this._super(controller, post);\n this.controllerFor('posts').set('currentPost', post);\n }\n });\n ```\n\n By default, the controller for `post` is the shared instance of\n `App.PostController`.\n\n @param {String} name the name of the route\n @return {Ember.Controller}\n */\n controllerFor: function(name) {\n return this.container.lookup('controller:' + name);\n },\n\n /**\n Returns the current model for a given route.\n\n This is the object returned by the `model` hook of the route\n in question.\n\n @param {String} name the name of the route\n @return {Object} the model object\n */\n modelFor: function(name) {\n return this.container.lookup('route:' + name).currentModel;\n },\n\n renderTemplates: function(context) {\n this.render();\n },\n\n /**\n Renders a template into an outlet.\n\n This method has a number of defaults, based on the name of the\n route specified in the router.\n\n For example:\n\n ```js\n App.Router.map(function(match) {\n match(\"/\").to(\"index\");\n match(\"/posts/:post_id\").to(\"post\");\n });\n\n App.PostRoute = App.Route.extend({\n renderTemplates: function() {\n this.render();\n }\n });\n ```\n\n The name of the `PostRoute`, as defined by the router, is `post`.\n\n By default, render will:\n\n * render the `post` template\n * with the `post` view (`PostView`) for event handling, if one exists\n * and the `post` controller (`PostController`), if one exists\n * into the `main` outlet of the `application` template\n\n You can override this behavior:\n\n ```js\n App.PostRoute = App.Route.extend({\n renderTemplates: function() {\n this.render('myPost', { // the template to render\n into: 'index', // the template to render into\n outlet: 'detail', // the name of the outlet in that template\n controller: 'blogPost' // the controller to use for the template\n });\n }\n });\n ```\n\n Remember that the controller's `content` will be the route's model. In\n this case, the default model will be `App.Post.find(params.post_id)`.\n\n @param {String} name the name of the template to render\n @param {Object} options the options\n */\n render: function(name, options) {\n if (typeof name === 'object' && !options) {\n options = name;\n name = this.templateName;\n }\n\n name = name || this.templateName;\n\n var container = this.container,\n view = container.lookup('view:' + name),\n template = container.lookup('template:' + name);\n\n if (!view && !template) { return; }\n\n options = normalizeOptions(this, name, template, options);\n view = setupView(view, container, options);\n\n if (name === 'application') {\n appendApplicationView(this, view);\n } else {\n appendView(this, view, options);\n }\n }\n});\n\nfunction normalizeOptions(route, name, template, options) {\n options = options || {};\n options.into = options.into || 'application';\n options.outlet = options.outlet || 'main';\n options.name = name;\n options.template = template;\n\n var controller = options.controller || route.templateName;\n\n if (typeof controller === 'string') {\n controller = route.container.lookup('controller:' + controller);\n }\n\n options.controller = controller;\n\n return options;\n}\n\nfunction setupView(view, container, options) {\n var containerView;\n\n // Trying to set a template on a container view won't work,\n // so instead create a new default view with the template\n // and set it as the container view's `currentView`\n if (view instanceof Ember.ContainerView && options.template) {\n containerView = view;\n view = null;\n }\n\n view = view || container.lookup('view:default');\n\n set(view, 'template', options.template);\n set(view, 'viewName', options.name);\n\n if (containerView) {\n set(containerView, 'currentView', view);\n view = containerView;\n }\n\n set(view, 'controller', options.controller);\n\n return view;\n}\n\nfunction appendApplicationView(route, view) {\n var rootElement = get(route, 'router.namespace.rootElement');\n route.router._connectActiveView('application', view);\n view.appendTo(rootElement);\n}\n\nfunction appendView(route, view, options) {\n var parentView = route.router._lookupActiveView(options.into);\n parentView.connectOutlet(options.outlet, view);\n}\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\nvar get = Ember.get, set = Ember.set;\nEmber.onLoad('Ember.Handlebars', function(Handlebars) {\n /**\n @module ember\n @submodule ember-handlebars\n */\n\n Handlebars.OutletView = Ember.ContainerView.extend(Ember._Metamorph);\n\n /**\n The `outlet` helper allows you to specify that the current\n view's controller will fill in the view for a given area.\n\n ``` handlebars\n {{outlet}}\n ```\n\n By default, when the the current controller's `view` property changes, the\n outlet will replace its current view with the new view. You can set the\n `view` property directly, but it's normally best to use `connectOutlet`.\n\n ``` javascript\n # Instantiate App.PostsView and assign to `view`, so as to render into outlet.\n controller.connectOutlet('posts');\n ```\n\n You can also specify a particular name other than `view`:\n\n ``` handlebars\n {{outlet masterView}}\n {{outlet detailView}}\n ```\n\n Then, you can control several outlets from a single controller.\n\n ``` javascript\n # Instantiate App.PostsView and assign to controller.masterView.\n controller.connectOutlet('masterView', 'posts');\n # Also, instantiate App.PostInfoView and assign to controller.detailView.\n controller.connectOutlet('detailView', 'postInfo');\n ```\n\n @method outlet\n @for Ember.Handlebars.helpers\n @param {String} property the property on the controller\n that holds the view for this outlet\n */\n Handlebars.registerHelper('outlet', function(property, options) {\n if (property && property.data && property.data.isRenderData) {\n options = property;\n property = 'main';\n }\n\n options.hash.currentViewBinding = \"_view._outlets.\" + property;\n\n return Handlebars.helpers.view.call(this, Handlebars.OutletView, options);\n });\n\n Ember.View.reopen({\n init: function() {\n set(this, '_outlets', {});\n this._super();\n },\n\n connectOutlet: function(outletName, view) {\n var outlets = get(this, '_outlets'),\n container = get(this, 'container'),\n router = container && container.lookup('router:main'),\n oldView = get(outlets, outletName),\n viewName = get(view, 'viewName');\n\n set(outlets, outletName, view);\n\n if (router) {\n if (oldView) {\n router._disconnectActiveView(oldView);\n }\n if (viewName) {\n router._connectActiveView(viewName, view);\n }\n }\n },\n\n disconnectOutlet: function(outletName) {\n var outlets = get(this, '_outlets'),\n container = get(this, 'container'),\n router = container && container.lookup('router:main'),\n view = get(outlets, outletName);\n\n set(outlets, outletName, null);\n\n if (router && view) {\n router._disconnectActiveView(view);\n }\n }\n });\n\n function args(linkView, route) {\n var ret = [ route || linkView.namedRoute ],\n params = linkView.parameters,\n contexts = params.contexts,\n roots = params.roots,\n data = params.data;\n\n for (var i=0, l=contexts.length; i<l; i++) {\n ret.push( Ember.Handlebars.get(roots[i], contexts[i], { data: data }) );\n }\n\n return ret;\n }\n\n function simpleClick(event) {\n var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey,\n secondaryClick = event.which > 1; // IE9 may return undefined\n\n return !modifier && !secondaryClick;\n }\n\n var LinkView = Ember.View.extend({\n tagName: 'a',\n namedRoute: null,\n currentWhen: null,\n activeClass: 'active',\n attributeBindings: 'href',\n classNameBindings: 'active',\n\n active: Ember.computed(function() {\n var router = this.get('router'),\n isActive = router.isActive.apply(router, args(this, this.currentWhen));\n\n if (isActive) { return get(this, 'activeClass'); }\n }).property('namedRoute', 'router.url'),\n\n router: Ember.computed(function() {\n return this.get('controller').container.lookup('router:main');\n }),\n\n click: function(event) {\n if (!simpleClick(event)) { return true; }\n\n var router = this.get('router');\n router.transitionTo.apply(router, args(this));\n return false;\n },\n\n href: Ember.computed(function() {\n var router = this.get('router');\n return router.generate.apply(router, args(this));\n })\n });\n\n LinkView.toString = function() { return \"LinkView\"; };\n\n Ember.Handlebars.registerHelper('linkTo', function(name) {\n var options = [].slice.call(arguments, -1)[0];\n var contexts = [].slice.call(arguments, 1, -1);\n\n var hash = options.hash;\n\n hash.namedRoute = name;\n hash.currentWhen = hash.currentWhen || name;\n\n hash.parameters = {\n data: options.data,\n contexts: contexts,\n roots: options.contexts\n };\n\n return Ember.Handlebars.helpers.view.call(this, LinkView, options);\n });\n\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-old-router\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/*\n This file implements the `location` API used by Ember's router.\n\n That API is:\n\n getURL: returns the current URL\n setURL(path): sets the current URL\n onUpdateURL(callback): triggers the callback when the URL changes\n formatURL(url): formats `url` to be placed into `href` attribute\n\n Calling setURL will not trigger onUpdateURL callbacks.\n\n TODO: This should perhaps be moved so that it's visible in the doc output.\n*/\n\n/**\n Ember.Location returns an instance of the correct implementation of\n the `location` API.\n\n You can pass it a `implementation` ('hash', 'history', 'none') to force a\n particular implementation.\n\n @class Location\n @namespace Ember\n @static\n*/\nEmber.Location = {\n create: function(options) {\n var implementation = options && options.implementation;\n Ember.assert(\"Ember.Location.create: you must specify a 'implementation' option\", !!implementation);\n\n var implementationClass = this.implementations[implementation];\n Ember.assert(\"Ember.Location.create: \" + implementation + \" is not a valid implementation\", !!implementationClass);\n\n return implementationClass.create.apply(implementationClass, arguments);\n },\n\n registerImplementation: function(name, implementation) {\n this.implementations[name] = implementation;\n },\n\n implementations: {}\n};\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-old-router\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Ember.NoneLocation does not interact with the browser. It is useful for\n testing, or when you need to manage state with your Router, but temporarily\n don't want it to muck with the URL (for example when you embed your\n application in a larger page).\n\n @class NoneLocation\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.NoneLocation = Ember.Object.extend({\n path: '',\n\n getURL: function() {\n return get(this, 'path');\n },\n\n setURL: function(path) {\n set(this, 'path', path);\n },\n\n onUpdateURL: function(callback) {\n // We are not wired up to the browser, so we'll never trigger the callback.\n },\n\n formatURL: function(url) {\n // The return value is not overly meaningful, but we do not want to throw\n // errors when test code renders templates containing {{action href=true}}\n // helpers.\n return url;\n }\n});\n\nEmber.Location.registerImplementation('none', Ember.NoneLocation);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-old-router\n*/\n\nvar get = Ember.get, set = Ember.set;\n\n/**\n Ember.HashLocation implements the location API using the browser's\n hash. At present, it relies on a hashchange event existing in the\n browser.\n\n @class HashLocation\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.HashLocation = Ember.Object.extend({\n\n init: function() {\n set(this, 'location', get(this, 'location') || window.location);\n },\n\n /**\n @private\n\n Returns the current `location.hash`, minus the '#' at the front.\n\n @method getURL\n */\n getURL: function() {\n return get(this, 'location').hash.substr(1);\n },\n\n /**\n @private\n\n Set the `location.hash` and remembers what was set. This prevents\n `onUpdateURL` callbacks from triggering when the hash was set by\n `HashLocation`.\n\n @method setURL\n @param path {String}\n */\n setURL: function(path) {\n get(this, 'location').hash = path;\n set(this, 'lastSetURL', path);\n },\n\n /**\n @private\n\n Register a callback to be invoked when the hash changes. These\n callbacks will execute when the user presses the back or forward\n button, but not after `setURL` is invoked.\n\n @method onUpdateURL\n @param callback {Function}\n */\n onUpdateURL: function(callback) {\n var self = this;\n var guid = Ember.guidFor(this);\n\n Ember.$(window).bind('hashchange.ember-location-'+guid, function() {\n var path = location.hash.substr(1);\n if (get(self, 'lastSetURL') === path) { return; }\n\n set(self, 'lastSetURL', null);\n\n callback(location.hash.substr(1));\n });\n },\n\n /**\n @private\n\n Given a URL, formats it to be placed into the page as part\n of an element's `href` attribute.\n\n This is used, for example, when using the {{action}} helper\n to generate a URL based on an event.\n\n @method formatURL\n @param url {String}\n */\n formatURL: function(url) {\n return '#'+url;\n },\n\n willDestroy: function() {\n var guid = Ember.guidFor(this);\n\n Ember.$(window).unbind('hashchange.ember-location-'+guid);\n }\n});\n\nEmber.Location.registerImplementation('hash', Ember.HashLocation);\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-old-router\n*/\n\nvar get = Ember.get, set = Ember.set;\nvar popstateReady = false;\n\n/**\n Ember.HistoryLocation implements the location API using the browser's\n history.pushState API.\n\n @class HistoryLocation\n @namespace Ember\n @extends Ember.Object\n*/\nEmber.HistoryLocation = Ember.Object.extend({\n\n init: function() {\n set(this, 'location', get(this, 'location') || window.location);\n this.initState();\n },\n\n /**\n @private\n\n Used to set state on first call to setURL\n\n @method initState\n */\n initState: function() {\n this.replaceState(get(this, 'location').pathname);\n set(this, 'history', window.history);\n },\n\n /**\n Will be pre-pended to path upon state change\n\n @property rootURL\n @default '/'\n */\n rootURL: '/',\n\n /**\n @private\n\n Returns the current `location.pathname`.\n\n @method getURL\n */\n getURL: function() {\n return get(this, 'location').pathname;\n },\n\n /**\n @private\n\n Uses `history.pushState` to update the url without a page reload.\n\n @method setURL\n @param path {String}\n */\n setURL: function(path) {\n path = this.formatURL(path);\n\n if (this.getState() && this.getState().path !== path) {\n popstateReady = true;\n this.pushState(path);\n }\n },\n\n /**\n @private\n\n Get the current `history.state`\n\n @method getState\n */\n getState: function() {\n return get(this, 'history').state;\n },\n\n /**\n @private\n\n Pushes a new state\n\n @method pushState\n @param path {String}\n */\n pushState: function(path) {\n window.history.pushState({ path: path }, null, path);\n },\n\n /**\n @private\n\n Replaces the current state\n\n @method replaceState\n @param path {String}\n */\n replaceState: function(path) {\n window.history.replaceState({ path: path }, null, path);\n },\n\n /**\n @private\n\n Register a callback to be invoked whenever the browser\n history changes, including using forward and back buttons.\n\n @method onUpdateURL\n @param callback {Function}\n */\n onUpdateURL: function(callback) {\n var guid = Ember.guidFor(this);\n\n Ember.$(window).bind('popstate.ember-location-'+guid, function(e) {\n if(!popstateReady) {\n return;\n }\n callback(location.pathname);\n });\n },\n\n /**\n @private\n\n Used when using `{{action}}` helper. The url is always appended to the rootURL.\n\n @method formatURL\n @param url {String}\n */\n formatURL: function(url) {\n var rootURL = get(this, 'rootURL');\n\n if (url !== '') {\n rootURL = rootURL.replace(/\\/$/, '');\n }\n\n return rootURL + url;\n },\n\n willDestroy: function() {\n var guid = Ember.guidFor(this);\n\n Ember.$(window).unbind('popstate.ember-location-'+guid);\n }\n});\n\nEmber.Location.registerImplementation('history', Ember.HistoryLocation);\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n\n})();\n\n(function() {\nfunction visit(vertex, fn, visited, path) {\n var name = vertex.name,\n vertices = vertex.incoming,\n names = vertex.incomingNames,\n len = names.length,\n i;\n if (!visited) {\n visited = {};\n }\n if (!path) {\n path = [];\n }\n if (visited.hasOwnProperty(name)) {\n return;\n }\n path.push(name);\n visited[name] = true;\n for (i = 0; i < len; i++) {\n visit(vertices[names[i]], fn, visited, path);\n }\n fn(vertex, path);\n path.pop();\n}\n\nfunction DAG() {\n this.names = [];\n this.vertices = {};\n}\n\nDAG.prototype.add = function(name) {\n if (!name) { return; }\n if (this.vertices.hasOwnProperty(name)) {\n return this.vertices[name];\n }\n var vertex = {\n name: name, incoming: {}, incomingNames: [], hasOutgoing: false, value: null\n };\n this.vertices[name] = vertex;\n this.names.push(name);\n return vertex;\n};\n\nDAG.prototype.map = function(name, value) {\n this.add(name).value = value;\n};\n\nDAG.prototype.addEdge = function(fromName, toName) {\n if (!fromName || !toName || fromName === toName) {\n return;\n }\n var from = this.add(fromName), to = this.add(toName);\n if (to.incoming.hasOwnProperty(fromName)) {\n return;\n }\n function checkCycle(vertex, path) {\n if (vertex.name === toName) {\n throw new Error(\"cycle detected: \" + toName + \" <- \" + path.join(\" <- \"));\n }\n }\n visit(from, checkCycle);\n from.hasOutgoing = true;\n to.incoming[fromName] = from;\n to.incomingNames.push(fromName);\n};\n\nDAG.prototype.topsort = function(fn) {\n var visited = {},\n vertices = this.vertices,\n names = this.names,\n len = names.length,\n i, vertex;\n for (i = 0; i < len; i++) {\n vertex = vertices[names[i]];\n if (!vertex.hasOutgoing) {\n visit(vertex, fn, visited);\n }\n }\n};\n\nDAG.prototype.addEdges = function(name, value, before, after) {\n var i;\n this.map(name, value);\n if (before) {\n if (typeof before === 'string') {\n this.addEdge(name, before);\n } else {\n for (i = 0; i < before.length; i++) {\n this.addEdge(name, before[i]);\n }\n }\n }\n if (after) {\n if (typeof after === 'string') {\n this.addEdge(after, name);\n } else {\n for (i = 0; i < after.length; i++) {\n this.addEdge(after[i], name);\n }\n }\n }\n};\n\nEmber.DAG = DAG;\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-application\n*/\n\nvar get = Ember.get, set = Ember.set,\n classify = Ember.String.classify,\n decamelize = Ember.String.decamelize;\n\nEmber.Container.set = Ember.set;\n\n/**\n An instance of `Ember.Application` is the starting point for every Ember\n application. It helps to instantiate, initialize and coordinate the many\n objects that make up your app.\n\n Each Ember app has one and only one `Ember.Application` object. In fact, the\n very first thing you should do in your application is create the instance:\n\n ```javascript\n window.App = Ember.Application.create();\n ```\n\n Typically, the application object is the only global variable. All other\n classes in your app should be properties on the `Ember.Application` instance,\n which highlights its first role: a global namespace.\n\n For example, if you define a view class, it might look like this:\n\n ```javascript\n App.MyView = Ember.View.extend();\n ```\n\n Calling `Ember.Application.create()` will automatically initialize your\n application by calling the `Ember.Application.initialize()` method. If you\n need to delay initialization, you can pass `{autoinit: false}` to the\n `Ember.Application.create()` method, and call `App.initialize()`\n later.\n\n Because `Ember.Application` inherits from `Ember.Namespace`, any classes\n you create will have useful string representations when calling `toString()`.\n See the `Ember.Namespace` documentation for more information.\n\n While you can think of your `Ember.Application` as a container that holds the\n other classes in your application, there are several other responsibilities\n going on under-the-hood that you may want to understand.\n\n ### Event Delegation\n\n Ember uses a technique called _event delegation_. This allows the framework\n to set up a global, shared event listener instead of requiring each view to\n do it manually. For example, instead of each view registering its own\n `mousedown` listener on its associated element, Ember sets up a `mousedown`\n listener on the `body`.\n\n If a `mousedown` event occurs, Ember will look at the target of the event and\n start walking up the DOM node tree, finding corresponding views and invoking\n their `mouseDown` method as it goes.\n\n `Ember.Application` has a number of default events that it listens for, as\n well as a mapping from lowercase events to camel-cased view method names. For\n example, the `keypress` event causes the `keyPress` method on the view to be\n called, the `dblclick` event causes `doubleClick` to be called, and so on.\n\n If there is a browser event that Ember does not listen for by default, you\n can specify custom events and their corresponding view method names by\n setting the application's `customEvents` property:\n\n ```javascript\n App = Ember.Application.create({\n customEvents: {\n // add support for the loadedmetadata media\n // player event\n 'loadedmetadata': \"loadedMetadata\"\n }\n });\n ```\n\n By default, the application sets up these event listeners on the document\n body. However, in cases where you are embedding an Ember application inside\n an existing page, you may want it to set up the listeners on an element\n inside the body.\n\n For example, if only events inside a DOM element with the ID of `ember-app`\n should be delegated, set your application's `rootElement` property:\n\n ```javascript\n window.App = Ember.Application.create({\n rootElement: '#ember-app'\n });\n ```\n\n The `rootElement` can be either a DOM element or a jQuery-compatible selector\n string. Note that *views appended to the DOM outside the root element will\n not receive events.* If you specify a custom root element, make sure you only\n append views inside it!\n\n To learn more about the advantages of event delegation and the Ember view\n layer, and a list of the event listeners that are setup by default, visit the\n [Ember View Layer guide](http://emberjs.com/guides/view_layer#toc_event-delegation).\n\n ### Dependency Injection\n\n One thing you may have noticed while using Ember is that you define\n *classes*, not *instances*. When your application loads, all of the instances\n are created for you. Creating these instances is the responsibility of\n `Ember.Application`.\n\n When the `Ember.Application` initializes, it will look for an `Ember.Router`\n class defined on the applications's `Router` property, like this:\n\n ```javascript\n App.Router = Ember.Router.extend({\n // ...\n });\n ```\n\n If found, the router is instantiated and saved on the application's `router`\n property (note the lowercase 'r'). While you should *not* reference this\n router instance directly from your application code, having access to\n `App.router` from the console can be useful during debugging.\n\n After the router is created, the application loops through all of the\n registered _injections_ and invokes them once for each property on the\n `Ember.Application` object.\n\n An injection is a function that is responsible for instantiating objects from\n classes defined on the application. By default, the only injection registered\n instantiates controllers and makes them available on the router.\n\n For example, if you define a controller class:\n\n ```javascript\n App.MyController = Ember.Controller.extend({\n // ...\n });\n ```\n\n Your router will receive an instance of `App.MyController` saved on its\n `myController` property.\n\n Libraries on top of Ember can register additional injections. For example,\n if your application is using Ember Data, it registers an injection that\n instantiates `DS.Store`:\n\n ```javascript\n Ember.Application.registerInjection({\n name: 'store',\n before: 'controllers',\n\n injection: function(app, router, property) {\n if (property === 'Store') {\n set(router, 'store', app[property].create());\n }\n }\n });\n ```\n\n ### Routing\n\n In addition to creating your application's router, `Ember.Application` is\n also responsible for telling the router when to start routing.\n\n By default, the router will begin trying to translate the current URL into\n application state once the browser emits the `DOMContentReady` event. If you\n need to defer routing, you can call the application's `deferReadiness()`\n method. Once routing can begin, call the `advanceReadiness()` method.\n\n If there is any setup required before routing begins, you can implement a\n `ready()` method on your app that will be invoked immediately before routing\n begins:\n\n ```javascript\n window.App = Ember.Application.create({\n ready: function() {\n this.set('router.enableLogging', true);\n }\n });\n\n To begin routing, you must have at a minimum a top-level controller and view.\n You define these as `App.ApplicationController` and `App.ApplicationView`,\n respectively. Your application will not work if you do not define these two\n mandatory classes. For example:\n\n ```javascript\n App.ApplicationView = Ember.View.extend({\n templateName: 'application'\n });\n App.ApplicationController = Ember.Controller.extend();\n ```\n\n @class Application\n @namespace Ember\n @extends Ember.Namespace\n*/\nvar Application = Ember.Application = Ember.Namespace.extend(\n/** @scope Ember.Application.prototype */{\n\n /**\n The root DOM element of the Application. This can be specified as an\n element or a\n [jQuery-compatible selector string](http://api.jquery.com/category/selectors/).\n\n This is the element that will be passed to the Application's,\n `eventDispatcher`, which sets up the listeners for event delegation. Every\n view in your application should be a child of the element you specify here.\n\n @property rootElement\n @type DOMElement\n @default 'body'\n */\n rootElement: 'body',\n\n /**\n The `Ember.EventDispatcher` responsible for delegating events to this\n application's views.\n\n The event dispatcher is created by the application at initialization time\n and sets up event listeners on the DOM element described by the\n application's `rootElement` property.\n\n See the documentation for `Ember.EventDispatcher` for more information.\n\n @property eventDispatcher\n @type Ember.EventDispatcher\n @default null\n */\n eventDispatcher: null,\n\n /**\n The DOM events for which the event dispatcher should listen.\n\n By default, the application's `Ember.EventDispatcher` listens\n for a set of standard DOM events, such as `mousedown` and\n `keyup`, and delegates them to your application's `Ember.View`\n instances.\n\n If you would like additional events to be delegated to your\n views, set your `Ember.Application`'s `customEvents` property\n to a hash containing the DOM event name as the key and the\n corresponding view method name as the value. For example:\n\n ```javascript\n App = Ember.Application.create({\n customEvents: {\n // add support for the loadedmetadata media\n // player event\n 'loadedmetadata': \"loadedMetadata\"\n }\n });\n ```\n\n @property customEvents\n @type Object\n @default null\n */\n customEvents: null,\n\n isInitialized: false,\n\n // Start off the number of deferrals at 1. This will be\n // decremented by the Application's own `initialize` method.\n _readinessDeferrals: 1,\n\n init: function() {\n if (!this.$) { this.$ = Ember.$; }\n this.container = this.buildContainer();\n this.Router = this.Router || this.defaultRouter();\n\n this._super();\n\n this.deferUntilDOMReady();\n this.scheduleInitialize();\n },\n\n /**\n @private\n\n Build the container for the current application.\n\n Also register a default application view in case the application\n itself does not.\n\n @return {Ember.Container} the configured container\n */\n buildContainer: function() {\n var container = this.container = Application.buildContainer(this);\n\n return container;\n },\n\n /**\n @private\n\n If the application has not opted out of routing and has not explicitly\n defined a router, supply a default router for the application author\n to configure.\n\n This allows application developers to do:\n\n ```javascript\n App = Ember.Application.create();\n\n App.Router.map(function(match) {\n match(\"/\").to(\"index\");\n });\n ```\n\n @return {Ember.Router} the default router\n */\n defaultRouter: function() {\n // Create a default App.Router if one was not supplied to make\n // it possible to do App.Router.map(...) without explicitly\n // creating a router first.\n if (this.router === undefined) {\n return Ember.Router.extend();\n }\n },\n\n /**\n @private\n\n Defer Ember readiness until DOM readiness. By default, Ember\n will wait for both DOM readiness and application initialization,\n as well as any deferrals registered by initializers.\n */\n deferUntilDOMReady: function() {\n this.deferReadiness();\n\n var self = this;\n this.$().ready(function() {\n self.advanceReadiness();\n });\n },\n\n /**\n @private\n\n Automatically initialize the application once the DOM has\n become ready.\n\n The initialization itself is deferred using Ember.run.once,\n which ensures that application loading finishes before\n booting.\n\n If you are asynchronously loading code, you should call\n `deferReadiness()` to defer booting, and then call\n `advanceReadiness()` once all of your code has finished\n loading.\n */\n scheduleInitialize: function() {\n var self = this;\n this.$().ready(function() {\n if (self.isDestroyed || self.isInitialized) return;\n Ember.run.once(self, 'initialize');\n });\n },\n\n /**\n Use this to defer readiness until some condition is true.\n\n Example:\n\n ```javascript\n App = Ember.Application.create();\n App.deferReadiness();\n\n jQuery.getJSON(\"/auth-token\", function(token) {\n App.token = token;\n App.advanceReadiness();\n });\n ```\n\n This allows you to perform asynchronous setup logic and defer\n booting your application until the setup has finished.\n\n However, if the setup requires a loading UI, it might be better\n to use the router for this purpose.\n */\n deferReadiness: function() {\n Ember.assert(\"You cannot defer readiness since the `ready()` hook has already been called.\", this._readinessDeferrals > 0);\n this._readinessDeferrals++;\n },\n\n /**\n @see {Ember.Application#deferReadiness}\n */\n advanceReadiness: function() {\n this._readinessDeferrals--;\n\n if (this._readinessDeferrals === 0) {\n Ember.run.once(this, this.didBecomeReady);\n }\n },\n\n /**\n @private\n\n Initialize the application. This happens automatically.\n\n Run any injections and run the application load hook. These hooks may\n choose to defer readiness. For example, an authentication hook might want\n to defer readiness until the auth token has been retrieved.\n */\n initialize: function() {\n Ember.assert(\"Application initialize may only be called once\", !this.isInitialized);\n Ember.assert(\"Cannot initialize a destroyed application\", !this.isDestroyed);\n this.isInitialized = true;\n\n // At this point, the App.Router must already be assigned\n this.container.register('router', 'main', this.Router);\n\n // Run any injections and run the application load hook. These hooks may\n // choose to defer readiness. For example, an authentication hook might want\n // to defer readiness until the auth token has been retrieved.\n this.runInitializers();\n Ember.runLoadHooks('application', this);\n\n // At this point, any injections or load hooks that would have wanted\n // to defer readiness have fired. In general, advancing readiness here\n // will proceed to didBecomeReady.\n this.advanceReadiness();\n\n return this;\n },\n\n /** @private */\n runInitializers: function() {\n var router = this.container.lookup('router:main'),\n initializers = get(this.constructor, 'initializers'),\n container = this.container,\n graph = new Ember.DAG(),\n namespace = this,\n properties, i, initializer;\n\n for (i=0; i<initializers.length; i++) {\n initializer = initializers[i];\n graph.addEdges(initializer.name, initializer.initialize, initializer.before, initializer.after);\n }\n\n graph.topsort(function (vertex) {\n var initializer = vertex.value;\n initializer(container, namespace);\n });\n },\n\n /** @private */\n didBecomeReady: function() {\n this.setupEventDispatcher();\n this.ready(); // user hook\n this.startRouting();\n\n if (!Ember.testing) {\n Ember.BOOTED = true;\n }\n },\n\n /**\n @private\n\n Setup up the event dispatcher to receive events on the\n application's `rootElement` with any registered\n `customEvents`.\n */\n setupEventDispatcher: function() {\n var eventDispatcher = this.createEventDispatcher(),\n customEvents = get(this, 'customEvents');\n\n eventDispatcher.setup(customEvents);\n },\n\n /**\n @private\n\n Create an event dispatcher for the application's `rootElement`.\n */\n createEventDispatcher: function() {\n var rootElement = get(this, 'rootElement'),\n eventDispatcher = Ember.EventDispatcher.create({\n rootElement: rootElement\n });\n\n set(this, 'eventDispatcher', eventDispatcher);\n return eventDispatcher;\n },\n\n /**\n @private\n\n If the application has a router, use it to route to the current URL, and\n trigger a new call to `route` whenever the URL changes.\n\n @method startRouting\n @property router {Ember.Router}\n */\n startRouting: function() {\n var router = this.container.lookup('router:main');\n if (!router) { return; }\n\n router.startRouting();\n },\n\n /**\n Called when the Application has become ready.\n The call will be delayed until the DOM has become ready.\n\n @event ready\n */\n ready: Ember.K,\n\n willDestroy: function() {\n Ember.BOOTED = false;\n\n var eventDispatcher = get(this, 'eventDispatcher');\n if (eventDispatcher) { eventDispatcher.destroy(); }\n\n this.container.destroy();\n },\n\n initializer: function(options) {\n this.constructor.initializer(options);\n }\n});\n\nEmber.Application.reopenClass({\n concatenatedProperties: ['initializers'],\n initializers: Ember.A(),\n initializer: function(initializer) {\n var initializers = get(this, 'initializers');\n\n Ember.assert(\"The initializer '\" + initializer.name + \"' has already been registered\", !initializers.findProperty('name', initializers.name));\n Ember.assert(\"An injection cannot be registered with both a before and an after\", !(initializer.before && initializer.after));\n Ember.assert(\"An injection cannot be registered without an injection function\", Ember.canInvoke(initializer, 'initialize'));\n\n initializers.push(initializer);\n },\n\n /**\n @private\n\n This creates a container with the default Ember naming conventions.\n\n It also configures the container:\n\n * registered views are created every time they are looked up (they are\n not singletons)\n * registered templates are not factories; the registered value is\n returned directly.\n * the router receives the application as its `namespace` property\n * all controllers receive the router as their `target` and `controllers`\n properties\n * all controllers receive the application as their `namespace` property\n * the application view receives the application controller as its\n `controller` property\n * the application view receives the application template as its\n `defaultTemplate` property\n\n @param {Ember.Application} namespace the application to build the\n container for.\n @return {Ember.Container} the built container\n */\n buildContainer: function(namespace) {\n var container = new Ember.Container();\n Ember.Container.defaultContainer = container;\n var ApplicationView = Ember.ContainerView.extend({\n currentView: Ember.computed(function(key, value) {\n if (arguments.length > 1) { return value; }\n return get(this, '_outlets.main');\n }).property('_outlets.main')\n });\n\n container.set = Ember.set;\n container.resolve = resolveFor(namespace);\n container.optionsForType('view', { singleton: false });\n container.optionsForType('template', { instantiate: false });\n container.register('application', 'main', namespace, { instantiate: false });\n container.injection('router:main', 'namespace', 'application:main');\n\n container.typeInjection('controller', 'target', 'router:main');\n container.typeInjection('controller', 'controllers', 'router:main');\n container.typeInjection('controller', 'namespace', 'application:main');\n\n container.typeInjection('route', 'router', 'router:main');\n\n // Register a fallback application view. App.ApplicationView will\n // take precedence.\n container.register('view', 'application', ApplicationView);\n\n return container;\n }\n});\n\n/**\n @private\n\n This function defines the default lookup rules for container lookups:\n\n * templates are looked up on `Ember.TEMPLATES`\n * other names are looked up on the application after classifying the name.\n For example, `controller:post` looks up `App.PostController` by default.\n * if the default lookup fails, look for registered classes on the container\n\n This allows the application to register default injections in the container\n that could be overridden by the normal naming convention.\n\n @param {Ember.Namespace} namespace the namespace to look for classes\n @return {any} the resolved value for a given lookup\n*/\nfunction resolveFor(namespace) {\n return function(fullName) {\n var nameParts = fullName.split(\":\"),\n type = nameParts[0], name = nameParts[1];\n\n if (type === 'template') {\n var templateName = decamelize(name);\n if (Ember.TEMPLATES[templateName]) {\n return Ember.TEMPLATES[templateName];\n }\n }\n\n var className = classify(name) + classify(type);\n var factory = get(namespace, className);\n\n if (factory) { return factory; }\n\n return Ember.Container.prototype.resolve.call(this, fullName);\n };\n}\n\nEmber.runLoadHooks('Ember.Application', Ember.Application);\n\n\n})();\n\n\n\n(function() {\n\n})();\n\n\n\n(function() {\n/**\nEmber Application\n\n@module ember\n@submodule ember-application\n@requires ember-views, ember-states, ember-routing\n*/\n\n})();\n\n(function() {\nvar get = Ember.get, set = Ember.set;\n\n/**\n@module ember\n@submodule ember-states\n*/\n\n/**\n @class State\n @namespace Ember\n @extends Ember.Object\n @uses Ember.Evented\n*/\nEmber.State = Ember.Object.extend(Ember.Evented,\n/** @scope Ember.State.prototype */{\n isState: true,\n\n /**\n A reference to the parent state.\n\n @property parentState\n @type Ember.State\n */\n parentState: null,\n start: null,\n\n /**\n The name of this state.\n\n @property name\n @type String\n */\n name: null,\n\n /**\n The full path to this state.\n\n @property path\n @type String\n */\n path: Ember.computed(function() {\n var parentPath = get(this, 'parentState.path'),\n path = get(this, 'name');\n\n if (parentPath) {\n path = parentPath + '.' + path;\n }\n\n return path;\n }).property(),\n\n /**\n @private\n\n Override the default event firing from `Ember.Evented` to\n also call methods with the given name.\n\n @method trigger\n @param name\n */\n trigger: function(name) {\n if (this[name]) {\n this[name].apply(this, [].slice.call(arguments, 1));\n }\n this._super.apply(this, arguments);\n },\n\n init: function() {\n var states = get(this, 'states'), foundStates;\n set(this, 'childStates', Ember.A());\n set(this, 'eventTransitions', get(this, 'eventTransitions') || {});\n\n var name, value, transitionTarget;\n\n // As a convenience, loop over the properties\n // of this state and look for any that are other\n // Ember.State instances or classes, and move them\n // to the `states` hash. This avoids having to\n // create an explicit separate hash.\n\n if (!states) {\n states = {};\n\n for (name in this) {\n if (name === \"constructor\") { continue; }\n\n if (value = this[name]) {\n if (transitionTarget = value.transitionTarget) {\n this.eventTransitions[name] = transitionTarget;\n }\n\n this.setupChild(states, name, value);\n }\n }\n\n set(this, 'states', states);\n } else {\n for (name in states) {\n this.setupChild(states, name, states[name]);\n }\n }\n\n set(this, 'pathsCache', {});\n set(this, 'pathsCacheNoContext', {});\n },\n\n setupChild: function(states, name, value) {\n if (!value) { return false; }\n\n if (value.isState) {\n set(value, 'name', name);\n } else if (Ember.State.detect(value)) {\n value = value.create({\n name: name\n });\n }\n\n if (value.isState) {\n set(value, 'parentState', this);\n get(this, 'childStates').pushObject(value);\n states[name] = value;\n return value;\n }\n },\n\n lookupEventTransition: function(name) {\n var path, state = this;\n\n while(state && !path) {\n path = state.eventTransitions[name];\n state = state.get('parentState');\n }\n\n return path;\n },\n\n /**\n A Boolean value indicating whether the state is a leaf state\n in the state hierarchy. This is `false` if the state has child\n states; otherwise it is true.\n\n @property isLeaf\n @type Boolean\n */\n isLeaf: Ember.computed(function() {\n return !get(this, 'childStates').length;\n }),\n\n /**\n A boolean value indicating whether the state takes a context.\n By default we assume all states take contexts.\n\n @property hasContext\n @default true\n */\n hasContext: true,\n\n /**\n This is the default transition event.\n\n @event setup\n @param {Ember.StateManager} manager\n @param context\n @see Ember.StateManager#transitionEvent\n */\n setup: Ember.K,\n\n /**\n This event fires when the state is entered.\n\n @event enter\n @param {Ember.StateManager} manager\n */\n enter: Ember.K,\n\n /**\n This event fires when the state is exited.\n\n @event exit\n @param {Ember.StateManager} manager\n */\n exit: Ember.K\n});\n\nEmber.State.reopenClass({\n\n /**\n Creates an action function for transitioning to the named state while\n preserving context.\n\n The following example StateManagers are equivalent:\n\n ```javascript\n aManager = Ember.StateManager.create({\n stateOne: Ember.State.create({\n changeToStateTwo: Ember.State.transitionTo('stateTwo')\n }),\n stateTwo: Ember.State.create({})\n })\n\n bManager = Ember.StateManager.create({\n stateOne: Ember.State.create({\n changeToStateTwo: function(manager, context){\n manager.transitionTo('stateTwo', context)\n }\n }),\n stateTwo: Ember.State.create({})\n })\n ```\n\n @method transitionTo\n @static\n @param {String} target\n */\n\n transitionTo: function(target) {\n\n var transitionFunction = function(stateManager, contextOrEvent) {\n var contexts = [], transitionArgs,\n Event = Ember.$ && Ember.$.Event;\n\n if (contextOrEvent && (Event && contextOrEvent instanceof Event)) {\n if (contextOrEvent.hasOwnProperty('contexts')) {\n contexts = contextOrEvent.contexts.slice();\n }\n }\n else {\n contexts = [].slice.call(arguments, 1);\n }\n\n contexts.unshift(target);\n stateManager.transitionTo.apply(stateManager, contexts);\n };\n\n transitionFunction.transitionTarget = target;\n\n return transitionFunction;\n }\n\n});\n\n})();\n\n\n\n(function() {\n/**\n@module ember\n@submodule ember-states\n*/\n\nvar get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;\nvar arrayForEach = Ember.ArrayPolyfills.forEach;\n/**\n A Transition takes the enter, exit and resolve states and normalizes\n them:\n\n * takes any passed in contexts into consideration\n * adds in `initialState`s\n\n @class Transition\n @private\n*/\nvar Transition = function(raw) {\n this.enterStates = raw.enterStates.slice();\n this.exitStates = raw.exitStates.slice();\n this.resolveState = raw.resolveState;\n\n this.finalState = raw.enterStates[raw.enterStates.length - 1] || raw.resolveState;\n};\n\nTransition.prototype = {\n /**\n Normalize the passed in enter, exit and resolve states.\n\n This process also adds `finalState` and `contexts` to the Transition object.\n\n @method normalize\n @param {Ember.StateManager} manager the state manager running the transition\n @param {Array} contexts a list of contexts passed into `transitionTo`\n */\n normalize: function(manager, contexts) {\n this.matchContextsToStates(contexts);\n this.addInitialStates();\n this.removeUnchangedContexts(manager);\n return this;\n },\n\n /**\n Match each of the contexts passed to `transitionTo` to a state.\n This process may also require adding additional enter and exit\n states if there are more contexts than enter states.\n\n @method matchContextsToStates\n @param {Array} contexts a list of contexts passed into `transitionTo`\n */\n matchContextsToStates: function(contexts) {\n var stateIdx = this.enterStates.length - 1,\n matchedContexts = [],\n state,\n context;\n\n // Next, we will match the passed in contexts to the states they\n // represent.\n //\n // First, assign a context to each enter state in reverse order. If\n // any contexts are left, add a parent state to the list of states\n // to enter and exit, and assign a context to the parent state.\n //\n // If there are still contexts left when the state manager is\n // reached, raise an exception.\n //\n // This allows the following:\n //\n // |- root\n // | |- post\n // | | |- comments\n // | |- about (* current state)\n //\n // For `transitionTo('post.comments', post, post.get('comments')`,\n // the first context (`post`) will be assigned to `root.post`, and\n // the second context (`post.get('comments')`) will be assigned\n // to `root.post.comments`.\n //\n // For the following:\n //\n // |- root\n // | |- post\n // | | |- index (* current state)\n // | | |- comments\n //\n // For `transitionTo('post.comments', otherPost, otherPost.get('comments')`,\n // the `<root.post>` state will be added to the list of enter and exit\n // states because its context has changed.\n\n while (contexts.length > 0) {\n if (stateIdx >= 0) {\n state = this.enterStates[stateIdx--];\n } else {\n if (this.enterStates.length) {\n state = get(this.enterStates[0], 'parentState');\n if (!state) { throw \"Cannot match all contexts to states\"; }\n } else {\n // If re-entering the current state with a context, the resolve\n // state will be the current state.\n state = this.resolveState;\n }\n\n this.enterStates.unshift(state);\n this.exitStates.unshift(state);\n }\n\n // in routers, only states with dynamic segments have a context\n if (get(state, 'hasContext')) {\n context = contexts.pop();\n } else {\n context = null;\n }\n\n matchedContexts.unshift(context);\n }\n\n this.contexts = matchedContexts;\n },\n\n /**\n Add any `initialState`s to the list of enter states.\n\n @method addInitialStates\n */\n addInitialStates: function() {\n var finalState = this.finalState, initialState;\n\n while(true) {\n initialState = get(finalState, 'initialState') || 'start';\n finalState = get(finalState, 'states.' + initialState);\n\n if (!finalState) { break; }\n\n this.finalState = finalState;\n this.enterStates.push(finalState);\n this.contexts.push(undefined);\n }\n },\n\n /**\n Remove any states that were added because the number of contexts\n exceeded the number of explicit enter states, but the context has\n not changed since the last time the state was entered.\n\n @method removeUnchangedContexts\n @param {Ember.StateManager} manager passed in to look up the last\n context for a states\n */\n removeUnchangedContexts: function(manager) {\n // Start from the beginning of the enter states. If the state was added\n // to the list during the context matching phase, make sure the context\n // has actually changed since the last time the state was entered.\n while (this.enterStates.length > 0) {\n if (this.enterStates[0] !== this.exitStates[0]) { break; }\n\n if (this.enterStates.length === this.contexts.length) {\n if (manager.getStateMeta(this.enterStates[0], 'context') !== this.contexts[0]) { break; }\n this.contexts.shift();\n }\n\n this.resolveState = this.enterStates.shift();\n this.exitStates.shift();\n }\n }\n};\n\nvar sendRecursively = function(event, currentState, isUnhandledPass) {\n var log = this.enableLogging,\n eventName = isUnhandledPass ? 'unhandledEvent' : event,\n action = currentState[eventName],\n contexts, sendRecursiveArguments, actionArguments;\n\n contexts = [].slice.call(arguments, 3);\n\n // Test to see if the action is a method that\n // can be invoked. Don't blindly check just for\n // existence, because it is possible the state\n // manager has a child state of the given name,\n // and we should still raise an exception in that\n // case.\n if (typeof action === 'function') {\n if (log) {\n if (isUnhandledPass) {\n Ember.Logger.log(fmt(\"STATEMANAGER: Unhandled event '%@' being sent to state %@.\", [event, get(currentState, 'path')]));\n } else {\n Ember.Logger.log(fmt(\"STATEMANAGER: Sending event '%@' to state %@.\", [event, get(currentState, 'path')]));\n }\n }\n\n actionArguments = contexts;\n if (isUnhandledPass) {\n actionArguments.unshift(event);\n }\n actionArguments.unshift(this);\n\n return action.apply(currentState, actionArguments);\n } else {\n var parentState = get(currentState, 'parentState');\n if (parentState) {\n\n sendRecursiveArguments = contexts;\n sendRecursiveArguments.unshift(event, parentState, isUnhandledPass);\n\n return sendRecursively.apply(this, sendRecursiveArguments);\n } else if (!isUnhandledPass) {\n return sendEvent.call(this, event, contexts, true);\n }\n }\n};\n\nvar sendEvent = function(eventName, sendRecursiveArguments, isUnhandledPass) {\n sendRecursiveArguments.unshift(eventName, get(this, 'currentState'), isUnhandledPass);\n return sendRecursively.apply(this, sendRecursiveArguments);\n};\n\n/**\n StateManager is part of Ember's implementation of a finite state machine. A\n StateManager instance manages a number of properties that are instances of\n `Ember.State`,\n tracks the current active state, and triggers callbacks when states have changed.\n\n ## Defining States\n\n The states of StateManager can be declared in one of two ways. First, you can\n define a `states` property that contains all the states:\n\n ```javascript\n managerA = Ember.StateManager.create({\n states: {\n stateOne: Ember.State.create(),\n stateTwo: Ember.State.create()\n }\n })\n\n managerA.get('states')\n // {\n // stateOne: Ember.State.create(),\n // stateTwo: Ember.State.create()\n // }\n ```\n\n You can also add instances of `Ember.State` (or an `Ember.State` subclass)\n directly as properties of a StateManager. These states will be collected into\n the `states` property for you.\n\n ```javascript\n managerA = Ember.StateManager.create({\n stateOne: Ember.State.create(),\n stateTwo: Ember.State.create()\n })\n\n managerA.get('states')\n // {\n // stateOne: Ember.State.create(),\n // stateTwo: Ember.State.create()\n // }\n ```\n\n ## The Initial State\n\n When created a StateManager instance will immediately enter into the state\n defined as its `start` property or the state referenced by name in its\n `initialState` property:\n\n ```javascript\n managerA = Ember.StateManager.create({\n start: Ember.State.create({})\n })\n\n managerA.get('currentState.name') // 'start'\n\n managerB = Ember.StateManager.create({\n initialState: 'beginHere',\n beginHere: Ember.State.create({})\n })\n\n managerB.get('currentState.name') // 'beginHere'\n ```\n\n Because it is a property you may also provide a computed function if you wish\n to derive an `initialState` programmatically:\n\n ```javascript\n managerC = Ember.StateManager.create({\n initialState: function(){\n if (someLogic) {\n return 'active';\n } else {\n return 'passive';\n }\n }.property(),\n active: Ember.State.create({}),\n passive: Ember.State.create({})\n })\n ```\n\n ## Moving Between States\n\n A StateManager can have any number of `Ember.State` objects as properties\n and can have a single one of these states as its current state.\n\n Calling `transitionTo` transitions between states:\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown',\n poweredDown: Ember.State.create({}),\n poweredUp: Ember.State.create({})\n })\n\n robotManager.get('currentState.name') // 'poweredDown'\n robotManager.transitionTo('poweredUp')\n robotManager.get('currentState.name') // 'poweredUp'\n ```\n\n Before transitioning into a new state the existing `currentState` will have\n its `exit` method called with the StateManager instance as its first argument\n and an object representing the transition as its second argument.\n\n After transitioning into a new state the new `currentState` will have its\n `enter` method called with the StateManager instance as its first argument\n and an object representing the transition as its second argument.\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown',\n poweredDown: Ember.State.create({\n exit: function(stateManager){\n console.log(\"exiting the poweredDown state\")\n }\n }),\n poweredUp: Ember.State.create({\n enter: function(stateManager){\n console.log(\"entering the poweredUp state. Destroy all humans.\")\n }\n })\n })\n\n robotManager.get('currentState.name') // 'poweredDown'\n robotManager.transitionTo('poweredUp')\n\n // will log\n // 'exiting the poweredDown state'\n // 'entering the poweredUp state. Destroy all humans.'\n ```\n\n Once a StateManager is already in a state, subsequent attempts to enter that\n state will not trigger enter or exit method calls. Attempts to transition\n into a state that the manager does not have will result in no changes in the\n StateManager's current state:\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown',\n poweredDown: Ember.State.create({\n exit: function(stateManager){\n console.log(\"exiting the poweredDown state\")\n }\n }),\n poweredUp: Ember.State.create({\n enter: function(stateManager){\n console.log(\"entering the poweredUp state. Destroy all humans.\")\n }\n })\n })\n\n robotManager.get('currentState.name') // 'poweredDown'\n robotManager.transitionTo('poweredUp')\n // will log\n // 'exiting the poweredDown state'\n // 'entering the poweredUp state. Destroy all humans.'\n robotManager.transitionTo('poweredUp') // no logging, no state change\n\n robotManager.transitionTo('someUnknownState') // silently fails\n robotManager.get('currentState.name') // 'poweredUp'\n ```\n\n Each state property may itself contain properties that are instances of\n `Ember.State`. The StateManager can transition to specific sub-states in a\n series of transitionTo method calls or via a single transitionTo with the\n full path to the specific state. The StateManager will also keep track of the\n full path to its currentState\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown',\n poweredDown: Ember.State.create({\n charging: Ember.State.create(),\n charged: Ember.State.create()\n }),\n poweredUp: Ember.State.create({\n mobile: Ember.State.create(),\n stationary: Ember.State.create()\n })\n })\n\n robotManager.get('currentState.name') // 'poweredDown'\n\n robotManager.transitionTo('poweredUp')\n robotManager.get('currentState.name') // 'poweredUp'\n\n robotManager.transitionTo('mobile')\n robotManager.get('currentState.name') // 'mobile'\n\n // transition via a state path\n robotManager.transitionTo('poweredDown.charging')\n robotManager.get('currentState.name') // 'charging'\n\n robotManager.get('currentState.path') // 'poweredDown.charging'\n ```\n\n Enter transition methods will be called for each state and nested child state\n in their hierarchical order. Exit methods will be called for each state and\n its nested states in reverse hierarchical order.\n\n Exit transitions for a parent state are not called when entering into one of\n its child states, only when transitioning to a new section of possible states\n in the hierarchy.\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown',\n poweredDown: Ember.State.create({\n enter: function(){},\n exit: function(){\n console.log(\"exited poweredDown state\")\n },\n charging: Ember.State.create({\n enter: function(){},\n exit: function(){}\n }),\n charged: Ember.State.create({\n enter: function(){\n console.log(\"entered charged state\")\n },\n exit: function(){\n console.log(\"exited charged state\")\n }\n })\n }),\n poweredUp: Ember.State.create({\n enter: function(){\n console.log(\"entered poweredUp state\")\n },\n exit: function(){},\n mobile: Ember.State.create({\n enter: function(){\n console.log(\"entered mobile state\")\n },\n exit: function(){}\n }),\n stationary: Ember.State.create({\n enter: function(){},\n exit: function(){}\n })\n })\n })\n\n\n robotManager.get('currentState.path') // 'poweredDown'\n robotManager.transitionTo('charged')\n // logs 'entered charged state'\n // but does *not* log 'exited poweredDown state'\n robotManager.get('currentState.name') // 'charged\n\n robotManager.transitionTo('poweredUp.mobile')\n // logs\n // 'exited charged state'\n // 'exited poweredDown state'\n // 'entered poweredUp state'\n // 'entered mobile state'\n ```\n\n During development you can set a StateManager's `enableLogging` property to\n `true` to receive console messages of state transitions.\n\n ```javascript\n robotManager = Ember.StateManager.create({\n enableLogging: true\n })\n ```\n\n ## Managing currentState with Actions\n\n To control which transitions are possible for a given state, and\n appropriately handle external events, the StateManager can receive and\n route action messages to its states via the `send` method. Calling to\n `send` with an action name will begin searching for a method with the same\n name starting at the current state and moving up through the parent states\n in a state hierarchy until an appropriate method is found or the StateManager\n instance itself is reached.\n\n If an appropriately named method is found it will be called with the state\n manager as the first argument and an optional `context` object as the second\n argument.\n\n ```javascript\n managerA = Ember.StateManager.create({\n initialState: 'stateOne.substateOne.subsubstateOne',\n stateOne: Ember.State.create({\n substateOne: Ember.State.create({\n anAction: function(manager, context){\n console.log(\"an action was called\")\n },\n subsubstateOne: Ember.State.create({})\n })\n })\n })\n\n managerA.get('currentState.name') // 'subsubstateOne'\n managerA.send('anAction')\n // 'stateOne.substateOne.subsubstateOne' has no anAction method\n // so the 'anAction' method of 'stateOne.substateOne' is called\n // and logs \"an action was called\"\n // with managerA as the first argument\n // and no second argument\n\n someObject = {}\n managerA.send('anAction', someObject)\n // the 'anAction' method of 'stateOne.substateOne' is called again\n // with managerA as the first argument and\n // someObject as the second argument.\n ```\n\n If the StateManager attempts to send an action but does not find an appropriately named\n method in the current state or while moving upwards through the state hierarchy, it will\n repeat the process looking for a `unhandledEvent` method. If an `unhandledEvent` method is\n found, it will be called with the original event name as the second argument. If an\n `unhandledEvent` method is not found, the StateManager will throw a new Ember.Error.\n\n ```javascript\n managerB = Ember.StateManager.create({\n initialState: 'stateOne.substateOne.subsubstateOne',\n stateOne: Ember.State.create({\n substateOne: Ember.State.create({\n subsubstateOne: Ember.State.create({}),\n unhandledEvent: function(manager, eventName, context) {\n console.log(\"got an unhandledEvent with name \" + eventName);\n }\n })\n })\n })\n\n managerB.get('currentState.name') // 'subsubstateOne'\n managerB.send('anAction')\n // neither `stateOne.substateOne.subsubstateOne` nor any of it's\n // parent states have a handler for `anAction`. `subsubstateOne`\n // also does not have a `unhandledEvent` method, but its parent\n // state, `substateOne`, does, and it gets fired. It will log\n // \"got an unhandledEvent with name anAction\"\n ```\n\n Action detection only moves upwards through the state hierarchy from the current state.\n It does not search in other portions of the hierarchy.\n\n ```javascript\n managerC = Ember.StateManager.create({\n initialState: 'stateOne.substateOne.subsubstateOne',\n stateOne: Ember.State.create({\n substateOne: Ember.State.create({\n subsubstateOne: Ember.State.create({})\n })\n }),\n stateTwo: Ember.State.create({\n anAction: function(manager, context){\n // will not be called below because it is\n // not a parent of the current state\n }\n })\n })\n\n managerC.get('currentState.name') // 'subsubstateOne'\n managerC.send('anAction')\n // Error: <Ember.StateManager:ember132> could not\n // respond to event anAction in state stateOne.substateOne.subsubstateOne.\n ```\n\n Inside of an action method the given state should delegate `transitionTo` calls on its\n StateManager.\n\n ```javascript\n robotManager = Ember.StateManager.create({\n initialState: 'poweredDown.charging',\n poweredDown: Ember.State.create({\n charging: Ember.State.create({\n chargeComplete: function(manager, context){\n manager.transitionTo('charged')\n }\n }),\n charged: Ember.State.create({\n boot: function(manager, context){\n manager.transitionTo('poweredUp')\n }\n })\n }),\n poweredUp: Ember.State.create({\n beginExtermination: function(manager, context){\n manager.transitionTo('rampaging')\n },\n rampaging: Ember.State.create()\n })\n })\n\n robotManager.get('currentState.name') // 'charging'\n robotManager.send('boot') // throws error, no boot action\n // in current hierarchy\n robotManager.get('currentState.name') // remains 'charging'\n\n robotManager.send('beginExtermination') // throws error, no beginExtermination\n // action in current hierarchy\n robotManager.get('currentState.name') // remains 'charging'\n\n robotManager.send('chargeComplete')\n robotManager.get('currentState.name') // 'charged'\n\n robotManager.send('boot')\n robotManager.get('currentState.name') // 'poweredUp'\n\n robotManager.send('beginExtermination', allHumans)\n robotManager.get('currentState.name') // 'rampaging'\n ```\n\n Transition actions can also be created using the `transitionTo` method of the `Ember.State` class. The\n following example StateManagers are equivalent:\n\n ```javascript\n aManager = Ember.StateManager.create({\n stateOne: Ember.State.create({\n changeToStateTwo: Ember.State.transitionTo('stateTwo')\n }),\n stateTwo: Ember.State.create({})\n })\n\n bManager = Ember.StateManager.create({\n stateOne: Ember.State.create({\n changeToStateTwo: function(manager, context){\n manager.transitionTo('stateTwo', context)\n }\n }),\n stateTwo: Ember.State.create({})\n })\n ```\n\n @class StateManager\n @namespace Ember\n @extends Ember.State\n**/\nEmber.StateManager = Ember.State.extend({\n /**\n @private\n\n When creating a new statemanager, look for a default state to transition\n into. This state can either be named `start`, or can be specified using the\n `initialState` property.\n\n @method init\n */\n init: function() {\n this._super();\n\n set(this, 'stateMeta', Ember.Map.create());\n\n var initialState = get(this, 'initialState');\n\n if (!initialState && get(this, 'states.start')) {\n initialState = 'start';\n }\n\n if (initialState) {\n this.transitionTo(initialState);\n Ember.assert('Failed to transition to initial state \"' + initialState + '\"', !!get(this, 'currentState'));\n }\n },\n\n stateMetaFor: function(state) {\n var meta = get(this, 'stateMeta'),\n stateMeta = meta.get(state);\n\n if (!stateMeta) {\n stateMeta = {};\n meta.set(state, stateMeta);\n }\n\n return stateMeta;\n },\n\n setStateMeta: function(state, key, value) {\n return set(this.stateMetaFor(state), key, value);\n },\n\n getStateMeta: function(state, key) {\n return get(this.stateMetaFor(state), key);\n },\n\n /**\n The current state from among the manager's possible states. This property should\n not be set directly. Use `transitionTo` to move between states by name.\n\n @property currentState\n @type Ember.State\n */\n currentState: null,\n\n /**\n The path of the current state. Returns a string representation of the current\n state.\n\n @property currentPath\n @type String\n */\n currentPath: Ember.computed('currentState', function() {\n return get(this, 'currentState.path');\n }),\n\n /**\n The name of transitionEvent that this stateManager will dispatch\n\n @property transitionEvent\n @type String\n @default 'setup'\n */\n transitionEvent: 'setup',\n\n /**\n If set to true, `errorOnUnhandledEvents` will cause an exception to be\n raised if you attempt to send an event to a state manager that is not\n handled by the current state or any of its parent states.\n\n @property errorOnUnhandledEvents\n @type Boolean\n @default true\n */\n errorOnUnhandledEvent: true,\n\n send: function(event) {\n var contexts = [].slice.call(arguments, 1);\n Ember.assert('Cannot send event \"' + event + '\" while currentState is ' + get(this, 'currentState'), get(this, 'currentState'));\n return sendEvent.call(this, event, contexts, false);\n },\n unhandledEvent: function(manager, event) {\n if (get(this, 'errorOnUnhandledEvent')) {\n throw new Ember.Error(this.toString() + \" could not respond to event \" + event + \" in state \" + get(this, 'currentState.path') + \".\");\n }\n },\n\n /**\n Finds a state by its state path.\n\n Example:\n\n ```javascript\n manager = Ember.StateManager.create({\n root: Ember.State.create({\n dashboard: Ember.State.create()\n })\n });\n\n manager.getStateByPath(manager, \"root.dashboard\")\n\n // returns the dashboard state\n ```\n\n @method getStateByPath\n @param {Ember.State} root the state to start searching from\n @param {String} path the state path to follow\n @return {Ember.State} the state at the end of the path\n */\n getStateByPath: function(root, path) {\n var parts = path.split('.'),\n state = root;\n\n for (var i=0, len=parts.length; i<len; i++) {\n state = get(get(state, 'states'), parts[i]);\n if (!state) { break; }\n }\n\n return state;\n },\n\n findStateByPath: function(state, path) {\n var possible;\n\n while (!possible && state) {\n possible = this.getStateByPath(state, path);\n state = get(state, 'parentState');\n }\n\n return possible;\n },\n\n /**\n A state stores its child states in its `states` hash.\n This code takes a path like `posts.show` and looks\n up `root.states.posts.states.show`.\n\n It returns a list of all of the states from the\n root, which is the list of states to call `enter`\n on.\n\n @method getStatesInPath\n @param root\n @param path\n */\n getStatesInPath: function(root, path) {\n if (!path || path === \"\") { return undefined; }\n var parts = path.split('.'),\n result = [],\n states,\n state;\n\n for (var i=0, len=parts.length; i<len; i++) {\n states = get(root, 'states');\n if (!states) { return undefined; }\n state = get(states, parts[i]);\n if (state) { root = state; result.push(state); }\n else { return undefined; }\n }\n\n return result;\n },\n\n goToState: function() {\n // not deprecating this yet so people don't constantly need to\n // make trivial changes for little reason.\n return this.transitionTo.apply(this, arguments);\n },\n\n transitionTo: function(path, context) {\n // XXX When is transitionTo called with no path\n if (Ember.isEmpty(path)) { return; }\n\n // The ES6 signature of this function is `path, ...contexts`\n var contexts = context ? Array.prototype.slice.call(arguments, 1) : [],\n currentState = get(this, 'currentState') || this;\n\n // First, get the enter, exit and resolve states for the current state\n // and specified path. If possible, use an existing cache.\n var hash = this.contextFreeTransition(currentState, path);\n\n // Next, process the raw state information for the contexts passed in.\n var transition = new Transition(hash).normalize(this, contexts);\n\n this.enterState(transition);\n this.triggerSetupContext(transition);\n },\n\n contextFreeTransition: function(currentState, path) {\n var cache = currentState.pathsCache[path];\n if (cache) { return cache; }\n\n var enterStates = this.getStatesInPath(currentState, path),\n exitStates = [],\n resolveState = currentState;\n\n // Walk up the states. For each state, check whether a state matching\n // the `path` is nested underneath. This will find the closest\n // parent state containing `path`.\n //\n // This allows the user to pass in a relative path. For example, for\n // the following state hierarchy:\n //\n // | |root\n // | |- posts\n // | | |- show (* current)\n // | |- comments\n // | | |- show\n //\n // If the current state is `<root.posts.show>`, an attempt to\n // transition to `comments.show` will match `<root.comments.show>`.\n //\n // First, this code will look for root.posts.show.comments.show.\n // Next, it will look for root.posts.comments.show. Finally,\n // it will look for `root.comments.show`, and find the state.\n //\n // After this process, the following variables will exist:\n //\n // * resolveState: a common parent state between the current\n // and target state. In the above example, `<root>` is the\n // `resolveState`.\n // * enterStates: a list of all of the states represented\n // by the path from the `resolveState`. For example, for\n // the path `root.comments.show`, `enterStates` would have\n // `[<root.comments>, <root.comments.show>]`\n // * exitStates: a list of all of the states from the\n // `resolveState` to the `currentState`. In the above\n // example, `exitStates` would have\n // `[<root.posts>`, `<root.posts.show>]`.\n while (resolveState && !enterStates) {\n exitStates.unshift(resolveState);\n\n resolveState = get(resolveState, 'parentState');\n if (!resolveState) {\n enterStates = this.getStatesInPath(this, path);\n if (!enterStates) {\n Ember.assert('Could not find state for path: \"'+path+'\"');\n return;\n }\n }\n enterStates = this.getStatesInPath(resolveState, path);\n }\n\n // If the path contains some states that are parents of both the\n // current state and the target state, remove them.\n //\n // For example, in the following hierarchy:\n //\n // |- root\n // | |- post\n // | | |- index (* current)\n // | | |- show\n //\n // If the `path` is `root.post.show`, the three variables will\n // be:\n //\n // * resolveState: `<state manager>`\n // * enterStates: `[<root>, <root.post>, <root.post.show>]`\n // * exitStates: `[<root>, <root.post>, <root.post.index>]`\n //\n // The goal of this code is to remove the common states, so we\n // have:\n //\n // * resolveState: `<root.post>`\n // * enterStates: `[<root.post.show>]`\n // * exitStates: `[<root.post.index>]`\n //\n // This avoid unnecessary calls to the enter and exit transitions.\n while (enterStates.length > 0 && enterStates[0] === exitStates[0]) {\n resolveState = enterStates.shift();\n exitStates.shift();\n }\n\n // Cache the enterStates, exitStates, and resolveState for the\n // current state and the `path`.\n var transitions = currentState.pathsCache[path] = {\n exitStates: exitStates,\n enterStates: enterStates,\n resolveState: resolveState\n };\n\n return transitions;\n },\n\n triggerSetupContext: function(transitions) {\n var contexts = transitions.contexts,\n offset = transitions.enterStates.length - contexts.length,\n enterStates = transitions.enterStates,\n transitionEvent = get(this, 'transitionEvent');\n\n Ember.assert(\"More contexts provided than states\", offset >= 0);\n\n arrayForEach.call(enterStates, function(state, idx) {\n state.trigger(transitionEvent, this, contexts[idx-offset]);\n }, this);\n },\n\n getState: function(name) {\n var state = get(this, name),\n parentState = get(this, 'parentState');\n\n if (state) {\n return state;\n } else if (parentState) {\n return parentState.getState(name);\n }\n },\n\n enterState: function(transition) {\n var log = this.enableLogging;\n\n var exitStates = transition.exitStates.slice(0).reverse();\n arrayForEach.call(exitStates, function(state) {\n state.trigger('exit', this);\n }, this);\n\n arrayForEach.call(transition.enterStates, function(state) {\n if (log) { Ember.Logger.log(\"STATEMANAGER: Entering \" + get(state, 'path')); }\n state.trigger('enter', this);\n }, this);\n\n set(this, 'currentState', transition.finalState);\n }\n});\n\n})();\n\n\n\n(function() {\n/**\nEmber States\n\n@module ember\n@submodule ember-states\n@requires ember-runtime\n*/\n\n})();\n\n\n})();\n// Version: v1.0.0-pre.2-233-g2db13c3\n// Last commit: 2db13c3 (2012-12-30 16:18:06 -0800)\n\n\n(function() {\n/**\nEmber\n\n@module ember\n*/\n\n})();\n\n\n})();\n//@ sourceURL=ember");