var ENV={platform:"classic",mode:"production"},SC=SC||{BUNDLE_INFO:{},LAZY_INSTANTIATION:{}};SC.json=JSON;
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0]};a.current=
a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown";return a}();SC.bundleDidLoad=function(a){var b=this.BUNDLE_INFO[a];b||(b=this.BUNDLE_INFO[a]={});b.loaded=true};SC.bundleIsLoaded=function(a){return(a=this.BUNDLE_INFO[a])?!!a.loaded:false};SC.loadBundle=function(){throw"SC.loadBundle(): SproutCore is not loaded.";};
SC.setupBodyClassNames=function(){var a=document.body;if(a){var b,c,d,e,f;b=SC.browser.current;c=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";e=document.documentElement.style;d=e.MozBoxShadow!==undefined||e.webkitBoxShadow!==undefined||e.oBoxShadow!==undefined||e.boxShadow!==undefined;e=e.MozBorderRadius!==undefined||e.webkitBorderRadius!==undefined||e.oBorderRadius!==undefined||e.borderRadius!==undefined;f=a.className?a.className.split(" "):[];d&&f.push("box-shadow");e&&f.push("border-rad");
f.push(b);f.push(c);SC.browser.mobileSafari&&f.push("mobile-safari");a.className=f.join(" ")}};
if("undefined"===typeof tiki)var tiki=function(){function a(f,g){b.push({m:f,a:g})}var b=[],c={},d={},e={_modules:d,_factories:c,isBootstrap:true,queue:b,register:function(f,g){if(f==="tiki"&&"undefined"!==typeof ENV)if(ENV.app==="tiki"&&ENV.mode==="test"){if(!g.depends)g.depends=[];g.depends.push("core_test")}a("register",arguments);return this},script:function(){a("script",arguments);return this},stylesheet:function(){a("stylesheet",arguments);return this},module:function(f,g){c[f]=g;a("module",
arguments);return this},require:function(f){var g,h,i;if(f.indexOf(":")<0)f="tiki:"+f;if(g=d[f])g=g.exports;else{g={};i=d[f]={id:f,exports:g,boot:this};h=c[f];if(typeof h!=="function")throw f+" is not function";f=c["tiki:index"]?e.require("tiki:index"):null;h.call(g,e.require,g,i,f);g=i.exports}return g},destroy:function(){if(this.isDestroyed)return this;this.isDestroyed=true;d=c=b=this.queue=null;return this}};e.require.loader=e;e.ENV=typeof ENV!=="undefined"?ENV:undefined;e.ARGV=typeof ARGV!=="undefined"?
ARGV:undefined;return e}();tiki.register("tiki",{scripts:[{url:"/static/tiki/en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js",id:"tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js"}]});
tiki.module("tiki:index",function(a,b){function c(u,A,E){var x=A.length;u=u||{};var n,q,y;for(E=E;E<x;E++)if(n=A[E])for(q in n)if(n.hasOwnProperty(q)){y=n[q];if(u!==y)if(y!==undefined)u[q]=y}return u}function d(){return function(){this.__init(arguments);return this}}function e(u,A,E,x,n,q){if(u[A])x&&x.isInvocation?x.invoke():v.invoke(x,n,q,2);else{A=x&&x.isInvocation?x.retain():v.create(x,n,q,2);u[E]||(u[E]=[]);u[E].push(A);u.schedule()}}function f(u,A){var E=u[A],x=E?E.length:0,n,q;for(n=0;n<x;n++){q=
E[n];q.invoke();q.release()}u[A]=null}b.T_ERROR="error";b.T_OBJECT="object";b.T_NULL="null";b.T_CLASS="class";b.T_HASH="hash";b.T_FUNCTION="function";b.T_UNDEFINED="undefined";b.T_NUMBER="number";b.T_BOOL="boolean";b.T_ARRAY="array";b.T_STRING="string";b.T_BOOLEAN="boolean";b.YES=true;b.NO=false;var g=[],h=function(u){if(u&&u.isArray)return true;if(!u)return false;if("undefined"!==typeof u.length)if(typeof u!=="function"&&typeof u!=="string"&&u.constructor!==String)return true;return false};b.isArray=
h;Array.prototype.isArray=true;b.$A=function(u){if(u===null||u===undefined)return[];if(u.slice instanceof Function)return typeof u==="string"?[u]:u.slice();if(u.toArray)return u.toArray();if(!h(u))return[u];for(var A=[],E=u.length;--E>=0;)A[E]=u[E];return A};b.typeOf=function(u){if(u===undefined)return"undefined";if(u===null)return"null";var A=typeof u;if(A=="object")A=h(u)?"array":u instanceof Function?u.isClass?"class":"function":u instanceof Error||u.isError?"error":u.isObject?"object":u.isClass?
"class":u.constructor===Object?"hash":u.constructor===Number?"number":u.constructor===String?"string":"object";else if(A==="function")A=u.isClass?"class":"function";return A};var i="_tk_guid_"+(new Date).getTime(),j=0,k=[],l=[],m=function(u){var A="tk"+j++;if(u)u[i]=A;return A};b.generateGuid=m;b.guidFor=function(u){if(u===undefined)return"(undefined)";if(u===null)return"(null)";if(u===Object)return"(Object)";if(u===Array)return"(Array)";if(u[i])return u[i];switch(typeof u){case "number":return k[u]=
k[u]||"nu"+u;case "string":return l[u]=l[u]||"st"+u;case "boolean":return u?"(true)":"(false)";default:return m(u)}};b.mixin=function(u){return c(u,arguments,1)};var o=function(){},r=o.prototype,w=function(u){var A;if("object"!==typeof u)return u;o.prototype=u;A=new o;o.prototype=r;return c(A,arguments,1)};b.beget=w;var p=function(u){var A;if(A=this.init)A.apply(this,u)};b.extend=function(u){var A=d(),E;if("function"===typeof u){E=A.prototype=w(u.prototype);if(!E.__init)E.__init=p;c(E,arguments,1)}else E=
A.prototype=c({__init:p},arguments,0);return E.constructor=A};var s=function(u,A){g[0]=A;var E;for(E in u)if(u.hasOwnProperty(E)){A=u[E];if("function"===typeof A){g[1]=E;A.displayName=g.join(".")}}g.length=0;return u};b.setupDisplayNames=s;s(b,"tiki");b.Retainable=a("retainable");b.Invocation=a("invocation");b.Promise=a("promise");var v=a("invocation"),t,z;t=function(u,A){e(t,"isReady","queue",u,A,arguments)};b.ready=t;t.main=function(u,A){e(t,"isReady","mqueue",u,A,arguments)};t.isReady=false;t.fire=
function(){if(!t.isReady){t.isReady=true;if(a.loader)a.loader.isReady=true;t.cleanup&&t.cleanup();t.cleanup=null;f(t,"queue");f(t,"mqueue");var u=a.loader?a.loader.nextReady:null;u&&u!==t&&u.fire()}};t.fire.displayName="ready.fire()";t.schedule=function(){};if("undefined"!==typeof document)if(document.addEventListener){t.cleanup=function(){document.removeEventListener("DOMContentLoaded",t.fire,false);document.removeEventListener("load",t.fire,false)};document.addEventListener("DOMContentLoaded",t.fire,
false);document.addEventListener("load",t.fire,false)}else if(document.attachEvent){t.cleanup=function(){document.detachEvent("onreadystatechange",t.fire);document.detachEvent("onload",t.fire);t.ieHandler=null};document.attachEvent("onreadystatechange",t.fire);document.attachEvent("onload",t.fire);if(document.documentElement.doScroll&&window==window.top){t.ieHandler=function(){if(t.ieHandler&&!t.isReady)try{document.documentElement.doScroll("left")}catch(u){setTimeout(t.ieHandler,0);return}t.fire()};
t.ieHandler()}}if(a.loader&&a.loader.previousLoader){if(a.loader.previousLoader.isReady)t.fire();else a.loader.previousLoader.nextReady=t;a.loader.previousLoder=null}z=function(u,A){e(z,"isUnloading","queue",u,A,arguments)};b.unload=z;z.isUnloading=false;z.fire=function(){if(!z.isUnloading){z.isUnloading=true;z.cleanup&&z.cleanup();z.cleanup=null;var u=z.queue,A=u?u.length:0,E,x;for(E=0;E<A;E++){x=u[E];x.invoke();x.release()}z.queue=null}};z.schedule=function(){if(!z.isScheduled){z.isScheduled=true;
if("undefined"!==typeof document)if(document.addEventListener){z.cleanup=function(){document.removeEventListener("unload",z.fire)};document.addEventListener("unload",z.fire,false)}else if(document.attachEvent){z.cleanup=function(){document.detachEvent("onunload",z.fire)};document.attachEvent("unload",z.fire)}}}});
tiki.module("tiki:invocation",function(a,b,c,d){a=a("retainable");var e,f=Array.prototype.slice,g=[];e=d.extend(a,{init:function(h,i,j,k){if(j&&k!==undefined)j=j.length>k?f.call(j,k):null;this.recycled++;this.inPool=this.isDestroyed=false;this.target=h;this.method=i;this.args=j;return this},destroy:function(){this.isDestroyed=true;this.retainCount=1;this.inPool=true;this.target=this.method=this.args=null;g.push(this);return this},invoke:function(){return e.invoke(this.target,this.method,this.args,
undefined,arguments)},isInvocation:true,recycled:0});e.create=function(h,i,j,k){return g.length>0?g.pop().init(h,i,j,k):new e(h,i,j,k)};e.invoke=function(h,i,j,k,l){if(!i&&d.typeOf(h)===d.T_FUNCTION)i=h;if(d.typeOf(i)===d.T_STRING)i=h[i];if(!i)throw"Invocation: method "+this.method+" not defined";if(k!==undefined&&j)j=j.length>k?f.call(j,k):null;if(l&&l.length>0)j=j?j.concat(l):l;return j?i.apply(h,j):i.call(h)};b=c.exports=e;b.Invocation=e});
tiki.module("tiki:loader",function(a,b,c,d){function e(p,s){m[0]=p;m[1]=s;return m.join("::")}function f(p){var s=r[p];if(s)return s;return r[p]="tiki/"+p}function g(p,s){var v=w[p],t;v||(v=w[p]={});(t=v[s])||(t=v[s]=p+":"+s);return t}var h=a("promise"),i=a("sandbox"),j,k=["(function(require, exports, module, tiki) {",null,"\n});\n//@ sourceURL=",null,"\n"],l={},m=[],o=Object.keys;o||(o=function(p){var s,v=[];for(s in p)p.hasOwnProperty(s)&&v.push(s);return v});var r={},w={};j=function(p,s,v){this.id=
p;this.scripts=[];this.packages=[];this.stylesheets=[];this.modules=[];this.ENV=v;this.sandbox=i.create(p,this);this.register("default",{});this.register("tiki",{});p=s?s.length:0;var t;for(v=0;v<p;v++){t=s[v];this[t.m].apply(this,t.a)}return this};j.prototype={scripts:null,stylesheets:null,packages:null,sandbox:null,modules:null,logLoadFailures:true,destroy:function(){},resolve:function(p,s,v){var t,z,u,A;if(p.match(/(^\.\.?\/)|(\/\.\.?\/)|(\/\.\.?\/?$)/)){if((z=p.indexOf(":"))>=0){v=p.slice(0,z);
p=p.slice(z+1);s=[]}else if(p.match(/^\.\.?\//)){if(!s)throw"base required to resolve relative: "+p;z=s.indexOf(":");v||(v=s.slice(0,z));if(z>=0)s=s.slice(z+1);s=s.split("/");s.pop()}else s=[];A=p.split("/");t=A.length;for(z=0;z<t;z++){u=A[z];if(u===".."){if(s.length<1)throw"invalid path: "+p;s.pop()}else u!=="."&&s.push(u)}p=s.join("/");if(v)p=g(v,p)}return p},canonical:function(p,s,v){var t=this.resolve(p,s,v),z=this._factories,u=this._catalog;if((p=t.indexOf(":"))<0){if(!v&&s&&(p=s.indexOf(":")))v=
s.slice(0,p);if(v==="default")v="tiki";p=g(v,t);t=!u||z&&z[p]?p:u[t]?g(t,"index"):u[f(t)]?g(f(t),"index"):p}else{v=t.slice(0,p);if(v==="default")t=g("tiki",t.slice(p+1));else if(u&&!u[v]&&u[f(v)])t=f(t)}return t},evaluate:function(p,s){k[1]=p;k[3]=s||"(unknown module)";p=k.join("");p=eval(p);k[1]=k[3]=null;return p},load:function(p,s){var v=this._factories;p=this.canonical(p,s);if(!this.ready(p))throw p+" is not ready";if((s=v[p])&&"string"===typeof s){s=this.evaluate(s,p);v[p]=s}if(!s.displayName)s.displayName=
p;return s},global:function(p){var s,v,t,z,u,A;p=this.canonical(p);if((t=p.indexOf(":"))<0)throw"package not found: "+p;u=p.slice(0,t);p.split(":");s=this._catalog[u];if(!s)throw u+" is not registered";v=(s=s.depends)?s.length:0;if(v<=0)return this;z=this._factories;if(!z)return this;for(t=0;t<v;t++){u=s[t];if(!l[u]){l[u]=true;if(!this.ready(u))throw"cannot make "+u+" global because it is not ready";p=this.canonical(u);if(z[p]){u=this.require(p);if(!u)throw"require "+p+" failed";if(p=u.__globals__){v=
p.length;for(t=0;t<v;t++){A=p[t];window[A]=u[A]}}else for(A in u)if(u.hasOwnProperty(A))window[A]=u[A]}}}},register:function(p,s){if(p.indexOf(":")>0)return this.module(p,s);var v=this._catalog,t;if(!v)v=this._catalog={};if(s=(v[p]=s)?s.packages:null)for(t in s)!s.hasOwnProperty(t)||v[t]||(v[t]=s[t]);this._resolved("catalog",p)||this.packages.push(p);this._promiseFor("catalog",p).resolve(p)},script:function(p){this._resolved("scripts",p)||this.scripts.push(p);this._promiseFor("scripts",p).resolve(p);
return this},stylesheet:function(p){this._resolved("stylesheets",p)||this.stylesheets.push(p);this._promiseFor("stylesheets",p).resolve(p);return this},module:function(p,s){var v=this._factories;if(!v)v=this._factories={};v[p]=s;this._resolved("modules",p)||this.modules.push(p);this._promiseFor("modules",p).resolve(p)},async:function(p){return this._async(p,null)},_async:function(p,s){var v=this._promiseFor("loads",p);if(v.isPending)if(this.ready(p))v.resolve();else{var t=this;v.action(function(z){t._promiseFor("catalog",
p).then(z,function(){t._loadPackage(p,z,s||{});z.resolve()},function(u){z.cancel(u)});t._loadPackage(p,z,s||{})}).run()}return v},require:function(p,s){return this.sandbox.require(p,s)},ready:function(p){return this._ready(p,null)},_ready:function(p,s){if(s)if(s[p])return true;else s[p]=true;var v,t,z,u,A;v=p.indexOf(":");v=v>=0?p.slice(0,v):p;if(!this._resolved("catalog",v))return false;t=this._catalog[v];for(u=(z=t.depends)?z.length:0;--u>=0;){s||(s={});A=z[u];if(!this._ready(A,s)){this.logLoadFailures&&
console.log("Can't load ",p," - Dependency is not loaded: ",A);return false}}for(u=(z=t.stylesheets)?z.length:0;--u>=0;){s=z[u];if("string"!==typeof s)s=s.id;if(!this._resolved("stylesheets",s)){this.logLoadFailures&&console.log("Can't load ",p," - Stylesheet is not loaded: ",s);return false}}for(u=(z=t.scripts)?z.length:0;--u>=0;){s=z[u];if("string"!==typeof s)s=s.id;if(!this._resolved("scripts",s)){this.logLoadFailures&&console.log("Can't load ",p," - Script is not loaded: ",s);return false}}if(p!==
v)if(!this._resolved("modules",p)){this.logLoadFailures&&console.log("Can't load ",p," - Module is not loaded: ",p);return false}return true},main:function(p,s){var v=this.require("index","tiki").ready;if(!v)throw"cannot register main because system.ready does not exist";v.main(this,function(){this.async(p).then(this,function(){this.require(p)[s]()})});return this},_loadScript:function(p){var s,v;if("string"!==typeof p){s=p.id;v=p.url}else s=v=p;p=this._promiseFor("scripts",s);p.isPending&&p.action(function(){var t=
document.body,z;t||promise.cancel("no document to append script");z=document.createElement("script");z.setAttribute("src",v);t.appendChild(z)});return p},_loadStylesheet:function(p){var s,v;if("string"!==typeof p){s=p.id;v=p.url}else s=v=p;p=this._promiseFor("stylesheets",s);if(p.isPending){var t=this;p.action(function(z){var u=document.body;u||z.cancel("no document to append stylesheet");z=document.createElement("link");z.setAttribute("rel","stylesheet");z.setAttribute("href",v);u.appendChild(z);
t.stylesheet(s)})}return p},_loadPackage:function(p,s,v){if(v)if(v[p]){console.warn("detected cyclical reference to "+p+" seen="+o(v).join(", "));return}else v[p]=true;var t=this._catalog?this._catalog[p]:null,z,u,A,E;if(!t)return this;u=(z=t.depends)?z.length:0;for(E=h.create(e("load-package",p));--u>=0;){p=z[u];p!=="tiki"&&E.depends(this._async(p,v))}s.depends(E);E.resolve();u=(z=t.scripts)?z.length:0;A=null;for(v=t.ordered!==false;--u>=0;){p=this._loadScript(z[u]);s.depends(p);if(v)A&&p.then(A,
A.run,A.cancel);else p.run();A=p}A&&v&&E.then(A,A.run,A.cancel);u=(z=t.stylesheets)?z.length:0;for(A=null;--u>=0;){p=this._loadStylesheet(z[u]);s.depends(p);A&&p.then(A,A.run,A.cancel);A=p}A&&E.then(A,A.run,A.cancel)},_promiseFor:function(p,s,v){var t=this._promises,z;if(!t)t=this._promises={};(z=t[p])||(z=t[p]={});if(v===undefined){t=z;v=s}else(t=z[s])||(t=z[s]={});(z=t[v])||(z=t[v]=h.create(e(p,s)));return z},_discoveredStylesheets:false,discoverStylesheets:function(){this._discoveredStylesheets=
true;if("undefined"===typeof document)return this;for(var p=document.getElementsByTagName("link"),s=p?p.length:0,v,t;--s>=0;){v=p[s];if(!(!v||v.rel!=="stylesheet")){(t=v.getAttribute("loadid")||v.getAttribute("LOADID"))&&this.stylesheet(t.toString());(t=v.href)&&this.stylesheet(t.toString())}}return this},_resolved:function(p,s,v){p==="stylesheets"&&!this._discoveredStylesheets&&this.discoverStylesheets();var t=this._promises;if(t)t=t[p];if(t)t=t[s];if(t&&v)t=t[v];return t?t.isResolved:false},_inspectLoader:function(){var p=
[],s,v;p.push("Loader<id="+this.id+">:");if(this.packages.length>0){p.push("  packages: "+this.packages.join(","));p.push("")}if(this.scripts.length>0){p.push("  scripts:");s=this.scripts.length;for(v=0;v<s;v++)p.push("    "+this.scripts[v]);p.push("")}if(this.stylesheets.length>0){p.push("  stylesheets:");s=this.scripts.length;for(v=0;v<s;v++)p.push("    "+this.scripts[v]);p.push("")}if(this.modules.length>0){p.push("  modules: ");s=this.modules.length;for(v=0;v<s;v++)p.push("    "+this.modules[v]);
p.push("")}return p.join("\n")},_inspectModule:function(p){var s=[],v=p.slice(0,p.indexOf(":")),t;if(this._catalog&&!this._catalog[v]){t="tiki/"+v;if(this._catalog[t]){v=t;p="tiki/"+p}}s.push(p+" ("+(this.ready(p)?"READY":"NOT READY")+"):");s.push(this._inspectPackage(v));return s.join("\n")},_inspectPackage:function(p){if(this._catalog&&!this._catalog[p]){var s="tiki/"+p;if(this._catalog[s])p=s}s=[];var v=this._catalog?this._catalog[p]:null,t,z,u;s.push(p+" ("+(this.ready(p)?"READY":"NOT READY")+
"): "+(v?"":"Not in Catalog!"));if(!v)return s.join("\n");t=v.depends?v.depends.length:0;if(t>0){u=[];for(p=0;p<t;p++){z=v.depends[p];u.push(z+" ("+(this.ready(z)?"READY":"NOT READY")+")")}s.push("  depends: "+u.join(", "))}t=v.scripts?v.scripts.length:0;if(t>0){s.push("\n  scripts:");for(p=0;p<t;p++){z=v.scripts[p];if("string"!==typeof z)z=z.id;s.push("    "+z+" ("+(this._resolved("scripts",z)?"READY":"NOT READY")+")")}}t=v.stylesheets?v.stylesheets.length:0;if(t>0){s.push("\n  stylesheets:");for(p=
0;p<t;p++){z=v.stylesheets[p];if("string"!==typeof z)z=z.id;s.push("    "+z+"("+(this._resolved("stylesheets",z)?"READY":"NOT READY")+")")}}return s.join("\n")},inspect:function(p){return arguments.length===0?this._inspectLoader():p.indexOf(":")<0?this._inspectPackage(p):this._inspectModule(p)},toString:function(){return"Loader<id="+this.id+">"}};d.setupDisplayNames(j.prototype,"Loader");j.setup=function(p,s){if(p&&!p.isBootstrap)return p;s=new j(p?p.id:"default",p?p.queue:null,s);(s.previousLoader=
p)&&p.destroy&&p.destroy();return s};b=c.exports=j;b.Loader=j;b.setup=j.setup});
tiki.module("tiki:promise",function(a,b,c,d){function e(i,j,k){i=d.guidFor(i)+":"+i.id+"."+j+"() dep="+i.holds+" status="+h[i._status]+" handlers="+(i._handlers?i._handlers.length:"null");if(k)i+=" pr="+k.toString();console.log(i)}b=a("retainable");a("invocation");var f,g=[],h={4097:"PENDING",12289:"BLOCKED_PENDING",12290:"BLOCKED_RESOLVED",16386:"RESOLVED",16388:"CANCELLED"};f=d.extend(b,{init:function(i){this.inPool=false;this.id=i;this._status=4097;this._actionStatus=257;this.holds=0;this.retain();
return this},destroy:function(){this.isDestroyed=false;this.retainCount=1;this.inPool=true;this.target=this.method=this._actions=null;g.push(this);return this},value:null,isPending:true,isResolved:false,isCancelled:false,hasAction:false,_status:4097,_actionStatus:257,resolve:function(i){f.LOG_PROMISES&&e(this,"resolve");switch(this._status){case 4097:this.value=i;this._makeResolved();break;case 12289:this.value=i;this._status=12290;break}return this},_makeResolved:function(){this.isPending=false;
this.isResolved=true;this._status=16386;this._didResolve();this._invoke("__resolved",this.value,true);this.release()},cancel:function(i){f.LOG_PROMISES&&e(this,"cancel");switch(this._status){case 4097:case 12289:this.value=i;this._makeCancelled()}return this},_makeCancelled:function(){this._status=16388;this.isPending=false;this.isCancelled=true;this._didCancel();this._invoke("__cancel",this.value,true);this.release()},update:function(i){f.LOG_PROMISES&&e(this,"update");switch(this._status){case 4097:case 12289:this._invoke("__progress",
i,false);break}return this},then:function(i,j,k,l){var m=typeof i,o=this.values;if(arguments.length<4&&("function"===m||"string"===m)){l=k;k=j;j=i;i=this}m=f.create();switch(this._status){case 16386:if(j)o=j.call(i,this.value,this);m.resolve(o);break;case 16388:if(k)o=k.call(i,this.value,this);m.cancel(o);break;default:m.__resolved=j;m.__cancel=k;m.__progress=l;m.__target=i;if(!this._handlers)this._handlers=[];this._handlers.push(m)}return m},_invoke:function(i,j,k){var l=this._handlers,m=l?l.length:
0,o,r,w;if(m<=0)return this;for(o=0;o<m;o++){r=l[o];w=(w=r[i])?w.call(r.__target,j,this):null;if(k){i==="__cancel"?r.cancel(w):r.resolve(w);r.__resolve=r.__cancel=r.__progress=r.__target=null}}if(k)this._handlers=null},depends:function(i){f.LOG_PROMISES&&e(this,"depends",i);switch(this._status){case 4097:this._status=12289;this.holds=1;if(!this._depends)this._depends={};this._depends[d.guidFor(i)]=i;i.then(this,this._resolveHold,this._cancelHold);break;case 12289:case 12290:this.holds++;this._depends[d.guidFor(i)]=
i;i.then(this,this._resolveHold,this._cancelHold);break}return this},_resolveHold:function(i,j){f.LOG_PROMISES&&e(this,"resolveHold",j);this._depends&&delete this._depends[d.guidFor(j)];switch(this._status){case 12289:if(this.holds<=1){this._status=4097;this.holds=null}else this.holds--;break;case 12290:if(this.holds<=1){this.holds=null;this._makeResolved()}else this.holds--;break}},_cancelHold:function(i,j){f.LOG_PROMISES&&e(this,"cancelHold",j);this._depends&&delete this._depends[d.guidFor(j)];
if(this._status&12288){this.holds=null;this.value=new Error("hold cancelled");this._makeCancelled()}},action:function(i,j){if(this._actionStatus===257){if(arguments.length===1){j=i;i=this}this.hasAction=true;this.actionTarget=i;this.actionMethod=j;this._actionStatus=258}return this},run:function(){if(this._actionStatus===258){this._actionStatus=512;this.actionMethod.call(this.actionTarget,this);this._actionStatus=768}return this},_didResolve:function(){this._actionStatus=768},_didCancel:function(){this._actionStatus=
768},toString:function(){return"Promise<guid="+d.guidFor(this)+" id="+this.id+" status="+h[this._status]+">"}});f.create=function(i){return g.length>0?g.pop().init(i):new f(i)};f.create.displayName="Promise.create";f.LOG_PROMISES=false;d.setupDisplayNames(f.prototype,"Promise");b=c.exports=f;b.Promise=f});
tiki.module("tiki:retainable",function(a,b,c){a={retainCount:1,isDestroyed:false,retain:function(){this.retainCount++;return this},release:function(){--this.retainCount<=0&&this.__destroy();return this},__destroy:function(){if(!this.isDestroyed){this.isDestroyed=true;this.destroy&&this.destroy()}}};b=c.exports=a;b.Retainable=a});
tiki.module("tiki:sandbox",function(a,b,c){var d;d=function(e,f){function g(){var l=arguments.length,m;if(l>0)for(;--l>=0;){if((m=arguments[l])&&i[m]){delete i[m];delete j[m];k.splice(k.indexOf(m),1)}}else{i={};j={};k.length=0}}function h(l,m,o){var r,w,p;if(m){r=l.indexOf(":");if(r>=0)l=l.slice(0,r);l=m+":"+l}l=f.canonical(l,o);if(o=i[l]){o=o.exports;j[l]||(j[l]=o);return o||{}}k.push(l);m={};i[l]=r={id:l,exports:m};o=function(s,v){return h(s,v,l)};o.displayName="Sandbox.require";o.loader=f;o.clear=
g;o.sandbox=this;w=f.load(l);p=h("tiki:index");if(!w)throw"could not load function for "+l;w.call(m,o,m,r,p);m=r.exports;if((o=j[l])&&o!==m)throw"circular require in "+l;return j[l]=m}var i={},j={},k=[];this.id=e;this.modules=k;this.loader=f;g.displayName="Sandbox.clear";this.clear=g;this.require=function(l,m){return h(l,m)};this.require.displayName="Sandbox.require"};d.create=function(e,f){return new d(e,f)};d.create.displayName="Sandbox.create";d.prototype={};b=c.exports=d;b.Sandbox=d});
tiki.module("tiki:system",function(a,b,c,d){if(a.loader){b.env=a.loader.ENV;b.args=a.loader.ARGV}a=function(e){d.console.log(e)};b.print=a;c=function(){return null};b.stdin={read:c,readLine:c};b.stdout=b.stderr={write:a,writeLine:a,print:a};b.platform="tiki";b.global=window;d.unload(function(){b.global={}})});
tiki.module("tiki:timer",function(a,b){function c(h){if(h){delete f[h.timerKey];delete h.timerKey;h.release()}}function d(h,i){return function(){h.invoke();i&&c(h)}}var e=a("invocation"),f={},g={};b.setTimeout=function(h,i,j){var k,l;if(arguments.length>2){l=e.create(j,h,arguments,3);h=d(l,true)}k=setTimeout(h,i);if(l){l.timerKey=k;f[k]=l}return k};b.clearTimeout=function(h){c(f[h]);clearTimeout(h)};b.setInterval=function(h,i,j){var k,l;if(arguments.length>2){l=e.create(j,h,arguments,3);h=d(l,false)}k=
setInterval(h,i);if(l)g[k]=l;return k};b.clearInterval=function(h){var i=g[h];if(i){i.release();delete g[h]}clearInterval(h)}});tiki=tiki.require("tiki:loader").setup(tiki,"undefined"===typeof ENV?null:ENV,"undefined"===typeof ARGV?null:ARGV);tiki.script("tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js");tiki.stylesheet("sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css");tiki.stylesheet("sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css");
tiki.stylesheet("sproutcore/standard_theme:en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/stylesheet.css");tiki.stylesheet("sproutcore/designer:en/c31f4a999b308340c034ef4ae90087615be810b2/stylesheet.css");tiki.stylesheet("sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css");
tiki.register("sproutcore/runtime",{packages:{tiki:{scripts:[{url:"/static/tiki/en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js",id:"tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js"}]}},depends:["tiki"],scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]});
tiki.module("sproutcore/runtime:core",function(a,b,c){var d=a("system","default"),e,f;if(d.platform==="tiki"){if("undefined"===typeof console)console=d.console;if("undefined"===typeof sc_require)sc_require=function(){};if("undefined"===typeof sc_resource)sc_resource=function(){}}e=window.SC==undefined?(f={}):window.SC;e.global=function(g,h){d.global[g]=h;return e};e.global.remove=function(g){delete d.global[g];return e};e.global("SC",e);e.mixin=function(){var g=arguments[0]||{},h=1,i=arguments.length,
j,k,l;if(i===1){g=this||{};h=0}for(;h<i;h++)if(j=arguments[h])for(l in j)if(j.hasOwnProperty(l)){k=j[l];if(g!==k)if(k!==undefined)g[l]=k}return g};e.supplement=function(){var g=arguments[0]||{},h=1,i=arguments.length,j;if(i===1){g=this||{};h=0}for(;h<i;h++)if(j=arguments[h])for(var k in j)if(j.hasOwnProperty(k)){var l=g[k],m=j[k];if(g!==m)if(m!==undefined&&l===undefined)g[k]=m}return g};e.extend=e.mixin;e.mixin({T_ERROR:"error",T_OBJECT:"object",T_NULL:"null",T_CLASS:"class",T_HASH:"hash",T_FUNCTION:"function",
T_UNDEFINED:"undefined",T_NUMBER:"number",T_BOOL:"boolean",T_ARRAY:"array",T_STRING:"string",typeOf:function(g){if(g===undefined)return e.T_UNDEFINED;if(g===null)return e.T_NULL;var h=typeof g;if(h=="object")h=g instanceof Array?e.T_ARRAY:g instanceof Function?g.isClass?e.T_CLASS:e.T_FUNCTION:e.Error&&g instanceof e.Error?e.T_ERROR:g.isObject===true?e.T_OBJECT:e.T_HASH;else if(h===e.T_FUNCTION)h=g.isClass?e.T_CLASS:e.T_FUNCTION;return h},none:function(g){return g===null||g===undefined},empty:function(g){return g===
null||g===undefined||g===""},isArray:function(g){if(g&&g.objectAt)return true;var h=g?g.length:null,i=e.typeOf(g);return!(e.none(h)||i===e.T_FUNCTION||i===e.T_STRING||g.setInterval)},makeArray:function(g){return e.isArray(g)?g:e.A(g)},A:function(g){if(e.none(g))return[];if(g.slice instanceof Function)return typeof g==="string"?[g]:g.slice();if(g.toArray)return g.toArray();if(!e.isArray(g))return[g];for(var h=[],i=g.length;--i>=0;)h[i]=g[i];return h},guidKey:"_sc_guid_"+(new Date).getTime(),_nextGUID:0,
_numberGuids:[],_stringGuids:{},_keyCache:{},guidFor:function(g){if(g===undefined)return"(undefined)";if(g===null)return"(null)";if(g===Object)return"(Object)";if(g===Array)return"(Array)";var h=this.guidKey;if(g[h])return g[h];switch(typeof g){case e.T_NUMBER:return this._numberGuids[g]=this._numberGuids[g]||"nu"+g;case e.T_STRING:return this._stringGuids[g]=this._stringGuids[g]||"st"+g;case e.T_BOOL:return g?"(true)":"(false)";default:return e.generateGuid(g)}},keyFor:function(g,h){var i,j=this._keyCache[g];
j||(j=this._keyCache[g]={});(i=j[h])||(i=j[h]=g+"_"+h);return i},generateGuid:function(g){var h="sc"+this._nextGUID++;if(g)g[this.guidKey]=h;return h},hashFor:function(g){return g&&g.hash&&typeof g.hash===e.T_FUNCTION?g.hash():this.guidFor(g)},isEqual:function(g,h){return g===null?h===null:g===undefined?h===undefined:this.hashFor(g)===this.hashFor(h)},compare:function(g,h){if(g===h)return 0;var i=e.typeOf(g),j=e.typeOf(h),k=e.ORDER_DEFINITION_MAPPING;if(!k){var l=e.ORDER_DEFINITION;k=e.ORDER_DEFINITION_MAPPING=
{};var m,o;m=0;for(o=l.length;m<o;++m)k[l[m]]=m;delete e.ORDER_DEFINITION}l=k[i];j=k[j];if(l<j)return-1;if(l>j)return 1;switch(i){case e.T_BOOL:case e.T_NUMBER:if(g<h)return-1;if(g>h)return 1;return 0;case e.T_STRING:i=g.localeCompare(h);if(i<0)return-1;if(i>0)return 1;return 0;case e.T_ARRAY:i=g.length;j=h.length;k=Math.min(i,j);m=l=0;for(o=arguments.callee;l===0&&m<k;){l=o(g[m],h[m]);m++}if(l!==0)return l;if(i<j)return-1;if(i>j)return 1;return 0;case e.T_OBJECT:if(g.constructor.isComparable===true)return g.constructor.compare(g,
h);return 0;default:return 0}},K:function(){return this},EMPTY_ARRAY:[],EMPTY_HASH:{},EMPTY_RANGE:{start:0,length:0},beget:function(g){if(e.none(g))return null;var h=e.K;h.prototype=g;var i=new h;h.prototype=null;if(e.typeOf(g.didBeget)===e.T_FUNCTION)i=g.didBeget(i);return i},copy:function(g){var h=g;if(g&&g.isCopyable)return g.copy();switch(e.typeOf(g)){case e.T_ARRAY:h=g.clone&&e.typeOf(g.clone)===e.T_FUNCTION?g.clone():g.slice();break;case e.T_HASH:case e.T_OBJECT:if(g.clone&&e.typeOf(g.clone)===
e.T_FUNCTION)h=g.clone();else{h={};for(var i in g)h[i]=g[i]}}return h},merge:function(){var g={},h=arguments.length,i;for(i=0;i<h;i++)e.mixin(g,arguments[i]);return g},keys:function(g){var h=[];for(var i in g)h.push(i);return h},inspect:function(g){var h,i=[];for(var j in g){h=g[j];if(h!=="toString"){if(e.typeOf(h)===e.T_FUNCTION)h="function() { ... }";i.push(j+": "+h)}}return"{"+i.join(" , ")+"}"},tupleForPropertyPath:function(g,h){if(e.typeOf(g)===e.T_ARRAY)return g;var i,j=g.indexOf("*");if(j<
0)j=g.lastIndexOf(".");i=j>=0?g.slice(j+1):g;return(g=this.objectForPropertyPath(g,h,j))&&i?[g,i]:null},objectForPropertyPath:function(g,h,i){var j,k,l;if(!h)h=d.global;if(e.typeOf(g)===e.T_STRING){if(i===undefined)i=g.length;for(j=0;h&&j<i;){k=g.indexOf(".",j);if(k<0||k>i)k=i;l=g.slice(j,k);h=h.get?h.get(l):h[l];j=k+1}if(j<i)h=undefined}else{j=0;for(i=g.length;j<i&&h;)if(l=g[j++])h=h.get?h.get(l):h[l];if(j<i)h=undefined}return h},STRINGS:{},stringsFor:function(g,h){e.mixin(e.STRINGS,h);return this}});
e.clone=e.copy;e.$A=e.A;e.didLoad=e.K;e.ORDER_DEFINITION=[e.T_ERROR,e.T_UNDEFINED,e.T_NULL,e.T_BOOL,e.T_NUMBER,e.T_STRING,e.T_ARRAY,e.T_HASH,e.T_OBJECT,e.T_FUNCTION,e.T_CLASS];e.mixin(Function.prototype,{property:function(){this.dependentKeys=e.$A(arguments);var g=e.guidFor(this);this.cacheKey="__cache__"+g;this.lastSetValueKey="__lastValue__"+g;this.isProperty=true;return this},cacheable:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isCacheable=g===undefined?
true:g;return this},idempotent:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isVolatile=g===undefined?true:g;return this},observes:function(){for(var g=arguments.length,h=null,i=null;--g>=0;){var j=arguments[g];if(j.indexOf(".")<0&&j.indexOf("*")<0){if(!h)h=this.localPropertyPaths=[];h.push(j)}else{if(!i)i=this.propertyPaths=[];i.push(j)}}return this}});String.prototype.fmt=function(){var g=arguments,h=0;return this.replace(/%@([0-9]+)?/g,function(i,j){j=j?parseInt(j,
0)-1:h++;i=g[j];return(i===null?"(null)":i===undefined?"":i).toString()})};String.prototype.loc=function(){var g=e.STRINGS[this]||this;return g.fmt.apply(g,arguments)};String.prototype.w=function(){var g=[],h=this.split(" "),i=h.length,j,k=0;for(k=0;k<i;++k){j=h[k];j.length!==0&&g.push(j)}return g};c.exports=e;e.SC=e;e.SproutCore=f;e.YES=true;e.NO=false});
tiki.module("sproutcore/runtime:index",function(a,b,c){b=c.exports=a("core");a("mixins/array");a("mixins/comparable");a("mixins/copyable");a("mixins/delegate_support");a("mixins/enumerable");a("mixins/freezable");a("mixins/observable");a("system/binding");a("system/cookie");a("system/enumerator");a("system/error");a("system/index_set");a("system/logger");a("system/object");a("system/range_observer");a("system/run_loop");a("system/selection_set");a("system/set");a("system/sparse_array");b.__globals__=
["SC","SproutCore","YES","NO"]});
tiki.module("sproutcore/runtime:mixins/array",function(a){var b=a("core");a("mixins/observable");a("mixins/enumerable");a("system/range_observer");b.OUT_OF_RANGE_EXCEPTION="Index out of range";b.Array={isSCArray:true,replace:function(){throw"replace() must be implemented to support SC.Array";},objectAt:function(c){if(!(c<0))if(!(c>=this.get("length")))return this.get(c)},"[]":function(c,d){d!==undefined&&this.replace(0,this.get("length"),d);return this}.property(),insertAt:function(c,d){if(c>this.get("length"))throw b.OUT_OF_RANGE_EXCEPTION;
this.replace(c,0,[d]);return this},removeAt:function(c,d){var e=0,f=[];if(typeof c===b.T_NUMBER){if(c<0||c>=this.get("length"))throw b.OUT_OF_RANGE_EXCEPTION;if(d===undefined){this.replace(c,1,f);return this}else c=b.IndexSet.create(c,d)}this.beginPropertyChanges();c.forEachRange(function(g,h){g-=e;e+=h;this.replace(g,h,f)},this);this.endPropertyChanges();return this},removeObject:function(c){for(var d=this.get("length")||0;--d>=0;)this.objectAt(d)==c&&this.removeAt(d);return this},removeObjects:function(c){this.beginPropertyChanges();
c.forEach(function(d){this.removeObject(d)},this);this.endPropertyChanges();return this},pushObject:function(c){this.insertAt(this.get("length"),c);return c},pushObjects:function(c){this.beginPropertyChanges();c.forEach(function(d){this.pushObject(d)},this);this.endPropertyChanges();return this},popObject:function(){var c=this.get("length");if(c!==0){var d=this.objectAt(c-1);this.removeAt(c-1);return d}},shiftObject:function(){if(this.get("length")!==0){var c=this.objectAt(0);this.removeAt(0);return c}},
unshiftObject:function(c){this.insertAt(0,c);return c},unshiftObjects:function(c){this.beginPropertyChanges();c.forEach(function(d){this.unshiftObject(d)},this);this.endPropertyChanges();return this},isEqual:function(c){if(!c)return false;if(c==this)return true;var d=c.get("length");if(d!=this.get("length"))return false;for(;--d>=0;)if(!b.isEqual(c.objectAt(d),this.objectAt(d)))return false;return true},compact:function(){return this.without(null)},without:function(c){if(this.indexOf(c)<0)return this;
var d=[];this.forEach(function(e){if(e!==c)d[d.length]=e});return d},uniq:function(){var c=[];this.forEach(function(d){if(c.indexOf(d)<0)c[c.length]=d});return c},rangeObserverClass:b.RangeObserver,addRangeObserver:function(c,d,e,f){var g=this._array_rangeObservers;if(!g)g=this._array_rangeObservers=b.CoreSet.create();if(this._array_oldLength===undefined)this._array_oldLength=this.get("length");c=this.rangeObserverClass.create(this,c,d,e,f,false);g.add(c);if(!this._array_isNotifyingRangeObservers){this._array_isNotifyingRangeObservers=
true;this.addObserver("[]",this,this._array_notifyRangeObservers)}return c},updateRangeObserver:function(c,d){return c.update(this,d)},removeRangeObserver:function(c){var d=c.destroy(this),e=this._array_rangeObservers;e&&e.remove(c);return d},enumerableContentDidChange:function(c,d,e){var f=this._array_rangeObservers,g=this._array_oldLength;this.beginPropertyChanges();this.notifyPropertyChange("length");if(f&&f.length>0){if(g===undefined)g=0;this._array_oldLength=f=this.get("length");if(c===undefined)c=
0;if(e===undefined)e=f-g;if(e!==0||d===undefined){d=f-c;if(e<0)d-=e}else d=d;e=this._array_rangeChanges;if(!e)e=this._array_rangeChanges=b.IndexSet.create();e.add(c,d)}this.notifyPropertyChange("[]");this.endPropertyChanges();return this},_array_notifyRangeObservers:function(){var c=this._array_rangeObservers,d=this._array_rangeChanges,e=c?c.length:0,f;if(e>0&&d&&d.length>0){for(f=0;f<e;f++)c[f].rangeDidChange(d);d.clear()}}};b.mixin(Array.prototype,b.Array);b.Array=b.mixin({},b.Enumerable,b.Array);
b.Array.slice=function(c,d){var e=[],f=this.get("length");if(b.none(c))c=0;if(b.none(d)||d>f)d=f;for(;c<d;)e[e.length]=this.objectAt(c++);return e};b.Array.indexOf=function(c,d){var e=this.get("length");d=d===undefined?0:d<0?Math.ceil(d):Math.floor(d);if(d<0)d+=e;for(d=d;d<e;d++)if(this.objectAt(d)===c)return d;return-1};if(!Array.prototype.indexOf)Array.prototype.indexOf=b.Array.indexOf;b.Array.lastIndexOf=function(c,d){var e=this.get("length");d=d===undefined?e-1:d<0?Math.ceil(d):Math.floor(d);
if(d<0)d+=e;for(d=d;d>=0;d--)if(this.objectAt(d)===c)return d;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=b.Array.lastIndexOf;(function(){b.mixin(Array.prototype,{replace:function(d,e,f){if(this.isFrozen)throw b.FROZEN_ERROR;!f||f.length===0?this.splice(d,e):this.splice.apply(this,[d,e].concat(f));f=f?f.get?f.get("length"):f.length:0;this.enumerableContentDidChange(d,e,f-e);return this},unknownProperty:function(d,e){var f=this.reducedProperty(d,e);if(e!==undefined&&f===undefined)f=
this[d]=e;return f}});var c=Array.prototype.indexOf;if(!c||c===b.Array.indexOf)Array.prototype.indexOf=function(d,e){var f=this.length;e=e===undefined?0:e<0?Math.ceil(e):Math.floor(e);if(e<0)e+=f;for(e=e;e<f;e++)if(this[e]===d)return e;return-1};c=Array.prototype.lastIndexOf;if(!c||c===b.Array.lastIndexOf)Array.prototype.lastIndexOf=function(d,e){var f=this.length;e=e===undefined?f-1:e<0?Math.ceil(e):Math.floor(e);if(e<0)e+=f;for(e=e;e>=0;e--)if(this[e]===d)return e;return-1}})()});
tiki.module("sproutcore/runtime:mixins/comparable",function(a){a("core").Comparable={isComparable:true,compare:function(){throw"%@.compare() is not implemented".fmt(this.toString());}}});
tiki.module("sproutcore/runtime:mixins/copyable",function(a){a=a("core");a.Copyable={isCopyable:true,copy:function(){throw"%@.copy() is not implemented";},frozenCopy:function(){var b=this.get?this.get("isFrozen"):this.isFrozen;if(b===true)return this;else if(b===undefined)throw"%@ does not support freezing".fmt(this);else return this.copy().freeze()}};a.mixin(Array.prototype,a.Copyable);Array.prototype.copy=Array.prototype.slice});
tiki.module("sproutcore/runtime:mixins/delegate_support",function(a){var b=a("core");b.DelegateSupport={delegateFor:function(c){for(var d=1,e=arguments.length,f;d<e;){if((f=arguments[d])&&f[c]!==undefined)return f;d++}return this[c]!==undefined?this:null},invokeDelegateMethod:function(c,d,e){e=b.A(arguments);e=e.slice(2,e.length);if(!c||!c[d])c=this;var f=c[d];return f?f.apply(c,e):null},getDelegateProperty:function(c){for(var d=1,e=arguments.length,f;d<e;)if((f=arguments[d++])&&f[c]!==undefined)return f.get?
f.get(c):f[c];return this[c]!==undefined?this.get(c):undefined}}});
tiki.module("sproutcore/runtime:mixins/enumerable",function(a){var b=a("core");a("system/enumerator");b.Enumerable={isEnumerable:true,nextObject:function(c){return this.objectAt?this.objectAt(c):this[c]},firstObject:function(){if(this.get("length")!==0){if(this.objectAt)return this.objectAt(0);var c=b.Enumerator._popContext(),d;d=this.nextObject(0,null,c);b.Enumerator._pushContext(c);return d}}.property(),enumerator:function(){return b.Enumerator.create(this)},forEach:function(c,d){if(typeof c!==
"function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=null,g=b.Enumerator._popContext(),h=0;h<e;h++){f=this.nextObject(h,f,g);c.call(d,f,h,this);f=f}b.Enumerator._pushContext(g);return this},getEach:function(c){return this.map(function(d){return d?d.get?d.get(c):d[c]:null},this)},setEach:function(c,d){this.forEach(function(e){if(e)if(e.set)e.set(c,d);else e[c]=d},this);return this},map:function(c,d){if(typeof c!=="function")throw new TypeError;
var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=[],g=null,h=b.Enumerator._popContext(),i=0;i<e;i++){g=this.nextObject(i,g,h);f[i]=c.call(d,g,i,this);g=g}b.Enumerator._pushContext(h);return f},mapProperty:function(c){return this.map(function(d){return d?d.get?d.get(c):d[c]:null})},filter:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=[],g=null,h=b.Enumerator._popContext(),i=0;i<
e;i++){g=this.nextObject(i,g,h);c.call(d,g,i,this)&&f.push(g);g=g}b.Enumerator._pushContext(h);return f},sortProperty:function(c){var d=typeof c===b.T_STRING?arguments:c,e=d.length,f;if(this instanceof Array)f=this;else{f=[];this.forEach(function(g){f.push(g)})}if(!f)return[];return f.sort(function(g,h){var i,j,k;for(i=k=0;k===0&&i<e;i++){j=d[i];k=g?g.get?g.get(j):g[j]:null;j=h?h.get?h.get(j):h[j]:null;k=b.compare(k,j)}return k})},filterProperty:function(c,d){for(var e=this.get?this.get("length"):
this.length,f=[],g=null,h=b.Enumerator._popContext(),i=0;i<e;i++){var j=(g=this.nextObject(i,g,h))?g.get?g.get(c):g[c]:null;(d===undefined?!!j:b.isEqual(j,d))&&f.push(g);g=g}b.Enumerator._pushContext(h);return f},find:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=null,g=false,h=null,i=b.Enumerator._popContext(),j=0;j<e&&!g;j++){f=this.nextObject(j,f,i);if(g=c.call(d,f,j,this))h=f;f=f}b.Enumerator._pushContext(i);
return h},findProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=false,g=null,h=null,i=b.Enumerator._popContext(),j=0;j<e&&!f;j++){f=(h=this.nextObject(j,h,i))?h.get?h.get(c):h[c]:null;if(f=d===undefined?!!f:b.isEqual(f,d))g=h;h=h}b.Enumerator._pushContext(i);return g},every:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=true,g=null,h=b.Enumerator._popContext(),i=0;f&&i<e;i++){g=this.nextObject(i,
g,h);c.call(d,g,i,this)||(f=false);g=g}b.Enumerator._pushContext(h);return f},everyProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=true,g=null,h=b.Enumerator._popContext(),i=0;f&&i<e;i++){f=(g=this.nextObject(i,g,h))?g.get?g.get(c):g[c]:null;f=d===undefined?!!f:b.isEqual(f,d);g=g}b.Enumerator._pushContext(h);return f},some:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=false,g=null,
h=b.Enumerator._popContext(),i=0;!f&&i<e;i++){g=this.nextObject(i,g,h);if(c.call(d,g,i,this))f=true;g=g}b.Enumerator._pushContext(h);return f},someProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=false,g=null,h=b.Enumerator._popContext(),i=0;!f&&i<e;i++){f=(g=this.nextObject(i,g,h))?g.get?g.get(c):g[c]:null;f=d===undefined?!!f:b.isEqual(f,d);g=g}b.Enumerator._pushContext(h);return f},reduce:function(c,d,e){if(typeof c!=="function")throw new TypeError;var f=this.get?this.get("length"):
this.length;if(f===0&&d===undefined)throw new TypeError;d=d;for(var g=null,h=b.Enumerator._popContext(),i=0;i<f;i++){g=this.nextObject(i,g,h);if(g!==null)d=d===undefined?g:c.call(null,d,g,i,this,e);g=g}b.Enumerator._pushContext(h);if(d===undefined)throw new TypeError;return d},invoke:function(c){var d=this.get?this.get("length"):this.length;if(d<=0)return[];var e,f=[],g=arguments.length;if(g>1)for(e=1;e<g;e++)f.push(arguments[e]);g=[];var h=null,i=b.Enumerator._popContext();for(e=0;e<d;e++){var j=
(h=this.nextObject(e,h,i))?h[c]:null;if(j)g[e]=j.apply(h,f);h=h}b.Enumerator._pushContext(i);return g},invokeWhile:function(c,d){var e=this.get?this.get("length"):this.length;if(e<=0)return null;var f,g=[],h=arguments.length;if(h>2)for(f=2;f<h;f++)g.push(arguments[f]);h=c;var i=null,j=b.Enumerator._popContext();for(f=0;h===c&&f<e;f++){var k=(i=this.nextObject(f,i,j))?i[d]:null;if(k)h=k.apply(i,g);i=i}b.Enumerator._pushContext(j);return h},toArray:function(){var c=[];this.forEach(function(d){c.push(d)},
this);return c}};b._buildReducerFor=function(c,d){return function(e,f){var g=this[c];return b.typeOf(g)!==b.T_FUNCTION?this.unknownProperty?this.unknownProperty(e,f):null:b.Enumerable.reduce.call(this,g,null,d)}.property("[]")};b.Reducers={"[]":function(){return this}.property(),enumerableContentDidChange:function(){this.notifyPropertyChange("[]");return this},reducedProperty:function(c,d,e){if(!(!c||c.charAt(0)!=="@")){d=c.match(/^@([^(]*)(\(([^)]*)\))?$/);if(!(!d||d.length<2)){var f=d[1];d=d[3];
f="reduce"+f.slice(0,1).toUpperCase()+f.slice(1);var g=this[f];if(b.typeOf(g)===b.T_FUNCTION){if(e===false)return b.Enumerable.reduce.call(this,g,null,d);f=b._buildReducerFor(f,d);if(e=this.constructor.prototype){e[c]=f;f=e._properties||[];f.push(c);e._properties=f;this.registerDependentKey(c,"[]")}return b.Enumerable.reduce.call(this,g,null,d)}}}},reduceMax:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];if(c===null)return d;return d>c?d:c},reduceMaxObject:function(c,d,e,f,g){e=c;f=d;if(g){if(d)f=
d.get?d.get(g):d[g];if(c)e=c.get?c.get(g):c[g]}if(e===null)return d;return f>e?d:c},reduceMin:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];if(c===null)return d;return d<c?d:c},reduceMinObject:function(c,d,e,f,g){e=c;f=d;if(g){if(d)f=d.get?d.get(g):d[g];if(c)e=c.get?c.get(g):c[g]}if(e===null)return d;return f<e?d:c},reduceAverage:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];c=(c||0)+d;f=f.get?f.get("length"):f.length;if(e>=f-1)c/=f;return c},reduceSum:function(c,d,e,f,g){if(g&&d)d=d.get?
d.get(g):d[g];return c===null?d:c+d}};b.mixin(b.Enumerable,b.Reducers);b.mixin(Array.prototype,b.Reducers);Array.prototype.isEnumerable=true;(function(){var c={nextObject:b.Enumerable.nextObject,enumerator:b.Enumerable.enumerator,firstObject:b.Enumerable.firstObject,sortProperty:b.Enumerable.sortProperty,mapProperty:function(f){for(var g=this.length,h=[],i=0;i<g;i++){var j=this[i];h[i]=j?j.get?j.get(f):j[f]:null}return h},filterProperty:function(f,g){for(var h=this.length,i=[],j=0;j<h;j++){var k=
this[j],l=k?k.get?k.get(f):k[f]:null;(g===undefined?!!l:b.isEqual(l,g))&&i.push(k)}return i},find:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i,j=null,k=false,l=0;l<h&&!k;l++){i=this[l];if(k=f.call(g,i,l,this))j=i}return j},findProperty:function(f,g){var h=this.length,i,j;j=false;for(var k=null,l=0;l<h&&!j;l++){j=(i=this[l])?i.get?i.get(f):i[f]:null;if(j=g===undefined?!!j:b.isEqual(j,g))k=i}return k},everyProperty:function(f,g){for(var h=
this.length,i=true,j=0;i&&j<h;j++){i=(i=this[j])?i.get?i.get(f):i[f]:null;i=g===undefined?!!i:b.isEqual(i,g)}return i},someProperty:function(f,g){for(var h=this.length,i=false,j=0;!i&&j<h;j++){i=(i=this[j])?i.get?i.get(f):i[f]:null;i=g===undefined?!!i:b.isEqual(i,g)}return i},invoke:function(f){var g=this.length;if(g<=0)return[];var h,i=[],j=arguments.length;if(j>1)for(h=1;h<j;h++)i.push(arguments[h]);j=[];for(h=0;h<g;h++){var k=this[h],l=k?k[f]:null;if(l)j[h]=l.apply(k,i)}return j},invokeWhile:function(f,
g){var h=this.length;if(h<=0)return null;var i,j=[],k=arguments.length;if(k>2)for(i=2;i<k;i++)j.push(arguments[i]);k=f;for(i=0;k===f&&i<h;i++){var l=this[i],m=l?l[g]:null;if(m)k=m.apply(l,j)}return k},toArray:function(){var f=this.length;if(f<=0)return[];for(var g=[],h=0;h<f;h++)g.push(this[h]);return g},getEach:function(f){for(var g=[],h=this.length,i=0;i<h;i++){var j=this[i];g[i]=j?j.get?j.get(f):j[f]:null}return g},setEach:function(f,g){for(var h=this.length,i=0;i<h;i++){var j=this[i];if(j)if(j.set)j.set(f,
g);else j[f]=g}return this}},d={forEach:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i=0;i<h;i++)f.call(g,this[i],i,this);return this},map:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i=[],j=0;j<h;j++)i[j]=f.call(g,this[j],j,this);return i},filter:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i=[],j=0;j<h;j++){var k=
this[j];f.call(g,k,j,this)&&i.push(k)}return i},every:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i=true,j=0;i&&j<h;j++)f.call(g,this[j],j,this)||(i=false);return i},some:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var i=false,j=0;!i&&j<h;j++)if(f.call(g,this[j],j,this))i=true;return i},reduce:function(f,g,h){if(typeof f!=="function")throw new TypeError;var i=this.length;if(i===
0&&g===undefined)throw new TypeError;g=g;for(var j=0;j<i;j++){var k=this[j];if(k!==null)g=g===undefined?k:f.call(null,g,k,j,this,h)}if(g===undefined)throw new TypeError;return g}};for(var e in d)if(d.hasOwnProperty(e))if(!Array.prototype[e]||typeof Prototype==="object"&&Prototype.Version.match(/^1\.6/))Array.prototype[e]=d[e];b.mixin(Array.prototype,c)})()});
tiki.module("sproutcore/runtime:mixins/freezable",function(a){a=a("core");a.FROZEN_ERROR=new Error("Cannot modify a frozen object");a.Freezable={isFreezable:true,isFrozen:false,freeze:function(){if(this.set)this.set("isFrozen",true);else this.isFrozen=true;return this}};a.mixin(Array.prototype,a.Freezable)});
tiki.module("sproutcore/runtime:mixins/observable",function(a){var b=a("core");a("private/observer_set");a("private/chain_observer");b.LOG_OBSERVERS=false;b.Observable={isObservable:true,automaticallyNotifiesObserversFor:function(){return true},get:function(c){var d=this[c],e;if(d===undefined)return this.unknownProperty(c);else if(d&&d.isProperty)if(d.isCacheable){e=this._kvo_cache;if(!e)e=this._kvo_cache={};return e[d.cacheKey]!==undefined?e[d.cacheKey]:(e[d.cacheKey]=d.call(this,c))}else return d.call(this,
c);else return d},set:function(c,d){var e=this[c],f=this.automaticallyNotifiesObserversFor(c),g=d,h,i,j,k;if(!f&&this._kvo_cacheable&&(i=this._kvo_cache)){h=this._kvo_cachedep;if(!h||(h=h[c])===undefined)h=this._kvo_computeCachedDependentsFor(c);if(h)for(j=h.length;--j>=0;){k=h[j];i[k.cacheKey]=i[k.lastSetValueKey]=undefined}}if(e&&e.isProperty){i=this._kvo_cache;if(e.isVolatile||!i||i[e.lastSetValueKey]!==d){if(!i)i=this._kvo_cache={};i[e.lastSetValueKey]=d;f&&this.propertyWillChange(c);g=e.call(this,
c,d);if(e.isCacheable)i[e.cacheKey]=g;f&&this.propertyDidChange(c,g,true)}}else if(e===undefined){f&&this.propertyWillChange(c);this.unknownProperty(c,d);f&&this.propertyDidChange(c,g)}else if(this[c]!==d){f&&this.propertyWillChange(c);g=this[c]=d;f&&this.propertyDidChange(c,g)}return this},unknownProperty:function(c,d){if(d!==undefined)this[c]=d;return d},beginPropertyChanges:function(){this._kvo_changeLevel=(this._kvo_changeLevel||0)+1;return this},endPropertyChanges:function(){this._kvo_changeLevel=
(this._kvo_changeLevel||1)-1;var c=this._kvo_changes;this._kvo_changeLevel<=0&&c&&c.length>0&&!b.Observers.isObservingSuspended&&this._notifyPropertyObservers();return this},propertyWillChange:function(){return this},propertyDidChange:function(c,d,e){this._kvo_revision=(this._kvo_revision||0)+1;var f=this._kvo_changeLevel||0,g,h,i;d=b.LOG_OBSERVERS&&this.LOG_OBSERVING!==false;if(this._kvo_cacheable&&(i=this._kvo_cache)){if(!e)if((e=this[c])&&e.isProperty)i[e.cacheKey]=i[e.lastSetValueKey]=undefined;
e=this._kvo_cachedep;if(!e||(e=e[c])===undefined)e=this._kvo_computeCachedDependentsFor(c);if(e)for(g=e.length;--g>=0;){h=e[g];i[h.cacheKey]=i[h.lastSetValueKey]=undefined}}i=b.Observers.isObservingSuspended;if(f>0||i){f=this._kvo_changes;if(!f)f=this._kvo_changes=b.CoreSet.create();f.add(c);if(i){d&&console.log("%@%@: will not notify observers because observing is suspended".fmt(b.KVO_SPACES,this));b.Observers.objectHasPendingChanges(this)}}else this._notifyPropertyObservers(c);return this},registerDependentKey:function(c,
d){var e=this._kvo_dependents,f,g,h,i,j;if(b.typeOf(d)===b.T_ARRAY){f=d;h=0}else{f=arguments;h=1}g=f.length;if(!e)this._kvo_dependents=e={};for(;--g>=h;){i=f[g];(j=e[i])||(j=e[i]=[]);j.push(c)}},_kvo_addCachedDependents:function(c,d,e,f){for(var g=d.length,h,i,j;--g>=0;){i=d[g];f.add(i);if((h=this[i])&&h instanceof Function&&h.isProperty){h.isCacheable&&c.push(h);if((j=e[i])&&j.length>0)this._kvo_addCachedDependents(c,j,e,f)}}},_kvo_computeCachedDependentsFor:function(c){var d=this._kvo_cachedep,
e=this._kvo_dependents,f=e?e[c]:null,g,h;if(!d)d=this._kvo_cachedep={};if(!f||f.length===0)return d[c]=null;g=d[c]=[];h=b._TMP_SEEN_SET=b._TMP_SEEN_SET||b.CoreSet.create();h.add(c);this._kvo_addCachedDependents(g,f,e,h);h.clear();if(g.length===0)g=d[c]=null;return g},_kvo_for:function(c,d){var e=this[c];if(!this._kvo_cloned)this._kvo_cloned={};if(e){if(!this._kvo_cloned[c]){e=this[c]=e.copy();this._kvo_cloned[c]=true}}else{e=this[c]=d===undefined?[]:d.create();this._kvo_cloned[c]=true}return e},addObserver:function(c,
d,e,f){var g;if(e===undefined){e=d;d=this}d||(d=this);if(b.typeOf(e)===b.T_STRING)e=d[e];if(!e)throw"You must pass a method to addObserver()";c=c.toString();if(c.indexOf(".")>=0){f=b._ChainObserver.createChain(this,c,d,e,f);f.masterTarget=d;f.masterMethod=e;this._kvo_for(b.keyFor("_kvo_chains",c)).push(f)}else{this[c]===undefined&&c.indexOf("@")===0&&this.get(c);if(d===this)d=null;g=b.keyFor("_kvo_observers",c);this._kvo_for(g,b.ObserverSet).add(d,e,f);this._kvo_for("_kvo_observed_keys",b.CoreSet).add(c)}this.didAddObserver&&
this.didAddObserver(c,d,e);return this},removeObserver:function(c,d,e){var f,g,h;if(e===undefined){e=d;d=this}d||(d=this);if(b.typeOf(e)===b.T_STRING)e=d[e];if(!e)throw"You must pass a method to removeObserver()";c=c.toString();if(c.indexOf(".")>=0){f=b.keyFor("_kvo_chains",c);if(this[f]){f=this._kvo_for(f);for(h=f.length;--h>=0;)if((g=f[h])&&g.masterTarget===d&&g.masterMethod===e)f[h]=g.destroyChain()}}else{if(d===this)d=null;f=b.keyFor("_kvo_observers",c);if(this[f]){f=this._kvo_for(f);f.remove(d,
e);f.targets<=0&&this._kvo_for("_kvo_observed_keys",b.CoreSet).remove(c)}}this.didRemoveObserver&&this.didRemoveObserver(c,d,e);return this},hasObserverFor:function(c){b.Observers.flush(this);var d=this[b.keyFor("_kvo_observers",c)];if((c=this[b.keyFor("_kvo_local",c)])&&c.length>0)return true;if(d&&d.getMembers().length>0)return true;return false},initObservable:function(){if(!this._observableInited){this._observableInited=true;var c,d,e,f,g,h,i,j,k,l;if(d=this._observers){f=d.length;for(c=0;c<f;c++){e=
d[c];e=this[e];h=(g=e.propertyPaths)?g.length:0;for(i=0;i<h;i++){j=g[i];k=j.indexOf(".");if(k<0)this.addObserver(j,this,e);else if(j.indexOf("*")===0)this.addObserver(j.slice(1),this,e);else{l=null;if(k===0){l=this;j=j.slice(1)}else if(k===4&&j.slice(0,5)==="this."){l=this;j=j.slice(5)}else if(k<0&&j.length===4&&j==="this"){l=this;j=""}b.Observers.addObserver(j,this,e,l)}}}}this.bindings=[];if(d=this._bindings){c=0;for(h=d.length;c<h;c++){e=d[c];f=this[e];g=e.slice(0,-7);this[e]=this.bind(g,f)}}if(d=
this._properties){c=0;for(h=d.length;c<h;c++){e=d[c];if(f=this[e]){if(f.isCacheable)this._kvo_cacheable=true;f.dependentKeys&&f.dependentKeys.length>0&&this.registerDependentKey(e,f.dependentKeys)}}}}},observersForKey:function(c){return this._kvo_for("_kvo_observers",c).getMembers()||[]},_notifyPropertyObservers:function(c){this._observableInited||this.initObservable();b.Observers.flush(this);var d=b.LOG_OBSERVERS&&this.LOG_OBSERVING!==false,e,f,g,h,i,j,k,l,m,o,r,w;if(d){w=b.KVO_SPACES=(b.KVO_SPACES||
"")+"  ";console.log('%@%@: notifying observers after change to key "%@"'.fmt(w,this,c))}g=this["_kvo_observers_*"];for(this._kvo_changeLevel=(this._kvo_changeLevel||0)+1;(f=this._kvo_changes)&&f.length>0||c;){j=++this.propertyRevision;f||(f=b.CoreSet.create());this._kvo_changes=null;if(c==="*"){f.add("*");f.addEach(this._kvo_for("_kvo_observed_keys",b.CoreSet))}else c&&f.add(c);if(e=this._kvo_dependents)for(h=0;h<f.length;h++){c=f[h];if((i=e[c])&&(o=i.length)){d&&console.log("%@...including dependent keys for %@: %@".fmt(w,
c,i));k=this._kvo_cache;if(!k)k=this._kvo_cache={};for(;--o>=0;){f.add(c=i[o]);if(c=this[c]){this[c.cacheKey]=undefined;k[c.cacheKey]=k[c.lastSetValueKey]=undefined}}}}for(;f.length>0;){c=f.pop();if(e=this[b.keyFor("_kvo_observers",c)]){e=e.getMembers();h=e.length;for(k=0;k<h;k++){i=e[k];if(i[3]!==j){l=i[0]||this;m=i[1];r=i[2];i[3]=j;d&&console.log('%@...firing observer on %@ for key "%@"'.fmt(w,l,c));r!==undefined?m.call(l,this,c,null,r,j):m.call(l,this,c,null,j)}}}if(e=this[b.keyFor("_kvo_local",
c)]){h=e.length;for(k=0;k<h;k++){i=e[k];if(m=this[i]){d&&console.log('%@...firing local observer %@.%@ for key "%@"'.fmt(w,this,i,c));m.call(this,this,c,null,j)}}}if(g&&c!=="*"){e=g.getMembers();h=e.length;for(k=0;k<h;k++){i=e[k];l=i[0]||this;m=i[1];r=i[2];d&&console.log('%@...firing * observer on %@ for key "%@"'.fmt(w,l,c));r!==undefined?m.call(l,this,c,null,r,j):m.call(l,this,c,null,j)}}if(this.propertyObserver){d&&console.log('%@...firing %@.propertyObserver for key "%@"'.fmt(w,this,c));this.propertyObserver(this,
c,null,j)}}f&&f.destroy();c=null}this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;if(d)b.KVO_SPACES=w.slice(0,-2);return true},bind:function(c,d,e){if(e!==undefined)d=[d,e];e=b.typeOf(d);if(e===b.T_STRING||e===b.T_ARRAY){e=this[c+"BindingDefault"]||b.Binding;e=e.beget().from(d)}else e=d;e=e.to(c,this).connect();this.bindings.push(e);return e},didChangeFor:function(c){var d,e,f,g,h,i,j,k,l;c=b.hashFor(c);d=this._kvo_didChange_valueCache;if(!d)d=this._kvo_didChange_valueCache={};e=this._kvo_didChange_revisionCache;
if(!e)e=this._kvo_didChange_revisionCache={};f=d[c]||{};g=e[c]||{};h=false;i=this._kvo_revision||0;for(j=arguments.length;--j>=1;){k=arguments[j];if(g[k]!=i){l=this.get(k);if(f[k]!==l){h=true;f[k]=l}}g[k]=i}d[c]=f;e[c]=g;return h},setIfChanged:function(c,d){return this.get(c)!==d?this.set(c,d):this},getPath:function(c){c=b.tupleForPropertyPath(c,this);if(!(c===null||c[0]===null))return c[0].get(c[1])},setPath:function(c,d){if(c.indexOf(".")>=0){c=b.tupleForPropertyPath(c,this);if(!c||!c[0])return null;
c[0].set(c[1],d)}else this.set(c,d);return this},setPathIfChanged:function(c,d){if(c.indexOf(".")>=0){c=b.tupleForPropertyPath(c,this);if(!c||!c[0])return null;c[0].get(c[1])!==d&&c[0].set(c[1],d)}else this.setIfChanged(c,d);return this},getEach:function(){var c=b.A(arguments),d=[],e,f;e=0;for(f=c.length;e<f;e++)d[d.length]=this.getPath(c[e]);return d},incrementProperty:function(c){this.set(c,(this.get(c)||0)+1);return this.get(c)},decrementProperty:function(c){this.set(c,(this.get(c)||0)-1);return this.get(c)},
toggleProperty:function(c,d,e){if(d===undefined)d=true;if(e===undefined)e=false;d=this.get(c)==d?e:d;this.set(c,d);return this.get(c)},notifyPropertyChange:function(c,d){this.propertyWillChange(c);this.propertyDidChange(c,d);return this},allPropertiesDidChange:function(){this._kvo_cache=null;this._notifyPropertyObservers("*");return this},addProbe:function(c){this.addObserver(c,b.logChange)},removeProbe:function(c){this.removeObserver(c,b.logChange)},logProperty:function(){var c=b.$A(arguments),d,
e,f;f=0;for(e=c.length;f<e;f++){d=c[f];console.log("%@:%@: ".fmt(b.guidFor(this),d),this.get(d))}},propertyRevision:1};b.logChange=function(c,d){console.log("CHANGE: %@[%@] => %@".fmt(c,d,c.get(d)))};b.mixin(b,{get:function(c,d){if(c){if(d===undefined)return this[c];if(c.get)return c.get(d);return c[d]}}});b.mixin(Array.prototype,b.Observable);a("system/binding");a("private/observer_queue")});
tiki.module("sproutcore/runtime:private/chain_observer",function(a){var b=a("core");b._ChainObserver=function(c){this.property=c};b._ChainObserver.createChain=function(c,d,e,f,g){d=d.split(".");for(var h=new b._ChainObserver(d[0]),i=h,j=d.length,k=1;k<j;k++)i=i.next=new b._ChainObserver(d[k]);h.objectDidChange(c);i.target=e;i.method=f;i.context=g;return h};b._ChainObserver.prototype={isChainObserver:true,object:null,property:null,next:null,target:null,method:null,objectDidChange:function(c){if(c!==
this.object){this.object&&this.object.removeObserver&&this.object.removeObserver(this.property,this,this.propertyDidChange);(this.object=c)&&this.object.addObserver&&this.object.addObserver(this.property,this,this.propertyDidChange);this.propertyDidChange()}},propertyDidChange:function(){var c=this.object,d=this.property,e=c&&c.get?c.get(d):null;this.next&&this.next.objectDidChange(e);var f=this.target,g=this.method,h=this.context;if(f&&g){var i=c?c.propertyRevision:null;h?g.call(f,c,d,e,h,i):g.call(f,
c,d,e,i)}},destroyChain:function(){var c=this.object;c&&c.removeObserver&&c.removeObserver(this.property,this,this.propertyDidChange);this.next&&this.next.destroyChain();return this.next=this.target=this.method=this.object=this.context=null}}});
tiki.module("sproutcore/runtime:private/observer_queue",function(a){var b=a("core");a("system/set");b.Observers={queue:[],addObserver:function(c,d,e,f){var g;(g=b.typeOf(c)===b.T_STRING?b.tupleForPropertyPath(c,f):c)?g[0].addObserver(g[1],d,e):this.queue.push([c,d,e,f])},removeObserver:function(c,d,e,f){var g,h,i;(g=b.tupleForPropertyPath(c,f))&&g[0].removeObserver(g[1],d,e);g=this.queue.length;for(h=this.queue;--g>=0;){i=h[g];if(i[0]===c&&i[1]===d&&i[2]==e&&i[3]===f)h[g]=null}},addPendingRangeObserver:function(c){var d=
this.rangeObservers;if(!d)d=this.rangeObservers=b.CoreSet.create();d.add(c);return this},_TMP_OUT:[],flush:function(c){var d=this.queue;if(d&&d.length>0)for(var e=this.queue=[],f=d.length;--f>=0;){var g=d[f];if(g){var h=b.tupleForPropertyPath(g[0],g[3]);h?h[0].addObserver(h[1],g[1],g[2]):e.push(g)}}if(c._kvo_needsRangeObserver){e=(d=this.rangeObservers)?d.get("length"):0;g=this._TMP_OUT;for(f=0;f<e;f++){h=d[f];h.setupPending(c)&&g.push(h)}g.length>0&&d.removeEach(g);g.length=0;c._kvo_needsRangeObserver=
false}},isObservingSuspended:0,_pending:b.CoreSet.create(),objectHasPendingChanges:function(c){this._pending.add(c)},suspendPropertyObserving:function(){this.isObservingSuspended++},resumePropertyObserving:function(){var c;if(--this.isObservingSuspended<=0){c=this._pending;this._pending=b.CoreSet.create();var d,e=c.length;for(d=0;d<e;d++)c[d]._notifyPropertyObservers();c.clear()}}}});
tiki.module("sproutcore/runtime:private/observer_set",function(a){var b=a("core");b.ObserverSet={targets:0,_membersCacheIsValid:false,add:function(c,d,e){var f=c?b.guidFor(c):"__this__",g=this[f];if(!g){g=this[f]=b.CoreSet.create();g.target=c;g.isTargetSet=true;this.targets++}g.add(d);if(e!==undefined){c=g.contexts;if(!e)e=g.contexts={};c[b.guidFor(d)]=e}this._membersCacheIsValid=false},remove:function(c,d){c=c?b.guidFor(c):"__this__";var e=this[c];if(!e)return false;e.remove(d);if(e.length<=0){e.target=
null;e.isTargetSet=false;e.contexts=null;delete this[c];this.targets--}else e.contexts&&delete e.contexts[b.guidFor(d)];this._membersCacheIsValid=false;return true},invokeMethods:function(){for(var c in this)if(this.hasOwnProperty(c)){var d=this[c];if(d&&d.isTargetSet)for(var e=d.length,f=d.target;--e>=0;)d[e].call(f)}},getMembers:function(){if(this._membersCacheIsValid)return this._members;if(this._members)this._members.length=0;else this._members=[];var c=this._members;for(var d in this)if(this.hasOwnProperty(d)){var e=
this[d];if(e&&e.isTargetSet){var f=e.length,g=e.target,h=e.contexts;if(h)for(;--f>=0;){var i=e[f];c.push([g,i,h[b.guidFor(i)]])}else for(;--f>=0;)c.push([g,e[f]])}}this._membersCacheIsValid=true;return c},clone:function(){var c,d,e,f=b.ObserverSet.create();for(e in this)if(this.hasOwnProperty(e))if((c=this[e])&&c.isTargetSet){d=c.clone();d.target=c.target;if(c.contexts)d.contexts=b.clone(c.contexts);f[e]=d}f.targets=this.targets;f._membersCacheIsValid=false;return f},create:function(){return b.beget(this)}};
b.ObserverSet.slice=b.ObserverSet.clone});
tiki.module("sproutcore/runtime:system/binding",function(a){var b=a("core");a("system/set");b.LOG_BINDINGS=false;b.BENCHMARK_BINDING_NOTIFICATIONS=false;b.BENCHMARK_BINDING_SETUP=false;b.MULTIPLE_PLACEHOLDER="@@MULT@@";b.NULL_PLACEHOLDER="@@NULL@@";b.EMPTY_PLACEHOLDER="@@EMPTY@@";b.Binding={beget:function(c){var d=b.beget(this);d.parentBinding=this;if(c!==undefined)d=d.from(c);return d},builder:function(){var c=this,d=function(e){return c.beget().from(e)};d.beget=function(){return c.beget()};return d},
from:function(c,d){if(!c)return this;var e=this===b.Binding?this.beget():this;e._fromPropertyPath=c;e._fromRoot=d;e._fromTuple=null;return e},to:function(c,d){var e=this===b.Binding?this.beget():this;e._toPropertyPath=c;e._toRoot=d;e._toTuple=null;return e},connect:function(){if(this.isConnected)return this;this._syncOnConnect=this._connectionPending=this.isConnected=true;b.Binding._connectQueue.add(this);return this},_connect:function(){if(this._connectionPending){this._connectionPending=false;var c,
d,e=b.BENCHMARK_BINDING_SETUP;e&&b.Benchmark.start("SC.Binding.connect()");c=this._fromPropertyPath;d=this._fromRoot;if(b.typeOf(c)===b.T_STRING)if(c.indexOf(".")===0){c=c.slice(1);if(!d)d=this._toRoot}else if(c.indexOf("*")===0){c=[this._fromRoot||this._toRoot,c.slice(1)];d=null}b.Observers.addObserver(c,this,this.fromPropertyDidChange,d);if(!this._oneWay){c=this._toPropertyPath;d=this._toRoot;b.Observers.addObserver(c,this,this.toPropertyDidChange,d)}e&&b.Benchmark.end("SC.Binding.connect()");if(this._syncOnConnect){this._syncOnConnect=
false;e&&b.Benchmark.start("SC.Binding.connect().sync");this.sync();e&&b.Benchmark.end("SC.Binding.connect().sync")}}},disconnect:function(){if(!this.isConnected)return this;if(this._connectionPending)this._connectionPending=false;else{b.Observers.removeObserver(this._fromPropertyPath,this,this.fromPropertyDidChange,this._fromRoot);this._oneWay||b.Observers.removeObserver(this._toPropertyPath,this,this.toPropertyDidChange,this._toRoot)}this.isConnected=false;return this},fromPropertyDidChange:function(c,
d){if((c?c.get(d):null)!==this._bindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}},toPropertyDidChange:function(c,d){if(!this._oneWay)if(c.get(d)!==this._transformedBindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}},_setBindingValue:function(c,d){this._bindingSource=c;this._bindingKey=d},_computeBindingValue:function(){var c=this._bindingSource,d;if(c){this._bindingValue=c=c.getPath(this._bindingKey);
var e=this._transforms;if(e){var f=e.length,g;for(d=0;d<f;d++){g=e[d];c=g(c,this)}}if(this._noError&&b.typeOf(c)===b.T_ERROR)c=null;this._transformedBindingValue=c}},_connectQueue:b.CoreSet.create(),_alternateConnectQueue:b.CoreSet.create(),_changeQueue:b.CoreSet.create(),_alternateChangeQueue:b.CoreSet.create(),_changePending:false,flushPendingChanges:function(){if(this._isFlushing)return false;this._isFlushing=true;b.Observers.suspendPropertyObserving();for(var c=false,d=b.LOG_BINDINGS,e,f;(e=this._connectQueue).length>
0;){this._connectQueue=this._alternateConnectQueue;for(this._alternateConnectQueue=e;f=e.pop();)f._connect()}for(;(e=this._changeQueue).length>0;){d&&console.log("Begin: Trigger changed bindings");c=true;this._changeQueue=this._alternateChangeQueue;for(this._alternateChangeQueue=e;f=e.pop();)f.applyBindingValue();d&&console.log("End: Trigger changed bindings")}this._isFlushing=false;b.Observers.resumePropertyObserving();return c},applyBindingValue:function(){this._changePending=false;this._computeBindingTargets();
this._computeBindingValue();var c=this._bindingValue,d=this._transformedBindingValue,e=b.BENCHMARK_BINDING_NOTIFICATIONS,f=b.LOG_BINDINGS;if(!this._oneWay&&this._fromTarget){f&&console.log("%@: %@ -> %@".fmt(this,c,d));e&&b.Benchmark.start(this.toString()+"->");this._fromTarget.setPathIfChanged(this._fromPropertyKey,c);e&&b.Benchmark.end(this.toString()+"->")}if(this._toTarget){f&&console.log("%@: %@ <- %@".fmt(this,c,d));e&&b.Benchmark.start(this.toString()+"<-");this._toTarget.setPathIfChanged(this._toPropertyKey,
d);e&&b.Benchmark.start(this.toString()+"<-")}},sync:function(){if(!this.isConnected)return this;if(this._connectionPending)this._syncOnConnect=true;else{this._computeBindingTargets();var c=this._fromTarget,d=this._fromPropertyKey;if(!c||!d)return this;if(c.getPath(d)!==this._bindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}}return this},_syncOnConnect:false,_computeBindingTargets:function(){if(!this._fromTarget){var c,d;c=this._fromPropertyPath;d=
this._fromRoot;if(b.typeOf(c)===b.T_STRING)if(c.indexOf(".")===0){c=c.slice(1);if(!d)d=this._toRoot}else if(c.indexOf("*")===0){c=[d||this._toRoot,c.slice(1)];d=null}if(c=b.tupleForPropertyPath(c,d)){this._fromTarget=c[0];this._fromPropertyKey=c[1]}}if(!this._toTarget){c=this._toPropertyPath;d=this._toRoot;if(c=b.tupleForPropertyPath(c,d)){this._toTarget=c[0];this._toPropertyKey=c[1]}}},oneWay:function(c,d){if(d===undefined&&b.typeOf(c)===b.T_BOOL){d=c;c=null}c=this.from(c);if(c===b.Binding)c=c.beget();
c._oneWay=d===undefined?true:d;return c},transform:function(c){var d=this===b.Binding?this.beget():this,e=d._transforms;if(e&&e===d.parentBinding._transform)e=d._transforms=e.slice();if(!e)e=d._transforms=[];e.push(c);return d},resetTransforms:function(){var c=this===b.Binding?this.beget():this;c._transforms=null;return c},noError:function(c,d){if(d===undefined&&b.typeOf(c)===b.T_BOOL){d=c;c=null}c=this.from(c);if(c===b.Binding)c=c.beget();c._noError=d===undefined?true:d;return c},single:function(c,
d){if(d===undefined)d=b.MULTIPLE_PLACEHOLDER;return this.from(c).transform(function(e){if(e&&e.isEnumerable){var f=e.get("length");e=f>1?d:f<=0?null:e.firstObject()}return e})},notEmpty:function(c,d){if(d===undefined)d=b.EMPTY_PLACEHOLDER;return this.from(c).transform(function(e){if(b.none(e)||e===""||b.isArray(e)&&e.length===0)e=d;return e})},notNull:function(c,d){if(d===undefined)d=b.EMPTY_PLACEHOLDER;return this.from(c).transform(function(e){if(b.none(e))e=d;return e})},multiple:function(c){return this.from(c).transform(function(d){b.isArray(d)||
(d=d==null?[]:[d]);return d})},bool:function(c){return this.from(c).transform(function(d){var e=b.typeOf(d);if(e===b.T_ERROR)return d;return e==b.T_ARRAY?d.length>0:d===""?false:!!d})},not:function(c){return this.from(c).transform(function(d){var e=b.typeOf(d);if(e===b.T_ERROR)return d;return!(e==b.T_ARRAY?d.length>0:d===""?false:!!d)})},isNull:function(c){return this.from(c).transform(function(d){return b.typeOf(d)===b.T_ERROR?d:b.none(d)})},toString:function(){var c=this._fromRoot?"<%@>:%@".fmt(this._fromRoot,
this._fromPropertyPath):this._fromPropertyPath,d=this._toRoot?"<%@>:%@".fmt(this._toRoot,this._toPropertyPath):this._toPropertyPath,e=this._oneWay?"[oneWay]":"";return"SC.Binding%@(%@ -> %@)%@".fmt(b.guidFor(this),c,d,e)}};b.binding=function(c,d){return b.Binding.from(c,d)}});
tiki.module("sproutcore/runtime:system/cookie",function(a){var b=a("core");a("system/object");b.Cookie=b.Object.extend({name:null,value:"",expires:null,path:null,domain:null,secure:false,isCookie:true,destroy:function(){this.set("expires",-1);this.write();arguments.callee.base.apply(this,arguments)},write:function(){var c=this.get("name"),d=this.get("value"),e=this.get("expires"),f=this.get("path"),g=this.get("domain"),h=this.get("secure"),i="";if(e&&(b.typeOf(e)===b.T_NUMBER||b.DateTime&&e.get&&
e.get("milliseconds")||b.typeOf(e.toUTCString)===b.T_FUNCTION)){var j;if(b.typeOf(e)===b.T_NUMBER){j=new Date;j.setTime(j.getTime()+e*24*60*60*1E3)}else if(b.DateTime&&e.get&&e.get("milliseconds"))j=new Date(e.get("milliseconds"));else if(b.typeOf(e.toUTCString)===b.T_FUNCTION)j=e;if(j)i="; expires="+j.toUTCString()}e=f?"; path="+f:"";g=g?"; domain="+g:"";h=h?"; secure":"";document.cookie=[c,"=",encodeURIComponent(d),i,e,g,h].join("");return this}});b.Cookie.mixin({find:function(c){if(document.cookie&&
document.cookie!=="")for(var d=document.cookie.split(";"),e=0;e<d.length;e++){var f=String(d[e]).trim();if(f.substring(0,c.length+1)===c+"=")return b.Cookie.create({name:c,value:decodeURIComponent(f.substring(c.length+1))})}return null}})});
tiki.module("sproutcore/runtime:system/enumerator",function(a){var b=a("core");b.Enumerator=function(c){this.enumerable=c;this.reset();return this};b.Enumerator.prototype={nextObject:function(){var c=this._index,d=this._length;if(!(c>=d)){var e=this.enumerable.nextObject(c,this._previousObject,this._context);this._previousObject=e;this._index=c+1;if(c>=d)this._context=b.Enumerator._pushContext(this._context);return e}},reset:function(){var c=this.enumerable;if(!c)throw b.$error("Enumerator has been destroyed");
c=this._length=c.get?c.get("length"):c.length;this._index=0;this._previousObject=null;this._context=c>0?b.Enumerator._popContext():null},destroy:function(){this.enumerable=this._length=this._index=this._previousObject=this._context=null}};b.Enumerator.create=function(c){return new b.Enumerator(c)};b.Enumerator._popContext=function(){return(this._contextCache?this._contextCache.pop():null)||{}};b.Enumerator._pushContext=function(c){this._contextCache=this._contextCache||[];this._contextCache.push(c);
return null}});
tiki.module("sproutcore/runtime:system/error",function(a){var b=a("core");b.Error=b.Object.extend({code:-1,message:"",errorValue:null,errorObject:function(){return this}.property().cacheable(),label:null,toString:function(){return"SC.Error:%@:%@ (%@)".fmt(b.guidFor(this),this.get("message"),this.get("code"))},isError:true});b.Error.desc=function(c,d,e,f){c={message:c};if(d!==undefined)c.label=d;if(f!==undefined)c.code=f;if(e!==undefined)c.errorValue=e;return this.create(c)};b.$error=function(c,d,
e,f){return b.Error.desc(c,d,e,f)};b.ok=function(c){return c!==false&&!(c&&c.isError)};b.$ok=b.ok;b.val=function(c){return c&&c.isError?c.get?c.get("errorValue"):null:c};b.$val=b.val;b.Error.HAS_MULTIPLE_VALUES=-100});
tiki.module("sproutcore/runtime:system/index_set",function(a){var b=a("core");a("mixins/enumerable");a("mixins/observable");a("mixins/freezable");a("mixins/copyable");b.IndexSet=b.mixin({},b.Enumerable,b.Observable,b.Freezable,b.Copyable,{_sc_sliceContent:function(c){if(c.length<1E3)return c.slice();for(var d=0,e=[],f=c[0];f!==0;){e[d]=f;d=f<0?0-f:f;f=c[d]}e[d]=0;this._hint(0,d,e);return e},create:function(c,d){var e=b.beget(this);e.initObservable();if(c&&c.isIndexSet){e._content=this._sc_sliceContent(c._content);
e.max=c.max;e.length=c.length;e.source=c.source}else{e._content=[0];c!==undefined&&e.add(c,d)}return e},isIndexSet:true,HINT_SIZE:256,length:0,max:0,min:function(){var c=this._content[0];return c===0?-1:c>0?0:Math.abs(c)}.property("[]").cacheable(),firstObject:function(){return this.get("length")>0?this.get("min"):undefined}.property(),rangeStartForIndex:function(c){var d=this._content,e=this.get("max"),f;if(c>=e)return e;if(Math.abs(d[c])>c)return c;f=c-c%b.IndexSet.HINT_SIZE;e=d[f];if(e<0||e>c)e=
f;for(f=Math.abs(d[e]);f<c;){e=f;f=Math.abs(d[e])}return e},isEqual:function(c){if(c===this)return true;if(!c||!c.isIndexSet||c.max!==this.max||c.length!==this.length)return false;var d=this._content;c=c._content;var e=0,f=d[e];do{if(c[e]!==f)return false;e=Math.abs(f);f=d[e]}while(e!==0);return true},indexBefore:function(c){if(c===0)return-1;c--;var d=this._content,e=this.get("max"),f=this.rangeStartForIndex(c);if(!d)return null;for(;f===e||d[f]<0;){if(f===0)return-1;c=f-1;f=this.rangeStartForIndex(c)}return c},
indexAfter:function(c){var d=this._content,e=this.get("max");if(!d||c>=e)return-1;c++;e=this.rangeStartForIndex(c);for(e=d[e];e<0;){if(e===0)return-1;c=e=Math.abs(e);e=d[e]}return c},contains:function(c,d){var e,f;if(d===undefined){if(c===null||c===undefined)return false;if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){if(c===this)return true;c=c._content;d=0;for(e=c[d];e!==0;){if(e>0&&!this.contains(d,e-d))return false;d=Math.abs(e);e=c[d]}return true}else{d=c.length;c=c.start}}e=this.rangeStartForIndex(c);
f=this._content[e];return f>0&&e<=c&&f>=c+d},intersects:function(c,d){var e,f,g;if(d===undefined)if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){if(c===this)return true;e=c._content;f=0;for(g=e[f];g!==0;){if(g>0&&this.intersects(f,g-f))return true;f=Math.abs(g);g=e[f]}return false}else{d=c.length;c=c.start}f=this.rangeStartForIndex(c);e=this._content;g=e[f];for(d=c+d;f<d;){if(g===0)return false;if(g>0&&g>c)return true;f=Math.abs(g);g=e[f]}return false},without:function(c,d){if(c===this)return b.IndexSet.create();
return this.clone().remove(c,d)},replace:function(c,d){if(d===undefined)if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){this._content=this._sc_sliceContent(c._content);this.beginPropertyChanges().set("max",c.max).set("length",c.length).set("source",c.source).enumerableContentDidChange().endPropertyChanges();return this}else{d=c.length;c=c.start}this._content.length=1;this.length=this.max=this._content[0]=0;return this.add(c,d)},add:function(c,d){if(this.isFrozen)throw b.FROZEN_ERROR;var e,f,
g;if(c&&c.isIndexSet){e=c._content;if(!e)return this;f=0;for(g=e[0];g!==0;){g>0&&this.add(f,g-f);f=g<0?0-g:g;g=e[f]}return this}else if(d===undefined)if(c===null||c===undefined)return this;else if(typeof c===b.T_NUMBER)d=1;else{d=c.length;c=c.start}else if(d===null)d=1;if(d<=0)return this;var h=this.get("max"),i=h,j;e=this._content;if(c===h){if(c>0){f=this.rangeStartForIndex(c-1);g=e[f];if(g>0){delete e[h];e[f]=h=c+d;c=f}else e[h]=h=c+d}else e[c]=h=d;e[h]=0;this.set("max",h);this.set("length",this.length+
d);d=h-c}else if(c>h){e[h]=0-c;e[c]=c+d;e[c+d]=0;this.set("max",c+d);this.set("length",this.length+d);d=c+d-h;c=h}else{f=this.rangeStartForIndex(c);g=e[f];h=c+d;j=0;if(c>0&&f===c&&g<=0){f=this.rangeStartForIndex(c-1);g=e[f]}if(g<0){e[f]=0-c;if(Math.abs(g)>h){e[c]=0-h;e[h]=g}else e[c]=g}else{c=f;if(g>h)h=g}for(f=c;f<h;){d=e[f];if(d===0){e[h]=0;g=h;j+=h-f}else{g=Math.abs(d);if(g>h){e[h]=d;g=h}if(d<0)j+=g-f}delete e[f];f=g}if((f=e[h])>0){delete e[h];h=f}e[c]=h;h>i&&this.set("max",h);this.set("length",
this.get("length")+j);d=h-c}this._hint(c,d);j!==0&&this.enumerableContentDidChange();return this},remove:function(c,d){if(this.isFrozen)throw b.FROZEN_ERROR;if(d===undefined)if(c===null||c===undefined)return this;else if(typeof c===b.T_NUMBER)d=1;else if(c.isIndexSet){c.forEachRange(this.remove,this);return this}else{d=c.length;c=c.start}if(d<=0)return this;var e=this.get("max"),f=this._content,g,h,i;if(c>=e)return this;e=this.rangeStartForIndex(c);g=f[e];i=c+d;h=0;if(c>0&&e===c&&g>0){e=this.rangeStartForIndex(c-
1);g=f[e]}if(g>0){f[e]=c;if(g>i){f[c]=i;f[i]=g}else f[c]=g}else{c=e;g=Math.abs(g);if(g>i)i=g}for(e=c;e<i;){d=f[e];if(d===0){f[i]=0;g=i}else{g=Math.abs(d);if(g>i){f[i]=d;g=i}if(d>0)h+=g-e}delete f[e];e=g}if((e=f[i])<0){delete f[i];i=Math.abs(e)}if(f[i]===0){delete f[i];f[c]=0;this.set("max",c)}else f[c]=0-i;this.set("length",this.get("length")-h);d=i-c;this._hint(c,d);h!==0&&this.enumerableContentDidChange();return this},_hint:function(c,d,e){if(e===undefined)e=this._content;var f=b.IndexSet.HINT_SIZE,
g=Math.abs(e[c]),h=c-c%f+f;for(d=c+d;h<d;){for(;g!==0&&g<=h;){c=g;g=Math.abs(e[c])}if(g===0)delete e[h];else if(h!==c)e[h]=c;h+=f}},clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;var c=this.length;this._content.length=1;this._content[0]=0;this.set("length",0).set("max",0);c>0&&this.enumerableContentDidChange()},addEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;this.beginPropertyChanges();var d=c.get("length");if(c.isSCArray)for(;--d>=0;)this.add(c.objectAt(d));else c.isEnumerable&&
c.forEach(function(e){this.add(e)},this);this.endPropertyChanges();return this},removeEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;this.beginPropertyChanges();var d=c.get("length");if(c.isSCArray)for(;--d>=0;)this.remove(c.objectAt(d));else c.isEnumerable&&c.forEach(function(e){this.remove(e)},this);this.endPropertyChanges();return this},clone:function(){return b.IndexSet.create(this)},inspect:function(){var c=this._content,d=c.length,e=0,f=[],g;for(e=0;e<d;e++){g=c[e];g!==undefined&&f.push("%@:%@".fmt(e,
g))}return"SC.IndexSet<%@>".fmt(f.join(" , "))},forEachRange:function(c,d){var e=this._content,f=0,g=e[f],h=this.source;if(d===undefined)d=null;for(;g!==0;){g>0&&c.call(d,f,g-f,this,h);f=Math.abs(g);g=e[f]}return this},forEachIn:function(c,d,e,f){var g=this._content,h=0,i=0;d=c+d;var j=this.source,k=g[h];if(f===undefined)f=null;for(;k!==0;){if(h<c)h=c;for(;h<k&&h<d;)e.call(f,h++,i++,this,j);if(h>=d)h=k=0;else{h=Math.abs(k);k=g[h]}}return this},lengthIn:function(c,d){var e=0;if(d===undefined)if(c===
null||c===undefined)return 0;else if(typeof c===b.T_NUMBER)d=1;else if(c.isIndexSet){c.forEachRange(function(i,j){e+=this.lengthIn(i,j)},this);return e}else{d=c.length;c=c.start}if(this.get("length")===0)return 0;var f=this._content,g=0,h=f[g];for(c=c+d;g<c&&h!==0;){if(h>0)e+=h>c?c-g:h-g;g=Math.abs(h);h=f[g]}return e},source:null,indexOf:function(c){var d=this.source;if(!d)throw"%@.indexOf() requires source".fmt(this);var e=d.get("length"),f=this._content;for(f=f[0]<0?Math.abs(f[0]):0;f>=0&&f<e;){f=
d.indexOf(c,f);if(f<0)return-1;if(this.contains(f))return f;f=f+1}return-1},lastIndexOf:function(c){var d=this.source;if(!d)throw"%@.lastIndexOf() requires source".fmt(this);var e=d.get("length"),f=this.max-1;if(f>=e)f=e-1;for(;f>=0;){e=d.lastIndexOf(c,f);if(e<0)return-1;if(this.contains(e))return e;f=e+1}return-1},forEachObject:function(c,d){var e=this.source;if(!e)throw"%@.forEachObject() requires source".fmt(this);var f=this._content,g=0,h=f[g];if(d===undefined)d=null;for(;h!==0;){for(;g<h;){c.call(d,
e.objectAt(g),g,e,this);g++}g=Math.abs(h);h=f[g]}return this},addObject:function(c,d){var e=this.source;if(!e)throw"%@.addObject() requires source".fmt(this);for(var f=e.get("length"),g=0;g>=0&&g<f;){g=e.indexOf(c,g);if(g>=0){this.add(g);if(d)return this;g=g++}else return this}return this},addObjects:function(c,d){c.forEach(function(e){this.addObject(e,d)},this);return this},removeObject:function(c,d){var e=this.source;if(!e)throw"%@.removeObject() requires source".fmt(this);for(var f=e.get("length"),
g=0;g>=0&&g<f;){g=e.indexOf(c,g);if(g>=0){this.remove(g);if(d)return this;g=g+1}else return this}return this},removeObjects:function(c,d){c.forEach(function(e){this.removeObject(e,d)},this);return this},LOG_OBSERVING:false,forEach:function(c,d){var e=this._content,f=0,g=0,h=this.source,i=e[f];if(d===undefined)d=null;for(;i!==0;){for(;f<i;)c.call(d,f++,g++,this,h);f=Math.abs(i);i=e[f]}return this},nextObject:function(c,d,e){c=this._content;var f=e.next,g=this.get("max");if(d===null)d=f=0;else if(d>=
g){delete e.next;return null}else d++;if(d===f){do{d=Math.abs(f);f=c[d]}while(f<0);e.next=f}return d},toString:function(){var c=[];this.forEachRange(function(d,e){c.push(e===1?d:"%@..%@".fmt(d,d+e-1))},this);return"SC.IndexSet<%@>".fmt(c.join(","))},max:0});b.IndexSet.slice=b.IndexSet.copy=b.IndexSet.clone;b.IndexSet.EMPTY=b.IndexSet.create().freeze()});
tiki.module("sproutcore/runtime:system/logger",function(){SC.LOGGER_LOG_DELIMITER=", ";SC.LOGGER_LOG_ERROR="ERROR: ";SC.LOGGER_LOG_INFO="INFO: ";SC.LOGGER_LOG_WARN="WARNING: ";SC.LOGGER_LOG_DEBUG="DEBUG: ";SC.Logger=SC.Object.create({debugEnabled:false,exists:function(){return typeof this.get("reporter")!=="undefined"&&this.get("reporter")!=null}.property("reporter").cacheable(),fallBackOnAlert:false,fallBackOnLog:true,format:true,reporter:console,log:function(){var a=this.get("reporter");if(this.get("exists")&&
typeof a.log==="function"){this.get("format")?a.log(this._argumentsToString.apply(this,arguments)):a.log.apply(a,arguments);return true}else if(this.fallBackOnAlert){var b=this.get("format")?this._argumentsToString.apply(this,arguments):arguments;this.get("exists")&&typeof a.alert==="function"?a.alert(b):alert(b);return true}return false},debug:function(){var a=this.get("reporter");if(this.get("debugEnabled")!==true)return false;if(this.get("exists")&&typeof a.debug==="function"){a.debug.apply(a,
arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_DEBUG);return this.log.apply(this,a)}return false},dir:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.dir==="function"){a.dir.apply(a,arguments);return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},dirxml:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.dirxml==="function"){a.dirxml.apply(a,
arguments);return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},error:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.error==="function"){a.error.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_ERROR);return this.log.apply(this,a)}return false},group:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.group==="function"){b.group(a);return true}return false},
groupEnd:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.groupEnd==="function"){a.groupEnd();return true}return false},info:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.info==="function"){a.info.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_INFO);return this.log.apply(this,a)}return false},profile:function(){var a=this.get("reporter");if(this.get("exists")&&
typeof a.profile==="function"){a.profile();return true}return false},profileEnd:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.profileEnd==="function"){a.profileEnd();return true}return false},time:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.time==="function"){b.time(a);return true}return false},timeEnd:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.timeEnd==="function"){b.timeEnd(a);return true}return false},trace:function(){var a=
this.get("reporter");if(this.get("exists")&&typeof a.trace==="function"){a.trace();return true}return false},warn:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.warn==="function"){a.warn.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_WARN);return this.log.apply(this,a)}return false},_argumentsToArray:function(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b},
_argumentsToString:function(){for(var a="",b=0;b<arguments.length-1;b++)a+=arguments[b]+SC.LOGGER_LOG_DELIMITER;a+=arguments[arguments.length-1];return a}})});
tiki.module("sproutcore/runtime:system/object",function(a){function b(){if(!c._object_foundObjectClassNames){c._object_foundObjectClassNames=true;var d=[],e=function(f,g,h){h--;if(!(d.indexOf(g)>=0)){d.push(g);for(var i in g)if(i!="__scope__")if(i!="superclass")if(i.match(/^[A-Z0-9]/)){var j=f?[f,i].join("."):i,k=g[i];switch(c.typeOf(k)){case c.T_CLASS:if(!k._object_className)k._object_className=j;h>=0&&e(j,k,h);break;case c.T_OBJECT:h>=0&&e(j,k,h);break;case c.T_HASH:if((f||j==="SC")&&h>=0)e(j,k,
h);break;default:break}}}};e(null,a("system","default").global,2)}}var c=a("core");a("mixins/observable");a("system/set");c.BENCHMARK_OBJECTS=false;c._object_extend=function(d,e){if(!e)throw"SC.Object.extend expects a non-null value.  Did you forget to 'sc_require' something?  Or were you passing a Protocol to extend() as if it were a mixin?";d._kvo_cloned=null;var f,g,h,i=d.concatenatedProperties,j=c.K,k,l;g=i?i.length:0;for(var m=g>0?{}:null;--g>=0;){f=i[g];k=d[f];l=e[f];if(k){k instanceof Array||
(k=c.$A(k));m[f]=l?k.concat(l):l}else{l instanceof Array||(l=c.$A(l));m[f]=l}}g=d._bindings;i=false;k=d._observers;l=false;var o=d._properties,r=false,w,p,s,v=d.outlets,t=false;if(e.outlets){v=(v||c.EMPTY_ARRAY).concat(e.outlets);t=true}for(f in e)if(f!=="_kvo_cloned")if(e.hasOwnProperty(f)){var z=(m.hasOwnProperty(f)?m[f]:null)||e[f];if(f.slice(-7)==="Binding"){if(!i){g=(g||c.EMPTY_ARRAY).slice();i=true}if(g===null)g=(d._bindings||c.EMPTY_ARRAY).slice();g[g.length]=f}else if(z&&z instanceof Function){if(!z.superclass&&
z!==(h=d[f]))z.superclass=z.base=h||j;if(z.propertyPaths){if(!l){k=(k||c.EMPTY_ARRAY).slice();l=true}k[k.length]=f}else if(w=z.localPropertyPaths)for(p=w.length;--p>=0;){s=d._kvo_for(c.keyFor("_kvo_local",w[p]),c.Set);s.add(f);d._kvo_for("_kvo_observed_keys",c.CoreSet).add(w[p])}else if(z.dependentKeys){if(!r){o=(o||c.EMPTY_ARRAY).slice();r=true}o[o.length]=f}else if(z.autoconfiguredOutlet){if(!t){v=(v||c.EMPTY_ARRAY).slice();t=true}v[v.length]=f}}d[f]=z}if(e.hasOwnProperty("toString")){f="toString";
z=(m.hasOwnProperty(f)?m[f]:null)||e[f];if(!z.superclass&&z!==(h=d[f]))z.superclass=z.base=h||j;d[f]=z}d._bindings=g||[];d._observers=k||[];d._properties=o||[];d.outlets=v||[];return d};c.Object=function(d){return this._object_init(d)};c.mixin(c.Object,{mixin:function(){var d=arguments.length,e;for(e=0;e<d;e++)c.mixin(this,arguments[e]);return this},superclass:null,extend:function(){var d=c.BENCHMARK_OBJECTS;d&&c.Benchmark.start("SC.Object.extend");var e,f=function(i){return this._object_init(i)};
for(e in this)if(this.hasOwnProperty(e))f[e]=this[e];if(this.hasOwnProperty("toString"))f.toString=this.toString;f.superclass=this;c.generateGuid(f);f.subclasses=c.Set.create();this.subclasses.add(f);e=f.prototype=c.beget(this.prototype);var g,h=arguments.length;for(g=0;g<h;g++)c._object_extend(e,arguments[g]);e.constructor=f;d&&c.Benchmark.end("SC.Object.extend");return f},create:function(){return new this(arguments)},isClass:true,subclasses:c.Set.create(),toString:function(){return c._object_className(this)},
subclassOf:function(d){if(this===d)return false;for(var e=this;e=e.superclass;)if(e===d)return true;return false},hasSubclass:function(d){return d&&d.subclassOf?d.subclassOf(this):false},kindOf:function(d){return this===d||this.subclassOf(d)}});c.Object.prototype={_kvo_enabled:true,_object_init:function(d){var e,f=d?d.length:0;for(e=0;e<f;e++)c._object_extend(this,d[e]);c.generateGuid(this);this.init();f=(d=this.initMixin)?d.length:0;for(e=0;e<f;e++)d[e].call(this);return this},mixin:function(){var d,
e=arguments.length;for(d=0;d<e;d++)c.mixin(this,arguments[d]);for(d=0;d<e;d++){var f=arguments[d].initMixin;f&&f.call(this)}return this},init:function(){this.initObservable();return this},isDestroyed:false,destroy:function(){if(this.get("isDestroyed"))return this;this.set("isDestroyed",true);var d,e=this.destroyMixin,f=e?e.length:0;for(d=0;d<f;d++)e[d].call(this);return this},isObject:true,respondsTo:function(d){return c.typeOf(this[d])===c.T_FUNCTION},tryToPerform:function(d,e,f){return this.respondsTo(d)&&
this[d](e,f)!==false},superclass:function(){var d=arguments.callee.caller;if(!d)throw"superclass cannot determine the caller method";return d.superclass?d.superclass.apply(this,arguments):null},instanceOf:function(d){return this.constructor===d},kindOf:function(d){return this.constructor.kindOf(d)},toString:function(){if(!this._object_toString){var d=c._object_className(this.constructor),e="%@:%@".fmt(d,c.guidFor(this));if(d)this._object_toString=e;else return e}return this._object_toString},awake:function(){this.outlets.forEach(function(d){this.get(d)},
this);this.bindings.invoke("sync")},invokeOnce:function(d){c.RunLoop.currentRunLoop.invokeOnce(this,d);return this},invokeLast:function(d){c.RunLoop.currentRunLoop.invokeLast(this,d);return this},concatenatedProperties:["concatenatedProperties","initMixin","destroyMixin"]};c.Object.prototype.constructor=c.Object;c.mixin(c.Object.prototype,c.Observable);c.instanceOf=function(d,e){return!!(d&&d.constructor===e)};c.kindOf=function(d,e){if(d&&!d.isClass)d=d.constructor;return!!(d&&d.kindOf&&d.kindOf(e))};
c._object_className=function(d){if(!c.isReady)return"";d._object_className||b();if(d._object_className)return d._object_className;for(d=d;d&&!d._object_className;)d=d.superclass;return d&&d._object_className?d._object_className:"Anonymous"}});
tiki.module("sproutcore/runtime:system/range_observer",function(a){var b=a("core");a("private/observer_queue");a("system/index_set");b.RangeObserver={isRangeObserver:true,toString:function(){return(this.indexes?this.indexes.toString():"SC.IndexSet<..>").replace("IndexSet","RangeObserver(%@)".fmt(b.guidFor(this)))},create:function(c,d,e,f,g,h){var i=b.beget(this);i.source=c;i.indexes=d?d.frozenCopy():null;i.target=e;i.method=f;i.context=g;i.isDeep=h||false;i.beginObserving();return i},extend:function(){var c=
b.beget(this),d=arguments,e=d.length,f;for(f=0;f<e;f++)b.mixin(c,d[f]);return c},destroy:function(){this.endObserving();return this},update:function(c,d){if(this.indexes&&this.indexes.isEqual(d))return this;this.indexes=d?d.frozenCopy():null;this.endObserving().beginObserving();return this},beginObserving:function(){if(!this.isDeep)return this;var c=this.observing;if(!c)c=this.observing=b.CoreSet.create();var d=this._beginObservingForEach;if(!d)d=this._beginObservingForEach=function(e){if((e=this.source.objectAt(e))&&
e.addObserver){c.push(e);e._kvo_needsRangeObserver=true}};this.indexes.forEach(d,this);this.isObserving=false;b.Observers.addPendingRangeObserver(this);return this},setupPending:function(c){var d=this.observing;if(this.isObserving||!d||d.get("length")===0)return true;if(d.contains(c)){this.isObserving=true;c=this._setupPendingForEach;if(!c){var e=this.objectPropertyDidChange;c=this._setupPendingForEach=function(f){var g=this.source.objectAt(f),h=b.guidFor(g);if(g&&g.addObserver){d.push(g);g.addObserver("*",
this,e);g=this[h];if(g===undefined||g===null)this[h]=f;else if(g.isIndexSet)g.add(f);else this[h]=b.IndexSet.create(g).add(f)}}}this.indexes.forEach(c,this);return true}else return false},endObserving:function(){if(!this.isDeep)return this;var c=this.observing;if(this.isObserving){var d=this.objectPropertyDidChange,e,f,g;if(c){f=c.length;for(e=0;e<f;e++){g=c[e];g.removeObserver("*",this,d);this[b.guidFor(g)]=null}c.length=0}this.isObserving=false}c&&c.clear();return this},rangeDidChange:function(c){var d=
this.indexes;if(!c||!d||d.intersects(c)){this.endObserving();this.method.call(this.target,this.source,null,"[]",c,this.context);this.beginObserving()}return this},objectPropertyDidChange:function(c,d,e,f){e=this.context;var g=this.method,h=b.guidFor(c),i=this[h];if(i&&!i.isIndexSet)i=this[h]=b.IndexSet.create(i).freeze();e?g.call(this.target,this.source,c,d,i,e,f):g.call(this.target,this.source,c,d,i,f)}}});
tiki.module("sproutcore/runtime:system/run_loop",function(a){var b=a("core");a("private/observer_set");a("system/object");b.RunLoop=b.Object.extend({beginRunLoop:function(){this._start=(new Date).getTime();if(b.LOG_BINDINGS||b.LOG_OBSERVERS)console.log("-- SC.RunLoop.beginRunLoop at %@".fmt(this._start));return this},endRunLoop:function(){var c;if(b.LOG_BINDINGS||b.LOG_OBSERVERS)console.log("-- SC.RunLoop.endRunLoop ~ flushing application queues");do(c=this.flushApplicationQueues())||(c=this._flushinvokeLastQueue());
while(c);this._start=null;if(b.LOG_BINDINGS||b.LOG_OBSERVERS)console.log("-- SC.RunLoop.endRunLoop ~ End");return this},invokeOnce:function(c,d){if(d===undefined){d=c;c=this}if(b.typeOf(d)===b.T_STRING)d=c[d];if(!this._invokeQueue)this._invokeQueue=b.ObserverSet.create();this._invokeQueue.add(c,d);return this},invokeLast:function(c,d){if(d===undefined){d=c;c=this}if(b.typeOf(d)===b.T_STRING)d=c[d];if(!this._invokeLastQueue)this._invokeLastQueue=b.ObserverSet.create();this._invokeLastQueue.add(c,d);
return this},flushApplicationQueues:function(){var c=false,d=this._invokeQueue;if(d&&d.targets>0){this._invokeQueue=null;c=true;d.invokeMethods()}return b.Binding.flushPendingChanges()||c},_flushinvokeLastQueue:function(){var c=this._invokeLastQueue,d=false;if(c&&c.targets>0){this._invokeLastQueue=null;(d=true)&&c.invokeMethods()}return d}});b.RunLoop.currentRunLoop=null;b.RunLoop.runLoopClass=b.RunLoop;b.RunLoop.begin=function(){var c=this.currentRunLoop;if(!c)c=this.currentRunLoop=this.runLoopClass.create();
c.beginRunLoop();return this};b.RunLoop.end=function(){var c=this.currentRunLoop;if(!c)throw"SC.RunLoop.end() called outside of a runloop!";c.endRunLoop();return this};b.run=function(c,d){b.RunLoop.begin();c.call(d);b.RunLoop.end()}});
tiki.module("sproutcore/runtime:system/selection_set",function(a){var b=a("core");a("system/object");a("mixins/enumerable");a("mixins/copyable");a("mixins/freezable");a("system/set");a("system/index_set");b.SelectionSet=b.Object.extend(b.Enumerable,b.Freezable,b.Copyable,{isSelectionSet:true,length:function(){var c=0,d=this._sets,e=this._objects;if(e)c+=e.get("length");d&&d.forEach(function(f){c+=f.get("length")});return c}.property().cacheable(),sources:function(){var c=[],d=this._sets,e=d?d.length:
0,f,g;for(f=0;f<e;f++)(g=d[f])&&g.get("length")>0&&g.source&&c.push(g.source);return c}.property().cacheable(),indexSetForSource:function(c){if(!c||!c.isSCArray)return null;var d=this._indexSetCache,e=this._objects,f,g;if(!d)d=this._indexSetCache={};if((f=d[b.guidFor(c)])&&f._sourceRevision&&f._sourceRevision!==c.propertyRevision)f=null;if(!f){if((f=this._indexSetForSource(c,false))&&f.get("length")===0)f=null;if(e){if(f)f=f.copy();e.forEach(function(h){if((g=c.indexOf(h))>=0){f||(f=b.IndexSet.create());
f.add(g)}},this)}if(f){f=d[b.guidFor(c)]=f.frozenCopy();f._sourceRevision=c.propertyRevision}}return f},_indexSetForSource:function(c,d){if(d===undefined)d=true;var e=b.guidFor(c),f=this[e],g=this._sets,h=g?g.length:0,i=null;if(f>=h)f=null;if(b.none(f)){if(d&&!this.isFrozen){this.propertyWillChange("sources");if(!g)g=this._sets=[];i=g[h]=b.IndexSet.create();i.source=c;this[e]=h;this.propertyDidChange("sources")}}else i=g?g[f]:null;return i},add:function(c,d,e){if(this.isFrozen)throw b.FROZEN_ERROR;
var f,g,h;if(d===undefined&&e===undefined){if(!c)throw"Must pass params to SC.SelectionSet.add()";if(c.isIndexSet)return this.add(c.source,c);if(c.isSelectionSet){d=c._sets;g=c._objects;e=d?d.length:0;this.beginPropertyChanges();for(f=0;f<e;f++)(c=d[f])&&c.get("length")>0&&this.add(c.source,c);g&&this.addObjects(g);this.endPropertyChanges();return this}}c=this._indexSetForSource(c,true);f=this.get("length");h=c.get("length");g=f-h;c.add(d,e);this._indexSetCache=null;g+=c.get("length");if(g!==f){this.propertyDidChange("length");
this.enumerableContentDidChange();h===0&&this.notifyPropertyChange("sources")}return this},remove:function(c,d,e){if(this.isFrozen)throw b.FROZEN_ERROR;var f,g,h,i,j;if(d===undefined&&e===undefined){if(!c)throw"Must pass params to SC.SelectionSet.remove()";if(c.isIndexSet)return this.remove(c.source,c);if(c.isSelectionSet){f=c._sets;j=c._objects;e=f?f.length:0;this.beginPropertyChanges();for(g=0;g<e;g++)(h=f[g])&&h.get("length")>0&&this.remove(h.source,h);j&&this.removeObjects(j);this.endPropertyChanges();
return this}}h=this._indexSetForSource(c,true);f=this.get("length");i=f-h.get("length");if(h&&(j=this._objects)){if(e!==undefined){d=b.IndexSet.create(d,e);e=undefined}j.forEach(function(k){g=c.indexOf(k);if(d.contains(g)){j.remove(k);i--}},this)}h.remove(d,e);h=h.get("length");i+=h;this._indexSetCache=null;if(i!==f){this.propertyDidChange("length");this.enumerableContentDidChange();h===0&&this.notifyPropertyChange("sources")}return this},contains:function(c,d,e){if(d===undefined&&e===undefined)return this.containsObject(c);
c=this.indexSetForSource(c);if(!c)return false;return c.contains(d,e)},intersects:function(c,d,e){c=this.indexSetForSource(c,false);if(!c)return false;return c.intersects(d,e)},_TMP_ARY:[],addObject:function(c){var d=this._TMP_ARY;d[0]=c;c=this.addObjects(d);d.length=0;return c},addObjects:function(c){var d=this._objects,e;if(!d)d=this._objects=b.CoreSet.create();e=d.get("length");d.addEach(c);c=d.get("length");this._indexSetCache=null;if(c!==e){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},
removeObject:function(c){var d=this._TMP_ARY;d[0]=c;c=this.removeObjects(d);d.length=0;return c},removeObjects:function(c){var d=this._objects,e,f;if(!d)return this;e=d.get("length");d.removeEach(c);f=d.get("length");if(d=this._sets)d.forEach(function(g){e+=g.get("length");g.removeObjects(c);f+=g.get("length")},this);this._indexSetCache=null;if(f!==e){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},containsObject:function(c){var d=this._objects;if(d&&d.contains(c))return true;
var e=(d=this._sets)?d.length:0,f,g;for(f=0;f<e;f++)if((g=d[f])&&g.indexOf(c)>=0)return true;return false},constrain:function(c){var d,e,f;this.beginPropertyChanges();this.get("sources").forEach(function(g){if(g!==c)(g=this._indexSetForSource(c,false))&&this.remove(c,g)},this);if((d=this._indexSetForSource(c,false))&&(f=d.get("max"))>(e=c.get("length")))this.remove(c,e,f-e);if(d=this._objects)d.forEach(function(g){c.indexOf(g)<0&&this.removeObject(g)},this);this.endPropertyChanges();return this},
isEqual:function(c){var d,e,f,g;if(!c||!c.isSelectionSet)return false;if(c===this)return true;if(this._sets===c._sets&&this._objects===c._objects)return true;if(this.get("length")!==c.get("length"))return false;d=this._objects;e=c._objects;if(d||e){if((d?d.get("length"):0)!==(e?e.get("length"):0))return false;if(d&&!d.isEqual(e))return false}g=this.get("sources");f=g.get("length");for(c=0;c<f;c++){e=g.objectAt(c);d=this._indexSetForSource(e,false);e=this._indexSetForSource(e,false);if(!!e!==!!d)return false;
if(d&&!d.isEqual(e))return false}return true},clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;if(this._sets)this._sets.length=0;if(this._objects)this._objects=null;this._indexSetCache=null;this.propertyDidChange("length");this.enumerableContentDidChange();this.notifyPropertyChange("sources");return this},copy:function(){var c=this.constructor.create(),d=this._sets,e=d?d.length:0,f,g;if(d&&e>0){d=c._sets=d.slice();for(f=0;f<e;f++)if(g=d[f]){g=d[f]=g.copy();c[b.guidFor(g.source)]=f}}if(this._objects)c._objects=
this._objects.copy();return c},freeze:function(){if(this.isFrozen)return this;for(var c=this._sets,d=c?c.length:0,e;--d>=0;)if(e=c[d])e.freeze();this._objects&&this._objects.freeze();return arguments.callee.base.apply(this,arguments)},toString:function(){var c=this._sets||[];c=c.map(function(d){return d.toString().replace("SC.IndexSet",b.guidFor(d.source))},this);this._objects&&c.push(this._objects.toString());return"SC.SelectionSet:%@<%@>".fmt(b.guidFor(this),c.join(","))},firstObject:function(){var c=
this._sets,d=this._objects;if(c&&c.get("length")>0){var e=c?c[0]:null;c=e?e.source:null;e=e?e.firstObject():-1;if(c&&e>=0)return c.objectAt(e)}return d?d.firstObject():undefined}.property(),nextObject:function(c,d,e){var f;if(c===0){f=e.objects=[];this.forEach(function(g){f.push(g)},this);e.max=f.length}f=e.objects;d=f[c];if(c+1>=e.max)e.objects=e.max=null;return d},forEach:function(c,d){var e=this._sets,f=this._objects,g=e?e.length:0,h,i;for(i=0;i<g;i++)(h=e[i])&&h.forEachObject(c,d);f&&f.forEach(c,
d);return this}});b.SelectionSet.prototype.clone=b.SelectionSet.prototype.copy;b.SelectionSet.EMPTY=b.SelectionSet.create().freeze()});
tiki.module("sproutcore/runtime:system/set",function(a){var b=a("core");a("mixins/enumerable");a("mixins/copyable");a("mixins/freezable");a("mixins/observable");b.Set=b.mixin({},b.Enumerable,b.Observable,b.Freezable,{create:function(c){var d,e;e=b.Set._pool;var f=this.isObservable;if(!f&&c===undefined&&e.length>0)d=e.pop();else{d=b.beget(this);f&&d.initObservable();if(c&&c.isEnumerable&&c.get("length")>0){d.isObservable=false;if(c.isSCArray)for(e=c.get?c.get("length"):c.length;--e>=0;)d.add(c.objectAt(e));
else if(c.isSet)for(e=c.length;--e>=0;)d.add(c[e]);else c.forEach(function(g){d.add(g)},this);d.isObservable=f}}return d},isSet:true,length:0,firstObject:function(){return this.length>0?this[0]:undefined}.property(),clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;this.length=0;return this},contains:function(c){if(c===null)return false;var d=this[b.hashFor(c)];return!b.none(d)&&d<this.length&&this[d]===c},isEqual:function(c){if(!c||!c.isSet||c.get("length")!==this.get("length"))return false;
for(var d=this.get("length");--d>=0;)if(!c.contains(this[d]))return false;return true},add:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(c===null||c===undefined)return this;var d=b.hashFor(c),e=this[d],f=this.length;if(e===null||e===undefined||e>=f||this[e]!==c){this[f]=c;this[d]=f;this.length=f+1}this.isObservable&&this.enumerableContentDidChange();return this},addEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(!c||!c.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);
var d,e=this.isObservable;e&&this.beginPropertyChanges();if(c.isSCArray)for(d=c.get("length");--d>=0;)this.add(c.objectAt(d));else if(c.isSet)for(d=c.length;--d>=0;)this.add(c[d]);else c.forEach(function(f){this.add(f)},this);e&&this.endPropertyChanges();return this},remove:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(b.none(c))return this;var d=b.hashFor(c),e=this[d],f=this.length;if(b.none(e)||e>=f||this[e]!==c)return this;delete this[d];if(e<f-1){c=this[e]=this[f-1];this[b.hashFor(c)]=
e}this.length=f-1;this.isObservable&&this.enumerableContentDidChange();return this},pop:function(){if(this.isFrozen)throw b.FROZEN_ERROR;var c=this.length>0?this[this.length-1]:null;c&&this.remove(c);return c},removeEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(!c||!c.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);var d,e=this.isObservable;e&&this.beginPropertyChanges();if(c.isSCArray)for(d=c.get("length");--d>=0;)this.remove(c.objectAt(d));else if(c.isSet)for(d=c.length;--d>=
0;)this.remove(c[d]);else c.forEach(function(f){this.remove(f)},this);e&&this.endPropertyChanges();return this},copy:function(){return this.constructor.create(this)},destroy:function(){this.isFrozen=false;this.isObservable||b.Set._pool.push(this.clear());return this},forEach:function(c,d){var e=this.length;d||(d=this);for(var f=0;f<e;f++)c.call(d,this[f],f,this);return this},toString:function(){var c=this.length,d,e=[];for(d=0;d<c;d++)e[d]=this[d];return"SC.Set<%@>".fmt(e.join(","))},_pool:[],isObservable:true});
b.Set.constructor=b.Set;b.Set.clone=b.Set.copy;b.Set.push=b.Set.unshift=b.Set.add;b.Set.shift=b.Set.pop;b.Set.addObject=b.Set.add;b.Set.removeObject=b.Set.remove;b.Set._pool=[];b.CoreSet=b.beget(b.Set);b.CoreSet.isObservable=false;b.CoreSet.constructor=b.CoreSet});
tiki.module("sproutcore/runtime:system/sparse_array",function(a){var b=a("core");a("system/index_set");a("system/object");a("mixins/enumerable");a("mixins/array");a("mixins/delegate_support");b.SparseArray=b.Object.extend(b.Enumerable,b.Array,b.DelegateSupport,{_requestingLength:0,_requestingIndex:0,length:function(){var c=this.delegate;if(c&&b.none(this._length)&&c.sparseArrayDidRequestLength){this._requestingLength++;c.sparseArrayDidRequestLength(this);this._requestingLength--}return this._length||
0}.property().cacheable(),provideLength:function(c){if(b.none(c))this._sa_content=null;if(c!==this._length){this._length=c;this._requestingLength<=0&&this.enumerableContentDidChange()}return this},rangeWindowSize:1,requestedRangeIndex:[],objectAt:function(c){var d=this._sa_content,e;if(!d)d=this._sa_content=[];if((e=d[c])===undefined){this.requestIndex(c);e=d[c]}return e},definedIndexes:function(c){var d=b.IndexSet.create(),e=this._sa_content,f;if(!e)return d.freeze();if(c)c.forEach(function(g){e[g]!==
undefined&&d.add(g)});else{f=e.length;for(c=0;c<f;c++)e[c]!==undefined&&d.add(c)}return d.freeze()},_TMP_RANGE:{},requestIndex:function(c){var d=this.delegate;if(!d)return this;var e=this.get("rangeWindowSize");c=c;if(e>1)c-=Math.floor(c%e);if(e<1)e=1;this._requestingIndex++;if(d.sparseArrayDidRequestRange){var f=this._TMP_RANGE;if(this.wasRangeRequested(c)===-1){f.start=c;f.length=e;d.sparseArrayDidRequestRange(this,f);this.requestedRangeIndex.push(c)}}else if(d.sparseArrayDidRequestIndex)for(;--e>=
0;)d.sparseArrayDidRequestIndex(this,c+e);this._requestingIndex--;return this},wasRangeRequested:function(c){var d,e;d=0;for(e=this.requestedRangeIndex.length;d<e;d++)if(this.requestedRangeIndex[d]===c)return d;return-1},rangeRequestCompleted:function(c){c=this.wasRangeRequested(c);if(c>=0){this.requestedRangeIndex.removeAt(c,1);return true}return false},provideObjectsInRange:function(c,d){var e=this._sa_content;if(!e)e=this._sa_content=[];var f=c.start;for(c=c.length;--c>=0;)e[f+c]=d[c];this._requestingIndex<=
0&&this.enumerableContentDidChange();return this},_TMP_PROVIDE_ARRAY:[],_TMP_PROVIDE_RANGE:{length:1},provideObjectAtIndex:function(c,d){var e=this._TMP_PROVIDE_ARRAY,f=this._TMP_PROVIDE_RANGE;e[0]=d;f.start=c;return this.provideObjectsInRange(f,e)},objectsDidChangeInRange:function(c){var d=this._sa_content;if(d)if(c.start===0&&b.maxRange(c)>=d.length)this._sa_content=null;else for(var e=c.start,f=Math.min(e+c.length,d.length);--f>=e;)d[f]=undefined;this.enumerableContentDidChange(c);return this},
indexOf:function(c){var d=this.delegate;if(d&&d.sparseArrayDidRequestIndexOf)return d.sparseArrayDidRequestIndexOf(this,c);else{d=this._sa_content;if(!d)d=this._sa_content=[];return d.indexOf(c)}},replace:function(c,d,e){e=e||[];var f=this.delegate;if(f)if(!f.sparseArrayShouldReplace||!f.sparseArrayShouldReplace(this,c,d,e))return this;f=this._sa_content;if(!f)f=this._sa_content=[];f.replace(c,d,e);e=(e?e.get?e.get("length"):e.length:0)-d;if(!b.none(this._length)){this.propertyWillChange("length");
this._length+=e;this.propertyDidChange("length")}this.enumerableContentDidChange(c,d,e);return this},reset:function(){this._length=this._sa_content=null;this.enumerableContentDidChange();this.invokeDelegateMethod(this.delegate,"sparseArrayDidReset",this);return this}});b.SparseArray.array=function(c){return this.create({_length:c||0})}});tiki.script("sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js");
tiki.register("sproutcore/datastore",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js",id:"tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js"}]}},depends:["tiki","sproutcore/runtime"],scripts:[{url:"/static/sproutcore/datastore/en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js",
id:"sproutcore/datastore:en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js"}]});tiki.module("sproutcore/datastore:index",function(){});tiki.script("sproutcore/datastore:en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js");
tiki.register("sproutcore/foundation",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js",id:"tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css",
id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css"}],depends:["tiki","sproutcore/runtime"],scripts:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js",id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js"}]});tiki.global("sproutcore/foundation");
SC.Locale=SC.Object.extend({init:function(){this.language||SC.Locale._assignLocales();if(!this.hasStrings){var a=this._deprecatedLanguageCodes||[];a.push(this.language);for(var b=a.length,c=null;!c&&--b>=0;)c=String[a[b]];if(c){this.hasStrings=YES;this.strings=c}}},hasStrings:NO,strings:{},toString:function(){this.language||SC.Locale._assignLocales();return"SC.Locale["+this.language+"]"+SC.guidFor(this)},locWithDefault:function(a,b){return this.strings[a]||b||a}});
SC.Locale.mixin({useAutodetectedLanguage:NO,preferredLanguage:null,createCurrentLocale:function(){var a=String.preferredLanguage!==undefined?String.preferredLanguage:this.preferredLanguage;a=((String.useAutodetectedLanguage!==undefined?String.useAutodetectedLanguage:this.useAutodetectedLanguage)?SC.browser.language:null)||a||SC.browser.language||"en";a=SC.Locale.normalizeLanguage(a);var b=this.localeClassFor(a);if(a!=this.currentLanguage){this.currentLanguage=a;this.currentLocale=b.create()}return this.currentLocale},
localeClassFor:function(a){a=SC.Locale.normalizeLanguage(a);var b,c=this.locales[a];if(!c&&(b=a.split("-")[0])!==a&&(c=this.locales[b]))c=this.locales[a]=c.extend();c||(c=this.locales[a]=this.locales.en.extend());return c},define:function(a,b){var c;if(b===undefined&&SC.typeOf(a)!==SC.T_STRING){c=this;b=a}else c=SC.Locale.localeClassFor(a);SC.mixin(c.prototype,b);return c},options:function(){return this.prototype},addStrings:function(a){var b=this.prototype.strings;if(b){if(!this.prototype.hasOwnProperty("strings"))this.prototype.strings=
SC.clone(b)}else b=this.prototype.strings={};if(a)this.prototype.strings=SC.mixin(b,a);this.prototype.hasStrings=YES;return this},_map:{english:"en",french:"fr",german:"de",japanese:"ja",jp:"ja",spanish:"es"},normalizeLanguage:function(a){if(!a)return"en";return SC.Locale._map[a.toLowerCase()]||a},_assignLocales:function(){for(var a in this.locales)this.locales[a].prototype.language=a},toString:function(){this.prototype.language||SC.Locale._assignLocales();return"SC.Locale["+this.prototype.language+
"]"},extend:function(){var a=SC.Object.extend.apply(this,arguments);a.addStrings=SC.Locale.addStrings;a.define=SC.Locale.define;a.options=SC.Locale.options;a.toString=SC.Locale.toString;return a}});SC.Locale.locales={en:SC.Locale.extend({_deprecatedLanguageCodes:["English"]}),fr:SC.Locale.extend({_deprecatedLanguageCodes:["French"]}),de:SC.Locale.extend({_deprecatedLanguageCodes:["German"]}),ja:SC.Locale.extend({_deprecatedLanguageCodes:["Japanese","jp"]}),es:SC.Locale.extend({_deprecatedLanguageCodes:["Spanish"]})};
SC.stringsFor=function(a,b){SC.Locale.localeClassFor(a).addStrings(b);return this};sc_require("system/locale");SC.stringsFor("English",{"_SC.DateTime.dayNames":"Sunday Monday Tuesday Wednesday Thursday Friday Saturday","_SC.DateTime.abbreviatedDayNames":"Sun Mon Tue Wed Thu Fri Sat","_SC.DateTime.monthNames":"January February March April May June July August September October November December","_SC.DateTime.abbreviatedMonthNames":"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"});SC.DROP_ON=1;
SC.DROP_BEFORE=2;SC.DROP_AFTER=4;SC.DROP_ANY=7;SC.SAFARI_FOCUS_BEHAVIOR=YES;SC.mixin({data:function(a,b,c){a=a===window?"@window":a;a=SC.hashFor(a);var d=SC._data_cache;if(!d)SC._data_cache=d={};var e=d[a];if(b&&!e)d[a]=e={};if(e&&c!==undefined)e[b]=c;return b?e[b]:e},removeData:function(a,b){a=a===window?"@window":a;a=SC.hashFor(a);var c=SC._data_cache;if(c){var d=c[a];if(d){var e=b?d[b]:d;if(b)delete d[b];else delete c[a];return e}}}});
SC.mixin(Function.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=this;if(arguments.length>2){var d=SC.$A(arguments).slice(2,arguments.length);d.unshift(a);var e=this,f=c;c=function(){return f.apply(e,d.slice(1))}}return SC.Timer.schedule({target:a,action:c,interval:b})}});SC.Controller=SC.Object.extend({isEditable:YES});
SC.SelectionSupport={hasSelectionSupport:YES,allowsSelection:YES,allowsMultipleSelection:YES,allowsEmptySelection:YES,firstSelectableObject:function(){return this.get("firstObject")}.property(),selection:function(a,b){var c=(a=this._scsel_selection)?a.get("length"):0,d;if(b===undefined||!this.get("allowsSelection"))b=a;d=b&&b.isEnumerable?b.get("length"):0;if(d>1&&!this.get("allowsMultipleSelection"))if(c>1){b=SC.SelectionSet.create().addObject(a.get("firstObject")).freeze();d=1}else{b=a;d=c}if(d===
0&&!this.get("allowsEmptySelection"))if(c===0){b=(b=this.get("firstSelectableObject"))?SC.SelectionSet.create().addObject(b).freeze():SC.SelectionSet.EMPTY;d=b.get("length")}else{b=a;d=c}if(d===0)b=SC.SelectionSet.EMPTY;return this._scsel_selection=b=b.frozenCopy()}.property("arrangedObjects","allowsEmptySelection","allowsMultipleSelection","allowsSelection").cacheable(),hasSelection:function(){var a=this.get("selection");return!!a&&a.get("length")>0}.property("selection").cacheable(),selectObjects:function(a,
b){if(!a||a.get("length")===0){b||this.set("selection",SC.SelectionSet.EMPTY);return this}var c=this.get("selection");c=b&&c?c.copy():SC.SelectionSet.create();c.addObjects(a).freeze();this.set("selection",c);return this},selectObject:function(a,b){if(a===null){b||this.set("selection",null);return this}else return this.selectObjects([a],b)},deselectObjects:function(a){if(!a||a.get("length")===0)return this;var b=this.get("selection");if(!b||b.get("length")===0)return this;b=b.copy().removeObjects(a).freeze();
this.set("selection",b.freeze());return this},deselectObject:function(a){return a?this.deselectObjects([a]):this},updateSelectionAfterContentChange:function(){var a=this.get("arrangedObjects"),b=this.get("selection"),c=b,d,e;if(c&&a&&c.get("sources").indexOf(a)>=0){d=c.indexSetForSource(a);e=a.get("length");d=d?d.get("max"):0;if(d>e){c=c.copy().remove(a,e,d-e).freeze();this.set("selection",c)}}if(c===b){e=b?b.get("length"):0;d=a?a.get("length"):0;e===0&&!this.get("allowsEmptySelection")&&d>0&&this.notifyPropertyChange("selection")}return this}};
sc_require("controllers/controller");sc_require("mixins/selection_support");
SC.ArrayController=SC.Controller.extend(SC.Array,SC.SelectionSupport,{content:null,isEditable:YES,orderBy:null,allowsSingleContent:YES,destroyOnRemoval:NO,arrangedObjects:function(){return this}.property().cacheable(),canRemoveContent:function(){var a=this.get("content");return a&&this.get("isEditable")&&this.get("hasContent")?!a.isEnumerable||SC.typeOf(a.removeObject)===SC.T_FUNCTION:NO}.property("content","isEditable","hasContent"),canReorderContent:function(){var a=this.get("content");return!!a&&
this.get("isEditable")&&!this.get("orderBy")&&!!a.isSCArray}.property("content","isEditable","orderBy"),canAddContent:function(){var a=this.get("content");return a&&this.get("isEditable")&&a.isEnumerable?SC.typeOf(a.addObject)===SC.T_FUNCTION||SC.typeOf(a.pushObject)===SC.T_FUNCTION:NO}.property("content","isEditable"),hasContent:function(){var a=this.get("content");return!!a&&(!!a.isEnumerable||!!this.get("allowsSingleContent"))}.property("content","allowSingleContent"),status:function(){var a=this.get("content");
return(a=a?a.get("status"):null)?a:SC.Record.READY}.property().cacheable(),addObject:function(a){if(!this.get("canAddContent"))throw"%@ cannot add content".fmt(this);var b=this.get("content");if(b.isSCArray)b.pushObject(a);else if(b.addObject)b.addObject(a);else throw"%@.content does not support addObject".fmt(this);return this},removeObject:function(a){if(!this.get("canRemoveContent"))throw"%@ cannot remove content".fmt(this);var b=this.get("content");b.isEnumerable?b.removeObject(a):this.set("content",
null);this.get("destroyOnRemoval")&&a.destroy&&a.destroy();return this},length:function(){var a=this._scac_observableContent();return a?a.get("length"):0}.property().cacheable(),objectAt:function(a){var b=this._scac_observableContent();return b?b.objectAt(a):undefined},replace:function(a,b,c){if(!c||c.get("length")===0){if(!this.get("canRemoveContent"))throw"%@ cannot remove objects from the current content".fmt(this);}else if(!this.get("canReorderContent"))throw"%@ cannot add or reorder the current content".fmt(this);
var d=this.get("content"),e=[],f;if(this.get("destroyOnRemoval"))for(f=0;f<b;f++)e.push(d.objectAt(f+a));d&&d.replace(a,b,c);f=0;for(a=e.length;f<a;f++)e[f].destroy();return this},indexOf:function(a,b){var c=this._scac_observableContent();return c?c.indexOf(a,b):-1},init:function(){arguments.callee.base.apply(this,arguments);this._scac_contentDidChange()},_scac_cached:NO,_scac_observableContent:function(){var a=this._scac_cached;if(a!==NO)return a;var b=this.get("content"),c,d,e;if(SC.none(b))return this._scac_cached=
[];if(!b.isEnumerable)return this._scac_cached=a=this.get("allowsSingleContent")?[b]:[];c=this.get("orderBy");if(!c)if(b.isSCArray)return this._scac_cached=b;else throw"%@.orderBy is required for unordered content".fmt(this);switch(SC.typeOf(c)){case SC.T_STRING:c=[c];break;case SC.T_FUNCTION:d=c;break;case SC.T_ARRAY:break;default:throw"%@.orderBy must be Array, String, or Function".fmt(this);}if(!d){e=c.get("length");d=function(f,g){var h=0,i=0,j;for(h=0;h<e&&i===0;h++){j=c.objectAt(h);i=f?f.isObservable?
f.get(j):f[j]:f;j=g?g.isObservable?g.get(j):g[j]:g;i=SC.compare(i,j)}return i}}a=[];b.forEach(function(f){a.push(f)});a.sort(d);d=null;return this._scac_cached=a},_scac_contentDidChange:function(){this._scac_cached=NO;var a=this.get("content"),b=!!this.get("orderBy"),c=this._scac_content,d=this._scac_length||0,e=this._scac_rangeObserver,f=this._scac_rangeDidChange,g=this._scac_enumerableDidChange,h=this._scac_contentStatusDidChange;if(c===a)return this;if(c){if(e&&c.isSCArray)c.removeRangeObserver(e);
else c.isEnumerable&&c.removeObserver("[]",this,g);c.removeObserver("status",this,h)}e=null;this._scac_cached=NO;if(this._scac_content=a){if(!b&&a.isSCArray)e=a.addRangeObserver(null,this,f);else a.isEnumerable&&a.addObserver("[]",this,g);b=a.isEnumerable?a.get("length"):1;a.addObserver("status",this,h)}else b=SC.none(a)?0:1;this._scac_rangeObserver=e;this._scac_length=b;this._scac_contentStatusDidChange();this.enumerableContentDidChange(0,b,b-d);this.updateSelectionAfterContentChange()}.observes("content"),
_scac_enumerableDidChange:function(){var a=this.get("content");a=a?a.get("length"):0;var b=this._scac_length;this._scac_length=a;this.beginPropertyChanges();this._scac_cached=NO;this.enumerableContentDidChange(0,a,a-b);this.endPropertyChanges();this.updateSelectionAfterContentChange()}.observes("orderBy"),_scac_rangeDidChange:function(a,b,c,d){if(c==="[]"){this._scac_length=this.get("content").get("length");this._scac_cached=NO;if(d){this.beginPropertyChanges();d.forEachRange(function(e,f){this.enumerableContentDidChange(e,
f,0)},this);this.endPropertyChanges();this.updateSelectionAfterContentChange()}}},_scac_contentStatusDidChange:function(){this.notifyPropertyChange("status")}});sc_require("controllers/controller");
SC.ObjectController=SC.Controller.extend({content:null,allowsMultipleContent:NO,hasContent:function(){return!SC.none(this.get("observableContent"))}.property("observableContent"),isEditable:YES,observableContent:function(){var a=this.get("content"),b,c;if(a&&a.isEnumerable){b=a.get("length");c=this.get("allowsMultipleContent");if(b===1)a=a.firstObject();else if(b===0||!c)a=null;if(a&&!c&&a.isEnumerable)a=null}return a}.property("content","allowsMultipleContent").cacheable(),destroy:function(){var a=
this.get("observableContent");a&&SC.typeOf(a.destroy)===SC.T_FUNCTION&&a.destroy();this.set("content",null);return this},contentPropertyDidChange:function(a,b){b==="*"?this.allPropertiesDidChange():this.notifyPropertyChange(b)},unknownProperty:function(a,b){if(a==="content"){if(b!==undefined)this.content=b;return this.content}var c=this.get("observableContent"),d;if(!(c===null||c===undefined)){if(b===undefined)if(c.isEnumerable){b=c.getEach(a);a=b.get("length");if(a>0){d=YES;for(c=b.objectAt(0);--a>
0&&d;)if(c!==b.objectAt(a))d=NO;if(d)b=c}else b=undefined}else b=c.isObservable?c.get(a):c[a];else{if(!this.get("isEditable"))throw"%@.%@ is not editable".fmt(this,a);if(c.isEnumerable)c.setEach(a,b);else if(c.isObservable)c.set(a,b);else c[a]=b}return b}},init:function(){arguments.callee.base.apply(this,arguments);this.get("observableContent")&&this._scoc_contentDidChange()},_scoc_contentDidChange:function(){var a=this._scoc_observableContent,b=this.get("observableContent"),c=this.contentPropertyDidChange,
d=this._scoc_enumerableContentDidChange;if(a===b)return this;this._scoc_observableContent=b;if(a)if(a.isEnumerable)a.removeObserver("[]",this,d);else a.isObservable&&a.removeObserver("*",this,c);if(b)if(b.isEnumerable)b.addObserver("[]",this,d);else b.isObservable&&b.addObserver("*",this,c);a&&a.isEnumerable||b&&b.isEnumerable?this._scoc_enumerableContentDidChange():this.contentPropertyDidChange(b,"*")}.observes("observableContent"),_scoc_enumerableContentDidChange:function(){var a=this.get("observableContent"),
b=this._scoc_observableContentItems,c=this.contentPropertyDidChange;if(b){b.forEach(function(d){d.isObservable&&d.removeObserver("*",this,c)},this);b.clear()}if(a&&a.isEnumerable){b||(b=SC.Set.create());a.forEach(function(d){if(!b.contains(d)){b.add(d);d.isObservable&&d.addObserver("*",this,c)}},this)}else b=null;this._scoc_observableContentItems=b;this.contentPropertyDidChange(a,"*");return this}});
SC.TreeItemContent={isTreeItemContent:YES,treeItemChildren:null,treeItemIsExpanded:YES,treeItemIsGrouped:NO,treeItemDisclosureState:function(){return this.get("treeItemIsExpanded")?SC.BRANCH_OPEN:SC.BRANCH_CLOSED},treeItemCollapse:function(){this.setIfChanged("treeItemIsExpanded",NO)},treeItemExpand:function(){this.setIfChanged("treeItemIsExpanded",YES)},treeItemBranchIndexes:function(){var a=this.get("treeItemChildren"),b,c,d,e;if(!a)return null;b=SC.IndexSet.create();c=a.get("length");for(d=0;d<
c;d++)if(e=a.objectAt(d))e.get("treeItemChildren")&&e.treeItemDisclosureState(this,d)!==SC.LEAF_NODE&&b.add(d);return b.get("length")>0?b:null}};SC.BRANCH_OPEN=17;SC.BRANCH_CLOSED=18;SC.LEAF_NODE=32;
SC.CollectionContent={isCollectionContent:YES,contentIndexIsSelected:function(a,b,c){return(a=a.get("selection"))?a.contains(b,c):NO},contentIndexIsEnabled:function(a){return a.get("isEnabled")},contentGroupIndexes:function(){return null},contentIndexIsGroup:function(){return NO},contentIndexOutlineLevel:function(){return-1},contentIndexDisclosureState:function(){return SC.LEAF_NODE},contentIndexExpand:function(a,b,c){console.log("contentIndexExpand(%@, %@, %@)".fmt(a,b,c))},contentIndexCollapse:function(a,
b,c){console.log("contentIndexCollapse(%@, %@, %@)".fmt(a,b,c))}};sc_require("mixins/tree_item_content");sc_require("mixins/collection_content");
SC.TreeItemObserver=SC.Object.extend(SC.Array,SC.CollectionContent,{item:null,delegate:null,parentObserver:null,parentItem:function(){var a=this.get("parentObserver");return a?a.get("item"):null}.property("parentObserver").cacheable(),index:null,outlineLevel:0,children:null,disclosureState:SC.BRANCH_OPEN,branchIndexes:function(){var a=this.get("item"),b,c,d,e,f;if(a)if(a.isTreeItemContent){c=this.get("parentItem");d=this.get("index");return a.treeItemBranchIndexes(c,d)}else{e=this.get("children");
if(!e)return null;f=SC.IndexSet.create();b=e.get("length");c=a;for(d=0;d<b;d++)if(a=e.objectAt(d))this._computeChildren(a,c,d)&&this._computeDisclosureState(a,c,d)!==SC.LEAF_NODE&&f.add(d);return f.get("length")>0?f:null}else return SC.IndexSet.EMPTY}.property("children").cacheable(),isHeaderVisible:function(){return!!this.get("parentObserver")}.property("parentObserver").cacheable(),length:0,objectAt:function(a){var b=this.get("length"),c=this.get("item"),d=this._objectAtCache,e=a,f;if(!(a>=b)){if(this.get("isHeaderVisible"))if(a===
0)return c;else e--;c=null;if(!d)d=this._objectAtCache=[];if((c=d[a])!==undefined)return c;if(f=this.get("children")){if(b=this.get("branchIndexes"))b.forEach(function(g){if(!(c||g>e)){var h=this.branchObserverAt(g),i;if(h){i=h.get("length");if(g+i>e){c=h.objectAt(e-g);e=-1}else e-=i-1}}},this);if(e>=0)c=f.objectAt(e);return d[a]=c}}},replace:function(a,b,c,d){var e=a,f=null,g,h;if(d===undefined)d=SC.DROP_BEFORE;this.get("isHeaderVisible")&&e--;if(e<0)throw"Tree Item cannot replace itself";if(a=this.get("branchIndexes"))a.forEach(function(i){if(!(f||
i>=e))if(f=this.branchObserverAt(i)){g=f.get("length");if(i+g===e&&d===SC.DROP_AFTER)e-=i;else if(i+g>e)e-=i;else{e-=g-1;f=null}}},this);if(f){f.replace(e,b,c,d);return this}h=e+b;b>1&&a&&a.forEachIn(e,a.get("max")-e,function(i){if(!(i>h))if(f=this.branchObserverAt(i)){g=f.get("length");h-=g-1}},this);b=h-e;a=this.get("children");if(!a)throw"cannot replace() tree item with no children";if(b<0||h>a.get("length"))throw"replace() range must lie within a single tree item";a.replace(e,b,c,d);return this},
observerContentDidChange:function(a,b,c){this.invalidateBranchObserversAt(a);this._disclosureStateCache=this._objectAtCache=this._outlineLevelCache=null;this._contentGroupIndexes=NO;this.notifyPropertyChange("branchIndexes");var d=this.get("length"),e=this._computeLength();c=this.get("parentObserver");d!==e&&this.set("length",e);if(!this._notifyParent)return this;if(c){a=SC.IndexSet.create(this.get("index"));c._childrenRangeDidChange(c.get("children"),null,"[]",a)}else{if(d===e){b=this.expandChildIndex(a+
b);a=this.expandChildIndex(a);b-=a;c=0}else{a=this.expandChildIndex(a);b=e-a;c=e-d}this.enumerableContentDidChange(a,b,c)}},expandChildIndex:function(a){var b=a;this.get("isHeaderVisible")&&a++;var c=this.get("branchIndexes");if(!c||c.get("length")===0)return b;c.forEachIn(0,a,function(d){b+=this.branchObserverAt(d).get("length")-1},this);return b},_contentGroupIndexes:NO,contentGroupIndexes:function(a,b){if(b!==this)return null;var c=this._contentGroupIndexes;if(c!==NO)return c;if(this.get("parentObserver"))return null;
a=this.get("item");var d,e;if(a&&a.isTreeItemContent?a.get("treeItemIsGrouped"):!!this.delegate.get("treeItemIsGrouped")){c=SC.IndexSet.create();a=this.get("branchIndexes");b=(b=this.get("children"))?b.get("length"):0;d=e=0;a&&a.forEach(function(f){c.add(d,f+1-e);d+=f+1-e;e=f+1;if(f=this.branchObserverAt(f))d+=f.get("length")-1},this);e<b&&c.add(d,b-e)}else c=null;return this._contentGroupIndexes=c},contentIndexIsGroup:function(a,b,c){return(a=this.contentGroupIndexes(a,b))?a.contains(c):NO},contentIndexOutlineLevel:function(a,
b,c){if(b!==this)return-1;if((b=this._outlineLevelCache)&&b[c]!==undefined)return b[c];if(!b)b=this._outlineLevelCache=[];var d=this.get("length"),e=c,f=null;if(c>=d)return-1;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("outlineLevel")-1;else e--;if(d=this.get("branchIndexes"))d.forEach(function(g){if(!(f!==null||g>e)){var h=this.branchObserverAt(g),i;if(h){i=h.get("length");if(g+i>e){f=h.contentIndexOutlineLevel(a,h,e-g);e=-1}else e-=i-1}}},this);if(e>=0)f=this.get("outlineLevel");
return b[c]=f},contentIndexDisclosureState:function(a,b,c){if(b!==this)return-1;if((b=this._disclosureStateCache)&&b[c]!==undefined)return b[c];if(!b)b=this._disclosureStateCache=[];var d=this.get("length"),e=c,f=null;if(c>=d)return SC.LEAF_NODE;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("disclosureState");else e--;if(d=this.get("branchIndexes"))d.forEach(function(g){if(!(f!==null||g>e)){var h=this.branchObserverAt(g),i;if(h){i=h.get("length");if(g+i>e){f=h.contentIndexDisclosureState(a,
h,e-g);e=-1}else e-=i-1}}},this);if(e>=0)f=SC.LEAF_NODE;return b[c]=f},contentIndexExpand:function(a,b,c){var d=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._expand(this.get("item"));return}else d--;if(b=this.get("branchIndexes"))b.forEach(function(e){if(!(e>=d)){var f=this.branchObserverAt(e),g;if(f){g=f.get("length");if(e+g>d){f.contentIndexExpand(a,f,d-e);d=-1}else d-=g-1}}},this);if(d>=0)(b=(b=this.get("children"))?b.objectAt(d):null)&&this._expand(b,this.get("item"),d)}},contentIndexCollapse:function(a,
b,c){var d=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._collapse(this.get("item"));return}else d--;if(b=this.get("branchIndexes"))b.forEach(function(e){if(!(e>=d)){var f=this.branchObserverAt(e),g;if(f){g=f.get("length");if(e+g>d){f.contentIndexCollapse(a,f,d-e);d=-1}else d-=g-1}}},this);if(d>=0)(b=(b=this.get("children"))?b.objectAt(d):null)&&this._collapse(b,this.get("item"),d)}},branchObserverAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes,d;if(!b)b=
this._branchObserversByIndex=[];if(!c)c=this._branchObserverIndexes=SC.IndexSet.create();if(d=b[a])return d;d=(d=this.get("children"))?d.objectAt(a):null;if(!d)return null;b[a]=d=SC.TreeItemObserver.create({item:d,delegate:this.get("delegate"),parentObserver:this,index:a,outlineLevel:this.get("outlineLevel")+1});c.add(a);return d},invalidateBranchObserversAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes;if(!b||b.length<=a)return this;if(a<0)a=0;c.forEachIn(a,c.get("max")-
a,function(d){(d=b[d])&&d.destroy()},this);b.length=a;return this},init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("item");if(!a)throw"SC.TreeItemObserver.item cannot be null";a.addObserver("*",this,this._itemPropertyDidChange);this._itemPropertyDidChange(a,"*");this._notifyParent=YES},destroy:function(){this.invalidateBranchObserversAt(0);this._objectAtCache=null;var a=this.get("item");a&&a.removeObserver("*",this,this._itemPropertyDidChange);a=this._children;var b=this._childrenRangeObserver;
a&&b&&a.removeRangeObserver(b);arguments.callee.base.apply(this,arguments)},_itemPropertyDidChange:function(){var a=this.get("children"),b=this.get("disclosureState"),c=this.get("item"),d;this.beginPropertyChanges();d=this._computeDisclosureState(c);b!==d&&this.set("disclosureState",d);d=this._computeChildren(c);a!==d&&this.set("children",d);this.endPropertyChanges()},_childrenDidChange:function(){var a=this.get("disclosureState")===SC.BRANCH_OPEN?this.get("children"):null,b=this._children,c=this._childrenRangeObserver;
if(b===a)return this;c&&b.removeRangeObserver(c);this._childrenRangeObserver=a?a.addRangeObserver(null,this,this._childrenRangeDidChange):null;this._children=a;this._childrenRangeDidChange(a,null,"[]",null)}.observes("children","disclosureState"),_childrenRangeDidChange:function(a,b,c,d){a=(a=this.get("children"))?a.get("length"):0;b=d?d.get("min"):0;d=d?d.get("max"):a;c=this._childrenLen||0;this._childrenLen=a;this.observerContentDidChange(b,d-b,a-c)},_computeDisclosureState:function(a,b,c){if(!a||
!this._computeChildren(a))return SC.LEAF_NODE;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");return a.treeItemDisclosureState(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";return a.get(b)?SC.BRANCH_OPEN:SC.BRANCH_CLOSED}},_collapse:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=
this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemCollapse(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,NO)}return this},_expand:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemExpand(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=
b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,YES)}return this},_computeChildren:function(a){var b;if(a)if(a.isTreeItemContent)return a.get("treeItemChildren");else{b=this._treeItemChildrenKey;if(!b)this._treeItemChildrenKey=b=(b=this.get("delegate"))?b.get("treeItemChildrenKey"):"treeItemChildren";return a.get(b)}else return null},_computeLength:function(){var a=this.get("isHeaderVisible")?1:0,b=this.get("disclosureState"),c=this.get("children");
if(b===SC.BRANCH_OPEN&&c){a+=c.get("length");if(b=this.get("branchIndexes"))b.forEach(function(d){d=this.branchObserverAt(d);a+=d.get("length")-1},this)}return a}});sc_require("controllers/object");sc_require("mixins/selection_support");sc_require("private/tree_item_observer");
SC.TreeController=SC.ObjectController.extend(SC.SelectionSupport,{treeItemIsGrouped:NO,treeItemIsExpandedKey:"treeItemIsExpanded",treeItemChildrenKey:"treeItemChildren",arrangedObjects:function(){var a;return this._sctc_arrangedObjects=a=(a=this.get("content"))?SC.TreeItemObserver.create({item:a,delegate:this}):null}.property().cacheable(),_sctc_invalidateArrangedObjects:function(){this.propertyWillChange("arrangedObjects");var a=this._sctc_arrangedObjects;a&&a.destroy();this._sctc_arrangedObjects=
null;this.propertyDidChange("arrangedObjects")}.observes("content","treeItemIsExpandedKey","treeItemChildrenKey","treeItemIsGrouped"),_sctc_arrangedObjectsContentDidChange:function(){this.updateSelectionAfterContentChange()}.observes("*arrangedObjects.[]"),firstSelectableObject:function(){var a=this.get("arrangedObjects"),b,c,d=0;if(!a)return null;b=a.contentGroupIndexes(null,a);for(c=a.get("length");b.contains(d)&&d<c;)d++;return d>=c?null:a.objectAt(d)}.property()});
SC.mixin(SC.Object.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=a,d,e;if(arguments.length>2){d=SC.$A(arguments).slice(2);if(SC.typeOf(c)===SC.T_STRING)c=this[a];e=c;c=function(){return e.apply(this,d)}}return SC.Timer.schedule({target:this,action:c,interval:b})},invokeWith:function(a,b,c){if(c===undefined){c=b;b=this}b||(b=this);if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=this.getPath(a);c.call(b,a,this);return this}});
SC.RunLoop=SC.RunLoop.extend({startTime:function(){if(!this._start)this._start=Date.now();return this._start}.property(),endRunLoop:function(){this.fireExpiredTimers();var a=arguments.callee.base.apply(this,arguments);this.scheduleNextTimeout();return a},scheduleTimer:function(a,b){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);this._timerQueue=a.scheduleInTimerQueue(this._timerQueue,b);return this},cancelTimer:function(a){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);return this},
TIMER_ARRAY:[],fireExpiredTimers:function(){if(!this._timerQueue||this._firing)return NO;var a=this.get("startTime");this._firing=YES;var b=this.TIMER_ARRAY;this._timerQueue=this._timerQueue.collectExpiredTimers(b,a);var c=b.length;for(a=0;a<c;a++)b[a].fire();a=b.length>0;b.length=0;this._firing=NO;return a},scheduleNextTimeout:function(){var a=this._timerQueue,b=NO;if(a){a=a._timerQueueRunTime;if(this._timeoutAt!==a){this._timeout&&clearTimeout(this._timeout);b=Math.max(0,a-Date.now());this._timeout=
setTimeout(this._timeoutDidFire,b);this._timeoutAt=a}b=YES}else this._timeout&&clearTimeout(this._timeout);return b},_timeoutDidFire:function(){var a=SC.RunLoop.currentRunLoop;a._timeout=a._timeoutAt=null;SC.RunLoop.begin().end()}});SC.RunLoop.currentRunLoop=SC.RunLoop.create();
SC.Button={value:null,toggleOnValue:YES,toggleOffValue:NO,localize:NO,localizeBindingDefault:SC.Binding.bool(),title:"",contentTitleKey:null,icon:null,contentIconKey:null,needsEllipsis:YES,displayTitle:function(){var a=this.get("title");return a&&this.get("localize")?a.loc():a||""}.property("title","localize").cacheable(),keyEquivalent:null,renderTitle:function(a,b){var c=this.get("icon"),d="",e=this.get("displayTitle"),f=!SC.none(e)&&e.length>0;if(c){f=SC.BLANK_IMAGE_URL;d=c.indexOf("/")>=0?'<img src="'+
c+'" alt="" class="icon" />':'<img src="'+f+'" alt="" class="'+c+'" />';f=YES}c=d+e;if(b){this.get("needsEllipsis")?a.push('<label class="sc-button-label ellipsis">'+c+"</label>"):a.push('<label class="sc-button-label">'+c+"</label>");this._ImageTitleCached=c}else{b=this.$("label");if(e=b[0])if(f){this.get("needsEllipsis")?b.addClass("ellipsis"):b.removeClass("ellipsis");if(this._ImageTitleCached!==c){this._ImageTitleCached=c;e.innerHTML=c}}else e.innerHTML=""}return a},contentPropertyDidChange:function(a,
b){var c=this.get("displayDelegate");a=this.get("content");var d=this.getDelegateProperty("contentValueKey",c);if(d&&(b===d||b==="*"))this.set("value",a?a.get(d):null);if((d=this.getDelegateProperty("contentTitleKey",c))&&(b===d||b==="*"))this.set("title",a?a.get(d):null);if((c=this.getDelegateProperty("contentIconKey",c))&&(b===c||b==="*"))this.set("icon",a?a.get(c):null);return this},_button_displayObserver:function(){this.displayDidChange()}.observes("title","icon","value"),performKeyEquivalent:function(a,
b){if(!this.get("isEnabled"))return NO;var c=this.get("keyEquivalent");if(c){if(c===a)return this.triggerAction(b)}else if(this.get("isDefault")&&a==="return"||this.get("isCancel")&&a==="escape")return this.triggerAction(b);return NO},triggerAction:function(){throw"SC.Button.triggerAction() is not defined in %@".fmt(this);},computeIsSelectedForValue:function(a){var b=this.get("toggleOnValue"),c,d;if(SC.typeOf(a)===SC.T_ARRAY)if(a.length===1)c=a[0]==b;else{c=null;a.find(function(e){d=e==b;if(c===null)c=
d;else if(d!==c)c=SC.MIXED_STATE;return c===SC.MIXED_STATE})}else c=a===SC.MIXED_STATE?SC.MIXED_STATE:a==b;return c},initMixin:function(){SC.none(this.get("value"))||this._button_valueDidChange()},_button_valueDidChange:function(){this.set("isSelected",this.computeIsSelectedForValue(this.get("value")))}.observes("value"),_button_isSelectedDidChange:function(){var a=this.get("isSelected"),b=this.computeIsSelectedForValue(this.get("value"));if(a!==SC.MIXED_STATE&&b!==a)this.set("value",this.get(a?"toggleOnValue":
"toggleOffValue"))}.observes("isSelected")};
SC.ContentDisplay={concatenatedProperties:"contentDisplayProperties",displayProperties:["content"],contentDisplayProperties:[],_display_contentDidChange:function(a,b,c){if((c=this.get("content"))!=this._display_content){a=this._display_contentPropertyDidChange;if(b=this._display_content)if(SC.isArray(b))b.invoke("removeObserver","*",this,a);else b.removeObserver&&b.removeObserver("*",this,a);if(b=this._display_content=c)if(SC.isArray(b))b.invoke("addObserver","*",this,a);else b.addObserver&&b.addObserver("*",
this,a);this.allPropertiesDidChange();this.endPropertyChanges()}}.observes("content"),_display_contentPropertyDidChange:function(a,b){if(b==="*")this.displayDidChange();else(a=this.get("contentDisplayProperties"))&&a.indexOf(b)>=0&&this.displayDidChange()}};sc_require("system/locale");SC.STRING_TITLEIZE_REGEXP=/([\s|\-|\_|\n])([^\s|\-|\_|\n]?)/g;SC.STRING_DECAMELIZE_REGEXP=/([a-z])([A-Z])/g;SC.STRING_DASHERIZE_REGEXP=/[ _]/g;SC.STRING_HUMANIZE_REGEXP=/[\-_]/g;SC.STRING_TRIM_REGEXP=/^\s+|\s+$/g;
SC.STRING_TRIM_LEFT_REGEXP=/^\s+/g;SC.STRING_TRIM_RIGHT_REGEXP=/\s+$/g;
SC.String={loc:function(){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var a=SC.Locale.currentLocale.locWithDefault(this)||this;return a.fmt.apply(a,arguments)},locWithDefault:function(a){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var b=SC.Locale.currentLocale.locWithDefault(a)||this,c=SC.$A(arguments);c.shift();return b.fmt.apply(b,c)},capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},capitalizeEach:function(){return this.replace(SC.STRING_TITLEIZE_REGEXP,
function(a,b,c){return c?b+c.toUpperCase():b}).capitalize()},titleize:function(){return this.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2").replace(SC.STRING_TITLEIZE_REGEXP,function(a,b,c){return c?" "+c.toUpperCase():" "}).capitalize()},camelize:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(d,e,f){return f?f.toUpperCase():""}),b=a.charAt(0),c=b.toLowerCase();return b!==c?c+a.slice(1):a},classify:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(d,e,f){return f?f.toUpperCase():
""}),b=a.charAt(0),c=b.toUpperCase();return b!==c?c+a.slice(1):a},decamelize:function(){return this.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2").toLowerCase()},dasherize:function(){return this.decamelize().replace(SC.STRING_DASHERIZE_REGEXP,"-")},humanize:function(){return this.decamelize().replace(SC.STRING_HUMANIZE_REGEXP," ")},removeDiacritics:function(){var a=SC.diacriticMappingTable;if(!a){SC.diacriticMappingTable={"\u00c0":"A","\u00c1":"A","\u00c2":"A","\u00c3":"A","\u00c4":"A","\u00c5":"A",
"\u0100":"A","\u0102":"A","\u0104":"A","\u01cd":"A","\u01de":"A","\u01e0":"A","\u01fa":"A","\u0200":"A","\u0202":"A","\u0226":"A","\u1e00":"A","\u1ea0":"A","\u1ea2":"A","\u1ea4":"A","\u1ea6":"A","\u1ea8":"A","\u1eaa":"A","\u1eac":"A","\u1eae":"A","\u1eb0":"A","\u1eb2":"A","\u1eb4":"A","\u1eb6":"A","\u212b":"A","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u00c7":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u1e08":"C","\u010e":"D","\u1e0a":"D","\u1e0c":"D","\u1e0e":"D","\u1e10":"D","\u1e12":"D",
"\u00c8":"E","\u00c9":"E","\u00ca":"E","\u00cb":"E","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u0228":"E","\u1e14":"E","\u1e16":"E","\u1e18":"E","\u1e1a":"E","\u1e1c":"E","\u1eb8":"E","\u1eba":"E","\u1ebc":"E","\u1ebe":"E","\u1ec0":"E","\u1ec2":"E","\u1ec4":"E","\u1ec6":"E","\u1e1e":"F","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u01e6":"G","\u01f4":"G","\u1e20":"G","\u0124":"H","\u021e":"H","\u1e22":"H","\u1e24":"H","\u1e26":"H","\u1e28":"H",
"\u1e2a":"H","\u00cc":"I","\u00cd":"I","\u00ce":"I","\u00cf":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1e2c":"I","\u1e2e":"I","\u1ec8":"I","\u1eca":"I","\u0134":"J","\u0136":"K","\u01e8":"K","\u1e30":"K","\u1e32":"K","\u1e34":"K","\u0139":"L","\u013b":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u1e3a":"L","\u1e3c":"L","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u00d1":"N","\u0143":"N","\u0145":"N","\u0147":"N","\u01f8":"N","\u1e44":"N",
"\u1e46":"N","\u1e48":"N","\u1e4a":"N","\u00d2":"O","\u00d3":"O","\u00d4":"O","\u00d5":"O","\u00d6":"O","\u014c":"O","\u014e":"O","\u0150":"O","\u01a0":"O","\u01d1":"O","\u01ea":"O","\u01ec":"O","\u020c":"O","\u020e":"O","\u022a":"O","\u022c":"O","\u022e":"O","\u0230":"O","\u1e4c":"O","\u1e4e":"O","\u1e50":"O","\u1e52":"O","\u1ecc":"O","\u1ece":"O","\u1ed0":"O","\u1ed2":"O","\u1ed4":"O","\u1ed6":"O","\u1ed8":"O","\u1eda":"O","\u1edc":"O","\u1ede":"O","\u1ee0":"O","\u1ee2":"O","\u1e54":"P","\u1e56":"P",
"\u0154":"R","\u0156":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e58":"R","\u1e5a":"R","\u1e5c":"R","\u1e5e":"R","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u0218":"S","\u1e60":"S","\u1e62":"S","\u1e64":"S","\u1e66":"S","\u1e68":"S","\u0162":"T","\u0164":"T","\u021a":"T","\u1e6a":"T","\u1e6c":"T","\u1e6e":"T","\u1e70":"T","\u00d9":"U","\u00da":"U","\u00db":"U","\u00dc":"U","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u01af":"U","\u01d3":"U","\u01d5":"U",
"\u01d7":"U","\u01d9":"U","\u01db":"U","\u0214":"U","\u0216":"U","\u1e72":"U","\u1e74":"U","\u1e76":"U","\u1e78":"U","\u1e7a":"U","\u1ee4":"U","\u1ee6":"U","\u1ee8":"U","\u1eea":"U","\u1eec":"U","\u1eee":"U","\u1ef0":"U","\u1e7c":"V","\u1e7e":"V","\u0174":"W","\u1e80":"W","\u1e82":"W","\u1e84":"W","\u1e86":"W","\u1e88":"W","\u1e8a":"X","\u1e8c":"X","\u00dd":"Y","\u0176":"Y","\u0178":"Y","\u0232":"Y","\u1e8e":"Y","\u1ef2":"Y","\u1ef4":"Y","\u1ef6":"Y","\u1ef8":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z",
"\u1e90":"Z","\u1e92":"Z","\u1e94":"Z","\u1fef":"`","\u00e0":"a","\u00e1":"a","\u00e2":"a","\u00e3":"a","\u00e4":"a","\u00e5":"a","\u0101":"a","\u0103":"a","\u0105":"a","\u01ce":"a","\u01df":"a","\u01e1":"a","\u01fb":"a","\u0201":"a","\u0203":"a","\u0227":"a","\u1e01":"a","\u1ea1":"a","\u1ea3":"a","\u1ea5":"a","\u1ea7":"a","\u1ea9":"a","\u1eab":"a","\u1ead":"a","\u1eaf":"a","\u1eb1":"a","\u1eb3":"a","\u1eb5":"a","\u1eb7":"a","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u00e7":"c","\u0107":"c","\u0109":"c",
"\u010b":"c","\u010d":"c","\u1e09":"c","\u010f":"d","\u1e0b":"d","\u1e0d":"d","\u1e0f":"d","\u1e11":"d","\u1e13":"d","\u00e8":"e","\u00e9":"e","\u00ea":"e","\u00eb":"e","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u0229":"e","\u1e15":"e","\u1e17":"e","\u1e19":"e","\u1e1b":"e","\u1e1d":"e","\u1eb9":"e","\u1ebb":"e","\u1ebd":"e","\u1ebf":"e","\u1ec1":"e","\u1ec3":"e","\u1ec5":"e","\u1ec7":"e","\u1e1f":"f","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g",
"\u01e7":"g","\u01f5":"g","\u1e21":"g","\u0125":"h","\u021f":"h","\u1e23":"h","\u1e25":"h","\u1e27":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u00ec":"i","\u00ed":"i","\u00ee":"i","\u00ef":"i","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1e2d":"i","\u1e2f":"i","\u1ec9":"i","\u1ecb":"i","\u0135":"j","\u01f0":"j","\u0137":"k","\u01e9":"k","\u1e31":"k","\u1e33":"k","\u1e35":"k","\u013a":"l","\u013c":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u1e3b":"l",
"\u1e3d":"l","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u00f1":"n","\u0144":"n","\u0146":"n","\u0148":"n","\u01f9":"n","\u1e45":"n","\u1e47":"n","\u1e49":"n","\u1e4b":"n","\u00f2":"o","\u00f3":"o","\u00f4":"o","\u00f5":"o","\u00f6":"o","\u014d":"o","\u014f":"o","\u0151":"o","\u01a1":"o","\u01d2":"o","\u01eb":"o","\u01ed":"o","\u020d":"o","\u020f":"o","\u022b":"o","\u022d":"o","\u022f":"o","\u0231":"o","\u1e4d":"o","\u1e4f":"o","\u1e51":"o","\u1e53":"o","\u1ecd":"o","\u1ecf":"o","\u1ed1":"o","\u1ed3":"o",
"\u1ed5":"o","\u1ed7":"o","\u1ed9":"o","\u1edb":"o","\u1edd":"o","\u1edf":"o","\u1ee1":"o","\u1ee3":"o","\u1e55":"p","\u1e57":"p","\u0155":"r","\u0157":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e59":"r","\u1e5b":"r","\u1e5d":"r","\u1e5f":"r","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0219":"s","\u1e61":"s","\u1e63":"s","\u1e65":"s","\u1e67":"s","\u1e69":"s","\u0163":"t","\u0165":"t","\u021b":"t","\u1e6b":"t","\u1e6d":"t","\u1e6f":"t","\u1e71":"t","\u1e97":"t","\u00f9":"u","\u00fa":"u",
"\u00fb":"u","\u00fc":"u","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u01b0":"u","\u01d4":"u","\u01d6":"u","\u01d8":"u","\u01da":"u","\u01dc":"u","\u0215":"u","\u0217":"u","\u1e73":"u","\u1e75":"u","\u1e77":"u","\u1e79":"u","\u1e7b":"u","\u1ee5":"u","\u1ee7":"u","\u1ee9":"u","\u1eeb":"u","\u1eed":"u","\u1eef":"u","\u1ef1":"u","\u1e7d":"v","\u1e7f":"v","\u0175":"w","\u1e81":"w","\u1e83":"w","\u1e85":"w","\u1e87":"w","\u1e89":"w","\u1e98":"w","\u1e8b":"x","\u1e8d":"x",
"\u00fd":"y","\u00ff":"y","\u0177":"y","\u0233":"y","\u1e8f":"y","\u1e99":"y","\u1ef3":"y","\u1ef5":"y","\u1ef7":"y","\u1ef9":"y","\u017a":"z","\u017c":"z","\u017e":"z","\u1e91":"z","\u1e93":"z","\u1e95":"z"};a=SC.diacriticMappingTable}for(var b,c,d="",e=this.length,f=0;f<=e;++f){b=this.charAt(f);c=a[b];d+=c?c:b}return d},trim:function(){return this.replace(SC.STRING_TRIM_REGEXP,"")},trimLeft:function(){return this.replace(SC.STRING_TRIM_LEFT_REGEXP,"")},trimRight:function(){return this.replace(SC.STRING_TRIM_RIGHT_REGEXP,
"")}};SC.String.strip=SC.String.trim;SC.supplement(String.prototype,SC.String);String.prototype.loc=SC.String.loc;SC.String.fmt=String.prototype.fmt;sc_require("mixins/string");SC.MIXED_STATE="__MIXED__";SC.HUGE_CONTROL_SIZE="sc-huge-size";SC.LARGE_CONTROL_SIZE="sc-large-size";SC.REGULAR_CONTROL_SIZE="sc-regular-size";SC.SMALL_CONTROL_SIZE="sc-small-size";SC.TINY_CONTROL_SIZE="sc-tiny-size";
SC.Control={initMixin:function(){this._control_contentDidChange()},isSelected:NO,isSelectedBindingDefault:SC.Binding.oneWay().bool(),isActive:NO,isActiveBindingDefault:SC.Binding.oneWay().bool(),value:null,content:null,contentValueKey:null,contentPropertyDidChange:function(a,b){return this.updatePropertyFromContent("value",b,"contentValueKey")},updatePropertyFromContent:function(a,b,c,d){var e=b==="*";if(c===undefined)c="content%@Key".fmt(a.capitalize());if(d===undefined)d=this.get("content");if((c=
this[c]?this.get(c):this.getDelegateProperty(c,this.displayDelegate))&&(e||b===c)){b=d?d.get?d.get(c):d[c]:null;this.set(a,b)}return this},updateContentWithValueObserver:function(){var a=this.contentValueKey?this.get("contentValueKey"):this.getDelegateProperty("contentValueKey",this.displayDelegate),b=this.get("content");if(a&&b){var c=this.get("value");if(typeof b.setIfChanged===SC.T_FUNCTION)b.setIfChanged(a,c);else if(b[a]!==c)b[a]=c}}.observes("value"),fieldKey:null,fieldLabel:null,errorLabel:function(){var a,
b;if(a=this.get("fieldLabel"))return a;a=this.get("fieldKey")||this.constructor.toString();b=(a||"").humanize().capitalize();return"ErrorLabel.%@".fmt(a).locWithDefault("FieldKey.%@".fmt(a).locWithDefault(b))}.property("fieldLabel","fieldKey").cacheable(),controlSize:SC.REGULAR_CONTROL_SIZE,displayProperties:"isEnabled isSelected isActive controlSize".w(),_CONTROL_TMP_CLASSNAMES:{},renderMixin:function(a,b){var c=this.get("isSelected"),d=!this.get("isEnabled"),e=this._CONTROL_TMP_CLASSNAMES;e.mixed=
c===SC.MIXED_STATE;e.sel=c&&c!==SC.MIXED_STATE;e.active=this.get("isActive");a.setClass(e).addClass(this.get("controlSize"));!b&&this.$input&&this.$input().attr("disabled",d)},_control_content:null,_control_contentDidChange:function(){var a=this.get("content");if(this._control_content!==a){var b=this.contentPropertyDidChange,c=this._control_content;c&&c.removeObserver&&c.removeObserver("*",this,b);(this._control_content=a)&&a.addObserver&&a.addObserver("*",this,b);this.contentPropertyDidChange(a,
"*")}}.observes("content")};SC.Editable={isEditable:NO,isEditing:NO,beginEditing:function(){if(!this.get("isEditable"))return NO;if(this.get("isEditing"))return YES;this.set("isEditing",YES);this.becomeFirstResponder();return YES},discardEditing:function(){return!this.get("isEditing")},commitEditing:function(){if(!this.get("isEditing"))return YES;this.set("isEditing",NO);this.resignFirstResponder();return YES}};
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0]};SC.extend(a,
{isOpera:!!a.opera,isIe:!!a.msie,isIE:!!a.msie,isSafari:!!a.safari,isMobileSafari:!!a.mobileSafari,isMozilla:!!a.mozilla,isWindows:!!a.windows,isMac:!!a.mac,current:a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown",compareVersion:function(){if(this._versionSplit===undefined){function c(g){return Number(g.match(/^[0-9]+/))}this._versionSplit=SC.A(this.version.split(".")).map(c)}for(var d=SC.A(arguments).map(Number),e=0;e<d.length;e++){var f=this._versionSplit[e]-d[e];if(isNaN(f))return 0;
if(f!==0)return f}return 0}});return a}();SC.Builder=function(a){return SC.Builder.create(a)};SC.Builder.create=function(a){var b=SC.mixin(SC.beget(this.fn),a||{});if(a.hasOwnProperty("toString"))b.toString=a.toString;var c=function(){var d=SC.beget(b);d.defaultClass=this;d.constructor=c;return d.init.apply(d,arguments)};c.fn=c.prototype=b;c.extend=SC.Builder.create;c.mixin=SC.Builder.mixin;return c};
SC.Builder.mixin=function(){var a=arguments.length,b;for(b=0;b<a;b++)SC.mixin(this,arguments[b]);return this};
SC.Builder.fn={init:function(a){if(a!==undefined)if(SC.typeOf(a)===SC.T_ARRAY){for(var b=a.length;--b>=0;)this[b]=a.objectAt?a.objectAt(b):a[b];this.length=a.length}else{this[0]=a;this.length=1}return this},size:function(){return this.length},pushStack:function(){var a=this.constructor.apply(this,arguments);a.prevObject=this;return a},end:function(){return this.prevObject||this.constructor()},toString:function(){return"%@$(%@)".fmt(this.defaultClass.toString(),SC.A(this).invoke("toString").join(","))},
mixin:SC.Builder.mixin};(function(){var a=SC.Enumerable,b=SC.Builder.fn,c,d;for(c in a)if(a.hasOwnProperty(c)){d=Array.prototype[c]||a[c];b[c]=d}})();sc_require("system/builder");
SC.CoreQuery=function(){function a(n,q){return n[0]&&parseInt(x.curCSS(n[0],q,true),10)||0}var b=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,c=/^.[^:#\[\.]*$/,d=/ CQ\d+="(?:\d+|null)"/g,e=/(<(\w+)[^>]*?)\/>/g,f=/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,g=/\s+/,h=/^\s+/,i=/^body|html$/i,j=/href|src|style/,k=/(button|input|object|select|textarea)/i,l=/alpha\([^)]*\)/,m=/opacity=([^)]*)/,o=SC.browser.msie?"styleFloat":"cssFloat",r=SC.browser.safari&&parseInt(SC.browser.version,0)<417?"(?:[\\w*_-]|\\\\.)":
"(?:[\\w\u0128-\uffff*_-]|\\\\.)",w=new RegExp("^([#.]?)("+r+"*)"),p=new RegExp("([#.]?)("+r+"*)","g"),s=["Left","Right"],v=["Top","Bottom"],t={position:"absolute",visibility:"hidden",display:"block"},z=function(n,q,y){q=q==="width"?n.offsetWidth:n.offsetHeight;for(var C=0,B=0,D=y.length,F;--D>=0;){F=y[D];C+=parseFloat(x.curCSS(n,"padding"+F,true))||0;B+=parseFloat(x.curCSS(n,"border"+F+"Width",true))||0}q-=Math.round(C+B);return q},u=/z-?index|font-?weight|opacity|zoom|line-?height/i,A=document.defaultView||
{},E=function(n){if(!SC.browser.safari)return false;n=A.getComputedStyle(n,null);return!n||n.getPropertyValue("color")===""},x;x=r=SC.Builder.create({jquery:"SC.CoreQuery",init:function(n,q){n=n||document;if(n.nodeType){this[0]=n;this.length=1;return this}else if(typeof n==="string"){var y=b.exec(n);if(y&&(y[1]||!q))if(y[1])n=x.clean([y[1]],q);else{if(q=document.getElementById(y[3])){if(q.id!=y[3])return x().find(n);return x(q)}n=[]}else return x(q).find(n)}else if(SC.typeOf(n)===SC.T_FUNCTION)return SC.ready(n);
return this.setArray(x.makeArray(n))},size:function(){return this.length},get:function(n){return n===undefined?x.makeArray(this):this[n]},find:function(n){return this.pushStack(x.map(this,function(q){return x.find(n,q)}))},filter:function(n){return this.pushStack(SC.typeOf(n)===SC.T_FUNCTION&&x.grep(this,function(q,y){return n.call(q,y)})||x.multiFilter(n,this))},not:function(n){if(typeof n==="string")if(c.test(n))return this.pushStack(x.multiFilter(n,this,true));else n=x.multiFilter(n,this);var q=
n.length&&n[n.length-1]!==undefined&&!n.nodeType;return this.filter(function(){return q?x.inArray(this,n)<0:this!=n})},setArray:function(n){this.length=0;Array.prototype.push.apply(this,n);return this},map:function(n){return this.pushStack(x.map(this,function(q,y){return n.call(q,y,q)}))},each:function(n,q){return x.each(this,n,q)},index:function(n){if(n&&n.jquery)n=n[0];return Array.prototype.indexOf.call(this,n)},eq:function(n){return this.slice(n,+n+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,
arguments))},add:function(n){return this.pushStack(x.merge(this.get(),typeof n==="string"?x(n):x.makeArray(n)).uniq())},attr:function(n,q,y){var C=n;if(typeof n==="string")if(q===undefined)return this[0]&&x[y||"attr"](this[0],n);else{C={};C[n]=q}return this.each(function(B){for(n in C)x.attr(y?this.style:this,n,x.prop(this,C[n],y,B,n))})},html:function(n){return n===undefined?this[0]?this[0].innerHTML.replace(d,""):null:this.empty().append(n)},andSelf:function(){return this.add(this.prevObject)},
is:function(n){return!!n&&x.multiFilter(n,this).length>0},hasClass:function(n){return Array.prototype.every.call(this,function(q){return q.nodeType===1&&x.className.has(q,n)})},val:function(n){if(n===undefined){var q=this[0];if(q){if(x.nodeName(q,"option"))return(q.attributes.value||{}).specified?q.value:q.text;if(x.nodeName(q,"select")){var y=q.selectedIndex,C=[],B=q.options;q=q.type==="select-one";if(y<0)return null;var D,F=q?y+1:B.length;for(D=q?y:0;D<F;D++){y=B[D];if(y.selected){n=x(y).val();
if(q)return n;C.push(n)}}return C}return(q.value||"").replace(/\r/g,"")}}else{if(typeof n==="number")n+="";this.each(function(){if(this.nodeType===1)if(SC.typeOf(n)===SC.T_ARRAY&&/radio|checkbox/.test(this.type))this.checked=x.inArray(this.value,n)>=0||x.inArray(this.name,n)>=0;else if(x.nodeName(this,"select")){var J=x.makeArray(n);x("option",this).each(function(){this.selected=x.inArray(this.value,J)>=0||x.inArray(this.text,J)>=0});if(!J.length)this.selectedIndex=-1}else this.value=n});return this}},
clone:function(){var n=this.map(function(){if(SC.browser.msie&&!x.isXMLDoc(this)){var q=this.cloneNode(true),y=document.createElement("div");y.appendChild(q);return x.clean([y.innerHTML])[0]}else return this.cloneNode(true)});n.find("*").andSelf().each(function(){if(this[SC.guidKey]!==undefined)this[SC.guidKey]=null});return n},css:function(n,q){if((n==="width"||n==="height")&&parseFloat(q,0)<0)q=undefined;return this.attr(n,q,"curCSS")},text:function(n){if(n!==undefined&&typeof n!=="object"&&n!=
null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(n));var q="";x.each(n||this,function(){x.each(this.childNodes,function(){if(this.nodeType!==8)q+=this.nodeType!==1?this.nodeValue:x.fn.text([this])})});return q},show:function(){var n=SC.$.isVisible;this.each(function(){if(!n(this)){this.style.display=this.oldblock||"";if(x.css(this,"display")==="none"){var q=x("<"+this.tagName+"/>");x("body").append(q);this.style.display=q.css("display");if(this.style.display===
"none")this.style.display="block";q.remove()}}});return this},hide:function(){var n=SC.$.isVisible;this.each(function(){if(n(this)){this.oldblock=this.oldblock||x.css(this,"display");this.style.display="none"}});return this},domManip:function(n,q,y,C){var B=this.length>1,D;return this.each(function(){if(!D){D=x.clean(n,this.ownerDocument);y&&D.reverse()}var F=this;if(q&&x.nodeName(this,"table")&&x.nodeName(D[0],"tr"))F=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));
x.each(D,function(){var J=B?x(this).clone(true)[0]:this;C.call(F,J)})})},append:function(){return this.domManip(arguments,true,false,function(n){this.nodeType===1&&this.appendChild(n)})},prepend:function(){return this.domManip(arguments,true,true,function(n){this.nodeType===1&&this.insertBefore(n,this.firstChild)})},before:function(){return this.domManip(arguments,false,false,function(n){this.parentNode.insertBefore(n,this)})},after:function(){return this.domManip(arguments,false,true,function(n){this.parentNode.insertBefore(n,
this.nextSibling)})},replaceWith:function(n){return this.after(n).remove()},removeData:function(n){return this.each(function(){SC.removeData(this,n)})}});r.mixin({nodeName:function(n,q){return n.nodeName&&n.nodeName.toUpperCase()===q.toUpperCase()},map:function(n,q){var y=[],C,B,D;B=0;for(D=n.length;B<D;B++){C=q(n[B],B);if(C!=null)y[y.length]=C}return y.concat.apply([],y)},each:function(n,q,y){var C,B=0,D=n.length;if(y)if(D===undefined)for(C in n){if(q.apply(n[C],y)===false)break}else for(;B<D;){if(q.apply(n[B++],
y)===false)break}else if(D===undefined)for(C in n){if(q.call(n[C],C,n[C])===false)break}else for(y=n[0];B<D&&q.call(y,B,y)!==false;y=n[++B]);return n},isXMLDoc:function(n){return n.documentElement&&!n.body||n.tagName&&n.ownerDocument&&!n.ownerDocument.body},clean:function(n,q){var y=[];q=q||document;if(typeof q.createElement=="undefined")q=q.ownerDocument||q[0]&&q[0].ownerDocument||document;x.each(n,function(C,B){if(typeof B==="number")B+="";if(B){if(typeof B==="string"){B=B.replace(e,function(J,
I,G){return G.match(f)?J:I+"></"+G+">"});var D=B.replace(h,"").substring(0,10).toLowerCase();C=q.createElement("div");var F=!D.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!D.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||D.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!D.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!D.indexOf("<td")||!D.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!D.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>",
"</colgroup></table>"]||SC.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];for(C.innerHTML=F[1]+B+F[2];F[0]--;)C=C.lastChild;if(SC.browser.msie){D=!D.indexOf("<table")&&D.indexOf("<tbody")<0?C.firstChild&&C.firstChild.childNodes:F[1]==="<table>"&&D.indexOf("<tbody")<0?C.childNodes:[];for(F=D.length-1;F>=0;--F)x.nodeName(D[F],"tbody")&&!D[F].childNodes.length&&D[F].parentNode.removeChild(D[F]);/^\s/.test(B)&&C.insertBefore(q.createTextNode(B.match(/^\s*/)[0]),C.firstChild)}B=x.makeArray(C.childNodes)}if(!(B.length===
0&&!x.nodeName(B,"form")&&!x.nodeName(B,"select")))if(B[0]===undefined||x.nodeName(B,"form")||B.options)y.push(B);else y=x.merge(y,B)}});return y},find:function(n,q){var y;if(typeof n!=="string")return[n];if(n.indexOf(",")>=0){y=n.split(",").map(function(L){return x.find(L,q)});return y.concat.apply([],y).uniq()}if(q&&q.nodeType!==1&&q.nodeType!==9)return[];q=q||document;y=[q];for(var C=YES,B=n.match(p),D=B.length,F=0;F<D;F++){n=B[F];if(n===" "||n==="")C=YES;else if(C){n=w.exec(n);if(n[1]===""&&F<
D-1&&B[F+1].charAt(0)==="#"){n=B[F+1];B[F+1]=B[F];n=w.exec(n)}C=[];var J=y.length,I,G,K=n[2],H;for(I=0;I<J;I++){G=y[I];switch(n[1]){case "":K||(K="*");if(K==="*"&&G.nodeName.toLowerCase()==="object")K="param";C=x.merge(C,G.getElementsByTagName(K));break;case "#":if(G===document){H=document.getElementById(K);if(SC.browser.msie&&H&&H.getAttribute("id")!==K)H=NO;else{H&&C.push(H);H=YES}}else H=NO;if(!H){H=G.getElementsByTagName("*");(H=Array.prototype.find.call(H,function(L){return L.getAttribute&&L.getAttribute("id")===
K}))&&C.push(H)}break;case ".":C=G.getElementsByClassName?x.merge(C,G.getElementsByClassName(K)):x.merge(C,x.classFilter(G.getElementsByTagName("*"),K));break;default:}}delete y;y=C;C=NO}else y=x.filter(n,y)}y&&y[0]==q&&y.shift();return y.uniq()},classFilter:function(n,q,y){q=" "+q+" ";for(var C=[],B,D=0;n[D];D++){B=(" "+n[D].className+" ").indexOf(q)>=0;if(!y&&B||y&&!B)C.push(n[D])}return C},filter:function(n,q,y){n=w.exec(n);var C=n[2];n=n[1];if(n===".")return x.classFilter(x.makeArray(q),C,y);
else{n=n==="#"?function(B){B=B&&B.getAttribute&&B.getAttribute("id")===C;return y?!B:B}:function(B){B=x.nodeName(B,C);return y?!B:B};return Array.prototype.filter.call(x.makeArray(q),n)}},multiFilter:function(n,q,y){n=n.indexOf(",")?n.split(","):[n];for(var C=n.length,B,D=[];--C>=0;){B=x.filter(n[C].trim(),q,y);D=y?(q=B):x.merge(B,D)}return D},merge:function(n,q){var y=0,C,B=n.length;if(SC.browser.msie)for(;C=q[y++];){if(C.nodeType!==8)n[B++]=C}else for(;C=q[y++];)n[B++]=C;return n},makeArray:function(n){var q=
[];if(n!==undefined||n!=null){var y=n.length;if(y==null||typeof n==="string"||n.setInterval)q[0]=n;else for(;y;)q[--y]=n[y]}return q},inArray:function(n,q){return q.indexOf?q.indexOf(n):Array.prototype.indexOf.call(q,n)},boxModel:!SC.browser.msie||document.compatMode==="CSS1Compat",props:{"for":"htmlFor","class":"className","float":o,cssFloat:o,styleFloat:o,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan"},prop:function(n,q,y,C,B){if(SC.typeOf(q)===SC.T_FUNCTION)q=
q.call(n,C);return q&&typeof q==="number"&&y==="curCSS"&&!u.test(B)?q+"px":q},grep:function(n,q,y){for(var C=[],B=0,D=n.length;B<D;B++)!y!=!q(n[B],B)&&C.push(n[B]);return C},className:{add:function(n,q){var y=x.className.has;x.each((q||"").split(g),function(C,B){if(n.nodeType===1&&!y(n.className,B))n.className+=(n.className?" ":"")+B})},remove:function(n,q){if(n.nodeType===1)n.className=q!==undefined?x.grep(n.className.split(g),function(y){return!x.className.has(q,y)}).join(" "):""},has:function(n,
q){return n&&x.inArray(q,(n.className||n).toString().split(g))>-1}},swap:function(n,q,y,C,B){var D={},F;for(F in q){D[F]=n.style[F];n.style[F]=q[F]}y=y(n,C,B);for(F in q)n.style[F]=D[F];return y},css:function(n,q,y){if(q==="width"||q==="height"){y=q==="width"?s:v;n=SC.$.isVisible(n)?z(n,q,y):x.swap(n,t,z,q,y);return Math.max(0,n)}return x.curCSS(n,q,y)},curCSS:function(n,q,y){var C,B=n.style;if(q==="opacity"&&SC.browser.msie){C=x.attr(B,"opacity");return C===""?"1":C}if(SC.browser.opera&&q==="display"){var D=
B.outline;B.outline="0 solid black";B.outline=D}if(D=q.match(/float/i))q=o;if(!y&&B&&B[q])C=B[q];else if(A.getComputedStyle){if(D)q="float";q=q.replace(/([A-Z])/g,"-$1").toLowerCase();if((C=A.getComputedStyle(n,null))&&!E(n,A))C=C.getPropertyValue(q);else{B=[];y=[];D=n;for(n=0;D&&E(D);D=D.parentNode)y.unshift(D);for(D=y.length;n<D;n++)if(E(y[n])){B[n]=y[n].style.display;y[n].style.display="block"}C=q==="display"&&B[y.length-1]!==null?"none":C&&C.getPropertyValue(q)||"";n=0;for(D=B.length;n<D;n++)if(B[n]!==
null)y[n].style.display=B[n]}if(q==="opacity"&&C==="")C="1"}else if(n.currentStyle){C=n.currentStyle[q]||n.currentStyle[q.camelize()];if(!/^\d+(px)?$/i.test(C)&&/^\d/.test(C)){q=B.left;y=n.runtimeStyle.left;n.runtimeStyle.left=n.currentStyle.left;B.left=C||0;C=B.pixelLeft+"px";B.left=q;n.runtimeStyle.left=y}}return C},dir:function(n,q){var y=[];for(n=n[q];n&&n!=document;){n.nodeType===1&&y.push(n);n=n[q]}return y},nth:function(n,q,y){q=q||1;for(var C=0;n;n=n[y])if(n.nodeType===1&&++C==q)break;return n},
sibling:function(n,q){for(var y=[];n;n=n.nextSibling)n.nodeType===1&&n!=q&&y.push(n);return y},attr:function(n,q,y){if(!(!n||n.nodeType===3||n.nodeType===8)){var C=!x.isXMLDoc(n),B=y!==undefined,D=SC.browser.msie;q=C&&x.props[q]||q;if(n.tagName){var F=j.test(q);if(q in n&&C&&!F){if(B){if(q==="type"&&x.nodeName(n,"input")&&n.parentNode)throw"type property can't be changed";n[q]=y}if(x.nodeName(n,"form")&&n.getAttributeNode(q))return n.getAttributeNode(q).nodeValue;if(q==="tabIndex")return(q=n.getAttributeNode("tabIndex"))&&
q.specified?q.value:n.nodeName.match(k)?0:n.nodeName.match(/^(a|area)$/i)&&n.href?0:undefined;return n[q]}if(D&&C&&q==="style")return x.attr(n.style,"cssText",y);B&&n.setAttribute(q,""+y);n=D&&C&&F?n.getAttribute(q,2):n.getAttribute(q);return n===null?undefined:n}if(D&&q==="opacity"){if(B){n.zoom=1;n.filter=(n.filter||"").replace(l,"")+(parseInt(y,0)+""=="NaN"?"":"alpha(opacity="+y*100+")")}return n.filter&&n.filter.indexOf("opacity=")>=0?parseFloat(n.filter.match(m)[1])/100+"":""}q=q.camelize();
if(B)n[q]=y;return n[q]}}});x.fn.init.prototype=x.fn;x.each({parent:function(n){return n.parentNode},parents:function(n){return x.dir(n,"parentNode")},next:function(n){return x.nth(n,2,"nextSibling")},prev:function(n){return x.nth(n,2,"previousSibling")},nextAll:function(n){return x.dir(n,"nextSibling")},prevAll:function(n){return x.dir(n,"previousSibling")},siblings:function(n){return x.sibling(n.parentNode.firstChild,n)},children:function(n){return x.sibling(n.firstChild)},contents:function(n){return x.nodeName(n,
"iframe")?n.contentDocument||n.contentWindow.document:x.makeArray(n.childNodes)}},function(n,q){x.fn[n]=function(y){var C=x.map(this,q);if(y&&typeof y==="string")C=x.multiFilter(y,C);return this.pushStack(C.uniq())}});x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(n,q){x.fn[n]=function(){var y=arguments;return this.each(function(){for(var C=0,B=y.length;C<B;C++)x(y[C])[q](this)})}});x.each({removeAttr:function(n){x.attr(this,
n,"");this.nodeType===1&&this.removeAttribute(n)},addClass:function(n){x.className.add(this,n)},removeClass:function(n){x.className.remove(this,n)},toggleClass:function(n){x.className[x.className.has(this,n)?"remove":"add"](this,n)},remove:function(n){if(!n||x.filter(n,[this]).length)this.parentNode&&this.parentNode.removeChild(this)},empty:function(){for(;this.firstChild;)this.removeChild(this.firstChild)}},function(n,q){x.fn[n]=function(){return this.each(q,arguments)}});x.each(["Height","Width"],
function(n,q){var y=q.toLowerCase(),C;x.fn[y]=function(F){if(this[0]===window)C=SC.browser.opera?document.body["client"+q]:SC.browser.safari?window["inner"+q]:document.compatMode?documentElement["client"+q]:document.body["client"+q];else if(this[0]===document)C=Math.max(Math.max(document.body["scroll"+q],document.documentElement["scroll"+q]),Math.max(document.body["offset"+q],document.documentElement["offset"+q]));else return F===undefined?this.length?x.css(this[0],y):null:this.css(y,typeof F==="string"?
F:F+"px");return C};var B=n?"Left":"Top",D=n?"Right":"Bottom";x.fn["inner"+q]=function(){return this[q.toLowerCase()]()+a(this,"padding"+B)+a(this,"padding"+D)};x.fn["outer"+q]=function(F){return this["inner"+q]()+a(this,"border"+B+"Width")+a(this,"border"+D+"Width")+(F?a(this,"margin"+B)+a(this,"margin"+D):0)}});r.fn.offset=function(){function n(M){q(x.curCSS(M,"borderLeftWidth",true),x.curCSS(M,"borderTopWidth",true))}function q(M,N){y+=parseInt(M,10)||0;C+=parseInt(N,10)||0}var y=0,C=0,B=this[0],
D=SC.browser;if(B){var F=B.parentNode,J=B,I=B.offsetParent,G=B.ownerDocument,K=D.safari&&parseInt(D.version,0)<522&&!/adobeair/i.test(D.userAgent),H=x.curCSS,L=x.css(B,"position")==="fixed";if(!(D.mozilla&&B==document.body)&&B.getBoundingClientRect){B=B.getBoundingClientRect();q(B.left+Math.max(G.documentElement.scrollLeft,G.body.scrollLeft),B.top+Math.max(G.documentElement.scrollTop,G.body.scrollTop));q(-G.documentElement.clientLeft,-G.documentElement.clientTop)}else{for(q(B.offsetLeft,B.offsetTop);I;){q(I.offsetLeft,
I.offsetTop);if(D.mozilla&&!/^t(able|d|h)$/i.test(I.tagName)||D.safari&&!K)n(I);if(!L&&H(I,"position")==="fixed")L=true;J=/^body$/i.test(I.tagName)?J:I;I=I.offsetParent}for(;F&&F.tagName&&!i.test(F.tagName);){/^inline|table.*$/i.test(H(F,"display"))||q(-F.scrollLeft,-F.scrollTop);D.mozilla&&H(F,"overflow")!=="visible"&&n(F);F=F.parentNode}if(K&&(L||H(J,"position")==="absolute")||D.mozilla&&H(J,"position")!=="absolute")q(-G.body.offsetLeft,-G.body.offsetTop);L&&q(Math.max(G.documentElement.scrollLeft,
G.body.scrollLeft),Math.max(G.documentElement.scrollTop,G.body.scrollTop))}return{top:C,left:y}}};r.fn.mixin({position:function(){var n;if(this[0]){n=this.offsetParent();var q=this.offset(),y=i.test(n[0].tagName)?{top:0,left:0}:n.offset();q.top-=a(this,"marginTop");q.left-=a(this,"marginLeft");y.top+=a(n,"borderTopWidth");y.left+=a(n,"borderLeftWidth");n={top:q.top-y.top,left:q.left-y.left}}return n},offsetParent:function(){for(var n=this[0].offsetParent||document.body;n&&!i.test(n.tagName)&&x.css(n,
"position")==="static";)n=n.offsetParent;return x(n)}});x.each(["Left","Top"],function(n,q){var y="scroll"+q;x.fn[y]=function(C){if(this[0])return C!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!n?C:x(window).scrollLeft(),n?C:x(window).scrollTop()):(this[y]=C)}):this[0]==window||this[0]==document?self[n?"pageYOffset":"pageXOffset"]||x.boxModel&&document.documentElement[y]||document.body[y]:this[0][y]}});return r}();SC.$=typeof jQuery=="undefined"?SC.CoreQuery:jQuery;
SC.mixin(SC.$.fn,{isCoreQuery:YES,toString:function(){var a=[],b=this.length,c=0;for(c=0;c<b;c++)a[c]="%@: %@".fmt(c,this[c]?this[c].toString():"(null)");return"<$:%@>(%@)".fmt(SC.guidFor(this),a.join(" , "))},isVisible:function(){return Array.prototype.every.call(this,function(a){return SC.$.isVisible(a)})},first:function(){return this.pushStack([this[0]])},last:function(){return this.pushStack([this[this.length-1]])},view:function(){return this.map(function(){for(var a=null,b=this,c;!a&&b&&b!==
document;){if(c=b.getAttribute("id"))a=SC.View.views[c];b=b.parentNode}return a})},setClass:function(a,b){if(SC.none(a))return this;var c=SC.typeOf(a)!==SC.T_STRING,d=this._fixupClass;this.each(function(){if(this.nodeType===1){var e=this.className.split(/\s+/),f=NO;if(c)for(var g in a){if(a.hasOwnProperty(g))f=d(e,g,a[g])||f}else f=d(e,a,b);if(f)this.className=e.join(" ")}});return this},_fixupClass:function(a,b,c){var d=a.indexOf(b);if(c){if(d<0){a.push(b);return YES}}else if(d>=0){a[d]=null;return YES}return NO},
within:function(a){a=SC.$(a);for(var b,c,d,e=a.length,f=this.length;!b&&--f>=0;){c=this[f];for(d=0;!b&&d<e;d++){for(b=a[d];b&&b!==c;)b=b.parentNode;b=b===c}}return b}});
(function(){var a={},b={find:function(g,h){return h!==undefined?SC.Enumerable.find.call(this,g,h):a.find.call(this,g)},filter:function(g,h){return h!==undefined?this.pushStack(SC.Enumerable.filter.call(this,g,h)):a.filter.call(this,g)},filterProperty:function(g,h){return this.pushStack(SC.Enumerable.filterProperty.call(this,g,h))},indexOf:SC.$.index,map:function(g,h){return h!==undefined?SC.Enumerable.map.call(this,g,h):a.map.call(this,g)}},c=SC.$.fn,d=SC.$.jquery==="SC.CoreQuery"?b:SC.Enumerable,
e;for(var f in d)if(d.hasOwnProperty(f)){e=d[f];if(f in b){a[f]=c[f];e=b[f]}c[f]=e}})();SC.mixin(SC.$,{isVisible:function(a){var b=SC.$;return"hidden"!=a.type&&b.css(a,"display")!="none"&&b.css(a,"visibility")!="hidden"}});sc_require("system/core_query");
SC.Event=function(a){if(a){this.originalEvent=a;for(var b=SC.Event._props,c=b.length,d;--c>=0;){d=b[c];this[d]=a[d]}}this.timeStamp=this.timeStamp||Date.now();if(!this.target)this.target=this.srcElement||document;if(this.target.nodeType===3)this.target=this.target.parentNode;if(!this.relatedTarget&&this.fromElement)this.relatedTarget=this.fromElement===this.target?this.toElement:this.fromElement;if(SC.none(this.pageX)&&!SC.none(this.clientX)){b=document.documentElement;c=document.body;this.pageX=
this.clientX+(b&&b.scrollLeft||c&&c.scrollLeft||0)-(b.clientLeft||0);this.pageY=this.clientY+(b&&b.scrollTop||c&&c.scrollTop||0)-(b.clientTop||0)}if(!this.which&&(this.charCode||a.charCode===0?this.charCode:this.keyCode))this.which=this.charCode||this.keyCode;if(!this.metaKey&&this.ctrlKey)this.metaKey=this.ctrlKey;if(!this.which&&this.button)this.which=this.button&1?1:this.button&2?3:this.button&4?2:0;if(SC.browser.safari&&a.wheelDelta!==undefined){this.wheelDelta=this.wheelDeltaY=0-(a.wheelDeltaY||
a.wheelDelta);this.wheelDeltaX=0-(a.wheelDeltaX||0)}else if(SC.none(a.detail)){this.wheelDelta=this.wheelDeltaY=SC.browser.msie?0-a.wheelDelta:a.wheelDelta;this.wheelDeltaX=0}else{b=Math.floor(a.detail*2);if(a.axis&&a.axis===a.HORIZONTAL_AXIS){this.wheelDeltaX=b;this.wheelDeltaY=this.wheelDelta=0}else{this.wheelDeltaY=this.wheelDelta=b;this.wheelDeltaX=0}}return this};
SC.mixin(SC.Event,{create:function(a){return new SC.Event(a)},add:function(a,b,c,d,e){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(h){this.add(h,b,c,d,e)},this);return this}else a=a[0];if(!a)return this;if(a.nodeType===3||a.nodeType===8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;if(SC.typeOf(c)===SC.T_FUNCTION){e=d;d=c;c=null}else if(c&&SC.typeOf(d)===SC.T_STRING)d=c[d];var f=SC.data(a,"events")||SC.data(a,"events",{}),g=f[b];if(!g){g=f[b]={};this._addEventListener(a,b)}g[SC.guidFor(d)]=
[c,d,e];SC.Event._global[b]=YES;a=f=g=null;return this},remove:function(a,b,c,d){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(i){this.remove(i,b,c,d)},this);return this}else a=a[0];if(!a)return this;if(a.nodeType===3||a.nodeType===8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;var e,f,g=SC.data(a,"events");if(!g)return this;if(b===undefined)for(b in g)this.remove(a,b);else if(e=g[b]){var h=NO;if(c||d){if(SC.typeOf(c)===SC.T_FUNCTION){d=c;c=null}else if(SC.typeOf(d)===SC.T_STRING)d=
c[d];delete e[SC.guidFor(d)];f=null;for(f in e)break;if(f===null)h=YES}else h=YES;if(h){delete g[b];this._removeEventListener(a,b)}f=null;for(f in g)break;if(!f){SC.removeData(a,"events");delete this._elements[SC.guidFor(a)]}}a=g=e=null;return this},NO_BUBBLE:["blur","focus","change"],simulateEvent:function(a,b,c){a=SC.Event.create({type:b,target:a,preventDefault:function(){this.cancelled=YES},stopPropagation:function(){this.bubbles=NO},allowDefault:function(){this.hasCustomEventHandling=YES},timeStamp:Date.now(),
bubbles:this.NO_BUBBLE.indexOf(b)<0,cancelled:NO,normalized:YES});c&&SC.mixin(a,c);return a},trigger:function(a,b,c,d){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(j){this.trigger(j,b,c,d)},this);return this}else a=a[0];if(!a)return this;if(!(a.nodeType===3||a.nodeType===8)){c=SC.A(c);var e,f=SC.typeOf(a[b]||null)===SC.T_FUNCTION,g,h;g=c[0];if(!g||!g.preventDefault){g=this.simulateEvent(a,b);c.unshift(g)}g.type=b;h=a;do{e=SC.Event.handle.apply(h,c);h=h===document?null:h.parentNode||document}while(!e&&
g.bubbles&&h);h=null;g=a["on"+b];h=SC.CoreQuery.nodeName(a,"a")&&b==="click";if((!f||h)&&g&&g.apply(a,c)===NO)e=NO;if(f&&d!==NO&&e!==NO&&!h){this.triggered=YES;try{a[b]()}catch(i){}}this.triggered=NO;return e}},handle:function(a){if(typeof SC==="undefined"||SC.Event.triggered)return YES;var b,c,d,e,f,g;e=SC.A(arguments);e[0]=a=SC.Event.normalizeEvent(a||window.event);d=(SC.data(this,"events")||{})[a.type];if(!d)return NO;for(f in d){g=d[f];c=g[1];a.handler=c;a.data=a.context=g[2];g=g[0]||this;c=c.apply(g,
e);if(b!==NO)b=c;if(c===NO){a.preventDefault();a.stopPropagation()}}return b},unload:function(){var a,b=this._elements;for(a in b)this.remove(b[a]);for(a in b)delete b[a];delete this._elements},special:{ready:{setup:function(){SC._bindReady()},teardown:function(){}},mouseenter:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseover",SC.Event.special.mouseover.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseover",SC.Event.special.mouseover.handler);
return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;a.type="mouseenter";return SC.Event.handle.apply(this,arguments)}},mouseleave:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;a.type="mouseleave";return SC.Event.handle.apply(this,
arguments)}}},KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,_withinElement:function(a,b){for(a=a.relatedTarget;a&&a!=b;)try{a=a.parentNode}catch(c){a=b}return a===b},_addEventListener:function(a,b){var c;c=this.special[b];if(!c||c.setup.call(a)===NO){var d=SC.guidFor(a);this._elements[d]=a;c=SC.data(a,"listener")||SC.data(a,"listener",function(){return SC.Event.handle.apply(SC.Event._elements[d],
arguments)});if(a.addEventListener)a.addEventListener(b,c,NO);else a.attachEvent&&a.attachEvent("on"+b,c)}a=c=c=null},_removeEventListener:function(a,b){var c;c=SC.Event.special[b];if(!c||c.teardown.call(a)===NO)if(c=SC.data(a,"listener"))if(a.removeEventListener)a.removeEventListener(b,c,NO);else a.detachEvent&&a.detachEvent("on"+b,c)},_elements:{},normalizeEvent:function(a){return a===window.event?SC.Event.create(a):a.normalized?a:SC.Event.create(a)},_global:{},_props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view which touches targetTouches changedTouches".split(" ")});
SC.Event.prototype={hasCustomEventHandling:NO,allowDefault:function(){this.hasCustomEventHandling=YES;return this},preventDefault:function(){var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=NO}this.hasCustomEventHandling=YES;return this},stopPropagation:function(){var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=YES}this.hasCustomEventHandling=YES;return this},stop:function(){return this.preventDefault().stopPropagation()},normalized:YES,
getCharString:function(){return SC.browser.msie?this.keyCode==8||this.keyCode==9||this.keyCode>=37&&this.keyCode<=40?String.fromCharCode(0):this.keyCode>0?String.fromCharCode(this.keyCode):null:this.charCode>0?String.fromCharCode(this.charCode):null},commandCodes:function(){var a=this.keyCode,b=null,c=null,d="";if(a){b=SC.FUNCTION_KEYS[a];if(!b&&(this.altKey||this.ctrlKey||this.metaKey))b=SC.PRINTABLE_KEYS[a];if(b){if(this.altKey)d+="alt_";if(this.ctrlKey||this.metaKey)d+="ctrl_";if(this.shiftKey)d+=
"shift_"}}if(!b){a=this.which;c=b=String.fromCharCode(a);a=b.toLowerCase();if(this.metaKey){d="meta_";b=a}else b=null}if(b)b=d+b;return[b,c]}};SC.Event.observe=SC.Event.add;SC.Event.stopObserving=SC.Event.remove;SC.Event.fire=SC.Event.trigger;SC.Event.add(window,"unload",SC.Event.prototype,SC.Event.unload);SC.MODIFIER_KEYS={16:"shift",17:"ctrl",18:"alt"};
SC.FUNCTION_KEYS={8:"backspace",9:"tab",13:"return",19:"pause",27:"escape",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",44:"printscreen",45:"insert",46:"delete",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock"};
SC.PRINTABLE_KEYS={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:'"'};SC.SYSTEM_CURSOR="default";SC.AUTO_CURSOR=SC.DEFAULT_CURSOR="auto";SC.CROSSHAIR_CURSOR="crosshair";
SC.HAND_CURSOR=SC.POINTER_CURSOR="pointer";SC.MOVE_CURSOR="move";SC.E_RESIZE_CURSOR="e-resize";SC.NE_RESIZE_CURSOR="ne-resize";SC.NW_RESIZE_CURSOR="nw-resize";SC.N_RESIZE_CURSOR="n-resize";SC.SE_RESIZE_CURSOR="se-resize";SC.SW_RESIZE_CURSOR="sw-resize";SC.S_RESIZE_CURSOR="s-resize";SC.W_RESIZE_CURSOR="w-resize";SC.IBEAM_CURSOR=SC.TEXT_CURSOR="text";SC.WAIT_CURSOR="wait";SC.HELP_CURSOR="help";
SC.Cursor=SC.Object.extend({init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("cursorStyle")||SC.DEFAULT_CURSOR,b=this.constructor.sharedStyleSheet();if(b.insertRule)b.insertRule(".%@ {cursor: %@;}".fmt(SC.guidFor(this),a),b.cssRules?b.cssRules.length:0);else b.addRule&&b.addRule("."+SC.guidFor(this),"cursor: "+a);this.cursorStyle=a;this.className=SC.guidFor(this);return this},className:null,cursorStyle:SC.DEFAULT_CURSOR,cursorStyleDidChange:function(){var a,b,c,d,e,f;a=this.get("cursorStyle")||
SC.DEFAULT_CURSOR;if(b=this._rule)b.style.cursor=a;else{c="."+this.get("className");b=this.constructor.sharedStyleSheet();d=(b.cssRules?b.cssRules:b.rules)||[];e=0;for(f=d.length;e<f;++e){b=d[e];if(b.selectorText===c){this._rule=b;b.style.cursor=a;break}}}}.observes("cursorStyle")});
SC.Cursor.sharedStyleSheet=function(){var a,b=this._styleSheet;if(!b){b=document.createElement("style");b.type="text/css";a=document.getElementsByTagName("head")[0];if(!a)a=document.documentElement;a.appendChild(b);this._styleSheet=b=document.styleSheets[document.styleSheets.length-1]}return b};
SC.Responder=SC.Object.extend({isResponder:YES,pane:null,responderContext:null,nextResponder:null,isFirstResponder:NO,hasFirstResponder:NO,acceptsFirstResponder:YES,becomeFirstResponder:function(){var a=this.get("pane")||this.get("responderContext")||this.pane();a&&this.get("acceptsFirstResponder")&&a.get("firstResponder")!==this&&a.makeFirstResponder(this);return this},resignFirstResponder:function(){var a=this.get("pane")||this.get("responderContext");a&&a.get("firstResponder")===this&&a.makeFirstResponder(null);
return YES},willLoseFirstResponder:function(){},didBecomeFirstResponder:function(){}});sc_require("system/browser");sc_require("system/event");sc_require("system/cursor");sc_require("system/responder");sc_require("mixins/string");SC.viewKey=SC.guidKey+"_view";SC.LAYOUT_HORIZONTAL="sc-layout-horizontal";SC.LAYOUT_VERTICAL="sc-layout-vertical";SC._VIEW_DEFAULT_DIMS="marginTop marginLeft".w();SC.ANCHOR_TOP={top:0};SC.ANCHOR_LEFT={left:0};SC.ANCHOR_TOP_LEFT={top:0,left:0};SC.ANCHOR_BOTTOM={bottom:0};
SC.ANCHOR_RIGHT={right:0};SC.ANCHOR_BOTTOM_RIGHT={bottom:0,right:0};SC.FULL_WIDTH={left:0,right:0};SC.FULL_HEIGHT={top:0,bottom:0};SC.ANCHOR_CENTER={centerX:0,centerY:0};SC.LAYOUT_AUTO="auto";SC.EMPTY_CHILD_VIEWS_ARRAY=[];SC.EMPTY_CHILD_VIEWS_ARRAY.needsClone=YES;
SC.View=SC.Responder.extend(SC.DelegateSupport,{concatenatedProperties:"outlets displayProperties layoutProperties classNames renderMixin didCreateLayerMixin willDestroyLayerMixin".w(),pane:function(){for(var a=this;a&&!a.isPane;)a=a.get("parentView");return a}.property("parentView").cacheable(),page:null,splitView:function(){for(var a=this;a&&!a.isSplitView;)a=a.get("parentView");return a}.property("parentView").cacheable(),parentView:null,backgroundColor:null,isEnabled:YES,isEnabledBindingDefault:SC.Binding.oneWay().bool(),
isEnabledInPane:function(){var a=this.get("isEnabled"),b;if(a&&(b=this.get("parentView")))a=b.get("isEnabledInPane");return a}.property("parentView","isEnabled"),isVisible:YES,isVisibleBindingDefault:SC.Binding.bool(),isVisibleInWindow:NO,recomputeIsVisibleInWindow:function(a){this.get("isVisibleInWindow");var b=this.get("isVisible"),c;if(b)b=a===undefined?(c=this.get("parentView"))?c.get("isVisibleInWindow"):NO:a;this.set("isVisibleInWindow",b);this._needsVisibiltyChange=YES;a=this.get("childViews");
c=a.length;var d;for(d=0;d<c;d++)a[d].recomputeIsVisibleInWindow(b);if(b){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}this.set("layerNeedsUpdate",YES);!b&&this.get("isFirstResponder")&&this.resignFirstResponder();return this}.observes("isVisible"),childViews:SC.EMPTY_CHILD_VIEWS_ARRAY,insertBefore:function(a,b){a.beginPropertyChanges();a.get("parentView")&&a.removeFromParent();this.willAddChild&&this.willAddChild(a,
b);a.willAddToParent&&a.willAddToParent(this,b);a.set("parentView",this);var c,d=this.get("childViews");if(d.needsClone)this.set(d=[]);c=b?d.indexOf(b):d.length;if(c<0)c=d.length;d.insertAt(c,a);a.parentViewDidChange();a.layoutDidChange();(c=a.get("pane"))&&c.get("isPaneAttached")&&a._notifyDidAppendToDocument();this.didAddChild&&this.didAddChild(a,b);a.didAddToParent&&a.didAddToParent(this,b);a.endPropertyChanges();return this},removeChild:function(a){if(!a)return this;if(a.parentView!==this)throw"%@.removeChild(%@) must belong to parent".fmt(this,
a);a.willRemoveFromParent&&a.willRemoveFromParent();this.willRemoveChild&&this.willRemoveChild(a);a.set("parentView",null);var b=this.get("childViews"),c=b.indexOf(a);c>=0&&b.removeAt(c);a.parentViewDidChange();this.didRemoveChild&&this.didRemoveChild(a);a.didRemoveFromParent&&a.didRemoveFromParent(this);return this},removeAllChildren:function(){for(var a=this.get("childViews"),b;b=a.objectAt(a.get("length")-1);)this.removeChild(b);return this},removeFromParent:function(){var a=this.get("parentView");
a&&a.removeChild(this);return this},replaceChild:function(a,b){a.beginPropertyChanges();b.beginPropertyChanges();this.beginPropertyChanges();this.insertBefore(a,b).removeChild(b);this.endPropertyChanges();b.endPropertyChanges();a.endPropertyChanges();return this},replaceAllChildren:function(a){var b=a.get("length"),c;this.beginPropertyChanges();this.destroyLayer().removeAllChildren();for(c=0;c<b;c++)this.appendChild(a.objectAt(c));this.replaceLayer();this.endPropertyChanges();return this},appendChild:function(a){return this.insertBefore(a,
null)},parentViewDidChange:function(){this.recomputeIsVisibleInWindow();this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded);this._invalidatePaneCacheForSelfAndAllChildViews();return this}.observes("isVisible"),_invalidatePaneCacheForSelfAndAllChildViews:function(){this.notifyPropertyChange("pane");var a=this.get("childViews"),b=a.length,c;for(c=0;c<b;++c){var d=a[c];d._invalidatePaneCacheForSelfAndAllChildViews&&d._invalidatePaneCacheForSelfAndAllChildViews()}},
layer:function(a,b){if(b!==undefined)this._view_layer=b;else{b=this._view_layer;if(!b){if(a=this.get("parentView"))a=a.get("layer");if(a)this._view_layer=b=this.findLayerInParentLayer(a)}}return b}.property("isVisibleInWindow").cacheable(),$:function(a){var b=this.get("layer");return!b?SC.$([]):a===undefined?SC.$(b):SC.$(a,b)},containerLayer:function(){return this.get("layer")}.property("layer").cacheable(),layerId:function(){return SC.guidFor(this)}.property().cacheable(),findLayerInParentLayer:function(a){var b=
this.get("layerId"),c,d,e,f;f=a.getElementById?a.getElementById(b):document.getElementById(b);if(SC.browser.msie&&f&&f.id!==b)f=null;if(!f&&a.querySelector)f=a.querySelector("#"+b);if(!f){f=a.firstChild;var g=[];for(g.push(a);g.length!==0;){a=g[0];g.shift();if(a.id===b){e=true;f=a;break}c=0;for(d=a.childNodes.length;c<d;c++)g.push(a.childNodes[c])}e||(f=null)}return f},displayDidChange:function(){this.set("layerNeedsUpdate",YES);return this},layerNeedsUpdate:NO,_view_layerNeedsUpdateDidChange:function(){this.get("layerNeedsUpdate")&&
this.invokeOnce(this.updateLayerIfNeeded)}.observes("layerNeedsUpdate"),updateLayerIfNeeded:function(){if((this.get("isVisibleInWindow")||this._needsVisibiltyChange)&&this.get("layerNeedsUpdate")){this._needsVisibiltyChange=NO;if(this.get("layer")){this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.updateLayer();this.endPropertyChanges()}}else this.set("layerNeedsUpdate",NO);return this},updateLayer:function(){var a=this.renderContext(this.get("layer"));this.prepareContext(a,NO);a.update();
if(a._innerHTMLReplaced)(a=this.get("pane"))&&a.get("isPaneAttached")&&this._notifyDidAppendToDocument();this.didUpdateLayer&&this.didUpdateLayer();this.designer&&this.designer.viewDidUpdateLayer&&this.designer.viewDidUpdateLayer();return this},renderContext:function(a){return SC.RenderContext(a)},createLayer:function(){if(this.get("layer"))return this;var a=this.renderContext(this.get("tagName"));this.prepareContext(a,YES);this.set("layer",a.element());this._notifyDidCreateLayer();return this},_notifyDidCreateLayer:function(){this.didCreateLayer&&
this.didCreateLayer();var a=this.didCreateLayerMixin,b,c,d=this.get("childViews");if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}b=d.length;for(c=0;c<b;++c)d[c]&&d[c]._notifyDidCreateLayer()},destroyLayer:function(){var a=this.get("layer");if(a){this._notifyWillDestroyLayer();a.parentNode&&a.parentNode.removeChild(a)}return this},replaceLayer:function(){this.destroyLayer();this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded)},_notifyWillDestroyLayer:function(){this.willDestroyLayer&&
this.willDestroyLayer();var a=this.willDestroyLayerMixin,b,c,d=this.get("childViews");if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}b=d.length;for(c=0;c<b;++c)d[c]._notifyWillDestroyLayer();this.set("layer",null)},prepareContext:function(a,b){var c,d,e;if(b){c=this.layerId?this.get("layerId"):SC.guidFor(this);a.id(c).classNames(this.get("classNames"),YES);this.renderLayout(a,b)}else{a.resetClassNames();a.classNames(this.get("classNames"),YES)}this.get("isTextSelectable")&&a.addClass("allow-select");
this.get("isEnabled")||a.addClass("disabled");this.get("isVisible")||a.addClass("hidden");this.get("isFirstResponder")&&a.addClass("focus");(c=this.get("backgroundColor"))&&a.addStyle("backgroundColor",c);(c=this.get("cursor"))&&a.addClass(c.get("className"));this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.render(a,b);if(c=this.renderMixin){d=c.length;for(e=0;e<d;++e)c[e].call(this,a,b)}this.endPropertyChanges()},renderChildViews:function(a,b){var c=this.get("childViews"),d=c.length,
e,f;for(e=0;e<d;++e)if(f=c[e]){a=a.begin(f.get("tagName"));f.prepareContext(a,b);a=a.end()}return a},render:function(a,b){b&&this.renderChildViews(a,b)},_notifyDidAppendToDocument:function(){this.didAppendToDocument&&this.didAppendToDocument();var a=0,b,c,d=this.get("childViews");a=0;for(c=d.length;a<c;a++){b=d[a];b._notifyDidAppendToDocument&&b._notifyDidAppendToDocument()}},tagName:"div",classNames:["sc-view"],toolTip:null,isTextSelectable:NO,displayProperties:["isFirstResponder","isVisible"],cursor:null,
layerLocationNeedsUpdate:NO,updateLayerLocationIfNeeded:function(){if(this.get("layerLocationNeedsUpdate")){this.set("layerLocationNeedsUpdate",NO);this.updateLayerLocation()}return this},updateLayerLocation:function(){var a=this.get("layer"),b=this.get("parentView"),c=b?b.get("containerLayer"):null;a&&a.parentNode&&a.parentNode!==c&&a.parentNode.removeChild(a);if(b)if(c){if(!a){this.createLayer();a=this.get("layer")}b=b.get("childViews");var d=(b=b.objectAt(b.indexOf(this)+1))?b.get("layer"):null;
if(b&&(!d||d.parentNode!==c)){b.updateLayerLocationIfNeeded();d=b.get("layer")}if(a.parentNode!==c||a.nextSibling!==d){c.insertBefore(a,d);this.parentViewDidResize&&this.parentViewDidResize()}}else{if(a){a.parentNode&&a.parentNode.removeChild(a);this.destroyLayer()}}else a&&a.parentNode&&a.parentNode.removeChild(a);return this},nextResponder:function(){return this.get("parentView")}.property("parentView").cacheable(),acceptsFirstResponder:NO,isKeyResponder:NO,willLoseKeyResponderTo:function(){},willBecomeKeyResponderFrom:function(){},
didLoseKeyResponderTo:function(){},didBecomeKeyResponderFrom:function(){},interpretKeyEvents:function(a){var b=a.commandCodes(),c=b[0];b=b[1];if(!c&&!b)return null;if(c)if(c=SC.MODIFIED_KEY_BINDINGS[c]||SC.BASE_KEY_BINDINGS[c.match(/[^_]+$/)[0]]){b=this;for(var d=this.get("pane"),e=null;b&&!(e=b.tryToPerform(c,a));)b=b===d?null:b.get("nextResponder");return e}if(b&&this.respondsTo("insertText"))return(a=this.insertText(b,a))?a===YES?this:a:null;return null},insertText:function(){return NO},performKeyEquivalent:function(a,
b){for(var c=NO,d=this.get("childViews"),e=d.length,f=-1;!c&&++f<e;)c=d[f].performKeyEquivalent(a,b);return c},nextKeyView:null,nextValidKeyView:function(){return this.pane()._computeNextValidKeyView(this,[])}.property("nextKeyView"),_computeNextValidKeyView:function(a,b){var c=this.get("nextKeyView"),d,e,f,g;if(this!==a&&b.indexOf(a)!=-1&&this.get("acceptsFirstResponder")&&this.get("isVisibleInWindow"))return this;b.push(this);if(!c){d=this.get("childViews");e=0;for(f=d.length;e<f;e++){g=d[e];if(g.get("isVisibleInWindow")&&
g.get("isVisible"))c=g._computeNextValidKeyView(a,b);if(c)return c}c=null}return c},previousKeyView:null,previousValidKeyView:function(){return this.pane()._computePreviousValidKeyView(this,[])}.property("previousKeyView"),_computePreviousValidKeyView:function(a,b){var c=this.get("previousKeyView"),d,e,f;if(this!==a&&b.indexOf(a)!=-1&&this.get("acceptsFirstResponder")&&this.get("isVisibleInWindow"))return this;b.push(this);if(!c){d=this.get("childViews");for(e=d.length-1;0<=e;e--){f=d[e];if(f.get("isVisibleInWindow")&&
f.get("isVisible"))c=f._computePreviousValidKeyView(a,b);if(c)return c}c=null}return c},init:function(){var a,b;arguments.callee.base.apply(this,arguments);this.get("isMaterialized")||(SC.View.views[this.get("layerId")]=this);this.childViews=(a=this.get("childViews"))?a.slice():[];this.createChildViews();b=this.get("displayProperties");for(a=b.length;--a>=0;)this.addObserver(b[a],this,this.displayDidChange);this.get("isDropTarget")&&SC.Drag.addDropTarget(this);this.get("isScrollable")&&SC.Drag.addScrollableView(this)},
awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("childViews"),b=a.length,c;for(c=0;c<b;++c)a[c]&&a[c].awake()},destroy:function(){if(this.get("isDestroyed"))return this;arguments.callee.base.apply(this,arguments);this.removeFromParent();this._destroy();this.get("isDropTarget")&&SC.Drag.removeDropTarget(this);this.get("isScrollable")&&SC.Drag.removeScrollableView(this);return this},_destroy:function(){if(this.get("isDestroyed"))return this;this.destroyLayer();var a=this.get("childViews"),
b=a.length,c;if(b){a=a.slice();for(c=0;c<b;++c)a[c]._destroy()}delete SC.View.views[this.get("layerId")];delete this._CQ;delete this.page;this.set("isDestroyed",YES);return this},createChildViews:function(){var a=this.get("childViews"),b=a.length,c,d,e;this.beginPropertyChanges();for(c=0;c<b;++c){if(d=e=a[c]){if(typeof d===SC.T_STRING)e=this[d];else d=null;if(!e){console.error("No view with name "+d+" has been found in "+this.toString());continue}if(e.isClass){e=this.createChildView(e);if(d)this[d]=
e}}a[c]=e}this.endPropertyChanges();return this},createChildView:function(a,b){b||(b={});b.owner=b.parentView=this;b.isVisibleInWindow=this.get("isVisibleInWindow");if(!b.page)b.page=this.page;return a=a.create(b)},adjust:function(a,b){var c=SC.clone(this.get("layout")),d=NO,e;if(a===undefined)return this;if(SC.typeOf(a)===SC.T_STRING){e=c[a];if(SC.none(b)){if(e!==undefined)d=YES;delete c[a]}else{if(e!==b)d=YES;c[a]=b}}else{var f=a;for(a in f)if(f.hasOwnProperty(a)){b=f[a];e=c[a];if(b===null){if(e!==
undefined)d=YES;delete c[a]}else if(b!==undefined){if(e!==b)d=YES;c[a]=b}}}d&&this.set("layout",c);return this},layout:{top:0,left:0,bottom:0,right:0},convertFrameToView:function(a,b){var c=0,d=0,e=0,f=0,g=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;g;){h=g.get("frame");c+=h.x;d+=h.y;g=g.get("layoutView")}if(b)for(g=b;g;){h=g.get("frame");e+=h.x;f+=h.y;g=g.get("layoutView")}c=a.x+c-e;d=a.y+d-f;return{x:c,y:d,width:a.width,height:a.height}},
convertFrameFromView:function(a,b){var c=0,d=0,e=0,f=0,g=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;g&&g.get("frame");){h=g.get("frame");c+=h.x;d+=h.y;g=g.get("parentView")}if(b)for(g=b;g;){h=g.get("frame");e+=h.x;f+=h.y;g=g.get("parentView")}c=a.x-c+e;d=a.y-d+f;return{x:c,y:d,width:a.width,height:a.height}},scrollToVisible:function(){for(var a=this.get("parentView");a&&!a.get("isScrollable");)a=a.get("parentView");if(a){a.scrollToVisible();
return a.scrollToVisible(this)}else return NO},frame:function(){return this.computeFrameWithParentFrame(null)}.property("layout","useStaticLayout").cacheable(),computeFrameWithParentFrame:function(a){var b=this.get("layout"),c={},d=SC.LAYOUT_AUTO,e=this.get("useStaticLayout");if(b.width!==undefined&&b.width===SC.LAYOUT_AUTO&&e!==undefined&&!e){b=SC.Error.desc("%@.layout() you cannot use width:auto if staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(b.height!==
undefined&&b.height===SC.LAYOUT_AUTO&&e!==undefined&&!e){b=SC.Error.desc("%@.layout() you cannot use height:auto if staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(e)return null;if(SC.none(b.left))if(SC.none(b.right))if(SC.none(b.centerX)){c.x=0;if(SC.none(b.width)){a||(a=this.computeParentDimensions(b));c.width=Math.floor(a.width)}else c.width=b.width===d?d:Math.floor(b.width||0)}else{a||(a=this.computeParentDimensions(b));c.width=b.width===d?d:Math.floor(b.width||
0);c.x=Math.floor((a.width-c.width)/2+b.centerX)}else{a||(a=this.computeParentDimensions(b));if(SC.none(b.width)){c.width=a.width-b.right;c.x=0}else{c.width=b.width===d?d:Math.floor(b.width||0);c.x=Math.floor(a.width-b.right-c.width)}}else{c.x=Math.floor(b.left);if(b.width!==undefined)c.width=b.width===d?d:Math.floor(b.width);else{a||(a=this.computeParentDimensions(b));c.width=Math.floor(a.width-c.x-(b.right||0))}}if(SC.none(b.top))if(SC.none(b.bottom))if(SC.none(b.centerY)){c.y=0;if(SC.none(b.height)){a||
(a=this.computeParentDimensions(b));c.height=Math.floor(a.height)}else c.height=b.height===d?d:Math.floor(b.height||0)}else{a||(a=this.computeParentDimensions(b));c.height=b.height===d?d:Math.floor(b.height||0);c.y=Math.floor((a.height-c.height)/2+b.centerY)}else{a||(a=this.computeParentDimensions(b));if(SC.none(b.height)){c.height=a.height-b.bottom;c.y=0}else{c.height=b.height===d?d:Math.floor(b.height||0);c.y=Math.floor(a.height-b.bottom-c.height)}}else{c.y=Math.floor(b.top);if(b.height!==undefined)c.height=
b.height===d?d:Math.floor(b.height);else{a||(a=this.computeParentDimensions(b));c.height=Math.floor(a.height-c.y-(b.bottom||0))}}if(c.height===d||c.width===d){a=this.get("layer");if(c.height===d)c.height=a?a.clientHeight:0;if(c.width===d)c.width=a?a.clientWidth:0}if(!SC.none(b.maxHeight)&&c.height>b.maxHeight)c.height=b.maxHeight;if(!SC.none(b.minHeight)&&c.height<b.minHeight)c.height=b.minHeight;if(!SC.none(b.maxWidth)&&c.width>b.maxWidth)c.width=b.maxWidth;if(!SC.none(b.minWidth)&&c.width<b.minWidth)c.width=
b.minWidth;if(c.height<0)c.height=0;if(c.width<0)c.width=0;return c},computeParentDimensions:function(a){var b=this.get("parentView");return(b=b?b.get("frame"):null)?{width:b.width,height:b.height}:{width:(a.left||0)+(a.width||0)+(a.right||0),height:(a.top||0)+(a.height||0)+(a.bottom||0)}},clippingFrame:function(){var a=this.get("parentView"),b=this.get("frame"),c=b;if(a){a=a.get("clippingFrame");c=SC.intersectRects(a,b)}c.x-=b.x;c.y-=b.y;return c}.property("parentView","frame").cacheable(),_sc_view_clippingFrameDidChange:function(){var a=
this.get("childViews"),b=a.length,c,d;for(c=0;c<b;++c){d=a[c];d.hasStaticLayout||d.notifyPropertyChange("clippingFrame")}}.observes("clippingFrame"),parentViewDidResize:function(){var a=this.get("layout");if(!(a.left!==undefined&&a.top!==undefined&&a.width!==undefined&&a.height!==undefined)){this.notifyPropertyChange("frame");this.viewDidResize()}},viewDidResize:function(){var a=this.childViews,b=a.length,c,d;for(c=0;c<b;++c){d=a[c];d.parentViewDidResize&&d.parentViewDidResize()}}.observes("layout"),
beginLiveResize:function(){this.willBeginLiveResize&&this.willBeginLiveResize();var a=this.get("childViews"),b=a.length,c,d;for(c=0;c<b;++c){d=a[c];d.beginLiveResize&&d.beginLiveResize()}return this},endLiveResize:function(){var a=this.get("childViews"),b,c;for(b=a.length-1;b>=0;--b){c=a[b];c.endLiveResize&&c.endLiveResize()}this.didEndLiveResize&&this.didEndLiveResize();return this},layoutStyle:function(){var a=this.get("layout"),b={},c=this.get("useStaticLayout");if(a.width!==undefined&&a.width===
SC.LAYOUT_AUTO&&!c){b=SC.Error.desc("%@.layout() you cannot use width:auto if  staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(a.height!==undefined&&a.height===SC.LAYOUT_AUTO&&!c){b=SC.Error.desc("%@.layout() you cannot use height:auto if  staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(SC.none(a.left))if(SC.none(a.right))if(SC.none(a.centerX)){if(SC.none(a.width)){b.left=0;b.right=0;b.width=null}else{b.left=
0;b.right=null;b.width=a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width)}b.marginLeft=0}else{b.left="50%";b.width=Math.floor(a.width||0);b.marginLeft=Math.floor(a.centerX-b.width/2);b.right=null}else{b.right=Math.floor(a.right);b.marginLeft=0;if(SC.none(a.width)){b.left=0;b.width=null}else{b.left=null;b.width=a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width||0)}}else{b.left=Math.floor(a.left);if(a.width!==undefined){b.width=a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width);
b.right=null}else{b.width=null;b.right=Math.floor(a.right||0)}b.marginLeft=0}b.minWidth=a.minWidth===undefined?null:a.minWidth;b.maxWidth=a.maxWidth===undefined?null:a.maxWidth;if(SC.none(a.top))if(SC.none(a.bottom))if(SC.none(a.centerY)){if(SC.none(a.height)){b.top=0;b.bottom=0;b.height=null}else{b.top=0;b.bottom=null;b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height||0)}b.marginTop=0}else{b.top="50%";b.height=Math.floor(a.height||0);b.marginTop=Math.floor(a.centerY-b.height/
2);b.bottom=null}else{b.marginTop=0;b.bottom=Math.floor(a.bottom);if(SC.none(a.height)){b.top=0;b.height=null}else{b.top=null;b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height||0)}}else{b.top=Math.floor(a.top);if(a.height!==undefined){b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height);b.bottom=null}else{b.height=null;b.bottom=Math.floor(a.bottom||0)}b.marginTop=0}b.minHeight=a.minHeight===undefined?null:a.minHeight;b.maxHeight=a.maxHeight===undefined?null:a.maxHeight;
b.zIndex=SC.none(a.zIndex)?null:a.zIndex.toString();b.backgroundPosition=SC.none(a.backgroundPosition)?null:a.backgroundPosition.toString();a=SC._VIEW_DEFAULT_DIMS;c=a.length;for(var d;--c>=0;){d=a[c];if(b[d]===0)b[d]=null}for(var e in b){a=b[e];if(typeof a===SC.T_NUMBER)b[e]=a+"px"}return b}.property().cacheable(),layoutView:function(){return this.get("parentView")}.property("parentView").cacheable(),layoutDidChange:function(){this.beginPropertyChanges();this.frame&&this.notifyPropertyChange("frame");
this.notifyPropertyChange("layoutStyle");this.endPropertyChanges();var a=this.get("layoutView");if(a){a.set("childViewsNeedLayout",YES);a.layoutDidChangeFor(this);a.get("childViewsNeedLayout")&&a.invokeOnce(a.layoutChildViewsIfNeeded)}return this}.observes("layout"),childViewsNeedLayout:NO,layoutDidChangeFor:function(a){var b=this._needLayoutViews;if(!b)b=this._needLayoutViews=SC.CoreSet.create();b.add(a)},layoutChildViewsIfNeeded:function(a){a||(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){this.set("childViewsNeedLayout",
NO);this.layoutChildViews()}return this},layoutChildViews:function(){var a=this._needLayoutViews,b=a?a.length:0,c,d;for(c=0;c<b;c++){d=a[c];d.updateLayout()}a.clear()},updateLayout:function(){var a=this.get("layer");if(a){a=this.renderContext(a);this.renderLayout(a);a.update()}return this},renderLayout:function(a){a.addStyle(this.get("layoutStyle"))},isView:YES,selectStart:function(){return this.get("isTextSelectable")}});
SC.View.mixin({isViewClass:YES,design:function(){if(this.isDesign)return this;var a=this.extend.apply(this,arguments);a.isDesign=YES;SC.ViewDesigner&&SC.ViewDesigner.didLoadDesign(a,this,SC.A(arguments));return a},layout:function(a){this.prototype.layout=a;return this},convertLayoutToAnchoredLayout:function(a,b){var c={top:0,left:0,width:b.width,height:b.height};if(SC.none(a.left))if(SC.none(a.right))if(SC.none(a.centerX))if(SC.none(a.width)){c.left=0;c.width=0}else{c.left=0;c.width=a.width===SC.LAYOUT_AUTO?
SC.LAYOUT_AUTO:Math.floor(a.width)}else{c.width=Math.floor(a.width||0);c.left=Math.floor((b.width-c.width)/2)+a.centerX}else if(SC.none(a.width)){c.left=0;c.width=b.width-Math.floor(a.right||0)}else if(a.width===SC.LAYOUT_AUTO)c.width=SC.LAYOUT_AUTO;else{c.width=a.width;c.left=b.width-(a.width+a.right)}else{c.left=Math.floor(a.left);c.width=a.width!==undefined?a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width):b.width-c.left-Math.floor(a.right||0)}if(a.minWidth!==undefined)c.minWidth=a.minWidth;
if(a.maxWidth!==undefined)c.maxWidth=a.maxWidth;if(SC.none(a.top))if(SC.none(a.bottom))if(SC.none(a.centerY))if(SC.none(a.height)){c.top=0;c.height=0}else{c.top=0;c.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height)}else{c.height=Math.floor(a.height||0);c.top=Math.floor((b.height-c.height)/2)+a.centerY}else if(SC.none(a.height)){c.top=0;c.height=b.height-Math.floor(a.bottom||0)}else if(a.height===SC.LAYOUT_AUTO)c.height=SC.LAYOUT_AUTO;else{c.height=a.height;c.top=b.height-(a.height+
a.bottom)}else{c.top=Math.floor(a.top);c.height=a.height!==undefined?a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height):b.height-c.top-Math.floor(a.bottom||0)}if(a.minHeight!==undefined)c.minHeight=a.minHeight;if(a.maxHeight!==undefined)c.maxHeight=a.maxHeight;return c},convertLayoutToCustomLayout:function(){},classNames:function(a){a=(this.prototype.classNames||[]).concat(a);this.prototype.classNames=a;return this},tagName:function(a){this.prototype.tagName=a;return this},childView:function(a){var b=
this.prototype.childViews||[];if(b===this.superclass.prototype.childViews)b=b.slice();b.push(a);this.prototype.childViews=b;return this},bind:function(a,b){var c=this.prototype,d=this.superclass.prototype,e=c._bindings;if(!e||e===d._bindings)e=c._bindings=(e||[]).slice();a+="Binding";c[a]=b;e.push(a);return this},prop:function(a,b){this.prototype[a]=b;return this},localization:function(a,b){if(b)a.rootElement=SC.$(b)[0];return a},viewFor:function(a){var b=SC.$A(arguments);if(SC.none(a))b.shift();
else b[0]={rootElement:SC.$(a)[0]};var c=this.create.apply(this,arguments);b[0]=null;return c},create:function(){var a=new this(arguments);SC.ViewDesigner&&SC.ViewDesigner.didCreateView(a,SC.$A(arguments));return a},loc:function(a){var b=a.childViews;delete a.childViews;this.applyLocalizedAttributes(a);SC.ViewDesigner&&SC.ViewDesigner.didLoadLocalization(this,SC.$A(arguments));for(var c=this.prototype.childViews,d=c.length;--d>=0;){var e=c[d];(a=b[d])&&e&&e.loc&&e.loc(a)}return this},applyLocalizedAttributes:function(a){SC.mixin(this.prototype,
a)},views:{}});SC.outlet=function(a){return function(b){return this[b]=SC.objectForPropertyPath(a,this)}.property()};SC.View.unload=function(){var a=SC.View.views;if(a)for(var b in a)a.hasOwnProperty(b)&&delete a[b]};SC.Event.add(window,"unload",SC.View,SC.View.unload);
SC.Validatable={initMixin:function(){this._validatable_validatorDidChange()},validator:null,errorLabel:null,isValid:function(){return SC.typeOf(this.get("value"))!==SC.T_ERROR}.property("value"),ownerForm:null,performValidate:function(a){var b=SC.VALIDATE_OK;if(this._validator){var c=this.get("ownerForm");if(a){b=this._validator.validatePartial(c,this);if(b==SC.VALIDATE_NO_CHANGE&&this._validator.validateChange(c,this)==SC.VALIDATE_OK)b=SC.VALIDATE_OK}else b=this._validator.validateChange(c,this)}return b},
performValidateSubmit:function(){return this._validator?this._validator.validateSubmit(this.get("ownerForm"),this):SC.VALIDATE_OK},performValidateKeyDown:function(a){a=a.getCharString();if(!a)return YES;return this._validator?this._validator.validateKeyDown(this.get("ownerForm"),this,a):YES},validatorObject:function(){return this._validator}.property(),validateSubmit:function(){return this.performValidateSubmit()},objectForFieldValue:function(a){return this._validator?this._validator.objectForFieldValue(a,
this.get("ownerForm"),this):a},fieldValueForObject:function(a){return this._validator?this._validator.fieldValueForObject(a,this.get("ownerForm"),this):a},_validatable_displayObserver:function(){this.displayDidChange()}.observes("isValid"),updateLayerMixin:function(a){a.setClass("invalid",!this.get("isValid"))},_validatable_validatorDidChange:function(){var a=this.get("ownerForm"),b=SC.Validator.findFor(a,this,this.get("validator"));if(b!=this._validator){this.propertyWillChange("validatorObject");
this._validator&&this._validator.detachFrom(a,this);(this._validator=b)&&this._validator.attachTo(a,this);this.propertyDidChange("validatorObject")}}.observes("validator","ownerForm")};sc_require("views/view");sc_require("mixins/control");sc_require("mixins/validatable");
SC.FieldView=SC.View.extend(SC.Control,SC.Validatable,{isTextArea:NO,_field_isMouseDown:NO,fieldValue:function(){var a=this.get("value");if(SC.typeOf(a)===SC.T_ERROR)a=a.get("value");return this.fieldValueForObject(a)}.property("value","validator").cacheable(),$input:function(){return this.get("isTextArea")?this.$("textarea").andSelf().filter("textarea"):this.$("input").andSelf().filter("input")},setFieldValue:function(a){if(SC.none(a))a="";var b=this.$input();b.val()!==a&&b.val(a);return this},getFieldValue:function(){return this.$input().val()},
_field_fieldValueDidChange:function(){SC.RunLoop.begin();this.fieldValueDidChange(NO);SC.RunLoop.end()},fieldValueDidChange:function(a){this.setIfChanged("value",this.objectForFieldValue(this.getFieldValue(),a))},_field_valueDidChange:function(){this.setFieldValue(this.get("fieldValue"))}.observes("value"),didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)},didAppendToDocument:function(){if(this.get("isTextArea")){this.setFieldValue(this.get("fieldValue"));
SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)}},willDestroyLayer:function(){SC.Event.remove(this.$input(),"change",this,this._field_fieldValueDidChange)},updateLayer:function(){arguments.callee.base.apply(this,arguments)},mouseDown:function(a){this._field_isMouseDown=YES;a.allowDefault();return YES},mouseOut:function(a){this._field_isMouseDown&&this.set("isActive",NO);a.allowDefault();return YES},mouseOver:function(a){this.set("isActive",this._field_isMouseDown);a.allowDefault();
return YES},mouseUp:function(a){this._field_isMouseDown&&this.set("isActive",NO);this._field_isMouseDown=NO;a.allowDefault();return YES},keyDown:function(a){if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(this.performValidateKeyDown(a)){this._isKeyDown=YES;a.allowDefault()}else a.stop();return YES},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),
willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$input()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},_field_setFieldValue:function(a){this.propertyWillChange("fieldValue");if(this.fieldValueForObject)a=this.fieldValueForObject(a);a=this.setFieldValue(a);this.propertyDidChange("fieldValue");return a},_field_getFieldValue:function(){var a=this.getFieldValue();if(this.objectForFieldValue)a=
this.objectForFieldValue(a);return a}});
SC.TextSelection=SC.Object.extend(SC.Copyable,SC.Freezable,{start:-1,end:-1,length:function(){var a=this.get("start"),b=this.get("end");return a===-1||b===-1?-1:b-a}.property("start","end").cacheable(),init:function(){arguments.callee.base.apply(this,arguments);this.freeze()},copy:function(){return SC.TextSelection.create({start:this.get("start"),end:this.get("end")})},toString:function(){var a=this.get("length");return a&&a>0?a===1?"[%@ character selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):
"[%@ characters selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):"[no text selected; caret at %@]".fmt(this.get("start"))}});SC.StaticLayout={hasStaticLayout:YES,useStaticLayout:NO,renderMixin:function(a){a.setClass("sc-static-layout",this.get("useStaticLayout"))},clippingFrame:null,parentViewDidResize:null,beginLiveResize:null,endLiveResize:null,viewDidResize:null};sc_require("views/field");sc_require("system/text_selection");sc_require("mixins/static_layout");
SC.TextFieldView=SC.FieldView.extend(SC.StaticLayout,SC.Editable,{tagName:"label",classNames:["sc-text-field-view"],isPassword:NO,isTextArea:NO,hint:null,isEditing:NO,leftAccessoryView:null,rightAccessoryView:null,_isFocused:NO,isEditable:function(){return this.get("isEnabled")}.property("isEnabled").cacheable(),selection:function(a,b){a=this.$input()[0];var c,d;if(b===undefined)if(a){b=d=null;if(a.value){if("selectionStart"in a)d=a.selectionStart;if("selectionEnd"in a)b=a.selectionEnd;if(d===null||
b===null)if(c=document.selection){var e=c.type;if(e&&(e==="None"||e==="Text")){c=c.createRange();if(this.get("isTextArea")){d=c.duplicate();d.moveToElementText(a);d.setEndPoint("EndToStart",c);d=d.text.length;b=d+c.text.length}else{b=c.text.length;d=Math.abs(c.moveStart("character",0-(a.value.length+1)));b=d+b}}}}else d=b=0;return SC.TextSelection.create({start:d,end:b})}else return null;else{if(!b||!b.kindOf||!b.kindOf(SC.TextSelection))throw"When setting the selection, you must specify an SC.TextSelection instance.";
if(a){if("selectionStart"in a){a.selectionStart=b.get("start");d=YES}if("selectionEnd"in a){a.selectionEnd=b.get("end");c=YES}if(!d||!c){c=a.createTextRange();d=b.get("start");c.move("character",d);c.moveEnd("character",b.get("end")-d);c.select()}}}}.property("fieldValue").cacheable(),displayProperties:"hint fieldValue isEditing leftAccessoryView rightAccessoryView isTextArea".w(),createChildViews:function(){this.accessoryViewObserver()},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled"),
accessoryViewObserver:function(){var a,b=["leftAccessoryView","rightAccessoryView"],c=b.length,d,e,f,g;for(d=0;d<c;d++){e=b[d];f=this["_"+e];g=this.get(e);if(!(f&&g&&f===g)){if(f){a=f.get("classNames");a=a.without("sc-text-field-accessory-view");f.set("classNames",a);this.removeChild(f);this["_"+e]=null}if(g){if(g.isClass)g=g.create({layoutView:this});a=g.get("classNames");a.indexOf("sc-text-field-accessory-view")<0&&a.push("sc-text-field-accessory-view");this.appendChild(g);this["_"+e]=g}}}}.observes("leftAccessoryView",
"rightAccessoryView"),layoutChildViewsIfNeeded:function(a){a||(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){var b=this.get("rightAccessoryView");if(b&&b.get){var c=b.get("layout");if(c){c.left=null;if(!c.right)c.right=0;b.adjust({layout:c})}}}arguments.callee.base.apply(this,arguments)},render:function(a,b){arguments.callee.base.apply(this,arguments);this.get("isEnabled");SC.guidFor(this);this.get("isPassword");var c,d,e;this.get("isTextArea")&&a.addClass("text-area");
c=this.get("fieldValue");if(SC.none(c))c="";a.setClass("not-empty",c.length>0);d=this._getAccessoryViewWidths();e=d.left;d=d.right;if(e)e+="px";if(d)d+="px";this._renderField(a,b,c,e,d);SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix)},_forceRenderFirstTime:NO,_renderFieldLikeFirstTime:function(){this.set("_forceRenderFirstTime",YES)}.observes("isTextArea"),_renderField:function(a,b,c,d,e){var f=this.get("hint"),g,h;if(b||this._forceRenderFirstTime){this._forceRenderFirstTime=NO;b=
this.get("isEnabled")?"":'disabled="disabled"';g=this.get("layerId");a.push('<span class="border"></span>');h="";if(d||e){h='style="';if(d)h+="left: "+d+"; ";if(e)h+="right: "+e+";";h+='"'}a.push('<span class="padding" %@>'.fmt(h));a.push('<span class="sc-hint">',f,"</span>");if(this.get("isTextArea"))a.push('<textarea name="',g,'" ',b,">",c,"</textarea></span>");else{d=this.get("isPassword")?"password":"text";a.push('<input type="',d,'" name="',g,'" ',b,' value="',c,'"/></span>')}}else{a=this.$(".sc-hint");
if(f!==this._textField_currentHint){this._textField_currentHint=f;a.text(f)}if(a=this.$input()[0]){a.disabled=this.get("isEnabled")?null:"true";a=a.parentNode.style;if(d){if(a.left!==d)a.left=d}else a.left=null;if(e){if(a.right!==e)a.right=e}else a.right=null}}},_getAccessoryViewWidths:function(){var a={},b=["left","right"],c=b.length,d,e,f,g;for(d=0;d<c;d++){e=b[d];if((f=this.get(e+"AccessoryView"))&&f.get)if(g=f.get("frame"))if(g=g.width){if(f=f.get("layout")){f=f[e];g+=f}a[e]=g}}return a},didCreateLayer:function(){if(!this.get("isTextArea")){arguments.callee.base.apply(this,
arguments);this._addTextAreaEvents()}},didAppendToDocument:function(){if(this.get("isTextArea")){arguments.callee.base.apply(this,arguments);this._addTextAreaEvents()}},_addTextAreaEvents:function(){var a=this.$input();SC.Event.add(a,"focus",this,this._textField_fieldDidFocus);SC.Event.add(a,"blur",this,this._textField_fieldDidBlur);SC.Event.add(a,"select",this,this._textField_selectionDidChange);if(SC.browser.mozilla){this._cacheInputElement=this.$input();this._cachePaddingElement=this.$(".padding")}},
willDestroyLayer:function(){arguments.callee.base.apply(this,arguments);var a=this.$input();SC.Event.remove(a,"focus",this,this._textField_fieldDidFocus);SC.Event.remove(a,"blur",this,this._textField_fieldDidBlur);SC.Event.remove(a,"select",this,this._textField_selectionDidChange)},_textField_fieldDidFocus:function(){SC.RunLoop.begin();this.fieldDidFocus();SC.RunLoop.end()},_textField_fieldDidBlur:function(){SC.RunLoop.begin();this.fieldDidBlur();SC.RunLoop.end()},fieldDidFocus:function(){this.beginEditing()},
fieldDidBlur:function(){this.commitEditing()},_topOffsetForFirefoxCursorFix:3,_applyFirefoxCursorFix:function(){if(SC.browser.mozilla){var a,b,c,d,e;e=this._cacheInputElement;if((a=this._cachePaddingElement)&&a[0]){d=a[0];b=SC.$(d).offset();a=SC.browser.compareVersion(1,9,2)<0&&e[0].tagName.toLowerCase()==="input"?b.top+this._topOffsetForFirefoxCursorFix:b.top;b=b.left;c=d.offsetWidth;d=d.offsetHeight;a="position: fixed; top: %@px; left: %@px; width: %@px; height: %@px;".fmt(a,b,c,d);if(!this._prevStyle||
this._prevStyle!=a)e.attr("style",a);this._prevStyle=a}}return this},_textField_selectionDidChange:function(){this.notifyPropertyChange("selection")},willBecomeKeyResponderFrom:function(){if(this.get("isVisibleInWindow")){this.$input()[0].focus();if(!this._txtFieldMouseDown)if(SC.browser.mozilla)this.invokeOnce(this._selectRootElement);else SC.browser.safari?this.invokeLater(this._selectRootElement,1):this._selectRootElement()}},willLoseKeyResponderTo:function(){},_selectRootElement:function(){this.$input()[0].select()},
didLoseKeyResponderTo:function(){this.$input()[0].blur()},parentViewDidResize:function(){SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix);arguments.callee.base.apply(this,arguments)},keyDown:function(a){if(a.which===13&&!this.get("isTextArea"))return NO;if(a.which===27)return NO;if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(this.performValidateKeyDown(a)){this._isKeyDown=YES;
a.allowDefault()}else a.stop();return YES},keyUp:function(a){this.notifyPropertyChange("selection");this._isKeyDown&&this.invokeLater(this.fieldValueDidChange,1,YES);this._isKeyDown=NO;a.allowDefault();return YES},mouseDown:function(a){this._txtFieldMouseDown=YES;if(this.get("isEnabled"))if(this.value&&this.value.length===0||!this.value){this.$input()[0].focus();return YES}else{SC.browser.mozilla&&this.$input()[0].focus();return arguments.callee.base.apply(this,arguments)}else{a.stop();return YES}},
mouseUp:function(a){this._txtFieldMouseDown=NO;this.notifyPropertyChange("selection");if(this.get("isEnabled"))if(this.value&&this.value.length===0||!this.value){SC.browser.msie<8?this.invokeLater(this.focusIE7,1):this.$input()[0].focus();return YES}else return arguments.callee.base.apply(this,arguments);else{a.stop();return YES}},focusIE7:function(){this.$input()[0].focus()},selectStart:function(){return YES}});sc_require("views/text_field");
SC.InlineTextFieldView=SC.TextFieldView.extend(SC.DelegateSupport,{_topOffsetForFirefoxCursorFix:0,beginEditing:function(a){if(a){var b={},c,d;this.beginPropertyChanges();if(this.get("isEditing")&&!this.blurEditor()){this.endPropertyChanges();return NO}this._optframe=a.frame;this._optIsCollection=a.isCollection;this._exampleElement=a.exampleElement;this._delegate=a.delegate;if(!this._optframe||!this._delegate)throw"At least frame and delegate options are required for inline editor";this._originalValue=
a.value||"";(this._multiline=a.multiline!==undefined?a.multiline:NO)?this.set("isTextArea",YES):this.set("isTextArea",NO);this._commitOnBlur=a.commitOnBlur!==undefined?a.commitOnBlur:YES;this.set("validator",a.validator);this.set("value",this._originalValue);this.set("isEditing",YES);a=this._delegate.pane();b.height=this._optframe.height;b.width=this._optframe.width;c=this._delegate.get("layout");d=a.$()[0];b.left=this._optIsCollection&&c.left?this._optframe.x-c.left-d.offsetLeft-1:this._optframe.x-
d.offsetLeft-1;SC.browser.msie==7&&b.left--;b.top=this._optIsCollection&&c.top?this._optframe.y-c.top-d.offsetTop:this._optframe.y-d.offsetTop;if(SC.browser.msie==7)b.top-=2;this.set("layout",b);this.set("parentNode",a);a.appendChild(this);SC.RunLoop.begin().end();b=this._delegate;(this._className=this.getDelegateProperty(b,"inlineEditorClassName"))&&!this.hasClassName(this._className)&&this.setClassName(this._className,true);this.invokeDelegateMethod(b,"inlineEditorWillBeginEditing",this);this._previousFirstResponder=
a?a.get("firstResponder"):null;this.endPropertyChanges();this.invokeDelegateMethod(b,"inlineEditorDidBeginEditing",this);this.invokeLast(this.becomeFirstResponder)}},commitEditing:function(){if(!SC.$ok(this.validateSubmit()))return NO;return this._endEditing(this.get("value"))},discardEditing:function(){return this._endEditing(this._originalValue)},blurEditor:function(){if(!this.get("isEditing"))return YES;return this._commitOnBlur?this.commitEditing():this.discardEditing()},_endEditing:function(a){if(!this.get("isEditing"))return YES;
var b=this._delegate;if(!this.invokeDelegateMethod(b,"inlineEditorShouldEndEditing",this,a))return NO;this.invokeDelegateMethod(b,"inlineEditorDidEndEditing",this,a);this._className&&this.setClassName(this._className,false);this._originalValue=this._delegate=this._exampleElement=this._optframe=this._className=null;this.set("isEditing",NO);if(this.get("isFirstResponder"))(a=this.get("pane"))&&this._previousFirstResponder?a.makeFirstResponder(this._previousFirstResponder):this.resignFirstResponder();
this._previousFirstResponder=null;this.get("parentNode")&&this.removeFromParent();return YES},isEditing:NO,mouseDown:function(a){arguments.callee.base.call(this,a);return this.get("isEditing")},keyDown:function(a){a=this.interpretKeyEvents(a);this.fieldValueDidChange(true);return!a?NO:a},insertText:null,willRemoveFromParent:function(){this.$input()[0].blur()},willLoseFirstResponder:function(a){if(a===this){this._previousFirstResponder=null;this.$input()[0].blur();return this.blurEditor()}},cancel:function(){this.discardEditing();
return YES},fieldValueDidChange:function(a){arguments.callee.base.call(this,a)},insertNewline:function(a){if(this._multiline){a.allowDefault();return arguments.callee.base.call(this,a)}else{this.get("value")!=this.$input().val()&&this.set("value",this.$input().val());this.commitEditing();return YES}},insertTab:function(){this.resignFirstResponder();this.commitEditing();if(this._delegate){var a=this._delegate.nextValidKeyView();a&&a.beginEditing()}return YES},insertBacktab:function(){this.commitEditing();
if(this._delegate){var a=this._delegate.previousValidKeyView();a&&a.beginEditing()}return YES},deleteForward:function(a){a.allowDefault();return YES},deleteBackward:function(a){a.allowDefault();return YES}});
SC.InlineTextFieldView.mixin({beginEditing:function(a){this._exampleElement=a.exampleElement;var b=a.exampleInlineTextFieldView?a.exampleInlineTextFieldView:this,c=a.delegate.get("layout"),d=this.updateViewStyle(),e=this.updateViewPaddingStyle(),f=".inline-editor input{"+d+"} ";f=f+".inline-editor textarea{"+d+"} .inline-editor .padding{"+e+"}";d=document.getElementsByTagName("head")[0];e=document.createElement("style");e.type="text/css";e.media="screen";if(e.styleSheet)e.styleSheet.cssText=f;else e.appendChild(document.createTextNode(f));
d.appendChild(e);this.editor=b.create({classNames:"inline-editor",layout:c});return this.editor.beginEditing(a)},commitEditing:function(){return this.editor?this.editor.commitEditing():YES},discardEditing:function(){return this.editor?this.editor.discardEditing():YES},updateViewStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"font-size");if(c&&c.length>0)b=b+"font-size: "+c+" !important; ";if((c=SC.getStyle(a,"font-family"))&&c.length>0)b=b+"font-family: "+c+" !important; ";if((c=
SC.getStyle(a,"font-weight"))&&c.length>0)b=b+"font-weight: "+c+" !important; ";if((c=SC.getStyle(a,"z-index"))&&c.length>0)b=b+"z-index: "+c+" !important; ";if((c=SC.getStyle(a,"line-height"))&&c.length>0)b=b+"line-height: "+c+" !important; ";if((c=SC.getStyle(a,"text-align"))&&c.length>0)b=b+"text-align: "+c+" !important; ";if((c=SC.getStyle(a,"top-margin"))&&c.length>0)b=b+"top-margin: "+c+" !important; ";if((c=SC.getStyle(a,"bottom-margin"))&&c.length>0)b=b+"bottom-margin: "+c+" !important; ";
if((c=SC.getStyle(a,"left-margin"))&&c.length>0)b=b+"left-margin: "+c+" !important; ";if((c=SC.getStyle(a,"right-margin"))&&c.length>0)b=b+"right-margin: "+c+" !important; ";return b},updateViewPaddingStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"padding-top");if(c&&c.length>0)b=b+"top: "+c+" !important; ";if((c=SC.getStyle(a,"padding-bottom"))&&c.length>0)b=b+"bottom: "+c+" !important; ";if((c=SC.getStyle(a,"padding-left"))&&c.length>0)b=b+"left: "+c+" !important; ";if((c=
SC.getStyle(a,"padding-right"))&&c.length>0)b=b+"right: "+c+" !important; ";return b},editor:null});sc_require("views/view");
SC.Pane=SC.View.extend({isPane:YES,page:null,rootResponder:null,currentWindowSize:null,computeParentDimensions:function(){var a=this.get("currentWindowSize"),b={x:0,y:0,width:1E3,height:1E3};if(a){b.width=a.width;b.height=a.height}else if(SC.RootResponder.responder){if(a=SC.RootResponder.responder.get("currentWindowSize")){b.width=a.width;b.height=a.height}}else{if(window.innerHeight){b.width=window.innerWidth;b.height=window.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b.width=
document.documentElement.clientWidth;b.height=document.documentElement.clientHeight}else if(document.body){b.width=document.body.clientWidth;b.height=document.body.clientHeight}this.windowSizeDidChange(null,b)}return b},frame:function(){return this.computeFrameWithParentFrame(null)}.property(),windowSizeDidChange:function(a,b){this.set("currentWindowSize",b);this.parentViewDidResize();return this},sendEvent:function(a,b,c){for(c||(c=this.get("firstResponder"));c&&!c.tryToPerform(a,b);)c=c===this?
null:c.get("nextResponder");if(!c&&(c=this.get("defaultResponder"))){if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);c=c?c.isResponderContext?c.sendAction(a,this,b):c.tryToPerform(a,b)?c:null:null}return b.mouseHandler||c},performKeyEquivalent:function(a,b){var c=arguments.callee.base.apply(this,arguments);if(!c){var d=this.get("defaultResponder");if(d){if(d.performKeyEquivalent)c=d.performKeyEquivalent(a,b);c||(c=d.tryToPerform(a,b))}}return c},defaultResponder:null,nextResponder:function(){return null}.property().cacheable(),
firstResponder:null,acceptsKeyPane:YES,isKeyPane:NO,becomeKeyPane:function(){if(this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(this);return this},resignKeyPane:function(){if(!this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(null);return this},makeFirstResponder:function(a){var b=this.get("firstResponder"),c=this.get("isKeyPane");if(b===a)return this;b&&b.willLoseFirstResponder(b);if(c){b&&b.willLoseKeyResponderTo(a);a&&a.willBecomeKeyResponderFrom(b)}b&&
b.beginPropertyChanges().set("isFirstResponder",NO).set("isKeyResponder",NO).endPropertyChanges();this.set("firstResponder",a);a&&a.beginPropertyChanges().set("isFirstResponder",YES).set("isKeyResponder",c).endPropertyChanges();if(c){a&&a.didBecomeKeyResponderFrom(b);b&&b.didLoseKeyResponderTo(a)}a&&a.didBecomeFirstResponder(a);return this},_forwardKeyChange:function(a,b,c,d){var e;if(a&&(e=this.get("firstResponder"))){c=c?c.get("firstResponder"):null;(a=this.get("firstResponder"))&&a[b](c);d!==undefined&&
e&&e.set("isKeyResponder",d)}},willLoseKeyPaneTo:function(a){this._forwardKeyChange(this.get("isKeyPane"),"willLoseKeyResponderTo",a,NO);return this},willBecomeKeyPaneFrom:function(a){this._forwardKeyChange(!this.get("isKeyPane"),"willBecomeKeyResponderFrom",a,YES);return this},didLoseKeyPaneTo:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",NO);this._forwardKeyChange(b,"didLoseKeyResponderTo",a);return this},didBecomeKeyPaneFrom:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",
YES);this._forwardKeyChange(!b,"didBecomeKeyResponderFrom",a,YES);return this},isMainPane:NO,focusFrom:function(){},blurTo:function(){},blurMainTo:function(){this.set("isMainPane",NO)},focusMainFrom:function(){this.set("isMainPane",YES)},append:function(){return this.appendTo(document.body)},remove:function(){if(!this.get("isVisibleInWindow"))return this;if(!this.get("isPaneAttached"))return this;this.set("isVisibleInWindow",NO);var a=this.get("layer");a.parentNode&&a.parentNode.removeChild(a);this.resignKeyPane();
a=this.rootResponder;this.get("isMainPane")&&a.makeMainPane(null);a.panes.remove(this);this.rootResponder=null;this.set("isPaneAttached",NO);return this},appendTo:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&b.parentNode===a)return this;a.insertBefore(b,null);return this.paneDidAttach()},prependTo:function(a){if(this.get("isPaneAttached"))return this;var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&
b.parentNode===a)return this;a.insertBefore(b,a.firstChild);return this.paneDidAttach()},before:function(a){if(this.get("isPaneAttached"))return this;var b=this.get("layer");b||(b=this.createLayer().get("layer"));var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;c.insertBefore(b,a);return this.paneDidAttach()},after:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;
c.insertBefore(b,a.nextSibling);return this.paneDidAttach()},removeFromParent:function(){},paneDidAttach:function(){var a=this.rootResponder=SC.RootResponder.responder;a.panes.add(this);this.set("currentWindowSize",a.computeWindowSize());this.set("isPaneAttached",YES);this.parentViewDidChange();this._notifyDidAppendToDocument();return this},isPaneAttached:NO,recomputeIsVisibleInWindow:function(){this.get("isVisibleInWindow");var a=this.get("isVisible");this.set("isVisibleInWindow",a);this._needsVisibiltyChange=
YES;a&&this.get("layerNeedsUpdate")&&this.updateLayerIfNeeded();a&&this.get("childViewsNeedLayout")&&this.layoutChildViewsIfNeeded();var b=this.get("childViews"),c=b.length,d;for(d=0;d<c;d++)b[d].recomputeIsVisibleInWindow(a);!a&&this.get("isFirstResponder")&&this.resignFirstResponder();if(a){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}return this},updateLayerLocation:function(){return this},init:function(){var a=
!!this.get("layer");arguments.callee.base.apply(this,arguments);var b=this.get("theme");if(!b&&"undefined"!==ENV)b=ENV.theme;if(b){var c=this.get("classNames").copy();c.push(b);this.set("classNames",c)}a&&this.paneDidAttach()},classNames:function(){var a=["sc-pane"],b,c,d,e;b=SC.browser.current;c=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";e=document.documentElement.style;d=e.MozBoxShadow!==undefined||e.webkitBoxShadow!==undefined||e.oBoxShadow!==undefined||e.boxShadow!==undefined;
e=e.MozBorderRadius!==undefined||e.webkitBorderRadius!==undefined||e.oBorderRadius!==undefined||e.borderRadius!==undefined;d&&a.push("box-shadow");e&&a.push("border-rad");a.push(b);a.push(c);SC.browser.msie==7&&a.push("ie7");SC.browser.mobileSafari&&a.push("mobile-safari");return a}()});sc_require("system/responder");
SC.ResponderContext=SC.Responder.extend({isResponderContext:YES,trace:NO,defaultResponder:null,nextResponder:function(){return this.get("defaultResponder")}.property("defaultResponder").cacheable(),firstResponder:null,nextResponderFor:function(a){var b=a.get("nextResponder");if(typeof b===SC.T_STRING)b=SC.objectForPropertyPath(b,this);else if(!b&&a!==this)b=this;return b},responderNameFor:function(a){if(a){if(a._scrc_name)return a._scrc_name}else return"(No Responder)";this._findResponderNamesFor(this,
3,this.NAMESPACE?[this.NAMESPACE]:[]);return a._scrc_name||a.toString()},_findResponderNamesFor:function(a,b,c){var d,e;for(d in a)if(d!=="nextResponder")if((e=a[d])&&e.isResponder)if(!e._scrc_name){c.push(d);e._scrc_name=c.join(".");b>0&&this._findResponderNamesFor(e,b-1,c);c.pop()}},makeFirstResponder:function(a){var b=this.get("firstResponder"),c=this.get("nextResponder"),d=this.get("trace");if(this._locked){d&&console.log("%@: AFTER ACTION: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));
this._pendingResponder=a}else{d&&console.log("%@: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));this._locked=YES;this._pendingResponder=null;for(d=a?this.nextResponderFor(a):null;d;){if(d.get("hasFirstResponder"))break;d=d===c?null:this.nextResponderFor(d)}d||(d=c);this._notifyWillLoseFirstResponder(b,b,d);b&&b.set("isFirstResponder",NO);this.set("firstResponder",a);a&&a.set("isFirstResponder",YES);this._notifyDidBecomeFirstResponder(a,a,d);this._locked=NO;if(this._pendingResponder){this.makeFirstResponder(this._pendingResponder);
this._pendingResponder=null}return this}},_notifyWillLoseFirstResponder:function(a,b,c){if(b!==c){b.willLoseFirstResponder(a);b.set("hasFirstResponder",NO);(b=this.nextResponderFor(b))&&this._notifyWillLoseFirstResponder(a,b,c)}},_notifyDidBecomeFirstResponder:function(a,b,c){if(b!==c){var d=this.nextResponderFor(b);d&&this._notifyDidBecomeFirstResponder(a,d,c);b.set("hasFirstResponder",YES);b.didBecomeFirstResponder(a)}},sendAction:function(a,b,c){var d=this.get("firstResponder"),e=this.get("nextResponder"),
f=this.get("trace"),g=NO;this._locked=YES;for(f&&console.log("%@: begin action '%@' (%@, %@)".fmt(this,a,b,c));!g&&d;){if(d.tryToPerform)g=d.tryToPerform(a,b,c);g||(d=d===e?null:this.nextResponderFor(d))}if(f)g?console.log("%@: action '%@' handled by %@".fmt(this,a,this.responderNameFor(d))):console.log("%@:  action '%@' NOT HANDLED".fmt(this,a));this._locked=NO;if(a=this._pendingResponder){this._pendingResponder=null;this.makeFirstResponder(a)}return d}});sc_require("system/responder_context");
SC.Application=SC.ResponderContext.extend({});sc_require("core");
SC.Benchmark={verbose:NO,enabled:YES,stats:{},globalStartTime:null,start:function(a,b,c,d){if(this.enabled){c=c||Date.now();b=b?this._subStatFor(a,b):this._statFor(a);d&&b._starts.length>0?b._starts.push("ignore"):b._starts.push(c);b._times.push({start:c,_subStats:{}});return a}},end:function(a,b,c){if(this.enabled){b=b?this._subStatFor(a,b):this._statFor(a);var d=b._starts.pop();if(d){if(d!="ignore"){c=c||Date.now();d=c-d;b._times[b._times.length-1].end=c;b._times[b._times.length-1].dur=d;b.amt+=
d;b.runs++;this.verbose&&this.log(a)}}else console.log('SC.Benchmark "%@" ended without a matching start.  No information was saved.'.fmt(a))}},setGlobalStartTime:function(a){this.globalStartTime=a},bench:function(a,b,c){b||(b="bench%@".fmt(this._benchCount++));c||(c=1);for(var d;--c>=0;){var e=SC.Benchmark.start(b);d=a();SC.Benchmark.end(e)}return d},install:function(a,b,c){a["b__"+b]=a[b];var d=a["b__"+b];a[b]=function(){var e="%@(%@)".fmt(b,$A(arguments).join(", "));SC.Benchmark.start(e,c);var f=
d.apply(this,arguments);SC.Benchmark.end(e);return f}},restore:function(a,b){a[b]=a["b__"+b]},report:function(a){if(a)return this._genReport(a);a=[];for(var b in this.stats)this.stats.hasOwnProperty(b)&&a.push(this._genReport(b));return a.join("\n")},timelineReport:function(a){a=a?"SproutCore Application":a;a=[a,"User-Agent: %@".fmt(navigator.userAgent),"Report Generated: %@ (%@)".fmt((new Date).toString(),Date.now()),""];for(var b=this._compileChartData(true),c=0;c<b.length;c++)b[c][4]?a.push(this._timelineGenSubReport(b[c])):
a.push(this._timelineGenReport(b[c]));return a.join("\n")},timelineChart:function(a){var b=0;this.hideChart();var c=this._compileChartData(false),d=c.length;if(d!==0){var e=this.globalStartTime?this.globalStartTime:c[0][1];b=c[d-1][2]-e;var f=50+d*30,g=Math.ceil(b/200)+1,h=g*50,i=document.createElement("div");i.className="sc-benchmark-graph";document.body.appendChild(i);var j=document.createElement("div");j.innerHTML=(a?a:"SproutCore Application")+(" - Total Captured Time: "+b+" ms - Points Captured: "+
d)+' [<a href="javascript:SC.Benchmark.hideChart();">Hide Chart</a>]';j.className="sc-benchmark-title";i.appendChild(j);b=document.createElement("div");b.className="sc-benchmark-top";b.style.width=h+"px";i.appendChild(b);for(b=0;b<g;b++){a=document.createElement("div");a.className="sc-benchmark-tick";a.style.left=b*50+"px";a.style.height=f+"px";j=document.createElement("div");j.className="sc-benchmark-tick-label";j.style.left=b*50+"px";j.innerHTML=b*200+" ms";i.appendChild(a);i.appendChild(j)}for(b=
0;b<d;b++){f=document.createElement("div");f.style.top=75+b*30+"px";f.style.width=h+"px";f.className=b%2===0?"sc-benchmark-row even":"sc-benchmark-row";i.appendChild(f);f=document.createElement("div");g=c[b][1];a=c[b][2];j=c[b][3];f.innerHTML="&nbsp;"+(c[b][0]+" <span class='sc-benchmark-emphasis'>"+j+"ms</span>");f.className="sc-benchmark-bar";f.style.cssText="left:"+(g-e)/4+"px; width: "+j/4+"px; top: "+(53+b*30)+"px;";f.title="start: "+(g-e)+" ms, end: "+(a-e)+" ms, duration: "+j+" ms";i.appendChild(f)}this._graph=
i}},hideChart:function(){if(this._graph)try{document.body.removeChild(this._graph)}catch(a){}},log:function(a){console.log(this.report(a))},startProfile:function(a){this.enabled&&console&&console.profile&&console.profile(a)},endProfile:function(a){this.enabled&&console&&console.profileEnd&&console.profileEnd(a)},_compileChartData:function(a){var b=[],c;for(var d in this.stats)for(var e=this.stats[d],f=0;f<e._times.length;f++){var g=e._times[f];c=e._times.length>1?f+1+" - "+d:d;b.push([c,g.start,g.end,
g.dur,false]);if(a){g=g._subStats;for(var h in g)for(var i=g[h],j=0;j<i._times.length;j++){var k=i._times[j];c=i._times.length>1?j+1+" - "+h:h;b.push([c,k.start,k.end,k.dur,true])}}}b.sort(function(l,m){if(l[1]<m[1])return-1;else if(l[1]==m[1]){if(l[3]&&!m[3])return-1;if(!l[3]&&m[3])return 1;return 0}return 1});return b},_genReport:function(a){var b=this._statFor(a);return"BENCH %@ msec: %@ (%@x)".fmt(b.runs>0?Math.floor(b.amt*1E3/b.runs)/1E3:0,b.name||a,b.runs)},_timelineGenReport:function(a){return this.globalStartTime?
"BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_timelineGenSubReport:function(a){return this.globalStartTime?"   CHECKPOINT BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"   CHECKPOINT BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_subStatFor:function(a,b){if(this.stats[b]._times.length!==0){b=this.stats[b]._times[this.stats[b]._times.length-1]._subStats;var c=b[a];if(!c){b[a]=
{runs:0,amt:0,name:a,_starts:[],_times:[]};c=b[a]}return c}},_statFor:function(a){var b=this.stats[a];if(!b){this.stats[a]={runs:0,amt:0,name:a,_starts:[],_times:[]};b=this.stats[a]}return b},reset:function(){this.stats={}},_bench:function(a,b){SC.Benchmark.bench(a,b,1)},_benchCount:1};SC.Benchmark=SC.Benchmark;
SC.mixin({logBundleLoading:NO,bundleIsLoaded:function(a){return tiki.ready(a)},loadBundle:function(a,b,c){if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}var d=SC.A(arguments).slice(3),e=function(){if(SC.T_STRING===typeof b)b=SC.objectForPropertyPath(b);if(SC.T_STRING===typeof c)c=SC.objectForPropertyPath(c,b);if(!b||!c)throw"could not find callback for load";SC.RunLoop.begin();c.apply(b,d);SC.RunLoop.end();e=null};tiki.async(a).then(function(){tiki.require("tiki").ready(this,e)})}});sc_require("system/locale");
SC.IMAGE_ABORTED_ERROR=SC.$error("SC.Image.AbortedError","Image",-100);SC.IMAGE_FAILED_ERROR=SC.$error("SC.Image.FailedError","Image",-101);
SC.imageCache=SC.Object.create({loadLimit:4,activeRequests:0,loadImage:function(a,b,c,d){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];if(SC.none(d))d=SC.none(b)&&SC.none(c);a=this._imageEntryFor(a);if(a.status===this.IMAGE_LOADED){if(c)c.call(b||a.image,a.url,a.image)}else{if(b||c)this._addCallback(a,b,c);a.retainCount++;this._scheduleImageEntry(a,d)}},releaseImage:function(a,b,c){a=this._imageEntryFor(a,NO);if(!a)return this;if(--a.retainCount<=
0)this._deleteEntry(a);else if(b||c){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];this._removeCallback(a,b,c)}},reloadImage:function(a){if((a=this._imageEntryFor(a,NO))&&a.status===this.IMAGE_LOADED)a.status=this.IMAGE_WAITING},loadNextImage:function(){var a=null,b;if(!(this.get("activeRequests")>=this.get("loadLimit"))){for(b=this._foregroundQueue;b.length>0&&!a;)a=b.shift();if(!a)for(b=this._backgroundQueue;b.length>0&&!a;)a=b.shift();this.set("isLoading",
!!a);if(a){b=a.image;b.onabort=this._imageDidAbort;b.onerror=this._imageDidError;b.onload=this._imageDidLoad;b.src=a.url;this._loading.push(a);this.incrementProperty("activeRequests");this.loadNextImage()}}},_imageEntryFor:function(a,b){if(b===undefined)b=YES;var c=this._images[a];if(!c&&b){b=new Image;c=this._images[a]={url:a,status:this.IMAGE_WAITING,callbacks:[],retainCount:0,image:b};b.entry=c}return c},_deleteEntry:function(a){this._unscheduleEntry(a);delete this._images[a.url]},_addCallback:function(a,
b,c){a=a.callbacks;a.find(function(d){return d[0]===b&&d[1]===c},this)||a.push([b,c]);a=null;return this},_removeCallback:function(a,b,c){var d=a.callbacks;d.forEach(function(e,f){if(e[0]===b&&e[1]===c)d[f]=null},this);d=null;return this},_scheduleImageEntry:function(a,b){var c=this._backgroundQueue,d=this._foregroundQueue;if(a.status===this.IMAGE_LOADED)return this;if(a.status===this.IMAGE_QUEUE&&!b&&a.isBackground){c[c.indexOf(a)]=null;a.status=this.IMAGE_WAITING}if(a.status!==this.IMAGE_QUEUE){(b?
c:d).push(a);a.status=this.IMAGE_QUEUE;a.isBackground=b}this.isLoading||this.invokeLater(this.loadNextImage,100);this.set("isLoading",YES);return this},_unscheduleImageEntry:function(a){if(a.status!==this.IMAGE_QUEUE)return this;var b=a.isBackground?this._backgroundQueue:this._foregroundQueue;b[b.indexOf(a)]=null;if(this._loading.indexOf(a)>=0){b.image.abort();this.imageStatusDidChange(a,this.ABORTED)}return this},_imageDidAbort:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ABORTED)},
_imageDidError:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ERROR)},_imageDidLoad:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.LOADED)},imageStatusDidChange:function(a,b){if(a){var c=a.url,d;switch(b){case this.LOADED:d=a.image;break;case this.ABORTED:d=SC.IMAGE_ABORTED_ERROR;break;case this.ERROR:d=SC.IMAGE_FAILED_ERROR;break;default:d=SC.IMAGE_FAILED_ERROR;break}a.callbacks.forEach(function(f){f[1].call(f[0],c,d)},this);a.callbacks=[];a.status=
b===this.LOADED?this.IMAGE_LOADED:this.IMAGE_WAITING;var e=a.image;if(e){e.onload=e.onerror=e.onabort=null;if(b!==this.LOADED)a.image=null}this._loading[this._loading.indexOf(a)]=null;if(this._loading.length>this.loadLimit*2)this._loading=this._loading.compact();this.decrementProperty("activeRequests");this.loadNextImage()}},init:function(){arguments.callee.base.apply(this,arguments);this._images={};this._loading=[];this._foregroundQueue=[];this._backgroundQueue=[]},IMAGE_LOADED:"loaded",IMAGE_QUEUED:"queued",
IMAGE_WAITING:"waiting",ABORTED:"aborted",ERROR:"error",LOADED:"loaded"});SC.Math=SC.Object.create({near:function(a,b,c){c||(c=1.0E-5);return Math.abs(a-b)<=c},round:function(a,b){b||(b=0);var c=Math.pow(10,b);if(b<0){b=c.toString();c=b.substring(0,b.indexOf("1")+1)}a=a.valueOf();return Math.round(a*c)/c}});
SC.Page=SC.Object.extend({owner:null,get:function(a){var b=this[a];if(b&&b.isClass){this[a]=b=b.create({page:this});this.get("inDesignMode")||b.awake();return b}else return arguments.callee.base.apply(this,arguments)},awake:function(){var a,b;for(b in this)if(this.hasOwnProperty(b))if((a=this[b])&&a.isViewClass)this[b]=a.create({page:this});return this},getIfConfigured:function(a){var b=this[a];return b&&b.isViewClass?null:this.get(a)},loc:function(a){var b,c;for(c in a)if(a.hasOwnProperty(c))(b=
this[c])&&b.isViewClass&&b.loc(a[c]);return this}});SC.Page.design=SC.Page.create;SC.Page.localization=function(a){return a};sc_require("system/event");
SC.mixin({_isReadyBound:NO,_bindReady:function(){if(!this._isReadyBound){this._isReadyBound=YES;tiki.require("tiki").ready.main(SC,SC._didBecomeReady)}},_readyQueue:[],_afterReadyQueue:[],isReady:NO,_didBecomeReady:function(){if(!SC.isReady){typeof SC.mapDisplayNames===SC.T_FUNCTION&&SC.mapDisplayNames();typeof SC.addInvokeOnceLastDebuggingInfo===SC.T_FUNCTION&&SC.addInvokeOnceLastDebuggingInfo();SC.Locale.createCurrentLocale();if(document&&document.getElementsByTagName){var a=document.getElementsByTagName("body")[0];
if(a){var b=a.className,c=SC.Locale.currentLanguage.toLowerCase();a.className=b&&b.length>0?[b,c].join(" "):c}}SC.Benchmark.start("ready");SC.RunLoop.begin();var d;do{a=SC._readyQueue;SC._readyQueue=[];b=0;for(c=a.length;b<c;b++){d=a[b];var e=d[0]||document;(d=d[1])&&d.call(e)}}while(SC._readyQueue.length>0);SC.isReady=YES;SC._readyQueue=null;SC.Event.trigger("ready",null,document,NO);SC.removeLoading&&SC.$("#loading").remove();SC.mode===SC.APP_MODE&&typeof main!="undefined"&&main instanceof Function&&
!SC.suppressMain&&main();SC.routes&&SC.routes.ping&&SC.routes.ping();SC.RunLoop.end();SC.Benchmark.end("ready");SC.Benchmark.log()}},ready:function(a,b){var c=this._readyQueue;if(b===undefined){b=a;a=null}else if(SC.typeOf(b)===SC.T_STRING)b=a[b];if(!b)return this;if(this.isReady)return b.call(a||document);c.push([a,b]);return this}});SC._bindReady();SC.removeLoading=YES;SC.APP_MODE="APP_MODE";SC.TEST_MODE="TEST_MODE";SC.mode=SC.APP_MODE;sc_require("system/builder");SC.MODE_REPLACE="replace";
SC.MODE_APPEND="append";SC.MODE_PREPEND="prepend";
SC.RenderContext=SC.Builder.create({SELF_CLOSING:SC.CoreSet.create().addEach("area base basefront br hr input img link meta".w()),init:function(a,b){if(a===undefined)a="div";if(b){this.prevObject=b;this.strings=b.strings;this.offset=b.length+b.offset}if(!this.strings)this.strings=[];this.needsContent=YES;if(SC.typeOf(a)===SC.T_STRING){this._tagName=a.toLowerCase();this._needsTag=YES;for(a=this;a;){a.length++;a=a.prevObject}this.strings.push(null);this._selfClosing=this.SELF_CLOSING.contains(this._tagName)}else{this._elem=
a;this._needsTag=NO;this.length=0;this.needsContent=NO}return this},strings:null,offset:0,length:0,updateMode:SC.MODE_REPLACE,needsContent:NO,get:function(a){var b=this.strings||[];return a===undefined?b.slice(this.offset,this.length):b[a+this.offset]},push:function(a){var b=this.strings,c=arguments.length;if(!b)this.strings=b=[];c>1?b.push.apply(b,arguments):b.push(a);for(b=this;b;){b.length+=c;b=b.prevObject}this.needsContent=YES;return this},text:function(){var a=arguments.length,b=0;for(b=0;b<
a;b++)this.push(SC.RenderContext.escapeHTML(arguments[b]));return this},join:function(a){this._needsTag&&this.end();var b=this.strings;return b?b.join(a||""):""},begin:function(a){return SC.RenderContext(a,this)},element:function(){if(this._elem)return this._elem;var a;if(!SC.RenderContext.factory)SC.RenderContext.factory=document.createElement("div");SC.RenderContext.factory.innerHTML=this.join();if(SC.RenderContext.factory.innerHTML.length>0){a=SC.RenderContext.factory.firstChild.cloneNode(true);
SC.RenderContext.factory.innerHTML=""}else a=null;return a},remove:function(a){if(a){var b=this._elem;if(b&&b.removeChild)(a=document.getElementById(a))&&b.removeChild(a)}},update:function(){var a=this._elem,b=this.updateMode,c,d,e,f;this._innerHTMLReplaced=NO;if(a){if(this.length>0){this._innerHTMLReplaced=YES;if(b===SC.MODE_REPLACE)a.innerHTML=this.join();else{b=a.cloneNode(false);b.innerHTML=this.join();for(b=b.firstChild;b;){f=b.nextSibling;a.insertBefore(b,f);b=f}}}if(this._attrsDidChange&&(d=
this._attrs))for(c in d)if(d.hasOwnProperty(c))d[c]===null?a.removeAttribute(c):SC.$(a).attr(c,d[c]);if(this._classNamesDidChange&&(d=this._classNames))SC.$(a).attr("class",d.join(" "));if(this._idDidChange&&(d=this._id))SC.$(a).attr("id",d);if(this._stylesDidChange&&(e=this._styles)){b=this._STYLE_PAIR_ARRAY;f=this._JOIN_ARRAY;for(c in e)if(e.hasOwnProperty(c)){d=e[c];if(d!==null){if(typeof d===SC.T_NUMBER)d=d.toString()+"px";b[0]=c.dasherize();b[1]=d;f.push(b.join(": "))}}SC.$(a).attr("style",f.join("; "));
f.length=0}this._elem=null;return this.prevObject||this}},_DEFAULT_ATTRS:{},_TAG_ARRAY:[],_JOIN_ARRAY:[],_STYLE_PAIR_ARRAY:[],end:function(){var a=this._TAG_ARRAY,b,c,d,e=this._attrs;b=this._classNames;c=this._id;var f=this._styles;a[0]="<";a[1]=this._tagName;if(e||b||f||c){if(!e)e=this._DEFAULT_ATTRS;if(c)e.id=c;if(b)e["class"]=b.join(" ");if(f){c=this._JOIN_ARRAY;b=this._STYLE_PAIR_ARRAY;for(d in f)if(f.hasOwnProperty(d)){b[0]=d.dasherize();b[1]=f[d];if(b[1]!==null){if(typeof b[1]===SC.T_NUMBER)b[1]+=
"px";c.push(b.join(": "))}}e.style=c.join("; ");c.length=0}a.push(" ");for(d in e)if(e.hasOwnProperty(d))if(e[d]!==null){a.push(d);a.push('="');a.push(e[d]);a.push('" ')}if(e===this._DEFAULT_ATTRS){delete e.style;delete e["class"];delete e.id}}d=this.strings;e=this._selfClosing===NO?NO:this.length===1;a.push(e?" />":">");d[this.offset]=a.join("");a.length=0;if(!e){a[0]="</";a[1]=this._tagName;a[2]=">";d.push(a.join(""));for(d=this;d;){d.length++;d=d.prevObject}a.length=0}this._elem=null;return this.prevObject||
this},tag:function(a,b){return this.begin(a,b).end()},tagName:function(a){if(a===undefined){if(!this._tagName&&this._elem)this._tagName=this._elem.tagName;return this._tagName}else{this._tagName=a;this._tagNameDidChange=YES;return this}},id:function(a){if(a===undefined){if(!this._id&&this._elem)this._id=this._elem.id;return this._id}else{this._id=a;this._idDidChange=YES;return this}},classNames:function(a,b){if(a===undefined){if(!this._classNames&&this._elem)this._classNames=(SC.$(this._elem).attr("class")||
"").split(" ");if(this._cloneClassNames){this._classNames=(this._classNames||[]).slice();this._cloneClassNames=NO}if(!this._classNames)this._classNames=[];return this._classNames}else{this._classNames=a;this._cloneClassNames=b||NO;this._classNamesDidChange=YES;return this}},hasClass:function(a){return this.classNames().indexOf(a)>=0},addClass:function(a){var b=this.classNames();if(b.indexOf(a)<0){b.push(a);this._classNamesDidChange=YES}return this},removeClass:function(a){var b=this._classNames,c;
if(!b&&this._elem)b=this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");if(b&&(c=b.indexOf(a))>=0){if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}b[c]=null;this._classNamesDidChange=YES}return this},resetClassNames:function(){this._classNames=[];this._classNamesDidChange=YES;return this},setClass:function(a,b){var c,d,e;if(b!==undefined)return b?this.addClass(a):this.removeClass(a);else{b=this._classNames;if(!b&&this._elem)b=this._classNames=(SC.$(this._elem).attr("class")||
"").split(" ");if(!b)b=this._classNames=[];if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}e=NO;for(d in a)if(a.hasOwnProperty(d)){c=b.indexOf(d);if(a[d]){if(c<0){b.push(d);e=YES}}else if(c>=0){b[c]=null;e=YES}}if(e)this._classNamesDidChange=YES}return this},_STYLE_REGEX:/\s*([^:\s]+)\s*:\s*([^;]+)\s*;?/g,styles:function(a,b){var c,d;if(a===undefined){if(!this._styles&&this._elem)if((b=SC.$(this._elem).attr("style"))&&(b=b.toString()).length>0){if(SC.browser.msie)b=
b.toLowerCase();a={};c=this._STYLE_REGEX;for(c.lastIndex=0;d=c.exec(b);)a[d[1].camelize()]=d[2];this._styles=a;this._cloneStyles=NO}else this._styles={};else if(this._styles){if(this._cloneStyles){this._styles=SC.beget(this._styles);this._cloneStyles=NO}}else this._styles={};return this._styles}else{this._styles=a;this._cloneStyles=b||NO;this._stylesDidChange=YES;return this}},addStyle:function(a,b){var c,d=NO,e=this.styles();if(typeof a===SC.T_STRING)if(b===undefined)return e[a];else{if(e[a]!==b){e[a]=
b;this._stylesDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(e[c]!==b){e[c]=b;d=YES}}if(d)this._stylesDidChange=YES}return this},removeStyle:function(a){if(!this._styles&&!this._elem)return this;var b=this.styles();if(b[a]){b[a]=null;this._stylesDidChange=YES}},attr:function(a,b){var c,d=this._attrs,e=NO;if(!d)this._attrs=d={};if(typeof a===SC.T_STRING)if(b===undefined)return d[a];else{if(d[a]!==b){d[a]=b;this._attrsDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(d[c]!==
b){d[c]=b;e=YES}}if(e)this._attrsDidChange=YES}return this}});SC.RenderContext.fn.html=SC.RenderContext.fn.push;SC.RenderContext.fn.css=SC.RenderContext.fn.addStyle;if(!SC.browser.isSafari||parseInt(SC.browser.version,10)<526)SC.RenderContext._safari3=YES;
SC.RenderContext.escapeHTML=function(a){var b,c;if(SC.none(a))return a;b=this.escapeHTMLElement;if(!b)b=this.escapeHTMLElement=document.createElement("div");c=this.escapeTextNode;if(!c){c=this.escapeTextNode=document.createTextNode("");b.appendChild(c)}c.data=a;a=b.innerHTML;if(SC.RenderContext._safari3)a=a.replace(/>/g,"&gt;");return a};
SC.Response=SC.Object.extend({isError:NO,errorValue:function(){return this}.property().cacheable(),errorObject:null,request:null,originalRequest:function(){for(var a=this.get("request");a.get("source");)a=a.get("source");return a}.property("request").cacheable(),type:function(){return this.getPath("request.type")}.property("request").cacheable(),address:function(){return this.getPath("request.address")}.property("request").cacheable(),isJSON:function(){return this.getPath("request.isJSON")||NO}.property("request").cacheable(),
isXML:function(){return this.getPath("request.isXML")||NO}.property("request").cacheable(),listeners:function(){return this.getPath("request.listeners")}.property("request").cacheable(),status:-100,headers:null,encodedBody:null,body:function(){var a=this.get("encodedBody");if(a&&this.get("isJSON"))try{a=SC.json.decode(a)}catch(b){return SC.Error.create({message:b.name+": "+b.message,label:"Response",errorValue:this})}return a}.property("encodedBody").cacheable(),response:function(){return this.get("body")}.property("body").cacheable(),
isCancelled:NO,timedOut:null,timeoutTimer:null,fire:function(){var a=this.get("request"),b=a?a.get("source"):null;b&&b.willSend&&b.willSend(a,this);a.freeze();this.get("isCancelled")||this.invokeTransport();var c=a.get("timeout");c&&this.set("timeoutTimer",SC.Timer.schedule({target:this,action:"timeoutReached",interval:c,repeats:NO}));!this.get("isCancelled")&&b&&b.didSend&&b.didSend(a,this)},invokeTransport:function(){this.receive(function(){this.set("status",200)},this)},receive:function(a,b){if(!this.get("timedOut")){var c=
this.get("timeoutTimer");c&&c.invalidate();this.set("timedOut",NO);var d=(c=this.get("request"))?c.get("source"):null;d&&d.willReceive&&d.willReceive(c,this);a.call(b,!this.get("isCancelled"));!this.get("isCancelled")&&d&&d.didReceive&&d.didReceive(c,this);this.get("isCancelled")||this.notify()}SC.Request.manager.transportDidClose(this);return this},cancel:function(){if(!this.get("isCancelled")){this.set("isCancelled",YES);this.cancelTransport();SC.Request.manager.transportDidClose(this)}},timeoutReached:function(){if(this.get("timedOut")===
null){this.set("timedOut",YES);this.cancelTransport();SC.Request.manager.transportDidClose(this);var a=SC.$error("HTTP Request timed out","Request",408);a.set("errorValue",this);this.set("isError",YES);this.set("errorObject",a);var b=(a=this.get("request"))?a.get("source"):null;!this.get("isCancelled")&&b&&b.didTimeout&&b.didTimeout(a,this)}},cancelTransport:function(){},_notifyListener:function(a,b){var c=a[b];if(!c)return NO;a=(c.params||[]).copy();a.unshift(this);b=c.target;c=c.action;if(SC.typeOf(c)===
SC.T_STRING)c=b[c];return c.apply(b,a)},notify:function(){var a=this.get("listeners"),b=this.get("status"),c=Math.floor(b/100)*100,d=NO;if(!a)return this;SC.RunLoop.begin();(d=this._notifyListener(a,b))||(d=this._notifyListener(a,c));d||this._notifyListener(a,0);SC.RunLoop.end();return this},toString:function(){return"%@<%@ %@, status=%@".fmt(arguments.callee.base.apply(this,arguments),this.get("type"),this.get("address"),this.get("status"))}});
SC.XHRResponse=SC.Response.extend({headers:function(){var a=this.get("rawRequest");a=a?a.getAllResponseHeaders():null;var b={};if(!a)return b;a.split("\n").forEach(function(c){var d=c.indexOf(":"),e;if(d>=0){e=c.slice(0,d);c=c.slice(d+1).trim();b[e]=c}},this);return b}.property("status").cacheable(),header:function(a){var b=this.get("rawRequest");return b?b.getResponseHeader(a):null},encodedBody:function(){var a=this.get("rawRequest");return a?this.get("isXML")?a.responseXML:a.responseText:null}.property("status").cacheable(),
cancelTransport:function(){var a=this.get("rawRequest");a&&a.abort();this.set("rawRequest",null)},invokeTransport:function(){function a(){for(var g=0;g<arguments.length;g++)try{return arguments[g]()}catch(h){}return NO}var b,c,d,e;b=a(function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")});this.set("rawRequest",b);if(e=!!this.getPath("request.isAsynchronous"))if(SC.browser.msie){c=this;d=function(){if(!c)return null;
var g=c.finishRequest();if(g)c=null;return g};b.onreadystatechange=d}else SC.Event.add(b,"readystatechange",this,this.finishRequest,b);b.open(this.get("type"),this.get("address"),e);d=this.getPath("request.headers");for(var f in d)b.setRequestHeader(f,d[f]);b.send(this.getPath("request.encodedBody"));e||this.finishRequest();return b},finishRequest:function(){var a=this.get("rawRequest"),b,c,d;if(a.readyState===4){this.receive(function(e){if(e){c=-1;try{c=a.status||0}catch(f){}if(c<200||c>=300){try{d=
a.statusText||""}catch(g){d=""}b=SC.$error(d||"HTTP Request failed","Request",c);b.set("errorValue",this);this.set("isError",YES);this.set("errorObject",b)}this.set("status",c)}},this);a.onreadystatechange=function(){};return YES}return NO}});sc_require("system/response");
SC.Request=SC.Object.extend(SC.Copyable,SC.Freezable,{isAsynchronous:YES,isJSON:NO,isXML:NO,headers:function(){var a=this._headers;if(!a)a=this._headers={};return a}.property().cacheable(),responseClass:SC.XHRResponse,source:null,address:null,type:"GET",timeout:null,body:null,encodedBody:function(){var a=this.get("body");if(a&&this.get("isJSON"))a=SC.json.encode(a);return a}.property("isJSON","isXML","body").cacheable(),willSend:function(){},didSend:function(){},willReceive:function(){},didReceive:function(){},
didTimeout:function(){},COPY_KEYS:"isAsynchronous isJSON isXML address type timeout body responseClass willSend didSend willReceive didReceive".w(),copy:function(){for(var a={},b=this.COPY_KEYS,c=b.length,d;--c>=0;){d=b[c];if(this.hasOwnProperty(d))a[d]=this.get(d)}if(this.hasOwnProperty("listeners"))a.listeners=SC.copy(this.get("listeners"));if(this.hasOwnProperty("_headers"))a._headers=SC.copy(this._headers);a.source=this.get("source")||this;return this.constructor.create(a)},header:function(a,
b){var c;if(SC.typeOf(a)===SC.T_STRING){c=this._headers;if(arguments.length===1)return c?c[a]:null;else{this.propertyWillChange("headers");if(!c)c=this._headers={};c[a]=b;this.propertyDidChange("headers");return this}}else if(b===undefined){c=a;this.beginPropertyChanges();for(a in c)c.hasOwnProperty(a)&&this.header(a,c[a]);this.endPropertyChanges();return this}return this},json:function(a){if(a===undefined)a=YES;a&&this.set("isXML",NO);return this.set("isJSON",a)},xml:function(a){if(a===undefined)a=
YES;a&&this.set("isJSON",NO);return this.set("isXML",a)},_prep:function(){var a=!!this.header("Content-Type");if(this.get("isJSON")&&!a)this.header("Content-Type","application/json");else this.get("isXML")&&!a&&this.header("Content-Type","text/xml");return this},send:function(a){var b=this.get("timeout");if(b){if(!this.get("isAsynchronous"))throw"Timeout values cannot be used with synchronous requests";}else if(b===0)throw"The timeout value must either not be specified or must be greater than 0";
a&&this.set("body",a);return SC.Request.manager.sendRequest(this.copy()._prep())},resend:function(){var a=this.get("source")?this:this.copy()._prep();return SC.Request.manager.sendRequest(a)},notify:function(a,b,c,d){if(SC.typeOf(a)!==SC.T_NUMBER){d=SC.A(arguments).slice(2);c=b;b=a;a=0}else d=SC.A(arguments).slice(3);var e=this.get("listeners");e||this.set("listeners",e={});e[a]={target:b,action:c,params:d};return this}});
SC.Request.mixin({getUrl:function(a){return this.create().set("address",a).set("type","GET")},postUrl:function(a,b){a=this.create().set("address",a).set("type","POST");b&&a.set("body",b);return a},deleteUrl:function(a){return this.create().set("address",a).set("type","DELETE")},putUrl:function(a,b){a=this.create().set("address",a).set("type","PUT");b&&a.set("body",b);return a}});
SC.Request.manager=SC.Object.create(SC.DelegateSupport,{maxRequests:6,inflight:[],pending:[],sendRequest:function(a){if(!a)return null;a=a.get("responseClass").create({request:a});this.get("pending").pushObject(a);this.fireRequestIfNeeded();return a},cancel:function(a){var b=this.get("pending"),c=this.get("inflight");if(b.indexOf(a)>=0){this.propertyWillChange("pending");b.removeObject(a);this.propertyDidChange("pending");return YES}else if(c.indexOf(a)>=0){a.cancel();c.removeObject(a);this.fireRequestIfNeeded();
return YES}else return NO},cancelAll:function(){if(this.get("pending").length||this.get("inflight").length){this.set("pending",[]);this.get("inflight").forEach(function(a){a.cancel()});this.set("inflight",[]);return YES}else return NO},fireRequestIfNeeded:function(){var a=this.get("pending"),b=this.get("inflight"),c=this.get("maxRequests");if(a.length>0&&b.length<c){a=a.shiftObject();b.pushObject(a);a.fire()}},transportDidClose:function(a){this.get("inflight").removeObject(a);this.fireRequestIfNeeded()}});
sc_require("system/ready");
SC.RootResponder=SC.Object.extend({panes:null,init:function(){arguments.callee.base.apply(this,arguments);this.panes=SC.Set.create()},mainPane:null,makeMainPane:function(a){var b=this.get("mainPane");if(b===a)return this;this.beginPropertyChanges();this.get("keyPane")===b&&this.makeKeyPane(a);this.set("mainPane",a);b&&b.blurMainTo(a);a&&a.focusMainFrom(b);this.endPropertyChanges();return this},keyPane:null,previousKeyPanes:[],makeKeyPane:function(a){var b,c;if(a)if(a.get("acceptsKeyPane")){b=this.get("keyPane");
if(b===a)return this;else{if(b){c=this.get("previousKeyPanes");c.push(b)}a=a}}else return this;else{b=this.get("keyPane");c=this.get("previousKeyPanes");for(a=null;c.length>0;){var d=c.pop();if(d.get("isPaneAttached")&&d.get("acceptsKeyPane")){a=d;break}}}if(!a)if((c=this.get("mainPane"))&&c.get("acceptsKeyPane"))a=c;b&&b.willLoseKeyPaneTo(a);a&&a.willBecomeKeyPaneFrom(b);this.set("keyPane",a);a&&a.didBecomeKeyPaneFrom(b);b&&b.didLoseKeyPaneTo(a);return this},computeWindowSize:function(){return{width:640,
height:480}},defaultResponder:null,sendAction:function(a,b,c,d,e){return(b=this.targetForAction(a,b,c,d))&&b.isResponderContext?!!b.sendAction(a,c,e):b&&b.tryToPerform(a,c)},_responderFor:function(a,b){var c=a?a.get("defaultResponder"):null;if(a){a=a.get("firstResponder")||a;do if(a.respondsTo(b))return a;while(a=a.get("nextResponder"))}if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);return c?c.isResponderContext?c:c.respondsTo(b)?c:null:null},targetForAction:function(a,b,c,d){if(!a||SC.typeOf(a)!==
SC.T_STRING)return null;if(b){if(SC.typeOf(b)===SC.T_STRING)b=SC.objectForPropertyPath(b);if(b)if(b.respondsTo&&!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null;return b}if(d)return this._responderFor(d,a);c=this.get("keyPane");var e=this.get("mainPane");if(c&&c!==d)b=this._responderFor(c,a);if(!b&&e&&e!==c)b=this._responderFor(e,a);if(!b&&(b=this.get("defaultResponder"))){if(SC.typeOf(b)===SC.T_STRING)(b=SC.objectForPropertyPath(b))&&this.set("defaultResponder",b);if(b)if(b.respondsTo&&
!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null}return b},targetViewForEvent:function(a){return a.target?SC.$(a.target).view()[0]:null},sendEvent:function(a,b,c){var d;SC.RunLoop.begin();a=(d=c?c.get("pane"):this.get("keyPane")||this.get("mainPane"))?d.sendEvent(a,b,c):null;SC.RunLoop.end();return a},listenFor:function(a,b){a.forEach(function(c){var d=this[c];d&&SC.Event.add(b,c,this,d)},this);b=null;return this},setup:function(){this.listenFor("touchstart touchmove touchend touchcancel".w(),
document)},touchstart:function(a){try{var b=this.targetViewForEvent(a);if((b=this._touchView=this.sendEvent("touchStart",a,b))&&b.respondsTo("touchDragged"))this._touchCanDrag=YES}catch(c){console.log("Exception during touchStart: %@".fmt(c));this._touchView=null;return this._touchCanDrag=NO}return b?a.hasCustomEventHandling:YES},touchmove:function(a){SC.RunLoop.begin();try{for(var b=this._lastHovered||[],c=[],d=this.targetViewForEvent(a);d&&d!==this;){b.indexOf(d)!==-1?d.tryToPerform("touchMoved",
a):d.tryToPerform("touchEntered",a);c.push(d);d=d.get("nextResponder")}for(var e=0;e<b.length;e++){d=b[e];d.respondsTo("touchExited")&&c.indexOf(d)===-1&&d.tryToPerform("touchExited",a)}this._lastHovered=c;this._touchView&&this._touchView.tryToPerform("touchDragged",a)}catch(f){console.log("Exception during touchMove: %@".fmt(f))}SC.RunLoop.end();return YES},touchend:function(a){try{a.cancel=NO;var b=null,c=this._touchView;if(c)b=this.sendEvent("touchEnd",a,c);b||this.targetViewForEvent(a);this._touchCanDrag=
NO;this._touchView=null}catch(d){console.log("Exception during touchEnd: %@".fmt(d));this._touchCanDrag=NO;this._touchView=null;return NO}return b?a.hasCustomEventHandling:YES},touchcancel:function(a){a.cancel=YES;return this.touchend(a)}});SC.ready(SC.RootResponder,SC.RootResponder.ready=function(){(SC.RootResponder.responder=SC.RootResponder.create()).setup()});
SC.routes=SC.Object.create({location:function(a,b){if(b!==undefined){if(b===null)b="";if(typeof b=="object"){var c=b.route?b.route.split("&"):[""],d=c.shift(),e={};c.forEach(function(f){f=f.split("=");e[f[0]]=f[1]});for(a in b)if(b.hasOwnProperty(a))if(a!="route")e[a]=encodeURIComponent(""+b[a]);c=[d];for(a in e)e.hasOwnProperty(a)&&c.push([a,e[a]].join("="));b=c.join("&")}if(this._location!=b){this._location=b;this._setWindowLocation(b)}}return this._location}.property(),ping:function(){if(!this._didSetupHistory){this._didSetupHistory=
true;this._setupHistory()}this._checkWindowLocation()},add:function(a,b,c){if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}else if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=a.split("/");if(!this._routes)this._routes=SC.routes._Route.create();this._routes.addRoute(a,b,c);return this},gotoRoute:function(a){var b={},c;this._lastRoute=a;if((c=a.split("&"))&&c.length>0){a=c.shift();c.forEach(function(d){if((d=d.split("="))&&d.length>1)b[d[0]]=decodeURIComponent(d[1])})}else a="";c=a.split("/");if(!this._routes)this._routes=
SC.routes._Route.create();if(c=this._routes.functionForRoute(c,b)){a=c._target;(c=c._method)&&c.call(a,b)}},init:function(){arguments.callee.base.call(this);if(SC.browser.isSafari&&parseInt(SC.browser.version,0)<417)SC.mixin(this,this.browserFuncs.safari);else if(SC.browser.isIE)SC.mixin(this,this.browserFuncs.ie);else SC.browser.isMozilla&&SC.mixin(this,this.browserFuncs.firefox);this._didSetupHistory=false},invokeCheckWindowLocation:function(a){var b=this.__checkWindowLocation,c=this;if(!b)b=this.__checkWindowLocation=
function(){c._checkWindowLocation()};setTimeout(b,a)},browserFuncs:{safari:{_setupHistory:function(){var a=location.hash;this._cloc=a=a&&a.length>0?a.slice(1,a.length):"";this._backStack=[];this._backStack.length=history.length;this._backStack.push(a);this._forwardStack=[];this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=history.length-this._lastLength!==0,b=a?history.length-this._backStack.length:0;this._lastLength=history.length;a&&console.log("historyDidChange");if(b)if(b<
0){this._forwardStack.push(this._cloc);for(a=0;a<Math.abs(b+1);a++)this._forwardStack.push(this._backStack.pop());this._cloc=this._backStack.pop()}else{this._backStack.push(this._cloc);for(a=0;a<b-1;a++)this._backStack.push(this._forwardStack.pop());this._cloc=this._forwardStack.pop()}else if(a&&this._locationDidChange){this.gotoRoute(this._cloc);this._locationDidChange=false}b=this._cloc;a=this.get("location");if(b!=a){this.set("location",b?b:"");this.gotoRoute(b)}this.invokeCheckWindowLocation(50)},
_setWindowLocation:function(a){if(this._cloc!=a){this._backStack.push(this._cloc);this._forwardStack.length=0;this._cloc=a;location.hash=a&&a.length>0?a:"";this._locationDidChange=true}}},ie:{_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)this.set("location",b?b:"");this.invokeCheckWindowLocation(100)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>
0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}},firefox:{_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}}},_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},
_checkWindowLocation:function(){var a=this.get("location"),b=decodeURI(location.hash);b=b&&b.length>0?b.slice(1,b.length):"";if(b!==a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?encodeURI(a):"#";this.gotoRoute(a)},_routes:null,_Route:SC.Object.extend({_target:null,_method:null,_static:null,_dynamic:null,_wildcard:null,
addRoute:function(a,b,c){if(!a||a.length===0){this._target=b;this._method=c}else{var d=a.shift(),e=null;switch(d.slice(0,1)){case ":":d=d.slice(1,d.length);var f=this._dynamic[d]||[];e=SC.routes._Route.create();f.push(e);this._dynamic[d]=f;break;case "*":this._wildcard=d=d.slice(1,d.length);this._target=b;this._method=c;break;default:f=this._static[d]||[];e=SC.routes._Route.create();f.push(e);this._static[d]=f}e&&e.addRoute(a,b,c)}},functionForRoute:function(a,b){if(!a||a.length===0)return this;else{var c=
a.shift(),d=null,e,f,g;if(e=this._static[c]){f=0;for(g=e.length;f<g&&d===null;f++){d=a.slice();d=e[f].functionForRoute(d,b)}}if(d===null)for(var h in this._dynamic){if(e=this._dynamic[h]){f=0;for(g=e.length;f<g&&d===null;f++){d=a.slice();if((d=e[f].functionForRoute(d,b))&&b)b[h]=c}}if(d)break}if(d===null&&this._wildcard){a.unshift(c);if(b)b[this._wildcard]=a.join("/");d=this}return d}},init:function(){arguments.callee.base.call(this);this._static={};this._dynamic={}}})});
SC.time=function(){var a=SC.beget(fn);a.value=timeOffset;return a};(function(){var a=new Date;SC.mixin(SC.time,{month:function(b,c){a.setTime(b);if(c===undefined)return a.getMonth();a.setMonth(c);return a.getTime()},utc:function(b){a.setTime(b);return b+a.getTimezoneOffset()*60*1E3},local:function(b){a.setTime(b);return b-a.getTimezoneOffset()*60*1E3},parse:function(){},format:function(){}})})();SC.time.fmt=SC.time.format;SC.time.fn={done:function(){return this.value}};
"month day year".split(" ").forEach(function(a){SC.time.fn[a]=function(b){if(b===undefined)return SC.time[a](this.value);else{this.value=SC.time[a](this.value,b);return this}}});
var MONTH_NAMES=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),DAY_NAMES=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");function LZ(a){return(a<0||a>9?"":"0")+a}
SC.Locale.define("en",{longMonthNames:"January February March April May".split(" "),shortMonthNames:[],shortDateFormat:"dd/mm/yy",longDateFormat:""});
SC.mixin(Date,{now:function(){return(new Date).getTime()},isDate:function(a,b){if(Date.getDateFromFormat(a,b)==0)return false;return true},compareDates:function(a,b,c,d){a=Date.getDateFromFormat(a,b);c=Date.getDateFromFormat(c,d);if(a==0||c==0)return-1;else if(a>c)return 1;return 0},getDateFromFormat:function(a,b){a+="";b+="";var c=0,d=0,e="",f="",g,h,i=new Date,j=i.getFullYear(),k=i.getMonth()+1,l=1,m=i.getHours(),o=i.getMinutes();i=i.getSeconds();for(var r="";d<b.length;){e=b.charAt(d);for(f="";b.charAt(d)==
e&&d<b.length;)f+=b.charAt(d++);if(f=="yyyy"||f=="yy"||f=="y"){if(f=="yyyy")h=g=4;if(f=="yy")h=g=2;if(f=="y"){g=2;h=4}j=Date._getInt(a,c,g,h);if(j==null)return 0;c+=j.length;if(j.length==2)j=j>70?1900+(j-0):2E3+(j-0)}else if(f=="MMM"||f=="NNN"){for(e=k=0;e<MONTH_NAMES.length;e++){var w=MONTH_NAMES[e];if(a.substring(c,c+w.length).toLowerCase()==w.toLowerCase())if(f=="MMM"||f=="NNN"&&e>11){k=e+1;if(k>12)k-=12;c+=w.length;break}}if(k<1||k>12)return 0}else if(f=="EE"||f=="E")for(e=0;e<DAY_NAMES.length;e++){f=
DAY_NAMES[e];if(a.substring(c,c+f.length).toLowerCase()==f.toLowerCase()){c+=f.length;break}}else if(f=="MM"||f=="M"){k=Date._getInt(a,c,f.length,2);if(k==null||k<1||k>12)return 0;c+=k.length}else if(f=="dd"||f=="d"){l=Date._getInt(a,c,f.length,2);if(l==null||l<1||l>31)return 0;c+=l.length}else if(f=="hh"||f=="h"){m=Date._getInt(a,c,f.length,2);if(m==null||m<1||m>12)return 0;c+=m.length}else if(f=="HH"||f=="H"){m=Date._getInt(a,c,f.length,2);if(m==null||m<0||m>23)return 0;c+=m.length}else if(f=="KK"||
f=="K"){m=Date._getInt(a,c,f.length,2);if(m==null||m<0||m>11)return 0;c+=m.length}else if(f=="kk"||f=="k"){m=Date._getInt(a,c,f.length,2);if(m==null||m<1||m>24)return 0;c+=m.length;m--}else if(f=="mm"||f=="m"){o=Date._getInt(a,c,f.length,2);if(o==null||o<0||o>59)return 0;c+=o.length}else if(f=="ss"||f=="s"){i=Date._getInt(a,c,f.length,2);if(i==null||i<0||i>59)return 0;c+=i.length}else if(f=="a"){if(a.substring(c,c+2).toLowerCase()=="am")r="AM";else if(a.substring(c,c+2).toLowerCase()=="pm")r="PM";
else return 0;c+=2}else if(a.substring(c,c+f.length)!=f)return 0;else c+=f.length}if(c!=a.length)return 0;if(k==2)if(j%4==0&&j%100!=0||j%400==0){if(l>29)return 0}else if(l>28)return 0;if(k==4||k==6||k==9||k==11)if(l>30)return 0;if(m<12&&r=="PM")m=m-0+12;else if(m>11&&r=="AM")m-=12;return(new Date(j,k-1,l,m,o,i)).getTime()},parseDate:function(a){var b=arguments.length==2?arguments[1]:false;generalFormats=new Array("E NNN dd HH:mm:ss UTC yyyy","y-M-d","y-M-d","MMM d, y","MMM d,y","y-MMM-d","d-MMM-y",
"MMM d","d MMM y","d.MMM.y","y MMM d","y.MMM.d");monthFirst=new Array("M/d/y","M-d-y","M.d.y","MMM-d","M/d","M-d");dateFirst=new Array("d/M/y","d-M-y","d.M.y","d-MMM","d/M","d-M");b=new Array("generalFormats",b?"dateFirst":"monthFirst",b?"monthFirst":"dateFirst");var c=null;c=0;var d=(new Date).getTime();switch(a.toLowerCase()){case "yesterday".loc():c=d-864E5;break;case "today".loc():case "now".loc():c=d;break;case "tomorrow".loc():c=d+864E5;break}if(c>0)return new Date(c);for(d=0;d<b.length;d++)for(var e=
window[b[d]],f=0;f<e.length;f++){c=Date.getDateFromFormat(a,e[f]);if(c==0)c=Date.getDateFromFormat(a,e[f]+" H:m:s");if(c==0)c=Date.getDateFromFormat(a,e[f]+" h:m:s a");if(c!=0)return new Date(c)}return null},_isInteger:function(a){for(var b=0;b<a.length;b++)if("1234567890".indexOf(a.charAt(b))==-1)return false;return true},_getInt:function(a,b,c,d){for(d=d;d>=c;d--){var e=a.substring(b,b+d);if(e.length<c)return null;if(Date._isInteger(e))return e}return null}});
SC.mixin(Date.prototype,{format:function(a){a+="";var b=this,c="",d=0,e="",f="";e=b.getFullYear()+"";f=b.getMonth()+1;var g=b.getDate(),h=b.getDay(),i=b.getHours(),j=b.getMinutes(),k=b.getSeconds();b={};if(e.length<4)e=""+(e-0+1900);b.y=""+e;b.yyyy=e;b.yy=e.substring(2,4);b.M=f;b.MM=LZ(f);b.MMM=MONTH_NAMES[f-1];b.NNN=MONTH_NAMES[f+11];b.d=g;b.dd=LZ(g);b.E=DAY_NAMES[h+7];b.EE=DAY_NAMES[h];b.H=i;b.HH=LZ(i);b.h=i==0?12:i>12?i-12:i;b.hh=LZ(b.h);b.K=i>11?i-12:i;b.k=i+1;b.KK=LZ(b.K);b.kk=LZ(b.k);b.a=i>
11?"PM":"AM";b.m=j;b.mm=LZ(j);b.s=k;for(b.ss=LZ(k);d<a.length;){e=a.charAt(d);for(f="";a.charAt(d)==e&&d<a.length;)f+=a.charAt(d++);c+=b[f]!=null?b[f]:f}return c},utcFormat:function(){return(new Date(this.getTime()+this.getTimezoneOffset()*60*1E3)).format("E NNN dd HH:mm:ss UTC yyyy")}});
SC.Timer=SC.Object.extend({target:null,action:null,isPooled:NO,interval:0,startTime:null,repeats:NO,until:null,isPaused:NO,isScheduled:NO,isValid:YES,lastFireTime:0,fireTime:function(){if(!this.get("isValid"))return-1;var a=this.get("startTime");if(!a||a===0)return-1;var b=this.get("interval"),c=this.get("lastFireTime");if(c<a)c=a;a=this.get("repeats")?b===0?c:a+(Math.floor((c-a)/b)+1)*b:a+b;if((b=this.get("until"))&&b>0&&a>b)a=b;return a}.property("interval","startTime","repeats","until","isValid",
"lastFireTime").cacheable(),schedule:function(){if(!this.get("isValid"))return this;this.beginPropertyChanges();this.startTime||this.set("startTime",SC.RunLoop.currentRunLoop.get("startTime"));var a=this.get("fireTime"),b=this.get("lastFireTime");if(a>=b){this.set("isScheduled",YES);SC.RunLoop.currentRunLoop.scheduleTimer(this,a)}this.endPropertyChanges();return this},invalidate:function(){this.beginPropertyChanges();this.set("isValid",NO);SC.RunLoop.currentRunLoop.cancelTimer(this);this.action=this.target=
null;this.endPropertyChanges();this.get("isPooled")&&SC.Timer.returnTimerToPool(this);return this},fire:function(){var a=Date.now();this.set("lastFireTime",a);var b=this.get("fireTime");this.get("isPaused")||this.performAction();b>a?this.schedule():this.invalidate()},performAction:function(){var a=SC.typeOf(this.action);if(a==SC.T_FUNCTION)this.action.call(this.target||this,this);else if(a===SC.T_STRING)if(this.action.indexOf(".")>=0){var b=this.action.split(".");a=b.pop();b=SC.objectForPropertyPath(b,
window);if((a=b.get?b.get(a):b[a])&&SC.typeOf(a)==SC.T_FUNCTION)a.call(b,this);else throw"%@: Timer could not find a function at %@".fmt(this,this.action);}else SC.RootResponder.responder.sendAction(this.action,this.target,this)},init:function(){arguments.callee.base.apply(this,arguments);if(this.startTime instanceof Date)this.startTime=this.startTime.getTime();if(this.until instanceof Date)this.until=this.until.getTime()},RESET_DEFAULTS:{target:null,action:null,isPooled:NO,isPaused:NO,isScheduled:NO,
isValid:YES,interval:0,repeats:NO,until:null,startTime:null,lastFireTime:0},reset:function(a){if(!a)a=SC.EMPTY_HASH;this.propertyWillChange("fireTime");var b=this.RESET_DEFAULTS;for(var c in b)if(b.hasOwnProperty(c))this[c]=SC.none(a[c])?b[c]:a[c];this.propertyDidChange("fireTime");return this},removeFromTimerQueue:function(a){var b=this._timerQueuePrevious,c=this._timerQueueNext;if(!b&&!c&&a!==this)return a;if(b)b._timerQueueNext=c;if(c)c._timerQueuePrevious=b;this._timerQueuePrevious=this._timerQueueNext=
null;return a===this?c:a},scheduleInTimerQueue:function(a,b){this._timerQueueRunTime=b;for(var c=a,d=null;c&&c._timerQueueRunTime<b;){d=c;c=c._timerQueueNext}if(d){d._timerQueueNext=this;this._timerQueuePrevious=d}if(c){c._timerQueuePrevious=this;this._timerQueueNext=c}return c===a?this:a},collectExpiredTimers:function(a,b){if(this._timerQueueRunTime>b)return this;a.push(this);var c=this._timerQueueNext;this._timerQueueNext=null;if(c)c._timerQueuePrevious=null;return c?c.collectExpiredTimers(a,b):
null}});SC.Timer.schedule=function(a){return(!a||SC.none(a.isPooled)||a.isPooled?this.timerFromPool(a):this.create(a)).schedule()};SC.Timer.timerFromPool=function(a){var b=this._timerPool;if(!b)b=this._timerPool=[];(b=b.pop())||(b=this.create());return b.reset(a)};SC.Timer.returnTimerToPool=function(a){if(!this._timerPool)this._timerPool=[];this._timerPool.push(a);return this};
SC.UserDefaults=SC.Object.extend({userDomain:null,appDomain:null,_defaults:null,defaults:function(a){this._defaults=a;this.allPropertiesDidChange()},readDefault:function(a){var b=undefined;a=this._normalizeKeyName(a);var c=this._userKeyName(a);if(this._written)b=this._written[c];var d=window.localStorage;if(!d&&window.globalStorage)d=window.globalStorage[window.location.hostname];if(d){b=d[["SC.UserDefaults",c].join("@")];if(SC.none(b))b=undefined;else try{b=SC.json.decode(b)}catch(e){b=undefined}}if((d=
this.delegate)&&d.userDefaultsNeedsDefault)b=d.userDefaultsNeedsDefault(this,a,c);if(b===undefined&&this._defaults)b=this._defaults[c]||this._defaults[a];return b},writeDefault:function(a,b){a=this._normalizeKeyName(a);var c=this._userKeyName(a),d=this._written;if(!d)d=this._written={};d[c]=b;d=window.localStorage;if(!d&&window.globalStorage)d=window.globalStorage[window.location.hostname];if(d)d[["SC.UserDefaults",c].join("@")]=SC.json.encode(b);(d=this.delegate)&&d.userDefaultsDidChange&&d.userDefaultsDidChange(this,
a,b,c);return this},resetDefault:function(a){var b=this._normalizeKeyName(a),c=this._userKeyName(b);this.propertyWillChange(a);this.propertyWillChange(b);var d=this._written;d&&delete d[c];d=window.localStorage;if(!d&&window.globalStorage)d=window.globalStorage[window.location.hostname];d&&delete d[["SC.UserDefaults",c].join("@")];this.propertyDidChange(a);this.propertyDidChange(b);return this},unknownProperty:function(a,b){if(b===undefined)return this.readDefault(a);else{this.writeDefault(a,b);return b}},
_normalizeKeyName:function(a){if(a.indexOf(":")<0)a=[this.get("appDomain")||"app",a].join(":");return a},_userKeyName:function(a){return[this.get("userDomain")||"(anonymous)",a].join("@")},_domainDidChange:function(){var a=NO;if(this.get("userDomain")!==this._scud_userDomain){this._scud_userDomain=this.get("userDomain");a=YES}if(this.get("appDomain")!==this._scud_appDomain){this._scud_appDomain=this.get("appDomain");a=YES}a&&this.allPropertiesDidChange()}.observes("userDomain","appDomain"),init:function(){arguments.callee.base.apply(this,
arguments);this._scud_userDomain=this.get("userDomain");this._scud_appDomain=this.get("appDomain")}});SC.userDefaults=SC.UserDefaults.create();sc_require("system/browser");
SC.mixin({_downloadFrames:0,_copy_computed_props:["maxWidth","maxHeight","paddingLeft","paddingRight","paddingTop","paddingBottom","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","lineHeight","whiteSpace"],download:function(a){var b=document.createElement("iframe"),c="DownloadFrame_"+this._downloadFrames;SC.$(b).attr("id",c);b.style.border="10px";b.style.width="0px";b.style.height="0px";b.style.position="absolute";b.style.top="-10000px";b.style.left="-10000px";SC.browser.isSafari||
SC.$(b).attr("src",a);document.getElementsByTagName("body")[0].appendChild(b);SC.browser.isSafari&&SC.$(b).attr("src",a);this._downloadFrames+=1;SC.browser.isSafari||function(){document.body.removeChild(document.getElementById(c));c=null}.invokeLater(null,2E3);b=null},normalizeURL:function(a){if(a.slice(0,1)=="/")a=window.location.protocol+"//"+window.location.host+a;else a.slice(0,5)=="http:"||a.slice(0,6)=="https:"||(a=window.location.href+"/"+a);return a},minX:function(a){return a.x||0},maxX:function(a){return(a.x||
0)+(a.width||0)},midX:function(a){return(a.x||0)+(a.width||0)/2},minY:function(a){return a.y||0},maxY:function(a){return(a.y||0)+(a.height||0)},midY:function(a){return(a.y||0)+(a.height||0)/2},centerX:function(a,b){return(b.width-a.width)/2},centerY:function(a,b){return(b.height-a.height)/2},pointInRect:function(a,b){return a.x>=SC.minX(b)&&a.y>=SC.minY(b)&&a.x<=SC.maxX(b)&&a.y<=SC.maxY(b)},rectsEqual:function(a,b,c){if(!a||!b)return a==b;if(!c&&c!==0)c=0.1;if(a.y!=b.y&&Math.abs(a.y-b.y)>c)return NO;
if(a.x!=b.x&&Math.abs(a.x-b.x)>c)return NO;if(a.width!=b.width&&Math.abs(a.width-b.width)>c)return NO;if(a.height!=b.height&&Math.abs(a.height-b.height)>c)return NO;return YES},intersectRects:function(a,b){a={x:Math.max(SC.minX(a),SC.minX(b)),y:Math.max(SC.minY(a),SC.minY(b)),width:Math.min(SC.maxX(a),SC.maxX(b)),height:Math.min(SC.maxY(a),SC.maxY(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},unionRects:function(a,b){a={x:Math.min(SC.minX(a),SC.minX(b)),y:Math.min(SC.minY(a),
SC.minY(b)),width:Math.max(SC.maxX(a),SC.maxX(b)),height:Math.max(SC.maxY(a),SC.maxY(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},cloneRect:function(a){return{x:a.x,y:a.y,width:a.width,height:a.height}},stringFromRect:function(a){return"{%@, %@, %@, %@}".fmt(a.x,a.y,a.width,a.height)},stringFromLayout:function(a){for(var b=["maxHeight","maxWidth","minHeight","minWidth","centerY","centerX","width","height","bottom","right","top","left"],c=[],d=b.length;--d>=0;){var e=
b[d];a.hasOwnProperty(e)&&c.push(e+":"+a[e])}return"{"+c.join(", ")+"}"},heightForString:function(a,b,c,d){var e=this._heightCalcElement;d=d&&SC.typeOf(d)===SC.T_ARRAY?d.join(" "):"";b||(b=100);if(!e){e=this._heightCalcElement=document.createElement("div");document.body.insertBefore(e,null)}c="%@; width: %@px; left: %@px; position: absolute".fmt(c,b,-1*b);SC.$(e).attr("style",c);d!==""&&SC.$(e).attr("class",d);e.innerHTML=a;return e.clientHeight},metricsForString:function(a,b,c){var d=this._metricsCalculationElement;
c=SC.A(c).join(" ");if(!d){d=this._metricsCalculationElement=document.createElement("div");document.body.insertBefore(d,null)}if(SC.typeOf(b)!=SC.T_STRING){var e=null;e=document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(b,null):b.currentStyle;b=e.cssText;if(!b||b.trim()===""){b=this._copy_computed_props;for(var f=0;f<b.length;f++){var g=b[f];d.style[g]=e[g]}e=d.style;if(e.font===""){b="";if(e.fontStyle)b+=e.fontStyle+" ";if(e.fontVariant)b+=e.fontVariant+
" ";if(e.fontWeight)b+=e.fontWeight+" ";b+=e.fontSize?e.fontSize:"10px";if(e.lineHeight)b+="/"+e.lineHeight;b+=" ";if(e.fontFamily)b+=e.fontFamily;d.style.font=b}SC.mixin(d.style,{left:"0px",top:"0px",position:"absolute",bottom:"auto",right:"auto",width:"auto",height:"auto"})}else d.setAttribute("style",b+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}else{b=b;d.setAttribute("style",b+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}if(typeof d.innerText!=
"undefined")d.innerText=a;else d.textContent=a;d.className=c;a={width:d.clientWidth,height:d.clientHeight};d.innerHTML="";d.className="";d.setAttribute("style","");return a},viewportOffset:function(a){if(a.getBoundingClientRect){a=a.getBoundingClientRect();return{x:a.left,y:a.top}}for(var b=0,c=0,d=a,e=SC.browser.mozilla>=3;d;){c+=d.offsetTop||0;if(!e||d!==a)c+=d.clientTop||0;b+=d.offsetLeft||0;if(!e||d!==a)b+=d.clientLeft||0;if(SC.browser.mozilla){if(SC.$(d).attr("overflow")!=="visible"){var f=parseInt(SC.$(d).attr("borderLeftWidth"),
0)||0,g=parseInt(SC.$(d).attr("borderTopWidth"),0)||0;if(a!==d){f*=2;g*=2}b+=f;c+=g}f=d.offsetParent;if(SC.browser.mozilla>=3&&f){c-=f.clientTop;b-=f.clientLeft}}if(d.offsetParent==document.body&&SC.$(d).attr("position")=="absolute")break;d=d.offsetParent}for(d=a;d;){if(!SC.browser.isOpera||d.tagName=="BODY"){c-=d.scrollTop||0;b-=d.scrollLeft||0}d=d.parentNode}return{x:b,y:c}},ZERO_POINT:{x:0,y:0},ZERO_RANGE:{start:0,length:0},RANGE_NOT_FOUND:{start:0,length:-1},valueInRange:function(a,b){return a>=
0&&a>=b.start&&a<b.start+b.length},minRange:function(a){return a.start},maxRange:function(a){return a.length<0?-1:a.start+a.length},unionRanges:function(a,b){if(a==null||a.length<0)return b;if(b==null||b.length<0)return a;var c=Math.min(a.start,b.start);a=Math.max(SC.maxRange(a),SC.maxRange(b));return{start:c,length:a-c}},intersectRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),
SC.maxRange(b));if(a<c)return SC.RANGE_NOT_FOUND;return{start:c,length:a-c}},subtractRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),SC.maxRange(b));if(c<a)return SC.RANGE_NOT_FOUND;return{start:a,length:c-a}},cloneRange:function(a){return{start:a.start,length:a.length}},rangesEqual:function(a,b){if(a===b)return true;if(a==null)return b.length<0;if(b==null)return a.length<
0;return a.start==b.start&&a.length==b.length},convertHsvToHex:function(a,b,c){var d=0,e=0,f=0;if(c>0){f=a==1?0:Math.floor(a*6);a=a==1?0:a*6-f;d=c*(1-b);e=c*(1-b*a);b=c*(1-b*(1-a));c=[[c,b,d],[e,c,d],[d,c,b],[d,e,c],[b,d,c],[c,d,e]];d=Math.round(255*c[f][0]);e=Math.round(255*c[f][1]);f=Math.round(255*c[f][2])}return this.parseColor("rgb("+d+","+e+","+f+")")},convertHexToHsv:function(a){var b=this.expandColor(a);a=Math.max(Math.max(b[0],b[1]),b[2]);var c=Math.min(Math.min(b[0],b[1]),b[2]);b=a==c?0:
a==b[0]?(b[1]-b[2])/(a-c)/6:a==b[1]?(b[2]-b[0])/(a-c)/6+1/3:(b[0]-b[1])/(a-c)/6+2/3;b=b<0?b+1:b>1?b-1:b;return[b,a==0?0:1-c/a,a/255]},PARSE_COLOR_RGBRE:/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,PARSE_COLOR_HEXRE:/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,expandColor:function(a){var b,c;if(b=this.parseColor(a)){a=parseInt(b.slice(1,3),16);c=parseInt(b.slice(3,5),16);b=parseInt(b.slice(5,7),16);return[a,c,b]}},parseColor:function(a){var b=0,c="#",d;if(d=this.PARSE_COLOR_RGBRE.exec(a)){for(b=1;b<=3;b++){a=
Math.max(0,Math.min(255,parseInt(d[b],0)));c+=this.toColorPart(a)}return c}if(d=this.PARSE_COLOR_HEXRE.exec(a)){if(d[1].length==3){for(b=0;b<3;b++)c+=d[1].charAt(b)+d[1].charAt(b);return c}return"#"+d[1]}return false},toColorPart:function(a){if(a>255)a=255;var b=a.toString(16);if(a<16)return"0"+b;return b},getStyle:function(a,b){var c="";if(document.defaultView&&document.defaultView.getComputedStyle)c=document.defaultView.getComputedStyle(a,"").getPropertyValue(b);else if(a.currentStyle){b=b.replace(/\-(\w)/g,
function(d,e){return e.toUpperCase()});c=a.currentStyle[b]}return c}});SC.VALIDATE_OK=YES;SC.VALIDATE_NO_CHANGE=NO;
SC.Validator=SC.Object.extend({fieldValueForObject:function(a){return a},objectForFieldValue:function(a){return a},validate:function(){return true},validateError:function(a,b){return SC.$error("Invalid.General(%@)".loc(b.get("fieldValue")),b.get("fieldKey"))},validateChange:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateSubmit:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validatePartial:function(a,b){return b.get("isValid")?
SC.VALIDATE_NO_CHANGE:this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateKeyDown:function(){return true},attachTo:function(){},detachFrom:function(){}});
SC.Validator.mixin({OK:true,NO_CHANGE:false,findFor:function(a,b,c){var d;if(c){if(c instanceof SC.Validator)d=c;else if(c.isClass)d=c.create();else if(SC.typeOf(c)===SC.T_STRING){var e=null;if(d=c.match(/^(.+)\[(.*)\]/)){c=d[1];e=d[2]}c=c.classify();var f=SC.Validator[c];if(SC.none(f))throw"validator %@ not found for %@".fmt(c,b);else if(e){if(!a)throw"named validator (%@) could not be found for field %@ because the field does not belong to a form".fmt(e,b);if(!a._validatorHash)a._validatorHash=
{};(d=e?a._validatorHash[e]:null)||(d=f.create());if(e)a._validatorHash[e]=d}else d=f.create()}return d}},fieldValueForObject:function(a,b,c){return this.prototype&&this.prototype.fieldValueForObject?this.prototype.fieldValueForObject(a,b,c):null},objectForFieldValue:function(a,b,c){return this.prototype&&this.prototype.objectForFieldValue?this.prototype.objectForFieldValue(a,b,c):null}});sc_require("validators/validator");
SC.Validator.CreditCard=SC.Validator.extend({fieldValueForObject:function(a){if(typeof a=="string"&&a.length==16)a=[a.slice(0,4),a.slice(4,8),a.slice(8,12),a.slice(12,16)].join(" ");return a},objectForFieldValue:function(a){return a.replace(/[\s-\.\:]/g,"")},validate:function(a,b){return this.checkNumber(b.get("fieldValue"))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.CreditCard(%@)".loc(a),a)},validateKeyDown:function(a,b,c){return!!c.match(/[0-9\- ]/)},
checkNumber:function(a){if(!a||a.length===0)return YES;a=a.replace(/[^0-9]/g,"");var b=a.length,c=parseInt(a,0),d=a.toString();d=d.replace(/^\s+|\s+$/g,"");a=0;for(var e=true,f=false,g,h=0;h<b;h++){g=""+d.substring(h,h+1);if("0123456789".indexOf(g)=="-1")e=false}e||(f=false);if(b===0&&f)f=false;else if(b>=15){for(d=b;d>0;d--){b=parseInt(c,0)%10;b=parseInt(b,0);a+=b;d--;c/=10;b=parseInt(c,0)%10;b*=2;switch(b){case 10:b=1;break;case 12:b=3;break;case 14:b=5;break;case 16:b=7;break;case 18:b=9;break;
default:b=b}c/=10;a+=b}f=a%10===0?true:false}return f}});sc_require("validators/validator");SC.Validator.Date=SC.Validator.extend({format:"NNN d, yyyy h:mm:ss a",fieldValueForObject:function(a){var b;if(typeof a==="number")b=new Date(a);else if(a instanceof Date)b=a;if(b)a=b.format(this.get("format"));return a},objectForFieldValue:function(a){if(a)a=(a=Date.parseDate(a))?a.getTime():null;return a}});sc_require("validators/validator");
SC.Validator.Email=SC.Validator.extend({validate:function(a,b){return(b.get("fieldValue")||"").match(/.+@.+\...+/)},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Email(%@)".loc(a),a)}});SC.Validator.EmailOrEmpty=SC.Validator.Email.extend({validate:function(a,b){return(a=b.get("fieldValue"))&&a.length>0?a.match(/.+@.+\...+/):true}});sc_require("validators/validator");
SC.Validator.NotEmpty=SC.Validator.extend({validate:function(a,b){a=b.get("fieldValue");if((b=!!a)&&a.length)b=a.length>0;return b},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.NotEmpty(%@)".loc(a.capitalize()),b.get("errorLabel"))}});sc_require("validators/validator");
SC.Validator.Number=SC.Validator.extend({places:0,fieldValueForObject:function(a){switch(SC.typeOf(a)){case SC.T_NUMBER:a=a.toFixed(this.get("places"));break;case SC.T_NULL:case SC.T_UNDEFINED:a="";break}return a},objectForFieldValue:function(a){a=a.replace(/,/g,"");switch(SC.typeOf(a)){case SC.T_STRING:a=a.length===0?null:this.get("places")>0?parseFloat(a):a.length==1&&a.match(/-/)?null:parseInt(a,0);break;case SC.T_NULL:case SC.T_UNDEFINED:a=null;break}return a},validate:function(a,b){a=b.get("fieldValue");
return a===""||!(isNaN(a)||isNaN(parseFloat(a)))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Number(%@)".loc(a),a)},validateKeyDown:function(a,b,c){return this.get("places")===0?c.match(/^[\-+]?[0-9,\0]*/)[0]===c||c.length===0:c.match(/^[\-+]?[0-9,\0]*\.?[0-9\0]+/)===c||c.length===0}});sc_require("validators/validator");
SC.Validator.Password=SC.Validator.extend({attachTo:function(a,b){arguments.callee.base.apply(this,arguments);if(!this.fields)this.fields=[];this.fields.push(b)},validate:function(a){if(!this.fields||this.fields.length===0)return true;var b=false,c=false,d=true,e=this.fields[0].get("fieldValue");this.fields.forEach(function(f){f=f.get("fieldValue");if(f!=e)d=false;if(!f||f.length===0)b=true;if(f&&f.length>0)c=true});return a?c===false?false:d:b===true?true:d},updateFields:function(a,b){if(!this.fields||
this.fields.length===0)return true;var c="Invalid.Password".loc(),d=this._field;this.fields.forEach(function(e){a.setErrorFor(e,b?null:e==d?c:"")});return b?SC.VALIDATE_OK:c},validateChange:function(a){return this.updateFields(a,this.validate(false))},validateSubmit:function(a){return this.updateFields(a,this.validate(true))},validatePartial:function(a){return!this._field.get("isValid")?this.updateFields(a,this.validate(false)):SC.VALIDATE_NO_CHANGE}});sc_require("views/view");
SC.ContainerView=SC.View.extend({classNames:["sc-container-view"],nowShowing:null,contentView:null,contentViewBindingDefault:SC.Binding.single(),replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("nowShowing");a&&a.length>0&&this.nowShowingDidChange()},nowShowingDidChange:function(){var a=
this.get("nowShowing"),b=null;if(SC.typeOf(a)===SC.T_STRING){if(a===SC.CONTENT_SET_DIRECTLY)return;if(a&&a.length>0)b=a.indexOf(".")>0?SC.objectForPropertyPath(a,null):SC.objectForPropertyPath(a,this.get("page"))}else b=a;if(b&&!(b instanceof SC.View))b=null;this.set("contentView",b)}.observes("nowShowing"),contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView")});sc_require("views/view");sc_require("mixins/control");SC.IMAGE_STATE_NONE="none";
SC.IMAGE_STATE_LOADING="loading";SC.IMAGE_STATE_LOADED="loaded";SC.IMAGE_STATE_FAILED="failed";SC.IMAGE_STATE_SPRITE="sprite";SC.BLANK_IMAGE_DATAURL="data:image/gif;base64,R0lGODlhAQABAJAAAP///wAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==";SC.BLANK_IMAGE_URL=SC.browser.msie&&SC.browser.msie<8?"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/blank.gif":SC.BLANK_IMAGE_DATAURL;
SC.ImageView=SC.View.extend(SC.Control,{classNames:"sc-image-view",tagName:"img",status:SC.IMAGE_STATE_NONE,value:null,useImageCache:YES,canLoadInBackground:NO,localize:YES,displayProperties:"status toolTip".w(),render:function(a){var b=this.get("status"),c=this.get("value");b===SC.IMAGE_STATE_NONE&&c&&this._image_valueDidChange();b=this.get("status");var d=b===SC.IMAGE_STATE_LOADED?c:SC.BLANK_IMAGE_URL;b===SC.IMAGE_STATE_SPRITE&&a.addClass(c);a.attr("src",d);b=this.get("toolTip");if(SC.typeOf(b)===
SC.T_STRING){if(this.get("localize"))b=b.loc();a.attr("title",b);a.attr("alt",b)}},_image_valueDidChange:function(){var a=this.get("value"),b;if(a&&a.isEnumerable)a=a.firstObject();if((b=SC.ImageView.valueIsUrl(a))&&this.get("useImageCache")){b=this.get("isVisibleInWindow")||this.get("canLoadInBackground");this._loadingUrl=a;SC.imageCache.loadImage(a,this,this.imageDidLoad,b);this._loadingUrl&&this.set("status",SC.IMAGE_STATE_LOADING)}else{this._loadingUrl=null;this.set("status",b?SC.IMAGE_STATE_LOADED:
SC.IMAGE_STATE_SPRITE);this.displayDidChange()}}.observes("value"),imageDidLoad:function(a,b){if(a===this._loadingUrl)this._loadingUrl=null;if(this.get("value")===a){this.set("status",SC.$ok(b)?SC.IMAGE_STATE_LOADED:SC.IMAGE_STATE_FAILED);this.displayDidChange()}}});SC.ImageView.valueIsUrl=function(a){return a?a.indexOf("/")>=0:NO};sc_require("views/view");sc_require("mixins/control");SC.ALIGN_LEFT="left";SC.ALIGN_RIGHT="right";SC.ALIGN_CENTER="center";SC.REGULAR_WEIGHT="normal";SC.BOLD_WEIGHT="bold";
SC.LabelView=SC.View.extend(SC.Control,{classNames:["sc-label-view"],fontWeight:SC.REGULAR_WEIGHT,escapeHTML:true,escapeHTMLBindingDefault:SC.Binding.oneWay().bool(),localize:false,localizeBindingDefault:SC.Binding.oneWay().bool(),formatter:null,value:"",hint:null,exampleInlineTextFieldView:SC.InlineTextFieldView,icon:null,textAlign:SC.ALIGN_LEFT,isInlineEditorMultiline:NO,displayValue:function(){var a=this.get("value"),b=this.getDelegateProperty("formatter",this.displayDelegate);if(b){b=SC.typeOf(b)===
SC.T_FUNCTION?b(a,this):b.fieldValueForObject(a,this);SC.none(b)||(a=b)}if(SC.typeOf(a)===SC.T_ARRAY){b=[];for(var c=0;c<a.get("length");c++){var d=a.objectAt(c);if(!SC.none(d)&&d.toString)d=d.toString();b.push(d)}a=b.join(",")}if(!SC.none(a)&&a.toString)a=a.toString();if(a&&this.getDelegateProperty("localize",this.displayDelegate))a=a.loc();if(this.get("escapeHTML"))a=SC.RenderContext.escapeHTML(a);return a}.property("value","localize","formatter","escapeHTML").cacheable(),isEditable:NO,isEditableBindingDefault:SC.Binding.bool(),
isEditing:NO,validator:null,doubleClick:function(){return this.beginEditing()},beginEditing:function(){if(this.get("isEditing"))return YES;if(!this.get("isEditable"))return NO;var a=this.$(),b=this.get("value")||"",c=SC.viewportOffset(a[0]),d=this.convertFrameFromView(this.get("frame"),null);c.width=d.width;c.height=d.height;SC.InlineTextFieldView.beginEditing({frame:c,delegate:this,exampleElement:a,value:b,multiline:this.get("isInlineEditorMultiline"),isCollection:NO,validator:this.get("validator"),
exampleInlineTextFieldView:this.get("exampleInlineTextFieldView")})},discardEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.discardEditing()},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){this._oldOpacity=this.$().css("opacity");this.$().css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},
inlineEditorDidEndEditing:function(a,b){this.setIfChanged("value",b);this.$().css("opacity",this._oldOpacity);this._oldOpacity=null;this.set("isEditing",NO)},displayProperties:"displayValue textAlign fontWeight icon".w(),_TEMPORARY_CLASS_HASH:{},render:function(a){var b=this.get("displayValue"),c=this.get("icon"),d=this.get("hint");if(c){var e=c.indexOf("/")>=0?c:SC.BLANK_IMAGE_URL;c='<img src="%@" alt="" class="icon %@" />'.fmt(e,e===c?"":c);a.push(c)}d&&(!b||b==="")?a.push('<span class="sc-hint">',
d,"</span>"):a.push(b);a.addStyle("text-align",this.get("textAlign")).addStyle("font-weight",this.get("fontWeight"));b=this._TEMPORARY_CLASS_HASH;b.icon=!!this.get("icon");a.setClass(b);this.get("isEditing")&&a.addStyle("opacity",0)}});sc_require("panes/pane");
SC.MainPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments),b=this.rootResponder;b.makeMainPane(this);b.get("keyRootView")||b.makeKeyPane(this);return a},acceptsKeyPane:YES,classNames:["sc-main"]});tiki.script("sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js");
tiki.register("sproutcore/desktop",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js",id:"sproutcore/datastore:en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css",
id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js",id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css",id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css"}],depends:["sproutcore/runtime",
"sproutcore/datastore","sproutcore/foundation"],scripts:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js",id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js"}]});tiki.global("sproutcore/desktop");
SC.stringsFor("English",{"Invalid.CreditCard(%@)":"%@ is not a valid credit card number","Invalid.Email(%@)":"%@ is not a valid email address","Invalid.NotEmpty(%@)":"%@ must not be empty","Invalid.Password":"Your passwords do not match.  Please try typing them again.","Invalid.General(%@)":"%@ is invalid.  Please try again.","Invalid.Number(%@)":"%@ is not a number."});SC.allowsBackspaceToPreviousPage=NO;SC.BORDER_BEZEL="sc-bezel-border";SC.BORDER_BLACK="sc-black-border";SC.BORDER_GRAY="sc-gray-border";
SC.BORDER_TOP="sc-top-border";SC.BORDER_BOTTOM="sc-bottom-border";SC.BORDER_NONE=null;SC.Border={borderStyle:SC.BORDER_GRAY,_BORDER_REGEXP:/-border$/,renderMixin:function(a){var b=this.get("borderStyle");if(b)this._BORDER_REGEXP.exec(b)?a.addClass(b):a.addStyle("border","1px %@ solid".fmt(b))}};SC.CollectionGroup={classNames:["sc-collection-group"]};SC.CollectionRowDelegate={isCollectionRowDelegate:YES,rowHeight:18,customRowHeightIndexes:null,contentIndexRowHeight:function(){return this.get("rowHeight")}};
SC.CollectionViewDelegate={isCollectionViewDelegate:YES,collectionViewSelectionForProposedSelection:function(a,b){return b},collectionViewShouldSelectIndexes:function(a,b){return b},collectionViewShouldDeselectIndexes:function(a,b){return b},collectionViewShouldDeleteIndexes:function(a,b){return b},collectionViewDeleteContent:function(a,b,c){if(!b)return NO;if(SC.typeOf(b.destroyAt)===SC.T_FUNCTION){b.destroyAt(c);a.selectPreviousItem(NO,1);return YES}else if(SC.typeOf(b.removeAt)===SC.T_FUNCTION){b.removeAt(c);
a.selectPreviousItem(NO,1);return YES}else return NO},collectionViewShouldBeginDrag:function(){return YES},collectionViewDragDataTypes:function(){return[]},collectionViewDragDataForType:function(){return null},collectionViewComputeDragOperations:function(a,b,c){return c},collectionViewValidateDragOperation:function(a,b,c,d,e){return e&SC.DROP_ON?SC.DRAG_NONE:c},collectionViewPerformDragOperation:function(){return SC.DRAG_NONE},collectionViewDragViewFor:function(){return null},ghostActsLikeCursor:NO};
SC.Scrollable={isScrollable:true,verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("innerFrame").height}.property("innerFrame"),horizontalPageScroll:function(){return this.get("innerFrame").width}.property("innerFrame"),hasVerticalScroller:function(){return this.get("scrollFrame").height>this.get("innerFrame").height}.property("scrollFrame"),hasHorizontalScroller:function(){return this.get("scrollFrame").width>this.get("innerFrame").width}.property("scrollFrame"),
scrollBy:function(a){var b=this.get("scrollFrame"),c=this.get("innerFrame");if(!this.get("hasVerticalScroller"))a.y=0;if(b.height<=c.height)a.y=0;if(!this.get("hasHorizontalScroller"))a.x=0;if(b.width<=c.width)a.x=0;a={x:b.x-(a.x||0),y:b.y-(a.y||0)};this.set("scrollFrame",a);a=this.get("scrollFrame");return{x:a.x-b.x,y:a.y-b.y}},scrollTo:function(a,b){this.set("scrollFrame",{x:0-a,y:0-b})},scrollToVisible:function(a){var b=this.get("innerFrame"),c=this.get("scrollFrame");a=this.convertFrameFromView(a.get("frame"),
a);a.x-=b.x+c.x;a.y-=b.y+c.y;b={x:0-c.x,y:0-c.y,width:b.width,height:b.height};b.y-=Math.max(0,SC.minY(b)-SC.minY(a));b.x-=Math.max(0,SC.minX(b)-SC.minX(a));b.y+=Math.max(0,SC.maxY(a)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(a)-SC.maxX(b));this.scrollTo(b.x,b.y)},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalLineScroll")*a}).y},scrollUpLine:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalLineScroll")*a}).y},scrollRightLine:function(a){if(a===
undefined)a=1;return this.scrollTo({y:this.get("horizontalLineScroll")*a}).x},scrollLeftLine:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalLineScroll")*a}).x},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalPageScroll")*a}).y},scrollUpPage:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalPageScroll")*a}).y},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollTo({y:this.get("horizontalPageScroll")*
a}).x},scrollLeftPage:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalPageScroll")*a}).x}};
SC.ModalPane=SC.Pane.extend({classNames:"sc-modal",layout:{top:0,left:0,bottom:0,right:0},_openPaneCount:0,paneWillAppend:function(){this._openPaneCount++;this.get("isVisibleInWindow")||this.append();return this},paneDidRemove:function(){this._openPaneCount--;if(this._openPaneCount<=0){this._openPaneCount=0;this.get("isVisibleInWindow")&&this.remove()}},mouseDown:function(a){var b=this.get("owner");b&&b.modalPaneDidClick&&b.modalPaneDidClick(a)}});sc_require("panes/modal");
SC.PanelPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},classNames:["sc-panel"],acceptsKeyPane:YES,isModal:YES,modalPane:SC.ModalPane.extend({classNames:"for-sc-panel"}),contentView:null,contentViewBindingDefault:SC.Binding.single(),render:function(a,b){if(a.needsContent){this.renderChildViews(a,b);a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>","<div class='right-edge'></div>","<div class='bottom-right-edge'></div>","<div class='bottom-edge'></div>",
"<div class='bottom-left-edge'></div>","<div class='left-edge'></div>")}},replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.contentView;if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView"),_modalPane:function(){var a=this.get("modalPane");if(a&&a.isClass){a=a.create({owner:this});this.set("modalPane",a)}return a},appendTo:function(){var a;
if(!this.get("isVisibleInWindow")&&this.get("isModal")&&(a=this._modalPane())){this._isShowingModal=YES;a.paneWillAppend(this)}return arguments.callee.base.apply(this,arguments)},remove:function(){var a,b=arguments.callee.base.apply(this,arguments);if(this._isShowingModal){this._isShowingModal=NO;if(a=this._modalPane())a.paneDidRemove(this)}return b},_isModalDidChange:function(){var a;if(this.get("isModal")){if(!this._isShowingModal&&this.get("isVisibleInWindow")&&(a=this._modalPane())){this._isShowingModal=
YES;a.paneWillAppend(this)}}else if(this._isShowingModal&&(a=this._modalPane())){this._isShowingModal=NO;a.paneDidRemove(this)}}.observes("isModal"),paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments);this.becomeKeyPane();return a}});SC.TOGGLE_BEHAVIOR="toggle";SC.PUSH_BEHAVIOR="push";SC.TOGGLE_ON_BEHAVIOR="on";SC.TOGGLE_OFF_BEHAVIOR="off";SC.HOLD_BEHAVIOR="hold";
SC.ButtonView=SC.View.extend(SC.Control,SC.Button,SC.StaticLayout,{tagName:"a",classNames:["sc-button-view"],theme:"square",buttonBehavior:SC.PUSH_BEHAVIOR,holdInterval:100,isDefault:NO,isDefaultBindingDefault:SC.Binding.oneWay().bool(),isCancel:NO,isCancelBindingDefault:SC.Binding.oneWay().bool(),href:"",action:null,target:null,triggerAction:function(a){if(!this.get("isEnabled"))return NO;this.set("isActive",YES);this._action(a,YES);this.didTriggerAction();this.invokeLater("set",200,"isActive",NO);
return true},didTriggerAction:function(){},titleMinWidth:80,init:function(){arguments.callee.base.apply(this,arguments);if(this.get("keyEquivalent"))this._defaultKeyEquivalent=this.get("keyEquivalent")},_TEMPORARY_CLASS_HASH:{},displayProperties:["href","icon","title","value","toolTip"],render:function(a,b){var c;if(this.get("tagName")==="a"){c=this.get("href");if(!c||c.length===0)c="javascript:;";a.attr("href",c)}c=this.get("toolTip");if(SC.typeOf(c)===SC.T_STRING){if(this.get("localize"))c=c.loc();
a.attr("title",c);a.attr("alt",c)}c=this._TEMPORARY_CLASS_HASH;c.def=this.get("isDefault");c.cancel=this.get("isCancel");c.icon=!!this.get("icon");a.attr("role","button").setClass(c).addClass(this.get("theme"));if(b){a=a.push("<span class='sc-button-inner' style = 'min-width:%@px'>".fmt(this.get("titleMinWidth")));this.renderTitle(a,b);a.push("</span>")}else this.renderTitle(a,b)},_defaultKeyEquivalent:null,_isDefaultOrCancelDidChange:function(){var a=!!this.get("isDefault"),b=!a&&this.get("isCancel");
if(this.didChangeFor("defaultCancelChanged","isDefault","isCancel")){this.displayDidChange();if(a)this.set("keyEquivalent","return");else b?this.setIfChanged("keyEquivalent","escape"):this.set("keyEquivalent",this._defaultKeyEquivalent)}}.observes("isDefault","isCancel"),isMouseDown:false,mouseDown:function(a){var b=this.get("buttonBehavior");if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;if(b===SC.HOLD_BEHAVIOR)this._action(a);else if(!this._isFocused&&b!==SC.PUSH_BEHAVIOR){this._isFocused=
YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}return YES},mouseExited:function(){this._isMouseDown&&this.set("isActive",NO);return YES},mouseEntered:function(){this.set("isActive",this._isMouseDown);return YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);this._isMouseDown=false;this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR&&this.$().within(a.target)&&this.get("isEnabled")&&this._action(a);return YES},keyDown:function(a){if(a.which===9){var b=
a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(a.which===13){this.triggerAction(a);return YES}return YES},_action:function(a,b){switch(this.get("buttonBehavior")){case SC.TOGGLE_BEHAVIOR:this.get("isSelected")?this.set("value",this.get("toggleOffValue")):this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_ON_BEHAVIOR:this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_OFF_BEHAVIOR:this.set("value",
this.get("toggleOffValue"));break;case SC.HOLD_BEHAVIOR:this._runHoldAction(a,b);break;default:this._runAction(a)}},_runAction:function(a){var b=this.get("action"),c=this.get("target")||null;if(b)this._hasLegacyActionHandler()?this._triggerLegacyActionHandler(a):this.getPath("pane.rootResponder").sendAction(b,c,this,this.get("pane"))},_runHoldAction:function(a,b){if(this.get("isActive")){this._runAction();if(!b){SC.RunLoop.begin();this.invokeLater("_runHoldAction",this.get("holdInterval"),a);SC.RunLoop.end()}}},
_hasLegacyActionHandler:function(){var a=this.get("action");if(a&&SC.typeOf(a)===SC.T_FUNCTION)return true;if(a&&SC.typeOf(a)===SC.T_STRING&&a.indexOf(".")!=-1)return true;return false},_triggerLegacyActionHandler:function(a){if(!this._hasLegacyActionHandler())return false;var b=this.get("action");SC.typeOf(b)===SC.T_FUNCTION&&this.action(a);if(SC.typeOf(b)===SC.T_STRING){eval("this.action = function(e) { return "+b+"(this, e); };");this.action(a)}},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?
NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO}});sc_require("panes/panel");sc_require("views/button");SC.BUTTON1_STATUS="button1";SC.BUTTON2_STATUS="button2";SC.BUTTON3_STATUS="button3";
SC.AlertPane=SC.PanelPane.extend({classNames:"sc-alert",delegate:null,icon:"sc-icon-alert-48",message:"",description:"",displayDescription:function(){var a=this.get("description");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="description">'+a.split("\n").join('</p><p class="description">')+"</p>"}.property("description").cacheable(),caption:"",displayCaption:function(){var a=this.get("caption");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="caption">'+
a.split("\n").join('</p><p class="caption">')+"</p>"}.property("caption").cacheable(),buttonOne:SC.outlet("contentView.childViews.1.childViews.1"),buttonTwo:SC.outlet("contentView.childViews.1.childViews.0"),buttonThree:SC.outlet("contentView.childViews.2.childViews.0"),buttonThreeWrapper:SC.outlet("contentView.childViews.2"),layout:{centerX:0,width:500,top:55},contentView:SC.View.extend({useStaticLayout:YES,layout:{left:0,right:0,top:0,height:"auto"},childViews:[SC.View.extend(SC.StaticLayout,{classNames:["info"],
render:function(a){var b=this.get("pane"),c=SC.BLANK_IMAGE_URL;b.get("icon")=="blank"&&a.addClass("plain");a.push('<img src="%@" class="icon %@" />'.fmt(c,b.get("icon")));a.begin("h1").text(b.get("message")||"").end();a.push(b.get("displayDescription")||"");a.push(b.get("displayCaption")||"");a.push('<div class="separator"></div>')}}),SC.View.extend({layout:{bottom:13,height:24,right:18,width:466},childViews:["cancelButton","okButton"],classNames:["text-align-right"],cancelButton:SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON2_STATUS,localize:YES,titleMinWidth:64,layout:{right:5,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Cancel",action:"dismiss",isVisible:NO}),okButton:SC.ButtonView.extend({useStaticLayout:YES,actionKey:SC.BUTTON1_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"OK",isDefault:YES,action:"dismiss"})}),SC.View.extend({layout:{bottom:13,height:24,left:18,width:150},isVisible:NO,childViews:[SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON3_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Extra",action:"dismiss",isVisible:NO})]})]}),dismiss:function(a){var b=this.delegate;b&&b.alertPaneDidDismiss&&b.alertPaneDidDismiss(this,a.get("actionKey"));this.remove()},alertInfoDidChange:function(){var a=this.getPath("contentView.childViews.0");a&&a.displayDidChange()}.observes("icon","message","displayDescription","displayCaption")});
SC.AlertPane._normalizeArguments=function(a){a=SC.A(a);var b=a.length,c=a[b-1];if(SC.typeOf(c)!==SC.T_STRING)a[b-1]=null;else c=null;a[7]=c;return a};
SC.AlertPane.show=function(){for(var a=this._normalizeArguments(arguments),b=this.create({message:a[0]||"",description:a[1]||null,caption:a[2]||null,icon:a[6]||"sc-icon-alert-48",delegate:a[7]}),c="buttonOne buttonTwo buttonThree".w(),d,e,f=0;f<3;f++){d=b.get(c[f]);if(e=a[f+3]){d.set("title",e).set("isVisible",YES);e=="?"&&d.set("titleMinWidth",0);f==2&&b.get("buttonThreeWrapper").set("isVisible",YES)}}a=b.append();b.adjust("height",b.childViews[0].$().height());b.updateLayout();return a};
SC.AlertPane.warn=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-alert-48";return this.show.apply(this,a)};SC.AlertPane.info=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-info-48";return this.show.apply(this,a)};SC.AlertPane.error=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-error-48";return this.show.apply(this,a)};SC.AlertPane.plain=function(){var a=this._normalizeArguments(arguments);a[6]="blank";return this.show.apply(this,a)};sc_require("panes/panel");
SC.PalettePane=SC.PanelPane.extend({classNames:"sc-palette",isModal:NO,modalPane:SC.ModalPane,isAnchored:NO,_mouseOffsetX:null,_mouseOffsetY:null,mouseDown:function(a){var b=this.get("frame");this._mouseOffsetX=b?b.x-a.pageX:0;this._mouseOffsetY=b?b.y-a.pageY:0;return YES},mouseDragged:function(a){if(!this.isAnchored){this.set("layout",{width:this.layout.width,height:this.layout.height,left:this._mouseOffsetX+a.pageX,top:this._mouseOffsetY+a.pageY});this.updateLayout()}return YES}});sc_require("panes/palette");
SC.PICKER_MENU="menu";SC.PICKER_FIXED="fixed";SC.PICKER_POINTER="pointer";SC.POINTER_LAYOUT=["perfectRight","perfectLeft","perfectTop","perfectBottom"];
SC.PickerPane=SC.PalettePane.extend({classNames:"sc-picker",isAnchored:YES,isModal:YES,pointerPos:"perfectRight",pointerPosX:0,pointerPosY:0,anchorElement:null,preferType:null,preferMatrix:null,popup:function(a,b,c){a=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.set("anchorElement",a);b&&this.set("preferType",b);c&&this.set("preferMatrix",c);this.endPropertyChanges();this.positionPane();this.append()},positionPane:function(){var a=this.get("anchorElement"),b=this.get("preferType"),c=
this.get("preferMatrix"),d=this.get("layout");if(a){a=this.computeAnchorRect(a);d=SC.cloneRect(a);if(b)switch(b){case SC.PICKER_MENU:case SC.PICKER_FIXED:if(!c||c.length!==3)this.set("preferMatrix",[1,4,3]);d.x+=(this.preferMatrix[2]===0?d.width:0)+this.preferMatrix[0];d.y+=(this.preferMatrix[2]===3?d.height:0)+this.preferMatrix[1];break;default:d.y+=d.height;break}else d.y+=d.height;d=this.fitPositionToScreen(d,this.get("frame"),a);d={width:d.width,height:d.height,left:d.x,top:d.y}}else d={width:d.width,
height:d.height,centerX:0,centerY:0};this.set("layout",d).updateLayout();return this},computeAnchorRect:function(a){var b=SC.viewportOffset(a);a=SC.$(a);b.width=a.outerWidth();b.height=a.outerHeight();return b},fitPositionToScreen:function(a,b,c){var d=this.get("currentWindowSize")||SC.RootResponder.responder.computeWindowSize();d={x:0,y:0,width:d.width,height:d.height};b.x=a.x;b.y=a.y;if(this.preferType)switch(this.preferType){case SC.PICKER_MENU:b=this.fitPositionToScreenDefault(d,b,c);b=this.fitPositionToScreenMenu(d,
b);break;case SC.PICKER_POINTER:b=this.fitPositionToScreenPointer(d,b,c);break;case SC.PICKER_FIXED:break;default:break}else b=this.fitPositionToScreenDefault(d,b,c);this.displayDidChange();return b},fitPositionToScreenDefault:function(a,b,c){if(SC.maxX(b)>a.width){var d=Math.max(SC.maxX(c),b.width);b.x=Math.min(d,a.width)-b.width}if(SC.minX(b)<0){b.x=SC.minX(Math.max(c,0));if(SC.maxX(b)>a.width)b.x=Math.max(0,a.width-b.width)}if(SC.maxY(b)>a.height){d=Math.max(c.y-b.height,0);b.y=d>a.height?Math.max(0,
a.height-b.height):d}if(SC.minY(b)<0){d=Math.min(SC.maxY(c),a.height-c.height);b.y=Math.max(d,0)}return b},fitPositionToScreenMenu:function(a,b){if(b.x+b.width>a.width-9)b.x=a.width-b.width-9;if(b.x<7)b.x=7;if(b.height>a.height){b.y=15;b.height=a.height-35}return b},fitPositionToScreenPointer:function(a,b,c){var d=c.height>12?0:1,e=c.height>12?0:3,f=[[c.x+c.width+(7+d),c.y+parseInt(c.height/2,0)-40],[c.x-b.width-(7+d),c.y+parseInt(c.height/2,0)-40],[c.x+parseInt(c.width/2-b.width/2,0),c.y-b.height-
(17+e)],[c.x+parseInt(c.width/2-b.width/2,0),c.y+c.height+(17+e)]];d=[[c.x+c.width+b.width+(7+d),c.y+parseInt(c.height/2,0)+b.height-24],[c.x-(7+d),c.y+parseInt(c.height/2,0)+b.height-24],[c.x+parseInt(c.width/2-b.width/2,0)+b.width,c.y-(17+e)],[c.x+parseInt(c.width/2-b.width/2,0)+b.width,c.y+c.height+b.height+(17+e)]];a=[[f[0][1]>0?0:0-f[0][1],d[0][0]<a.width?0:d[0][0]-a.width,d[0][1]<a.height?0:d[0][1]-a.height,f[0][0]>0?0:0-f[0][0]],[f[1][1]>0?0:0-f[1][1],d[1][0]<a.width?0:d[1][0]-a.width,d[1][1]<
a.height?0:d[1][1]-a.height,f[1][0]>0?0:0-f[1][0]],[f[2][1]>0?0:0-f[2][1],d[2][0]<a.width?0:d[2][0]-a.width,d[2][1]<a.height?0:d[2][1]-a.height,f[2][0]>0?0:0-f[2][0]],[f[3][1]>0?0:0-f[3][1],d[3][0]<a.width?0:d[3][0]-a.width,d[3][1]<a.height?0:d[3][1]-a.height,f[3][0]>0?0:0-f[3][0]]];if(!this.preferMatrix||this.preferMatrix.length!==5)this.set("preferMatrix",[0,1,2,3,2]);d=this.preferMatrix;if(d[4]===-1){b.x=c.x+parseInt(c.width/2,0);b.y=c.y+parseInt(c.height/2,0)-parseInt(b.height/2,0);this.set("pointerPos",
SC.POINTER_LAYOUT[0]+" fallback");this.set("pointerPosY",parseInt(b.height/2,0)-40)}else{b.x=f[d[4]][0];b.y=f[d[4]][1];this.set("pointerPos",SC.POINTER_LAYOUT[d[4]]);this.set("pointerPosY",0)}this.set("pointerPosX",0);c=0;for(var g=SC.POINTER_LAYOUT.length;c<g;c++){e=d[c];if(a[e][0]===0&&a[e][1]===0&&a[e][2]===0&&a[e][3]===0){if(d[4]!==e){b.x=f[e][0];b.y=f[e][1];this.set("pointerPosY",0);this.set("pointerPos",SC.POINTER_LAYOUT[e])}c=SC.POINTER_LAYOUT.length}else if((e===0||e===1)&&a[e][0]===0&&a[e][1]===
0&&a[e][2]<b.height-91&&a[e][3]===0){if(d[4]!==e){b.x=f[e][0];this.set("pointerPos",SC.POINTER_LAYOUT[e])}b.y=f[e][1]-a[e][2];this.set("pointerPosY",a[e][2]);c=SC.POINTER_LAYOUT.length}else if((e===0||e===1)&&a[e][0]===0&&a[e][1]===0&&a[e][2]<=b.height-57&&a[e][3]===0){if(d[4]!==e)b.x=f[e][0];b.y=f[e][1]-(b.height-57);this.set("pointerPosY",b.height-59);this.set("pointerPos",SC.POINTER_LAYOUT[e]+" extra-low");c=SC.POINTER_LAYOUT.length}}return b},displayProperties:["pointerPosY"],render:function(a){var b=
arguments.callee.base.apply(this,arguments);if(a.needsContent)this.get("preferType")==SC.PICKER_POINTER&&a.push('<div class="sc-pointer %@" style="margin-top: %@px"></div>'.fmt(this.get("pointerPos"),this.get("pointerPosY")));else{var c=this.$(".sc-pointer");c.attr("class","sc-pointer %@".fmt(this.get("pointerPos")));c.attr("style","margin-top: %@px".fmt(this.get("pointerPosY")))}return b},modalPaneDidClick:function(a){this.clickInside(this.get("frame"),a)||this.remove();return YES},mouseDown:function(a){return this.modalPaneDidClick(a)},
clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},a)},windowSizeDidChange:function(){arguments.callee.base.apply(this,arguments);this.positionPane()}});SC.SeparatorView=SC.View.extend({classNames:["sc-separator-view"],tagName:"span",layoutDirection:SC.LAYOUT_HORIZONTAL,render:function(a,b){b&&a.push("<span></span>");a.addClass(this.get("layoutDirection"))}});sc_require("views/button");sc_require("views/separator");SC.BENCHMARK_MENU_ITEM_RENDER=YES;
SC.MenuItemView=SC.ButtonView.extend(SC.ContentDisplay,{classNames:["sc-menu-item"],tagName:"div",parentPane:null,acceptsFirstResponder:YES,content:null,isSubMenuViewVisible:null,isSeparator:NO,contentValueKey:null,contentIsBranchKey:null,shortCutKey:null,contentIconKey:null,contentCheckboxKey:"checkbox",contentActionKey:null,itemWidth:100,itemHeight:20,subMenu:null,hasMouseExited:NO,anchor:null,displayProperties:["contentValueKey","contentIconKey","shortCutKey","contentIsBranchKey","itemHeight",
"subMenu","isEnabled","content"],contentDisplayProperties:"title value icon separator action checkbox shortcut branchItem subMenu".w(),render:function(a){var b;if(SC.BENCHMARK_MENU_ITEM_RENDER){b="%@.render".fmt(this);SC.Benchmark.start(b)}var c=this.get("content"),d=this.displayDelegate,e,f;f=this.parentMenu();f=this.get("itemWidth")||f.layout.width;e=this.get("itemHeight")||20;this.set("itemWidth",f);this.set("itemHeight",e);this.get("isEnabled")||a.addClass("disabled");f=a.begin("a").attr("href",
"javascript: ;");if(e=(e=this.getDelegateProperty("isSeparatorKey",d))&&c?c.get?c.get(e):c[e]:null){f.push("<span class='separator'></span>");a.addClass("disabled")}else{if(e=this.getDelegateProperty("contentCheckboxKey",d))(e=c?c.get?c.get(e):c[e]:NO)&&f.begin("div").addClass("checkbox").end();if((e=(e=this.getDelegateProperty("contentIconKey",d))&&c?c.get?c.get(e):c[e]:null)&&SC.typeOf(e)!==SC.T_STRING)e=e.toString();if(e){this.renderImage(f,e);f.addClass("hasIcon")}if((e=(e=this.getDelegateProperty("contentValueKey",
d))&&c?c.get?c.get(e):c[e]:c)&&SC.typeOf(e)!==SC.T_STRING)e=e.toString();this.renderLabel(f,e||"");if(e=(e=this.getDelegateProperty("contentIsBranchKey",d))&&c?c.get?c.get(e):c[e]:NO){this.renderBranch(f,e);f.addClass("has-branch")}else{(e=(e=this.getDelegateProperty("action",d))&&c?c.get?c.get(e):c[e]:null)&&isNaN(e)&&this.set("action",e);(e=(e=this.getDelegateProperty("target",d))&&c?c.get?c.get(e):c[e]:null)&&isNaN(e)&&this.set("target",e);if(this.getDelegateProperty("shortCutKey",d))if(e=(e=this.getDelegateProperty("shortCutKey",
d))&&c?c.get?c.get(e):c[e]:null){this.renderShortcut(f,e);f.addClass("shortcutkey")}}}f.end();SC.BENCHMARK_MENU_ITEM_RENDER&&SC.Benchmark.end(b)},renderImage:function(a,b){var c;if(b&&SC.ImageView.valueIsUrl(b)){b=b;c=""}else{c=b;b=SC.BLANK_IMAGE_URL}a.begin("img").addClass("image").addClass(c).attr("src",b).end()},renderLabel:function(a,b){a.push("<span class='value ellipsis'>"+b+"</span>")},renderBranch:function(a){a.push('<span class= "hasBranch">></span>')},renderShortcut:function(a,b){a.push('<span class = "shortcut">'+
b+"</span>")},getAnchor:function(){var a=this.get("anchor");if(a&&a.kindOf&&a.kindOf(SC.MenuItemView))return a;return null},isCurrent:NO,isSeparator:function(){var a=this.get("content"),b=this.getDelegateProperty("isSeparatorKey",this.displayDelegate);if(b&&a?a.get?a.get(b):a[b]:null)return YES;return NO},isSubMenuAMenuPane:function(){var a=this.get("content").get("subMenu");if(a&&a.kindOf(SC.MenuPane))return a;return NO},branching:function(){this.get("hasMouseExited")?this.set("hasMouseExited",NO):
this.createSubMenu()},loseFocus:function(){if(!this.isSubMenuAMenuPane()){this.set("hasMouseExited",YES);this.$().removeClass("focus")}},createSubMenu:function(){var a=this.isSubMenuAMenuPane();if(a){a.set("anchor",this);a.popup(this,[0,0,0]);var b=SC.RenderContext(this);b=b.begin(a.get("tagName"));a.prepareContext(b,YES);b.end();(b=a.get("menuItemViews"))&&b.length>0&&a.becomeKeyPane()}},parentMenu:function(){return this.get("parentPane")},isAnchorMouseDown:NO,mouseUp:function(a){var b=this.parentMenu();
if(b)if((b=b.get("currentSelectedMenuItem"))&&this!==b)return b.tryToPerform("mouseUp",a);if(!this.get("isEnabled")){this.set("hasMouseExited",NO);return YES}this.set("hasMouseExited",NO);b=this.get("contentCheckboxKey");var c=this.get("content");if(b){if(c&&c.get(b))c.set(b,NO);else c.get(b)!==undefined&&c.set(b,YES);this.displayDidChange()}this._action(a);(b=this.getAnchor())?b.mouseUp(a):this.resignFirstResponder();this.closeParent();return YES},mouseDown:function(){return YES},mouseEntered:function(){var a=
this.parentMenu();this.set("hasMouseExited",NO);if(a){a.becomeKeyPane();if(a.get("anchor")._isMouseDown){this.set("isAnchorMouseDown",a.getPath("anchor._isMouseDown"));this.get("isAnchorMouseDown")&&SC.Event.trigger(this.get("layer"),"mousedown")}}if(!this.get("isEnabled")&&!this.isSeparator()){a&&a.set("currentSelectedMenuItem",null);return YES}if(a=this.get("contentIsBranchKey")){var b=this.get("content");(a&&b?b.get?b.get(a):b[a]:NO)&&this.invokeLater(this.branching(),100)}this.becomeFirstResponder();
return YES},mouseExited:function(){this.loseFocus();var a=this.parentMenu();a&&a.set("previousSelectedMenuItem",this);return YES},moveUp:function(){var a=this.parentMenu();a&&a.moveUp(this);return YES},moveDown:function(){var a=this.parentMenu();a&&a.moveDown(this);return YES},moveRight:function(){this.createSubMenu();return YES},keyDown:function(a){return this.interpretKeyEvents(a)},keyUp:function(){return YES},cancel:function(){this.loseFocus();var a=this.parentMenu();a&&a.remove();(a=a.getPath("anchor.pane"))&&
a.becomeKeyPane();return YES},didBecomeFirstResponder:function(a){if(a===this){this.isSeparator()||this.$().addClass("focus");(a=this.parentMenu())&&a.set("currentSelectedMenuItem",this)}},willLoseFirstResponder:function(a){if(a===this){this.$().removeClass("focus");if(a=this.parentMenu()){a.set("currentSelectedMenuItem",null);a.set("previousSelectedMenuItem",this)}}},insertNewline:function(a,b){this.mouseUp(b)},closeParent:function(){this.$().removeClass("focus");var a=this.parentMenu();a&&a.remove()},
clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},a)}});sc_require("panes/picker");sc_require("views/menu_item");SC.BENCHMARK_MENU_PANE_RENDER=YES;
SC.MenuPane=SC.PickerPane.extend({menuItemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemSeparatorKey itemActionKey itemCheckboxKey itemShortCutKey itemBranchKey itemHeightKey subMenuKey itemKeyEquivalentKey itemTargetKey".w(),classNames:["sc-menu"],tagName:"div",isModal:YES,itemIsEnabledKey:"isEnabled",itemTitleKey:"title",items:[],itemValueKey:"value",itemIconKey:"icon",itemWidth:null,itemHeight:20,menuHeight:null,itemHeightKey:"height",subMenuKey:"subMenu",localize:YES,itemSeparatorKey:"separator",
itemActionKey:"action",itemCheckboxKey:"checkbox",itemBranchKey:"branchItem",itemShortCutKey:"shortcut",itemKeyEquivalentKey:"keyEquivalent",itemTargetKey:"target",preferType:SC.PICKER_MENU,currentSelectedMenuItem:null,previousSelectedMenuItem:null,anchor:null,displayItemsArray:null,menuItemViews:[],exampleView:SC.MenuItemView,controlSize:SC.REGULAR_CONTROL_SIZE,menuHeightPadding:0,createChildViews:function(){var a,b;a=SC.MenuScrollView;b=this.get("menuItemViews");b=SC.View.design({layout:{top:0,
left:0,minHeight:this.get("menuHeight")},classNames:"menuContainer",childViews:b});this.set("itemWidth",this.get("layout").width||100);a=this.createChildView(a,{borderStyle:SC.BORDER_NONE,contentView:b});this.childViews=[a]},popup:function(a,b){var c=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.get("displayItems");this.set("anchorElement",c);this.set("anchor",a);this.set("preferType",SC.PICKER_MENU);b&&this.set("preferMatrix",b);this.endPropertyChanges();this.positionPane();this.append()},
displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=null,d,e=[],f,g=a.get("length"),h,i,j=SC._menu_fetchKeys,k=SC._menu_fetchItem,l=this.get("menuHeightPadding");for(h=0;h<g;++h){i=a.objectAt(h);if(!SC.none(i)){d=SC.typeOf(i);f=e.length;if(d===SC.T_STRING){e[f]=SC.Object.create({title:i.humanize().titleize(),value:i,isEnabled:YES,icon:null,isSeparator:null,action:null,isCheckbox:NO,menuItemNumber:h,isShortCut:NO,isBranch:NO,itemHeight:this.get("itemHeight"),subMenu:null,keyEquivalent:null,
target:null});l+=this.get("itemHeight")}else if(d!==SC.T_ARRAY){if(c===null)c=this.menuItemKeys.map(j,this);d=c.map(k,i);d[d.length]=h;if(!c[0]&&i.toString)d[0]=i.toString();c[1]||(d[1]=i);c[2]||(d[2]=YES);d[9]||(d[9]=this.get("itemHeight"));if(d[4])d[9]=9;l+=d[9];if(b&&d[0])d[0]=d[0].loc();e[f]=SC.Object.create({title:d[0],value:d[1],isEnabled:d[2],icon:d[3],isSeparator:d[4]||NO,action:d[5],isCheckbox:d[6],isShortCut:d[7],menuItemNumber:h,isBranch:d[8],itemHeight:d[9],subMenu:d[10],keyEquivalent:d[11],
target:d[12]})}}}this.set("menuHeight",l);this.set("displayItemsArray",e);this.generateMenuItems(e);return e}.property("items").cacheable(),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},displayProperties:["displayItems","value",
"controlSize"],render:function(a,b){if(SC.BENCHMARK_MENU_PANE_RENDER){var c="%@.render".fmt(this);SC.Benchmark.start(c)}arguments.callee.base.apply(this,arguments);if(b){if(!this.get("isEnabled"))return;a.addStyle("text-align","center")}SC.BENCHMARK_MENU_PANE_RENDER&&SC.Benchmark.end(c)},menuHeightObserver:function(){var a=this.layout.height,b=this.get("menuHeight");a!==b&&this.adjust("height",b).updateLayout()}.observes("menuHeight"),generateMenuItems:function(a){if(this.get("isEnabled")){var b,
c,d,e,f,g,h=[],i,j;i=a.length;SC.makeArray(a);for(j=0;j<i;++j){b=a[j];c=b.get("action");d=b.get("menuItemNumber");f=b.get("itemHeight");g=this.get("itemWidth");e=this.createChildView(this.exampleView,{owner:e,displayDelegate:e,parentPane:this,anchor:this.get("anchor"),isVisible:YES,contentValueKey:"title",contentIconKey:"icon",contentCheckboxKey:this.itemCheckboxKey,contentIsBranchKey:"branchItem",isSeparatorKey:"separator",shortCutKey:"shortCut",action:c,target:b.get("target"),layout:{top:0,left:0,
width:g,height:f},isEnabled:b.get("isEnabled"),itemHeight:f,itemWidth:g,keyEquivalent:b.get("keyEquivalent"),controlSize:this.get("controlSize"),content:SC.Object.create({title:b.get("title"),value:b.get("value"),icon:b.get("icon"),separator:b.get("isSeparator"),action:c,checkbox:b.get("isCheckbox"),shortCut:b.get("isShortCut"),branchItem:b.get("isBranch"),subMenu:b.get("subMenu")}),rootElementPath:[d]});h.push(e)}a=this.childViews[0].contentView;a.replaceAllChildren(h);a.adjust("minHeight",this.get("menuHeight"));
this.set("menuItemViews",h)}},previousSelectedMenuItemObserver:function(){var a=this.get("previousSelectedMenuItem");if(a)(a=a.isSubMenuAMenuPane())&&a.remove()}.observes("previousSelectedMenuItem"),isAnchorMenuItemType:function(){var a=this.get("anchor");return a&&a.kindOf&&a.kindOf(SC.MenuItemView)},performKeyEquivalent:function(a){var b,c,d,e,f,g,h;if(!this.get("isEnabled"))return NO;this.displayItems();SC.RunLoop.begin().end();b=this.get("displayItemsArray");if(!b)return NO;if(a==="escape"){this.remove();
(c=this.getPath("anchor.pane"))&&c.becomeKeyPane()}c=b.length;for(h=0;h<c;++h){d=b[h];e=d.get("keyEquivalent");f=d.get("action");g=d.get("isEnabled");d=d.get("target")||this;if(e==a&&g){a=SC.RootResponder.responder.sendAction(f,d);this.remove();return a}}return NO},mouseDown:function(){return YES},mouseUp:function(a){this.remove();var b=this.get("anchor");this.isAnchorMenuItemType()&&this.sendEvent("mouseUp",a,b);return YES},moveDown:function(a){var b=this.getNextEnabledMenuItem(a);a&&a.resignFirstResponder();
b.becomeFirstResponder()},moveUp:function(a){var b=this.getPreviousEnabledMenuItem(a);a&&a.resignFirstResponder();b.becomeFirstResponder();return YES},getPreviousEnabledMenuItem:function(a){var b,c,d,e,f,g,h=this.get("menuItemViews");if(h){c=h.length;e=d=h.indexOf(a)===-1?c:h.indexOf(a);for(g=f=NO;(!f||g)&&--d!==e;){if(d===-1)d=c-1;b=h[d];f=b.get("isEnabled");if(a=b.get("content"))g=a.get(b.get("isSeparatorKey"))}return h[d]}},getNextEnabledMenuItem:function(a){var b,c=this.get("menuItemViews");if(c){for(var d=
c.length,e=c.indexOf(a)===-1?0:c.indexOf(a),f=e,g=NO,h=NO;(!g||h)&&++e!==f;){if(e===d)e=0;b=c[e];g=b.get("isEnabled");if(a=b.get("content"))h=a.get(b.get("isSeparatorKey"))}return c[e]}},modalPaneDidClick:function(a){var b,c=this.get("frame");if(b=this.get("currentSelectedMenuItem"))if(b=b.getAnchor()){b=b.parentMenu();b.kindOf(SC.MenuPane)&&b.modalPaneDidClick(a)}this.clickInside(c,a)||this.remove();return YES},getMenuItem:function(a,b){var c,d;c=this.get("displayItemsArray");d=this.get("menuItemViews");
if(c&&d){a=c.get(a).indexOf(b);return a!==-1?d[a]:null}else return null}});SC._menu_fetchKeys=function(a){return this.get(a)};SC._menu_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};sc_require("views/button");
SC.SelectButtonView=SC.ButtonView.extend({objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,iconKey:null,localize:YES,disableSort:YES,classNames:["select-button"],itemList:[],currentSelItem:null,itemIdx:null,value:null,checkboxEnabled:YES,separatorPostion:null,_defaultVal:null,_defaultTitle:null,_defaultIcon:null,theme:"popup",displayProperties:["icon","value","controlSize","objects"],preferMatrix:null,SELECT_BUTTON_SPRITE_WIDTH:28,CUSTOM_MENU_ITEM_HEIGHT:20,
isSelectedBinding:"*menu.isVisibleInWindow",isDefaultPosition:NO,lastMenuWidth:null,customView:null,customViewClassName:null,customViewMenuOffsetWidth:0,needsEllipsis:YES,menuPaneHeightPadding:0,leftAlign:function(){var a=0,b=this.get("controlSize");if(b===SC.SMALL_CONTROL_SIZE)a=-14;if(b===SC.REGULAR_CONTROL_SIZE)a=-16;return a}.property("controlSize"),sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,d){if(b){c=c.get?c.get(b):
c[b];d=d.get?d.get(b):d[b]}return c<d?-1:c>d?1:0})}return a},render:function(a,b){arguments.callee.base.apply(this,arguments);var c,d,e,f,g,h,i,j,k,l,m,o,r,w,p;c=this.layout.width;b&&c&&this.adjust({width:c-this.SELECT_BUTTON_SPRITE_WIDTH});c=this.get("objects");c=this.sortObjects(c);d=c.length;e=this.get("nameKey");f=this.get("iconKey");g=this.get("valueKey");h=this.get("checkboxEnabled");i=this.get("value");j=this.get("localize");k=this.get("separatorPostion");l=[];m=YES;o=0;c.forEach(function(s){if(s){r=
e?s.get?s.get(e):s[e]:s.toString();r=j?r.loc():r;w=f?s.get?s.get(f):s[f]:null;if(SC.none(s[f]))w=null;p=g?s.get?s.get(g):s[g]:s;if(!SC.none(i)&&!SC.none(p))if(i===p){this.set("title",r);this.set("icon",w)}if(p===this.get("value")){this.set("itemIdx",o);m=!h?NO:YES}else m=NO;if(o===0){this._defaultVal=p;this._defaultTitle=r;this._defaultIcon=w}s=SC.Object.create({title:r,icon:w,value:p,isEnabled:YES,checkbox:m,action:this.displaySelectedItem});l.push(s)}o+=1;if(k&&o===d-k){s=SC.Object.create({separator:YES});
l.push(s)}this.set("itemList",l)},this);b&&this.invokeLast(function(){var s=this.get("value");if(SC.none(s)){this.set("value",this._defaultVal);this.set("title",this._defaultTitle);this.set("icon",this._defaultIcon)}});this.changeSelectButtonPreferMatrix(this.itemIdx)},_action:function(){var a,b,c,d,e,f,g,h,i;a=this.$(".sc-button-label")[0];b=this.get("layer").offsetWidth;c=a.scrollWidth;d=this.get("lastMenuWidth");if(c){a=a.offsetWidth;if(c&&a)b=b+c-a}if(!d||b>d)d=b;b=this.get("itemList");g=this.get("customViewClassName");
c=this.get("customViewMenuOffsetWidth");a="sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button sc-scroll-view sc-menu-scroll-view sc-container-view menuContainer sc-button-view sc-menu-item sc-regular-size";a=g?a+" "+g:a;h=0;for(i=b.length;h<i;++h){e=b.objectAt(h);g=document.createElement("div");g.style.cssText="top:-10000px; left: -10000px;  position: absolute;";g.className=a;g.innerHTML=e.title;document.body.appendChild(g);e=g.offsetWidth+c;if(!f||e>f)f=e;document.body.removeChild(g)}d=
f>d?f:d;f=SC.RootResponder.responder.get("currentWindowSize").width;if(d>f)d=f-25;this.set("lastMenuWidth",d);f=this.get("currentSelItem");b=this.get("itemList");c=this.get("controlSize");a=this.get("menuPaneHeightPadding");g=this.get("customView");d=SC.MenuPane.create({classNames:["select-button"],items:b,exampleView:g?g:SC.MenuItemView,isEnabled:YES,menuHeightPadding:a,preferType:SC.PICKER_MENU,itemHeightKey:"height",layout:{width:d},controlSize:c,itemWidth:d,contentView:SC.View.extend({})});if(!d)return NO;
d.popup(this,this.preferMatrix);d.set("currentSelectedMenuItem",f);return YES},displaySelectedItem:function(){var a,b,c,d,e=0,f,g,h=null;a=this.parentMenu();b=a.get("currentSelectedMenuItem");c=a.menuItemViews;if(b&&c)e=c.indexOf(b);c=a.get("anchor");f=a.get("items");for(g=f.length;!h&&--g>=0;){d=f[g];a=!SC.none(d.title)?d.title:f.toString();d=!SC.none(d.value)?d.value:a;if(a===this.get("value")&&e===g){h=f;c.set("value",d);c.set("title",a)}}c.set("icon",this.get("icon")).set("currentSelItem",b).set("itemIdx",
e)},changeSelectButtonPreferMatrix:function(){var a=0,b=this.get("itemIdx"),c=this.get("leftAlign");if(this.get("isDefaultPosition")){a=[c,4,3];this.set("preferMatrix",a)}else{if(b)a=b*this.CUSTOM_MENU_ITEM_HEIGHT;a=[c,-a,2];this.set("preferMatrix",a)}},mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;this.becomeFirstResponder();this._action();return YES},keyDown:function(a){if(this.interpretKeyEvents(a))return YES;else arguments.callee.base.apply(this,
arguments)},interpretKeyEvents:function(a){if(a)if(a.keyCode===38||a.keyCode===40)this._action();else a.keyCode===27&&this.resignFirstResponder();return arguments.callee.base.apply(this,arguments)}});sc_require("panes/panel");
SC.SheetPane=SC.PanelPane.extend({classNames:"sc-sheet",transitionDuration:200,NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",SLIDE_DOWN:"SLIDEDOWN",SLIDE_UP:"SLIDEUP",_state:"NO_VIEW",append:function(){var a=this.get("layout");if(!a.height||!a.top)a=SC.View.convertLayoutToAnchoredLayout(a,this.computeParentDimensions());a.top=-1*a.height;this.adjust(a);return arguments.callee.base.apply(this,arguments)},remove:function(){var a=this,b=arguments;this.invokeLater(function(){b.callee.base.apply(a,
b)},this.transitionDuration);this.slideUp();return this},paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments);this.slideDown();return a},slideDown:function(){this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.SLIDE_DOWN;this.tick()},slideUp:function(){this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.SLIDE_UP;this.tick()},blurTo:function(){this.setFirstResponder("")},
tick:function(){this._timer=null;var a=this,b=(Date.now()-this._start)/(this._end-this._start),c=this._direction,d=this.get("layout");if(b<0)b=0;if(b>=1){c===this.SLIDE_DOWN?a.adjust("top",0):a.adjust("top",-1*d.height);this._state=SC.SheetPane.READY;this.updateLayout();return this}b=Math.floor(d.height*b);if(c==this.SLIDE_DOWN)a.adjust("top",0-(d.height-b));else c==this.SLIDE_UP&&a.adjust("top",0-b);this._timer=this.invokeLater(this.tick,20);a.updateLayout();return this}});SC.DRAG_LINK=4;
SC.DRAG_COPY=1;SC.DRAG_MOVE=2;SC.DRAG_NONE=0;SC.DRAG_ANY=7;SC.DRAG_AUTOSCROLL_ZONE_THICKNESS=20;
SC.Drag=SC.Object.extend({source:null,ghostView:null,ghostActsLikeCursor:NO,dragView:null,ghost:YES,slideBack:YES,mouseDownEvent:null,ghostOffset:{x:0,y:0},location:{},dataTypes:function(){if(this.dataSource)return this.dataSource.get("dragDataTypes")||[];var a=this.data;if(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}if((a=this.get("source"))&&a.dragDataTypes)return a.get("dragDataTypes")||[];return[]}.property().cacheable(),hasDataType:function(a){return this.get("dataTypes").indexOf(a)>=
0},dataForType:function(a){if(this.dataSource)return this.dataSource.dragDataForType(this,a);else if(this.data)return this.data[a];else{var b=this.get("source");return b&&SC.typeOf(b.dragDataForType)==SC.T_FUNCTION?b.dragDataForType(this,a):null}},dataSource:null,data:null,allowedDragOperations:SC.DRAG_ANY,_dragInProgress:YES,startDrag:function(){this._createGhostView();var a=this.event,b={x:a.pageX,y:a.pageY};this.set("location",b);var c=this.dragView,d=c.get("pane"),e=c.get("parentView");c.get("clippingFrame");
e=e?e.convertFrameToView(c.get("frame"),null):c.get("frame");d=d?d.get("frame"):{x:0,y:0};c.adjust({top:e.y+d.y,left:e.x+d.x,width:e.width,height:e.height});c.get("frame");this.ghostOffset=this.ghostActsLikeCursor?{x:14,y:14}:{x:b.x-e.x,y:b.y-e.y};this._ghostViewHidden||this._positionGhostView(a);this.ghostView.rootResponder.dragDidStart(this);(c=this.source)&&c.dragDidBegin&&c.dragDidBegin(this,b);b=this._dropTargets();c=0;for(d=b.length;c<d;c++)b[c].tryToPerform("dragStarted",this,a)},mouseDragged:function(a){var b=
this._autoscroll(a),c=this.get("location");if(!(!b&&a.pageX===c.x&&a.pageY===c.y)){c={x:a.pageX,y:a.pageY};this.set("location",c);b=this.source;for(var d=this._lastTarget,e=this._findDropTarget(a),f=SC.DRAG_NONE;e&&e!==d&&f===SC.DRAG_NONE;){f=e&&b&&b.dragSourceOperationMaskFor?b.dragSourceOperationMaskFor(this,e):SC.DRAG_ANY;if(f!==SC.DRAG_NONE&&e&&e.computeDragOperations)f&=e.computeDragOperations(this,a,f);else f=SC.DRAG_NONE;this.allowedDragOperations=f;if(f===SC.DRAG_NONE)e=this._findNextDropTarget(e)}if(e!==
d){d&&d.dragExited&&d.dragExited(this,a);if(e){e.dragEntered&&e.dragEntered(this,a);e.dragUpdated&&e.dragUpdated(this,a)}this._lastTarget=e}else e&&e.dragUpdated&&e.dragUpdated(this,a);b&&b.dragDidMove&&b.dragDidMove(this,c);this._ghostViewHidden||this._positionGhostView(a)}},mouseUp:function(a){var b={x:a.pageX,y:a.pageY},c=this._lastTarget,d=this.allowedDragOperations;this.set("location",b);try{d=c&&c.acceptDragOperation&&c.acceptDragOperation(this,d)?c.performDragOperation?c.performDragOperation(this,
d):SC.DRAG_NONE:SC.DRAG_NONE}catch(e){console.error("Exception in SC.Drag.mouseUp(acceptDragOperation|performDragOperation): %@".fmt(e))}try{c&&c.dragExited&&c.dragExited(this,a)}catch(f){console.error("Exception in SC.Drag.mouseUp(target.dragExited): %@".fmt(f))}c=this._dropTargets();for(var g=0,h=c.length;g<h;g++)try{c[g].tryToPerform("dragEnded",this,a)}catch(i){console.error("Exception in SC.Drag.mouseUp(dragEnded on %@): %@".fmt(c[g],i))}this._destroyGhostView();(a=this.source)&&a.dragDidEnd&&
a.dragDidEnd(this,b,d);this._lastTarget=null;this._dragInProgress=NO},_createGhostView:function(){var a=this,b=this.dragView.get("frame");(this.ghostView=SC.Pane.create({classNames:["sc-ghost-view"],layout:{top:b.y,left:b.x,width:b.width,height:b.height},owner:this,didCreateLayer:function(){if(a.dragView){var c=a.dragView.get("layer");c&&this.get("layer").appendChild(c.cloneNode(true))}}})).append()},_positionGhostView:function(){var a=this.get("location");a.x-=this.ghostOffset.x;a.y-=this.ghostOffset.y;
var b=this.ghostView;if(b){b.adjust({top:a.y,left:a.x});b.invokeOnce("updateLayout")}},_ghostViewHidden:NO,hideGhostView:function(){if(this.ghostView&&!this._ghostViewHidden){this.ghostView.remove();this._ghostViewHidden=YES}},unhideGhostView:function(){if(this._ghostViewHidden){this._ghostViewHidden=NO;this._createGhostView()}},_destroyGhostView:function(){if(this.ghostView){this.ghostView.remove();this.ghostView=null;this._ghostViewHidden=NO}},_dropTargets:function(){if(this._cachedDropTargets)return this._cachedDropTargets;
var a=[],b=SC.Drag._dropTargets;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);var d={},e=SC.Drag._dropTargets,f=function(g){if(!g)return 0;var h=SC.guidFor(g),i=d[h];if(!i){for(i=1;g=g.get("parentView");)e[SC.guidFor(g)]!==undefined&&i++;d[h]=i}return i};a.sort(function(g,h){if(g===h)return 0;g=f(g);h=f(h);return g>h?-1:1});return this._cachedDropTargets=a},_findDropTarget:function(a){a={x:a.pageX,y:a.pageY};for(var b,c,d=this._dropTargets(),e=0,f=d.length;e<f;e++){b=d[e];if(b.get("isVisibleInWindow")){c=
b.convertFrameToView(b.get("clippingFrame"),null);if(SC.pointInRect(a,c))return b}}return null},_findNextDropTarget:function(a){for(var b=SC.Drag._dropTargets;a=a.get("parentView");)if(b[SC.guidFor(a)])return a;return null},_autoscroll:function(a){if(!a)a=this._lastAutoscrollEvent;if(!this._dragInProgress)return NO;for(var b=a?{x:a.pageX,y:a.pageY}:this.get("location"),c=this._findScrollableView(b),d=null,e,f,g,h,i;c&&!d;){e=c.get("canScrollVertical")?1:0;f=c.get("canScrollHorizontal")?1:0;if(e||
f)if(g=c.get("containerView"))i=c.convertFrameToView(g.get("frame"),null);else e=f=0;if(e){h=SC.maxY(i);g=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.y>=g&&b.y<=h)e=1;else{g=SC.minY(i);h=g+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;e=b.y>=g&&b.y<=h?-1:0}}if(f){h=SC.maxX(i);g=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.x>=g&&b.x<=h)f=1;else{g=SC.minX(i);h=g+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;f=b.x>=g&&b.x<=h?-1:0}}if(e||f)d=c;else c=this._findNextScrollableView(c)}if(d&&this._lastScrollableView===d){if(Date.now()-
this._hotzoneStartTime>100){this._horizontalScrollAmount*=1.05;this._verticalScrollAmount*=1.05}}else{this._lastScrollableView=d;this._verticalScrollAmount=this._horizontalScrollAmount=15;this._hotzoneStartTime=d?Date.now():null;f=e=0}if(d&&(f||e))d.scrollBy({x:f*this._horizontalScrollAmount,y:e*this._verticalScrollAmount});if(d){if(a)this._lastAutoscrollEvent={pageX:a.pageX,pageY:a.pageY};this.invokeLater(this._autoscroll,100,null);return YES}else{this._lastAutoscrollEvent=null;return NO}},_scrollableViews:function(){if(this._cachedScrollableView)return this._cachedScrollableView;
var a=[],b=SC.Drag._scrollableViews;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);return this._cachedScrollableView=a=a.sort(function(d,e){for(d=d;d=d.get("parentView");)if(e==d)return-1;return 1})},_findScrollableView:function(a){var b=this._scrollableViews(),c=b?b.length:0,d,e,f;for(f=0;f<c;f++){d=b[f];if(d.get("isVisibleInWindow")){e=d.convertFrameToView(d.get("clippingFrame"),null);if(SC.pointInRect(a,e))return d}}return null},_findNextScrollableView:function(a){for(var b=SC.Drag._scrollableViews;a=
a.get("parentView");)if(b[SC.guidFor(a)])return a;return null}});SC.Drag.mixin({start:function(a){a=this.create(a);a.startDrag();return a},_dropTargets:{},_scrollableViews:{},addDropTarget:function(a){this._dropTargets[SC.guidFor(a)]=a},removeDropTarget:function(a){delete this._dropTargets[SC.guidFor(a)]},addScrollableView:function(a){this._scrollableViews[SC.guidFor(a)]=a},removeScrollableView:function(a){delete this._scrollableViews[SC.guidFor(a)]}});
SC.MODIFIED_KEY_BINDINGS={"ctrl_.":"cancel",shift_tab:"insertBacktab",shift_left:"moveLeftAndModifySelection",shift_right:"moveRightAndModifySelection",shift_up:"moveUpAndModifySelection",shift_down:"moveDownAndModifySelection",alt_left:"moveLeftAndModifySelection",alt_right:"moveRightAndModifySelection",alt_up:"moveUpAndModifySelection",alt_down:"moveDownAndModifySelection",ctrl_a:"selectAll"};
SC.BASE_KEY_BINDINGS={escape:"cancel",backspace:"deleteBackward","delete":"deleteForward","return":"insertNewline",tab:"insertTab",left:"moveLeft",right:"moveRight",up:"moveUp",down:"moveDown",home:"moveToBeginningOfDocument",end:"moveToEndOfDocument",pagedown:"pageDown",pageup:"pageUp"};SC.CAPTURE_BACKSPACE_KEY=NO;SC.PANEL_ORDER_LAYER=4096;SC.PALETTE_ORDER_LAYER=8192;SC.POPUP_ORDER_LAYER=12288;
SC.RootResponder=SC.RootResponder.extend({platform:"desktop",focusedPane:function(){var a=this.get("orderedPanes");return a[a.length-1]}.property("orderedPanes"),orderedPanes:null,orderBefore:function(a,b){var c=this.get("focusedPane"),d=this.get("orderedPanes").without(a),e,f,g,h=a.get("orderLayer");if(b){e=d.length;f=d.indexOf(b);g=b.get("orderLayer");if(g<h){for(;b.get("orderLayer")<h&&++f<e;)b=d[f];if(f>=e)b=null}else if(g>h){for(;b.get("orderLayer")>h&&--f>=0;)b=d[f];b=f<0?d[0]:d[f+1]}}else{for(f=
d.length;--f>=0&&!b;){b=d[f];if(b.get("orderLayer")>h)b=null}b=f<0?d[0]:d[f+1]}if(b){f=d.indexOf(b);d.insertAt(f,a)}else d.push(a);this.set("orderedPanes",d);a=this.get("focusedPane");if(a!==c){c&&c.blurTo(a);a&&a.focusFrom(c)}return this},orderOut:function(a){var b=this.get("focusedPane"),c=this.get("keyPane");this.set("orderedPanes",this.get("orderedPanes").without(a));if(b===a){var d=this.get("focusedPane");b&&b.blurTo(d);d&&d.focusFrom(b);c===a&&this.makeKeyPane(d)}else c===a&&this.makeKeyPane(null);
return this},init:function(){arguments.callee.base.apply(this,arguments);this.orderedPanes=[]},setup:function(){this.listenFor("keydown keyup mousedown mouseup click dblclick mouseout mouseover mousemove selectstart".w(),document).listenFor("resize focus blur".w(),window);if(this.keypress)if(SC.CAPTURE_BACKSPACE_KEY&&SC.browser.mozilla){var a=this;document.onkeypress=function(b){b=SC.Event.normalizeEvent(b);return a.keypress.call(a,b)};SC.Event.add(window,"unload",this,function(){document.onkeypress=
null})}else SC.Event.add(document,"keypress",this,this.keypress);"drag selectstart".w().forEach(function(b){var c=this[b];if(c)if(SC.browser.msie){var d=this;document.body["on"+b]=function(){return c.call(d,SC.Event.normalizeEvent(event||window.event))};SC.Event.add(window,"unload",this,function(){document.body["on"+b]=null})}else SC.Event.add(document,b,this,c)},this);SC.Event.add(document,SC.browser.mozilla?"DOMMouseScroll":"mousewheel",this,this.mousewheel);this.set("currentWindowSize",this.computeWindowSize());
this.focus()},attemptKeyEquivalent:function(a){var b=null,c=a.commandCodes()[0];if(!c)return NO;var d=this.get("keyPane"),e=this.get("mainPane"),f=this.get("mainMenu");if(d)if((b=d.performKeyEquivalent(c,a))||d.get("isModal"))return b;if(!b&&e&&e!==d)if((b=e.performKeyEquivalent(c,a))||e.get("isModal"))return b;if(!b&&f)b=f.performKeyEquivalent(c,a);return b},currentWindowSize:null,computeWindowSize:function(){var a;if(window.innerHeight)a={width:window.innerWidth,height:window.innerHeight};else if(document.documentElement&&
document.documentElement.clientHeight)a={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};else if(document.body)a={width:document.body.clientWidth,height:document.body.clientHeight};return a},resize:function(){this._resize();return YES},_resize:function(){var a=this.computeWindowSize(),b=this.get("currentWindowSize");this.set("currentWindowSize",a);if(!SC.rectsEqual(a,b))if(this.panes){SC.RunLoop.begin();this.panes.invoke("windowSizeDidChange",b,a);SC.RunLoop.end()}},
hasFocus:NO,focus:function(){if(!this.get("hasFocus")){SC.$("body").addClass("sc-focus").removeClass("sc-blur");SC.RunLoop.begin();this.set("hasFocus",YES);SC.RunLoop.end()}return YES},blur:function(){if(this.get("hasFocus")){SC.$("body").addClass("sc-blur").removeClass("sc-focus");SC.RunLoop.begin();this.set("hasFocus",NO);SC.RunLoop.end()}return YES},dragDidStart:function(a){this._drag=this._mouseDownView=a},_lastModifiers:null,_handleModifierChanges:function(a){var b;b=this._lastModifiers=this._lastModifiers||
{alt:false,ctrl:false,shift:false};var c=false;if(a.altKey!==b.alt){b.alt=a.altKey;c=true}if(a.ctrlKey!==b.ctrl){b.ctrl=a.ctrlKey;c=true}if(a.shiftKey!==b.shift){b.shift=a.shiftKey;c=true}a.modifiers=b;return c?this.sendEvent("flagsChanged",a)?a.hasCustomEventHandling:YES:YES},_isFunctionOrNonPrintableKey:function(a){return!!(a.altKey||a.ctrlKey||a.metaKey||a.charCode!==a.which&&SC.FUNCTION_KEYS[a.which])},_isModifierKey:function(a){return!!SC.MODIFIER_KEYS[a.charCode]},keydown:function(a){if(SC.none(a))return YES;
if(SC.browser.mozilla&&a.which===8)return true;var b=this._handleModifierChanges(a),c=a.target||a.srcElement;c=a.which===8&&!SC.allowsBackspaceToPreviousPage&&c===document.body;if(this._isModifierKey(a))return c?NO:b;b=YES;if(this._isFunctionOrNonPrintableKey(a)){if(a.keyCode>=37&&a.keyCode<=40&&SC.browser.mozilla)return YES;if(b=this.sendEvent("keyDown",a)){if(b=a.hasCustomEventHandling)c=NO}else b=!this.attemptKeyEquivalent(a)}return c?NO:b},keypress:function(a){var b;if(SC.browser.mozilla&&a.which===
8){a.which=a.keyCode;return(b=this.sendEvent("keyDown",a))?SC.allowsBackspaceToPreviousPage||a.hasCustomEventHandling:YES}else{b=a.keyCode>=37&&a.keyCode<=40&&SC.browser.mozilla;if(a.charCode!==undefined&&a.charCode===0&&!b)return YES;if(b)a.which=a.keyCode;return this.sendEvent("keyDown",a)?a.hasCustomEventHandling:YES}},keyup:function(a){if(this._ffevt)this._ffevt=null;var b=this._handleModifierChanges(a);if(this._isModifierKey(a))return b;return this.sendEvent("keyUp",a)?a.hasCustomEventHandling:
YES},mousedown:function(a){try{window.focus();this.focus();if(SC.browser.msie){this._lastMouseDownX=a.clientX;this._lastMouseDownY=a.clientY}this._clickCount+=1;if(!this._lastMouseUpAt||Date.now()-this._lastMouseUpAt>200)this._clickCount=1;a.clickCount=this._clickCount;var b,c=this.targetViewForEvent(a);if(c)b=c.get("pane").get("firstResponder");b&&b.kindOf(SC.InlineTextFieldView)&&b!==c&&b.resignFirstResponder();if((c=this._mouseDownView=this.sendEvent("mouseDown",a,c))&&c.respondsTo("mouseDragged"))this._mouseCanDrag=
YES}catch(d){console.warn("Exception during mousedown: %@".fmt(d));this._mouseDownView=null;this._mouseCanDrag=NO;throw d;}return c?a.hasCustomEventHandling:YES},mouseup:function(a){try{if(this._drag){this._drag.tryToPerform("mouseUp",a);this._drag=null}var b=null,c=this._mouseDownView;this._lastMouseUpAt=Date.now();a.clickCount=this._clickCount;if(c){b=this.sendEvent("mouseUp",a,c);if(!b&&this._clickCount===2)b=this.sendEvent("doubleClick",a,c);b||(b=this.sendEvent("click",a,c))}if(!b){c=this.targetViewForEvent(a);
if(this._clickCount===2)b=this.sendEvent("doubleClick",a,c);b||(b=this.sendEvent("click",a,c))}this._mouseCanDrag=NO;this._mouseDownView=null}catch(d){this._drag=null;this._mouseCanDrag=NO;this._mouseDownView=null;throw d;}return b?a.hasCustomEventHandling:YES},dblclick:function(a){if(SC.browser.isIE){this._clickCount=2;this.mouseup(a)}},mousewheel:function(a){try{var b=this.targetViewForEvent(a),c=this.sendEvent("mouseWheel",a,b)}catch(d){throw d;}return c?a.hasCustomEventHandling:YES},_lastHovered:null,
mousemove:function(a){if(SC.browser.msie)if(this._lastMoveX===a.clientX&&this._lastMoveY===a.clientY)return;this._lastMoveX=a.clientX;this._lastMoveY=a.clientY;SC.RunLoop.begin();try{this.focus();if(this._drag)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._drag.tryToPerform("mouseDragged",a);else this._drag.tryToPerform("mouseDragged",a);else{for(var b=this._lastHovered||[],c=[],d,e,f,g=this.targetViewForEvent(a);g&&g!==this;){b.indexOf(g)!==-1?g.tryToPerform("mouseMoved",
a):g.tryToPerform("mouseEntered",a);c.push(g);g=g.get("nextResponder")}e=0;for(f=b.length;e<f;e++){g=b[e];(d=g.respondsTo("mouseExited"))&&c.indexOf(g)===-1&&g.tryToPerform("mouseExited",a)}this._lastHovered=c;if(this._mouseDownView)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._mouseDownView.tryToPerform("mouseDragged",a);else this._mouseDownView.tryToPerform("mouseDragged",a)}}catch(h){throw h;}SC.RunLoop.end()},_mouseCanDrag:YES,selectstart:function(a){return(this.sendEvent("selectStart",
a,this.targetViewForEvent(a))!==null?YES:NO)&&(this._mouseCanDrag?NO:YES)},drag:function(){return false}});sc_require("core");
SC.UndoManager=SC.Object.extend({undoActionName:function(){return this.undoStack?this.undoStack.name:null}.property("undoStack"),redoActionName:function(){return this.redoStack?this.redoStack.name:null}.property("redoStack"),canUndo:function(){return this.undoStack!=null}.property("undoStack"),canRedo:function(){return this.redoStack!=null}.property("redoStack"),undo:function(){this._undoOrRedo("undoStack","isUndoing")},redo:function(){this._undoOrRedo("redoStack","isRedoing")},isUndoing:false,isRedoing:false,
groupingLevel:0,registerUndo:function(a,b){this.beginUndoGroup(b);this._activeGroup.actions.push(a);this.endUndoGroup(b)},beginUndoGroup:function(a){if(this._activeGroup)this.groupingLevel++;else{var b=this.isUndoing?"redoStack":"undoStack";this._activeGroup={name:a,actions:[],prev:this.get(b)};this.set(b,this._activeGroup);this.groupingLevel=1}},endUndoGroup:function(){this._activeGroup||raise("endUndoGroup() called outside group.");if(this.groupingLevel>1)this.groupingLevel--;else{this._activeGroup=
null;this.groupingLevel=0}this.propertyDidChange(this.isUndoing?"redoStack":"undoStack")},setActionName:function(a){this._activeGroup||raise("setActionName() called outside group.");this._activeGroup.name=a},_activeGroup:null,undoStack:null,redoStack:null,_undoOrRedo:function(a,b){if(this._activeGroup)return false;if(this.get(a)==null)return true;this.set(b,true);var c=this.get(a);this.set(a,c.prev);var d=c.actions.length>1;for(d&&this.beginUndoGroup(c.name);a=c.actions.pop();)a();d&&this.endUndoGroup(c.name);
this.set(b,false)}});
SC.CheckboxView=SC.FieldView.extend(SC.StaticLayout,SC.Button,{classNames:["sc-checkbox-view"],tagName:"label",needsEllipsis:NO,render:function(a,b){if(b){b=this._field_currentDisplayTitle=this.get("displayTitle");var c=this.get("isEnabled")?"":'disabled="disabled"';SC.browser.msie&&a.attr("for",SC.guidFor(this));a.push('<span class="button" ></span>');a.push('<input type="checkbox" id="%@" name="%@" %@ />'.fmt(SC.guidFor(this),SC.guidFor(this),c));this.get("needsEllipsis")?a.push('<span class="label ellipsis">',b,
"</span>"):a.push('<span class="label">',b,"</span>");a.attr("name",SC.guidFor(this))}else{if(a=this.$input()[0])a.disabled=this.get("isEnabled")?NO:YES;b=this.get("displayTitle");if(b!==this._field_currentDisplayTitle){this._field_currentDisplayTitle=b;this.$("span.label").text(b)}}},$input:function(){return this.$("input")},getFieldValue:function(){var a=this.$input().attr("checked");if(a)this._lastFieldValue=null;else if(this._lastFieldValue===SC.MIXED_STATE)a=SC.MIXED_STATE;return a},setFieldValue:function(a){this._lastFieldValue=
a;this.$input().attr("checked",a===SC.MIXED_STATE?NO:!!a)},fieldValueForObject:function(a){return this.computeIsSelectedForValue(a)},objectForFieldValue:function(a){return a===SC.MIXED_STATE?this.get("value"):a?this.get("toggleOnValue"):this.get("toggleOffValue")},didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input()[0],"click",this,this._field_fieldValueDidChange)},willDestroyLayer:function(){SC.Event.remove(this.$input()[0],"click",this,this._field_fieldValueDidChange)},
mouseDown:function(){this.set("isActive",YES);return this._field_isMouseDown=YES}});SC.LIST_ITEM_ACTION_CANCEL="sc-list-item-cancel-action";SC.LIST_ITEM_ACTION_REFRESH="sc-list-item-cancel-refresh";SC.LIST_ITEM_ACTION_EJECT="sc-list-item-cancel-eject";
SC.ListItemView=SC.View.extend(SC.StaticLayout,SC.Control,{classNames:["sc-list-item-view"],content:null,hasContentIcon:NO,hasContentRightIcon:NO,hasContentBranch:NO,contentCheckboxKey:null,contentIconKey:null,contentRightIconKey:null,contentValueKey:null,escapeHTML:YES,contentUnreadCountKey:null,contentIsBranchKey:null,isEditing:NO,outlineIndent:16,outlineLevel:0,disclosureState:SC.LEAF_NODE,contentPropertyDidChange:function(){this.get("contentIsEditable")!==this.contentIsEditable()&&this.notifyPropertyChange("contentIsEditable");
this.displayDidChange()},contentIsEditable:function(){var a=this.get("content");return a&&(a.get?a.get("isEditable")!==NO:NO)}.property("content").cacheable(),render:function(a){var b=this.get("content"),c=this.displayDelegate,d=this.get("outlineLevel"),e=this.get("outlineIndent"),f;a.addClass(this.get("contentIndex")%2===0?"even":"odd");a.setClass("disabled",!this.get("isEnabled"));f=a.begin("div").addClass("sc-outline");d>=0&&e>0&&f.addStyle("left",e*(d+1));d=this.get("disclosureState");if(d!==
SC.LEAF_NODE){this.renderDisclosure(f,d);a.addClass("has-disclosure")}if(d=this.getDelegateProperty("contentCheckboxKey",c)){d=b?b.get?b.get(d):b[d]:NO;this.renderCheckbox(f,d);a.addClass("has-checkbox")}if(this.getDelegateProperty("hasContentIcon",c)){d=(d=this.getDelegateProperty("contentIconKey",c))&&b?b.get?b.get(d):b[d]:null;this.renderIcon(f,d);a.addClass("has-icon")}if((d=(d=this.getDelegateProperty("contentValueKey",c))&&b?b.get?b.get(d):b[d]:b)&&SC.typeOf(d)!==SC.T_STRING)d=d.toString();
if(this.get("escapeHTML"))d=SC.RenderContext.escapeHTML(d);this.renderLabel(f,d);if(this.getDelegateProperty("hasContentRightIcon",c)){d=(d=this.getDelegateProperty("contentRightIconKey",c))&&b?b.get?b.get(d):b[d]:null;this.renderRightIcon(f,d);a.addClass("has-right-icon")}d=(d=this.getDelegateProperty("contentUnreadCountKey",c))&&b?b.get?b.get(d):b[d]:null;if(!SC.none(d)&&d!==0){this.renderCount(f,d);e=["zero","one","two","three","four","five"];d=d.toString().length<e.length?e[d.toString().length]:
e[e.length-1];a.addClass("has-count "+d+"-digit")}if(d=(d=this.getDelegateProperty("listItemActionProperty",c))&&b?b.get?b.get(d):b[d]:null){this.renderAction(f,d);a.addClass("has-action")}if(this.getDelegateProperty("hasContentBranch",c)){d=(d=this.getDelegateProperty("contentIsBranchKey",c))&&b?b.get?b.get(d):b[d]:NO;this.renderBranch(f,d);a.addClass("has-branch")}f.end()},renderDisclosure:function(a,b){b=b===SC.BRANCH_OPEN?"open":"closed";var c=this._scli_disclosureHtml,d;if(!c)c=this.constructor.prototype._scli_disclosureHtml=
{};(d=c[b])||(d=c[b]='<img src="'+SC.BLANK_IMAGE_URL+'" class="disclosure button '+b+'" />');a.push(d)},renderCheckbox:function(a,b){var c=b===SC.MIXED_STATE?"mixed":b?"sel":"nosel",d=this._scli_checkboxHtml,e=this.get("contentIsEditable")&&this.get("isEnabled"),f;e||(c=SC.keyFor("disabled",c));if(!d)d=this.constructor.prototype._scli_checkboxHtml={};f=d[c];if(!f){f=SC.RenderContext("a").attr("href","javascript:;").classNames(SC.CheckboxView.prototype.classNames);b===SC.MIXED_STATE?f.addClass("mixed"):
f.setClass("sel",b);f.setClass("disabled",!e);f.push('<span class="button"></span>');f=d[c]=f.join()}a.push(f)},renderIcon:function(a,b){var c=null,d=null;if(b&&SC.ImageView.valueIsUrl(b)){c=b;d=""}else{d=b;c=SC.BLANK_IMAGE_URL}a.begin("img").addClass("icon").addClass(d).attr("src",c).end()},renderLabel:function(a,b){a.push("<label>",b||"","</label>")},$label:function(){return this.$("label")},renderRightIcon:function(a,b){var c=null,d=null;if(b&&SC.ImageView.valueIsUrl(b)){c=b;d=""}else{d=b;c=SC.BLANK_IMAGE_URL}a.begin("img").addClass("right-icon").addClass(d).attr("src",
c).end()},renderCount:function(a,b){a.push('<span class="count"><span class="inner">').push(b.toString()).push("</span></span>")},renderAction:function(a){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="action" />')},renderBranch:function(a,b){a.begin("span").addClass("branch").addClass(b?"branch-visible":"branch-hidden").push("&nbsp;").end()},_isInsideElementWithClassName:function(a,b){var c=this.get("layer");if(!c)return NO;b=SC.$(b.target);for(var d=NO;!d&&b.length>0&&b[0]!==c;){if(b.hasClass(a))d=
YES;b=b.parent()}return d},_isInsideCheckbox:function(a){return this.getDelegateProperty("contentCheckboxKey",this.displayDelegate)&&this._isInsideElementWithClassName("sc-checkbox-view",a)},_isInsideDisclosure:function(a){if(this.get("disclosureState")===SC.LEAF_NODE)return NO;return this._isInsideElementWithClassName("disclosure",a)},_isInsideRightIcon:function(a){return this.getDelegateProperty("hasContentRightIcon",this.displayDelegate)&&this._isInsideElementWithClassName("right-icon",a)},mouseDown:function(a){if(!this.get("contentIsEditable"))return NO;
if(this._isInsideCheckbox(a)){this._addCheckboxActiveState();return this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=YES}else if(this._isInsideDisclosure(a)){this._addDisclosureActiveState();return this._isMouseInsideDisclosure=this._isMouseDownOnDisclosure=YES}else if(this._isInsideRightIcon(a)){this._addRightIconActiveState();return this._isMouseInsideRightIcon=this._isMouseDownOnRightIcon=YES}return NO},mouseUp:function(a){var b=NO,c;if(this._isMouseDownOnCheckbox){if(this._isInsideCheckbox(a)){b=
this.displayDelegate;a=this.getDelegateProperty("contentCheckboxKey",b);if((b=this.get("content"))&&b.get){c=b.get(a);c=c===SC.MIXED_STATE?YES:!c;b.set(a,c);this.displayDidChange()}}this._removeCheckboxActiveState();b=YES}else if(this._isMouseDownOnDisclosure){if(this._isInsideDisclosure(a)){a=this.get("disclosureState");b=this.get("contentIndex");c=!SC.none(b)?SC.IndexSet.create(b):null;b=this.get("displayDelegate");if(a===SC.BRANCH_OPEN){c&&b&&b.collapse?b.collapse(c):this.set("disclosureState",
SC.BRANCH_CLOSED);this.displayDidChange()}else if(a===SC.BRANCH_CLOSED){c&&b&&b.expand?b.expand(c):this.set("disclosureState",SC.BRANCH_OPEN);this.displayDidChange()}}this._removeDisclosureActiveState();b=YES}else if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();b=YES}this._isMouseInsideRightIcon=this._isMouseDownOnRightIcon=this._isMouseDownOnDisclosure=this._isMouseInsideDisclosure=this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=NO;return b},mouseExited:function(){if(this._isMouseDownOnCheckbox){this._removeCheckboxActiveState();
this._isMouseInsideCheckbox=NO}else if(this._isMouseDownOnDisclosure){this._removeDisclosureActiveState();this._isMouseInsideDisclosure=NO}else if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();this._isMouseInsideRightIcon=NO}return NO},mouseEntered:function(){if(this._isMouseDownOnCheckbox){this._addCheckboxActiveState();this._isMouseInsideCheckbox=YES}else if(this._isMouseDownOnDisclosure){this._addDisclosureActiveState();this._isMouseInsideDisclosure=YES}else if(this._isMouseDownOnRightIcon){this._addRightIconActiveState();
this._isMouseInsideRightIcon=YES}return NO},_addCheckboxActiveState:function(){var a=this.get("isEnabled");this.$(".sc-checkbox-view").setClass("active",a)},_removeCheckboxActiveState:function(){this.$(".sc-checkbox-view").removeClass("active")},_addDisclosureActiveState:function(){var a=this.get("isEnabled");this.$("img.disclosure").setClass("active",a)},_removeDisclosureActiveState:function(){this.$("img.disclosure").removeClass("active")},_addRightIconActiveState:function(){this.$("img.right-icon").setClass("active",
YES)},_removeRightIconActiveState:function(){this.$("img.right-icon").removeClass("active")},contentHitTest:function(a){if(!this.getDelegateProperty("contentValueKey",this.displayDelegate))return NO;var b=this.$label()[0];if(!b)return NO;a=a.target;for(var c=this.get("layer");a&&a!==c&&a!==window;){if(a===b)return YES;a=a.parentNode}return NO},beginEditing:function(){if(this.get("isEditing"))return YES;return this._beginEditing(YES)},_beginEditing:function(a){var b=this.get("content"),c=this.getDelegateProperty("contentValueKey",
this.get("displayDelegate")),d=this.get("parentView");d&&d.get("frame");var e=this.$label(),f,g,h,i;if(a&&this.scrollToVisible()){var j=this.get("owner"),k=this.get("contentIndex");this.invokeLater(function(){var l=j.itemViewForContentIndex(k);l&&l._beginEditing&&l._beginEditing(NO)});return YES}if(!d||!e||e.get("length")===0)return NO;c=c&&b&&b.get?b.get(c):null;b=this.computeFrameWithParentFrame(null);d=SC.viewportOffset(e[0]);a=e.css("lineHeight");f=e.css("fontSize");g=(g=this.$().css("top"))?
parseInt(g.substring(0,g.length-2),0):0;h=a;i=0;if(f&&h){f=f*1.5;if(f<h){e.css({lineHeight:"1.5"});i=(h-f)/2}else a=null}b.x=d.x;b.y=d.y+g+i;b.height=e[0].offsetHeight;b.width=e[0].offsetWidth;b=SC.InlineTextFieldView.beginEditing({frame:b,exampleElement:e,delegate:this,value:c,multiline:NO,isCollection:YES});a&&e.css({lineHeight:a});return b},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},discardEditing:function(){if(!this.get("isEditing"))return YES;
return SC.InlineTextFieldView.discardEditing()},inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){var a=this.$label();this._oldOpacity=a.css("opacity");a.css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},inlineEditorDidEndEditing:function(a,b){this.set("isEditing",NO);a=this.get("content");var c=this.getDelegateProperty("contentValueKey",this.displayDelegate);c&&a&&a.set&&a.set(c,b);this.displayDidChange()}});sc_require("mixins/collection_view_delegate");
sc_require("views/list_item");SC.DRAG_REORDER=16;SC.HORIZONTAL_ORIENTATION="horizontal";SC.VERTICAL_ORIENTATION="vertical";SC.BENCHMARK_RELOAD=NO;
SC.CollectionView=SC.View.extend(SC.CollectionViewDelegate,SC.CollectionContent,{classNames:["sc-collection-view"],ACTION_DELAY:200,content:null,contentBindingDefault:SC.Binding.multiple(),length:0,nowShowing:function(){return this.computeNowShowing()}.property("length","clippingFrame").cacheable(),selection:null,isSelectable:YES,isSelectableBindingDefault:SC.Binding.bool(),isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),isEditable:YES,isEditableBindingDefault:SC.Binding.bool(),canReorderContent:NO,
canReorderContentBindingDefault:SC.Binding.bool(),canDeleteContent:NO,canDeleteContentBindingDefault:SC.Binding.bool(),canEditContent:NO,canEditContentBindingDefault:SC.Binding.bool(),isDropTarget:NO,useToggleSelection:NO,actOnSelect:NO,selectOnMouseDown:YES,exampleView:SC.ListItemView,contentExampleViewKey:null,groupExampleView:null,contentGroupExampleViewKey:null,action:null,target:null,contentValueKey:null,acceptsFirstResponder:NO,isActive:NO,calculatedHeight:0,calculatedWidth:0,computeLayout:function(){return null},
layoutForContentIndex:function(){return null},allContentIndexes:function(){return SC.IndexSet.create(0,this.get("length")).freeze()}.property("length").cacheable(),contentIndexesInRect:function(){return null},computeNowShowing:function(){var a=this.contentIndexesInRect(this.get("clippingFrame"));if(a){var b=this.get("length"),c=a.get("max");if(c>b)a=a.copy().remove(b,c-b).freeze()}else a=this.get("allContentIndexes");return a},showInsertionPoint:function(){},hideInsertionPoint:function(){},delegate:null,
selectionDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionViewDelegate",a,b)}.property("delegate","content").cacheable(),contentDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionContent",a,b)}.property("delegate","content").cacheable(),contentRangeDidChange:function(a,b,c,d){!b&&c==="[]"?this.reload(d):this.contentPropertyDidChange(b,c,d)},contentPropertyDidChange:function(){},updateContentRangeObserver:function(){var a=
this.get("nowShowing"),b=this._cv_contentRangeObserver,c=this.get("content");if(c)if(b)c.updateRangeObserver(b,a);else this._cv_contentRangeObserver=b=c.addRangeObserver(a,this,this.contentRangeDidChange,null)},removeContentRangeObserver:function(){var a=this.get("content"),b=this._cv_contentRangeObserver;if(b){a&&a.removeRangeObserver(b);this._cv_contentRangeObserver=null}},contentLengthDidChange:function(){var a=this.get("content");this.set("length",a?a.get("length"):0)},_cv_contentDidChange:function(){var a=
this.get("content"),b=this.contentLengthDidChange;if(a===this._content)return this;this.removeContentRangeObserver();this._content&&this._content.removeObserver("length",this,b);(this._content=a)&&a.addObserver("length",this,b);this.contentLengthDidChange();this.contentRangeDidChange(a,null,"[]",null)}.observes("content"),_invalidIndexes:NO,reload:function(a){var b=this._invalidIndexes;if(a&&b!==YES)if(b)b.add(a);else this._invalidIndexes=a.clone();else this._invalidIndexes=YES;this.get("isVisibleInWindow")&&
this.invokeOnce(this.reloadIfNeeded);return this},reloadIfNeeded:function(){var a=this._invalidIndexes;if(!a||!this.get("isVisibleInWindow"))return this;this._invalidIndexes=NO;var b=this.get("content");b&&b.get("length");b=this.computeLayout();var c=SC.BENCHMARK_RELOAD,d=this.get("nowShowing"),e=this._sc_itemViews,f=this.get("containerView")||this,g,h,i;if(a.isIndexSet&&a.contains(d))a=YES;if(this.willReload)this.willReload(a===YES?null:a);if(a.isIndexSet){if(c)SC.Benchmark.start(c="%@#reloadIfNeeded (Partial)".fmt(this),
YES);a.forEach(function(j){var k=e?e[j]:null;if(d.contains(j)){h=this.itemViewForContentIndex(j,YES);if(k&&k.parentView===f){(i=k.get("layer"))&&i.parentNode&&i.parentNode.removeChild(i);i=null;f.replaceChild(h,k)}else f.appendChild(h)}else if(k&&k.parentView===f){delete e[j];(i=k.get("layer"))&&i.parentNode&&i.parentNode.removeChild(i);i=null;f.removeChild(k)}},this)}else{if(c)SC.Benchmark.start(c="%@#reloadIfNeeded (Full)".fmt(this),YES);if(e)e.length=0;g=[];d.forEach(function(j){g.push(this.itemViewForContentIndex(j,
YES))},this);f.beginPropertyChanges();f.destroyLayer().removeAllChildren();f.set("childViews",g);f.replaceLayer();f.endPropertyChanges()}c&&SC.Benchmark.end(c);b&&this.adjust(b);if(this.didReload)this.didReload(a===YES?null:a);return this},displayProperties:"isFirstResponder isEnabled isActive".w(),render:function(a,b){b&&this._needsReload&&this.reloadIfNeeded();a.setClass("focus",this.get("isFirstResponder"));a.setClass("disabled",!this.get("isEnabled"));a.setClass("active",this.get("isActive"));
return arguments.callee.base.apply(this,arguments)},_TMP_ATTRS:{},_COLLECTION_CLASS_NAMES:"sc-collection-item".w(),_GROUP_COLLECTION_CLASS_NAMES:"sc-collection-item sc-group-item".w(),itemViewForContentIndex:function(a,b){var c=this.get("content"),d=this._sc_itemViews,e=c.objectAt(a),f=this.get("contentDelegate"),g=f.contentGroupIndexes(this,c),h=NO,i,j;if(!d)d=this._sc_itemViews=[];if(!b&&(i=d[a]))return i;if(h=g&&g.contains(a))h=f.contentIndexIsGroup(this,c,a);if(h){if((b=this.get("contentGroupExampleViewKey"))&&
e)j=e.get(b);j||(j=this.get("groupExampleView")||this.get("exampleView"))}else{if((b=this.get("contentExampleViewKey"))&&e)j=e.get(b);j||(j=this.get("exampleView"))}b=this._TMP_ATTRS;b.contentIndex=a;b.content=e;b.owner=b.displayDelegate=this;b.parentView=this.get("containerView")||this;b.page=this.page;b.layerId=this.layerIdFor(a,e);b.isEnabled=f.contentIndexIsEnabled(this,c,a);b.isSelected=f.contentIndexIsSelected(this,c,a);b.outlineLevel=f.contentIndexOutlineLevel(this,c,a);b.disclosureState=f.contentIndexDisclosureState(this,
c,a);b.isGroupView=h;b.isVisibleInWindow=this.isVisibleInWindow;b.classNames=h?this._GROUP_COLLECTION_CLASS_NAMES:this._COLLECTION_CLASS_NAMES;if(c=this.layoutForContentIndex(a))b.layout=c;else delete b.layout;i=this.createItemView(j,a,b);return d[a]=i},itemViewForContentObject:function(a){return this.itemViewForContentIndex(this.get("content").indexOf(a))},_TMP_LAYERID:[],createItemView:function(a,b,c){return a.create(c)},layerIdFor:function(a){var b=this._TMP_LAYERID;b[0]=SC.guidFor(this);b[1]=
a;return b.join("-")},contentIndexForLayerId:function(a){if(!a||!(a=a.toString()))return null;var b=this._baseLayerId;if(!b)b=this._baseLayerId=SC.guidFor(this)+"-";if(a.length<=b.length||a.indexOf(b)!==0)return null;a=Number(a.slice(a.lastIndexOf("-")+1));return isNaN(a)?null:a},itemViewForEvent:function(a){if(!this.getPath("pane.rootResponder"))return null;SC.guidFor(this);a=a.target;for(var b=this.get("layer"),c=null,d;a&&a!==document&&a!==b;){if((d=a?SC.$(a).attr("id"):null)&&(c=this.contentIndexForLayerId(d))!==
null)break;a=a.parentNode}if(c===null||a===b)return null;if(c>=this.get("length"))throw"layout for item view %@ was found when item view does not exist (%@)".fmt(d,this);return this.itemViewForContentIndex(c)},expand:function(a){if(!a)return this;var b=this.get("contentDelegate"),c=this.get("content");a.forEach(function(d){b.contentIndexDisclosureState(this,c,d)===SC.BRANCH_CLOSED&&b.contentIndexExpand(this,c,d)},this);return this},collapse:function(a){if(!a)return this;var b=this.get("contentDelegate"),
c=this.get("content");a.forEach(function(d){b.contentIndexDisclosureState(this,c,d)===SC.BRANCH_OPEN&&b.contentIndexCollapse(this,c,d)},this);return this},_cv_selectionDidChange:function(){var a=this.get("selection"),b=this._cv_selection,c=this._cv_selectionContentDidChange;if(a===b)return this;b&&b.removeObserver("[]",this,c);a&&a.addObserver("[]",this,c);this._cv_selection=a;this._cv_selectionContentDidChange()}.observes("selection"),_cv_selectionContentDidChange:function(){var a=this.get("selection"),
b=this._cv_selindexes,c=this.get("content");this._cv_selindexes=a?a.frozenCopy():null;if(b)b=b.indexSetForSource(c);if(a)a=a.indexSetForSource(c);(a=a&&b?a.without(b).add(b.without(a)):a||b)&&a.get("length")>0&&this.reloadSelectionIndexes(a)},_invalidSelection:NO,reloadSelectionIndexes:function(a){var b=this._invalidSelection;if(a&&b!==YES)if(b)b.add(a);else this._invalidSelection=a.copy();else this._invalidSelection=YES;this.get("isVisibleInWindow")&&this.invokeOnce(this.reloadSelectionIndexesIfNeeded);
return this},reloadSelectionIndexesIfNeeded:function(){var a=this._invalidSelection;if(!a||!this.get("isVisibleInWindow"))return this;var b=this.get("nowShowing"),c=this._invalidIndexes,d=this.get("content"),e=this.get("selection");this._invalidSelection=NO;if(c===YES||!b)return this;if(a===YES)a=b;if(c&&c.isIndexSet)a=a.without(c);a.forEach(function(f){if(b.contains(f)){var g=this.itemViewForContentIndex(f,NO);if(g)g.set("isSelected",e?e.contains(d,f):NO)}},this);return this},select:function(a,b){var c=
this.get("content"),d=this.get("selectionDelegate"),e=this.get("contentDelegate").contentGroupIndexes(this,c),f;if(!this.get("isSelectable"))return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);if(a&&a.get("length")>0){if(e&&e.get("length")>0)a=a.copy().remove(e);a=d.collectionViewShouldSelectIndexes(this,a,b);if(!a||a.get("length")===0)return this}else a=null;f=b&&(f=this.get("selection"))?f.copy():SC.SelectionSet.create();if(a&&a.get("length")>0)a.get("length")===1?f.addObject(c.objectAt(a.get("firstObject"))):
f.add(c,a);(f=d.collectionViewSelectionForProposedSelection(this,f))||(f=SC.SelectionSet.create());this._selectionAnchor=null;this.set("selection",f.freeze());return this},deselect:function(a){var b=this.get("selection"),c=this.get("content"),d=this.get("selectionDelegate");if(!this.get("isSelectable"))return this;if(!b||b.get("length")===0)return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);a=d.collectionViewShouldDeselectIndexes(this,a);if(!a||a.get("length")===0)return this;b=b.copy().remove(c,
a);(b=d.collectionViewSelectionForProposedSelection(this,b))||(b=SC.SelectionSet.create());this.set("selection",b.freeze());return this},_findNextSelectableItemFromIndex:function(a,b){var c=this.get("length"),d=SC.IndexSet.create(),e=this.get("content"),f=this.get("selectionDelegate");e=this.get("contentDelegate").contentGroupIndexes(this,e);var g;if(!e&&f.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;for(;a<c;){if(!e||!e.contains(a)){d.add(a);if((g=f.collectionViewShouldSelectIndexes(this,
d))&&g.get("length")>=1)return a;d.remove(a)}a++}if(b===undefined)b=(a=this.get("selection"))?a.get("max"):-1;return b},_findPreviousSelectableItemFromIndex:function(a,b){var c=SC.IndexSet.create(),d=this.get("content"),e=this.get("selectionDelegate");d=this.get("contentDelegate").contentGroupIndexes(this,d);var f;if(SC.none(a))a=-1;if(!d&&e.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;for(;a>=0;){if(!d||!d.contains(a)){c.add(a);if((f=e.collectionViewShouldSelectIndexes(this,
c))&&f.get("length")>=1)return a;c.remove(a)}a--}if(b===undefined)b=(a=this.get("selection"))?a.get("min"):-1;if(SC.none(b))b=-1;return b},selectPreviousItem:function(a,b){if(SC.none(b))b=1;if(SC.none(a))a=false;var c=this.get("selection"),d=this.get("content");if(c)c=c.indexSetForSource(d);d=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var e=this._selectionAnchor;if(SC.none(e))e=d;if(a){if(c>e)c-=b;else d=this._findPreviousSelectableItemFromIndex(d-b);if(SC.none(d)||d<0)d=0;if(c<d)c=d}else{d=this._findPreviousSelectableItemFromIndex(d-
b);if(SC.none(d)||d<0)d=0;c=d;e=null}a=d;c=SC.IndexSet.create(d,c+1-d);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=e;return this},selectNextItem:function(a,b){if(SC.none(b))b=1;if(SC.none(a))a=false;var c=this.get("selection"),d=this.get("content");if(c)c=c.indexSetForSource(d);d=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var e=this._selectionAnchor,f=this.get("length");if(SC.none(e))e=d;if(a){if(d<e)d+=b;else c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=f)c=f-1;if(d>c)d=
c}else{c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=f)c=f-1;d=c;e=null}a=c;c=SC.IndexSet.create(d,c-d+1);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=e;return this},deleteSelection:function(){if(!this.get("canDeleteContent"))return NO;var a=this.get("selection"),b=this.get("content"),c=this.get("selectionDelegate");a=a&&b?a.indexSetForSource(b):null;if(!b||!a||a.get("length")===0)return NO;a=c.collectionViewShouldDeleteIndexes(this,a);if(!a||a.get("length")===0)return NO;
c.collectionViewDeleteContent(this,this.get("content"),a);return YES},scrollToContentIndex:function(a){(a=this.itemViewForContentIndex(a))&&this.scrollToItemView(a);return this},scrollToItemView:function(a){a&&a.scrollToVisible();return this},keyDown:function(a){a=this.interpretKeyEvents(a);return!a?NO:a},keyUp:function(){return true},insertText:function(a,b){if(a===" "){(a=this.get("selection"))&&a.get("length")>0&&this.invokeLater(this._cv_action,0,null,b);return YES}else return NO},selectAll:function(){var a=
this.get("content");this.select(a?SC.IndexSet.create(0,a.get("length")):null,NO);return YES},deleteBackward:function(){return this.deleteSelection()},deleteForward:function(){return this.deleteSelection()},moveDown:function(a,b){this.selectNextItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveUp:function(a,b){this.selectPreviousItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveLeft:function(a,
b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{b=this.get("selection");a=this.get("content");var c=b?b.indexSetForSource(a):null;if(c){b=undefined;var d=false,e=undefined;if(c.get("length")===1){e=c.get("firstObject");b=this.get("contentDelegate");if(b.contentIndexDisclosureState(this,a,e)!==SC.BRANCH_OPEN)d=true}if(d){c=b.contentIndexOutlineLevel(this,a,e)-1;if(c>=0){for(d=-1;d<0;){var f=this._findPreviousSelectableItemFromIndex(e-
1);if(f<0)return false;e=f;if(b.contentIndexOutlineLevel(this,a,e)===c)d=f}d!==-1&&this.select(e)}}else this.collapse(c)}}return true},moveRight:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{a=this.get("selection");b=this.get("content");(a=a?a.indexSetForSource(b):null)&&this.expand(a)}return true},moveDownAndModifySelection:function(a,b){this.selectNextItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,
b,this.ACTION_DELAY);return true},moveUpAndModifySelection:function(a,b){this.selectPreviousItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveLeftAndModifySelection:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(true,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},moveRightAndModifySelection:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(true,1);this._cv_performSelectAction(null,
b,this.ACTION_DELAY)}return true},insertNewline:function(){var a=this.get("isEditable")&&this.get("canEditContent"),b,c,d,e;if(a){b=this.get("selection");c=this.get("content");if(b&&b.get("length")===1){d=(a=b.indexSetForSource(c))?a.get("min"):-1;a=d>=0}}if(a)a=(e=this.itemViewForContentIndex(d))&&SC.typeOf(e.beginEditing)===SC.T_FUNCTION;if(a){this.scrollToContentIndex(d);e=this.itemViewForContentIndex(d);e.beginEditing()}else this.invokeLater(this._cv_action,0,e,null);return YES},mouseDown:function(a){if(this.get("useToggleSelection"))return true;
var b=this.itemViewForEvent(a),c=this.get("content"),d=b?b.get("contentIndex"):-1,e;e=this.mouseDownInfo={event:a,itemView:b,contentIndex:d,at:Date.now()};this.becomeFirstResponder();if(!b){this.get("allowDeselectAll")&&this.select(null,false);return YES}b=this.get("selection");var f;if(b)b=b.indexSetForSource(c);c=b?b.contains(d):NO;if((e.modifierKeyPressed=f=a.ctrlKey||a.metaKey)&&c)e.shouldDeselect=d>=0;else if(a.shiftKey&&b&&b.get("length")>0){b=this._findSelectionExtendedByShift(b,d);a=this._selectionAnchor;
this.select(b);this._selectionAnchor=a}else if(!f&&c)e.shouldReselect=d>=0;else if(this.get("selectOnMouseDown"))this.select(d,f);else e.shouldSelect=d>=0;e.previousContentIndex=d;return YES},mouseUp:function(a){var b=this.itemViewForEvent(a),c=this.mouseDownInfo,d,e;if(this.get("useToggleSelection")){if(!b)return;c=this.get("selection");d=b?b.get("contentIndex"):-1;(c=c&&c.include(d))?this.deselect(d):this.select(d,YES)}else if(c){d=c.contentIndex;b&&b.get("contentIndex");c.shouldSelect&&this.select(d,
c.modifierKeyPressed);c.shouldDeselect&&this.deselect(d);if(c.shouldReselect){if(c=this.get("isEditable")&&this.get("canEditContent"))c=(c=this.get("selection"))&&c.get("length")===1;if(c)c=(c=(e=this.itemViewForContentIndex(d))&&(!e.contentHitTest||e.contentHitTest(a)))&&e.beginEditing?e.beginEditing():NO;if(!c){this._cv_reselectTimer&&this._cv_reselectTimer.invalidate();this._cv_reselectTimer=this.invokeLater(this.select,300,d,false)}}this._cleanupMouseDown()}this._cv_performSelectAction(b,a,0,
a.clickCount);return NO},_cleanupMouseDown:function(){var a=this.mouseDownInfo,b;if(a)for(b in a)a.hasOwnProperty(b)&&delete a[b];this.mouseDownInfo=null},mouseMoved:function(a){var b=this.itemViewForEvent(a),c=this._lastHoveredItem;if(b!==c){c&&c.mouseOut&&c.mouseOut(a);b&&b.mouseOver&&b.mouseOver(a)}(this._lastHoveredItem=b)&&b.mouseMoved&&b.mouseMoved(a);return YES},mouseOut:function(a){var b=this._lastHoveredItem;this._lastHoveredItem=null;b&&b.mouseOut&&b.mouseOut(a);return YES},_findSelectionExtendedByShift:function(a,
b){if(!a||a.get("length")===0)return SC.IndexSet.create(b);this.get("content").get("length");var c=a.get("min");a=a.get("max")-1;var d=this._selectionAnchor;if(SC.none(d))d=-1;if(b<c){c=b;if(d<0)this._selectionAnchor=a}else if(b>a){a=b;if(d<0)this._selectionAnchor=c}else if(b>=c&&b<=a){if(d<0)this._selectionAnchor=d=c;if(b===d)c=a=b;else if(b>d){c=d;a=b}else if(b<d){c=b;a=d}}return SC.IndexSet.create(c,a-c+1)},reorderDataType:function(){return"SC.CollectionView.Reorder.%@".fmt(SC.guidFor(this))}.property().cacheable(),
dragContent:null,proposedInsertionIndex:null,proposedDropOperation:null,mouseDragged:function(){var a=this.get("selectionDelegate"),b=this.get("content"),c=this.get("selection"),d=this.mouseDownInfo,e=this.get("contentDelegate").contentGroupIndexes(this,b);if(!d||d.contentIndex<0)return YES;if(Date.now()-d.at<123)return YES;if(a.collectionViewShouldBeginDrag(this)){if((c=this.get("selectOnMouseDown")?c?c.indexSetForSource(b):null:SC.IndexSet.create(d.contentIndex))&&e&&e.get("length")>0){c=c.copy().remove(e);
if(c.get("length")===0)c=null;else c.freeze()}if(c)c=c.frozenCopy();else return YES;c={content:b,indexes:c};this.set("dragContent",c);if((b=this.get("dragDataTypes"))&&b.get("length")>0){(b=a.collectionViewDragViewFor(this,c.indexes))||(b=this._cv_dragViewFor(c.indexes));b.createLayer();SC.Drag.start({event:d.event,source:this,dragView:b,ghost:NO,ghostActsLikeCursor:a.ghostActsLikeCursor,slideBack:YES,dataSource:this});this._cleanupMouseDown();this._lastInsertionIndex=null}else this.set("dragContent",
null);return YES}},_cv_dragViewFor:function(a){a=this.get("nowShowing").without(a);a=this.get("nowShowing").without(a);var b=this.get("layer").cloneNode(false),c=SC.View.create({layer:b,parentView:this});SC.$(b).css("backgroundColor","transparent").css("border","none").css("top",0).css("left",0);a.forEach(function(d){d=this.itemViewForContentIndex(d);var e,f;if(d){e=d.get("isSelected");d.set("isSelected",NO);d.updateLayerIfNeeded();if(f=d.get("layer"))f=f.cloneNode(true);d.set("isSelected",e);d.updateLayerIfNeeded()}f&&
b.appendChild(f)},this);b=null;return c},dragDataTypes:function(){var a=this.get("selectionDelegate").collectionViewDragDataTypes(this),b;if(this.get("canReorderContent")){a=a?a.copy():[];b=this.get("reorderDataType");a.indexOf(b)<0&&a.push(b)}return a?a:[]}.property(),dragDataForType:function(a,b){if(this.get("canReorderContent"))if(b===this.get("reorderDataType"))return this.get("dragContent");return this.get("selectionDelegate").collectionViewDragDataForType(this,a,b)},computeDragOperations:function(a){var b=
SC.DRAG_NONE,c=this.get("selectionDelegate");if(this.get("canReorderContent"))if(a.get("dataTypes").indexOf(this.get("reorderDataType"))>=0)b=SC.DRAG_REORDER;b=c.collectionViewComputeDragOperations(this,a,b);if(b&SC.DRAG_REORDER)b=SC.DRAG_MOVE;return b},_computeDropOperationState:function(a,b,c){var d=this.convertFrameFromView(a.get("location"),null);b=SC.DROP_BEFORE;var e=this.get("selectionDelegate"),f=this.get("canReorderContent"),g,h,i=this.insertionIndexForLocation(d,SC.DROP_ON);if(SC.typeOf(i)===
SC.T_ARRAY){b=i[1];i=i[0]}if(b===SC.DROP_ON){this.set("proposedInsertionIndex",i);this.set("proposedDropOperation",b);g=e.collectionViewValidateDragOperation(this,a,c,i,b);i=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;if(g!==SC.DRAG_NONE)return[i,b,g];else{b=SC.DROP_BEFORE;i=this.insertionIndexForLocation(d,SC.DROP_BEFORE);if(SC.typeOf(i)===SC.T_ARRAY){b=i[1];i=i[0]}}}if(i>=0&&f&&b!==SC.DROP_ON)if(d=a.dataForType(this.get("reorderDataType"))){f=
this.get("content");if(b===SC.DROP_BEFORE){g=d.indexes.contains(i-1);h=d.indexes.contains(i)}else{g=d.indexes.contains(i);h=d.indexes.contains(i-1)}if(g&&h)if(SC.none(this._lastInsertionIndex))if(b===SC.DROP_BEFORE)for(;i>=0&&d.indexes.contains(i);)i--;else for(f=f?f.get("length"):0;i<f&&d.indexes.contains(i);)i++;else i=this._lastInsertionIndex;if(i>=0)c=SC.DRAG_REORDER}this.set("proposedInsertionIndex",i);this.set("proposedDropOperation",b);c=e.collectionViewValidateDragOperation(this,a,c,i,b);
i=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;return[i,b,c]},dragUpdated:function(a,b){var c=a.get("allowedDragOperations");c=this._computeDropOperationState(a,b,c);a=c[0];b=c[1];c=c[2];if(c!==SC.DRAG_NONE){if(this._lastInsertionIndex!==a||this._lastDropOperation!==b)this.showInsertionPoint(this.itemViewForContentIndex(a),b);this._lastInsertionIndex=a;this._lastDropOperation=b}else{this.hideInsertionPoint();this._lastInsertionIndex=
this._lastDropOperation=null}return c&SC.DRAG_REORDER?SC.DRAG_MOVE:c},dragExited:function(){this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null},acceptDragOperation:function(){return YES},performDragOperation:function(a,b){var c=this._computeDropOperationState(a,null,b),d=c[0],e=c[1];c=c[2];var f=this.get("selectionDelegate"),g,h,i;if(c&SC.DRAG_REORDER)b=b&SC.DRAG_MOVE?SC.DRAG_REORDER:SC.DRAG_NONE;else b&=c;if(b===SC.DRAG_NONE)return b;if(f.collectionViewPerformDragOperation(this,
a,b,d,e)===SC.DRAG_NONE&&b&SC.DRAG_REORDER){a=a.dataForType(this.get("reorderDataType"));if(!a)return SC.DRAG_NONE;h=this.get("content");b=a.indexes;if(b.get("length")===1)if((e===SC.DROP_BEFORE||e===SC.DROP_AFTER)&&b.get("min")===d)return SC.DRAG_MOVE;h.beginPropertyChanges();g=[];i=0;a.indexes.forEach(function(j){g.push(h.objectAt(j-i));h.removeAt(j-i);i++;j<d&&d--},this);e===SC.DROP_AFTER&&d++;h.replace(d,0,g,e);this.select(SC.IndexSet.create(d,g.length));h.endPropertyChanges();b=SC.DRAG_MOVE}return b},
collectionViewShouldBeginDrag:function(){return this.get("canReorderContent")},insertionIndexForLocation:function(){return-1},_cv_isVisibleInWindowDidChange:function(){if(this.get("isVisibleInWindow")){this._invalidIndexes&&this.invokeOnce(this.reloadIfNeeded);this._invalidSelection&&this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}}.observes("isVisibleInWindow"),collectionViewShouldSelectItem:function(){return this.get("isSelectable")},_TMP_DIFF1:SC.IndexSet.create(),_TMP_DIFF2:SC.IndexSet.create(),
_cv_nowShowingDidChange:function(){var a=this.get("nowShowing"),b=this._sccv_lastNowShowing,c,d,e;if(b!==a)if(b&&a){d=this._TMP_DIFF1.add(b).remove(a);e=this._TMP_DIFF2.add(a).remove(b);c=d.add(e)}else c=b||a;if(c&&c.get("length")>0){this._sccv_lastNowShowing=a?a.frozenCopy():null;this.updateContentRangeObserver();this.reload(c)}d&&d.clear();e&&e.clear()}.observes("nowShowing"),init:function(){arguments.callee.base.apply(this,arguments);this.get("canReorderContent")&&this._cv_canReorderContentDidChange();
this._sccv_lastNowShowing=this.get("nowShowing").clone();this.content&&this._cv_contentDidChange();this.selection&&this._cv_selectionDidChange()},_cv_canReorderContentDidChange:function(){if(this.get("canReorderContent")){this.get("isDropTarget")||this.set("isDropTarget",YES);SC.Drag.addDropTarget(this)}}.observes("canReorderContent"),_cv_performSelectAction:function(a,b,c,d){if(c===undefined)c=0;if(d===undefined)d=1;if(d>1||this.get("actOnSelect")){this._cv_reselectTimer&&this._cv_reselectTimer.invalidate();
d=(d=this.get("selection"))?d.toArray():[];this._cv_actionTimer&&this._cv_actionTimer.invalidate();this._cv_actionTimer=this.invokeLater(this._cv_action,c,a,b,d)}},_cv_action:function(a,b,c){var d=this.get("action"),e=this.get("target")||null;this._cv_actionTimer=null;if(d){if(SC.typeOf(d)===SC.T_FUNCTION)return this.action(a,b);(a=this.get("pane"))&&a.rootResponder.sendAction(d,e,this,a,c)}else if(a)if(SC.typeOf(a._action)==SC.T_FUNCTION)return a._action(b);else if(SC.typeOf(a.action)==SC.T_FUNCTION)return a.action(b)}});
SC.DisclosureView=SC.ButtonView.extend({classNames:["sc-disclosure-view"],theme:"disclosure",buttonBehavior:SC.TOGGLE_BEHAVIOR,toggleOnValue:YES,toggleOffValue:NO,valueBindingDefault:SC.Binding.bool(),render:function(a,b){if(b){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="button" alt="" />');this.get("needsEllipsis")?a.push('<label class="ellipsis">',this.get("displayTitle"),"</label>"):a.push("<label>",this.get("displayTitle"),"</label>")}else this.$("label")[0].text=this.get("displayTitle")},
keyDown:function(a){if(a.which===37||a.which===38){this.set("value",this.get("toggleOffValue"));return YES}if(a.which===39||a.which===40){this.set("value",this.get("toggleOnValue"));return YES}arguments.callee.base.apply(this,arguments)}});sc_require("views/collection");sc_require("mixins/collection_row_delegate");
SC.ListView=SC.CollectionView.extend(SC.CollectionRowDelegate,{classNames:["sc-list-view"],acceptsFirstResponder:YES,showAlternatingRows:NO,render:function(a){a.setClass("alternating",this.get("showAlternatingRows"));return arguments.callee.base.apply(this,arguments)},rowDelegate:function(){var a=this.delegate,b=this.get("content");return this.delegateFor("isCollectionRowDelegate",a,b)}.property("delegate","content").cacheable(),_sclv_rowDelegateDidChange:function(){var a=this._sclv_rowDelegate,b=
this.get("rowDelegate"),c=this._sclv_rowHeightDidChange,d=this._sclv_customRowHeightIndexesDidChange;if(a===b)return this;this._sclv_rowDelegate=b;if(a){a.removeObserver("rowHeight",this,c);a.removeObserver("customRowHeightIndexes",this,d)}if(!b)throw"Internal Inconsistancy: ListView must always have CollectionRowDelegate";b.addObserver("rowHeight",this,c);b.addObserver("customRowHeightIndexes",this,d);this._sclv_rowHeightDidChange()._sclv_customRowHeightIndexesDidChange();return this}.observes("rowDelegate"),
_sclv_rowHeightDidChange:function(){var a=this.get("rowDelegate").get("rowHeight");if(a===this._sclv_rowHeight)return this;this._sclv_rowHeight=a;this.rowHeightDidChangeForIndexes(SC.IndexSet.create(0,this.get("length")));return this},_sclv_customRowHeightIndexesDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes,c=this._sclv_customRowHeightIndexesContentDidChange;if(a===b||b&&b.isEqual(a))return this;b&&this._sclv_isObservingCustomRowHeightIndexes&&
b.removeObserver("[]",this,c);if(this._sclv_isObservingCustomRowHeightIndexes=a&&!a.get("isFrozen"))a.addObserver("[]",this,c);this._sclv_customRowHeightIndexesContentDidChange();return this},_sclv_customRowHeightIndexesContentDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes;b=a&&b?a.copy().add(b):a||b;this._sclv_customRowHeightIndexes=a?a.frozenCopy():null;this.rowHeightDidChangeForIndexes(b);return this},rowOffsetForContentIndex:function(a){if(a===
0)return 0;var b=this.get("rowDelegate"),c=b.get("rowHeight"),d,e,f,g,h;d=a*c;if(this.get("rowSpacing"))d+=a*this.get("rowSpacing");if(b.customRowHeightIndexes&&(e=b.get("customRowHeightIndexes"))){f=this._sclv_offsetCache;if(!f){f=this._sclv_offsetCache=[];g=h=0;e.forEach(function(i){g+=this.rowHeightForContentIndex(i)-c;f[i+1]=g;h=i},this);this._sclv_max=h+1}g=f[a];if(g===undefined){g=f[a]=f[a-1];if(g===undefined){h=this._sclv_max;if(a<h)h=e.indexBefore(a)+1;g=f[a]=f[h]||0}}d+=g}return d},rowHeightForContentIndex:function(a){var b=
this.get("rowDelegate"),c,d,e;if(b.customRowHeightIndexes&&(e=b.get("customRowHeightIndexes"))){c=this._sclv_heightCache;if(!c){c=this._sclv_heightCache=[];d=this.get("content");e.forEach(function(f){c[f]=b.contentIndexRowHeight(this,d,f)},this)}a=c[a];if(a===undefined)a=b.get("rowHeight")}else a=b.get("rowHeight");return a},rowHeightDidChangeForIndexes:function(a){var b=this.get("length");this._sclv_heightCache=this._sclv_offsetCache=null;if(a&&a.isIndexSet)a=a.get("min");this.reload(SC.IndexSet.create(a,
b-a));return this},computeLayout:function(){var a=this._sclv_layout;if(!a)a=this._sclv_layout={};a.minHeight=this.rowOffsetForContentIndex(this.get("length"))+4;this.set("calculatedHeight",a.minHeight);return a},layoutForContentIndex:function(a){return{top:this.rowOffsetForContentIndex(a),height:this.rowHeightForContentIndex(a),left:0,right:0}},contentIndexesInRect:function(a){var b=this.get("rowDelegate").get("rowHeight"),c=SC.minY(a),d=SC.maxY(a),e=a.height||0;a=this.get("length");var f,g;g=(c-
c%b)/b;for(f=this.rowOffsetForContentIndex(g);g>0&&f>=c;){g--;f-=this.rowHeightForContentIndex(g)}for(f+=this.rowHeightForContentIndex(g);g<a&&f<c;){f+=this.rowHeightForContentIndex(g);g++}if(g<0)g=0;if(g>=a)g=a;b=g+(e-e%b)/b;if(b>a)b=a;for(f=this.rowOffsetForContentIndex(b);b>=g&&f>=d;){b--;f-=this.rowHeightForContentIndex(b)}for(f+=this.rowHeightForContentIndex(b);b<a&&f<=d;){f+=this.rowHeightForContentIndex(b);b++}b++;if(b<g)b=g;if(b>a)b=a;return SC.IndexSet.create(g,b-g)},insertionPointView:SC.View.extend({classNames:"sc-list-insertion-point",
render:function(a,b){b&&a.push('<div class="anchor"></div>')}}),showInsertionPoint:function(a,b){var c=this._insertionPointView;if(!c)c=this._insertionPointView=this.get("insertionPointView").create();var d=a.get("contentIndex"),e=this.get("length"),f=SC.clone(a.get("layout")),g=a.get("outlineLevel"),h=a.get("outlineIndent")||0;if(d>=e&&d>0){d=this.itemViewForContentIndex(e-1);if(d.get("isGroupView")){g=1;h=d.get("outlineIndent")}}if(SC.none(g))g=-1;if(b&SC.DROP_ON){this.hideInsertionPoint();a.set("isSelected",
YES);this._lastDropOnView=a}else{if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}if(b&SC.DROP_AFTER)f.top+=f.height;f.height=2;f.right=0;f.left=(g+1)*h+12;delete f.width;c.set("layout",f);this.appendChild(c)}},hideInsertionPoint:function(){if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}var a=this._insertionPointView;a&&a.removeFromParent().destroy();this._insertionPointView=null},insertionIndexForLocation:function(a,
b){var c=this.contentIndexesInRect(a).get("min"),d=this.get("length"),e,f,g;if(SC.none(c)||c<0)if(d===0||a.y<=this.rowOffsetForContentIndex(0))c=0;else if(a.y>=this.rowOffsetForContentIndex(d))c=d;e=this.rowOffsetForContentIndex(c);f=e+this.rowHeightForContentIndex(c);if(b==SC.DROP_ON){g=this.get("isEditable")?Math.min(Math.floor((f-e)*0.2),5):0;if(a.y>=e+g||a.y<=f+g)return[c,SC.DROP_ON]}c<d&&a.y>=f-10&&c++;if(c>0){f=((g=this.itemViewForContentIndex(c-1))?g.get("outlineIndent"):0)||0;e=g?g.get("outlineLevel"):
0;if(c<d){a=(g=this.itemViewForContentIndex(c))?g.get("outlineLevel"):0;g=(g?g.get("outlineIndent"):0)||0;g*=a}else{a=g.get("isGroupView")?1:0;g=f*a}f*=e;if(a!==e&&g!==f)if(f>g){c--;b=SC.DROP_AFTER}}if(b===SC.DROP_BEFORE){g=c<d?this.itemViewForContentIndex(c):null;if(!g||g.get("isGroupView"))if(c>0){g=this.itemViewForContentIndex(c-1);if(!g.get("isGroupView")||g.get("disclosureState")===SC.BRANCH_OPEN){c-=1;b=SC.DROP_AFTER}else c=-1}else c=-1;if(c<0)b=SC.DRAG_NONE}return[c,b]},init:function(){arguments.callee.base.apply(this,
arguments);this._sclv_rowDelegateDidChange()}});sc_require("views/list");
SC.GridView=SC.ListView.extend({classNames:["sc-grid-view"],layout:{left:0,right:0,top:0,bottom:0},rowHeight:48,columnWidth:64,exampleView:SC.LabelView,insertionOrientation:SC.HORIZONTAL_ORIENTATION,itemsPerRow:function(){var a=this.get("frame"),b=this.get("columnWidth")||0;return b<=0?1:Math.floor(a.width/b)}.property("clippingFrame","columnWidth").cacheable(),contentIndexesInRect:function(a){var b=this.get("rowHeight")||48,c=this.get("itemsPerRow"),d=Math.floor(SC.minY(a)/b)*c;a=Math.ceil(SC.maxY(a)/
b)*c;return SC.IndexSet.create(d,a-d)},layoutForContentIndex:function(a){var b=this.get("rowHeight")||48,c=this.get("clippingFrame").width,d=this.get("itemsPerRow");c=Math.floor(c/d);var e=Math.floor(a/d);return{left:(a-d*e)*c,top:e*b,height:b,width:c}},computeLayout:function(){var a=this.get("content"),b=a?a.get("length"):0;a=this.get("rowHeight")||48;var c=this.get("itemsPerRow");b=Math.ceil(b/c);c=this._cachedLayoutHash;if(!c)c=this._cachedLayoutHash={};c.minHeight=b*a;this.calculatedHeight=c.minHeight;
return c},insertionPointClass:SC.View.extend({classNames:["grid-insertion-point"],render:function(a,b){b&&a.push('<span class="anchor"></span>')}}),showInsertionPoint:function(a,b){if(a)if(b===SC.DROP_ON){if(a!==this._dropOnInsertionPoint){this.hideInsertionPoint();a.addClassName("drop-target");this._dropOnInsertionPoint=a}}else{if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}if(!this._insertionPointView)this._insertionPointView=
this.insertionPointClass.create();b=this._insertionPointView;var c=a.get("frame");c={height:c.height-6,x:c.x,y:c.y+6,width:0};SC.rectsEqual(b.get("frame"),c)||b.set("frame",c);b.parentNode!=a.parentNode&&a.parentNode.appendChild(b)}},hideInsertionPoint:function(){var a=this._insertionPointView;a&&a.removeFromParent();if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}},insertionIndexForLocation:function(a,b){var c=this.get("frame"),
d=this.get("scrollFrame"),e=this.get("itemsPerRow"),f=Math.floor(c.width/e),g=Math.floor((a.y-c.y-d.y)/this.get("rowHeight")),h=SC.DROP_BEFORE;c=a.x-c.x-d.x;a=Math.floor(c/f);f=c/f-a;if(b===SC.DROP_ON){f>0.8&&a++;if(f>=0.2&&f<=0.8)h=SC.DROP_ON}else f>0.45&&a++;return[g*e+a,h]},_gv_clippingFrameDidChange:function(){var a=this.get("nowShowing"),b,c;this.notifyPropertyChange("itemsPerRow");c=a.get("length");for(b=0;b<c;b++){a=this.itemViewForContentIndex(b);a.adjust(this.layoutForContentIndex(b))}}.observes("clippingFrame")});
SC.ScrollerView=SC.View.extend({classNames:["sc-scroller-view"],scrollerThickness:function(){var a=document.createElement("div"),b;a.style.position="absolute";a.style.left="-4000px";a.style.width="200px";a.style.overflow="scroll";document.body.appendChild(a);b=200-a.clientWidth;document.body.removeChild(a);return b}.property().cacheable(),value:function(a,b){if(b!==undefined){if(b>=0)this._value=b}else return Math.min(this._value||0,this.get("maximum"))}.property("maximum").cacheable(),maximum:0,
isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,ownerScrollValueKey:function(){var a=null;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a="verticalScrollOffset";break;case SC.LAYOUT_HORIZONTAL:a="horizontalScrollOffset";break;default:a=null}return a}.property("layoutDirection").cacheable(),displayProperties:"maximum isEnabled layoutDirection".w(),render:function(a,b){var c=this.get("maximum");switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.addClass("sc-vertical");if(b)a.push('<div class="sc-inner" style="height: %@px;">&nbsp;</div>'.fmt(c));
else this.$("div")[0].style.height=c+"px";break;case SC.LAYOUT_HORIZONTAL:a.addClass("sc-horizontal");if(b)a.push('<div class="sc-inner" style="width: %@px;">&nbsp;</div>'.fmt(c));else this.$("div")[0].style.width=c+"px";break;default:throw"You must set a layoutDirection for your scroller class.";}a.setClass("disabled",!this.get("isEnabled"))},didCreateLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.add(this.$(),"scroll",this,a);a=this.get("value");var b=this.get("layer");switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:b.scrollTop=
a;break;case SC.LAYOUT_HORIZONTAL:b.scrollLeft=a;break}},willDestroyLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.remove(this.$(),"scroll",this,a)},_sc_scroller_armScrollTimer:function(){if(!this._sc_scrollTimer){SC.RunLoop.begin();this._sc_scrollTimer=this.invokeLater(this._sc_scroller_scrollDidChange,50);SC.RunLoop.end()}},_sc_scroller_scrollDidChange:function(){var a=Date.now(),b=this._sc_lastScroll;if(b&&a-b<50)return this._sc_scroller_armScrollTimer();this._sc_scrollTimer=
null;this._sc_lastScroll=a;SC.RunLoop.begin();if(this.get("isEnabled")){a=this.get("layer");b=0;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:this._sc_scrollValue=b=a.scrollTop;break;case SC.LAYOUT_HORIZONTAL:this._sc_scrollValue=b=a.scrollLeft;break}this.set("value",b);SC.RunLoop.end()}},_sc_scroller_valueDidChange:function(){var a=this.get("value");if(a!==this._sc_scrollValue){var b=this.get("layer");if(b)switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:b.scrollTop=a;break;
case SC.LAYOUT_HORIZONTAL:b.scrollLeft=a;break}}}.observes("value")});sc_require("views/scroller");sc_require("mixins/border");
SC.ScrollView=SC.View.extend(SC.Border,{classNames:["sc-scroll-view"],isScrollable:YES,contentView:null,horizontalScrollOffset:0,verticalScrollOffset:0,maximumHorizontalScrollOffset:function(){if(!this.get("canScrollHorizontal"))return 0;var a=this.get("contentView"),b=a?a.get("frame").width:0;if(a.calculatedWidth&&a.calculatedWidth!==0)b=a.calculatedWidth;a=this.get("containerView").get("frame").width;return Math.max(0,b-a)}.property(),maximumVerticalScrollOffset:function(){if(!this.get("canScrollVertical"))return 0;
var a=this.get("contentView"),b=a&&a.get("frame")?a.get("frame").height:0;if(a.calculatedHeight&&a.calculatedHeight!==0)b=a.calculatedHeight;a=this.get("containerView").get("frame").height;return Math.max(0,b-a)}.property(),verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("frame").height}.property("frame"),horizontalPageScroll:function(){return this.get("frame").width}.property("frame"),hasHorizontalScroller:YES,horizontalScrollerView:SC.ScrollerView,isHorizontalScrollerVisible:YES,
canScrollHorizontal:function(){return!!(this.get("hasHorizontalScroller")&&this.get("horizontalScrollerView")&&this.get("isHorizontalScrollerVisible"))}.property("isHorizontalScrollerVisible").cacheable(),autohidesHorizontalScroller:YES,hasVerticalScroller:YES,verticalScrollerView:SC.ScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:function(){return!!(this.get("hasVerticalScroller")&&this.get("verticalScrollerView")&&this.get("isVerticalScrollerVisible"))}.property("isVerticalScrollerVisible").cacheable(),
autohidesVerticalScroller:YES,verticalScrollerBottom:0,containerView:SC.ContainerView,scrollTo:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}if(!SC.none(a)){a=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),a));this.set("horizontalScrollOffset",a)}if(!SC.none(b)){b=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),b));this.set("verticalScrollOffset",b)}return this},scrollBy:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}a=a?this.get("horizontalScrollOffset")+
a:null;b=b?this.get("verticalScrollOffset")+b:null;return this.scrollTo(a,b)},scrollToVisible:function(a){if(arguments.length===0)return arguments.callee.base.apply(this,arguments);var b=this.get("contentView");if(!b)return NO;var c=a.get("frame");if(!c)return NO;c=b.convertFrameFromView(c,a.get("parentView"));b=SC.cloneRect(this.get("containerView").get("frame"));b.x=this.get("horizontalScrollOffset");b.y=this.get("verticalScrollOffset");var d=b.x,e=b.y;b.y-=Math.max(0,SC.minY(b)-SC.minY(c));b.x-=
Math.max(0,SC.minX(b)-SC.minX(c));b.y+=Math.max(0,SC.maxY(c)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(c)-SC.maxX(b));if(d!==b.x||e!==b.y){this.scrollTo(b.x,b.y);return YES}else return NO},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalLineScroll")*a)},scrollUpLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalLineScroll")*a)},scrollRightLine:function(a){if(a===undefined)a=1;return this.scrollTo(this.get("horizontalLineScroll")*
a,null)},scrollLeftLine:function(a){if(a===undefined)a=1;return this.scrollTo(0-this.get("horizontalLineScroll")*a,null)},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalPageScroll")*a)},scrollUpPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalPageScroll")*a)},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollBy(this.get("horizontalPageScroll")*a,null)},scrollLeftPage:function(a){if(a===undefined)a=1;return this.scrollBy(0-
this.get("horizontalPageScroll")*a,null)},tile:function(){var a=this.get("hasHorizontalScroller")?this.get("horizontalScrollerView"):null,b=a&&this.get("isHorizontalScrollerVisible"),c=this.get("hasVerticalScroller")?this.get("verticalScrollerView"):null,d=c&&this.get("isVerticalScrollerVisible"),e=this.get("containerView"),f={left:0,top:0},g=b?a.get("scrollerThickness"):0,h=d?c.get("scrollerThickness"):0;if(b){a.set("layout",{left:0,bottom:0,right:h-1,height:g});f.bottom=g-1}else f.bottom=0;a&&a.set("isVisible",
b);if(d){g+=this.get("verticalScrollerBottom");c.set("layout",{top:0,bottom:g,right:0,width:h});f.right=h-1}else f.right=0;c&&c.set("isVisible",d);e.set("layout",f)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible","isHorizontalScrollerVisible"),_scroll_wheelDeltaX:0,_scroll_wheelDeltaY:0,mouseWheel:function(a){this._scroll_wheelDeltaX+=a.wheelDeltaX;this._scroll_wheelDeltaY+=a.wheelDeltaY;this.invokeLater(this._scroll_mouseWheel,10);return this.get("canScrollHorizontal")||
this.get("canScrollVertical")},_scroll_mouseWheel:function(){this.scrollBy(this._scroll_wheelDeltaX,this._scroll_wheelDeltaY);this._scroll_wheelDeltaX=this._scroll_wheelDeltaY=0},createChildViews:function(){var a=[],b;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView}));this.contentView=this.containerView.get("contentView");if(b=this.horizontalScrollerView)if(this.get("hasHorizontalScroller")){b=this.horizontalScrollerView=
this.createChildView(b,{layoutDirection:SC.LAYOUT_HORIZONTAL,valueBinding:"*owner.horizontalScrollOffset"});a.push(b)}else this.horizontalScrollerView=null;if(b=this.verticalScrollerView)if(this.get("hasVerticalScroller")){b=this.verticalScrollerView=this.createChildView(b,{layoutDirection:SC.LAYOUT_VERTICAL,valueBinding:"*owner.verticalScrollOffset"});a.push(b)}else this.verticalScrollerView=null;this.childViews=a;this.contentViewDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,
arguments);var a=this._scroll_contentView=this.get("contentView");a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),contentViewDidChange:function(){var a=this.get("contentView"),b=this._scroll_contentView,c=this.contentViewFrameDidChange;if(a!==b){b&&b.removeObserver("frame",
this,c);(this._scroll_contentView=a)&&a.addObserver("frame",this,c);this.containerView.set("contentView",a);this.contentViewFrameDidChange()}}.observes("contentView"),oldMaxHOffset:0,oldMaxVOffset:0,contentViewFrameDidChange:function(){var a=this.get("contentView"),b=a?a.get("frame"):null,c=b?b.width:0;b=b?b.height:0;var d=this.get("frame");this._scroll_contentWidth=c;this._scroll_contentHeight=b;if(this.get("hasHorizontalScroller")&&(a=this.get("horizontalScrollerView"))){c-=1;this.get("autohidesHorizontalScroller")&&
this.set("isHorizontalScrollerVisible",c>d.width);a.setIfChanged("maximum",c)}if(this.get("hasVerticalScroller")&&(a=this.get("verticalScrollerView"))){b-=1;this.get("autohidesVerticalScroller")&&this.set("isVerticalScrollerVisible",b>d.height);b-=this.get("verticalScrollerBottom");a.setIfChanged("maximum",b)}!this.get("isVerticalScrollerVisible")&&this.get("verticalScrollOffset")!==0&&this.get("autohidesVerticalScroller")&&this.set("verticalScrollOffset",0);!this.get("isHorizontalScrollerVisible")&&
this.get("horizontalScrollOffset")!==0&&this.get("autohidesHorizontalScroller")&&this.set("horizontalScrollOffset",0);d=this.get("maximumVerticalScrollOffset");a=this.get("verticalScrollOffset");b=this.get("maximumHorizontalScrollOffset");c=this.get("horizontalScrollOffset");d=d<a;b=b<c;if(d||b)this.forceDimensionsRecalculation(b,d,a,c)},_scroll_horizontalScrollOffsetDidChange:function(){var a=this.get("horizontalScrollOffset");a=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),a));var b=
this.get("contentView");b&&b.adjust("left",0-a)}.observes("horizontalScrollOffset"),_scroll_verticalScrollOffsetDidChange:function(){var a=this.get("verticalScrollOffset");a=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),a));var b=this.get("contentView");this.get("containerView");b&&b.adjust("top",0-a)}.observes("verticalScrollOffset"),forceDimensionsRecalculation:function(a,b,c,d){this.scrollTo(0,0);a&&b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),this.get("maximumVerticalScrollOffset"));
a&&!b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),c);!a&&b&&this.scrollTo(d,this.get("maximumVerticalScrollOffset"))}});sc_require("views/scroll");
SC.MenuScrollerView=SC.ScrollerView.extend({classNames:["sc-menu-scroller-view"],scrollDown:NO,value:function(a,b){if(b!==undefined)this._value=b;else return Math.min(this._value||0,this.get("maximum"))}.property("maximum").cacheable(),maximum:0,isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,verticalLineScroll:20,ownerScrollValueKey:function(){return"verticalScrollOffset"}.property("layoutDirection").cacheable(),render:function(a,b){a.addClass("sc-vertical");if(b)this.get("scrollDown")?a.push('<span class="arrowDown">&nbsp;</span>'):
a.push('<span class="arrowUp">&nbsp;</span>');a.setClass("disabled",!this.get("isEnabled"))},didCreateLayer:function(){var a;a=this._sc_scroller_scrollDidChange;SC.Event.add(this.$(),"scroll",this,a);a=this.get("value");this.get("layer").scrollTop=a},willDestroyLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.remove(this.$(),"scroll",this,a)},mouseEntered:function(){this.set("isMouseOver",YES);this._invokeScrollOnMouseOver()},mouseExited:function(){this.set("isMouseOver",NO)},_sc_scroller_valueDidChange:function(){}.observes("value"),
_sc_scroller_armScrollTimer:function(){if(!this._sc_scrollTimer){SC.RunLoop.begin();this._sc_scrollTimer=this.invokeLater(this._sc_scroller_scrollDidChange,50);SC.RunLoop.end()}},_sc_scroller_scrollDidChange:function(){var a=Date.now(),b=this._sc_lastScroll,c=this.get("layer"),d=0;if(b&&a-b<50)return this._sc_scroller_armScrollTimer();this._sc_scrollTimer=null;this._sc_lastScroll=a;SC.RunLoop.begin();if(this.get("isEnabled")){this._sc_scrollValue=d=c.scrollTop;this.set("value",d);SC.RunLoop.end()}},
_scrollMenu:function(){var a=this.get("value"),b;if(this.get("scrollDown")){b=a+this.verticalLineScroll;b<=this.get("maximum")&&this.set("value",b)}else{b=a-this.verticalLineScroll;if(b>=0)this.set("value",b);else a<=this.verticalLineScroll&&a>0&&this.set("value",0)}return YES},_invokeScrollOnMouseOver:function(){this._scrollMenu();this.get("isMouseOver")&&this.invokeLater(this._invokeScrollOnMouseOver,50)}});
SC.MenuScrollView=SC.ScrollView.extend({classNames:["sc-menu-scroll-view"],maximumHorizontalScrollOffset:function(){}.property(),hasHorizontalScroller:NO,horizontalScrollerView:SC.MenuScrollerView,isHorizontalScrollerVisible:NO,canScrollHorizontal:function(){return false}.property("isHorizontalScrollerVisible").cacheable(),autohidesHorizontalScroller:NO,hasVerticalScroller:YES,verticalScrollerView:SC.MenuScrollerView,verticalScrollerView2:SC.MenuScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:function(){return YES}.property("isVerticalScrollerVisible").cacheable(),
autohidesVerticalScroller:YES,verticalScrollerBottom:0,containerView:SC.ContainerView,tile:function(){var a,b,c,d,e,f;b=(a=this.get("hasVerticalScroller"))?this.get("verticalScrollerView"):null;a=a?this.get("verticalScrollerView2"):null;c=b&&this.get("isVerticalScrollerVisible");d=this.get("containerView");e={left:0,top:0};if(c){f=0;var g=this.get("contentView");g=(g=g?g.get("frame"):null)?g.height:0;var h=this.containerView.$()[0],i=this.get("verticalScrollOffset"),j={height:0,top:0,right:0,left:0},
k={height:this.verticalLineScroll,top:0,right:0,left:0},l={height:this.verticalLineScroll,bottom:0,right:0,left:0},m={height:0,bottom:0,right:0,left:0};if(h)f=h.offsetHeight;if(i===0){e.top=0;e.bottom=this.verticalLineScroll;b.set("layout",j);a.set("layout",l)}else if(i>=g-f-this.verticalLineScroll){e.top=this.verticalLineScroll;e.bottom=0;b.set("layout",k);a.set("layout",m)}else{e.top=this.verticalLineScroll;e.bottom=this.verticalLineScroll;b.set("layout",k);a.set("layout",l)}}if(b){b.set("isVisible",
c);a.set("isVisible",c)}d.set("layout",e)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible","isHorizontalScrollerVisible","verticalScrollOffset"),createChildViews:function(){var a=[],b,c;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView}));this.contentView=this.containerView.get("contentView");if((b=this.verticalScrollerView)&&(c=this.verticalScrollerView2))if(this.get("hasVerticalScroller")){b=
this.verticalScrollerView=this.createChildView(b,{layout:{top:0,left:0,right:0,height:this.verticalLineScroll},valueBinding:"*owner.verticalScrollOffset"});a.push(b);c=this.verticalScrollerView2=this.createChildView(c,{scrollDown:YES,layout:{bottom:0,left:0,right:0,height:this.verticalLineScroll},valueBinding:"*owner.verticalScrollOffset"});a.push(c)}else this.verticalScrollerView2=this.verticalScrollerView=null;this.childViews=a;this.contentViewFrameDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,
arguments);var a=this._scroll_contentView=this.get("contentView");a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),contentViewDidChange:function(){var a=this.get("contentView"),b=this._scroll_contentView,c=this.contentViewFrameDidChange;if(a!==b){b&&b.removeObserver("frame",
this,c);(this._scroll_contentView=a)&&a.addObserver("frame",this,c);this.containerView.set("content",a);this.contentViewFrameDidChange()}}.observes("contentView"),contentViewFrameDidChange:function(){var a=this.get("contentView"),b,c=a?a.get("frame"):null,d=c?c.width:0;c=c?c.height:0;var e=this.get("frame");this._scroll_contentWidth=d;this._scroll_contentHeight=c;if(this.get("hasVerticalScroller")&&(a=this.get("verticalScrollerView"))&&(b=this.get("verticalScrollerView2"))){c-=1;this.get("autohidesVerticalScroller")&&
this.set("isVerticalScrollerVisible",c>e.height);c-=this.get("verticalScrollerBottom");d=0;if(e=this.containerView.$()[0])d=e.offsetHeight;c-=d;a.setIfChanged("maximum",c);b.setIfChanged("maximum",c)}},_scroll_horizontalScrollOffsetDidChange:function(){}.observes("horizontalScrollOffset"),_scroll_verticalScrollOffsetDidChange:function(){var a=this.get("verticalScrollOffset"),b=this.get("contentView");b&&b.adjust("top",0-a)}.observes("verticalScrollOffset")});sc_require("views/button");
SC.PopupButtonView=SC.ButtonView.extend({keyEquivalent:null,classNames:["sc-popup-button"],preferMatrix:null,acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),isSelected:NO,performKeyEquivalent:function(a,b){if(!this.get("isEnabled"))return NO;var c=this.get("menu");return!!c&&c.performKeyEquivalent(a,b)},menu:null,isSelectedBinding:"*menu.isVisibleInWindow",action:function(){var a=this.get("menu");if(!a)return NO;a.popup(this,this.preferMatrix);
return YES},mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;this._action();return YES}});
SC.ProgressView=SC.View.extend(SC.Control,{value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),offsetRange:24,contentMaximumKey:null,isIndeterminate:NO,isIndeterminateBindingDefault:SC.Binding.bool(),isRunning:NO,isRunningBindingDefault:SC.Binding.bool(),animatedBackgroundMatrix:[],contentIsIndeterminateKey:null,classNames:"sc-progress-view",
_backgroundOffset:0,_currentBackground:1,_nextBackground:1,init:function(){arguments.callee.base.apply(this,arguments);this.animateProgressBar()},animateProgressBar:function(){this.get("isRunning")&&this.get("isVisibleInWindow")&&this._animateProgressBar(500)}.observes("isRunning","isVisibleInWindow"),_animateProgressBar:function(a){if(a===0)a=1E3/30;if(this.get("isRunning")&&this.get("isVisibleInWindow")){this.displayDidChange();this.invokeLater(this._animateProgressBar,a,10)}},displayProperties:"value minimum maximum isIndeterminate".w(),
render:function(a,b){var c,d,e=this.get("isIndeterminate");d=this.get("isRunning");c=this.get("isEnabled");var f=this.get("offsetRange");d=e&&d?Math.floor(Date.now()/75)%f-f:0;if(c)if(e)c="120%";else{f=this.get("minimum")||0;var g=this.get("maximum")||1;c=this.get("value")||0;c=(c-f)/(g-f);if(c>1)c=1;if(isNaN(c))c=0;if(c<f)c=0;if(c>g)c=1;c=c*100+"%"}else c="0%";e={"sc-indeterminate":e,"sc-empty":c<=0,"sc-complete":c>=100};if(b){b=this._createClassNameString(e);a.push('<div class="sc-inner ',b,'" style="width: ',
c,";left: ",d,'">');a.push('<div class="sc-inner-head"></div><div class="sc-inner-tail"></div></div><div class="sc-outer-head"></div><div class="sc-outer-tail"></div>')}else{a.setClass(e);a=this.$(".sc-inner");b=this.get("animatedBackgroundMatrix");c="width: "+c+"; ";c=c+"left: "+d+"; ";if(b.length===3){d="0px -"+(b[0]+b[1]*this._currentBackground)+"px";if(this._currentBackground===b[2]-1||this._currentBackground===0)this._nextBackground*=-1;this._currentBackground+=this._nextBackground;c=c+"backgroundPosition: "+
d+"; "}a.attr("style",c)}},contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()},_createClassNameString:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&a[c]&&b.push(c);return b.join(" ")}});
SC.RadioView=SC.FieldView.extend({classNames:["sc-radio-view"],value:null,layoutDirection:SC.LAYOUT_VERTICAL,escapeHTML:YES,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=this.get("itemTitleKey"),d=this.get("itemValueKey"),e=this.get("itemIsEnabledKey"),f=this.get("itemIconKey"),g=[],h=a?a.get("length"):0,i,j,k,l,m,o;for(l=0;l<h;l++){i=a.objectAt(l);if(SC.typeOf(i)===SC.T_ARRAY){j=i[0];k=
i[1]}else if(i){j=c?i.get?i.get(c):i[c]:i.toString?i.toString():null;k=d?i.get?i.get(d):i[d]:i;m=e?i.get?i.get(e):i[e]:YES;o=f?i.get?i.get(f):i[f]:null}else{j=k=o=null;m=NO}if(b)j=j.loc();g.push([j,k,m,o])}return g}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey").cacheable(),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);
this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},$input:function(){return this.$("input")},displayProperties:["value","displayItems"],render:function(a,b){var c,d,e,f,g,h,i,j,k=this.get("displayItems"),l=this.get("value"),m=SC.isArray(l);a.addClass(this.get("layoutDirection"));if(m&&l.length<=0){l=l[0];m=NO}if(b){b=SC.guidFor(this);f=k.length;for(d=0;d<f;d++){c=k[d];if(e=c[3]){g=e.indexOf("/")>=0?e:SC.BLANK_IMAGE_URL;e=g===e?
"":e;e='<img src="%@" class="icon %@" alt="" />'.fmt(g,e)}else e="";j=this._getSelectionState(c,l,m,false);g=!c[2]||!this.get("isEnabled")?'disabled="disabled" ':"";h=this.escapeHTML?SC.RenderContext.escapeHTML(c[0]):c[0];a.push('<label class="sc-radio-button ',j,'">');a.push('<input type="radio" value="',d,'" name="',b,'" ',g,"/>");a.push('<span class="button"></span>');a.push('<span class="sc-button-label">',e,h,"</span></label>")}this._field_setFieldValue(this.get("value"))}else this.$input().forEach(function(o){o=
this.$(o);d=parseInt(o.val(),0);c=d>=0?k[d]:null;o.attr("disabled",!c[2]?"disabled":null);i=this._getSelectionState(c,l,m,true);o.parent().setClass(i);d=i=null},this)},_getSelectionState:function(a,b,c,d){var e;b=a?c?b.indexOf(a[1])>=0:b===a[1]:NO;a={sel:b&&!c,mixed:b&&c,disabled:!a[2]};if(d)return a;else{d=[];for(e in a)a.hasOwnProperty(e)&&a[e]&&d.push(e);return d.join(" ")}},getFieldValue:function(){var a=this.$input().filter(function(){return this.checked}).val();return(a=this.get("displayItems")[parseInt(a,
0)])?a[1]:this._mixedValue},setFieldValue:function(a){if(SC.isArray(a))if(a.get("length")>1){this._mixedValue=a;a=undefined}else a=a.objectAt(0);var b,c;if(a===undefined)c=-1;else{b=this.get("displayItems");c=b.indexOf(b.find(function(d){return d[1]===a}))}this.$input().forEach(function(d){d=SC.$(d);d.attr("checked",parseInt(d.val(),0)===c)});return this},didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));for(var a=this.$input(),b=0,c=a.length;b<c;b++)SC.Event.add(a[b],"click",this,
this._field_fieldValueDidChange)},willDestroyLayer:function(){for(var a=0,b=this.$input().length;a<b;a++)SC.Event.remove(this.$input()[a],"click",this,this._field_fieldValueDidChange)},mouseDown:function(a){for(a=a.target;a;){if(a.className&&a.className.indexOf("sc-radio-button")>-1)break;a=a.parentNode}if(!a)return NO;a=this.$(a);a.addClass("active");this._activeRadioButton=a;return this._field_isMouseDown=YES},mouseUp:function(){var a=this._activeRadioButton;if(a){a.removeClass("active");this._activeRadioButton=
null}}});
SC.SceneView=SC.ContainerView.extend({scenes:["master","detail"],nowShowing:null,transitionDuration:200,_state:"NO_VIEW",replaceContent:function(a){a&&this._state===this.READY?this.animateScene(a):this.replaceScene(a);return this},replaceScene:function(a){var b=this._targetView,c=this.STANDARD_LAYOUT,d=this.get("scenes");d=d?d.indexOf(this.get("nowShowing")):-1;this._targetView=a;this._targetIndex=d;this._timer&&this._timer.invalidate();this._timer=this._leftView=this._rightView=this._start=this._end=
null;this.removeAllChildren();b&&b.set("layout",c);a&&a.set("layout",c);a&&this.appendChild(a);this._state=a?this.READY:this.NO_VIEW},animateScene:function(a){var b=this._targetView,c=this._targetIndex,d=this.get("scenes");d=d?d.indexOf(this.get("nowShowing")):-1;if(c<0||d<0||c===d)return this.replaceScene(a);this._targetView=a;this._targetIndex=d;if(d>c){this._leftView=b;this._rightView=a;this._target=-1}else{this._leftView=a;this._rightView=b;this._target=1}this.removeAllChildren();b&&this.appendChild(b);
a&&this.appendChild(a);this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this.tick()},tick:function(){this._timer=null;var a=(Date.now()-this._start)/(this._end-this._start),b=this._target,c=this._leftView,d=this._rightView,e;if(a<0)a=0;if(!this.get("isVisibleInWindow")||a>=1)return this.replaceScene(this._targetView);e=SC.clone(this.get("frame"));a=Math.floor(e.width*a);if(b>0){e.left=0-(e.width-a);c.set("layout",e);e=SC.clone(e);e.left=a}else{e.left=
0-a;c.set("layout",e);e=SC.clone(e);e.left=e.width-a}d.set("layout",e);this._timer=this.invokeLater(this.tick,20);return this},NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",STANDARD_LAYOUT:{top:0,left:0,bottom:0,right:0}});
SC.SegmentedView=SC.View.extend(SC.Control,{classNames:["sc-segmented-view"],value:null,isEnabled:YES,allowsEmptySelection:NO,allowsMultipleSelection:NO,localize:YES,layoutDirection:SC.LAYOUT_HORIZONTAL,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemActionKey:null,itemTargetKey:null,itemKeyEquivalentKey:null,itemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w(),displayItems:function(){var a=this.get("items"),
b=this.get("localize"),c=null,d,e,f=[],g=a.get("length"),h,i,j=SC._segmented_fetchKeys,k=SC._segmented_fetchItem;for(h=0;h<g;h++){i=a.objectAt(h);if(!SC.none(i)){d=SC.typeOf(i);if(d===SC.T_STRING)e=[i.humanize().titleize(),i,YES,null,null,null,h];else if(d!==SC.T_ARRAY){if(c===null)c=this.itemKeys.map(j,this);e=c.map(k,i);e[e.length]=h;if(!c[0]&&i.toString)e[0]=i.toString();c[1]||(e[1]=i);c[2]||(e[2]=YES)}if(b&&e[0])e[0]=e[0].loc();if(b&&e[5]&&SC.typeOf(e[5])===SC.T_STRING)e[5]=e[5].loc();f[f.length]=
e}}return f}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey","itemWidthKey","itemToolTipKey"),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},init:function(){arguments.callee.base.apply(this,
arguments);this.itemsDidChange()},displayProperties:["displayItems","value","activeIndex"],render:function(a,b){var c=this.get("displayItems"),d=this._seg_displayItems;if(b||c!==d){this._seg_displayItems=c;this.renderDisplayItems(a,c)}else{a=this.get("activeIndex");b=this.get("value");if((d=SC.isArray(b))&&b.get("length")===1){b=b.objectAt(0);d=NO}for(var e={},f=c.length,g=this.$("a.sc-segment"),h;--f>=0;){h=c[f];e.sel=d?b.indexOf(h[1])>=0:h[1]===b;e.active=a===f;e.disabled=!h[2];SC.$(g[f]).setClass(e)}}},
renderDisplayItems:function(a,b){var c=this.get("value"),d=SC.isArray(c),e=this.get("activeIndex"),f=b.length,g,h,i,j,k,l;for(l=0;l<f;l++){j=a.begin("a").attr("href","javascript:;");k=b[l];g=k[0];h=k[3];i=k[5];j.addStyle("display","inline-block");j.addClass("sc-segment");k[2]||j.addClass("disabled");l===0&&j.addClass("sc-first-segment");l===f-1&&j.addClass("sc-last-segment");l!==0&&l!==f-1&&j.addClass("sc-middle-segment");if(d?c.indexOf(k[1])>=0:k[1]===c)j.addClass("sel");e===l&&j.addClass("active");
if(k[4]){k=k[4];j.addStyle("width",k+"px")}i&&j.attr("title",i);if(h){i=h.indexOf("/")>=0?h:SC.BLANK_IMAGE_URL;h=i===h?"":h;h='<img src="'+i+'" alt="" class="icon '+h+'" />'}else h="";j.push('<span class="sc-button-inner"><label class="sc-button-label">',h+g,"</label></span>");j.end()}},displayItemIndexForEvent:function(a){a=SC.$(a.target);if(!a||a===document)return-1;for(var b=this.$(),c=null;!c&&a.length>0&&a[0]!==b[0];)if(a.hasClass("sc-segment")&&a.attr("tagName")==="A")c=a;else a=a.parent();
return c?this.$("a.sc-segment").index(c):-1},keyDown:function(a){var b,c,d,e,f;if(a.which===9){(c=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView"))?c.becomeFirstResponder():a.allowDefault();return YES}if(!this.get("allowsMultipleSelection")&&!this.get("allowsEmptySelection")){c=this.get("displayItems");d=c.length;e=this.get("value");f=SC.isArray(e);if(a.which===39||a.which===40){for(a=0;a<d-1;a++){b=c[a];if(f?e.indexOf(b[1])>=0:b[1]===e)this.triggerItemAtIndex(a+1)}return YES}else if(a.which===
37||a.which===38){for(a=1;a<d;a++){b=c[a];if(f?e.indexOf(b[1])>=0:b[1]===e)this.triggerItemAtIndex(a-1)}return YES}}return YES},mouseDown:function(a){if(!this.get("isEnabled"))return YES;a=this.displayItemIndexForEvent(a);if(a>=0){this._isMouseDown=YES;this.set("activeIndex",a)}return YES},mouseUp:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&a>=0&&this.triggerItemAtIndex(a);this._isMouseDown=NO;this.set("activeIndex",-1);return YES},mouseMoved:function(a){a=this.displayItemIndexForEvent(a);
this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOver:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOut:function(){this._isMouseDown&&this.set("activeIndex",-1);return YES},triggerItemAtIndex:function(a){a=this.get("displayItems").objectAt(a);var b,c,d,e,f;if(!a[2])return this;e=this.get("allowsEmptySelection");f=this.get("allowsMultipleSelection");b=a[1];c=d=this.get("value");SC.isArray(c)||(c=[c]);if(f)if(c.indexOf(b)>=
0){if(c.get("length")>1||c.objectAt(0)!==b||e)c=c.without(b)}else c=c.concat([b]);else c=e&&c.get("length")===1&&c.objectAt(0)===b?[]:[b];switch(c.get("length")){case 0:c=null;break;case 1:c=c.objectAt(0);break;default:break}b=this.get("itemActionKey");e=this.get("itemTargetKey");var g;f=null;var h=this.getPath("pane.rootResponder");if(b&&(a=this.get("items").objectAt(a[6]))){g=a.get?a.get(b):a[b];if(e)f=a.get?a.get(e):a[e];h&&h.sendAction(g,f,this,this.get("pane"))}!g&&d!==undefined&&this.set("value",
c);(g=this.get("action"))&&h&&h.sendAction(g,this.get("target"),this,this.get("pane"))},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO}});SC._segmented_fetchKeys=function(a){return this.get(a)};
SC._segmented_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};
SC.SelectFieldView=SC.FieldView.extend({tagName:"select",classNames:["sc-select-field-view"],objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,emptyName:null,localize:false,cpDidChange:YES,disableSort:NO,validateMenuItem:function(){return true},sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,d){if(b){c=c.get?c.get(b):c[b];d=d.get?d.get(b):d[b]}return c<d?-1:c>d?1:0})}return a},render:function(a,
b){if(this.get("cpDidChange")){this.set("cpDidChange",NO);var c=this.get("nameKey"),d=this.get("valueKey"),e=this.get("objects"),f=this.get("value"),g,h,i=this.get("localize");if(!d&&f)f=SC.guidFor(f);if(f===null||f==="")f="***";if(e){e=this.sortObjects(e);if(!b){h=this.$input()[0];h.innerHTML=""}var j=this.get("emptyName");if(j){if(i)j=j.loc();if(b){a.push('<option value="***">%@</option>'.fmt(j));a.push('<option disabled="disabled"></option>')}else{g=document.createElement("option");g.value="***";
g.innerHTML=j;h.appendChild(g);g=document.createElement("option");g.disabled="disabled";h.appendChild(g)}}e.forEach(function(k){if(k){var l=c?k.get?k.get(c):k[c]:k.toString();if(i)l=l.loc();if(k=d?k.get?k.get(d):k[d]:k)k=SC.guidFor(k)?SC.guidFor(k):k.toString();var m=this.validateMenuItem&&this.validateMenuItem(k,l)?"":'disabled="disabled" ';if(b)a.push('<option %@value="%@">%@</option>'.fmt(m,k,l));else{g=document.createElement("option");g.value=k;g.innerHTML=l;if(m.length>0)g.disable="disabled";
h.appendChild(g)}}else if(b)a.push('<option disabled="disabled"></option>');else{g=document.createElement("option");g.disabled="disabled";h.appendChild(g)}},this);this.setFieldValue(f)}else this.set("value",null)}},displayProperties:["objects","nameKey","valueKey"],_objectsObserver:function(){this.set("cpDidChange",YES)}.observes("objects"),_nameKeyObserver:function(){this.set("cpDidChange",YES)}.observes("nameKey"),_valueKeyObserver:function(){this.set("cpDidChange",YES)}.observes("valueKey"),$input:function(){return this.$()},
mouseDown:function(a){if(this.get("isEnabled"))return arguments.callee.base.apply(this,arguments);else{a.stop();return YES}},getFieldValue:function(){var a=arguments.callee.base.apply(this,arguments),b=this.get("valueKey"),c=this.get("objects"),d,e;if(a=="***")a=null;else if(a&&c){var f=SC.typeOf(c.length)===SC.T_FUNCTION?c.length():c.length;for(d=null;!d&&--f>=0;){e=c.objectAt?c.objectAt(f):c[f];if(b)e=e.get?e.get(b):e[b];var g=e?SC.guidFor(e)?SC.guidFor(e):e.toString():null;if(a==g)d=e}}return b||
d?d:a},setFieldValue:function(a){a=SC.none(a)?"":a?SC.guidFor(a)?SC.guidFor(a):a.toString():null;this.$input().val(a);return this},fieldDidFocus:function(){this.get("isFocused")||this.set("isFocused",true)},fieldDidBlur:function(){this.get("isFocused")&&this.set("isFocused",false)},_isFocusedObserver:function(){this.$().setClass("focus",this.get("isFocused"))}.observes("isFocused"),didCreateLayer:function(){var a=this.$input();SC.Event.add(a,"blur",this,this.fieldDidBlur);SC.Event.add(a,"focus",this,
this.fieldDidFocus);return arguments.callee.base.apply(this,arguments)},willDestroyLayer:function(){var a=this.$input();SC.Event.remove(a,"focus",this,this.fieldDidFocus);SC.Event.remove(a,"blur",this,this.fieldDidBlur);return arguments.callee.base.apply(this,arguments)}});
SC.SliderView=SC.View.extend(SC.Control,{classNames:"sc-slider-view",handleSelector:"img.sc-handle",value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),contentMaximumKey:null,step:0.1,displayProperties:"value minimum maximum".w(),render:function(a,b){arguments.callee.base.apply(this,arguments);var c=this.get("minimum"),d=this.get("maximum"),
e=this.get("value");e=Math.min(Math.max(e,c),d);var f=this.get("step");if(!SC.none(f)&&f!==0)e=Math.round(e/f)*f;e=Math.floor((e-c)/(d-c)*100);if(b){c=SC.BLANK_IMAGE_URL;a.push('<span class="sc-inner">');a.push('<span class="sc-leftcap"></span>');a.push('<span class="sc-rightcap"></span>');a.push('<img src="',c,'" class="sc-handle" style="left: ',e,'%" />');a.push("</span>")}else this.$(this.get("handleSelector")).css("left",e+"%")},_isMouseDown:NO,mouseDown:function(a){if(!this.get("isEnabled"))return YES;
this.set("isActive",YES);this._isMouseDown=YES;return this._triggerHandle(a)},mouseDragged:function(a){return this._isMouseDown?this._triggerHandle(a):YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);a=this._isMouseDown?this._triggerHandle(a):YES;this._isMouseDown=NO;return a},_triggerHandle:function(a){a=this.convertFrameFromView({x:a.pageX}).x;var b=this.get("frame").width;a=Math.max(Math.min(a,b-8),8)-8;b-=16;a/=b;b=this.get("minimum");var c=this.get("maximum"),d=this.get("step"),
e=this.get("value");a=b+(c-b)*a;if(d!==0)a=Math.round(a/d)*d;Math.abs(e-a)>=0.01&&this.set("value",a);return YES},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},keyDown:function(a){if(a.which===9){var b=
a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(a.which===37||a.which===38||a.which===39||a.which===40){b=this.get("minimum");var c=this.get("maximum"),d=this.get("step"),e=c-b,f=0;if(a.which===37||a.which===38)if(d===0)if(e<100)f=this.get("value")-1;else{Math.abs(e/100);f=this.get("value")-Math.abs(e/100)}else f=this.get("value")-d;if(a.which===39||a.which===40)if(d===0)if(e<100)f=this.get("value")+2;else{a=Math.abs(e/
100);if(a<2)a=2;f=this.get("value")+a}else f=this.get("value")+d;f>=b&&f<=c&&this.set("value",f)}SC.RunLoop.begin().end();return YES},contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()}});
sc_require("mixins/collection_group");sc_require("views/disclosure");
SC.SourceListGroupView=SC.View.extend(SC.Control,SC.CollectionGroup,{classNames:["sc-source-list-group"],content:null,isGroupVisible:YES,hasGroupTitle:YES,groupTitleKey:null,groupVisibleKey:null,render:function(a){a.push('<a href="javascript:;" class="sc-source-list-label sc-disclosure-view sc-button-view button disclosure no-disclosure">');a.push('<img src="%@" class="button" />'.fmt(SC.BLANK_IMAGE_URL));a.push('<span class="label"></span></a>')},createChildViews:function(){},contentPropertyDidChange:function(a,
b){var c=this.get("content");a=this.outlet("labelView");if(c===null){a.setIfChanged("isVisible",NO);this.setIfChanged("hasGroupTitle",NO)}else{a.setIfChanged("isVisible",YES);this.setIfChanged("hasGroupTitle",YES);var d=this.getDelegateProperty("groupTitleKey",this.displayDelegate);if(b=="*"||d&&b==d){d=c&&c.get&&d?c.get(d):c;if(d!=this._title){if(this._title=d)d=d.capitalize();a.set("title",d)}}d=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);if(b=="*"||d&&b==d)if(d){a.removeClassName("no-disclosure");
b=c&&c.get?!!c.get(d):YES;if(b!=this.get("isGroupVisible")){this.set("isGroupVisible",b);a.set("value",b)}}else a.addClassName("no-disclosure")}},disclosureValueDidChange:function(a){if(a!=this.get("isGroupVisible")){var b=this.get("content"),c=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);b&&b.set&&c&&b.set(c,a);this.set("isGroupVisible",a);this.owner&&this.owner.updateChildren&&this.owner.updateChildren(true)}},labelView:SC.DisclosureView.extend({value:YES,_valueObserver:function(){this.owner&&
this.owner.disclosureValueDidChange(this.get("value"))}.observes("value")})});sc_require("views/list");sc_require("views/source_list_group");SC.BENCHMARK_SOURCE_LIST_VIEW=YES;SC.SourceListView=SC.ListView.extend({classNames:["sc-source-list"],rowHeight:32,selectOnMouseDown:NO,actOnSelect:YES});sc_require("views/split");
SC.SplitDividerView=SC.View.extend({classNames:["sc-split-divider-view"],prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)},doubleClick:function(a){console.log("doubleClick in split divider");var b=this.get("splitView");return b?b.doubleClickInThumbView(a,this):arguments.callee.base.apply(this,
arguments)}});sc_require("views/split_divider");SC.RESIZE_BOTH="resize-both";SC.RESIZE_TOP_LEFT="resize-top-left";SC.RESIZE_BOTTOM_RIGHT="resize-bottom-right";
SC.SplitView=SC.View.extend({classNames:["sc-split-view"],childLayoutProperties:"layoutDirection dividerThickness autoresizeBehavior".w(),displayProperties:["layoutDirection"],delegate:null,layoutDirection:SC.LAYOUT_HORIZONTAL,canCollapseViews:YES,autoresizeBehavior:SC.RESIZE_BOTTOM_RIGHT,defaultThickness:0.5,isSplitView:YES,topLeftView:SC.View,dividerView:SC.SplitDividerView,bottomRightView:SC.View,topLeftThickness:function(){var a=this.get("topLeftView");return a?this.thicknessForView(a):0}.property("topLeftView").cacheable(),
bottomRightThickness:function(){var a=this.get("bottomRightView");return a?this.thicknessForView(a):0}.property("bottomRightView").cacheable(),thumbViewCursor:null,canCollapseView:function(a){return this.invokeDelegateMethod(this.delegate,"splitViewCanCollapse",this,a)},thicknessForView:function(a){var b=this.get("layoutDirection");a=a.get("frame");return b===SC.LAYOUT_HORIZONTAL?a.width:a.height},createChildViews:function(){var a=[],b=["topLeftView","dividerView","bottomRightView"],c,d,e;d=0;for(e=
b.length;d<e;++d)if(c=this.get(b[d])){c=this[b[d]]=this.createChildView(c,{layoutView:this,rootElementPath:[d]});a.push(c)}this.set("childViews",a);return this},updateChildLayout:function(){var a=this.get("topLeftView"),b=this.get("bottomRightView"),c=this.get("dividerView"),d=this.get("layoutDirection"),e=this._desiredTopLeftThickness,f=this.get("dividerThickness");f=!SC.none(f)?f:7;var g=(d===SC.LAYOUT_HORIZONTAL?this.get("frame").width:this.get("frame").height)-f-e,h=this.get("autoresizeBehavior"),
i;i=a.get("isCollapsed")||NO;a.setIfChanged("isVisible",!i);i=SC.clone(a.get("layout"));if(d===SC.LAYOUT_HORIZONTAL){i.top=0;i.left=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:i.right=g+f;delete i.width;break;case SC.RESIZE_BOTTOM_RIGHT:delete i.right;delete i.height;i.width=e;break}}else{i.top=0;i.left=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:i.bottom=g+
f;delete i.height;break;case SC.RESIZE_BOTTOM_RIGHT:delete i.bottom;delete i.width;i.height=e;break}}a.set("layout",i);if(c){i=SC.clone(c.get("layout"));if(d===SC.LAYOUT_HORIZONTAL){i.width=f;delete i.height;i.top=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:delete i.left;i.right=g;delete i.centerX;delete i.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:i.left=e;delete i.right;delete i.centerX;delete i.centerY;break}}else{delete i.width;
i.height=f;i.left=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:delete i.top;i.bottom=g;delete i.centerX;delete i.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:i.top=e;delete i.bottom;delete i.centerX;delete i.centerY;break}}c.set("layout",i)}i=b.get("isCollapsed")||NO;b.setIfChanged("isVisible",!i);i=SC.clone(b.get("layout"));if(d===SC.LAYOUT_HORIZONTAL){i.top=0;i.bottom=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";
case SC.RESIZE_BOTTOM_RIGHT:i.left=e+f;delete i.width;break;case SC.RESIZE_TOP_LEFT:delete i.left;i.width=g;break}}else{i.left=0;i.right=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_BOTTOM_RIGHT:i.top=e+f;delete i.height;break;case SC.RESIZE_TOP_LEFT:delete i.top;i.height=g;break}}b.set("layout",i);this.notifyPropertyChange("topLeftThickness").notifyPropertyChange("bottomRightThickness")},renderLayout:function(a,b){if(b||this._recalculateDivider){this.get("thumbViewCursor")||
this.set("thumbViewCursor",SC.Cursor.create());var c=this.get("layoutDirection"),d=this.get("frame"),e=this.$(),f=this.get("defaultThickness"),g=this.get("autoresizeBehavior"),h=this.get("dividerThickness");h=!SC.none(h)?h:7;if(this._recalculateDivider===undefined&&f<1)this._recalculateDivider=YES;else if(this._recalculateDivider)this._recalculateDivider=NO;c=e[0]?c===SC.LAYOUT_HORIZONTAL?e[0].offsetWidth:e[0].offsetHeight:c===SC.LAYOUT_HORIZONTAL?d.width:d.height;if(SC.none(f)||f>0&&f<1)f=Math.floor((c-
h)*(f||0.5));this._desiredTopLeftThickness=g===SC.RESIZE_BOTTOM_RIGHT?f:c-h-f;this._topLeftView=this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this._updateTopLeftThickness(0);this._setCursorStyle();this.updateChildLayout()}arguments.callee.base.apply(this,
arguments)},render:function(a,b){arguments.callee.base.apply(this,arguments);this._inLiveResize&&this._setCursorStyle();if(b)this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?a.addClass("sc-horizontal"):a.addClass("sc-vertical")},mouseDownInThumbView:function(a,b){var c=this.getPath("pane.rootResponder");if(!c)return NO;c.dragDidStart(this);this._mouseDownX=a.pageX;this._mouseDownY=a.pageY;this._thumbView=b;this._topLeftView=this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");
this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this.beginLiveResize();return this._inLiveResize=YES},mouseDragged:function(a){this._updateTopLeftThickness(this._layoutDirection===SC.LAYOUT_HORIZONTAL?a.pageX-this._mouseDownX:a.pageY-this._mouseDownY);return YES},mouseUp:function(){if(this._inLiveResize===
YES){this._thumbView=null;this._inLiveResize=NO;this.endLiveResize();return YES}return NO},doubleClickInThumbView:function(){var a=this._topLeftView,b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a)){a=this._bottomRightView;b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a))return NO}if(b){if(a===this._topLeftView)this._topLeftViewThickness=this._uncollapsedThickness;else this._bottomRightViewThickness=this._uncollapsedThickness;a._uncollapsedThickness=null}else{this._uncollapsedThickness=
this.getThicknessForView(a);if(a===this._topLeftView)this._topLeftViewThickness=0;else this._bottomRightViewThickness=0;if(!a.get("isCollapsed"))this._uncollapsedThickness=null}this._setCursorStyle();return true},_updateTopLeftThickness:function(a){var b=this._topLeftView,c=this._bottomRightView,d=this.thicknessForView(b),e=this.thicknessForView(c),f=this._dividerThickness,g=0;a=this._topLeftViewThickness+a;this.canCollapseView(c);var h=a,i=this.get("topLeftMaxThickness"),j=this.get("topLeftMinThickness");
b.get("isCollapsed")||(g+=d);c.get("isCollapsed")||(g+=e);SC.none(i)||(h=Math.min(i,h));SC.none(j)||(h=Math.max(j,h));i=this.get("bottomRightMaxThickness");j=this.get("bottomRightMinThickness");h=g-h;SC.none(i)||(h=Math.min(i,h));SC.none(j)||(h=Math.max(j,h));h=g-h;h=this.invokeDelegateMethod(this.delegate,"splitViewConstrainThickness",this,b,h);h=Math.min(h,g);h=Math.max(0,h);(d=b.get("collapseAtThickness"))||(d=0);e=c.get("collapseAtThickness");e=SC.none(e)?g:g-e;if(a<=d&&this.canCollapseView(b)){i=
c.get("maxThickness");if(!i||f+g<=i)h=0}else if(a>=e&&this.canCollapseView(c)){i=b.get("maxThickness");if(!i||f+g<=i)h=g}if(h!=this.thicknessForView(b)){this._desiredTopLeftThickness=h;b.set("isCollapsed",h===0);c.set("isCollapsed",h>=g);this.updateChildLayout();this.displayDidChange()}},_setCursorStyle:function(){var a=this._topLeftView;bottomRightView=this._bottomRightView;thumbViewCursor=this.get("thumbViewCursor");tlThickness=this.thicknessForView(a);brThickness=this.thicknessForView(bottomRightView);
this._layoutDirection=this.get("layoutDirection");if(a.get("isCollapsed")||tlThickness===this.get("topLeftMinThickness")||brThickness==this.get("bottomRightMaxThickness"))thumbViewCursor.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"e-resize":"s-resize");else bottomRightView.get("isCollapsed")||tlThickness===this.get("topLeftMaxThickness")||brThickness==this.get("bottomRightMinThickness")?thumbViewCursor.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"w-resize":"n-resize"):
thumbViewCursor.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"ew-resize":"ns-resize")}.observes("layoutDirection"),splitViewCanCollapse:function(a,b){if(a.get("canCollapseViews")===NO)return NO;if(b.get("canCollapse")===NO)return NO;return YES},splitViewConstrainThickness:function(a,b,c){return c},_forceSplitCalculation:function(){this.updateLayout()}.observes("*pane.isPaneAttached")});sc_require("views/collection");
SC.StackedView=SC.CollectionView.extend({classNames:["sc-stacked-view"],layout:{top:0,left:0,right:0,height:1},computeNowShowing:function(){return this.get("allContentIndexes")},updateHeight:function(a){a?this._updateHeight():this.invokeLast(this._updateHeight);return this},_updateHeight:function(){var a=this.get("childViews"),b=a.get("length");if(b===0)a=1;else a=(a=(a=a.objectAt(b-1))?a.get("layer"):null)?a.offsetTop+a.offsetHeight:1;this.adjust("height",a)},didReload:function(){return this.updateHeight()},
didCreateLayer:function(){return this.updateHeight()}});sc_require("views/segmented");SC.TOP_LOCATION="top";SC.BOTTOM_LOCATION="bottom";
SC.TabView=SC.View.extend({classNames:["sc-tab-view"],displayProperties:["nowShowing"],nowShowing:null,items:[],isEnabled:YES,itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemToolTipKey:null,tabLocation:SC.TOP_LOCATION,userDefaultKey:null,_tab_nowShowingDidChange:function(){var a=this.get("nowShowing");this.get("containerView").set("nowShowing",a);this.get("segmentedView").set("value",a);return this}.observes("nowShowing"),_tab_saveUserDefault:function(){var a=
this.get("nowShowing"),b=this.get("userDefaultKey");b&&SC.userDefaults.set([b,"nowShowing"].join(":"),a)}.observes("nowShowing"),_tab_itemsDidChange:function(){this.get("segmentedView").set("items",this.get("items"));return this}.observes("items"),init:function(){arguments.callee.base.apply(this,arguments);this._tab_nowShowingDidChange()._tab_itemsDidChange()},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("userDefaultKey");if(a){a=[a,"nowShowing"].join(":");a=SC.userDefaults.get(a);
SC.none(a)||this.set("nowShowing",a)}},createChildViews:function(){var a=[],b;b=this.containerView=this.createChildView(this.get("tabLocation")===SC.TOP_LOCATION?this.containerView.extend({layout:{top:12,left:0,right:0,bottom:0}}):this.containerView.extend({layout:{top:0,left:0,right:0,bottom:12}}));a.push(b);b=this.segmentedView=this.createChildView(this.segmentedView);a.push(b);this.set("childViews",a);return this},containerView:SC.ContainerView,segmentedView:SC.SegmentedView.extend({layout:{left:0,
right:0,height:24},_sc_tab_segmented_valueDidChange:function(){var a=this.get("parentView");a&&a.set("nowShowing",this.get("value"));this.set("layerNeedsUpdate",YES);this.invokeOnce(this.updateLayerIfNeeded)}.observes("value"),render:function(a){arguments.callee.base.apply(this,arguments);var b=this.get("parentView");(b?b.get("tabLocation"):SC.TOP_LOCATION)===SC.TOP_LOCATION?a.addStyle("top","0px"):a.addStyle("bottom","0px")},init:function(){var a=this.get("parentView");a&&SC._TAB_ITEM_KEYS.forEach(function(b){this[b]=
a.get(b)},this);return arguments.callee.base.apply(this,arguments)}})});SC._TAB_ITEM_KEYS="itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w();
SC.ThumbView=SC.View.extend({classNames:["sc-thumb-view"],isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){if(!this.get("isEnabled"))return NO;var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)}});
SC.ToolbarView=SC.View.extend({classNames:["sc-toolbar-view"],anchorLocation:null,layout:{left:0,height:32,right:0},init:function(){if(this.anchorLocation)this.layout=SC.merge(this.layout,this.anchorLocation);arguments.callee.base.apply(this,arguments)}});
SC.WebView=SC.View.extend(SC.Control,{classNames:"sc-web-view",displayProperties:["value","shouldAutoResize"],shouldAutoResize:NO,render:function(a,b){var c=this.get("value");if(b)a.push('<iframe src="'+c+'" style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0p;"></iframe>');else{a=this.$("iframe");a.attr("src","javascript:;");a.attr("src",c)}},didCreateLayer:function(){var a=this.$("iframe");SC.Event.add(a,"load",this,this.iframeDidLoad)},iframeDidLoad:function(){if(this.get("shouldAutoResize")===
YES){var a;if((a=this.$("iframe")[0])&&a.contentWindow)if((a=a.contentWindow)&&a.document&&a.document.documentElement){a=a.document.documentElement;if(SC.browser.isIE){this.$().width(a.scrollWidth+12);this.$().height(a.scrollHeight+5)}else{this.$().width(a.scrollWidth);this.$().height(a.scrollHeight)}}}}});
SC.WellView=SC.ContainerView.extend({classNames:"sc-well-view",contentLayout:{top:10,bottom:10,left:10,right:10},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);a.set("layout",this.contentLayout);this.childViews=[a]}},render:function(a,b){b&&a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>","<div class='right-edge'></div>","<div class='bottom-right-edge'></div>","<div class='bottom-edge'></div>",
"<div class='bottom-left-edge'></div>","<div class='left-edge'></div>","<div class='content-background'></div>");arguments.callee.base.apply(this,arguments)},contentViewDidChange:function(){var a=this.get("contentView");a.set("layout",this.contentLayout);this.replaceContent(a)}.observes("contentView")});tiki.script("sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js");
tiki.register("sproutcore",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js",id:"sproutcore/datastore:en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css",
id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js",id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js"}]},"sproutcore/desktop":{stylesheets:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css",id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css"}],scripts:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js",
id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js",id:"tiki:en/9f76cda2d7e44b7acc4c94bb51f3277709b0cb56/javascript.js"}]}},depends:["tiki","sproutcore/runtime","sproutcore/datastore","sproutcore/foundation","sproutcore/desktop"],scripts:[{url:"/static/sproutcore/en/dbd7a5e120cf0552319377c4d7a28a11c599b1d6/javascript.js",id:"sproutcore:en/dbd7a5e120cf0552319377c4d7a28a11c599b1d6/javascript.js"}]});
tiki.module("sproutcore:index",function(a,b,c){c.exports=a("sproutcore/runtime");a("sproutcore/datastore")});tiki.module("sproutcore:license",function(){});tiki.script("sproutcore:en/dbd7a5e120cf0552319377c4d7a28a11c599b1d6/javascript.js");
tiki.register("sproutcore/animation",{packages:{sproutcore:{scripts:[{url:"/static/sproutcore/en/dbd7a5e120cf0552319377c4d7a28a11c599b1d6/javascript.js",id:"sproutcore:en/dbd7a5e120cf0552319377c4d7a28a11c599b1d6/javascript.js"}]}},depends:["sproutcore"],scripts:[{url:"/static/sproutcore/animation/en/2ba607ab369dda8bd146e581906ea3ce82dd2abb/javascript.js",id:"sproutcore/animation:en/2ba607ab369dda8bd146e581906ea3ce82dd2abb/javascript.js"}]});tiki.global("sproutcore/animation");
SC.Animatable={isAnimatable:YES,transitions:{},concatenatedProperties:["transitions"],style:{},_cssTransitionFor:{left:"left",top:"top",right:"right",bottom:"bottom",width:"width",height:"height",opacity:"opacity"},_styleProperties:["opacity","display"],_layoutStyles:["left","right","top","bottom","width","height","centerX","centerY"],_animationsToStart:{},_animationOrder:["top","left","bottom","right","width","height","centerX","centerY","opacity","display"],initMixin:function(){this._animatable_original_did_update_layer=
this.didUpdateLayer||function(){};this.didUpdateLayer=this._animatable_did_update_layer;this._animatable_original_willRemoveFromParent=this.willRemoveFromParent||function(){};this.willRemoveFromParent=this._animatable_will_remove_from_parent;this._animateTickPixel.displayName="animate-tick";var a;if(SC.isArray(this.transitions)){var b={};for(a=0;a<this.transitions.length;a++)SC.mixin(b,this.transitions[a]);this.transitions=b}for(a in this.transitions)if(typeof this.transitions[a]=="number")this.transitions[a]=
{duration:this.transitions[a]};this._animatableCurrentStyle=null;this._animators={};this._last_transition_css=this._animatableSetCSS="";this._disableAnimation=0},_animatable_will_remove_from_parent:function(){this.resetAnimation()},disableAnimation:function(){this._disableAnimation++},enableAnimation:function(){this._disableAnimation--;if(this._disableAnimation<0)this._disableAnimation=0},adjust:function(a,b){if(SC.none(b))a=SC.clone(a);else{var c=a;a={};a[c]=b}b=SC.clone(this.get("style"));c=NO;
var d=SC.clone(this.get("layout")),e=NO,f=this._styleProperties;for(var g in a){var h=NO,i=f.indexOf(g)>=0?b:d,j=i[g],k=a[g];if(k!==undefined&&j!==k)if(k===null){if(j!==undefined)h=YES;delete i[g]}else{i[g]=k;h=YES}if(h)if(i===b)c=YES;else e=YES}c&&this.set("style",b);e&&this.set("layout",d);return this},getCurrentJavaScriptStyles:function(){return this._animatableCurrentStyle},resetAnimation:function(){this._animatableCurrentStyle=null;this._stopJavaScriptAnimations();this.disableAnimation();this.updateStyle();
this.enableAnimation()},_stopJavaScriptAnimations:function(){for(var a in this._animators)this._animators[a]&&this._animators[a].isQueued&&SC.Animatable.removeTimer(this._animators[a])},_getStartStyleHash:function(a,b){var c=this.layout;this.layout=a;this.notifyPropertyChange("layout");var d=this.get("frame"),e=this.getPath("layoutView.frame");this.layout=c;c={};for(var f in b){if(d)if(f=="left"){c[f]=d.x;continue}else if(f=="top"){c[f]=d.y;continue}else if(f=="right"){c[f]=e.width-d.x-d.width;continue}else if(f==
"bottom"){c[f]=e.height-d.y-d.height;continue}else if(f=="width"){c[f]=d.width;continue}else if(f=="height"){c[f]=d.height;continue}else if(f=="centerX"){c[f]=d.x+d.width/2-e.width/2;continue}else if(f=="centerY"){c[f]=d.y+d.height/2-e.height/2;continue}c[f]=SC.none(a[f])?b[f]:a[f]}return c},_TMP_CSS_TRANSITIONS:[],updateStyle:function(){var a=this.get("layer"),b=this.get("style"),c;if(!this._animatableCurrentStyle||this._disableAnimation>0||!a){this._animatableCurrentStyle={};for(c in b)if(c[0]!=
"_")this._animatableCurrentStyle[c]=b[c];a&&this._animatableApplyStyles(a,b);return this}if(a){var d=true;for(c in b)if(c[0]!="_")if(b[c]!=this._animatableCurrentStyle[c]){d=false;break}if(d)return this;d=this._getStartStyleHash(this._animatableCurrentStyle,b);var e,f=this._TMP_CSS_TRANSITIONS;if(SC.Animatable.enableCSSTransitions)for(c in this.transitions)if(this._cssTransitionFor[c]){var g="linear";if(this.transitions[c].timing||SC.Animatable.defaultTimingFunction){e=this.transitions[c].timing||
SC.Animatable.defaultTimingFunction;g=SC.typeOf(e)!=SC.T_STRING?"cubic-bezier("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")":e}f.push(this._cssTransitionFor[c]+" "+this.transitions[c].duration+"s "+g)}for(c in b)if(c[0]!="_"){g=!this.transitions[c]||b[c]==d[c];if(c=="display"&&b[c]!="none")g=true;if(g){d[c]=b[c];if(g=this._animators[c]){g.endValue=b[c];g.end=0}}else if(SC.Animatable.enableCSSTransitions&&this._cssTransitionFor[c])d[c]=b[c];else{e=this._animateTickPixel;var h=c,i=d[c],j=b[c];if(h=="centerX"||
h=="centerY")e=this._animateTickCenter;else if(h=="opacity")e=this._animateTickNumber;else if(h=="display")e=this._animateTickDisplay;this._animators[c]||(this._animators[c]={});g=this._animators[c];g.start=null;g.duration=Math.floor(this.transitions[c].duration*1E3);g.startValue=i;g.endValue=j;g.layer=a;g.property=h;g.action=e;g.style=a.style;g.holder=this;if((e=this.transitions[c].timing||SC.Animatable.defaultTimingFunction)&&SC.typeOf(e)!=SC.T_STRING)g.timingFunction=e;g.going||(this._animationsToStart[c]=
g)}}b=this._animationOrder;g=this._animationOrder.length;for(c=0;c<g;c++){e=b[c];if(this._animationsToStart[e]){SC.Animatable.addTimer(this._animationsToStart[e]);delete this._animationsToStart[e]}}c=f.join(",");f.length="";this._animatableSetCSS=c;this._animatableApplyStyles(a,d);return this}}.observes("style"),_style_opacity_helper:function(a,b,c){a.opacity=c.opacity;a.mozOpacity=c.opacity;a.filter="alpha(opacity="+c.opacity*100+")"},_animatableApplyStyles:function(a,b){if(a){if(b.display)a.style.display=
b.display;if(this._animatableSetCSS!=this._last_transition_css){a.style["-webkit-transition"]=this._animatableSetCSS;this._last_transition_css=a.style["-moz-transition"]=this._animatableSetCSS}this._animators["display-styles"]||(this._animators["display-styles"]={});var c=this._animators["display-styles"];c.holder=this;c.action=this._animatableApplyNonDisplayStyles;c.layer=a;this._animatableCurrentStyle=c.styles=b;SC.Animatable.addTimer(c)}},_animatableApplyNonDisplayStyles:function(){var a=SC.RunLoop.begin(),
b=this.styles,c={opacity:this.holder._style_opacity_helper},d={},e=NO,f=this.layer.style;for(var g in b)if(g!="display")if(this.holder._layoutStyles.indexOf(g)>=0){d[g]=b[g];e=YES}else c[g]&&c[g](f,g,b);if(e){b=this.holder.layout;this.holder.layout=d;this.holder.notifyPropertyChange("layoutStyle");d=this.holder.get("layoutStyle");for(var h in d)if(SC.none(d[h]))f[h]="";else if(f[h]!=d[h])f[h]=d[h];this.holder.layout=b}a.end()},_animatable_did_update_layer:function(){this._animatable_original_did_update_layer();
var a=this._animatableCurrentStyle,b=this.get("layer");if(!a){a={};var c=this.get("style"),d=this.get("layout");SC.mixin(a,c,d)}this._animatableApplyStyles(b,a)},updateLayout:function(){var a=SC.clone(this.get("style")),b=this.get("layout"),c=0,d=this._layoutStyles,e=d.length,f=NO;for(c=0;c<e;c++){var g=d[c];if(a[g]!==b[g]){a[g]=SC.none(b[g])?"":b[g];f=YES}}if(f){this.style=a;this.updateStyle()}return this},_solveBezierForT:function(a,b,c,d,e,f,g,h){b=1/(200*h);var i;d=g;for(i=0;i<8;i++){f=((a*d+
c)*d+e)*d-g;if(Math.abs(f)<b)return d;h=(3*a*d+2*c)*d+e;if(Math.abs(h)<Math.pow(10,-6))break;d-=f/h}h=0;i=1;d=g;if(d<h)return h;if(d>i)return i;for(;h<i;){f=((a*d+c)*d+e)*d;if(Math.abs(f-g)<b)return d;if(g>f)h=d;else i=d;d=(i-h)*0.5+h}return d},_solveBezier:function(a,b,c,d,e,f){var g=3*a;c=3*(c-a)-g;a=3*b;b=3*(d-b)-a;d=1-a-b;e=this._solveBezierForT(1-g-c,d,c,b,g,a,e,f);return((d*e+b)*e+a)*e},_animateTickPixel:function(a){if(SC.none(this.start)){this.start=a;this.end=this.start+this.duration}var b=
this.start,c=this.end,d=this.startValue,e=c-b,f=this.endValue-d;b=Math.min((a-b)/e,1);if(this.timingFunction){var g=this.timingFunction;b=this.holder._solveBezier(g[0],g[1],g[2],g[3],b,e)}d=Math.floor(d+f*b);this.holder._animatableCurrentStyle[this.property]=d;this.style[this.property]=d+"px";if(a<c)SC.Animatable.addTimer(this);else{this.going=false;this.layer=this.styles=null}},_animateTickDisplay:function(a){if(SC.none(this.start)){this.start=a;this.end=this.start+this.duration}if(a<this.end)SC.Animatable.addTimer(this);
else{this.holder._animatableCurrentStyle[this.property]=this.endValue;this.style[this.property]=this.endValue;this.going=false;this.layer=this.styles=null}},_animateTickNumber:function(a){if(SC.none(this.start)){this.start=a;this.end=this.start+this.duration}var b=this.start,c=this.end,d=this.startValue,e=c-b,f=this.endValue-d;b=Math.min((a-b)/e,1);if(this.timingFunction){var g=this.timingFunction;b=this.holder._solveBezier(g[0],g[1],g[2],g[3],b,e)}d=Math.round((d+f*b)*100)/100;this.holder._animatableCurrentStyle[this.property]=
d;this.style[this.property]=d;if(this.property=="opacity"){this.style.zoom=1;this.style.filter="alpha(opacity="+Math.round(d*20)*5+")"}if(a<c)SC.Animatable.addTimer(this);else{this.going=false;this.layer=this.styles=null}},_animateTickCenter:function(a){if(SC.none(this.start)){this.start=a;this.end=this.start+this.duration}var b=this.start,c=this.end,d=this.startValue,e=c-b,f=this.endValue-d;b=Math.min((a-b)/e,1);if(this.timingFunction){var g=this.timingFunction;b=this.holder._solveBezier(g[0],g[1],
g[2],g[3],b,e)}d=d+f*b;this.holder._animatableCurrentStyle[this.property]=d;if(this.property=="centerX"){e="width";f="margin-left"}else{e="height";f="margin-top"}this.style[f]=Math.round(d-this.holder._animatableCurrentStyle[e]/2)+"px";if(a<c)SC.Animatable.addTimer(this);else{this.going=false;this.layer=this.styles=null}}};
SC.mixin(SC.Animatable,{NAMESPACE:"SC.Animatable",VERSION:"0.1.0",TRANSITION_NONE:"linear",TRANSITION_CSS_EASE:"ease",TRANSITION_CSS_EASE_IN:"ease-in",TRANSITION_CSS_EASE_OUT:"ease-out",TRANSITION_CSS_EASE_IN_OUT:"ease-in-out",TRANSITION_EASE:[0.25,0.1,0.25,1],TRANSITION_LINEAR:[0,0,1,1],TRANSITION_EASE_IN:[0.42,0,1,1],TRANSITION_EASE_OUT:[0,0,0.58,1],TRANSITION_EASE_IN_OUT:[0.42,0,0.58,1],defaultTimingFunction:null,baseTimer:{next:null},going:false,_ticks:0,_timer_start_time:null,interval:10,currentTime:(new Date).getTime(),
enableCSSTransitions:false,stats:SC.Object.create({lastFPS:0}),addTimer:function(a){if(!a.isQueued){a.prev=SC.Animatable.baseTimer;if(a.next=SC.Animatable.baseTimer.next)SC.Animatable.baseTimer.next.prev=a;SC.Animatable.baseTimer.next=a;a.isQueued=true;SC.Animatable.going||SC.Animatable.start()}},removeTimer:function(a){if(a.isQueued){if(a.next)a.next.prev=a.prev;a.prev.next=a.next;a.isQueued=false}},start:function(){SC.Animatable._ticks=0;SC.Animatable._timer_start_time=(new Date).getTime();SC.Animatable.going=
true;setTimeout(SC.Animatable.timeout,0)},timeout:function(){SC.Animatable.currentTime=(new Date).getTime();var a=SC.Animatable.currentTime,b=SC.Animatable.baseTimer.next;SC.Animatable.baseTimer.next=null;for(var c=0;b;){var d=b.next;b.isQueued=false;b.next=null;b.prev=null;b.action.call(b,a);b=d;c++}SC.Animatable._ticks<1E6&&SC.Animatable._ticks++;b=(new Date).getTime();a=b-a;if(SC.Animatable.baseTimer.next)setTimeout(function(){SC.Animatable.timeout()},Math.max(0,SC.Animatable.interval-a));else{SC.Animatable.going=
false;a=b-SC.Animatable._timer_start_time;b=SC.RunLoop.begin();SC.Animatable.stats.set("lastFPS",SC.Animatable._ticks/(a/1E3));b.end()}}});(function(){if(function(){var a=document.createElement("div"),b=["-webkit"],c=["moz","Moz","o","ms","webkit"],d="",e=null;for(e=0;e<b.length;e++)d+=b[e]+"-transition:all 1s linear;";a.style.cssText=d;for(e=0;e<c.length;e++)if(a.style[c[e]+"TransitionProperty"]!==undefined)return true;return false}())SC.Animatable.enableCSSTransitions=true})();tiki.script("sproutcore/animation:en/2ba607ab369dda8bd146e581906ea3ce82dd2abb/javascript.js");
tiki.register("sproutcore/core_tools",{packages:{"sproutcore/desktop":{stylesheets:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css",id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/stylesheet.css"}],scripts:[{url:"/static/sproutcore/desktop/en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js",id:"sproutcore/desktop:en/d04d0e999d88aafd88674367b08329da31eac5ab/javascript.js"}]}},depends:["sproutcore/desktop"],scripts:[{url:"/static/sproutcore/core_tools/en/43e301133b1f9cc0f187e8d5477638314d2427c5/javascript.js",
id:"sproutcore/core_tools:en/43e301133b1f9cc0f187e8d5477638314d2427c5/javascript.js"}]});tiki.global("sproutcore/core_tools");tiki.script("sproutcore/core_tools:en/43e301133b1f9cc0f187e8d5477638314d2427c5/javascript.js");tiki.register("sproutcore/datejs",{scripts:[{url:"/static/sproutcore/datejs/en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js",id:"sproutcore/datejs:en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js"}]});tiki.script("sproutcore/datejs:en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js");
tiki.register("sproutcore/debug",{scripts:[{url:"/static/sproutcore/debug/en/ced8f13f56ee44e96dec8557edb9570d68730e6c/javascript.js",id:"sproutcore/debug:en/ced8f13f56ee44e96dec8557edb9570d68730e6c/javascript.js"}]});SC=SC||{};SC._mapDisplayNamesUseHashForSeenTypes=["object","number","boolean","array","string","function","class","undefined","error"];
SC.mapDisplayNames=function(a,b,c,d,e){if(SC.browser.safari){if(!SC._mapDisplayNamesUseHashForSeenTypesHash){for(var f=SC._mapDisplayNamesUseHashForSeenTypes,g={},h=f.length,i=0;i<h;++i)g[f[i]]=true;SC._mapDisplayNamesUseHashForSeenTypesHash=g}if(a===undefined)a=window;if(b===undefined)b=0;if(c===undefined)c=[];if(d===undefined)d={};if(e===undefined)e=[];if(!(b>5)){f=!!SC._mapDisplayNamesUseHashForSeenTypesHash[SC.typeOf(a)];var j;if(f){j=SC.hashFor(a);g=d[j]}else g=e;if(!(g&&g.indexOf(a)!==-1)){if(g)g.push(a);
else if(f)d[j]=[a];j=c.length;c[j]="";for(var k in a)if(!(a.hasOwnProperty&&!a.hasOwnProperty(k)))if(isNaN(Number(k)))if(k!=="constructor")if(k!=="superclass")if(k!=="document"){f=a[k];if(k==="SproutCore")k="SC";g=SC.typeOf(f);if(g===SC.T_FUNCTION){if(!f.displayName){c[j]=k;g=c.join(".").replace(".prototype.","#");f.displayName=g}if(f.prototype){c.push("prototype");SC.mapDisplayNames(f.prototype,b+1,c,d,e);c.pop()}}else if(g===SC.T_CLASS){c[j]=k;SC.mapDisplayNames(f,b+1,c,d,e)}else if(k.indexOf("_")!==
0&&(g===SC.T_OBJECT||g===SC.T_HASH)){c[j]=k;SC.mapDisplayNames(f,b+1,c,d,e)}}c.pop()}}}};SC=SC||{};
SC.addInvokeOnceLastDebuggingInfo=function(){SC.ObserverSet.add=function(a,b,c,d,e,f){var g=a?SC.guidFor(a):"__this__",h=this[g];if(!h){h=this[g]=SC.CoreSet.create();h.target=a;h.isTargetSet=YES;this.targets++}h.add(b);if(c!==undefined){a=h.contexts;c||(a={});a[SC.guidFor(b)]=c}if(e!==undefined){c=h.originatingTargets;a=h.originatingMethods;g=h.originatingStacks;if(!c)c=h.originatingTargets={};if(!a)a=h.originatingMethods={};if(!g)g=h.originatingStacks={};b=SC.guidFor(b);if((h=a[b])&&SC.typeOf(h)!==
SC.T_ARRAY){var i=g[b];c[b]=[c[b],d];a[b]=[h,e];g[b]=[i,f]}else{c[b]=d;a[b]=e;g[b]=f}}this._membersCacheIsValid=NO};SC.ObserverSet.invokeMethods=function(){for(var a in this)if(this.hasOwnProperty(a)){var b=this[a];if(b&&b.isTargetSet)for(var c=b.length,d=b.target,e,f=SC.LOG_RUNLOOP_INVOCATIONS;--c>=0;){e=b[c];if(f){var g=e.displayName||e,h=SC.guidFor(e),i=b.originatingTargets[h],j=b.originatingMethods[h];h=b.originatingStacks[h];if(j&&SC.typeOf(j)===SC.T_ARRAY){console.log("Invoking runloop-scheduled method %@ on %@, which was scheduled by multiple target/method pairs:".fmt(g,
d));var k,l,m,o;g=0;for(k=j.length;g<k;++g){l=i[g];m=j[g];m=m.displayName||m;o=h[g];console.log("[%@]  originated by target %@,  method %@,  stack:".fmt(g,l,m),o)}}else console.log("Invoking runloop-scheduled method %@ on %@.  Originated by target %@,  method %@,  stack: ".fmt(g,d,i,j.displayName||j),h)}e.call(d)}}};SC.Object.prototype.invokeOnce=function(a){var b=this;if(SC.LOG_RUNLOOP_INVOCATIONS){originatingStack=SC.getRecentStack();originatingMethod=originatingStack[0]}else{originatingStack=null;
originatingMethod=arguments.callee.caller}SC.RunLoop.currentRunLoop.invokeOnce(this,a,b,originatingMethod,originatingStack);return this};SC.Object.prototype.invokeLast=function(a){var b=this,c,d;if(SC.LOG_RUNLOOP_INVOCATIONS){c=SC.getRecentStack();d=c[0]}else{c=null;d=arguments.callee.caller}SC.RunLoop.currentRunLoop.invokeLast(this,a,b,d,c);return this};SC.RunLoop.prototype.invokeOnce=function(a,b,c,d,e){c||(c=null);if(!d)if(SC.LOG_RUNLOOP_INVOCATIONS){e=SC.getRecentStack();d=e[0]}else{e=null;d=
arguments.callee.caller}if(b===undefined){b=a;a=this}if(SC.typeOf(b)===SC.T_STRING)b=a[b];if(!this._invokeQueue)this._invokeQueue=SC.ObserverSet.create();this._invokeQueue.add(a,b,null,c,d,e);return this};SC.RunLoop.prototype.invokeLast=function(a,b,c,d,e){c||(c=null);if(!d)if(SC.LOG_RUNLOOP_INVOCATIONS){e=SC.getRecentStack();d=e[0]}else{e=null;d=arguments.callee.caller}if(b===undefined){b=a;a=this}if(SC.typeOf(b)===SC.T_STRING)b=a[b];if(!this._invokeLastQueue)this._invokeLastQueue=SC.ObserverSet.create();
this._invokeLastQueue.add(a,b,null,c,d,e);return this};SC.getRecentStack=function(){for(var a=arguments.callee.caller,b=0,c={},d=YES,e;a&&b<6;){if(d)d=NO;else{e=a.displayName||a.toString();c[b++]=e}a=a.caller}return c}};tiki.script("sproutcore/debug:en/ced8f13f56ee44e96dec8557edb9570d68730e6c/javascript.js");
tiki.register("sproutcore/designer",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css",id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js",
id:"sproutcore/foundation:en/08011d4c986534c14a166d04e7c3aead93e9ceae/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/designer/en/c31f4a999b308340c034ef4ae90087615be810b2/stylesheet.css",id:"sproutcore/designer:en/c31f4a999b308340c034ef4ae90087615be810b2/stylesheet.css"}],depends:["sproutcore/runtime","sproutcore/foundation"],scripts:[{url:"/static/sproutcore/designer/en/c31f4a999b308340c034ef4ae90087615be810b2/javascript.js",id:"sproutcore/designer:en/c31f4a999b308340c034ef4ae90087615be810b2/javascript.js"}]});
tiki.global("sproutcore/designer");tiki.script("sproutcore/designer:en/c31f4a999b308340c034ef4ae90087615be810b2/javascript.js");tiki.register("sproutcore/empty_theme",{scripts:[{url:"/static/sproutcore/empty_theme/en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js",id:"sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js"}]});tiki.module("sproutcore/empty_theme:index",function(){});tiki.script("sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js");
tiki.register("sproutcore/mini",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js",id:"sproutcore/runtime:en/15e447c5c26c99b3ab764060e903e7e13fcea42b/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js",id:"sproutcore/datastore:en/13640fbbf9b7306554106c0144025d970a92b30d/javascript.js"}]}},depends:["sproutcore/runtime","sproutcore/datastore"],
scripts:[{url:"/static/sproutcore/mini/en/860d2cb132bc57cdeaf48df9016f2f9de33c5698/javascript.js",id:"sproutcore/mini:en/860d2cb132bc57cdeaf48df9016f2f9de33c5698/javascript.js"}]});tiki.global("sproutcore/mini");tiki.script("sproutcore/mini:en/860d2cb132bc57cdeaf48df9016f2f9de33c5698/javascript.js");
tiki.register("sproutcore/standard_theme",{packages:{"sproutcore/empty_theme":{scripts:[{url:"/static/sproutcore/empty_theme/en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js",id:"sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/standard_theme/en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/stylesheet.css",id:"sproutcore/standard_theme:en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/stylesheet.css"}],depends:["sproutcore/empty_theme"],
scripts:[{url:"/static/sproutcore/standard_theme/en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/javascript.js",id:"sproutcore/standard_theme:en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/javascript.js"}]});tiki.module("sproutcore/standard_theme:index",function(){});tiki.script("sproutcore/standard_theme:en/a56ea1a2b3ce510f45a5406d71a926f32602d18e/javascript.js");
tiki.register("sproutcore/testing",{stylesheets:[{url:"/static/sproutcore/testing/en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css",id:"sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css"}],scripts:[{url:"/static/sproutcore/testing/en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js",id:"sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js"}]});tiki.script("sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js");
tiki.register("bespin",{});
tiki.module("bespin:builtins",function(a,b){b.metadata={bespin:{provides:[{ep:"extensionpoint",name:"extensionpoint",description:"Use the 'extensionpoint' extension point to define new extension points. You can provide an 'indexOn' property to name a property of extensions through which you'd like to be able to easily look up the extension. You can also provide a 'register' and 'unregister' properties which are pointers to functions that are called whenever a new extension is discovered or removed, respectively. 'register' and 'unregister' should be used sparingly, because your plugin will be loaded whenever a matching plugin is available."},{ep:"extensionpoint",
name:"extensionhandler",description:"extensionhandlers are able to have 'register' and 'unregister' pointers to functions that are called with each extension as it is discovered or unregistered. Use 'register' sparingly as your plugin will be loaded automatically if there is a matching extension (and not just when your extension's functionality is required)."},{ep:"extensionpoint",name:"startup",description:"A function that should be called at startup. This should be used sparingly, as these plugins will be eagerly loaded at the beginning. All that's needed for this extension point is a pointer to a function that takes no arguments.",
register:"plugins#startupHandler"},{ep:"extensionpoint",name:"factory",description:"Provides a factory for singleton components. Each extension needs to provide a name, a pointer and an action. The action can be 'call' (if the pointer refers to a function), 'create' (if the pointer refers to an SC.Object), 'new' (if the pointer refers to a traditional JS object) or 'value' (if the pointer refers to the object itself that is the component).",indexOn:"name"},{ep:"factory",name:"hub",action:"create",
pointer:"util/hub#Hub"},{ep:"extensionpoint",name:"command",description:"Editor commands/actions. TODO: list parameters here."}]}}});
tiki.module("bespin:editor/mixins/textinput",function(a,b){var c=a("sproutcore/runtime").SC;b.TextInput={_TextInput_composing:false,_TextInput_ignore:false,_TextInput_textFieldId:undefined,_TextInput_textFieldDom:undefined,_isChrome:!!parseFloat(navigator.userAgent.split("Chrome/")[1]),_TextInput_textFieldChanged:function(){if(!(this._TextInput_composing||this._TextInput_ignore)){var d=this._TextInput_textFieldDom,e=d.value;if(e!=""){d.value="";this._TextInput_textInserted(e)}}},_TextInput_copy:function(){var d=
false;if(this.respondsTo("copy")){c.RunLoop.begin();d=this.copy();c.RunLoop.end()}return d},_TextInput_cut:function(){var d=false;if(this.respondsTo("cut")){c.RunLoop.begin();d=this.cut();c.RunLoop.end()}return d},_TextInput_textInserted:function(d){if(this.respondsTo("textInserted")){c.RunLoop.begin();this.textInserted(d);c.RunLoop.end()}},_TextInput_setValueAndSelect:function(d){var e=this._TextInput_textFieldDom;e.value=d;e.select()},focusTextInput:function(){this._TextInput_textFieldDom.focus()},
unfocusTextInput:function(){this._TextInput_textFieldDom.blur()},render:function(d,e){arguments.callee.base.apply(this,arguments);if(e){var f=this.get("frame"),g=d.begin("textarea");this._TextInput_textFieldId=c.guidFor(g);g.id(this._TextInput_textFieldId);g.attr("style","position: absolute; z-index: -99999; top: 0px; left: 0px; width: %@px; height: %@px".fmt(f.width,f.height));g.end()}},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);var d=this.$("#"+this._TextInput_textFieldId)[0];
this._TextInput_textFieldDom=d;var e=this;if(c.browser.safari){this._isChrome||d.addEventListener("compositionend",function(i){e._TextInput_textInserted(i.data)},false);d.addEventListener("textInput",function(i){e._TextInput_textInserted(i.data)},false);d.addEventListener("paste",function(i){e._TextInput_textInserted(i.clipboardData.getData("text/plain"))},false)}else{var f=function(){e._TextInput_textFieldChanged()};d.addEventListener("keypress",f,false);d.addEventListener("keyup",f,false);d.addEventListener("compositionstart",
function(){e._TextInput_composing=true},false);d.addEventListener("compositionend",function(){e._TextInput_composing=false;e._TextInput_textFieldChanged()},false);d.addEventListener("paste",function(){e._TextInput_setValueAndSelect("");window.setTimeout(function(){e._TextInput_textFieldChanged()},0)},false)}d.addEventListener("keydown",function(i){switch(i.keyCode){case 13:i.stopPropagation();break}},false);var g=function(i){i=i.type.indexOf("copy")!=-1?e._TextInput_copy():e._TextInput_cut();e._TextInput_setValueAndSelect(i)};
if(c.browser.isSafari&&!this._isChrome&&c.browser.isMac){var h=(new Date).getTime();f=function(i){var j=i.type.indexOf("cut")!=-1;if(!(j&&(new Date).getTime()-h<10)){g(i);if(j)h=(new Date).getTime()}};d.addEventListener("beforecopy",f,false);d.addEventListener("beforecut",f,false)}else{f=false;if(c.browser.isMozilla)f=function(i){g(i);if(c.browser.isMozilla){e._TextInput_ignore=true;window.setTimeout(function(){e._TextInput_setValueAndSelect("");e._TextInput_ignore=false},0)}};d.addEventListener("copy",
f||g,false);d.addEventListener("cut",f||g,false)}d.addEventListener("blur",function(){e.resignFirstResponder()},false)},mouseDown:function(){arguments.callee.base.apply(this,arguments);this.get("pane").makeFirstResponder(this)},willBecomeKeyResponderFrom:function(){arguments.callee.base.apply(this,arguments);this.focusTextInput()},willLoseKeyResponderTo:function(){arguments.callee.base.apply(this,arguments);this.unfocusTextInput()}}});
tiki.module("bespin:globals",function(a){var b=a("sproutcore/runtime").SC;(function(){if(!Array.isArray)Array.isArray=function(c){return c&&Object.prototype.toString.call(c)=="[object Array]"};if(!Function.prototype.bind)Function.prototype.bind=function(){var c=Array.prototype.slice.call(arguments),d=this,e=function(){return d.call.apply(d,c.concat(Array.prototype.slice.call(arguments)))};e.name=this.name;e.displayName=this.displayName;e.length=this.length;e.unbound=d;return e};b.Object.prototype.sc_super=
function c(){c.caller.base.apply(this,c.caller.arguments)};b.objectForPropertyPathOriginal=b.objectForPropertyPath;b.objectForPropertyPath=function(c,d,e){e=e==undefined?c.length:e;var f=c.split("#");if(f.length==1)return b.objectForPropertyPathOriginal(c,d,e);c=a(f[0]);if(c!==undefined){e-=f[0].length;return b.objectForPropertyPathOriginal(f[1],c,e)}}})()});
tiki.module("bespin:plugins",function(a,b){var c=a("sproutcore/runtime").SC;a("globals");var d=a("promise").Promise,e=a("builtins"),f=a.loader,g=Object.keys;g||(g=function(l){var m,o=[];for(m in l)l.hasOwnProperty(m)&&o.push(m);return o});var h=function(l,m){if(m){m=m.split("#");return{modName:m[0]?l+":"+m[0]:l,objName:m[1]}}},i=function(l){var m=a(l.modName);if(l.objName)return m[l.objName];return m};b.Extension=c.Object.extend({_getPointer:function(l){l=l||"pointer";return h(this._pluginName,this.get(l))},
init:function(){this._observers=[]},load:function(l,m){var o=this._getPointer(m);if(!o){console.error("Extension cannot be loaded because it has no 'pointer'");console.log(this);return null}var r=new d;f.async(this._pluginName).then(function(){c.run(function(){var w=a(o.modName);w=o.objName?w[o.objName]:w;l&&l(w);r.resolve(w)})});return r},observe:function(l,m,o){this._observers.push({plugin:l,callback:m,property:o});this.load(m,o)},_getLoaded:function(l){l=this._getPointer(l);return i(l)}});b.ExtensionPoint=
c.Object.extend({init:function(){this.extensions=[];this.handlers=[]},getByKey:function(l){var m=this.get("indexOn");if(m)for(var o=0;o<this.extensions.length;o++)if(this.extensions[o][m]==l)return this.extensions[o]},register:function(l){this.extensions.push(l);this.handlers.forEach(function(m){m.register&&m.load(function(o){o(l)},"register")})},unregister:function(l){this.extensions.removeObject(l);this.handlers.forEach(function(m){m.unregister&&m.load(function(o){o(l)},"unregister")})}});b.Plugin=
c.Object.extend({register:function(){var l=this;this.provides.forEach(function(m){l.get("catalog").getExtensionPoint(m.ep).register(m)})},unregister:function(){var l=this;this.provides.forEach(function(m){l.get("catalog").getExtensionPoint(m.ep).unregister(m)})},_getObservers:function(){var l={};this.provides.forEach(function(m){console.log("ep: ",m.ep);console.log(m._observers);l[m.ep]=m._observers});return l},_findDependents:function(l,m){var o=this.name,r=this;l.forEach(function(w){if(w!=o){var p=
r.catalog.plugins[w];p&&p.depends&&p.depends.forEach(function(s){if(s==o&&!m[w]){m[w]={keepModule:false};p._findDependents(l,m)}})}})},reload:function(l){var m,o;if(this.get("reloadURL")){var r=this.name,w=this.get("reloadPointer");if(w){w=h(r,w);if(m=i(w))m();else{console.error("Reload function could not be loaded. Aborting reload.");return}}var p={},s=this;this._findDependents(g(this.catalog.plugins),p);var v={pluginName:r,dependents:p};for(o in p){w=this.catalog.plugins[o];if(w.preRefresh){w=h(o,
w.preRefresh);if(m=i(w))p[o]=m(v)}}this.unregister();for(o in p)this.catalog.plugins[o].unregister();w=new RegExp("^"+r+":");j(w,f.scripts);j(w,f.modules,function(n){delete f._factories[n]});j(w,f.stylesheets);j(new RegExp("^"+r+"$"),f.packages);var t=f._promises;delete t.catalog[r];delete t.loads[r];k(w,t.modules);k(w,t.scripts);k(w,t.stylesheets);delete f._catalog[r];t=[];var z=f.sandbox,u=z.modules.length,A=[];for(o in p)p[o].keepModule||A.push(new RegExp("^"+o+":"));for(;--u>=0;){var E=z.modules[u];
if(w.exec(E))t.push(E);else for(var x=A.length;--x>=0;)if(A[x].exec(E)){t.push(E);break}}t.length>0&&z.clear.apply(z,t);this.catalog.loadMetadata(this.reloadURL,function(){f.async(r).then(function(){c.run(function(){for(o in p)s.catalog.plugins[o].register();for(o in p)if(p[o].callPointer){var n=h(o,p[o].callPointer);(m=i(n))&&m(v)}l&&l()})})})}}});b.Catalog=c.Object.extend({init:function(){this.points={};this.plugins={};this.getExtensionPoint("extensionpoint").set("indexOn","name");this.load(e.metadata)},
getObject:function(l){l=this.getExtensionByKey("factory",l);if(l!==undefined){var m=l.get("instance");if(m)return m;m=l._getLoaded();var o=l.action;if(o=="call")m=m();else if(o=="create")m=m.create();else if(o=="new")m=new m;else if(o=="value")m=m;else throw new Error("Create action must be call|create|new|value. Found"+o);l.set("instance",m);return m}},getExtensionPoint:function(l){if(this.points[l]===undefined)this.points[l]=b.ExtensionPoint.create({name:l,catalog:this});return this.points[l]},
getExtensions:function(l){l=this.getExtensionPoint(l);if(l===undefined)return[];return l.extensions},getExtensionByKey:function(l,m){l=this.getExtensionPoint(l);if(l!==undefined)return l.getByKey(m)},_registerExtensionPoint:function(l){var m=this.getExtensionPoint(l.name);m.handlers.push(l);l.indexOn&&m.set("indexOn",l.indexOn)},_registerExtensionHandler:function(l){var m=this.getExtensionPoint(l.name);m.handlers.push(l);l.register&&l.load(function(o){if(!o)throw l.name+" is not ready";m.extensions.forEach(function(r){o(r)})},
"register")},load:function(l){for(var m in l){var o=l[m];o.catalog=this;if(o.provides)for(var r=o.provides,w=0;w<r.length;w++){var p=b.Extension.create(r[w]);p._pluginName=m;r[w]=p;var s=p.ep;if(s=="extensionpoint")this._registerExtensionPoint(p);else s=="extensionhandler"&&this._registerExtensionHandler(p);this.getExtensionPoint(p.ep).register(p)}else o.provides=[];o.name=m;o=b.Plugin.create(o);this.plugins[m]=o}},loadPlugin:function(l,m){l=f.async(l);m&&l.then(m,function(o){console.error("Plugin loading canceled: ",
o)})},loadMetadata:function(l,m){c.Request.create({address:l}).notify(0,this,this._metadataFinishedLoading,{callback:m}).send("")},getResourceURL:function(l){l=this.plugins[l];if(l!=undefined)return l.resourceURL},_metadataFinishedLoading:function(l,m){if(!l.isError){var o=l.body();o=JSON.parse(o);for(var r in o)if(o[r].errors){console.error("Plugin ",r," has errors:");o[r].errors.forEach(function(w){console.error(w)});delete o[r]}else f.register(r,o[r]);this.load(o)}m.callback&&m.callback(this,l)}});
var j=function(l,m,o){for(var r=0;r<m.length;)if(l.exec(m[r])){var w=m.splice(r,1);o&&o(w)}else r++},k=function(l,m){for(var o=g(m),r=o.length;--r>0;)l.exec(o[r])&&delete m[o[r]]};b.catalog=b.Catalog.create();b.startupHandler=function(l){l.load(function(m){m()})}});
tiki.module("bespin:promise",function(a,b){function c(){return new d}function d(k,l){function m(A){if(w)throw new Error("This deferred has already been resolved");r=A;w=true;if(l&&p&&s.length===0)throw r;for(A=0;A<s.length;A++)o(s[A])}function o(A){var E=p?A.error:A.resolved;if(E){v=true;g(function(){z&&z.resume();try{var x=E(r);x&&typeof x.then==="function"?x.then(A.deferred.resolve,A.deferred.reject):A.deferred.resolve(x)}catch(n){console.error("promise caught exception ",n);console.log(f({e:n}));
A.deferred.reject(n)}finally{z&&z.suspend()}})}else A.deferred[p?"reject":"resolve"](r)}var r,w,p,s=[],v,t=this.promise=new i,z=j.getHandler&&j.getHandler();this.resolve=this.callback=this.emitSuccess=function(A){m(A)};var u=function(A){p=true;m(A)};this.reject=this.errback=this.emitError=l?u:function(A){return g(function(){u(A)})};this.progress=function(A){for(var E=0;E<s.length;E++){var x=s[E].progress;x&&x(A)}};this.then=t.then=function(A,E,x){var n=new d(t.cancel,true);A={resolved:A,error:E,progress:x,
deferred:n};w?o(A):s.push(A);return n.promise};if(k)this.cancel=t.cancel=function(){var A=k();A instanceof Error||(A=new Error(A));u(A)};this.valueIfResolved=function(){return w?r:null}}function e(k,l,m){try{if((k=k&&typeof k.then==="function"?l(k):m(k))&&typeof k.then==="function")return k;var o=new d;o.resolve(k);return o.promise}catch(r){console.error("promise caught exception: ",r);console.log(f({e:r}));o=new d;o.reject(r);return o.promise}}var f=a("bespin:util/stacktrace").printStackTrace;try{var g=
a("event-queue").enqueue}catch(h){}g||(g=function(k){k()});var i=function(){};i.prototype.then=function(){throw new TypeError("The Promise base class is abstract, this function must be implemented by the Promise implementation");};i.prototype.get=function(k){return this.then(function(l){return l[k]})};i.prototype.put=function(k,l){return this.then(function(m){return m[k]=l})};i.prototype.call=function(){return this.then(function(k){return k[propertyName].apply(k,Array.prototype.slice.call(arguments,
1))})};i.prototype.addCallback=function(k){return this.then(k)};i.prototype.addErrback=function(k){return this.then(function(){},k)};i.prototype.addBoth=function(k){return this.then(k,k)};i.prototype.addCallbacks=function(k,l){return this.then(k,l)};i.prototype.wait=function(){return b.wait(this)};d.prototype=i.prototype;b.Promise=b.Deferred=b.defer=c;var j=b.contextHandler={};b.whenPromise=function(k,l,m,o){return e(k,function(r){return r.then(l,m,o)},function(r){return l(r)})};b.when=function(k,
l,m,o){if(k&&typeof k.then==="function")return b.whenPromise(k,l,m,o);return l(k)};b.get=function(k,l){return e(k,function(m){return m.get(l)},function(m){return m[l]})};b.post=function(k,l,m){return e(k,function(o){return o.call(property,m)},function(o){return o[l].apply(o,m)})};b.put=function(k,l,m){return e(k,function(o){return o.put(l,m)},function(o){return o[l]=m})};b.wait=function(k){if(!queue)throw new Error("Can not wait, the event-queue module is not available");if(k&&typeof k.then==="function"){var l,
m,o;for(k.then(function(r){l=true;o=r},function(r){m=l=true;o=r});!l;)queue.processNextEvent(true);if(m)throw o;return o}else return k};b.group=function(k){var l=c();k instanceof Array||(k=Array.prototype.slice.call(arguments));var m=0,o=k.length;if(!o){l.resolve([]);return l.promise}var r=[];k.forEach(function(w,p){b.when(w,function(s){r[p]=s;m++;m===o&&l.resolve(r)},l.reject)});return l.promise}});
tiki.module("bespin:theme",function(a,b){a=a("sproutcore/runtime").SC;b.coffee={backgroundStyle:"#2A211C",gutterStyle:"#4c4a41",lineNumberColor:"#e5c138",lineNumberFont:"10pt Monaco, Lucida Console, monospace",lineMarkerErrorColor:"#CC4444",lineMarkerWarningColor:"#B8860B",lineMarkerMessageColor:"green",zebraStripeColor:"#2A211C",highlightCurrentLineColor:"#3a312b",editorTextFont:"10pt Monaco, Lucida Console, monospace",editorTextColor:"rgb(230, 230, 230)",editorSelectedTextColor:"rgb(240, 240, 240)",
editorSelectedTextBackground:"#526DA5",cursorStyle:"#879aff",cursorType:"ibeam",unfocusedCursorStrokeStyle:"#FF0033",unfocusedCursorFillStyle:"#73171E",partialNibStyle:"rgba(100, 100, 100, 0.3)",partialNibArrowStyle:"rgba(255, 255, 255, 0.3)",partialNibStrokeStyle:"rgba(150, 150, 150, 0.3)",fullNibStyle:"rgb(100, 100, 100)",fullNibArrowStyle:"rgb(255, 255, 255)",fullNibStrokeStyle:"rgb(150, 150, 150)",scrollTrackFillStyle:"rgba(50, 50, 50, 0.8)",scrollTrackStrokeStyle:"rgb(150, 150, 150)",scrollBarFillStyle:"rgba(0, 0, 0, %a)",
scrollBarFillGradientTopStart:"rgba(90, 90, 90, %a)",scrollBarFillGradientTopStop:"rgba(40, 40, 40, %a)",scrollBarFillGradientBottomStart:"rgba(22, 22, 22, %a)",scrollBarFillGradientBottomStop:"rgba(44, 44, 44, %a)",tabSpace:"#392A25",searchHighlight:"#B55C00",searchHighlightSelected:"#FF9A00",plain:"#bdae9d",keyword:"#42a8ed",string:"#039a0a",comment:"#666666","c-comment":"#666666",punctuation:"#888888",attribute:"#BF9464",test:"rgb(255,0,0)",cdata:"#bdae9d","attribute-value":"#039a0a",tag:"#46a8ed",
color:"#c4646b","tag-name":"#46a8ed",value:"#039a0a",important:"#990000",sizes:"#990000",cssclass:"#BF9464",cssid:"#46a8ed",atom:"#aa4444",variable:"#00cccc",variabledef:"#4422cc",localvariable:"#cc2277",property:"#66bb33",operator:"#88bbff",error:"#FF0000",processing:"#999999",entity:"#AA2222",text:"#00BB00","compile-time-constant":"#776088","predefined-constant":"#33CC33","reserved-language-construct":"#00FF00","predefined-function":"#22FF22","predefined-class":"#22FF22",literal:"#DD4411",identifier:"#22FF22",
func:"#2200FF",type:"#8822FF",decorator:"#2222FF"};b.coffeezebra={};a.mixin(b.coffeezebra,b.coffee);b.coffeezebra.zebraStripeColor="#FFFFFF";b["default"]=b.coffee});
tiki.module("bespin:util/cookie",function(a,b){var c=function(d,e){return d.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(f){if(e&&e.indexOf(f)!=-1)return f;return"\\"+f})};b.get=function(d){d=new RegExp("(?:^|; )"+c(d)+"=([^;]*)");return(d=document.cookie.match(d))?decodeURIComponent(d[1]):undefined};b.set=function(d,e,f){f=f||{};if(typeof f.expires=="number"){var g=new Date;g.setTime(g.getTime()+f.expires*24*60*60*1E3);f.expires=g}if(f.expires&&f.expires.toUTCString)f.expires=f.expires.toUTCString();
e=encodeURIComponent(e);d=d+"="+e;var h;for(h in f){d+="; "+h;e=f[h];if(e!==true)d+="="+e}document.cookie=d};b.remove=function(d){b.set(d,"",{expires:-1})};b.isSupported=function(){if(!("cookieEnabled"in navigator)){b.set("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=b.get("__djCookieTest__")=="CookiesAllowed";navigator.cookieEnabled&&b.remove("__djCookieTest__")}return navigator.cookieEnabled}});
tiki.module("bespin:util/scratchcanvas",function(a,b){var c=a("sproutcore/runtime").SC,d=c.Object.extend({getContext:function(){return document.getElementById("bespin-scratch-canvas").getContext("2d")},init:function(){if(c.none(document.getElementById("bespin-scratch-canvas"))){var f=document.createElement("canvas");f.id="bespin-scratch-canvas";f.width=400;f.height=300;f.style.position="absolute";f.style.top="-10000px";f.style.left="-10000px";document.body.appendChild(f)}},measureStringWidth:function(f,
g){if(c.none(g))g="M";var h=this.getContext();h.save();h.font=f;f=h.measureText(g).width;h.restore();return f}}),e=null;b.get=function(){if(e===null)e=d.create();return e}});
tiki.module("bespin:util/stacktrace",function(a,b){var c=b.printStackTrace=function(d){var e=d&&d.e?d.e:null;d=d&&d.guess?d.guess:false;var f=new c.implementation;e=f.run(e);return d?f.guessFunctions(e):e};c.implementation=function(){};c.implementation.prototype={run:function(d){var e=this._mode||this.mode();if(e==="other")return this.other(arguments.callee);else{d=d||function(){try{0()}catch(f){return f}}();return this[e](d)}},mode:function(){try{0()}catch(d){if(d.arguments)return this._mode="chrome";
if(d.stack)return this._mode="firefox";if(window.opera&&!("stacktrace"in d))return this._mode="opera"}return this._mode="other"},chrome:function(d){return d.stack.replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(d){return d.stack.replace(/^.*?\n/,"").replace(/(?:\n@:0)?\s+$/m,"").replace(/^\(/gm,"{anonymous}(").split("\n")},opera:function(d){d=
d.message.split("\n");var e=/Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i,f,g,h;f=4;g=0;for(h=d.length;f<h;f+=2)if(e.test(d[f]))d[g++]=(RegExp.$3?RegExp.$3+"()@"+RegExp.$2+RegExp.$1:"{anonymous}()@"+RegExp.$2+":"+RegExp.$1)+" -- "+d[f+1].replace(/^\s+/,"");d.splice(g,d.length-g);return d},other:function(d){for(var e=/function\s*([\w\-$]+)?\s*\(/i,f=[],g=0,h,i;d&&f.length<10;){h=e.test(d.toString())?RegExp.$1||"{anonymous}":"{anonymous}";i=Array.prototype.slice.call(d.arguments);
f[g++]=h+"("+c.implementation.prototype.stringifyArguments(i)+")";if(d===d.caller&&window.opera)break;d=d.caller}return f},stringifyArguments:function(d){for(var e=0;e<d.length;++e){var f=d[e];if(typeof f=="object")d[e]="#object";else if(typeof f=="function")d[e]="#function";else if(typeof f=="string")d[e]='"'+f+'"'}return d.join(",")},sourceCache:{},ajax:function(d){var e=this.createXMLHTTPObject();if(e){e.open("GET",d,false);e.setRequestHeader("User-Agent","XMLHTTP/1.0");e.send("");return e.responseText}},
createXMLHTTPObject:function(){for(var d,e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],f=0;f<e.length;f++)try{d=e[f]();this.createXMLHTTPObject=e[f];return d}catch(g){}},getSource:function(d){d in this.sourceCache||(this.sourceCache[d]=this.ajax(d).split("\n"));return this.sourceCache[d]},guessFunctions:function(d){for(var e=0;e<d.length;++e){var f=
d[e],g=/{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/.exec(f);if(g){var h=g[1];g=g[4];if(h&&g){h=this.guessFunctionName(h,g);d[e]=f.replace("{anonymous}",h)}}}return d},guessFunctionName:function(d,e){try{return this.guessFunctionNameFromLines(e,this.getSource(d))}catch(f){return"getSource failed with url: "+d+", exception: "+f.toString()}},guessFunctionNameFromLines:function(d,e){for(var f=/function ([^(]*)\(([^)]*)\)/,g=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,
h="",i=0;i<10;++i){h=e[d-i]+h;if(h!==undefined){var j=g.exec(h);if(j)return j[1];else j=f.exec(h);if(j&&j[1])return j[1]}}return"(?)"}}});
tiki.module("bespin:util/util",function(a,b){b.queryToObject=function(g,h){var i={};g=g.split(h||"&");var j=decodeURIComponent;g.forEach(function(k){if(k.length){var l=k.split("=");k=j(l.shift());l=j(l.join("="));if(b.isString(i[k]))i[k]=[i[k]];if(Array.isArray(i[k]))i[k].push(l);else i[k]=l}});return i};b.objectToQuery=function(g){var h=encodeURIComponent,i=[],j={};for(var k in g){var l=g[k];if(l!=j[k]){var m=h(k)+"=";if(_d.isArray(l))for(var o=0;o<l.length;o++)i.push(m+h(l[o]));else i.push(m+h(l))}}return i.join("&")};
var c=0,d={};b.rateLimit=function(g,h,i){if(g){var j=c++;return function(){d[j]&&clearTimeout(d[j]);d[j]=setTimeout(function(){i.apply(h,arguments);delete d[j]},g)}}};b.isString=function(g){return typeof g=="string"||g instanceof String};b.isObject=function(g){return g!==undefined&&(g===null||typeof g=="object"||Array.isArray(g)||b.isFunction(g))};b.isFunction=function(){var g=function(h){var i=typeof h;return h&&(i=="function"||h instanceof Function)&&!h.nodeType};return b.isSafari?function(h){if(typeof h==
"function"&&h=="[object NodeList]")return false;return g(h)}:g}();b.endsWith=function(g,h){if(!g)return false;return g.match(new RegExp(h+"$"))};b.include=function(g,h){return g.indexOf(h)>-1};b.indexOfProperty=function(g,h,i){for(var j=0;j<g.length;j++)if(g[j][h]==i)return j;return null};b.last=function(g){if(Array.isArray(g))return g[g.length-1]};b.shrinkArray=function(g){var h=[],i=true;g.reverse().forEach(function(j){if(!(i&&j===undefined)){i=false;h.push(j)}});return h.reverse()};b.makeArray=
function(g,h){if(g<1)return[];h||(h=" ");for(var i=[],j=0;j<g;j++)i.push(h);return i};b.repeatString=function(g,h){for(var i="",j=0;j<h;j++)i+=g;return i};b.leadingSpaces=function(g){for(var h=0,i=0;i<g.length;i++)if(g[i]==" "||g[i]==""||g[i]===undefined)h++;else return h;return h};b.leadingTabs=function(g){for(var h=0,i=0;i<g.length;i++)if(g[i]=="\t"||g[i]==""||g[i]===undefined)h++;else return h;return h};b.leadingWhitespace=function(g){for(var h=[],i=0;i<g.length;i++)if(g[i]==" "||g[i]=="\t"||g[i]==
""||g[i]===undefined)h.push(g[i]);else return h;return h};b.englishFromCamel=function(g){g.replace(/([A-Z])/g,function(h){return" "+h.toLowerCase()}).trim()};b.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"};a=navigator.userAgent;var e=navigator.appVersion;b.isLinux=e.indexOf("Linux")>=0;b.isWindows=e.indexOf("Win")>=0;b.isWebKit=parseFloat(a.split("WebKit/")[1])||undefined;b.isChrome=parseFloat(a.split("Chrome/")[1])||undefined;b.isMac=e.indexOf("Macintosh")>=0;if(a.indexOf("AdobeAIR")>=0)b.isAIR=
1;var f=Math.max(e.indexOf("WebKit"),e.indexOf("Safari"),0);if(f&&!b.isChrome){b.isSafari=parseFloat(e.split("Version/")[1]);if(!b.isSafari||parseFloat(e.substr(f+7))<=419.3)b.isSafari=2}if(a.indexOf("Gecko")>=0&&!b.isWebKit)b.isMozilla=parseFloat(e);b.getOS=function(){return b.isMac?b.OS.MAC:b.isLinux?b.OS.LINUX:b.OS.WINDOWS};b.contains=document.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)};b.stopEvent=function(g){g.preventDefault();
g.stopPropagation()};b.randomPassword=function(g){g=g||16;for(var h="",i=0;i<g;i++){var j=Math.floor(Math.random()*62);h+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".charAt(j)}return h};b.isEmpty=function(g){for(var h in g)if(g.hasOwnProperty(h))return false;return true};b.isMyProject=function(g){return g.indexOf("+")==-1};b.formatDate=function(g){if(!g)return"Unknown";return g.getDate()+" "+b.formatDate.shortMonths[g.getMonth()]+" "+g.getFullYear()};b.formatDate.shortMonths=
["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});
tiki.module("bespin:views/dock",function(a,b){var c=a("sproutcore/runtime").SC;b.DOCK_BOTTOM="bottom";b.DockView=c.View.extend({classNames:["bespin-dock-view"],centerView:c.View,dockedViews:[],addDockedView:function(d,e){var f=this.get("dockedViews");if(c.none(e))e=f.length;var g=this;d=this.createChildView(d,{layoutView:this,rootElementPath:[e],_bespin_dockView_frameDidChange:function(){g._updateChildLayout()}.observes("frame")});return f[e]=d},removeDockedView:function(d){this.get("dockedViews").removeObject(d);
this.removeChild(d);this._updateChildLayout()},createChildViews:function(){var d=this.createChildView(this.get("centerView"),{layoutView:this});this.set("centerView",d);d=[d];for(var e=this.get("dockedViews"),f=0;f<e.length;f++)d.push(this.addDockedView(e[f],f));this.set("childViews",d);return this},_updateChildLayout:function(){var d={left:0,bottom:0,top:0,right:0};this.get("dockedViews").forEach(function(e){var f=e.get("frame");e=e.get("dock");switch(e){case b.DOCK_BOTTOM:d.bottom+=f.height;break;
default:throw new Error("invalid 'dock' property: "+e);}});this.get("centerView").adjust(d)},renderLayout:function(){this._updateChildLayout();arguments.callee.base.apply(this,arguments)}})});tiki.module("bespin:index",function(){});tiki.register("AppSupport",{});
tiki.module("AppSupport:controllers/undomanager",function(a,b){a=a("sproutcore/runtime").SC;b.undoManager=a.Object.create({_redoStack:null,_undoStack:null,_undoOrRedo:function(c,d,e){if(d.length===0)return false;d=d.pop();if(!d.target[c](d.context)){this._redoStack=[];this._undoStack=[];return false}e.push(d);return true},init:function(){this._redoStack=[];this._undoStack=[]},redo:function(){return this._undoOrRedo("redo",this._redoStack,this._undoStack)},registerUndo:function(c,d){this._redoStack=
[];this._undoStack.push({target:c,context:d})},undo:function(){return this._undoOrRedo("undo",this._undoStack,this._redoStack)}});b.undoManagerCommand=function(c,d,e){b.undoManager[e.commandExt.name]()}});tiki.module("AppSupport:views/keylistener",function(a,b){var c=a("sproutcore/runtime").SC,d=a("Canon:keyboard").keyboardManager;b.KeyListener=c.Responder.extend({performKeyEquivalent:function(e,f){d.processKeyEvent(f,this,{isApplication:true})}})});tiki.module("AppSupport:index",function(){});
tiki.register("Types",{});
tiki.module("Types:basic",function(a,b){b.text={isValid:function(c){return typeof c=="string"},toString:function(c){return c},fromString:function(c){return c}};b.number={isValid:function(c){return typeof c=="number"},toString:function(c){return""+c},fromString:function(c){return parseInt(c,10)}};b.bool={isValid:function(c){return typeof c=="boolean"},toString:function(c){return""+c},fromString:function(c){return!!c}};b.object={isValid:function(c){return typeof c=="object"},toString:function(c){return JSON.stringify(c)},
fromString:function(c){return JSON.parse(c)}};b.selection={isValid:function(c,d){if(typeof c!="string")return false;if(!d.data){console.error("Missing data on selection type extension. Skipping");return true}var e=false;d.data.forEach(function(f){if(c==f)e=true});return e},toString:function(c){return c},fromString:function(c){return c}};b.deferred={isValid:function(c){return typeof c=="string"},toString:function(c){return c.toString()},fromString:function(c){return c}}});
tiki.module("Types:types",function(a,b){var c=a("bespin:plugins").catalog,d=a("bespin:promise").Promise;b.fromString=function(e,f){var g=new d;b.getTypeExt(f).then(function(h){h.load(function(i){i=i.fromString(e,h);g.resolve(i)})});return g};b.toString=function(e,f){var g=new d;b.getTypeExt(f).then(function(h){h.load(function(i){i=i.toString(e,h);g.resolve(i)})});return g};b.isValid=function(e,f){var g=new d;b.getTypeExt(f).then(function(h){h.load(function(i){i=i.isValid(e,h);g.resolve(i)})});return g};
b.getTypeExt=function(e){var f=new d,g;if(typeof e==="string"){var h=e.split(":");if(h.length===1)(g=c.getExtensionByKey("type",e))?f.resolve(g):f.reject("Unknown type: "+e);else{g=c.getExtensionByKey("type",h.shift());e=h.join(":");if(e.substring(0,1)=="["||e.substring(0,1)=="{"){g.data=JSON.parse(e);f.resolve(g)}else{h=e.split("#");var i=h.shift(),j=h.join("#");a.loader.async(i).then(function(){var k=a(i);g.data=k[j]();f.resolve(g)})}}}else if(typeof e==="object"){g=c.getExtensionByKey("type",e.name);
g.data=e.data;f.resolve(g)}return f}});tiki.module("Types:index",function(){});tiki.register("Canon",{});
tiki.module("Canon:commands",function(a,b){var c=a("bespin:util/util");a=a("plugins").catalog;var d=a.getObject("files"),e=a.getObject("editor"),f=a.getObject("editSession"),g=a.getObject("server");b.loadCommand=function(h,i,j){d.loadContents(d.userSettingsProject,"commands/"+i.commandname+".js",function(k){try{eval(k.content)}catch(l){j.doneWithError("Something is wrong about the command:<br><br>"+l)}},true)};b.editCommand=function(h,i){e.openFile(d.userSettingsProject,"commands/"+i.commandname+
".js",{content:"{\n    name: '"+i.commandname+"',\n    takes: [YOUR_ARGUMENTS_HERE],\n    preview: 'execute any editor action',\n    execute: function(self, args) {\n\n    }\n}",force:true})};b.listCommand=function(h,i,j){g.list(d.userSettingsProject,"commands/",function(k){if(!k||k.length<1)j.done("You haven't installed any custom commands.<br>Want to <a href='https://wiki.mozilla.org/Labs/Bespin/Roadmap/Commands'>learn how?</a>");else{var l="<u>Your Custom Commands</u><br/><br/>";k=k.filter(function(m){return c.endsWith(m.name,
"\\.js")});l+=k.map(function(m){return m.name.replace(/\.js$/,"")}).join("<br>");j.done(l)}})};b.deleteCommand=function(h,i,j){var k=d.userSettingsProject,l="commands/"+i.commandname+".js";d.removeFile(k,l,function(){f.checkSameFile(k,l)&&e.model.clear();j.done("Removed command: "+i.commandname)},function(m){j.done("Wasn't able to remove the command <b>"+i.commandname+"</b><br/><em>Error</em> (probably doesn't exist): "+m.responseText)})}});
tiki.module("Canon:environment",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:plugins").catalog;b.Environment=c.Object.extend({session:function(){return d.getObject("session")}.property(),view:function(){var e=this.get("session");if(e)return e.get("currentView");else console.error("command attempted to get view but there's no session")}.property(),model:function(){var e=this.get("session");if(e)if(e=e.get("currentBuffer"))return e.get("model");else console.error("Session has no current buffer");
else console.error("command attempted to get model but there's no session")}.property(),file:function(){var e=this.get("session");if(e)if(e=e.get("currentBuffer"))return e.get("file");else console.error("Session has no current buffer");else console.error("command attempted to get file but there's no session")}.property(),buffer:function(){var e=this.get("session");if(e)return e.get("currentBuffer");else console.error("command attempted to get buffer but there's no session")}.property(),files:function(){return d.getObject("files")}.property().cacheable()});
b.global=b.Environment.create()});
tiki.module("Canon:keyboard",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:plugins").catalog,e=a("Canon:request").Request,f=a("Canon:environment");a=c.Object.extend({processKeyEvent:function(g,h,i){var j=this._findCommandExtension(g.commandCodes()[0],i);if(j!=null){j.load(function(k){var l=e.create({command:k,commandExt:j});try{k(f.global,{},l);return true}catch(m){console.group("Error calling command: "+j.name);console.error(m);console.trace();console.groupEnd();return false}});return true}return false},
_findCommandExtension:function(g,h){var i=null;d.getExtensions("command").some(function(j){if(this._commandMatches(j,g,h)){i=j;return true}return false}.bind(this));return i},_commandMatches:function(g,h,i){var j=g.predicates;if(!c.none(j)){if(c.none(i))return false;for(var k in j)if(i[k]!==j[k])return false}j=g.key;if(!j)return false;if(typeof j=="string"){if(j!=h)return false;return true}if(!j.isArray){j=[j];g.key=j}for(g=0;g<j.length;g++){var l=j[g];if(typeof l=="string"){if(l==h)return true}else if(l.key==
h){j=l.predicates;if(!j)return true;for(k in j)if(!i||i[k]!=j[k])return false;return true}}return false}});b.keyboardManager=a.create()});
tiki.module("Canon:request",function(a,b){a=a("sproutcore/runtime").SC;b.history=a.Object.create({requests:[]});b.Request=a.Object.extend({command:null,commandExt:null,args:{},typed:null,outputs:[],start:new Date,end:null,duration:null,completed:false,error:false,_hack:"",_inited:false,_init:function(){this.set("_inited",true);b.history.requests.pushObject(this)},doneWithError:function(c){this.set("error",true).done(c)},async:function(){},output:function(c){this.get("_inited")||this._init();var d=
this.get("_hack");typeof c=="string"?this.set("_hack",d+c+"<br/>"):this.set("_hack",d+c.innerHTML+"<br/>");this.outputs.push(c);return this},done:function(c){c&&this.output(c);this.set("completed",true);this.set("end",new Date);this.set("duration",this.get("end").getTime()-this.get("start").getTime())}})});tiki.module("Canon:index",function(){});tiki.register("DelegateSupport",{});
tiki.module("DelegateSupport:index",function(a,b){a("sproutcore/runtime");b.MultiDelegateSupport={delegates:[],addDelegate:function(c){this.set("delegates",this.get("delegates").concat(c))},notifyDelegates:function(c){for(var d=[this],e=1;e<arguments.length;e++)d.push(arguments[e]);this.get("delegates").forEach(function(f){f.respondsTo(c)&&f[c].apply(f,d)})}}});tiki.register("RangeUtils",{});
tiki.module("RangeUtils:utils/range",function(a,b){var c=a("sproutcore/runtime").SC;b.addPositions=function(d,e){return{row:d.row+e.row,column:d.column+e.column}};b.comparePositions=function(d,e){var f=d.row-e.row;return f===0?d.column-e.column:f};b.extendRange=function(d,e){var f=d.end;return{start:d.start,end:{row:f.row+e.row,column:f.column+e.column}}};b.intersectRangeSets=function(d,e){d=c.clone(d);e=c.clone(e);for(var f=[];d.length>0&&e.length>0;){var g=d.shift(),h=e.shift(),i=b.comparePositions(g.start,
h.start),j=b.comparePositions(g.end,h.end);if(b.comparePositions(g.end,h.start)<0){f.push(g);e.unshift(h)}else if(b.comparePositions(h.end,g.start)<0){f.push(h);d.unshift(g)}else if(i<0){f.push({start:g.start,end:h.start});d.unshift({start:h.start,end:g.end});e.unshift(h)}else if(i===0)if(j<0)e.unshift({start:g.end,end:h.end});else j>0&&d.unshift({start:h.end,end:g.end});else if(i>0){f.push({start:h.start,end:g.start});d.unshift(g);e.unshift({start:g.start,end:h.end})}}return f.concat(d,e)};b.isZeroLength=
function(d){return d.start.row===d.end.row&&d.start.column===d.end.column};b.maxPosition=function(d,e){return b.comparePositions(d,e)>0?d:e};b.normalizeRange=function(d){return this.comparePositions(d.start,d.end)<0?d:{start:d.end,end:d.start}};b.rangeSetBoundaries=function(d){return{start:d[0].start,end:d[d.length-1].end}};b.toString=function(d){var e=d.start;d=d.end;return"[ %@,%@ %@,%@ ]".fmt(e.row,e.column,d.row,d.column)};b.unionRanges=function(d,e){return{start:d.start.row<e.start.row||d.start.row===
e.start.row&&d.start.column<e.start.column?d.start:e.start,end:d.end.row>e.end.row||d.end.row===e.end.row&&d.end.column>e.end.column?d.end:e.end}}});tiki.module("RangeUtils:index",function(){});tiki.register("SyntaxManager",{});
tiki.module("SyntaxManager:controllers/standardsyntax",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise").Promise;b.StandardSyntax=c.Object.extend({_stickySupported:null,_parseActions:function(e){if(c.none(e))return[];return e.split(" ").map(function(f){f=f.split(":");return f.length===1?["transition",f[0]]:f})},_transition:function(e,f){var g=f;e.actions.forEach(function(h){if(h[0]==="transition")g=h[1]});return g},states:null,init:function(){for(var e=null,f=this.get("states"),
g=f.length,h=0;h<g;h++)for(var i=f[h],j=i.length,k=0;k<j;k++){var l=i[k].regex;if(e===null)e=l.sticky!==undefined;if(e)l.sticky=true}this._stickySupported=e},syntaxInfoForLineFragment:function(e,f,g,h,i){var j=new d,k=[],l=this._stickySupported,m=this.get("states");if(i!==null&&i<g.length)g=g.substring(0,i);var o=g.length;for(h=h;h!==o;){var r=l?g:g.substring(h);if(m[f]===undefined)throw new Error("StandardSyntax: no such states '%@'".fmt(f));for(var w={start:h,state:f},p,s=m[f],v=s.length,t=0;t<
v;t++){p=s[t];var z=p.regex;if(l)z.lastIndex=h;var u=z.exec(r);if(u!==null){r=u[0].length;w.end=h+r;w.tag=p.tag;w.actions=this._parseActions(p.then);p=this._transition(w,f);if(r===0&&p===f)throw new Error("Syntax regex matches the empty string and the state didn't change: "+z.toSource());f=p;break}}if(w.tag===undefined){w.end=h+1;w.tag="plain";w.actions=[]}h!==w.end&&k.push(w);h=w.end}i===null&&k.push({start:h,end:null,state:f,tag:"plain",actions:[]});j.resolve({attrs:k,next:{context:e,state:f}});
return j}})});
tiki.module("SyntaxManager:controllers/syntaxdirectory",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise").Promise;b.discoveredNewSyntax=function(f){b.syntaxDirectory.registerExtension(f)};var e=c.Object.extend({extension:null,name:null,init:function(){this.set("name",this.get("extension").name)}});b.syntaxDirectory=c.Object.create({_syntaxInfo:{},loadSyntax:function(f){f=this._syntaxInfo[f];if(f===undefined)return null;var g=new d;f.get("extension").load(function(h){g.resolve(h)});return g},
registerExtension:function(f){f=e.create({extension:f});this._syntaxInfo[f.get("name")]=f}})});
tiki.module("SyntaxManager:controllers/syntaxmanager",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise"),e=a("utils/array"),f=a("DelegateSupport").MultiDelegateSupport,g=d.Promise,h=a("RangeUtils:utils/range");a("utils/yield");var i=a("controllers/syntaxdirectory").syntaxDirectory;b.SyntaxManager=c.Object.extend(f,{_invalidRows:[],_lineAttrInfo:null,_adjustInvalidRowsForDeletion:function(j,k){var l=[];this._invalidRows.forEach(function(m){if(m<=j)l.push(m);else m>j||m<k||m>=k&&l.push(m-
(k-j))});this._invalidRows=l},_adjustInvalidRowsForInsertion:function(j,k){this._invalidRows=this._invalidRows.map(function(l){return l<j?l:l+k-j})},_attrIndexForColumn:function(j,k){j=e.binarySearch(j,k,function(l,m){if(l<m.start)return-1;m=m.end;if(m!==null&&l>=m)return 1;return 0});j===null&&console.error("position not found",position);return j},_attrsToString:function(j){return j.map(function(k){return"%@.%@.%@@%@-%@".fmt(k.context,k.state,k.tag,k.start,k.end)}.bind(this)).join(", ")},_clearAttrsAtRow:function(j){for(var k=
[],l=0;l<2;l++)k.push(this._defaultAttrs());this._lineAttrInfo[j].attrs=k},_deepSyntaxInfoForLine:function(j,k){var l=new g,m=j[0],o=m.context;this._shallowSyntaxInfoForLineFragment(o,m.state,k,0,null).then(function(r){var w=r.attrs;w.forEach(function(v){v.context=o});var p=[{attrs:w,next:r.next}],s=this._innerRangesFromAttrs(w,j[1]);if(s.length===0){p.push({attrs:[{context:null,start:0,end:null}],next:{context:null}});l.resolve(p)}else{r=s.map(function(v){return this._shallowSyntaxInfoForLineFragment(v.context,
v.state,k,v.start,v.end)}.bind(this));d.group(r).then(function(v){var t=v.map(function(u){return u.attrs});for(v=0;v<t.length;v++){var z=s[v].context;t[v].forEach(function(u){u.context=z})}v=this._flattenAttrGroups(t);t=t[t.length-1];t=t[t.length-1];p.push({attrs:v,next:t.end===null?{context:t.context,state:t.state}:{context:null}});l.resolve(p)}.bind(this))}}.bind(this));return l},_defaultAttrs:function(){return[{start:0,end:null,tag:"plain",actions:[]}]},_deleteAttrsInRange:function(j){var k=j.start.row;
j=j.end.row;this._clearAttrsAtRow(k);this._lineAttrInfo.splice(k+1,j-k)},_deleteRange:function(j){if(!h.isZeroLength(j)){this._deleteAttrsInRange(j);var k=j.start.row;this._adjustInvalidRowsForDeletion(k,j.end.row);this._invalidateRow(k)}},_flattenAttrGroups:function(j){var k=[],l=0;j.forEach(function(m){var o=m[0].start;l!==o&&k.push({start:l,end:o,context:null});k.pushObjects(m);l=m[m.length-1].end});l!==null&&k.push({start:l,end:null,context:null});return k},_initialContextChanged:function(){this._reset();
this.notifyDelegates("syntaxManagerInvalidatedSyntax")}.observes("initialContext"),_innerRangesFromAttrs:function(j,k){var l=k.context,m=k.state,o=0,r=[];j.forEach(function(w){w.actions.forEach(function(p){switch(p[0]){case "start":if(l!==null)break;l=p[1];m="start";o=w.end;break;case "stop":if(l!==p[1])break;p=w.start;o!==p&&r.push({context:l,state:m,start:o,end:p});l=null;break}})});l!==null&&r.push({context:l,state:m,start:o,end:null});return r},_insertAttrsIntoRange:function(j){var k=j.start.row,
l=j.end.row;this._clearAttrsAtRow(k);j=this._lineAttrInfo;l=l-k;for(var m=0;m<l;m++){for(var o=[],r=[],w=0;w<2;w++){o.push({context:null});r.push(this._defaultAttrs())}j.splice(k+1,0,{snapshot:o,attrs:r})}},_insertRange:function(j){if(!h.isZeroLength(j)){this._insertAttrsIntoRange(j);var k=j.start.row;this._adjustInvalidRowsForInsertion(k,j.end.row);this._invalidateRow(k)}},_invalidateRow:function(j){var k=this._invalidRows;k.push(j);k.sort(function(l,m){return l-m});this._invalidRows=k.uniq()},_mergeAttrGroups:function(j){var k=
[],l=j[0];j=j[1];for(var m=0,o=0,r=0;r!==null;){var w=l[m],p=j[o];if(p.context!==null){k.push(p);r=p.end;o++;w.end===r&&m++}else{k.push(w);r=w.end;m++;p.end===r&&o++}}return k},_recomputeAttrInfoForRows:function(j,k){var l=new g,m=this._lineAttrInfo;if(j===k){l.resolve(j===m.length?j:false);return l}var o=m[j],r=this.getPath("textStorage.lines")[j];this._deepSyntaxInfoForLine(o.snapshot,r).then(function(w){o.attrs=w.map(function(v){return v.attrs});if(j!==m.length-1){var p=m[j+1],s=p.snapshot;w=w.map(function(v){return v.next});
if(this._snapshotsEqual(s,w)){l.resolve(j+1);return}p.snapshot=w}this._recomputeAttrInfoForRows(j+1,k).then(function(v){l.resolve(v)})}.bind(this));return l},_reset:function(){for(var j=[],k=this.getPath("textStorage.lines").length,l=this.get("initialContext"),m=0;m<k;m++)j.push({snapshot:[m===0?{context:l,state:"start"}:{context:null},{context:null}],attrs:[this._defaultAttrs(),[{context:null,start:0,end:null}]]});this._invalidRows=[0];this._lineAttrInfo=j},_shallowSyntaxInfoForLineFragment:function(j,
k,l,m,o){var r=new g;j==="plain"?r.resolve({attrs:this._defaultAttrs(),next:{context:"plain",state:"start"}}):i.loadSyntax(j).then(function(w){try{w.syntaxInfoForLineFragment(j,k,l,m,o).then(function(s){r.resolve(s)})}catch(p){console.log("Syntax highlighter ",j," caused an exception:",p);r.resolve({attrs:this._defaultAttrs(),next:{context:"plain",state:"start"}})}}.bind(this));return r},_snapshotsEqual:function(j,k){if(j.length!==k.length)return false;for(var l=0;l<j.length;l++){var m=j[l],o=k[l];
if(m.context!==o.context||m.state!==o.state)return false}return true},attrsForRows:function(j,k){return this._lineAttrInfo.slice(j,k).map(function(l){return this._mergeAttrGroups(l.attrs)},this)},initialContext:"plain",textStorage:null,init:function(){this._reset()},layoutManagerReplacedText:function(j,k){this._deleteRange(j);this._insertRange(k)},toString:function(){return"{ lineAttrInfo: [ %@ ], invalidRows: [ %@ ] }".fmt(this._lineAttrInfo.map(function(j){return"{ (%@) -> (%@) }".fmt(j.snapshot.map(function(k){return k.context+
": "+k.state}).join(", "),j.attrs.map(this._attrsToString.bind(this)).join(", "))}.bind(this)).join(", "),this._invalidRows.join(", "))},updateSyntaxForRows:function(j,k){var l=this._invalidRows,m=l.length,o;for(o=0;o<m;o++){var r=l[o];if(r>=j&&r<k)break}var w=new g;if(o===m)w.resolve({startRow:j,endRow:j});else{for(r=l[o];o<l.length&&l[o]<k;)l.splice(o,1);this._recomputeAttrInfoForRows(r,k).then(function(p){if(p===false){this._invalidateRow(k);p=k}w.resolve({startRow:j,endRow:p})}.bind(this))}return w}})});
tiki.module("SyntaxManager:utils/array",function(a,b){a("sproutcore/runtime");b.binarySearch=function(c,d,e){for(var f=0,g=c.length;f<g;){var h=f+(g-f)/2>>0,i=e(d,c[h]);if(i<0)g=h;else if(i>0)f=h+1;else return h}return null}});
tiki.module("SyntaxManager:utils/yield",function(a,b){a("sproutcore/runtime");var c=a("bespin:promise").Promise;b.loop=function(d,e,f){for(var g=new c;d(g);){var h=e(),i=h.valueIfResolved();if(i===null){h.then(function(j){f(j,g)&&b.loop(d,e,f).then(function(k){g.resolve(k)})});return g}if(!f(i,g))return g}return g}});tiki.module("SyntaxManager:index",function(){});tiki.register("Editor",{});
tiki.module("Editor:commands/editor",function(a,b){var c=a("bespin:util/util"),d=a("Settings").settings;b.gotoCommand=function(e,f){if(f.value){e=e.get("view");e._moveCursorTo({row:f.value-1,column:0});e.focus()}};b.replaceCommand=function(e,f){editor.replace(f)};b.sortCommand=function(e,f){e=editor.getDocument().split(/\n/);e.sort();direction&&/^desc/.test(f.direction.toLowerCase())&&e.reverse();editor.insertDocument(e.join("\n"))};b.entabCommand=function(e,f){(e=f.tabsize)||(e=d.get("tabsize"));
editor.replace({search:" {"+e+"}",replace:"\t"})};b.detabCommand=function(e,f){(e=f.tabsize)||(e=d.get("tabsize"));editor.replace({search:"\t",replace:c.repeatString(" ",e)})};b.trimCommand=function(e,f){e={replace:""};if(c.include(["left","both"],f.side)){e.search="^\\s+";editor.replace(e)}if(c.include(["right","both"],f.side)){e.search="\\s+$";editor.replace(e)}};b.ucCommand=function(){editor.selectionChangeCase({stringCase:"u"})};b.lcCommand=function(){editor.selectionChangeCase({stringCase:"l"})}});
tiki.module("Editor:controllers/layoutmanager",function(a,b){var c=a("sproutcore/runtime").SC,d=a("DelegateSupport").MultiDelegateSupport;a("RangeUtils:utils/range");var e=a("SyntaxManager:controllers/syntaxmanager").SyntaxManager,f=a("models/textstorage").TextStorage;a=a("bespin:plugins").catalog;b.LayoutManager=c.Object.extend(d,{_characterWidth:8,_lineHeight:20,_maximumWidth:0,margin:{left:5,bottom:6,top:0,right:12},pluginCatalog:a,syntaxManager:e,textLines:null,textStorage:f,theme:{editorTextColor:"rgb(230, 230, 230)",
editorTextColor_comment:"rgb(102, 102, 102)",editorTextColor_directive:"rgb(153, 153, 153)",editorTextColor_error:"rgb(255, 0, 0)",editorTextColor_identifier:"rgb(230, 230, 230)",editorTextColor_keyword:"rgb(66, 168, 237)",editorTextColor_operator:"rgb(136, 187, 255)",editorTextColor_plain:"rgb(230, 230, 230)",editorTextColor_string:"rgb(3, 154, 10)"},_computeInvalidRects:function(g,h){var i=this.characterRectForPosition(g.start),j={x:i.x,y:i.y,width:Number.MAX_VALUE,height:i.height};return g.end.row===
h.end.row?[j]:[j,{x:0,y:i.y+this._lineHeight,width:Number.MAX_VALUE,height:Number.MAX_VALUE}]},_lastCharacterPosition:function(){return{row:this.get("textLines").length-1,column:this._maximumWidth}},_recalculateMaximumWidth:function(){var g=0;this.get("textLines").forEach(function(h){h=h.characters.length;if(g<h)g=h});this._maximumWidth=g},_recomputeEntireLayout:function(){var g=this.get("textStorage").range();this._recomputeLayoutForRanges(g,g)},_recomputeLayoutForRanges:function(g,h){for(var i=
g.start.row,j=g.end.row,k=h.end.row,l=k-i+1,m=this.getPath("textStorage.lines"),o=this.get("theme").editorTextColor_plain,r=[],w=0;w<l;w++)r[w]={characters:m[i+w],colors:[{start:0,end:null,color:o}]};this.textLines.replace(i,j-i+1,r);this._recalculateMaximumWidth();this.updateTextRows(i,k+1);this.notifyDelegates("layoutManagerChangedTextAtRow",i);this.notifyDelegates("layoutManagerInvalidatedRects",this._computeInvalidRects(g,h))},boundingRect:function(){return this.rectsForRange({start:{row:0,column:0},
end:{row:this.get("textLines").length-1,column:this._maximumWidth}})[0]},characterAtPoint:function(g){var h=this.get("margin"),i=g.x-h.left,j=g.y-h.top;g=this._characterWidth;h=this.get("textStorage");j=h.clampPosition({row:Math.floor(j/this._lineHeight),column:Math.floor(i/g)});h=h.get("lines")[j.row].length;return c.mixin(j,{partialFraction:i<0||j.column===h?0:i%g/g})},characterRangeForBoundingRect:function(g){var h=this._lineHeight,i=this._characterWidth,j=this.get("margin"),k=g.x-j.left;j=g.y-
j.top;return{start:{row:Math.max(Math.floor(j/h),0),column:Math.max(Math.floor(k/i),0)},end:{row:Math.floor((j+g.height-1)/h),column:Math.floor((k+g.width-1)/i)+1}}},characterRectForPosition:function(g){return this.rectsForRange({start:g,end:{row:g.row,column:g.column+1}})[0]},createSyntaxManager:function(){this.set("syntaxManager",this.get("syntaxManager").create({delegates:[this],textStorage:this.get("textStorage")}))},createTextStorage:function(){this.set("textStorage",this.get("textStorage").create())},
init:function(){this.set("textLines",[{characters:"",colors:[{start:0,end:0,color:this.get("theme").editorTextColor}]}]);this.createTextStorage();this.get("textStorage").addDelegate(this);this.createSyntaxManager();this._recomputeEntireLayout()},lineRectForRow:function(g){return this.rectsForRange({start:{row:g,column:0},end:{row:g,column:this._maximumWidth}})[0]},rectForPosition:function(g){var h=this.get("margin"),i=this._characterWidth,j=this._lineHeight;return{x:h.left+i*g.column,y:h.top+j*g.row,
width:i,height:j}},rectsForRange:function(g){var h=this._characterWidth,i=this._lineHeight,j=this._maximumWidth,k=this.get("margin"),l=g.start,m=g.end;g=l.row;var o=l.column;l=m.row;m=m.column;if(g===l)return[{x:k.left+h*o,y:k.top+i*g,width:h*(m-o),height:i}];var r=[],w;if(o===0)w=g;else{w=g+1;r.push({x:k.left+h*o,y:k.top+i*g,width:h*(j-o),height:i})}if(m===0)g=l-1;else if(m===j)g=l;else{g=l-1;r.push({x:k.left,y:k.top+i*l,width:h*m,height:i})}r.push({x:k.left,y:k.top+i*w,width:h*j,height:i*(g-w+1)});
return r},syntaxManagerInvalidatedSyntax:function(){this._recomputeEntireLayout()},textStorageEdited:function(g,h,i){this.get("syntaxManager").layoutManagerReplacedText(h,i);this._recomputeLayoutForRanges(h,i)},updateTextRows:function(g,h){var i=this.get("textLines");h=this.get("syntaxManager").attrsForRows(g,h);for(var j=this.get("theme"),k=0;k<h.length;k++)i[g+k].colors=h[k].map(function(l){var m=j["editorTextColor_"+l.tag];if(c.none(m))m=j.editorTextColor_plain;return{start:l.start,end:l.end,color:m}})}})});
tiki.module("Editor:controllers/undo",function(a,b){var c=a("sproutcore/runtime").SC,d=a("AppSupport:controllers/undomanager").undoManager;b.EditorUndoController=c.Object.extend({_inTransaction:false,_record:null,textView:null,_beginTransaction:function(){if(this._inTransaction){console.trace();throw new Error("UndoController._beginTransaction() called with a transaction already in place");}this._inTransaction=true;this._record={patches:[]}},_endTransaction:function(){if(!this._inTransaction)throw new Error("UndoController._endTransaction() called without a transaction in place");
d.registerUndo(this,this._record);this._record=null;this._inTransaction=false},_tryApplyingPatches:function(e){var f=this.getPath("textView.layoutManager.textStorage");e.forEach(function(g){f.replaceCharacters(g.oldRange,g.newCharacters)});return true},_undoOrRedo:function(e,f){if(this._inTransaction)throw new Error("UndoController._undoOrRedo() called while in a transaction");if(!this._tryApplyingPatches(e))return false;this.get("textView").setSelection(f);return true},init:function(){this._redoStack=
[];this._undoStack=[];this.get("textView").addDelegate(this)},redo:function(e){return this._undoOrRedo(e.patches,e.selectionAfter)},textViewBeganChangeGroup:function(e,f){this._beginTransaction();this._record.selectionBefore=f},textViewEndedChangeGroup:function(e,f){this._record.selectionAfter=f;this._endTransaction()},textViewReplacedCharacters:function(e,f,g){if(!this._inTransaction)throw new Error("UndoController.textViewReplacedCharacters() called outside a transaction");this._record.patches.push({oldCharacters:this._deletedCharacters,
oldRange:f,newCharacters:g,newRange:this.getPath("textView.layoutManager.textStorage").resultingRangeForReplacement(f,g.split("\n"))});this._deletedCharacters=null},textViewWillReplaceRange:function(e,f){if(!this._inTransaction)throw new Error("UndoController.textViewWillReplaceRange() called outside a transaction");this._deletedCharacters=this.getPath("textView.layoutManager.textStorage").getCharacters(f)},undo:function(e){return this._undoOrRedo(e.patches.map(function(f){return{oldCharacters:f.newCharacters,
oldRange:f.newRange,newCharacters:f.oldCharacters,newRange:f.oldRange}}),e.selectionBefore)}})});tiki.module("Editor:mixins/textbuffer",function(a,b){a("sproutcore/runtime");b.TextBuffer={deleteCharacters:function(c){this.replaceCharacters(c,"")},insertCharacters:function(c,d){this.replaceCharacters({start:c,end:c},d)},resultingRangeForReplacement:function(c,d){var e=d.length;c=c.start;return{start:c,end:{row:c.row+e-1,column:(e===1?c.column:0)+d[e-1].length}}}}});
tiki.module("Editor:models/textstorage",function(a,b){var c=a("sproutcore/runtime").SC,d=a("DelegateSupport").MultiDelegateSupport;a=a("mixins/textbuffer").TextBuffer;b.TextStorage=c.Object.extend(d,a,{lines:null,value:function(e,f){f!==undefined&&this.replaceCharacters(this.range(),f);return this.get("lines").join("\n")}.property("lines.[]"),clampPosition:function(e){var f=this.get("lines"),g=e.row;if(g<0)return{row:0,column:0};else if(g>=f.length)return this.range().end;return{row:g,column:Math.max(0,
Math.min(e.column,f[g].length))}},displacePosition:function(e,f){var g=e.row,h=e.column;switch(f){case -1:if(g===0&&h==0)return e;return h===0?{row:g-1,column:this.get("lines")[g-1].length}:{row:g,column:h-1};case 1:f=this.get("lines");var i=f[g].length;if(g===f.length-1&&h===i)return e;return h===i?{row:g+1,column:0}:{row:g,column:h+1};default:throw new Error("TextStorage.displacePosition(): count must be 1 or -1");}},getCharacters:function(e){var f=this.get("lines"),g=e.start,h=e.end;e=g.row;var i=
h.row;g=g.column;h=h.column;if(e===i)return f[e].substring(g,h);return[f[e].substring(g)].concat(f.slice(e+1,i),f[i].substring(0,h)).join("\n")},init:function(){this.superclass();this.set("delegates",[]);this.set("lines",[""])},range:function(){var e=this.get("lines");return{start:{row:0,column:0},end:{row:e.length-1,column:e[e.length-1].length}}},replaceCharacters:function(e,f){f=f.split("\n");var g=f.length,h=this.resultingRangeForReplacement(e,f),i=e.start,j=e.end,k=i.row,l=j.row;i=i.column;var m=
this.get("lines");f[0]=m[k].substring(0,i)+f[0];f[g-1]+=m[l].substring(j.column);m.replace(k,l-k+1,f);this.notifyDelegates("textStorageEdited",e,h)}})});
tiki.module("Editor:utils/rect",function(a,b){var c=a("sproutcore/runtime").SC;b._distanceFromBounds=function(d,e,f){if(d<e)return d-e;if(d>=f)return d-f;return 0};b.addRectToSet=function(d,e){d=d.concat(e);do{e=false;for(var f=[],g=0;g<d.length;g++){var h=d[g];f.push(h);for(var i=g+1;i<d.length;i++){var j=d[i];if(b.rectsIntersect(h,j)){d.removeAt(i,1);f[f.length-1]=c.unionRects(h,j);e=true;break}}}d=f}while(e);return d};b.offsetFromRect=function(d,e){return{x:b._distanceFromBounds(e.x,d.x,c.maxX(d)),
y:b._distanceFromBounds(e.y,d.y,c.maxY(d))}};b.rectsIntersect=function(d,e){d=c.intersectRects(d,e);return d.width!==0&&d.height!==0}});
tiki.module("Editor:views/canvas",function(a,b){var c=a("sproutcore/runtime").SC,d=a("utils/rect");b.CanvasView=c.View.extend({_cvCanvasContext:null,_cvCanvasDom:null,_cvCanvasId:null,_cvInvalidRects:null,_cvLastRedrawTime:null,_cvPreviousClippingFrame:null,_cvRedrawTimer:null,_cvClippingFrameChanged:function(){var e=this._cvPreviousClippingFrame,f=this.get("clippingFrame");if(e===null||!c.rectsEqual(f,e)){this._cvPreviousClippingFrame=f;this.clippingFrameChanged()}}.observes("clippingFrame"),_cvGetContext:function(){if(this._cvCanvasContext===
null)this._cvCanvasContext=this._cvCanvasDom.getContext("2d");return this._cvCanvasContext},_cvResizeCanvas:function(){var e=this.getPath("parentView.frame"),f=this._cvCanvasDom;if(!c.none(f)){var g=f.width!==e.width,h=f.height!==e.height;if(g)f.width=e.width;if(h)f.height=e.height;if(g||h)this.setNeedsDisplay()}},layoutStyle:{left:"0px",top:"0px"},minimumRedrawDelay:1E3/30,clippingFrameChanged:function(){this.setNeedsDisplay()},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);
this._cvCanvasDom=this.$("#"+this._cvCanvasId)[0];this.redraw()},drawRect:function(){},init:function(){arguments.callee.base.apply(this,arguments);this._cvInvalidRects=[];this.get("parentView").addObserver("frame",this,this.parentViewFrameChanged)},parentViewFrameChanged:function(){this._cvResizeCanvas()},redraw:function(){var e=this.get("frame");e.x<0&&this.computeFrameWithParentFrame(null);var f=this._cvGetContext();f.save();f.translate(e.x,e.y);var g=this.get("clippingFrame");this._cvInvalidRects.forEach(function(h){f.save();
h=c.intersectRects(h,g);if(h.width!==0&&h.height!==0){var i=h.x,j=h.y,k=h.width,l=h.height;f.beginPath();f.moveTo(i,j);f.lineTo(i+k,j);f.lineTo(i+k,j+l);f.lineTo(i,j+l);f.closePath();f.clip();this.drawRect(h,f)}f.restore()},this);f.restore();this._cvInvalidRects=[];this._cvLastRedrawTime=(new Date).getTime();return true},render:function(e,f){arguments.callee.base.apply(this,arguments);if(f){var g=this.getPath("parentView.frame"),h=e.begin("canvas");this._cvCanvasId=c.guidFor(h);h.id(this._cvCanvasId);
h.attr("width",""+g.width);h.attr("height",""+g.height);h.push("canvas tag not supported by your browser");h.end()}else c.RunLoop.currentRunLoop.invokeLast(this,this.tryRedraw)},renderLayout:function(e,f){arguments.callee.base.apply(this,arguments);var g=this.getPath("parentView.frame");if(f){e.attr("width",g.width);e.attr("height",g.height)}},setNeedsDisplay:function(){var e=this.get("frame");this._cvInvalidRects=[{x:0,y:0,width:e.width,height:e.height}];this.set("layerNeedsUpdate",true)},setNeedsDisplayInRect:function(e){this._cvInvalidRects=
d.addRectToSet(this._cvInvalidRects,e);this.set("layerNeedsUpdate",true)},tryRedraw:function(){var e=(new Date).getTime(),f=this._cvLastRedrawTime,g=this.get("minimumRedrawDelay");if(f===null||e-f>=g)this.redraw();else{e=this._cvRedrawTimer;if(!(e!==null&&e.get("isValid")))this._cvRedrawTimer=c.Timer.schedule({target:this,action:this.redraw,interval:g,repeats:false})}}})});
tiki.module("Editor:views/editor",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/gutter").GutterView,e=a("controllers/layoutmanager").LayoutManager,f=a("views/scroll").ScrollView,g=a("SyntaxManager:controllers/syntaxmanager").SyntaxManager,h=a("views/text").TextView;a=a("controllers/undo").EditorUndoController;b.EditorView=c.View.extend(c.Border,{borderStyle:c.BORDER_GRAY,gutterView:d,layoutManager:e,scrollView:f,syntaxManager:g,textView:h,undoController:a,_gutterViewFrameChanged:function(){this.get("scrollView").adjust({left:this.getPath("gutterView.frame").width})},
_scrollViewVerticalScrollOffsetChanged:function(){this.setPath("gutterView.verticalScrollOffset",this.getPath("scrollView.verticalScrollOffset"))},createChildViews:function(){var i=this.get("layoutManager"),j=this.get("scrollView"),k=this.createChildView(this.get("gutterView"),{layoutManager:i});this.set("gutterView",k);k.addObserver("frame",this,this._gutterViewFrameChanged);var l=this.get("textView");i=this.createChildView(j,{contentView:l.extend({layoutManager:i,undoController:this.get("undoController")}),
layout:{left:k.get("frame").width,bottom:0,top:0,right:0}});this.set("scrollView",i);i.addObserver("verticalScrollOffset",this,this._scrollViewVerticalScrollOffsetChanged);j=i.get("contentView");this.set("textView",j);this.set("undoController",this.get("undoController").create({textView:j}));this.set("childViews",[k,i])},init:function(){this.set("layoutManager",this.get("layoutManager").create());return arguments.callee.base.apply(this,arguments)}})});
tiki.module("Editor:views/gutter",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/canvas").CanvasView;a("bespin:util/scratchcanvas");var e=d.extend({_lineAscent:16,theme:{gutterStyle:"#4c4a41",lineNumberColor:"#e5c138",lineNumberFont:"10pt Monaco, Lucida Console, monospace",editorTextFont:"10pt Monaco, Lucida Console, monospace"},_frameChanged:function(){this.setNeedsDisplay()}.observes("frame"),drawRect:function(f,g){var h=this.get("theme");g.fillStyle=h.gutterStyle;g.fillRect(f.x,f.y,
f.width,f.height);g.save();var i=this.get("parentView"),j=i.get("padding");g.translate(j.left,0);g.fillStyle=h.lineNumberColor;g.font=h.lineNumberFont;h=i.get("layoutManager");j=h.characterRangeForBoundingRect(f);f=Math.min(j.end.row,h.get("textLines").length-1);i=this._lineAscent;for(j=j.start.row;j<=f;j++)g.fillText(""+(j+1),-0.5,h.lineRectForRow(j).y+i-0.5);g.restore()}});b.GutterView=c.View.extend({_interiorView:null,layout:{left:0,top:0,bottom:0,width:32},layoutManager:null,padding:{bottom:30,
left:5,right:10},verticalScrollOffset:0,_recomputeLayout:function(){var f=this.get("layoutManager"),g=this.get("padding"),h=c.clone(this.get("layout"));h.width=32;this.set("layout",h);h=this.get("frame");this._interiorView.set("layout",{left:0,top:-this.get("verticalScrollOffset"),width:h.width,height:Math.max(h.height,f.boundingRect().height+g.bottom)})},_verticalScrollOffsetChanged:function(){this._recomputeLayout()}.observes("verticalScrollOffset"),createChildViews:function(){var f=this.createChildView(e);
this._interiorView=f;this.get("frame");this._recomputeLayout();this.set("childViews",[f])},init:function(){arguments.callee.base.apply(this,arguments);this.get("layoutManager").addDelegate(this)},layoutManagerInvalidatedRects:function(){this._recomputeLayout()}})});
tiki.module("Editor:views/scroll",function(a,b){var c=a("sproutcore/runtime").SC;a=a("views/scroller").BespinScrollerView;b.ScrollView=c.ScrollView.extend({_containerViewLaidOut:false,autohidesHorizontalScroller:false,autohidesVerticalScroller:false,borderStyle:c.BORDER_NONE,hasHorizontalScroller:true,hasVerticalScroller:true,horizontalScrollerThickness:24,horizontalScrollerView:a,verticalScrollerThickness:24,verticalScrollerView:a,tile:function(){if(!this._containerViewLaidOut){var d=this.get("containerView");
d.adjust({left:0,bottom:0,top:0,right:0});d.updateLayout();this._containerViewLaidOut=true}var e=this.get("horizontalScrollerView"),f=this.get("verticalScrollerView");e=this.get("isHorizontalScrollerVisible");f=this.get("isVerticalScrollerVisible");d=this.get("horizontalScrollerThickness");var g=this.get("verticalScrollerThickness");if(e){e=this.get("horizontalScrollerView");e.set("scrollerThickness",d);e.set("padding",{top:0,bottom:6,left:6,right:6+g});e.set("layout",{left:0,bottom:0,right:0,height:d})}if(f){f=
this.get("verticalScrollerView");f.set("scrollerThickness",g);f.set("padding",{left:0,right:6,top:6,bottom:6+d});f.set("layout",{top:0,right:0,bottom:0,width:g})}this.get("contentView").get("hasPadding")===true&&this.get("contentView").set("padding",{bottom:d+6,right:g+6})}})});
tiki.module("Editor:views/scroller",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/canvas").CanvasView.extend({classNames:["bespin-scroller-view"],lineHeight:20,_mouseDownScreenPoint:null,_mouseDownValue:null,_isMouseOver:false,_scrollTimer:null,_mouseEventPosition:null,_mouseOverHandle:false,theme:{backgroundStyle:"#2A211C",partialNibStyle:"rgba(100, 100, 100, 0.3)",partialNibArrowStyle:"rgba(255, 255, 255, 0.3)",partialNibStrokeStyle:"rgba(150, 150, 150, 0.3)",fullNibStyle:"rgb(100, 100, 100)",
fullNibArrowStyle:"rgb(255, 255, 255)",fullNibStrokeStyle:"rgb(150, 150, 150)",scrollTrackFillStyle:"rgba(50, 50, 50, 0.8)",scrollTrackStrokeStyle:"rgb(150, 150, 150)",scrollBarFillStyle:"rgba(0, 0, 0, %a)",scrollBarFillGradientTopStart:"rgba(90, 90, 90, %a)",scrollBarFillGradientTopStop:"rgba(40, 40, 40, %a)",scrollBarFillGradientBottomStart:"rgba(22, 22, 22, %a)",scrollBarFillGradientBottomStop:"rgba(44, 44, 44, %a)"},_drawNib:function(e){var f=this.get("theme"),g,h;if(this._isHighlighted()){g=
f.fullNibStyle;h=f.fullNibArrowStyle;f=f.fullNibStrokeStyle}else{g=f.partialNibStyle;h=f.partialNibArrowStyle;f=f.partialNibStrokeStyle}var i=Math.floor(7.5);e.fillStyle=g;e.beginPath();e.arc(0,0,Math.floor(7.5),0,Math.PI*2,true);e.closePath();e.fill();e.strokeStyle=f;e.stroke();e.fillStyle=h;e.beginPath();e.moveTo(0,-i+3);e.lineTo(-i+3,i-5);e.lineTo(i-3,i-5);e.closePath();e.fill()},_drawNibs:function(e){var f=this._getClientThickness(),g=this.getPath("parentView.value"),h=this._isHighlighted();if(h||
g!==0){e.save();e.translate(8,f/2);e.rotate(Math.PI*1.5);e.moveTo(0,0);this._drawNib(e);e.restore()}if(h||g!==this.getMaximumValue()){e.save();e.translate(this._getClientLength()-8,f/2);e.rotate(Math.PI*0.5);e.moveTo(0,0);this._drawNib(e);e.restore()}},_getClientFrame:function(){var e=this.get("frame"),f=this.getPath("parentView.padding");return{x:f.left,y:f.top,width:e.width-(f.left+f.right),height:e.height-(f.top+f.bottom)}},_getClientLength:function(){var e=this._getClientFrame();switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:return e.width;
case c.LAYOUT_VERTICAL:return e.height;default:console.assert(false,"unknown layout direction");return null}},_getClientThickness:function(){var e=this.get("parentView"),f=e.get("padding"),g=e.get("scrollerThickness");switch(e.get("layoutDirection")){case c.LAYOUT_VERTICAL:return g-(f.left+f.right);case c.LAYOUT_HORIZONTAL:return g-(f.top+f.bottom);default:console.assert(false,"unknown layout direction");return null}}.property(),_getFrameLength:function(){var e=this.get("frame");switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:return e.width;
case c.LAYOUT_VERTICAL:return e.height;default:console.assert(false,"unknown layout direction");return null}},_getGutterFrame:function(){var e=this._getClientFrame(),f=this._getClientThickness();switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_VERTICAL:return{x:e.x,y:e.y+15,width:f,height:Math.max(0,e.height-30)};case c.LAYOUT_HORIZONTAL:return{x:e.x+15,y:e.y,width:Math.max(0,e.width-30),height:f};default:console.assert(false,"unknown layout direction");return null}},_getGutterLength:function(){var e=
this._getGutterFrame(),f;switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:f=e.width;break;case c.LAYOUT_VERTICAL:f=e.height;break;default:console.assert(false,"unknown layout direction");break}return f},_getHandleFrame:function(){var e=this.get("parentView"),f=e.get("value"),g=e.get("maximum"),h=this.get("frame"),i=this._getClientFrame(),j=this._getGutterFrame(),k=this._getClientThickness();switch(e.get("layoutDirection")){case c.LAYOUT_VERTICAL:return{x:i.x,y:i.y+15+f*
j.height/g,width:k,height:Math.min(h.height,g)*j.height/g};case c.LAYOUT_HORIZONTAL:return{x:i.x+15+f*j.width/g,y:i.y,width:Math.min(h.width,g)*j.width/g,height:k};default:console.assert(false,"unknown layout direction");return null}},_isHighlighted:function(){return this._isMouseOver===true||this._mouseDownScreenPoint!==null},_segmentForMouseEvent:function(e){e=this.convertFrameFromView({x:e.pageX,y:e.pageY});var f=this._getClientFrame(),g=this.getPath("parentView.padding");if(!c.pointInRect(e,f))return null;
var h=this.getPath("parentView.layoutDirection");switch(h){case c.LAYOUT_HORIZONTAL:if(e.x-g.left<15)return"nib-start";else if(e.x>=f.width-15)return"nib-end";break;case c.LAYOUT_VERTICAL:if(e.y-g.top<15)return"nib-start";else if(e.y>=f.height-15)return"nib-end";break;default:console.assert(false,"unknown layout direction");break}g=this._getHandleFrame();if(c.pointInRect(e,g))return"handle";switch(h){case c.LAYOUT_HORIZONTAL:if(e.x<g.x)return"gutter-before";else if(e.x>=g.x+g.width)return"gutter-after";
break;case c.LAYOUT_VERTICAL:if(e.y<g.y)return"gutter-before";else if(e.y>=g.y+g.height)return"gutter-after";break;default:console.assert(false,"unknown layout direction");break}console.assert(false,"_segmentForMouseEvent: point ",e," outside view with handle frame ",g," and client frame ",f);return null},adjustFrame:function(){var e=this.getPath("parentView.frame");this.set("layout",{left:0,top:0,width:e.width,height:e.height})},drawRect:function(e,f){e=f.globalAlpha?f.globalAlpha:1;var g=this.get("theme"),
h=this._isHighlighted(),i=this.get("frame");f.clearRect(0,0,i.width,i.height);f.save();i=this.get("parentView");var j=i.get("padding");f.translate(j.left,j.top);var k=this._getHandleFrame(),l=this._getGutterLength(),m=this._getClientThickness(),o=m/2,r,w;switch(i.get("layoutDirection")){case c.LAYOUT_VERTICAL:r=k.y-j.top;w=k.height;f.translate(m+1,0);f.rotate(Math.PI*0.5);break;case c.LAYOUT_HORIZONTAL:r=k.x-j.left;w=k.width;break;default:console.assert(false,"unknown layout direction");break}if(!(l<=
w)){if(h){i=this._getClientLength();f.fillStyle=g.scrollTrackFillStyle;f.fillRect(8.5,0.5,i-16,m-1);f.strokeStyle=g.scrollTrackStrokeStyle;f.strokeRect(8.5,0.5,i-16,m-1)}else f.globalAlpha=0.3;i=function(){f.beginPath();f.arc(r+o+0.5,o,o-0.5,Math.PI/2,3*Math.PI/2,false);f.arc(r+w-o-0.5,o,o-0.5,3*Math.PI/2,Math.PI/2,false);f.lineTo(r+o+0.5,m-0.5);f.closePath()};i();j=f.createLinearGradient(r,0,r,m);j.addColorStop(0,g.scrollBarFillGradientTopStart.replace(/%a/,e));j.addColorStop(0.4,g.scrollBarFillGradientTopStop.replace(/%a/,
e));j.addColorStop(0.41,g.scrollBarFillStyle.replace(/%a/,e));j.addColorStop(0.8,g.scrollBarFillGradientBottomStart.replace(/%a/,e));j.addColorStop(1,g.scrollBarFillGradientBottomStop.replace(/%a/,e));f.fillStyle=j;f.fill();f.save();f.clip();f.fillStyle=g.scrollBarFillStyle.replace(/%a/,e);f.beginPath();f.moveTo(r+o*0.4,o*0.6);f.lineTo(r+o*0.9,m*0.4);f.lineTo(r,m*0.4);f.closePath();f.fill();f.beginPath();f.moveTo(r+w-o*0.4,0+o*0.6);f.lineTo(r+w-o*0.9,0+m*0.4);f.lineTo(r+w,0+m*0.4);f.closePath();f.fill();
f.restore();f.save();i();f.strokeStyle=g.scrollTrackStrokeStyle;f.stroke();f.restore();if(!h)f.globalAlpha=1;this._drawNibs(f);f.restore()}},getMaximumValue:function(){return Math.max(this.getPath("parentView.maximum")-this._getFrameLength(),0)},_repeatAction:function(e,f){if(e()!==false)this._scrollTimer=c.Timer.schedule({target:this,action:function(){this._repeatAction(e,100)},interval:f})},_scrollByDelta:function(e){var f=this.get("parentView"),g=f.get("value");f.set("value",g+e)},_scrollUpOneLine:function(){this._scrollByDelta(-this.get("lineHeight"));
return true},_scrollDownOneLine:function(){this._scrollByDelta(this.get("lineHeight"));return true},_scrollPage:function(){switch(this._segmentForMouseEvent(this._mouseEventPosition)){case "gutter-before":this._scrollByDelta(this._getGutterLength()*-1);break;case "gutter-after":this._scrollByDelta(this._getGutterLength());break;case null:break;default:return false}return true},mouseDown:function(e){this._mouseEventPosition=e;this._mouseOverHandle=false;var f=this.get("parentView");f.get("value");
this._getGutterLength();switch(this._segmentForMouseEvent(e)){case "nib-start":this._repeatAction(this._scrollUpOneLine.bind(this),500);break;case "nib-end":this._repeatAction(this._scrollDownOneLine.bind(this),500);break;case "gutter-before":this._repeatAction(this._scrollPage.bind(this),500);break;case "gutter-after":this._repeatAction(this._scrollPage.bind(this),500);break;case "handle":break;default:console.assert("_segmentForMouseEvent returned an unknown value");break}switch(f.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:this._mouseDownScreenPoint=
e.clientX;break;case c.LAYOUT_VERTICAL:this._mouseDownScreenPoint=e.clientY;break;default:console.assert(false,"unknown layout direction");break}},mouseDragged:function(e){var f=this.get("parentView");if(this._segmentForMouseEvent(e)=="handle"||this._mouseOverHandle===true){this._mouseOverHandle=true;if(this._scrollTimer!==null){this._scrollTimer.invalidate();this._scrollTimer=null}var g;switch(f.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:g=e.clientX;break;case c.LAYOUT_VERTICAL:g=e.clientY;
break;default:console.assert(false,"unknown layout direction");break}var h=g-this._mouseDownScreenPoint,i=f.get("maximum"),j=this._getGutterLength(),k=f.get("value");f.set("value",k+h*i/j);this._mouseDownScreenPoint=g}this._mouseEventPosition=e},mouseEntered:function(){this._isMouseOver=true;this.setNeedsDisplay()},mouseExited:function(){this._isMouseOver=false;this.setNeedsDisplay()},mouseUp:function(){this._mouseDownValue=this._mouseDownScreenPoint=null;if(this._scrollTimer){this._scrollTimer.invalidate();
this._scrollTimer=null}this.setNeedsDisplay()},mouseWheel:function(e){var f=this.get("parentView");switch(f.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:e=e.wheelDeltaX;break;case c.LAYOUT_VERTICAL:e=e.wheelDeltaY;break;default:console.assert(false,"unknown layout direction");return}f.set("value",f.get("value")+2*e)}});b.BespinScrollerView=c.View.extend({_scrollerCanvasView:null,_frameChanged:function(){this._scrollerCanvasView.adjustFrame()}.observes("frame"),_maximumChanged:function(){this._scrollerCanvasView.adjustFrame()}.observes("maximum"),
_valueChanged:function(){var e=this._scrollerCanvasView,f=e.getMaximumValue(),g=this.get("value");if(g<0)this.set("value",0);else g>f&&this.set("value",f);e.setNeedsDisplay()}.observes("value"),layoutDirection:c.LAYOUT_VERTICAL,maximum:0,padding:{left:0,bottom:0,top:0,right:0},scrollerThickness:c.NATURAL_SCROLLER_THICKNESS,value:0,createChildViews:function(){var e=this.createChildView(d);e.adjustFrame();this._scrollerCanvasView=e;this.set("childViews",[e])}})});
tiki.module("Editor:views/text",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/canvas").CanvasView;a("controllers/layoutmanager");var e=a("DelegateSupport").MultiDelegateSupport,f=a("RangeUtils:utils/range"),g=a("utils/rect"),h=a("bespin:editor/mixins/textinput").TextInput,i=a("Canon:keyboard").keyboardManager;b.TextView=d.extend(e,h,{_dragPoint:null,_dragTimer:null,_inChangeGroup:false,_lineAscent:16,_selectedRange:null,_selectedRangeEndVirtual:null,_beginChangeGroup:function(){if(this._inChangeGroup)throw new Error("TextView._beginChangeGroup() called while already in a change group");
this._inChangeGroup=true;this.notifyDelegates("textViewBeganChangeGroup",this._selectedRange)},_drag:function(){var j=this.convertFrameFromView(this._dragPoint),k=g.offsetFromRect(this.get("clippingFrame"),j);this._moveCursorTo(this._selectionPositionForPoint({x:j.x-k.x,y:j.y-k.y}),false,true);this.becomeFirstResponder()},_drawInsertionPoint:function(j,k){j=this._selectedRange;j=this.get("layoutManager").characterRectForPosition(j.start);k.save();k.strokeStyle=this.get("theme").cursorStyle;k.beginPath();
k.moveTo(j.x+0.5,j.y);k.lineTo(j.x+0.5,j.y+j.height);k.closePath();k.stroke();k.restore()},_drawLines:function(j,k){var l=this.get("layoutManager"),m=l.get("textLines"),o=this.get("theme"),r=this._lineAscent;k.save();k.font=o.editorTextFont;o=l.characterRangeForBoundingRect(j);j=o.start;o=o.end;for(var w=o.row,p=j.row;p<=w;p++){var s=m[p];if(!c.none(s)){var v=s.characters,t=v.length,z=Math.min(o.column,t),u=j.column;if(!(u>=t)){s=s.colors;for(t=0;u<s[t].start;)t++;for(var A=u;A!==null&&A<z;){var E=
s[t];u=E.end;k.fillStyle=E.color;E=l.characterRectForPosition({row:p,column:A});A=u===null?v.substring(A):v.substring(A,u);k.fillText(A,E.x,E.y+r);A=u;t++}}}}k.restore()},_drawSelectionHighlight:function(j,k){j=this.get("theme");j=this.get("isFirstResponder")?j.editorSelectedTextBackground:j.unfocusedCursorFillStyle;var l=this.get("layoutManager");k.save();var m=f.normalizeRange(this._selectedRange);k.fillStyle=j;l.rectsForRange(m).forEach(function(o){k.fillRect(o.x,o.y,o.width,o.height)});k.restore()},
_drawSelection:function(j,k){this._rangeIsInsertionPoint(this._selectedRange)?this._drawInsertionPoint(j,k):this._drawSelectionHighlight(j,k)},_endChangeGroup:function(){if(!this._inChangeGroup)throw new Error("TextView._endChangeGroup() called while not in a change group");this._inChangeGroup=false;this.notifyDelegates("textViewEndedChangeGroup",this._selectedRange)},_getVirtualSelection:function(j){return{start:j&&this._selectedRangeEndVirtual?this._selectedRangeEndVirtual:this._selectedRange.start,
end:this._selectedRangeEndVirtual||this._selectedRange.end}},_insertText:function(j){this._beginChangeGroup();this.getPath("layoutManager.textStorage");var k=f.normalizeRange(this._selectedRange);this._replaceCharacters(k,j);var l=j.split("\n");this._moveCursorTo(l.length>1?{row:k.start.row+l.length-1,column:l[l.length-1].length}:f.addPositions(k.start,{row:0,column:j.length}));this._endChangeGroup()},_invalidateInsertionPointIfNecessary:function(j){if(this._rangeIsInsertionPoint(j)){j=this.get("layoutManager").characterRectForPosition(j.start);
this.setNeedsDisplayInRect({x:j.x,y:j.y,width:1,height:j.height})}},_isDelimiter:function(j){return["="," ","\t",">","<",".",",","(",")","{","}",":",'"',"'",";"].indexOf(j)>-1},_moveCursorTo:function(j,k,l){var m;m=this.getPath("layoutManager.textStorage").clampPosition(j);this.setSelection({start:l?this._selectedRange.start:m,end:m});this._selectedRangeEndVirtual=k?j:null;this._scrollToPosition(this._selectedRange.end)},_moveOrSelectEnd:function(j,k){var l=this.getPath("layoutManager.textStorage.lines");
k=k?this._selectedRange.end.row:l.length-1;this._moveCursorTo({row:k,column:l[k].length},false,j)},_moveOrSelectStart:function(j,k){var l=this._selectedRange;this._moveCursorTo({row:k?l.end.row:0,column:0},false,j)},_performBackspaceOrDelete:function(j){this._beginChangeGroup();var k=this.getPath("layoutManager.textStorage");k.get("lines");var l=f.normalizeRange(this._selectedRange);if(this._rangeIsInsertionPoint(l))l=j?{start:k.displacePosition(l.start,-1),end:l.end}:{start:l.start,end:k.displacePosition(l.end,
1)};this._replaceCharacters(l,"");this._moveCursorTo(l.start);this._endChangeGroup()},_performVerticalKeyboardSelection:function(j){this.getPath("layoutManager.textStorage");this._moveCursorTo(f.addPositions(this._selectedRangeEndVirtual!==null?this._selectedRangeEndVirtual:this._selectedRange.end,{row:j,column:0}),true,true)},_rangeIsInsertionPoint:function(j){return f.isZeroLength(j)},_replaceCharacters:function(j,k){if(!this._inChangeGroup)throw new Error("TextView._replaceCharacters() called without a change group");
j=f.normalizeRange(j);this.notifyDelegates("textViewWillReplaceRange",j);this.getPath("layoutManager.textStorage").replaceCharacters(j,k);this.notifyDelegates("textViewReplacedCharacters",j,k)},_repositionSelection:function(){var j=this.getPath("layoutManager.textLines"),k=j.length,l=this._selectedRange,m=Math.min(l.start.row,k-1);k=Math.min(l.end.row,k-1);var o=j[k];this.setSelection({start:{row:m,column:Math.min(l.start.column,j[m].characters.length)},end:{row:k,column:Math.min(l.end.column,o.characters.length)}})},
_resize:function(){var j=this.get("layoutManager").boundingRect(),k=this.get("padding"),l=this.getPath("parentView.frame");this.set("layout",c.mixin(c.clone(this.get("layout")),{width:Math.max(l.width,j.width+k.right),height:Math.max(l.height,j.height+k.bottom)}))},_scrollPage:function(j){var k=this._scrollView(),l=this.get("clippingFrame");k.scrollTo(l.x,l.y+(l.height+this._lineAscent)*(j?-1:1))},_scrollToPosition:function(j){var k=this._scrollView();if(!c.none(k)){var l=this.get("layoutManager").characterRectForPosition(j);
j=l.x;var m=l.y,o=l.width;l=l.height;var r=this.get("clippingFrame"),w=r.x,p=r.y,s=this.get("padding"),v=r.width-s.right;r=r.height-s.bottom;k.scrollTo(j>=w&&j+o<w+v?w:j-v/2+o/2,m>=p&&m+l<p+r?p:m-r/2+l/2)}},_scrollView:function(){for(var j=this.get("parentView");!c.none(j)&&!j.get("isScrollable");)j=j.get("parentView");return j},_scrollWhileDragging:function(){var j=this._scrollView();if(!c.none(j)){var k=g.offsetFromRect(this.get("clippingFrame"),this.convertFrameFromView(this._dragPoint));if(!(k.x===
0&&k.y===0)){j.scrollBy(k.x,k.y);this._drag()}}},_selectionPositionForPoint:function(j){j=this.get("layoutManager").characterAtPoint(j);return j.partialFraction<0.5?j:f.addPositions(j,{row:0,column:1})},_syntaxManagerUpdatedSyntaxForRows:function(j,k){if(j!==k){var l=this.get("layoutManager");l.updateTextRows(j,k);l.rectsForRange({start:{row:j,column:0},end:{row:k,column:0}}).forEach(this.setNeedsDisplayInRect,this)}},_updateSyntax:function(j){var k=this.get("layoutManager"),l=k.characterRangeForBoundingRect(this.get("clippingFrame")),
m=l.start.row;l=l.end.row;if(j!==null){if(j<m||j>l)return;m=j}var o=this;j=k.getPath("textStorage.lines");k=k.get("syntaxManager");l=Math.min(j.length,l+1);k.updateSyntaxForRows(m,l).then(function(r){o._syntaxManagerUpdatedSyntaxForRows(r.startRow,r.endRow)})},acceptsFirstResponder:true,clippingFrameChanged:function(){arguments.callee.base.apply(this,arguments);this._updateSyntax(null)},hasPadding:true,layoutManager:null,padding:{bottom:0,right:0},parentViewFrameChanged:function(){arguments.callee.base.apply(this,
arguments);this._resize()},tabStop:8,theme:{backgroundStyle:"#2a211c",cursorStyle:"#879aff",editorTextFont:"10pt Monaco, Lucida Console, monospace",editorSelectedTextColor:"rgb(240, 240, 240)",editorSelectedTextBackground:"#526da5",unfocusedCursorStrokeStyle:"#ff0033",unfocusedCursorFillStyle:"#73171e"},backspace:function(){this._performBackspaceOrDelete(true)},copy:function(){return this.getSelectedCharacters()},cut:function(){var j=this.getSelectedCharacters();j!=""&&this.deleteSelectionOrNextCharacter();
return j},deleteSelectionOrNextCharacter:function(){this._performBackspaceOrDelete(false)},drawRect:function(j,k){k.fillStyle=this.get("theme").backgroundStyle;k.fillRect(j.x,j.y,j.width,j.height);this._drawSelection(j,k);this._drawLines(j,k)},getSelectedCharacters:function(){return this._rangeIsInsertionPoint(this._selectedRange)?"":this.getPath("layoutManager.textStorage").getCharacters(f.normalizeRange(this._selectedRange))},getSelectedRange:function(){return f.normalizeRange(this._selectedRange)},
init:function(){arguments.callee.base.apply(this,arguments);this._invalidRange=null;this._selectedRange={start:{row:0,column:0},end:{row:0,column:0}};this.set("padding",c.clone(this.get("padding")));this.get("layoutManager").addDelegate(this);this._resize()},keyDown:function(j){return j.charCode===0?i.processKeyEvent(j,this,{isTextView:true}):false},layoutManagerChangedTextAtRow:function(j,k){this._updateSyntax(k);this._repositionSelection()},layoutManagerInvalidatedRects:function(j,k){k.forEach(this.setNeedsDisplayInRect,
this);this._resize()},mouseDown:function(j){switch(j.clickCount){case 1:var k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));this._moveCursorTo(k,false,j.shiftKey);break;case 2:k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));var l=this.getPath("layoutManager.textStorage").lines[k.row];if(l.length===0)return;k.column-=k.column==l.length?1:0;var m=!this._isDelimiter(l[k.column]),o=this,r=function(p,s){for(;p>-1&&p<l.length;p+=
s)if(o._isDelimiter(l[p])===m)break;return p+(s==1?0:1)},w=r(k.column,-1);r=r(k.column,1);this._moveCursorTo({row:k.row,column:w});this._moveCursorTo({row:k.row,column:r},false,true);break;case 3:w=this.getPath("layoutManager.textStorage").lines;k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));this.setSelection({start:{row:k.row,column:0},end:{row:k.row,column:w[k.row].length}});break}this._dragPoint={x:j.clientX,y:j.clientY};this._dragTimer=c.Timer.schedule({target:this,
action:"_scrollWhileDragging",interval:100,repeats:true});this.becomeFirstResponder()},mouseDragged:function(j){this._dragPoint={x:j.clientX,y:j.clientY};this._drag()},mouseUp:function(){this._dragTimer!==null&&this._dragTimer.invalidate()},moveDocEnd:function(){this._moveOrSelectEnd(false,false)},moveDocStart:function(){this._moveOrSelectStart(false,false)},moveDown:function(){var j=this._getVirtualSelection();j=f.normalizeRange(j);j=this._rangeIsInsertionPoint(this._selectedRange)?j.end:{row:j.end.row,
column:j.start.column};j=f.addPositions(j,{row:1,column:0});this._moveCursorTo(j,true)},moveLeft:function(){var j=f.normalizeRange(this._selectedRange);this._rangeIsInsertionPoint(j)?this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(j.start,-1)):this._moveCursorTo(j.start)},moveLineEnd:function(){this._moveOrSelectEnd(false,true)},moveLineStart:function(){this._moveOrSelectStart(false,true)},moveRight:function(){var j=f.normalizeRange(this._selectedRange);this._rangeIsInsertionPoint(j)?
this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(j.end,1)):this._moveCursorTo(j.end)},moveUp:function(){var j=f.normalizeRange(this._getVirtualSelection(true));position=f.addPositions({row:j.start.row,column:this._getVirtualSelection().end.column},{row:-1,column:0});this._moveCursorTo(position,true)},newline:function(){var j=this._selectedRange.start;this._insertText("\n"+/^\s*/.exec(this.getPath("layoutManager.textStorage.lines")[j.row].substring(0,j.column))[0])},scrollDocStart:function(){this._scrollToPosition({column:0,
row:0})},scrollDocEnd:function(){this._scrollToPosition(this.getPath("layoutManager.textStorage").range().end)},scrollPageDown:function(){this._scrollPage(false)},scrollPageUp:function(){this._scrollPage(true)},selectAll:function(){var j=this.getPath("layoutManager.textStorage.lines"),k=j.length-1;this.setSelection({start:{row:0,column:0},end:{row:k,column:j[k].length}})},selectDocEnd:function(){this._moveOrSelectEnd(true,false)},selectDocStart:function(){this._moveOrSelectStart(true,false)},selectDown:function(){this._performVerticalKeyboardSelection(1)},
selectLeft:function(){this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,-1),false,true)},selectLineEnd:function(){this._moveOrSelectEnd(true,true)},selectLineStart:function(){this._moveOrSelectStart(true,true)},selectRight:function(){this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,1),false,true)},selectUp:function(){this._performVerticalKeyboardSelection(-1)},setSelection:function(j){this.getPath("layoutManager.textStorage");
var k=f.normalizeRange(this._selectedRange),l=f.normalizeRange(j);this._selectedRange=j;j=this.get("layoutManager");j.rectsForRange(k).forEach(this.setNeedsDisplayInRect,this);j.rectsForRange(l).forEach(this.setNeedsDisplayInRect,this);this._invalidateInsertionPointIfNecessary(k);this._invalidateInsertionPointIfNecessary(l)},tab:function(){var j=this.get("tabStop");j=j-this._selectedRange.start.column%j;for(var k="",l=0;l<j;l++)k+=" ";this._insertText(k)},textInserted:function(j){j==="\n"?this.newline():
this._insertText(j)},focus:function(){this.focusTextInput();this.becomeFirstResponder()}});b.textViewCommand=function(j,k,l){j=j.get("view");j[l.commandExt.name].apply(j)}});tiki.module("Editor:index",function(){});tiki.register("Filesystem",{});
tiki.module("Filesystem:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:util/util"),e=a("path"),f=a("bespin:promise").Promise,g=b.NEW={name:"NEW"},h=b.LOADING={name:"LOADING"},i=b.READY={name:"READY"};b.Directory=c.Object.extend({source:null,parent:null,name:null,directories:null,files:null,status:g,contents:function(){return this.get("directories").concat(this.get("files"))}.property("directories","files").cacheable(),init:function(){var k=this.get("source");typeof k=="string"&&
this.set("source",c.objectForPropertyPath(k));if(!this.get("source"))throw new Error("Directory must have a source.");if(this.get("name")==null){if(this.get("parent")!=null)throw new Error("Directories must have a name, except for the root");this.set("name","/")}this.get("directories")==null&&this.set("directories",[]);this.get("files")==null&&this.set("files",[])},load:function(){var k=new f;if(this.get("status")==i){k.resolve(this);return k}this.set("status",h);var l=this;this.get("source").loadDirectory(this).then(function(m){l.populateDirectory(m);
k.resolve(l)},function(m){k.reject({message:m.toString(),error:m,directory:l})});return k},loadPath:function(k){var l,m=this.getObject(k);if(m==null){l=new f;l.reject({message:"Cannot find "+k});return l}if(e.isDir(k))return m.load();else{l=new f;l.resolve(m);return l}},_getItem:function(k){return(d.endsWith(k,"/")?this.get("directories"):this.get("files")).findProperty("name",k)},getObject:function(k){var l=k.split("/");(k=e.isDir(k))&&l.pop();for(var m=this,o=0;o<l.length-1;o++){var r=l[o]+"/",
w=m._getItem(r);if(w==null){if(m.get("status")==i)return null;w=b.Directory.create({source:m.get("source"),name:r,parent:m});m.get("directories").push(w)}m=w}l=l[o];if(k)l+="/";o=m._getItem(l);if(!o){if(m.get("status")==i)return null;if(k){o=b.Directory.create({name:l,source:m.get("source"),parent:m});m.get("directories").push(o)}else{o=b.File.create({name:l,directory:m});m.get("files").push(o)}}return o},path:function(){var k=this.get("parent");if(k)return e.combine(k.get("path"),this.get("name"));
return this.get("name")}.property().cacheable(),originPath:function(){return this.get("path")}.property().cacheable(),toString:function(){return"Directory "+this.get("name")},populateDirectory:function(k){this.set("status",i);var l=[],m=[],o=this.get("source");k.forEach(function(r){if(r.name)if(d.endsWith(r.name,"/")){r.parent=this;r.source=o;m.push(b.Directory.create(r))}else{r.directory=this;l.push(b.File.create(r))}else console.error("Bad data, no directory/file name: ",r)}.bind(this));this.set("directories",
m);this.set("files",l)}});b.File=c.Object.extend({directory:null,name:null,source:function(){return this.get("directory").get("source")}.property(),path:function(){return e.combine(this.get("directory").get("path"),this.get("name"))}.property().cacheable(),dirname:function(){return this.get("directory").get("path")}.property().cacheable(),ext:function(){return e.fileType(this.get("name"))}.property(),originPath:function(){return this.get("path")}.property().cacheable(),loadContents:function(){return this.get("source").loadContents(this)},
saveContents:function(k){return this.get("source").saveContents(this,k)}});b.FileSystemOld=c.Object.extend({userSettingsProject:"BespinSettings",newFile:function(k,l,m,o){this.whenFileDoesNotExist(k,l,{execute:function(){if(editSession.shouldCollaborate())editSession.startSession(k,l||"new.txt",m,o);else{hub.publish("path:changed",{project:k,path:l});editSession.setReadOnlyIfNotMyProject(k);m({name:l,content:"",timestamp:(new Date).getTime()})}},elseFailed:function(){d.isFunction(o)&&o({responseText:"The file "+
l+" already exists my friend."});throw new Error("The file "+l+" already exists my friend.");}})},loadContents:function(k,l,m,o){server.loadFile(k,l,function(r){if(/\n$/.test(r))r=r.substr(0,r.length-1);m({name:l,content:r,timestamp:(new Date).getTime()})},o)},editFile:function(k,l,m,o){editSession.shouldCollaborate()?editSession.startSession(k,l,m,o):this.loadContents(k,l,function(){editSession.setReadOnlyIfNotMyProject(k);m.apply(null,arguments)},o)},evalFile:function(k,l,m){m=m||j();if(!k||!l)throw new Error("Please, I need a project and filename to evaulate");
this.loadContents(k,l,function(o){with(m)try{eval(o.content)}catch(r){throw new Error("There is a error trying to run "+l+" in project "+k+": "+r);}},true)},projects:function(k){server.projects(k)},fileNames:function(k,l){server.list(k,"",l)},saveFile:function(k,l,m,o){if(/\n$/.test(l.content))l.content+="\n";server.saveFile(k,l.name,l.content,l.lastOp,{onSuccess:function(){console.log("File saved: "+k+" "+l.name);hub.publish("file:saved",{project:k,path:l.name});d.isFunction(m)&&m()},onFailure:o})},
makeDirectory:function(k,l,m,o){server.makeDirectory(k,l,function(r){hub.publish("directory:created",{project:k,path:l});m(r)},o)},removeDirectory:function(k,l,m,o){server.removeFile(k,l,function(r){hub.publish("directory:removed",{project:k,path:l});m(r)},o)},removeFile:function(k,l,m,o){server.removeFile(k,l,function(r){hub.publish("file:removed",{project:k,path:l});m(r)},o)},closeFile:function(k,l,m){server.closeFile(k,l,m)},whenFileExists:function(k,l,m){server.list(k,l.directory(l),function(o){var r=
o.some(function(w){return w.name==l});if(o&&r)m.execute();else m.elseFailed&&m.elseFailed()},function(o){m.elseFailed&&m.elseFailed(o)})},whenFileDoesNotExist:function(k,l,m){server.list(k,l.directory(l),function(o){var r=o.some(function(w){return w.name==l});if(!o||!r)m.execute();else m.elseFailed&&m.elseFailed()},function(){m.execute()})}});var j=function(){if(k)return k;var k={include:function(l){files.evalFile(files.userSettingsProject,l)},require:a,execute:function(l){cliController.executeCommand(l)}};
["editor","files","server"].forEach(function(l){k.id=this[l]});return k}});
tiki.module("Filesystem:path",function(a,b){var c=a("bespin:util/util");b.combine=function(){var d=Array.prototype.slice.call(arguments).join("/");d=d.replace(/\/\/+/g,"/");return d=d.replace(/^\s+|\s+$/g,"")};b.directory=function(d){var e=d.split("/");return e.length==1?"":e.length==2&&e[e.length-1]==""?d:e.slice(0,e.length-1).join("/")};b.makeDirectory=function(d){/\/$/.test(d)||(d+="/");return d};b.combineAsDirectory=function(){return this.makeDirectory(this.combine.apply(this,arguments))};b.escape=
function(){return escape(this.combine.apply(this,arguments))};b.trimLeadingSlash=function(d){if(d.indexOf("/")==0)d=d.substring(1,d.length);return d};b.hasLeadingSlash=function(d){return d.indexOf("/")==0};b.fileType=function(d){if(d.indexOf(".")>=0){d=d.split(".");if(d.length>1)return d[d.length-1]}};b.isDir=function(d){return c.endsWith(d,"/")}});
tiki.module("Filesystem:project",function(a,b){var c=a("bespin:util/util");a=a("bespin:plugin").catalog;var d=a.getObject("server"),e=a.getObject("editSession"),f=a.getObject("files");b.showCommand=function(){request.done(e.getStatus())};b.listCommand=function(){f.projects(function(k){for(var l="",m=0;m<k.length;m++)l+=k[m].name+"<br/>";request.done(l)})};b.createCommand=function(k,l){if(l){var m=k.link(function(){e.setProject(l);request.done("Created project '"+l+"'.")});k=k.link(function(o){request.doneWithError("Unable to create project '"+
l+": "+o.responseText)});f.makeDirectory(l,"",m,k)}else k.addParameterError("project","Value missing")};b.deleteCommand=function(k,l){if(!l||l==f.userSettingsProject)request.doneWithError("You can't delete the settings project.");else{var m=k.link(function(){request.done("Deleted project "+l)});k=k.link(function(o){request.doneWithError("Failed to delete project "+l+": "+o.responseText)});f.removeDirectory(l,"",m,k)}};b.renameCommand=function(k,l){l.currentProject!=l.newProject&&d.renameProject(l.currentProject,
l.newProject,{onSuccess:k.link(function(){e.setProject(l.newProject);request.done()}),onFailure:k.link(function(){request.doneWithError("Unable to rename project from "+l.currentProject+" to "+l.newProject+"<br><br><em>Are you sure that the "+l.currentProject+" project exists?</em>")})})};b.exportCommand=function(k,l){var m=l.project||e.project,o=l.archivetype;c.include(["zip","tgz","tar.gz"],o)||(o="zip");f.projects(function(r){c.indexOfProperty(r,"name",m+"/")!=null?d.exportProject(m,o):request.doneWithError("Unabled to export project "+
m+" because it doesn't seem to exist.")})};var g=function(k){k=k.split("/");k=k[k.length-1].split(".");k.pop();return k.join("_")},h=function(k){return k&&/^http(:|s:)/.test(k)},i={connect:function(){throw new Error("Find an alternative for dojo.connect()");},disconnect:function(){throw new Error("Find an alternative for dojo.disconnect()");},io:{iframe:{send:function(){throw new Error("Find an alternative for dojo.io.iframe.send()");}}}},j=function(k){var l=document.getElementById("centerpopup");
l.innerHTML="<div id='upload-container'><form method='POST' name='upload' id='upload' enctype='multipart/form-data'><div id='upload-header'>Import project via upload <img id='upload-close' src='images/icn_close_x.png' align='right'></div><div id='upload-content'><div id='upload-status'></div><p>Browse to find the project archive that you wish to archive<br>and then click on the <code>Upload</code> button.</p><center><input type='file' id='filedata' name='filedata' accept='application/zip,application/x-gzip'> <input type='submit' value='Upload'></center></div></form></div>";
i.connect(document.getElementById("upload"),"submit",function(){var s=document.getElementById("upload-status");s.innerHTML="Importing file into new project "+k;i.io.iframe.send({url:"/project/import/"+k,form:document.getElementById("upload"),method:"POST",handleAs:"text",preventCache:true,contentType:"multipart/form-data",load:function(){s.innerHTML="Thanks for uploading the file!"},error:function(){setTimeout(function(){f.projects(function(v){s.innerHTML=v.some(function(t){return k+"/"==t.name})?
"Archive imported and project "+k+" has been created!":"Error uploading the file."})},100)}})});var m,o,r=function(){l.removeChild(l.firstChild);i.disconnect(m);i.disconnect(o)},w=document.getElementById("upload-close"),p=document.getElementById("overlay");m=i.connect(w,"onclick",r);o=i.connect(p,"onclick",r)};b.importCommand=function(k,l){var m,o;if(l.url)if(!l.project&&h(l.url))l.project=g(l.url);else if(h(l.project)){m=l.project;o=l.url;l.project=o;l.url=m}else if(h(l.url)){m=l.project;o=l.url;
request.done("About to import "+m+" from:<br><br>"+o+"<br><em>It can take awhile to download the project, so be patient!</em>");d.importProject(m,o,{onSuccess:function(){request.done("Project "+m+" imported from:<br><br>"+o)},onFailure:function(r){request.doneWithError("Unable to import "+m+" from:<br><br>"+o+".<br><br>Maybe due to: "+r.responseText)}})}else{m=l.url;j(m)}else k.addParameterError("url","Value missing")}});tiki.register("EditSession",{});
tiki.module("EditSession:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("Editor:models/textstorage").TextStorage;b.Buffer=c.Object.extend({model:null,_file:null,file:function(e,f){var g=this;if(f!=undefined){this._file=f;f.loadContents().then(function(h){g.get("model").set("value",h.contents)})}return this._file}.property(),init:function(){this.get("model")==null&&this.set("model",d.create())},changeFile:function(e){var f=this;this.changeFileOnly(e);return e.loadContents().then(function(g){f.get("model").set("value",
g.contents);return f})},changeFileOnly:function(e){this._file=e;this.propertyDidChange("file")},save:function(){return this._file.saveContents(this.model.get("value"))}});b.EditSession=c.Object.extend({currentView:null,currentBuffer:null})});tiki.register("Embedded",{});
tiki.module("Embedded:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:views/dock").DockView,e=a("Editor:views/editor").EditorView,f=a("AppSupport:views/keylistener").KeyListener;a("bespin:index");var g=a("EditSession");a("bespin:util/util");b.EmbeddedEditor=c.Object.extend({_editorView:null,_focused:false,_attachEmbeddedEvents:function(){this.getPath("pane.layer").addEventListener("mousedown",function(){this.setFocus(true)}.bind(this),true);document.body.addEventListener("mousedown",
function(){this.setFocus(false)}.bind(this),true)},_attachPane:function(){typeof this.get("element")==="string"&&this.set("element",document.getElementById("element"));var h=this.get("element");if(c.none("element"))throw new Error("No element was specified to attach Bespin Embedded to");var i=this.get("options");if(c.none(i.initialContent))i.initialContent=h.innerHTML;c.$(h).css("position","relative");h.innerHTML="";this.get("pane").appendTo(h)},_computeLayout:function(){for(var h=this.get("element"),
i={top:0,left:0,width:h.clientWidth,height:h.clientHeight};!c.none(h);){i.top+=h.offsetTop+h.clientTop;i.left+=h.offsetLeft+h.clientLeft;h=h.offsetParent}return i},_createValueProperty:function(){this.__defineGetter__("value",function(){return this._editorView.getPath("layoutManager.textStorage.value")});this.__defineSetter__("value",function(h){c.run(function(){this._editorView.setPath("layoutManager.textStorage.value",h)}.bind(this))})},_hookWindowResizeEvent:function(){window.addEventListener("resize",
this.dimensionsChanged.bind(this),false)},_setOptions:function(){var h=this._editorView.get("layoutManager"),i=this.get("options"),j=i.initialContent;c.none(j)||h.setPath("textStorage.value",j);j=i.noAutoresize;if(c.none(j))j=i.dontHookWindowResizeEvent;if(c.none(j)||!j)this._hookWindowResizeEvent();j=i.stealFocus;!c.none(j)&&j&&window.setTimeout(function(){this.setFocus(true)}.bind(this),1);h=h.get("syntaxManager");i=i.syntax;c.none(i)||h.set("initialContext",i)},element:null,options:null,pane:c.Pane.extend({_layoutChanged:function(){this._recomputeLayoutStyle()}.observes("layout"),
_recomputeLayoutStyle:function(){var h=this.get("layout");this.set("layoutStyle",{width:"%@px".fmt(h.width),height:"%@px".fmt(h.height)})},applicationView:d.extend({centerView:e.extend(),dockedViews:[]}),childViews:"applicationView".w(),layoutStyle:{},init:function(){arguments.callee.base.apply(this,arguments);this.set("defaultResponder",f.create());this._recomputeLayoutStyle()}}),dimensionsChanged:function(){c.run(function(){var h=this.get("pane"),i=h.get("layout"),j=this._computeLayout(this.get("element"));
if(!c.rectsEqual(i,j)){h.adjust(j);h.updateLayout()}}.bind(this))},init:function(){var h=g.EditSession.create();b.session=h;var i=this.get("pane").create({layout:this._computeLayout()});this.set("pane",i);this._attachPane();var j=i.getPath("applicationView.centerView");this._editorView=j;i=j.get("textStorage");j=j.get("textView");b.model=i;b.view=j;i=g.Buffer.create({model:i});h.set("currentBuffer",i);h.set("currentView",j);c.run(function(){this._attachEmbeddedEvents();this._createValueProperty();
this._setOptions()}.bind(this))},setFocus:function(h){var i=this.get("pane");if(this._focused!==h)(this._focused=h)?i.becomeKeyPane():i.resignKeyPane()},setLineNumber:function(h){c.RunLoop.begin();var i=this.getPath("pane.editorView.textView");h={row:h-1,column:0,partialFraction:0};i.setSelection([{start:h,end:h}]);c.RunLoop.end()}});b.session=null;b.useBespin=function(h,i){return b.EmbeddedEditor.create({element:h,options:c.none(i)?{}:i})}});tiki.register("HTML",{});
tiki.module("HTML:index",function(a,b){a("sproutcore/runtime");a=a("SyntaxManager:controllers/standardsyntax").StandardSyntax;var c={},d=function(e,f){c[e+"_beforeAttrName"]=[{regex:/^\s+/,tag:"plain"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:f},{regex:/^./,tag:"keyword",then:e+"_attrName"}];c[e+"_attrName"]=[{regex:/^\s+/,tag:"plain",then:e+"_afterAttrName"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^=/,tag:"operator",then:e+
"_beforeAttrValue"},{regex:/^>/,tag:"operator",then:f},{regex:/^["'<]+/,tag:"error"},{regex:/^[^ \t\n\/=>"'<]+/,tag:"keyword"}];c[e+"_afterAttrName"]=[{regex:/^\s+/,tag:"plain"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^=/,tag:"operator",then:e+"_beforeAttrValue"},{regex:/^>/,tag:"operator",then:f},{regex:/^./,tag:"keyword",then:e+"_attrName"}];c[e+"_beforeAttrValue"]=[{regex:/^\s+/,tag:"plain"},{regex:/^"/,tag:"string",then:e+"_attrValueQQ"},{regex:/^(?=&)/,tag:"plain",
then:e+"_attrValueU"},{regex:/^'/,tag:"string",then:e+"_attrValueQ"},{regex:/^>/,tag:"error",then:f},{regex:/^./,tag:"string",then:e+"_attrValueU"}];c[e+"_attrValueQQ"]=[{regex:/^"/,tag:"string",then:e+"_afterAttrValueQ"},{regex:/^[^"]+/,tag:"string"}];c[e+"_attrValueQ"]=[{regex:/^'/,tag:"string",then:e+"_afterAttrValueQ"},{regex:/^[^']+/,tag:"string"}];c[e+"_attrValueU"]=[{regex:/^\s/,tag:"string",then:e+"_beforeAttrName"},{regex:/^>/,tag:"operator",then:f},{regex:/[^ \t\n>]+/,tag:"string"}];c[e+
"_afterAttrValueQ"]=[{regex:/^\s/,tag:"plain",then:e+"_beforeAttrName"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:f},{regex:/^(?=.)/,tag:"operator",then:e+"_beforeAttrName"}];c[e+"_selfClosingStartTag"]=[{regex:/^>/,tag:"operator",then:"start"},{regex:/^./,tag:"error",then:e+"_beforeAttrName"}]};c={start:[{regex:/^[^<]+/,tag:"plain"},{regex:/^<!--/,tag:"comment",then:"commentStart"},{regex:/^<!/,tag:"directive",then:"markupDeclarationOpen"},{regex:/^<\?/,
tag:"comment",then:"bogusComment"},{regex:/^</,tag:"operator",then:"tagOpen"}],tagOpen:[{regex:/^\//,tag:"operator",then:"endTagOpen"},{regex:/^script/i,tag:"keyword",then:"script_beforeAttrName"},{regex:/^[a-zA-Z]/,tag:"keyword",then:"tagName"},{regex:/^(?=.)/,tag:"plain",then:"start"}],scriptData:[{regex:/^<(?=\/script>)/i,tag:"operator",then:"tagOpen stop:js"},{regex:/^[^<]+/,tag:"plain"}],endTagOpen:[{regex:/^[a-zA-Z]/,tag:"keyword",then:"tagName"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,
tag:"error",then:"bogusComment"}],tagName:[{regex:/^\s+/,tag:"plain",then:"normal_beforeAttrName"},{regex:/^\//,tag:"operator",then:"normal_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:"start"},{regex:/^[^ \t\n\/>]+/,tag:"keyword"}],bogusComment:[{regex:/^[^>]+/,tag:"comment"},{regex:/^>/,tag:"comment",then:"start"}],markupDeclarationOpen:[{regex:/^doctype/i,tag:"directive",then:"doctype"},{regex:/^(?=.)/,tag:"comment",then:"bogusComment"}],commentStart:[{regex:/^--\>/,tag:"comment",then:"start"},
{regex:/^[^-]+/,tag:"comment"}],doctype:[{regex:/^\s/,tag:"plain",then:"beforeDoctypeName"},{regex:/^./,tag:"error",then:"beforeDoctypeName"}],beforeDoctypeName:[{regex:/^\s+/,tag:"plain"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"directive",then:"doctypeName"}],doctypeName:[{regex:/^\s/,tag:"plain",then:"afterDoctypeName"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^[^ \t\n>]+/,tag:"directive"}],afterDoctypeName:[{regex:/^\s+/,tag:"directive"},{regex:/^>/,tag:"directive",then:"start"},
{regex:/^public/i,tag:"directive",then:"afterDoctypePublicKeyword"},{regex:/^system/i,tag:"directive",then:"afterDoctypeSystemKeyword"},{regex:/^./,tag:"error",then:"bogusDoctype"}],afterDoctypePublicKeyword:[{regex:/^\s+/,tag:"plain",then:"beforeDoctypePublicId"},{regex:/^"/,tag:"error",then:"doctypePublicIdQQ"},{regex:/^'/,tag:"error",then:"doctypePublicIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],beforeDoctypePublicId:[{regex:/^\s+/,tag:"plain"},{regex:/^"/,
tag:"string",then:"doctypePublicIdQQ"},{regex:/^'/,tag:"string",then:"doctypePublicIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],doctypePublicIdQQ:[{regex:/^"/,tag:"string",then:"afterDoctypePublicId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^>"]+/,tag:"string"}],doctypePublicIdQ:[{regex:/^'/,tag:"string",then:"afterDoctypePublicId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^>']+/,tag:"string"}],afterDoctypePublicId:[{regex:/^\s/,tag:"plain",
then:"betweenDoctypePublicAndSystemIds"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^"/,tag:"error",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"error",then:"doctypeSystemIdQ"},{regex:/^./,tag:"error",then:"bogusDoctype"}],betweenDoctypePublicAndSystemIds:[{regex:/^\s+/,tag:"plain",then:"betweenDoctypePublicAndSystemIds"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^"/,tag:"string",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"string",then:"doctypeSystemIdQ"},{regex:/^./,tag:"error",then:"bogusDoctype"}],
afterDoctypeSystemKeyword:[{regex:/^\s/,tag:"plain",then:"beforeDoctypeSystemId"},{regex:/^"/,tag:"error",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"error",then:"doctypeSystemIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],beforeDoctypeSystemId:[{regex:/^\s+/,tag:"plain",then:"beforeDoctypeSystemId"},{regex:/^"/,tag:"string",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"string",then:"doctypeSystemIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/./,tag:"error",
then:"bogusDoctype"}],doctypeSystemIdQQ:[{regex:/^"/,tag:"string",then:"afterDoctypeSystemId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^">]+/,tag:"string"}],doctypeSystemIdQ:[{regex:/^'/,tag:"string",then:"afterDoctypeSystemId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^'>]+/,tag:"string"}],afterDoctypeSystemId:[{regex:/^\s+/,tag:"plain"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],bogusDoctype:[{regex:/^>/,tag:"directive",then:"start"},{regex:/^[^>]+/,
tag:"directive"}]};d("normal","start");d("script","scriptData start:js");b.HTMLSyntax=a.create({states:c})});tiki.register("JavaScript",{});
tiki.module("JavaScript:index",function(a,b){a("sproutcore/runtime");a("bespin:promise");a=a("SyntaxManager:controllers/standardsyntax").StandardSyntax;b.JSSyntax=a.create({states:{start:[{regex:/^(?:break|case|catch|continue|default|delete|do|else|false|finally|for|function|if|in|instanceof|let|new|null|return|switch|this|throw|true|try|typeof|var|void|while|with)(?![a-zA-Z0-9_])/,tag:"keyword"},{regex:/^[A-Za-z_][A-Za-z0-9_]*/,tag:"identifier"},{regex:/^[^'"/ \tA-Za-z0-9_]+/,tag:"plain"},{regex:/^[ \t]+/,
tag:"plain"},{regex:/^'/,tag:"string",then:"qstring"},{regex:/^"/,tag:"string",then:"qqstring"},{regex:/^\/\/.*/,tag:"comment"},{regex:/^\/\*/,tag:"comment",then:"comment"},{regex:/^./,tag:"plain"}],qstring:[{regex:/^'/,tag:"string",then:"start"},{regex:/^(?:\\.|[^'\\])+/,tag:"string"}],qqstring:[{regex:/^"/,tag:"string",then:"start"},{regex:/^(?:\\.|[^"\\])+/,tag:"string"}],comment:[{regex:/^[^*\/]+/,tag:"comment"},{regex:/^\*\//,tag:"comment",then:"start"},{regex:/^[*\/]/,tag:"comment"}]}})});
tiki.require("bespin:plugins").catalog.load({SyntaxManager:{testmodules:[],depends:["DelegateSupport"],resourceURL:"resources/SyntaxManager/",provides:[{register:"controllers/syntaxdirectory#discoveredNewSyntax",ep:"extensionhandler",name:"syntax"}]},Embedded:{testmodules:[],depends:["AppSupport","EditSession","Editor"],resourceURL:"resources/Embedded/",provides:[{action:"value",pointer:"#session",ep:"factory",name:"session"}]},JavaScript:{testmodules:[],depends:["SyntaxManager"],resourceURL:"resources/JavaScript/",
provides:[{pointer:"#JSSyntax",ep:"syntax",name:"js"}]},Canon:{testmodules:["tests/testKeyboard"],depends:["Types"],resourceURL:"resources/Canon/",provides:[{indexOn:"name",decription:"A command is a bit of functionality with optional typed arguments which can do something small like moving the cursor around the screen, or large like cloning a project from VCS.",ep:"extensionpoint",name:"command"}]},RangeUtils:{testmodules:[],depends:[],resourceURL:"resources/RangeUtils/"},HTML:{testmodules:[],depends:["SyntaxManager"],
resourceURL:"resources/HTML/",provides:[{pointer:"#HTMLSyntax",ep:"syntax",name:"html"}]},Editor:{testmodules:[],depends:["AppSupport","Canon","DelegateSupport","RangeUtils","SyntaxManager"],resourceURL:"resources/Editor/",provides:[{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"backspace",name:"backspace"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"delete",name:"deleteSelectionOrNextCharacter"},{predicates:{isTextView:true},
pointer:"views/text#textViewCommand",ep:"command",key:"down",name:"moveDown"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"left",name:"moveLeft"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"right",name:"moveRight"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"up",name:"moveUp"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_home",name:"scrollDocStart"},
{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_up",name:"moveDocStart"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:["ctrl_a","meta_a"],name:"selectAll"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_shift_up",name:"selectDocStart"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_end",name:"scrollDocEnd"},{predicates:{isTextView:true},
pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_down",name:"moveDocEnd"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"ctrl_shift_down",name:"selectDocEnd"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:["home","ctrl_left"],name:"moveLineStart"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:["shift_home","ctrl_shift_left"],name:"selectLineStart"},{predicates:{isTextView:true},
pointer:"views/text#textViewCommand",ep:"command",key:["end","ctrl_right"],name:"moveLineEnd"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:["shift_end","ctrl_shift_right"],name:"selectLineEnd"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",name:"newline"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"pagedown",name:"scrollPageDown"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",
ep:"command",key:"pageup",name:"scrollPageUp"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"shift_down",name:"selectDown"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"shift_left",name:"selectLeft"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"shift_right",name:"selectRight"},{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"shift_up",name:"selectUp"},
{predicates:{isTextView:true},pointer:"views/text#textViewCommand",ep:"command",key:"tab",name:"tab"},{pointer:"commands/editor#gotoCommand",description:"move it! make the editor head to a line number.",params:[{type:"text",name:"value",description:"add the line number to move to in the file"}],ep:"command",name:"goto"},{pointer:"commands/editor#replaceCommand",description:"s/foo/bar/g",params:[{type:"text",name:"search",description:"the search regex"},{type:"text",name:"replace",description:"the replacement text"}],
ep:"command",name:"replace"},{pointer:"commands/editor#sortCommand",description:"sort the current buffer",params:[{defaultValue:null,type:"text",name:"direction",description:"optionally, sort descending"}],ep:"command",name:"sort"},{pointer:"commands/editor#entabCommand",description:"Convert spaces to tabs.",params:[{defaultValue:null,type:"text",name:"tabsize",description:"Optionally, specify a tab size. (Defaults to setting.)"}],ep:"command",name:"entab"},{pointer:"commands/editor#detabCommand",
description:"Convert tabs to spaces.",params:[{defaultValue:null,type:"text",name:"tabsize",description:"Optionally, specify a tab size. (Defaults to setting.)"}],ep:"command",name:"detab"},{pointer:"commands/editor#trimCommand",description:"trim trailing or leading whitespace",params:[{defaultValue:null,type:"text",name:"side",description:"optionally, give a side of left, right, or both (defaults to right)"}],ep:"command",name:"trim"},{pointer:"commands/editor#ucCommand",description:"Change all selected text to uppercase",
withKey:"CMD SHIFT U",ep:"command",name:"uc"},{pointer:"commands/editor#lcCommand",description:"Change all selected text to lowercase",withKey:"CMD SHIFT L",ep:"command",name:"lc"}]},Filesystem:{testmodules:["tests/testFileManagement"],resourceURL:"resources/Filesystem/"},AppSupport:{testmodules:[],depends:[],resourceURL:"resources/AppSupport/",provides:[{predicates:["isApplication",true],pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_shift_z","meta_shift_z"],name:"redo"},
{predicates:["isApplication",true],pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_z","meta_z"],name:"undo"}]},DelegateSupport:{testmodules:[],depends:[],resourceURL:"resources/DelegateSupport/"},EditSession:{testmodules:["tests/testSession"],depends:["Editor","Filesystem"],resourceURL:"resources/EditSession/"},Types:{testmodules:["tests/testTypes"],depends:[],resourceURL:"resources/Types/",provides:[{indexOn:"name",description:"Commands can accept various arguments that the user enters or that are automatically supplied by the environment. Those arguments have types that define how they are supplied or completed. The pointer points to an object with methods convert(str value) and getDefault(). Both functions have `this` set to the command's `takes` parameter. If getDefault is not defined, the default on the command's `takes` is used, if there is one. The object can have a noInput property that is set to true to reflect that this type is provided directly by the system. getDefault must be defined in that case.",
ep:"extensionpoint",name:"type"},{description:"Text that the user needs to enter.",pointer:"basic#text",ep:"type",name:"text"},{description:"A JavaScript number",pointer:"basic#number",ep:"type",name:"number"},{description:"A true/false value",pointer:"basic#bool",ep:"type",name:"boolean"},{description:"An object that converts via JavaScript",pointer:"basic#object",ep:"type",name:"object"},{description:"A string that is constrained to be one of a number of pre-defined values",pointer:"basic#selection",
ep:"type",name:"selection"},{description:"A type which we don't understand from the outset, but which we hope context can help us with",pointer:"basic#deferred",ep:"type",name:"deferred"}]}});SC.ready(function(){for(var a=tiki.require("Embedded"),b=document.querySelectorAll(".bespin"),c=0;c<b.length;c++){var d=b[c],e=d.getAttribute("data-bespinoptions");d.bespin=a.useBespin(d,JSON.parse(e))}window.onBespinLoad&&window.onBespinLoad()});document.addEventListener("DOMContentLoaded",SC.didLoad,false);
window.tiki=tiki;
