(function(){var a=(typeof this.global==='object')?this.global:this;a.JS=a.JS||{};JS.ENV=a})();JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._5(this);this._0=a;this._2=new b();this._6=new b();this._d=new b();this._e=new b();this._3={};this._7={}};(function(e){e.displayName='Package';e.toString=function(){return e.displayName};e.log=function(a){if(typeof window==='undefined')return;if(typeof window.runtime==='object')window.runtime.trace(a);if(window.console&&console.info)console.info(a)};var p=e.OrderedSet=function(a){this._f=this.list=[];this._5={};if(!a)return;for(var b=0,c=a.length;b<c;b++)this.push(a[b])};p.prototype.push=function(a){var b=(a.id!==undefined)?a.id:a,c=this._5;if(c.hasOwnProperty(b))return;c[b]=this._f.length;this._f.push(a)};var m=e.Deferred=function(){this._g='deferred';this._h=null;this._i=[]};m.prototype.callback=function(a,b){if(this._g==='succeeded')a.call(b,this._h);else this._i.push([a,b])};m.prototype.succeed=function(a){this._g='succeeded';this._h=a;var b;while(b=this._i.shift())b[0].call(b[1],a)};e.ENV=JS.ENV;e.onerror=function(a){throw a};e._j=function(a){e.onerror(new Error(a));};var l=e.prototype,n=[['requires','_6'],['uses','_d'],['styling','_e']],o=n.length;while(o--)(function(pair){var q=pair[0],r=pair[1];l[q]=function(){var a=arguments.length,b;for(b=0;b<a;b++)this[r].push(arguments[b]);return this}})(n[o]);l.provides=function(){var a=arguments.length,b;for(b=0;b<a;b++){this._2.push(arguments[b]);e._8(arguments[b]).pkg=this}return this};l.setup=function(a){this._k=a;return this};l._r=function(a,b,c){if(this._7[a])return b.call(c);var d=this._3[a]=this._3[a]||[];d.push([b,c]);this._s()};l._1=function(a){if(this._7[a])return false;this._7[a]=true;var b=this._3[a];if(!b)return true;delete this._3[a];for(var c=0,d=b.length;c<d;c++)b[c][0].call(b[c][1]);return true};l._l=function(a){if(!a&&this.__isLoaded!==undefined)return this.__isLoaded;var b=this._2.list,c=b.length,d,h;while(c--){d=b[c];h=e._4(d,this._m);if(h!==undefined)continue;if(a)return e._j('Expected package at '+this._0+' to define '+d);else return this.__isLoaded=false}return this.__isLoaded=true};l._s=function(){if(!this._1('request'))return;this._t();var i=this._6.list.concat(this._d.list),g=this._9||[],k=(this._0||{}).length,j=this;e.when({load:i});e.when({complete:this._6.list},function(){e.when({complete:i,load:[this]},function(){this._1('complete')},this);var c=function(a){if(k===0)return d(a);k-=1;var b=j._0.length-k-1;e.Loader.loadFile(j._0[b],c,g[b])};var d=function(a){j._m=a;if(j._k)j._k();j._l(true);j._1('load')};if(this._l()){this._1('download');return this._1('load')}if(this._0===undefined)return e._j('No load path found for '+this._2.list[0]);if(typeof this._0==='function')this._0(d);else c();if(!e.Loader.loadStyle)return;var h=this._e.list,f=h.length;while(f--)e.Loader.loadStyle(h[f]);this._1('download')},this)};l._t=function(){if(this._9||!(this._0 instanceof Array)||!e.Loader.fetch)return;this._9=[];for(var a=0,b=this._0.length;a<b;a++)this._9[a]=e.Loader.fetch(this._0[a])};l.toString=function(){return'Package:'+this._2.list.join(',')};e.when=function(a,b,c){var d=[],h={},f,i,g;for(f in a){if(!a.hasOwnProperty(f))continue;h[f]=[];i=new e.OrderedSet(a[f]);g=i.list.length;while(g--)d.push([f,i.list[g],g])}var k=g=d.length;if(k===0)return b&&b.call(c,h);while(g--)(function(f){var j=e._a(f[1]);j._r(f[0],function(){h[f[0]][f[2]]=e._4(f[1],j._m);k-=1;if(k===0&&b)b.call(c,h)})})(d[g])};e._n=1;e._b={};e._c={};e._o=[];e._5=function(a){a.id=this._n;this._n+=1};e._p=function(a){var b=a.toString(),c=this._b[b];if(c)return c;if(typeof a==='string')a=[].slice.call(arguments);c=this._b[b]=new this(a);return c};e._a=function(a){if(typeof a!=='string')return a;var b=this._8(a);if(b.pkg)return b.pkg;var c=this._u(a);if(c)return c;var d=new this();d.provides(a);return d};e.remove=function(a){var b=this._a(a);delete this._c[a];delete this._b[b._0]};e._v=function(a,b){this._o.push([a,b])};e._u=function(d){var h=this._o,f=h.length,i,g,k;for(i=0;i<f;i++){g=h[i];if(!g[0].test(d))continue;k=g[1].from+'/'+d.replace(/([a-z])([A-Z])/g,function(a,b,c){return b+'_'+c}).replace(/\./g,'/').toLowerCase()+'.js';var j=new this([k]);j.provides(d);if(k=g[1].require)j.requires(d.replace(g[0],k));return j}return null};e._8=function(a){return this._c[a]=this._c[a]||{}};e._4=function(a,b){if(typeof a!=='string')return undefined;var c=b?{}:this._8(a);if(c.obj!==undefined)return c.obj;var d=b||this.ENV,h=a.split('.'),f;while(f=h.shift())d=d&&d[f];if(b&&d===undefined)return this._4(a);return c.obj=d}})(JS.Package);JS.Package.DomLoader={HOST_REGEX:/^https?\:\/\/[^\/]+/i,usable:function(){return!!JS.Package._4('window.document.getElementsByTagName')},__FILE__:function(){var a=document.getElementsByTagName('script');src=a[a.length-1].src,url=window.location.href;if(/^\w+\:\/+/.test(src))return src;if(/^\//.test(src))return window.location.origin+src;return url.replace(/[^\/]*$/g,'')+src},cacheBust:function(a){var b=new Date().getTime();return a+(/\?/.test(a)?'&':'?')+b},fetch:function(a){var b=a;if(JS.cacheBust)a=this.cacheBust(a);this.HOST=this.HOST||this.HOST_REGEX.exec(window.location.href);var c=this.HOST_REGEX.exec(a);if(!this.HOST||(c&&c[0]!==this.HOST[0]))return null;JS.Package.log('Loading '+a);var d=new JS.Package.Deferred(),h=this,f=window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();f.open('GET',a,true);f.onreadystatechange=function(){if(f.readyState!==4)return;f.onreadystatechange=h._q;d.succeed(f.responseText+'\n//@ sourceURL='+b);f=null};f.send(null);return d},loadFile:function(c,d,h){if(JS.cacheBust&&!h)c=this.cacheBust(c);var f=this,i=document.getElementsByTagName('head')[0],g=document.createElement('script');g.type='text/javascript';if(h)return h.callback(function(code){JS.Package.log('Executing '+c);eval(code);d()});JS.Package.log('Loading and executing '+c);g.src=c;g.onload=g.onreadystatechange=function(){var a=g.readyState,b=g.status;if(!a||a==='loaded'||a==='complete'||(a===4&&b===200)){d();g.onload=g.onreadystatechange=f._q;i=null;g=null}};i.appendChild(g)},loadStyle:function(a){var b=document.createElement('link');b.rel='stylesheet';b.type='text/css';b.href=a;document.getElementsByTagName('head')[0].appendChild(b)},_q:function(){}};JS.Package.Loader=JS.Package.DomLoader;JS.Package.DSL={__FILE__:function(){return JS.Package.Loader.__FILE__()},pkg:function(a,b){var c=b?JS.Package._p(b):JS.Package._a(a);c.provides(a);return c},file:function(){return JS.Package._p.apply(JS.Package,arguments)},load:function(a,b){JS.Package.Loader.loadFile(a,b)},autoload:function(a,b){JS.Package._v(a,b)}};JS.Package.DSL.files=JS.Package.DSL.file;JS.Package.DSL.loader=JS.Package.DSL.file;JS.Packages=function(a){a.call(JS.Package.DSL)};JS.cacheBust=false;JS.load=function(a,b){JS.Package.Loader.loadFile(a,function(){if(typeof b==='function')b()});return this};JS.require=function(){var b=[],c=0;while(typeof arguments[c]==='string'){b.push(arguments[c]);c+=1}var d=arguments[c],h=arguments[c+1];JS.Package.when({complete:b},function(a){if(!d)return;d.apply(h||null,a&&a.complete)});return this};JS.Packages(function(){with(this){JS.Package.ENV.JSCLASS_PATH=JS.Package.ENV.JSCLASS_PATH||__FILE__().replace(/[^\/]*$/g,'');var b=JS.Package.ENV.JSCLASS_PATH;if(!/\/$/.test(b))b=b+'/';var c=function(a){return file(b+a+'.js')};c('core').provides('JS.Module','JS.Class','JS.Method','JS.Kernel','JS.Singleton','JS.Interface');var d='JS.Test.Unit';c('test').provides('JS.Test','JS.Test.Context','JS.Test.Mocking','JS.Test.FakeClock','JS.Test.AsyncSteps','JS.Test.Helpers',d,d+'.Assertions',d+'.TestCase',d+'.TestSuite',d+'.TestResult').requires('JS.Module','JS.Class','JS.Console','JS.DOM','JS.Enumerable','JS.SortedSet','JS.Comparable','JS.StackTrace').styling(b+'assets/testui.css');c('dom').provides('JS.DOM','JS.DOM.Builder').requires('JS.Class');c('console').provides('JS.Console').requires('JS.Module','JS.Enumerable');c('benchmark').provides('JS.Benchmark').requires('JS.Module').requires('JS.Console');c('comparable').provides('JS.Comparable').requires('JS.Module');c('constant_scope').provides('JS.ConstantScope').requires('JS.Module');c('forwardable').provides('JS.Forwardable').requires('JS.Module');c('enumerable').provides('JS.Enumerable').requires('JS.Module','JS.Class');c('deferrable').provides('JS.Deferrable').requires('JS.Module');c('observable').provides('JS.Observable').requires('JS.Module');c('hash').provides('JS.Hash','JS.OrderedHash').requires('JS.Class','JS.Enumerable','JS.Comparable');c('range').provides('JS.Range').requires('JS.Class','JS.Enumerable');c('set').provides('JS.Set','JS.HashSet','JS.OrderedSet','JS.SortedSet').requires('JS.Class','JS.Enumerable').uses('JS.Hash');c('linked_list').provides('JS.LinkedList','JS.LinkedList.Doubly','JS.LinkedList.Doubly.Circular').requires('JS.Class','JS.Enumerable');c('command').provides('JS.Command','JS.Command.Stack').requires('JS.Class','JS.Enumerable','JS.Observable');c('decorator').provides('JS.Decorator').requires('JS.Module','JS.Class');c('method_chain').provides('JS.MethodChain').requires('JS.Module','JS.Kernel');c('proxy').provides('JS.Proxy','JS.Proxy.Virtual').requires('JS.Module','JS.Class');c('stack_trace').provides('JS.StackTrace').requires('JS.Module','JS.Singleton','JS.Observable','JS.Enumerable','JS.Console');c('state').provides('JS.State').requires('JS.Module','JS.Class');c('tsort').provides('JS.TSort').requires('JS.Module').requires('JS.Class').requires('JS.Hash')}});
