bespin.tiki.register("::text_editor",{name:"text_editor",dependencies:{completion:"0.0.0",undomanager:"0.0.0",settings:"0.0.0",canon:"0.0.0",rangeutils:"0.0.0",traits:"0.0.0",theme_manager:"0.0.0",keyboard:"0.0.0",edit_session:"0.0.0",syntax_manager:"0.0.0"}});
bespin.tiki.module("text_editor:commands/editing",function(y,u){var v=y("settings").settings,s=y("environment").env,o=y("rangeutils:utils/range");u.backspace=function(){s.view.performBackspaceOrDelete(true)};u.deleteCommand=function(){s.view.performBackspaceOrDelete(false)};u.deleteLines=function(){if(!s.model.readOnly)if(s.model.lines.length!=1){var b=s.view;b.groupChanges(function(){var f=b.getSelectedRange(),q=s.model.lines,h=q.length-1,j;j=f.start.row==h?{col:q[h-1].length,row:h-1}:{col:0,row:f.start.row};
b.replaceCharacters({start:j,end:f.end.row==h?{col:q[h].length,row:h}:{col:0,row:f.end.row+1}},"");b.moveCursorTo(j)})}};var k=function(b,f){var q=f.getSelectedRange().start;b=/^\s*/.exec(b.lines[q.row].substring(0,q.col));f.insertText("\n"+b)};u.insertText=function(b){s.view.insertText(b.text)};u.newline=function(){k(s.model,s.view)};u.joinLines=function(){var b=s.model;if(!b.readOnly){var f=s.view,q=f.getSelectedRange(),h=b.lines,j=q.end.row;h.length!=j&&f.groupChanges(function(){f.replaceCharacters({start:{col:h[j].length,
row:j},end:{col:/^\s*/.exec(h[j+1])[0].length,row:j+1}},"")})}};u.openLine=function(){if(!s.model.readOnly){var b=s.model,f=s.view,q=f.getSelectedRange().end.row;f.moveCursorTo({row:q,col:b.lines[q].length});k(b,f)}};u.tab=function(){var b=s.view;b.groupChanges(function(){var f=v.get("tabstop"),q=b.getSelectedRange(),h="";if(o.isZeroLength(q)){var j=s.model.lines[q.start.row].substring(q.start.col).match(/^\s*/)[0].length;f=f-(q.start.col+j)%f;for(var g=0;g<f;g++)h+=" ";b.replaceCharacters({start:q.start,
end:q.start},h);b.moveCursorTo({col:q.start.col+f+j,row:q.end.row})}else{for(g=0;g<f;g++)h+=" ";for(g=q.start.row-1;g++<q.end.row;){j=g==q.start.row?q.start.col:0;b.replaceCharacters({start:{row:g,col:j},end:{row:g,col:j}},h)}b.setSelection({start:q.start,end:{col:q.end.col+f,row:q.end.row}})}}.bind(this))};u.untab=function(){var b=s.view;b.groupChanges(function(){var f=v.get("tabstop"),q=b.getSelectedRange(),h=s.model.lines,j=0;if(o.isZeroLength(q)){j=Math.min(h[q.start.row].substring(0,q.start.col).match(/\s*$/)[0].length,
(q.start.col-f)%f||f);b.replaceCharacters({start:{col:q.start.col-j,row:q.start.row},end:q.start},"");b.moveCursorTo({row:q.start.row,col:q.end.col-j})}else{for(var g,p=q.start.row-1;p++<q.end.row;){g=p==q.start.row?q.start.col:0;j=Math.min(h[p].substring(g).match(/^\s*/)[0].length,f);b.replaceCharacters({start:{row:p,col:g},end:{row:p,col:g+j}},"")}b.setSelection({start:{row:q.start.row,col:q.start.col},end:{row:q.end.row,col:q.end.col-j}})}}.bind(this))}});
bespin.tiki.module("text_editor:commands/editor",function(y,u){y("bespin:plugins");var v=y("settings").settings,s=y("environment").env;u.findNextCommand=function(){var k=s.view,b=k.editor.searchController,f=k.getSelectedRange();if(b=b.findNext(f.end,true)){k.setSelection(b,true);k.focus()}};u.findPrevCommand=function(){var k=s.view,b=k.editor.searchController,f=k.getSelectedRange();if(b=b.findPrevious(f.start,true)){k.setSelection(b,true);k.focus()}};var o=function(k){var b=s.view,f=b.getSelectedCharacters();
k=k(f);b=b.getSelectedRange();s.model.replaceCharacters(b,k)};u.replaceCommand=function(k){o(function(b){return b.replace(k.search+"/g",k.replace)})};u.entabCommand=function(){tabstop=v.get("tabstop");o(function(k){return k.replace(" {"+tabstop+"}","\t")})};u.detabCommand=function(){tabstop=v.get("tabstop");o(function(k){return k.replace("\t",(new Array(tabstop+1)).join(" "))})};u.trimCommand=function(k){o(function(b){b=b.split("\n");b=b.map(function(f){if(k.side==="left"||k.side==="both")f=f.replace(/^\s+/,
"");if(k.side==="right"||k.side==="both")f=f.replace(/\s+$/,"");return f});return b.join("\n")})};u.ucCommand=function(){o(function(k){return k.toUpperCase()})};u.lcCommand=function(){o(function(k){return k.toLowerCase()})}});
bespin.tiki.module("text_editor:commands/movement",function(y,u){y("rangeutils:utils/range");var v=y("environment").env;u.moveDown=function(){v.view.moveDown()};u.moveLeft=function(){v.view.moveLeft()};u.moveRight=function(){v.view.moveRight()};u.moveUp=function(){v.view.moveUp()};u.selectDown=function(){v.view.selectDown()};u.selectLeft=function(){v.view.selectLeft()};u.selectRight=function(){v.view.selectRight()};u.selectUp=function(){v.view.selectUp()};var s=function(q,h){var j=v.view,g=v.model.lines,
p=j.getSelectedRange(true);h=h?p.end.row:g.length-1;j.moveCursorTo({row:h,col:g[h].length},q)};u.moveLineEnd=function(){s(false,true)};u.selectLineEnd=function(){s(true,true)};u.moveDocEnd=function(){s(false,false)};u.selectDocEnd=function(){s(true,false)};var o=function(q,h){var j=v.view,g=j.getSelectedRange(true);j.moveCursorTo({row:h?g.end.row:0,col:0},q)};u.moveLineStart=function(){o(false,true)};u.selectLineStart=function(){o(true,true)};u.moveDocStart=function(){o(false,false)};u.selectDocStart=
function(){o(true,false)};var k=function(q,h,j,g,p){var r=0,z=false;if(g<0){j--;if(p)r=1}for(;j<h.length&&j>-1;){if(p=q.isDelimiter(h[j]))r++;else z=true;if((p||r>1)&&z)break;j+=g}g<0&&j++;return j},b=function(q){var h=v.view,j=v.model.lines,g=h.getSelectedRange(true).end,p=g.row;g=g.col;var r=j[p],z=false;if(g>=r.length){p++;z=true;if(p<j.length){g=0;r=j[p]}else r=""}g=k(h,r,g,1,z);h.moveCursorTo({row:p,col:g},q)},f=function(q){var h=v.view,j=v.model.lines,g=h.getSelectedRange(true).end,p=g.row;
g=g.col;var r=j[p],z=false;if(g>r.length)g=r.length;else if(g==0){p--;z=true;if(p>-1){r=j[p];g=r.length}else r=""}g=k(h,r,g,-1,z);h.moveCursorTo({row:p,col:g},q)};u.moveNextWord=function(){b(false)};u.selectNextWord=function(){b(true)};u.movePreviousWord=function(){f(false)};u.selectPreviousWord=function(){f(true)};u.selectAll=function(){v.view.selectAll()}});
bespin.tiki.module("text_editor:commands/scrolling",function(y,u){var v=y("environment").env;u.scrollDocStart=function(){v.view.scrollToPosition({col:0,row:0})};u.scrollDocEnd=function(){v.view.scrollToPosition(v.model.range.end)};u.scrollPageDown=function(){v.view.scrollPageDown()};u.scrollPageUp=function(){v.view.scrollPageUp()}});
bespin.tiki.module("text_editor:controllers/layoutmanager",function(y,u){var v=y("bespin:util/util"),s=y("events").Event;y("rangeutils:utils/range");var o=y("syntax_manager").SyntaxManager,k=y("models/textstorage").TextStorage,b=y("bespin:plugins").catalog,f=y("settings").settings,q=y("bespin:util/scratchcanvas"),h={};y=function(){var j=f.get("fontsize"),g=f.get("fontface");g=j+"px "+g;for(var p=q.get(),r="",z=0;z<100;z++)r+="M";g=p.measureStringWidth(g,r)/100;h.characterWidth=g;h.lineHeight=Math.floor(j*
1.6);h.lineAscent=Math.floor(j*1.3)};y();b.registerExtension("settingChange",{match:"font[size|face]",pointer:y});u.LayoutManager=function(j){this.changedTextAtRow=new s;this.invalidatedRects=new s;this.fontDimension=h;if(j.textStorage){j._textStorage=j.textStorage;delete j.textStorage}else this._textStorage=new k;v.mixin(this,j);this._textStorage.changed.add(this.textStorageChanged.bind(this));this.textLines=[{characters:"",colors:[{start:0,end:0,color:"plain"}]}];this.syntaxManager=j=new o(this);
j.attrsChanged.add(this._attrsChanged.bind(this));this._size={width:0,height:0};this.sizeChanged=new s;this._height=0;this._recomputeEntireLayout()};u.LayoutManager.prototype={_maximumWidth:0,_textStorage:null,_size:null,sizeChanged:null,_theme:{},margin:{left:5,bottom:6,top:0,right:12},pluginCatalog:b,syntaxManager:null,textLines:null,_attrsChanged:function(j,g){this.updateTextRows(j,g);this.invalidatedRects(this,this.rectsForRange({start:{row:j,col:0},end:{row:g,col:0}}))},_computeInvalidRects:function(j,
g){var p=this.characterRectForPosition(j.start),r={x:p.x,y:p.y,width:Number.MAX_VALUE,height:p.height};return j.end.row===g.end.row?[r]:[r,{x:0,y:p.y+h.lineHeight,width:Number.MAX_VALUE,height:Number.MAX_VALUE}]},_lastCharacterPosition:function(){return{row:this.textLines.length-1,col:this._maximumWidth}},_recalculateMaximumWidth:function(){var j=0;this.textLines.forEach(function(g){g=g.characters.length;if(j<g)j=g});this._maximumWidth=j;this.size={width:j,height:this.textLines.length}},_recomputeEntireLayout:function(){var j=
this._textStorage.range;this._recomputeLayoutForRanges(j,j)},_recomputeLayoutForRanges:function(j,g){for(var p=j.start.row,r=j.end.row,z=g.end.row,C=z-p+1,e=this._textStorage.lines,K=this._theme.plain,M=[],l=0;l<C;l++)M[l]={characters:e[p+l],colors:[{start:0,end:null,color:K}]};this.textLines=v.replace(this.textLines,p,r-p+1,M);this._recalculateMaximumWidth();r=this.textLines.length;C=this.syntaxManager;if(this._height!==r)this._height=r;C.invalidateRow(p);this.updateTextRows(p,z+1);this.changedTextAtRow(this,
p);this.invalidatedRects(this,this._computeInvalidRects(j,g))},boundingRect:function(){return this.rectsForRange({start:{row:0,col:0},end:{row:this.textLines.length-1,col:this._maximumWidth}})[0]},characterAtPoint:function(j){var g=this.margin,p=j.x-g.left,r=h.characterWidth,z=this._textStorage;j=z.clampPosition({row:Math.floor((j.y-g.top)/h.lineHeight),col:Math.floor(p/r)});z=z.lines[j.row].length;j.partialFraction=p<0||j.col===z?0:p%r/r;return j},characterRangeForBoundingRect:function(j){var g=
h.lineHeight,p=h.characterWidth,r=this.margin,z=j.x-r.left;r=j.y-r.top;return{start:{row:Math.max(Math.floor(r/g),0),col:Math.max(Math.floor(z/p),0)},end:{row:Math.floor((r+j.height-1)/g),col:Math.floor((z+j.width-1)/p)+1}}},characterRectForPosition:function(j){return this.rectsForRange({start:j,end:{row:j.row,col:j.col+1}})[0]},lineRectForRow:function(j){return this.rectsForRange({start:{row:j,col:0},end:{row:j,col:this._maximumWidth}})[0]},rectForPosition:function(j){var g=this.margin,p=h.characterWidth,
r=h.lineHeight;return{x:g.left+p*j.col,y:g.top+r*j.row,width:p,height:r}},rectsForRange:function(j){var g=h.characterWidth,p=h.lineHeight,r=this._maximumWidth,z=this.margin,C=j.start,e=j.end;j=C.row;var K=C.col;C=e.row;e=e.col;if(j===C)return[{x:z.left+g*K,y:z.top+p*j,width:g*(e-K),height:p}];var M=[],l;if(K===0)l=j;else{l=j+1;M.push({x:z.left+g*K,y:z.top+p*j,width:99999,height:p})}if(e===0)r=C-1;else if(e===r)r=C;else{r=C-1;M.push({x:z.left,y:z.top+p*C,width:g*e,height:p})}M.push({x:z.left,y:z.top+
p*l,width:99999,height:p*(r-l+1)});return M},textStorageChanged:function(j,g){this._recomputeLayoutForRanges(j,g)},updateTextRows:function(j,g){var p=this.textLines;g=this.syntaxManager.getAttrsForRows(j,g);for(var r=0;r<g.length;r++)p[j+r].colors=g[r]}};Object.defineProperties(u.LayoutManager.prototype,{size:{set:function(j){if(j.width!==this._size.width||j.height!==this._size.height){this.sizeChanged(j);this._size=j}},get:function(){return this._size}},textStorage:{get:function(){return this._textStorage}}})});
bespin.tiki.module("text_editor:controllers/search",function(y,u){var v=y("bespin:util/util");y("rangeutils:utils/range");y("bespin:console");u.EditorSearchController=function(s){this.editor=s};u.EditorSearchController.prototype={editor:null,_escapeString:/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g,_findMatchesInString:function(s){var o=[],k=this.searchRegExp,b;for(k.lastIndex=0;;){b=k.exec(s);if(b===null)break;o.push(b);k.lastIndex=b.index+b[0].length}return o},_makeRange:function(s,o){return{start:{row:o,
col:s.index},end:{row:o,col:s.index+s[0].length}}},isRegExp:null,searchRegExp:null,searchText:null,setSearchText:function(s,o){this.searchRegExp=o?new RegExp(s):new RegExp(s.replace(this._escapeString,"\\$1"),"gi");this.isRegExp=o;this.searchText=s},findNext:function(s,o){var k=this.searchRegExp;if(v.none(k))return null;s=s||this.editor.textView.getSelectedRange().end;var b=this.editor.layoutManager.textStorage.lines,f;k.lastIndex=s.col;var q;for(q=s.row;q<b.length;q++){f=k.exec(b[q]);if(!v.none(f))return this._makeRange(f,
q)}if(!o)return null;for(q=0;q<=s.row;q++){f=k.exec(b[q]);if(!v.none(f))return this._makeRange(f,q)}return null},findPrevious:function(s,o){if(v.none(this.searchRegExp))return null;s=s||this.editor.textView.getSelectedRange().start;var k=this.editor.buffer.layoutManager.textStorage.lines,b;b=this._findMatchesInString(k[s.row].substring(0,s.col));if(b.length!==0)return this._makeRange(b[b.length-1],s.row);var f;for(f=s.row-1;f!==-1;f--){b=this._findMatchesInString(k[f]);if(b.length!==0)return this._makeRange(b[b.length-
1],f)}if(!o)return null;for(f=k.length-1;f>=s.row;f--){b=this._findMatchesInString(k[f]);if(b.length!==0)return this._makeRange(b[b.length-1],f)}return null}}});
bespin.tiki.module("text_editor:controllers/undo",function(y,u){var v=y("bespin:console").console,s=y("environment").env;u.EditorUndoController=function(o){this.editor=o;o=this.textView=o.textView;o.beganChangeGroup.add(function(k,b){this._beginTransaction();this._record.selectionBefore=b}.bind(this));o.endedChangeGroup.add(function(k,b){this._record.selectionAfter=b;this._endTransaction()}.bind(this));o.replacedCharacters.add(function(k,b,f){if(!this._inTransaction)throw new Error("UndoController.textViewReplacedCharacters() called outside a transaction");
this._record.patches.push({oldCharacters:this._deletedCharacters,oldRange:b,newCharacters:f,newRange:this.editor.layoutManager.textStorage.resultingRangeForReplacement(b,f.split("\n"))});this._deletedCharacters=null}.bind(this));o.willReplaceRange.add(function(k,b){if(!this._inTransaction)throw new Error("UndoController.textViewWillReplaceRange() called outside a transaction");this._deletedCharacters=this.editor.layoutManager.textStorage.getCharacters(b)}.bind(this))};u.EditorUndoController.prototype=
{_inTransaction:false,_record:null,textView:null,_beginTransaction:function(){if(this._inTransaction){v.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");this.editor.buffer.undoManager.registerUndo(this,this._record);this._record=null;this._inTransaction=
false},_tryApplyingPatches:function(o){var k=this.editor.layoutManager.textStorage;o.forEach(function(b){k.replaceCharacters(b.oldRange,b.newCharacters)});return true},_undoOrRedo:function(o,k){if(this._inTransaction)throw new Error("UndoController._undoOrRedo() called while in a transaction");if(!this._tryApplyingPatches(o))return false;this.textView.setSelection(k,true);return true},redo:function(o){var k=o.patches.concat();k.reverse();return this._undoOrRedo(k,o.selectionAfter)},undo:function(o){return this._undoOrRedo(o.patches.map(function(k){return{oldCharacters:k.newCharacters,
oldRange:k.newRange,newCharacters:k.oldCharacters,newRange:k.oldRange}}),o.selectionBefore)}};u.undoManagerCommand=function(o,k){s.editor.buffer.undoManager[k.commandExt.name]()}});
bespin.tiki.module("text_editor:models/buffer",function(y,u){var v=y("environment").env,s=y("bespin:util/util"),o=y("bespin:promise").Promise,k=y("models/textstorage").TextStorage,b=y("controllers/layoutmanager").LayoutManager,f=y("undomanager").UndoManager;u.Buffer=function(q,h){this._file=q;this._model=new k(h);this._layoutManager=new b({textStorage:this._model});this.undoManager=new f;if(q)this.reload().then(function(){this._updateSyntaxManagerInitialContext()}.bind(this));else{this.loadPromise=
new o;this.loadPromise.resolve()}h=v.session?v.session.history:null;var j,g,p;if(h&&q&&(j=h.getHistoryForPath(q.path))){g=j.selection;p=j.scroll}this._selectedRange=g||{start:{row:0,col:0},end:{row:0,col:0}};this._scrollOffset=p||{x:0,y:0}};u.Buffer.prototype={undoManager:null,loadPromise:null,_scrollOffset:null,_selectedRange:null,_selectedRangeEndVirtual:null,_layoutManager:null,_file:null,_model:null,save:function(){return this._file.saveContents(this._model.value)},saveAs:function(q){var h=new o;
q.saveContents(this._model.value).then(function(){this._file=q;this._updateSyntaxManagerInitialContext();h.resolve()}.bind(this),function(j){h.reject(j)});return h},reload:function(){var q=this,h;return this.loadPromise=h=this._file.loadContents().then(function(j){q._model.value=j})},_updateSyntaxManagerInitialContext:function(){var q=this._file.extension();this._layoutManager.syntaxManager.setSyntaxFromFileExt(q===null?"":q)},untitled:function(){return s.none(this._file)}};Object.defineProperties(u.Buffer.prototype,
{layoutManager:{get:function(){return this._layoutManager}},syntaxManager:{get:function(){}},file:{get:function(){return this._file}},model:{get:function(){return this._model}}})});
bespin.tiki.module("text_editor:models/textstorage",function(y,u){var v=y("events").Event,s=y("bespin:util/util");y=function(o){this._lines=o!==null&&o!==undefined?o.split("\n"):[""];this.changed=new v;return this};y.prototype={_lines:null,readOnly:false,clampPosition:function(o){var k=this._lines,b=o.row;if(b<0)return{row:0,col:0};else if(b>=k.length)return this.range.end;o=Math.max(0,Math.min(o.col,k[b].length));return{row:b,col:o}},clampRange:function(o){var k=this.clampPosition(o.start);o=this.clampPosition(o.end);
return{start:k,end:o}},deleteCharacters:function(o){this.replaceCharacters(o,"")},displacePosition:function(o,k){var b=k>0,f=this._lines,q=f.length;for(k=Math.abs(k);k!==0;k--)if(b){var h=f[o.row].length;if(o.row===q-1&&o.col===h)return o;o=o.col===h?{row:o.row+1,col:0}:{row:o.row,col:o.col+1}}else{if(o.row===0&&o.col==0)return o;if(o.col===0){f=this._lines;o={row:o.row-1,col:f[o.row-1].length}}else o={row:o.row,col:o.col-1}}return o},getCharacters:function(o){var k=this._lines,b=o.start,f=o.end,
q=b.row;o=f.row;var h=b.col;b=f.col;if(q===o)return k[q].substring(h,b);f=k[q].substring(h);q=k.slice(q+1,o);k=k[o].substring(0,b);return[f].concat(q,k).join("\n")},getLines:function(){return this._lines},getRange:function(){var o=this._lines,k=o.length-1;return{start:{row:0,col:0},end:{row:k,col:o[k].length}}},getValue:function(){return this._lines.join("\n")},insertCharacters:function(o,k){this.replaceCharacters({start:o,end:o},k)},replaceCharacters:function(o,k){if(this.readOnly)throw new Error("Attempt to modify a read-only text storage object");
var b=k.split("\n"),f=b.length,q=this.resultingRangeForReplacement(o,b),h=o.start,j=o.end,g=h.row,p=j.row,r=this._lines;b[0]=r[g].substring(0,h.col)+b[0];b[f-1]+=r[p].substring(j.col);this._lines=s.replace(r,g,p-g+1,b);this.changed(o,q,k)},resultingRangeForReplacement:function(o,k){var b=k.length;o=o.start;return{start:o,end:{row:o.row+b-1,col:(b===1?o.col:0)+k[b-1].length}}},setLines:function(o){this.setValue(o.join("\n"))},setValue:function(o){this.replaceCharacters(this.range,o)}};u.TextStorage=
y;Object.defineProperties(u.TextStorage.prototype,{lines:{get:function(){return this.getLines()},set:function(o){return this.setLines(o)}},range:{get:function(){return this.getRange()}},value:{get:function(){return this.getValue()},set:function(o){this.setValue(o)}}})});
bespin.tiki.module("text_editor:utils/rect",function(y,u){u._distanceFromBounds=function(v,s,o){if(v<s)return v-s;if(v>=o)return v-o;return 0};u.merge=function(v){var s;do{s=false;for(var o=[],k=0;k<v.length;k++){var b=v[k];o.push(b);for(var f=k+1;f<v.length;f++){var q=v[f];if(u.rectsSideBySide(b,q)||u.rectsIntersect(b,q)){v.splice(f,1);o[o.length-1]=u.unionRects(b,q);s=true;break}}}v=o}while(s);return v};u.offsetFromRect=function(v,s){return{x:u._distanceFromBounds(s.x,v.x,u.maxX(v)),y:u._distanceFromBounds(s.y,
v.y,u.maxY(v))}};u.rectsIntersect=function(v,s){v=u.intersectRects(v,s);return v.width!==0&&v.height!==0};u.rectsSideBySide=function(v,s){if(v.x==s.x&&v.width==s.width)return v.y<s.y?v.y+v.height==s.y:s.y+s.height==v.y;else if(v.y==s.y&&v.height==s.height)return v.x<s.x?v.x+v.width==s.x:s.x+s.width==v.x;return false};u.intersectRects=function(v,s){v={x:Math.max(u.minX(v),u.minX(s)),y:Math.max(u.minY(v),u.minY(s)),width:Math.min(u.maxX(v),u.maxX(s)),height:Math.min(u.maxY(v),u.maxY(s))};v.width=Math.max(0,
v.width-v.x);v.height=Math.max(0,v.height-v.y);return v};u.minX=function(v){return v.x||0};u.maxX=function(v){return(v.x||0)+(v.width||0)};u.minY=function(v){return v.y||0};u.maxY=function(v){return(v.y||0)+(v.height||0)};u.pointInRect=function(v,s){return v.x>=u.minX(s)&&v.y>=u.minY(s)&&v.x<=u.maxX(s)&&v.y<=u.maxY(s)};u.unionRects=function(v,s){v={x:Math.min(u.minX(v),u.minX(s)),y:Math.min(u.minY(v),u.minY(s)),width:Math.max(u.maxX(v),u.maxX(s)),height:Math.max(u.maxY(v),u.maxY(s))};v.width=Math.max(0,
v.width-v.x);v.height=Math.max(0,v.height-v.y);return v};u.rectsEqual=function(v,s,o){if(!v||!s)return v==s;if(!o&&o!==0)o=0.1;if(v.y!=s.y&&Math.abs(v.y-s.y)>o)return false;if(v.x!=s.x&&Math.abs(v.x-s.x)>o)return false;if(v.width!=s.width&&Math.abs(v.width-s.width)>o)return false;if(v.height!=s.height&&Math.abs(v.height-s.height)>o)return false;return true}});
bespin.tiki.module("text_editor:views/canvas",function(y,u){var v=y("bespin:util/util"),s=y("utils/rect"),o=y("events").Event;u.CanvasView=function(k,b,f){if(k){this._preventDownsize=b||false;this._clearOnFullInvalid=f||false;this._clippingFrame=this._frame={x:0,y:0,width:0,height:0};this._invalidRects=[];b=document.createElement("canvas");b.setAttribute("style","position: absolute");b.innerHTML="canvas tag not supported by your browser";k.appendChild(b);this.domNode=b;this.clippingChanged=new o;
this.clippingChanged.add(this.clippingFrameChanged.bind(this))}};u.CanvasView.prototype={domNode:null,clippingChanged:null,_canvasContext:null,_canvasId:null,_invalidRects:null,_lastRedrawTime:null,_redrawTimer:null,_clippingFrame:null,_preventDownsize:false,_clearOnFullInvalid:false,_frame:null,_getContext:function(){if(this._canvasContext===null)this._canvasContext=this.domNode.getContext("2d");return this._canvasContext},computeWithClippingFrame:function(k,b){var f=this.clippingFrame;return{x:k+
f.x,y:b+f.y}},minimumRedrawDelay:1E3/30,clippingFrameChanged:function(){this.invalidate()},drawRect:function(){},render:function(){if(!(this._renderTimer||this._redrawTimer))this._renderTimer=setTimeout(this._tryRedraw.bind(this),0)},invalidate:function(){this._invalidRects="all";this.render()},invalidateRect:function(k){var b=this._invalidRects;if(b!=="all"){b.push(k);this.render()}},_tryRedraw:function(){this._renderTimer=null;var k=(new Date).getTime(),b=this._lastRedrawTime,f=this.minimumRedrawDelay;
if(b===null||k-b>=f)this._redraw();else if(this._redrawTimer===null)this._redrawTimer=window.setTimeout(this._redraw.bind(this),f)},_redraw:function(){var k=this.clippingFrame;k={x:Math.round(k.x),y:Math.round(k.y),width:k.width,height:k.height};var b=this._getContext();b.save();b.translate(-k.x,-k.y);var f=this._invalidRects;if(f==="all"){this._clearOnFullInvalid&&b.clearRect(0,0,this.domNode.width,this.domNode.height);this.drawRect(k,b)}else s.merge(f).forEach(function(q){q=s.intersectRects(q,k);
if(q.width!==0&&q.height!==0){b.save();var h=q.x,j=q.y,g=q.width,p=q.height;b.beginPath();b.moveTo(h,j);b.lineTo(h+g,j);b.lineTo(h+g,j+p);b.lineTo(h,j+p);b.closePath();b.clip();this.drawRect(q,b);b.restore()}},this);b.restore();this._invalidRects=[];this._redrawTimer=null;this._lastRedrawTime=(new Date).getTime()}};Object.defineProperties(u.CanvasView.prototype,{clippingFrame:{get:function(){return this._clippingFrame},set:function(k){k=v.mixin(v.clone(this._clippingFrame),k);if(this._clippingFrame===
null||!s.rectsEqual(k,this._clippingFrame)){this._clippingFrame=k;this.clippingChanged()}}},frame:{get:function(){return this._frame},set:function(k){var b=this.domNode,f=b.style,q=this._preventDownsize,h=b.width,j=b.height;f=b.style;f.left=k.x+"px";f.top=k.y+"px";var g,p;if(k.width!==h)if(k.width<h)q||(g=true);else g=true;if(k.height!==j)if(k.height<j)q||(p=true);else p=true;if(g)this.domNode.width=k.width;if(p)this.domNode.height=k.height;this._frame=k;this.clippingFrame={width:k.width,height:k.height}}}})});
bespin.tiki.module("text_editor:views/editor",function(y,u){function v(l){var w=C.plugins.text_editor.provides,D=w.length,H={};if(l){l=l.themestyles;if(l.currentThemeVariables&&l.currentThemeVariables.text_editor)H=l.currentThemeVariables.text_editor}for(;D--;)if(w[D].ep==="themevariable"){l=k.mixin(k.clone(w[D].defaultValue),H[w[D].name]);switch(w[D].name){case "gutter":case "editor":case "scroller":case "highlighterFG":case "highlighterBG":M[w[D].name]=l}}}var s=y("rangeutils:utils/range"),o=y("views/scroller"),
k=y("bespin:util/util"),b=y("models/buffer").Buffer,f=y("completion:controller").CompletionController,q=y("controllers/search").EditorSearchController,h=y("controllers/undo").EditorUndoController,j=y("events").Event,g=y("views/gutter").GutterView;y("controllers/layoutmanager");var p=o.ScrollerCanvasView,r=y("views/text").TextView,z=y("underscore")._,C=y("bespin:plugins").catalog,e=y("keyboard:keyboard").keyboardManager,K=y("settings").settings,M={};v();C.registerExtension("themeChange",{pointer:v});
u.EditorView=function(l){this.elementAppended=new j;var w=this.element=this.container=document.createElement("div");w.style.overflow="visible";w.style.position="relative";this.scrollOffsetChanged=new j;this.willChangeBuffer=new j;this.selectionChanged=new j;this.textChanged=new j;this.gutterView=new g(w,this);this.textView=new r(w,this);var D=new p(this,o.LAYOUT_VERTICAL),H=new p(this,o.LAYOUT_HORIZONTAL);this.verticalScroller=D;this.horizontalScroller=H;this.completionController=new f(this);this.editorUndoController=
new h(this);this.searchController=new q(this);this._textViewSize=this._oldSize={width:0,height:0};this._themeData=M;this.buffer=new b(null,l);this.elementAppended.add(function(){var R=K.get("fontsize"),W=K.get("fontface");this._font=R+"px "+W;C.registerExtension("themeChange",{pointer:this._themeVariableChange.bind(this)});C.registerExtension("settingChange",{match:"font[size|face]",pointer:this._fontSettingChanged.bind(this)});C.registerExtension("dimensionsChanged",{pointer:this.dimensionsChanged.bind(this)});
this._dontRecomputeLayout=false;this._recomputeLayout();w.addEventListener(k.isMozilla?"DOMMouseScroll":"mousewheel",this._onMouseWheel.bind(this),false);D.valueChanged.add(function($){this.scrollOffset={y:$}}.bind(this));H.valueChanged.add(function($){this.scrollOffset={x:$}}.bind(this));this.scrollOffsetChanged.add(function($){this._updateScrollOffsetChanged($)}.bind(this))}.bind(this))};u.EditorView.prototype={elementAppended:null,textChanged:null,selectionChanged:null,scrollOffsetChanged:null,
willChangeBuffer:null,_textViewSize:null,_textLinesCount:0,_gutterViewWidth:0,_oldSize:null,_buffer:null,_dontRecomputeLayout:true,_themeData:null,_layoutManagerSizeChanged:function(l){var w=this.layoutManager.fontDimension;this._textViewSize={width:l.width*w.characterWidth,height:l.height*w.lineHeight};if(this._textLinesCount!==l.height){this.gutterView.computeWidth()!==this._gutterViewWidth?this._recomputeLayout(true):this.gutterView.invalidate();this._textLinesLength=l.height}this._updateScrollers();
this.scrollOffset={}},_updateScrollers:function(){if(!this._dontRecomputeLayout){var l=this.textViewPaddingFrame,w=this._textViewSize.width,D=this._textViewSize.height,H=this.scrollOffset,R=this.verticalScroller,W=this.horizontalScroller;if(D<l.height)R.isVisible=false;else{R.isVisible=true;R.proportion=l.height/D;R.maximum=D-l.height;R.value=H.y}if(w<l.width)W.isVisible=false;else{W.isVisible=true;W.proportion=l.width/w;W.maximum=w-l.width;W.value=H.x}}},_onMouseWheel:function(l){var w=0;if(l.wheelDelta)w=
-l.wheelDelta;else if(l.detail)w=l.detail*40;var D=true;if(l.axis){if(l.axis==l.HORIZONTAL_AXIS)D=false}else if(l.wheelDeltaY||l.wheelDeltaX){if(l.wheelDeltaX==l.wheelDelta)D=false}else if(l.shiftKey)D=false;D?this.scrollBy(0,w):this.scrollBy(w*5,0);k.stopEvent(l)},scrollTo:function(l){this.scrollOffset=l},scrollBy:function(l,w){this.scrollOffset={x:this.scrollOffset.x+l,y:this.scrollOffset.y+w}},_recomputeLayout:function(l){if(!this._dontRecomputeLayout){var w=this.container.offsetWidth,D=this.container.offsetHeight;
if(!(!l&&w==this._oldSize.width&&D==this._oldSize.height)){this._oldSize={width:w,height:D};this._gutterViewWidth=l=this.gutterView.computeWidth();this.gutterView.frame={x:0,y:0,width:l,height:D};this.textView.frame={x:l,y:0,width:w-l,height:D};var H=this._themeData.scroller.padding,R=this._themeData.scroller.thickness;this.horizontalScroller.frame={x:l+H,y:D-(R+H),width:w-(l+2*H+R),height:R};this.verticalScroller.frame={x:w-(H+R),y:H,width:R,height:D-(2*H+R)};this.scrollOffset={};this._updateScrollers();
this.gutterView.invalidate();this.textView.invalidate();this.verticalScroller.invalidate();this.horizontalScroller.invalidate()}}},dimensionsChanged:function(){this._recomputeLayout()},_font:null,_fontSettingChanged:function(){var l=K.get("fontsize"),w=K.get("fontface");this._font=l+"px "+w;this.layoutManager._recalculateMaximumWidth();this._layoutManagerSizeChanged(this.layoutManager.size);this.textView.invalidate()},_themeVariableChange:function(){this._recomputeLayout(true)},_updateScrollOffsetChanged:function(l){this.verticalScroller.value=
l.y;this.horizontalScroller.value=l.x;this.textView.clippingFrame={x:l.x,y:l.y};this.gutterView.clippingFrame={y:l.y};this._updateScrollers();this.gutterView.invalidate();this.textView.invalidate()},processKeyEvent:function(l,w,D){D=z(D).clone();D.completing=this.completionController.isCompleting();return e.processKeyEvent(l,w,D)},convertTextViewPoint:function(l){var w=this.scrollOffset;return{x:l.x-w.x+this._gutterViewWidth,y:l.y-w.y}},replace:function(l,w,D){if(!s.isRange(l))throw new Error('replace(): expected range but found "'+
l+"'");if(!k.isString(w))throw new Error('replace(): expected text string but found "'+text+'"');var H=s.normalizeRange(l),R=this.textView,W=R.getSelectedRange(false);return R.groupChanges(function(){R.replaceCharacters(H,w);if(D)R.setSelection(W);else{var $=w.split("\n");$=$.length>1?{row:l.start.row+$.length-1,col:$[$.length-1].length}:s.addPositions(l.start,{row:0,col:w.length});R.moveCursorTo($)}})},getText:function(l){if(!s.isRange(l))throw new Error('getText(): expected range but found "'+l+
'"');return this.layoutManager.textStorage.getCharacters(s.normalizeRange(l))},setLineNumber:function(l){if(!k.isNumber(l))throw new Error("setLineNumber(): lineNumber must be a number");this.textView.moveCursorTo({row:l-1,col:0})},setCursor:function(l){if(!s.isPosition(l))throw new Error('setCursor(): expected position but found "'+l+'"');this.textView.moveCursorTo(l)},changeGroup:function(l){return this.textView.groupChanges(function(){l(this)}.bind(this))},addTags:function(l){this.completionController.tags.add(l)}};
Object.defineProperties(u.EditorView.prototype,{themeData:{get:function(){return this._themeData},set:function(){throw new Error("themeData can't be changed directly. Use themeManager.");}},font:{get:function(){return this._font},set:function(){throw new Error("font can't be changed directly. Use settings fontsize and fontface.");}},buffer:{set:function(l){if(l!==this._buffer){if(!l.loadPromise.isResolved())throw new Error("buffer.set(): the new buffer must first be loaded!");if(this._buffer!==null){this.layoutManager.sizeChanged.remove(this);
this.layoutManager.textStorage.changed.remove(this);this.textView.selectionChanged.remove(this)}this.willChangeBuffer(l);C.publish(this,"editorChange","buffer",l);this.layoutManager=l.layoutManager;this._buffer=l;var w=this.layoutManager,D=this.textView;w.sizeChanged.add(this,this._layoutManagerSizeChanged.bind(this));w.textStorage.changed.add(this,this.textChanged.bind(this));D.selectionChanged.add(this,this.selectionChanged.bind(this));this.textView.setSelection(l._selectedRange,false);this.scrollOffsetChanged(l._scrollOffset);
this.layoutManager.sizeChanged(this.layoutManager.size);this._recomputeLayout()}},get:function(){return this._buffer}},frame:{get:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},textViewPaddingFrame:{get:function(){var l=k.clone(this.textView.frame),w=this.textView.padding;l.width-=w.left+w.right;l.height-=w.top+w.bottom;return l}},scrollOffset:{set:function(l){if(l.x===undefined)l.x=this.scrollOffset.x;if(l.y===undefined)l.y=this.scrollOffset.y;var w=this.textViewPaddingFrame;
if(l.y<0)l.y=0;else if(this._textViewSize.height<w.height)l.y=0;else if(l.y+w.height>this._textViewSize.height)l.y=this._textViewSize.height-w.height;if(l.x<0)l.x=0;else if(this._textViewSize.width<w.width)l.x=0;else if(l.x+w.width>this._textViewSize.width)l.x=this._textViewSize.width-w.width;if(!(l.x===this.scrollOffset.x&&l.y===this.scrollOffset.y)){this.buffer._scrollOffset=l;this.scrollOffsetChanged(l);C.publish(this,"editorChange","scrollOffset",l)}},get:function(){return this.buffer._scrollOffset}},
readOnly:{get:function(){return this._buffer.model.readOnly},set:function(l){this._buffer.model.readOnly=l}},focus:{get:function(){return this.textView.hasFocus},set:function(l){if(!k.isBoolean(l))throw new Error('set focus: expected boolean but found "'+l+'"');this.textView.hasFocus=l}},selection:{get:function(){return k.clone(this.textView.getSelectedRange(false))},set:function(l){if(!s.isRange(l))throw new Error("set selection: position/selection must be supplied");this.textView.setSelection(l)}},
selectedText:{get:function(){return this.getText(this.selection)},set:function(l){if(!k.isString(l))throw new Error('set selectedText: expected string but found "'+l+'"');return this.replace(this.selection,l)}},value:{get:function(){return this.layoutManager.textStorage.value},set:function(l){if(!k.isString(l))throw new Error('set value: expected string but found "'+l+'"');return this.replace(this.layoutManager.textStorage.range,l,false)}},syntax:{get:function(){return this.layoutManager.syntaxManager.getSyntax()},
set:function(l){if(!k.isString(l))throw new Error('set syntax: expected string but found "'+newValue+'"');return this.layoutManager.syntaxManager.setSyntax(l)}}})});
bespin.tiki.module("text_editor:views/gutter",function(y,u){var v=y("bespin:util/util"),s=y("bespin:plugins").catalog,o=y("utils/rect"),k=y("views/canvas").CanvasView;u.GutterView=function(b,f){k.call(this,b,true);this.editor=f;this.domNode.addEventListener("click",this._click.bind(this),false)};u.GutterView.prototype=new k;v.mixin(u.GutterView.prototype,{_decorationSpacing:2,drawRect:function(b,f){var q=this.editor.themeData.gutter;f.fillStyle=q.backgroundColor;f.fillRect(b.x,b.y,b.width,b.height);
f.save();f.translate(q.paddingLeft-0.5,-0.5);q=this.editor.layoutManager;var h=q.characterRangeForBoundingRect(b);b=Math.min(h.end.row,q.textLines.length-1);for(var j=q.fontDimension.lineAscent,g=this._loadedDecorations(true),p=[],r=0;r<g.length;r++)p.push(g[r].computeWidth(this));for(h=h.start.row;h<=b;h++){f.save();r=q.lineRectForRow(h).y;f.translate(0,r);for(r=0;r<g.length;r++){g[r].drawDecoration(this,f,j,h);f.translate(p[r]+this._decorationSpacing,0)}f.restore()}f.restore()},computeWidth:function(){var b=
this.editor.themeData.gutter;b=b.paddingLeft+b.paddingRight;for(var f=this._loadedDecorations(true),q=0;q<f.length;q++)b+=f[q].computeWidth(this);b+=(f.length-1)*this._decorationSpacing;return b},_click:function(b){var f={x:b.layerX,y:b.layerY};if(o.pointInRect(f,this.frame))if((b=this._decorationAtPoint(f))&&"selected"in b){f=this.editor.layoutManager.characterAtPoint(this.computeWithClippingFrame(f.x,f.y));b.selected(this,f.row)}},_loadedDecorations:function(b){for(var f=[],q=s.getExtensions("gutterDecoration"),
h=0;h<q.length;h++){var j=q[h].load();if(j.isResolved())j.then(f.push.bind(f));else b&&j.then(this.invalidate.bind(this))}return f},_decorationAtPoint:function(b){var f=this.editor.themeData.gutter;if(b.x>f.paddingLeft){var q=this._loadedDecorations(false);f=f.paddingLeft;for(var h=0;h<q.length;h++){var j=q[h],g=j.computeWidth(this);if(b.x<f+g)return j;f+=g+this._decorationSpacing}}return null}});u.lineNumbers={drawDecoration:function(b,f,q,h){b=b.editor;f.fillStyle=b.themeData.gutter.color;f.font=
b.font;f.fillText(""+(h+1),0,q)},computeWidth:function(b){b=b.editor.layoutManager;return b.fontDimension.characterWidth*(""+b.textLines.length).length}}});
bespin.tiki.module("text_editor:views/scroller",function(y,u){var v=y("bespin:util/util"),s=y("events").Event,o=y("bespin:console").console,k=y("utils/rect"),b=y("views/canvas").CanvasView,f=u.LAYOUT_HORIZONTAL=0,q=u.LAYOUT_VERTICAL=1;u.ScrollerCanvasView=function(h,j){b.call(this,h.container,false,true);this.editor=h;this.layoutDirection=j;h=function(g,p,r){r=r||this.domNode;r.addEventListener(g,function(z){p.call(this,z);v.stopEvent(z)}.bind(this),false)}.bind(this);h("mouseover",this.mouseEntered);
h("mouseout",this.mouseExited);h("mousedown",this.mouseDown);h("mouseup",this.mouseUp,window);h("mousemove",this.mouseMove,window);this.valueChanged=new s};u.ScrollerCanvasView.prototype=new b;v.mixin(u.ScrollerCanvasView.prototype,{lineHeight:20,proportion:0,layoutDirection:q,_isVisible:false,_maximum:0,_value:0,valueChanged:null,padding:{left:0,bottom:0,top:0,right:0},_mouseDownScreenPoint:null,_mouseDownValue:null,_isMouseOver:false,_scrollTimer:null,_mouseEventPosition:null,_mouseOverHandle:false,
_drawNib:function(h){var j=this.editor.themeData.scroller,g,p;g=j.nibStyle;p=j.nibArrowStyle;j=j.nibStrokeStyle;var r=Math.floor(7.5);h.fillStyle=g;h.beginPath();h.arc(0,0,Math.floor(7.5),0,Math.PI*2,true);h.closePath();h.fill();h.strokeStyle=j;h.stroke();h.fillStyle=p;h.beginPath();h.moveTo(0,-r+3);h.lineTo(-r+3,r-5);h.lineTo(r-3,r-5);h.closePath();h.fill()},_drawNibs:function(h,j){var g=this._getClientThickness(),p=this._value,r=this._maximum,z=this._isHighlighted();if(z||p!==0){h.save();h.translate(8,
g/2);h.rotate(Math.PI*1.5);h.moveTo(0,0);this._drawNib(h,j);h.restore()}if(z||p!==r){h.save();h.translate(this._getClientLength()-8,g/2);h.rotate(Math.PI*0.5);h.moveTo(0,0);this._drawNib(h,j);h.restore()}},_getClientFrame:function(){var h=this.frame,j=this.padding;return{x:j.left,y:j.top,width:h.width-(j.left+j.right),height:h.height-(j.top+j.bottom)}},_getClientLength:function(){var h=this._getClientFrame();switch(this.layoutDirection){case f:return h.width;case q:return h.height;default:o.error("unknown layout direction");
return null}},_getClientThickness:function(){var h=this.padding,j=this.editor.themeData.scroller.thickness;switch(this.layoutDirection){case q:return j-(h.left+h.right);case f:return j-(h.top+h.bottom);default:o.error("unknown layout direction");return null}},_getFrameLength:function(){switch(this.layoutDirection){case f:return this.frame.width;case q:return this.frame.height;default:o.error("unknown layout direction");return null}},_getGutterFrame:function(){var h=this._getClientFrame(),j=this._getClientThickness();
switch(this.layoutDirection){case q:return{x:h.x,y:h.y+15,width:j,height:Math.max(0,h.height-30)};case f:return{x:h.x+15,y:h.y,width:Math.max(0,h.width-30),height:j};default:o.error("unknown layout direction");return null}},_getGutterLength:function(){var h=this._getGutterFrame(),j;switch(this.layoutDirection){case f:j=h.width;break;case q:j=h.height;break;default:o.error("unknown layout direction");break}return j},_getHandleFrame:function(){var h=this._getGutterFrame(),j=this._getHandleOffset(),
g=this._getHandleLength();switch(this.layoutDirection){case q:return{x:h.x,y:h.y+j,width:h.width,height:g};case f:return{x:h.x+j,y:h.y,width:g,height:h.height}}},_getHandleLength:function(){var h=this._getGutterLength();return Math.max(h*this.proportion,20)},_getHandleOffset:function(){var h=this._maximum;if(h===0)return 0;var j=this._getGutterLength(),g=this._getHandleLength();return(j-g)*this._value/h},_isHighlighted:function(){return this._isMouseOver===true||this._mouseDownScreenPoint!==null},
_segmentForMouseEvent:function(h){h={x:h.layerX,y:h.layerY};var j=this._getClientFrame(),g=this.padding;if(!k.pointInRect(h,j))return null;var p=this.layoutDirection;switch(p){case f:if(h.x-g.left<15)return"nib-start";else if(h.x>=j.width-15)return"nib-end";break;case q:if(h.y-g.top<15)return"nib-start";else if(h.y>=j.height-15)return"nib-end";break;default:o.error("unknown layout direction");break}g=this._getHandleFrame();if(k.pointInRect(h,g))return"handle";switch(p){case f:if(h.x<g.x)return"gutter-before";
else if(h.x>=g.x+g.width)return"gutter-after";break;case q:if(h.y<g.y)return"gutter-before";else if(h.y>=g.y+g.height)return"gutter-after";break;default:o.error("unknown layout direction");break}o.error("_segmentForMouseEvent: point ",h," outside view with handle frame ",g," and client frame ",j);return null},adjustFrame:function(){var h=this.frame;this.set("layout",{left:0,top:0,width:h.width,height:h.height})},drawRect:function(h,j){if(this._isVisible){var g=this._isHighlighted();h=this.editor.themeData.scroller;
var p=g?h.fullAlpha:h.particalAlpha,r=this.frame;j.clearRect(0,0,r.width,r.height);j.save();r=this.padding;j.translate(r.left,r.top);this._getHandleFrame();r=this._getGutterLength();var z=this._getClientThickness(),C=z/2,e=this.layoutDirection,K=this._getHandleOffset()+15,M=this._getHandleLength();if(e===q){j.translate(z+1,0);j.rotate(Math.PI*0.5)}if(!(r<=M)){j.globalAlpha=p;if(g){g=this._getClientLength();j.fillStyle=h.trackFillStyle;j.fillRect(8.5,0.5,g-16,z-1);j.strokeStyle=h.trackStrokeStyle;
j.strokeRect(8.5,0.5,g-16,z-1)}g=function(){j.beginPath();j.arc(K+C+0.5,C,C-0.5,Math.PI/2,3*Math.PI/2,false);j.arc(K+M-C-0.5,C,C-0.5,3*Math.PI/2,Math.PI/2,false);j.lineTo(K+C+0.5,z-0.5);j.closePath()};g();r=j.createLinearGradient(K,0,K,z);r.addColorStop(0,h.barFillGradientTopStart);r.addColorStop(0.4,h.barFillGradientTopStop);r.addColorStop(0.41,h.barFillStyle);r.addColorStop(0.8,h.barFillGradientBottomStart);r.addColorStop(1,h.barFillGradientBottomStop);j.fillStyle=r;j.fill();j.save();j.clip();j.fillStyle=
h.barFillStyle;j.beginPath();j.moveTo(K+C*0.4,C*0.6);j.lineTo(K+C*0.9,z*0.4);j.lineTo(K,z*0.4);j.closePath();j.fill();j.beginPath();j.moveTo(K+M-C*0.4,0+C*0.6);j.lineTo(K+M-C*0.9,0+z*0.4);j.lineTo(K+M,0+z*0.4);j.closePath();j.fill();j.restore();j.save();g();j.strokeStyle=h.trackStrokeStyle;j.stroke();j.restore();this._drawNibs(j,p);j.restore()}}},_repeatAction:function(h,j){if(h()!==false){var g=function(){this._repeatAction(h,100)}.bind(this);this._scrollTimer=setTimeout(g,j)}},_scrollByDelta:function(h){this.value=
this._value+h},_scrollUpOneLine:function(){this._scrollByDelta(-this.lineHeight);return true},_scrollDownOneLine:function(){this._scrollByDelta(this.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(h){this._mouseEventPosition=
h;this._mouseOverHandle=false;this._getGutterLength();switch(this._segmentForMouseEvent(h)){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:o.error("_segmentForMouseEvent returned an unknown value");break}switch(this.layoutDirection){case f:this._mouseDownScreenPoint=
h.pageX;break;case q:this._mouseDownScreenPoint=h.pageY;break;default:o.error("unknown layout direction");break}},mouseMove:function(h){if(this._mouseDownScreenPoint!==null){if(this._segmentForMouseEvent(h)=="handle"||this._mouseOverHandle===true){this._mouseOverHandle=true;if(this._scrollTimer!==null){clearTimeout(this._scrollTimer);this._scrollTimer=null}var j;switch(this.layoutDirection){case f:j=h.pageX;break;case q:j=h.pageY;break;default:o.error("unknown layout direction");break}var g=j-this._mouseDownScreenPoint,
p=this._maximum,r=this._value,z=this._getGutterLength(),C=this._getHandleLength();this.value=r+p*g/(z-C);this._mouseDownScreenPoint=j}this._mouseEventPosition=h}},mouseEntered:function(){this._isMouseOver=true;this.invalidate()},mouseExited:function(){this._isMouseOver=false;this.invalidate()},mouseUp:function(){this._mouseDownValue=this._mouseDownScreenPoint=null;if(this._scrollTimer){clearTimeout(this._scrollTimer);this._scrollTimer=null}this.invalidate()}});Object.defineProperties(u.ScrollerCanvasView.prototype,
{isVisible:{set:function(h){if(this._isVisible!==h){this._isVisible=h;this.domNode.style.display=h?"block":"none";h&&this.invalidate()}}},maximum:{set:function(h){if(this._value>this._maximum)this._value=this._maximum;if(h!==this._maximum){this._maximum=h;this.invalidate()}}},value:{set:function(h){if(h<0)h=0;else if(h>this._maximum)h=this._maximum;if(h!==this._value){this._value=h;this.valueChanged(h);this.invalidate()}}}})});
bespin.tiki.module("text_editor:views/text",function(y,u){var v=y("bespin:plugins").catalog,s=y("bespin:util/util"),o=y("events").Event,k=y("views/canvas").CanvasView;y("controllers/layoutmanager");var b=y("rangeutils:utils/range"),f=y("utils/rect"),q=y("views/textinput").TextInput,h=y("bespin:console").console,j=y("settings").settings;u.TextView=function(g,p){k.call(this,g,true);this.editor=p;this.padding={top:0,bottom:30,left:0,right:30};this.clippingChanged.add(this.clippingFrameChanged.bind(this));
var r=this.domNode;r.style.cursor="text";r.addEventListener("click",this.click.bind(this),false);r.addEventListener("mousedown",this.mouseDown.bind(this),false);r.addEventListener("mousemove",this.mouseMove.bind(this),false);window.addEventListener("mouseup",this.mouseUp.bind(this),false);p.willChangeBuffer.add(this.editorWillChangeBuffer.bind(this));this.selectionChanged=new o;this.beganChangeGroup=new o;this.endedChangeGroup=new o;this.willReplaceRange=new o;this.replacedCharacters=new o;this.textInput=
new q(g,this)};u.TextView.prototype=new k;s.mixin(u.TextView.prototype,{_dragPoint:null,_dragTimer:null,_enclosingScrollView:null,_inChangeGroup:false,_insertionPointBlinkTimer:null,_insertionPointVisible:true,_keyBuffer:"",_keyMetaBuffer:"",_keyState:"start",_hasFocus:false,_mouseIsDown:false,selectionChanged:null,beganChangeGroup:null,endedChangeGroup:null,willReplaceRange:null,replacedCharacters:null,editorWillChangeBuffer:function(g){if(this.editor.layoutManager){var p=this.editor.layoutManager;
p.invalidatedRects.remove(this);p.changedTextAtRow.remove(this)}p=g.layoutManager;p.invalidatedRects.add(this,this.layoutManagerInvalidatedRects.bind(this));p.changedTextAtRow.add(this,this.layoutManagerChangedTextAtRow.bind(this))},didFocus:function(){this._setFocus(true,true)},didBlur:function(){this._setFocus(false,true)},_drag:function(){var g=this._dragPoint,p=f.offsetFromRect(this.clippingFrame,g);this.moveCursorTo(this._selectionPositionForPoint({x:g.x-p.x,y:g.y-p.y}),true)},_drawInsertionPoint:function(g,
p){if(this._insertionPointVisible){var r=this.editor.layoutManager.characterRectForPosition(this.editor.buffer._selectedRange.start);g=Math.floor(r.x);var z=r.y,C=Math.ceil(r.width);r=r.height;p.save();var e=this.editor.themeData.editor;if(this._hasFocus){p.strokeStyle=e.cursorColor;p.beginPath();p.moveTo(g+0.5,z);p.lineTo(g+0.5,z+r);p.closePath();p.stroke()}else{p.fillStyle=e.unfocusedCursorBackgroundColor;p.fillRect(g+0.5,z,C-0.5,r);p.strokeStyle=e.unfocusedCursorColor;p.strokeRect(g+0.5,z+0.5,
C-1,r-1)}p.restore()}},_drawLines:function(g,p){var r=this.editor,z=r.layoutManager,C=z.textLines,e=z.fontDimension.lineAscent,K=r.themeData;r=K.highlighterFG;K=K.highlighterBG;p.save();p.font=this.editor.font;var M=z.characterRangeForBoundingRect(g),l=M.start;M=M.end;for(var w=M.row,D=l.row;D<=w;D++){var H=C[D];if(!s.none(H)){var R=H.characters,W=R.length,$=Math.min(M.col,W);g=l.col;if(!(g>=W)){H=H.colors;if(H==null)H=[];for(W=0;W<H.length&&g<H[W].start;)W++;for(var ea=W<H.length?H[W].start:g;ea<
$;){g=H[W];var Y=g!=null?g.end:$,da=g!=null?g.tag:"plain";g=z.characterRectForPosition({row:D,col:ea});if(K.hasOwnProperty(da)){var ia=z.characterRectForPosition({row:D,col:Y-1});p.fillStyle=K[da];p.fillRect(g.x,g.y,ia.x-g.x+ia.width,ia.height)}da=r.hasOwnProperty(da)?r[da]:"red";ea=R.substring(ea,Y);p.fillStyle=da;p.fillText(ea,g.x,g.y+e);ea=Y;W++}}}}p.restore()},_drawSelectionHighlight:function(g,p){g=this.editor.themeData.editor;g=this._hasFocus?g.selectedTextBackgroundColor:g.unfocusedCursorBackgroundColor;
var r=this.editor.layoutManager;p.save();var z=b.normalizeRange(this.editor.buffer._selectedRange);p.fillStyle=g;r.rectsForRange(z).forEach(function(C){p.fillRect(C.x,C.y,C.width,C.height)});p.restore()},_drawSelection:function(g,p){this._rangeIsInsertionPoint(this.editor.buffer._selectedRange)?this._drawInsertionPoint(g,p):this._drawSelectionHighlight(g,p)},_getVirtualSelection:function(g){var p=this.editor.buffer._selectedRange,r=this.editor.buffer._selectedRangeEndVirtual;return{start:g&&r?r:p.start,
end:r||p.end}},_invalidateSelection:function(){var g=function(z){return{x:z.x-1,y:z.y,width:z.width+2,height:z.height}},p=this.editor.layoutManager,r=b.normalizeRange(this.editor.buffer._selectedRange);if(this._rangeIsInsertionPoint(r)){p=p.characterRectForPosition(r.start);this.invalidateRect(g(p))}else p.rectsForRange(r).forEach(function(z){this.invalidateRect(g(z))},this)},_isReadOnly:function(){return this.editor.layoutManager.textStorage.readOnly},_keymappingChanged:function(){this._keyBuffer=
"";this._keyState="start"},_performVerticalKeyboardSelection:function(g){var p=this.editor.buffer._selectedRangeEndVirtual;this.moveCursorTo(b.addPositions(p!==null?p:this.editor.buffer._selectedRange.end,{row:g,col:0}),true,true)},_rangeIsInsertionPoint:function(g){return b.isZeroLength(g)},_rearmInsertionPointBlinkTimer:function(){this._insertionPointVisible||this.blinkInsertionPoint();this._insertionPointBlinkTimer!==null&&clearInterval(this._insertionPointBlinkTimer);this._insertionPointBlinkTimer=
setInterval(this.blinkInsertionPoint.bind(this),750)},_repositionSelection:function(){var g=this.editor.layoutManager.textLines,p=g.length,r=this.editor.buffer._selectedRange,z=Math.min(r.start.row,p-1);p=Math.min(r.end.row,p-1);var C=g[p];this.setSelection({start:{row:z,col:Math.min(r.start.col,g[z].characters.length)},end:{row:p,col:Math.min(r.end.col,C.characters.length)}})},_scrollPage:function(g){this.editor.scrollBy(0,(this.clippingFrame.height+this.editor.layoutManager.fontDimension.lineAscent)*
(g?-1:1))},_scrollWhileDragging:function(){var g=this._dragPoint;g=this.computeWithClippingFrame(g.layerX,g.layerY);s.mixin(this._dragPoint,g);this._drag()},_selectionPositionForPoint:function(g){g=this.editor.layoutManager.characterAtPoint(g);return g.partialFraction<0.5?g:b.addPositions(g,{row:0,col:1})},_syntaxManagerUpdatedSyntaxForRows:function(g,p){if(g!==p){var r=this.editor.layoutManager;r.updateTextRows(g,p);r.rectsForRange({start:{row:g,col:0},end:{row:p,col:0}}).forEach(this.invalidateRect,
this)}},blinkInsertionPoint:function(){this._insertionPointVisible=!this._insertionPointVisible;this._invalidateSelection()},copy:function(){return this.getSelectedCharacters()},cut:function(){var g=this.getSelectedCharacters();g!=""&&this.performBackspaceOrDelete(false);return g},click:function(){this.focus()},drawRect:function(g,p){p.fillStyle=this.editor.themeData.editor.backgroundColor;p.fillRect(g.x,g.y,g.width,g.height);this._drawSelection(g,p);this._drawLines(g,p)},focus:function(){this.textInput.focus()},
getInsertionPointPosition:function(){var g=this.editor;g=g.layoutManager.characterRectForPosition(g.buffer._selectedRange.start);return{x:g.x,y:g.y}},getSelectedCharacters:function(){return this._rangeIsInsertionPoint(this.editor.buffer._selectedRange)?"":this.editor.layoutManager.textStorage.getCharacters(b.normalizeRange(this.editor.buffer._selectedRange))},getSelectedRange:function(g){return g?this.editor.buffer._selectedRange:b.normalizeRange(this.editor.buffer._selectedRange)},groupChanges:function(g){if(this._isReadOnly())return false;
if(this._inChangeGroup){g();return true}this._inChangeGroup=true;this.beganChangeGroup(this,this.editor.buffer._selectedRange);try{g()}catch(p){h.error("Error in groupChanges(): "+p);this._inChangeGroup=false;this.endedChangeGroup(this,this.editor.buffer._selectedRange);return false}finally{this._inChangeGroup=false;this.endedChangeGroup(this,this.editor.buffer._selectedRange);return true}},insertText:function(g){if(this._isReadOnly())return false;this.groupChanges(function(){var p=b.normalizeRange(this.editor.buffer._selectedRange);
this.replaceCharacters(p,g);var r=g.split("\n");this.moveCursorTo(r.length>1?{row:p.start.row+r.length-1,col:r[r.length-1].length}:b.addPositions(p.start,{row:0,col:g.length}))}.bind(this));return true},isDelimiter:function(g){return"\"',;.!~@#$%^&*?[]<>():/\\-+ \t".indexOf(g)!==-1},keyDown:function(g){if(g.charCode===0||g._charCode===0)return this.editor.processKeyEvent(g,this,{isTextView:true});else if(g.keyCode===9)g.preventDefault();else return false},layoutManagerChangedTextAtRow:function(){this._repositionSelection()},
layoutManagerInvalidatedRects:function(g,p){p.forEach(this.invalidateRect,this)},mouseDown:function(g){this._mouseIsDown=this.hasFocus=true;var p=this.computeWithClippingFrame(g.layerX,g.layerY);s.mixin(p,{layerX:g.layerX,layerY:g.layerY});switch(g.detail){case 1:var r=this._selectionPositionForPoint(p);this.moveCursorTo(r,g.shiftKey);break;case 2:r=this._selectionPositionForPoint(p);var z=this.editor.layoutManager.textStorage.lines[r.row];if(z.length===0)return true;r.col-=r.col==z.length?1:0;var C=
!this.isDelimiter(z[r.col]),e=this,K=function(M,l){for(;M>-1&&M<z.length;M+=l)if(e.isDelimiter(z[M])===C)break;return M+(l==1?0:1)};g=K(r.col,-1);K=K(r.col,1);this.moveCursorTo({row:r.row,col:g});this.moveCursorTo({row:r.row,col:K},true);break;case 3:g=this.editor.layoutManager.textStorage.lines;r=this._selectionPositionForPoint(p);this.setSelection({start:{row:r.row,col:0},end:{row:r.row,col:g[r.row].length}});break}this._dragPoint=p;this._dragTimer=setInterval(this._scrollWhileDragging.bind(this),
100)},mouseMove:function(g){if(this._mouseIsDown){this._dragPoint=this.computeWithClippingFrame(g.layerX,g.layerY);s.mixin(this._dragPoint,{layerX:g.layerX,layerY:g.layerY});this._drag()}},mouseUp:function(){this._mouseIsDown=false;if(this._dragTimer!==null){clearInterval(this._dragTimer);this._dragTimer=null}},moveCursorTo:function(g,p,r){var z=this.editor.layoutManager.textStorage,C=z.clampPosition(g);this.setSelection({start:p?this.editor.buffer._selectedRange.start:C,end:C});if(r){p=z.lines.length;
r=g.row;z=g.col;this.editor.buffer._selectedRangeEndVirtual=r>0&&r<p?g:{row:r<1?0:p-1,col:z}}else this.editor.buffer._selectedRangeEndVirtual=null;this.scrollToPosition(this.editor.buffer._selectedRange.end)},moveDown:function(){var g=this._getVirtualSelection();g=b.normalizeRange(g);g=this._rangeIsInsertionPoint(this.editor.buffer._selectedRange)?g.end:{row:g.end.row,col:g.start.col};g=b.addPositions(g,{row:1,col:0});this.moveCursorTo(g,false,true)},moveLeft:function(){var g=b.normalizeRange(this.editor.buffer._selectedRange);
this._rangeIsInsertionPoint(g)?this.moveCursorTo(this.editor.layoutManager.textStorage.displacePosition(g.start,-1)):this.moveCursorTo(g.start)},moveRight:function(){var g=b.normalizeRange(this.editor.buffer._selectedRange);this._rangeIsInsertionPoint(g)?this.moveCursorTo(this.editor.layoutManager.textStorage.displacePosition(g.end,1)):this.moveCursorTo(g.end)},moveUp:function(){var g=b.normalizeRange(this._getVirtualSelection(true));position=b.addPositions({row:g.start.row,col:this._getVirtualSelection().end.col},
{row:-1,col:0});this.moveCursorTo(position,false,true)},parentViewFrameChanged:function(){arguments.callee.base.apply(this,arguments);this._resize()},replaceCharacters:function(g,p){if(this._isReadOnly())return false;this.groupChanges(function(){g=b.normalizeRange(g);this.willReplaceRange(this,g);this.editor.layoutManager.textStorage.replaceCharacters(g,p);this.replacedCharacters(this,g,p)}.bind(this));return true},performBackspaceOrDelete:function(g){if(this._isReadOnly())return false;var p=this.editor.layoutManager.textStorage,
r=p.lines,z="";z=0;var C=j.get("tabstop"),e=this.getSelectedRange();if(b.isZeroLength(e))if(g){g=e.start;z=r[g.row];z=z.substring(0,g.col).match(/\s*$/)[0].length<C||(g.col-C)%C!=0?1:C;e={start:p.displacePosition(g,z*-1),end:e.end}}else{g=e.end;z=r[g.row];z=z.substring(g.col).match(/^\s*/)[0].length<C?1:C;e={start:e.start,end:p.displacePosition(e.end,z)}}this.groupChanges(function(){this.replaceCharacters(e,"");this.moveCursorTo(e.start)}.bind(this));return true},resetKeyBuffers:function(){this._keyMetaBuffer=
this._keyBuffer=""},scrollPageDown:function(){this._scrollPage(false)},scrollPageUp:function(){this._scrollPage(true)},scrollToPosition:function(g){var p=this.editor.layoutManager.characterRectForPosition(g);g=p.x;var r=p.y,z=p.width;p=p.height;var C=this.clippingFrame,e=C.x,K=C.y,M=this.padding,l=C.width-M.right;C=C.height-M.bottom;this.editor.scrollTo({x:g>=e+30&&g+z<e+l?e:g-l/2+z/2,y:r>=K&&r+p<K+C?K:r-C/2+p/2})},selectAll:function(){var g=this.editor.layoutManager.textStorage.lines,p=g.length-
1;this.setSelection({start:{row:0,col:0},end:{row:p,col:g[p].length}})},selectDown:function(){this._performVerticalKeyboardSelection(1)},selectLeft:function(){this.moveCursorTo(this.editor.layoutManager.textStorage.displacePosition(this.editor.buffer._selectedRange.end,-1),true)},selectRight:function(){this.moveCursorTo(this.editor.layoutManager.textStorage.displacePosition(this.editor.buffer._selectedRange.end,1),true)},selectUp:function(){this._performVerticalKeyboardSelection(-1)},setSelection:function(g,
p){var r=this.editor.layoutManager.textStorage;g=r.clampRange(g);if(!b.equal(g,this.editor.buffer._selectedRange)){this._invalidateSelection();this.editor.buffer._selectedRange=g=r.clampRange(g);this._invalidateSelection();this._hasFocus&&this._rearmInsertionPointBlinkTimer();p&&this.scrollToPosition(g.end);this.selectionChanged(g);v.publish(this.editor,"editorChange","selection",g)}},textInserted:function(g){if(g!=="\n")if(!this.editor.processKeyEvent(g,this,{isTextView:true,isCommandKey:false})){this.insertText(g);
this.resetKeyBuffers()}},_setFocus:function(g,p){if(g!=this._hasFocus)if(this._hasFocus=g){this._rearmInsertionPointBlinkTimer();this._invalidateSelection();p||this.textInput.focus()}else{if(this._insertionPointBlinkTimer){clearInterval(this._insertionPointBlinkTimer);this._insertionPointBlinkTimer=null}this._insertionPointVisible=true;this._invalidateSelection();p||this.textInput.blur()}}});Object.defineProperties(u.TextView.prototype,{hasFocus:{get:function(){return this._hasFocus},set:function(g){this._setFocus(g,
false)}}})});
bespin.tiki.module("text_editor:views/textinput",function(y,u){var v=y("bespin:util/util");y("events");var s=y("rangeutils:utils/range"),o=y("keyboard:keyutil");u.TextInput=function(k,b){var f=this.domNode=document.createElement("textarea");f.setAttribute("style","position: absolute; z-index: -99999; width: 0px; height: 0px; margin: 0px; outline: none; border: 0;");k.appendChild(f);this.delegate=b;this._attachEvents()};u.TextInput.prototype={_composing:false,domNode:null,delegate:null,_textFieldChanged:function(){if(!(this._composing||
this._ignore)){var k=this.domNode,b=k.value;if(b!=""){k.value="";this._textInserted(b)}}},_copy:function(){var k=false,b=this.delegate;if(b&&b.copy)k=b.copy();return k},_cut:function(){var k=false,b=this.delegate;if(b&&b.cut)k=b.cut();return k},_textInserted:function(k){var b=this.delegate;b&&b.textInserted&&b.textInserted(k)},_setValueAndSelect:function(k){var b=this.domNode;b.value=k;b.select()},focus:function(){this.domNode.focus()},blur:function(){this.domNode.blur()},_attachEvents:function(){var k=
this.domNode,b=this;k.addEventListener("focus",function(){b.delegate&&b.delegate.didFocus&&b.delegate.didFocus()},false);k.addEventListener("blur",function(){b.delegate&&b.delegate.didBlur&&b.delegate.didBlur()},false);o.addKeyDownListener(k,function(j){return b.delegate&&b.delegate.keyDown?b.delegate.keyDown(j):false});if(v.isWebKit){v.isChrome||k.addEventListener("compositionend",function(j){b._textInserted(j.data)},false);k.addEventListener("textInput",function(j){b._textInserted(j.data)},false);
k.addEventListener("paste",function(j){b._textInserted(j.clipboardData.getData("text/plain"));j.preventDefault()},false)}else{k.addEventListener("input",function(){b._textFieldChanged()},false);k.addEventListener("compositionstart",function(){b._composing=true},false);k.addEventListener("compositionend",function(){b._composing=false;b._textFieldChanged()},false);k.addEventListener("paste",function(){b._setValueAndSelect("");window.setTimeout(function(){b._textFieldChanged()},0)},false);this.delegate.selectionChanged.add(function(j){if(s.isZeroLength(j))wasSelection=
false;else{k.value="z";k.select();wasSelection=true}}.bind(this))}var f=function(j){j=j.type.indexOf("copy")!=-1?b._copy():b._cut();b._setValueAndSelect(j)};if(v.isWebKit&&!v.isChrome&&v.isMac){var q=(new Date).getTime(),h=function(j){var g=j.type.indexOf("cut")!=-1;if(!(g&&(new Date).getTime()-q<10)){f(j);if(g)q=(new Date).getTime()}};k.addEventListener("beforecopy",h,false);k.addEventListener("beforecut",h,false)}else{h=false;if(v.isMozilla)h=function(j){f(j);b._ignore=true;window.setTimeout(function(){b._setValueAndSelect("");
b._ignore=false},0)};k.addEventListener("copy",h||f,false);k.addEventListener("cut",h||f,false)}}}});bespin.tiki.module("text_editor:index",function(){});bespin.tiki.register("::less",{name:"less",dependencies:{}});
bespin.tiki.module("less:index",function(y,u){function v(b){if(b instanceof k.Dimension)return parseFloat(b.unit=="%"?b.value/100:b.value);else if(typeof b==="number")return b;else throw{error:"RuntimeError",message:"color functions take numbers as parameters"};}function s(b){return Math.min(1,Math.max(0,b))}if(!Array.isArray)Array.isArray=function(b){return Object.prototype.toString.call(b)==="[object Array]"||b instanceof Array};if(!Array.prototype.forEach)Array.prototype.forEach=function(b,f){for(var q=
this.length>>>0,h=0;h<q;h++)h in this&&b.call(f,this[h],h,this)};if(!Array.prototype.map)Array.prototype.map=function(b,f){for(var q=this.length>>>0,h=new Array(q),j=0;j<q;j++)if(j in this)h[j]=b.call(f,this[j],j,this);return h};if(!Array.prototype.filter)Array.prototype.filter=function(b,f){for(var q=[],h=0;h<this.length;h++)b.call(f,this[h])&&q.push(this[h]);return q};if(!Array.prototype.reduce)Array.prototype.reduce=function(b){var f=this.length>>>0,q=0;if(f===0&&arguments.length===1)throw new TypeError;
if(arguments.length>=2)var h=arguments[1];else{do{if(q in this){h=this[q++];break}if(++q>=f)throw new TypeError;}while(1)}for(;q<f;q++)if(q in this)h=b.call(null,h,this[q],q,this);return h};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(b,f){var q=this.length;f=f||0;if(!q)return-1;if(f>=q)return-1;if(f<0)f+=q;for(;f<q;f++)if(Object.prototype.hasOwnProperty.call(this,f))if(b===this[f])return f;return-1};if(!Object.keys)Object.keys=function(b){var f=[];for(var q in b)Object.prototype.hasOwnProperty.call(b,
q)&&f.push(q);return f};if(!String.prototype.trim)String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")};if(typeof y!=="undefined")var o=u,k={};else o=k={};o.Parser=function(b){function f(l){var w,D,H;if(l instanceof Function)return l.call(C.parsers);else if(typeof l==="string"){w=h.charAt(j)===l?l:null;D=1}else{if(j>=z+r[g].length&&g<r.length-1)z+=r[g++].length;l.lastIndex=H=j-z;if(w=l.exec(r[g])){D=w[0].length;if(l.lastIndex-D!==H)return}}if(w){j+=D;for(D=
z+r[g].length;j<=D;){l=h.charCodeAt(j);if(!(l===32||l===10||l===9))break;j++}return typeof w==="string"?w:w.length===1?w[0]:w}}function q(l){var w;if(typeof l==="string")return h.charAt(j)===l;else{l.lastIndex=j;if((w=l.exec(h))&&l.lastIndex-w[0].length===j)return w}}var h,j,g,p,r,z,C,e=this,K=function(){},M=this.imports={paths:b&&b.paths||[],queue:[],files:{},push:function(l,w){var D=this;this.queue.push(l);o.Parser.importer(l,this.paths,function(H){D.queue.splice(D.queue.indexOf(l),1);D.files[l]=
H;w(H);D.queue.length===0&&K()})}};this.env=b||{};this.optimization="optimization"in this.env?this.env.optimization:1;return C={imports:M,parse:function(l,w){var D,H,R=null;j=g=z=p=0;r=[];h=l.replace(/\r\n/g,"\n");if(e.optimization>0){h=h.replace(/\/\*(?:[^*]|\*+[^\/*])*\*+\//g,function(ea){return e.optimization>1?"":ea.replace(/\n(\s*\n)+/g,"\n")});r=h.split(/^(?=\n)/mg)}else r=[h];D=new k.Ruleset([],f(this.parsers.primary));D.root=true;D.toCSS=function(ea){var Y,da;return function(){try{return ea.call(this)}catch(ia){da=
h.split("\n");Y=(h.slice(0,ia.index).match(/\n/g)||"").length+1;for(var ma=ia.index,na=-1;ma>=0&&h.charAt(ma)!=="\n";ma--)na++;throw{name:"NameError",message:ia.message,line:Y,column:na,extract:[da[Y-2],da[Y-1],da[Y]]};}}}(D.toCSS);if(j<h.length-1){j=p;H=h.split("\n");l=(h.slice(0,j).match(/\n/g)||"").length+1;for(var W=j,$=-1;W>=0&&h.charAt(W)!=="\n";W--)$++;R={name:"ParseError",message:"Syntax Error on line "+l,filename:b.filename,line:l,column:$,extract:[H[l-2],H[l-1],H[l]]}}if(this.imports.queue.length>
0)K=function(){w(R,D)};else w(R,D)},parsers:{primary:function(){for(var l,w=[];l=f(this.mixin.definition)||f(this.rule)||f(this.ruleset)||f(this.mixin.call)||f(this.comment)||f(/[\n\s]+/g)||f(this.directive);)w.push(l);return w},comment:function(){var l;if(h.charAt(j)==="/")return(l=f(/\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/g))?new k.Comment(l):f(/\/\/.*/g)},entities:{quoted:function(){var l;if(!(h.charAt(j)!=='"'&&h.charAt(j)!=="'"))if(l=f(/"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/g))return new k.Quoted(l[0],
l[1]||l[2])},keyword:function(){var l;if(l=f(/[A-Za-z-]+/g))return new k.Keyword(l)},call:function(){var l,w;if(l=f(/([a-zA-Z0-9_-]+|%)\(/g)){if(l[1].toLowerCase()==="alpha")return f(this.alpha);w=f(this.entities.arguments);if(f(")"))if(l)return new k.Call(l[1],w)}},arguments:function(){for(var l=[],w;w=f(this.expression);){l.push(w);if(!f(","))break}return l},literal:function(){return f(this.entities.dimension)||f(this.entities.color)||f(this.entities.quoted)},url:function(){var l;if(!(h.charAt(j)!==
"u"||!f(/url\(/g))){l=f(this.entities.quoted)||f(/[-a-zA-Z0-9_%@$\/.&=:;#+?]+/g);if(!f(")"))throw new Error("missing closing ) for url()");return new k.URL(l.value?l:new k.Anonymous(l))}},variable:function(){var l,w=j;if(h.charAt(j)==="@"&&(l=f(/@[a-zA-Z0-9_-]+/g)))return new k.Variable(l,w)},color:function(){var l;if(h.charAt(j)==="#"&&(l=f(/#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/g)))return new k.Color(l[1])},dimension:function(){var l;l=h.charCodeAt(j);if(!(l>57||l<45||l===47))if(l=f(/(-?[0-9]*\.?[0-9]+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm)?/g))return new k.Dimension(l[1],
l[2])}},variable:function(){var l;if(h.charAt(j)==="@"&&(l=f(/(@[a-zA-Z0-9_-]+)\s*:/g)))return l[1]},shorthand:function(){var l,w;if(q(/[@\w.-]+\/[@\w.-]+/g))if((l=f(this.entity))&&f("/")&&(w=f(this.entity)))return new k.Shorthand(l,w)},mixin:{call:function(){for(var l=[],w,D,H,R=j;w=f(/[#.][a-zA-Z0-9_-]+/g);){l.push(new k.Element(D,w));D=f(">")}f("(")&&(H=f(this.entities.arguments))&&f(")");if(l.length>0&&(f(";")||q("}")))return new k.mixin.Call(l,H,R)},definition:function(){var l,w=[],D,H;if(!(h.charAt(j)!==
"."||q(/[^{]*(;|})/g)))if(l=f(/([#.][a-zA-Z0-9_-]+)\s*\(/g)){for(l=l[1];D=f(/@[\w-]+/g)||f(this.entities.literal)||f(this.entities.keyword);){if(D[0]==="@")if(f(":"))if(H=f(this.expression))w.push({name:D,value:H});else throw new Error("Expected value");else w.push({name:D});else w.push({value:D});if(!f(","))break}if(!f(")"))throw new Error("Expected )");if(D=f(this.block))return new k.mixin.Definition(l,w,D)}}},entity:function(){return f(this.entities.literal)||f(this.entities.variable)||f(this.entities.url)||
f(this.entities.call)||f(this.entities.keyword)},end:function(){return f(";")||q("}")},alpha:function(){var l;if(f(/opacity=/gi))if(l=f(/[0-9]+/g)||f(this.entities.variable)){if(!f(")"))throw new Error("missing closing ) for alpha()");return new k.Alpha(l)}},element:function(){var l;c=f(this.combinator);if(l=f(/[.#:]?[a-zA-Z0-9_-]+/g)||f("*")||f(this.attribute)||f(/\([^)@]+\)/g))return new k.Element(c,l)},combinator:function(){var l;return(l=f(/[+>~]/g)||f("&")||f(/::/g))?new k.Combinator(l):new k.Combinator(h.charAt(j-
1)===" "?" ":null)},selector:function(){for(var l,w=[];l=f(this.element);)w.push(l);if(w.length>0)return new k.Selector(w)},tag:function(){return f(/[a-zA-Z][a-zA-Z-]*[0-9]?/g)||f("*")},attribute:function(){var l="",w,D,H;if(f("[")){if(w=f(/[a-z-]+/g)||f(this.entities.quoted))l=(H=f(/[|~*$^]?=/g))&&(D=f(this.entities.quoted)||f(/[\w-]+/g))?[w,H,D.toCSS?D.toCSS():D].join(""):w;if(f("]"))if(l)return"["+l+"]"}},block:function(){var l;if(f("{")&&(l=f(this.primary))&&f("}"))return l},ruleset:function(){var l=
[],w,D,H=j;if(w=q(/([a-z.#: _-]+)[\s\n]*\{/g)){j+=w[0].length-1;l=[new k.Selector([new k.Element(null,w[1])])]}else{for(;w=f(this.selector);){l.push(w);if(!f(","))break}w&&f(this.comment)}if(l.length>0&&(D=f(this.block)))return new k.Ruleset(l,D);else{p=j;j=H}},rule:function(){var l,w=j;if(name=f(this.property)||f(this.variable)){if(name.charAt(0)!="@"&&(match=q(/([^@+\/*(;{}-]*);/g))){j+=match[0].length-1;l=new k.Anonymous(match[1])}else l=name==="font"?f(this.font):f(this.value);if(f(this.end))return new k.Rule(name,
l,w);else{p=j;j=w}}},"import":function(){var l;if(f(/@import\s+/g)&&(l=f(this.entities.quoted)||f(this.entities.url))&&f(";"))return new k.Import(l,M)},directive:function(){var l,w,D;if(h.charAt(j)==="@")if(w=f(this["import"]))return w;else if(l=f(/@media|@page/g)){D=f(/[^{]+/g).trim();if(w=f(this.block))return new k.Directive(l+" "+D,w)}else if(l=f(/@[-a-z]+/g))if(l==="@font-face"){if(w=f(this.block))return new k.Directive(l,w)}else if((w=f(this.entity))&&f(";"))return new k.Directive(l,w)},font:function(){for(var l=
[],w=[],D;D=f(this.shorthand)||f(this.entity);)w.push(D);l.push(new k.Expression(w));if(f(","))for(;D=f(this.expression);){l.push(D);if(!f(","))break}return new k.Value(l,f(this.important))},value:function(){for(var l,w=[];l=f(this.expression);){w.push(l);if(!f(","))break}l=f(this.important);if(w.length>0)return new k.Value(w,l)},important:function(){return f(/!\s*important/g)},sub:function(){var l;if(f("(")&&(l=f(this.expression))&&f(")"))return l},multiplication:function(){var l,w,D,H;if(l=f(this.operand)){for(;(D=
f(/[\/*]/g))&&(w=f(this.operand));)H=new k.Operation(D,[H||l,w]);return H||l}},addition:function(){var l,w,D,H;if(l=f(this.multiplication)){for(;(D=f(/[-+]\s+/g)||h.charAt(j-1)!=" "&&f(/[-+]/g))&&(w=f(this.multiplication));)H=new k.Operation(D,[H||l,w]);return H||l}},operand:function(){return f(this.sub)||f(this.entities.dimension)||f(this.entities.color)||f(this.entities.variable)},expression:function(){for(var l,w=[];l=f(this.addition)||f(this.entity);)w.push(l);if(w.length>0)return new k.Expression(w)},
property:function(){var l;if(l=f(/(\*?-?[-a-z_0-9]+)\s*:/g))return l[1]}}}};o.Parser.importer=null;k.functions={rgb:function(b,f,q){return this.rgba(b,f,q,1)},rgba:function(b,f,q,h){b=[b,f,q].map(function(j){return v(j)});h=v(h);return new k.Color(b,h)},hsl:function(b,f,q){return this.hsla(b,f,q,1)},hsla:function(b,f,q,h){function j(r){r=r<0?r+1:r>1?r-1:r;return r*6<1?p+(g-p)*r*6:r*2<1?g:r*3<2?p+(g-p)*(2/3-r)*6:p}b=(v(b)%360+360)%360/360;f=v(f);q=v(q);h=v(h);var g=q<=0.5?q*(f+1):q+f-q*f,p=q*2-g;return this.rgba(j(b+
1/3)*255,j(b)*255,j(b-1/3)*255,h)},opacity:function(b,f){v(f);return new k.Color(b.rgb,v(f))},saturate:function(b,f){b=b.toHSL();b.s+=f.value/100;b.s=s(b.s);return this.hsl(b.h,b.s,b.l)},desaturate:function(b,f){b=b.toHSL();b.s-=f.value/100;b.s=s(b.s);return this.hsl(b.h,b.s,b.l)},lighten:function(b,f){b=b.toHSL();b.l*=1+f.value/100;b.l=s(b.l);return this.hsl(b.h,b.s,b.l)},darken:function(b,f){b=b.toHSL();b.l*=1-f.value/100;b.l=s(b.l);return this.hsl(b.h,b.s,b.l)},greyscale:function(b){return this.desaturate(b,
new k.Dimension(100))},e:function(b){return new k.Anonymous(b)},"%":function(b){for(var f=Array.prototype.slice.call(arguments,1),q=b.content,h=0;h<f.length;h++)q=q.replace(/%s/,f[h].content).replace(/%[da]/,f[h].toCSS());q=q.replace(/%%/g,"%");return new k.Quoted('"'+q+'"',q)}};k.Alpha=function(b){this.value=b};k.Alpha.prototype={toCSS:function(){return"alpha(opacity="+this.value.toCSS()+")"},eval:function(){return this}};k.Anonymous=function(b){this.value=b.content||b};k.Anonymous.prototype={toCSS:function(){return this.value},
eval:function(){return this}};k.Call=function(b,f){this.name=b;this.args=f};k.Call.prototype={eval:function(b){var f=this.args.map(function(q){return q.eval(b)});return this.name in k.functions?k.functions[this.name].apply(k.functions,f):new k.Anonymous(this.name+"("+f.map(function(q){return q.toCSS()}).join(", ")+")")},toCSS:function(b){return this.eval(b).toCSS()}};k.Color=function(b,f){if(Array.isArray(b)){this.rgb=b;this.alpha=f}else this.rgb=b.length==6?b.match(/.{2}/g).map(function(q){return parseInt(q,
16)}):b.split("").map(function(q){return parseInt(q+q,16)})};k.Color.prototype={eval:function(){return this},toCSS:function(){return this.alpha&&this.alpha<1?"rgba("+this.rgb.concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(b){b=Math.round(b);b=(b>255?255:b<0?0:b).toString(16);return b.length===1?"0"+b:b}).join("")},operate:function(b,f){var q=[];f instanceof k.Color||(f=f.toColor());for(var h=0;h<3;h++)q[h]=k.operate(b,this.rgb[h],f.rgb[h]);return new k.Color(q)},toHSL:function(){var b=
this.rgb[0]/255,f=this.rgb[1]/255,q=this.rgb[2]/255,h=Math.max(b,f,q),j=Math.min(b,f,q),g,p=(h+j)/2,r=h-j;if(h===j)g=j=0;else{j=p>0.5?r/(2-h-j):r/(h+j);switch(h){case b:g=(f-q)/r+(f<q?6:0);break;case f:g=(q-b)/r+2;break;case q:g=(b-f)/r+4;break}g/=6}return{h:g*360,s:j,l:p}}};k.Comment=function(b){this.value=b};k.Comment.prototype={toCSS:function(){return this.value}};k.Dimension=function(b,f){this.value=parseFloat(b);this.unit=f||null};k.Dimension.prototype={eval:function(){return this},toColor:function(){return new k.Color([this.value,
this.value,this.value])},toCSS:function(){return this.value+this.unit},operate:function(b,f){return new k.Dimension(k.operate(b,this.value,f.value),this.unit||f.unit)}};k.Directive=function(b,f){this.name=b;if(Array.isArray(f))this.ruleset=new k.Ruleset([],f);else this.value=f};k.Directive.prototype={toCSS:function(b,f){if(this.ruleset){this.ruleset.root=true;return this.name+" {\n  "+this.ruleset.toCSS(b,f).trim().replace(/\n/g,"\n  ")+"\n}\n"}else return this.name+" "+this.value.toCSS()+";\n"},
eval:function(b){b.frames.unshift(this);this.ruleset&&this.ruleset.evalRules(b);b.frames.shift();return this},variable:function(b){return k.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return k.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return k.Ruleset.prototype.rulesets.apply(this.ruleset)}};k.Element=function(b,f){this.combinator=b instanceof k.Combinator?b:new k.Combinator(b);this.value=f.trim()};k.Element.prototype.toCSS=function(){return this.combinator.toCSS()+
this.value};k.Combinator=function(b){this.value=b===" "?" ":b?b.trim():""};k.Combinator.prototype.toCSS=function(){switch(this.value){case "":return"";case " ":return" ";case "&":return"";case ":":return" :";case "::":return"::";case "+":return" + ";case "~":return" ~ ";case ">":return" > "}};k.Expression=function(b){this.value=b};k.Expression.prototype={eval:function(b){return this.value.length>1?new k.Expression(this.value.map(function(f){return f.eval(b)})):this.value[0].eval(b)},toCSS:function(){return this.value.map(function(b){return b.toCSS()}).join(" ")}};
k.Import=function(b,f){var q=this;this._path=b;this.path=b instanceof k.Quoted?/\.(le?|c)ss$/.test(b.content)?b.content:b.content+".less":b.value.content||b.value;(this.css=/css$/.test(this.path))||f.push(this.path,function(h){q.root=h})};k.Import.prototype={toCSS:function(){return this.css?"@import "+this._path.toCSS()+";\n":""},eval:function(){if(this.css)return this;else{for(var b=0;b<this.root.rules.length;b++)this.root.rules[b]instanceof k.Import&&Array.prototype.splice.apply(this.root.rules,
[b,1].concat(this.root.rules[b].eval()));return this.root.rules}}};k.Keyword=function(b){this.value=b};k.Keyword.prototype={eval:function(){return this},toCSS:function(){return this.value}};k.mixin={};k.mixin.Call=function(b,f,q){this.selector=new k.Selector(b);this.arguments=f;this.index=q};k.mixin.Call.prototype={eval:function(b){for(var f,q=[],h=false,j=0;j<b.frames.length;j++)if((f=b.frames[j].find(this.selector)).length>0){for(j=0;j<f.length;j++)if(f[j].match(this.arguments,b))try{Array.prototype.push.apply(q,
f[j].eval(this.arguments,b).rules);h=true}catch(g){throw{message:g.message,index:this.index};}if(h)return q;else throw{message:"No matching definition was found for `"+this.selector.toCSS().trim()+"("+this.arguments.map(function(p){return p.toCSS()}).join(", ")+")`",index:this.index};}throw{message:this.selector.toCSS().trim()+" is undefined",index:this.index};}};k.mixin.Definition=function(b,f,q){this.name=b;this.selectors=[new k.Selector([new k.Element(null,b)])];this.params=f;this.arity=f.length;
this.rules=q;this._lookups={};this.required=f.reduce(function(h,j){return j.name&&!j.value?h+1:h},0)};k.mixin.Definition.prototype={toCSS:function(){return""},variable:function(b){return k.Ruleset.prototype.variable.call(this,b)},find:function(){return k.Ruleset.prototype.find.apply(this,arguments)},rulesets:function(){return k.Ruleset.prototype.rulesets.apply(this)},eval:function(b,f){for(var q=new k.Ruleset(null,[]),h=0,j;h<this.params.length;h++)if(this.params[h].name)if(j=b&&b[h]||this.params[h].value)q.rules.unshift(new k.Rule(this.params[h].name,
j.eval(f)));else throw{message:"wrong number of arguments for "+this.name+" ("+b.length+" for "+this.arity+")"};return(new k.Ruleset(null,this.rules)).evalRules({frames:[this,q].concat(f.frames)})},match:function(b,f){var q=b&&b.length||0;if(q<this.required)return false;for(var h=0;h<Math.min(q,this.arity);h++)if(!this.params[h].name)if(!b[h].wildcard)if(b[h].eval(f).toCSS()!=this.params[h].value.eval(f).toCSS())return false;return true}};k.Operation=function(b,f){this.op=b.trim();this.operands=f};
k.Operation.prototype.eval=function(b){var f=this.operands[0].eval(b);b=this.operands[1].eval(b);var q;if(f instanceof k.Dimension&&b instanceof k.Color)if(this.op==="*"||this.op==="+"){q=b;b=f;f=q}else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};return f.operate(this.op,b)};k.operate=function(b,f,q){switch(b){case "+":return f+q;case "-":return f-q;case "*":return f*q;case "/":return f/q}};k.Quoted=function(b,f){this.value=b;this.content=f};k.Quoted.prototype=
{toCSS:function(){return this.value},eval:function(){return this}};k.Rule=function(b,f,q){this.name=b;this.value=f instanceof k.Value?f:new k.Value([f]);this.index=q;this.variable=b.charAt(0)==="@"?true:false};k.Rule.prototype.toCSS=function(){return this.variable?"":this.name+": "+this.value.toCSS()+";"};k.Rule.prototype.eval=function(b){return new k.Rule(this.name,this.value.eval(b))};k.Value=function(b){this.value=b;this.is="value"};k.Value.prototype={eval:function(b){return this.value.length===
1?this.value[0].eval(b):new k.Value(this.value.map(function(f){return f.eval(b)}))},toCSS:function(){return this.value.map(function(b){return b.toCSS()}).join(", ")}};k.Shorthand=function(b,f){this.a=b;this.b=f};k.Shorthand.prototype={toCSS:function(b){return this.a.toCSS(b)+"/"+this.b.toCSS(b)},eval:function(){return this}};k.Ruleset=function(b,f){this.selectors=b;this.rules=f;this._lookups={}};k.Ruleset.prototype={eval:function(){return this},evalRules:function(b){var f=[];this.rules.forEach(function(q){if(q.evalRules)f.push(q.evalRules(b));
else q instanceof k.mixin.Call?Array.prototype.push.apply(f,q.eval(b)):f.push(q.eval(b))});this.rules=f;return this},match:function(b){return!b||b.length===0},variable:function(b){return this._variables?this._variables[b]:(this._variables=this.rules.reduce(function(f,q){if(q instanceof k.Rule&&q.variable===true)f[q.name]=q;return f},{}))[b]},rulesets:function(){return this._rulesets?this._rulesets:(this._rulesets=this.rules.filter(function(b){if(b instanceof k.Ruleset||b instanceof k.mixin.Definition)return b}))},
find:function(b,f){f=f||this;var q=[],h=b.toCSS();if(h in this._lookups)return this._lookups[h];this.rulesets().forEach(function(j){if(j!==f)for(var g=0;g<j.selectors.length;g++)if(b.match(j.selectors[g])){b.elements.length>1?Array.prototype.push.apply(q,j.find(new k.Selector(b.elements.slice(1)),f)):q.push(j);break}});return this._lookups[h]=q},toCSS:function(b,f){var q=[],h=[],j=[],g=[];if(this.root){b=[];f={frames:[]};for(var p=0;p<this.rules.length;p++)this.rules[p]instanceof k.Import&&Array.prototype.splice.apply(this.rules,
[p,1].concat(this.rules[p].eval(f)))}else if(b.length===0)g=this.selectors.map(function(z){return[z]});else for(p=0;p<this.selectors.length;p++)for(var r=0;r<b.length;r++)g.push(b[r].concat([this.selectors[p]]));f.frames.unshift(this);for(p=0;p<this.rules.length;p++)this.rules[p]instanceof k.mixin.Call&&Array.prototype.splice.apply(this.rules,[p,1].concat(this.rules[p].eval(f)));for(p=0;p<this.rules.length;p++){b=this.rules[p];if(b instanceof k.Directive)j.push(b.eval(f).toCSS(g,f));else if(b.rules)j.push(b.toCSS(g,
f));else if(b instanceof k.Comment)this.root?j.push(b.toCSS()):h.push(b.toCSS());else if(b.toCSS&&!b.variable)h.push(b.eval(f).toCSS());else b.value&&!b.variable&&h.push(b.value.toString())}j=j.join("");if(this.root)q.push(h.join("\n"));else if(h.length>0){g=g.map(function(z){return z.map(function(C){return C.toCSS()}).join("").trim()}).join(g.length>3?",\n":", ");q.push(g," {\n  "+h.join("\n  ")+"\n}\n")}q.push(j);f.frames.shift();return q.join("")}};k.Selector=function(b){this.elements=b;if(this.elements[0].combinator.value===
"")this.elements[0].combinator.value=" "};k.Selector.prototype.match=function(b){return this.elements[0].value===b.elements[0].value?true:false};k.Selector.prototype.toCSS=function(){if(this._css)return this._css;return this._css=this.elements.map(function(b){return typeof b==="string"?" "+b.trim():b.toCSS()}).join("")};k.URL=function(b){this.value=b};k.URL.prototype={toCSS:function(){return"url("+this.value.toCSS()+")"},eval:function(){return this}};k.Variable=function(b,f){this.name=b;this.index=
f};k.Variable.prototype={eval:function(b){var f,q,h=this.name;if(f=k.find(b.frames,function(j){if(q=j.variable(h))return q.value.eval(b)}))return f;else throw{message:"variable "+this.name+" is undefined",index:this.index};}};k.find=function(b,f){for(var q=0,h;q<b.length;q++)if(h=f.call(b,b[q]))return h;return null};(function(){function b(C){for(var e=0;e<r.length;e++)f(r[e],C)}function f(C,e){var K=typeof localStorage!=="undefined"&&localStorage.getItem(C.href),M=K&&JSON.parse(K);h(C.href,function(l,
w){if(M&&(new Date(w)).valueOf()===(new Date(M.timestamp)).valueOf()){q(M.css,C);e(null,C,{local:true})}else(new o.Parser({optimization:3})).parse(l,function(D,H){if(D)return p(D,C.href);try{e(H,C,{local:false,lastModified:w})}catch(R){p(R,C.href)}})},function(l){throw new Error("Couldn't load "+C.href+" ("+l+")");})}function q(C,e,K){var M=document.createElement("style");M.type="text/css";M.media="screen";M.title="less-sheet";if(e){M.title=e.title||e.href.match(/(?:^|\/)([-\w]+)\.[a-z]+$/i)[1];K&&
typeof localStorage!=="undefined"&&localStorage.setItem(e.href,JSON.stringify({timestamp:K,css:C}))}if(M.styleSheet)M.styleSheet.cssText=C;else M.appendChild(document.createTextNode(C));document.getElementsByTagName("head")[0].appendChild(M)}function h(C,e,K){var M=j();if(window.location.protocol==="file:"){M.open("GET",C,false);M.send(null);M.status===0?e(M.responseText):K(M.status)}else{M.open("GET",C,true);M.onreadystatechange=function(){if(M.readyState==4)if(M.status>=200&&M.status<300)e(M.responseText,
M.getResponseHeader("Last-Modified"));else typeof K==="function"&&K(M.status)};M.send(null)}}function j(){if(window.XMLHttpRequest)return new XMLHttpRequest;else try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(C){g("less: browser doesn't support AJAX.");return null}}function g(C){o.env=="development"&&typeof console!=="undefined"&&console.log(C)}function p(C,e){var K=document.createElement("div"),M;K.id="less-error-message";K.innerHTML="<h3>"+(C.message||"There is an error in your .less file")+
'</h3><p><a href="'+e+'">'+e+"</a> on line "+C.line+", column "+(C.column+1)+":</p>"+'<div>\n<pre class="ctx"><span>[-1]</span>{0}</pre>\n<pre><span>[0]</span>{current}</pre>\n<pre class="ctx"><span>[1]</span>{2}</pre>\n</div>'.replace(/\[(-?\d)\]/g,function(l,w){return C.line+parseInt(w)}).replace(/\{(\d)\}/g,function(l,w){return C.extract[parseInt(w)]}).replace(/\{current\}/,C.extract[1].slice(0,C.column)+'<span class="error">'+C.extract[1].slice(C.column)+"</span>");q("#less-error-message span {margin-right: 15px;}#less-error-message pre {color: #ee4444;padding: 4px 0;margin: 0;}#less-error-message pre.ctx {color: #dd7777;}#less-error-message h3 {padding: 15px 0 5px 0;margin: 0;}#less-error-message a {color: #10a}#less-error-message .error {color: red;font-weight: bold;padding-bottom: 2px;border-bottom: 1px dashed red;}");
K.style.cssText="font-family: Arial, sans-serif;border: 1px solid #e00;background-color: #eee;border-radius: 5px;color: #e00;padding: 15px;margin-bottom: 15px";if(o.env=="development")M=setInterval(function(){if(document.body){document.body.insertBefore(K,document.body.childNodes[0]);clearInterval(M)}},10)}var r=[];o.env=location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.protocol=="file:"?"development":"production";var z=setInterval(function(){if(document.body){if(!document.querySelectorAll&&
typeof jQuery==="undefined")g("No selector method found");else r=(document.querySelectorAll||jQuery).call(document,'link[rel="stylesheet/less"]');clearInterval(z);b(function(C,e,K){q(C.toCSS(),e,K.lastModified);K.local?g("less: loading "+e.href+" from local storage."):g("less: parsed "+e.href+" successfully.")})}},10);if(o.env==="development")refreshTimer=setInterval(function(){/!refresh/.test(location.hash)&&b(function(C,e,K){q(C.toCSS(),e,K)})},1E3);o.Parser.importer=function(C,e,K){f({href:C,title:C},
function(M){K(M)})}})()});bespin.tiki.register("::theme_manager_base",{name:"theme_manager_base",dependencies:{}});bespin.tiki.module("theme_manager_base:index",function(){});bespin.tiki.register("::canon",{name:"canon",dependencies:{environment:"0.0.0",events:"0.0.0",settings:"0.0.0"}});
bespin.tiki.module("canon:history",function(y,u){var v=y("bespin:util/stacktrace").Trace,s=y("bespin:plugins").catalog,o=y("bespin:console").console;u.requests=[];u.addRequestOutput=function(k){for(u.requests.push(k);u.requests.length>100;)u.requests.shiftObject();s.publish(this,"addedRequestOutput",null,k)};u.execute=function(k,b){if(b.command)try{b.command(k,b)}catch(f){var q=new v(f,true);o.group("Error executing command '"+b.typed+"'");o.log("command=",b.commandExt);o.log("args=",k);o.error(f);
q.log(3);o.groupEnd();b.doneWithError(f)}else b.doneWithError("Command not found.")}});
bespin.tiki.module("canon:request",function(y,u){var v=y("events").Event,s=y("canon:history");u.Request=function(o){o=o||{};this.command=o.command;this.commandExt=o.commandExt;this.args=o.args;this.typed=o.typed;this._begunOutput=false;this.start=new Date;this.end=null;this.error=this.completed=false;this.changed=new v};u.Request.prototype._beginOutput=function(){this._begunOutput=true;this.outputs=[];s.addRequestOutput(this)};u.Request.prototype.doneWithError=function(o){this.error=true;this.done(o)};
u.Request.prototype.async=function(){this._begunOutput||this._beginOutput()};u.Request.prototype.output=function(o){this._begunOutput||this._beginOutput();if(typeof o!=="string"&&!(o instanceof Node))o=o.toString();this.outputs.push(o);this.changed();return this};u.Request.prototype.done=function(o){this.completed=true;this.end=new Date;this.duration=this.end.getTime()-this.start.getTime();o?this.output(o):this.changed()}});bespin.tiki.module("canon:index",function(){});
bespin.tiki.register("::traits",{name:"traits",dependencies:{}});
bespin.tiki.module("traits:index",function(y,u){y=function(){function v(){try{if(Object.getOwnPropertyDescriptor)return!!Object.getOwnPropertyDescriptor({x:0},"x")}catch(L){}return false}function s(){try{if(Object.defineProperty){var L={};Object.defineProperty(L,"x",{value:0});return L.x===0}}catch(P){}return false}function o(L){var P=function(){throw new Error("Conflicting property: "+L);};Y(P.prototype);return Y(P)}function k(){return Y({value:undefined,enumerable:false,required:true})}function b(L){L=
o(L);return D?Y({get:L,set:L,enumerable:false,conflict:true}):Y({value:L,enumerable:false,conflict:true})}function f(L,P){return L===P?L!==0||1/L===1/P:L!==L&&P!==P}function q(L,P){return L.conflict&&P.conflict?true:L.get===P.get&&L.set===P.set&&f(L.value,P.value)&&L.enumerable===P.enumerable&&L.required===P.required&&L.conflict===P.conflict}function h(L,P){return Y(R(L,P))}function j(L){var P={};ea(L,function(S){P[S]=true});return Y(P)}function g(L){var P={};ea(da(L),function(S){var T=ia(L,S);if(T.value===
ta)T=k(S);else if(typeof T.value==="function"){T.method=true;"prototype"in T.value&&Y(T.value.prototype)}else{T.get&&T.get.prototype&&Y(T.get.prototype);T.set&&T.set.prototype&&Y(T.set.prototype)}P[S]=T});return P}function p(){var L=$(arguments,0),P={};ea(L,function(S){ea(da(S),function(T){var aa=S[T];if(W(P,T)&&!P[T].required)aa.required||q(P[T],aa)||(P[T]=b(T));else P[T]=aa})});return Y(P)}function r(L,P){var S=j(L),T={};ea(da(P),function(aa){T[aa]=!W(S,aa)||P[aa].required?P[aa]:k(aa)});return Y(T)}
function z(){var L=$(arguments,0),P={};ea(L,function(S){ea(da(S),function(T){var aa=S[T];if(!W(P,T)||P[T].required)P[T]=aa})});return Y(P)}function C(L,P){var S={};ea(da(P),function(T){if(W(L,T)&&!P[T].required){var aa=L[T];S[aa]=W(S,aa)&&!S[aa].required?b(aa):P[T];W(S,T)||(S[T]=k(T))}else if(W(S,T))P[T].required||(S[T]=b(T));else S[T]=P[T]});return Y(S)}function e(L,P){var S={},T=[];for(var aa in L)if(W(L,aa))if(L[aa])S[aa]=L[aa];else T.push(aa);return C(S,r(T,P))}function K(L,P){var S=oa(L),T={};
ea(da(P),function(aa){var ha=P[aa];if(ha.required){if(!(aa in L))throw new Error("Missing required property: "+aa);}else if(ha.conflict)throw new Error("Remaining conflicting property: "+aa);else T[aa]="value"in ha?ha.method?{value:h(ha.value,S),enumerable:ha.enumerable,configurable:ha.configurable,writable:ha.writable}:ha:{get:ha.get?h(ha.get,S):undefined,set:ha.set?h(ha.set,S):undefined,enumerable:ha.enumerable,configurable:ha.configurable,writable:ha.writable}});na(S,T);return Y(S)}function M(L,
P){return K(Object.prototype,g(L),P)}function l(L,P){var S=da(L),T=da(P);if(S.length!==T.length)return false;for(var aa=0;aa<S.length;aa++){T=S[aa];if(!P[T]||!q(L[T],P[T]))return false}return true}function w(L){return g(L)}var D=function(){try{var L={};Object.defineProperty(L,"x",{get:function(){return 0}});return L.x===0}catch(P){return false}}(),H=Function.prototype.call,R=Function.prototype.bind?function(L,P){return Function.prototype.bind.call(L,P)}:function(L,P){function S(){return L.apply(P,
arguments)}return S},W=R(H,Object.prototype.hasOwnProperty),$=R(H,Array.prototype.slice),ea=Array.prototype.forEach?R(H,Array.prototype.forEach):function(L,P){for(var S=0,T=L.length;S<T;S++)P(L[S])},Y=Object.freeze?function(L){Object.freeze(L);return L}:function(L){return L},da=Object.getOwnPropertyNames||function(L){var P=[];for(var S in L)W(L,S)&&P.push(S);return P},ia=v()?Object.getOwnPropertyDescriptor:function(L,P){return{value:L[P],enumerable:true,writable:true,configurable:true}},ma=s()?Object.defineProperty:
function(L,P,S){L[P]=S.value},na=Object.defineProperties||function(L,P){for(var S in P)W(P,S)&&ma(L,S,P[S])},oa=Object.create||function(L,P){function S(){}S.prototype=L||Object.prototype;L=new S;P&&na(L,P);return L};H=Object.getOwnProperties||function(L){var P={};ea(da(L),function(S){P[S]=ia(L,S)});return P};var ta=Y({toString:function(){return"<Trait.required>"}});if(!Object.create)Object.create=oa;if(!Object.getOwnProperties)Object.getOwnProperties=H;w.required=Y(ta);w.compose=Y(p);w.resolve=Y(e);
w.override=Y(z);w.create=Y(K);w.eqv=Y(l);w.object=Y(M);return Y(w)}();if(typeof u!=="undefined")u.Trait=y});bespin.tiki.register("::keyboard",{name:"keyboard",dependencies:{canon:"0.0.0",settings:"0.0.0"}});
bespin.tiki.module("keyboard:keyboard",function(y,u){var v=y("bespin:plugins").catalog;y("bespin:console");y("bespin:util/stacktrace");var s=y("bespin:util/util"),o=y("settings").settings,k=y("keyboard:keyutil"),b=y("canon:history"),f=y("canon:request").Request,q=y("environment").env;u.buildFlags=function(h){h.context=q.contexts[0];return h};y=function(){};s.mixin(y.prototype,{_customKeymappingCache:{states:{}},processKeyEvent:function(h,j,g){h=k.commandCodes(h,true)[0];if(s.none(h))return false;
u.buildFlags(g);g.isCommandKey=true;return this._matchCommand(h,j,g)},_matchCommand:function(h,j,g){var p=this._findCommandExtension(h,j,g);if(p&&p.commandExt!=="no command"){g.isTextView&&j.resetKeyBuffers();var r=p.commandExt;r.load(function(z){z=new f({command:z,commandExt:r});b.execute(p.args,z)});return true}return p&&p.commandExt==="no command"?true:false},_buildBindingsRegex:function(h){h.forEach(function(j){if(s.none(j.key))if(Array.isArray(j.regex)){j.key=new RegExp("^"+j.regex[1]+"$");j.regex=
new RegExp(j.regex.join("")+"$")}else j.regex=new RegExp(j.regex+"$");else j.key=new RegExp("^"+j.key+"$")})},_buildKeymappingRegex:function(h){for(state in h.states)this._buildBindingsRegex(h.states[state]);h._convertedRegExp=true},_findCommandExtension:function(h,j,g){if(g.isTextView){var p=j._keyState;if(!g.isCommandKey||h.indexOf("alt_")===-1){j._keyBuffer+=h.replace(/ctrl_meta|meta/,"ctrl");j._keyMetaBuffer+=h}var r=[this._customKeymappingCache];r=r.concat(v.getExtensions("keymapping"));for(var z=
0;z<r.length;z++)if(!s.none(r[z].states[p])){s.none(r[z]._convertedRegExp)&&this._buildKeymappingRegex(r[z]);var C=this._bindingsMatch(h,g,j,r[z]);if(!s.none(C))return C}}j=v.getExtensions("command");var e=null;p={};h=h.replace(/ctrl_meta|meta/,"ctrl");j.some(function(K){if(this._commandMatches(K,h,g)){e=K;return true}return false}.bind(this));return s.none(e)?null:{commandExt:e,args:p}},_bindingsMatch:function(h,j,g,p){var r,z=null,C={},e;e=s.none(p.hasMetaKey)?g._keyMetaBuffer:g._keyBuffer;if(h.indexOf("alt_")===
0&&j.isCommandKey)e+=h;p.states[g._keyState].some(function(K){if(K.key&&!K.key.test(h))return false;if(K.regex&&!(r=K.regex.exec(e)))return false;if(K.disallowMatches)for(var M=0;M<K.disallowMatches.length;M++)if(r[K.disallowMatches[M]])return true;if(!u.flagsMatch(K.predicates,j))return false;if(K.exec){z=v.getExtensionByKey("command",K.exec);if(s.none(z))throw new Error("Can't find command "+K.exec+" in state="+g._keyState+", symbolicName="+h);if(K.params){var l;K.params.forEach(function(w){l=!s.none(w.match)&&
!s.none(r)?r[w.match]||w.defaultValue:w.defaultValue;if(w.type==="number")l=parseInt(l);C[w.name]=l})}g.resetKeyBuffers()}if(K.then){g._keyState=K.then;g.resetKeyBuffers()}if(s.none(z))z="no command";return true});if(s.none(z))return null;return{commandExt:z,args:C}},_commandMatches:function(h,j,g){var p=h.key;if(!p)return false;if(!u.flagsMatch(h.predicates,g))return false;if(typeof p==="string"){if(p!=j)return false;return true}if(!Array.isArray(p)){p=[p];h.key=p}for(h=0;h<p.length;h++){var r=p[h];
if(typeof r==="string"){if(r==j)return true}else if(r.key==j)return u.flagsMatch(r.predicates,g)}return false},_customKeymappingChanged:function(){var h=this._customKeymappingCache=JSON.parse(o.get("customKeymapping"));h.states=h.states||{};for(state in h.states)this._buildBindingsRegex(h.states[state]);h._convertedRegExp=true}});u.flagsMatch=function(h,j){if(s.none(h))return true;if(!j)return false;for(var g in h)if(j[g]!==h[g])return false;return true};u.keyboardManager=new y;v.registerExtension("settingChange",
{match:"customKeymapping",pointer:u.keyboardManager._customKeymappingChanged.bind(u.keyboardManager)})});
bespin.tiki.module("keyboard:keyutil",function(y,u){var v=y("bespin:util/util");u.KeyHelper=function(){var o={MODIFIER_KEYS:{16:"shift",17:"ctrl",18:"alt",224:"meta"},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"},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:'"'},PRINTABLE_KEYS_CHARCODE:{},KEY:{}};for(var k in o.PRINTABLE_KEYS){var b=o.PRINTABLE_KEYS[k];o.PRINTABLE_KEYS_CHARCODE[b.charCodeAt(0)]=k;if(b.toUpperCase()!=
b)o.PRINTABLE_KEYS_CHARCODE[b.toUpperCase().charCodeAt(0)]=k}for(k in o.FUNCTION_KEYS){b=o.FUNCTION_KEYS[k].toUpperCase();o.KEY[b]=parseInt(k,10)}return o}();var s=function(o){return!!(o.altKey||o.ctrlKey||o.metaKey||o.charCode!==o.which&&u.KeyHelper.FUNCTION_KEYS[o.which])};u.commandCodes=function(o,k){var b=o._keyCode||o.keyCode,f=o._charCode===undefined?o.charCode:o._charCode,q=null,h=null,j="",g=true;if(b===0&&o.which===0)return false;if(f!==0)return false;if(u.KeyHelper.MODIFIER_KEYS[f])return[u.KeyHelper.MODIFIER_KEYS[f],
null];if(b){q=u.KeyHelper.FUNCTION_KEYS[b];if(!q&&(o.altKey||o.ctrlKey||o.metaKey)){q=u.KeyHelper.PRINTABLE_KEYS[b];if(b>47&&b<58)g=o.altKey}if(q){if(o.altKey)j+="alt_";if(o.ctrlKey)j+="ctrl_";if(o.metaKey)j+="meta_"}else if(o.ctrlKey||o.metaKey)return false}if(!q){b=o.which;h=q=String.fromCharCode(b);b=q.toLowerCase();if(o.metaKey){j="meta_";q=b}else q=null}if(o.shiftKey&&q&&g)j+="shift_";if(q)q=j+q;if(!k&&q)q=q.replace(/ctrl_meta|meta/,"ctrl");return[q,h]};u.addKeyDownListener=function(o,k){var b=
function(f){var q=k(f);q&&v.stopEvent(f);return q};o.addEventListener("keydown",function(f){if(v.isMozilla)if(u.KeyHelper.FUNCTION_KEYS[f.keyCode])return true;else if((f.ctrlKey||f.metaKey)&&u.KeyHelper.PRINTABLE_KEYS[f.keyCode])return true;if(s(f))return b(f);return true},false);o.addEventListener("keypress",function(f){if(v.isMozilla)if(u.KeyHelper.FUNCTION_KEYS[f.keyCode])return b(f);else if((f.ctrlKey||f.metaKey)&&u.KeyHelper.PRINTABLE_KEYS_CHARCODE[f.charCode]){f._keyCode=u.KeyHelper.PRINTABLE_KEYS_CHARCODE[f.charCode];
f._charCode=0;return b(f)}if(f.charCode!==undefined&&f.charCode===0)return true;return b(f)},false)}});bespin.tiki.module("keyboard:index",function(){});bespin.tiki.register("::worker_manager",{name:"worker_manager",dependencies:{canon:"0.0.0",events:"0.0.0",underscore:"0.0.0"}});
bespin.tiki.module("worker_manager:index",function(y,u){function v(j){var g=/^([^#:]+)(?::([^#:]+))?#([^#:]+)$/.exec(j);if(g==null)throw new Error('WorkerSupervisor: invalid pointer specification: "'+j+'"');j=g[1];var p=g[3];g=j+":"+(g[2]!=null?g[2]:"index");var r=bespin!=null&&bespin.base!=null?bespin.base:"";this._packageId=j;this._moduleId=g;this._base=r;this._target=p;this._worker=null;this._currentId=0;this.started=new f}function s(){h.restartAll()}if(window==null)throw new Error('The "worker_manager" plugin can only be loaded in the browser, not a web worker. Use "worker" instead.');
var o=y("bespin:proxy");y("bespin:plugins");var k=y("bespin:console").console,b=y("underscore")._,f=y("events").Event,q=y("bespin:promise").Promise;y("environment");var h={_workers:[],add:function(j){this._workers.push(j)},remove:function(j){this._workers=b(this._workers).without(j)},restartAll:function(){var j=this._workers;b(j).invoke("kill");b(j).invoke("start")}};v.prototype={_onError:function(j){this._worker=null;h.remove(this);k.error("WorkerSupervisor: worker failed at file "+j.filename+":"+
j.lineno+"; fix the worker and use 'worker restart' to restart it")},_onMessage:function(j){j=JSON.parse(j.data);switch(j.op){case "finish":if(j.id===this._currentId){var g=this._promise;this._promise=null;g.resolve(j.result)}break;case "log":k[j.method].apply(k,j.args);break}},_promise:null,started:null,kill:function(){var j=this._promise;if(j!=null){j.reject("killed");this._promise=null}this._worker.terminate();this._worker=null;h.remove(this)},send:function(j,g){var p=this._promise;if(p!=null){p.reject("interrupted");
this._currentId++}p=this._currentId;var r=new q;this._promise=r;this._worker.postMessage(JSON.stringify({op:"invoke",id:p,method:j,args:g}));return r},start:function(){if(this._worker!=null)throw new Error("WorkerSupervisor: worker already started");var j=this._base,g=this._target,p=this._packageId,r=this._moduleId,z=new o.Worker(j+"BespinEmbedded.js");z.onmessage=this._onMessage.bind(this);z.onerror=this._onError.bind(this);z.postMessage(JSON.stringify({op:"load",base:j,pkg:p,module:r,target:g}));
this._worker=z;this._currentId=0;h.add(this);this.started()}};u.WorkerSupervisor=v;u.workerManager=h;u.workerRestartCommand=s});bespin.tiki.register("::edit_session",{name:"edit_session",dependencies:{events:"0.0.0"}});
bespin.tiki.module("edit_session:index",function(y,u){y("bespin:promise");y("bespin:plugins");y("bespin:util/util");y("events");u.EditSession=function(){};u.EditSession.prototype={_currentView:null,currentUser:null,history:null,getCompletePath:function(v){if(v==null)v="";if(v==null||v.substring(0,1)!="/"){var s;if(this._currentView&&this._currentView.buffer)s=this._currentView.buffer;var o;if(s)o=s.file;v=o?o.parentdir()+v:"/"+v}return v}};Object.defineProperties(u.EditSession.prototype,{currentView:{set:function(v){if(v!==
this._currentView)this._currentView=v},get:function(){return this._currentView}}});u.createSession=function(v,s){var o=new u.EditSession;if(v)o.currentView=v.textView;if(s)o.currentUser=s;return o}});bespin.tiki.register("::syntax_manager",{name:"syntax_manager",dependencies:{worker_manager:"0.0.0",syntax_directory:"0.0.0",events:"0.0.0",underscore:"0.0.0",settings:"0.0.0"}});
bespin.tiki.module("syntax_manager:index",function(y,u){function v(g,p,r,z){for(;g.length<p;)g.push(b(z).clone());p=[p,r.length].concat(r);Array.prototype.splice.apply(g,p);return g}function s(){this._lines=[];this._syms={}}function o(g,p){this._syntaxInfo=g;this._syntaxManager=p;this._invalidRow=0;this._states=[];this._active=false;this.symbols=new s}function k(g){this.layoutManager=g;this.attrsChanged=new f;this.syntaxChanged=new f;this._contextRanges=this._invalidRows=this._context=null;this._attrs=
[];this._symbols=new s;this._syntax="plain";this._reset()}var b=y("underscore")._,f=y("events").Event,q=y("worker_manager").WorkerSupervisor;y("bespin:console");y("rangeutils:utils/range");var h=y("settings").settings,j=y("syntax_directory").syntaxDirectory;s.prototype={get:function(g){return this._syms["-"+g]},replaceLine:function(g,p){function r(e){return e.substring(1)}var z=this._lines,C=this._syms;g<z.length&&b(z[g]).isArray()&&b(z[g]).each(function(e){delete C["-"+e]});z[g]=b(p).keys().map(r);
b(C).extend(p)}};o.prototype={_annotate:function(){if(this._invalidRow==null)throw new Error("syntax_manager.Context: attempt to annotate without any invalid row");if(!this._active)throw new Error("syntax_manager.Context: attempt to annotate while inactive");if(this._worker==null)this._createWorker();else{var g=this._syntaxManager.getTextLines(),p=this._invalidRow,r=p===0?this.getName()+":start":this._states[p],z=Math.min(g.length,p+100);g=g.slice(p,z);var C={start:{row:p,col:0},end:{row:z-1,col:b(g).last().length}};
this._worker.send("annotate",[r,g,C]).then(b(this._annotationFinished).bind(this,p,z))}},_annotationFinished:function(g,p,r){if(this._active){var z=this._syntaxManager;z.mergeAttrs(g,r.attrs);z.mergeSymbols(g,r.symbols);v(this._states,g,r.states);if(p>=this._getRowCount()){this._invalidRow=null;this._active=false}else{this._invalidRow=p;this._annotate()}}},_createWorker:function(){if(this._syntaxInfo==null)return false;var g=new q("syntax_worker#syntaxWorker");this._worker=g;g.started.add(this._workerStarted.bind(this));
g.start();return true},_getRowCount:function(){return this._syntaxManager.getTextLines().length},_workerStarted:function(){this._syntaxInfo.settings.forEach(function(g){var p=h.get(g);this._worker.send("setSyntaxSetting",[g,p])},this);this._worker.send("loadSyntax",[this._syntaxInfo.name]);this._active&&this._annotate()},activateAndAnnotate:function(){this._active=true;this._annotate()},contextsAtPosition:function(){var g=this._syntaxInfo;if(g==null)return["plain"];return[g.name]},cut:function(g){var p=
this._getRowCount();if(g<0||g>=p)throw new Error("Attempt to cut the context at an invalid row");if(!(this._invalidRow!=null&&this._invalidRow<g)){this._invalidRow=g;this._active=false}},getName:function(){return this._syntaxInfo.name},kill:function(){var g=this._worker;if(g!=null){g.kill();this._worker=null}}};k.prototype={_getTextStorage:function(){return this.layoutManager.textStorage},_reset:function(){var g=this._context;if(g!=null){g.kill();this._context=null}g=this._syntax;g=g==="plain"?null:
j.get(g);this._context=g=new o(g,this);g.activateAndAnnotate()},attrsChanged:null,syntaxChanged:null,contextsAtPosition:function(g){return this._context.contextsAtPosition(g)},getAttrsForRows:function(g,p){return this._attrs.slice(g,p)},getSymbol:function(g){return this._symbols.get(g)},getSyntax:function(){return this._syntax},getTextLines:function(){return this._getTextStorage().lines},invalidateRow:function(g){var p=this._context;p.cut(g);p.activateAndAnnotate()},mergeAttrs:function(g,p){v(this._attrs,
g,p,[]);this.attrsChanged(g,g+p.length)},mergeSymbols:function(g,p){var r=this._symbols;b(p).each(function(z,C){r.replaceLine(g+C,z)})},setSyntax:function(g){this._syntax=j.hasSyntax(g)?g:"plain";this.syntaxChanged(g);this._reset()},setSyntaxFromFileExt:function(g){return this.setSyntax(j.syntaxForFileExt(g))}};u.SyntaxManager=k});bespin.tiki.register("::completion",{name:"completion",dependencies:{jquery:"0.0.0",ctags:"0.0.0",rangeutils:"0.0.0",canon:"0.0.0",underscore:"0.0.0"}});
bespin.tiki.module("completion:controller",function(y,u){function v(h){this._editorView=h;h.selectionChanged.add(this._selectionChanged.bind(this));h.willChangeBuffer.add(this._willChangeBuffer.bind(this));this._syntaxChanged=this._syntaxChanged.bind(this);this.tags=new o.Tags;this.ui=new b(h.element)}function s(h){return function(){return q.editor.completionController[h](q)}}var o=y("ctags"),k=y("rangeutils:utils/range"),b=y("completion:ui").CompletionUI,f=y("bespin:plugins").catalog,q=y("environment").env;
v.prototype={_buffer:null,_completionEngine:null,_completions:null,_stem:null,_hideCompletions:function(){this.ui.hide()},_selectionChanged:function(h){var j=this._completionEngine;if(!(j==null||!k.isZeroLength(h))){var g=this._buffer.layoutManager,p=g.syntaxManager,r=h.start;h=r.col;r=g.textStorage.lines[r.row];g=r.substring(0,h);h=r.substring(h);j=j.getCompletions(g,h,p);if(j==null)this._hideCompletions();else{p=j.tags;this._stem=j.stem;this._showCompletions(p)}}},_showCompletions:function(h){var j=
this._editorView,g=j.textView.getInsertionPointPosition();g=j.convertTextViewPoint(g);this.ui.show(h,g,j.layoutManager.fontDimension.lineHeight)},_syntaxChanged:function(h){h=f.getExtensionByKey("completion",h);if(h==null)this._completionEngine=null;else h.load().then(function(j){this._completionEngine=new j(this.tags)}.bind(this))},_willChangeBuffer:function(h){var j=this._buffer;j!=null&&j.layoutManager.syntaxManager.syntaxChanged.remove(this._syntaxChanged);h.layoutManager.syntaxManager.syntaxChanged.add(this._syntaxChanged);
this._buffer=h},cancel:function(){this.ui.hide()},complete:function(h){var j=this.ui,g=j.getCompletion().name;h.view.insertText(g.substring(this._stem.length));j.hide()},isCompleting:function(){return this.ui.visible},moveDown:function(){this.ui.move("down")},moveUp:function(){this.ui.move("up")},tags:null};u.CompletionController=v;u.completeCommand=s("complete");u.completeCancelCommand=s("cancel");u.completeDownCommand=s("moveDown");u.completeUpCommand=s("moveUp")});
bespin.tiki.module("completion:ui",function(y,u){function v(q){var h=o.uniqueId("bespin-completion-panel"),j=document.createElement("div");j.id=h;j.className="bespin-completion-panel";j.style.display="none";j.innerHTML='<div class="bespin-completion-pointer"></div><div class="bespin-completion-bubble-outer"><div class="bespin-completion-bubble-inner"><div class="bespin-completion-highlight"></div><ul></ul></div></div>';s(q).append(j);this.panel=s(j);this.parent=s(q)}var s=y("jquery").$,o=y("underscore")._,
k=o.template('<span class="bespin-completion-container"> &mdash; <%= container %></span>'),b=o.template('<div class="bespin-completion-second-row"><%= type %></div>'),f=o.template('<li><div class="bespin-completion-top-row"><span class="bespin-completion-kind bespin-completion-kind-<%= kind %>"><%= kind %></span><span class="bespin-completion-ident"><%= ident %></span><%= container %></div><%= second_row %></li>');v.prototype={_fromBottom:false,_index:0,_tags:null,_getHighlightDimensions:function(q){var h=
q.position(),j=q.outerHeight()-2;q=q.outerWidth()-2;return{left:h.left,top:h.top,height:j,width:q}},_listItemForIndex:function(q){return this.panel.find("li:eq("+q+")")},_populate:function(){var q=o(this._tags).map(function(h){var j=h["class"],g=h.module,p=h.namespace;j=j!=null?j:p!=null?p:"";if(g!=null)j=g+(j!=""?"#"+j:"");g=j==""?"":k({container:j});j=h.type;j=j==null?"":b({type:j});return f({kind:h.kind,ident:h.name,container:g,second_row:j})});this.panel.find("ul").html(q.join("\n"))},panel:null,
visible:false,getCompletion:function(){return this.visible?this._tags[this._index]:null},hide:function(){if(this.visible){this.panel.fadeOut(100);this.visible=false}},move:function(q){var h=this._index,j=this._listItemForIndex(h),g=q==="up"?j.prev():j.next();if(g.length!==0){this._index=h=q==="up"?h-1:h+1;h=s(j).find(".bespin-completion-top-row");var p=s(j).find(".bespin-completion-second-row");j=s(g).find(".bespin-completion-top-row");var r=s(g).find(".bespin-completion-second-row");p.hide();r.show();
var z=this.panel.find(".bespin-completion-highlight");z.stop(true,true);g=this._getHighlightDimensions(g);z.animate(g,100);r.hide();if(q==="down"){q=p.height();j.css("top",q);j.animate({top:0},100)}else{q=r.height();h.css("top",-q);h.animate({top:0},100)}r.fadeIn()}},show:function(q,h,j){this._tags=q=o(q).clone();this._populate();var g=this.visible,p=this.panel;p.stop(true,true);g||p.show();var r=this.parent.offset(),z=r.left,C=z+h.x,e=r.top+h.y;r=p.outerWidth();var K=p.outerHeight(),M=s(window).width(),
l=s(window).height();this._fromBottom=e=e+K+j>l;if(this._index>=q.length)this._index=q.length-1;if(e){e=p.find(".bespin-completion-pointer");e.removeClass("bespin-completion-pointer-up");e.addClass("bespin-completion-pointer-down");p.css({bottom:-h.y,top:""});this._tags.reverse();this._populate();if(!g)this._index=q.length-1}else{e=p.find(".bespin-completion-pointer");e.removeClass("bespin-completion-pointer-down");e.addClass("bespin-completion-pointer-up");p.css({top:h.y+j,bottom:""});if(!g)this._index=
0}if(!g){if(C+h.x+r>M){e.css({left:"",right:32});p.css("left",Math.min(M-r-z,h.x-r+43))}else{e.css({left:32,right:""});p.css("left",Math.max(z,h.x-43))}p.hide().animate({opacity:"show"},100)}q=p.find(".bespin-completion-highlight");q.stop(true,true);h=this._listItemForIndex(this._index);h.find(".bespin-completion-second-row").show();h=this._getHighlightDimensions(h);q.css(h);this.visible=true}};u.CompletionUI=v});bespin.tiki.module("completion:index",function(){});
bespin.tiki.register("::rangeutils",{name:"rangeutils",dependencies:{}});
bespin.tiki.module("rangeutils:utils/range",function(y,u){var v=y("bespin:util/util");u.addPositions=function(s,o){return{row:s.row+o.row,col:s.col+o.col}};u.cloneRange=function(s){var o=s.start;s=s.end;return{start:{row:o.row,col:o.col},end:{row:s.row,col:s.col}}};u.comparePositions=function(s,o){var k=s.row-o.row;return k===0?s.col-o.col:k};u.equal=function(s,o){return u.comparePositions(s.start,o.start)===0&&u.comparePositions(s.end,o.end)===0};u.extendRange=function(s,o){var k=s.end;return{start:s.start,
end:{row:k.row+o.row,col:k.col+o.col}}};u.intersectRangeSets=function(s,o){s=v.clone(s);o=v.clone(o);for(var k=[];s.length>0&&o.length>0;){var b=s.shift(),f=o.shift(),q=u.comparePositions(b.start,f.start),h=u.comparePositions(b.end,f.end);if(u.comparePositions(b.end,f.start)<0){k.push(b);o.unshift(f)}else if(u.comparePositions(f.end,b.start)<0){k.push(f);s.unshift(b)}else if(q<0){k.push({start:b.start,end:f.start});s.unshift({start:f.start,end:b.end});o.unshift(f)}else if(q===0)if(h<0)o.unshift({start:b.end,
end:f.end});else h>0&&s.unshift({start:f.end,end:b.end});else if(q>0){k.push({start:f.start,end:b.start});s.unshift(b);o.unshift({start:b.start,end:f.end})}}return k.concat(s,o)};u.isZeroLength=function(s){return s.start.row===s.end.row&&s.start.col===s.end.col};u.maxPosition=function(s,o){return u.comparePositions(s,o)>0?s:o};u.normalizeRange=function(s){return this.comparePositions(s.start,s.end)<0?s:{start:s.end,end:s.start}};u.rangeSetBoundaries=function(s){return{start:s[0].start,end:s[s.length-
1].end}};u.toString=function(s){var o=s.start;s=s.end;return"[ "+o.row+", "+o.col+" "+s.row+","+ +s.col+" ]"};u.unionRanges=function(s,o){return{start:s.start.row<o.start.row||s.start.row===o.start.row&&s.start.col<o.start.col?s.start:o.start,end:s.end.row>o.end.row||s.end.row===o.end.row&&s.end.col>o.end.col?s.end:o.end}};u.isPosition=function(s){return!v.none(s)&&!v.none(s.row)&&!v.none(s.col)};u.isRange=function(s){return!v.none(s)&&u.isPosition(s.start)&&u.isPosition(s.end)}});
bespin.tiki.module("rangeutils:index",function(){});bespin.tiki.register("::undomanager",{name:"undomanager",dependencies:{}});
bespin.tiki.module("undomanager:index",function(y,u){var v=y("bespin:util/util");y("environment");u.UndoManager=function(){};v.mixin(u.UndoManager.prototype,{_redoStack:[],_undoStack:[],_undoOrRedo:function(s,o,k){if(o.length===0)return false;o=o.pop();if(!o.target[s](o.context)){this._redoStack=[];this._undoStack=[];return false}k.push(o);return true},redo:function(){return this._undoOrRedo("redo",this._redoStack,this._undoStack)},registerUndo:function(s,o){this._redoStack=[];this._undoStack.push({target:s,
context:o})},undo:function(){return this._undoOrRedo("undo",this._undoStack,this._redoStack)}});u.global=new u.UndoManager;u.undoManagerCommand=function(s,o){u.global[o.commandExt.name]()}});bespin.tiki.register("::environment",{name:"environment",dependencies:{settings:"0.0.0"}});
bespin.tiki.module("environment:index",function(y,u){var v=y("bespin:util/util"),s=y("bespin:console").console,o=y("bespin:plugins").catalog,k=y("settings").settings;u.Environment=function(){this.commandLine=null;window.addEventListener("resize",this.dimensionsChanged.bind(this),false)};Object.defineProperties(u.Environment.prototype,{settings:{value:{set:function(b,f){if(v.none(b))throw new Error("setSetting(): key must be supplied");if(v.none(f))throw new Error("setSetting(): value must be supplied");
k.set(b,f)},get:function(b){if(v.none(b))throw new Error("getSetting(): key must be supplied");return k.get(b)}}},dimensionsChanged:{value:function(){o.publish(this,"dimensionsChanged")}},session:{get:function(){return o.getObject("session")}},view:{get:function(){if(!this.session)return null;return this.session.currentView}},editor:{get:function(){if(!this.session)return null;return this.session.currentView.editor}},contexts:{get:function(){if(!this.view)return[];var b=this.view.editor.layoutManager.syntaxManager,
f=this.view.getSelectedRange().start;return b.contextsAtPosition(f)}},buffer:{get:function(){if(this.session)return this.view.editor.buffer;else s.error("command attempted to get buffer but there's no session")}},model:{get:function(){if(this.buffer)return this.view.editor.layoutManager.textStorage;else s.error("Session has no current buffer")}},file:{get:function(){if(this.buffer)return this.buffer.file;else s.error("Session has no current buffer")}},files:{get:function(){return o.getObject("files")}}});
u.env=new u.Environment});bespin.tiki.register("::ctags",{name:"ctags",dependencies:{traits:"0.0.0",underscore:"0.0.0"}});
bespin.tiki.module("ctags:index",function(y,u){var v=y("underscore")._,s=y("./reader").TagReader;y=y("traits").Trait;u.Tags=function(){this.tags=[]};u.Tags.prototype=Object.create(Object.prototype,y.compose(y({_search:function(o,k){var b={name:o};o=this.tags;var f=v(o).sortedIndex(b,function(q){return q.name});for(f=b=f;b>=0&&b<o.length&&k(o[b]);)b--;for(;f>=0&&f<o.length&&k(o[f]);)f++;return o.slice(b+1,f)},add:function(o){var k=this.tags;Array.prototype.push.apply(k,o);k.sort(function(b,f){b=b.name;
f=f.name;if(b<f)return-1;if(b===f)return 0;return 1})},get:function(o){return this._search(o,function(k){return k.name===o})},scan:function(o,k,b){if(b===null||b===undefined)b={};var f=o.split("\n");o=parse(o,k,1);k=new Interpreter(o,k,f,b);k.interpret();this.add(k.tags)},stem:function(o){var k=o.length;return this._search(o,function(b){return b.name.substring(0,k)===o})}}),s))});
bespin.tiki.module("ctags:reader",function(y,u){var v=y("underscore")._;y=y("traits").Trait;u.TagReader=y({readLines:function(s){var o=[];v(s).each(function(k){k=k.split("\t");if(!(k.length<3)){var b=k[0];if(!/^!_TAG_/.test(b)){b={name:b,tagfile:k[1],addr:k[2]};var f;if(k.length>3&&k[3].indexOf(":")===-1){b.kind=k[3];f=4}else f=3;var q={};v(k.slice(f)).each(function(h){h=/^([^:]+):(.*)/.exec(h);q[h[1]]=h[2]});b.fields=q;o.push(b)}}});this.add(o)},readString:function(s){this.readLines(s.split("\n"))}})});
bespin.tiki.register("::theme_manager",{name:"theme_manager",dependencies:{theme_manager_base:"0.0.0",settings:"0.0.0",events:"0.0.0",less:"0.0.0"}});
bespin.tiki.module("theme_manager:index",function(y,u){y("bespin:promise");var v=y("bespin:plugins").catalog;y("events");var s=y("themestyles"),o=y("settings").settings,k=null,b=null;u.themestyles=s;u.themeSettingChanged=function(f,q,h){var j=v.getExtensionByKey("theme",h);if(h==="standard"||!h||!j){j=null;if(b!==null)j=v.getExtensionByKey("theme",b)}if(j)j.load().then(function(g){k&&s.unregisterThemeStyles(k);s.currentThemeVariables=g();k=j;s.parseGlobalVariables();s.reparse();j.url&&s.registerThemeStyles(j);
v.publish(u,"themeChange")});else if(k){s.unregisterThemeStyles(k);k=null;s.currentThemeVariables=null;s.parseGlobalVariables();s.reparse();v.publish(this,"themeChange")}};v.registerExtension("settingChange",{match:"theme",pointer:u.themeSettingChanged.bind(u)});u.setStandardTheme=function(f){b=f;f!==o.get("theme")&&u.themeSettingChanged(this)};u.setBasePlugin=function(f){s.basePluginName=f};u.startParsing=function(){s.preventParsing=false;return s.reparse()};u.registerTheme=function(f){var q=o.get("theme");
f.name===q&&u.themeSettingChanged(this,"theme",f.name)};u.unregisterTheme=function(f){f.name===o.get("theme")&&u.themeSettingChanged(this)};u.appLaunched=function(){v.publish(u,"themeChange")}});
bespin.tiki.module("theme_manager:themestyles",function(y,u){var v=y("bespin:util/util"),s=y("bespin:plugins").catalog,o=y("bespin:console").console,k=y("bespin:promise").Promise,b=y("bespin:promise").group,f=y("bespin:proxy"),q=new (y("less").Parser)({optimization:3}),h=1;u.currentThemeVariables=null;u.basePluginName=null;u.preventParsing=true;var j="";u.globalThemeVariables={};var g={},p={},r=function(w){var D={},H=[],R=function(W,$){H.push(W);if(typeof $!="object")D[H.join("_")]=$;else for(prop in $)R(prop,
$[prop]);H.pop()};R("global",w);return D},z={},C={font:"arial, lucida, helvetica, sans-serif",font_size:"14px",line_height:"1.8em",color:"#DAD4BA",text_shadow:"1px 1px rgba(0, 0, 0, 0.4)",error_color:"#F99",header_color:"white",link_color:"#ACF",control:{color:"#E1B41F",border:"1px solid rgba(0, 0, 0, 0.2)",border_radius:"0.25em",background:"rgba(0, 0, 0, 0.2)",active:{color:"#FF9600",border:"1px solid #E1B41F",inset_color:"#ff9600",background:"rgba(0, 0, 0, 0.2)"}},pane:{h1:{font:"'MuseoSans', Helvetica",
font_size:"2.8em",color:"white"},color:"#DAD4BA",text_shadow:"1px 1px rgba(0, 0, 0, 0.4)",link_color:"white",background:"#45443C",border_radius:".5em"},form:{color:"white",text_shadow:"1px 1px rgba(0, 0, 0, 0.4)",font:"'Lucida Sans','Lucida Grande',Verdana,Arial,sans-serif",font_size:"@global_font_size",line_height:"@global_line_height"},button:{color:"white",background:"#3E6CB9"},container:{background:"#1E1916",border:"1px solid black"},selectable:{color:"white",border:"0px solid transparent",background:"transparent",
active:{color:"black",border:"0px solid transparent",background:"#FF8E00"},hover:{color:"black",border:"0px solid transparent",background:"#FF8E00"}},hint:{color:"#AAA",active:{color:"black"},hover:{color:"black"}},accelerator:{color:"#996633",active:{color:"black"},hover:{color:"black"}},menu:{border_color:"black",inset_color_right:"#1E1916",inset_color_top_left:"#3E3936",background:"transparent"}};C=r(C);u.getPluginThemeVariables=function(w){var D=s.plugins[w];if(!D)return null;var H={};if(u.currentThemeVariables&&
u.currentThemeVariables[w])H=u.currentThemeVariables[w];D.provides.forEach(function(R){if(R.ep==="themevariable"){var W=R.name;H[W]=H[W]||R.defaultValue}});return H};u.parseGlobalVariables=function(){var w={},D="",H=u.currentThemeVariables;v.mixin(w,C);H&&H.global&&v.mixin(w,r(H.global));u.globalThemeVariables=w;for(prop in w)D+="@"+prop+":"+w[prop]+";";j=D};u.parseGlobalVariables();var e=function(w,D,H){if(g[D])styleElem=document.getElementById("_bespin_theme_style_"+g[D]);else{styleElem=document.createElement("style");
styleElem.setAttribute("id","_bespin_theme_style_"+h);g[D]=h;h++;document.body.appendChild(styleElem)}q.parse(j+H+p[D],function(R,W){if(R){R="Error less parsing "+D+" "+R.message;o.error(R);w.reject(R)}else{try{var $=W.toCSS()}catch(ea){R="Error less parsing "+D+" "+ea;o.error(R);w.reject(R);return}if(styleElem&&styleElem.firstChild)styleElem.firstChild.textContent=$;else{R=document.createTextNode($);styleElem.appendChild(R)}w.resolve()}})},K={};u.parsePlugin=function(w){if(u.preventParsing)return(new k).resolve();
var D=s.plugins[w];if(!D)throw"reparsePlugin: plugin "+w+" is not defined!";if(!K[w]){K[w]=new k;setTimeout(function(){var H=u.getPluginThemeVariables(w),R="";for(prop in H)R+="@"+prop+":"+H[prop]+";";H=new k;H.then(function(W){K[this.name].resolve(W);K[this.name]=null}.bind(this),function(){K[this.name].reject(data);K[this.name]=null}.bind(this));e(H,w,R)}.bind(D),0)}return K[w]};var M=function(w,D,H,R){H=H.replace(/url\(['"]*([^'")]*)(['"]*)\)/g,"url("+w+"$1)");p[D]+=H;R&&R.resolve()},l=null;u.registerThemeStyles=
function(w){var D=w.getPluginName(),H=s.getResourceURL(D);if(!(w.url instanceof Array))w.url=[w.url];p[D]="";var R=[],W=u.preventParsing;w.url.forEach(function($){if(z[D]&&z[D][$])M(H,D,z[D][$]);else{var ea=new k;R.push(ea);var Y=H+$+"?"+(new Date).getTime();f.xhr("GET",Y,true,function(da){da.overrideMimeType("text/plain")}).then(function(da){M(H,D,da,ea)},function(){o.error("registerLessFile: Could not load "+H+$);ea.resolve()})}});if(R.length===0)u.parsePlugin(D);else{W||b(R).then(function(){u.parsePlugin(D)});
if(l!==null)R=R.concat(l);l=b(R)}};u.reparse=function(){var w=new k;if(u.preventParsing)return w.resolve();l?l.then(function(){var D=[],H=u.basePluginName;H!==null&&p[H]&&D.push(u.parsePlugin(H));for(var R in p)R!==H&&D.push(u.parsePlugin(R));b(D).then(w.resolve.bind(w),w.reject.bind(w))},function(D){w.reject(D)}):w.resolve();return w};u.unregisterThemeStyles=function(w){w=w.getPluginName();if(g[w]){var D=document.getElementById("_bespin_theme_style_"+g[w]);D.parentNode.removeChild(D);delete g[w];
delete p[w]}}});bespin.tiki.register("::whitetheme",{name:"whitetheme",dependencies:{theme_manager:"0.0.0"}});
bespin.tiki.module("whitetheme:index",function(y,u){u.whiteTheme=function(){return{global:{font:"arial, lucida, helvetica, sans-serif",font_size:"14px",line_height:"1.8em",color:"#2E2E3D",text_shadow:"1px 1px white",error_color:"#C03A38",header_color:"#222222",link_color:"#597BAC",pane:{h1:{font:"'MuseoSans', Helvetica",font_size:"2.8em",color:"#2C3480"},link_color:"@global_link_color",background:"#DFDFDF",border_radius:".5em",color:"#2E2E3D",text_shadow:"1px 1px #DDD"},form:{font:"@global_font",
font_size:"@global_font_size",line_height:"@global_line_height",color:"black",text_shadow:"0px 0px transparent"},control:{color:"#222",border:"1px solid rgba(0, 0, 0, 0.2)",border_radius:"0.25em",background:"rgba(0, 0, 0, 0.1)",active:{color:"#000",border:"1px solid #597BAC",inset_color:"#597BAC",background:"rgba(0, 0, 0, 0.1)"}},button:{color:"white",background:"#3E6CB9"},container:{background:"#F8F8F8",border:"1px solid black"},menu:{border_color:"black",inset_color:"#999",background:"transparent"},
selectable:{color:"black",border:"0px solid transparent",background:"transparent",active:{color:"white",border:"0px solid transparent",background:"#6780E4"},hover:{color:"white",border:"0px solid transparent",background:"#6780E4"}},hint:{color:"#78788D",active:{color:"white"},hover:{color:"white"}},accelerator:{color:"#344DB1",active:{color:"white"},hover:{color:"white"}}},text_editor:{gutter:{color:"#888888",backgroundColor:"#d2d2d2"},editor:{color:"#3D3D3D",backgroundColor:"#ffffff",cursorColor:"#000000",
selectedTextBackgroundColor:"#BDD9FC",unfocusedCursorColor:"#57A1FF",unfocusedCursorBackgroundColor:"#D9E9FC"},highlighterFG:{plain:"#030303",comment:"#919191",directive:"#999999",error:"#ff0000",identifier:"#A7379F",keyword:"#1414EF",operator:"#477ABE",string:"#017F19",addition:"#ffffff",deletion:"#ffffff"},highlighterBG:{plain:"#ffffff",addition:"#008000",deletion:"#800000"},scroller:{padding:5,thickness:17,backgroundStyle:"#2A211C",fullAlpha:1,particalAlpha:0.3,nibStyle:"rgb(150, 150, 150)",nibArrowStyle:"rgb(255, 255, 255)",
nibStrokeStyle:"white",trackFillStyle:"rgba(50, 50, 50, 0.2)",trackStrokeStyle:"rgb(150, 150, 150)",barFillStyle:"rgb(60, 60, 60)",barFillGradientTopStart:"rgb(150, 150, 150)",barFillGradientTopStop:"rgb(100, 100, 100)",barFillGradientBottomStart:"rgb(82, 82, 82)",barFillGradientBottomStop:"rgb(104, 104, 104)"}}}}});bespin.tiki.register("::jquery",{name:"jquery",dependencies:{}});
bespin.tiki.module("jquery:index",function(y,u){function v(){if(!e.isReady){try{l.documentElement.doScroll("left")}catch(a){setTimeout(v,1);return}e.ready()}}function s(a,d){d.src?e.ajax({url:d.src,async:false,dataType:"script"}):e.globalEval(d.text||d.textContent||d.innerHTML||"");d.parentNode&&d.parentNode.removeChild(d)}function o(a,d,i,n,m,A){var B=a.length;if(typeof d==="object"){for(var J in d)o(a,J,d[J],n,m,i);return a}if(i!==undefined){n=!A&&n&&e.isFunction(i);for(J=0;J<B;J++)m(a[J],d,n?i.call(a[J],
J,m(a[J],d)):i,A);return a}return B?m(a[0],d):undefined}function k(){return(new Date).getTime()}function b(){return false}function f(){return true}function q(a,d,i){i[0].type=a;return e.event.handle.apply(d,i)}function h(a){var d,i=[],n=[],m=arguments,A,B,J,E,I,Q;B=e.data(this,"events");if(!(a.liveFired===this||!B||!B.live||a.button&&a.type==="click")){a.liveFired=this;var V=B.live.slice(0);for(E=0;E<V.length;E++){B=V[E];B.origType.replace(ua,"")===a.type?n.push(B.selector):V.splice(E--,1)}A=e(a.target).closest(n,
a.currentTarget);I=0;for(Q=A.length;I<Q;I++)for(E=0;E<V.length;E++){B=V[E];if(A[I].selector===B.selector){J=A[I].elem;n=null;if(B.preType==="mouseenter"||B.preType==="mouseleave")n=e(a.relatedTarget).closest(B.selector)[0];if(!n||n!==J)i.push({elem:J,handleObj:B})}}I=0;for(Q=i.length;I<Q;I++){A=i[I];a.currentTarget=A.elem;a.data=A.handleObj.data;a.handleObj=A.handleObj;if(A.handleObj.origHandler.apply(A.elem,m)===false){d=false;break}}return d}}function j(a,d){return"live."+(a&&a!=="*"?a+".":"")+
d.replace(/\./g,"`").replace(/ /g,"&")}function g(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function p(a,d){var i=0;d.each(function(){if(this.nodeName===(a[i]&&a[i].nodeName)){var n=e.data(a[i++]),m=e.data(this,n);if(n=n&&n.events){delete m.handle;m.events={};for(var A in n)for(var B in n[A])e.event.add(this,A,n[A][B],n[A][B].data)}}})}function r(a,d,i){var n,m,A;d=d&&d[0]?d[0].ownerDocument||d[0]:l;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&d===l&&!Ia.test(a[0])&&(e.support.checkClone||
!Ja.test(a[0]))){m=true;if(A=e.fragments[a[0]])if(A!==1)n=A}if(!n){n=d.createDocumentFragment();e.clean(a,d,n,i)}if(m)e.fragments[a[0]]=A?n:1;return{fragment:n,cacheable:m}}function z(a,d){var i={};e.each(Ka.concat.apply([],Ka.slice(0,d)),function(){i[this]=a});return i}function C(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var e=function(a,d){return new e.fn.init(a,d)},K=window.jQuery,M=window.$,l=window.document,w,D=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
H=/^.[^:#\[\.,]*$/,R=/\S/,W=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,$=/^<(\w+)\s*\/?>(?:<\/\1>)?$/;y=navigator.userAgent;var ea=false,Y=[],da,ia=Object.prototype.toString,ma=Object.prototype.hasOwnProperty,na=Array.prototype.push,oa=Array.prototype.slice,ta=Array.prototype.indexOf;e.fn=e.prototype={init:function(a,d){var i,n;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!d){this.context=l;this[0]=l.body;this.selector="body";this.length=1;return this}if(typeof a===
"string")if((i=D.exec(a))&&(i[1]||!d))if(i[1]){n=d?d.ownerDocument||d:l;if(a=$.exec(a))if(e.isPlainObject(d)){a=[l.createElement(a[1])];e.fn.attr.call(a,d,true)}else a=[n.createElement(a[1])];else{a=r([i[1]],[n]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return e.merge(this,a)}else{if(d=l.getElementById(i[2])){if(d.id!==i[2])return w.find(a);this.length=1;this[0]=d}this.context=l;this.selector=a;return this}else if(!d&&/^\w+$/.test(a)){this.selector=a;this.context=l;a=l.getElementsByTagName(a);
return e.merge(this,a)}else return!d||d.jquery?(d||w).find(a):e(d).find(a);else if(e.isFunction(a))return w.ready(a);if(a.selector!==undefined){this.selector=a.selector;this.context=a.context}return e.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return oa.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,d,i){var n=e();e.isArray(a)?na.apply(n,a):e.merge(n,a);n.prevObject=this;
n.context=this.context;if(d==="find")n.selector=this.selector+(this.selector?" ":"")+i;else if(d)n.selector=this.selector+"."+d+"("+i+")";return n},each:function(a,d){return e.each(this,a,d)},ready:function(a){e.bindReady();if(e.isReady)a.call(l,e);else Y&&Y.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(oa.apply(this,arguments),"slice",oa.call(arguments).join(","))},
map:function(a){return this.pushStack(e.map(this,function(d,i){return a.call(d,i,d)}))},end:function(){return this.prevObject||e(null)},push:na,sort:[].sort,splice:[].splice};e.fn.init.prototype=e.fn;e.extend=e.fn.extend=function(){var a=arguments[0]||{},d=1,i=arguments.length,n=false,m,A,B,J;if(typeof a==="boolean"){n=a;a=arguments[1]||{};d=2}if(typeof a!=="object"&&!e.isFunction(a))a={};if(i===d){a=this;--d}for(;d<i;d++)if((m=arguments[d])!=null)for(A in m){B=a[A];J=m[A];if(a!==J)if(n&&J&&(e.isPlainObject(J)||
e.isArray(J))){B=B&&(e.isPlainObject(B)||e.isArray(B))?B:e.isArray(J)?[]:{};a[A]=e.extend(n,B,J)}else if(J!==undefined)a[A]=J}return a};e.extend({noConflict:function(a){window.$=M;if(a)window.jQuery=K;return e},isReady:false,ready:function(){if(!e.isReady){if(!l.body)return setTimeout(e.ready,13);e.isReady=true;if(Y){for(var a,d=0;a=Y[d++];)a.call(l,e);Y=null}e.fn.triggerHandler&&e(l).triggerHandler("ready")}},bindReady:function(){if(!ea){ea=true;if(l.readyState==="complete")return e.ready();if(l.addEventListener){l.addEventListener("DOMContentLoaded",
da,false);window.addEventListener("load",e.ready,false)}else if(l.attachEvent){l.attachEvent("onreadystatechange",da);window.attachEvent("onload",e.ready);var a=false;try{a=window.frameElement==null}catch(d){}l.documentElement.doScroll&&a&&v()}}},isFunction:function(a){return ia.call(a)==="[object Function]"},isArray:function(a){return ia.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||ia.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!ma.call(a,
"constructor")&&!ma.call(a.constructor.prototype,"isPrototypeOf"))return false;var d;for(d in a);return d===undefined||ma.call(a,d)},isEmptyObject:function(a){for(var d in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=e.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return window.JSON&&
window.JSON.parse?window.JSON.parse(a):(new Function("return "+a))();else e.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&R.test(a)){var d=l.getElementsByTagName("head")[0]||l.documentElement,i=l.createElement("script");i.type="text/javascript";if(e.support.scriptEval)i.appendChild(l.createTextNode(a));else i.text=a;d.insertBefore(i,d.firstChild);d.removeChild(i)}},nodeName:function(a,d){return a.nodeName&&a.nodeName.toUpperCase()===d.toUpperCase()},each:function(a,d,i){var n,
m=0,A=a.length,B=A===undefined||e.isFunction(a);if(i)if(B)for(n in a){if(d.apply(a[n],i)===false)break}else for(;m<A;){if(d.apply(a[m++],i)===false)break}else if(B)for(n in a){if(d.call(a[n],n,a[n])===false)break}else for(i=a[0];m<A&&d.call(i,m,i)!==false;i=a[++m]);return a},trim:function(a){return(a||"").replace(W,"")},makeArray:function(a,d){d=d||[];if(a!=null)a.length==null||typeof a==="string"||e.isFunction(a)||typeof a!=="function"&&a.setInterval?na.call(d,a):e.merge(d,a);return d},inArray:function(a,
d){if(d.indexOf)return d.indexOf(a);for(var i=0,n=d.length;i<n;i++)if(d[i]===a)return i;return-1},merge:function(a,d){var i=a.length,n=0;if(typeof d.length==="number")for(var m=d.length;n<m;n++)a[i++]=d[n];else for(;d[n]!==undefined;)a[i++]=d[n++];a.length=i;return a},grep:function(a,d,i){for(var n=[],m=0,A=a.length;m<A;m++)!i!==!d(a[m],m)&&n.push(a[m]);return n},map:function(a,d,i){for(var n=[],m,A=0,B=a.length;A<B;A++){m=d(a[A],A,i);if(m!=null)n[n.length]=m}return n.concat.apply([],n)},guid:1,proxy:function(a,
d,i){if(arguments.length===2)if(typeof d==="string"){i=a;a=i[d];d=undefined}else if(d&&!e.isFunction(d)){i=d;d=undefined}if(!d&&a)d=function(){return a.apply(i||this,arguments)};if(a)d.guid=a.guid=a.guid||d.guid||e.guid++;return d},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});
y=e.uaMatch(y);if(y.browser){e.browser[y.browser]=true;e.browser.version=y.version}if(e.browser.webkit)e.browser.safari=true;if(ta)e.inArray=function(a,d){return ta.call(d,a)};w=e(l);if(l.addEventListener)da=function(){l.removeEventListener("DOMContentLoaded",da,false);e.ready()};else if(l.attachEvent)da=function(){if(l.readyState==="complete"){l.detachEvent("onreadystatechange",da);e.ready()}};(function(){e.support={};var a=l.documentElement,d=l.createElement("script"),i=l.createElement("div"),n=
"script"+k();i.style.display="none";i.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var m=i.getElementsByTagName("*"),A=i.getElementsByTagName("a")[0];if(!(!m||!m.length||!A)){e.support={leadingWhitespace:i.firstChild.nodeType===3,tbody:!i.getElementsByTagName("tbody").length,htmlSerialize:!!i.getElementsByTagName("link").length,style:/red/.test(A.getAttribute("style")),hrefNormalized:A.getAttribute("href")==="/a",opacity:/^0.55$/.test(A.style.opacity),
cssFloat:!!A.style.cssFloat,checkOn:i.getElementsByTagName("input")[0].value==="on",optSelected:l.createElement("select").appendChild(l.createElement("option")).selected,parentNode:i.removeChild(i.appendChild(l.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};d.type="text/javascript";try{d.appendChild(l.createTextNode("window."+n+"=1;"))}catch(B){}a.insertBefore(d,a.firstChild);if(window[n]){e.support.scriptEval=true;delete window[n]}try{delete d.test}catch(J){e.support.deleteExpando=
false}a.removeChild(d);if(i.attachEvent&&i.fireEvent){i.attachEvent("onclick",function E(){e.support.noCloneEvent=false;i.detachEvent("onclick",E)});i.cloneNode(true).fireEvent("onclick")}i=l.createElement("div");i.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=l.createDocumentFragment();a.appendChild(i.firstChild);e.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;e(function(){var E=l.createElement("div");E.style.width=E.style.paddingLeft="1px";l.body.appendChild(E);
e.boxModel=e.support.boxModel=E.offsetWidth===2;l.body.removeChild(E).style.display="none"});a=function(E){var I=l.createElement("div");E="on"+E;var Q=E in I;if(!Q){I.setAttribute(E,"return;");Q=typeof I[E]==="function"}return Q};e.support.submitBubbles=a("submit");e.support.changeBubbles=a("change");a=d=i=m=A=null}})();e.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",
frameborder:"frameBorder"};var L="jQuery"+k(),P=0,S={};e.extend({cache:{},expando:L,noData:{embed:true,object:true,applet:true},data:function(a,d,i){if(!(a.nodeName&&e.noData[a.nodeName.toLowerCase()])){a=a==window?S:a;var n=a[L],m=e.cache;if(!n&&typeof d==="string"&&i===undefined)return null;n||(n=++P);if(typeof d==="object"){a[L]=n;m[n]=e.extend(true,{},d)}else if(!m[n]){a[L]=n;m[n]={}}a=m[n];if(i!==undefined)a[d]=i;return typeof d==="string"?a[d]:a}},removeData:function(a,d){if(!(a.nodeName&&e.noData[a.nodeName.toLowerCase()])){a=
a==window?S:a;var i=a[L],n=e.cache,m=n[i];if(d){if(m){delete m[d];e.isEmptyObject(m)&&e.removeData(a)}}else{if(e.support.deleteExpando)delete a[e.expando];else a.removeAttribute&&a.removeAttribute(e.expando);delete n[i]}}}});e.fn.extend({data:function(a,d){if(typeof a==="undefined"&&this.length)return e.data(this[0]);else if(typeof a==="object")return this.each(function(){e.data(this,a)});var i=a.split(".");i[1]=i[1]?"."+i[1]:"";if(d===undefined){var n=this.triggerHandler("getData"+i[1]+"!",[i[0]]);
if(n===undefined&&this.length)n=e.data(this[0],a);return n===undefined&&i[1]?this.data(i[0]):n}else return this.trigger("setData"+i[1]+"!",[i[0],d]).each(function(){e.data(this,a,d)})},removeData:function(a){return this.each(function(){e.removeData(this,a)})}});e.extend({queue:function(a,d,i){if(a){d=(d||"fx")+"queue";var n=e.data(a,d);if(!i)return n||[];if(!n||e.isArray(i))n=e.data(a,d,e.makeArray(i));else n.push(i);return n}},dequeue:function(a,d){d=d||"fx";var i=e.queue(a,d),n=i.shift();if(n===
"inprogress")n=i.shift();if(n){d==="fx"&&i.unshift("inprogress");n.call(a,function(){e.dequeue(a,d)})}}});e.fn.extend({queue:function(a,d){if(typeof a!=="string"){d=a;a="fx"}if(d===undefined)return e.queue(this[0],a);return this.each(function(){var i=e.queue(this,a,d);a==="fx"&&i[0]!=="inprogress"&&e.dequeue(this,a)})},dequeue:function(a){return this.each(function(){e.dequeue(this,a)})},delay:function(a,d){a=e.fx?e.fx.speeds[a]||a:a;d=d||"fx";return this.queue(d,function(){var i=this;setTimeout(function(){e.dequeue(i,
d)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var T=/[\n\t]/g,aa=/\s+/,ha=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,cb=/^(a|area)$/i,La=/radio|checkbox/;e.fn.extend({attr:function(a,d){return o(this,a,d,true,e.attr)},removeAttr:function(a){return this.each(function(){e.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(e.isFunction(a))return this.each(function(I){var Q=e(this);Q.addClass(a.call(this,
I,Q.attr("class")))});if(a&&typeof a==="string")for(var d=(a||"").split(aa),i=0,n=this.length;i<n;i++){var m=this[i];if(m.nodeType===1)if(m.className){for(var A=" "+m.className+" ",B=m.className,J=0,E=d.length;J<E;J++)if(A.indexOf(" "+d[J]+" ")<0)B+=" "+d[J];m.className=e.trim(B)}else m.className=a}return this},removeClass:function(a){if(e.isFunction(a))return this.each(function(E){var I=e(this);I.removeClass(a.call(this,E,I.attr("class")))});if(a&&typeof a==="string"||a===undefined)for(var d=(a||
"").split(aa),i=0,n=this.length;i<n;i++){var m=this[i];if(m.nodeType===1&&m.className)if(a){for(var A=(" "+m.className+" ").replace(T," "),B=0,J=d.length;B<J;B++)A=A.replace(" "+d[B]+" "," ");m.className=e.trim(A)}else m.className=""}return this},toggleClass:function(a,d){var i=typeof a,n=typeof d==="boolean";if(e.isFunction(a))return this.each(function(m){var A=e(this);A.toggleClass(a.call(this,m,A.attr("class"),d),d)});return this.each(function(){if(i==="string")for(var m,A=0,B=e(this),J=d,E=a.split(aa);m=
E[A++];){J=n?J:!B.hasClass(m);B[J?"addClass":"removeClass"](m)}else if(i==="undefined"||i==="boolean"){this.className&&e.data(this,"__className__",this.className);this.className=this.className||a===false?"":e.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var d=0,i=this.length;d<i;d++)if((" "+this[d].className+" ").replace(T," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===undefined){var d=this[0];if(d){if(e.nodeName(d,"option"))return(d.attributes.value||
{}).specified?d.value:d.text;if(e.nodeName(d,"select")){var i=d.selectedIndex,n=[],m=d.options;d=d.type==="select-one";if(i<0)return null;var A=d?i:0;for(i=d?i+1:m.length;A<i;A++){var B=m[A];if(B.selected){a=e(B).val();if(d)return a;n.push(a)}}return n}if(La.test(d.type)&&!e.support.checkOn)return d.getAttribute("value")===null?"on":d.value;return(d.value||"").replace(ha,"")}}else{var J=e.isFunction(a);return this.each(function(E){var I=e(this),Q=a;if(this.nodeType===1){if(J)Q=a.call(this,E,I.val());
if(typeof Q==="number")Q+="";if(e.isArray(Q)&&La.test(this.type))this.checked=e.inArray(I.val(),Q)>=0;else if(e.nodeName(this,"select")){var V=e.makeArray(Q);e("option",this).each(function(){this.selected=e.inArray(e(this).val(),V)>=0});if(!V.length)this.selectedIndex=-1}else this.value=Q}})}}});e.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,d,i,n){if(!(!a||a.nodeType===3||a.nodeType===8)){if(n&&d in e.attrFn)return e(a)[d](i);
n=a.nodeType!==1||!e.isXMLDoc(a);var m=i!==undefined;d=n&&e.props[d]||d;if(a.nodeType===1){var A=$a.test(d);if(d in a&&n&&!A){if(m){d==="type"&&ab.test(a.nodeName)&&a.parentNode&&e.error("type property can't be changed");a[d]=i}if(e.nodeName(a,"form")&&a.getAttributeNode(d))return a.getAttributeNode(d).nodeValue;if(d==="tabIndex")return(d=a.getAttributeNode("tabIndex"))&&d.specified?d.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:undefined;return a[d]}if(!e.support.style&&n&&d==="style"){if(m)a.style.cssText=
""+i;return a.style.cssText}m&&a.setAttribute(d,""+i);a=!e.support.hrefNormalized&&n&&A?a.getAttribute(d,2):a.getAttribute(d);return a===null?undefined:a}return e.style(a,d,i)}}});var ua=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,function(d){return"\\"+d})};e.event={add:function(a,d,i,n){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==window&&!a.frameElement)a=window;var m,A;if(i.handler){m=i;i=m.handler}if(!i.guid)i.guid=e.guid++;if(A=e.data(a)){var B=A.events=A.events||
{},J=A.handle;if(!J)A.handle=J=function(){return typeof e!=="undefined"&&!e.event.triggered?e.event.handle.apply(J.elem,arguments):undefined};J.elem=a;d=d.split(" ");for(var E,I=0,Q;E=d[I++];){A=m?e.extend({},m):{handler:i,data:n};if(E.indexOf(".")>-1){Q=E.split(".");E=Q.shift();A.namespace=Q.slice(0).sort().join(".")}else{Q=[];A.namespace=""}A.type=E;A.guid=i.guid;var V=B[E],ca=e.event.special[E]||{};if(!V){V=B[E]=[];if(!ca.setup||ca.setup.call(a,n,Q,J)===false)if(a.addEventListener)a.addEventListener(E,
J,false);else a.attachEvent&&a.attachEvent("on"+E,J)}if(ca.add){ca.add.call(a,A);if(!A.handler.guid)A.handler.guid=i.guid}V.push(A);e.event.global[E]=true}a=null}}},global:{},remove:function(a,d,i,n){if(!(a.nodeType===3||a.nodeType===8)){var m,A=0,B,J,E,I,Q,V,ca=e.data(a),ga=ca&&ca.events;if(ca&&ga){if(d&&d.type){i=d.handler;d=d.type}if(!d||typeof d==="string"&&d.charAt(0)==="."){d=d||"";for(m in ga)e.event.remove(a,m+d)}else{for(d=d.split(" ");m=d[A++];){I=m;B=m.indexOf(".")<0;J=[];if(!B){J=m.split(".");
m=J.shift();E=new RegExp("(^|\\.)"+e.map(J.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(Q=ga[m])if(i){I=e.event.special[m]||{};for(fa=n||0;fa<Q.length;fa++){V=Q[fa];if(i.guid===V.guid){if(B||E.test(V.namespace)){n==null&&Q.splice(fa--,1);I.remove&&I.remove.call(a,V)}if(n!=null)break}}if(Q.length===0||n!=null&&Q.length===1){if(!I.teardown||I.teardown.call(a,J)===false)Ma(a,m,ca.handle);delete ga[m]}}else for(var fa=0;fa<Q.length;fa++){V=Q[fa];if(B||E.test(V.namespace)){e.event.remove(a,
I,V.handler,fa);Q.splice(fa--,1)}}}if(e.isEmptyObject(ga)){if(d=ca.handle)d.elem=null;delete ca.events;delete ca.handle;e.isEmptyObject(ca)&&e.removeData(a)}}}}},trigger:function(a,d,i,n){var m=a.type||a;if(!n){a=typeof a==="object"?a[L]?a:e.extend(e.Event(m),a):e.Event(m);if(m.indexOf("!")>=0){a.type=m=m.slice(0,-1);a.exclusive=true}if(!i){a.stopPropagation();e.event.global[m]&&e.each(e.cache,function(){this.events&&this.events[m]&&e.event.trigger(a,d,this.handle.elem)})}if(!i||i.nodeType===3||i.nodeType===
8)return;a.result=undefined;a.target=i;d=e.makeArray(d);d.unshift(a)}a.currentTarget=i;(n=e.data(i,"handle"))&&n.apply(i,d);n=i.parentNode||i.ownerDocument;try{if(!(i&&i.nodeName&&e.noData[i.nodeName.toLowerCase()]))if(i["on"+m]&&i["on"+m].apply(i,d)===false)a.result=false}catch(A){}if(!a.isPropagationStopped()&&n)e.event.trigger(a,d,n,true);else if(!a.isDefaultPrevented()){n=a.target;var B,J=e.nodeName(n,"a")&&m==="click",E=e.event.special[m]||{};if((!E._default||E._default.call(i,a)===false)&&!J&&
!(n&&n.nodeName&&e.noData[n.nodeName.toLowerCase()])){try{if(n[m]){if(B=n["on"+m])n["on"+m]=null;e.event.triggered=true;n[m]()}}catch(I){}if(B)n["on"+m]=B;e.event.triggered=false}}},handle:function(a){var d,i,n,m;a=arguments[0]=e.event.fix(a||window.event);a.currentTarget=this;d=a.type.indexOf(".")<0&&!a.exclusive;if(!d){i=a.type.split(".");a.type=i.shift();n=new RegExp("(^|\\.)"+i.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}m=e.data(this,"events");i=m[a.type];if(m&&i){i=i.slice(0);m=0;for(var A=
i.length;m<A;m++){var B=i[m];if(d||n.test(B.namespace)){a.handler=B.handler;a.data=B.data;a.handleObj=B;B=B.handler.apply(this,arguments);if(B!==undefined){a.result=B;if(B===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
fix:function(a){if(a[L])return a;var d=a;a=e.Event(d);for(var i=this.props.length,n;i;){n=this.props[--i];a[n]=d[n]}if(!a.target)a.target=a.srcElement||l;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){d=l.documentElement;i=l.body;a.pageX=a.clientX+(d&&d.scrollLeft||i&&i.scrollLeft||0)-(d&&d.clientLeft||i&&i.clientLeft||0);a.pageY=a.clientY+(d&&d.scrollTop||
i&&i.scrollTop||0)-(d&&d.clientTop||i&&i.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==undefined)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:e.proxy,special:{ready:{setup:e.bindReady,teardown:e.noop},live:{add:function(a){e.event.add(this,a.origType,e.extend({},a,{handler:h}))},remove:function(a){var d=true,i=a.origType.replace(ua,"");e.each(e.data(this,
"events").live||[],function(){if(i===this.origType.replace(ua,""))return d=false});d&&e.event.remove(this,a.origType,h)}},beforeunload:{setup:function(a,d,i){if(this.setInterval)this.onbeforeunload=i;return false},teardown:function(a,d){if(this.onbeforeunload===d)this.onbeforeunload=null}}}};var Ma=l.removeEventListener?function(a,d,i){a.removeEventListener(d,i,false)}:function(a,d,i){a.detachEvent("on"+d,i)};e.Event=function(a){if(!this.preventDefault)return new e.Event(a);if(a&&a.type){this.originalEvent=
a;this.type=a.type}else this.type=a;this.timeStamp=k();this[L]=true};e.Event.prototype={preventDefault:function(){this.isDefaultPrevented=f;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=f;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=f;this.stopPropagation()},isDefaultPrevented:b,isPropagationStopped:b,
isImmediatePropagationStopped:b};var Na=function(a){var d=a.relatedTarget;try{for(;d&&d!==this;)d=d.parentNode;if(d!==this){a.type=a.data;e.event.handle.apply(this,arguments)}}catch(i){}},Oa=function(a){a.type=a.data;e.event.handle.apply(this,arguments)};e.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,d){e.event.special[a]={setup:function(i){e.event.add(this,d,i&&i.selector?Oa:Na,a)},teardown:function(i){e.event.remove(this,d,i&&i.selector?Oa:Na)}}});if(!e.support.submitBubbles)e.event.special.submit=
{setup:function(){if(this.nodeName.toLowerCase()!=="form"){e.event.add(this,"click.specialSubmit",function(a){var d=a.target,i=d.type;if((i==="submit"||i==="image")&&e(d).closest("form").length)return q("submit",this,arguments)});e.event.add(this,"keypress.specialSubmit",function(a){var d=a.target,i=d.type;if((i==="text"||i==="password")&&e(d).closest("form").length&&a.keyCode===13)return q("submit",this,arguments)})}else return false},teardown:function(){e.event.remove(this,".specialSubmit")}};if(!e.support.changeBubbles){var za=
/textarea|input|select/i,Aa,Pa=function(a){var d=a.type,i=a.value;if(d==="radio"||d==="checkbox")i=a.checked;else if(d==="select-multiple")i=a.selectedIndex>-1?e.map(a.options,function(n){return n.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")i=a.selectedIndex;return i},Ba=function(a,d){var i=a.target,n,m;if(!(!za.test(i.nodeName)||i.readOnly)){n=e.data(i,"_change_data");m=Pa(i);if(a.type!=="focusout"||i.type!=="radio")e.data(i,"_change_data",m);if(!(n===undefined||m===n))if(n!=
null||m){a.type="change";return e.event.trigger(a,d,i)}}};e.event.special.change={filters:{focusout:Ba,click:function(a){var d=a.target,i=d.type;if(i==="radio"||i==="checkbox"||d.nodeName.toLowerCase()==="select")return Ba.call(this,a)},keydown:function(a){var d=a.target,i=d.type;if(a.keyCode===13&&d.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(i==="checkbox"||i==="radio")||i==="select-multiple")return Ba.call(this,a)},beforeactivate:function(a){a=a.target;e.data(a,"_change_data",Pa(a))}},
setup:function(){if(this.type==="file")return false;for(var a in Aa)e.event.add(this,a+".specialChange",Aa[a]);return za.test(this.nodeName)},teardown:function(){e.event.remove(this,".specialChange");return za.test(this.nodeName)}};Aa=e.event.special.change.filters}l.addEventListener&&e.each({focus:"focusin",blur:"focusout"},function(a,d){function i(n){n=e.event.fix(n);n.type=d;return e.event.handle.call(this,n)}e.event.special[d]={setup:function(){this.addEventListener(a,i,true)},teardown:function(){this.removeEventListener(a,
i,true)}}});e.each(["bind","one"],function(a,d){e.fn[d]=function(i,n,m){if(typeof i==="object"){for(var A in i)this[d](A,n,i[A],m);return this}if(e.isFunction(n)){m=n;n=undefined}var B=d==="one"?e.proxy(m,function(E){e(this).unbind(E,B);return m.apply(this,arguments)}):m;if(i==="unload"&&d!=="one")this.one(i,n,m);else{A=0;for(var J=this.length;A<J;A++)e.event.add(this[A],i,B,n)}return this}});e.fn.extend({unbind:function(a,d){if(typeof a==="object"&&!a.preventDefault)for(var i in a)this.unbind(i,
a[i]);else{i=0;for(var n=this.length;i<n;i++)e.event.remove(this[i],a,d)}return this},delegate:function(a,d,i,n){return this.live(d,i,n,a)},undelegate:function(a,d,i){return arguments.length===0?this.unbind("live"):this.die(d,null,i,a)},trigger:function(a,d){return this.each(function(){e.event.trigger(a,d,this)})},triggerHandler:function(a,d){if(this[0]){a=e.Event(a);a.preventDefault();a.stopPropagation();e.event.trigger(a,d,this[0]);return a.result}},toggle:function(a){for(var d=arguments,i=1;i<
d.length;)e.proxy(a,d[i++]);return this.click(e.proxy(a,function(n){var m=(e.data(this,"lastToggle"+a.guid)||0)%i;e.data(this,"lastToggle"+a.guid,m+1);n.preventDefault();return d[m].apply(this,arguments)||false}))},hover:function(a,d){return this.mouseenter(a).mouseleave(d||a)}});var Qa={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};e.each(["live","die"],function(a,d){e.fn[d]=function(i,n,m,A){var B,J=0,E,I,Q=A||this.selector,V=A?this:e(this.context);if(e.isFunction(n)){m=
n;n=undefined}for(i=(i||"").split(" ");(B=i[J++])!=null;){A=ua.exec(B);E="";if(A){E=A[0];B=B.replace(ua,"")}if(B==="hover")i.push("mouseenter"+E,"mouseleave"+E);else{I=B;if(B==="focus"||B==="blur"){i.push(Qa[B]+E);B+=E}else B=(Qa[B]||B)+E;d==="live"?V.each(function(){e.event.add(this,j(B,Q),{data:n,selector:Q,handler:m,origType:B,origHandler:m,preType:I})}):V.unbind(j(B,Q),m)}}return this}});e.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
function(a,d){e.fn[d]=function(i){return i?this.bind(d,i):this.trigger(d)};if(e.attrFn)e.attrFn[d]=true});window.attachEvent&&!window.addEventListener&&window.attachEvent("onunload",function(){for(var a in e.cache)if(e.cache[a].handle)try{e.event.remove(e.cache[a].handle.elem)}catch(d){}});(function(){function a(t){for(var x="",F,G=0;t[G];G++){F=t[G];if(F.nodeType===3||F.nodeType===4)x+=F.nodeValue;else if(F.nodeType!==8)x+=a(F.childNodes)}return x}function d(t,x,F,G,O,N){O=0;for(var X=G.length;O<
X;O++){var U=G[O];if(U){U=U[t];for(var ba=false;U;){if(U.sizcache===F){ba=G[U.sizset];break}if(U.nodeType===1&&!N){U.sizcache=F;U.sizset=O}if(U.nodeName.toLowerCase()===x){ba=U;break}U=U[t]}G[O]=ba}}}function i(t,x,F,G,O,N){O=0;for(var X=G.length;O<X;O++){var U=G[O];if(U){U=U[t];for(var ba=false;U;){if(U.sizcache===F){ba=G[U.sizset];break}if(U.nodeType===1){if(!N){U.sizcache=F;U.sizset=O}if(typeof x!=="string"){if(U===x){ba=true;break}}else if(E.filter(x,[U]).length>0){ba=U;break}}U=U[t]}G[O]=ba}}}
var n=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,m=0,A=Object.prototype.toString,B=false,J=true;[0,0].sort(function(){J=false;return 0});var E=function(t,x,F,G){F=F||[];var O=x=x||l;if(x.nodeType!==1&&x.nodeType!==9)return[];if(!t||typeof t!=="string")return F;for(var N=[],X,U,ba,va,pa=true,ra=Z(x),qa=t;(n.exec(""),X=n.exec(qa))!==null;){qa=X[3];N.push(X[1]);if(X[2]){va=X[3];break}}if(N.length>1&&Q.exec(t))if(N.length===
2&&I.relative[N[0]])U=Ca(N[0]+N[1],x);else for(U=I.relative[N[0]]?[x]:E(N.shift(),x);N.length;){t=N.shift();if(I.relative[t])t+=N.shift();U=Ca(t,U)}else{if(!G&&N.length>1&&x.nodeType===9&&!ra&&I.match.ID.test(N[0])&&!I.match.ID.test(N[N.length-1])){X=E.find(N.shift(),x,ra);x=X.expr?E.filter(X.expr,X.set)[0]:X.set[0]}if(x){X=G?{expr:N.pop(),set:ca(G)}:E.find(N.pop(),N.length===1&&(N[0]==="~"||N[0]==="+")&&x.parentNode?x.parentNode:x,ra);U=X.expr?E.filter(X.expr,X.set):X.set;if(N.length>0)ba=ca(U);
else pa=false;for(;N.length;){var ja=N.pop();X=ja;if(I.relative[ja])X=N.pop();else ja="";if(X==null)X=x;I.relative[ja](ba,X,ra)}}else ba=[]}ba||(ba=U);ba||E.error(ja||t);if(A.call(ba)==="[object Array]")if(pa)if(x&&x.nodeType===1)for(t=0;ba[t]!=null;t++){if(ba[t]&&(ba[t]===true||ba[t].nodeType===1&&ka(x,ba[t])))F.push(U[t])}else for(t=0;ba[t]!=null;t++)ba[t]&&ba[t].nodeType===1&&F.push(U[t]);else F.push.apply(F,ba);else ca(ba,F);if(va){E(va,O,F,G);E.uniqueSort(F)}return F};E.uniqueSort=function(t){if(fa){B=
J;t.sort(fa);if(B)for(var x=1;x<t.length;x++)t[x]===t[x-1]&&t.splice(x--,1)}return t};E.matches=function(t,x){return E(t,null,null,x)};E.find=function(t,x,F){var G,O;if(!t)return[];for(var N=0,X=I.order.length;N<X;N++){var U=I.order[N];if(O=I.leftMatch[U].exec(t)){var ba=O[1];O.splice(1,1);if(ba.substr(ba.length-1)!=="\\"){O[1]=(O[1]||"").replace(/\\/g,"");G=I.find[U](O,x,F);if(G!=null){t=t.replace(I.match[U],"");break}}}}G||(G=x.getElementsByTagName("*"));return{set:G,expr:t}};E.filter=function(t,
x,F,G){for(var O=t,N=[],X=x,U,ba,va=x&&x[0]&&Z(x[0]);t&&x.length;){for(var pa in I.filter)if((U=I.leftMatch[pa].exec(t))!=null&&U[2]){var ra=I.filter[pa],qa,ja;ja=U[1];ba=false;U.splice(1,1);if(ja.substr(ja.length-1)!=="\\"){if(X===N)N=[];if(I.preFilter[pa])if(U=I.preFilter[pa](U,X,F,N,G,va)){if(U===true)continue}else ba=qa=true;if(U)for(var wa=0;(ja=X[wa])!=null;wa++)if(ja){qa=ra(ja,U,wa,X);var Ra=G^!!qa;if(F&&qa!=null)if(Ra)ba=true;else X[wa]=false;else if(Ra){N.push(ja);ba=true}}if(qa!==undefined){F||
(X=N);t=t.replace(I.match[pa],"");if(!ba)return[];break}}}if(t===O)if(ba==null)E.error(t);else break;O=t}return X};E.error=function(t){throw"Syntax error, unrecognized expression: "+t;};var I=E.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(t){return t.getAttribute("href")}},relative:{"+":function(t,x){var F=typeof x==="string",G=F&&!/\W/.test(x);F=F&&!G;if(G)x=x.toLowerCase();G=0;for(var O=t.length,N;G<O;G++)if(N=t[G]){for(;(N=N.previousSibling)&&N.nodeType!==1;);t[G]=F||N&&N.nodeName.toLowerCase()===
x?N||false:N===x}F&&E.filter(x,t,true)},">":function(t,x){var F=typeof x==="string";if(F&&!/\W/.test(x)){x=x.toLowerCase();for(var G=0,O=t.length;G<O;G++){var N=t[G];if(N){F=N.parentNode;t[G]=F.nodeName.toLowerCase()===x?F:false}}}else{G=0;for(O=t.length;G<O;G++)if(N=t[G])t[G]=F?N.parentNode:N.parentNode===x;F&&E.filter(x,t,true)}},"":function(t,x,F){var G=m++,O=i;if(typeof x==="string"&&!/\W/.test(x)){var N=x=x.toLowerCase();O=d}O("parentNode",x,G,t,N,F)},"~":function(t,x,F){var G=m++,O=i;if(typeof x===
"string"&&!/\W/.test(x)){var N=x=x.toLowerCase();O=d}O("previousSibling",x,G,t,N,F)}},find:{ID:function(t,x,F){if(typeof x.getElementById!=="undefined"&&!F)return(t=x.getElementById(t[1]))?[t]:[]},NAME:function(t,x){if(typeof x.getElementsByName!=="undefined"){var F=[];x=x.getElementsByName(t[1]);for(var G=0,O=x.length;G<O;G++)x[G].getAttribute("name")===t[1]&&F.push(x[G]);return F.length===0?null:F}},TAG:function(t,x){return x.getElementsByTagName(t[1])}},preFilter:{CLASS:function(t,x,F,G,O,N){t=
" "+t[1].replace(/\\/g,"")+" ";if(N)return t;N=0;for(var X;(X=x[N])!=null;N++)if(X)if(O^(X.className&&(" "+X.className+" ").replace(/[\t\n]/g," ").indexOf(t)>=0))F||G.push(X);else if(F)x[N]=false;return false},ID:function(t){return t[1].replace(/\\/g,"")},TAG:function(t){return t[1].toLowerCase()},CHILD:function(t){if(t[1]==="nth"){var x=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(t[2]==="even"&&"2n"||t[2]==="odd"&&"2n+1"||!/\D/.test(t[2])&&"0n+"+t[2]||t[2]);t[2]=x[1]+(x[2]||1)-0;t[3]=x[3]-0}t[0]=m++;return t},
ATTR:function(t,x,F,G,O,N){x=t[1].replace(/\\/g,"");if(!N&&I.attrMap[x])t[1]=I.attrMap[x];if(t[2]==="~=")t[4]=" "+t[4]+" ";return t},PSEUDO:function(t,x,F,G,O){if(t[1]==="not")if((n.exec(t[3])||"").length>1||/^\w/.test(t[3]))t[3]=E(t[3],null,null,x);else{t=E.filter(t[3],x,F,true^O);F||G.push.apply(G,t);return false}else if(I.match.POS.test(t[0])||I.match.CHILD.test(t[0]))return true;return t},POS:function(t){t.unshift(true);return t}},filters:{enabled:function(t){return t.disabled===false&&t.type!==
"hidden"},disabled:function(t){return t.disabled===true},checked:function(t){return t.checked===true},selected:function(t){return t.selected===true},parent:function(t){return!!t.firstChild},empty:function(t){return!t.firstChild},has:function(t,x,F){return!!E(F[3],t).length},header:function(t){return/h\d/i.test(t.nodeName)},text:function(t){return"text"===t.type},radio:function(t){return"radio"===t.type},checkbox:function(t){return"checkbox"===t.type},file:function(t){return"file"===t.type},password:function(t){return"password"===
t.type},submit:function(t){return"submit"===t.type},image:function(t){return"image"===t.type},reset:function(t){return"reset"===t.type},button:function(t){return"button"===t.type||t.nodeName.toLowerCase()==="button"},input:function(t){return/input|select|textarea|button/i.test(t.nodeName)}},setFilters:{first:function(t,x){return x===0},last:function(t,x,F,G){return x===G.length-1},even:function(t,x){return x%2===0},odd:function(t,x){return x%2===1},lt:function(t,x,F){return x<F[3]-0},gt:function(t,
x,F){return x>F[3]-0},nth:function(t,x,F){return F[3]-0===x},eq:function(t,x,F){return F[3]-0===x}},filter:{PSEUDO:function(t,x,F,G){var O=x[1],N=I.filters[O];if(N)return N(t,F,x,G);else if(O==="contains")return(t.textContent||t.innerText||a([t])||"").indexOf(x[3])>=0;else if(O==="not"){x=x[3];F=0;for(G=x.length;F<G;F++)if(x[F]===t)return false;return true}else E.error("Syntax error, unrecognized expression: "+O)},CHILD:function(t,x){var F=x[1],G=t;switch(F){case "only":case "first":for(;G=G.previousSibling;)if(G.nodeType===
1)return false;if(F==="first")return true;G=t;case "last":for(;G=G.nextSibling;)if(G.nodeType===1)return false;return true;case "nth":F=x[2];var O=x[3];if(F===1&&O===0)return true;x=x[0];var N=t.parentNode;if(N&&(N.sizcache!==x||!t.nodeIndex)){var X=0;for(G=N.firstChild;G;G=G.nextSibling)if(G.nodeType===1)G.nodeIndex=++X;N.sizcache=x}t=t.nodeIndex-O;return F===0?t===0:t%F===0&&t/F>=0}},ID:function(t,x){return t.nodeType===1&&t.getAttribute("id")===x},TAG:function(t,x){return x==="*"&&t.nodeType===
1||t.nodeName.toLowerCase()===x},CLASS:function(t,x){return(" "+(t.className||t.getAttribute("class"))+" ").indexOf(x)>-1},ATTR:function(t,x){var F=x[1];t=I.attrHandle[F]?I.attrHandle[F](t):t[F]!=null?t[F]:t.getAttribute(F);F=t+"";var G=x[2];x=x[4];return t==null?G==="!=":G==="="?F===x:G==="*="?F.indexOf(x)>=0:G==="~="?(" "+F+" ").indexOf(x)>=0:!x?F&&t!==false:G==="!="?F!==x:G==="^="?F.indexOf(x)===0:G==="$="?F.substr(F.length-x.length)===x:G==="|="?F===x||F.substr(0,x.length+1)===x+"-":false},POS:function(t,
x,F,G){var O=I.setFilters[x[2]];if(O)return O(t,F,x,G)}}},Q=I.match.POS;for(var V in I.match){I.match[V]=new RegExp(I.match[V].source+/(?![^\[]*\])(?![^\(]*\))/.source);I.leftMatch[V]=new RegExp(/(^(?:.|\r|\n)*?)/.source+I.match[V].source.replace(/\\(\d+)/g,function(t,x){return"\\"+(x-0+1)}))}var ca=function(t,x){t=Array.prototype.slice.call(t,0);if(x){x.push.apply(x,t);return x}return t};try{Array.prototype.slice.call(l.documentElement.childNodes,0)}catch(ga){ca=function(t,x){x=x||[];if(A.call(t)===
"[object Array]")Array.prototype.push.apply(x,t);else if(typeof t.length==="number")for(var F=0,G=t.length;F<G;F++)x.push(t[F]);else for(F=0;t[F];F++)x.push(t[F]);return x}}var fa;if(l.documentElement.compareDocumentPosition)fa=function(t,x){if(!t.compareDocumentPosition||!x.compareDocumentPosition){if(t==x)B=true;return t.compareDocumentPosition?-1:1}t=t.compareDocumentPosition(x)&4?-1:t===x?0:1;if(t===0)B=true;return t};else if("sourceIndex"in l.documentElement)fa=function(t,x){if(!t.sourceIndex||
!x.sourceIndex){if(t==x)B=true;return t.sourceIndex?-1:1}t=t.sourceIndex-x.sourceIndex;if(t===0)B=true;return t};else if(l.createRange)fa=function(t,x){if(!t.ownerDocument||!x.ownerDocument){if(t==x)B=true;return t.ownerDocument?-1:1}var F=t.ownerDocument.createRange(),G=x.ownerDocument.createRange();F.setStart(t,0);F.setEnd(t,0);G.setStart(x,0);G.setEnd(x,0);t=F.compareBoundaryPoints(Range.START_TO_END,G);if(t===0)B=true;return t};(function(){var t=l.createElement("div"),x="script"+(new Date).getTime();
t.innerHTML="<a name='"+x+"'/>";var F=l.documentElement;F.insertBefore(t,F.firstChild);if(l.getElementById(x)){I.find.ID=function(G,O,N){if(typeof O.getElementById!=="undefined"&&!N)return(O=O.getElementById(G[1]))?O.id===G[1]||typeof O.getAttributeNode!=="undefined"&&O.getAttributeNode("id").nodeValue===G[1]?[O]:undefined:[]};I.filter.ID=function(G,O){var N=typeof G.getAttributeNode!=="undefined"&&G.getAttributeNode("id");return G.nodeType===1&&N&&N.nodeValue===O}}F.removeChild(t);F=t=null})();(function(){var t=
l.createElement("div");t.appendChild(l.createComment(""));if(t.getElementsByTagName("*").length>0)I.find.TAG=function(x,F){F=F.getElementsByTagName(x[1]);if(x[1]==="*"){x=[];for(var G=0;F[G];G++)F[G].nodeType===1&&x.push(F[G]);F=x}return F};t.innerHTML="<a href='#'></a>";if(t.firstChild&&typeof t.firstChild.getAttribute!=="undefined"&&t.firstChild.getAttribute("href")!=="#")I.attrHandle.href=function(x){return x.getAttribute("href",2)};t=null})();l.querySelectorAll&&function(){var t=E,x=l.createElement("div");
x.innerHTML="<p class='TEST'></p>";if(!(x.querySelectorAll&&x.querySelectorAll(".TEST").length===0)){E=function(G,O,N,X){O=O||l;if(!X&&O.nodeType===9&&!Z(O))try{return ca(O.querySelectorAll(G),N)}catch(U){}return t(G,O,N,X)};for(var F in t)E[F]=t[F];x=null}}();(function(){var t=l.createElement("div");t.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!t.getElementsByClassName||t.getElementsByClassName("e").length===0)){t.lastChild.className="e";if(t.getElementsByClassName("e").length!==
1){I.order.splice(1,0,"CLASS");I.find.CLASS=function(x,F,G){if(typeof F.getElementsByClassName!=="undefined"&&!G)return F.getElementsByClassName(x[1])};t=null}}})();var ka=l.compareDocumentPosition?function(t,x){return!!(t.compareDocumentPosition(x)&16)}:function(t,x){return t!==x&&(t.contains?t.contains(x):true)},Z=function(t){return(t=(t?t.ownerDocument||t:0).documentElement)?t.nodeName!=="HTML":false},Ca=function(t,x){var F=[],G="",O;for(x=x.nodeType?[x]:x;O=I.match.PSEUDO.exec(t);){G+=O[0];t=
t.replace(I.match.PSEUDO,"")}t=I.relative[t]?t+"*":t;O=0;for(var N=x.length;O<N;O++)E(t,x[O],F);return E.filter(G,F)};e.find=E;e.expr=E.selectors;e.expr[":"]=e.expr.filters;e.unique=E.uniqueSort;e.text=a;e.isXMLDoc=Z;e.contains=ka})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,gb=/,/;oa=Array.prototype.slice;var Sa=function(a,d,i){if(e.isFunction(d))return e.grep(a,function(m,A){return!!d.call(m,A,m)===i});else if(d.nodeType)return e.grep(a,function(m){return m===d===i});else if(typeof d===
"string"){var n=e.grep(a,function(m){return m.nodeType===1});if(H.test(d))return e.filter(d,n,!i);else d=e.filter(d,n)}return e.grep(a,function(m){return e.inArray(m,d)>=0===i})};e.fn.extend({find:function(a){for(var d=this.pushStack("","find",a),i=0,n=0,m=this.length;n<m;n++){i=d.length;e.find(a,this[n],d);if(n>0)for(var A=i;A<d.length;A++)for(var B=0;B<i;B++)if(d[B]===d[A]){d.splice(A--,1);break}}return d},has:function(a){var d=e(a);return this.filter(function(){for(var i=0,n=d.length;i<n;i++)if(e.contains(this,
d[i]))return true})},not:function(a){return this.pushStack(Sa(this,a,false),"not",a)},filter:function(a){return this.pushStack(Sa(this,a,true),"filter",a)},is:function(a){return!!a&&e.filter(a,this).length>0},closest:function(a,d){if(e.isArray(a)){var i=[],n=this[0],m,A={},B;if(n&&a.length){m=0;for(var J=a.length;m<J;m++){B=a[m];A[B]||(A[B]=e.expr.match.POS.test(B)?e(B,d||this.context):B)}for(;n&&n.ownerDocument&&n!==d;){for(B in A){m=A[B];if(m.jquery?m.index(n)>-1:e(n).is(m)){i.push({selector:B,
elem:n});delete A[B]}}n=n.parentNode}}return i}var E=e.expr.match.POS.test(a)?e(a,d||this.context):null;return this.map(function(I,Q){for(;Q&&Q.ownerDocument&&Q!==d;){if(E?E.index(Q)>-1:e(Q).is(a))return Q;Q=Q.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return e.inArray(this[0],a?e(a):this.parent().children());return e.inArray(a.jquery?a[0]:a,this)},add:function(a,d){a=typeof a==="string"?e(a,d||this.context):e.makeArray(a);d=e.merge(this.get(),a);return this.pushStack(g(a[0])||
g(d[0])?d:e.unique(d))},andSelf:function(){return this.add(this.prevObject)}});e.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return e.dir(a,"parentNode")},parentsUntil:function(a,d,i){return e.dir(a,"parentNode",i)},next:function(a){return e.nth(a,2,"nextSibling")},prev:function(a){return e.nth(a,2,"previousSibling")},nextAll:function(a){return e.dir(a,"nextSibling")},prevAll:function(a){return e.dir(a,"previousSibling")},nextUntil:function(a,d,i){return e.dir(a,
"nextSibling",i)},prevUntil:function(a,d,i){return e.dir(a,"previousSibling",i)},siblings:function(a){return e.sibling(a.parentNode.firstChild,a)},children:function(a){return e.sibling(a.firstChild)},contents:function(a){return e.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:e.makeArray(a.childNodes)}},function(a,d){e.fn[a]=function(i,n){var m=e.map(this,d,i);eb.test(a)||(n=i);if(n&&typeof n==="string")m=e.filter(n,m);m=this.length>1?e.unique(m):m;if((this.length>1||gb.test(n))&&
fb.test(a))m=m.reverse();return this.pushStack(m,a,oa.call(arguments).join(","))}});e.extend({filter:function(a,d,i){if(i)a=":not("+a+")";return e.find.matches(a,d)},dir:function(a,d,i){var n=[];for(a=a[d];a&&a.nodeType!==9&&(i===undefined||a.nodeType!==1||!e(a).is(i));){a.nodeType===1&&n.push(a);a=a[d]}return n},nth:function(a,d,i){d=d||1;for(var n=0;a;a=a[i])if(a.nodeType===1&&++n===d)break;return a},sibling:function(a,d){for(var i=[];a;a=a.nextSibling)a.nodeType===1&&a!==d&&i.push(a);return i}});
var Ta=/ jQuery\d+="(?:\d+|null)"/g,xa=/^\s+/,Ua=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Va=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,Ia=/<script|<object|<embed|<option|<style/i,Ja=/checked\s*(?:[^=]|=\s*.checked.)/i,Wa=function(a,d,i){return hb.test(i)?a:d+"></"+i+">"},la={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>",
"</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};la.optgroup=la.option;la.tbody=la.tfoot=la.colgroup=la.caption=la.thead;la.th=la.td;if(!e.support.htmlSerialize)la._default=[1,"div<div>","</div>"];e.fn.extend({text:function(a){if(e.isFunction(a))return this.each(function(d){var i=e(this);i.text(a.call(this,d,i.text()))});if(typeof a!=="object"&&a!==undefined)return this.empty().append((this[0]&&this[0].ownerDocument||
l).createTextNode(a));return e.text(this)},wrapAll:function(a){if(e.isFunction(a))return this.each(function(i){e(this).wrapAll(a.call(this,i))});if(this[0]){var d=e(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&d.insertBefore(this[0]);d.map(function(){for(var i=this;i.firstChild&&i.firstChild.nodeType===1;)i=i.firstChild;return i}).append(this)}return this},wrapInner:function(a){if(e.isFunction(a))return this.each(function(d){e(this).wrapInner(a.call(this,d))});return this.each(function(){var d=
e(this),i=d.contents();i.length?i.wrapAll(a):d.append(a)})},wrap:function(a){return this.each(function(){e(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){e.nodeName(this,"body")||e(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&
this[0].parentNode)return this.domManip(arguments,false,function(d){this.parentNode.insertBefore(d,this)});else if(arguments.length){var a=e(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(d){this.parentNode.insertBefore(d,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,e(arguments[0]).toArray());return a}},
remove:function(a,d){for(var i=0,n;(n=this[i])!=null;i++)if(!a||e.filter(a,[n]).length){if(!d&&n.nodeType===1){e.cleanData(n.getElementsByTagName("*"));e.cleanData([n])}n.parentNode&&n.parentNode.removeChild(n)}return this},empty:function(){for(var a=0,d;(d=this[a])!=null;a++)for(d.nodeType===1&&e.cleanData(d.getElementsByTagName("*"));d.firstChild;)d.removeChild(d.firstChild);return this},clone:function(a){var d=this.map(function(){if(!e.support.noCloneEvent&&!e.isXMLDoc(this)){var i=this.outerHTML,
n=this.ownerDocument;if(!i){i=n.createElement("div");i.appendChild(this.cloneNode(true));i=i.innerHTML}return e.clean([i.replace(Ta,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(xa,"")],n)[0]}else return this.cloneNode(true)});if(a===true){p(this,d);p(this.find("*"),d.find("*"))}return d},html:function(a){if(a===undefined)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ta,""):null;else if(typeof a==="string"&&!Ia.test(a)&&(e.support.leadingWhitespace||!xa.test(a))&&!la[(Va.exec(a)||
["",""])[1].toLowerCase()]){a=a.replace(Ua,Wa);try{for(var d=0,i=this.length;d<i;d++)if(this[d].nodeType===1){e.cleanData(this[d].getElementsByTagName("*"));this[d].innerHTML=a}}catch(n){this.empty().append(a)}}else e.isFunction(a)?this.each(function(m){var A=e(this),B=A.html();A.empty().append(function(){return a.call(this,m,B)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(e.isFunction(a))return this.each(function(d){var i=e(this),n=i.html();i.replaceWith(a.call(this,
d,n))});if(typeof a!=="string")a=e(a).detach();return this.each(function(){var d=this.nextSibling,i=this.parentNode;e(this).remove();d?e(d).before(a):e(i).append(a)})}else return this.pushStack(e(e.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,d,i){function n(V){return e.nodeName(V,"table")?V.getElementsByTagName("tbody")[0]||V.appendChild(V.ownerDocument.createElement("tbody")):V}var m,A,B=a[0],J=[],E;if(!e.support.checkClone&&arguments.length===
3&&typeof B==="string"&&Ja.test(B))return this.each(function(){e(this).domManip(a,d,i,true)});if(e.isFunction(B))return this.each(function(V){var ca=e(this);a[0]=B.call(this,V,d?ca.html():undefined);ca.domManip(a,d,i)});if(this[0]){m=B&&B.parentNode;m=e.support.parentNode&&m&&m.nodeType===11&&m.childNodes.length===this.length?{fragment:m}:r(a,this,J);E=m.fragment;if(A=E.childNodes.length===1?(E=E.firstChild):E.firstChild){d=d&&e.nodeName(A,"tr");for(var I=0,Q=this.length;I<Q;I++)i.call(d?n(this[I],
A):this[I],I>0||m.cacheable||this.length>1?E.cloneNode(true):E)}J.length&&e.each(J,s)}return this}});e.fragments={};e.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,d){e.fn[a]=function(i){var n=[];i=e(i);var m=this.length===1&&this[0].parentNode;if(m&&m.nodeType===11&&m.childNodes.length===1&&i.length===1){i[d](this[0]);return this}else{m=0;for(var A=i.length;m<A;m++){var B=(m>0?this.clone(true):this).get();e.fn[d].apply(e(i[m]),
B);n=n.concat(B)}return this.pushStack(n,a,i.selector)}}});e.extend({clean:function(a,d,i,n){d=d||l;if(typeof d.createElement==="undefined")d=d.ownerDocument||d[0]&&d[0].ownerDocument||l;for(var m=[],A=0,B;(B=a[A])!=null;A++){if(typeof B==="number")B+="";if(B){if(typeof B==="string"&&!jb.test(B))B=d.createTextNode(B);else if(typeof B==="string"){B=B.replace(Ua,Wa);var J=(Va.exec(B)||["",""])[1].toLowerCase(),E=la[J]||la._default,I=E[0],Q=d.createElement("div");for(Q.innerHTML=E[1]+B+E[2];I--;)Q=Q.lastChild;
if(!e.support.tbody){I=ib.test(B);J=J==="table"&&!I?Q.firstChild&&Q.firstChild.childNodes:E[1]==="<table>"&&!I?Q.childNodes:[];for(E=J.length-1;E>=0;--E)e.nodeName(J[E],"tbody")&&!J[E].childNodes.length&&J[E].parentNode.removeChild(J[E])}!e.support.leadingWhitespace&&xa.test(B)&&Q.insertBefore(d.createTextNode(xa.exec(B)[0]),Q.firstChild);B=Q.childNodes}if(B.nodeType)m.push(B);else m=e.merge(m,B)}}if(i)for(A=0;m[A];A++)if(n&&e.nodeName(m[A],"script")&&(!m[A].type||m[A].type.toLowerCase()==="text/javascript"))n.push(m[A].parentNode?
m[A].parentNode.removeChild(m[A]):m[A]);else{m[A].nodeType===1&&m.splice.apply(m,[A+1,0].concat(e.makeArray(m[A].getElementsByTagName("script"))));i.appendChild(m[A])}return m},cleanData:function(a){for(var d,i,n=e.cache,m=e.event.special,A=e.support.deleteExpando,B=0,J;(J=a[B])!=null;B++)if(i=J[e.expando]){d=n[i];if(d.events)for(var E in d.events)m[E]?e.event.remove(J,E):Ma(J,E,d.handle);if(A)delete J[e.expando];else J.removeAttribute&&J.removeAttribute(e.expando);delete n[i]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,
Xa=/alpha\([^)]*\)/,Ya=/opacity=([^)]*)/,Da=/float/i,Ea=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=l.defaultView&&l.defaultView.getComputedStyle,Za=e.support.cssFloat?"cssFloat":"styleFloat",Fa=function(a,d){return d.toUpperCase()};e.fn.css=function(a,d){return o(this,a,d,true,function(i,n,m){if(m===undefined)return e.curCSS(i,n);if(typeof m==="number"&&!kb.test(n))m+="px";e.style(i,
n,m)})};e.extend({style:function(a,d,i){if(!(!a||a.nodeType===3||a.nodeType===8)){if((d==="width"||d==="height")&&parseFloat(i)<0)i=undefined;var n=a.style||a,m=i!==undefined;if(!e.support.opacity&&d==="opacity"){if(m){n.zoom=1;d=parseInt(i,10)+""==="NaN"?"":"alpha(opacity="+i*100+")";a=n.filter||e.curCSS(a,"filter")||"";n.filter=Xa.test(a)?a.replace(Xa,d):d}return n.filter&&n.filter.indexOf("opacity=")>=0?parseFloat(Ya.exec(n.filter)[1])/100+"":""}if(Da.test(d))d=Za;d=d.replace(Ea,Fa);if(m)n[d]=
i;return n[d]}},css:function(a,d,i,n){if(d==="width"||d==="height"){var m,A=d==="width"?pb:qb;i=function(){m=d==="width"?a.offsetWidth:a.offsetHeight;n!=="border"&&e.each(A,function(){n||(m-=parseFloat(e.curCSS(a,"padding"+this,true))||0);if(n==="margin")m+=parseFloat(e.curCSS(a,"margin"+this,true))||0;else m-=parseFloat(e.curCSS(a,"border"+this+"Width",true))||0})};a.offsetWidth!==0?i():e.swap(a,ob,i);return Math.max(0,Math.round(m))}return e.curCSS(a,d,i)},curCSS:function(a,d,i){var n,m=a.style;
if(!e.support.opacity&&d==="opacity"&&a.currentStyle){n=Ya.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return n===""?"1":n}if(Da.test(d))d=Za;if(!i&&m&&m[d])n=m[d];else if(rb){if(Da.test(d))d="float";d=d.replace(lb,"-$1").toLowerCase();m=a.ownerDocument.defaultView;if(!m)return null;if(a=m.getComputedStyle(a,null))n=a.getPropertyValue(d);if(d==="opacity"&&n==="")n="1"}else if(a.currentStyle){i=d.replace(Ea,Fa);n=a.currentStyle[d]||a.currentStyle[i];if(!mb.test(n)&&nb.test(n)){d=
m.left;var A=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;m.left=i==="fontSize"?"1em":n||0;n=m.pixelLeft+"px";m.left=d;a.runtimeStyle.left=A}}return n},swap:function(a,d,i){var n={};for(var m in d){n[m]=a.style[m];a.style[m]=d[m]}i.call(a);for(m in d)a.style[m]=n[m]}});if(e.expr&&e.expr.filters){e.expr.filters.hidden=function(a){var d=a.offsetWidth,i=a.offsetHeight,n=a.nodeName.toLowerCase()==="tr";return d===0&&i===0&&!n?true:d>0&&i>0&&!n?false:e.curCSS(a,"display")==="none"};e.expr.filters.visible=
function(a){return!e.expr.filters.hidden(a)}}var sb=k(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,sa=/=\?(&|$)/,Ga=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=e.fn.load;e.fn.extend({load:function(a,d,i){if(typeof a!=="string")return zb.call(this,a);else if(!this.length)return this;var n=a.indexOf(" ");if(n>=0){var m=a.slice(n,a.length);a=a.slice(0,n)}n="GET";if(d)if(e.isFunction(d)){i=
d;d=null}else if(typeof d==="object"){d=e.param(d,e.ajaxSettings.traditional);n="POST"}var A=this;e.ajax({url:a,type:n,dataType:"html",data:d,complete:function(B,J){if(J==="success"||J==="notmodified")A.html(m?e("<div />").append(B.responseText.replace(tb,"")).find(m):B.responseText);i&&A.each(i,[B.responseText,J,B])}});return this},serialize:function(){return e.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?e.makeArray(this.elements):this}).filter(function(){return this.name&&
!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,d){a=e(this).val();return a==null?null:e.isArray(a)?e.map(a,function(i){return{name:d.name,value:i}}):{name:d.name,value:a}}).get()}});e.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,d){e.fn[d]=function(i){return this.bind(d,i)}});e.extend({get:function(a,d,i,n){if(e.isFunction(d)){n=n||i;i=d;d=null}return e.ajax({type:"GET",url:a,data:d,success:i,dataType:n})},
getScript:function(a,d){return e.get(a,null,d,"script")},getJSON:function(a,d,i){return e.get(a,d,i,"json")},post:function(a,d,i,n){if(e.isFunction(d)){n=n||i;i=d;d={}}return e.ajax({type:"POST",url:a,data:d,success:i,dataType:n})},ajaxSetup:function(a){e.extend(e.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:window.XMLHttpRequest&&(window.location.protocol!=="file:"||!window.ActiveXObject)?function(){return new window.XMLHttpRequest}:
function(){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function d(){m.success&&m.success.call(E,J,B,Z);m.global&&n("ajaxSuccess",[Z,m])}function i(){m.complete&&m.complete.call(E,Z,B);m.global&&n("ajaxComplete",[Z,m]);m.global&&!--e.active&&e.event.trigger("ajaxStop")}
function n(O,N){(m.context?e(m.context):e.event).trigger(O,N)}var m=e.extend(true,{},e.ajaxSettings,a),A,B,J,E=a&&a.context||m,I=m.type.toUpperCase();if(m.data&&m.processData&&typeof m.data!=="string")m.data=e.param(m.data,m.traditional);if(m.dataType==="jsonp"){if(I==="GET")sa.test(m.url)||(m.url+=(Ga.test(m.url)?"&":"?")+(m.jsonp||"callback")+"=?");else if(!m.data||!sa.test(m.data))m.data=(m.data?m.data+"&":"")+(m.jsonp||"callback")+"=?";m.dataType="json"}if(m.dataType==="json"&&(m.data&&sa.test(m.data)||
sa.test(m.url))){A=m.jsonpCallback||"jsonp"+sb++;if(m.data)m.data=(m.data+"").replace(sa,"="+A+"$1");m.url=m.url.replace(sa,"="+A+"$1");m.dataType="script";window[A]=window[A]||function(O){J=O;d();i();window[A]=undefined;try{delete window[A]}catch(N){}ca&&ca.removeChild(ga)}}if(m.dataType==="script"&&m.cache===null)m.cache=false;if(m.cache===false&&I==="GET"){var Q=k(),V=m.url.replace(wb,"$1_="+Q+"$2");m.url=V+(V===m.url?(Ga.test(m.url)?"&":"?")+"_="+Q:"")}if(m.data&&I==="GET")m.url+=(Ga.test(m.url)?
"&":"?")+m.data;m.global&&!e.active++&&e.event.trigger("ajaxStart");Q=(Q=xb.exec(m.url))&&(Q[1]&&Q[1]!==location.protocol||Q[2]!==location.host);if(m.dataType==="script"&&I==="GET"&&Q){var ca=l.getElementsByTagName("head")[0]||l.documentElement,ga=l.createElement("script");ga.src=m.url;if(m.scriptCharset)ga.charset=m.scriptCharset;if(!A){var fa=false;ga.onload=ga.onreadystatechange=function(){if(!fa&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){fa=true;d();i();ga.onload=
ga.onreadystatechange=null;ca&&ga.parentNode&&ca.removeChild(ga)}}}ca.insertBefore(ga,ca.firstChild)}else{var ka=false,Z=m.xhr();if(Z){m.username?Z.open(I,m.url,m.async,m.username,m.password):Z.open(I,m.url,m.async);try{if(m.data||a&&a.contentType)Z.setRequestHeader("Content-Type",m.contentType);if(m.ifModified){e.lastModified[m.url]&&Z.setRequestHeader("If-Modified-Since",e.lastModified[m.url]);e.etag[m.url]&&Z.setRequestHeader("If-None-Match",e.etag[m.url])}Q||Z.setRequestHeader("X-Requested-With",
"XMLHttpRequest");Z.setRequestHeader("Accept",m.dataType&&m.accepts[m.dataType]?m.accepts[m.dataType]+", */*":m.accepts._default)}catch(Ca){}if(m.beforeSend&&m.beforeSend.call(E,Z,m)===false){m.global&&!--e.active&&e.event.trigger("ajaxStop");Z.abort();return false}m.global&&n("ajaxSend",[Z,m]);var t=Z.onreadystatechange=function(O){if(!Z||Z.readyState===0||O==="abort"){ka||i();ka=true;if(Z)Z.onreadystatechange=e.noop}else if(!ka&&Z&&(Z.readyState===4||O==="timeout")){ka=true;Z.onreadystatechange=
e.noop;B=O==="timeout"?"timeout":!e.httpSuccess(Z)?"error":m.ifModified&&e.httpNotModified(Z,m.url)?"notmodified":"success";var N;if(B==="success")try{J=e.httpData(Z,m.dataType,m)}catch(X){B="parsererror";N=X}if(B==="success"||B==="notmodified")A||d();else e.handleError(m,Z,B,N);i();O==="timeout"&&Z.abort();if(m.async)Z=null}};try{var x=Z.abort;Z.abort=function(){Z&&x.call(Z);t("abort")}}catch(F){}m.async&&m.timeout>0&&setTimeout(function(){Z&&!ka&&t("timeout")},m.timeout);try{Z.send(I==="POST"||
I==="PUT"||I==="DELETE"?m.data:null)}catch(G){e.handleError(m,Z,null,G);i()}m.async||t();return Z}}},handleError:function(a,d,i,n){if(a.error)a.error.call(a.context||a,d,i,n);if(a.global)(a.context?e(a.context):e.event).trigger("ajaxError",[d,a,n])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(d){}return false},httpNotModified:function(a,d){var i=a.getResponseHeader("Last-Modified"),
n=a.getResponseHeader("Etag");if(i)e.lastModified[d]=i;if(n)e.etag[d]=n;return a.status===304||a.status===0},httpData:function(a,d,i){var n=a.getResponseHeader("content-type")||"",m=d==="xml"||!d&&n.indexOf("xml")>=0;a=m?a.responseXML:a.responseText;m&&a.documentElement.nodeName==="parsererror"&&e.error("parsererror");if(i&&i.dataFilter)a=i.dataFilter(a,d);if(typeof a==="string")if(d==="json"||!d&&n.indexOf("json")>=0)a=e.parseJSON(a);else if(d==="script"||!d&&n.indexOf("javascript")>=0)e.globalEval(a);
return a},param:function(a,d){function i(B,J){if(e.isArray(J))e.each(J,function(E,I){d||/\[\]$/.test(B)?n(B,I):i(B+"["+(typeof I==="object"||e.isArray(I)?E:"")+"]",I)});else!d&&J!=null&&typeof J==="object"?e.each(J,function(E,I){i(B+"["+E+"]",I)}):n(B,J)}function n(B,J){J=e.isFunction(J)?J():J;m[m.length]=encodeURIComponent(B)+"="+encodeURIComponent(J)}var m=[];if(d===undefined)d=e.ajaxSettings.traditional;if(e.isArray(a)||a.jquery)e.each(a,function(){n(this.name,this.value)});else for(var A in a)i(A,
a[A]);return m.join("&").replace(yb,"+")}});var Ha={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,ya,Ka=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];e.fn.extend({show:function(a,d){if(a||a===0)return this.animate(z("show",3),a,d);else{a=0;for(d=this.length;a<d;a++){var i=e.data(this[a],"olddisplay");this[a].style.display=i||"";if(e.css(this[a],"display")==="none"){i=this[a].nodeName;var n;
if(Ha[i])n=Ha[i];else{var m=e("<"+i+" />").appendTo("body");n=m.css("display");if(n==="none")n="block";m.remove();Ha[i]=n}e.data(this[a],"olddisplay",n)}}a=0;for(d=this.length;a<d;a++)this[a].style.display=e.data(this[a],"olddisplay")||"";return this}},hide:function(a,d){if(a||a===0)return this.animate(z("hide",3),a,d);else{a=0;for(d=this.length;a<d;a++){var i=e.data(this[a],"olddisplay");!i&&i!=="none"&&e.data(this[a],"olddisplay",e.css(this[a],"display"))}a=0;for(d=this.length;a<d;a++)this[a].style.display=
"none";return this}},_toggle:e.fn.toggle,toggle:function(a,d){var i=typeof a==="boolean";if(e.isFunction(a)&&e.isFunction(d))this._toggle.apply(this,arguments);else a==null||i?this.each(function(){var n=i?a:e(this).is(":hidden");e(this)[n?"show":"hide"]()}):this.animate(z("toggle",3),a,d);return this},fadeTo:function(a,d,i){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:d},a,i)},animate:function(a,d,i,n){var m=e.speed(d,i,n);if(e.isEmptyObject(a))return this.each(m.complete);
return this[m.queue===false?"each":"queue"](function(){var A=e.extend({},m),B,J=this.nodeType===1&&e(this).is(":hidden"),E=this;for(B in a){var I=B.replace(Ea,Fa);if(B!==I){a[I]=a[B];delete a[B];B=I}if(a[B]==="hide"&&J||a[B]==="show"&&!J)return A.complete.call(this);if((B==="height"||B==="width")&&this.style){A.display=e.css(this,"display");A.overflow=this.style.overflow}if(e.isArray(a[B])){(A.specialEasing=A.specialEasing||{})[B]=a[B][1];a[B]=a[B][0]}}if(A.overflow!=null)this.style.overflow="hidden";
A.curAnim=e.extend({},a);e.each(a,function(Q,V){var ca=new e.fx(E,A,Q);if(Ab.test(V))ca[V==="toggle"?J?"show":"hide":V](a);else{var ga=Bb.exec(V),fa=ca.cur(true)||0;if(ga){V=parseFloat(ga[2]);var ka=ga[3]||"px";if(ka!=="px"){E.style[Q]=(V||1)+ka;fa=(V||1)/ca.cur(true)*fa;E.style[Q]=fa+ka}if(ga[1])V=(ga[1]==="-="?-1:1)*V+fa;ca.custom(fa,V,ka)}else ca.custom(fa,V,"")}});return true})},stop:function(a,d){var i=e.timers;a&&this.queue([]);this.each(function(){for(var n=i.length-1;n>=0;n--)if(i[n].elem===
this){d&&i[n](true);i.splice(n,1)}});d||this.dequeue();return this}});e.each({slideDown:z("show",1),slideUp:z("hide",1),slideToggle:z("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,d){e.fn[a]=function(i,n){return this.animate(d,i,n)}});e.extend({speed:function(a,d,i){var n=a&&typeof a==="object"?a:{complete:i||!i&&d||e.isFunction(a)&&a,duration:a,easing:i&&d||d&&!e.isFunction(d)&&d};n.duration=e.fx.off?0:typeof n.duration==="number"?n.duration:e.fx.speeds[n.duration]||e.fx.speeds._default;
n.old=n.complete;n.complete=function(){n.queue!==false&&e(this).dequeue();e.isFunction(n.old)&&n.old.call(this)};return n},easing:{linear:function(a,d,i,n){return i+n*a},swing:function(a,d,i,n){return(-Math.cos(a*Math.PI)/2+0.5)*n+i}},timers:[],fx:function(a,d,i){this.options=d;this.elem=a;this.prop=i;if(!d.orig)d.orig={}}});e.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(e.fx.step[this.prop]||e.fx.step._default)(this);if((this.prop==="height"||
this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(e.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(e.curCSS(this.elem,this.prop))||0},custom:function(a,d,i){function n(A){return m.step(A)}this.startTime=k();this.start=a;this.end=d;this.unit=i||this.unit||"px";this.now=this.start;this.pos=this.state=0;var m=this;n.elem=this.elem;
if(n()&&e.timers.push(n)&&!ya)ya=setInterval(e.fx.tick,13)},show:function(){this.options.orig[this.prop]=e.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());e(this.elem).show()},hide:function(){this.options.orig[this.prop]=e.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var d=k(),i=true;if(a||d>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();
this.options.curAnim[this.prop]=true;for(var n in this.options.curAnim)if(this.options.curAnim[n]!==true)i=false;if(i){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=e.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(e.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&e(this.elem).hide();if(this.options.hide||this.options.show)for(var m in this.options.curAnim)e.style(this.elem,m,this.options.orig[m]);
this.options.complete.call(this.elem)}return false}else{m=d-this.startTime;this.state=m/this.options.duration;a=this.options.easing||(e.easing.swing?"swing":"linear");this.pos=e.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,m,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};e.extend(e.fx,{tick:function(){for(var a=e.timers,d=0;d<a.length;d++)a[d]()||a.splice(d--,1);a.length||e.fx.stop()},stop:function(){clearInterval(ya);
ya=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){e.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(e.expr&&e.expr.filters)e.expr.filters.animated=function(a){return e.grep(e.timers,function(d){return a===d.elem}).length};e.fn.offset="getBoundingClientRect"in l.documentElement?function(a){var d=this[0];if(a)return this.each(function(m){e.offset.setOffset(this,
a,m)});if(!d||!d.ownerDocument)return null;if(d===d.ownerDocument.body)return e.offset.bodyOffset(d);var i=d.getBoundingClientRect(),n=d.ownerDocument;d=n.body;n=n.documentElement;return{top:i.top+(self.pageYOffset||e.support.boxModel&&n.scrollTop||d.scrollTop)-(n.clientTop||d.clientTop||0),left:i.left+(self.pageXOffset||e.support.boxModel&&n.scrollLeft||d.scrollLeft)-(n.clientLeft||d.clientLeft||0)}}:function(a){var d=this[0];if(a)return this.each(function(Q){e.offset.setOffset(this,a,Q)});if(!d||
!d.ownerDocument)return null;if(d===d.ownerDocument.body)return e.offset.bodyOffset(d);e.offset.initialize();var i=d.offsetParent,n=d,m=d.ownerDocument,A,B=m.documentElement,J=m.body;n=(m=m.defaultView)?m.getComputedStyle(d,null):d.currentStyle;for(var E=d.offsetTop,I=d.offsetLeft;(d=d.parentNode)&&d!==J&&d!==B;){if(e.offset.supportsFixedPosition&&n.position==="fixed")break;A=m?m.getComputedStyle(d,null):d.currentStyle;E-=d.scrollTop;I-=d.scrollLeft;if(d===i){E+=d.offsetTop;I+=d.offsetLeft;if(e.offset.doesNotAddBorder&&
!(e.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(d.nodeName))){E+=parseFloat(A.borderTopWidth)||0;I+=parseFloat(A.borderLeftWidth)||0}n=i;i=d.offsetParent}if(e.offset.subtractsBorderForOverflowNotVisible&&A.overflow!=="visible"){E+=parseFloat(A.borderTopWidth)||0;I+=parseFloat(A.borderLeftWidth)||0}n=A}if(n.position==="relative"||n.position==="static"){E+=J.offsetTop;I+=J.offsetLeft}if(e.offset.supportsFixedPosition&&n.position==="fixed"){E+=Math.max(B.scrollTop,J.scrollTop);I+=Math.max(B.scrollLeft,
J.scrollLeft)}return{top:E,left:I}};e.offset={initialize:function(){var a=l.body,d=l.createElement("div"),i,n,m,A=parseFloat(e.curCSS(a,"marginTop",true))||0;e.extend(d.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});d.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
a.insertBefore(d,a.firstChild);i=d.firstChild;n=i.firstChild;m=i.nextSibling.firstChild.firstChild;this.doesNotAddBorder=n.offsetTop!==5;this.doesAddBorderForTableAndCells=m.offsetTop===5;n.style.position="fixed";n.style.top="20px";this.supportsFixedPosition=n.offsetTop===20||n.offsetTop===15;n.style.position=n.style.top="";i.style.overflow="hidden";i.style.position="relative";this.subtractsBorderForOverflowNotVisible=n.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==A;a.removeChild(d);
e.offset.initialize=e.noop},bodyOffset:function(a){var d=a.offsetTop,i=a.offsetLeft;e.offset.initialize();if(e.offset.doesNotIncludeMarginInBodyOffset){d+=parseFloat(e.curCSS(a,"marginTop",true))||0;i+=parseFloat(e.curCSS(a,"marginLeft",true))||0}return{top:d,left:i}},setOffset:function(a,d,i){if(/static/.test(e.curCSS(a,"position")))a.style.position="relative";var n=e(a),m=n.offset(),A=parseInt(e.curCSS(a,"top",true),10)||0,B=parseInt(e.curCSS(a,"left",true),10)||0;if(e.isFunction(d))d=d.call(a,
i,m);i={top:d.top-m.top+A,left:d.left-m.left+B};"using"in d?d.using.call(a,i):n.css(i)}};e.fn.extend({position:function(){if(!this[0])return null;var a=this[0],d=this.offsetParent(),i=this.offset(),n=/^body|html$/i.test(d[0].nodeName)?{top:0,left:0}:d.offset();i.top-=parseFloat(e.curCSS(a,"marginTop",true))||0;i.left-=parseFloat(e.curCSS(a,"marginLeft",true))||0;n.top+=parseFloat(e.curCSS(d[0],"borderTopWidth",true))||0;n.left+=parseFloat(e.curCSS(d[0],"borderLeftWidth",true))||0;return{top:i.top-
n.top,left:i.left-n.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||l.body;a&&!/^body|html$/i.test(a.nodeName)&&e.css(a,"position")==="static";)a=a.offsetParent;return a})}});e.each(["Left","Top"],function(a,d){var i="scroll"+d;e.fn[i]=function(n){var m=this[0],A;if(!m)return null;if(n!==undefined)return this.each(function(){if(A=C(this))A.scrollTo(!a?n:e(A).scrollLeft(),a?n:e(A).scrollTop());else this[i]=n});else return(A=C(m))?"pageXOffset"in A?A[a?"pageYOffset":
"pageXOffset"]:e.support.boxModel&&A.document.documentElement[i]||A.document.body[i]:m[i]}});e.each(["Height","Width"],function(a,d){var i=d.toLowerCase();e.fn["inner"+d]=function(){return this[0]?e.css(this[0],i,false,"padding"):null};e.fn["outer"+d]=function(n){return this[0]?e.css(this[0],i,false,n?"margin":"border"):null};e.fn[i]=function(n){var m=this[0];if(!m)return n==null?null:this;if(e.isFunction(n))return this.each(function(A){var B=e(this);B[i](n.call(this,A,B[i]()))});return"scrollTo"in
m&&m.document?m.document.compatMode==="CSS1Compat"&&m.document.documentElement["client"+d]||m.document.body["client"+d]:m.nodeType===9?Math.max(m.documentElement["client"+d],m.body["scroll"+d],m.documentElement["scroll"+d],m.body["offset"+d],m.documentElement["offset"+d]):n===undefined?e.css(m,i):this.css(i,typeof n==="string"?n:n+"px")}});u.$=u.jQuery=e});
bespin.tiki.register("::embedded",{name:"embedded",dependencies:{theme_manager:"0.0.0",text_editor:"0.0.0",appconfig:"0.0.0",edit_session:"0.0.0",screen_theme:"0.0.0"}});bespin.tiki.module("embedded:index",function(){});bespin.tiki.register("::appconfig",{name:"appconfig",dependencies:{jquery:"0.0.0",canon:"0.0.0",underscore:"0.0.0",settings:"0.0.0"}});
bespin.tiki.module("appconfig:index",function(y,u){var v=y("jquery").$;y("underscore");var s=y("settings").settings,o=y("bespin:promise").group,k=y("bespin:promise").Promise,b=y("bespin:console").console,f=y("bespin:util/stacktrace").Trace,q=y("bespin:util/util"),h=true;u.launch=function(p){var r=new k;v("#_bespin_loading").remove();var z;if(h){z=bespin.tiki.require;h=false}else z=(new (bespin.tiki.require("bespin:sandbox").Sandbox)).createRequire({id:"index",ownerPackage:bespin.tiki.loader.anonymousPackage});
var C=z("bespin:plugins").catalog;p=p||{};u.normalizeConfig(C,p);var e=p.objects;for(var K in e)C.registerObject(K,e[K]);for(var M in p.settings)s.set(M,p.settings[M]);var l=function(){var D=z("environment").env,H=D.editor;if(H){p.lineNumber&&H.setLineNumber(p.lineNumber);if(p.stealFocus)H.focus=true;if(p.readOnly)H.readOnly=p.readOnly;if(p.syntax)H.syntax=p.syntax}if(H=C.getObject("commandLine"))D.commandLine=H;C.publish(this,"appLaunched");r.resolve(D)}.bind(this),w=new k;w.then(function(){e.loginController?
C.createObject("loginController").then(function(D){D.showLogin().then(function(H){p.objects.session.arguments.push(H);u.launchEditor(C,p).then(l,r.reject.bind(r))})}):u.launchEditor(C,p).then(l,r.reject.bind(r))},function(D){r.reject(D)});C.plugins.theme_manager?bespin.tiki.require.ensurePackage("::theme_manager",function(){var D=z("theme_manager");p.theme.basePlugin&&D.setBasePlugin(p.theme.basePlugin);p.theme.standard&&D.setStandardTheme(p.theme.standard);D.startParsing().then(function(){w.resolve()},
function(H){w.reject(H)})}):w.resolve();return r};u.normalizeConfig=function(p,r){if(r.objects===undefined)r.objects={};if(r.autoload===undefined)r.autoload=[];if(r.theme===undefined)r.theme={};if(!r.theme.basePlugin&&p.plugins.screen_theme)r.theme.basePlugin="screen_theme";if(!r.initialContent)r.initialContent="";if(!r.settings)r.settings={};if(!r.objects.notifier&&p.plugins.notifier)r.objects.notifier={};if(!r.objects.loginController&&p.plugins.userident)r.objects.loginController={};if(!r.objects.fileHistory&&
p.plugins.file_history)r.objects.fileHistory={factory:"file_history",arguments:["session"],objects:{"0":"session"}};if(!r.objects.server&&p.plugins.bespin_server){r.objects.server={factory:"bespin_server"};r.objects.filesource={factory:"bespin_filesource",arguments:["server"],objects:{"0":"server"}}}if(!r.objects.files&&p.plugins.filesystem&&r.objects.filesource)r.objects.files={arguments:["filesource"],objects:{"0":"filesource"}};if(!r.objects.editor)r.objects.editor={factory:"text_editor",arguments:[r.initialContent]};
if(!r.objects.session)r.objects.session={arguments:["editor"],objects:{"0":"editor"}};if(!r.objects.commandLine&&p.plugins.command_line)r.objects.commandLine={};if(!r.objects.toolbar&&p.plugins.toolbar)r.objects.toolbar={};if(r.gui===undefined)r.gui={};p={};for(var z in r.gui){var C=r.gui[z];if(C.component)p[C.component]=true}if(!r.gui.north&&r.objects.toolbar&&!p.toolbar)r.gui.north={component:"toolbar"};if(!r.gui.center&&r.objects.editor&&!p.editor)r.gui.center={component:"editor"};if(!r.gui.south&&
r.objects.commandLine&&!p.commandLine)r.gui.south={component:"commandLine"}};u.launchEditor=function(p,r){var z=new k;if(r===null){b.error("Cannot start editor without a configuration!");z.reject("Cannot start editor without a configuration!");return z}j(p,r).then(function(){g(p,r,z)},function(C){b.error("Error while creating objects");(new f(C)).log();z.reject(C)});return z};var j=function(p,r){var z=[];for(var C in r.objects)z.push(p.createObject(C));return o(z)},g=function(p,r,z){var C=document.createElement("div");
C.setAttribute("class","container");var e=document.createElement("div");e.setAttribute("class","center-container");var K=false,M=r.element||document.body;q.addClass(M,"bespin");M.appendChild(C);try{["north","west","center","east","south"].forEach(function(w){var D=r.gui[w];if(D){var H=p.getObject(D.component);if(!H)throw"Cannot find object "+D.component+" to attach to the Bespin UI";M=H.element;if(!M)throw"Component "+D.component+' does not have an "element" attribute to attach to the Bespin UI';
v(M).addClass(w);if(w=="west"||w=="east"||w=="center"){if(!K){C.appendChild(e);K=true}e.appendChild(M)}else C.appendChild(M)}});["north","west","east","south","center"].forEach(function(w){if(w=r.gui[w]){w=p.getObject(w.component);w.elementAppended!=null&&w.elementAppended()}});z.resolve()}catch(l){b.error(l);z.reject(l)}}});bespin.tiki.register("::events",{name:"events",dependencies:{traits:"0.0.0"}});
bespin.tiki.module("events:index",function(y,u){u.Event=function(){var v=[],s=function(){var o=arguments;v.forEach(function(k){k.func.apply(null,o)})};s.add=function(){arguments.length==1?v.push({ref:arguments[0],func:arguments[0]}):v.push({ref:arguments[0],func:arguments[1]})};s.remove=function(o){v=v.filter(function(k){return o!==k.ref})};s.removeAll=function(){v=[]};return s}});bespin.tiki.register("::screen_theme",{name:"screen_theme",dependencies:{theme_manager:"0.0.0"}});
bespin.tiki.module("screen_theme:index",function(){});
(function(){var y=bespin.tiki.require("jquery").$;y(document).ready(function(){bespin.tiki.require("bespin:plugins").catalog.registerMetadata({text_editor:{resourceURL:"resources/text_editor/",description:"Canvas-based text editor component and many common editing commands",dependencies:{completion:"0.0.0",undomanager:"0.0.0",settings:"0.0.0",canon:"0.0.0",rangeutils:"0.0.0",traits:"0.0.0",theme_manager:"0.0.0",keyboard:"0.0.0",edit_session:"0.0.0",syntax_manager:"0.0.0"},testmodules:["tests/controllers/testLayoutmanager",
"tests/models/testTextstorage","tests/testScratchcanvas","tests/utils/testRect"],provides:[{action:"new",pointer:"views/editor#EditorView",ep:"factory",name:"text_editor"},{predicates:{isTextView:true},pointer:"commands/editing#backspace",ep:"command",key:"backspace",name:"backspace"},{predicates:{isTextView:true},pointer:"commands/editing#deleteCommand",ep:"command",key:"delete",name:"delete"},{description:"Delete all lines currently selected",key:"ctrl_d",predicates:{isTextView:true},pointer:"commands/editing#deleteLines",
ep:"command",name:"deletelines"},{description:"Create a new, empty line below the current one",key:"ctrl_return",predicates:{isTextView:true},pointer:"commands/editing#openLine",ep:"command",name:"openline"},{description:"Join the current line with the following",key:"ctrl_shift_j",predicates:{isTextView:true},pointer:"commands/editing#joinLines",ep:"command",name:"joinline"},{params:[{defaultValue:"",type:"text",name:"text",description:"The text to insert"}],pointer:"commands/editing#insertText",
ep:"command",name:"insertText"},{predicates:{completing:false,isTextView:true},pointer:"commands/editing#newline",ep:"command",key:"return",name:"newline"},{predicates:{completing:false,isTextView:true},pointer:"commands/editing#tab",ep:"command",key:"tab",name:"tab"},{predicates:{isTextView:true},pointer:"commands/editing#untab",ep:"command",key:"shift_tab",name:"untab"},{predicates:{isTextView:true},ep:"command",name:"move"},{description:"Repeat the last search (forward)",pointer:"commands/editor#findNextCommand",
ep:"command",key:"ctrl_g",name:"findnext"},{description:"Repeat the last search (backward)",pointer:"commands/editor#findPrevCommand",ep:"command",key:"ctrl_shift_g",name:"findprev"},{predicates:{completing:false,isTextView:true},pointer:"commands/movement#moveDown",ep:"command",key:"down",name:"move down"},{predicates:{isTextView:true},pointer:"commands/movement#moveLeft",ep:"command",key:"left",name:"move left"},{predicates:{isTextView:true},pointer:"commands/movement#moveRight",ep:"command",key:"right",
name:"move right"},{predicates:{completing:false,isTextView:true},pointer:"commands/movement#moveUp",ep:"command",key:"up",name:"move up"},{predicates:{isTextView:true},ep:"command",name:"select"},{predicates:{isTextView:true},pointer:"commands/movement#selectDown",ep:"command",key:"shift_down",name:"select down"},{predicates:{isTextView:true},pointer:"commands/movement#selectLeft",ep:"command",key:"shift_left",name:"select left"},{predicates:{isTextView:true},pointer:"commands/movement#selectRight",
ep:"command",key:"shift_right",name:"select right"},{predicates:{isTextView:true},pointer:"commands/movement#selectUp",ep:"command",key:"shift_up",name:"select up"},{predicates:{isTextView:true},pointer:"commands/movement#moveLineEnd",ep:"command",key:["end","ctrl_right"],name:"move lineend"},{predicates:{isTextView:true},pointer:"commands/movement#selectLineEnd",ep:"command",key:["shift_end","ctrl_shift_right"],name:"select lineend"},{predicates:{isTextView:true},pointer:"commands/movement#moveDocEnd",
ep:"command",key:"ctrl_down",name:"move docend"},{predicates:{isTextView:true},pointer:"commands/movement#selectDocEnd",ep:"command",key:"ctrl_shift_down",name:"select docend"},{predicates:{isTextView:true},pointer:"commands/movement#moveLineStart",ep:"command",key:["home","ctrl_left"],name:"move linestart"},{predicates:{isTextView:true},pointer:"commands/movement#selectLineStart",ep:"command",key:["shift_home","ctrl_shift_left"],name:"select linestart"},{predicates:{isTextView:true},pointer:"commands/movement#moveDocStart",
ep:"command",key:"ctrl_up",name:"move docstart"},{predicates:{isTextView:true},pointer:"commands/movement#selectDocStart",ep:"command",key:"ctrl_shift_up",name:"select docstart"},{predicates:{isTextView:true},pointer:"commands/movement#moveNextWord",ep:"command",key:["alt_right"],name:"move nextword"},{predicates:{isTextView:true},pointer:"commands/movement#selectNextWord",ep:"command",key:["alt_shift_right"],name:"select nextword"},{predicates:{isTextView:true},pointer:"commands/movement#movePreviousWord",
ep:"command",key:["alt_left"],name:"move prevword"},{predicates:{isTextView:true},pointer:"commands/movement#selectPreviousWord",ep:"command",key:["alt_shift_left"],name:"select prevword"},{predicates:{isTextView:true},pointer:"commands/movement#selectAll",ep:"command",key:["ctrl_a","meta_a"],name:"select all"},{predicates:{isTextView:true},ep:"command",name:"scroll"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollDocStart",ep:"command",key:"ctrl_home",name:"scroll start"},{predicates:{isTextView:true},
pointer:"commands/scrolling#scrollDocEnd",ep:"command",key:"ctrl_end",name:"scroll end"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollPageDown",ep:"command",key:"pagedown",name:"scroll down"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollPageUp",ep:"command",key:"pageup",name:"scroll up"},{pointer:"commands/editor#lcCommand",description:"Change all selected text to lowercase",withKey:"CMD SHIFT L",ep:"command",name:"lc"},{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#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#trimCommand",description:"trim trailing or leading whitespace from each line in selection",
params:[{defaultValue:"both",type:{data:[{name:"left"},{name:"right"},{name:"both"}],name:"selection"},name:"side",description:"Do we trim from the left, right or both"}],ep:"command",name:"trim"},{pointer:"commands/editor#ucCommand",description:"Change all selected text to uppercase",withKey:"CMD SHIFT U",ep:"command",name:"uc"},{predicates:{isTextView:true},pointer:"controllers/undo#undoManagerCommand",ep:"command",key:["ctrl_shift_z"],name:"redo"},{predicates:{isTextView:true},pointer:"controllers/undo#undoManagerCommand",
ep:"command",key:["ctrl_z"],name:"undo"},{description:"The distance in characters between each tab",defaultValue:8,type:"number",ep:"setting",name:"tabstop"},{description:"Customize the keymapping",defaultValue:"{}",type:"text",ep:"setting",name:"customKeymapping"},{description:"The keymapping to use",defaultValue:"standard",type:"text",ep:"setting",name:"keymapping"},{description:"The editor font size in pixels",defaultValue:14,type:"number",ep:"setting",name:"fontsize"},{description:"The editor font face",
defaultValue:"Monaco, Lucida Console, monospace",type:"text",ep:"setting",name:"fontface"},{defaultValue:{color:"#e5c138",paddingLeft:5,backgroundColor:"#4c4a41",paddingRight:10},ep:"themevariable",name:"gutter"},{defaultValue:{color:"#e6e6e6",selectedTextBackgroundColor:"#526da5",backgroundColor:"#2a211c",cursorColor:"#879aff",unfocusedCursorBackgroundColor:"#73171e",unfocusedCursorColor:"#ff0033"},ep:"themevariable",name:"editor"},{defaultValue:{comment:"#666666",directive:"#999999",keyword:"#42A8ED",
addition:"#FFFFFF",plain:"#e6e6e6",module:"#BA4946",specialmodule:"#C741BB",builtin:"#307BAD",deletion:"#FFFFFF",error:"#ff0000",operator:"#88BBFF",identifier:"#D841FF",string:"#039A0A"},ep:"themevariable",name:"highlighterFG"},{defaultValue:{addition:"#008000",deletion:"#800000"},ep:"themevariable",name:"highlighterBG"},{defaultValue:{nibStrokeStyle:"rgb(150, 150, 150)",fullAlpha:1,barFillStyle:"rgb(0, 0, 0)",particalAlpha:0.3,barFillGradientBottomStop:"rgb(44, 44, 44)",backgroundStyle:"#2A211C",
thickness:17,padding:5,trackStrokeStyle:"rgb(150, 150, 150)",nibArrowStyle:"rgb(255, 255, 255)",barFillGradientBottomStart:"rgb(22, 22, 22)",barFillGradientTopStop:"rgb(40, 40, 40)",barFillGradientTopStart:"rgb(90, 90, 90)",nibStyle:"rgb(100, 100, 100)",trackFillStyle:"rgba(50, 50, 50, 0.8)"},ep:"themevariable",name:"scroller"},{description:"Event: Notify when something within the editor changed.",params:[{required:true,name:"pointer",description:"Function that is called whenever a change happened."}],
ep:"extensionpoint",name:"editorChange"},{description:"Decoration for the gutter",ep:"extensionpoint",name:"gutterDecoration"},{description:"Line number decoration for the gutter",pointer:"views/gutter#lineNumbers",ep:"gutterDecoration",name:"lineNumbers"}],type:"plugins/supported",name:"text_editor"},less:{resourceURL:"resources/less/",description:"Leaner CSS",contributors:[],author:"Alexis Sellier <self@cloudhead.net>",url:"http://lesscss.org",version:"1.0.11",dependencies:{},testmodules:[],provides:[],
keywords:["css","parser","lesscss","browser"],type:"plugins/thirdparty",name:"less"},theme_manager_base:{resourceURL:"resources/theme_manager_base/",name:"theme_manager_base",share:true,environments:{main:true},dependencies:{},testmodules:[],provides:[{description:"(Less)files holding the CSS style information for the UI.",params:[{required:true,name:"url",description:"Name of the ThemeStylesFile - can also be an array of files."}],ep:"extensionpoint",name:"themestyles"},{description:"Event: Notify when the theme(styles) changed.",
params:[{required:true,name:"pointer",description:"Function that is called whenever the theme is changed."}],ep:"extensionpoint",name:"themeChange"},{indexOn:"name",description:"A theme is a way change the look of the application.",params:[{required:false,name:"url",description:"Name of a ThemeStylesFile that holds theme specific CSS rules - can also be an array of files."},{required:true,name:"pointer",description:"Function that returns the ThemeData"}],ep:"extensionpoint",name:"theme"}],type:"plugins/supported",
description:"Defines extension points required for theming"},canon:{resourceURL:"resources/canon/",name:"canon",environments:{main:true,worker:false},dependencies:{environment:"0.0.0",events:"0.0.0",settings:"0.0.0"},testmodules:[],provides:[{indexOn:"name",description:"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"},{description:"An extension point to be called whenever a new command begins output.",
ep:"extensionpoint",name:"addedRequestOutput"},{description:"A dimensionsChanged is a way to be notified of changes to the dimension of Bespin",ep:"extensionpoint",name:"dimensionsChanged"},{description:"How many typed commands do we recall for reference?",defaultValue:50,type:"number",ep:"setting",name:"historyLength"},{action:"create",pointer:"history#InMemoryHistory",ep:"factory",name:"history"}],type:"plugins/supported",description:"Manages commands"},traits:{resourceURL:"resources/traits/",description:"Traits library, traitsjs.org",
dependencies:{},testmodules:[],provides:[],type:"plugins/thirdparty",name:"traits"},keyboard:{resourceURL:"resources/keyboard/",description:"Keyboard shortcuts",dependencies:{canon:"0.0",settings:"0.0"},testmodules:["tests/testKeyboard"],provides:[{description:"A keymapping defines how keystrokes are interpreted.",params:[{required:true,name:"states",description:"Holds the states and all the informations about the keymapping. See docs: pluginguide/keymapping"}],ep:"extensionpoint",name:"keymapping"}],
type:"plugins/supported",name:"keyboard"},worker_manager:{resourceURL:"resources/worker_manager/",description:"Manages a web worker on the browser side",dependencies:{canon:"0.0.0",events:"0.0.0",underscore:"0.0.0"},testmodules:[],provides:[{description:"Low-level web worker control (for plugin development)",ep:"command",name:"worker"},{description:"Restarts all web workers (for plugin development)",pointer:"#workerRestartCommand",ep:"command",name:"worker restart"}],type:"plugins/supported",name:"worker_manager"},
edit_session:{resourceURL:"resources/edit_session/",description:"Ties together the files being edited with the views on screen",dependencies:{events:"0.0.0"},testmodules:["tests/testSession"],provides:[{action:"call",pointer:"#createSession",ep:"factory",name:"session"}],type:"plugins/supported",name:"edit_session"},syntax_manager:{resourceURL:"resources/syntax_manager/",name:"syntax_manager",environments:{main:true,worker:false},dependencies:{worker_manager:"0.0.0",syntax_directory:"0.0.0",events:"0.0.0",
underscore:"0.0.0",settings:"0.0.0"},testmodules:[],provides:[],type:"plugins/supported",description:"Provides syntax highlighting services for the editor"},completion:{resourceURL:"resources/completion/",description:"Code completion support",dependencies:{jquery:"0.0.0",ctags:"0.0.0",rangeutils:"0.0.0",canon:"0.0.0",underscore:"0.0.0"},testmodules:[],provides:[{indexOn:"name",description:"Code completion support for specific languages",ep:"extensionpoint",name:"completion"},{description:"Accept the chosen completion",
key:["return","tab"],predicates:{completing:true},pointer:"controller#completeCommand",ep:"command",name:"complete"},{description:"Abandon the completion",key:"escape",predicates:{completing:true},pointer:"controller#completeCancelCommand",ep:"command",name:"complete cancel"},{description:"Choose the completion below",key:"down",predicates:{completing:true},pointer:"controller#completeDownCommand",ep:"command",name:"complete down"},{description:"Choose the completion above",key:"up",predicates:{completing:true},
pointer:"controller#completeUpCommand",ep:"command",name:"complete up"}],type:"plugins/supported",name:"completion"},environment:{testmodules:[],dependencies:{settings:"0.0.0"},resourceURL:"resources/environment/",name:"environment",type:"plugins/supported"},undomanager:{resourceURL:"resources/undomanager/",description:"Manages undoable events",testmodules:["tests/testUndomanager"],provides:[{pointer:"#undoManagerCommand",ep:"command",key:["ctrl_shift_z"],name:"redo"},{pointer:"#undoManagerCommand",
ep:"command",key:["ctrl_z"],name:"undo"}],type:"plugins/supported",name:"undomanager"},rangeutils:{testmodules:["tests/test"],type:"plugins/supported",resourceURL:"resources/rangeutils/",description:"Utility functions for dealing with ranges of text",name:"rangeutils"},stylesheet:{resourceURL:"resources/stylesheet/",name:"stylesheet",environments:{worker:true},dependencies:{standard_syntax:"0.0.0"},testmodules:[],provides:[{pointer:"#CSSSyntax",ep:"syntax",fileexts:["css","less"],name:"css"}],type:"plugins/supported",
description:"CSS syntax highlighter"},html:{resourceURL:"resources/html/",name:"html",environments:{worker:true},dependencies:{standard_syntax:"0.0.0"},testmodules:[],provides:[{pointer:"#HTMLSyntax",ep:"syntax",fileexts:["htm","html"],name:"html"}],type:"plugins/supported",description:"HTML syntax highlighter"},js_syntax:{resourceURL:"resources/js_syntax/",name:"js_syntax",environments:{worker:true},dependencies:{standard_syntax:"0.0.0",settings:"0.0.0"},testmodules:[],provides:[{settings:["specialmodules"],
pointer:"#JSSyntax",ep:"syntax",fileexts:["js","json"],name:"js"},{description:"Regex that matches special modules",defaultValue:"^jetpack\\.[^\"']+",type:"text",ep:"setting",name:"specialmodules"}],type:"plugins/supported",description:"JavaScript syntax highlighter"},ctags:{resourceURL:"resources/ctags/",description:"Reads and writes tag files",dependencies:{traits:"0.0.0",underscore:"0.0.0"},testmodules:[],type:"plugins/supported",name:"ctags"},events:{resourceURL:"resources/events/",description:"Dead simple event implementation",
dependencies:{traits:"0.0"},testmodules:["tests/test"],provides:[],type:"plugins/supported",name:"events"},theme_manager:{resourceURL:"resources/theme_manager/",name:"theme_manager",share:true,environments:{main:true,worker:false},dependencies:{theme_manager_base:"0.0.0",settings:"0.0.0",events:"0.0.0",less:"0.0.0"},testmodules:[],provides:[{unregister:"themestyles#unregisterThemeStyles",register:"themestyles#registerThemeStyles",ep:"extensionhandler",name:"themestyles"},{unregister:"index#unregisterTheme",
register:"index#registerTheme",ep:"extensionhandler",name:"theme"},{defaultValue:"standard",description:"The theme plugin's name to use. If set to 'standard' no theme will be used",type:"text",ep:"setting",name:"theme"},{pointer:"#appLaunched",ep:"appLaunched"}],type:"plugins/supported",description:"Handles colors in Bespin"},whitetheme:{resourceURL:"resources/whitetheme/",description:"Provides a white theme for Bespin",dependencies:{theme_manager:"0.0.0"},testmodules:[],provides:[{url:["theme.less"],
description:"A basic white theme",pointer:"index#whiteTheme",ep:"theme",name:"white"}],type:"plugins/supported",name:"whitetheme"},standard_syntax:{resourceURL:"resources/standard_syntax/",description:"Easy-to-use basis for syntax engines",environments:{worker:true},dependencies:{syntax_worker:"0.0.0",syntax_directory:"0.0.0",underscore:"0.0.0"},testmodules:[],type:"plugins/supported",name:"standard_syntax"},jquery:{testmodules:[],resourceURL:"resources/jquery/",name:"jquery",type:"plugins/thirdparty"},
embedded:{testmodules:[],dependencies:{theme_manager:"0.0.0",text_editor:"0.0.0",appconfig:"0.0.0",edit_session:"0.0.0",screen_theme:"0.0.0"},resourceURL:"resources/embedded/",name:"embedded",type:"plugins/supported"},appconfig:{resourceURL:"resources/appconfig/",description:"Instantiates components and displays the GUI based on configuration.",dependencies:{jquery:"0.0.0",canon:"0.0.0",underscore:"0.0.0",settings:"0.0.0"},testmodules:[],provides:[{description:"Event: Fired when the app is completely launched.",
ep:"extensionpoint",name:"appLaunched"}],type:"plugins/supported",name:"appconfig"},syntax_worker:{resourceURL:"resources/syntax_worker/",description:"Coordinates multiple syntax engines",environments:{worker:true},dependencies:{syntax_directory:"0.0.0",underscore:"0.0.0"},testmodules:[],type:"plugins/supported",name:"syntax_worker"},screen_theme:{resourceURL:"resources/screen_theme/",description:"Bespins standard theme basePlugin",dependencies:{theme_manager:"0.0.0"},testmodules:[],provides:[{url:["theme.less"],
ep:"themestyles"},{defaultValue:"@global_font",ep:"themevariable",name:"container_font"},{defaultValue:"@global_font_size",ep:"themevariable",name:"container_font_size"},{defaultValue:"@global_container_background",ep:"themevariable",name:"container_bg"},{defaultValue:"@global_color",ep:"themevariable",name:"container_color"},{defaultValue:"@global_line_height",ep:"themevariable",name:"container_line_height"},{defaultValue:"@global_pane_background",ep:"themevariable",name:"pane_bg"},{defaultValue:"@global_pane_border_radius",
ep:"themevariable",name:"pane_border_radius"},{defaultValue:"@global_form_font",ep:"themevariable",name:"form_font"},{defaultValue:"@global_form_font_size",ep:"themevariable",name:"form_font_size"},{defaultValue:"@global_form_line_height",ep:"themevariable",name:"form_line_height"},{defaultValue:"@global_form_color",ep:"themevariable",name:"form_color"},{defaultValue:"@global_form_text_shadow",ep:"themevariable",name:"form_text_shadow"},{defaultValue:"@global_pane_link_color",ep:"themevariable",name:"pane_a_color"},
{defaultValue:"@global_font",ep:"themevariable",name:"pane_font"},{defaultValue:"@global_font_size",ep:"themevariable",name:"pane_font_size"},{defaultValue:"@global_pane_text_shadow",ep:"themevariable",name:"pane_text_shadow"},{defaultValue:"@global_pane_h1_font",ep:"themevariable",name:"pane_h1_font"},{defaultValue:"@global_pane_h1_font_size",ep:"themevariable",name:"pane_h1_font_size"},{defaultValue:"@global_pane_h1_color",ep:"themevariable",name:"pane_h1_color"},{defaultValue:"@global_font_size * 1.8",
ep:"themevariable",name:"pane_line_height"},{defaultValue:"@global_pane_color",ep:"themevariable",name:"pane_color"},{defaultValue:"@global_text_shadow",ep:"themevariable",name:"pane_text_shadow"},{defaultValue:"@global_font",ep:"themevariable",name:"button_font"},{defaultValue:"@global_font_size",ep:"themevariable",name:"button_font_size"},{defaultValue:"@global_button_color",ep:"themevariable",name:"button_color"},{defaultValue:"@global_button_background",ep:"themevariable",name:"button_bg"},{defaultValue:"@button_bg - #063A27",
ep:"themevariable",name:"button_bg2"},{defaultValue:"@button_bg - #194A5E",ep:"themevariable",name:"button_border"},{defaultValue:"@global_control_background",ep:"themevariable",name:"control_bg"},{defaultValue:"@global_control_color",ep:"themevariable",name:"control_color"},{defaultValue:"@global_control_border",ep:"themevariable",name:"control_border"},{defaultValue:"@global_control_border_radius",ep:"themevariable",name:"control_border_radius"},{defaultValue:"@global_control_active_background",
ep:"themevariable",name:"control_active_bg"},{defaultValue:"@global_control_active_border",ep:"themevariable",name:"control_active_border"},{defaultValue:"@global_control_active_color",ep:"themevariable",name:"control_active_color"},{defaultValue:"@global_control_active_inset_color",ep:"themevariable",name:"control_active_inset_color"}],type:"plugins/supported",name:"screen_theme"}})})})();
(function(){var y=bespin.tiki.require("bespin:promise").Promise,u=bespin.tiki.require("bespin:promise").group,v=bespin.tiki.require("jquery").$;bespin.loaded=new y;bespin.initialized=new y;var s=function(o,k,b){o=o.style[b]||document.defaultView.getComputedStyle(o,"").getPropertyValue(b);if(!o||o=="auto"||o=="intrinsic")o=k.style[b];return o};bespin.useBespin=function(o,k){var b=bespin.tiki.require("bespin:util/util"),f={},q=f.settings;k=k||{};for(var h in k)f[h]=k[h];k=f.settings;if(q!==undefined)for(h in q)if(k[h]===
undefined)f.settings[h]=q[h];var j=null,g=new y;bespin.tiki.require.ensurePackage("::appconfig",function(){var p=bespin.tiki.require("appconfig");if(b.isString(o))o=document.getElementById(o);if(b.none(f.initialContent))f.initialContent=o.value||o.innerHTML;o.innerHTML="";if(o.type=="textarea"){var r=o.parentNode,z=document.createElement("div"),C=function(){var K="position:relative;";["margin-top","margin-left","margin-right","margin-bottom"].forEach(function(w){K+=w+":"+s(o,z,w)+";"});var M=s(o,
z,"width"),l=s(o,z,"height");K+="height:"+l+";width:"+M+";";K+="display:inline-block;";z.setAttribute("style",K)};window.addEventListener("resize",C,false);C();for(o.nextSibling?r.insertBefore(z,o.nextSibling):r.appendChild(z);r!==document;){if(r.tagName.toUpperCase()==="FORM"){var e=r.onsubmit;r.onsubmit=function(K){o.value=j.editor.value;o.innerHTML=j.editor.value;e&&e.call(this,K)};break}r=r.parentNode}o.style.display="none";f.element=z;if(!b.none(o.getAttribute("readonly")))f.readOnly=true}else f.element=
o;p.launch(f).then(function(K){j=K;g.resolve(K)})});return g};v(document).ready(function(){bespin.loaded.resolve();for(var o=[],k=document.querySelectorAll(".bespin"),b=0;b<k.length;b++){var f=k[b],q=f.getAttribute("data-bespinoptions")||"{}";q=bespin.useBespin(f,JSON.parse(q));q.then(function(h){f.bespin=h},function(h){throw new Error("Launch failed: "+h);});o.push(q)}u(o).then(function(){bespin.initialized.resolve();window.onBespinLoad&&window.onBespinLoad()},function(h){bespin.initialized.reject("At least one Bespin failed to launch!"+
h)})})})();
