text: !function(){var a=Ember.ArrayPolyfills.map,b=Ember.ArrayPolyfills.forEach;DS.DjangoRESTSerializer=DS.RESTSerializer.extend({init:function(){this._super.apply(this,arguments)},keyForType:function(a){return a+"_type"},keyForEmbeddedType:function(){return"type"},extractDjangoPayload:function(a,c,d){c.eachRelationship(function(c,e){var f=!1;if(e.options&&e.options.polymorphic&&(f=!0),Ember.isNone(d[c])||"number"==typeof d[c][0]||"string"==typeof d[c][0]||"hasMany"!==e.kind){if(!Ember.isNone(d[c])&&"object"==typeof d[c]&&"belongsTo"===e.kind){var g=e.type;f&&(g=this.typeForRoot(d[c].type));var h=d[c].id;this.pushSinglePayload(a,g,d[c]),f||(d[c]=h)}}else if("array"===Ember.typeOf(d[c])&&d[c].length>0)if(f)b.call(d[c],function(b){var c=this.typeForRoot(b.type);this.pushSinglePayload(a,c,b)},this);else{var i=d[c].mapBy("id");this.pushArrayPayload(a,e.type,d[c]),d[c]=i}},this)},extractDjangoMetaPayload:function(a){if(a.count&&a.results){var b=new RegExp("page=([0-9]+)"),c={total:a.count,first:1,last:a.results.length,per_page:void 0},d={total:1,current:1,previous:!1,next:!1};return(res=b.exec(a.previous))&&(d.previous=parseInt(res[1],10),d.current=d.previous+1,c.per_page=(a.count-a.results.length)/d.previous),(res=b.exec(a.next))&&(d.next=parseInt(res[1],10),d.current=d.next-1,c.per_page=a.results.length),void 0===c.per_page||(d.total=Math.ceil(a.count/c.per_page),c.first=(d.current-1)*c.per_page+1,c.last=c.first+a.results.length-1),{page:d,items:c}}return null},extractSingle:function(a,b,c){return this.normalize(b,c),this.extractDjangoPayload(a,b,c),c},extractArray:function(a,b,c){var d=this;!c.length&&c.count&&c.results&&(c=c.results);for(var e=0;e<c.length;e++)this.normalize(b,c[e]),d.extractDjangoPayload(a,b,c[e]);return c},extractMeta:function(a,b,c){var d=this.extractDjangoMetaPayload(c);c&&d&&(a.metaForType(b,d),delete d)},pushSinglePayload:function(a,b,c){b=a.modelFor(b),c=this.extract(a,b,c,null,"find"),a.push(b,c)},pushArrayPayload:function(a,b,c){b=a.modelFor(b),c=this.extract(a,b,c,null,"findAll"),a.pushMany(b,c)},keyForAttribute:function(a){return Ember.String.decamelize(a)},keyForRelationship:function(a){return Ember.String.decamelize(a)},serializeAttribute:function(a,b,c,d){return d.options.readOnly?void 0:this._super(a,b,c,d)},serializeBelongsTo:function(a,b,c){var d=c.key,e=a.get(d),f=this.keyForRelationship?this.keyForRelationship(d,"belongsTo"):d;b[f]=Ember.isNone(e)?e:"string"==typeof a.get(d)?a.get(d):a.get(d).get("id"),c.options.polymorphic&&this.serializePolymorphicType(a,b,c)},serializeHasMany:function(a,b,c){if(!c.options.polymorphic){var d=c.key,e=this.keyForRelationship(d,"hasMany"),f=DS.RelationshipChange?DS.RelationshipChange.determineRelationshipType(a.constructor,c):a.constructor.determineRelationshipType(c);("manyToNone"===f||"manyToMany"===f)&&(b[e]=a.get(d).mapBy("id"))}},serializePolymorphicType:function(a,b,c){var d=c.key,e=Ember.get(a,d);d=this.keyForAttribute?this.keyForAttribute(d):d,b[this.keyForType(d)]=e?Ember.String.underscore(e.constructor.typeKey):null},normalizeRelationships:function(b,c){this._super.apply(this,arguments),this.keyForRelationship&&b.eachRelationship(function(b,d){if(d.options.polymorphic){var e=this.keyForType(d.key);if(c[e]){var f=e.replace(/_type$/,"Type");c[f]=c[e],delete c[e]}if(c[d.key]){var g=c[d.key],h=this.keyForEmbeddedType(d.key);"type"!==h&&(Ember.isArray(g)&&g.length?a.call(g,function(a){this.normalizeTypeKey(a,h)},this):g[h]&&this.normalizeTypeKey(g,h))}}},this)},normalizeTypeKey:function(a,b){a.type=a[b]}})}(),function(){var a=Ember.get;DS.DjangoRESTAdapter=DS.RESTAdapter.extend({defaultSerializer:"DS/djangoREST",pathForType:function(a){var b=Ember.String.decamelize(a);return Ember.String.pluralize(b)},createRecord:function(a,b,c){var d=this.buildURL(b.typeKey),e=a.serializerFor(b.typeKey).serialize(c);return this.ajax(d,"POST",{data:e})},updateRecord:function(b,c,d){var e=!1;d.eachAttribute(function(a,b){b.options.readOnly&&(e=!0)},this);var f=e?"PATCH":"PUT",g=b.serializerFor(c.typeKey).serialize(d),h=a(d,"id");return this.ajax(this.buildURL(c.typeKey,h),f,{data:g})},findMany:function(a,b,c,d){var e,f,g;return d?(g=this.getHasManyAttributeName(b,d,c),f=a.serializerFor(b.typeKey).keyForAttribute(g),e=this.buildFindManyUrlWithParent(b,d,f)):Ember.assert("You need to add belongsTo for type ("+b.typeKey+"). No Parent for this record was found"),this.ajax(e,"GET")},ajax:function(a,b,c){return c=c||{},c.cache=!1,this._super(a,b,c)},ajaxError:function(a){var b=this._super(a);if(a&&400===a.status){var c=Ember.$.parseJSON(a.responseText),d={};return Ember.EnumerableUtils.forEach(Ember.keys(c),function(a){d[Ember.String.camelize(a)]=c[a]}),new DS.InvalidError(d)}return b},buildURL:function(a,b){var c=this._super(a,b);return"/"!==c.charAt(c.length-1)&&(c+="/"),c},buildFindManyUrlWithParent:function(a,b,c){var d,e,f;return f=b.get("id"),d=b.constructor.typeKey,e=this.buildURL(d,f),e+c+"/"},getHasManyAttributeName:function(a,b,c){var d;return b.eachRelationship(function(e,f){var g;"hasMany"===f.kind&&f.type.typeKey===a.typeKey&&(g=b._data[e].mapBy("id"),Ember.EnumerableUtils.intersection(c,g).length===c.length&&(d=e))}),d}})}(),function(){DS.DjangoDateTransform=DS.Transform.extend({deserialize:function(a){return"string"==typeof a?new Date(Ember.Date.parse(a)):"number"==typeof a?new Date(a):Ember.isEmpty(a)?a:null},serialize:function(a){return a instanceof Date&&"Invalid Date"!==a.toString()?(year=a.getFullYear(),month=a.getMonth()+1,month=10>month?"0"+month:month,day=a.getDate(),year+"-"+month+"-"+day):null}})}(),function(){DS.DjangoDatetimeTransform=DS.Transform.extend({deserialize:function(a){return"string"==typeof a?new Date(Ember.Date.parse(a)):"number"==typeof a?new Date(a):Ember.isEmpty(a)?a:null},serialize:function(a){return a instanceof Date&&"Invalid Date"!==a.toString()?a.toJSON():null}})}(),function(){Ember.Application.initializer({name:"DjangoDatetimeTransforms",initialize:function(a,b){b.register("transform:date",DS.DjangoDateTransform),b.register("transform:datetime",DS.DjangoDatetimeTransform)}})}(),function(){var a="1.0.6";DS.DjangoRESTSerializer.VERSION=a,DS.DjangoRESTAdapter.VERSION=a,Ember.libraries&&Ember.libraries.register("ember-data-django-rest-adapter",a)}();