define('ember-cli-simple-store/initializers/ember-cli-simple-store', ['exports', 'ember-cli-simple-store/store'], function (exports, Store) {

    'use strict';

    exports['default'] = function(container, application) {
        application.register('store:main', Store['default']);
        application.inject('controller', 'store', 'store:main');
        application.inject('route', 'store', 'store:main');
    }

});
define('ember-cli-simple-store/model', ['exports', 'ember'], function (exports, Ember) {

    'use strict';

    function factory(obj) {
        return obj.get("constructor.ClassMixin.ownerConstructor");
    }

    function attrs(obj) {
        var all = [];
        factory(obj).eachComputedProperty(function (key, meta) {
            if (meta.isAttribute) {
                all.push(key);
            }
        });
        return all;
    }

    function clone(obj) {
        var copy = {};
        factory(obj).eachComputedProperty(function (key, meta) {
            if (meta.isAttribute) {
                copy[key] = obj.get(key);
            }
        });
        return copy;
    }

    var attr = function() {
        var meta = {isAttribute: true};
        return function(key, value) {
            var data = this.get("_data") || {};
            var dirty = this.get("_dirty") || {};
            if (arguments.length === 2) {
                if (!this.get("isDirty")) {
                    var oldState = clone(this);
                    this.set("_oldState", oldState);
                }
                var primed = value === "" && !data[key];
                if(!primed) {
                    this.set("isDirty", true);
                    dirty["%@:isDirty".fmt(key)] = true;
                    data[key] = value;
                }
            }
            return data[key];
        }.property("_data").meta(meta);
    };

    var Model = Ember['default'].Object.extend({
        init: function() {
            this.set("_data", {});
            this._reset();
            this._setup();
        },
        rollback: function() {
            var oldState = this.get("_oldState");
            for(var key in oldState){
                this.set(key, oldState[key]);
            }
            this._reset();
        },
        save: function() {
            var oldState = clone(this);
            this.set("_oldState", oldState);
            this._reset();
        },
        _reset: function() {
            this.set("isDirty", false);
            this.set("_dirty", {});
        },
        _setup: function() {
            var self = this;
            attrs(this).forEach(function(attrName) {
                var dynamicKey = "%@IsDirty".fmt(attrName);
                Ember['default'].defineProperty(self, dynamicKey, Ember['default'].computed(function() {
                    var dirty = this.get("_dirty");
                    var dirtyKey = "%@:isDirty".fmt(attrName);
                    return dirty[dirtyKey];
                }).property("_dirty", "" + attrName));
            });
        }
    });

    exports.attr = attr;
    exports.Model = Model;

});
define('ember-cli-simple-store/store', ['exports', 'ember'], function (exports, Ember) {

    'use strict';

    function buildRecord(type, data, store) {
        var containerKey = "model:" + type;
        var factory = store.container.lookupFactory(containerKey);

        Ember['default'].assert("No model was found for type: " + type, factory);

        var record = factory.create(data);
        var id = data.id;
        identityMapForType(type, store)[id] = record;
        arrayForType(type, store).pushObject(record);
        return record;
    }

    function arrayForType(type, store) {
        var all = store.get("array");
        var models = all[type] || [];
        all[type] = models;
        return models;
    }

    function identityMapForType(type, store) {
        var typeIdentityMap = store.get("identityMap");
        var idIdentityMap = typeIdentityMap[type] || {};
        typeIdentityMap[type] = idIdentityMap;
        return idIdentityMap;
    }

    var Store = Ember['default'].Object.extend({
        init: function() {
            this.set("identityMap", {});
            this.set("array", {});
        },
        clear: function(type) {
            delete this.get("identityMap")[type];
            arrayForType(type, this).clear();
        },
        push: function(type, data) {
            var record = this._findById(type, data.id);
            if (record) {
                record.setProperties(data);
            } else {
                record = buildRecord(type, data, this);
            }
            return record;
        },
        remove: function(type, id) {
            var record = this._findById(type, id);
            if (record) {
                delete this.get("identityMap")[type][record.id];
                arrayForType(type, this).removeObject(record);
            }
        },
        find: function(type, options) {
            if (typeof options === "undefined") {
                return this._findAll(type);
            }
            if (typeof options === "object") {
                var params = Object.keys(options);

                Ember['default'].assert("No key was found in the filter options", params.length);

                var attr = params[0];
                var value = options[attr];
                return this._findWithFilter(type, attr, value);
            }
            return this._findById(type, options);
        },
        findOne: function(type) {
            var all = this._findAll(type);
            return all.length > 0 ? all.objectAt(0) : null;
        },
        _findById: function(type, id) {
            var identityMap = identityMapForType(type, this);
            return identityMap[id] || null;
        },
        _findAll: function(type) {
            return arrayForType(type, this);
        },
        _findWithFilter: function(type, filter_attr, filter_value) {
            var computed_string = "source.@each." + filter_attr;
            return Ember['default'].ArrayProxy.extend({
              source: undefined,
              content: function () {
                var filter_value = this.get("filter_value");
                return this.get("source").filterBy(filter_attr, filter_value);
              }.property(computed_string)
            }).create({
              filter_value: filter_value,
              source: this._findAll(type)
            });
        }
    });

    exports['default'] = Store;

});
define("ember-cli-simple-store", ["ember-cli-simple-store/index","exports"], function(__index__, __exports__) {
  "use strict";
  Object.keys(__index__).forEach(function(key){
    __exports__[key] = __index__[key];
  });
});
//# sourceMappingURL=ember-cli-simple-store.map