errStr="Parse error on line "+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'";
}else{
errStr="Parse error on line "+(yylineno+1)+": Unexpected "+(symbol==1?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'");
(function(){vart=function(e,n){varr=t.resolve(e,n||"/"),i=t.modules[r];if(!i)throwError("Failed to resolve module "+e+", tried "+r);varo=t.cache[r],s=o?o.exports:i();returns};t.paths=[],t.modules={},t.cache={},t.extensions=[".js",".coffee",".json"],t._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},t.resolve=function(){returnfunction(e,n){functionr(e){if(e=a.normalize(e),t.modules[e])returne;for(varn=0;t.extensions.length>n;n++){varr=t.extensions[n];if(t.modules[e+r])returne+r}}functioni(e){e=e.replace(/\/+$/,"");varn=a.normalize(e+"/package.json");if(t.modules[n]){vari=t.modules[n](),o=i.browserify;if("object"==typeofo&&o.main){vars=r(a.resolve(e,o.main));if(s)returns}elseif("string"==typeofo){vars=r(a.resolve(e,o));if(s)returns}elseif(i.main){vars=r(a.resolve(e,i.main));if(s)returns}}returnr(e+"/index")}functiono(t,e){for(varn=s(e),o=0;n.length>o;o++){vara=n[o],l=r(a+"/"+t);if(l)returnl;varh=i(a+"/"+t);if(h)returnh}varl=r(t);returnl?l:void0}functions(t){vare;e="/"===t?[""]:a.normalize(t).split("/");for(varn=[],r=e.length-1;r>=0;r--)if("node_modules"!==e[r]){vari=e.slice(0,r+1).join("/")+"/node_modules";n.push(i)}returnn}if(n||(n="/"),t._core[e])returne;vara=t.modules.path();n=a.resolve("/",n);varl=n||"/";if(e.match(/^(?:\.\.?\/|\/)/)){varh=r(a.resolve(l,e))||i(a.resolve(l,e));if(h)returnh}varu=o(e,l);if(u)returnu;throwError("Cannot find module '"+e+"'")}}(),t.alias=function(e,n){varr=t.modules.path(),i=null;try{i=t.resolve(e+"/package.json","/")}catch(o){i=t.resolve(e,"/")}for(vars=r.dirname(i),a=(Object.keys||function(t){vare=[];for(varnint)e.push(n);returne})(t.modules),l=0;a.length>l;l++){varh=a[l];if(h.slice(0,s.length+1)===s+"/"){varu=h.slice(s.length);t.modules[n+u]=t.modules[s+u]}elseh===s&&(t.modules[n]=t.modules[s])}},function(){vare={},n="undefined"!=typeofwindow?window:{},r=!1;t.define=function(i,o){!r&&t.modules.__browserify_process&&(e=t.modules.__browserify_process(),r=!0);vars=t._core[i]?"":t.modules.path().dirname(i),a=function(e){varn=t(e,s),r=t.cache[t.resolve(e,s)];returnr&&null===r.parent&&(r.parent=l),n};a.resolve=function(e){returnt.resolve(e,s)},a.modules=t.modules,a.define=t.define,a.cache=t.cache;varl={id:i,filename:i,exports:{},loaded:!1,parent:null};t.modules[i]=function(){returnt.cache[i]=l,o.call(l.exports,a,l,l.exports,s,i,e,n),l.loaded=!0,l.exports}}}(),t.define("path",function(t,e,n,r,i,o){functions(t,e){for(varn=[],r=0;t.length>r;r++)e(t[r],r,t)&&n.push(t[r]);returnn}functiona(t,e){for(varn=0,r=t.length;r>=0;r--){vari=t[r];"."==i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");returnt}varl=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(vart="",e=!1,n=arguments.length;n>=-1&&!e;n--){varr=n>=0?arguments[n]:o.cwd();"string"==typeofr&&r&&(t=r+"/"+t,e="/"===r.charAt(0))}returnt=a(s(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."},n.normalize=function(t){vare="/"===t.charAt(0),n="/"===t.slice(-1);returnt=a(s(t.split("/"),function(t){return!!t}),!e).join("/"),t||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t},n.join=function(){vart=Array.prototype.slice.call(arguments,0);returnn.normalize(s(t,function(t){returnt&&"string"==typeoft}).join("/"))},n.dirname=function(t){vare=l.exec(t)[1]||"",n=!1;returne?1===e.length||n&&3>=e.length&&":"===e.charAt(1)?e:e.substring(0,e.length-1):"."},n.basename=function(t,e){varn=l.exec(t)[2]||"";returne&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){returnl.exec(t)[3]||""}}),t.define("__browserify_process",function(t,e,n,r,i,o){varo=e.exports={};o.nextTick=function(){vart="undefined"!=typeofwindow&&window.setImmediate,e="undefined"!=typeofwindow&&window.postMessage&&window.addEventListener;if(t)returnfunction(t){returnwindow.setImmediate(t)};if(e){varn=[];returnwindow.addEventListener("message",function(t){if(t.source===window&&"browserify-tick"===t.data&&(t.stopPropagation(),n.length>0)){vare=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("browserify-tick","*")}}returnfunction(t){setTimeout(t,0)}}(),o.title="browser",o.browser=!0,o.env={},o.argv=[],o.binding=function(e){if("evals"===e)returnt("vm");throwError("No such module. (Possibly not yet loaded)")},function(){vare,n="/";o.cwd=function(){returnn},o.chdir=function(r){e||(e=t("path")),n=e.resolve(r,n)}}()}),t.define("/collection.coffee",function(t,e,n){(function(){vare,r,i,o,s=function(t,e){returnfunction(){returnt.apply(e,arguments)}},a={}.hasOwnProperty,l=function(t,e){functionn(){this.constructor=t}for(varrine)a.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};o=t("./view").View,i=t("./util"),n.Collection=r=function(t){functione(){returnthis.draw=s(this.draw,this),this.createView=s(this.createView,this),this.refresh=s(this.refresh,this),this.afterRender=s(this.afterRender,this),this.release=s(this.release,this),this.init=s(this.init,this),e.__super__.constructor.apply(this,arguments)}returnl(e,t),e.prototype.tag="ul",e.prototype.skipTemplate=!0,e.prototype.init=function(){vart,n;returne.__super__.init.apply(this,arguments),i.log("collection","init"),this.itemViews={},this.localMozartModel=i._getPath("Mozart.Model"),this.localMozartInstanceCollection=i._getPath("Mozart.InstanceCollection"),null!=this.filterAttribute&&(this.bind("change:filterAttribute",this.draw),this.bind("change:filterText",this.draw)),null!=this.sortAttribute&&(this.bind("change:sortAttribute",this.draw),this.bind("change:sortDescending",this.draw)),null==this.pageSize&&this.set("pageSize",1e4),null==this.pageCurrent&&this.set("pageCurrent",0),this.bind("change:pageSize",this.draw),this.bind("change:pageCurrent",this.draw),null==(n=this.method)&&(this.method="all"),this.bind("change:collection",this.afterRender),this.bind("change:method",this.afterRender),"function"==typeof(t=this.collection).bind?t.bind("change",this.afterRender):void0},e.prototype.release=function(){vart;return"function"==typeof(t=this.collection).unbind&&t.unbind("change",this.afterRender),e.__super__.release.apply(this,arguments)},e.prototype.afterRender=function(){returnthis.refresh(),this.draw()},e.prototype.refresh=function(){vart,e,n,r,o,s,a,l,h,u,c,d,p,f,g,y;if(i.log("collection","refresh"),this.dataSet={},null!=this.collection)if(i.isObject(this.collection)){if(i.isFunction(this.collection[this.method+"AsMap"]))this.dataSet=this.collection[this.method+"AsMap"]();elseif(i.isFunction(this.collection[this.method]))for(c=this.collecton[this.method](),o=0,l=c.length;l>o;o++)e=c[o],this.dataSet[e.id]=e}elseif(i.isFunction(this.collection))for(d=this.collection(),s=0,h=d.length;h>s;s++)e=d[s],this.dataSet[e.id]=e;elseif(i.isArray(this.collection))for(p=this.collection,a=0,u=p.length;u>a;a++)e=p[a],this.dataSet[e.id]=e;elseconsole.error("Collection: "+typeofthis.collection+" can't be iterated");n=[],f=this.itemViews;for(tinf)r=f[t],null==this.dataSet[t]&&n.push(t);for(y=[];n.length>0;)t=n.pop(),i.log("collection","destroyView",t,this.itemViews[t]),this.removeView(this.itemViews[t]),null!=(g=this.itemViews[t].element)&&g.remove(),this.layout.queueReleaseView(this.itemViews[t]),y.push(deletethis.itemViews[t]);returny},e.prototype.createView=function(t){vare,n;returni.log("collection","createView",t,"layout",this.layout.rootElement),e={content:t,parent:this},this.viewClass===o&&(e.tag="li"),null!=this.viewClassTemplateName&&(e.templateName=this.viewClassTemplateName),null!=this.viewClassTemplateFunction&&(e.templateFunction=this.viewClassTemplateFunction),null!=this.collectionTag&&(e.tag=this.collectionTag),null!=this.collectionClassNames&&(e.classNames=this.collectionClassNames),null!=this.tooltips&&(e.tooltips=this.tooltips),n=this.layout.createView(this.viewClass,e),this.element.append(n.createElement()),this.itemViews[t.id]=n,this.addView(n),this.layout.queueRenderView(n)},e.prototype.draw=function(){vart,e,n,r,o,s,a,l,h,u,c,d,p,f,g,y,m,v,w,b,C,M;v=this.itemViews;for(oinv)u=v[o],null!=(w=u.element)&&w.detach();if(this.displayOrder=_(this.dataSet).values(),this.hidden={},null!=this.sortAttribute&&i.sortBy(this.displayOrder,this.sortAttribute),this.sortDescending&&this.displayOrder.reverse(),null!=this.filterText&&null!=this.filterAttribute&&this.filterText.length>0)for(a=(""+this.filterText).toLowerCase(),b=this.displayOrder,d=0,g=b.length;g>d;d++)for(s=b[d],r=!0,C=this.filterAttribute.split(","),p=0,y=C.length;y>p;p++)n=C[p],c=i.getPath(s,n),null!=c&&(r=r&&-1===(""+c).toLowerCase().indexOf(a)),r&&(this.hidden[s.id]=1);for(l=this.pageCurrent*this.pageSize,t=0,h=0,e=0,M=this.displayOrder,f=0,m=M.length;m>f;f++)s=M[f],null==this.hidden[s.id]&&(l>t||e>=this.pageSize||(null==this.itemViews[s.id]&&this.createView(s),this.element.append(this.itemViews[s.id].element),e++),h++),t++;returnthis.set("pageTotal",Math.ceil(h/this.pageSize)),this.pageCurrent>this.pageTotal?this.set("pageCurrent",this.pageTotal-1):void0},e}(o),n.BoundView=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returnl(e,t),e.prototype.init=function(){returne.__super__.init.apply(this,arguments),this.content.bind("change",this.redraw)},e.prototype.release=function(){returnthis.content.unbind("change",this.redraw),e.__super__.release.apply(this,arguments)},e}(o)}).call(this)}),t.define("/view.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./object").MztObject,r=t("./util"),n.View=i=function(t){functione(){returnthis.copyHtmlAttrsToElement=o(this.copyHtmlAttrsToElement,this),this.getHtmlAttrsMap=o(this.getHtmlAttrsMap,this),this.createElement=o(this.createElement,this),this.release=o(this.release,this),this.hasAncestor=o(this.hasAncestor,this),this.removeView=o(this.removeView,this),this.namedChildViewExists=o(this.namedChildViewExists,this),this.childView=o(this.childView,this),this.addView=o(this.addView,this),this.redraw=o(this.redraw,this),this.postRender=o(this.postRender,this),this.replaceElement=o(this.replaceElement,this),this.findElementInPreparedContent=o(this.findElementInPreparedContent,this),this.reassignElements=o(this.reassignElements,this),this.prepareElement=o(this.prepareElement,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.tag="div",e.prototype.disableHtmlAttributes=!1,e.prototype.idPrefix="view",e.prototype.init=function(){vart,e,n;returnnull==(t=this.id)&&(this.id=""+this.idPrefix+"-"+this._mozartId),this.childViews={},null==(e=this.context)&&(this.context={}),this.namedChildViews={},this.valid=!0,this.domBindings={},null==(n=this.display)&&(this.display=!0),null!=this.parent&&this.parent.addView(this),null==this.templateFunction&&null==this.skipTemplate&&(null==this.templateName&&r.error("View: View has no templateName or templateFunction","view",this),this.templateFunction=HandlebarsTemplates[this.templateName]),r.log("views","view "+this.id+" init"),this.bind("change:display",this.redraw)},e.prototype.prepareElement=function(){returnthis.released?void0:(this.newElement=this.createElement(),!this.skipTemplate&&this.display?this.newElement.innerHTML=this.templateFunction(this,{data:this}):void0)},e.prototype.reassignElements=function(){vart,e,n;n=this.childViews;for(tinn)e=n[t],e.reassignElements();returnnull!=this.parent?this.el=this.parent.findElementInPreparedContent(this.id):void0},e.prototype.findElementInPreparedContent=function(t){vare;returnthis.newElement?e=this._find(this.newElement,t):null},e.prototype._find=function(t,e){varn,r,i,o,s;if(t.id===e)returnt;for(s=t.children,i=0,o=s.length;o>i;i++)if(n=s[i],r=this._find(n,e),null!=r)returnr;returnnull},e.prototype.replaceElement=function(){vart,e,n;if(!this.released&&this.el){n=this.childViews;for(tinn)e=n[t],e.replaceElement();returnthis.el!==this.newElement&&(this.oldEl=this.el,this.el.parentNode.replaceChild(this.newElement,this.el),null!=this.layout&&this.el===this.layout.rootEl&&(this.layout.rootEl=this.newElement),this.el=this.newElement,deletethis.oldEl),this.element=$(this.el)}},e.prototype.beforeRender=function(){},e.prototype.afterRender=function(){},e.prototype.postRender=function(){returnthis.released?void0:(this.createDomBinds(),this.afterRender())},e.prototype.redraw=function(){returnthis.released?void0:this.layout.queueRenderView(this)},e.prototype.addView=function(t){returnthis.childViews[t.id]=t,null!=t.name?this.namedChildViews[t.name]=t:void0},e.prototype.childView=function(t){returnthis.namedChildViews[t]},e.prototype.namedChildViewExists=function(t){returnnull!=this.namedChildViews[t]},e.prototype.releaseChildren=function(){vart,e,n;n=this.childViews;for(tinn)e=n[t],this.layout.queueReleaseView(e);returnthis.childViews={},this.namedChildViews={}},e.prototype.removeView=function(t){returnnull!=this.childViews?deletethis.childViews[t.id]:void0},e.prototype.hasAncestor=function(t){vare;for(e=this.parent;null!=e;){if(e.id===t.id)return!0;e=e.parent}return!1},e.prototype.release=function(){returnthis.released?void0:(r.log("views",this.layout,"releasing view "+this.id),this.removeDomBinds(),this.unbind(),null!=this.parent&&this.parent.removeView(this),this.releaseChildren(),this.layout.releaseView(this),e.__super__.release.apply(this,arguments))},e.prototype.createElement=function(){vart,e,n,r;if(this.display===!1)returnt=document.createElement("script"),t.setAttribute("id",this.id),t;if(t=document.createElement(this.tag),t.setAttribute("id",this.id),t.setAttribute("view",""),!this.disableHtmlAttributes){r=this.getHtmlAttrsMap();for(einr)n=r[e],t.setAttribute(e,n)}returnt},e.prototype.getHtmlAttrsMap=function(){vart,e,n;e={};for(tinthis)n=this[t],"string"==typeofthis[t]&&r.stringEndsWith(t,"Html")&&(e[r.sliceStringBefore(t,"Html")]=n);returne},e.prototype.copyHtmlAttrsToElement=function(t){returnt.attr(this.getHtmlAttrsMap()),t},e.prototype.registerDomBind=function(t,e){varn,i,o,s;returns=r.parsePath(e),o=s[0],n=s[1],i=null!=o?r.getPath(this,o):this,null==i&&r.error("View.registerDomBind (bind helper) - cannot find object "+o),this.domBindings[t]={view:this,target:i,attribute:n,element:null}},e.prototype.createDomBinds=function(){vart,e,n,i;n=this.domBindings,i=[];for(tinn)e=n[t],e.element=$("#"+t),null==e.element&&r.error("View.createDomBinds - cannot find element "+t),e.target.bind("change:"+e.attribute,this.onDomBindChange,e),i.push(e.element.text(e.target[e.attribute]));returni},e.prototype.onDomBindChange=function(t,e){returne.element.text(e.target[e.attribute])},e.prototype.removeDomBinds=function(){vart,e,n;n=this.domBindings;for(tinn)e=n[t],true===e.element&&e.target.unbind("change:"+e.attribute,this.onDomBindChange);returnthis.domBindings={}},e}(e)}).call(this)}),t.define("/object.coffee",function(t,e,n){(function(){vare,r,i,o=[].indexOf||function(t){for(vare=0,n=this.length;n>e;e++)if(einthis&&this[e]===t)returne;return-1},s=[].slice,a={}.hasOwnProperty;i=t("./util"),e=t("./events").Events,n.MztObject=r=function(){functiont(){this._mozartId=i.getId()}varn;returnn=["extended","included"],t.NOTIFY=2,t.OBSERVE=1,t.SYNC=0,t.include=function(t){vare,r,i;for(eint)r=t[e],0>o.call(n,e)&&(this[e]=r);returnnull!=(i=t.extended)&&i.apply(this),this},t.extend=function(t){vare,r,i;for(eint)r=t[e],0>o.call(n,e)&&(this.prototype[e]=r);returnnull!=(i=t.included)&&i.apply(this),this},t.create=function(t){vare,n,r;e=newthis;for(nint)r=t[n],e[n]=r;returne._bindings={},e._bindings.notify={},e._bindings.observe={},e._bindings.stored={},e._createDeclaredBinds(),e._createLookups(),"function"==typeofe.init&&e.init(),e},t.prototype.toString=function(){return"obj-"+this._mozartId},t.prototype.get=function(t){returni.isFunction(this[t])?this[t].call(this):this[t]},t.prototype.set=function(t,e){varn,r,i,o,s,a,l;if(o=this[t],o!==e){if(oinstanceofMozart.MztObject&&(this._bindings.stored[t]={notify:o._stripNotifyBindings(!0),observe:o._stripObserveBindings(!0)},this._bindings.stored[t].notify==={}&&this._bindings.stored[t].observe==={}&&deletethis._bindings.stored[t]),null!=this._bindings.stored[t]&&null!=this._bindings.stored[t].notify&&null===e){l=this._bindings.stored[t].notify;for(iinl)for(r=l[i],s=0,a=r.length;a>s;s++)n=r[s],n.target.set(n.attr,null)}returneinstanceofMozart.MztObject&&null!=this._bindings.stored[t]&&(this._bindings.stored[t].notify!=={}&&e._addNotifyBindings(this._bindings.stored[t].notify),this._bindings.stored[t].observe!=={}&&e._addObserveBindings(this._bindings.stored[t].observe),deletethis._bindings.stored[t]),this[t]=e,this._doNotifyBinding(t),this.trigger("change"),this.trigger("change:"+t)}},t.prototype.bind=function(){vart;returnt=arguments.length>=1?s.call(arguments,0):[],e.bind.apply(e,[this._mozartId].concat(s.call(t))),this},t.prototype.one=function(){vart;returnt=arguments.length>=1?s.call(arguments,0):[],e.one.apply(e,[this._mozartId].concat(s.call(t))),this},t.prototype.trigger=function(){vart;returnt=arguments.length>=1?s.call(arguments,0):[],e.trigger.apply(e,[this._mozartId].concat(s.call(t))),this},t.prototype.unbind=function(){vart;returnt=arguments.length>=1?s.call(arguments,0):[],e.unbind.apply(e,[this._mozartId].concat(s.call(t))),this},t.prototype.release=function(){vart,e;if(!this.released){this._removeAllBindings(),this.unbind();for(tinthis)a.call(this,t)&&(e=this[t],this[t]=void0,deletethis[t]);returnthis.released=!0}},t.prototype._stripNotifyBindings=function(e){varn,r,i,o,s,a;null==e&&(e=!1),r={},a=this._bindings.notify;for(iina)for(r=a[i],r[i]=[],o=0,s=r.length;s>o;o++)n=r[o],(!e||n.transferable)&&(r[i].push(n),this._removeBinding(i,n.target,n.attr,t.NOTIFY));returnr},t.prototype._addNotifyBindings=function(e){varn,r,i,o;o=[];for(iine)r=e[i],o.push(function(){vare,o,s;for(s=[],e=0,o=r.length;o>e;e++)n=r[e],s.push(this._createBinding(i,n.target,n.attr,t.NOTIFY,n.transferable));returns}.call(this));returno},t.prototype._stripObserveBindings=function(e){varn,r,i,o,s,a;null==e&&(e=!1),r={},a=this._bindings.observe;for(iina)for(r=a[i],r[i]=[],o=0,s=r.length;s>o;o++)n=r[o],(!e||n.transferable)&&(r[i].push(n),this._removeBinding(i,n.source,n.attr,t.OBSERVE,n.transferable));returnr},t.prototype._addObserveBindings=function(e){varn,r,i,o;o=[];for(iine)r=e[i],o.push(function(){vare,o,s;for(s=[],e=0,o=r.length;o>e;e++)n=r[e],s.push(this._createBinding(i,n.source,n.attr,t.OBSERVE,n.transferable));returns}.call(this));returno},t.prototype._createDeclaredBinds=function(){vare,n,r,o,s,a,l,h;h=[];for(ninthis)a=this[n],!i.isFunction(this[n])&&i.stringEndsWith(n,"Binding")&&(n=i.sliceStringBefore(n,"Binding"),s=t.SYNC,i.stringEndsWith(n,"Observe")?(n=i.sliceStringBefore(n,"Observe"),s=t.OBSERVE):i.stringEndsWith(n,"Notify")&&(n=i.sliceStringBefore(n,"Notify"),s=t.NOTIFY),l=i.parsePath(a),o=l[0],e=l[1],r=null!=o?i._getPath(this,o):this,h.push(this._createBinding(n,r,e,s,i.isAbsolutePath(a))));returnh},t.prototype._createBinding=function(e,n,r,i,o){vars,a,l,h;switch(i){caset.NOTIFY:returnnull==(l=(s=this._bindings.notify)[e])&&(s[e]=[]),this._bindings.notify[e].push({attr:r,target:n,transferable:o}),ninstanceoft&&(null==(h=(a=n._bindings.observe)[r])&&(a[r]=[]),n._bindings.observe[r].push({attr:e,source:this,transferable:o})),this._doNotifyBinding(e);caset.OBSERVE:returnninstanceoft?n._createBinding(r,this,e,t.NOTIFY,o):console.warn("Binding "+e+"ObserveBinding on",this,": target",n,"is not a MztObject");caset.SYNC:returnthis._createBinding(e,n,r,t.OBSERVE,o),this._createBinding(e,n,r,t.NOTIFY,o)}},t.prototype._removeBinding=function(e,n,r,i){varo,s,a,l,h,u,c,d,p,f,g,y;switch(i){caset.NOTIFY:a={},p=this._bindings.notify;for(linp)for(s=p[l],h=0,c=s.length;c>h;h++)o=s[h],o.attr!==r&&o.target!==n&&(null==(f=a[l])&&(a[l]=[]),a[l].push(o));if(this._bindings.notify=a,ninstanceoft){a={},g=n._bindings.observe;for(ling)for(s=g[l],u=0,d=s.length;d>u;u++)o=s[u],o.attr!==e&&o.source!==this&&(null==(y=a[l])&&(a[l]=[]),a[l].push(o));returnn._bindings.observe=a}break;caset.OBSERVE:if(ninstanceoft)returnn._removeBinding(r,this,e,t.NOTIFY);break;caset.SYNC:returnthis._removeBinding(e,n,r,t.NOTIFY),this._removeBinding(e,n,r,t.OBSERVE)}},t.prototype._removeAllBindings=function(){returnthis._stripObserveBindings(!1),this._stripNotifyBindings(!1)},t.prototype._doNotifyBinding=function(t){vare,n,r,o,s;if(n=this._bindings.notify[t],null!=n){for(s=[],r=0,o=n.length;o>r;r++)e=n[r],null!=e?i.isFunction(e.target.set)?s.push(e.target.set(e.attr,this.get(t))):s.push(e.target[e.attr]=this.get(t)):s.push(void0);returns}},t.prototype._createLookups=function(){vart,e,n;n=[];for(tinthis)e=this[t],!i.isFunction(this[t])&&i.stringEndsWith(t,"Lookup")&&(t=i.sliceStringBefore(t,"Lookup"),n.push(this[t]=i._getPath(e)));returnn},t}()}).call(this)}),t.define("/util.coffee",function(t,e){(function(){vart,n,r,i=[].slice,o={}.hasOwnProperty;r={},n=0,t=e.exports={toString:Object.prototype.toString,getType:function(t){returnthis.toString.call(t).match(/^\[object\s(.*)\]$/)[1]},isObject:function(t){return"Object"===this.getType(t)},isFunction:function(t){return"Function"===this.getType(t)},isArray:function(t){return"Array"===this.getType(t)},isString:function(t){return"String"===this.getType(t)},isBoolean:function(t){return"Boolean"===this.getType(t)},log:function(){vart,e;returne=arguments[0],t=arguments.length>=2?i.call(arguments,1):[],null!=r[e]&&"undefined"!=typeofconsole&&null!==console?console.log.apply(console,[e+":"].concat(i.call(t))):void0},showLog:function(t){returnr[t]=!0},hideLog:function(t){returnr[t]=!1},error:function(){vart,e;throwe=arguments[0],t=arguments.length>=2?i.call(arguments,1):[],"undefined"!=typeofconsole&&null!==console&&console.error("Exception:",e,t),e},warn:function(){vart,e;returne=arguments[0],t=arguments.length>=2?i.call(arguments,1):[],"undefined"!=typeofconsole&&null!==console?console.log("Warning:",e,t):void0},clone:function(t){return$.extend({},t)},getPath:function(t,e){varn;if(n=this._getPath(t,e),void0===n)throwError("Object "+t+" has no "+e);returnn},isAbsolutePath:function(t){returnt[0].toUpperCase()===t[0]},_getPath:function(e,n){varr,i,o;for(null!=e&&null==n&&(n=e,e=Mozart.root),t.isAbsolutePath(n)&&(e=Mozart.root),r=n.split(".");r.length>0;){if(i=r.shift(),"this"!==i){if(void0===e[i])returnvoid0;if(o=t.isFunction(e.get)?e.get.call(e,i):e[i],null===o&&r.length>0)returnvoid0}elseo=e;e=o}returno},getId:function(){return++n},parsePath:function(t){vare,n;return-1===t.indexOf(".")?[null,t]:(n=t.split("."),e=n.pop(),[n.join("."),e])},toMap:function(t,e){varn,r,i,o;for(null==e&&(e="id"),r={},i=0,o=t.length;o>i;i++)n=t[i],r[n[e]]=n;returnr},sortBy:function(e,n){returnn=t.parseSort(n),e.sort(function(t,e){varr,i,o,s,a;for(s=0,a=n.length;a>s;s++)if(o=n[s],r="function"==typeoft[o]?t[o]():t[o],i="function"==typeofe[o]?e[o]():e[o],null!=r&&null!=i){if(null==r)return-1;if(null==i)return1;if(r=(""+r).toLowerCase(),i=(""+i).toLowerCase(),r>i)return1;if(i>r)return-1}})},parseSort:function(t,e){varn,r,i;for(null==e&&(e={pos:0}),i=[],r="";e.pos<t.length;)switch(n=t[e.pos++]){case",":r.length>0&&(i.push(r),r="");break;case"[":if(r.length>0)throwError("parseSort: Unexpected Character [ at "+(""+e.pos));i.push(this.parseSort(t,e));break;case"]":returnr.length>0&&i.push(r),i;default:r+=n}returnr.length>0&&(i.push(r),r=""),i},toCapsCase:function(t){vare;returne=t.replace(/^[a-z]{1,1}/g,function(t){returnt.toUpperCase()}),e=e.replace(/_[a-z]{1,1}/g,function(t){returnt.toUpperCase()}),e=e.replace(/_/g,"")},toSnakeCase:function(t){vare;returne=t.replace(/[A-Z]{1,1}/g,function(t){return"_"+t.toLowerCase()}),e.replace(/^_/,"")},sliceStringBefore:function(t,e){returnt.slice(0,t.length-e.length)},sliceStringAfter:function(t,e){returnt.slice(e.length)},stringEndsWith:function(t,e){varn;returnn=e.length,t.length>=n&&t.slice(-n)===e},stringStartsWith:function(t,e){varn;returnn=e.length,t.length>=n&&t.slice(0,n)===e},addBindingsParent:function(e){varn,r,i;i=[];for(nine)o.call(e,n)&&(r=e[n],t.stringEndsWith(n,"Binding")&&null!=r&&null!=r.length&&r.length>0&&r[0]!==r[0].toUpperCase()?i.push(e[n]="parent."+e[n]):i.push(void0));returni}}}).call(this)}),t.define("/events.coffee",function(t,e,n){(function(){vare,r;r=t("./util"),n.Events=e=function(){functiont(){}returnt.callbacks={},t.eventInit=function(e,n){varr,i,o,s;returnnull==(o=(r=t.callbacks)[e])&&(r[e]={count:0,events:{}}),null!=(s=(i=t.callbacks[e].events)[n])?s:i[n]={}},t.trigger=function(e,n,i){varo,s,a,l,h,u,c;if(null!=t.callbacks[e]&&null!=t.callbacks[e].events[n]){a=[],u=t.callbacks[e].events[n];for(sinu)o=u[s],null==o.fn.call&&r.log("general","callback issue ",o.fn),o.fn.call(this,i,o.binddata),o.once&&a.push({objectId:e,eventName:n,id:s});for(c=[],l=0,h=a.length;h>l;l++)o=a[l],c.push(deletet.callbacks[o.objectId].events[o.eventName][o.id]);returnc}},t.one=function(e,n,r,i){returnt.eventInit(e,n),t.callbacks[e].events[n][t.callbacks[e].count++]={fn:r,binddata:i,once:!0}},t.bind=function(e,n,r,i){returnt.eventInit(e,n),t.callbacks[e].events[n][t.callbacks[e].count++]={fn:r,binddata:i}},t.unbind=function(e,n,r){vari,o,s,a,l,h;{if(null==r||null==t.callbacks[e]||null==t.callbacks[e].events[n])returnnull!=n&&null!=t.callbacks[e]&&null!=t.callbacks[e].events[n]?(deletet.callbacks[e].events[n],void0):deletet.callbacks[e];s=[],h=t.callbacks[e].events[n];for(oinh)i=h[o],i.fn===r&&s.push(o);for(a=0,l=s.length;l>a;a++)o=s[a],deletet.callbacks[e].events[n][o]}},t.getBinds=function(e,n){return_(t.callbacks[e].events[n]).values()},t}()}).call(this)}),t.define("/control.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};r=t("./view").View,n.Control=e=function(t){functione(){returnthis.afterRender=i(this.afterRender,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.idPrefix="control",e.prototype.error=function(t){returnthis.help=t,this.errorState=!0},e.prototype.afterRender=function(){returnthis.errorState?this.element.addClass("error"):void0},e}(r)}).call(this)}),t.define("/controller.coffee",function(t,e,n){(function(){vare,r,i={}.hasOwnProperty,o=function(t,e){functionn(){this.constructor=t}for(varrine)i.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};r=t("./object").MztObject,n.Controller=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returno(e,t),e}(r)}).call(this)}),t.define("/data-index.coffee",function(t,e,n){(function(){vare,r,i,o,s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};o=t("./object").MztObject,n.DataIndex=r=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returna(e,t),e.indexTypes={},e.prototype.load=function(){throwError("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.add=function(){throwError("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.remove=function(){throwError("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.update=function(){throwError("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.rebuild=function(){throwError("Mozart.DataIndex: Abstract, Not Implemented")},e.registerIndexClassType=function(t,e){returnthis.indexTypes[t]=e},e.getIndexClassType=function(t){returnthis.indexTypes[t]},e}(o),n.MapIndex=i=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.init=function(){returnthis.map={},this.rebuild()},e.prototype.load=function(t){returnnull!=this.map[t]?this.map[t]:{}},e.prototype.update=function(t,e,n){varr,i;returnnull!=this.map[e]&&(deletethis.map[e][t.id],0===_(this.map[e]).keys().length&&deletethis.map[e]),null==(i=(r=this.map)[n])&&(r[n]={}),this.map[n][t.id]=t},e.prototype.add=function(t){vare,n,r;returnnull==(r=(e=this.map)[n=t[this.attribute]])&&(e[n]={}),this.map[t[this.attribute]][t.id]=t},e.prototype.remove=function(t){vare,n,r,i;r=this.map,i=[];for(ninr)e=r[n],deletee[t.id],0===_(e).keys().length?i.push(deletethis.map[n]):i.push(void0);returni},e.prototype.rebuild=function(){vart,e,n,r,i;for(this.map={},r=this.modelClass.all(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(this.add(t));returni},e}(r),r.registerIndexClassType("map",i),n.BooleanIndex=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.init=function(){returnthis.value=this.options.value,this.rebuild()},e.prototype.load=function(t){returnt===this.value?this.valueIds:this.nonValueIds},e.prototype.update=function(t,e,n){returne===this.value?deletethis.valueIds[t.id]:deletethis.nonValueIds[t.id],n===this.value?this.valueIds[t.id]=t:this.nonValueIds[t.id]=t},e.prototype.add=function(t){returnt[this.attribute]===this.value?this.valueIds[t.id]=t:this.nonValueIds[t.id]=t},e.prototype.remove=function(t){returndeletethis.valueIds[t.id],deletethis.nonValueIds[t.id]},e.prototype.rebuild=function(){vart,e,n,r,i;for(this.valueIds={},this.nonValueIds={},r=this.modelClass.all(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(this.add(t));returni},e}(r),r.registerIndexClassType("boolean",e)}).call(this)}),t.define("/dom-manager.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t},l=[].indexOf||function(t){for(vare=0,n=this.length;n>e;e++)if(einthis&&this[e]===t)returne;return-1};i=t("./util"),r=t("./object").MztObject,n.DOMManager=e=function(t){functione(){returnthis.getControlOptionsValues=o(this.getControlOptionsValues,this),this.onControlEvent=o(this.onControlEvent,this),this.onViewEvent=o(this.onViewEvent,this),this.onApplicationEvent=o(this.onApplicationEvent,this),this.release=o(this.release,this),this.checkClickOutside=o(this.checkClickOutside,this),this.checkClickInside=o(this.checkClickInside,this),this.find=o(this.find,this),e.__super__.constructor.apply(this,arguments)}varn;returna(e,t),n={click:"click",dblclick:"dblClick",focus:"focus",blur:"blur",keyup:"keyUp",keydown:"keyDown",keypress:"keyPress",focusout:"focusOut",focusin:"focusIn",change:"change",mouseover:"mouseOver",mouseout:"mouseOut"},e.prototype.init=function(){vart,e,r,i,o;this.element=$(this.rootElement);for(tinn)i=n[t],this.element.on(t,null,{eventName:i},this.onApplicationEvent);returne=function(){vart;t=[];for(rinn)o=n[r],t.push(r);returnt}().join(""),this.element.on(e,"[view]",this.onViewEvent),this.element.on(e,"[data-mozart-action]",this.onControlEvent),this.openElements={}},e.prototype.find=function(t){vare,n,r,o,s,a;for(a=this.layouts,o=0,s=a.length;s>o;o++){if(r=a[o],null!=r.views[t])returni.log("general",""+t+": view of",r.rootElement),r.views[t];if(e=r.getControl(t),null!=e)returni.log("general",""+t+": control of",r.rootElement),e}returnn=$("#"+t),n.length>0?(i.log("general",""+t+" is a an element"),n[0]):i.log("general","Cannot find ID "+t)},e.prototype.checkClickInside=function(t){vare,n,r,o,s,a,l;if("click"===t.type){for(a=this.layouts,l=[],o=0,s=a.length;s>o;o++)n=a[o],l.push(function(){varo,s;o=n.hasClickInside,s=[];for(eino)r=o[e],$(t.target).parents("#"+e).length>0?(i.log("events","clickInside on",r,"(",t,")"),s.push(r.clickInside())):s.push(void0);
returns}());returnl}},e.prototype.checkClickOutside=function(t){vare,n,r,o,s,a,l;if("click"===t.type){for(a=this.layouts,l=[],o=0,s=a.length;s>o;o++)n=a[o],l.push(function(){varo,s;o=n.hasClickOutside,s=[];for(eino)r=o[e],0===$(t.target).parents("#"+e).length?(i.log("events","clickOutside on",r,"(",t,")"),s.push(r.clickOutside())):s.push(void0);returns}());returnl}},e.prototype.release=function(){vart,r,i,o,s;for(tinn)o=n[t],this.element.off(t,null,this._checkRootEvent);returnr=function(){vart;t=[];for(iinn)s=n[i],t.push(i);returnt}().join(""),this.element.off(r,"[view]",this.onViewEvent),this.element.off(r,"[data-mozart-action]",this.onControlEvent),e.__super__.release.apply(this,arguments)},e.prototype.onApplicationEvent=function(t){returnthis.trigger(t.data.eventName,t)},e.prototype.onViewEvent=function(t){vare,r,o,s,a,l,h,u;if(this.checkClickInside(t),a=null,e=s=t.currentTarget,null!=e){for(u=this.layouts,l=0,h=u.length;h>l;l++)r=u[l],a=r.views[e.id],null!=a&&(o=n[t.type],this.trigger("viewEvent",t,a),"function"==typeofa[o]&&(i.log("events",o,"on",a,"(",t,")"),a[o](t,a)));returnthis.checkClickOutside(t),!0}},e.prototype.onControlEvent=function(t){vare,n,r,o,s,a,h,u;for(this.checkClickInside(t),n=$(t.currentTarget),r=n.attr("data-mozart-action"),i.log("controls","action",t),h=this.layouts,s=0,a=h.length;a>s;s++)o=h[s],e=o.getControl(r),null!=e&&(null===e.events||(u=t.type,l.call(e.events,u)>=0))&&("function"==typeofe.view[e.action]?(i.log("events","method",e.action,"on",e.view,"(",t,")"),i.log("controls","action on control",e,t),this.trigger("controlEvent",t,e),e.view[e.action](n,this.getControlOptionsValues(e.view,e.options),t),e.allowDefault||t.preventDefault()):i.warn("Action "+e.action+" does not exist on view "+e.view.id+", "+e.view.name,e));returnthis.checkClickOutside(t),t.stopImmediatePropagation()},e.prototype.getControlOptionsValues=function(t,e){varn,r,o,s;o={};for(nine)s=e[n],i.stringEndsWith(n,"Lookup")?(r=i.sliceStringBefore(n,"Lookup"),o[r]=i._getPath(t,s)):o[n]=s;returno},e}(r)}).call(this)}),t.define("/handlebars.coffee",function(t){(function(){vare,n,r,i,o,s;r=t("./util"),i=t("./view").View,n=t("./i18n-view").I18nView,e=t("./collection").Collection,o=function(t,e){returnr._getPath(t,e)},s=function(t,e){varn;return"string"==typeofe?n=r._getPath(t,e):"function"==typeofe&&(n=e.call(t)),n},Handlebars.registerHelper("site",function(){returnnewHandlebars.SafeString("/#")}),Handlebars.registerHelper("bind",function(t,e){varn,i,o,s,a,l,h;r.log("handlebars","handlebars helper 'bind':",this,t,e),1===arguments.length&&r.error("Bind helper must have a target."),n="bind"+r.getId(),s=null!=(l=e.hash.tag)?l:"span",i="<"+s+" id='"+n+"'",h=e.hash;for(oinh)a=h[o],r.stringEndsWith(o,"Html")&&(i+=""+r.sliceStringBefore(o,"Html")+'="'+a+'"');returni+="></"+s+">",e.data.registerDomBind(n,t),newHandlebars.SafeString(i)}),Handlebars.registerHelper("i18n",function(t,e){varn,i,o;returnr.log("handlebars","handlebars helper 'i18n':",this,t,e),1===arguments.length?(n="",r.error("i18n helper usage must reference a key.")):(i=r._getPath(window,"i18n."+t),null==i?(r.error("i18n helper: key '"+t+"' does not exist in current language file."),n=""):(o=null!=e&&null!=e.hash?Mozart.MztObject.create(e.hash):{},n=r.getPath(window,"i18n."+t)(o))),newHandlebars.SafeString(n)}),Handlebars.registerHelper("bindI18n",function(t,e){vari,o,s,a,l,h,u;if(r.log("handlebars","handlebars helper 'bindI18n':",this,t,e),1===arguments.length&&r.error("bindI18n helper must have a target."),l={context:this,i18nTemplate:t,parent:e.data},null!=e.hash){r.addBindingsParent(e.hash),u=e.hash;for(oinu)a=u[o],l[o]=a}returnh=l.parent.layout.createView(n,l),l.parent.addView(h),s=h.createElement(),i=s.outerHTML,null==i&&(i=""),l.parent.layout.queueRenderView(h),newHandlebars.SafeString(i)}),Handlebars.registerHelper("view",function(t,e){varn,o,s,a,l,h,u,c,d;if(r.log("handlebars","handlebars helper 'view':",this,t,e),1===arguments.length&&(e=t,t=null),s=e.data,u=null!=t?"string"==typeoft?r._getPath(t):t:i,null==u&&r.error("view handlebars helper: viewClass does not exist","context",t,"this",this),c={context:this,parent:s},null!=e.fn&&(c.templateFunction=e.fn),null!=e.hash){r.addBindingsParent(e.hash),d=e.hash;for(oind)l=d[o],c[o]=l}returnh=s.layout.createView(u,c),s.addView(h),a=h.createElement(),n=a.outerHTML,null==n&&(n=""),s.layout.queueRenderView(h),newHandlebars.SafeString(n)}),Handlebars.registerHelper("collection",function(t,n){varo,s,a,l,h,u,c,d,p,f;r.log("handlebars","handlebars helper 'collection':",this,r.clone(t),n),1===arguments.length?(n=t,t=null,d=i):(d=r.getPath(t),null==d&&r.error("View for collection does not exist","view name",t)),l=n.data,p={context:this,viewClass:d,parent:l},null!=n.fn&&(p.viewClassTemplateFunction=n.fn),r.addBindingsParent(n.hash),f=n.hash;for(ainf)u=f[a],p[a]=u;returno=null!=n.hash.collectionClass?r.getPath(n.hash.collectionClass):e,c=l.layout.createView(o,p),c.parent=l,l.addView(c),h=c.createElement(),s=h.outerHTML,null==s&&(s=""),l.layout.queueRenderView(c),newHandlebars.SafeString(s)}),Handlebars.registerHelper("linkTo",function(t,e){varn,i,o;returnr.log("handlebars","handlebars helper 'linkTo':",this,t,e),1===arguments.length&&(e=t),"string"==typeoft?t=r._getPath(this,t):"function"==typeoft&&(t=t.call(this)),null!=t?(n="<a href='/#"+t.showUrl()+"'",null!=(null!=(o=e.hash)?o.classNames:void0)&&(n+=" class='"+e.hash.classNames+"'"),n+=">",i=e.fn(this),null!=i&&i.length>0||(i="(Empty Value)"),n+=i,n+="</a>",newHandlebars.SafeString(n)):""}),Handlebars.registerHelper("valueOf",function(t,e){varn;returnr.log("handlebars","handlebars helper 'valueOf':",this,t,e),1===arguments.length&&(e=t),n=r._getPath(this,t),null==n&&(n=""),newHandlebars.SafeString(n)}),Handlebars.registerHelper("rawPath",function(t,e){varn;return1===arguments.length&&(e=t),n=r._getPath(this,t),null==n&&(n=""),n}),Handlebars.registerHelper("uriPath",function(t,e){varn;return1===arguments.length&&(e=t),n=r._getPath(this,t),null==n&&(n=""),encodeURI(n)}),Handlebars.registerHelper("valueEach",function(t,e){varn,i,o,s,a,l;if(r.log("handlebars","handlebars helper 'valueEach':",this,t,e),1===arguments.length&&(e=t),t=r.getPath(this,t),null==t)return"";for(i="",o=0,s=t.length;s>o;o++)n=t[o],i+=e.fn(n),null!=(null!=e?null!=(a=e.hash)?a.seperator:void0:void0)&&(i+=e.hash.seperator);returnnull!=(null!=e?null!=(l=e.hash)?l.seperator:void0:void0)&&i.length>0&&(i=i.slice(0,i.length-e.hash.seperator.length)),newHandlebars.SafeString(i)}),Handlebars.registerHelper("yesNo",function(t,e){returnr.log("handlebars","handlebars helper 'yesNo':",this,t,e),1===arguments.length&&(e=t),"string"==typeoft&&(t=r.getPath(this,t)),null==t?"No":t?"Yes":"No"}),Handlebars.registerHelper("valueIf",function(t,e){returnr.log("handlebars","handlebars helper 'valueOf':",this,t,e),"string"==typeoft&&(t=r._getPath(this,t)),t?e.fn(this):e.inverse(this)}),Handlebars.registerHelper("valueUnless",function(t,e){return"string"==typeoft&&(t=r.getPath(this,t)),t?e.inverse(this):e.fn(this)}),Handlebars.registerHelper("action",function(t,e){varn,i,o,s,a;returnr.log("handlebars","handlebars helper 'action':",this,t,e),1===arguments.length&&(e=record),a=e.data,null!=e.hash.target&&(a="parent"===e.hash.target?e.data.parent:r.getPath(e.data,e.hash.target)),n=r.getId(),s='data-mozart-action="'+n+'"',o=null!=e.hash.events?e.hash.events.split(","):["click"],i=e.hash.allowDefault&&!0,e.data.layout.addControl(n,{action:t,view:a,options:e.hash,events:o,allowDefault:i}),newHandlebars.SafeString(s)}),Handlebars.registerHelper("date",function(t){vare,n;returnn=s(this,t),e=r.serverToLocalDate(n)||"(none)",newHandlebars.SafeString(e)}),Handlebars.registerHelper("dateTime",function(t){vare,n;returnn=s(this,t),e=r.serverToLocalDateTime(n),newHandlebars.SafeString(e)}),Handlebars.registerHelper("timeAgo",function(t){vare,n;returnn=s(this,t),e=r.serverToLocalTimeAgo(n),newHandlebars.SafeString(e)}),Handlebars.registerHelper("mozartversion",function(){returnnewHandlebars.SafeString(Mozart.version)}),Handlebars.registerHelper("mozartversiondate",function(){returnnewHandlebars.SafeString(Mozart.versionDate.toLocaleDateString())})}).call(this)}),t.define("/i18n-view.coffee",function(t,e,n){(function(){vare,r,i,o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};i=t("./view").View,r=t("./util"),n.I18nView=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.tag="span",e.prototype.idPrefix="i18nview",e.prototype.init=function(){if(e.__super__.init.apply(this,arguments),null==this.i18nTemplate)throwError("Mozart.I18nView must have a i18nTemplate");returnthis.bind("change",this.redraw)},e.prototype.templateFunction=function(){try{returnr.getPath(window,"i18n."+this.i18nTemplate)(this)}catch(t){returnr.warn("MessageFormat failed with Error:",t),""}},e}(i)}).call(this)}),t.define("/http.coffee",function(t,e,n){(function(){vare,r,i,o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};r=t("./object").MztObject,i=t("./util"),n.HTTP=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.handleError=function(t,e,n,r){switch(t.status){case401:returnMozart.Ajax.trigger("httpAuthorizationRequired",n,t);case404:returnMozart.Ajax.trigger("httpForbidden",n,t);default:returni.error("Model.Ajax.handleError",t,e,r)}},e.prototype._xhrHandler=function(t,e,n,r,o){vars,a,l,h,u;returnthis.support.ajax?(u="object"==typeoft?this.support.cors?t.cors||t.proxy:t.proxy:t,l=e||"GET",h=r||{},s=o||{},a=n||{},o.success=o.success||function(t,n,r){returni.log("Mozart.HTTP",e,"success",t,n,r)},o.error=o.error||function(t,n,r){returni.log("Mozart.HTTP",e,"error",t,n,r)},o.complete=o.complete||function(t,n){returni.log("Mozart.HTTP",e,"complete",t,n)},this._request(u,l,a,h,s)):i.log("Mozart.HTTP","AJAX is not supported. Exiting")},e.prototype._request=function(t,e,n,r,i){return$.ajax({url:t,type:e,success:i.success,error:i.error,complete:i.complete,data:n,context:r.context||this,dataType:r.dataType||"json",contentType:r.contentType||"application/json"})},e.prototype.support={ajax:function(){try{return!!newXMLHttpRequest}catch(t){return!1}},cors:function(){returnthis.ajax&&"withCredentials"innewXMLHttpRequest}},e.prototype.get=function(t,e){varn,r,i;returne=e||{},r=e.data||{},i=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"GET",r,i,n)},e.prototype.post=function(t,e){varn,r,i;returne=e||{},r=e.data||{},i=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"POST",r,i,n)},e.prototype.put=function(t,e){varn,r,i;returne=e||{},r=e.data||{},i=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"PUT",r,i,n)},e.prototype["delete"]=function(t,e){varn,r,i;returne=e||{},r=e.data||{},i=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"DELETE",r,i,n)},e}(r)}).call(this)}),t.define("/layout.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};i=t("./util"),r=t("./router").Router,n.Layout=e=function(t){functione(){returnthis.releaseViewControls=o(this.releaseViewControls,this),this.removeControl=o(this.removeControl,this),this.getControl=o(this.getControl,this),this.addControl=o(this.addControl,this),this.releaseViews=o(this.releaseViews,this),this.releaseView=o(this.releaseView,this),this.queueReleaseView=o(this.queueReleaseView,this),this.release=o(this.release,this),this.processRenderQueue=o(this.processRenderQueue,this),this.queueRenderView=o(this.queueRenderView,this),this._transition=o(this._transition,this),this.doRoute=o(this.doRoute,this),this.resetRoute=o(this.resetRoute,this),this.bindRoot=o(this.bindRoot,this),this.createView=o(this.createView,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.init=function(){vart,n,r,i,o;for(e.__super__.init.apply(this,arguments),this.viewRenderQueue=[],this.releaseMap={},this.views={},this.currentState=null,this.controls={},this.hasClickOutside={},this.hasClickInside={},i=this.states,o=[],n=0,r=i.length;r>n;n++)t=i[n],null!=t.path&&null!=t.viewClass&&o.push(this.register(t.path,this.doRoute,t));returno},e.prototype.createView=function(t,e){varn;returnnull==e&&(e={}),e.layout=this,n=t.create(e),this.views[n.id]=n,null!=n.clickInside&&(this.hasClickInside[n.id]=n),null!=n.clickOutside&&(this.hasClickOutside[n.id]=n),n},e.prototype.bindRoot=function(){returnthis.rootEl=$(this.rootElement)[0]},e.prototype.resetRoute=function(){returnthis.viewRenderQueue=[],this.currentState=null,this.releaseViews()},e.prototype.doRoute=function(t,e){returnnull==this.currentState||this.currentState.canExit()?(this.currentState=null,t.canEnter(e)?(this._transition(t),!0):(i.log("layout","cannot enter state",t,e),!1)):(i.log("layout","cannot exit state",this.currentState),!1)},e.prototype._transition=function(t){returnthis.resetRoute(),this.currentState=t,this.currentState.doTitle(),null!=this.currentState.viewClass?(null!=this.currentView&&(this.releaseMap[this.currentView.id]=this.currentView),this.currentView=this.createView(this.currentState.viewClass,this.currentState.viewOptions),this.currentView.el=this.rootEl,this.queueRenderView(this.currentView)):void0},e.prototype.queueRenderView=function(t){vare,n,r;returni.log("layout",""+this._mozartId+" queueRenderView",t),null==(r=(e=this.views)[n=t.id])&&(e[n]=t),0===this.viewRenderQueue.length&&_.delay(this.processRenderQueue,0),this.viewRenderQueue.push(t)},e.prototype.processRenderQueue=function(){vart,e,n,r,o,s,a,l,h,u,c,d,p,f,g,y,m,v,w;if(!this.released&&0!==this.viewRenderQueue.length){for(i.log("layout",""+this._mozartId+" processRenderQueue with "+this.viewRenderQueue.length+" views"),e=[],n=[];this.viewRenderQueue.length>0;)s=this.viewRenderQueue.shift(),s.beforeRender(),s.releaseChildren(),s.prepareElement(),n.push(s);for(r=[],h=0,p=n.length;p>h;h++)for(a=n[h],u=0,f=n.length;f>u;u++)l=n[u],l!==a&&a.hasAncestor(l)&&!_.contains(r,a)&&r.push(a);for(o=_.difference(n,r),c=0,g=o.length;g>c;c++)s=o[c],s.reassignElements();for(d=0,y=o.length;y>d;d++)s=o[d],s.replaceElement();for(v=0,m=n.length;m>v;v++)s=n[v],s.postRender();w=this.releaseMap;for(tinw)s=w[t],null!=s&&s.release();returnthis.releaseMap={},i.log("layout",""+this._mozartId+" render finished"),this.trigger("render:complete")}},e.prototype.release=function(){returnthis.releaseViews(),e.__super__.release.apply(this,arguments)},e.prototype.queueReleaseView=function(t){returnthis.releaseMap[t.id]=t},e.prototype.releaseView=function(t){returnthis.releaseViewControls(t),deletethis.views[t.id],deletethis.hasClickOutside[t.id],deletethis.hasClickInside[t.id]},e.prototype.releaseViews=function(){vart,e,n,r;n=this.views,r=[];for(tinn)e=n[t],i.log("layout","processRenderQueue:releasing",e.id,e),this.releaseMap[t]=e,r.push(this.processRenderQueue());returnr},e.prototype.addControl=function(t,e){returni.log("layout","adding control",t,e),this.controls[t]=e},e.prototype.getControl=function(t){returnthis.controls[t]},e.prototype.removeControl=function(t){returni.log("layout","removing control",t),deletethis.controls[t]},e.prototype.releaseViewControls=function(t){vare,n,r,o;r=this.controls,o=[];for(ninr)e=r[n],e.view===t&&(i.log("layout","releasing control for view",t,"control",e.action,e),o.push(deletethis.controls[n]));returno},e}(r)}).call(this)}),t.define("/router.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./object").MztObject,i=t("./util"),n.Router=r=function(t){functione(){returnthis.release=o(this.release,this),this.navigateRoute=o(this.navigateRoute,this),this.onPopState=o(this.onPopState,this),this.onNavigationEvent=o(this.onNavigationEvent,this),this.onHashChange=o(this.onHashChange,this),this.register=o(this.register,this),this.stop=o(this.stop,this),this.start=o(this.start,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.init=function(){vart;returnthis.routes={},null!=(t=this.useHashRouting)?t:this.useHashRouting=!1},e.prototype.start=function(){returnthis.useHashRouting?($(window).bind("hashchange",this.onHashChange),this.onHashChange()):($("body").on("click","a",this.onNavigationEvent),$(window).on("popstate",this.onPopState),-1!==navigator.userAgent.indexOf("Firefox")?this.onPopState():void0)},e.prototype.stop=function(){returnthis.useHashRouting?$(window).unbind("hashchange",this.onHashChange):($("body").off("click","a",this.onNavigationEvent),$(window).off("popstate",this.onPopState))},e.prototype.register=function(t,e,n){varr,o,s,a,l,h;for(i.log("routes","registering route",t,n),a=t.split("/"),r=[],o="",l=0,h=a.length;h>l;l++)s=a[l],":"===s[0]?(o+="([^\\/]+)\\/",r.push(s.substr(1))):o+=this._escForRegEx(s)+"\\/";returno.length>2&&(o=o.substr(0,o.length-2)),this.routes[t]={regex:RegExp("^"+o+"$","i"),params:r,callback:e,data:n}},e.prototype.onHashChange=function(){vart;returnt=window.location.hash,t.length>0&&"#"===t[0]&&(t=t.substr(1)),this.navigateRoute(t)},e.prototype.onNavigationEvent=function(t){returnt.target.host===document.location.host&&t.target.port===document.location.port&&t.target.protocol===document.location.protocol?this.navigateRoute(t.target.pathname)?(history.pushState({one:1},null,t.target.href),t.preventDefault()):void0:void0},e.prototype.onPopState=function(){returnthis.navigateRoute(window.location.pathname)},e.prototype.navigateRoute=function(t){vare,n,r,o,s,a,l,h,u,c;if(this.isNavigating=!0,null==t||0===t.length){if(a=this.routes["/"],null!=a)returna.callback(a.data,r),this.isNavigating=!1,!1;i.log("routemanager","WARNING: No Default route defined, no route for path",t)}u=this.routes;for(oinu)if(a=u[o],r={},n=a.regex.exec(t),null!==n){for(e=1,c=a.params,l=0,h=c.length;h>l;l++)s=c[l],n.length>e&&(r[s]=n[e++]);returna.callback(a.data,r),this.isNavigating=!1,!0}returnthis.isNavigating=!1,this.trigger("noroute",window.location.hash),!1},e.prototype.release=function(){returnthis.stop(),e.__super__.release.apply(this,arguments)},e.prototype._escForRegEx=function(t){vare,n,r,i;for(t.replace("\\","\\\\"),e="./+{}()*",r=0,i=e.length;i>r;r++)n=e[r],t=t.replace(n,"\\"+n);returnt},e}(e)}).call(this)}),t.define("/model-instance.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t},l=[].indexOf||function(t){for(vare=0,n=this.length;n>e;e++)if(einthis&&this[e]===t)returne;return-1};i=t("./util"),r=t("./object").MztObject,n.Instance=e=function(t){functione(){returnthis.copyFrom=o(this.copyFrom,this),this.copyTo=o(this.copyTo,this),this.set=o(this.set,this),this.get=o(this.get,this),this.destroy=o(this.destroy,this),this.save=o(this.save,this),this.load=o(this.load,this),e.__super__.constructor.apply(this,arguments)}varn;returna(e,t),n=["id"],e.prototype.init=function(){returnthis._type=this.modelClass.modelName},e.prototype.load=function(t){returnnull==t&&(t={}),this.modelClass.loadInstance(this,t)},e.prototype.save=function(t){returnnull==t&&(t={}),this.modelClass.exists(this.id)?(this.modelClass.updateInstance(this,t),this.trigger("update")):(this.modelClass.createInstance(this,t),this.trigger("create")),this.trigger("change")},e.prototype.destroy=function(t){returnnull==t&&(t={}),this.trigger("destroy",t),this.trigger("change"),this.modelClass.destroyInstance(this,t)},e.prototype.get=function(t){if(this.modelClass.hasAttribute(t)||i.isFunction(this[t]))returni.isFunction(this[t])?this[t].apply(this):e.__super__.get.call(this,t);throwError(""+this.modelClass.modelName+" has no attribute or relation '"+t+"' or foreign key '"+t+"_id'")},e.prototype.set=function(t,n){if(this.modelClass.hasAttribute(t)||i.isFunction(this[t]))returni.isFunction(this[t])?this[t](n):("id"!==t&&this.modelClass.hasIndex(t)&&this.modelClass.exists(this.id)&&this.modelClass.updateIndex(t,this,this[t],n),e.__super__.set.call(this,t,n));throwError(""+this.modelClass.modelName+" has no attribute or relation '"+t+"' or foreign key '"+t+"_id'")},e.prototype.copyTo=function(t){vare,i,o;null==t&&(t=r.create()),o=this.modelClass.attrs;for(eino)i=o[e],0>l.call(n,e)&&(null!=t.set?t.set(e,this[e]):t[e]=this[e]);returnt},e.prototype.copyFrom=function(t){vare,r,i,o,s;r=!1;for(eint)s=t[e],0>l.call(n,e)&&(o=this.modelClass.attrs[e],null!=o&&(i=s,"decimal"===o&&(i=parseFloat(i)),this[e]!==i&&(r=!0,this.set(e,i))));returnr},e}(r)}).call(this)}),t.define("/model-instancecollection.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};i=t("./util"),r=t("./object").MztObject,n.InstanceCollection=e=function(t){functione(){returnthis.unBindEvents=o(this.unBindEvents,this),this.bindEvents=o(this.bindEvents,this),this.allAsMap=o(this.allAsMap,this),this.count=o(this.count,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.count=function(){returnthis.all().length},e.prototype.allAsMap=function(){returni.toMap(this.all())},e.prototype.all=function(){return[]},e.prototype.bindEvents=function(t){vare,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],e.bind("create",this.onModelChange),e.bind("update",this.onModelChange),i.push(e.bind("destroy",this.onModelChange));returni},e.prototype.unBindEvents=function(t){vare,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],e.unbind("create",this.onModelChange),e.unbind("update",this.onModelChange),i.push(e.unbind("destroy",this.onModelChange));returni},e}(r)}).call(this)}),t.define("/model-onetomanycollection.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.OneToManyCollection=r=function(t){functione(){returnthis.release=i(this.release,this),this.onModelChange=i(this.onModelChange,this),this.contains=i(this.contains,this),this.remove=i(this.remove,this),this.createFromValues=i(this.createFromValues,this),this.add=i(this.add,this),this.all=i(this.all,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.init=function(){returnthis.bindEvents([this.otherModel])},e.prototype.all=function(){returnthis.otherModel.findByAttribute(this.fkname,this.record.id)},e.prototype.add=function(t){returnt.set(this.fkname,this.record.id),t.save(),this.record.trigger("change:"+this.attribute)},e.prototype.createFromValues=function(t){vare;returne=this.otherModel.initInstance(t),this.add(e),e},e.prototype.remove=function(t){returnt.set(this.fkname,null),this.record.trigger("change:"+this.attribute)},e.prototype.contains=function(){returnthis.otherModel.findByAttribute(this.fkname,this.record.id).length>0},e.prototype.onModelChange=function(t){returnthis.trigger("change",t)},e.prototype.release=function(){returnthis.unBindEvents([this.otherModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-onetomanypolycollection.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.OneToManyPolyCollection=r=function(t){functione(){returnthis.contains=i(this.contains,this),this.remove=i(this.remove,this),this.add=i(this.add,this),this.createFromValues=i(this.createFromValues,this),this.all=i(this.all,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.all=function(){vart;returnt={},t[this.thatFkAttr]=this.record.id,t[this.thatTypeAttr]=this.model.modelName,this.otherModel.findByAttributes(t)},e.prototype.createFromValues=function(t){vare;returne=this.otherModel.initInstance(t),this.add(e),e},e.prototype.add=function(t){returnt.set(this.thatFkAttr,this.record.id),t.set(this.thatTypeAttr,this.model.modelName),t.save()},e.prototype.remove=function(t){returnt.set(this.thatFkAttr,null),t.set(this.thatTypeAttr,null),t.save()},e.prototype.contains=function(){vart;returnt={},t[this.thatFkAttr]=this.record.id,t[this.thatTypeAttr]=this.model.modelName,0!==this.otherModel.findByAttributes(t).length},e}(e)}).call(this)}),t.define("/model-manytomanycollection.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyCollection=r=function(t){functione(){returnthis.release=i(this.release,this),this.onModelChange=i(this.onModelChange,this),this.contains=i(this.contains,this),this.remove=i(this.remove,this),this.createFromValues=i(this.createFromValues,this),this.add=i(this.add,this),this.all=i(this.all,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.init=function(){returnthis.bindEvents([this.linkModel])},e.prototype.all=function(){vart,e,n,r,i;for(e=this.linkModel.findByAttribute(this.thisFkAttr,this.record.id),i=[],n=0,r=e.length;r>n;n++)t=e[n],i.push(this.otherModel.findById(t[this.thatFkAttr]));returni},e.prototype.add=function(t){vare,n;returnn={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,this.record.id),e.set(this.thatFkAttr,t.id),e.save(),e):void0},e.prototype.createFromValues=function(t){vare;returne=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.remove=function(t){vare,n,r,i,o,s;for(r={},r[this.thisFkAttr]=this.record.id,r[this.thatFkAttr]=t.id,n=this.linkModel.findByAttributes(r),s=[],i=0,o=n.length;o>i;i++)e=n[i],s.push(e.destroy());returns},e.prototype.contains=function(t){vare;returne={},e[this.thisFkAttr]=this.record.id,e[this.thatFkAttr]=t.id,0!==this.linkModel.findByAttributes(e).length},e.prototype.onModelChange=function(t){vare;returnt.get(this.thisFkAttr)===this.record.id?(e=this.otherModel.findById(t[this.thatFkAttr]),this.trigger("change",e)):void0},e.prototype.release=function(){returnthis.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-manytomanypolycollection.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyPolyCollection=r=function(t){functione(){returnthis.release=i(this.release,this),this.onModelChange=i(this.onModelChange,this),this.contains=i(this.contains,this),this.remove=i(this.remove,this),this.add=i(this.add,this),this.createFromValues=i(this.createFromValues,this),this.all=i(this.all,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.init=function(){returnthis.bindEvents([this.linkModel])},e.prototype.all=function(){vart,e,n,r,i,o;for(n={},n[this.thisFkAttr]=this.record.id,n[this.thatTypeAttr]=this.otherModel.modelName,e=this.linkModel.findByAttributes(n),o=[],r=0,i=e.length;i>r;r++)t=e[r],o.push(this.otherModel.findById(t[this.thatFkAttr]));returno},e.prototype.createFromValues=function(t){vare;returne=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.add=function(t){vare,n;returnn={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,n[this.thatTypeAttr]=this.otherModel.modelName,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,this.record.id),e.set(this.thatFkAttr,t.id),e.set(this.thatTypeAttr,this.otherModel.modelName),e.save(),e):void0},e.prototype.remove=function(t){vare,n,r,i,o,s;for(n={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,n[this.thatTypeAttr]=this.otherModel.modelName,o=this.linkModel.findByAttributes(n),s=[],r=0,i=o.length;i>r;r++)e=o[r],s.push(e.destroy());returns},e.prototype.contains=function(t){vare;returne={},e[this.thisFkAttr]=this.record.id,e[this.thatFkAttr]=t.id,e[this.thatTypeAttr]=this.otherModel.modelName,0!==this.linkModel.findByAttributes(e).length},e.prototype.onModelChange=function(t){vare;returnt[this.thisFkAttr]===this.record.id&&t[this.thatTypeAttr]===this.otherModel.modelName?(e=this.otherModel.findById(t[this.thatFkAttr]),this.trigger("change",e)):void0},e.prototype.release=function(){returnthis.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-manytomanypolyreversecollection.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyPolyReverseCollection=r=function(t){functione(){returnthis.release=i(this.release,this),this.onModelChange=i(this.onModelChange,this),this.contains=i(this.contains,this),this.remove=i(this.remove,this),this.add=i(this.add,this),this.createFromValues=i(this.createFromValues,this),this.all=i(this.all,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.init=function(){returnthis.bindEvents([this.linkModel])},e.prototype.all=function(){vart,e,n,r,i,o;for(n={},n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,e=this.linkModel.findByAttributes(n),o=[],r=0,i=e.length;i>r;r++)t=e[r],o.push(this.otherModel.findById(t[this.thisFkAttr]));returno},e.prototype.createFromValues=function(t){vare;returne=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.add=function(t){vare,n;returnn={},n[this.thisFkAttr]=t.id,n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,t.id),e.set(this.thatFkAttr,this.record.id),e.set(this.thatTypeAttr,this.model.modelName),e.save(),e):void0},e.prototype.remove=function(t){vare,n,r,i,o,s;for(n={},n[this.thisFkAttr]=t.id,n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,o=this.linkModel.findByAttributes(n),s=[],r=0,i=o.length;i>r;r++)e=o[r],s.push(e.destroy());returns},e.prototype.contains=function(t){vare;returne={},e[this.thisFkAttr]=t.id,e[this.thatFkAttr]=this.record.id,e[this.thatTypeAttr]=this.model.modelName,0!==this.linkModel.findByAttributes(e).length
},e.prototype.onModelChange=function(t){vare;returnt[this.thatFkAttr]===this.record.id&&t[this.thatTypeAttr]===this.model.modelName?(e=this.model.findById(t[this.thisFkAttr]),this.trigger("change",e)):void0},e.prototype.release=function(){returnthis.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-ajax.coffee",function(t){(function(){vare,n,r,i;e=t("./model").Model,n=t("./util"),i={},r={},e.extend({ajax:function(t){vare,o,s,a,l,h,u,c,d;for(h=["url","interface","plural"],o=0,s=h.length;s>o;o++)e=h[o],null!=t[e]&&(this[e]=t[e]);returnthis.bind("load",this.loadServer),this.bind("create",this.createServer),this.bind("update",this.updateServer),this.bind("destroy",this.destroyServer),null==(u=i[a=this.modelName])&&(i[a]={}),null==(c=r[l=this.modelName])&&(r[l]={}),null==(d=Mozart.Ajax)&&(Mozart.Ajax=Mozart.MztObject.create({handleError:function(t,e,r,i){switch(t.status){case401:returnMozart.Ajax.trigger("httpAuthorizationRequired",r,t);case404:returnMozart.Ajax.trigger("httpForbidden",r,t);default:returnn.error("Model.Ajax.handleError",t,e,i)}}})),this.instanceClass.extend({getServerId:function(){returnthis.modelClass.getServerId(this.id)},existsOnServer:function(){returnnull!=this.modelClass.getServerId(this.id)},loadServer:function(){returnthis.modelClass.load(this.modelClass.getServerId(this.id))}})},registerServerId:function(t,e){if(null==i[this.modelName])throwError("Model.registerServerId: "+this.modelName+" is not registered for ajax.");returni[this.modelName][e]=t,r[this.modelName][t]=e},unRegisterServerId:function(t,e){returndeletei[this.modelName][e],deleter[this.modelName][t]},getServerId:function(t){returnr[this.modelName][t]},getClientId:function(t){returni[this.modelName][t]},toServerObject:function(t){varn,r,i,o,s,a,l,h;i={},a=this.attrs;for(nina)o=a[n],"id"!==n&&(i[n]=t[n]);i.id=this.getServerId(t.id),l=this.fks;for(ninl)r=l[n],i[n]=r.getServerId(t[n]);h=this.polyFks;for(ninh)s=h[n],i[n]=null!=t[s]?e.models[t[s]].getServerId(t[n]):null;returni},toClientObject:function(t){varn,r,i,o,s,a,l,h;i={},a=this.attrs;for(nina)o=a[n],"id"!==n&&t[n]!==void0&&(i[n]=t[n]);i.id=this.getClientId(t.id),l=this.fks;for(ninl)r=l[n],t[n]!==void0&&(i[n]=r.getClientId(t[n]),i[n]===void0&&(i[n]=null));h=this.polyFks;for(ninh)s=h[n],i[n]=t[n]!==void0&&null!=t[s]?e.models[t[s]].getClientId(t[n]):null;returni},loadServer:function(t){vare;returne=t.modelClass.getServerId(t.id),null!=e?t.modelClass.load(e):void0},createServer:function(t){returnt.modelClass.createAjax(t.id,t.modelClass.toServerObject(t))},updateServer:function(t){vare;returne=t.modelClass.getServerId(t.id),null!=e?t.modelClass.updateAjax(e,t.id,t.modelClass.toServerObject(t)):void0},destroyServer:function(t){vare;returne=t.modelClass.getServerId(t.id),null!=e?t.modelClass.destroyAjax(t.modelClass.getServerId(t.id),t.id):void0},loadAll:function(){vart,e,r,i;returni=function(t,e){varn,r,i;for(null!=this.model.plural&&(t=t[this.model.plural]),r=0,i=t.length;i>r;r++)n=t[r],this.model._processLoad(n,this.model,e);returnthis.model.trigger("loadAllComplete")},r=function(t,e,n){returnMozart.Ajax.handleError(t,e,this,n)},e=function(t,e){returnn.log("ajax","Model.loadAll.onComplete",t,e)},t=Mozart.HTTP.create(),t.get(this.url,{options:{context:{model:this}},callbacks:{success:i,error:r,complete:e}})},load:function(t){vare,r,i,o;returno=function(t,e){returnnull!=this.model.plural&&(t=t[this.model.plural]),this.model._processLoad(t,this.model,e)},i=function(t,e,n){returnMozart.Ajax.handleError(t,e,this,n)},r=function(t,e){returnn.log("ajax","Model.load.onComplete",t,e)},e=Mozart.HTTP.create(),e.get(this.url+"/"+t,{options:{context:{model:this,id:t}},callbacks:{success:o,error:i,complete:r}})},_processLoad:function(t,e,r){vari,o,s;returns=t.id,i=e.toClientObject(t),o=e.findById(i.id),null==o&&(o=e.initInstance(t)),e.registerServerId(o.id,s),o.copyFrom(i),o.save({disableModelCreateEvent:!0,disableModelUpdateEvent:!0}),n.log("ajax","Model._processLoad.onSuccess",r,t),e.trigger("loadComplete",o)},createAjax:function(t,e){varr,i,o,s;returns=function(e,r){returnthis.model.registerServerId(this.clientId,e.id),n.log("ajax","Model.createAjax.onSuccess",r,e),this.model.trigger("createComplete",this.model.findById(t))},o=function(t,e,n){returnMozart.Ajax.handleError(t,e,this,n)},i=function(t,e){returnn.log("ajax","Model.createAjax.onComplete",t,e)},r=Mozart.HTTP.create(),r.post(this.url,{data:JSON.stringify(e),options:{context:{model:this,clientId:t}},callbacks:{success:s,error:o,complete:i}})},updateAjax:function(t,e,r){vari,o,s,a;returna=function(t,r){returnn.log("ajax","Model.updateAjax.onSuccess",r,t),this.model.trigger("updateComplete",this.model.findById(e))},s=function(t,e,n){returnMozart.Ajax.handleError(t,e,this,n)},o=function(t,e){returnn.log("ajax","Model.updateAjax.onComplete",t,e)},i=Mozart.HTTP.create(),i.put(this.url+"/"+t,{data:JSON.stringify(r),options:{context:{model:this,clientId:this.clientId,serverId:this.serverId}},callbacks:{success:a,error:s,complete:o}})},destroyAjax:function(t,e){varr,i,o,s;returns=function(r,i){returnthis.model.unRegisterServerId(e,t),n.log("ajax","Model.destroyAjax.onSuccess",i,r),this.model.trigger("destroyComplete",t)},o=function(t,e,n){returnMozart.Ajax.handleError(t,e,this,n)},i=function(t,e){returnn.log("ajax","Model.destroyAjax.onComplete",t,e)},r=Mozart.HTTP.create(),r["delete"](this.url+"/"+t,{options:{context:{model:this,clientId:e,serverId:t}},callbacks:{success:s,error:o,complete:i}})}})}).call(this)}),t.define("/model.coffee",function(t,e,n){(function(){vare,r,i,o,s,a,l,h,u,c,d,p=function(t,e){returnfunction(){returnt.apply(e,arguments)}},f={}.hasOwnProperty,g=function(t,e){functionn(){this.constructor=t}for(varrine)f.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};d=t("./util"),h=t("./object").MztObject,e=t("./data-index").DataIndex,r=t("./model-instance").Instance,i=t("./model-instancecollection").InstanceCollection,u=t("./model-onetomanycollection").OneToManyCollection,c=t("./model-onetomanypolycollection").OneToManyPolyCollection,o=t("./model-manytomanycollection").ManyToManyCollection,s=t("./model-manytomanypolycollection").ManyToManyPolyCollection,a=t("./model-manytomanypolyreversecollection").ManyToManyPolyReverseCollection,n.Model=l=function(t){functionn(){returnthis.index=p(this.index,this),this._generateId=p(this._generateId,this),this._getInstance=p(this._getInstance,this),this.toSnakeCase=p(this.toSnakeCase,this),this.destroyInstance=p(this.destroyInstance,this),this.updateInstance=p(this.updateInstance,this),this.createInstance=p(this.createInstance,this),this.loadInstance=p(this.loadInstance,this),this.createFromValues=p(this.createFromValues,this),this.initInstance=p(this.initInstance,this),this.exists=p(this.exists,this),this.findByAttributes=p(this.findByAttributes,this),this.findByAttribute=p(this.findByAttribute,this),this.selectAsMap=p(this.selectAsMap,this),this.selectIds=p(this.selectIds,this),this.select=p(this.select,this),this.findAll=p(this.findAll,this),this.findById=p(this.findById,this),this.count=p(this.count,this),this.allAsMap=p(this.allAsMap,this),this.all=p(this.all,this),this.hasManyThrough=p(this.hasManyThrough,this),this.hasMany=p(this.hasMany,this),this.belongsToPoly=p(this.belongsToPoly,this),this.belongsTo=p(this.belongsTo,this),this.polyForeignKeys=p(this.polyForeignKeys,this),this.foreignKeys=p(this.foreignKeys,this),this.attributes=p(this.attributes,this),this.reset=p(this.reset,this),n.__super__.constructor.apply(this,arguments)}returng(n,t),n.idCount=1,n.indexForeignKeys=!0,n.models={},n.prototype.toString=function(){return"Model: "+this.modelName},n.prototype.init=function(){vart;if(null==this.modelName)throwError("Model must have a modelName");returnthis.records={},this.fks={},this.polyFks={},this.attrs={id:"integer"},this.relations={},this.indexes={},n.models[this.modelName]=this,this.instanceClass=t=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returng(e,t),e}(r)},n.prototype.reset=function(){vart,e,n;n=this.records;for(tinn)e=n[t],e.release();returnthis.records={},this.rebuildAllIndexes()},n.prototype.attributes=function(t){vare,n,r;r=[];for(eint)n=t[e],r.push(this.attrs[e]=n);returnr},n.prototype.hasAttribute=function(t){returnnull!=this.attrs[t]||null!=this.fks[t+"_id"]},n.prototype.hasRelation=function(t){returnnull!=this.relations[t]},n.prototype.foreignKeys=function(t){vare,r,i;i=[];for(eint)r=t[e],this.fks[e]=r,n.DataIndexForeignKeys?i.push(this.index(e)):i.push(void0);returni},n.prototype.polyForeignKeys=function(t){vare,r,i;i=[];for(eint)r=t[e],this.polyFks[e]=r,n.DataIndexForeignKeys?i.push(this.index(e)):i.push(void0);returni},n.prototype.belongsTo=function(t,e,n){varr,i,o,s,a;returnnull==e&&null==e&&(e=this.toSnakeCase(t.modelName)),i={},null==n&&(n=e+"_id"),i[n]="integer",this.attributes(i),o={},o[n]=t,this.foreignKeys(o),s={},s[e]=function(r){vari;if(1===arguments.length){if(null!==r&&(null==r.modelClass||r.modelClass!==t))throwError("Cannot assign "+r+" to belongsTo "+this.modelClass.modelName+":"+e+" (Value is not an Instance or incorrect ModelClass)");returnnull!=r?this.set(n,r.id):this.set(n,null)}returni=this[n],null==i?null:t.findById(i)},this.instanceClass.extend(s),r=this,a=function(e){varr,i,o,s,a;for(s=t.findByAttribute(n,e.id),a=[],i=0,o=s.length;o>i;i++)r=s[i],r.set(n,null),a.push(r.save());returna},t.bind("destroy",a)},n.prototype.hasOne=function(t,e,n){varr,i,o,s;returnnull==e&&(e=this.toSnakeCase(this.modelName)),i={},null==n&&(n=e+"_id"),i[n]="integer",t.attributes(i),o={},o[n]=this,t.foreignKeys(o),this.instanceClass.prototype[e]=function(r){vari,o,s,a,l;if(1===arguments.length){for(l=t.findByAttribute(n,this.id),s=0,a=l.length;a>s;s++)i=l[s],i!==r&&(i.set(n,null),i.save());if(null===r)return;returnr.set(n,this.id),r.save(),this.trigger("change:"+e),this.trigger("change")}returno=t.findByAttribute(n,this.id),o.length>0?o[0]:null},r=this,s=function(e){varr,i,o,s,a;for(s=t.findByAttribute(n,e.id),a=[],i=0,o=s.length;o>i;i++)r=s[i],r.set(n,null),a.push(r.save());returna},this.bind("destroy",s)},n.prototype.belongsToPoly=function(t,e,r,i){varo,s,a,l,h,u,c,p,f;for(null==e&&(e=this.toSnakeCase(l.modelName)),s={},null==r&&(r=e+"_id"),s[r]="integer",null==i&&(i=e+"_type"),s[i]="string",this[e+"_allowed_models"]=t,this.attributes(s),a={},a[r]=i,this.polyForeignKeys(a),h={},h[e]=function(e,o){vars,a;returnarguments.length>0?(null!=e?(_.contains(t,e.modelClass)||d.error("Cannot assign a model of type {{value.modelClass.modelName}} to this belongsToPoly - allowed model types are "+t.join(", ")),this.set(r,e.id),this.set(i,e.modelClass.modelName)):(this[r]=null,this[i]=null),this.save(o)):(s=this[r],a=n.models[this[i]],null==s||null==a?null:a.findById(s))},this.instanceClass.extend(h),o=this,u=function(t,e){varn,s,a,l,h,u;for(null==e&&(e={}),s={},s[r]=t.id,s[i]=t.modelClass.modelName,h=o.findByAttributes(s),u=[],a=0,l=h.length;l>a;a++)n=h[a],n.set(r,null),n.set(i,null),u.push(n.save(e));returnu},f=[],c=0,p=t.length;p>c;c++)l=t[c],f.push(l.bind("destroy",u));returnf},n.prototype.hasMany=function(t,e,n){varr,i,o,s,a;returnnull==e&&(e=this.toSnakeCase(t.modelName)),i={},null==n&&(n=this.toSnakeCase(this.modelName+"_id")),i[n]="integer",t.attributes(i),o={},o[n]=this,t.foreignKeys(o),this.relations[e]={type:"hasMany",otherModel:t,foreignKeyAttribute:n},r=this,s={},s[e]=function(){if(arguments.length>0)throwError("Cannot set a hasMany relation");returnnull==this[e+"_hasMany_collection"]&&(this[e+"_hasMany_collection"]=u.create({record:this,attribute:this.attribute,model:r,otherModel:t,fkname:n})),this[e+"_hasMany_collection"]},this.instanceClass.extend(s),a=function(e,r){vari,o,s,a,l;for(null==r&&(r={}),a=t.findByAttribute(n,e.id),l=[],o=0,s=a.length;s>o;o++)i=a[o],i.set(n,null),l.push(i.save(r));returnl},this.bind("destroy",a)},n.prototype.hasManyPoly=function(t,e,n,r){vari,o,s,a;returnnull==e&&(e=this.toSnakeCase(t.modelName)),null==n&&(n=e+"_id"),null==r&&(r=e+"_type"),o={},o[n]="integer",o[r]="string",t.attributes(o),s={},s[n]=r,t.polyForeignKeys(s),this.relations[e]={type:"hasManyPoly",otherModel:t,foreignKeyAttribute:n,foreignModelTypeAttribute:r},i=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throwError("Cannot set a hasManyPoly relation");returnnull==this[e+"_hasManyPoly_collection"]&&(this[e+"_hasManyPoly_collection"]=c.create({record:this,model:i,otherModel:t,thatFkAttr:n,thatTypeAttr:r})),this[e+"_hasManyPoly_collection"]},a=function(e,o){vars,a,l,h,u,c;for(null==o&&(o={}),a={},a[n]=e.id,a[r]=i.modelName,u=t.findByAttributes(a),c=[],l=0,h=u.length;h>l;l++)s=u[l],s.set(n,null),s.set(r,null),c.push(s.save(o));returnc},this.bind("destroy",a)},n.prototype.hasManyThrough=function(t,e,n,r,i){vars,a,l,h,u;returnnull==e&&(e=this.toSnakeCase(t.modelName)),a={},null==r&&(r=this.toSnakeCase(this.modelName+"_id")),null==i&&(i=this.toSnakeCase(t.modelName)+"_id"),a[r]="integer",a[i]="integer",n.attributes(a),l={},l[r]=this,l[i]=t,n.foreignKeys(l),this.relations[e]={type:"hasManyThrough",otherModel:t,linkModel:n,foreignKeyAttribute:r,otherModelForeignKeyAttribute:i},s=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throwError("Cannot set a hasManyThrough relation");returnnull==this[e+"_hasManyThrough_collection"]&&(this[e+"_hasManyThrough_collection"]=o.create({record:this,model:s,otherModel:t,linkModel:n,thisFkAttr:r,thatFkAttr:i})),this[e+"_hasManyThrough_collection"]},u=function(t,e){vari,o,s,a,l;for(null==e&&(e={}),a=n.findByAttribute(r,t.id),l=[],o=0,s=a.length;s>o;o++)i=a[o],l.push(i.destroy(e));returnl},this.bind("destroy",u),h=function(t,e){varr,o,s,a,l;for(null==e&&(e={}),a=n.findByAttribute(i,t.id),l=[],o=0,s=a.length;s>o;o++)r=a[o],l.push(r.destroy(e));returnl},t.bind("destroy",h)},n.prototype.hasManyThroughPoly=function(t,e,n,r,i,o){vara,l,h,u,c;returnnull==e&&(e=this.toSnakeCase(t.modelName)),null==r&&(r=this.toSnakeCase(this.modelName+"_id")),null==i&&(i=e+"_id"),null==o&&(o=e+"_type"),l={},l[r]="integer",l[i]="integer",l[o]="string",n.attributes(l),h={},h[r]=this,n.foreignKeys(h),h={},h[i]=o,n.polyForeignKeys(h),this.relations[e]={type:"hasManyThroughPoly",otherModel:t,linkModel:n,foreignKeyAttribute:r,otherModelForeignKeyAttribute:i,otherModelModelTypeAttribute:o},a=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throwError("Cannot set a hasManyThroughPoly relation");returnnull==this[e+"_hasManyThroughPoly_collection"]&&(this[e+"_hasManyThroughPoly_collection"]=s.create({record:this,model:a,otherModel:t,linkModel:n,thisFkAttr:r,thatFkAttr:i,thatTypeAttr:o})),this[e+"_hasManyThroughPoly_collection"]},c=function(t,e){vari,o,s,a,l,h;for(null==e&&(e={}),o={},o[r]=t.id,l=n.findByAttributes(o),h=[],s=0,a=l.length;a>s;s++)i=l[s],h.push(i.destroy(e));returnh},this.bind("destroy",c),u=function(t,e){varr,s,a,l,h,u;for(null==e&&(e={}),s={},s[i]=t.id,s[o]=t.modelClass.modelName,h=n.findByAttributes(s),u=[],a=0,l=h.length;l>a;a++)r=h[a],u.push(r.destroy(e));returnu},t.bind("destroy",u)},n.prototype.hasManyThroughPolyReverse=function(t,e,n,r,i,o){vars;returnnull==e&&(e=this.toSnakeCase(t.modelName)),null==r&&(r=this.toSnakeCase(this.modelName+"_id")),null==i&&(i=e+"_id"),null==o&&(o=e+"_type"),this.relations[e]={type:"hasManyThroughPolyReverse",otherModel:t,linkModel:n,foreignKeyAttribute:r,otherModelForeignKeyAttribute:i,otherModelModelTypeAttribute:o},(null==n.fks[r]||null==n.polyFks[i]||n.polyFks[i]===(null!=o))&&console.error("WARNING: hasManyThroughPolyReverse - "+r+", "+i+" or "+o+" do not exist on link model '"+n.modelName+"' - there should be an existing hasManyThroughPoly to support this hasManyThroughPolyReverse"),s=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throwError("Cannot set a hasManyThroughPolyReverse relation");returnnull==this[e+"_hasManyThroughPolyReverse_collection"]&&(this[e+"_hasManyThroughPolyReverse_collection"]=a.create({record:this,model:s,otherModel:t,linkModel:n,thisFkAttr:r,thatFkAttr:i,thatTypeAttr:o})),this[e+"_hasManyThroughPolyReverse_collection"]}},n.prototype.all=function(){return_(this.records).values()},n.prototype.allAsMap=function(){returnthis.records},n.prototype.count=function(){return_(this.records).keys().length},n.prototype.findById=function(t){returnnull==t?void0:this.records[t]},n.prototype.findAll=function(t){vare,n,r,i;for(n=[],r=0,i=t.length;i>r;r++)e=t[r],null!=this.exists(e)&&n.push(this.records[e]);returnn},n.prototype.select=function(t){returnthis.findAll(this.selectIds(t))},n.prototype.selectIds=function(t){vare,n,r,i;r=[],i=this.records;for(eini)n=i[e],t(n)&&r.push(e);returnr},n.prototype.selectAsMap=function(t){vare,n,r,i;r={},i=this.records;for(eini)n=i[e],t(n)&&(r[e]=n);returnr},n.prototype.findByAttribute=function(t,e){varn;returnn={},n[t]=e,this.findByAttributes(n)},n.prototype.findByAttributes=function(t){vare,n,r,i,o,s,a,l;s=[];for(eint)l=t[e],this.hasIndex(e)?s.push(this.getIndexFor(e,l)):s.push(this.selectAsMap(function(t){returnt[e]===l}));for(i=s.pop()||{};s.length>0;){a=s.pop(),o={};for(nina)r=a[n],null!=i[n]&&(o[n]=r);i=o}return_(i).values()},n.prototype.exists=function(t){returnnull!=this.records[t]},n.prototype.initInstance=function(t){vare,n,r,i;e=this._getInstance(),i=this.attrs;for(nini)r=i[n],null!=t&&null!=t[n]?e.set(n,t[n]):e.set(n,null);returne.set("id",this._generateId()),e},n.prototype.createFromValues=function(t){vare;returne=this.initInstance(t),e.save(),e},n.prototype.loadInstance=function(t,e){returnnull==e&&(e={}),this.trigger("load",t)},n.prototype.createInstance=function(t,e){varn;returnnull==e&&(e={}),n=t.id,this.exists(n)&&d.error("createInstance: ID Already Exists","collection","model",this.name,"id",n),this.records[n]=t,this.addToIndexes(t),e.disableModelCreateEvent||this.trigger("create",t,e),e.disableModelChangeEvent||this.trigger("change",t,e),t},n.prototype.updateInstance=function(t,e){varn;returnnull==e&&(e={}),e.disableModelUpdateEvent||this.trigger("update",t,e),e.disableModelChangeEvent||this.trigger("change",t,e),n=t.id,this.exists(n)?void0:d.error("updateInstance: ID does not exist","collection","model",this.name,"id",n)},n.prototype.destroyInstance=function(t,e){varn;returnnull==e&&(e={}),n=t.id,this.exists(n)||d.error("destroyInstance: ID does not exist","collection","model",this.name,"id",n),deletethis.records[t.id],t.modelClass.removeFromIndexes(t),e.disableModelDestroyEvent||this.trigger("destroy",t,e),e.disableModelChangeEvent?void0:this.trigger("change",t,e)},n.prototype.toSnakeCase=function(t){vare;returne=t.replace(/[A-Z]{1,1}/g,function(t){return"_"+t.toLowerCase()}),e.replace(/^_/,"")},n.prototype._getInstance=function(){returnthis.instanceClass.create({modelClass:this})},n.prototype._generateId=function(){return"c-"+n.idCount++},n.prototype.index=function(t,n,r){vari;if(null==n&&(n="map"),null==this.indexes[t]){if(i=e.getIndexClassType(n),null!=i)returnthis.indexes[t]=i.create({modelClass:this,attribute:t,options:r});throwError("Model: Index Type "+n+" is not supported")}returnthis.rebuildIndex(t)},n.prototype.hasIndex=function(t){returnnull!=this.indexes[t]},n.prototype.getIndexFor=function(t,e){if(null==this.indexes[t])throwError("Model.rebuildIndex: Index "+t+" does not exist");returnthis.indexes[t].load(e)},n.prototype.updateIndex=function(t,e,n,r){if(null==this.indexes[t])throwError("Model.rebuildIndex: Index "+t+" does not exist");returnthis.indexes[t].update(e,n,r)},n.prototype.addToIndexes=function(t){vare,n,r,i;r=this.indexes,i=[];for(einr)n=r[e],i.push(n.add(t));returni},n.prototype.removeFromIndexes=function(t){vare,n,r,i;r=this.indexes,i=[];for(einr)n=r[e],i.push(n.remove(t));returni},n.prototype.rebuildIndex=function(t){if(null==this.indexes[t])throwError("Model.rebuildIndex: Index "+t+" does not exist");returnthis.indexes[t].rebuild()},n.prototype.dropIndex=function(t){returndeletethis.indexes[t]},n.prototype.rebuildAllIndexes=function(){vart,e,n,r,i;for(r=_(this.indexes).keys(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(this.rebuildIndex(t));returni},n}(h)}).call(this)}),t.define("/model-localstorage.coffee",function(t){(function(){vare,n,r,i;e=t("./model").Model,n=t("./util"),i={},r={},e.extend({localStorage:function(t){vare,n,o,s,a,l,h,u,c;returnnull==window.localStorage&&Mozart.error(this.modelName+".localStorage - localStorage not available in this browser"),null==t&&(t={}),null==(l=t.prefix)&&(t.prefix="MozartLS"),this.localStorageOptions=t,this.bind("load",this.loadLocalStorage),this.bind("create",this.createLocalStorage),this.bind("update",this.updateLocalStorage),this.bind("destroy",this.destroyLocalStorage),null==(h=i[s=this.modelName])&&(i[s]={}),null==(u=r[a=this.modelName])&&(r[a]={}),null==(c=Mozart.LocalStorage)&&(Mozart.LocalStorage=Mozart.MztObject.create({handleError:function(t,e,n){returnMozart.LocalStorage.trigger("notFound",t,e,n)}})),o=this.getLocalStoragePrefix(),this.instanceClass.extend({getLocalStorageId:function(){returnthis.modelClass.getLocalStorageId(this.id)},existsInLocalStorage:function(){vart;returnt=this.modelClass.getLocalStorageId(this.id),null!=window.localStorage[this+("-"+t)]},loadLocalStorage:function(){returnthis.modelClass.loadLocalStorage(this)}}),n=window.localStorage[o+"-nextPK"],null==n&&(window.localStorage[o+"-nextPK"]="1"),e=window.localStorage[o+"-index"],null==e?window.localStorage[o+"-index"]="[]":void0},getLocalStoragePrefix:function(){returnthis.localStorageOptions.prefix+"-"+this.modelName},registerLocalStorageId:function(t,e){if(null==i[this.modelName])throwError("Model.registerLocalStorageId: "+this.modelName+" is not registered for localStorage.");returni[this.modelName][e]=t,r[this.modelName][t]=e},unRegisterLocalStorageId:function(t,e){returndeletei[this.modelName][e],deleter[this.modelName][t]},getLocalStorageId:function(t){returnr[this.modelName][t]},getLocalStorageClientId:function(t){returni[this.modelName][t]},toLocalStorageObject:function(t){varn,r,i,o,s,a,l,h;i={},a=this.attrs;for(nina)o=a[n],"id"!==n&&(i[n]=t[n]);i.id=this.getLocalStorageId(t.id),l=this.fks;for(ninl)r=l[n],i[n]=r.getLocalStorageId(t[n]);h=this.polyFks;for(ninh)s=h[n],i[n]=null!=t[s]?e.models[t[s]].getLocalStorageId(t[n]):null;returni},toLocalStorageClientObject:function(t){varn,r,i,o,s,a,l,h;i={},a=this.attrs;for(nina)o=a[n],"id"!==n&&(i[n]=t[n]);i.id=this.getLocalStorageClientId(t.id),l=this.fks;for(ninl)r=l[n],i[n]=r.getLocalStorageClientId(t[n]),i[n]===void0&&(i[n]=null);h=this.polyFks;for(ninh)s=h[n],i[n]=null!=t[s]?e.models[t[s]].getLocalStorageClientId(t[n]):null;returni},loadAllLocalStorage:function(){vart,e,r,i,o,s;for(i=this.getLocalStoragePrefix(),e=JSON.parse(window.localStorage[i+"-index"]),o=0,s=e.length;s>o;o++)r=e[o],t=JSON.parse(window.localStorage[i+("-"+r)]),this._processLocalStorageLoad(r,t,this);returnthis.trigger("loadAllLocalStorageComplete"),n.log("localStorage","Model.loadAllLocalStorage.onComplete")},loadLocalStorage:function(t){vare;returne=t.modelClass.getLocalStorageId(t.id),this.loadLocalStorageId(e)},loadLocalStorageId:function(t){vare,n;returnn=this.getLocalStoragePrefix(),e=window.localStorage[n+("-"+t)],null==e&&Mozart.LocalStorage.handleError(this,t,"record does not exist"),e=JSON.parse(e),e.id=t,this._processLocalStorageLoad(t,e,this)},_processLocalStorageLoad:function(t,e,r){vari,o,s;returni=r.getLocalStorageClientId(t),o=r.toLocalStorageClientObject(e),null!=i?(s=r.findById(i),s.copyFrom(o)):s=r.initInstance(e),s.save({disableModelCreateEvent:!0,disableModelUpdateEvent:!0}),r.registerLocalStorageId(s.id,t),n.log("localStorage","Model._processLocalStorageLoad.onSuccess",e,r),r.trigger("loadLocalStorageComplete",s)},createLocalStorage:function(t){vare,r,i,o;returne=t.modelClass.toLocalStorageObject(t),o=t.modelClass.getLocalStoragePrefix(),i=parseInt(window.localStorage[o+"-nextPK"]),window.localStorage[o+"-nextPK"]=""+(i+1),window.localStorage[o+("-"+i)]=JSON.stringify(e),t.modelClass.registerLocalStorageId(t.id,i),r=JSON.parse(window.localStorage[o+"-index"]),r.push(i),window.localStorage[o+"-index"]=JSON.stringify(r),n.log("localStorage","Model.createLocalStorageComplete",t),t.modelClass.trigger("createLocalStorageComplete",t)},updateLocalStorage:function(t){vare,r,i;returnr=t.modelClass.getLocalStorageId(t.id),null!=r?(e=t.modelClass.toLocalStorageObject(t),i=t.modelClass.getLocalStoragePrefix(),null==window.localStorage[i+("-"+r)]&&Mozart.LocalStorage.handleError(t.modelClass,r,"updateLocalStorage: record does not exist"),window.localStorage[i+("-"+r)]=JSON.stringify(e),t.modelClass.trigger("updateLocalStorageComplete",t),n.log("localStorage","Model.updateLocalStorage.onComplete",t)):void0},destroyLocalStorage:function(t){vare,r,i;returnr=t.modelClass.getLocalStorageId(t.id),null!=r?(i=t.modelClass.getLocalStoragePrefix(),null==window.localStorage[i+("-"+r)]&&Mozart.LocalStorage.handleError(t.modelClass,r,"destroyLocalStorage: record does not exist"),window.localStorage.removeItem(i+("-"+r)),t.modelClass.unRegisterLocalStorageId(t.id,r),e=JSON.parse(window.localStorage[i+"-index"]),e=_.without(e,r),window.localStorage[i+"-index"]=JSON.stringify(e),n.log("localStorage","Model.destroyLocalStorage.onSuccess",t),t.modelClass.trigger("destroyLocalStorageComplete",r)):void0},destroyAllLocalStorage:function(){vart,e,n,o,s;for(n=this.getLocalStoragePrefix(),e=JSON.parse(window.localStorage[n+"-index"]),o=0,s=e.length;s>o;o++)t=e[o],window.localStorage.removeItem(n+("-"+t));returnwindow.localStorage[n+"-index"]="[]",window.localStorage[n+"-nextPK"]="1",i[this.modelName]={},r[this.modelName]={}}})}).call(this)}),t.define("/route.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};i=t("./util"),e=t("./object").MztObject,n.Route=r=function(t){functione(){returnthis.doTitle=o(this.doTitle,this),this.canEnter=o(this.canEnter,this),this.canExit=o(this.canExit,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.init=function(){returnnull!=this.path&&this.path.length>0||i.warn("Route must have a path",this),null==this.viewClass?i.warn("Route must have a viewClass",this):void0},e.prototype.canExit=function(){return!(null!=this.exit)||this.exit()===!0},e.prototype.canEnter=function(t){return!(null!=this.enter)||this.enter(t)===!0},e.prototype.doTitle=function(){returnnull!=this.title?document.title="function"==typeofthis.title?this.title(this):this.title:void0},e}(e)}).call(this)}),t.define("/switch-view.coffee",function(t,e,n){(function(){vare,r,i=function(t,e){returnfunction(){returnt.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){functionn(){this.constructor=t}for(varrine)o.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};r=t("./view").View,n.SwitchView=e=function(t){functione(){returnthis.beforeRender=i(this.beforeRender,this),e.__super__.constructor.apply(this,arguments)}returns(e,t),e.prototype.beforeRender=function(){vart;returnt=HandlebarsTemplates[this.templateBase+"/"+this.content[this.templateField]],null!=t?this.templateFunction=t:(Util.log("views","SwitchView: No view found for "+this.templateBase+"/"+this.content[this.templateField]),this.templateFunction=function(){return""})},e}(r)}).call(this)}),t.define("/dynamic-view.coffee",function(t,e,n){(function(){vare,r,i,o=function(t,e){returnfunction(){returnt.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){functionn(){this.constructor=t}for(varrine)s.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};i=t("./view").View,r=t("./util"),n.DynamicView=e=function(t){functione(){returnthis.createText=o(this.createText,this),this.createView=o(this.createView,this),this.afterRender=o(this.afterRender,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}returna(e,t),e.prototype.skipTemplate=!0,e.prototype.init=function(){returne.__super__.init.apply(this,arguments),r.log("dynamicview","init"),null!=this.schema?this.bind("change:schema",this.afterRender):void0},e.prototype.afterRender=function(){vart,e,n,i,o;if(this.releaseChildren(),this.element.empty(),!r.isArray(this.schema))returnr.warn("DynamicView "+id+": schema is not an array"),void0;for(i=this.schema,o=[],e=0,n=i.length;n>e;e++)t=i[e],null!=t.viewClass?o.push(this.createView(t)):o.push(this.createText(t));returno},e.prototype.createView=function(t){vare,n;returnn=r._getPath(t.viewClass),deletet.viewClass,t.parent=this,e=this.layout.createView(n,t),this.element.append(e.createElement()),this.addView(e),this.layout.queueRenderView(e)},e.prototype.createText=function(t){returnthis.element.append(t)},e}(i)}).call(this)}),t.define("/cookies.coffee",function(t,e,n){(function(){vare,r,i={}.hasOwnProperty,o=function(t,e){functionn(){this.constructor=t}for(varrine)i.call(e,r)&&(t[r]=e[r]);returnn.prototype=e.prototype,t.prototype=newn,t.__super__=e.prototype,t};r=t("./object").MztObject,n.Cookies=e=function(t){functione(){returne.__super__.constructor.apply(this,arguments)}returno(e,t),e.setCookie=function(t,e,n){varr,i,o,s,a,l;returnn=n||{},void0!==document.cookie&&(n.path||(n.path="/"),s=""+encodeURIComponent(t)+"="+encodeURIComponent(e),a=n.path?";path="+n.path:"",r=n.domain?";domain="+n.domain:"",o=n["max-age"]?";max-age="+n["max-age"]:"",i="",n.expiresinstanceofDate&&(i=";expires="+n.expires.toUTCString()),l=n.secure?";secure":"",document.cookie=s+a+r+o+i+l),this},e.getCookie=function(t){vare,n,r,i,o,s;for(n=document.cookie.split(/;\s*/),o=0,s=n.length;s>o;o++)if(e=n[o],i=e.split("="),r=decodeURIComponent(i[0]),r===t)returndecodeURIComponent(i[1]);returnnull},e.removeCookie=function(t){vare;returne=newDate,e.setTime(e.getTime()-1),this.setCookie(t,"",{expires:e}),this},e.hasCookie=function(t){returnnull!==this.getCookie(t)},e}(r)}).call(this)}),t.define("/mozart.coffee",function(t,e,n,r,i,o,s){(function(){vare,n,r,i,o,a,l,h,u={}.hasOwnProperty;for(e={version:"0.1.8",versionDate:newDate(2013,6,1),Plugins:{}},l=[t("./collection"),t("./control"),t("./controller"),t("./data-index"),t("./dom-manager"),t("./events"),t("./handlebars"),t("./http"),t("./layout"),t("./model-instance"),t("./model-instancecollection"),t("./model-onetomanycollection"),t("./model-onetomanypolycollection"),t("./model-manytomanycollection"),t("./model-manytomanypolycollection"),t("./model-manytomanypolyreversecollection"),t("./model-ajax"),t("./model-localstorage"),t("./model"),t("./object"),t("./route"),t("./router"),t("./switch-view"),t("./util"),t("./view"),t("./dynamic-view"),t("./cookies")],o=0,a=l.length;a>o;o++){r=l[o];for(iinr)u.call(r,i)&&(n=r[i],e[i]=n)}null!=s.module?r.exports=e:null!=(null!=(h=s.define)?h.amd:void0)?define("mozart",e):s.Mozart=e}).call(this)}),t("/mozart.coffee")})();
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore may be freely distributed under the MIT license.
(function(){vare=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=r.unshift,l=i.toString,c=i.hasOwnProperty,h=r.forEach,p=r.map,d=r.reduce,v=r.reduceRight,m=r.filter,g=r.every,y=r.some,b=r.indexOf,w=r.lastIndexOf,E=Array.isArray,S=Object.keys,x=s.bind,T=function(e){if(einstanceofT)returne;if(!(thisinstanceofT))returnnewT(e);this._wrapped=e};typeofexports!="undefined"?(typeofmodule!="undefined"&&module.exports&&(exports=module.exports=T),exports._=T):e._=T,T.VERSION="1.4.2";varN=T.each=T.forEach=function(e,t,r){if(e==null)return;if(h&&e.forEach===h)e.forEach(t,r);elseif(e.length===+e.length){for(vari=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}elsefor(varoine)if(T.has(e,o)&&t.call(r,e[o],o,e)===n)return};T.map=T.collect=function(e,t,n){varr=[];returne==null?r:p&&e.map===p?e.map(t,n):(N(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)},T.reduce=T.foldl=T.inject=function(e,t,n,r){vari=arguments.length>2;e==null&&(e=[]);if(d&&e.reduce===d)returnr&&(t=T.bind(t,r)),i?e.reduce(t,n):e.reduce(t);N(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)thrownewTypeError("Reduce of empty array with no initial value");returnn},T.reduceRight=T.foldr=function(e,t,n,r){vari=arguments.length>2;e==null&&(e=[]);if(v&&e.reduceRight===v)returnr&&(t=T.bind(t,r)),arguments.length>2?e.reduceRight(t,n):e.reduceRight(t);vars=e.length;if(s!==+s){varo=T.keys(e);s=o.length}N(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)thrownewTypeError("Reduce of empty array with no initial value");returnn},T.find=T.detect=function(e,t,n){varr;returnC(e,function(e,i,s){if(t.call(n,e,i,s))returnr=e,!0}),r},T.filter=T.select=function(e,t,n){varr=[];returne==null?r:m&&e.filter===m?e.filter(t,n):(N(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},T.reject=function(e,t,n){varr=[];returne==null?r:(N(e,function(e,i,s){t.call(n,e,i,s)||(r[r.length]=e)}),r)},T.every=T.all=function(e,t,r){t||(t=T.identity);vari=!0;returne==null?i:g&&e.every===g?e.every(t,r):(N(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))returnn}),!!i)};varC=T.some=T.any=function(e,t,r){t||(t=T.identity);vari=!1;returne==null?i:y&&e.some===y?e.some(t,r):(N(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))returnn}),!!i)};T.contains=T.include=function(e,t){varn=!1;returne==null?n:b&&e.indexOf===b?e.indexOf(t)!=-1:(n=C(e,function(e){returne===t}),n)},T.invoke=function(e,t){varn=u.call(arguments,2);returnT.map(e,function(e){return(T.isFunction(t)?t:e[t]).apply(e,n)})},T.pluck=function(e,t){returnT.map(e,function(e){returne[t]})},T.where=function(e,t){returnT.isEmpty(t)?[]:T.filter(e,function(e){for(varnint)if(t[n]!==e[n])return!1;return!0})},T.max=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)returnMath.max.apply(Math,e);if(!t&&T.isEmpty(e))return-Infinity;varr={computed:-Infinity};returnN(e,function(e,i,s){varo=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},T.min=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)returnMath.min.apply(Math,e);if(!t&&T.isEmpty(e))returnInfinity;varr={computed:Infinity};returnN(e,function(e,i,s){varo=t?t.call(n,e,i,s):e;o<r.computed&&(r={value:e,computed:o})}),r.value},T.shuffle=function(e){vart,n=0,r=[];returnN(e,function(e){t=T.random(n++),r[n-1]=r[t],r[t]=e}),r};vark=function(e){returnT.isFunction(e)?e:function(t){returnt[e]}};T.sortBy=function(e,t,n){varr=k(t);returnT.pluck(T.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){varn=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void0)return1;if(n<r||r===void0)return-1}returne.index<t.index?-1:1}),"value")};varL=function(e,t,n,r){vari={},s=k(t);returnN(e,function(t,o){varu=s.call(n,t,o,e);r(i,u,t)}),i};T.groupBy=function(e,t,n){returnL(e,t,n,function(e,t,n){(T.has(e,t)?e[t]:e[t]=[]).push(n)})},T.countBy=function(e,t,n){returnL(e,t,n,function(e,t,n){T.has(e,t)||(e[t]=0),e[t]++})},T.sortedIndex=function(e,t,n,r){n=n==null?T.identity:k(n);vari=n.call(r,t),s=0,o=e.length;while(s<o){varu=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}returns},T.toArray=function(e){returne?e.length===+e.length?u.call(e):T.values(e):[]},T.size=function(e){returne.length===+e.length?e.length:T.keys(e).length},T.first=T.head=T.take=function(e,t,n){returnt!=null&&!n?u.call(e,0,t):e[0]},T.initial=function(e,t,n){returnu.call(e,0,e.length-(t==null||n?1:t))},T.last=function(e,t,n){returnt!=null&&!n?u.call(e,Math.max(e.length-t,0)):e[e.length-1]},T.rest=T.tail=T.drop=function(e,t,n){returnu.call(e,t==null||n?1:t)},T.compact=function(e){returnT.filter(e,function(e){return!!e})};varA=function(e,t,n){returnN(e,function(e){T.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};T.flatten=function(e,t){returnA(e,t,[])},T.without=function(e){returnT.difference(e,u.call(arguments,1))},T.uniq=T.unique=function(e,t,n,r){vari=n?T.map(e,n,r):e,s=[],o=[];returnN(i,function(n,r){if(t?!r||o[o.length-1]!==n:!T.contains(o,n))o.push(n),s.push(e[r])}),s},T.union=function(){returnT.uniq(a.apply(r,arguments))},T.intersection=function(e){vart=u.call(arguments,1);returnT.filter(T.uniq(e),function(e){returnT.every(t,function(t){returnT.indexOf(t,e)>=0})})},T.difference=function(e){vart=a.apply(r,u.call(arguments,1));returnT.filter(e,function(e){return!T.contains(t,e)})},T.zip=function(){vare=u.call(arguments),t=T.max(T.pluck(e,"length")),n=newArray(t);for(varr=0;r<t;r++)n[r]=T.pluck(e,""+r);returnn},T.object=function(e,t){varn={};for(varr=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];returnn},T.indexOf=function(e,t,n){if(e==null)return-1;varr=0,i=e.length;if(n){if(typeofn!="number")returnr=T.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(b&&e.indexOf===b)returne.indexOf(t,n);for(;r<i;r++)if(e[r]===t)returnr;return-1},T.lastIndexOf=function(e,t,n){if(e==null)return-1;varr=n!=null;if(w&&e.lastIndexOf===w)returnr?e.lastIndexOf(t,n):e.lastIndexOf(t);vari=r?n:e.length;while(i--)if(e[i]===t)returni;return-1},T.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;varr=Math.max(Math.ceil((t-e)/n),0),i=0,s=newArray(r);while(i<r)s[i++]=e,e+=n;returns};varO=function(){};T.bind=function(t,n){varr,i;if(t.bind===x&&x)returnx.apply(t,u.call(arguments,1));if(!T.isFunction(t))thrownewTypeError;returni=u.call(arguments,2),r=function(){if(thisinstanceofr){O.prototype=t.prototype;vare=newO,s=t.apply(e,i.concat(u.call(arguments)));returnObject(s)===s?s:e}returnt.apply(n,i.concat(u.call(arguments)))}},T.bindAll=function(e){vart=u.call(arguments,1);returnt.length==0&&(t=T.functions(e)),N(t,function(t){e[t]=T.bind(e[t],e)}),e},T.memoize=function(e,t){varn={};returnt||(t=T.identity),function(){varr=t.apply(this,arguments);returnT.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},T.delay=function(e,t){varn=u.call(arguments,2);returnsetTimeout(function(){returne.apply(null,n)},t)},T.defer=function(e){returnT.delay.apply(T,[e,1].concat(u.call(arguments,1)))},T.throttle=function(e,t){varn,r,i,s,o,u,a=T.debounce(function(){o=s=!1},t);returnfunction(){n=this,r=arguments;varf=function(){i=null,o&&(u=e.apply(n,r)),a()};returni||(i=setTimeout(f,t)),s?o=!0:(s=!0,u=e.apply(n,r)),a(),u}},T.debounce=function(e,t,n){varr,i;returnfunction(){vars=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;returnclearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},T.once=function(e){vart=!1,n;returnfunction(){returnt?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},T.wrap=function(e,t){returnfunction(){varn=[e];returno.apply(n,arguments),t.apply(this,n)}},T.compose=function(){vare=arguments;returnfunction(){vart=arguments;for(varn=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];returnt[0]}},T.after=function(e,t){returne<=0?t():function(){if(--e<1)returnt.apply(this,arguments)}},T.keys=S||function(e){if(e!==Object(e))thrownewTypeError("Invalid object");vart=[];for(varnine)T.has(e,n)&&(t[t.length]=n);returnt},T.values=function(e){vart=[];for(varnine)T.has(e,n)&&t.push(e[n]);returnt},T.pairs=function(e){vart=[];for(varnine)T.has(e,n)&&t.push([n,e[n]]);returnt},T.invert=function(e){vart={};for(varnine)T.has(e,n)&&(t[e[n]]=n);returnt},T.functions=T.methods=function(e){vart=[];for(varnine)T.isFunction(e[n])&&t.push(n);returnt.sort()},T.extend=function(e){returnN(u.call(arguments,1),function(t){for(varnint)e[n]=t[n]}),e},T.pick=function(e){vart={},n=a.apply(r,u.call(arguments,1));returnN(n,function(n){nine&&(t[n]=e[n])}),t},T.omit=function(e){vart={},n=a.apply(r,u.call(arguments,1));for(variine)T.contains(n,i)||(t[i]=e[i]);returnt},T.defaults=function(e){returnN(u.call(arguments,1),function(t){for(varnint)e[n]==null&&(e[n]=t[n])}),e},T.clone=function(e){returnT.isObject(e)?T.isArray(e)?e.slice():T.extend({},e):e},T.tap=function(e,t){returnt(e),e};varM=function(e,t,n,r){if(e===t)returne!==0||1/e==1/t;if(e==null||t==null)returne===t;einstanceofT&&(e=e._wrapped),tinstanceofT&&(t=t._wrapped);vari=l.call(e);if(i!=l.call(t))return!1;switch(i){case"[object String]":returne==String(t);case"[object Number]":returne!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":returne.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeofe!="object"||typeoft!="object")return!1;vars=n.length;while(s--)if(n[s]==e)returnr[s]==t;n.push(e),r.push(t);varo=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{vara=e.constructor,f=t.constructor;if(a!==f&&!(T.isFunction(a)&&ainstanceofa&&T.isFunction(f)&&finstanceoff))return!1;for(varcine)if(T.has(e,c)){o++;if(!(u=T.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(cint)if(T.has(t,c)&&!(o--))break;u=!o}}returnn.pop(),r.pop(),u};T.isEqual=function(e,t){returnM(e,t,[],[])},T.isEmpty=function(e){if(e==null)return!0;if(T.isArray(e)||T.isString(e))returne.length===0;for(vartine)if(T.has(e,t))return!1;return!0},T.isElement=function(e){return!!e&&e.nodeType===1},T.isArray=E||function(e){returnl.call(e)=="[object Array]"},T.isObject=function(e){returne===Object(e)},N(["Arguments","Function","String","Number","Date","RegExp"],function(e){T["is"+e]=function(t){returnl.call(t)=="[object "+e+"]"}}),T.isArguments(arguments)||(T.isArguments=function(e){return!!e&&!!T.has(e,"callee")}),typeof/./!="function"&&(T.isFunction=function(e){returntypeofe=="function"}),T.isFinite=function(e){returnT.isNumber(e)&&isFinite(e)},T.isNaN=function(e){returnT.isNumber(e)&&e!=+e},T.isBoolean=function(e){returne===!0||e===!1||l.call(e)=="[object Boolean]"},T.isNull=function(e){returne===null},T.isUndefined=function(e){returne===void0},T.has=function(e,t){returnc.call(e,t)},T.noConflict=function(){returne._=t,this},T.identity=function(e){returne},T.times=function(e,t,n){for(varr=0;r<e;r++)t.call(n,r)},T.random=function(e,t){returnt==null&&(t=e,e=0),e+(0|Math.random()*(t-e+1))};var_={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};_.unescape=T.invert(_.escape);varD={escape:newRegExp("["+T.keys(_.escape).join("")+"]","g"),unescape:newRegExp("("+T.keys(_.unescape).join("|")+")","g")};T.each(["escape","unescape"],function(e){T[e]=function(t){returnt==null?"":(""+t).replace(D[e],function(t){return_[e][t]})}}),T.result=function(e,t){if(e==null)returnnull;varn=e[t];returnT.isFunction(n)?n.call(e):n},T.mixin=function(e){N(T.functions(e),function(t){varn=T[t]=e[t];T.prototype[t]=function(){vare=[this._wrapped];returno.apply(e,arguments),F.call(this,n.apply(T,e))}})};varP=0;T.uniqueId=function(e){vart=P++;returne?e+t:t},T.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};varH=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;T.template=function(e,t,n){n=T.defaults({},n,T.templateSettings);varr=newRegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),i=0,s="__p+='";e.replace(r,function(t,n,r,o,u){s+=e.slice(i,u).replace(j,function(e){return"\\"+B[e]}),s+=n?"'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?"'+\n((__t=("+r+"))==null?'':__t)+\n'":o?"';\n"+o+"\n__p+='":"",i=u+t.length}),s+="';\n",n.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{varo=newFunction(n.variable||"obj","_",s)}catch(u){throwu.source=s,u}if(t)returno(t,T);vara=function(e){returno.call(this,e,T)};returna.source="function("+(n.variable||"obj")+"){\n"+s+"}",a},T.chain=function(e){returnT(e).chain()};varF=function(e){returnthis._chain?T(e).chain():e};T.mixin(T),N(["pop","push","reverse","shift","sort","splice","unshift"],function(e){vart=r[e];T.prototype[e]=function(){varn=this._wrapped;returnt.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&deleten[0],F.call(this,n)}}),N(["concat","join","slice"],function(e){vart=r[e];T.prototype[e]=function(){returnF.call(this,t.apply(this._wrapped,arguments))}}),T.extend(T.prototype,{chain:function(){returnthis._chain=!0,this},value:function(){returnthis._wrapped}})}).call(this);
A TodoMVC example in the [Mozart](http://mozart.io/) Framework.
Full details, downloads and documentation for Mozart can be found on [The official website](http://mozart.io/)
Please see [The official TodoMVC website](http://todomvc.com/) for more details on the TodoMVC project.
### Implementation
TodoMVC Mozart is implemented as a single controller and a set of views. A single model stores the todo items, persisted to LocalStorage by the built-in Mozart LocalStorage module.
app/controllers/
### Dependencies
-[Node.js](http://nodejs.org/)
```
npm install
```
### Run development server
```
grunt run
```
The development server runs at [http://localhost:8080/](http://localhost:8080/)
### Testing
The application can be tested from the command line:
```
grunt test
```
The spec runner is also available at [http://localhost:8080/specs/](http://localhost:8080/specs/)
### Notes
The Mozart TodoMVC app demonstrates:
- Views, Controllers, Models
- Custom Controls
- Binding
- Hash Routing
- LocalStorage persistence
Departures from specification:
- The Mozart LocalStorage places each entity record in a seperate key for speed of access, this is a departure from the TodoMVC application spec which states a single key with a large data blob.
- As this is a compiled example, a 'Full Source' link has been provided to the [standalone todomvc-mozart Github project](https://github.com/tomcully/todomvc-mozart).