if(typeof bespin==="undefined")bespin={};if(typeof document!=="undefined"){var link=document.getElementById("bespin_base");if(link){var href=link.href;bespin.base=href.substring(href.length-1)!=="/"?href+"/":href}else bespin.base=""}
(function(){if("undefined"===typeof y)var y=function(){function j(w,m){v.push({m:w,a:m})}var v=[],A={isBootstrap:true,queue:v,register:function(w,m){if(w.match(/^tiki/)&&this.ENV)if(this.ENV.app==="tiki"&&this.ENV.mode==="test"){if(!m.dependencies)m.dependencies={};m.dependencies.core_test="~"}j("register",arguments);return this},module:function(w,m){if(w.match(/\:tiki$/))this.tikiFactory=m;j("module",arguments);return this},start:function(){var w={};this.tikiFactory(null,w,null);w=w.Browser.start(this.ENV,
this.ARGS,v);v=null;return w}};if("undefined"!==typeof ENV)A.ENV=ENV;if("undefined"!==typeof ARGV)A.ARGS=ARGV;if("undefined"!==typeof ARGS)A.ARGS=ARGS;return A}();y.register("::tiki/1.0.0",{name:"tiki",version:"1.0.0"});y.module("::tiki/1.0.0:tiki",function(j,v){var A=/^::/,w=function(a){return!!A.exec(a)},m=function(){v.debug.apply(this,arguments)};v.debug=function(){var a=Array.prototype.join.call(arguments,"");j("sys").debug(a)};var d;d=Array.isArray?Array.isArray:function(a){if("object"!==typeof a)return false;
if(a instanceof Array)return true;return a.constructor&&a.constructor.name==="Array"};v.isArray=d;var h;if(Object.create)h=Object.create;else{var k=function(){},x=k.prototype;h=function(a){if(!a)a=Object.prototype;k.prototype=a;var b=new k;b.prototype=a;k.prototype=x;return b}}v.createObject=h;var u,B,E;u=function(){return function(){return this.init?this.init.apply(this,arguments):this}};B=function(){return E(this)};E=function(a){var b=u();b.prototype=h(a.prototype);b.prototype.constructor=b;b.super_=
a;b.extend=B;return b};v.extend=E;var f=function(a,b){if(b&&!b.displayName)b.displayName="parallel#fn";return function(c){if(a.length===0)return c(null,[]);var e=a.length,o=e,p=false,C,F=function(H){if(!p){if(H){p=true;return c(H)}--o<=0&&c()}};F.displayName="parallel#tail";for(C=0;C<e;C++)b(a[C],F)}};f.displayName="parallel";var i;i=Array.prototype.map?function(a,b){return a.map(b)}:function(a,b){var c,e=a.length,o=[];for(c=0;c<e;c++)o[c]=b(a[c],c);return o};i.displayName="map";var q=function(a,
b){var c="pending",e=[],o=false,p=null,C=function(F){b||(b=this);switch(c){case "ready":F.apply(null,p);break;case "running":e.push(F);break;case "pending":e.push(F);c="running";a.call(b,function(){p=Array.prototype.slice.call(arguments);var H=e,M=p;if(o){c="pending";e=[];p=null;o=false}else{c="ready";e=null}H&&H.forEach(function(O){O.apply(null,M)})});break}return this};C.displayName="once#handler";C.reset=function(){switch(c){case "ready":c="pending";e=[];p=null;break;case "running":o=true;break}};
C.reset.displayName="once#handler.reset";return C};v.once=q;var r=function(a,b){var c,e;for(c in a)if(a.hasOwnProperty(c)){e=a[c];if("function"===typeof e)if(!e.displayName){e.displayName=b?b+"."+c:c;r(e.prototype,e.displayName)}}return a},z=E(Error);z.prototype.init=function(a,b){a=a+" not found";if(b)a="string"===typeof b?a+" "+b:a+" in package "+(b.id||"(unknown)");this.message=a;return this};v.NotFound=z;var D=E(Error);D.prototype.init=function(a,b){if("undefined"!==typeof JSON)a=JSON.stringify(a);
this.message="Invalid package definition. "+b+" "+a};v.InvalidPackageDef=D;var L=function(){var a=function(e){return e.charCodeAt(0)<=32},b=function(e){e=e.charCodeAt(0);return e>=48&&e<=57},c=function(e,o){for(var p=0,C=0,F=0,H,M;;C++,F++){H=e.charAt(C);M=o.charAt(F);if(!b(H)&&!b(M))return p;else if(b(H))if(b(M)){if(H<M)if(p===0)p=-1;else if(H>M)if(p===0)p=+1;else if(H===0&&M===0)return p}else return+1;else return-1}};return function(e,o){for(var p=0,C=0,F=0,H=0,M,O,W;;){F=H=0;M=e.charAt(p);for(O=
o.charAt(C);a(M)||M=="0";){if(M=="0")F++;else F=0;M=e.charAt(++p)}for(;a(O)||O=="0";){if(O=="0")H++;else H=0;O=o.charAt(++C)}if(b(M)&&b(O))if((W=c(e.substring(p),o.substring(C)))!==0)return W;if(M===0&&O===0)return F-H;if(M<O)return-1;else if(M>O)return+1;++p;++C}}}();v.natcompare=L;var I=function(a){return new Error(""+a+" is an invalid version string")};I.displayName="invalidVers";var N=function(a,b,c,e){c=Number(c);e=Number(e);if(isNaN(c))throw I(a);if(isNaN(e))throw I(b);return c-e};N.displayName=
"compareNum";var l,J={parse:function(a){a=a.match(/^(=|~)?([\d]+?)(\.([\d]+?)(\.(.+))?)?$/);if(!a)return null;return[a,a[2],a[4]||"0",a[6]||"0",a[1]]},major:function(a){return Number(l(a)[1])},minor:function(a){return Number(l(a)[2])},patch:function(a){a=l(a)[3];return isNaN(Number(a))?a:Number(a)},STRICT:"strict",NORMAL:"normal",mode:function(a){return l(a)[4]==="="?J.STRICT:J.NORMAL},comparePatch:function(a,b){var c,e;if(a===b)return 0;c=Number(a);e=Number(b);return isNaN(c)?isNaN(e)?L(a,b):-1:
isNaN(e)?1:c<e?-1:c>e?1:0},compare:function(a,b){var c;if(a===b)return 0;if(a)a=l(a);if(b)b=l(b);if(!a&&!b)return 0;if(!a)return-1;if(!b)return 1;c=N(a[0],b[0],a[1],b[1]);if(c===0){c=N(a[0],b[0],a[2],b[2]);if(c===0)c=J.comparePatch(a[3],b[3])}return c<0?-1:c>0?1:0},compatible:function(a,b){if(!a)return true;if(a===b)return true;if(a&&!l(a))a=null;if(b&&!l(b))b=null;if(!a)return true;if(a===b)return true;if(J.mode(a)===J.STRICT)return b&&J.compare(a,b)===0;else{if(!b)return true;if(J.major(a)!==J.major(b))return false;
return J.compare(a,b)<=0}},normalize:function(a){var b;if(!a||a.length===0)return null;a=J.parse(a);if(!a)return null;b=Number(a[3]);if(isNaN(b))b=a[3];return[Number(a[1]),Number(a[2]),b].join(".")}};v.semver=J;l=J.parse;var U=v.extend(Object);v.Factory=U;U.prototype.init=function(a,b,c){this.id=a;this.pkg=b;this.factory=c};U.prototype.call=function(a,b){var c=this.factory,e=this.__filename,o=this.__dirname;if("string"===typeof c)c=this.factory=U.compile(c,this.pkg.id+":"+this.id);a=a.createRequire(b);
var p=b.exports;c.call(p,a,p,b,e,o);return b.exports};var R=["(function(require, exports, module) {",null,"\n});\n//@ sourceURL=",null,"\n"];U.compile=function(a,b){R[1]=a;R[3]=b||"(unknown module)";a=R.join("");a=eval(a);R[1]=R[3]=null;return a};v.Factory=U;var S=v.extend(Object);v.Module=S;S.prototype.init=function(a,b,c){this.id=a;this.ownerPackage=b;this.exports={};var e=this;this.resource=function(o){return c.resource(o,e.id,b)}};var Q=v.extend(Object);v.Package=Q;Q.prototype.init=function(a,
b){w(a)||(a="::"+a);this.id=a;this.config=b;this.isReady=true};Q.prototype.get=function(a){return this.config?this.config[a]:undefined};Q.prototype.set=function(a,b){if(!this.config)this.config={};this.config[a]=b;return this};Q.prototype.requiredVersion=function(a){var b=this.get("dependencies");return b?b[a]:null};Q.prototype.canonicalPackageId=function(a,b){if(a===this.get("name")&&J.compatible(b,this.get("version")))return this.id;return null};Q.prototype.packageFor=function(a){if(a===this.id)return this;
return null};Q.prototype.ensurePackage=function(a,b){return a===this.id?b():b(new z(a,this))};Q.prototype.catalogPackages=function(){return[this]};Q.prototype.exists=function(a){return!!(this.factories&&this.factories[a])};Q.prototype.load=function(a){return this.factories?this.factories[a]:null};var g=function(a,b){return a+":"+b},n=v.extend(Object);v.Loader=n;n.prototype.init=function(a){this.sources=a||[];this.clear()};n.prototype.clear=function(){this.factories={};this.canonicalIds={};this.packages=
{};this.packageSources={};this.canonicalPackageIds={}};n.prototype.defaultPackage=new Q("default",{name:"default"});n.prototype.anonymousPackage=new Q("(anonymous)",{name:"(anonymous)"});n.prototype.canonical=function(a,b,c){var e,o,p,C;if(b&&"string"!==typeof b){c=b;b=null}if(w(a))return a;if(!c)c=this.anonymousPackage;a=this._resolve(a,b,c);if(w(a))return a;e=c?c.id:"(null)";b=this.canonicalIds;if(!b)b=this.canonicalIds={};b[e]||(b[e]={});b=b[e];if(b[a])return b[a];e=a;o=a.indexOf(":");if(o>=0){p=
a.slice(0,o);a=a.slice(o+1);if(a[0]==="/")throw new Error("Absolute path not allowed with packageId");}o=null;if(p&&p.length>0){if(p=this._canonicalPackageId(p,null,c))o=g(p,a)}else{if(c&&c.exists(a))o=g(c.id,a);else{if(p=this._canonicalPackageId(a,null,c))C=this._packageFor(p,c);if(C)if(C.exists("index"))o=g(C.id,"index");else if(C.exists(a))o=g(C.id,a)}if(!o){if(this.defaultPackage)p=this.defaultPackage.id;else if(this.workingPackage)p=this.workingPackage.id;else if(this.anonymousPackage)p=this.anonymousPackage.id;
else return null;if(p)o=g(p,a)}}return b[e]=o};n.prototype.load=function(a,b,c){var e,o,p;if(!b)b=this.anonymousPackage;e=this.factories;if(!e)e=this.factories={};if(e[a])return e[a];o=a.indexOf(":",2);p=a.slice(0,o);o=a.slice(o+1);(b=this._packageFor(p,b))||m("Loader#load - "+p+" not found for "+o);if(!b)return null;c=b.load(o,c);return e[a]=c};n.prototype.catalogPackages=function(a){if(!a)a=this.anonymousPackage;var b=[],c,e,o={};this.defaultPackage&&b.push(this.defaultPackage);var p=function(C){var F,
H,M,O;if(C){H=C.length;for(F=0;F<H;F++){O=C[F];(M=o[O.get("name")])||(M=o[O.get("name")]={});if(!M[O.get("version")]){b.push(O);M[O.get("version")]=O}}}};a&&p(a.catalogPackages());a=this.sources;e=a.length;for(c=0;c<e;c++)p(a[c].catalogPackages());o=null;return b};n.prototype.canonicalPackageId=function(a,b,c){var e;if(a instanceof Q)return a.id;if(w(a)){e=a.indexOf(":",2);if(e>=0)a=a.slice(0,e);return a}if(b&&"string"!==typeof b){c=b;b=null}if(!c)c=this.anonymousPackage;e=a.indexOf(":");if(e>=0)a=
a.slice(0,e);return this._canonicalPackageId(a,b,c)};n.prototype.packageFor=function(a,b){if(!b)b=this.anonymousPackage;var c=a.indexOf(":",2);if(c>=0)a=a.slice(0,c);return this._packageFor(a,b)};n.prototype.ready=function(a,b){if(!b)b=this.anonymousPackage;var c=a.indexOf(":",2),e;if(c>=0){e=a.slice(c+1);a=a.slice(0,c)}if(this._packageReady(a,b,{})){a=this._packageFor(a,b);if(!a)return false;return!!a.exists(e)}else return false};n.prototype.ensurePackage=function(a,b,c,e){if(b&&"string"!==typeof b){e=
c;c=b;b=null}if(c&&"function"===typeof c){e=c;c=null}if(!c)c=this.anonymousPackage;this._ensurePackage(a,b,c,{},e)};n.prototype._ensurePackage=function(a,b,c,e,o){var p=this,C;C=this._canonicalPackageId(a,b,c);if(!C)return o(new z(a,c));if(e[C])return o();e[C]=true;a=this._sourceForCanonicalPackageId(C,c);if(!a)return o(new z(C,c));a.ensurePackage(C,function(F){var H,M,O;if(F)return o(F);H=p.packageFor(C,c);if(!H)return o(new z(C,c));F=H.get("dependencies");if(!F)return o();O=[];for(M in F)F.hasOwnProperty(M)&&
O.push({packageId:M,vers:F[M]});f(O,function(W,V){p._ensurePackage(W.packageId,W.vers,H,e,V)})(o)})};n.prototype._canonicalPackageId=function(a,b,c){if(a instanceof Q)return a.id;if(w(a))return a;if(a==="default"&&this.defaultPackage)return this.defaultPackage.id;var e=this.canonicalPackageIds,o,p,C,F,H;if(!c)c=this.anonymousPackage;if(!c)throw new Error("working package is required");b||(b=c.requiredVersion(a));o=c.id;if(!e)e=this.canonicalPackageIds={};e[o]||(e[o]={});e=e[o];e[a]||(e[a]={});e=e[a];
if(e[b])return e[b];o=this.sources;p=c.canonicalPackageId(a,b);H=c;if(!p)if(p=c.canonicalPackageId(a,null))throw new Error(c.get("name")+" contains an incompatible nested package "+a+" (expected: "+b+")");if(!p&&o){F=o.length;for(C=0;!p&&C<F;C++){H=o[C];p=H.canonicalPackageId(a,b)}}p&&this._cachePackageSource(p,c,H);return e[b]=p};n.prototype._cachePackageSource=function(a,b,c){var e=this.packageSources;b=b.id;if(!e)e=this.packageSources={};e[b]||(e[b]={});e=e[b];e[a]=c};n.prototype._sourceForCanonicalPackageId=
function(a,b){var c=this.packageSources,e=b.id,o,p;if(!c)c=this.packageSources={};c[e]||(c[e]={});c=c[e];if(c[a])return c[a];e=this.sources;if(b)if(o=b.packageFor(a))p=b;if(!p&&e){b=e.length;for(o=0;!p&&o<b;o++){p=e[o];p.packageFor(a)||(p=null)}}return c[a]=p};n.prototype._packageFor=function(a,b){var c,e;if(this.defaultPackage&&a===this.defaultPackage.id)return this.defaultPackage;c=this.packages;if(!c)c=this.packages={};if(c[a])return c[a];if(b=this._sourceForCanonicalPackageId(a,b))e=b.packageFor(a);
return c[a]=e};n.prototype._packageReady=function(a,b,c){var e;if(c[a])return true;c[a]=true;b=this._packageFor(a,b);if(!b)return false;a=b.get("dependencies");for(e in a)if(a.hasOwnProperty(e)){a=a[e];a=this._canonicalPackageId(e,a,b);if(!a)return false;return this._packageReady(a,b,c)}return true};n.prototype._resolve=function(a,b,c){var e,o,p,C;if(a[0]==="/"&&a.indexOf(":")<0)return this.anonymousPackage.id+":"+a;if(a.match(/(^\.\.?\/)|(\/\.\.?\/)|(\/\.\.?\/?$)/)){if((e=a.indexOf(":"))>=0){C=a.slice(0,
e);a=a.slice(e+1);b=[]}else if(a.match(/^\.\.?\//)){if(!b)throw new Error("id required to resolve relative id: "+a);if(b.indexOf(":")>=0)throw new Error("current moduleId cannot contain packageId");if(c)C=c.id;b=b.split("/");b.pop()}else b=[];p=a.split("/");c=p.length;for(e=0;e<c;e++){o=p[e];if(o===".."){if(b.length<1)throw new Error("invalid path: "+a);b.pop()}else o!=="."&&b.push(o)}a=b.join("/");if(C)a=g(C,a)}return a};var t=v.extend(Object);v.Sandbox=t;t.prototype.init=function(a,b,c,e){this.loader=
a;this.env=b;this.args=c;e&&this.main(e);this.clear()};t.prototype.catalogPackages=function(a){return this.loader.catalogPackages(a)};t.prototype.createRequire=function(a){var b=this,c=a.id,e=a.ownerPackage,o=function(p,C){if(C&&p.indexOf(":")<0){if(C.isPackage)C=C.id;p=C+":"+p}return b.require(p,c,e)};a=o.displayName=(c||"(unknown)")+"#require";o.nativeRequire=b.nativeRequire;o.ensure=function(p,C){if(!d(p)){p=Array.prototype.slice.call(arguments);C=p.pop()}f(p,function(F,H){b.ensure(F,c,e,H)})(function(F){if(F)return C(F);
if(C.length<=1)return C();C(null,i(p,function(H){return b.require(H,c,e)}))})};o.ensure.displayName=a+".ensure";o.ready=function(p){var C,F;d(p)||(p=Array.prototype.slice.call(arguments));F=p.length;for(C=0;C<F;C++)if(!b.ready(p[C],c,e))return false;return true};o.ready.displayName=a+".ready";o.packageFor=function(p,C){return b.packageFor(p,C,e)};o.packageFor.displayName=a+".packageFor";o.ensurePackage=function(p,C,F){b.ensurePackage(p,C,e,function(H){if(H)return F(H);if(F.length<=1)return F();F(null,
b.packageFor(p,C,e))})};o.ensurePackage.displayName=a+".ensurePackage.displayName";o.catalogPackages=function(){return b.catalogPackages(e)};o.main=b.main();o.env=b.env;o.args=b.args;o.sandbox=b;o.loader=b.loader;o.isTiki=true;return o};t.prototype.Module=S;t.prototype.module=function(a,b,c){var e,o,p;b=this.loader.canonical(a,b,c);if(!b)throw new z(a,c);e=this.modules;if(!e)e=this.modules={};if(a=e[b])return a;o=b.indexOf(":",2);a=b.slice(o+1);o=b.slice(0,o);p=this.loader.packageFor(o,c);if(!p)throw new z(o,
c);return a=e[b]=new this.Module(a,p,this)};t.prototype.main=function(a,b){if(a!==undefined){this._mainModule=null;this._mainModuleId=a;this._mainModuleWorkingPackage=b;return this}else{if(!this._mainModule&&this._mainModuleId){b=this._mainModuleWorkingPackage;this._mainModule=this.module(this._mainModuleId,b)}return this._mainModule}};t.prototype.require=function(a,b,c){var e,o;b=this.loader.canonical(a,b,c);if(!b)throw new z(a,c);o=this.exports;a=this.usedExports;if(!o)o=this.exports={};if(!a)a=
this.usedExports={};if(e=o[b]){e=e.exports;a[b]||(a[b]=e);return e}e=this.loader.load(b,c,this);if(!e)throw new z(b,c);c=this.module(b,c);o[b]=c;o=e.call(this,c);c.exports=o;if(a[b]&&a[b]!==o)throw new Error("cyclical requires() in "+b);return o};t.prototype.ready=function(a,b,c){return(a=this.loader.canonical(a,b,c))?this.loader.ready(a):false};t.prototype.ensure=function(a,b,c,e){var o,p,C;if(b&&"string"!==typeof b){e=c;c=b;b=null}if(c&&"function"===typeof c){e=c;c=null}b=this.loader.canonical(a,
b,c);if(!b)return e(new z(a,c));C=b.indexOf(":",2);a=b.slice(C+1);p=b.slice(0,C);o=this.loader;o.ensurePackage(p,c,function(F){if(F)return e(F);F=o.packageFor(p,c);F.exists(a)?e():e(new z(a,F))})};t.prototype.packageFor=function(a,b,c){a=this.loader.canonicalPackageId(a,b,c);if(!a)return null;return this.loader.packageFor(a)};t.prototype.ensurePackage=function(a,b,c,e){if(b&&"string"!==typeof b){e=c;c=b;b=null}if(c&&"function"===typeof c){e=c;c=null}b=this.loader.canonicalPackageId(a,b,c);if(!b)return e(new z(a,
c));this.loader.ensurePackage(b,e)};t.prototype.resource=function(a,b,c){if(!c.resource)return null;return c.resource(a,b)};t.prototype.clear=function(){this.exports={};this.modules={};this.usedExports={};return this};var s=v.extend(Object);v.Browser=s;s.prototype.init=function(){this._ready={};this._unload={};this.clear()};s.prototype.clear=function(){this.packageInfoByName={};this.packageInfoById={};this.packages={};this.factories={};this.stylesheetActions={};this.scriptActions={};this.ensureActions=
{}};s.start=function(a,b,c){var e;e=new s;e.loader=new n([e]);e.sandbox=new t(e.loader,a,b);e.queue=c;e.require=e.sandbox.createRequire({id:"index",ownerPackage:e.loader.anonymousPackage});return e};s.prototype.replay=function(){var a=this.queue,b=a?a.length:0,c,e;this.queue=null;for(c=0;c<b;c++){e=a[c];this[e.m].apply(this,e.a)}return this};s.prototype.start=function(){return this};s.prototype.global=function(a){if(!P&&!X)return this;var b=function(){return this}(),c,e,o,p,C,F,H,M;c=this.globals;
if(!c)c=this.globals={};e=this.packageFor(a);if(!e)throw new Error(a+" package not found");o=e.get("dependencies");if(!o)return this;for(p in o)if(o.hasOwnProperty(p)){a=this.loader.canonical(p,e);if(!c[a]){c[a]=true;if(this.sandbox.ready(p,e)){a=this.sandbox.require(p,e);if(C=a.__globals__){M=C.length;for(H=0;H<M;H++){F=C[H];b[F]=a[F]}}else for(F in a)if(a.hasOwnProperty(F))b[F]=a[F]}}}return this};var G=function(a){var b,c;if(a.length===1){b=null;c=a[0];a=Array.prototype.slice.call(a,1)}else{b=
a[0];c=a[1];a=Array.prototype.slice.call(a,2)}return{target:b,method:c,args:a}},K=function(a,b,c){a[b]||(a[b]=[]);a[b].push(G(c))};s.prototype.addReadyListener=function(){if(this._ready&&this._ready.isReady)this._invoke(G(arguments));else{this._setupReadyListener();K(this._ready,"queue",arguments)}};s.prototype.addMainListener=function(){if(this._ready&&this._ready.isReady)this._invoke(G(arguments));else{this._setupReadyListener();K(this._ready,"mqueue",arguments)}};s.prototype.addUnloadListener=
function(){if(this._unload&&this._unload.isUnloading)this._invoke(G(arguments));else{this._setupUnloadListener();K(this._unload,"queue",arguments)}};s.prototype._invoke=function(a){var b=a.target,c=a.method;if("string"===typeof b)b=this.require(b);if("string"===typeof c)c=b[c];c&&c.apply(b,a.args);a.target=a.method=a.args=null};s.prototype._setupReadyListener=function(){if(this._ready.setup)return this;this._ready.setup=true;var a=this._ready,b=this,c;c=function(){if(!a.isReady){a.isReady=true;a.cleanup&&
a.cleanup();a.cleanup=null;var e,o,p;o=(e=a.queue)?e.length:0;a.queue=null;for(p=0;p<o;p++)b._invoke(e[p]);o=(e=a.mqueue)?e.length:0;a.mqueue=null;for(p=0;p<o;p++)b._invoke(e[p]);b._runMain()}};if("undefined"!==typeof document)if(document.addEventListener){a.cleanup=function(){document.removeEventListener("DOMContentLoaded",c,false);document.removeEventListener("load",c,false)};document.addEventListener("DOMContentLoaded",c,false);document.addEventListener("load",c,false)}else if(document.attachEvent){a.cleanup=
function(){document.detachEvent("onreadystatechange",c);document.detachEvent("onload",c);a.ieHandler=null};document.attachEvent("onreadystatechange",c);document.attachEvent("onload",c);if(document.documentElement.doScroll&&window==window.top){a.ieHandler=function(){if(a.ieHandler&&!a.isReady)try{document.documentElement.doScroll("left")}catch(e){setTimeout(a.ieHandler,0);return}c()};a.ieHandler()}}};s._scheduleUnloadListener=function(){if(this._unload.setup)return this;this._unload.setup=true;var a=
this._unload,b=this,c;a.isUnloading=false;c=function(){if(!a.isUnloading){a.isUnloading=true;a.cleanup&&a.cleanup();a.cleanup=null;var e=a.queue,o=e?e.length:0,p;a.queue=null;for(p=0;p<o;p++)b._invoke(e[p])}};if("undefined"!==typeof document)if(document.addEventListener){a.cleanup=function(){document.removeEventListener("unload",c)};document.addEventListener("unload",c,false)}else if(document.attachEvent){a.cleanup=function(){document.detachEvent("onunload",c)};document.attachEvent("unload",c)}};
s.prototype.main=function(a,b){this.sandbox&&this.sandbox.main(a);this._setupReadyListener();this._main={id:a,method:b}};s.prototype._runMain=function(){if(this._main){var a=this._main.id,b=this._main.method,c=this.require;if(a&&c){this._main=null;c.ensure(a,function(e){if(e)throw e;e=c(a);if("string"===typeof b)b=e[b];b&&b.call(e)})}}};s.prototype._action=function(a){var b;return b=q(function(c){b.resolve=function(e,o){b.resolve=null;c(e,o)};a()})};s.prototype._resolve=function(a,b,c){if(a[b])a[b].resolve&&
a[b].resolve(null,c);else a[b]=function(e){e(null,c)};return this};s.prototype._fail=function(a,b,c){a[b].resolve&&a[b].resolve(c)};s.prototype._normalize=function(a,b){w(b)||(b="::"+b);a.id=b;a.version=J.normalize(a.version);a["tiki:external"]=!!a["tiki:external"];a["tiki:private"]=!!a["tiki:private"];var c=a["tiki:base"];if(a["tiki:resources"])a["tiki:resources"]=i(a["tiki:resources"],function(p){if("string"===typeof p)p={id:b+":"+p,name:p};if(!p.name)throw new D(a,"resources must have a name");
if(!p.id)p.id=b+":"+p.name;if(!w(p.id))p.id="::"+p.id;if(!p.type)p.type=p.name.match(/\.js$/)?"script":p.name.match(/\.css$/)?"stylesheet":"resource";if(!p.url)p.url=c?c+"/"+p.name:p.id+p.name;return p});if(!a.dependencies)a.dependencies={};var e=a["tiki:nested"],o;if(e)for(o in e){if(e.hasOwnProperty(o))w(e[o])||(e[o]="::"+e[o])}else a["tiki:nested"]={};return a};s.prototype.register=function(a,b){var c,e,o,p=-1;b=this._normalize(b,a);a=b.id;c=this.packageInfoById;if(!c)c=this.packageInfoById={};
if(c[a]){if(!c[a]["tiki:external"])return this;e=c[a]}c[a]=b;if(b.name){a=b.name;o=b.version;c=this.packageInfoByName;if(!c)c=this.packageInfoByName={};c[a]||(c[a]={});c=c[a];if(!c[o]||c[o].length<=1)c[o]=[b];else{if(e)p=c[o].indexOf(e);if(p>=0)c[o]=c[o].slice(0,p).concat(c[o].slice(p+1));c[o].push(b)}}return this};s.prototype.module=function(a,b){w(a)||(a="::"+a);this.factories[a]=b;return this};s.prototype.script=function(a){w(a)||(a="::"+a);this._resolve(this.scriptActions,a,true)};s.prototype.stylesheet=
function(a){w(a)||(a="::"+a);this._resolve(this.stylesheetActions,a,true)};var P="undefined"!==typeof document&&document.createElement,X="undefined"!==typeof XMLHttpRequest;s.prototype.xhr=!P;s.prototype.autowrap=false;var Z=function(a){if(!a)return null;for(var b=a.length;--b>=0;)if(!a[b]["tiki:private"])return a[b];return null};s.prototype.canonicalPackageId=function(a,b){a=this.packageInfoByName[a];var c,e,o;if(b)b=J.normalize(b);if(!a)return null;if(a[b]&&a[b].length===1)return a[b][0].id;for(e in a)if(a.hasOwnProperty(e))if(J.compatible(b,
e))if(!c||J.compare(o,e)<0)if(c=Z(a[e]))o=e;return c?c.id:null};s.prototype.packageFor=function(a){var b=this.packages[a];if(b)return b;if((b=this.packageInfoById[a])&&!b["tiki:external"]){b=new this.Package(a,b,this);return this.packages[a]=b}return null};s.prototype.ensurePackage=function(a,b){var c=this.ensureActions[a];if(c)return c(b);var e=this.packageInfoById[a];if(!e)return b(new z(a,"browser package info"));var o=this;c=q(function(p){var C=1,F=false,H,M=function(Y){if(!H){if(Y){H=true;return p(Y)}C-=
1;if(C<=0&&F)return p(null,e)}},O=e.dependencies,W=e["tiki:nested"],V,T;for(V in O)if(O.hasOwnProperty(V)){T=W[V];if(!T){T=O[V];T=o.canonicalPackageId(V,T)}if(T&&o.packageInfoById[a]){C++;o.ensurePackage(T,M)}}W=(O=e["tiki:resources"])?O.length:0;for(V=0;V<W;V++){T=O[V];if(T.type!=="resource")if(T.type==="script"){C++;o.ensureScript(T.id,T.url,M)}else if(T.type==="stylesheet"){C++;o.ensureStylesheet(T.id,T.url,M)}}F=true;M()});this.ensureActions[a]=c;c(b)};s.prototype.ensureScript=function(a,b,c){var e=
this.scriptActions[a];if(e)return e(c);var o=this;e=this._action(function(){o._loadScript(a,b)});this.scriptActions[a]=e;return e(c)};s.prototype.ensureStylesheet=function(a,b,c){var e=this.stylesheetActions[a];if(e)return e(c);var o=this;e=this._action(function(){o._loadStylesheet(a,b)});this.stylesheetActions[a]=e;return e(c)};s.prototype._injectScript=function(a,b){var c;a=document.body;c=document.createElement("script");c.src=b;a.appendChild(c)};s.prototype._xhrScript=function(a,b){var c=this.autowrap,
e=new XMLHttpRequest;e.open("GET",b,true);e.onreadystatechange=function(){if(!(e.readyState!==4||e.status!==200&&e.status!==0)){var o=e.responseText;if(c)o="tiki.module('"+a+"', function(require, exports, module) {"+o+"});tiki.script('"+a+"');";eval(o+"\n//@ sourceURL="+b)}};e.send(null)};s.prototype._loadScript=function(a,b){if(this.autowrap){this.xhr=true;X||m("Autowrap is on but XHR is not available. Danger ahead.")}if(X&&P)if(this.xhr)try{return this._xhrScript(a,b)}catch(c){return this._injectScript(a,
b)}else try{return this._injectScript(a,b)}catch(e){return this._xhrScript(a,b)}else if(X)return this._xhrScript(a,b);else if(P)return this._injectScript(a,b);m("Browser#_loadScript() not supported on this platform.");this.script(a)};s.prototype._loadStylesheet=P?function(a,b){var c,e;c=document.getElementsByTagName("head")[0]||document.body;e=document.createElement("link");e.rel="stylesheet";e.href=b;e.type="text/css";c.appendChild(e);this.stylesheet(a)}:function(a){m("Browser#_loadStylesheet() not supported on this platform.");
this.stylesheet(a)};S=Q.extend();s.prototype.Package=S;S.prototype.init=function(a,b,c){Q.prototype.init.call(this,a,b);this.source=c};S.prototype.canonicalPackageId=function(a,b){var c;if(c=Q.prototype.canonicalPackageId.call(this,a,b))return c;c=(this.get("tiki:nested")||{})[a];if(!c)return null;return(a=this.source.packageInfoById[c])&&J.compatible(b,a.version)?c:null};S.prototype.packageFor=function(a){var b=Q.prototype.packageFor.call(this,a);return b?b:this.source.packageFor(a)};S.prototype.ensurePackage=
function(a,b){if(a===this.id)return b();this.source.ensurePackage(a,b)};S.prototype.catalogPackages=function(){var a=[this],b,c;b=this.get("tiki:nested")||{};for(c in b)b.hasOwnProperty(c)&&a.push(this.source.packageFor(b[c]));return a};S.prototype.exists=function(a){return!!this.source.factories[this.id+":"+a]};S.prototype.load=function(a){var b;return(b=this.source.factories[this.id+":"+a])?new this.Factory(a,this,b):null};S.prototype.Factory=U;r(v,"tiki")});y=y.start();y.replay();bespin.tiki=y})();
bespin.tiki.register("::types",{name:"types",dependencies:{}});
bespin.tiki.module("types:basic",function(y,j){var v=y("bespin:plugins").catalog,A=y("bespin:console").console,w=y("bespin:promise").Promise;j.text={isValid:function(m){return typeof m=="string"},toString:function(m){return m},fromString:function(m){return m}};j.number={isValid:function(m){if(isNaN(m))return false;if(m===null)return false;if(m===undefined)return false;if(m===Infinity)return false;return typeof m=="number"},toString:function(m){if(!m)return null;return""+m},fromString:function(m){if(!m)return null;
var d=parseInt(m,10);if(isNaN(d))throw new Error("Can't convert \""+m+'" to a number.');return d}};j.bool={isValid:function(m){return typeof m=="boolean"},toString:function(m){return""+m},fromString:function(m){if(m===null)return null;if(!m.toLowerCase)return!!m;var d=m.toLowerCase();if(d=="true")return true;else if(d=="false")return false;return!!m}};j.object={isValid:function(m){return typeof m=="object"},toString:function(m){return JSON.stringify(m)},fromString:function(m){return JSON.parse(m)}};
j.selection={isValid:function(m,d){if(typeof m!="string")return false;if(!d.data){A.error("Missing data on selection type extension. Skipping");return true}var h=false;d.data.forEach(function(k){if(m==k)h=true});return h},toString:function(m){return m},fromString:function(m){return m},resolveTypeSpec:function(m,d){var h=new w;if(d.data){m.data=d.data;h.resolve()}else if(d.pointer)v.loadObjectForPropertyPath(d.pointer).then(function(k){k=k(d);if(typeof k.then==="function")k.then(function(x){m.data=
x;h.resolve()});else{m.data=k;h.resolve()}},function(k){h.reject(k)});else{A.warn("Missing data/pointer for selection",d);h.resolve()}return h}}});
bespin.tiki.module("types:types",function(y,j){function v(d){var h=new m,k=w.getExtensionByKey("type",d.name);k?h.resolve({ext:k,typeSpec:d}):h.reject(new Error("Unknown type: "+d.name));return h}function A(d){if(typeof d==="string")return v({name:d});if(typeof d==="object")if(d.name==="deferred"){var h=new m;j.undeferTypeSpec(d).then(function(k){A(k).then(function(x){h.resolve(x)},function(x){h.reject(x)})});return h}else return v(d);throw new Error("Unknown typeSpec type: "+typeof d);}var w=y("bespin:plugins").catalog;
y("bespin:console");var m=y("bespin:promise").Promise;j.getSimpleName=function(d){if(!d)throw new Error("null|undefined is not a valid typeSpec");if(typeof d=="string")return d;if(typeof d=="object"){if(!d.name)throw new Error("Missing name member to typeSpec");return d.name}throw new Error("Not a typeSpec: "+d);};j.equals=function(d,h){return j.getSimpleName(d)==j.getSimpleName(h)};j.undeferTypeSpec=function(d){var h=new m;if(!d.pointer){h.reject(new Error("Missing deferred pointer"));return h}w.loadObjectForPropertyPath(d.pointer).then(function(k){k=
k(d);typeof k.then==="function"?k.then(function(x){h.resolve(x)},function(x){h.reject(x)}):h.resolve(k)},function(k){h.reject(k)});return h};j.resolveType=function(d){var h=new m;A(d).then(function(k){k.ext.load(function(x){typeof x.resolveTypeSpec==="function"?x.resolveTypeSpec(k.ext,k.typeSpec).then(function(){h.resolve({type:x,ext:k.ext})},function(u){h.reject(u)}):h.resolve({type:x,ext:k.ext})})},function(k){h.reject(k)});return h};j.fromString=function(d,h){var k=new m;j.resolveType(h).then(function(x){k.resolve(x.type.fromString(d,
x.ext))});return k};j.toString=function(d,h){var k=new m;j.resolveType(h).then(function(x){k.resolve(x.type.toString(d,x.ext))});return k};j.isValid=function(d,h){var k=new m;j.resolveType(h).then(function(x){k.resolve(x.type.isValid(d,x.ext))});return k}});bespin.tiki.module("types:index",function(){});bespin.tiki.register("::bespin",{name:"bespin",dependencies:{}});bespin.bootLoaded=true;
bespin.tiki.module("bespin:builtins",function(y,j){j.metadata={bespin:{provides:[{ep:"extensionpoint",name:"extensionpoint",indexOx:"name",register:"plugins#registerExtensionPoint",unregister:"plugins#unregisterExtensionPoint",description:"Defines a new extension point",params:[{name:"name",type:"string",description:"the extension point's name",required:true},{name:"description",type:"string",description:"description of what the extension point is for"},{name:"params",type:"array of objects",description:"parameters that provide the metadata for a given extension. Each object should have name and description, minimally. It can also have a 'type' (eg string, pointer, or array) and required to denote whether or not this parameter must be present on the extension."},
{name:"indexOn",type:"string",description:"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."},{name:"register",type:"pointer",description:"function that is called when a new extension is discovered. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."},{name:"unregister",type:"pointer",description:"function that is called when an extension is removed. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."}]},
{ep:"extensionpoint",name:"extensionhandler",register:"plugins#registerExtensionHandler",unregister:"plugins#unregisterExtensionHandler",description:"Used to attach listeners ",params:[{name:"name",type:"string",description:"name of the extension point to listen to",required:true},{name:"register",type:"pointer",description:"function that is called when a new extension is discovered. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."},
{name:"unregister",type:"pointer",description:"function that is called when an extension is removed. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."}]},{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), '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."}]}}});
bespin.tiki.module("bespin:console",function(y,j){y=y("util/util");var v=function(){},A=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","log","profile","profileEnd","time","timeEnd","trace","warn"];if(typeof window==="undefined"){var w={};A.forEach(function(m){w[m]=function(){var d=Array.prototype.slice.call(arguments);postMessage(JSON.stringify({op:"log",method:m,args:d}))}});j.console=w}else if(y.isSafari||y.isChrome)j.console=window.console;else{j.console={};A.forEach(function(m){j.console[m]=
window.console&&window.console[m]?window.console[m].bind(window.console):v})}});
bespin.tiki.module("bespin:globals",function(){if(!Object.defineProperty)Object.defineProperty=function(y,j,v){var A=Object.prototype.hasOwnProperty;if(typeof v=="object"&&y.__defineGetter__){if(A.call(v,"value")){if(!y.__lookupGetter__(j)&&!y.__lookupSetter__(j))y[j]=v.value;if(A.call(v,"get")||A.call(v,"set"))throw new TypeError("Object doesn't support this action");}else typeof v.get=="function"&&y.__defineGetter__(j,v.get);typeof v.set=="function"&&y.__defineSetter__(j,v.set)}return y};if(!Object.defineProperties)Object.defineProperties=
function(y,j){for(var v in j)Object.prototype.hasOwnProperty.call(j,v)&&Object.defineProperty(y,v,j[v]);return y};(function(){if(!Array.isArray)Array.isArray=function(y){return y&&Object.prototype.toString.call(y)=="[object Array]"};if(!Object.keys)Object.keys=function(y){var j,v=[];for(j in y)y.hasOwnProperty(j)&&v.push(j);return v};if(!Function.prototype.bind)Function.prototype.bind=function(){var y=Array.prototype.slice.call(arguments),j=this,v=function(){return j.call.apply(j,y.concat(Array.prototype.slice.call(arguments)))};
v.name=this.name;v.displayName=this.displayName;v.length=this.length;v.unbound=j;return v}})()});bespin.tiki.module("bespin:index",function(y,j){j.versionNumber="0.9a2";j.versionCodename="Edison";j.apiVersion="4"});
bespin.tiki.module("bespin:plugins",function(y,j){y("globals");var v=y("promise").Promise,A=y("promise").group,w=y("builtins"),m=y("console").console,d=y("util/util");y("util/stacktrace");var h=y("proxy"),k=y.loader.sources[0],x=function(f,i){if(i){i=i.split("#");return{modName:i[0]?f+":"+i[0]:f,objName:i[1]}}},u=function(f){var i=y(f.modName);if(f.objName)return i[f.objName];return i};j.Extension=function(f){this.pluginName=null;for(property in f)if(f.hasOwnProperty(property))this[property]=f[property];
this._observers=[]};j.Extension.prototype={load:function(f,i,q){q=q||j.catalog;var r=new v,z=function(I){f&&f(I);r.resolve(I)};i=this[i||"pointer"];if(d.isFunction(i)){z(i);return r}var D=x(this.pluginName,i);if(!D){m.error("Extension cannot be loaded because it has no 'pointer'");m.log(this);r.reject(new Error("Extension has no 'pointer' to call"));return r}var L=this.pluginName;q.loadPlugin(L).then(function(){y.ensure(D.modName,function(){var I=u(D);z(I)})},function(I){m.error("Failed to load plugin ",
L,I)});return r},observe:function(f,i,q){this._observers.push({plugin:f,callback:i,property:q});this.load(i,q)},getPluginName:function(){return this.pluginName},_getLoaded:function(f){f=this._getPointer(f);return u(f)}};j.ExtensionPoint=function(f,i){this.name=f;this.catalog=i;this.indexOn=this.pluginName=undefined;this.extensions=[];this.handlers=[]};j.ExtensionPoint.prototype={getImplementingPlugins:function(){var f={};this.extensions.forEach(function(q){f[q.pluginName]=true});var i=Object.keys(f);
i.sort();return i},getDefiningPluginName:function(){return this.pluginName},getByKey:function(f){var i=this.indexOn;if(i)for(var q=0;q<this.extensions.length;q++)if(this.extensions[q][i]==f)return this.extensions[q]},register:function(f){var i=this.catalog;this.extensions.push(f);this.handlers.forEach(function(q){q.register&&q.load(function(r){r?r(f,i):m.error("missing register function for pluginName=",f.pluginName,", extension=",f.name)},"register",i)})},unregister:function(f){var i=this.catalog;
this.extensions.splice(this.extensions.indexOf(f),1);this.handlers.forEach(function(q){q.unregister&&q.load(function(r){r?r(f,i):m.error("missing unregister function for pluginName=",f.pluginName,", extension=",f.name)},"unregister",i)})},orderExtensions:function(f){for(var i=[],q=0;q<f.length;q++)for(var r=0;r!=this.extensions.length;)if(this.extensions[r].pluginName===f[q]){i.push(this.extensions[r]);this.extensions.splice(r,1)}else r++;this.extensions=i.concat(this.extensions)}};j.Plugin=function(f){this.name=
this.catalog=null;this.provides=[];this.stylesheets=[];this.reloadPointer=this.reloadURL=null;for(property in f)if(f.hasOwnProperty(property))this[property]=f[property]};j.Plugin.prototype={register:function(){this.provides.forEach(function(f){this.catalog.getExtensionPoint(f.ep,true).register(f)},this)},unregister:function(){this.provides.forEach(function(f){this.catalog.getExtensionPoint(f.ep,true).unregister(f)},this)},_getObservers:function(){var f={};this.provides.forEach(function(i){m.log("ep: ",
i.ep);m.log(i._observers);f[i.ep]=i._observers});return f},_findDependents:function(f,i,q){var r=this.name,z=this;f.forEach(function(D){if(D!=r){var L=z.catalog.plugins[D];if(L&&L.dependencies)for(dependName in L.dependencies)if(dependName==r&&!i[D]){i[D]={keepModule:false};q||L._findDependents(f,i)}}})},_cleanup:function(f){this.stylesheets.forEach(function(L){for(var I=document.getElementsByTagName("link"),N=0;N<I.length;N++)if(I[N].href.indexOf(L.url)!=-1){I[N].parentNode.removeChild(I[N]);break}});
var i=this.name,q=new RegExp("^"+i+"$"),r=new RegExp("^::"+i+":");i=new RegExp("^::"+i+"$");var z=y.sandbox,D=y.loader;if(!f){E(r,D.factories);E(i,D.canonicalIds);E(i,D.canonicalPackageIds);E(i,D.packageSources);E(i,D.packages);E(q,k.packageInfoByName);E(r,k.factories);E(r,k.scriptActions);E(r,k.stylesheetActions);E(i,k.packages);E(i,k.ensureActions);E(i,k.packageInfoById)}E(r,z.exports);E(r,z.modules);E(r,z.usedExports)},reload:function(f){if(this.reloadURL){if(this.reloadPointer){var i=x(this.name,
this.reloadPointer);if(func=u(i))func();else{m.error("Reload function could not be loaded. Aborting reload.");return}}var q={};this._findDependents(Object.keys(this.catalog.plugins),q);var r={pluginName:this.name,dependents:q};for(var z in q){i=this.catalog.plugins[z];if(i.preRefresh){i=x(z,i.preRefresh);if(func=u(i))q[z]=func(r)}}this.unregister();for(z in q)this.catalog.plugins[z].unregister();this._cleanup(this.name);i=[];var D=y.sandbox,L=Object.keys(D.modules),I=L.length,N=[];for(z in q)q[z].keepModule||
N.push(new RegExp("^::"+z+":"));for(var l=new RegExp("^::"+this.name+":");--I>=0;){var J=L[I];if(l.exec(J))i.push(J);else for(var U=N.length;--U>=0;)if(N[U].exec(J)){i.push(J);break}}i.forEach(function(R){delete D.exports[R];delete D.modules[R];delete D.usedExports[R]});i=function(){this.catalog.loadPlugin(this.name).then(function(){for(z in q)this.catalog.plugins[z].register();for(z in q)if(q[z].callPointer){var R=x(z,q[z].callPointer);(R=u(R))&&R(r)}f&&f()}.bind(this))}.bind(this);L=function(){m.error("Failed to load metadata from "+
this.reloadURL)}.bind(this);this.catalog.loadMetadataFromURL(this.reloadURL).then(i,L)}}};var B=function(f,i,q){i=i.split(".");f=f;var r=i.length-1;if(r>0)for(var z=0;z<r;z++)f=f[i[z]];f[r]=q};j.Catalog=function(){this.points={};this.plugins={};this.metadata={};this.USER_DEACTIVATED="USER";this.DEPENDS_DEACTIVATED="DEPENDS";this.deactivatedPlugins={};this._extensionsOrdering=[];this.instances={};this.instancesLoadPromises={};this._objectDescriptors={};this.children=[];this.getExtensionPoint("extensionpoint",
true).indexOn="name";this.registerMetadata(w.metadata)};j.Catalog.prototype={shareExtension:function(f){return this.plugins[f.pluginName].share},isPluginLoaded:function(f){return Object.keys(y.sandbox.usedExports).some(function(i){return i.indexOf("::"+f+":")==0})},registerObject:function(f,i){this._objectDescriptors[f]=i},_setObject:function(f,i){this.instances[f]=i},createObject:function(f){if(this.instancesLoadPromises[f]!==undefined)return this.instancesLoadPromises[f];var i=this._objectDescriptors[f];
if(i===undefined)throw new Error('Tried to create object "'+f+'" but that object is not registered.');var q=i.factory||f,r=this.getExtensionByKey("factory",q);if(r===undefined)throw new Error('When creating object "'+f+'", there is no factory called "'+q+'" available."');if(this.parent&&this.shareExtension(r))return this.instancesLoadPromises[f]=this.parent.createObject(f);var z=this.instancesLoadPromises[f]=new v,D=i.arguments||[];q=[];if(i.objects){i=i.objects;for(var L in i){var I=this.createObject(i[L]);
q.push(I);I.location=L;I.then(function(N){B(D,I.location,N)})}}A(q).then(function(){r.load().then(function(N){var l=r.action;if(l==="call")N=N.apply(N,D);else if(l==="new"){if(D.length>1){z.reject(new Error("For object "+f+", create a simple factory function and change the action to call because JS cannot handle this case."));return}N=new N(D[0])}else if(l==="value")N=N;else{z.reject(new Error("Create action must be call|new|value. Found"+l));return}this.instances[f]=N;z.resolve(N)}.bind(this))}.bind(this));
return z},getObject:function(f){return this.instances[f]||(this.parent?this.parent.getObject(f):undefined)},getExtensionPoint:function(f,i){if(i&&this.points[f]===undefined)this.points[f]=new j.ExtensionPoint(f,this);return this.points[f]},getExtensions:function(f){f=this.getExtensionPoint(f);if(f===undefined)return[];return f.extensions},orderExtensions:function(f){f=f||this._extensionsOrdering;for(name in this.points)this.points[name].orderExtensions(f);this._extensionsOrdering=f},getExtensionsOrdering:function(){return this._extensionsOrdering},
getExtensionByKey:function(f,i){f=this.getExtensionPoint(f);if(f!==undefined)return f.getByKey(i)},_toposort:function(f){var i=[],q={},r=function(D){if(!(D in q||!(D in f))){q[D]=true;var L=f[D].dependencies;if(!d.none(L))for(var I in L)r(I);i.push(D)}};for(var z in f)r(z);return i},registerMetadata:function(f){if(this.parent)this.parent.registerMetadata(f);else{for(var i in f){var q=f[i];if(q.errors){m.error("Plugin ",i," has errors:");q.errors.forEach(function(r){m.error(r)});delete f[i]}else{if(q.dependencies)q.depends=
Object.keys(q.dependencies);q.name=i;q.version=null;k.canonicalPackageId(i)===null&&k.register("::"+i,q)}}d.mixin(this.metadata,d.clone(f,true));this.children.forEach(function(r){r._registerMetadata(d.clone(f,true))});this._registerMetadata(d.clone(f,true))}},_registerMetadata:function(f){var i,q=this.plugins;this._toposort(f).forEach(function(r){if(this.plugins[r])if(this.isPluginLoaded(r))return;else{var z=this.plugins[r];z.unregister()}var D=f[r],L=!this.deactivatedPlugins[r];if(L&&D.depends&&
D.depends.length!=0)if(!D.depends.some(function(l){return!this.deactivatedPlugins[l]},this)){this.deactivatedPlugins[r]="DEPENDS";L=false}D.catalog=this;D.name=r;z=new j.Plugin(D);q[r]=z;if(D.provides){z=D.provides;for(D=0;D<z.length;D++){var I=new j.Extension(z[D]);I.pluginName=r;z[D]=I;var N=I.ep;if(N=="extensionpoint"&&I.name=="extensionpoint")j.registerExtensionPoint(I,this,false);else if(L)this.getExtensionPoint(I.ep,true).register(I);else N=="extensionpoint"&&j.registerExtensionPoint(I,this,
true)}}else D.provides=[]},this);for(i in f)this._checkLoops(i,q,[]);this.orderExtensions()},loadPlugin:function(f){var i=new v,q=this.plugins[f];if(q.objects){var r=[];q.objects.forEach(function(z){r.push(this.createObject(z))}.bind(this));A(r).then(function(){y.ensurePackage(f,function(){i.resolve()})})}else y.ensurePackage(f,function(z){z?i.reject(z):i.resolve()});return i},loadMetadataFromURL:function(f){var i=new v;h.xhr("GET",f,true).then(function(q){this.registerMetadata(JSON.parse(q));i.resolve()}.bind(this),
function(q){i.reject(q)});return i},deactivatePlugin:function(f,i){var q=this.plugins[f];if(!q){i||(this.deactivatedPlugins[f]="USER");return'There is no plugin named "'+f+'" in this catalog.'}if(this.deactivatedPlugins[f]){i||(this.deactivatedPlugins[f]="USER");return'The plugin "'+f+'" is already deactivated'}this.deactivatedPlugins[f]=i?"DEPENDS":"USER";var r={},z=[];q._findDependents(Object.keys(this.plugins),r,true);Object.keys(r).forEach(function(D){D=this.deactivatePlugin(D,true);if(Array.isArray(D))z=
z.concat(D)},this);q.unregister();i&&z.push(f);return z},activatePlugin:function(f,i){var q=this.plugins[f];if(!q)return'There is no plugin named "'+f+'" in this catalog.';if(!this.deactivatedPlugins[f])return'The plugin "'+f+'" is already activated';if(!(i&&this.deactivatedPlugins[f]==="USER")){if(q.depends&&q.depends.length!=0)if(!q.depends.some(function(D){return!this.deactivatedPlugins[D]},this)){this.deactivatedPlugins[f]="DEPENDS";return'Can not activate plugin "'+f+'" as some of its dependent plugins are not activated'}q.register();
this.orderExtensions();delete this.deactivatedPlugins[f];var r=[],z={};q._findDependents(Object.keys(this.plugins),z,true);Object.keys(z).forEach(function(D){D=this.activatePlugin(D,true);if(Array.isArray(D))r=r.concat(D)},this);i&&r.push(f);return r}},removePlugin:function(f){var i=this.plugins[f];if(i==undefined)throw new Error("Attempted to remove plugin "+f+" which does not exist.");i.unregister();i._cleanup(true);delete this.metadata[f];delete this.plugins[f]},getResourceURL:function(f){var i=
document.getElementById("bespin_base"),q="";if(i){q+=i.href;d.endsWith(q,"/")||(q+="/")}f=this.plugins[f];if(f!=undefined)return q+f.resourceURL},_checkLoops:function(f,i,q){var r=false;q.forEach(function(L){if(f===L){m.error("Circular dependency",f,q);r=true}});if(r)return true;q.push(f);if(i[f]){if(i[f].dependencies)for(var z in i[f].dependencies){var D=q.slice();if(this._checkLoops(z,i,D)){m.error("Errors found when looking at ",f);return true}}}else m.error("Missing metadata for ",f);return false},
getPlugins:function(f){var i=[],q=f.onlyType;for(var r in this.plugins){var z=this.plugins[r];q&&z.type&&z.type!=q||z.name=="bespin"||i.push(z)}var D=f.sortBy;D||(D=["name"]);i.sort(function(L,I){for(var N=0;N<D.length;N++){r=D[N];if(L[r]<I[r])return-1;else if(I[r]<L[r])return 1}return 0});return i},loadObjectForPropertyPath:function(f,i){var q=new v,r=/^([^:]+):([^#]+)#(.*)$/.exec(f);if(r===null)throw new Error("loadObjectForPropertyPath: malformed path: '"+f+"'");r=r[1];if(r===""){if(d.none(i))throw new Error("loadObjectForPropertyPath: no plugin name supplied and no context is present");
r=i}y.ensurePackage(r,function(){q.resolve(this.objectForPropertyPath(f))}.bind(this));return q},objectForPropertyPath:function(f,i,q){q=q==undefined?f.length:q;i||(i=window);var r=f.split("#");if(r.length!==1){i=y(r[0]);if(i===undefined)return;f=r[1];i=i;q-=r[0].length}for(var z=0;i&&z<q;){r=f.indexOf(".",z);if(r<0||r>q)r=q;z=f.slice(z,r);i=i[z];z=r+1}if(z<q)i=undefined;return i},publish:function(f,i,q,r){if(this.shareExtension(this.getExtensionPoint(i)))if(this.parent)this.parent.publish(f,i,q,
r);else{this.children.forEach(function(z){z._publish(f,i,q,r)});this._publish(f,i,q,r)}else this._publish(f,i,q,r)},_publish:function(f,i,q,r){this.getExtensions(i).forEach(function(z){if(z.match&&!z.regexp)z.regexp=new RegExp(z.match);if(z.regexp&&z.regexp.test(q)||z.key===q||d.none(z.key)&&d.none(q))z.load().then(function(D){D(f,q,r)})})},registerExtension:function(f,i){i=new j.Extension(i);i.pluginName="__dynamic";this.getExtensionPoint(f).register(i)}};j.registerExtensionPoint=function(f,i,q){var r=
i.getExtensionPoint(f.name,true);r.description=f.description;r.pluginName=f.pluginName;r.params=f.params;if(f.indexOn)r.indexOn=f.indexOn;if(!q&&(f.register||f.unregister))j.registerExtensionHandler(f,i)};j.registerExtensionHandler=function(f,i){if(!(i.parent&&i.shareExtension(f))){var q=i.getExtensionPoint(f.name,true);q.handlers.push(f);if(f.register){var r=d.clone(q.extensions);f.load(function(z){if(!z)throw f.name+" is not ready";r.forEach(function(D){z(D,i)})},"register",i)}}};j.unregisterExtensionPoint=
function(f){if(f.register||f.unregister)j.unregisterExtensionHandler(f)};j.unregisterExtensionHandler=function(f,i){if(!(i.parent&&i.shareExtension(f))){i=i.getExtensionPoint(f.name,true);if(i.handlers.indexOf(f)!=-1){i.handlers.splice(i.handlers.indexOf(f),1);if(f.unregister){var q=d.clone(i.extensions);f.load(function(r){if(!r)throw f.name+" is not ready";q.forEach(function(z){r(z)})},"unregister")}}}};j.catalog=new j.Catalog;var E=function(f,i){for(var q=Object.keys(i),r=q.length;--r>0;)f.exec(q[r])&&
delete i[q[r]]};j.getUserPlugins=function(){return j.catalog.getPlugins({onlyType:"user"})}});
bespin.tiki.module("bespin:promise",function(y,j){var v=y("bespin:console").console;y("bespin:util/stacktrace");var A=0;j._outstanding=[];j._recent=[];j.Promise=function(){this._status=0;this._value=undefined;this._onSuccessHandlers=[];this._onErrorHandlers=[];this._id=A++;j._outstanding[this._id]=this};j.Promise.prototype.isPromise=true;j.Promise.prototype.isComplete=function(){return this._status!=0};j.Promise.prototype.isResolved=function(){return this._status==1};j.Promise.prototype.isRejected=
function(){return this._status==-1};j.Promise.prototype.then=function(w,m){if(typeof w==="function")if(this._status===1)w.call(null,this._value);else this._status===0&&this._onSuccessHandlers.push(w);if(typeof m==="function")if(this._status===-1)m.call(null,this._value);else this._status===0&&this._onErrorHandlers.push(m);return this};j.Promise.prototype.chainPromise=function(w){var m=new j.Promise;m._chainedFrom=this;this.then(function(d){try{m.resolve(w(d))}catch(h){m.reject(h)}},function(d){m.reject(d)});
return m};j.Promise.prototype.resolve=function(w){return this._complete(this._onSuccessHandlers,1,w,"resolve")};j.Promise.prototype.reject=function(w){return this._complete(this._onErrorHandlers,-1,w,"reject")};j.Promise.prototype._complete=function(w,m,d,h){if(this._status!=0){v.group("Promise already closed");v.error("Attempted "+h+"() with ",d);v.error("Previous status = ",this._status,", previous value = ",this._value);v.trace();if(this._completeTrace){v.error("Trace of previous completion:");
this._completeTrace.log(5)}v.groupEnd();return this}this._status=m;this._value=d;w.forEach(function(k){k.call(null,this._value)},this);this._onSuccessHandlers.length=0;this._onErrorHandlers.length=0;delete j._outstanding[this._id];for(j._recent.push(this);j._recent.length>20;)j._recent.shift();return this};j.group=function(w){w instanceof Array||(w=Array.prototype.slice.call(arguments));if(w.length===0)return(new j.Promise).resolve([]);var m=new j.Promise,d=[],h=0,k=function(x){return function(u){d[x]=
u;h++;m._status!==-1&&h===w.length&&m.resolve(d)}};w.forEach(function(x,u){u=k(u);var B=m.reject.bind(m);x.then(u,B)});return m};j.synchronizer=function(w,m){return function(){var d=w.apply(m,arguments);if(!d.isComplete())throw new Error("asynchronous function can't be synchronized");return d._value}}});
bespin.tiki.module("bespin:proxy",function(y,j){y("util/util");var v=y("promise").Promise;j.xhr=function(A,w,m,d){var h=new v;if(!bespin.proxy||!bespin.proxy.xhr){var k=new XMLHttpRequest;k.onreadystatechange=function(){if(k.readyState===4){var x=k.status;if(x!==0&&x!==200){x=new Error(k.responseText+" (Status "+k.status+")");x.xhr=k;h.reject(x)}else h.resolve(k.responseText)}}.bind(this);k.open("GET",w,m);d&&d(k);k.send()}else bespin.proxy.xhr.call(this,A,w,m,d,h);return h};j.Worker=function(A){return!bespin.proxy||
!bespin.proxy.worker?new Worker(A):new bespin.proxy.worker(A)}});
bespin.tiki.module("bespin:sandbox",function(y,j){var v=y("tiki"),A=y("bespin:util/util"),w=y("bespin:plugins").catalog;if(w.parent)throw new Error("The sandbox module can't be used inside of a slave catalog!");y=function(){v.Sandbox.call(this,bespin.tiki.require.loader,{},[]);var m=this.require("bespin:plugins").catalog;m.parent=w;w.children.push(m);m.deactivatePlugin=A.clone(w.deactivatePlugin);m._extensionsOrdering=A.clone(w._extensionsOrdering);m._registerMetadata(A.clone(w.metadata,true))};y.prototype=
new v.Sandbox;y.prototype.require=function(m,d,h){var k=this.loader.canonical(m,d,h).substring(2).split(":")[0];return w.plugins[k].share?bespin.tiki.sandbox.require(m,d,h):v.Sandbox.prototype.require.call(this,m,d,h)};j.Sandbox=y});
bespin.tiki.module("bespin:util/cookie",function(y,j){var v=function(A,w){return A.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(m){if(w&&w.indexOf(m)!=-1)return m;return"\\"+m})};j.get=function(A){A=new RegExp("(?:^|; )"+v(A)+"=([^;]*)");return(A=document.cookie.match(A))?decodeURIComponent(A[1]):undefined};j.set=function(A,w,m){m=m||{};if(typeof m.expires=="number"){var d=new Date;d.setTime(d.getTime()+m.expires*24*60*60*1E3);m.expires=d}if(m.expires&&m.expires.toUTCString)m.expires=m.expires.toUTCString();
w=encodeURIComponent(w);A=A+"="+w;var h;for(h in m){A+="; "+h;w=m[h];if(w!==true)A+="="+w}document.cookie=A};j.remove=function(A){j.set(A,"",{expires:-1})};j.isSupported=function(){if(!("cookieEnabled"in navigator)){j.set("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=j.get("__djCookieTest__")=="CookiesAllowed";navigator.cookieEnabled&&j.remove("__djCookieTest__")}return navigator.cookieEnabled}});
bespin.tiki.module("bespin:util/scratchcanvas",function(y,j){var v=y("bespin:util/util"),A=function(){this._canvas=document.getElementById("bespin-scratch-canvas");if(v.none(this._canvas)){this._canvas=document.createElement("canvas");this._canvas.id="bespin-scratch-canvas";this._canvas.width=400;this._canvas.height=300;this._canvas.style.position="absolute";this._canvas.style.top="-10000px";this._canvas.style.left="-10000px";document.body.appendChild(this._canvas)}};A.prototype.getContext=function(){return this._canvas.getContext("2d")};
A.prototype.measureStringWidth=function(m,d){if(v.none(d))d="M";var h=this.getContext();h.save();h.font=m;m=h.measureText(d).width;h.restore();return m};var w=null;j.get=function(){if(w===null)w=new A;return w}});
bespin.tiki.module("bespin:util/stacktrace",function(y,j){function v(u){for(var B=0;B<u.length;++B){var E=u[B];if(typeof E=="object")u[B]="#object";else if(typeof E=="function")u[B]="#function";else if(typeof E=="string")u[B]='"'+E+'"'}return u.join(",")}function A(){}var w=y("bespin:util/util"),m=y("bespin:console").console,d=function(){if(w.isMozilla)return"firefox";else if(w.isOpera)return"opera";else if(w.isSafari)return"other";try{0()}catch(u){if(u.arguments)return"chrome";if(u.stack)return"firefox";
if(window.opera&&!("stacktrace"in u))return"opera"}return"other"}(),h={chrome:function(u){var B=u.stack;if(!B){m.log(u);return[]}return B.replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(u){var B=u.stack;if(!B){m.log(u);return[]}B=B.replace(/(?:\n@:0)?\s+$/m,"");B=B.replace(/^\(/gm,"{anonymous}(");return B.split("\n")},opera:function(u){u=u.message.split("\n");
var B=/Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i,E,f,i;E=4;f=0;for(i=u.length;E<i;E+=2)if(B.test(u[E]))u[f++]=(RegExp.$3?RegExp.$3+"()@"+RegExp.$2+RegExp.$1:"{anonymous}()@"+RegExp.$2+":"+RegExp.$1)+" -- "+u[E+1].replace(/^\s+/,"");u.splice(f,u.length-f);return u},other:function(u){for(var B=/function\s*([\w\-$]+)?\s*\(/i,E=[],f=0,i,q;u&&E.length<10;){i=B.test(u.toString())?RegExp.$1||"{anonymous}":"{anonymous}";q=Array.prototype.slice.call(u.arguments);E[f++]=i+"("+v(q)+")";
if(u===u.caller&&window.opera)break;u=u.caller}return E}};A.prototype={sourceCache:{},ajax:function(u){var B=this.createXMLHTTPObject();if(B){B.open("GET",u,false);B.setRequestHeader("User-Agent","XMLHTTP/1.0");B.send("");return B.responseText}},createXMLHTTPObject:function(){for(var u,B=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],E=0;E<
B.length;E++)try{u=B[E]();this.createXMLHTTPObject=B[E];return u}catch(f){}},getSource:function(u){u in this.sourceCache||(this.sourceCache[u]=this.ajax(u).split("\n"));return this.sourceCache[u]},guessFunctions:function(u){for(var B=0;B<u.length;++B){var E=u[B],f=/{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/.exec(E);if(f){var i=f[1];f=f[4];if(i&&f){i=this.guessFunctionName(i,f);u[B]=E.replace("{anonymous}",i)}}}return u},guessFunctionName:function(u,B){try{return this.guessFunctionNameFromLines(B,
this.getSource(u))}catch(E){return"getSource failed with url: "+u+", exception: "+E.toString()}},guessFunctionNameFromLines:function(u,B){for(var E=/function ([^(]*)\(([^)]*)\)/,f=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,i="",q=0;q<10;++q){i=B[u-q]+i;if(i!==undefined){var r=f.exec(i);if(r)return r[1];else r=E.exec(i);if(r&&r[1])return r[1]}}return"(?)"}};var k=new A,x=[/http:\/\/localhost:4020\/sproutcore.js:/];j.ignoreFramesMatching=function(u){x.push(u)};j.Trace=function(u,
B){this._ex=u;this._stack=h[d](u);if(B)this._stack=k.guessFunctions(this._stack)};j.Trace.prototype.log=function(u){if(u<=0)u=999999999;for(var B=0,E=0;E<this._stack.length&&B<u;E++){var f=this._stack[E],i=true;x.forEach(function(q){if(q.test(f))i=false});if(i){m.debug(f);B++}}}});
bespin.tiki.module("bespin:util/util",function(y,j){j.queryToObject=function(d,h){var k={};d=d.split(h||"&");var x=decodeURIComponent;d.forEach(function(u){if(u.length){var B=u.split("=");u=x(B.shift());B=x(B.join("="));if(j.isString(k[u]))k[u]=[k[u]];if(Array.isArray(k[u]))k[u].push(B);else k[u]=B}});return k};j.objectToQuery=function(d){var h=encodeURIComponent,k=[],x={};for(var u in d){var B=d[u];if(B!=x[u]){var E=h(u)+"=";if(B.isArray)for(var f=0;f<B.length;f++)k.push(E+h(B[f]));else k.push(E+
h(B))}}return k.join("&")};var v=0,A={};j.rateLimit=function(d,h,k){if(d){var x=v++;return function(){A[x]&&clearTimeout(A[x]);A[x]=setTimeout(function(){k.apply(h,arguments);delete A[x]},d)}}};j.isString=function(d){return typeof d=="string"||d instanceof String};j.isBoolean=function(d){return typeof d=="boolean"};j.isNumber=function(d){return typeof d=="number"&&isFinite(d)};j.isObject=function(d){return d!==undefined&&(d===null||typeof d=="object"||Array.isArray(d)||j.isFunction(d))};j.isFunction=
function(){var d=function(h){var k=typeof h;return h&&(k=="function"||h instanceof Function)&&!h.nodeType};return j.isSafari?function(h){if(typeof h=="function"&&h=="[object NodeList]")return false;return d(h)}:d}();j.endsWith=function(d,h){if(!d)return false;return d.match(new RegExp(h+"$"))};j.include=function(d,h){return d.indexOf(h)>-1};j.indexOfProperty=function(d,h,k){for(var x=0;x<d.length;x++)if(d[x][h]==k)return x;return null};j.last=function(d){if(Array.isArray(d))return d[d.length-1]};
j.shrinkArray=function(d){var h=[],k=true;d.reverse().forEach(function(x){if(!(k&&x===undefined)){k=false;h.push(x)}});return h.reverse()};j.makeArray=function(d,h){if(d<1)return[];h||(h=" ");for(var k=[],x=0;x<d;x++)k.push(h);return k};j.repeatString=function(d,h){for(var k="",x=0;x<h;x++)k+=d;return k};j.leadingSpaces=function(d){for(var h=0,k=0;k<d.length;k++)if(d[k]==" "||d[k]==""||d[k]===undefined)h++;else return h;return h};j.leadingTabs=function(d){for(var h=0,k=0;k<d.length;k++)if(d[k]=="\t"||
d[k]==""||d[k]===undefined)h++;else return h;return h};j.leadingWhitespace=function(d){for(var h=[],k=0;k<d.length;k++)if(d[k]==" "||d[k]=="\t"||d[k]==""||d[k]===undefined)h.push(d[k]);else return h;return h};j.englishFromCamel=function(d){d.replace(/([A-Z])/g,function(h){return" "+h.toLowerCase()}).trim()};j.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"};y=navigator.userAgent;var w=navigator.appVersion;j.isLinux=w.indexOf("Linux")>=0;j.isWindows=w.indexOf("Win")>=0;j.isWebKit=parseFloat(y.split("WebKit/")[1])||
undefined;j.isChrome=parseFloat(y.split("Chrome/")[1])||undefined;j.isMac=w.indexOf("Macintosh")>=0;j.isMozilla=w.indexOf("Gecko/")>=0;if(y.indexOf("AdobeAIR")>=0)j.isAIR=1;var m=Math.max(w.indexOf("WebKit"),w.indexOf("Safari"),0);if(m&&!j.isChrome){j.isSafari=parseFloat(w.split("Version/")[1]);if(!j.isSafari||parseFloat(w.substr(m+7))<=419.3)j.isSafari=2}if(y.indexOf("Gecko")>=0&&!j.isWebKit)j.isMozilla=parseFloat(w);j.getOS=function(){return j.isMac?j.OS.MAC:j.isLinux?j.OS.LINUX:j.OS.WINDOWS};j.contains=
typeof document!=="undefined"&&document.compareDocumentPosition?function(d,h){return d.compareDocumentPosition(h)&16}:function(d,h){return d!==h&&(d.contains?d.contains(h):true)};j.stopEvent=function(d){d.preventDefault();d.stopPropagation()};j.randomPassword=function(d){d=d||16;for(var h="",k=0;k<d;k++){var x=Math.floor(Math.random()*62);h+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".charAt(x)}return h};j.isEmpty=function(d){for(var h in d)if(d.hasOwnProperty(h))return false;
return true};j.isMyProject=function(d){return d.indexOf("+")==-1};j.formatDate=function(d){if(!d)return"Unknown";return d.getDate()+" "+j.formatDate.shortMonths[d.getMonth()]+" "+d.getFullYear()};j.formatDate.shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];j.addClass=function(d,h){h=h.split(/\s+/);for(var k=" "+d.className+" ",x=0,u=h.length,B;x<u;++x)if((B=h[x])&&k.indexOf(" "+B+" ")<0)k+=B+" ";d.className=k.trim()};j.removeClass=function(d,h){if(h!==undefined){var k=
h.split(/\s+/);h=" "+d.className+" ";for(var x=0,u=k.length;x<u;++x)h=h.replace(" "+k[x]+" "," ");h=h.trim()}else h="";if(d.className!=h)d.className=h};j.setClass=function(d,h,k){k?j.addClass(d,h):j.removeClass(d,h)};j.none=function(d){return d===null||d===undefined};j.clone=function(d,h){if(Array.isArray(d)&&!h)return d.slice();if(typeof d==="object"||Array.isArray(d)){if(d===null)return null;var k=Array.isArray(d)?[]:{};for(var x in d)k[x]=h&&(typeof d[x]==="object"||Array.isArray(d[x]))?j.clone(d[x],
true):d[x];return k}if(d&&typeof d.clone==="function")return d.clone();return d};j.mixin=function(d,h){for(var k in h){var x=h.__lookupGetter__(k),u=h.__lookupSetter__(k);if(x||u){x&&d.__defineGetter__(k,x);u&&d.__defineSetter__(k,u)}else d[k]=h[k]}return d};j.replace=function(d,h,k,x){return d.slice(0,h).concat(x).concat(d.slice(h+k))};j.rectsEqual=function(d,h,k){if(!d||!h)return d==h;if(!k&&k!==0)k=0.1;if(d.y!=h.y&&Math.abs(d.y-h.y)>k)return false;if(d.x!=h.x&&Math.abs(d.x-h.x)>k)return false;
if(d.width!=h.width&&Math.abs(d.width-h.width)>k)return false;if(d.height!=h.height&&Math.abs(d.height-h.height)>k)return false;return true}});bespin.tiki.register("::syntax_directory",{name:"syntax_directory",dependencies:{}});
bespin.tiki.module("syntax_directory:index",function(y,j){function v(m){this.extension=m;this.name=m.name;this.fileExts=m.hasOwnProperty("fileexts")?m.fileexts:[];this.settings=m.settings!=null?m.settings:[]}function A(m){w.register(m)}y("bespin:plugins");var w={_fileExts:{},_syntaxInfo:{},get:function(m){return this._syntaxInfo[m]},hasSyntax:function(m){return this._syntaxInfo.hasOwnProperty(m)},register:function(m){var d=new v(m);this._syntaxInfo[d.name]=d;var h=this._fileExts;d.fileExts.forEach(function(k){h[k]=
d.name})},syntaxForFileExt:function(m){m=m.toLowerCase();var d=this._fileExts;return d.hasOwnProperty(m)?d[m]:"plain"}};j.syntaxDirectory=w;j.discoveredNewSyntax=A});bespin.tiki.register("::underscore",{name:"underscore",dependencies:{}});
bespin.tiki.module("underscore:index",function(y,j){(function(){var v=this,A=v._,w=typeof StopIteration!=="undefined"?StopIteration:"__break__",m=function(g){return g.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},d=Array.prototype,h=Object.prototype,k=d.slice,x=d.unshift,u=h.toString,B=h.hasOwnProperty,E=d.forEach,f=d.map,i=d.reduce,q=d.reduceRight,r=d.filter,z=d.every,D=d.some,L=d.indexOf,I=d.lastIndexOf;h=Array.isArray;var N=Object.keys,l=function(g){return new R(g)};if(typeof j!=="undefined")j._=
l;v._=l;l.VERSION="1.0.2";var J=l.forEach=function(g,n,t){try{if(E&&g.forEach===E)g.forEach(n,t);else if(l.isNumber(g.length))for(var s=0,G=g.length;s<G;s++)n.call(t,g[s],s,g);else for(s in g)B.call(g,s)&&n.call(t,g[s],s,g)}catch(K){if(K!=w)throw K;}return g};l.map=function(g,n,t){if(f&&g.map===f)return g.map(n,t);var s=[];J(g,function(G,K,P){s.push(n.call(t,G,K,P))});return s};l.reduce=function(g,n,t,s){if(i&&g.reduce===i)return g.reduce(l.bind(t,s),n);J(g,function(G,K,P){n=t.call(s,n,G,K,P)});return n};
l.reduceRight=function(g,n,t,s){if(q&&g.reduceRight===q)return g.reduceRight(l.bind(t,s),n);g=l.clone(l.toArray(g)).reverse();return l.reduce(g,n,t,s)};l.detect=function(g,n,t){var s;J(g,function(G,K,P){if(n.call(t,G,K,P)){s=G;l.breakLoop()}});return s};l.filter=function(g,n,t){if(r&&g.filter===r)return g.filter(n,t);var s=[];J(g,function(G,K,P){n.call(t,G,K,P)&&s.push(G)});return s};l.reject=function(g,n,t){var s=[];J(g,function(G,K,P){!n.call(t,G,K,P)&&s.push(G)});return s};l.every=function(g,n,
t){n=n||l.identity;if(z&&g.every===z)return g.every(n,t);var s=true;J(g,function(G,K,P){(s=s&&n.call(t,G,K,P))||l.breakLoop()});return s};l.some=function(g,n,t){n=n||l.identity;if(D&&g.some===D)return g.some(n,t);var s=false;J(g,function(G,K,P){if(s=n.call(t,G,K,P))l.breakLoop()});return s};l.include=function(g,n){if(L&&g.indexOf===L)return g.indexOf(n)!=-1;var t=false;J(g,function(s){if(t=s===n)l.breakLoop()});return t};l.invoke=function(g,n){var t=l.rest(arguments,2);return l.map(g,function(s){return(n?
s[n]:s).apply(s,t)})};l.pluck=function(g,n){return l.map(g,function(t){return t[n]})};l.max=function(g,n,t){if(!n&&l.isArray(g))return Math.max.apply(Math,g);var s={computed:-Infinity};J(g,function(G,K,P){K=n?n.call(t,G,K,P):G;K>=s.computed&&(s={value:G,computed:K})});return s.value};l.min=function(g,n,t){if(!n&&l.isArray(g))return Math.min.apply(Math,g);var s={computed:Infinity};J(g,function(G,K,P){K=n?n.call(t,G,K,P):G;K<s.computed&&(s={value:G,computed:K})});return s.value};l.sortBy=function(g,
n,t){return l.pluck(l.map(g,function(s,G,K){return{value:s,criteria:n.call(t,s,G,K)}}).sort(function(s,G){s=s.criteria;G=G.criteria;return s<G?-1:s>G?1:0}),"value")};l.sortedIndex=function(g,n,t){t=t||l.identity;for(var s=0,G=g.length;s<G;){var K=s+G>>1;t(g[K])<t(n)?(s=K+1):(G=K)}return s};l.toArray=function(g){if(!g)return[];if(g.toArray)return g.toArray();if(l.isArray(g))return g;if(l.isArguments(g))return k.call(g);return l.values(g)};l.size=function(g){return l.toArray(g).length};l.first=function(g,
n,t){return n&&!t?k.call(g,0,n):g[0]};l.rest=function(g,n,t){return k.call(g,l.isUndefined(n)||t?1:n)};l.last=function(g){return g[g.length-1]};l.compact=function(g){return l.filter(g,function(n){return!!n})};l.flatten=function(g){return l.reduce(g,[],function(n,t){if(l.isArray(t))return n.concat(l.flatten(t));n.push(t);return n})};l.without=function(g){var n=l.rest(arguments);return l.filter(g,function(t){return!l.include(n,t)})};l.uniq=function(g,n){return l.reduce(g,[],function(t,s,G){if(0==G||
(n===true?l.last(t)!=s:!l.include(t,s)))t.push(s);return t})};l.intersect=function(g){var n=l.rest(arguments);return l.filter(l.uniq(g),function(t){return l.every(n,function(s){return l.indexOf(s,t)>=0})})};l.zip=function(){for(var g=l.toArray(arguments),n=l.max(l.pluck(g,"length")),t=new Array(n),s=0;s<n;s++)t[s]=l.pluck(g,String(s));return t};l.indexOf=function(g,n){if(L&&g.indexOf===L)return g.indexOf(n);for(var t=0,s=g.length;t<s;t++)if(g[t]===n)return t;return-1};l.lastIndexOf=function(g,n){if(I&&
g.lastIndexOf===I)return g.lastIndexOf(n);for(var t=g.length;t--;)if(g[t]===n)return t;return-1};l.range=function(g,n,t){var s=l.toArray(arguments),G=s.length<=1;g=G?0:s[0];n=G?s[0]:s[1];t=s[2]||1;s=Math.ceil((n-g)/t);if(s<=0)return[];s=new Array(s);G=g;for(var K=0;;G+=t){if((t>0?G-n:n-G)>=0)return s;s[K++]=G}};l.bind=function(g,n){var t=l.rest(arguments,2);return function(){return g.apply(n||{},t.concat(l.toArray(arguments)))}};l.bindAll=function(g){var n=l.rest(arguments);if(n.length==0)n=l.functions(g);
J(n,function(t){g[t]=l.bind(g[t],g)});return g};l.delay=function(g,n){var t=l.rest(arguments,2);return setTimeout(function(){return g.apply(g,t)},n)};l.defer=function(g){return l.delay.apply(l,[g,1].concat(l.rest(arguments)))};l.wrap=function(g,n){return function(){var t=[g].concat(l.toArray(arguments));return n.apply(n,t)}};l.compose=function(){var g=l.toArray(arguments);return function(){for(var n=l.toArray(arguments),t=g.length-1;t>=0;t--)n=[g[t].apply(this,n)];return n[0]}};l.keys=N||function(g){if(l.isArray(g))return l.range(0,
g.length);var n=[];for(var t in g)B.call(g,t)&&n.push(t);return n};l.values=function(g){return l.map(g,l.identity)};l.functions=function(g){return l.filter(l.keys(g),function(n){return l.isFunction(g[n])}).sort()};l.extend=function(g){J(l.rest(arguments),function(n){for(var t in n)g[t]=n[t]});return g};l.clone=function(g){if(l.isArray(g))return g.slice(0);return l.extend({},g)};l.tap=function(g,n){n(g);return g};l.isEqual=function(g,n){if(g===n)return true;var t=typeof g;if(t!=typeof n)return false;
if(g==n)return true;if(!g&&n||g&&!n)return false;if(g.isEqual)return g.isEqual(n);if(l.isDate(g)&&l.isDate(n))return g.getTime()===n.getTime();if(l.isNaN(g)&&l.isNaN(n))return true;if(l.isRegExp(g)&&l.isRegExp(n))return g.source===n.source&&g.global===n.global&&g.ignoreCase===n.ignoreCase&&g.multiline===n.multiline;if(t!=="object")return false;if(g.length&&g.length!==n.length)return false;t=l.keys(g);var s=l.keys(n);if(t.length!=s.length)return false;for(var G in g)if(!(G in n)||!l.isEqual(g[G],n[G]))return false;
return true};l.isEmpty=function(g){if(l.isArray(g)||l.isString(g))return g.length===0;for(var n in g)if(B.call(g,n))return false;return true};l.isElement=function(g){return!!(g&&g.nodeType==1)};l.isArray=h||function(g){return!!(g&&g.concat&&g.unshift&&!g.callee)};l.isArguments=function(g){return g&&g.callee};l.isFunction=function(g){return!!(g&&g.constructor&&g.call&&g.apply)};l.isString=function(g){return!!(g===""||g&&g.charCodeAt&&g.substr)};l.isNumber=function(g){return g===+g||u.call(g)==="[object Number]"};
l.isBoolean=function(g){return g===true||g===false};l.isDate=function(g){return!!(g&&g.getTimezoneOffset&&g.setUTCFullYear)};l.isRegExp=function(g){return!!(g&&g.test&&g.exec&&(g.ignoreCase||g.ignoreCase===false))};l.isNaN=function(g){return l.isNumber(g)&&isNaN(g)};l.isNull=function(g){return g===null};l.isUndefined=function(g){return typeof g=="undefined"};l.noConflict=function(){v._=A;return this};l.identity=function(g){return g};l.times=function(g,n,t){for(var s=0;s<g;s++)n.call(t,s)};l.breakLoop=
function(){throw w;};l.mixin=function(g){J(l.functions(g),function(n){Q(n,l[n]=g[n])})};var U=0;l.uniqueId=function(g){var n=U++;return g?g+n:n};l.templateSettings={start:"<%",end:"%>",interpolate:/<%=(.+?)%>/g};l.template=function(g,n){var t=l.templateSettings,s=new RegExp("'(?=[^"+t.end.substr(0,1)+"]*"+m(t.end)+")","g");g=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+g.replace(/[\r\t\n]/g," ").replace(s,"\t").split("'").join("\\'").split("\t").join("'").replace(t.interpolate,
"',$1,'").split(t.start).join("');").split(t.end).join("p.push('")+"');}return p.join('');");return n?g(n):g};l.each=l.forEach;l.foldl=l.inject=l.reduce;l.foldr=l.reduceRight;l.select=l.filter;l.all=l.every;l.any=l.some;l.head=l.first;l.tail=l.rest;l.methods=l.functions;var R=function(g){this._wrapped=g},S=function(g,n){return n?l(g).chain():g},Q=function(g,n){R.prototype[g]=function(){var t=l.toArray(arguments);x.call(t,this._wrapped);return S(n.apply(l,t),this._chain)}};l.mixin(l);J(["pop","push",
"reverse","shift","sort","splice","unshift"],function(g){var n=d[g];R.prototype[g]=function(){n.apply(this._wrapped,arguments);return S(this._wrapped,this._chain)}});J(["concat","join","slice"],function(g){var n=d[g];R.prototype[g]=function(){return S(n.apply(this._wrapped,arguments),this._chain)}});R.prototype.chain=function(){this._chain=true;return this};R.prototype.value=function(){return this._wrapped}})();j._.noConflict()});bespin.tiki.register("::settings",{name:"settings",dependencies:{types:"0.0.0"}});
bespin.tiki.module("settings:commands",function(y,j){y("bespin:plugins");y("environment");var v=y("settings").settings;j.setCommand=function(A,w){var m;if(A.setting)if(A.value===undefined)m="<strong>"+A.setting+"</strong> = "+v.get(A.setting);else{m="Setting: <strong>"+A.setting+"</strong> = "+A.value;v.set(A.setting,A.value)}else{A=v._list();m="";A.sort(function(d,h){return d.key<h.key?-1:d.key==h.key?0:1});A.forEach(function(d){m+='<a class="setting" href="https://wiki.mozilla.org/Labs/Bespin/Settings#'+
d.key+'" title="View external documentation on setting: '+d.key+'" target="_blank">'+d.key+"</a> = "+d.value+"<br/>"})}w.done(m)};j.unsetCommand=function(A,w){v.resetValue(A.setting);w.done("Reset "+A.setting+" to default: "+v.get(A.setting))}});
bespin.tiki.module("settings:cookie",function(y,j){var v=y("bespin:util/cookie");j.CookiePersister=function(){};j.CookiePersister.prototype={loadInitialValues:function(A){A._loadDefaultValues().then(function(){var w=v.get("settings");A._loadFromObject(JSON.parse(w))}.bind(this))},persistValue:function(A){try{var w={};A._getSettingNames().forEach(function(h){w[h]=A.get(h)});var m=JSON.stringify(w);v.set("settings",m)}catch(d){console.error("Unable to JSONify the settings! "+d)}}}});
bespin.tiki.module("settings:index",function(y,j){var v=y("bespin:plugins").catalog,A=y("bespin:console").console,w=y("bespin:promise").Promise,m=y("bespin:promise").group,d=y("types:types");j.addSetting=function(h){y("settings").settings.addSetting(h)};j.getSettings=function(){return v.getExtensions("setting")};j.getTypeSpecFromAssignment=function(h){var k=h.assignments;h="text";if(k){var x=null;k.forEach(function(u){if(u.param.name==="setting")x=u});if(x)if((k=x.value)&&k!=="")if(k=v.getExtensionByKey("setting",
k))h=k.type}return h};j.MemorySettings=function(){};j.MemorySettings.prototype={_values:{},_deactivated:{},setPersister:function(h){(this._persister=h)&&h.loadInitialValues(this)},get:function(h){return this._values[h]},set:function(h,k){var x=v.getExtensionByKey("setting",h);if(x)if(typeof k=="string"&&x.type=="string")this._values[h]=k;else{var u=false;d.fromString(k,x.type).then(function(B){u=true;this._values[h]=B;v.publish(this,"settingChange",h,B)}.bind(this),function(B){A.error("Error setting",
h,": ",B)});if(!u){A.warn("About to set string version of ",h,"delaying typed set.");this._values[h]=k}}else{A.warn("Setting not defined: ",h,k);this._deactivated[h]=k}this._persistValue(h,k);return this},addSetting:function(h){if(h.name){!h.defaultValue===undefined&&A.error("Setting.defaultValue == undefined",h);d.isValid(h.defaultValue,h.type).then(function(k){k||A.warn("!Setting.isValid(Setting.defaultValue)",h);this.set(h.name,this._deactivated[h.name]||h.defaultValue)}.bind(this),function(k){A.error("Type error ",
k," ignoring setting ",h)})}else A.error("Setting.name == undefined. Ignoring.",h)},resetValue:function(h){var k=v.getExtensionByKey("setting",h);k?this.set(h,k.defaultValue):A.log("ignore resetValue on ",h)},resetAll:function(){this._getSettingNames().forEach(function(h){this.resetValue(h)}.bind(this))},_getSettingNames:function(){var h=[];v.getExtensions("setting").forEach(function(k){h.push(k.name)});return h},_list:function(){var h=[];this._getSettingNames().forEach(function(k){h.push({key:k,
value:this.get(k)})}.bind(this));return h},_persistValue:function(h,k){var x=this._persister;x&&x.persistValue(this,h,k)},_loadInitialValues:function(){var h=this._persister;h?h.loadInitialValues(this):this._loadDefaultValues()},_loadDefaultValues:function(){return this._loadFromObject(this._defaultValues())},_loadFromObject:function(h){var k=[],x=function(i){return function(q){this.set(i,q)}};for(var u in h)if(h.hasOwnProperty(u)){var B=h[u],E=v.getExtensionByKey("setting",u);if(E){B=d.fromString(B,
E.type);E=x(u);B.then(E);k.push(B)}}var f=new w;m(k).then(function(){f.resolve()});return f},_saveToObject:function(){var h=[],k={};this._getSettingNames().forEach(function(u){var B=this.get(u),E=v.getExtensionByKey("setting",u);if(E){B=d.toString(B,E.type);B.then(function(f){k[u]=f});h.push(B)}}.bind(this));var x=new w;m(h).then(function(){x.resolve(k)});return x},_defaultValues:function(){var h={};v.getExtensions("setting").forEach(function(k){h[k.name]=k.defaultValue});return h}};j.settings=new j.MemorySettings});
bespin.tiki.require("bespin:plugins").catalog.registerMetadata({bespin:{testmodules:[],resourceURL:"resources/bespin/",name:"bespin",environments:{main:true,worker:true},type:"plugins/boot"},underscore:{testmodules:[],type:"plugins/thirdparty",resourceURL:"resources/underscore/",description:"Functional Programming Aid for Javascript. Works well with jQuery.",name:"underscore"},syntax_directory:{resourceURL:"resources/syntax_directory/",name:"syntax_directory",environments:{main:true,worker:true},
dependencies:{},testmodules:[],provides:[{register:"#discoveredNewSyntax",ep:"extensionhandler",name:"syntax"}],type:"plugins/supported",description:"Catalogs the available syntax engines"},types:{resourceURL:"resources/types/",description:"Defines parameter types for commands",testmodules:["tests/testBasic","tests/testTypes"],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",ep:"type",name:"deferred"}],type:"plugins/supported",name:"types"},settings:{resourceURL:"resources/settings/",description:"Infrastructure and commands for managing user preferences",share:true,dependencies:{types:"0.0"},testmodules:[],provides:[{indexOn:"name",description:"A setting is something that the application offers as a way to customize how it works",register:"index#addSetting",
ep:"extensionpoint",name:"setting"},{description:"A settingChange is a way to be notified of changes to a setting",ep:"extensionpoint",name:"settingChange"},{pointer:"commands#setCommand",description:"define and show settings",params:[{defaultValue:null,type:{pointer:"settings:index#getSettings",name:"selection"},name:"setting",description:"The name of the setting to display or alter"},{defaultValue:null,type:{pointer:"settings:index#getTypeSpecFromAssignment",name:"deferred"},name:"value",description:"The new value for the chosen setting"}],
ep:"command",name:"set"},{pointer:"commands#unsetCommand",description:"unset a setting entirely",params:[{type:{pointer:"settings:index#getSettings",name:"selection"},name:"setting",description:"The name of the setting to return to defaults"}],ep:"command",name:"unset"}],type:"plugins/supported",name:"settings"}});typeof window==="undefined"?importScripts("BespinWorker.js"):function(){var y=document.createElement("script");y.setAttribute("src",bespin.base+"BespinMain.js");document.getElementsByTagName("head")[0].appendChild(y)}();
