define(["app"],function(a){"use strict";a.registerController("TodoCtrl",["$scope","$timeout","Todo",function(a,b,c){a.newTodo=void 0,a.states=["Critical","Important","Completed"],a.todos=c.query({}),a.toggleCompleted=function(a){a.completedAt?(a.state="Critical",a.completedAt=null):(a.state="Completed",a.completedAt=new Date),a.$update()},a.updateTodoState=function(a,b){a.state=b,a.completedAt="Completed"==b?JSON.stringify(new Date):null,a.$update()},a.toggleAdd=function(){a.newTodo=a.newTodo?void 0:new c({state:"Important"})},a.createTodo=function(){a.newTodo.$save(function(b){a.todos.push(b),a.newTodo=void 0})},a.deleteTodo=function(b){b.$delete(function(){a.todos.splice(a.todos.indexOf(b),1)})}}])});