4 lines
87 KiB
JavaScript
4 lines
87 KiB
JavaScript
(function(){"use strict";var e=Ember.get;var r=["description","fileName","lineNumber","message","name","number","stack"];function t(e){var t=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(e));this.errors=e;for(var i=0,n=r.length;i<n;i++){this[r[i]]=t[r[i]]}}t.prototype=Ember.create(Error.prototype);var i=Ember.Object.extend({find:null,findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(r,t){var i=r._createSnapshot();return e(r,"store").serializerFor(i.typeKey).serialize(i,t)},createRecord:null,updateRecord:null,deleteRecord:null,coalesceFindRequests:true,groupRecordsForFindMany:function(e,r){return[r]}});var n=i;var a=Ember.get;var o=Ember.String.fmt;var s=Ember.EnumerableUtils.indexOf;var u=0;var c=n.extend({serializer:null,coalesceFindRequests:false,simulateRemoteResponse:true,latency:50,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if(r!=="number"&&r!=="string"){throw new Error(o("the id property must be defined as a number or string for fixture %@",[e]))}e.id=e.id+"";return e})}return null},queryFixtures:function(e,r,t){},updateFixtures:function(e,r){if(!e.FIXTURES){e.FIXTURES=[]}var t=e.FIXTURES;this.deleteLoadedFixture(e,r);t.push(r)},mockJSON:function(e,r,t){return e.serializerFor(t.typeKey).serialize(t,{includeId:true})},generateIdForRecord:function(e){return"fixture-"+u++},find:function(e,r,t,i){var n=this.fixturesForType(r);var a;if(n){a=Ember.A(n).findBy("id",t)}if(a){return this.simulateRemoteCall(function(){return a},this)}},findMany:function(e,r,t,i){var n=this.fixturesForType(r);if(n){n=n.filter(function(e){return s(t,e.id)!==-1})}if(n){return this.simulateRemoteCall(function(){return n},this)}},findAll:function(e,r){var t=this.fixturesForType(r);return this.simulateRemoteCall(function(){return t},this)},findQuery:function(e,r,t,i){var n=this.fixturesForType(r);n=this.queryFixtures(n,t,r);if(n){return this.simulateRemoteCall(function(){return n},this)}},createRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},updateRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},deleteRecord:function(e,r,t){this.deleteLoadedFixture(r,t);return this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(e,r){var t=this.findExistingFixture(e,r);if(t){var i=s(e.FIXTURES,t);e.FIXTURES.splice(i,1);return true}},findExistingFixture:function(e,r){var t=this.fixturesForType(e);var i=r.id;return this.findFixtureById(t,i)},findFixtureById:function(e,r){return Ember.A(e).find(function(e){if(""+a(e,"id")===""+r){return true}else{return false}})},simulateRemoteCall:function(e,r){var t=this;return new Ember.RSVP.Promise(function(i){var n=Ember.copy(e.call(r),true);if(a(t,"simulateRemoteResponse")){Ember.run.later(function(){i(n)},a(t,"latency"))}else{Ember.run.schedule("actions",null,function(){i(n)})}},"DS: FixtureAdapter#simulateRemoteCall")}});var l=Ember.Map;var d=Ember.MapWithDefault;var h=l;var f=Ember.get;var p=Ember.Mixin.create({buildURL:function(e,r,t){var i=[];var n=f(this,"host");var a=this.urlPrefix();if(e){i.push(this.pathForType(e))}if(r&&!Ember.isArray(r)){i.push(encodeURIComponent(r))}if(a){i.unshift(a)}i=i.join("/");if(!n&&i){i="/"+i}return i},urlPrefix:function(e,r){var t=f(this,"host");var i=f(this,"namespace");var n=[];if(e){if(/^\/\//.test(e)){}else if(e.charAt(0)==="/"){if(t){e=e.slice(1);n.push(t)}}else if(!/^http(s)?:\/\//.test(e)){n.push(r)}}else{if(t){n.push(t)}if(i){n.push(i)}}if(e){n.push(e)}return n.join("/")},pathForType:function(e){var r=Ember.String.camelize(e);return Ember.String.pluralize(r)}});var m=Ember.get;var v=Ember.ArrayPolyfills.forEach;var y=i.extend(p,{defaultSerializer:"-rest",sortQueryParams:function(e){var r=Ember.keys(e);var t=r.length;if(t<2){return e}var i={};var n=r.sort();for(var a=0;a<t;a++){i[n[a]]=e[n[a]]}return i},coalesceFindRequests:false,find:function(e,r,t,i){return this.ajax(this.buildURL(r.typeKey,t,i),"GET")},findAll:function(e,r,t){var i;if(t){i={since:t}}return this.ajax(this.buildURL(r.typeKey),"GET",{data:i})},findQuery:function(e,r,t){if(this.sortQueryParams){t=this.sortQueryParams(t)}return this.ajax(this.buildURL(r.typeKey),"GET",{data:t})},findMany:function(e,r,t,i){return this.ajax(this.buildURL(r.typeKey,t,i),"GET",{data:{ids:t}})},findHasMany:function(e,r,t,i){var n=m(this,"host");var a=r.id;var o=r.typeKey;if(n&&t.charAt(0)==="/"&&t.charAt(1)!=="/"){t=n+t}return this.ajax(this.urlPrefix(t,this.buildURL(o,a)),"GET")},findBelongsTo:function(e,r,t,i){var n=r.id;var a=r.typeKey;return this.ajax(this.urlPrefix(t,this.buildURL(a,n)),"GET")},createRecord:function(e,r,t){var i={};var n=e.serializerFor(r.typeKey);n.serializeIntoHash(i,r,t,{includeId:true});return this.ajax(this.buildURL(r.typeKey,null,t),"POST",{data:i})},updateRecord:function(e,r,t){var i={};var n=e.serializerFor(r.typeKey);n.serializeIntoHash(i,r,t);var a=t.id;return this.ajax(this.buildURL(r.typeKey,a,t),"PUT",{data:i})},deleteRecord:function(e,r,t){var i=t.id;return this.ajax(this.buildURL(r.typeKey,i,t),"DELETE")},_stripIDFromURL:function(e,r){var t=this.buildURL(r.typeKey,r.id,r);var i=t.split("/");var n=i[i.length-1];var a=r.id;if(n===a){i[i.length-1]=""}else if(b(n,"?id="+a)){i[i.length-1]=n.substring(0,n.length-a.length-1)}return i.join("/")},maxUrlLength:2048,groupRecordsForFindMany:function(e,r){var t=d.create({defaultValue:function(){return[]}});var i=this;var n=this.maxUrlLength;v.call(r,function(r){var n=i._stripIDFromURL(e,r);t.get(n).push(r)});function a(r,t,n){var a=i._stripIDFromURL(e,r[0]);var o=0;var s=[[]];v.call(r,function(e){var r=encodeURIComponent(e.id).length+n;if(a.length+o+r>=t){o=0;s.push([])}o+=r;var i=s.length-1;s[i].push(e)});return s}var o=[];t.forEach(function(e,r){var t="&ids%5B%5D=".length;var i=a(e,n,t);v.call(i,function(e){o.push(e)})});return o},ajaxError:function(e,r,t){var i=e!==null&&typeof e==="object";if(i){e.then=null;if(!e.errorThrown){if(typeof t==="string"){e.errorThrown=new Error(t)}else{e.errorThrown=t}}}return e},ajaxSuccess:function(e,r){return r},ajax:function(e,r,i){var n=this;return new Ember.RSVP.Promise(function(a,o){var s=n.ajaxOptions(e,r,i);s.success=function(e,r,i){e=n.ajaxSuccess(i,e);if(e instanceof t){Ember.run(null,o,e)}else{Ember.run(null,a,e)}};s.error=function(e,r,t){Ember.run(null,o,n.ajaxError(e,e.responseText,t))};Ember.$.ajax(s)},"DS: RESTAdapter#ajax "+r+" to "+e)},ajaxOptions:function(e,r,t){var i=t||{};i.url=e;i.type=r;i.dataType="json";i.context=this;if(i.data&&r!=="GET"){i.contentType="application/json; charset=utf-8";i.data=JSON.stringify(i.data)}var n=m(this,"headers");if(n!==undefined){i.beforeSend=function(e){v.call(Ember.keys(n),function(r){e.setRequestHeader(r,n[r])})}}return i}});function b(e,r){if(typeof String.prototype.endsWith!=="function"){return e.indexOf(r,e.length-r.length)!==-1}else{return e.endsWith(r)}}var g=self.Ember;var R=g.String.capitalize;var E=/^\s*$/;var _=/(\w+[_-])([a-z\d]+$)/;var F=/(\w+)([A-Z][a-z\d]*$)/;var A=/[A-Z][a-z\d]*$/;function S(e,r){for(var t=0,i=r.length;t<i;t++){e.uncountable[r[t].toLowerCase()]=true}}function z(e,r){var t;for(var i=0,n=r.length;i<n;i++){t=r[i];e.irregular[t[0].toLowerCase()]=t[1];e.irregular[t[1].toLowerCase()]=t[1];e.irregularInverse[t[1].toLowerCase()]=t[0];e.irregularInverse[t[0].toLowerCase()]=t[0]}}function T(e){e=e||{};e.uncountable=e.uncountable||k();e.irregularPairs=e.irregularPairs||k();var r=this.rules={plurals:e.plurals||[],singular:e.singular||[],irregular:k(),irregularInverse:k(),uncountable:k()};S(r,e.uncountable);z(r,e.irregularPairs);this.enableCache()}if(!Object.create&&!Object.create(null).hasOwnProperty){throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg")}function k(){var e=Object.create(null);e["_dict"]=null;delete e["_dict"];return e}T.prototype={enableCache:function(){this.purgeCache();this.singularize=function(e){this._cacheUsed=true;return this._sCache[e]||(this._sCache[e]=this._singularize(e))};this.pluralize=function(e){this._cacheUsed=true;return this._pCache[e]||(this._pCache[e]=this._pluralize(e))}},purgeCache:function(){this._cacheUsed=false;this._sCache=k();this._pCache=k()},disableCache:function(){this._sCache=null;this._pCache=null;this.singularize=function(e){return this._singularize(e)};this.pluralize=function(e){return this._pluralize(e)}},plural:function(e,r){if(this._cacheUsed){this.purgeCache()}this.rules.plurals.push([e,r.toLowerCase()])},singular:function(e,r){if(this._cacheUsed){this.purgeCache()}this.rules.singular.push([e,r.toLowerCase()])},uncountable:function(e){if(this._cacheUsed){this.purgeCache()}S(this.rules,[e.toLowerCase()])},irregular:function(e,r){if(this._cacheUsed){this.purgeCache()}z(this.rules,[[e,r]])},pluralize:function(e){return this._pluralize(e)},_pluralize:function(e){return this.inflect(e,this.rules.plurals,this.rules.irregular)},singularize:function(e){return this._singularize(e)},_singularize:function(e){return this.inflect(e,this.rules.singular,this.rules.irregularInverse)},inflect:function(e,r,t){var i,n,a,o,s,u,c,l,d,h,f,p;l=E.test(e);d=A.test(e);u="";if(l){return e}o=e.toLowerCase();s=_.exec(e)||F.exec(e);if(s){u=s[1];c=s[2].toLowerCase()}h=this.rules.uncountable[o]||this.rules.uncountable[c];if(h){return e}f=t&&(t[o]||t[c]);if(f){if(t[o]){return f}else{f=d?R(f):f;return u+f}}for(var m=r.length,v=0;m>v;m--){i=r[m-1];p=i[0];if(p.test(e)){break}}i=i||[];p=i[0];n=i[1];a=e.replace(p,n);return a}};var C=T;function M(e){return C.inflector.pluralize(e)}function x(e){return C.inflector.singularize(e)}var w={plurals:[[/$/,"s"],[/s$/i,"s"],[/^(ax|test)is$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(octop|vir)i$/i,"$1i"],[/(alias|status)$/i,"$1es"],[/(bu)s$/i,"$1ses"],[/(buffal|tomat)o$/i,"$1oes"],[/([ti])um$/i,"$1a"],[/([ti])a$/i,"$1a"],[/sis$/i,"ses"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/(hive)$/i,"$1s"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(x|ch|ss|sh)$/i,"$1es"],[/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"],[/^(m|l)ouse$/i,"$1ice"],[/^(m|l)ice$/i,"$1ice"],[/^(ox)$/i,"$1en"],[/^(oxen)$/i,"$1"],[/(quiz)$/i,"$1zes"]],singular:[[/s$/i,""],[/(ss)$/i,"$1"],[/(n)ews$/i,"$1ews"],[/([ti])a$/i,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"],[/(^analy)(sis|ses)$/i,"$1sis"],[/([^f])ves$/i,"$1fe"],[/(hive)s$/i,"$1"],[/(tive)s$/i,"$1"],[/([lr])ves$/i,"$1f"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/(s)eries$/i,"$1eries"],[/(m)ovies$/i,"$1ovie"],[/(x|ch|ss|sh)es$/i,"$1"],[/^(m|l)ice$/i,"$1ouse"],[/(bus)(es)?$/i,"$1"],[/(o)es$/i,"$1"],[/(shoe)s$/i,"$1"],[/(cris|test)(is|es)$/i,"$1is"],[/^(a)x[ie]s$/i,"$1xis"],[/(octop|vir)(us|i)$/i,"$1us"],[/(alias|status)(es)?$/i,"$1"],[/^(ox)en/i,"$1"],[/(vert|ind)ices$/i,"$1ex"],[/(matr)ices$/i,"$1ix"],[/(quiz)zes$/i,"$1"],[/(database)s$/i,"$1"]],irregularPairs:[["person","people"],["man","men"],["child","children"],["sex","sexes"],["move","moves"],["cow","kine"],["zombie","zombies"]],uncountable:["equipment","information","rice","money","species","series","fish","sheep","jeans","police"]};C.inflector=new C(w);function D(e,r){g.HTMLBars.helpers[e]=r}function P(e,r){g.HTMLBars.registerHelper(e,r)}function O(e,r){g.HTMLBars._registerHelper(e,r)}function I(e,r){if(g.HTMLBars){var t=g.HTMLBars.makeBoundHelper(r);if(g.HTMLBars._registerHelper){if(g.HTMLBars.helpers){D(e,t)}else{O(e,t)}}else if(g.HTMLBars.registerHelper){P(e,t)}}else if(g.Handlebars){g.Handlebars.helper(e,r)}}var $=I;$("singularize",function(e){return x(e[0])});$("pluralize",function(e){var r,t;if(e.length===1){t=e[0];return M(t)}else{r=e[0];t=e[1];if(r!==1){t=M(t)}return r+" "+t}});if(g.EXTEND_PROTOTYPES===true||g.EXTEND_PROTOTYPES.String){String.prototype.pluralize=function(){return M(this)};String.prototype.singularize=function(){return x(this)}}C.defaultRules=w;g.Inflector=C;g.String.pluralize=M;g.String.singularize=x;var L=C;if(typeof define!=="undefined"&&define.amd){define("ember-inflector",["exports"],function(e){e["default"]=C;return C})}else if(typeof module!=="undefined"&&module["exports"]){module["exports"]=C}var K=Ember.String.decamelize;var j=Ember.String.underscore;var B=y.extend({defaultSerializer:"-active-model",pathForType:function(e){var r=K(e);var t=j(r);return M(t)},ajaxError:function(e){var r=this._super.apply(this,arguments);if(e&&e.status===422){return new t(Ember.$.parseJSON(e.responseText))}else{return r}}});var U=B;var N=Ember.Object.extend({extract:null,serialize:null,normalize:function(e,r){return r}});var H=N;var V=Ember.get;var W=Ember.isNone;var q=Ember.ArrayPolyfills.map;var Q=Ember.merge;var X=H.extend({primaryKey:"id",applyTransforms:function(e,r){e.eachTransformedAttribute(function t(e,i){if(!r.hasOwnProperty(e)){return}var n=this.transformFor(i);r[e]=n.deserialize(r[e])},this);return r},normalize:function(e,r){if(!r){return r}this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r);this.normalizeUsingDeclaredMapping(e,r);this.applyTransforms(e,r);return r},normalizePayload:function(e){return e},normalizeAttributes:function(e,r){var t;if(this.keyForAttribute){e.eachAttribute(function(e){t=this.keyForAttribute(e);if(e===t){return}if(!r.hasOwnProperty(t)){return}r[e]=r[t];delete r[t]},this)}},normalizeRelationships:function(e,r){var t;if(this.keyForRelationship){e.eachRelationship(function(e,i){t=this.keyForRelationship(e,i.kind);if(e===t){return}if(!r.hasOwnProperty(t)){return}r[e]=r[t];delete r[t]},this)}},normalizeUsingDeclaredMapping:function(e,r){var t=V(this,"attrs");var i,n;if(t){for(n in t){i=this._getMappedKey(n);if(!r.hasOwnProperty(i)){continue}if(i!==n){r[n]=r[i];delete r[i]}}}},normalizeId:function(e){var r=V(this,"primaryKey");if(r==="id"){return}e.id=e[r];delete e[r]},normalizeErrors:function(e,r){this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r)},_getMappedKey:function(e){var r=V(this,"attrs");var t;if(r&&r[e]){t=r[e];if(t.key){t=t.key}if(typeof t==="string"){e=t}}return e},_canSerialize:function(e){var r=V(this,"attrs");return!r||!r[e]||r[e].serialize!==false},serialize:function(e,r){var t={};if(r&&r.includeId){var i=e.id;if(i){t[V(this,"primaryKey")]=i}}e.eachAttribute(function(r,i){this.serializeAttribute(e,t,r,i)},this);e.eachRelationship(function(r,i){if(i.kind==="belongsTo"){this.serializeBelongsTo(e,t,i)}else if(i.kind==="hasMany"){this.serializeHasMany(e,t,i)}},this);return t},serializeIntoHash:function(e,r,t,i){Q(e,this.serialize(t,i))},serializeAttribute:function(e,r,t,i){var n=i.type;if(this._canSerialize(t)){var a=e.attr(t);if(n){var o=this.transformFor(n);a=o.serialize(a)}var s=this._getMappedKey(t);if(s===t&&this.keyForAttribute){s=this.keyForAttribute(t)}r[s]=a}},serializeBelongsTo:function(e,r,t){var i=t.key;if(this._canSerialize(i)){var n=e.belongsTo(i,{id:true});var a=this._getMappedKey(i);if(a===i&&this.keyForRelationship){a=this.keyForRelationship(i,"belongsTo")}if(W(n)){r[a]=null}else{r[a]=n}if(t.options.polymorphic){this.serializePolymorphicType(e,r,t)}}},serializeHasMany:function(e,r,t){var i=t.key;if(this._canSerialize(i)){var n;n=this._getMappedKey(i);if(n===i&&this.keyForRelationship){n=this.keyForRelationship(i,"hasMany")}var a=e.type.determineRelationshipType(t);if(a==="manyToNone"||a==="manyToMany"){r[n]=e.hasMany(i,{ids:true})}}},serializePolymorphicType:Ember.K,extract:function(e,r,t,i,n){this.extractMeta(e,r,t);var a="extract"+n.charAt(0).toUpperCase()+n.substr(1);return this[a](e,r,t,i,n)},extractFindAll:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindQuery:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindMany:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractFindHasMany:function(e,r,t,i,n){return this.extractArray(e,r,t,i,n)},extractCreateRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractUpdateRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractDeleteRecord:function(e,r,t,i,n){return this.extractSave(e,r,t,i,n)},extractFind:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractFindBelongsTo:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractSave:function(e,r,t,i,n){return this.extractSingle(e,r,t,i,n)},extractSingle:function(e,r,t,i,n){t=this.normalizePayload(t);return this.normalize(r,t)},extractArray:function(e,r,t,i,n){var a=this.normalizePayload(t);var o=this;return q.call(a,function(e){return o.normalize(r,e)})},extractMeta:function(e,r,t){if(t&&t.meta){e.setMetadataFor(r,t.meta);delete t.meta}},extractErrors:function(e,r,t,i){if(t&&typeof t==="object"&&t.errors){t=t.errors;this.normalizeErrors(r,t)}return t},keyForAttribute:function(e){return e},keyForRelationship:function(e,r){return e},transformFor:function(e,r){var t=this.container.lookup("transform:"+e);return t}});var G=Ember.ArrayPolyfills.forEach;var J=Ember.ArrayPolyfills.map;var Y=Ember.String.camelize;function Z(e){return e==null?null:e+""}var ee=X.extend({normalize:function(e,r,t){this.normalizeId(r);this.normalizeAttributes(e,r);this.normalizeRelationships(e,r);this.normalizeUsingDeclaredMapping(e,r);if(this.normalizeHash&&this.normalizeHash[t]){this.normalizeHash[t](r)}this.applyTransforms(e,r);return r},extractSingle:function(e,r,t,i){var n=this.normalizePayload(t);var a=r.typeKey;var o;for(var s in n){var u=this.typeForRoot(s);if(!e.modelFactoryFor(u)){continue}var c=e.modelFor(u);var l=c.typeKey===a;var d=n[s];if(d===null){continue}if(l&&Ember.typeOf(d)!=="array"){o=this.normalize(r,d,s);continue}G.call(d,function(r){var t=this.typeForRoot(s);var n=e.modelFor(t);var a=e.serializerFor(n);r=a.normalize(n,r,s);var u=l&&!i&&!o;var c=l&&Z(r.id)===i;if(u||c){o=r}else{e.push(t,r)}},this)}return o},extractArray:function(e,r,t){var i=this.normalizePayload(t);var n=r.typeKey;var a;for(var o in i){var s=o;var u=false;if(o.charAt(0)==="_"){u=true;s=o.substr(1)}var c=this.typeForRoot(s);if(!e.modelFactoryFor(c)){continue}var l=e.modelFor(c);var d=e.serializerFor(l);var h=!u&&l.typeKey===n;var f=J.call(i[o],function(e){return d.normalize(l,e,o)},this);if(h){a=f}else{e.pushMany(c,f)}}return a},pushPayload:function(e,r){var t=this.normalizePayload(r);for(var i in t){var n=this.typeForRoot(i);if(!e.modelFactoryFor(n,i)){continue}var a=e.modelFor(n);var o=e.serializerFor(a);var s=J.call(Ember.makeArray(t[i]),function(e){return o.normalize(a,e,i)},this);e.pushMany(n,s)}},typeForRoot:function(e){return Y(x(e))},serialize:function(e,r){return this._super.apply(this,arguments)},serializeIntoHash:function(e,r,t,i){e[r.typeKey]=this.serialize(t,i)},serializePolymorphicType:function(e,r,t){var i=t.key;var n=e.belongsTo(i);i=this.keyForAttribute?this.keyForAttribute(i):i;if(Ember.isNone(n)){r[i+"Type"]=null}else{r[i+"Type"]=Ember.String.camelize(n.typeKey)}}});var re=ee;var te=Ember.EnumerableUtils.forEach;var ie=Ember.String.camelize;var ne=Ember.String.capitalize;var ae=Ember.String.decamelize;var oe=Ember.String.underscore;var se=re.extend({keyForAttribute:function(e){return ae(e)},keyForRelationship:function(e,r){var t=ae(e);if(r==="belongsTo"){return t+"_id"}else if(r==="hasMany"){return x(t)+"_ids"}else{return t}},serializeHasMany:Ember.K,serializeIntoHash:function(e,r,t,i){var n=oe(ae(r.typeKey));e[n]=this.serialize(t,i)},serializePolymorphicType:function(e,r,t){var i=t.key;var n=e.belongsTo(i);var a=oe(i+"_type");if(Ember.isNone(n)){r[a]=null}else{r[a]=ne(ie(n.typeKey))}},normalize:function(e,r,t){this.normalizeLinks(r);return this._super(e,r,t)},normalizeLinks:function(e){if(e.links){var r=e.links;for(var t in r){var i=ie(t);if(i!==t){r[i]=r[t];delete r[t]}}}},normalizeRelationships:function(e,r){if(this.keyForRelationship){e.eachRelationship(function(e,t){var i,n;if(t.options.polymorphic){i=this.keyForAttribute(e);n=r[i];if(n&&n.type){n.type=this.typeForRoot(n.type)}else if(n&&t.kind==="hasMany"){var a=this;te(n,function(e){e.type=a.typeForRoot(e.type)})}}else{i=this.keyForRelationship(e,t.kind);if(!r.hasOwnProperty(i)){return}n=r[i]}r[e]=n;if(e!==i){delete r[i]}},this)}}});var ue=se;function ce(e){this.container=e}ce.prototype.aliasedFactory=function(e,r){var t=this;return{create:function(){if(r){r()}return t.container.lookup(e)}}};ce.prototype.registerAlias=function(e,r,t){var i=this.aliasedFactory(r,t);return this.container.register(e,i)};ce.prototype.registerDeprecation=function(e,r){var t=function(){};return this.registerAlias(e,r,t)};ce.prototype.registerDeprecations=function(e){var r,t,i,n;for(r=e.length;r>0;r--){t=e[r-1];i=t["deprecated"];n=t["valid"];this.registerDeprecation(i,n)}};var le=ce;function de(e,r){var t=new le(e);t.registerDeprecations([{deprecated:"serializer:_ams",valid:"serializer:-active-model"},{deprecated:"adapter:_ams",valid:"adapter:-active-model"}]);e.register("serializer:-active-model",ue);e.register("adapter:-active-model",U)}var he=de;var fe=Ember.Namespace.create({VERSION:"1.0.0-beta.16.1"});if(Ember.libraries){Ember.libraries.registerCoreLibrary("Ember Data",fe.VERSION)}var pe=fe;var me=Ember.RSVP.Promise;var ve=Ember.get;var ye=Ember.ArrayProxy.extend(Ember.PromiseProxyMixin);var be=Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);var ge=function(e,r){return be.create({promise:me.resolve(e,r)})};var Re=function(e,r){return ye.create({promise:me.resolve(e,r)})};function Ee(e){return function(){var r=ve(this,"content");return r[e].apply(r,arguments)}}var _e=ye.extend({reload:function(){return _e.create({promise:ve(this,"content").reload()})},createRecord:Ee("createRecord"),on:Ee("on"),one:Ee("one"),trigger:Ee("trigger"),off:Ee("off"),has:Ee("has")});var Fe=function(e,r){return _e.create({promise:me.resolve(e,r)})};var Ae=Ember.get;function Se(e){var r=Array.prototype.slice.call(arguments,1);return function(){return e.apply(undefined,r)}}function ze(e,r){var t=e["finally"](function(){if(!r()){t._subscribers.length=0}});return t}function Te(e){return!(Ae(e,"isDestroyed")||Ae(e,"isDestroying"))}function ke(e,r,t){var i=r.serializer;if(i===undefined){i=e.serializerFor(t)}if(i===null||i===undefined){i={extract:function(e,r,t){return t}}}return i}var Ce=Ember.get;var Me=Ember.RSVP.Promise;function xe(e,r,t,i,n){var a=n._createSnapshot();var o=e.find(r,t,i,a);var s=ke(r,e,t);var u="DS: Handle Adapter#find of "+t+" with id: "+i;o=Me.cast(o,u);o=ze(o,Se(Te,r));return o.then(function(e){return r._adapterRun(function(){var n=s.extract(r,t,e,i,"find");return r.push(t,n)})},function(e){var n=r.getById(t,i);if(n){n.notFound();if(Ce(n,"isEmpty")){r.unloadRecord(n)}}throw e},"DS: Extract payload of '"+t+"'")}function we(e,r,t,i,n){var a=Ember.A(n).invoke("_createSnapshot");var o=e.findMany(r,t,i,a);var s=ke(r,e,t);var u="DS: Handle Adapter#findMany of "+t;if(o===undefined){throw new Error("adapter.findMany returned undefined, this was very likely a mistake")}o=Me.cast(o,u);o=ze(o,Se(Te,r));return o.then(function(e){return r._adapterRun(function(){var i=s.extract(r,t,e,null,"findMany");return r.pushMany(t,i)})},null,"DS: Extract payload of "+t)}function De(e,r,t,i,n){var a=t._createSnapshot();var o=e.findHasMany(r,a,i,n);var s=ke(r,e,n.type);var u="DS: Handle Adapter#findHasMany of "+t+" : "+n.type;o=Me.cast(o,u);o=ze(o,Se(Te,r));o=ze(o,Se(Te,t));return o.then(function(e){return r._adapterRun(function(){var t=s.extract(r,n.type,e,null,"findHasMany");var i=r.pushMany(n.type,t);return i})},null,"DS: Extract payload of "+t+" : hasMany "+n.type)}function Pe(e,r,t,i,n){var a=t._createSnapshot();var o=e.findBelongsTo(r,a,i,n);var s=ke(r,e,n.type);var u="DS: Handle Adapter#findBelongsTo of "+t+" : "+n.type;o=Me.cast(o,u);o=ze(o,Se(Te,r));o=ze(o,Se(Te,t));return o.then(function(e){return r._adapterRun(function(){var t=s.extract(r,n.type,e,null,"findBelongsTo");if(!t){return null}var i=r.push(n.type,t);return i})},null,"DS: Extract payload of "+t+" : "+n.type)}function Oe(e,r,t,i){var n=e.findAll(r,t,i);var a=ke(r,e,t);var o="DS: Handle Adapter#findAll of "+t;n=Me.cast(n,o);n=ze(n,Se(Te,r));return n.then(function(e){r._adapterRun(function(){var i=a.extract(r,t,e,null,"findAll");r.pushMany(t,i)});r.didUpdateAll(t);return r.all(t)},null,"DS: Extract payload of findAll "+t)}function Ie(e,r,t,i,n){var a=e.findQuery(r,t,i,n);var o=ke(r,e,t);var s="DS: Handle Adapter#findQuery of "+t;a=Me.cast(a,s);a=ze(a,Se(Te,r));return a.then(function(e){var i;r._adapterRun(function(){i=o.extract(r,t,e,null,"findQuery")});n.load(i);return n},null,"DS: Extract payload of findQuery "+t)}var $e=Ember.get;var Le=Ember.set;var Ke=Ember.ArrayProxy.extend(Ember.Evented,{type:null,content:null,isLoaded:false,isUpdating:false,store:null,objectAtContent:function(e){var r=$e(this,"content");return r.objectAt(e)},update:function(){if($e(this,"isUpdating")){return}var e=$e(this,"store");var r=$e(this,"type");return e.fetchAll(r,this)},addRecord:function(e,r){var t=$e(this,"content");if(r===undefined){t.addObject(e)}else if(!t.contains(e)){t.insertAt(r,e)}},_pushRecord:function(e){$e(this,"content").pushObject(e)},pushRecord:function(e){this._pushRecord(e)},removeRecord:function(e){$e(this,"content").removeObject(e)},save:function(){var e=this;var r="DS: RecordArray#save "+$e(this,"type");var t=Ember.RSVP.all(this.invoke("save"),r).then(function(r){return e},null,"DS: RecordArray#save return RecordArray");return ye.create({promise:t})},_dissociateFromOwnRecords:function(){var e=this;this.forEach(function(r){var t=r._recordArrays;if(t){t["delete"](e)}})},_unregisterFromManager:function(){var e=$e(this,"manager");if(e){e.unregisterFilteredRecordArray(this)}},willDestroy:function(){this._unregisterFromManager();this._dissociateFromOwnRecords();Le(this,"content",undefined);this._super.apply(this,arguments)}});var je=Ember.get;var Be=Ke.extend({filterFunction:null,isLoaded:true,replace:function(){var e=je(this,"type").toString();throw new Error("The result of a client-side filter (on "+e+") is immutable.")},_updateFilter:function(){var e=je(this,"manager");e.updateFilter(this,je(this,"type"),je(this,"filterFunction"))},updateFilter:Ember.observer(function(){Ember.run.once(this,this._updateFilter)},"filterFunction")});var Ue=Ember.get;function Ne(e){var r=Ember.create(null);for(var t in e){r[t]=e[t]}return r}var He=Ke.extend({query:null,replace:function(){var e=Ue(this,"type").toString();throw new Error("The result of a server query (on "+e+") is immutable.")},load:function(e){var r=Ue(this,"store");var t=Ue(this,"type");var i=r.pushMany(t,e);var n=r.metadataFor(t);this.setProperties({content:Ember.A(i),isLoaded:true,meta:Ne(n)});i.forEach(function(e){this.manager.recordArraysForRecord(e).add(this)},this);Ember.run.once(this,"trigger","didLoad")}});var Ve=Ember.OrderedSet;var We=Ember.guidFor;var qe=function(){this._super$constructor()};qe.create=function(){var e=this;return new e};qe.prototype=Ember.create(Ve.prototype);qe.prototype.constructor=qe;qe.prototype._super$constructor=Ve;qe.prototype.addWithIndex=function(e,r){var t=We(e);var i=this.presenceSet;var n=this.list;if(i[t]===true){return}i[t]=true;if(r===undefined||r==null){n.push(e)}else{n.splice(r,0,e)}this.size+=1;return this};var Qe=qe;var Xe=Ember.get;var Ge=Ember.EnumerableUtils.forEach;var Je=Ember.EnumerableUtils.indexOf;var Ye=Ember.Object.extend({init:function(){this.filteredRecordArrays=d.create({defaultValue:function(){return[]}});this.changedRecords=[];this._adapterPopulatedRecordArrays=[]},recordDidChange:function(e){if(this.changedRecords.push(e)!==1){return}Ember.run.schedule("actions",this,this.updateRecordArrays)},recordArraysForRecord:function(e){e._recordArrays=e._recordArrays||Qe.create();return e._recordArrays},updateRecordArrays:function(){Ge(this.changedRecords,function(e){if(Xe(e,"isDeleted")){this._recordWasDeleted(e)}else{this._recordWasChanged(e)}},this);this.changedRecords.length=0},_recordWasDeleted:function(e){var r=e._recordArrays;if(!r){return}r.forEach(function(r){r.removeRecord(e)});e._recordArrays=null},_recordWasChanged:function(e){var r=e.constructor;var t=this.filteredRecordArrays.get(r);var i;Ge(t,function(t){i=Xe(t,"filterFunction");if(i){this.updateRecordArray(t,i,r,e)}},this)},recordWasLoaded:function(e){var r=e.constructor;var t=this.filteredRecordArrays.get(r);var i;Ge(t,function(t){i=Xe(t,"filterFunction");this.updateRecordArray(t,i,r,e)},this)},updateRecordArray:function(e,r,t,i){var n;if(!r){n=true}else{n=r(i)}var a=this.recordArraysForRecord(i);if(n){if(!a.has(e)){e._pushRecord(i);a.add(e)}}else if(!n){a["delete"](e);e.removeRecord(i)}},updateFilter:function(e,r,t){var i=this.store.typeMapFor(r);var n=i.records;var a;for(var o=0,s=n.length;o<s;o++){a=n[o];if(!Xe(a,"isDeleted")&&!Xe(a,"isEmpty")){this.updateRecordArray(e,t,r,a)}}},createRecordArray:function(e){var r=Ke.create({type:e,content:Ember.A(),store:this.store,isLoaded:true,manager:this});this.registerFilteredRecordArray(r,e);return r},createFilteredRecordArray:function(e,r,t){var i=Be.create({query:t,type:e,content:Ember.A(),store:this.store,manager:this,filterFunction:r});this.registerFilteredRecordArray(i,e,r);return i},createAdapterPopulatedRecordArray:function(e,r){var t=He.create({type:e,query:r,content:Ember.A(),store:this.store,manager:this});this._adapterPopulatedRecordArrays.push(t);return t},registerFilteredRecordArray:function(e,r,t){var i=this.filteredRecordArrays.get(r);i.push(e);this.updateFilter(e,r,t)},unregisterFilteredRecordArray:function(e){var r=this.filteredRecordArrays.get(e.type);var t=Je(r,e);r.splice(t,1)},willDestroy:function(){this._super.apply(this,arguments);this.filteredRecordArrays.forEach(function(e){Ge(er(e),Ze)});Ge(this._adapterPopulatedRecordArrays,Ze)}});function Ze(e){e.destroy()}function er(e){var r=e.length;var t=Ember.A();for(var i=0;i<r;i++){t=t.concat(e[i])}return t}var rr=Ember.get;var tr=Ember.set;function ir(e,r){if(r.value===r.originalValue){delete e._attributes[r.name];e.send("propertyWasReset",r.name)}else if(r.value!==r.oldValue){e.send("becomeDirty")}e.updateRecordArraysLater()}var nr={initialState:"uncommitted",isDirty:true,uncommitted:{didSetProperty:ir,loadingData:Ember.K,propertyWasReset:function(e,r){var t=Ember.keys(e._attributes).length;var i=t>0;if(!i){e.send("rolledBack")}},pushedData:Ember.K,becomeDirty:Ember.K,willCommit:function(e){e.transitionTo("inFlight")},reloadRecord:function(e,r){r(rr(e,"store").reloadRecord(e))},rolledBack:function(e){e.transitionTo("loaded.saved")},becameInvalid:function(e){e.transitionTo("invalid")},rollback:function(e){e.rollback();e.triggerLater("ready")}},inFlight:{isSaving:true,didSetProperty:ir,becomeDirty:Ember.K,pushedData:Ember.K,unloadRecord:function(e){},willCommit:Ember.K,didCommit:function(e){var r=rr(this,"dirtyType");e.transitionTo("saved");e.send("invokeLifecycleCallbacks",r)},becameInvalid:function(e){e.transitionTo("invalid");e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted");e.triggerLater("becameError",e)}},invalid:{isValid:false,deleteRecord:function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()},didSetProperty:function(e,r){rr(e,"errors").remove(r.name);ir(e,r)},becomeDirty:Ember.K,willCommit:function(e){rr(e,"errors").clear();e.transitionTo("inFlight")},rolledBack:function(e){rr(e,"errors").clear();e.triggerLater("ready")},becameValid:function(e){e.transitionTo("uncommitted")},invokeLifecycleCallbacks:function(e){e.triggerLater("becameInvalid",e)},exit:function(e){e._inFlightAttributes={}}}};function ar(e){var r={};var t;for(var i in e){t=e[i];if(t&&typeof t==="object"){r[i]=ar(t)}else{r[i]=t}}return r}function or(e,r){for(var t in r){e[t]=r[t]}return e}function sr(e){var r=ar(nr);return or(r,e)}var ur=sr({dirtyType:"created",isNew:true});ur.uncommitted.rolledBack=function(e){e.transitionTo("deleted.saved")};var cr=sr({dirtyType:"updated"});ur.uncommitted.deleteRecord=function(e){e.disconnectRelationships();e.transitionTo("deleted.saved");e.send("invokeLifecycleCallbacks");
|
|
|
|
};ur.uncommitted.rollback=function(e){nr.uncommitted.rollback.apply(this,arguments);e.transitionTo("deleted.saved")};ur.uncommitted.pushedData=function(e){e.transitionTo("loaded.updated.uncommitted");e.triggerLater("didLoad")};ur.uncommitted.propertyWasReset=Ember.K;function lr(e){}cr.inFlight.unloadRecord=lr;cr.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()};var dr={isEmpty:false,isLoading:false,isLoaded:false,isDirty:false,isSaving:false,isDeleted:false,isNew:false,isValid:true,rolledBack:Ember.K,unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},propertyWasReset:Ember.K,empty:{isEmpty:true,loadingData:function(e,r){e._loadingPromise=r;e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted");e.triggerLater("ready")},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad");e.triggerLater("ready")}},loading:{isLoading:true,exit:function(e){e._loadingPromise=null},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad");e.triggerLater("ready");tr(e,"isError",false)},becameError:function(e){e.triggerLater("becameError",e)},notFound:function(e){e.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:true,loadingData:Ember.K,saved:{setup:function(e){var r=e._attributes;var t=Ember.keys(r).length>0;if(t){e.adapterDidDirty()}},didSetProperty:ir,pushedData:Ember.K,becomeDirty:function(e){e.transitionTo("updated.uncommitted")},willCommit:function(e){e.transitionTo("updated.inFlight")},reloadRecord:function(e,r){r(rr(e,"store").reloadRecord(e))},deleteRecord:function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()},unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},didCommit:function(e){e.send("invokeLifecycleCallbacks",rr(e,"lastDirtyType"))},notFound:Ember.K},created:ur,updated:cr},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:true,isLoaded:true,isDirty:true,setup:function(e){e.updateRecordArrays()},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback();e.triggerLater("ready")},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(e){e.transitionTo("loaded.saved");e.triggerLater("ready")}},inFlight:{isSaving:true,unloadRecord:lr,willCommit:Ember.K,didCommit:function(e){e.transitionTo("saved");e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted");e.triggerLater("becameError",e)},becameInvalid:function(e){e.transitionTo("invalid");e.triggerLater("becameInvalid",e)}},saved:{isDirty:false,setup:function(e){var r=rr(e,"store");r._dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.triggerLater("didDelete",e);e.triggerLater("didCommit",e)},willCommit:Ember.K,didCommit:Ember.K},invalid:{isValid:false,didSetProperty:function(e,r){rr(e,"errors").remove(r.name);ir(e,r)},deleteRecord:Ember.K,becomeDirty:Ember.K,willCommit:Ember.K,rolledBack:function(e){rr(e,"errors").clear();e.transitionTo("loaded.saved");e.triggerLater("ready")},becameValid:function(e){e.transitionTo("uncommitted")}}},invokeLifecycleCallbacks:function(e,r){if(r==="created"){e.triggerLater("didCreate",e)}else{e.triggerLater("didUpdate",e)}e.triggerLater("didCommit",e)}};function hr(e,r,t){e=or(r?Ember.create(r):{},e);e.parentState=r;e.stateName=t;for(var i in e){if(!e.hasOwnProperty(i)||i==="parentState"||i==="stateName"){continue}if(typeof e[i]==="object"){e[i]=hr(e[i],e,t+"."+i)}}return e}dr=hr(dr,null,"root");var fr=dr;var pr=Ember.get;var mr=Ember.isEmpty;var vr=Ember.EnumerableUtils.map;var yr=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(e,r,t){this.on("becameInvalid",e,r);this.on("becameValid",e,t)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return d.create({defaultValue:function(){return Ember.A()}})},addedItem:function(e,r){e.get(r.attribute).pushObject(r);return e},removedItem:function(e,r){e.get(r.attribute).removeObject(r);return e}}),errorsFor:function(e){return pr(this,"errorsByAttributeName").get(e)},messages:Ember.computed.mapBy("content","message"),content:Ember.computed(function(){return Ember.A()}),unknownProperty:function(e){var r=this.errorsFor(e);if(mr(r)){return null}return r},nextObject:function(e,r,t){return pr(this,"content").objectAt(e)},length:Ember.computed.oneWay("content.length").readOnly(),isEmpty:Ember.computed.not("length").readOnly(),add:function(e,r){var t=pr(this,"isEmpty");r=this._findOrCreateMessages(e,r);pr(this,"content").addObjects(r);this.notifyPropertyChange(e);this.enumerableContentDidChange();if(t&&!pr(this,"isEmpty")){this.trigger("becameInvalid")}},_findOrCreateMessages:function(e,r){var t=this.errorsFor(e);return vr(Ember.makeArray(r),function(r){return t.findBy("message",r)||{attribute:e,message:r}})},remove:function(e){if(pr(this,"isEmpty")){return}var r=pr(this,"content").rejectBy("attribute",e);pr(this,"content").setObjects(r);this.notifyPropertyChange(e);this.enumerableContentDidChange();if(pr(this,"isEmpty")){this.trigger("becameValid")}},clear:function(){if(pr(this,"isEmpty")){return}pr(this,"content").clear();this.enumerableContentDidChange();this.trigger("becameValid")},has:function(e){return!mr(this.errorsFor(e))}});function br(e,r){if(!r||typeof r!=="object"){return e}var t=Ember.keys(r);var i;var n=t.length;for(var a=0;a<n;a++){i=t[a];e[i]=r[i]}return e}var gr=br;var Rr=Ember.EnumerableUtils.forEach;var Er=function(e,r,t,i){this.members=new Qe;this.canonicalMembers=new Qe;this.store=e;this.key=i.key;this.inverseKey=t;this.record=r;this.isAsync=i.options.async;this.relationshipMeta=i;this.inverseKeyForImplicit=this.store.modelFor(this.record.constructor).typeKey+this.key;this.linkPromise=null};Er.prototype={constructor:Er,destroy:Ember.K,clear:function(){var e=this.members.list;var r;while(e.length>0){r=e[0];this.removeRecord(r)}},disconnect:function(){this.members.forEach(function(e){this.removeRecordFromInverse(e)},this)},reconnect:function(){this.members.forEach(function(e){this.addRecordToInverse(e)},this)},removeRecords:function(e){var r=this;Rr(e,function(e){r.removeRecord(e)})},addRecords:function(e,r){var t=this;Rr(e,function(e){t.addRecord(e,r);if(r!==undefined){r++}})},addCanonicalRecords:function(e,r){for(var t=0;t<e.length;t++){if(r!==undefined){this.addCanonicalRecord(e[t],t+r)}else{this.addCanonicalRecord(e[t])}}},addCanonicalRecord:function(e,r){if(!this.canonicalMembers.has(e)){this.canonicalMembers.add(e);if(this.inverseKey){e._relationships[this.inverseKey].addCanonicalRecord(this.record)}else{if(!e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit]=new Er(this.store,e,this.key,{options:{}})}e._implicitRelationships[this.inverseKeyForImplicit].addCanonicalRecord(this.record)}}this.flushCanonicalLater()},removeCanonicalRecords:function(e,r){for(var t=0;t<e.length;t++){if(r!==undefined){this.removeCanonicalRecord(e[t],t+r)}else{this.removeCanonicalRecord(e[t])}}},removeCanonicalRecord:function(e,r){if(this.canonicalMembers.has(e)){this.removeCanonicalRecordFromOwn(e);if(this.inverseKey){this.removeCanonicalRecordFromInverse(e)}else{if(e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit].removeCanonicalRecord(this.record)}}}this.flushCanonicalLater()},addRecord:function(e,r){if(!this.members.has(e)){this.members.addWithIndex(e,r);this.notifyRecordRelationshipAdded(e,r);if(this.inverseKey){e._relationships[this.inverseKey].addRecord(this.record)}else{if(!e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit]=new Er(this.store,e,this.key,{options:{}})}e._implicitRelationships[this.inverseKeyForImplicit].addRecord(this.record)}this.record.updateRecordArraysLater()}},removeRecord:function(e){if(this.members.has(e)){this.removeRecordFromOwn(e);if(this.inverseKey){this.removeRecordFromInverse(e)}else{if(e._implicitRelationships[this.inverseKeyForImplicit]){e._implicitRelationships[this.inverseKeyForImplicit].removeRecord(this.record)}}}},addRecordToInverse:function(e){if(this.inverseKey){e._relationships[this.inverseKey].addRecord(this.record)}},removeRecordFromInverse:function(e){var r=e._relationships[this.inverseKey];if(r){r.removeRecordFromOwn(this.record)}},removeRecordFromOwn:function(e){this.members["delete"](e);this.notifyRecordRelationshipRemoved(e);this.record.updateRecordArrays()},removeCanonicalRecordFromInverse:function(e){var r=e._relationships[this.inverseKey];if(r){r.removeCanonicalRecordFromOwn(this.record)}},removeCanonicalRecordFromOwn:function(e){this.canonicalMembers["delete"](e);this.flushCanonicalLater()},flushCanonical:function(){this.willSync=false;var e=[];for(var r=0;r<this.members.list.length;r++){if(this.members.list[r].get("isNew")){e.push(this.members.list[r])}}this.members=this.canonicalMembers.copy();for(r=0;r<e.length;r++){this.members.add(e[r])}},flushCanonicalLater:function(){if(this.willSync){return}this.willSync=true;var e=this;this.store._backburner.join(function(){e.store._backburner.schedule("syncRelationships",e,e.flushCanonical)})},updateLink:function(e){if(e!==this.link){this.link=e;this.linkPromise=null;this.record.notifyPropertyChange(this.key)}},findLink:function(){if(this.linkPromise){return this.linkPromise}else{var e=this.fetchLink();this.linkPromise=e;return e.then(function(e){return e})}},updateRecordsFromAdapter:function(e){var r=this;r.computeChanges(e)},notifyRecordRelationshipAdded:Ember.K,notifyRecordRelationshipRemoved:Ember.K};var _r=Er;var Fr=Ember.get;var Ar=Ember.set;var Sr=Ember.ArrayPolyfills.filter;var zr=Ember.Object.extend(Ember.MutableArray,Ember.Evented,{init:function(){this.currentState=Ember.A([])},record:null,canonicalState:null,currentState:null,length:0,objectAt:function(e){if(this.currentState[e]){return this.currentState[e]}else{return this.canonicalState[e]}},flushCanonical:function(){var e=Sr.call(this.canonicalState,function(e){return!e.get("isDeleted")});var r=this.currentState.filter(function(e){return e.get("isNew")});e=e.concat(r);var t=this.length;this.arrayContentWillChange(0,this.length,e.length);this.set("length",e.length);this.currentState=e;this.arrayContentDidChange(0,t,this.length);this.relationship.notifyHasManyChanged();this.record.updateRecordArrays()},isPolymorphic:false,isLoaded:false,relationship:null,internalReplace:function(e,r,t){if(!t){t=[]}this.arrayContentWillChange(e,r,t.length);this.currentState.splice.apply(this.currentState,[e,r].concat(t));this.set("length",this.currentState.length);this.arrayContentDidChange(e,r,t.length);if(t){this.relationship.notifyHasManyChanged()}this.record.updateRecordArrays()},internalRemoveRecords:function(e){var r;for(var t=0;t<e.length;t++){r=this.currentState.indexOf(e[t]);this.internalReplace(r,1)}},internalAddRecords:function(e,r){if(r===undefined){r=this.currentState.length}this.internalReplace(r,0,e)},replace:function(e,r,t){var i;if(r>0){i=this.currentState.slice(e,e+r);this.get("relationship").removeRecords(i)}if(t){this.get("relationship").addRecords(t,e)}},promise:null,loadingRecordsCount:function(e){this.loadingRecordsCount=e},loadedRecord:function(){this.loadingRecordsCount--;if(this.loadingRecordsCount===0){Ar(this,"isLoaded",true);this.trigger("didLoad")}},reload:function(){return this.relationship.reload()},save:function(){var e=this;var r="DS: ManyArray#save "+Fr(this,"type");var t=Ember.RSVP.all(this.invoke("save"),r).then(function(r){return e},null,"DS: ManyArray#save return ManyArray");return ye.create({promise:t})},createRecord:function(e){var r=Fr(this,"store");var t=Fr(this,"type");var i;i=r.createRecord(t,e);this.pushObject(i);return i},addRecord:function(e){this.addObject(e)},removeRecord:function(e){this.removeObject(e)}});var Tr=function(e,r,t,i){this._super$constructor(e,r,t,i);this.belongsToType=i.type;this.canonicalState=[];this.manyArray=zr.create({canonicalState:this.canonicalState,store:this.store,relationship:this,type:this.belongsToType,record:r});this.isPolymorphic=i.options.polymorphic;this.manyArray.isPolymorphic=this.isPolymorphic};Tr.prototype=Ember.create(_r.prototype);Tr.prototype.constructor=Tr;Tr.prototype._super$constructor=_r;Tr.prototype.destroy=function(){this.manyArray.destroy()};Tr.prototype._super$addCanonicalRecord=_r.prototype.addCanonicalRecord;Tr.prototype.addCanonicalRecord=function(e,r){if(this.canonicalMembers.has(e)){return}if(r!==undefined){this.canonicalState.splice(r,0,e)}else{this.canonicalState.push(e)}this._super$addCanonicalRecord(e,r)};Tr.prototype._super$addRecord=_r.prototype.addRecord;Tr.prototype.addRecord=function(e,r){if(this.members.has(e)){return}this._super$addRecord(e,r);this.manyArray.internalAddRecords([e],r)};Tr.prototype._super$removeCanonicalRecordFromOwn=_r.prototype.removeCanonicalRecordFromOwn;Tr.prototype.removeCanonicalRecordFromOwn=function(e,r){var t=r;if(!this.canonicalMembers.has(e)){return}if(t===undefined){t=this.canonicalState.indexOf(e)}if(t>-1){this.canonicalState.splice(t,1)}this._super$removeCanonicalRecordFromOwn(e,r)};Tr.prototype._super$flushCanonical=_r.prototype.flushCanonical;Tr.prototype.flushCanonical=function(){this.manyArray.flushCanonical();this._super$flushCanonical()};Tr.prototype._super$removeRecordFromOwn=_r.prototype.removeRecordFromOwn;Tr.prototype.removeRecordFromOwn=function(e,r){if(!this.members.has(e)){return}this._super$removeRecordFromOwn(e,r);if(r!==undefined){this.manyArray.currentState.removeAt(r)}else{this.manyArray.internalRemoveRecords([e])}};Tr.prototype.notifyRecordRelationshipAdded=function(e,r){var t=this.relationshipMeta.type;this.record.notifyHasManyAdded(this.key,e,r)};Tr.prototype.reload=function(){var e=this;if(this.link){return this.fetchLink()}else{return this.store.scheduleFetchMany(this.manyArray.toArray()).then(function(){e.manyArray.set("isLoaded",true);return e.manyArray})}};Tr.prototype.computeChanges=function(e){var r=this.canonicalMembers;var t=[];var i;var n;var a;e=kr(e);r.forEach(function(r){if(e.has(r)){return}t.push(r)});this.removeCanonicalRecords(t);e=e.toArray();i=e.length;for(a=0;a<i;a++){n=e[a];this.removeCanonicalRecord(n);this.addCanonicalRecord(n,a)}};Tr.prototype.fetchLink=function(){var e=this;return this.store.findHasMany(this.record,this.link,this.relationshipMeta).then(function(r){e.store._backburner.join(function(){e.updateRecordsFromAdapter(r)});return e.manyArray})};Tr.prototype.findRecords=function(){var e=this.manyArray;return this.store.findMany(e.toArray()).then(function(){e.set("isLoaded",true);return e})};Tr.prototype.notifyHasManyChanged=function(){this.record.notifyHasManyAdded(this.key)};Tr.prototype.getRecords=function(){if(this.isAsync){var e=this;var r;if(this.link){r=this.findLink().then(function(){return e.findRecords()})}else{r=this.findRecords()}return _e.create({content:this.manyArray,promise:r})}else{if(!this.manyArray.get("isDestroyed")){this.manyArray.set("isLoaded",true)}return this.manyArray}};function kr(e){var r=new Qe;if(e){for(var t=0,i=e.length;t<i;t++){r.add(e[t])}}return r}var Cr=Tr;var Mr=function(e,r,t,i){this._super$constructor(e,r,t,i);this.record=r;this.key=i.key;this.inverseRecord=null;this.canonicalState=null};Mr.prototype=Ember.create(_r.prototype);Mr.prototype.constructor=Mr;Mr.prototype._super$constructor=_r;Mr.prototype.setRecord=function(e){if(e){this.addRecord(e)}else if(this.inverseRecord){this.removeRecord(this.inverseRecord)}};Mr.prototype.setCanonicalRecord=function(e){if(e){this.addCanonicalRecord(e)}else if(this.inverseRecord){this.removeCanonicalRecord(this.inverseRecord)}};Mr.prototype._super$addCanonicalRecord=_r.prototype.addCanonicalRecord;Mr.prototype.addCanonicalRecord=function(e){if(this.canonicalMembers.has(e)){return}if(this.canonicalState){this.removeCanonicalRecord(this.canonicalState)}this.canonicalState=e;this._super$addCanonicalRecord(e)};Mr.prototype._super$flushCanonical=_r.prototype.flushCanonical;Mr.prototype.flushCanonical=function(){if(this.inverseRecord&&this.inverseRecord.get("isNew")&&!this.canonicalState){return}this.inverseRecord=this.canonicalState;this.record.notifyBelongsToChanged(this.key);this._super$flushCanonical()};Mr.prototype._super$addRecord=_r.prototype.addRecord;Mr.prototype.addRecord=function(e){if(this.members.has(e)){return}var r=this.relationshipMeta.type;if(this.inverseRecord){this.removeRecord(this.inverseRecord)}this.inverseRecord=e;this._super$addRecord(e);this.record.notifyBelongsToChanged(this.key)};Mr.prototype.setRecordPromise=function(e){var r=e.get&&e.get("content");this.setRecord(r)};Mr.prototype._super$removeRecordFromOwn=_r.prototype.removeRecordFromOwn;Mr.prototype.removeRecordFromOwn=function(e){if(!this.members.has(e)){return}this.inverseRecord=null;this._super$removeRecordFromOwn(e);this.record.notifyBelongsToChanged(this.key)};Mr.prototype._super$removeCanonicalRecordFromOwn=_r.prototype.removeCanonicalRecordFromOwn;Mr.prototype.removeCanonicalRecordFromOwn=function(e){if(!this.canonicalMembers.has(e)){return}this.canonicalState=null;this._super$removeCanonicalRecordFromOwn(e)};Mr.prototype.findRecord=function(){if(this.inverseRecord){return this.store._findByRecord(this.inverseRecord)}else{return Ember.RSVP.Promise.resolve(null)}};Mr.prototype.fetchLink=function(){var e=this;return this.store.findBelongsTo(this.record,this.link,this.relationshipMeta).then(function(r){if(r){e.addRecord(r)}return r})};Mr.prototype.getRecord=function(){if(this.isAsync){var e;if(this.link){var r=this;e=this.findLink().then(function(){return r.findRecord()})}else{e=this.findRecord()}return be.create({promise:e,content:this.inverseRecord})}else{return this.inverseRecord}};var xr=Mr;var wr=function(e,r,t){var i;var n=e.constructor.inverseFor(r.key);if(n){i=n.name}if(r.kind==="hasMany"){return new Cr(t,e,i,r)}else{return new xr(t,e,i,r)}};var Dr=wr;var Pr=Ember.get;function Or(e){this._attributes=Ember.create(null);this._belongsToRelationships=Ember.create(null);this._belongsToIds=Ember.create(null);this._hasManyRelationships=Ember.create(null);this._hasManyIds=Ember.create(null);e.eachAttribute(function(r){this._attributes[r]=Pr(e,r)},this);this.id=Pr(e,"id");this.record=e;this.type=e.constructor;this.typeKey=e.constructor.typeKey;if(Ember.platform.hasPropertyAccessors){var r=true;Ember.defineProperty(this,"constructor",{get:function(){if(r){r=false;r=true}return this.type}})}else{this.constructor=this.type}}Or.prototype={constructor:Or,id:null,record:null,type:null,typeKey:null,attr:function(e){if(e in this._attributes){return this._attributes[e]}throw new Ember.Error("Model '"+Ember.inspect(this.record)+"' has no attribute named '"+e+"' defined.")},attributes:function(){return Ember.copy(this._attributes)},belongsTo:function(e,r){var t=r&&r.id;var i;var n,a;if(t&&e in this._belongsToIds){return this._belongsToIds[e]}if(!t&&e in this._belongsToRelationships){return this._belongsToRelationships[e]}n=this.record._relationships[e];if(!(n&&n.relationshipMeta.kind==="belongsTo")){throw new Ember.Error("Model '"+Ember.inspect(this.record)+"' has no belongsTo relationship named '"+e+"' defined.")}a=Pr(n,"inverseRecord");if(t){if(a){i=Pr(a,"id")}this._belongsToIds[e]=i}else{if(a){i=a._createSnapshot()}this._belongsToRelationships[e]=i}return i},hasMany:function(e,r){var t=r&&r.ids;var i=[];var n,a;if(t&&e in this._hasManyIds){return this._hasManyIds[e]}if(!t&&e in this._hasManyRelationships){return this._hasManyRelationships[e]}n=this.record._relationships[e];if(!(n&&n.relationshipMeta.kind==="hasMany")){throw new Ember.Error("Model '"+Ember.inspect(this.record)+"' has no hasMany relationship named '"+e+"' defined.")}a=Pr(n,"members");if(t){a.forEach(function(e){i.push(Pr(e,"id"))});this._hasManyIds[e]=i}else{a.forEach(function(e){i.push(e._createSnapshot())});this._hasManyRelationships[e]=i}return i},eachAttribute:function(e,r){this.record.eachAttribute(e,r)},eachRelationship:function(e,r){this.record.eachRelationship(e,r)},get:function(e){if(e==="id"){return this.id}if(e in this._attributes){return this.attr(e)}var r=this.record._relationships[e];if(r&&r.relationshipMeta.kind==="belongsTo"){return this.belongsTo(e)}if(r&&r.relationshipMeta.kind==="hasMany"){return this.hasMany(e)}return Pr(this.record,e)},unknownProperty:function(e){return this.get(e)},_createSnapshot:function(){return this}};var Ir=Or;var $r=Ember.get;var Lr=Ember.set;var Kr=Ember.RSVP.Promise;var jr=Ember.ArrayPolyfills.forEach;var Br=Ember.ArrayPolyfills.map;var Ur=Ember.EnumerableUtils.intersection;var Nr=["attributes","currentState","data","relatedTypes","relationshipNames","relationships","relationshipsByName","transformedAttributes","store"];var Hr=Ember.computed("currentState",function(e,r){return $r($r(this,"currentState"),e)}).readOnly();var Vr=Ember.create(null);var Wr=Ember.create(null);function qr(e){return Wr[e]||(Wr[e]=e.split("."))}function Qr(e){return Vr[e]||(Vr[e]=qr(e)[0])}function Xr(e,r){var t=[];if(!r||typeof r!=="object"){return t}var i=Ember.keys(r);var n=i.length;var a,o,s;for(a=0;a<n;a++){s=i[a];o=r[s];if(e[s]!==o){t.push(s)}e[s]=o}return t}var Gr=Ember.Object.extend(Ember.Evented,{_recordArrays:undefined,_relationships:undefined,store:null,isEmpty:Hr,isLoading:Hr,isLoaded:Hr,isDirty:Hr,isSaving:Hr,isDeleted:Hr,isNew:Hr,isValid:Hr,dirtyType:Hr,isError:false,isReloading:false,clientId:null,id:null,currentState:fr.empty,errors:Ember.computed(function(){var e=yr.create();e.registerHandlers(this,function(){this.send("becameInvalid")},function(){this.send("becameValid")});return e}).readOnly(),serialize:function(e){return this.store.serialize(this,e)},toJSON:function(e){var r=X.create({container:this.container});var t=this._createSnapshot();return r.serialize(t,e)},ready:function(){this.store.recordArrayManager.recordWasLoaded(this)},didLoad:Ember.K,didUpdate:Ember.K,didCreate:Ember.K,didDelete:Ember.K,becameInvalid:Ember.K,becameError:Ember.K,data:Ember.computed(function(){this._data=this._data||{};return this._data}).readOnly(),_data:null,init:function(){this._super.apply(this,arguments);this._setup()},_setup:function(){this._changesToSync={};this._deferredTriggers=[];this._data={};this._attributes=Ember.create(null);this._inFlightAttributes=Ember.create(null);this._relationships={};this._implicitRelationships=Ember.create(null);var e=this;this.constructor.eachRelationship(function(r,t){e._relationships[r]=Dr(e,t,e.store)})},send:function(e,r){var t=$r(this,"currentState");if(!t[e]){this._unhandledEvent(t,e,r)}return t[e](this,r)},transitionTo:function(e){var r=Qr(e);var t=$r(this,"currentState");var i=t;do{if(i.exit){i.exit(this)}i=i.parentState}while(!i.hasOwnProperty(r));var n=qr(e);var a=[];var o=[];var s,u;for(s=0,u=n.length;s<u;s++){i=i[n[s]];if(i.enter){o.push(i)}if(i.setup){a.push(i)}}for(s=0,u=o.length;s<u;s++){o[s].enter(this)}Lr(this,"currentState",i);for(s=0,u=a.length;s<u;s++){a[s].setup(this)}this.updateRecordArraysLater()},_unhandledEvent:function(e,r,t){var i="Attempted to handle event `"+r+"` ";i+="on "+String(this)+" while in state ";i+=e.stateName+". ";if(t!==undefined){i+="Called with "+Ember.inspect(t)+"."}throw new Ember.Error(i)},withTransaction:function(e){var r=$r(this,"transaction");if(r){e(r)}},loadingData:function(e){this.send("loadingData",e)},loadedData:function(){this.send("loadedData")},notFound:function(){this.send("notFound")},pushedData:function(){this.send("pushedData")},deleteRecord:function(){this.send("deleteRecord")},destroyRecord:function(){this.deleteRecord();return this.save()},unloadRecord:function(){if(this.isDestroyed){return}this.send("unloadRecord")},clearRelationships:function(){this.eachRelationship(function(e,r){var t=this._relationships[e];if(t){t.clear();t.destroy()}},this);var e=this;jr.call(Ember.keys(this._implicitRelationships),function(r){e._implicitRelationships[r].clear();e._implicitRelationships[r].destroy()})},disconnectRelationships:function(){this.eachRelationship(function(e,r){this._relationships[e].disconnect()},this);var e=this;jr.call(Ember.keys(this._implicitRelationships),function(r){e._implicitRelationships[r].disconnect()})},reconnectRelationships:function(){this.eachRelationship(function(e,r){this._relationships[e].reconnect()},this);var e=this;jr.call(Ember.keys(this._implicitRelationships),function(r){e._implicitRelationships[r].reconnect()})},updateRecordArrays:function(){this._updatingRecordArraysLater=false;this.store.dataWasUpdated(this.constructor,this)},_preloadData:function(e){var r=this;jr.call(Ember.keys(e),function(t){var i=$r(e,t);var n=r.constructor.metaForProperty(t);if(n.isRelationship){r._preloadRelationship(t,i)}else{$r(r,"_data")[t]=i}})},_preloadRelationship:function(e,r){var t=this.constructor.metaForProperty(e);var i=t.type;if(t.kind==="hasMany"){this._preloadHasMany(e,r,i)}else{this._preloadBelongsTo(e,r,i)}},_preloadHasMany:function(e,r,t){var i=this;var n=Br.call(r,function(e){return i._convertStringOrNumberIntoRecord(e,t)});this._relationships[e].updateRecordsFromAdapter(n)},_preloadBelongsTo:function(e,r,t){var i=this._convertStringOrNumberIntoRecord(r,t);this._relationships[e].setRecord(i)},_convertStringOrNumberIntoRecord:function(e,r){if(Ember.typeOf(e)==="string"||Ember.typeOf(e)==="number"){return this.store.recordForId(r,e)}return e},_notifyProperties:function(e){Ember.beginPropertyChanges();var r;for(var t=0,i=e.length;t<i;t++){r=e[t];this.notifyPropertyChange(r)}Ember.endPropertyChanges()},changedAttributes:function(){var e=$r(this,"_data");var r=$r(this,"_attributes");var t={};var i;for(i in r){t[i]=[e[i],r[i]]}return t},adapterWillCommit:function(){this.send("willCommit")},adapterDidCommit:function(e){var r;Lr(this,"isError",false);if(e){r=Xr(this._data,e)}else{gr(this._data,this._inFlightAttributes)}this._inFlightAttributes=Ember.create(null);this.send("didCommit");this.updateRecordArraysLater();if(!e){return}this._notifyProperties(r)},adapterDidDirty:function(){this.send("becomeDirty");this.updateRecordArraysLater()},updateRecordArraysLater:function(){if(this._updatingRecordArraysLater){return}this._updatingRecordArraysLater=true;Ember.run.schedule("actions",this,this.updateRecordArrays)},setupData:function(e){var r=Xr(this._data,e);this.pushedData();this._notifyProperties(r)},materializeId:function(e){Lr(this,"id",e)},materializeAttributes:function(e){gr(this._data,e)},materializeAttribute:function(e,r){this._data[e]=r},rollback:function(){var e=Ember.keys(this._attributes);this._attributes=Ember.create(null);if($r(this,"isError")){this._inFlightAttributes=Ember.create(null);Lr(this,"isError",false)}if($r(this,"isDeleted")){this.reconnectRelationships()}if($r(this,"isNew")){this.clearRelationships()}if(!$r(this,"isValid")){this._inFlightAttributes=Ember.create(null)}this.send("rolledBack");this._notifyProperties(e)},_createSnapshot:function(){return new Ir(this)},toStringExtension:function(){return $r(this,"id")},save:function(){var e="DS: Model#save "+this;var r=Ember.RSVP.defer(e);this.store.scheduleSave(this,r);this._inFlightAttributes=this._attributes;this._attributes=Ember.create(null);return be.create({promise:r.promise})},reload:function(){Lr(this,"isReloading",true);var e=this;var r="DS: Model#reload of "+this;var t=new Kr(function(r){e.send("reloadRecord",r)},r).then(function(){e.set("isReloading",false);e.set("isError",false);return e},function(r){e.set("isError",true);throw r},"DS: Model#reload complete, update flags")["finally"](function(){e.updateRecordArrays()});return be.create({promise:t})},adapterDidInvalidate:function(e){var r=$r(this,"errors");for(var t in e){if(!e.hasOwnProperty(t)){continue}r.add(t,e[t])}this._saveWasRejected()},adapterDidError:function(){this.send("becameError");Lr(this,"isError",true);this._saveWasRejected()},_saveWasRejected:function(){var e=Ember.keys(this._inFlightAttributes);for(var r=0;r<e.length;r++){if(this._attributes[e[r]]===undefined){this._attributes[e[r]]=this._inFlightAttributes[e[r]]}}this._inFlightAttributes=Ember.create(null)},trigger:function(){var e=arguments.length;var r=new Array(e-1);var t=arguments[0];for(var i=1;i<e;i++){r[i-1]=arguments[i]}Ember.tryInvoke(this,t,r);this._super.apply(this,arguments)},triggerLater:function(){var e=arguments.length;var r=new Array(e);for(var t=0;t<e;t++){r[t]=arguments[t]}if(this._deferredTriggers.push(r)!==1){return}Ember.run.schedule("actions",this,"_triggerDeferredTriggers")},_triggerDeferredTriggers:function(){for(var e=0,r=this._deferredTriggers.length;e<r;e++){this.trigger.apply(this,this._deferredTriggers[e])}this._deferredTriggers.length=0},willDestroy:function(){this._super.apply(this,arguments);this.clearRelationships()},willMergeMixin:function(e){var r=this.constructor},attr:function(){},belongsTo:function(){},hasMany:function(){}});Gr.reopenClass({_create:Gr.create,create:function(){throw new Ember.Error("You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.")}});var Jr=Gr;var Yr=Ember.get;Jr.reopenClass({attributes:Ember.computed(function(){var e=l.create();this.eachComputedProperty(function(r,t){if(t.isAttribute){t.name=r;e.set(r,t)}});return e}).readOnly(),transformedAttributes:Ember.computed(function(){var e=l.create();this.eachAttribute(function(r,t){if(t.type){e.set(r,t.type)}});return e}).readOnly(),eachAttribute:function(e,r){Yr(this,"attributes").forEach(function(t,i){e.call(r,i,t)},r)},eachTransformedAttribute:function(e,r){Yr(this,"transformedAttributes").forEach(function(t,i){e.call(r,i,t)})}});Jr.reopen({eachAttribute:function(e,r){this.constructor.eachAttribute(e,r)}});function Zr(e,r,t){if(typeof r.defaultValue==="function"){return r.defaultValue.apply(null,arguments)}else{return r.defaultValue}}function et(e,r){return r in e._attributes||r in e._inFlightAttributes||e._data.hasOwnProperty(r)}function rt(e,r){if(r in e._attributes){return e._attributes[r]}else if(r in e._inFlightAttributes){return e._inFlightAttributes[r]}else{return e._data[r]}}function tt(e,r){if(typeof e==="object"){r=e;e=undefined}else{r=r||{}}var t={type:e,isAttribute:true,options:r};return Ember.computed(function(e,t){if(arguments.length>1){var i=rt(this,e);if(t!==i){this._attributes[e]=t;this.send("didSetProperty",{name:e,oldValue:i,originalValue:this._data[e],value:t})}return t}else if(et(this,e)){return rt(this,e)}else{return Zr(this,r,e)}}).meta(t)}var it=tt;var nt=Jr;var at=Ember.__loader.require("backburner")["default"]||Ember.__loader.require("backburner")["Backburner"];if(!at.prototype.join){var ot=function(e){return typeof e==="string"};at.prototype.join=function(){var e,r;if(this.currentInstance){var t=arguments.length;if(t===1){e=arguments[0];r=null}else{r=arguments[0];e=arguments[1]}if(ot(e)){e=r[e]}if(t===1){return e()}else if(t===2){return e.call(r)}else{var i=new Array(t-2);for(var n=0,a=t-2;n<a;n++){i[n]=arguments[n+2]}return e.apply(r,i)}}else{return this.run.apply(this,arguments)}}}var st=Ember.get;var ut=Ember.set;var ct=Ember.run.once;var lt=Ember.isNone;var dt=Ember.EnumerableUtils.forEach;var ht=Ember.EnumerableUtils.indexOf;var ft=Ember.EnumerableUtils.map;var pt=Ember.RSVP.Promise;var mt=Ember.copy;var vt;var yt=Ember.String.camelize;var bt=Ember.Service;if(!bt){bt=Ember.Object}function gt(e){return e==null?null:e+""}vt=bt.extend({init:function(){this._backburner=new at(["normalizeRelationships","syncRelationships","finished"]);this.typeMaps={};this.recordArrayManager=Ye.create({store:this});this._pendingSave=[];this._containerCache=Ember.create(null);this._pendingFetch=l.create()},adapter:"-rest",serialize:function(e,r){var t=e._createSnapshot();return this.serializerFor(t.typeKey).serialize(t,r)},defaultAdapter:Ember.computed("adapter",function(){var e=st(this,"adapter");if(typeof e==="string"){e=this.container.lookup("adapter:"+e)||this.container.lookup("adapter:application")||this.container.lookup("adapter:-rest")}if(DS.Adapter.detect(e)){e=e.create({
|
|
container:this.container,store:this})}return e}),createRecord:function(e,r){var t=this.modelFor(e);var i=mt(r)||{};if(lt(i.id)){i.id=this._generateId(t,i)}i.id=gt(i.id);var n=this.buildRecord(t,i.id);n.loadedData();n.setProperties(i);return n},_generateId:function(e,r){var t=this.adapterFor(e);if(t&&t.generateIdForRecord){return t.generateIdForRecord(this,e,r)}return null},deleteRecord:function(e){e.deleteRecord()},unloadRecord:function(e){e.unloadRecord()},find:function(e,r,t){if(arguments.length===1){return this.findAll(e)}if(Ember.typeOf(r)==="object"){return this.findQuery(e,r)}return this.findById(e,gt(r),t)},fetchById:function(e,r,t){if(this.hasRecordForId(e,r)){return this.getById(e,r).reload()}else{return this.find(e,r,t)}},fetchAll:function(e){e=this.modelFor(e);return this._fetchAll(e,this.all(e))},fetch:function(e,r,t){return this.fetchById(e,r,t)},findById:function(e,r,t){var i=this.modelFor(e);var n=this.recordForId(i,r);return this._findByRecord(n,t)},_findByRecord:function(e,r){var t;if(r){e._preloadData(r)}if(st(e,"isEmpty")){t=this.scheduleFetch(e)}else if(st(e,"isLoading")){t=e._loadingPromise}return ge(t||e,"DS: Store#findByRecord "+e.typeKey+" with id: "+st(e,"id"))},findByIds:function(e,r){var t=this;return Re(Ember.RSVP.all(ft(r,function(r){return t.findById(e,r)})).then(Ember.A,null,"DS: Store#findByIds of "+e+" complete"))},fetchRecord:function(e){var r=e.constructor;var t=st(e,"id");var i=this.adapterFor(r);var n=xe(i,this,r,t,e);return n},scheduleFetchMany:function(e){return pt.all(ft(e,this.scheduleFetch,this))},scheduleFetch:function(e){var r=e.constructor;if(lt(e)){return null}if(e._loadingPromise){return e._loadingPromise}var t=Ember.RSVP.defer("Fetching "+r+"with id: "+e.get("id"));var i={record:e,resolver:t};var n=t.promise;e.loadingData(n);if(!this._pendingFetch.get(r)){this._pendingFetch.set(r,[i])}else{this._pendingFetch.get(r).push(i)}Ember.run.scheduleOnce("afterRender",this,this.flushAllPendingFetches);return n},flushAllPendingFetches:function(){if(this.isDestroyed||this.isDestroying){return}this._pendingFetch.forEach(this._flushPendingFetchForType,this);this._pendingFetch=l.create()},_flushPendingFetchForType:function(e,r){var t=this;var i=t.adapterFor(r);var n=!!i.findMany&&i.coalesceFindRequests;var a=Ember.A(e).mapBy("record");function o(e){e.resolver.resolve(t.fetchRecord(e.record))}function s(r){dt(r,function(r){var t=Ember.A(e).findBy("record",r);if(t){var i=t.resolver;i.resolve(r)}});return r}function u(e){return function r(t){t=Ember.A(t);var i=e.reject(function(e){return t.contains(e)});if(i.length){}l(i)}}function c(e){return function(r){l(e,r)}}function l(r,t){dt(r,function(r){var i=Ember.A(e).findBy("record",r);if(i){var n=i.resolver;n.reject(t)}})}if(e.length===1){o(e[0])}else if(n){var d=Ember.A(a).invoke("_createSnapshot");var h=i.groupRecordsForFindMany(this,d);dt(h,function(n){var a=Ember.A(n).mapBy("record");var l=Ember.A(a);var d=l.mapBy("id");if(d.length>1){we(i,t,r,d,l).then(s).then(u(l)).then(null,c(l))}else if(d.length===1){var h=Ember.A(e).findBy("record",a[0]);o(h)}else{}})}else{dt(e,o)}},getById:function(e,r){if(this.hasRecordForId(e,r)){return this.recordForId(e,r)}else{return null}},reloadRecord:function(e){var r=e.constructor;var t=this.adapterFor(r);var i=st(e,"id");return this.scheduleFetch(e)},hasRecordForId:function(e,r){var t=this.modelFor(e);var i=gt(r);var n=this.typeMapFor(t).idToRecord[i];return!!n&&st(n,"isLoaded")},recordForId:function(e,r){var t=this.modelFor(e);var i=gt(r);var n=this.typeMapFor(t).idToRecord;var a=n[i];if(!a||!n[i]){a=this.buildRecord(t,i)}return a},findMany:function(e){var r=this;return pt.all(ft(e,function(e){return r._findByRecord(e)}))},findHasMany:function(e,r,t){var i=this.adapterFor(e.constructor);return De(i,this,e,r,t)},findBelongsTo:function(e,r,t){var i=this.adapterFor(e.constructor);return Pe(i,this,e,r,t)},findQuery:function(e,r){var t=this.modelFor(e);var i=this.recordArrayManager.createAdapterPopulatedRecordArray(t,r);var n=this.adapterFor(t);return Re(Ie(n,this,t,r,i))},findAll:function(e){return this.fetchAll(e)},_fetchAll:function(e,r){var t=this.adapterFor(e);var i=this.typeMapFor(e).metadata.since;ut(r,"isUpdating",true);return Re(Oe(t,this,e,i))},didUpdateAll:function(e){var r=this.typeMapFor(e).findAllCache;ut(r,"isUpdating",false)},all:function(e){var r=this.modelFor(e);var t=this.typeMapFor(r);var i=t.findAllCache;if(i){this.recordArrayManager.updateFilter(i,r);return i}var n=this.recordArrayManager.createRecordArray(r);t.findAllCache=n;return n},unloadAll:function(e){var r=this.modelFor(e);var t=this.typeMapFor(r);var i=t.records.slice();var n;for(var a=0;a<i.length;a++){n=i[a];n.unloadRecord();n.destroy()}t.findAllCache=null},filter:function(e,r,t){var i;var n=arguments.length;var a;var o=n===3;if(o){i=this.findQuery(e,r)}else if(arguments.length===2){t=r}e=this.modelFor(e);if(o){a=this.recordArrayManager.createFilteredRecordArray(e,t,r)}else{a=this.recordArrayManager.createFilteredRecordArray(e,t)}i=i||pt.cast(a);return Re(i.then(function(){return a},null,"DS: Store#filter of "+e))},recordIsLoaded:function(e,r){if(!this.hasRecordForId(e,r)){return false}return!st(this.recordForId(e,r),"isEmpty")},metadataFor:function(e){var r=this.modelFor(e);return this.typeMapFor(r).metadata},setMetadataFor:function(e,r){var t=this.modelFor(e);Ember.merge(this.typeMapFor(t).metadata,r)},dataWasUpdated:function(e,r){this.recordArrayManager.recordDidChange(r)},scheduleSave:function(e,r){e.adapterWillCommit();this._pendingSave.push([e,r]);ct(this,"flushPendingSave")},flushPendingSave:function(){var e=this._pendingSave.slice();this._pendingSave=[];dt(e,function(e){var r=e[0];var t=e[1];var i=this.adapterFor(r.constructor);var n;if(st(r,"currentState.stateName")==="root.deleted.saved"){return t.resolve(r)}else if(st(r,"isNew")){n="createRecord"}else if(st(r,"isDeleted")){n="deleteRecord"}else{n="updateRecord"}t.resolve(St(i,this,n,r))},this)},didSaveRecord:function(e,r){if(r){this._backburner.schedule("normalizeRelationships",this,"_setupRelationships",e,e.constructor,r);this.updateId(e,r)}e.adapterDidCommit(r)},recordWasInvalid:function(e,r){e.adapterDidInvalidate(r)},recordWasError:function(e){e.adapterDidError()},updateId:function(e,r){var t=st(e,"id");var i=gt(r.id);this.typeMapFor(e.constructor).idToRecord[i]=e;ut(e,"id",i)},typeMapFor:function(e){var r=st(this,"typeMaps");var t=Ember.guidFor(e);var i;i=r[t];if(i){return i}i={idToRecord:Ember.create(null),records:[],metadata:Ember.create(null),type:e};r[t]=i;return i},_load:function(e,r){var t=gt(r.id);var i=this.recordForId(e,t);i.setupData(r);this.recordArrayManager.recordDidChange(i);return i},_modelForMixin:function(e){var r=this.container._registry?this.container._registry:this.container;var t=r.resolve("mixin:"+e);if(t){r.register("model:"+e,DS.Model.extend(t))}var i=this.modelFactoryFor(e);if(i){i.__isMixin=true;i.__mixin=t}return i},modelFor:function(e){var r;if(typeof e==="string"){r=this.modelFactoryFor(e);if(!r){r=this._modelForMixin(e)}if(!r){throw new Ember.Error("No model was found for '"+e+"'")}r.typeKey=r.typeKey||this._normalizeTypeKey(e)}else{r=e;if(r.typeKey){r.typeKey=this._normalizeTypeKey(r.typeKey)}}r.store=this;return r},modelFactoryFor:function(e){return this.container.lookupFactory("model:"+e)},push:function(e,r){var t=this.modelFor(e);var i=Ember.EnumerableUtils.filter;if(Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS){}this._load(t,r);var n=this.recordForId(t,r.id);var a=this;this._backburner.join(function(){a._backburner.schedule("normalizeRelationships",a,"_setupRelationships",n,t,r)});return n},_setupRelationships:function(e,r,t){t=Rt(this,r,t);zt(this,e,t)},pushPayload:function(e,r){var t;var i;if(!r){i=e;t=At(this.container)}else{i=r;t=this.serializerFor(e)}var n=this;this._adapterRun(function(){t.pushPayload(n,i)})},normalize:function(e,r){var t=this.serializerFor(e);var i=this.modelFor(e);return t.normalize(i,r)},update:function(e,r){return this.push(e,r)},pushMany:function(e,r){var t=r.length;var i=new Array(t);for(var n=0;n<t;n++){i[n]=this.push(e,r[n])}return i},metaForType:function(e,r){this.setMetadataFor(e,r)},buildRecord:function(e,r,t){var i=this.typeMapFor(e);var n=i.idToRecord;var a=e._create({id:r,store:this,container:this.container});if(t){a.setupData(t)}if(r){n[r]=a}i.records.push(a);return a},recordWasLoaded:function(e){this.recordArrayManager.recordWasLoaded(e)},dematerializeRecord:function(e){this._dematerializeRecord(e)},_dematerializeRecord:function(e){var r=e.constructor;var t=this.typeMapFor(r);var i=st(e,"id");e.updateRecordArrays();if(i){delete t.idToRecord[i]}var n=ht(t.records,e);t.records.splice(n,1)},adapterFor:function(e){if(e!=="application"){e=this.modelFor(e)}var r=this.lookupAdapter(e.typeKey)||this.lookupAdapter("application");return r||st(this,"defaultAdapter")},_adapterRun:function(e){return this._backburner.run(e)},serializerFor:function(e){if(e!=="application"){e=this.modelFor(e)}var r=this.lookupSerializer(e.typeKey)||this.lookupSerializer("application");if(!r){var t=this.adapterFor(e);r=this.lookupSerializer(st(t,"defaultSerializer"))}if(!r){r=this.lookupSerializer("-default")}return r},retrieveManagedInstance:function(e,r){var t=e+":"+r;if(!this._containerCache[t]){var i=this.container.lookup(t);if(i){ut(i,"store",this);this._containerCache[t]=i}}return this._containerCache[t]},lookupAdapter:function(e){return this.retrieveManagedInstance("adapter",e)},lookupSerializer:function(e){return this.retrieveManagedInstance("serializer",e)},willDestroy:function(){var e=this.typeMaps;var r=Ember.keys(e);var t=ft(r,i);this.recordArrayManager.destroy();dt(t,this.unloadAll,this);function i(r){return e[r]["type"]}for(var n in this._containerCache){this._containerCache[n].destroy();delete this._containerCache[n]}delete this._containerCache},_normalizeTypeKey:function(e){return yt(x(e))}});function Rt(e,r,t,i){r.eachRelationship(function(r,i){var n=i.kind;var a=t[r];if(n==="belongsTo"){Et(e,t,r,i,a)}else if(n==="hasMany"){Ft(e,t,r,i,a)}});return t}function Et(e,r,t,i,n){if(lt(n)||n instanceof nt){return}var a;if(typeof n==="number"||typeof n==="string"){a=_t(i,t,r);r[t]=e.recordForId(a,n)}else if(typeof n==="object"){r[t]=e.recordForId(n.type,n.id)}}function _t(e,r,t){if(e.options.polymorphic){return t[r+"Type"]}else{return e.type}}function Ft(e,r,t,i,n){if(lt(n)){return}for(var a=0,o=n.length;a<o;a++){Et(e,n,a,i,n[a])}}function At(e){return e.lookup("serializer:application")||e.lookup("serializer:-default")}function St(e,r,i,n){var a=n.constructor;var o=n._createSnapshot();var s=e[i](r,a,o);var u=ke(r,e,a);var c="DS: Extract and notify about "+i+" completion of "+n;s=pt.cast(s,c);s=ze(s,Se(Te,r));s=ze(s,Se(Te,n));return s.then(function(e){var t;r._adapterRun(function(){if(e){t=u.extract(r,a,e,st(n,"id"),i)}else{t=e}r.didSaveRecord(n,t)});return n},function(e){if(e instanceof t){var i=u.extractErrors(r,a,e.errors,st(n,"id"));r.recordWasInvalid(n,i);e=new t(i)}else{r.recordWasError(n,e)}throw e},c)}function zt(e,r,t){var i=r.constructor;i.eachRelationship(function(e,i){var n=i.kind;var a=t[e];var o=r._relationships[e];if(t.links&&t.links[e]){o.updateLink(t.links[e])}if(n==="belongsTo"){if(a===undefined){return}o.setCanonicalRecord(a)}else if(n==="hasMany"&&a){o.updateRecordsFromAdapter(a)}})}var Tt=vt;function kt(e,r){e.optionsForType("serializer",{singleton:false});e.optionsForType("adapter",{singleton:false});e.register("store:main",e.lookupFactory("store:application")||r&&r.Store||Tt);var t=new le(e);t.registerDeprecations([{deprecated:"serializer:_default",valid:"serializer:-default"},{deprecated:"serializer:_rest",valid:"serializer:-rest"},{deprecated:"adapter:_rest",valid:"adapter:-rest"}]);e.register("serializer:-default",X);e.register("serializer:-rest",re);e.register("adapter:-rest",y);var i=e.lookup("store:main");e.register("service:store",i,{instantiate:false})}var Ct=kt;var Mt=Ember.Object.extend({serialize:null,deserialize:null});var xt=Ember.isEmpty;function wt(e){return e===e&&e!==Infinity&&e!==-Infinity}var Dt=Mt.extend({deserialize:function(e){var r;if(xt(e)){return null}else{r=Number(e);return wt(r)?r:null}},serialize:function(e){var r;if(xt(e)){return null}else{r=Number(e);return wt(r)?r:null}}});var Pt=Date.prototype.toISOString||function(){function e(e){if(e<10){return"0"+e}return e}return this.getUTCFullYear()+"-"+e(this.getUTCMonth()+1)+"-"+e(this.getUTCDate())+"T"+e(this.getUTCHours())+":"+e(this.getUTCMinutes())+":"+e(this.getUTCSeconds())+"."+(this.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};if(Ember.SHIM_ES5){if(!Date.prototype.toISOString){Date.prototype.toISOString=Pt}}var Ot=Mt.extend({deserialize:function(e){var r=typeof e;if(r==="string"){return new Date(Ember.Date.parse(e))}else if(r==="number"){return new Date(e)}else if(e===null||e===undefined){return e}else{return null}},serialize:function(e){if(e instanceof Date){return Pt.call(e)}else{return null}}});var It=Ember.isNone;var $t=Mt.extend({deserialize:function(e){return It(e)?null:String(e)},serialize:function(e){return It(e)?null:String(e)}});var Lt=Mt.extend({deserialize:function(e){var r=typeof e;if(r==="boolean"){return e}else if(r==="string"){return e.match(/^true$|^t$|^1$/i)!==null}else if(r==="number"){return e===1}else{return false}},serialize:function(e){return Boolean(e)}});function Kt(e){e.register("transform:boolean",Lt);e.register("transform:date",Ot);e.register("transform:number",Dt);e.register("transform:string",$t)}var jt=Kt;function Bt(e){e.injection("controller","store","store:main");e.injection("route","store","store:main");e.injection("data-adapter","store","store:main")}var Ut=Bt;var Nt=Ember.get;var Ht=Ember.String.capitalize;var Vt=Ember.String.underscore;var Wt=Ember.DataAdapter.extend({getFilters:function(){return[{name:"isNew",desc:"New"},{name:"isModified",desc:"Modified"},{name:"isClean",desc:"Clean"}]},detect:function(e){return e!==nt&&nt.detect(e)},columnsForType:function(e){var r=[{name:"id",desc:"Id"}];var t=0;var i=this;Nt(e,"attributes").forEach(function(e,n){if(t++>i.attributeLimit){return false}var a=Ht(Vt(n).replace("_"," "));r.push({name:n,desc:a})});return r},getRecords:function(e){return this.get("store").all(e)},getRecordColumnValues:function(e){var r=this;var t=0;var i={id:Nt(e,"id")};e.eachAttribute(function(n){if(t++>r.attributeLimit){return false}var a=Nt(e,n);i[n]=a});return i},getRecordKeywords:function(e){var r=[];var t=Ember.A(["id"]);e.eachAttribute(function(e){t.push(e)});t.forEach(function(t){r.push(Nt(e,t))});return r},getRecordFilterValues:function(e){return{isNew:e.get("isNew"),isModified:e.get("isDirty")&&!e.get("isNew"),isClean:!e.get("isDirty")}},getRecordColor:function(e){var r="black";if(e.get("isNew")){r="green"}else if(e.get("isDirty")){r="blue"}return r},observeRecord:function(e,r){var t=Ember.A();var i=this;var n=Ember.A(["id","isNew","isDirty"]);e.eachAttribute(function(e){n.push(e)});n.forEach(function(n){var a=function(){r(i.wrapRecord(e))};Ember.addObserver(e,n,a);t.push(function(){Ember.removeObserver(e,n,a)})});var a=function(){t.forEach(function(e){e()})};return a}});function qt(e){e.register("data-adapter:main",Wt)}var Qt=qt;function Xt(e,r){Qt(e,r);jt(e,r);Ut(e,r);Ct(e,r);he(e,r)}var Gt=Xt;var Jt=Ember.K;Ember.onLoad("Ember.Application",function(e){e.initializer({name:"ember-data",initialize:Gt});e.initializer({name:"store",after:"ember-data",initialize:Jt});e.initializer({name:"activeModelAdapter",before:"store",initialize:Jt});e.initializer({name:"transforms",before:"store",initialize:Jt});e.initializer({name:"data-adapter",before:"store",initialize:Jt});e.initializer({name:"injectStore",before:"store",initialize:Jt})});Ember.Date=Ember.Date||{};var Yt=Date.parse;var Zt=[1,4,5,6,7,10,11];Ember.Date.parse=function(e){var r,t;var i=0;if(t=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(e)){for(var n=0,a;a=Zt[n];++n){t[a]=+t[a]||0}t[2]=(+t[2]||1)-1;t[3]=+t[3]||1;if(t[8]!=="Z"&&t[9]!==undefined){i=t[10]*60+t[11];if(t[9]==="+"){i=0-i}}r=Date.UTC(t[1],t[2],t[3],t[4],t[5]+i,t[6],t[7])}else{r=Yt?Yt(e):NaN}return r};if(Ember.EXTEND_PROTOTYPES===true||Ember.EXTEND_PROTOTYPES.Date){Date.parse=Ember.Date.parse}nt.reopen({_debugInfo:function(){var e=["id"];var r={belongsTo:[],hasMany:[]};var t=[];this.eachAttribute(function(r,t){e.push(r)},this);this.eachRelationship(function(e,i){r[i.kind].push(e);t.push(e)});var i=[{name:"Attributes",properties:e,expand:true},{name:"Belongs To",properties:r.belongsTo,expand:true},{name:"Has Many",properties:r.hasMany,expand:true},{name:"Flags",properties:["isLoaded","isDirty","isSaving","isDeleted","isError","isNew","isValid"]}];return{propertyInfo:{includeOtherProperties:true,groups:i,expensiveProperties:t}}}});var ei=nt;var ri=Wt;var ti=Ember.get;var ii=Ember.EnumerableUtils.forEach;var ni=Ember.String.camelize;var ai=Ember.Mixin.create({normalize:function(e,r,t){var i=this._super(e,r,t);return oi(this,this.store,e,i)},keyForRelationship:function(e,r){if(this.hasDeserializeRecordsOption(e)){return this.keyForAttribute(e)}else{return this._super(e,r)||e}},serializeBelongsTo:function(e,r,t){var i=t.key;if(this.noSerializeOptionSpecified(i)){this._super(e,r,t);return}var n=this.hasSerializeIdsOption(i);var a=this.hasSerializeRecordsOption(i);var o=e.belongsTo(i);var s;if(n){s=this.keyForRelationship(i,t.kind);if(!o){r[s]=null}else{r[s]=o.id}}else if(a){s=this.keyForAttribute(i);if(!o){r[s]=null}else{r[s]=o.record.serialize({includeId:true});this.removeEmbeddedForeignKey(e,o,t,r[s])}}},serializeHasMany:function(e,r,t){var i=t.key;if(this.noSerializeOptionSpecified(i)){this._super(e,r,t);return}var n=this.hasSerializeIdsOption(i);var a=this.hasSerializeRecordsOption(i);var o;if(n){o=this.keyForRelationship(i,t.kind);r[o]=e.hasMany(i,{ids:true})}else if(a){o=this.keyForAttribute(i);r[o]=e.hasMany(i).map(function(r){var i=r.record.serialize({includeId:true});this.removeEmbeddedForeignKey(e,r,t,i);return i},this)}},removeEmbeddedForeignKey:function(e,r,t,i){if(t.kind==="hasMany"){return}else if(t.kind==="belongsTo"){var n=e.type.inverseFor(t.key);if(n){var a=n.name;var o=this.store.serializerFor(r.type);var s=o.keyForRelationship(a,n.kind);if(s){delete i[s]}}}},hasEmbeddedAlwaysOption:function(e){var r=this.attrsOption(e);return r&&r.embedded==="always"},hasSerializeRecordsOption:function(e){var r=this.hasEmbeddedAlwaysOption(e);var t=this.attrsOption(e);return r||t&&t.serialize==="records"},hasSerializeIdsOption:function(e){var r=this.attrsOption(e);return r&&(r.serialize==="ids"||r.serialize==="id")},noSerializeOptionSpecified:function(e){var r=this.attrsOption(e);return!(r&&(r.serialize||r.embedded))},hasDeserializeRecordsOption:function(e){var r=this.hasEmbeddedAlwaysOption(e);var t=this.attrsOption(e);return r||t&&t.deserialize==="records"},attrsOption:function(e){var r=this.get("attrs");return r&&(r[ni(e)]||r[e])}});function oi(e,r,t,i){t.eachRelationship(function(t,n){if(e.hasDeserializeRecordsOption(t)){var a=r.modelFor(n.type.typeKey);if(n.kind==="hasMany"){if(n.options.polymorphic){ui(r,t,i)}else{si(r,t,a,i)}}if(n.kind==="belongsTo"){if(n.options.polymorphic){li(r,t,i)}else{ci(r,t,a,i)}}}});return i}function si(e,r,t,i){if(!i[r]){return i}var n=[];var a=e.serializerFor(t.typeKey);ii(i[r],function(r){var i=a.normalize(t,r,null);e.push(t,i);n.push(i.id)});i[r]=n;return i}function ui(e,r,t){if(!t[r]){return t}var i=[];ii(t[r],function(r){var t=r.type;var n=e.serializerFor(t);var a=e.modelFor(t);var o=ti(n,"primaryKey");var s=n.normalize(a,r,null);e.push(a,s);i.push({id:s[o],type:t})});t[r]=i;return t}function ci(e,r,t,i){if(!i[r]){return i}var n=e.serializerFor(t.typeKey);var a=n.normalize(t,i[r],null);e.push(t,a);i[r]=a.id;return i}function li(e,r,t){if(!t[r]){return t}var i=t[r];var n=i.type;var a=e.serializerFor(n);var o=e.modelFor(n);var s=ti(a,"primaryKey");var u=a.normalize(o,i,null);e.push(o,u);t[r]=u[s];t[r+"Type"]=n;return t}var di=ai;function hi(e,r){if(typeof e==="object"){r=e;e=undefined}r=r||{};var t={type:e,isRelationship:true,options:r,kind:"belongsTo",key:null};return Ember.computed(function(e,r){if(arguments.length>1){if(r===undefined){r=null}if(r&&r.then){this._relationships[e].setRecordPromise(r)}else{this._relationships[e].setRecord(r)}}return this._relationships[e].getRecord()}).meta(t)}nt.reopen({notifyBelongsToChanged:function(e){this.notifyPropertyChange(e)}});var fi=hi;function pi(e,r){if(typeof e==="object"){r=e;e=undefined}r=r||{};var t={type:e,isRelationship:true,options:r,kind:"hasMany",key:null};return Ember.computed(function(e){var r=this._relationships[e];return r.getRecords()}).meta(t).readOnly()}nt.reopen({notifyHasManyAdded:function(e){this.notifyPropertyChange(e)}});var mi=pi;function vi(e,r){var t,i;t=r.type||r.key;if(typeof t==="string"){if(r.kind==="hasMany"){t=x(t)}i=e.modelFor(t)}else{i=r.type}return i}function yi(e,r){return{key:r.key,kind:r.kind,type:vi(e,r),options:r.options,parentType:r.parentType,isRelationship:true}}var bi=Ember.get;var gi=Ember.ArrayPolyfills.filter;var Ri=Ember.computed(function(){if(Ember.testing===true&&Ri._cacheable===true){Ri._cacheable=false}var e=new d({defaultValue:function(){return[]}});this.eachComputedProperty(function(r,t){if(t.isRelationship){t.key=r;var i=e.get(vi(this.store,t));i.push({name:r,kind:t.kind})}});return e}).readOnly();var Ei=Ember.computed(function(){if(Ember.testing===true&&Ei._cacheable===true){Ei._cacheable=false}var e;var r=Ember.A();this.eachComputedProperty(function(t,i){if(i.isRelationship){i.key=t;e=vi(this.store,i);if(!r.contains(e)){r.push(e)}}});return r}).readOnly();var _i=Ember.computed(function(){if(Ember.testing===true&&_i._cacheable===true){_i._cacheable=false}var e=l.create();this.eachComputedProperty(function(r,t){if(t.isRelationship){t.key=r;var i=yi(this.store,t);i.type=vi(this.store,t);e.set(r,i)}});return e}).readOnly();nt.reopen({didDefineProperty:function(e,r,t){if(t instanceof Ember.ComputedProperty){var i=t.meta();i.parentType=e.constructor}}});nt.reopenClass({typeForRelationship:function(e){var r=bi(this,"relationshipsByName").get(e);return r&&r.type},inverseMap:Ember.computed(function(){return Ember.create(null)}),inverseFor:function(e){var r=bi(this,"inverseMap");if(r[e]){return r[e]}else{var t=this._findInverseFor(e);r[e]=t;return t}},_findInverseFor:function(e){var r=this.typeForRelationship(e);if(!r){return null}var t=this.metaForProperty(e);var i=t.options;if(i.inverse===null){return null}var n,a,o;if(i.inverse){n=i.inverse;o=Ember.get(r,"relationshipsByName").get(n);a=o.kind}else{var s=c(this,r);if(s.length===0){return null}var u=gi.call(s,function(t){var i=r.metaForProperty(t.name).options;return e===i.inverse});if(u.length===1){s=u}n=s[0].name;a=s[0].kind}function c(r,t,i){var n=i||[];var a=bi(t,"relationships");if(!a){return}var o=a.get(r);o=gi.call(o,function(r){var i=t.metaForProperty(r.name).options;if(!i.inverse){return true}return e===i.inverse});if(o){n.push.apply(n,o)}if(r.superclass){c(r.superclass,t,n)}return n}return{type:r,name:n,kind:a}},relationships:Ri,relationshipNames:Ember.computed(function(){var e={hasMany:[],belongsTo:[]};this.eachComputedProperty(function(r,t){if(t.isRelationship){e[t.kind].push(r)}});return e}),relatedTypes:Ei,relationshipsByName:_i,fields:Ember.computed(function(){var e=l.create();this.eachComputedProperty(function(r,t){if(t.isRelationship){e.set(r,t.kind)}else if(t.isAttribute){e.set(r,"attribute")}});return e}).readOnly(),eachRelationship:function(e,r){bi(this,"relationshipsByName").forEach(function(t,i){e.call(r,i,t)})},eachRelatedType:function(e,r){bi(this,"relatedTypes").forEach(function(t){e.call(r,t)})},determineRelationshipType:function(e){var r=e.key;var t=e.kind;var i=this.inverseFor(r);var n,a;if(!i){return t==="belongsTo"?"oneToNone":"manyToNone"}n=i.name;a=i.kind;if(a==="belongsTo"){return t==="belongsTo"?"oneToOne":"manyToOne"}else{return t==="belongsTo"?"oneToMany":"manyToMany"}}});nt.reopen({eachRelationship:function(e,r){this.constructor.eachRelationship(e,r)},relationshipFor:function(e){return bi(this.constructor,"relationshipsByName").get(e)},inverseFor:function(e){return this.constructor.inverseFor(e)}});Ember.RSVP.Promise.cast=Ember.RSVP.Promise.cast||Ember.RSVP.resolve;pe.Store=vt;pe.PromiseArray=ye;pe.PromiseObject=be;pe.PromiseManyArray=_e;pe.Model=nt;pe.RootState=fr;pe.attr=it;pe.Errors=yr;pe.Snapshot=Ir;pe.Adapter=i;pe.InvalidError=t;pe.Serializer=H;pe.DebugAdapter=ri;pe.RecordArray=Ke;pe.FilteredRecordArray=Be;pe.AdapterPopulatedRecordArray=He;pe.ManyArray=zr;pe.RecordArrayManager=Ye;pe.RESTAdapter=y;pe.BuildURLMixin=p;pe.FixtureAdapter=c;pe.RESTSerializer=re;pe.JSONSerializer=X;pe.Transform=Mt;pe.DateTransform=Ot;pe.StringTransform=$t;pe.NumberTransform=Dt;pe.BooleanTransform=Lt;pe.ActiveModelAdapter=U;pe.ActiveModelSerializer=ue;pe.EmbeddedRecordsMixin=di;pe.belongsTo=fi;pe.hasMany=mi;pe.Relationship=_r;pe.ContainerProxy=le;pe._setupContainer=Gt;Ember.lookup.DS=pe;var Fi=pe}).call(this); |