(function(e){vart=function(){return{}};typeofdefine=="function"&&define.amd?define("epitome",[],t):e.Epitome=t(e)})(this),function(e){vart=function(e){vart=e.isEqual=function(e,n,r){r=r||[];if(e===n)returne!==0||1/e==1/n;if(e==null||n==null)returne===n;vari=typeOf(e),s=typeOf(n);if(i!=s)return!1;switch(i){case"string":returne==String(n);case"number":returne!=+e?n!=+n:e==0?1/e==1/n:e==+n;case"date":case"boolean":return+e==+n;case"regexp":returne.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if(typeofe!="object"||typeofn!="object")return!1;varo=r.length;while(o--)if(r[o]==e)return!0;r.push(e);varu=0,a=!0;if(i=="array"){u=e.length,a=u==n.length;if(a)while(u--)if(!(a=uine==uinn&&t(e[u],n[u],r)))break}else{if("constructor"ine!="constructor"inn||e.constructor!=n.constructor)return!1;for(varfine)if(e.hasOwnProperty(f)){u++;if(!(a=n.hasOwnProperty(f)&&t(e[f],n[f],r)))break}if(a){for(finn)if(n.hasOwnProperty(f)&&!(u--))break;a=!u}}returnr.pop(),a};returne};typeofdefine=="function"&&define.amd?define("epitome-isequal",["./epitome"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){returne.Model=newClass({Implements:[Options,Events],_attributes:{},properties:{id:{get:function(){vare=this._attributes.id||(this._attributes.id=String.uniqueID());returnthis.cid||(this.cid=e),e}}},options:{defaults:{}},collections:[],initialize:function(e,t){returnt&&t.defaults&&(this.options.defaults=Object.merge(this.options.defaults,t.defaults)),e=e&&typeOf(e)==="object"?e:{},this.set(Object.merge(this.options.defaults,e)),this.setOptions(t),this.fireEvent("ready")},set:function(){this.propertiesChanged=[],this._set.apply(this,arguments),this.propertiesChanged.length&&this.fireEvent("change",this.get(this.propertiesChanged))},_set:function(t,n){return!t||typeofn=="undefined"?this:this.properties[t]&&this.properties[t].set?this.properties[t].set.call(this,n):this._attributes[t]&&e.isEqual(this._attributes[t],n)?this:(n===null?deletethis._attributes[t]:this._attributes[t]=n,this.fireEvent("change:"+t,n),this.propertiesChanged.push(t),this)}.overloadSetter(),get:function(e){returne&&this.properties[e]&&this.properties[e].get?this.properties[e].get.call(this):e&&typeofthis._attributes[e]!="undefined"?this._attributes[e]:null}.overloadGetter(),unset:function(){vare=Array.prototype.slice.apply(arguments),t={},n=e.length;returnn?(Array.each(Array.flatten(e),function(e){t[e]=null}),this.set(t),this):this},toJSON:function(){returnObject.clone(this._attributes)},empty:function(){vare=Object.keys(this.toJSON()),t=this;this.fireEvent("change",[e]),Array.each(e,function(e){t.fireEvent("change:"+e,null)},this),this._attributes={},this.fireEvent("empty")},destroy:function(){this._attributes={},this.fireEvent("destroy")}}),e};typeofdefine=="function"&&define.amd?define("epitome-model",["./epitome-isequal"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){vart=e.Model,n="sync:",r={create:"POST",read:"GET",update:"PUT",delete_:"DELETE"};returnt.Sync=newClass({Extends:t,properties:{id:{get:function(){vare=this._attributes.id||(this._attributes.id=String.uniqueID());returnthis.cid||(this.cid=e),e}},urlRoot:{set:function(e){this.urlRoot=e,deletethis._attributes.urlRoot},get:function(){vare=this.urlRoot||this.options.urlRoot||"no-urlRoot-set";returne.charAt(e.length-1)!="/"&&(e+="/"),e}}},options:{emulateREST:!1},initialize:function(e,t){this.setupSync(),this.parent(e,t)},sync:function(e,t){varn={};e=e&&r[e]?r[e]:r.read,n.method=e;if(e==r.create||e==r.update)n.data=t||this.toJSON();returnn.url=this.get("urlRoot")+this.get("id")+"/",this.request.setOptions(n),this.request[e](t),this},setupSync:function(){vare=this,t=0,i=function(){t++};returnthis.getRequestId=function(){returnt+1},this.request=newRequest.JSON({link:"chain",url:this.get("urlRoot"),emulation:this.options.emulateREST,onRequest:i,onCancel:function(){this.removeEvents(n+t)},onSuccess:function(r){r=e.parse&&e.parse(r),e.fireEvent(n+t,[r]),e.fireEvent("sync",[r,this.options.method,this.options.data])},onFailure:function(){e.fireEvent(n+"error",[this.options.method,this.options.url,this.options.data])}}),Object.each(r,function(t,n){e[n]=function(e){this.sync(n,e)}}),this},_throwAwaySyncEvent:function(e,t){e=e||n+this.getRequestId();varr=this,i={};returni[e]=function(e){e&&typeofe=="object"&&(r.set(e),t&&t.call(r,e)),r.removeEvents(i)},this.addEvents(i)}.protect(),parse:function(e){returne},fetch:function(){returnthis._throwAwaySyncEvent(n+this.getRequestId(),function(){this.fireEvent("fetch"),this.isNewModel=!1}),this.read(),this},save:function(e,t){varr=["update","create"][+this.isNew()];if(e){vari=typeOf(e),s=i=="object"||i=="string"&&typeoft!="undefined";s&&this._set.apply(this,arguments)}returnthis._throwAwaySyncEvent(n+this.getRequestId(),function(){this.fireEvent("save"),this.fireEvent(r)}),this[r](),this.isNewModel=!1,this},destroy:function(){this._throwAwaySyncEvent(n+this.getRequestId(),function(){this._attributes={},this.delete_(),this.fireEvent("destroy")})},isNew:function(){returntypeofthis.isNewModel=="undefined"&&(this.isNewModel=!0),this.isNewModel}}),e};typeofdefine=="function"&&define.amd?define("epitome-model-sync",["./epitome-model"],t):e.Epitome=t(e)}(this),function(e){vart=function(t){returnt.Storage=function(){vart=typeofe.localStorage=="object"&&!!e.localStorage.getItem,n="localStorage",r="sessionStorage",i=function(n){varr,i="epitome-"+n,s={},o="model";if(t)try{s=JSON.decode(e[n].getItem(i))||s}catch(u){t=!1}if(!t)try{r=JSON.decode(e.name),r&&typeofr=="object"&&r[i]&&(s=r[i])}catch(u){h()}vara={store:function(e){e=e||this.toJSON(),l([o,this.get("id")].join(":"),e),this.fireEvent("store",e)},eliminate:function(){returnc([o,this.get("id")].join(":")),this.fireEvent("eliminate")},retrieve:function(){vare=f([o,this.get("id")].join(":"))||null;returnthis.fireEvent("retrieve",e),e}},f=function(e){returns[e]||null},l=function(r,o){s=JSON.decode(e[n].getItem(i))||s,s[r]=o;if(t)try{e[n].setItem(i,JSON.encode(s))}catch(u){}elseh();returnthis},c=function(r){deletes[r];if(t)try{e[n].setItem(i,JSON.encode(s))}catch(o){}elseh()},h=function(){vart={},n=JSON.decode(e.name);t[i]=s,e.name=JSON.encode(Object.merge(t,n))};returnfunction(e){returne&&(o=e),newClass(Object.clone(a))}};return{localStorage:i(n),sessionStorage:i(r)}}(),t};typeofdefine=="function"&&define.amd?define("epitome-storage",["./epitome"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){vart=["forEach","each","invoke","filter","map","some","indexOf","contains","getRandom","getLast"];Function.extend({monitorModelEvents:function(e,t){varn=this;returnt=t||this,!e||!e.fireEvent?this:function(r,i,s){n.apply(t,arguments),e.getModelByCID(t.cid)&&e.fireEvent(r,Array.flatten([t,i]),s)}}});varn=e.Collection=newClass({Implements:[Options,Events],model:e.Model,_models:[],initialize:function(e,t){returnthis.setOptions(t),e&&this.setUp(e),this.id=this.options.id||String.uniqueID(),this.fireEvent("ready")},setUp:function(e){returne=Array.from(e),Array.each(e,this.addModel.bind(this)),this.addEvent("destroy",this.removeModel.bind(this)),this},addModel:function(e,t){varn;returntypeOf(e)=="object"&&!instanceOf(e,this.model)&&(e=newthis.model(e)),e.cid=e.cid||e.get("id")||String.uniqueID(),n=this.getModelByCID(e.cid),n&&t!==!0?this.fireEvent("add:error",e):(n&&t===!0&&(this._models[this._models.indexOf(e)]=e),e.fireEvent=Function.monitorModelEvents.apply(e.fireEvent,[this,e]),this._models.push(e),e.collections.include(this),this.length=this._models.length,this.fireEvent("add",[e,e.cid]).fireEvent("reset",[e,e.cid]))},removeModel:function(e){vart=this;returne=Array.from(e),Array.each(e,function(e){e.collections.erase(t),e.collections.length||deletee.fireEvent,Array.erase(t._models,e),t.length=t._models.length,t.fireEvent("remove",[e,e.cid])}),this.fireEvent("reset",[e])},get:function(e){returnthis[e]},getModelByCID:function(e){vart=null;returnthis.some(function(n){returnn.cid==e&&(t=n)}),t},getModelById:function(e){vart=null;returnthis.some(function(n){returnn.get("id")==e&&(t=n)}),t},getModel:function(e){returnthis._models[e]},toJSON:function(){vare=function(e){returne.toJSON()};returnArray.map(this._models,e)},empty:function(){returnthis.removeModel(this._models),this.fireEvent("empty")},sort:function(e){if(!e)returnthis._models.sort(),this.fireEvent("sort");if(typeofe=="function")returnthis.model.sort(e),this.fireEvent("sort");vart="asc",n=e.split(":"),r=n[0],i=function(e,t){returne<t?-1:e>t?1:0};returnn[1]&&(t=n[1]),this._models.sort(function(e,n){vars=e.get(r),o=n.get(r),u=i(s,o),a={asc:u,desc:-u};returntypeofa[t]=="undefined"&&(t="asc"),a[t]}),this.fireEvent("sort")},reverse:function(){returnArray.reverse(this._models),this.fireEvent("sort")}});returnArray.each(t,function(e){n.implement(e,function(){returnArray.prototype[e].apply(this._models,arguments)})}),e};typeofdefine=="function"&&define.amd?define("epitome-collection",["./epitome-model"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){vart="no-urlRoot-set",n="fetch:";returne.Collection.Sync=newClass({Extends:e.Collection,options:{urlRoot:t},initialize:function(e,t){this.setupSync(),this.parent(e,t)},setupSync:function(){vare=this,t=0,r=function(){t++};returnthis.getRequestId=function(){returnt+1},this.request=newRequest.JSON({link:"chain",url:this.options.urlRoot,emulation:this.options.emulateREST,onRequest:r,onCancel:function(){this.removeEvents(n+t)},onSuccess:function(r){r=e.parse&&e.parse(r),e.fireEvent(n+t,[[r]])},onFailure:function(){e.fireEvent(n+"error",[this.options.method,this.options.url,this.options.data])}}),this},parse:function(e){returne},fetch:function(e){returnthis._throwAwayEvent(function(t){e?(this.empty(),Array.each(t,this.addModel.bind(this))):this.processModels(t),this.fireEvent("fetch",[t])}),this.request.get(),this},processModels:function(e){vart=this;Array.each(e,function(e){varn=e.id&&t.getModelById(e.id);n?n.set(e):t.addModel(e)})},_throwAwayEvent:function(e){vart=n+this.getRequestId(),r=this,i={};if(!e||typeofe!="function")return;returni[t]=function(t){e.apply(r,t),r.removeEvents(i)},this.addEvents(i)}.protect()}),e};typeofdefine=="function"&&define.amd?define("epitome-collection-sync",["./epitome-model"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){returne.Template=newClass({options:{evaluate:/<%([\s\S]+?)%>/g,normal:/<%=([\s\S]+?)%>/g,noMatch:/.^/,escaper:/\\|'|\r|\n|\t|\u2028|\u2029/g,unescaper:/\\(\\|'|r|n|t|u2028|u2029)/g},Implements:[Options],initialize:function(e){this.setOptions(e);vart=this.options.unescaper,n=this.escapes={"\\":"\\","'":"'",r:"\r",n:"\n",t:"",u2028:"\u2028",u2029:"\u2029"};returnObject.each(n,function(e,t){this[e]=t},n),this.unescape=function(e){returne.replace(t,function(e,t){returnn[t]})},this},template:function(e,t){varn=this.options,r=this.escapes,i=this.unescape,s=n.noMatch,o=n.escaper,u,a=["var __p=[],print=function(){__p.push.apply(__p,arguments);};","with(obj||{}){__p.push('",e.replace(o,function(e){return"\\"+r[e]}).replace(n.normal||s,function(e,t){return"',\nobj['"+i(t)+"'],\n'"}).replace(n.evaluate||s,function(e,t){return"');\n"+i(t)+"\n;__p.push('"}),"');\n}\nreturn __p.join('');"].join(""),f=newFunction("obj","_",a);returnt?f(t):(u=function(e){returnf.call(this,e)},u.source="function(obj){\n"+a+"\n}",u)}}),e};typeofdefine=="function"&&define.amd?define("epitome-template",["./epitome"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){returne.View=newClass({Implements:[Options,Events],element:null,collection:null,model:null,options:{template:"",events:{}},initialize:function(e){returne&&e.collection&&(this.setCollection(e.collection),deletee.collection),e&&e.model&&(this.setModel(e.model),deletee.model),this.setOptions(e),this.options.element&&(this.setElement(this.options.element,this.options.events),deletethis.options.element),this.fireEvent("ready")},setElement:function(e,t){returnthis.element&&this.detachEvents()&&this.destroy(),this.element=document.id(e),t&&this.attachEvents(t),this},setCollection:function(t){varn=this,r=function(e){returnfunction(){n.fireEvent(e+":collection",arguments)}};returninstanceOf(t,e.Collection)&&(this.collection=t,this.collection.addEvents({change:r("change"),fetch:r("fetch"),add:r("add"),remove:r("remove"),sort:r("sort"),reset:r("reset")})),this},setModel:function(t){varn=this,r=function(e){returnfunction(){n.fireEvent(e+":model",arguments)}};returninstanceOf(t,e.Model)&&(this.model=t,this.model.addEvents({change:r("change"),destroy:r("destroy"),empty:r("empty")})),this},attachEvents:function(e){vart=this;returnObject.each(e,function(e,n){t.element.addEvent(n,function(n){t.fireEvent(e,arguments)})}),this.element.store("attachedEvents",e),this},detachEvents:function(){vare=this.element.retrieve("attachedEvents");returne&&this.element.removeEvents(e).eliminate("attachedEvents"),this},template:function(t,n){n=n||this.options.template;varr=this.Template||(this.Template=newe.Template);returnr.template(n,t)},render:function(){returnthis.fireEvent("render")},empty:function(e){returne?this.element.empty():this.element.set("html",""),this.fireEvent("empty")},dispose:function(){returnthis.element.dispose(),this.fireEvent("dispose")},destroy:function(){returnthis.element.destroy(),this.fireEvent("destroy")}}),e};typeofdefine=="function"&&define.amd?define("epitome-view",["./epitome-template","./epitome-model","./epitome-collection"],t):e.Epitome=t(e)}(this),function(e){vart=function(e){vart="hashchange",n="on"+tinwindow,r=[window,document],i,s=function(e){vart={},n=/([^&=]+)=([^&]*)/g,r;while(r=n.exec(e))t[decodeURIComponent(r[1])]=decodeURIComponent(r[2]);returnt};returnElement.Events.hashchange={onAdd:function(){vare=location.hash,s=function(){if(e==location.hash)return;e=location.hash,r.invoke("fireEvent",t,e.indexOf("#")==0?e.substr(1):e)};n&&(window.onhashchange=s)||(i=s.periodical(100))},onRemove:function(){n&&(window.onhashchange=null)||clearInterval(i)}},e.Router=newClass({Implements:[Options,Events],options:{triggerOnLoad:!0},routes:{},boundEvents:{},initialize:function(e){varn=this;this.setOptions(e),this.options.routes&&(this.routes=this.options.routes),window.addEvent(t,function(e){vart=location.hash,r=t.split("?")[0],i=t.split("?")[1]||"",o=!0,u;for(uinn.routes){vara=[],f=n.normalize(u,a,!0,!1),l=f.exec(r),c=!1;if(l){o=!1,n.req=l[0];varh=l.slice(1),p={};Array.each(h,function(e,t){typeofa[t]!="undefined"&&(p[a[t].name]=e)}),n.route=u,n.param=p||{},n.query=i&&s(i),c=n.routes[u],n.fireEvent("before",c),c&&n.$events[c]?(n.fireEvent(c+":before"),n.fireEvent(c,Object.values(n.param))):n.fireEvent("error",["Route",c,"is undefined"].join("")),n.fireEvent("after",c),c&&n.fireEvent(c+":after");break}}o&&n.fireEvent("undefined")}),this.fireEvent("ready"),this.options.triggerOnLoad&&window.fireEvent(t)},navigate:function(e,n){location.hash==e&&n?window.fireEvent(t):location.hash=e},normalize:function(e,t,n,r){returneinstanceofRegExp?e:(e=e.concat(r?"":"/?").replace(/\/\(/g,"(?:/").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(e,n,r,i,s,o){returnt.push({name:i,optional:!!o}),n=n||"",[o?"":n,"(?:",o?n:"",(r||"")+(s||r&&"([^/.]+?)"||"([^/]+?)")+")",o||""].join("")}).replace(/([\/.])/g,"\\$1").replace(/\*/g,"(.*)"),newRegExp("^"+e+"$",n?"":"i"))},addRoute:function(e){return!e||!e.route||!e.id||!e.events?this.fireEvent("error","Please include route, id and events in the argument object when adding a route"):e.id.length?this.routes[e.route]?this.fireEvent("error",'Route "{route}" or id "{id}" already exists, aborting'.substitute(e)):(this.routes[e.route]=e.id,this.addEvents(this.boundEvents[e.route]=e.events),this.fireEvent("route:add",e)):this.fireEvent("error","Route id cannot be empty, aborting")},removeRoute:function(e){return!e||!this.routes[e]||!this.boundEvents[e]?this.fireEvent("error","Could not find route or route is not removable"):(this.removeEvents(this.boundEvents[e]),deletethis.routes[e],deletethis.boundEvents[e],this.fireEvent("route:remove",e))}}),e};typeofdefine=="function"&&define.amd?define("epitome-router",["./epitome"],t):e.Epitome=t(e)}(this)
(function(t){vare=function(){return{}};"function"==typeofdefine&&define.amd?define("epitome",e):t.Epitome=e(t)})(this),function(t){vare=function(){vart=function(e,n,i){if(i=i||[],e===n)return0!==e||1/e==1/n;if(null==e||null==n)returne===n;varo=typeOf(e),r=typeOf(n);if(o!=r)return!1;switch(o){case"string":returne==n+"";case"number":returne!=+e?n!=+n:0==e?1/e==1/n:e==+n;case"date":case"boolean":return+e==+n;case"regexp":returne.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if("object"!=typeofe||"object"!=typeofn)return!1;for(vars=i.length;s--;)if(i[s]==e)return!0;i.push(e);varu=0,a=!0;if("array"==o){if(u=e.length,a=u==n.length)for(;u--&&(a=uine==uinn&&t(e[u],n[u],i)););}else{if("constructor"ine!="constructor"inn||e.constructor!=n.constructor)return!1;for(varcine)if(e.hasOwnProperty(c)&&(u++,!(a=n.hasOwnProperty(c)&&t(e[c],n[c],i))))break;if(a){for(cinn)if(n.hasOwnProperty(c)&&!u--)break;a=!u}}returni.pop(),a};returnt};"function"==typeofdefine&&define.amd?define("epitome-isequal",["./epitome"],e):(t.Epitome=t.Epitome||{},t.Epitome.isEqual=e(t.Epitome))}(this),function(t){vare=function(t){returnnewClass({Implements:[Options,Events],_attributes:{},properties:{id:{get:function(){vart=this._attributes.id||String.uniqueID();returnthis.cid||(this.cid=t),this._attributes.id}}},validators:{},options:{defaults:{}},collections:[],initialize:function(t,e){returne&&e.defaults&&(this.options.defaults=Object.merge(this.options.defaults,e.defaults)),t=t&&"object"===typeOf(t)?t:{},this.set(Object.merge(this.options.defaults,t)),this.setOptions(e),this.fireEvent("ready")},set:function(){this.propertiesChanged=this.validationFailed=[],this._set.apply(this,arguments),this.propertiesChanged.length&&this.fireEvent("change",this.get(this.propertiesChanged)),this.validationFailed.length&&this.fireEvent("error",[this.validationFailed])},_set:function(e,n){if(!e||n===void0)returnthis;if(this.properties[e]&&this.properties[e].set)returnthis.properties[e].set.call(this,n);if(this._attributes[e]&&t(this._attributes[e],n))returnthis;vari=this.validate(e,n);if(this.validators[e]&&i!==!0){varo={};returno[e]={key:e,value:n,error:i},this.validationFailed.push(o),this.fireEvent("error:"+e,o[e]),this}returnnull===n?deletethis._attributes[e]:this._attributes[e]=n,this.fireEvent("change:"+e,n),this.propertiesChanged.push(e),this}.overloadSetter(),get:function(t){returnt&&this.properties[t]&&this.properties[t].get?this.properties[t].get.call(this):t&&this._attributes[t]!==void0?this._attributes[t]:null}.overloadGetter(),unset:function(){vart=Array.prototype.slice.apply(arguments),e={},n=t.length;returnn?(Array.each(Array.flatten(t),function(t){e[t]=null}),this.set(e),this):this},toJSON:function(){returnObject.clone(this._attributes)},empty:function(){vart=Object.keys(this.toJSON()),e=this;this.fireEvent("change",[t]),Array.each(t,function(t){e.fireEvent("change:"+t,null)},this),this._attributes={},this.fireEvent("empty")},destroy:function(){this._attributes={},this.fireEvent("destroy")},validate:function(t,e){returntinthis.validators?this.validators[t].call(this,e):!0}})};"function"==typeofdefine&&define.amd?define("epitome-model",["./epitome-isequal"],e):(t.Epitome=t.Epitome||{isEqual:{}},t.Epitome.Model=e(t.Epitome.isEqual))}(this),function(t){vare=newClass({Extends:Request,options:{secure:!0},initialize:function(t){this.parent(t),Object.append(this.headers,{Accept:"application/json","X-Request":"JSON"})},success:function(t){vare;try{e=this.response.json=JSON.decode(t,this.options.secure)}catch(n){returnthis.fireEvent("error",[t,n]),void0}t&&null==e&&204!=this.status?this.onFailure():this.onSuccess(e,t)}}),n=function(t){varn="sync:",i={create:"POST",read:"GET",update:"PUT",delete_:"DELETE"};returnnewClass({Extends:t,properties:{urlRoot:{set:function(t){this.urlRoot=t,deletethis._attributes.urlRoot},get:function(){vart=this.urlRoot||this.options.urlRoot||"no-urlRoot-set";return"/"!=t.charAt(t.length-1)&&(t+="/"),t}}},options:{emulateREST:!1,useJSON:!1},initialize:function(t,e){this.setupSync(),this.parent(t,e)},sync:function(t,e){varn={};returnt=t&&i[t]?i[t]:i.read,n.method=t,(t==i.create||t==i.update)&&(n.data=e||this.toJSON(),this.preProcessor&&(n.data=this.preProcessor(n.data))),this.options.useJSON&&["POST","PUT","DELETE"].contains(t)?(n.data=JSON.encode(n.data),n.urlEncoded=!1,this.request.setHeader("Content-type","application/json")):n.urlEncoded=!0,n.url=[this.get("urlRoot"),this.get("id")].join(""),"/"!==n.url.slice(-1)&&(n.url+="/"),this.request.setOptions(n),this.request[t](e),this},setupSync:function(){vart=this,o=0,r=function(){o++};returnthis.getRequestId=function(){returno+1},this.request=newe({link:"chain",url:this.get("urlRoot"),emulation:this.options.emulateREST,onRequest:r,onCancel:function(){this.removeEvents(n+o)},onSuccess:function(e){e=t.postProcessor&&t.postProcessor(e),t.fireEvent(n+o,[e]),t.fireEvent("sync",[e,this.options.method,this.options.data]),t.isNewModel=!1},onFailure:function(){t.fireEvent(n+"error",[this.options.method,this.options.url,this.options.data]),t.fireEvent("requestFailure",[this.status,this.response.text])}}),Object.each(i,function(e,n){t[n]=function(t){this.sync(n,t)}}),this},_throwAwaySyncEvent:function(t,e){t=t||n+this.getRequestId();vari=this,o={};returno[t]=function(t){t&&"object"==typeoft&&i.set(t),e&&e.call(i,t),i.removeEvents(o)},this.addEvents(o)}.protect(),postProcessor:function(t){returnt},preProcessor:function(t){returnt},fetch:function(){returnthis._throwAwaySyncEvent(n+this.getRequestId(),function(){this.fireEvent("fetch"),this.isNewModel=!1}),this.read(),this},save:function(t,e){vari=["update","create"][+this.isNew()];if(t){varo=typeOf(t),r="object"==o||"string"==o&&e!==void0;r&&this._set.apply(this,arguments)}returnthis._throwAwaySyncEvent(n+this.getRequestId(),function(){this.fireEvent("save"),this.fireEvent(i)}),this[i](),this},destroy:function(){this._throwAwaySyncEvent(n+this.getRequestId(),function(){this._attributes={},this.fireEvent("destroy")}),this.delete_()},isNew:function(){returnthis.isNewModel===void0&&(this.isNewModel=!this.get("id")),this.isNewModel}})};"function"==typeofdefine&&define.amd?define("epitome-model-sync",["./epitome-model"],n):(t.Epitome=t.Epitome||{Model:{}},t.Epitome.Model.Sync=n(t.Epitome.Model))}(this),function(t){vare=function(){vare=function(){vare=!("object"!=typeoft.localStorage||!t.localStorage.getItem),n="localStorage",i="sessionStorage",o=function(n){vari,o="epitome-"+n,r={},s="model";if(e)try{r=JSON.decode(t[n].getItem(o))||r}catch(u){e=!1}if(!e)try{i=JSON.decode(t.name),i&&"object"==typeofi&&i[o]&&(r=i[o])}catch(u){f()}vara={store:function(t){t=t||this.toJSON(),h([s,this.get("id")].join(":"),t),this.fireEvent("store",t)},eliminate:function(){returnl([s,this.get("id")].join(":")),this.fireEvent("eliminate")},retrieve:function(){vart=c([s,this.get("id")].join(":"))||null;returnthis.fireEvent("retrieve",t),t}},c=function(t){returnr[t]||null},h=function(i,s){if(r=e?JSON.decode(t[n].getItem(o))||r:r,r[i]=s,e)try{t[n].setItem(o,JSON.encode(r))}catch(u){}elsef();returnthis},l=function(i){if(deleter[i],e)try{t[n].setItem(o,JSON.encode(r))}catch(s){}elsef()},f=function(){vare={},n=JSON.decode(t.name);e[o]=r,t.name=JSON.encode(Object.merge(e,n))};returnfunction(t){returnt&&(s=t),newClass(Object.clone(a))}};return{localStorage:o(n),sessionStorage:o(i)}}();returne};"function"==typeofdefine&&define.amd?define("epitome-storage",["./epitome"],e):(t.Epitome=t.Epitome||{},t.Epitome.Storage=e(t))}(this),function(t){vare=function(e){varn=["forEach","each","invoke","filter","map","some","indexOf","contains","getRandom","getLast"];Function.extend({monitorModelEvents:function(t,e){varn=this;returne=e||this,t&&t.fireEvent&&!t.hasOwnProperty("fireEvent")?function(i,o,r){n.apply(e,arguments),t.getModelByCID(e.cid)&&t.fireEvent(i,Array.flatten([e,o]),r)}:this}});vari=newClass({Implements:[Options,Events],model:e,_models:[],initialize:function(t,e){returnthis.setOptions(e),t&&this.setUp(t),this.id=this.options.id||String.uniqueID(),this.fireEvent("ready")},setUp:function(t){returnt=Array.from(t),Array.each(t,this.addModel.bind(this)),this.addEvent("destroy",this.removeModel.bind(this)),this},addModel:function(t,e){varn;return"object"!=typeOf(t)||instanceOf(t,this.model)||(t=newthis.model(t)),t.cid=t.cid||t.get("id")||String.uniqueID(),n=this.getModelByCID(t.cid),n&&e!==!0?this.fireEvent("add:error",t):(n&&e===!0&&(this._models[this._models.indexOf(t)]=t),t.fireEvent=Function.monitorModelEvents.apply(t.fireEvent,[this,t]),this._models.push(t),t.collections.include(this),this.length=this._models.length,this.fireEvent("add",[t,t.cid]).fireEvent("reset",[t,t.cid]))},removeModel:function(t,e){varn=this;returnt=Array.from(t).slice(),Array.each(t,function(t){t.collections.erase(n),t.collections.length||deletet.fireEvent,Array.erase(n._models,t),n.length=n._models.length,e||n.fireEvent("remove",[t,t.cid])}),this.fireEvent("reset",[t])},get:function(t){returnthis[t]},getModelByCID:function(t){vare=null;returnthis.some(function(n){returnn.cid==t&&(e=n)}),e},getModelById:function(t){vare=null;returnthis.some(function(n){returnn.get("id")==t&&(e=n)}),e},getModel:function(t){returnthis._models[t]},toJSON:function(){vart=function(t){returnt.toJSON()};returnArray.map(this._models,t)},empty:function(t){returnthis.removeModel(this._models,t),this.fireEvent("empty")},sort:function(t){if(!t)returnthis._models.sort(),this.fireEvent("sort");if("function"==typeoft)returnthis.model.sort(t),this.fireEvent("sort");vare="asc",n=t.split(","),i=function(t,e){returne>t?-1:t>e?1:0};returnthis._models.sort(function(t,o){varr=0;returnArray.some(n,function(n){n=n.trim();vars=n.split(":"),u=s[0],a=s[1]?s[1]:e,c=t.get(u),h=o.get(u),l=i(c,h),f={asc:l,desc:-l};returnf[a]===void0&&(a=e),r=f[a],0!=r}),r}),this.fireEvent("sort")},reverse:function(){returnArray.reverse(this._models),this.fireEvent("sort")},find:function(e){varn=t.Slick.parse(e),i=[],o=this,r={"=":function(t,e){returnt==e},"!=":function(t,e){returnt!=e},"^=":function(t,e){return0===t.indexOf(e)},"*=":function(t,e){return-1!==t.indexOf(e)},"$=":function(t,e){returnt.indexOf(e)==t.length-e.length},"*":function(t){returnt!==void0}},s=function(t){returnt&&r[t]?r[t]:null},u=function(t){vare=t.key,n=t.value||null,i=t.tag||null,r=s(t.operator);o=o.filter(function(t){varo,s;returni&&e?(o=t.get(i),s=o?o[e]:null):s=i?t.get(i):t.get(e),null!==s&&null!==n&&null!==r?r(s,n):null!=s})};if(n.expressions.length){vara,c,h,l,f,d,p,v,m=n.expressions;t:for(c=0;l=m[c];c++){for(a=0;f=l[a];a++){if(h=f.attributes,d=f.id,d&&(p={key:"id",value:d,operator:"="},h||(h=[]),h.push(p)),v=f.tag,v&&"*"!=v&&(h||(h=[{key:null,value:"",operator:"*"}]),h=Array.map(h,function(t){returnt.tag=v,t})),!h)continuet;Array.each(h,u)}i[c]=o,o=this}}return[].combine(Array.flatten(i))},findOne:function(t){vare=this.find(t);returne.length?e[0]:null}});returnArray.each(n,function(t){i.implement(t,function(){returnArray.prototype[t].apply(this._models,arguments)})}),i};"function"==typeofdefine&&define.amd?define("epitome-collection",["./epitome-model"],e):(t.Epitome=t.Epitome||{Model:{}},t.Epitome.Collection=e(t.Epitome.Model))}(this),function(t){vare=function(t){vare="no-urlRoot-set",n="fetch:";returnnewClass({Extends:t,options:{urlRoot:e},initialize:function(t,e){this.setupSync(),this.parent(t,e)},setupSync:function(){vart=this,e=0,i=function(){e++};returnthis.getRequestId=function(){returne+1},this.request=newRequest.JSON({link:"chain",url:this.options.urlRoot,emulation:this.options.emulateREST,onRequest:i,onCancel:function(){this.removeEvents(n+e)},onSuccess:function(i){i=t.postProcessor&&t.postProcessor(i),t.fireEvent(n+e,[[i]])},onFailure:function(){t.fireEvent(n+"error",[this.options.method,this.options.url,this.options.data])}}),this},parse:function(t){returnt},fetch:function(t){returnthis._throwAwayEvent(function(e){t?(this.empty(),Array.each(e,this.addModel.bind(this))):this.processModels(e),this.fireEvent("fetch",[e])}),this.request.get(),this},processModels:function(t){vare=this;Array.each(t,function(t){varn=t.id&&e.getModelById(t.id);n?n.set(t):e.addModel(t)})},_throwAwayEvent:function(t){vare=n+this.getRequestId(),i=this,o={};if(t&&"function"==typeoft)returno[e]=function(e){t.apply(i,e),i.removeEvents(o)},this.addEvents(o)}.protect(),postProcessor:function(t){returnt}})};"function"==typeofdefine&&define.amd?define("epitome-collection-sync",["./epitome-collection"],e):(t.Epitome=t.Epitome||{Collection:{}},t.Epitome.Collection.Sync=e(t.Epitome.Collection))}(this),function(t){(function(){vart={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},e=RegExp("["+Object.keys(t).join("")+"]","g");String.implement({escape:function(){return(this+"").replace(e,function(e){returnt[e]})}})})();vare=function(){returnnewClass({options:{evaluate:/<%([\s\S]+?)%>/g,normal:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g,noMatch:/.^/,escaper:/\\|'|\r|\n|\t|\u2028|\u2029/g},Implements:[Options],initialize:function(t){this.setOptions(t);vare=this.escapes={"\\":"\\","'":"'",r:"\r",n:"\n",t:"",u2028:"\u2028",u2029:"\u2029"};returnObject.each(e,function(t,e){this[t]=e},e),this.matcher=RegExp([(this.options.escape||this.options.noMatch).source,(this.options.normal||this.options.noMatch).source,(this.options.evaluate||this.options.noMatch).source].join("|")+"|$","g"),this},template:function(t,e,n){vari,o=n?Object.merge(this.options,n):this.options,r=this.escapes,s=o.escaper,u=0,a="__p+='";t.replace(this.matcher,function(e,n,i,o,c){returna+=t.slice(u,c).replace(s,function(t){return"\\"+r[t]}),n&&(a+="'+\n((__t=(obj['"+n+"']))==null?'':String.escape(__t))+\n'"),i&&(a+="'+\n((__t=(obj['"+i+"']))==null?'':__t)+\n'"),o&&(a+="';\n"+o+"\n__p+='"),u=c+e.length,e}),a+="';\n",o.variable||(a="obj=obj||{};with(obj){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{i=Function(o.variable||"obj",a)}catch(c){throwc.source=a,c}if(e)returni(e);varh=function(t){returni.call(this,t)};returnh.source="function("+(o.variable||"obj")+"){\n"+a+"}",h}})};"function"==typeofdefine&&define.amd?define("epitome-template",["./epitome"],e):(t.Epitome=t.Epitome||{},t.Epitome.Template=e(t.Epitome))}(this),function(t){vare=function(t,e,n){returnnewClass({Implements:[Options,Events],element:null,collection:null,model:null,options:{template:"",events:{}},initialize:function(t){returnt&&t.collection&&(this.setCollection(t.collection),deletet.collection),t&&t.model&&(this.setModel(t.model),deletet.model),this.setOptions(t),this.options.element&&(this.setElement(this.options.element,this.options.events),deletethis.options.element),this.fireEvent("ready")},setElement:function(t,e){returnthis.element&&this.detachEvents()&&this.destroy(),this.element=document.id(t),e&&this.attachEvents(e),this},setCollection:function(t){vare=this,i=function(t){returnfunction(){e.fireEvent(t+":collection",arguments)}};returninstanceOf(t,n)&&(this.collection=t,this.collection.addEvents({change:i("change"),fetch:i("fetch"),add:i("add"),remove:i("remove"),sort:i("sort"),reset:i("reset"),error:i("error")})),this},setModel:function(t){varn=this,i=function(t){returnfunction(){n.fireEvent(t+":model",arguments)}};returninstanceOf(t,e)&&(this.model=t,this.model.addEvents({change:i("change"),destroy:i("destroy"),empty:i("empty"),error:i("error")})),this},attachEvents:function(t){vare=this;returnObject.each(t,function(t,n){e.element.addEvent(n,function(){e.fireEvent(t,arguments)})}),this.element.store("attachedEvents",t),this},detachEvents:function(){vart=this.element.retrieve("attachedEvents");returnt&&this.element.removeEvents(t).eliminate("attachedEvents"),this},template:function(e,n){n=n||this.options.template;vari=this.Template||(this.Template=newt);returni.template(n,e)},render:function(){returnthis.fireEvent("render")},empty:function(t){returnt?this.element.empty():this.element.set("html",""),this.fireEvent("empty")},dispose:function(){returnthis.element.dispose(),this.fireEvent("dispose")},destroy:function(){returnthis.element.destroy(),this.fireEvent("destroy")}})};"function"==typeofdefine&&define.amd?define("epitome-view",["./epitome-template","./epitome-model","./epitome-collection"],e):(t.Epitome=t.Epitome||{Template:{},Model:{},Collection:{}},t.Epitome.View=e(t.Epitome.Template,t.Epitome.Model,t.Epitome.Collection))}(this),function(t){vare=function(){vart,e="hashchange",n="on"+einwindow,i=[window,document],o=function(t){for(vare,n={},i=/([^&=]+)=([^&]*)/g;e=i.exec(t);)n[decodeURIComponent(e[1])]=decodeURIComponent(e[2]);returnn};returnElement.Events.hashchange={onAdd:function(){varo=location.hash,r=function(){o!=location.hash&&(o=location.hash,i.invoke("fireEvent",e,0==o.indexOf("#")?o.substr(1):o))};n&&(window.onhashchange=r)||(t=r.periodical(100))},onRemove:function(){n&&(window.onhashchange=null)||clearInterval(t)}},newClass({Implements:[Options,Events],options:{triggerOnLoad:!0},routes:{},boundEvents:{},initialize:function(t){varn=this;this.setOptions(t),this.options.routes&&(this.routes=this.options.routes),window.addEvent(e,function(){vart,e=location.hash,i=e.split("?")[0],r=e.split("?")[1]||"",s=!0;for(tinn.routes){varu=[],a=n.normalize(t,u,!0,!1),c=a.exec(i),h=!1;if(c){s=!1,n.req=c[0];varl=c.slice(1),f={};Array.each(l,function(t,e){u[e]!==void0&&(f[u[e].name]=t)}),n.route=t,n.param=f||{},n.query=r&&o(r),h=n.routes[t],n.fireEvent("before",h),h&&n.$events[h]?(n.fireEvent(h+":before"),n.fireEvent(h,Object.values(n.param))):n.fireEvent("error",["Route",h,"is undefined"].join("")),n.fireEvent("after",h),h&&n.fireEvent(h+":after");break}}s&&n.fireEvent("undefined")}),this.fireEvent("ready"),this.options.triggerOnLoad&&window.fireEvent(e)},navigate:function(t,n){location.hash==t&&n?window.fireEvent(e):location.hash=t},normalize:function(t,e,n,i){returntinstanceofRegExp?t:(t=t.concat(i?"":"/?").replace(/\/\(/g,"(?:/").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(t,n,i,o,r,s){returne.push({name:o,optional:!!s}),n=n||"",[s?"":n,"(?:",s?n:"",(i||"")+(r||i&&"([^/.]+?)"||"([^/]+?)")+")",s||""].join("")}).replace(/([\/.])/g,"\\$1").replace(/\*/g,"(.*)"),RegExp("^"+t+"$",n?"":"i"))},addRoute:function(t){returnt&&t.route&&t.id&&t.events?t.id.length?this.routes[t.route]?this.fireEvent("error",'Route "{route}" or id "{id}" already exists, aborting'.substitute(t)):(this.routes[t.route]=t.id,this.addEvents(this.boundEvents[t.route]=t.events),this.fireEvent("route:add",t)):this.fireEvent("error","Route id cannot be empty, aborting"):this.fireEvent("error","Please include route, id and events in the argument object when adding a route")},removeRoute:function(t){returnt&&this.routes[t]&&this.boundEvents[t]?(this.removeEvents(this.boundEvents[t]),deletethis.routes[t],deletethis.boundEvents[t],this.fireEvent("route:remove",t)):this.fireEvent("error","Could not find route or route is not removable")}})};"function"==typeofdefine&&define.amd?define("epitome-router",["./epitome"],e):(t.Epitome=t.Epitome||{},t.Epitome.Router=e(t.Epitome))}(this);