define(["ember","emberdata"],function(a,b){return b.RESTSerializer.extend({extractSingle:function(a,b,c,d){var e={};return this._extractRelationshipPayload(a,b,e,c),e[b.typeKey]=c,this._super(a,b,e,d)},extractArray:function(b,c,d){"array"!==a.typeOf(d)&&(d=d&&d.root&&d.total?d.root:d?[d]:[]);for(var e={},f=0;f<d.length;f++){var g=d[f];this._extractRelationshipPayload(b,c,e,g)}return e[c.typeKey]=d,this._super(b,c,e)},_extractRelationshipPayload:function(b,c,d,e){for(var f in e)if("array"==a.typeOf(e[f])){var g=f,h=a.get(c,"relationshipsByName");h&&h.get(f)&&(g=h.get(f).type.typeKey),void 0==d[g]&&(d[g]=[]),d[g].addObjects(e[f]);var i=b.serializerFor(g);if(i){var j=i.get("primaryKey");e[f]=e[f].mapBy(j)}}}})});