annotate-esprima/scripts/lib/esprima-master/assets/orion/built-editor.min.js

764 lines
270 KiB
JavaScript
Raw Normal View History

2014-04-15 09:04:48 +00:00
/*
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2009, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
Copyright (c) 2012 VMware, Inc.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Andrew Eisenberg - rename to jsTemplateContentAssist.js
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Alex Lakatos - fix for bug#369781
Copyright (c) 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
RequireJS i18n 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
Copyright (c) 2011 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
*/
var requirejs,require,define;
(function(s){function r(c,j){var q,a,b,d,e,i,f,g,k,h=j&&j.split("/"),l=o.map,m=l&&l["*"]||{};if(c&&c.charAt(0)===".")if(j){h=h.slice(0,h.length-1);c=h.concat(c.split("/"));for(g=0;g<c.length;g+=1)if(q=c[g],q===".")c.splice(g,1),g-=1;else if(q==="..")if(g===1&&(c[2]===".."||c[0]===".."))break;else g>0&&(c.splice(g-1,2),g-=2);c=c.join("/")}else c.indexOf("./")===0&&(c=c.substring(2));if((h||m)&&l){q=c.split("/");for(g=q.length;g>0;g-=1){a=q.slice(0,g).join("/");if(h)for(k=h.length;k>0;k-=1)if(b=l[h.slice(0,
k).join("/")])if(b=b[a]){d=b;e=g;break}if(d)break;!i&&m&&m[a]&&(i=m[a],f=g)}!d&&i&&(d=i,e=f);d&&(q.splice(0,e,d),c=q.join("/"))}return c}function p(c,j){return function(){return a.apply(s,q.call(arguments,0).concat([c,j]))}}function f(c){return function(j){return r(j,c)}}function h(c){return function(j){i[c]=j}}function l(u){if(j.call(g,u)){var q=g[u];delete g[u];c[u]=!0;e.apply(s,q)}if(!j.call(i,u)&&!j.call(c,u))throw Error("No "+u);return i[u]}function k(c){var j,q=c?c.indexOf("!"):-1;q>-1&&(j=
c.substring(0,q),c=c.substring(q+1,c.length));return[j,c]}function m(c){return function(){return o&&o.config&&o.config[c]||{}}}var e,a,b,d,i={},g={},o={},c={},j=Object.prototype.hasOwnProperty,q=[].slice;b=function(c,j){var q,a=k(c),b=a[0],c=a[1];b&&(b=r(b,j),q=l(b));b?c=q&&q.normalize?q.normalize(c,f(j)):r(c,j):(c=r(c,j),a=k(c),b=a[0],c=a[1],b&&(q=l(b)));return{f:b?b+"!"+c:c,n:c,pr:b,p:q}};d={require:function(c){return p(c)},exports:function(c){var j=i[c];return typeof j!=="undefined"?j:i[c]={}},
module:function(c){return{id:c,uri:"",exports:i[c],config:m(c)}}};e=function(q,a,e,n){var B,f,t,o,k=[],m,n=n||q;if(typeof e==="function"){a=!a.length&&e.length?["require","exports","module"]:a;for(o=0;o<a.length;o+=1)if(t=b(a[o],n),f=t.f,f==="require")k[o]=d.require(q);else if(f==="exports")k[o]=d.exports(q),m=!0;else if(f==="module")B=k[o]=d.module(q);else if(j.call(i,f)||j.call(g,f)||j.call(c,f))k[o]=l(f);else if(t.p)t.p.load(t.n,p(n,!0),h(f),{}),k[o]=i[f];else throw Error(q+" missing "+f);a=e.apply(i[q],
k);if(q)if(B&&B.exports!==s&&B.exports!==i[q])i[q]=B.exports;else if(a!==s||!m)i[q]=a}else q&&(i[q]=e)};requirejs=require=a=function(c,j,q,n,B){if(typeof c==="string")return d[c]?d[c](j):l(b(c,j).f);else c.splice||(o=c,j.splice?(c=j,j=q,q=null):c=s);j=j||function(){};typeof q==="function"&&(q=n,n=B);n?e(s,c,j,q):setTimeout(function(){e(s,c,j,q)},4);return a};a.config=function(c){o=c;return a};define=function(c,q,a){q.splice||(a=q,q=[]);!j.call(i,c)&&!j.call(g,c)&&(g[c]=[c,q,a])};define.amd={jQuery:!0}})();
define("almond",function(){});
define("orion/editor/eventTarget",[],function(){function s(){}s.addMixin=function(r){var p=s.prototype,f;for(f in p)p.hasOwnProperty(f)&&(r[f]=p[f])};s.prototype={addEventListener:function(r,p,f){if(!this._eventTypes)this._eventTypes={};var h=this._eventTypes[r];h||(h=this._eventTypes[r]={level:0,listeners:[]});h.listeners.push({listener:p,useCapture:f})},dispatchEvent:function(r){var p=r.type;this._dispatchEvent("pre"+p,r);this._dispatchEvent(p,r);this._dispatchEvent("post"+p,r)},_dispatchEvent:function(r,
p){var f=this._eventTypes?this._eventTypes[r]:null;if(f){var h=f.listeners;try{if(f.level++,h)for(var l=0,k=h.length;l<k;l++)if(h[l]){var m=h[l].listener;typeof m==="function"?m.call(this,p):m.handleEvent&&typeof m.handleEvent==="function"&&m.handleEvent(p)}}finally{if(f.level--,f.compact&&f.level===0){for(l=h.length-1;l>=0;l--)h[l]||h.splice(l,1);h.length===0&&delete this._eventTypes[r];f.compact=!1}}}},isListening:function(r){return!this._eventTypes?!1:this._eventTypes[r]!==void 0},removeEventListener:function(r,
p,f){if(this._eventTypes){var h=this._eventTypes[r];if(h){for(var l=h.listeners,k=0,m=l.length;k<m;k++){var e=l[k];if(e&&e.listener===p&&e.useCapture===f){h.level!==0?(l[k]=null,h.compact=!0):l.splice(k,1);break}}l.length===0&&delete this._eventTypes[r]}}}};return{EventTarget:s}});
define("orion/editor/util",[],function(){var s=navigator.userAgent,r=parseFloat(s.split("MSIE")[1])||void 0,p=parseFloat(s.split("Firefox/")[1]||s.split("Minefield/")[1])||void 0,f=s.indexOf("Opera")!==-1,h=parseFloat(s.split("Chrome/")[1])||void 0,l=s.indexOf("Safari")!==-1&&!h,k=parseFloat(s.split("WebKit/")[1])||void 0,m=s.indexOf("Android")!==-1,e=s.indexOf("iPad")!==-1,s=s.indexOf("iPhone")!==-1,a=e||s,b=navigator.platform.indexOf("Mac")!==-1,d=navigator.platform.indexOf("Win")!==-1,i=navigator.platform.indexOf("Linux")!==
-1;return{formatMessage:function(a){var b=arguments;return a.replace(/\$\{([^\}]+)\}/g,function(c,j){return b[(j<<0)+1]})},createElement:function(a,b){return a.createElementNS?a.createElementNS("http://www.w3.org/1999/xhtml",b):a.createElement(b)},isIE:r,isFirefox:p,isOpera:f,isChrome:h,isSafari:l,isWebkit:k,isAndroid:m,isIPad:e,isIPhone:s,isIOS:a,isMac:b,isWindows:d,isLinux:i,platformDelimiter:d?"\r\n":"\n"}});
define("orion/editor/textModel",["orion/editor/eventTarget","orion/editor/util"],function(s,r){function p(f,h){this._lastLineIndex=-1;this._text=[""];this._lineOffsets=[0];this.setText(f);this.setLineDelimiter(h)}p.prototype={find:function(f){if(this._text.length>1)this._text=[this._text.join("")];var h=f.string,l=h;!f.regex&&h&&(l=h.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"));var k=null,m;if(l){var h=f.reverse,e=f.wrap,a=f.wholeWord,b=f.caseInsensitive,d=f.start||0,i=f.end,f=f.end!==void 0,g=
"";g.indexOf("g")===-1&&(g+="g");b&&g.indexOf("i")===-1&&(g+="i");a&&(l="\\b"+l+"\\b");var o=this._text[0],c,j,q=0;f&&(o=o.substring(d,i),q=d);var u=RegExp(l,g);if(h)m=function(){var a=null;for(u.lastIndex=0;;){j=u.lastIndex;c=u.exec(o);if(j===u.lastIndex)return null;if(c){if(!(c.index<d)){if(!e||a)break;d=o.length}a={start:c.index+q,end:u.lastIndex+q}}else break}if(a)d=a.start;return a};else{if(!f)u.lastIndex=d;m=function(){for(;;){j=u.lastIndex;c=u.exec(o);if(j===u.lastIndex)break;if(c)return{start:c.index+
q,end:u.lastIndex+q};if(!(j!==0&&e))break}return null}}k=m()}return{next:function(){var c=k;c&&(k=m());return c},hasNext:function(){return k!==null}}},getCharCount:function(){for(var f=0,h=0;h<this._text.length;h++)f+=this._text[h].length;return f},getLine:function(f,h){var l=this.getLineCount();if(!(0<=f&&f<l))return null;var k=this._lineOffsets[f];if(f+1<l){l=this.getText(k,this._lineOffsets[f+1]);if(h)return l;for(var k=l.length,m;(m=l.charCodeAt(k-1))===10||m===13;)k--;return l.substring(0,k)}else return this.getText(k)},
getLineAtOffset:function(f){var h=this.getCharCount();if(!(0<=f&&f<=h))return-1;var l=this.getLineCount();if(f===h)return l-1;var k,m,e=this._lastLineIndex;if(0<=e&&e<l&&(k=this._lineOffsets[e],m=e+1<l?this._lineOffsets[e+1]:h,k<=f&&f<m))return e;for(var a=l,b=-1;a-b>1;)if(e=Math.floor((a+b)/2),k=this._lineOffsets[e],m=e+1<l?this._lineOffsets[e+1]:h,f<=k)a=e;else if(f<m){a=e;break}else b=e;return this._lastLineIndex=a},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},
getLineEnd:function(f,h){var l=this.getLineCount();if(!(0<=f&&f<l))return-1;if(f+1<l){l=this._lineOffsets[f+1];if(h)return l;for(var k=this.getText(Math.max(this._lineOffsets[f],l-2),l),m=k.length,e;(e=k.charCodeAt(m-1))===10||e===13;)m--;return l-(k.length-m)}else return this.getCharCount()},getLineStart:function(f){return!(0<=f&&f<this.getLineCount())?-1:this._lineOffsets[f]},getText:function(f,h){f===void 0&&(f=0);h===void 0&&(h=this.getCharCount());if(f===h)return"";for(var l=0,k=0,m;k<this._text.length;){m=
this._text[k].length;if(f<=l+m)break;l+=m;k++}for(var e=l,a=k;k<this._text.length;){m=this._text[k].length;if(h<=l+m)break;l+=m;k++}if(a===k)return this._text[a].substring(f-e,h-l);e=this._text[a].substring(f-e);l=this._text[k].substring(0,h-l);return e+this._text.slice(a+1,k).join("")+l},onChanging:function(f){return this.dispatchEvent(f)},onChanged:function(f){return this.dispatchEvent(f)},setLineDelimiter:function(f,h){f==="auto"&&(f=void 0,this.getLineCount()>1&&(f=this.getText(this.getLineEnd(0),
this.getLineEnd(0,!0))));this._lineDelimiter=f?f:r.platformDelimiter;if(h){var l=this.getLineCount();if(l>1){for(var k=Array(l),m=0;m<l;m++)k[m]=this.getLine(m);this.setText(k.join(this._lineDelimiter))}}},setText:function(f,h,l){f===void 0&&(f="");h===void 0&&(h=0);l===void 0&&(l=this.getCharCount());if(!(h===l&&f==="")){for(var k=this.getLineAtOffset(h),m=this.getLineAtOffset(l),e=h,a=l-h,b=m-k,d=f.length,i=0,g=this.getLineCount(),o=0,c=0,j=0,q=[];;){o!==-1&&o<=j&&(o=f.indexOf("\r",j));c!==-1&&
c<=j&&(c=f.indexOf("\n",j));if(c===-1&&o===-1)break;j=o!==-1&&c!==-1?o+1===c?c+1:(o<c?o:c)+1:o!==-1?o+1:c+1;q.push(h+j);i++}this.onChanging({type:"Changing",text:f,start:e,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:i});q.length===0&&(o=this.getLineStart(k),m=m+1<g?this.getLineStart(m+1):this.getCharCount(),h!==o&&(f=this.getText(o,h)+f,h=o),l!==m&&(f+=this.getText(l,m),l=m));m=d-a;for(o=k+b+1;o<g;o++)this._lineOffsets[o]+=m;k=[k+1,b].concat(q);Array.prototype.splice.apply(this._lineOffsets,
k);for(m=q=0;m<this._text.length;){o=this._text[m].length;if(h<=q+o)break;q+=o;m++}g=q;for(k=m;m<this._text.length;){o=this._text[m].length;if(l<=q+o)break;q+=o;m++}o=this._text[m];h=this._text[k].substring(0,h-g);l=o.substring(l-q);k=[k,m-k+1];h&&k.push(h);f&&k.push(f);l&&k.push(l);Array.prototype.splice.apply(this._text,k);if(this._text.length===0)this._text=[""];this.onChanged({type:"Changed",start:e,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:i})}}};s.EventTarget.addMixin(p.prototype);
return{TextModel:p}});
define("orion/editor/keyBinding",["orion/editor/util"],function(s){function r(p,f,h,l,k){this.keyCode=typeof p==="string"?p.toUpperCase().charCodeAt(0):p;this.mod1=f!==void 0&&f!==null?f:!1;this.mod2=h!==void 0&&h!==null?h:!1;this.mod3=l!==void 0&&l!==null?l:!1;this.mod4=k!==void 0&&k!==null?k:!1}r.prototype={match:function(p){return this.keyCode===p.keyCode?this.mod1!==(s.isMac?p.metaKey:p.ctrlKey)?!1:this.mod2!==p.shiftKey?!1:this.mod3!==p.altKey?!1:s.isMac&&this.mod4!==p.ctrlKey?!1:!0:!1},equals:function(p){return!p?
!1:this.keyCode!==p.keyCode?!1:this.mod1!==p.mod1?!1:this.mod2!==p.mod2?!1:this.mod3!==p.mod3?!1:this.mod4!==p.mod4?!1:!0}};return{KeyBinding:r}});
define("orion/editor/textView",["orion/editor/textModel","orion/editor/keyBinding","orion/editor/eventTarget","orion/editor/util"],function(s,r,p,f){function h(c,j,q,u){typeof c.addEventListener==="function"?c.addEventListener(j,q,u===!0):c.attachEvent("on"+j,q)}function l(c,j,q){if(q){j.className="";for(var q=j.attributes,u=q.length;u-- >0;)(!f.isIE||f.isIE>=9||f.isIE<9&&q[u].specified)&&j.removeAttribute(q[u].name)}if(c){if(c.styleClass)j.className=c.styleClass;if(q=c.style)for(var a in q)q.hasOwnProperty(a)&&
(j.style[a]=q[a]);if(c=c.attributes)for(var b in c)c.hasOwnProperty(b)&&j.setAttribute(b,c[b])}}function k(c){return c instanceof Array?c.slice(0):c}function m(c,j){if(c===j)return!0;if(c&&!j||!c&&j)return!1;if(c&&c.constructor===String||j&&j.constructor===String)return!1;if(c instanceof Array||j instanceof Array){if(!(c instanceof Array&&j instanceof Array))return!1;if(c.length!==j.length)return!1;for(var q=0;q<c.length;q++)if(!m(c[q],j[q]))return!1;return!0}if(!(c instanceof Object)||!(j instanceof
Object))return!1;for(q in c)if(c.hasOwnProperty(q)){if(!j.hasOwnProperty(q))return!1;if(!m(c[q],j[q]))return!1}for(q in j)if(!c.hasOwnProperty(q))return!1;return!0}function e(c,j,q){for(var a=0,b=0,d=0,n=c.length;d<n;){a!==-1&&a<=d&&(a=c.indexOf("\r",d));b!==-1&&b<=d&&(b=c.indexOf("\n",d));var e=d,i;if(b===-1&&a===-1){j(c.substring(d));break}a!==-1&&b!==-1?a+1===b?(i=a,d=b+1):(i=a<b?a:b,d=(a<b?a:b)+1):a!==-1?(i=a,d=a+1):(i=b,d=b+1);j(c.substring(e,i));q()}}function a(c){var j,q,a,b,d=c.ownerDocument.defaultView||
c.ownerDocument.parentWindow;if(d.getComputedStyle)c=d.getComputedStyle(c,null),j=c.getPropertyValue("padding-left"),q=c.getPropertyValue("padding-top"),a=c.getPropertyValue("padding-right"),b=c.getPropertyValue("padding-bottom");else if(c.currentStyle)j=c.currentStyle.paddingLeft,q=c.currentStyle.paddingTop,a=c.currentStyle.paddingRight,b=c.currentStyle.paddingBottom;return{left:parseInt(j,10)||0,top:parseInt(q,10)||0,right:parseInt(a,10)||0,bottom:parseInt(b,10)||0}}function b(c){var j,q,u,b,d=
c._trim;if(!d){var d=a(c),n=c.ownerDocument.defaultView||c.ownerDocument.parentWindow;if(n.getComputedStyle)b=n.getComputedStyle(c,null),j=b.getPropertyValue("border-left-width"),q=b.getPropertyValue("border-top-width"),u=b.getPropertyValue("border-right-width"),b=b.getPropertyValue("border-bottom-width");else if(c.currentStyle)j=c.currentStyle.borderLeftWidth,q=c.currentStyle.borderTopWidth,u=c.currentStyle.borderRightWidth,b=c.currentStyle.borderBottomWidth;j=parseInt(j,10)||0;q=parseInt(q,10)||
0;u=parseInt(u,10)||0;b=parseInt(b,10)||0;d.left+=j;d.top+=q;d.right+=u;d.bottom+=b;c._trim=d}return d}function d(c,j,q){this.start=c;this.end=j;this.caret=q}function i(c){this.left=c.left;this.top=c.top;this.right=c.right;this.bottom=c.bottom}function g(c,j,q){this.view=c;this.lineIndex=j;this._lineDiv=q}function o(c){this._init(c)}d.prototype={clone:function(){return new d(this.start,this.end,this.caret)},collapse:function(){this.caret?this.end=this.start:this.start=this.end},extend:function(c){this.caret?
this.start=c:this.end=c;if(this.start>this.end)c=this.start,this.start=this.end,this.end=c,this.caret=!this.caret},setCaret:function(c){this.end=this.start=c;this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},toString:function(){return"start="+this.start+" end="+this.end+(this.caret?" caret is at start":" caret is at end")},isEmpty:function(){return this.start===this.end},equals:function(c){return this.caret===c.caret&&this.start===c.start&&this.end===c.end}};i.prototype={toString:function(){return"{l="+
this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}};g.prototype={create:function(c,j){if(!this._lineDiv){var q=this._lineDiv=this._createLine(c,j,this.lineIndex);q._line=this;return q}},_createLine:function(c,j,q){var a=this.view,b=a._model,d=b.getLine(q),n=b.getLineStart(q),e={type:"LineStyle",textView:a,lineIndex:q,lineText:d,lineStart:n};if(d.length<2E3)a.onLineStyle(e);b=j||f.createElement(c.ownerDocument,"div");if(!j||!m(j.viewStyle,e.style)){l(e.style,b,j);if(j)j._trim=null;
b.viewStyle=e.style;b.setAttribute("role","presentation")}b.lineIndex=q;q=[];this._createRanges(e.ranges,d,0,d.length,n,{tabOffset:0,ranges:q});d=" ";!a._fullSelection&&f.isIE<9&&(d="\ufeff");f.isWebkit&&(d="\u200c");q.push({text:d,style:a._metrics.largestFontStyle,ignoreChars:1});var i,t,g,o,k,d=a=0,h,w;if(j){if(t=j.modelChangedEvent)t.removedLineCount===0&&t.addedLineCount===0?(w=t.start-n,h=t.addedCharCount-t.removedCharCount):w=-1,j.modelChangedEvent=void 0;t=j.firstChild}for(n=0;n<q.length;n++){i=
q[n];o=i.text;a+=o.length;e=i.style;if(t)if(k=t.firstChild.data,g=t.viewStyle,k===o&&m(e,g)){d+=k.length;t._rectsCache=void 0;i=t=t.nextSibling;continue}else for(;t;){if(w!==-1){g=a;g>=w&&(g-=h);k=(k=t.firstChild.data)?k.length:0;if(d+k>g)break;d+=k}g=t.nextSibling;b.removeChild(t);t=g}i=this._createSpan(b,o,e,i.ignoreChars);t?b.insertBefore(i,t):b.appendChild(i);if(j)j.lineWidth=void 0}if(j)for(c=i?i.nextSibling:null;c;)g=c.nextSibling,j.removeChild(c),c=g;else c.appendChild(b);return b},_createRanges:function(c,
j,q,a,b,d){if(!(q>=a)){if(c)for(var n=0;n<c.length;n++){var e=c[n];if(!(e.end<=b+q)){var i=Math.max(b+q,e.start)-b;if(i>=a)break;var f=Math.min(b+a,e.end)-b;if(i<f){i=Math.max(q,i);f=Math.min(a,f);for(q<i&&this._createRange(j,q,i,null,d);n+1<c.length&&c[n+1].start-b===f&&m(e.style,c[n+1].style);)e=c[n+1],f=Math.min(b+a,e.end)-b,n++;this._createRange(j,i,f,e.style,d);q=f}}}q<a&&this._createRange(j,q,a,null,d)}},_createRange:function(c,j,q,a,b){if(!(j>=q)){var d=this.view._customTabSize;if(d&&d!==8)for(var n=
c.indexOf("\t",j);n!==-1&&n<q;){j<n&&(j={text:c.substring(j,n),style:a},b.ranges.push(j),b.tabOffset+=j.text.length);j=d-b.tabOffset%d;if(j>0){for(var e="\u00a0",i=1;i<j;i++)e+=" ";j={text:e,style:a,ignoreChars:j-1};b.ranges.push(j);b.tabOffset+=j.text.length}j=n+1;n=c.indexOf("\t",j)}j<q&&(j={text:c.substring(j,q),style:a},b.ranges.push(j),b.tabOffset+=j.text.length)}},_createSpan:function(c,j,q,a){var b=q&&q.tagName==="A";if(b)c.hasLink=!0;var b=b&&this.view._linksVisible?"a":"span",d=c.ownerDocument,
c=f.createElement(c.ownerDocument,b);c.appendChild(d.createTextNode(j));l(q,c);if(b==="A"){var n=this.view,e=this._getWindow();h(c,"click",function(c){return n._handleLinkClick(c?c:e.event)},!1)}c.viewStyle=q;if(a)c.ignoreChars=a;return c},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(c,j){var q=this._ensureCreated(),a=this.view;if(c===void 0)return this._getLineBoundingClientRect(q,!0);var b=a._model,
d=q.ownerDocument,n=this.lineIndex,e=null;if(c<b.getLineEnd(n)){b=b.getLineStart(n);for(n=q.firstChild;n;){var g=n.firstChild,t=g.length;n.ignoreChars&&(t-=n.ignoreChars);if(b+t>c){e=c-b;if(a._isRangeRects)d=d.createRange(),d.setStart(g,e),d.setEnd(g,e+1),e=new i(d.getBoundingClientRect());else if(f.isIE)d=d.body.createTextRange(),d.moveToElementText(n),d.collapse(),d.moveEnd("character",e+1),d.moveStart("character",e),e=new i(d.getBoundingClientRect());else{var o=g.data;n.removeChild(g);n.appendChild(d.createTextNode(o.substring(0,
e)));var k=f.createElement(d,"span");k.appendChild(d.createTextNode(o.substring(e,e+1)));n.appendChild(k);n.appendChild(d.createTextNode(o.substring(e+1)));e=new i(k.getBoundingClientRect());n.innerHTML="";n.appendChild(g);this._createdDiv||(d=a._getSelection(),(b<=d.start&&d.start<b+t||b<=d.end&&d.end<b+t)&&a._updateDOMSelection())}f.isIE&&(d=q.ownerDocument.defaultView||q.ownerDocument.parentWindow,q=d.screen.logicalXDPI/d.screen.deviceXDPI,d=d.screen.logicalYDPI/d.screen.deviceYDPI,e.left*=q,e.right*=
q,e.top*=d,e.bottom*=d);break}b+=t;n=n.nextSibling}}q=this.getBoundingClientRect();if(!e)a._wrapMode?(a=this.getClientRects(),e=a[a.length-1],e.left=e.right,e.left+=q.left,e.top+=q.top,e.right+=q.left,e.bottom+=q.top):(e=new i(q),e.left=e.right);if(j||j===void 0)e.left-=q.left,e.top-=q.top,e.right-=q.left,e.bottom-=q.top;return e},_getClientRects:function(c,j){var q,a,b,d;if(!c._rectsCache){q=c.getClientRects();a=Array(q.length);for(d=0;d<q.length;d++)b=a[d]=new i(q[d]),b.left-=j.left,b.top-=j.top,
b.right-=j.left,b.bottom-=j.top;c._rectsCache=a}q=c._rectsCache;a=[q.length];for(d=0;d<q.length;d++)a[d]=new i(q[d]);return a},getClientRects:function(c){if(!this.view._wrapMode)return[this.getBoundingClientRect()];for(var j=this._ensureCreated(),q=[],a=j.firstChild,b,d=j.getBoundingClientRect();a;){for(var n=this._getClientRects(a,d),j=0;j<n.length;j++){var e=n[j],i;if(e.top!==e.bottom){var f=e.top+(e.bottom-e.top)/2;for(i=0;i<q.length;i++)if(b=q[i],b.top<=f&&f<b.bottom)break;if(i===q.length)q.push(e);
else{if(e.left<b.left)b.left=e.left;if(e.top<b.top)b.top=e.top;if(e.right>b.right)b.right=e.right;if(e.bottom>b.bottom)b.bottom=e.bottom}}}a=a.nextSibling}return c!==void 0?q[c]:q},_getLineBoundingClientRect:function(c,j){var q=new i(c.getBoundingClientRect());if(!this.view._wrapMode){q.right=q.left;for(var a=c.lastChild;a&&a.ignoreChars===a.firstChild.length;)a=a.previousSibling;if(a)a=a.getBoundingClientRect(),q.right=a.right+b(c).right}j&&(a=b(c),q.left+=a.left,q.right-=a.right);return q},getLineCount:function(){return!this.view._wrapMode?
1:this.getClientRects().length},getLineIndex:function(c){if(!this.view._wrapMode)return 0;for(var j=this.getClientRects(),c=this.getBoundingClientRect(c),c=c.top+(c.bottom-c.top)/2,q=0;q<j.length;q++)if(j[q].top<=c&&c<j[q].bottom)return q;return j.length-1},getLineStart:function(c){if(!this.view._wrapMode||c===0)return this.view._model.getLineStart(c);var j=this.getClientRects();return this.getOffset(j[c].left+1,j[c].top+1)},getOffset:function(c,j){var q=this.view,a=q._model,b=this.lineIndex,d=a.getLineStart(b),
a=a.getLineEnd(b);if(d===a)return d;var n=this._ensureCreated(),b=this.getBoundingClientRect(),e,i;if(q._wrapMode){e=this.getClientRects();if(j<e[0].top)j=e[0].top;for(var g=0;g<e.length;g++)if(i=e[g],i.top<=j&&j<i.bottom)break;if(c<i.left)c=i.left;c>i.right&&(c=i.right-1)}else c<0&&(c=0),c>b.right-b.left&&(c=b.right-b.left);var o=n.ownerDocument,g=o.defaultView||o.parentWindow,k=f.isIE?g.screen.logicalXDPI/g.screen.deviceXDPI:1,h=f.isIE?g.screen.logicalYDPI/g.screen.deviceYDPI:1,g=d,l=n.firstChild;
a:for(;l;){var m=l.firstChild,n=m.length;l.ignoreChars&&(n-=l.ignoreChars);var p,r,s;e=this._getClientRects(l,b);for(var y=0;y<e.length;y++)if(i=e[y],i.left<=c&&c<i.right&&(!q._wrapMode||i.top<=j&&j<i.bottom)){if(f.isIE||q._isRangeRects){for(var o=q._isRangeRects?o.createRange():o.body.createTextRange(),y=n,F=-1;y-F>1;){var G=Math.floor((y+F)/2);i=F+1;e=G===n-1&&l.ignoreChars?m.length:G+1;q._isRangeRects?(o.setStart(m,i),o.setEnd(m,e)):(o.moveToElementText(l),o.move("character",i),o.moveEnd("character",
e-i));e=o.getClientRects();for(var L=!1,I=0;I<e.length;I++)if(i=e[I],p=i.left*k-b.left,s=i.right*k-b.left,r=i.top*h-b.top,i=i.bottom*h-b.top,p<=c&&c<s&&(!q._wrapMode||r<=j&&j<i)){L=!0;break}L?y=G:F=G}g+=y;i=y;e=y===n-1&&l.ignoreChars?m.length:Math.min(y+1,m.length);q._isRangeRects?(o.setStart(m,i),o.setEnd(m,e)):(o.moveToElementText(l),o.move("character",i),o.moveEnd("character",e-i));i=o.getClientRects()[0];p=i.left*k-b.left;s=i.right*k-b.left;c>p+(s-p)/2&&g++}else{i=[];for(k=0;k<n;k++)i.push("<span>"),
k===n-1?i.push(m.data.substring(k)):i.push(m.data.substring(k,k+1)),i.push("</span>");l.innerHTML=i.join("");for(k=l.firstChild;k;){i=k.getBoundingClientRect();p=i.left-b.left;s=i.right-b.left;if(p<=c&&c<s){c>p+(s-p)/2&&g++;break}g++;k=k.nextSibling}if(!this._createdDiv)l.innerHTML="",l.appendChild(m),b=q._getSelection(),(g<=b.start&&b.start<g+n||g<=b.end&&b.end<g+n)&&q._updateDOMSelection()}break a}g+=n;l=l.nextSibling}return Math.min(a,Math.max(d,g))},getNextOffset:function(c,j,q){return j==="line"?
(j=this.view._model,c=j.getLineAtOffset(c),q>0?j.getLineEnd(c):j.getLineStart(c)):j==="wordend"?this._getNextOffset_W3C(c,j,q):f.isIE?this._getNextOffset_IE(c,j,q):this._getNextOffset_W3C(c,j,q)},_getNextOffset_W3C:function(c,j,q){function a(c){return 33<=c&&c<=47||58<=c&&c<=64||91<=c&&c<=94||c===96||123<=c&&c<=126}if(j==="word"||j==="wordend"){var b=this.view._model,d=b.getLineAtOffset(c),n=b.getLine(d),e=b.getLineStart(d),d=b.getLineEnd(d),b=n.length;c-=e;var i,f;if(q>0){if(c===b)return d;i=n.charCodeAt(c);
f=a(i);q=!f&&!(i===32||i===9);for(c++;c<b;){i=n.charCodeAt(c);d=a(i);if(j==="wordend"){if(!d&&f)break}else if(d&&!f)break;i=!d&&!(i===32||i===9);if(j==="wordend"){if(!i&&q)break}else if(i&&!q)break;q=i;f=d;c++}}else{if(c===0)return e;c--;i=n.charCodeAt(c);f=a(i);for(q=!f&&!(i===32||i===9);0<c;){i=n.charCodeAt(c-1);d=a(i);if(j==="wordend"){if(d&&!f)break}else if(!d&&f)break;i=!d&&!(i===32||i===9);if(j==="wordend"){if(i&&!q)break}else if(!i&&q)break;q=i;f=d;c--}}return e+c}return c+q},_getNextOffset_IE:function(c,
j,q){var a=this._ensureCreated(),b=this.view._model,d=this.lineIndex,n=0,e;e=b.getLineStart(d);var i=a.ownerDocument;if(c===b.getLineEnd(d))n=i.body.createTextRange(),n.moveToElementText(a.lastChild),e=n.text.length,n.moveEnd(j,q),n=c+n.text.length-e;else if(c===e&&q<0)n=e;else for(a=a.firstChild;a;){b=a.firstChild.length;a.ignoreChars&&(b-=a.ignoreChars);if(e+b>c){n=i.body.createTextRange();c===e&&q<0?n.moveToElementText(a.previousSibling):(n.moveToElementText(a),n.collapse(),n.moveEnd("character",
c-e));e=n.text.length;n.moveEnd(j,q);n=c+n.text.length-e;break}e=b+e;a=a.nextSibling}return n},destroy:function(){var c=this._createdDiv;if(c)c.parentNode.removeChild(c),this._createdDiv=null}};o.prototype={addRuler:function(c,j){c.setView(this);var a=this._rulers;if(j!==void 0){var b,d;for(b=0,d=0;b<a.length&&d<j;b++)c.getLocation()===a[b].getLocation()&&d++;a.splice(d,0,c);j=d}else a.push(c);this._createRuler(c,j);this._update()},computeSize:function(){var c=0,j=0,a=this._model,b=this._clientDiv;
if(!b)return{width:c,height:j};var d=b.style.width;if(f.isWebkit)b.style.width="0x7fffffffpx";for(var a=a.getLineCount(),e=0;e<a;e++){var n=this._getLine(e),i=n.getBoundingClientRect(),c=Math.max(c,i.right-i.left);j+=i.bottom-i.top;n.destroy()}if(f.isWebkit)b.style.width=d;b=this._getViewPadding();c+=b.right+b.left;j+=b.bottom+b.top;return{width:c,height:j}},convert:function(c,j,a){if(this._clientDiv){var b=this._getScroll(),d=this._getViewPadding(),e=this._viewDiv.getBoundingClientRect();j==="document"&&
(c.x!==void 0&&(c.x+=-b.x+e.left+d.left),c.y!==void 0&&(c.y+=-b.y+e.top+d.top));a==="document"&&(c.x!==void 0&&(c.x+=b.x-e.left-d.left),c.y!==void 0&&(c.y+=b.y-e.top-d.top));return c}},destroy:function(){for(var c=0;c<this._rulers.length;c++)this._rulers[c].setView(null);this.rulers=null;this._destroyView();this.onDestroy({type:"Destroy"});this._actions=this._keyBindings=this._doubleClickSelection=this._selection=this._model=this._parent=null},focus:function(){this._clientDiv&&(this._updateDOMSelection(),
f.isOpera&&this._clientDiv.blur(),this._clientDiv.focus(),this._updateDOMSelection())},hasFocus:function(){return this._hasFocus},getActionDescription:function(c){if(c=this._actions[c])return c.actionDescription},getActions:function(c){var j=[],a=this._actions,b;for(b in a)a.hasOwnProperty(b)&&(c||!a[b].defaultHandler)&&j.push(b);return j},getBottomIndex:function(c){return!this._clientDiv?0:this._getBottomIndex(c)},getBottomPixel:function(){return!this._clientDiv?0:this._getScroll().y+this._getClientHeight()},
getCaretOffset:function(){return this._getSelection().getCaret()},getClientArea:function(){if(!this._clientDiv)return{x:0,y:0,width:0,height:0};var c=this._getScroll();return{x:c.x,y:c.y,width:this._getClientWidth(),height:this._getClientHeight()}},getHorizontalPixel:function(){return!this._clientDiv?0:this._getScroll().x},getKeyBindings:function(c){for(var j=[],a=this._keyBindings,b=0;b<a.length;b++)a[b].actionID===c&&j.push(a[b].keyBinding);return j},getLineHeight:function(c){return!this._clientDiv?
0:this._getLineHeight(c)},getLineIndex:function(c){return!this._clientDiv?0:this._getLineIndex(c)},getLinePixel:function(c){return!this._clientDiv?0:this._getLinePixel(c)},getLocationAtOffset:function(c){if(!this._clientDiv)return{x:0,y:0};var j=this._model,c=Math.min(Math.max(0,c),j.getCharCount()),j=j.getLineAtOffset(c),a=this._getLine(j),c=a.getBoundingClientRect(c);a.destroy();a=c.left;j=this._getLinePixel(j)+c.top;return{x:a,y:j}},getOptions:function(){var c;if(arguments.length===0)c=this._defaultOptions();
else if(arguments.length===1){if(c=arguments[0],typeof c==="string")return k(this["_"+c])}else{c={};for(var j in arguments)arguments.hasOwnProperty(j)&&(c[arguments[j]]=void 0)}for(var a in c)c.hasOwnProperty(a)&&(c[a]=k(this["_"+a]));return c},getModel:function(){return this._model},getOffsetAtLocation:function(c,j){if(!this._clientDiv)return 0;var a=this._getLineIndex(j),b=this._getLine(a),a=b.getOffset(c,j-this._getLinePixel(a));b.destroy();return a},getRulers:function(){return this._rulers.slice(0)},
getSelection:function(){var c=this._getSelection();return{start:c.start,end:c.end}},getText:function(c,j){return this._model.getText(c,j)},getTopIndex:function(c){return!this._clientDiv?0:this._getTopIndex(c)},getTopPixel:function(){return!this._clientDiv?0:this._getScroll().y},invokeAction:function(c,j){if(this._clientDiv){var a=this._actions[c];if(a){if(!j&&a.handler&&a.handler())return;if(a.defaultHandler)return a.defaultHandler()}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(c){return this.dispatchEvent(c)},
onDragStart:function(c){return this.dispatchEvent(c)},onDrag:function(c){return this.dispatchEvent(c)},onDragEnd:function(c){return this.dispatchEvent(c)},onDragEnter:function(c){return this.dispatchEvent(c)},onDragOver:function(c){return this.dispatchEvent(c)},onDragLeave:function(c){return this.dispatchEvent(c)},onDrop:function(c){return this.dispatchEvent(c)},onDestroy:function(c){return this.dispatchEvent(c)},onLineStyle:function(c){return this.dispatchEvent(c)},onModelChanged:function(c){return this.dispatchEvent(c)},
onModelChanging:function(c){return this.dispatchEvent(c)},onModify:function(c){return this.dispatchEvent(c)},onMouseDown:function(c){return this.dispatchEvent(c)},onMouseUp:function(c){return this.dispatchEvent(c)},onMouseMove:function(c){return this.dispatchEvent(c)},onMouseOver:function(c){return this.dispatchEvent(c)},onMouseOut:function(c){return this.dispatchEvent(c)},onSelection:function(c){return this.dispatchEvent(c)},onScroll:function(c){return this.dispatchEvent(c)},onVerify:function(c){return this.dispatchEvent(c)},
onFocus:function(c){return this.dispatchEvent(c)},onBlur:function(c){return this.dispatchEvent(c)},redraw:function(){if(!(this._redrawCount>0)){var c=this._model.getLineCount();this.redrawRulers(0,c);this.redrawLines(0,c)}},redrawRulers:function(c,j){if(!(this._redrawCount>0))for(var a=this.getRulers(),b=0;b<a.length;b++)this.redrawLines(c,j,a[b])},redrawLines:function(c,j,a){if(!(this._redrawCount>0)&&(c===void 0&&(c=0),j===void 0&&(j=this._model.getLineCount()),c!==j)){var b=this._clientDiv;if(b){if(a)for(var d=
(a.getLocation()==="left"?this._leftDiv:this._rightDiv).firstChild.rows[0].cells,e=0;e<d.length;e++)if(d[e].firstChild._ruler===a){b=d[e].firstChild;break}a?b.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(c,j);if(!a||a.getOverview()==="page")for(b=b.firstChild;b;){d=b.lineIndex;if(c<=d&&d<j)b.lineChanged=!0;b=b.nextSibling}if(!a&&!this._wrapMode&&c<=this._maxLineIndex&&this._maxLineIndex<j)this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0;this._queueUpdate()}}},
redrawRange:function(c,j){if(!(this._redrawCount>0)){var a=this._model;c===void 0&&(c=0);j===void 0&&(j=a.getCharCount());var b=a.getLineAtOffset(c),a=a.getLineAtOffset(Math.max(c,j-1))+1;this.redrawLines(b,a)}},removeRuler:function(c){for(var j=this._rulers,a=0;a<j.length;a++)if(j[a]===c){j.splice(a,1);c.setView(null);this._destroyRuler(c);this._update();break}},resize:function(){this._clientDiv&&this._handleResize(null)},setAction:function(c,j,a){if(c){var b=this._actions,d=b[c];d||(d=b[c]={});
d.handler=j;d.actionDescription=a}},setKeyBinding:function(c,j){for(var a=this._keyBindings,b=0;b<a.length;b++){var d=a[b];if(d.keyBinding.equals(c)){j?d.actionID=j:d.predefined?d.actionID=null:a.splice(b,1);return}}j&&a.push({keyBinding:c,actionID:j})},setCaretOffset:function(c,j){var a=this._model.getCharCount(),c=Math.max(0,Math.min(c,a));this._setSelection(new d(c,c,!1),j===void 0||j)},setHorizontalPixel:function(c){this._clientDiv&&(c=Math.max(0,c),this._scrollView(c-this._getScroll().x,0))},
setRedraw:function(c){c?--this._redrawCount===0&&this.redraw():this._redrawCount++},setModel:function(c){if(c&&c!==this._model){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);var j=this._model.getLineCount(),a=this._model.getCharCount(),b=c.getLineCount(),d=c.getCharCount(),e={type:"ModelChanging",text:c.getText(),start:0,removedCharCount:a,addedCharCount:d,removedLineCount:j,addedLineCount:b};
this.onModelChanging(e);this._model=c;e={type:"ModelChanged",start:0,removedCharCount:a,addedCharCount:d,removedLineCount:j,addedLineCount:b};this.onModelChanged(e);this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);this._reset();this._update()}},setOptions:function(c){var j=this._defaultOptions(),a;for(a in c)if(c.hasOwnProperty(a)){var b=c[a];if(!m(this["_"+a],b)){var d=j[a]?j[a].update:null;d?d.call(this,
b):this["_"+a]=k(b)}}},setSelection:function(c,j,a){var b=c>j;if(b)var e=c,c=j,j=e;e=this._model.getCharCount();c=Math.max(0,Math.min(c,e));j=Math.max(0,Math.min(j,e));this._setSelection(new d(c,j,b),a===void 0||a)},setText:function(c,j,a){var b=j===void 0&&a===void 0;j===void 0&&(j=0);a===void 0&&(a=this._model.getCharCount());this._modifyContent({text:c,start:j,end:a,_code:!0},!b);if(b)this._columnX=-1,this._setSelection(new d(0,0,!1),!0),f.isFirefox&&this._fixCaret()},setTopIndex:function(c){this._clientDiv&&
this._scrollView(0,this._getLinePixel(Math.max(0,c))-this._getScroll().y)},setTopPixel:function(c){this._clientDiv&&this._scrollView(0,Math.max(0,c)-this._getScroll().y)},showSelection:function(){return this._showCaret(!0)},update:function(c,j){this._clientDiv&&(c&&this._updateStyle(),j===void 0||j?this._update():this._queueUpdate())},_handleRootMouseDown:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!1,this._ignoreBlur=(this._overlayDiv||this._clientDiv).draggable=!0;var j=
this._overlayDiv||this._clientDiv;if(f.isIE<9)j=this._viewDiv;for(var a=c.target?c.target:c.srcElement;a;){if(j===a)return;a=a.parentNode}c.preventDefault&&c.preventDefault();c.stopPropagation&&c.stopPropagation();if(!this._isW3CEvents){var b=this;this._getWindow().setTimeout(function(){b._clientDiv.focus()},0)}},_handleRootMouseUp:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1,this._fixCaret(),this._ignoreBlur=!1},_handleBlur:function(){if(!this._ignoreBlur){this._hasFocus=
!1;if(f.isIE<9&&!this._getSelection().isEmpty()){var c=this._rootDiv,j=f.createElement(c.ownerDocument,"div");c.appendChild(j);c.removeChild(j)}if(this._selDiv1)if(this._selDiv1.style.background="lightgray",this._selDiv2.style.background="lightgray",this._selDiv3.style.background="lightgray",c=this._getWindow(),j=this._selDiv1.ownerDocument,c.getSelection){j=c.getSelection();for(c=j.anchorNode;c;){if(c===this._clientDiv){j.rangeCount>0&&j.removeAllRanges();break}c=c.parentNode}}else if(j.selection){this._ignoreSelect=
!1;for(c=j.selection.createRange().parentElement();c;){if(c===this._clientDiv){j.selection.empty();break}c=c.parentNode}this._ignoreSelect=!0}if(!this._ignoreFocus)this.onBlur({type:"Blur"})}},_handleContextMenu:function(c){f.isIE&&this._lastMouseButton===3&&this._updateDOMSelection();var j=!1;if(this.isListening("ContextMenu"))j=this._createMouseEvent("ContextMenu",c),j.screenX=c.screenX,j.screenY=c.screenY,this.onContextMenu(j),j=j.defaultPrevented;if(j)return c.preventDefault&&c.preventDefault(),
!1},_handleCopy:function(c){if(!this._ignoreCopy&&this._doCopy(c))return c.preventDefault&&c.preventDefault(),!1},_handleCut:function(c){if(this._doCut(c))return c.preventDefault&&c.preventDefault(),!1},_handleDataModified:function(){this._startIME()},_handleDblclick:function(c){this._lastMouseTime=c.timeStamp?c.timeStamp:(new Date).getTime();if(this._clickCount!==2)this._clickCount=2,this._handleMouse(c)},_handleDragStart:function(c){if(f.isFirefox){var j=this;this._getWindow().setTimeout(function(){j._clientDiv.contentEditable=
!0;j._clientDiv.draggable=!1;j._ignoreBlur=!1},0)}if(this.isListening("DragStart")&&this._dragOffset!==-1)this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",c)),this._dragOffset=-1;else return c.preventDefault&&c.preventDefault(),!1},_handleDrag:function(c){if(this.isListening("Drag"))this.onDrag(this._createMouseEvent("Drag",c))},_handleDragEnd:function(c){this._dropTarget=!1;this._dragOffset=-1;if(this.isListening("DragEnd"))this.onDragEnd(this._createMouseEvent("DragEnd",
c));f.isFirefox&&(this._fixCaret(),c.dataTransfer.dropEffect==="none"&&!c.dataTransfer.mozUserCancelled&&this._fixCaret())},_handleDragEnter:function(c){var j=!0;this._dropTarget=!0;this.isListening("DragEnter")&&(j=!1,this.onDragEnter(this._createMouseEvent("DragEnter",c)));if(f.isWebkit||j)return c.preventDefault&&c.preventDefault(),!1},_handleDragOver:function(c){var j=!0;this.isListening("DragOver")&&(j=!1,this.onDragOver(this._createMouseEvent("DragOver",c)));if(f.isWebkit||j){if(j)c.dataTransfer.dropEffect=
"none";c.preventDefault&&c.preventDefault();return!1}},_handleDragLeave:function(c){this._dropTarget=!1;if(this.isListening("DragLeave"))this.onDragLeave(this._createMouseEvent("DragLeave",c))},_handleDrop:function(c){this._dropTarget=!1;if(this.isListening("Drop"))this.onDrop(this._createMouseEvent("Drop",c));c.preventDefault&&c.preventDefault();return!1},_handleFocus:function(){this._hasFocus=!0;f.isIOS&&this._lastTouchOffset!==void 0?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=
void 0):this._updateDOMSelection();if(this._selDiv1){var c=this._highlightRGB;this._selDiv1.style.background=c;this._selDiv2.style.background=c;this._selDiv3.style.background=c}if(!this._ignoreFocus)this.onFocus({type:"Focus"})},_handleKeyDown:function(c){var j=!1;switch(c.keyCode){case 16:case 17:case 18:case 91:j=!0;break;default:this._setLinksVisible(!1)}if(c.keyCode===229){if(this._readonly)return c.preventDefault&&c.preventDefault(),!1;j=!0;f.isSafari&&f.isMac&&c.ctrlKey&&(j=!1);j&&this._startIME()}else j||
this._commitIME();if((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)return this._keyDownEvent=c,!0;if(this._doAction(c))return c.preventDefault?(c.preventDefault(),c.stopPropagation()):(c.cancelBubble=!0,c.returnValue=!1,c.keyCode=0),!1},_handleKeyPress:function(c){if(f.isMac&&f.isWebkit&&(63232<=c.keyCode&&c.keyCode<=63487||c.keyCode===13||c.keyCode===8))return c.preventDefault&&c.preventDefault(),!1;if(((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)&&this._doAction(this._keyDownEvent))return c.preventDefault&&
c.preventDefault(),!1;var j=f.isMac?c.metaKey:c.ctrlKey;if(c.charCode!==void 0&&j)switch(c.charCode){case 99:case 118:case 120:return!0}j=!1;if(f.isMac){if(c.ctrlKey||c.metaKey)j=!0}else if(f.isFirefox){if(c.ctrlKey||c.altKey)j=!0}else c.ctrlKey^c.altKey&&(j=!0);if(!j&&(j=f.isOpera?c.which:c.charCode!==void 0?c.charCode:c.keyCode,j>31))return this._doContent(String.fromCharCode(j)),c.preventDefault&&c.preventDefault(),!1},_handleKeyUp:function(c){(f.isMac?c.metaKey:c.ctrlKey)||this._setLinksVisible(!1);
c.keyCode===13&&this._commitIME()},_handleLinkClick:function(c){if(!(f.isMac?c.metaKey:c.ctrlKey))return c.preventDefault&&c.preventDefault(),!1},_handleMouse:function(c){var j=this._getWindow(),a=!0,b=j;if(f.isIE||f.isFirefox&&!this._overlayDiv)b=this._clientDiv;if(this._overlayDiv){if(this._hasFocus)this._ignoreFocus=!0;var d=this;j.setTimeout(function(){d.focus();d._ignoreFocus=!1},0)}this._clickCount===1?(a=this._setSelectionTo(c.clientX,c.clientY,c.shiftKey,!f.isOpera&&this._hasFocus&&this.isListening("DragStart")))&&
this._setGrab(b):(this._isW3CEvents&&this._setGrab(b),this._doubleClickSelection=null,this._setSelectionTo(c.clientX,c.clientY,c.shiftKey),this._doubleClickSelection=this._getSelection());return a},_handleMouseDown:function(c){if(this._linksVisible)if((c.target||c.srcElement).tagName!=="A")this._setLinksVisible(!1);else return;this._commitIME();var j=c.which;j||(c.button===4&&(j=2),c.button===2&&(j=3),c.button===1&&(j=1));var a=j!==2&&c.timeStamp?c.timeStamp:(new Date).getTime(),b=a-this._lastMouseTime,
d=Math.abs(this._lastMouseX-c.clientX),e=Math.abs(this._lastMouseY-c.clientY),n=this._lastMouseButton===j;this._lastMouseX=c.clientX;this._lastMouseY=c.clientY;this._lastMouseTime=a;this._lastMouseButton=j;if(j===1)this._isMouseDown=!0,n&&b<=this._clickTime&&d<=this._clickDist&&e<=this._clickDist?this._clickCount++:this._clickCount=1;if(this.isListening("MouseDown")&&(a=this._createMouseEvent("MouseDown",c),this.onMouseDown(a),a.defaultPrevented)){c.preventDefault();return}if(j===1&&this._handleMouse(c)&&
(f.isIE>=9||f.isOpera||f.isChrome||f.isSafari||f.isFirefox&&!this._overlayDiv))this._hasFocus||this.focus(),c.preventDefault();f.isFirefox&&this._lastMouseButton===3&&this._updateDOMSelection()},_handleMouseOver:function(c){if(this.isListening("MouseOver"))this.onMouseOver(this._createMouseEvent("MouseOver",c))},_handleMouseOut:function(c){if(this.isListening("MouseOut"))this.onMouseOut(this._createMouseEvent("MouseOut",c))},_handleMouseMove:function(c){var j=this._isClientDiv(c);if(this.isListening("MouseMove")&&
j)this.onMouseMove(this._createMouseEvent("MouseMove",c));if(!this._dropTarget){var a=this._linksVisible||this._lastMouseMoveX!==c.clientX||this._lastMouseMoveY!==c.clientY;this._lastMouseMoveX=c.clientX;this._lastMouseMoveY=c.clientY;this._setLinksVisible(a&&!this._isMouseDown&&(f.isMac?c.metaKey:c.ctrlKey));if(!this._isW3CEvents){if(c.button===0)return this._setGrab(null),!0;if(!this._isMouseDown&&c.button===1&&(this._clickCount&1)!==0&&j)return this._clickCount=2,this._handleMouse(c,this._clickCount)}if(this._isMouseDown&&
this._dragOffset===-1){var j=c.clientX,c=c.clientY,b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect(),e=this._getClientWidth(),n=this._getClientHeight(),a=d.left+b.left,i=d.top+b.top,e=d.left+b.left+e,b=d.top+b.top+n,d=this._model,n=d.getLineAtOffset(this._getSelection().getCaret());c<i&&n!==0?this._doAutoScroll("up",j,c-i):c>b&&n!==d.getLineCount()-1?this._doAutoScroll("down",j,c-b):j<a&&!this._wrapMode?this._doAutoScroll("left",j-a,c):j>e&&!this._wrapMode?this._doAutoScroll("right",
j-e,c):(this._endAutoScroll(),this._setSelectionTo(j,c,!0))}}},_isClientDiv:function(c){for(var j=this._overlayDiv||this._clientDiv,c=c.target?c.target:c.srcElement;c;){if(j===c)return!0;c=c.parentNode}return!1},_createMouseEvent:function(c,j){var a=this.convert({x:j.clientX,y:j.clientY},"page","document");return{type:c,event:j,clickCount:this._clickCount,x:a.x,y:a.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(c){var j=c.which?c.button===0:c.button===1;if(this.isListening("MouseUp")&&
(this._isClientDiv(c)||j&&this._isMouseDown))this.onMouseUp(this._createMouseEvent("MouseUp",c));if(!this._linksVisible&&j&&this._isMouseDown){if(this._dragOffset!==-1)j=this._getSelection(),j.extend(this._dragOffset),j.collapse(),this._setSelection(j,!0,!0),this._dragOffset=-1;this._isMouseDown=!1;this._endAutoScroll();this._isW3CEvents&&this._setGrab(null);f.isFirefox&&c.preventDefault()}},_handleMouseWheel:function(c){var j=this._getLineHeight(),a=0,b=0;f.isIE||f.isOpera?b=-c.wheelDelta/40*j:f.isFirefox?
(j=f.isMac?c.detail*3:Math.max(-256,Math.min(256,c.detail))*j,c.axis===c.HORIZONTAL_AXIS?a=j:b=j):f.isMac?(b=a=40,c.wheelDeltaX%120!==0&&(a=1),c.wheelDeltaY%120!==0&&(b=1),a=-c.wheelDeltaX/a,-1<a&&a<0&&(a=-1),0<a&&a<1&&(a=1),b=-c.wheelDeltaY/b,-1<b&&b<0&&(b=-1),0<b&&b<1&&(b=1)):(a=-c.wheelDeltaX,b=-c.wheelDeltaY/120*8*j);if(f.isSafari){for(j=c.target;j&&j.lineIndex===void 0;)j=j.parentNode;this._mouseWheelLine=j}j=this._getScroll();this._scrollView(a,b);a=this._getScroll();if(j.x!==a.x||j.y!==a.y)return c.preventDefault&&
c.preventDefault(),!1},_handlePaste:function(c){if(!this._ignorePaste&&this._doPaste(c)){if(f.isIE){var a=this;this._ignoreFocus=!0;this._getWindow().setTimeout(function(){a._updateDOMSelection();a._ignoreFocus=!1},0)}c.preventDefault&&c.preventDefault();return!1}},_handleResize:function(){var c=this._parent.clientWidth,a=this._parent.clientHeight;if(this._parentWidth!==c||this._parentHeight!==a)this._parentWidth!==c&&this._resetLineHeight(),this._parentWidth=c,this._parentHeight=a,f.isIE<9?this._queueUpdate():
this._update()},_handleRulerEvent:function(c){for(var a=c.target?c.target:c.srcElement,b=a.lineIndex;a&&!a._ruler;){if(b===void 0&&a.lineIndex!==void 0)b=a.lineIndex;a=a.parentNode}a=a?a._ruler:null;if(b===void 0&&a&&a.getOverview()==="document"){var b=this._getClientHeight(),d=this._model.getLineCount(),e=this._getViewPadding(),i=this._viewDiv.getBoundingClientRect(),b=Math.floor((c.clientY-i.top-this._metrics.scrollWidth)*d/(b+e.top+e.bottom-2*this._metrics.scrollWidth));0<=b&&b<d||(b=void 0)}if(a)switch(c.type){case "click":if(a.onClick)a.onClick(b,
c);break;case "dblclick":if(a.onDblClick)a.onDblClick(b,c);break;case "mousemove":if(a.onMouseMove)a.onMouseMove(b,c);break;case "mouseover":if(a.onMouseOver)a.onMouseOver(b,c);break;case "mouseout":if(a.onMouseOut)a.onMouseOut(b,c)}},_handleScroll:function(){var c=this._getScroll(),a=this._hScroll,b=this._vScroll;if(a!==c.x||b!==c.y)this._checkOverlayScroll(),this._hScroll=c.x,this._vScroll=c.y,this._commitIME(),this._update(b===c.y),this.onScroll({type:"Scroll",oldValue:{x:a,y:b},newValue:c})},
_handleSelectStart:function(c){if(this._ignoreSelect)return c&&c.preventDefault&&c.preventDefault(),!1},_getModelOffset:function(c,a){if(c){var b;b=c.tagName==="DIV"?c:c.parentNode.parentNode;var d=0,e=b.lineIndex;if(c.tagName!=="DIV")for(b=b.firstChild;b;){var i=b.firstChild;if(i===c){b.ignoreChars&&(d-=b.ignoreChars);d+=a;break}b.ignoreChars&&(d-=b.ignoreChars);d+=i.data.length;b=b.nextSibling}return Math.max(0,d)+this._model.getLineStart(e)}},_updateSelectionFromDOM:function(){var c=this._getWindow().getSelection(),
a=this._getModelOffset(c.anchorNode,c.anchorOffset),c=this._getModelOffset(c.focusNode,c.focusOffset);a===void 0||c===void 0||this._setSelection(new d(a,c),!1,!1)},_handleSelectionChange:function(){if(this._imeOffset===-1)if(f.isAndroid){var c=this._getWindow();this._selTimer&&c.clearTimeout(this._selTimer);var a=this;this._selTimer=c.setTimeout(function(){if(a._clientDiv)a._selTimer=null,a._updateSelectionFromDOM()},250)}else this._updateSelectionFromDOM()},_handleTextInput:function(c){this._imeOffset=
-1;if(f.isAndroid){for(var a=this._getWindow().getSelection(),b=a.anchorNode;b;){if(b.lineIndex!==void 0)break;b=b.parentNode}if(b){var d=this._model,e=b.lineIndex,i=d.getLine(e),n=i,g=0,d=d.getLineStart(e);if(a.rangeCount>0)a.getRangeAt(0).deleteContents(),e=b.ownerDocument.createTextNode(c.data),a.getRangeAt(0).insertNode(e),g=this._getDOMText(b,e),n=g.text,g=g.offset,e.parentNode.removeChild(e);b.lineRemoved=!0;for(b=0;i.charCodeAt(b)===n.charCodeAt(b)&&b<g;)b++;a=i.length-1;for(e=n.length-i.length;i.charCodeAt(a)===
n.charCodeAt(a+e)&&a+e>=g+c.data.length;)a--;a++;i=n.substring(b,a+e);b+=d;a+=d;this._modifyContent({text:i,start:b,end:a,_ignoreDOMSelection:!0},!0)}}else this._doContent(c.data);c.preventDefault()},_handleTouchStart:function(c){this._commitIME();var a=this._getWindow();if(this._touchScrollTimer)this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",a.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null;var b=c.touches;if(b.length===1){var b=b[0],d=b.clientX,e=b.clientY;
this._touchStartX=d;this._touchStartY=e;if(f.isAndroid&&(e<b.pageY-a.pageYOffset||d<b.pageX-a.pageXOffset))d=b.pageX-a.pageXOffset,e=b.pageY-a.pageYOffset;a=this.convert({x:d,y:e},"page","document");this._lastTouchOffset=this.getOffsetAtLocation(a.x,a.y);this._touchStartTime=c.timeStamp;this._touching=!0}},_handleTouchMove:function(c){var a=c.touches;if(a.length===1){a=a[0];this._touchCurrentX=a.clientX;this._touchCurrentY=a.clientY;if(!this._touchScrollTimer&&c.timeStamp-this._touchStartTime<200){this._vScrollDiv.style.display=
"block";if(!this._wrapMode)this._hScrollDiv.style.display="block";var b=this,d=this._getWindow();this._touchScrollTimer=d.setInterval(function(){var c=0,a=0;if(b._touching)c=b._touchStartX-b._touchCurrentX,a=b._touchStartY-b._touchCurrentY,b._touchSpeedX=c/10,b._touchSpeedY=a/10,b._touchStartX=b._touchCurrentX,b._touchStartY=b._touchCurrentY;else if(Math.abs(b._touchSpeedX)<0.1&&Math.abs(b._touchSpeedY)<0.1){b._vScrollDiv.style.display="none";b._hScrollDiv.style.display="none";d.clearInterval(b._touchScrollTimer);
b._touchScrollTimer=null;return}else c=b._touchSpeedX*10,a=b._touchSpeedY*10,b._touchSpeedX*=0.95,b._touchSpeedY*=0.95;b._scrollView(c,a)},10)}this._touchScrollTimer&&c.preventDefault()}},_handleTouchEnd:function(c){if(c.touches.length===0)this._touching=!1},_doAction:function(c){for(var a=this._keyBindings,b=0;b<a.length;b++){var d=a[b];if(d.keyBinding.match(c)){if(d.actionID&&(c=this._actions[d.actionID]))if(c.handler){if(!c.handler())return c.defaultHandler?typeof c.defaultHandler()==="boolean":
!1}else if(c.defaultHandler)return typeof c.defaultHandler()==="boolean";return!0}}return!1},_doBackspace:function(c){var a=this._getSelection();if(a.isEmpty()){var b=this._model,d=a.getCaret(),e=b.getLineAtOffset(d),i=b.getLineStart(e);if(d===i)e>0&&a.extend(b.getLineEnd(e-1));else{var n=!1;this._expandTab&&c.unit==="character"&&(d-i)%this._tabSize===0&&(n=!/[^ ]/.test(b.getText(i,d)));n?a.extend(d-this._tabSize):(b=this._getLine(e),a.extend(b.getNextOffset(d,c.unit,-1)),b.destroy())}}this._modifyContent({text:"",
start:a.start,end:a.end},!0);return!0},_doContent:function(c){var a=this._getSelection();this._modifyContent({text:c,start:a.start,end:a.end,_ignoreDOMSelection:!0},!0)},_doCopy:function(c){var a=this._getSelection();return!a.isEmpty()?this._setClipboardText(this._getBaseText(a.start,a.end),c):!0},_doCursorNext:function(c){if(!c.select&&this._clearSelection("next"))return!0;var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d);d===a.getLineEnd(e)?e+1<a.getLineCount()&&b.extend(a.getLineStart(e+
1)):(a=this._getLine(e),b.extend(a.getNextOffset(d,c.unit,1)),a.destroy());c.select||b.collapse();this._setSelection(b,!0);return!0},_doCursorPrevious:function(c){if(!c.select&&this._clearSelection("previous"))return!0;var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d);d===a.getLineStart(e)?e>0&&b.extend(a.getLineEnd(e-1)):(a=this._getLine(e),b.extend(a.getNextOffset(d,c.unit,-1)),a.destroy());c.select||b.collapse();this._setSelection(b,!0);return!0},_doCut:function(c){var a=
this._getSelection();return!a.isEmpty()?(a=this._getBaseText(a.start,a.end),this._doContent(""),this._setClipboardText(a,c)):!0},_doDelete:function(c){var a=this._getSelection();if(a.isEmpty()){var b=this._model,d=a.getCaret(),e=b.getLineAtOffset(d);d===b.getLineEnd(e)?e+1<b.getLineCount()&&a.extend(b.getLineStart(e+1)):(b=this._getLine(e),a.extend(b.getNextOffset(d,c.unit,1)),b.destroy())}this._modifyContent({text:"",start:a.start,end:a.end},!0);return!0},_doEnd:function(c){var a=this._getSelection(),
b=this._model;if(c.ctrl)a.extend(b.getCharCount());else{var d=a.getCaret(),e=b.getLineAtOffset(d);if(this._wrapMode){var i=this._getLine(e),d=i.getLineIndex(d),d=d===i.getLineCount()-1?b.getLineEnd(e):i.getLineStart(d+1)-1;i.destroy()}else d=b.getLineEnd(e);a.extend(d)}c.select||a.collapse();this._setSelection(a,!0);return!0},_doEnter:function(c){var a=this._model,b=this._getSelection();this._doContent(a.getLineDelimiter());if(c&&c.noCursor)b.end=b.start,this._setSelection(b);return!0},_doHome:function(c){var a=
this._getSelection(),b=this._model;if(c.ctrl)a.extend(0);else{var d=a.getCaret(),e=b.getLineAtOffset(d);this._wrapMode?(b=this._getLine(e),d=b.getLineIndex(d),d=b.getLineStart(d),b.destroy()):d=b.getLineStart(e);a.extend(d)}c.select||a.collapse();this._setSelection(a,!0);return!0},_doLineDown:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getLine(e),n=this._columnX,g=1,o=!1;if(n===-1||c.wholeLine||c.select&&f.isIE)n=c.wholeLine?a.getLineEnd(e+1):
d,n=i.getBoundingClientRect(n).left;(d=i.getLineIndex(d))<i.getLineCount()-1?g=i.getClientRects(d+1).top+1:(o=e===a.getLineCount()-1,e++);o?c.select&&(b.extend(a.getCharCount()),this._setSelection(b,!0,!0)):(i.lineIndex!==e&&(i.destroy(),i=this._getLine(e)),b.extend(i.getOffset(n,g)),c.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;i.destroy();return!0},_doLineUp:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getLine(e),n=this._columnX,
g=!1,o;if(n===-1||c.wholeLine||c.select&&f.isIE)n=c.wholeLine?a.getLineStart(e-1):d,n=i.getBoundingClientRect(n).left;(d=i.getLineIndex(d))>0?o=i.getClientRects(d-1).top+1:(g=e===0,g||(e--,o=this._getLineHeight(e)-1));g?c.select&&(b.extend(0),this._setSelection(b,!0,!0)):(i.lineIndex!==e&&(i.destroy(),i=this._getLine(e)),b.extend(i.getOffset(n,o)),c.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;i.destroy();return!0},_doPageDown:function(c){var a=this._model,b=this._getSelection(),
d=b.getCaret(),e=a.getLineAtOffset(d),i=a.getLineCount(),n=this._getScroll(),g=this._getClientHeight(),o;if(this._lineHeight){a=this._columnX;n=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=n.left;d=this._getLineIndex(n.top+g);o=this._getLine(d);e=this._getLinePixel(d);d=o.getOffset(a,n.top+g-e);g=o.getBoundingClientRect(d);o.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,g.top+e-n.top);this._columnX=a;return!0}if(e<i-1){var t=this._getLineHeight(),k=Math.min(i-
e-1,Math.floor(g/t)),k=Math.max(1,k),a=this._columnX;if(a===-1||c.select&&f.isIE)o=this._getLine(e),a=o.getBoundingClientRect(d).left,o.destroy();o=this._getLine(e+k);b.extend(o.getOffset(a,0));o.destroy();c.select||b.collapse();c=i*t;d=n.y+k*t;d+g>c&&(d=c-g);this._setSelection(b,!0,!0,d-n.y);this._columnX=a}return!0},_doPageUp:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getScroll(),n=this._getClientHeight(),g;if(this._lineHeight){a=this._columnX;
i=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=i.left;d=this._getLineIndex(i.bottom-n);g=this._getLine(d);e=this._getLinePixel(d);d=g.getOffset(a,i.bottom-n-e);n=g.getBoundingClientRect(d);g.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,n.top+e-i.top);this._columnX=a;return!0}if(e>0){var o=this._getLineHeight(),n=Math.max(1,Math.min(e,Math.floor(n/o))),a=this._columnX;if(a===-1||c.select&&f.isIE)g=this._getLine(e),a=g.getBoundingClientRect(d).left,g.destroy();
g=this._getLine(e-n);b.extend(g.getOffset(a,this._getLineHeight(e-n)-1));g.destroy();c.select||b.collapse();c=Math.max(0,i.y-n*o);this._setSelection(b,!0,!0,c-i.y);this._columnX=a}return!0},_doPaste:function(c){var a=this;return this._getClipboardText(c,function(c){c&&(f.isLinux&&a._lastMouseButton===2&&(new Date).getTime()-a._lastMouseTime<=a._clickTime&&a._setSelectionTo(a._lastMouseX,a._lastMouseY),a._doContent(c))})!==null},_doScroll:function(c){var a=c.type,b=this._model,d=b.getLineCount(),c=
this._getClientHeight(),e=this._getLineHeight();d*=e;var i=this._getScroll().y,n;switch(a){case "textStart":n=0;break;case "textEnd":n=d-c;break;case "pageDown":n=i+c;break;case "pageUp":n=i-c;break;case "centerLine":a=this._getSelection(),n=b.getLineAtOffset(a.start),b=(b.getLineAtOffset(a.end)-n+1)*e,n=n*e-c/2+b/2}n!==void 0&&(n=Math.min(Math.max(0,n),d-c),this._scrollView(0,n-i));return!0},_doSelectAll:function(){var c=this._model,a=this._getSelection();a.setCaret(0);a.extend(c.getCharCount());
this._setSelection(a,!1);return!0},_doTab:function(){if(this._tabMode&&!this._readonly){var c="\t";if(this._expandTab)var a=this._model,c=this._getSelection().getCaret(),b=a.getLineAtOffset(c),a=a.getLineStart(b),c=Array(this._tabSize-(c-a)%this._tabSize+1).join(" ");this._doContent(c);return!0}},_doShiftTab:function(){return!this._tabMode||this._readonly?void 0:!0},_doTabMode:function(){this._tabMode=!this._tabMode;return!0},_doWrapMode:function(){this.setOptions({wrapMode:!this.getOptions("wrapMode")});
return!0},_autoScroll:function(){var c=this._getSelection(),a=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),b=c.getCaret(),d=this._model.getLineAtOffset(b),e;if(this._autoScrollDir==="up"||this._autoScrollDir==="down")b=this._autoScrollY/this._getLineHeight(),b=b<0?Math.floor(b):Math.ceil(b),e=d,e=Math.max(0,Math.min(this._model.getLineCount()-1,e+b));else if(this._autoScrollDir==="left"||this._autoScrollDir==="right")e=this._getLineIndex(a.y),d=this._getLine(d),a.x+=d.getBoundingClientRect(b,
!1).left,d.destroy();d=this._getLine(e);c.extend(d.getOffset(a.x,a.y-this._getLinePixel(e)));d.destroy();this._setSelection(c,!0)},_autoScrollTimer:function(){this._autoScroll();var c=this;this._autoScrollTimerID=this._getWindow().setTimeout(function(){c._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(c){if(this._lineHeight&&!this._calculateLHTimer){var a=this._model.getLineCount(),b=0;if(c){for(var c=0,d=(new Date).getTime(),e=0;b<a;)if(this._lineHeight[b]||(c++,e||
(e=b),this._lineHeight[b]=this._calculateLineHeight(b)),b++,(new Date).getTime()-d>100)break;this.redrawRulers(0,a);this._queueUpdate()}c=this._getWindow();if(b!==a){var i=this;this._calculateLHTimer=c.setTimeout(function(){i._calculateLHTimer=null;i._calculateLineHeightTimer(!0)},0)}else if(this._calculateLHTimer)c.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0}},_calculateLineHeight:function(c){var c=this._getLine(c),a=c.getBoundingClientRect();c.destroy();return Math.max(1,
Math.ceil(a.bottom-a.top))},_calculateMetrics:function(){var c=this._clientDiv,j=c.ownerDocument,d=f.createElement(j,"div");d.style.lineHeight="normal";var e={type:"LineStyle",textView:this,0:0,lineText:this._model.getLine(0),lineStart:0};this.onLineStyle(e);l(e.style,d);d.style.position="fixed";d.style.left="-1000px";var i=f.createElement(j,"span");i.appendChild(j.createTextNode(" "));d.appendChild(i);var g=f.createElement(j,"span");g.style.fontStyle="italic";g.appendChild(j.createTextNode(" "));
d.appendChild(g);var n=f.createElement(j,"span");n.style.fontWeight="bold";n.appendChild(j.createTextNode(" "));d.appendChild(n);e=f.createElement(j,"span");e.style.fontWeight="bold";e.style.fontStyle="italic";e.appendChild(j.createTextNode(" "));d.appendChild(e);c.appendChild(d);var o=d.getBoundingClientRect(),i=i.getBoundingClientRect(),g=g.getBoundingClientRect(),n=n.getBoundingClientRect(),e=e.getBoundingClientRect(),i=i.bottom-i.top,g=g.bottom-g.top,n=n.bottom-n.top,k=e.bottom-e.top,t=0,e=o.bottom-
o.top<=0,o=Math.max(1,o.bottom-o.top);g>i&&(t=1);n>g&&(t=2);k>n&&(t=3);var h;if(t!==0){h={style:{}};if((t&1)!==0)h.style.fontStyle="italic";if((t&2)!==0)h.style.fontWeight="bold"}i=b(d);c.removeChild(d);g=a(this._viewDiv);d=f.createElement(j,"div");d.style.position="fixed";d.style.left="-1000px";d.style.paddingLeft=g.left+"px";d.style.paddingTop=g.top+"px";d.style.paddingRight=g.right+"px";d.style.paddingBottom=g.bottom+"px";d.style.width="100px";d.style.height="100px";n=f.createElement(j,"div");
n.style.width="100%";n.style.height="100%";d.appendChild(n);c.appendChild(d);j=d.getBoundingClientRect();g=n.getBoundingClientRect();d.style.overflow="hidden";n.style.height="200px";n=d.clientWidth;d.style.overflow="scroll";k=d.clientWidth;c.removeChild(d);g={left:g.left-j.left,top:g.top-j.top,right:j.right-g.right,bottom:j.bottom-g.bottom};return{lineHeight:o,largestFontStyle:h,lineTrim:i,viewPadding:g,scrollWidth:n-k,invalid:e}},_checkOverlayScroll:function(){if(f.isMac){var c=this,a=this._getWindow();
this._overlayScrollTimer&&a.clearTimeout(this._overlayScrollTimer);var b=function(){var d=c._isOverOverlayScroll();d.vertical||d.horizontal?c._overlayScrollTimer=a.setTimeout(b,200):(c._overlayScrollTimer=void 0,c._update())};this._overlayScrollTimer=a.setTimeout(b,200)}},_clearSelection:function(c){var a=this._getSelection();if(a.isEmpty())return!1;c==="next"?a.start=a.end:a.end=a.start;this._setSelection(a,!0);return!0},_commitIME:function(){if(this._imeOffset!==-1){this._scrollDiv.focus();this._clientDiv.focus();
var c=this._model,a=c.getLineAtOffset(this._imeOffset),b=c.getLineStart(a),d=this._getDOMText(this._getLineNode(a)).text,c=c.getLine(a),b=this._imeOffset-b,c=b+d.length-c.length;b!==c&&this._doContent(d.substring(b,c));this._imeOffset=-1}},_createActions:function(){var c=r.KeyBinding,a=this._keyBindings=[];a.push({actionID:"lineUp",keyBinding:new c(38),predefined:!0});a.push({actionID:"lineDown",keyBinding:new c(40),predefined:!0});a.push({actionID:"charPrevious",keyBinding:new c(37),predefined:!0});
a.push({actionID:"charNext",keyBinding:new c(39),predefined:!0});f.isMac?(a.push({actionID:"scrollPageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(34),predefined:!0}),a.push({actionID:"pageUp",keyBinding:new c(33,null,null,!0),predefined:!0}),a.push({actionID:"pageDown",keyBinding:new c(34,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,!0),predefined:!0}),
a.push({actionID:"wordPrevious",keyBinding:new c(37,null,null,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,null,null,!0),predefined:!0}),a.push({actionID:"scrollTextStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"scrollTextEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(38,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(40,!0),predefined:!0}),a.push({actionID:"scrollPageUp",keyBinding:new c(38,null,null,null,
!0),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(40,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,null,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(38,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(40,null,null,!0),predefined:!0})):(a.push({actionID:"pageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"pageDown",
keyBinding:new c(34),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"wordPrevious",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,!0),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(36,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(35,!0),predefined:!0}));f.isFirefox&&f.isLinux&&(a.push({actionID:"lineUp",keyBinding:new c(38,
!0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c(40,!0),predefined:!0}));a.push({actionID:"selectLineUp",keyBinding:new c(38,null,!0),predefined:!0});a.push({actionID:"selectLineDown",keyBinding:new c(40,null,!0),predefined:!0});a.push({actionID:"selectCharPrevious",keyBinding:new c(37,null,!0),predefined:!0});a.push({actionID:"selectCharNext",keyBinding:new c(39,null,!0),predefined:!0});a.push({actionID:"selectPageUp",keyBinding:new c(33,null,!0),predefined:!0});a.push({actionID:"selectPageDown",
keyBinding:new c(34,null,!0),predefined:!0});f.isMac?(a.push({actionID:"selectLineStart",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,!0,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,null,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,null,!0,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35,
null,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(40,!0,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(37,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(38,null,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(40,null,!0,!0),
predefined:!0})):(f.isLinux&&(a.push({actionID:"selectWholeLineUp",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectWholeLineDown",keyBinding:new c(40,!0,!0),predefined:!0})),a.push({actionID:"selectLineStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(35,null,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,!0,!0),predefined:!0}),
a.push({actionID:"selectTextStart",keyBinding:new c(36,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35,!0,!0),predefined:!0}));a.push({actionID:"undo",keyBinding:new r.KeyBinding("z",!0),predefined:!0});f.isMac?a.push({actionID:"redo",keyBinding:new r.KeyBinding("z",!0,!0),predefined:!0}):a.push({actionID:"redo",keyBinding:new r.KeyBinding("y",!0),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8,
null,!0),predefined:!0});a.push({actionID:"deleteNext",keyBinding:new c(46),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0,!0),predefined:!0});a.push({actionID:"deleteWordNext",keyBinding:new c(46,!0),predefined:!0});a.push({actionID:"tab",keyBinding:new c(9),predefined:!0});a.push({actionID:"shiftTab",keyBinding:new c(9,null,!0),predefined:!0});a.push({actionID:"enter",keyBinding:new c(13),predefined:!0});
a.push({actionID:"enter",keyBinding:new c(13,null,!0),predefined:!0});a.push({actionID:"selectAll",keyBinding:new c("a",!0),predefined:!0});a.push({actionID:"toggleTabMode",keyBinding:new c("m",!0),predefined:!0});f.isMac&&(a.push({actionID:"deleteNext",keyBinding:new c(46,null,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,null,null,!0),predefined:!0}),a.push({actionID:"deleteWordNext",keyBinding:new c(46,null,null,!0),predefined:!0}));if(!f.isFirefox){var b=f.isMac&&
f.isChrome;a.push({actionID:null,keyBinding:new c("u",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("i",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("b",!b,!1,!1,b),predefined:!0})}f.isFirefox&&(a.push({actionID:"copy",keyBinding:new c(45,!0),predefined:!0}),a.push({actionID:"paste",keyBinding:new c(45,null,!0),predefined:!0}),a.push({actionID:"cut",keyBinding:new c(46,null,!0),predefined:!0}));f.isMac&&(a.push({actionID:"lineStart",keyBinding:new c("a",
!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c("e",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineUp",keyBinding:new c("p",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c("n",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charPrevious",keyBinding:new c("b",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charNext",keyBinding:new c("f",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deletePrevious",keyBinding:new c("h",!1,!1,!1,!0),predefined:!0}),
a.push({actionID:"deleteNext",keyBinding:new c("d",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineEnd",keyBinding:new c("k",!1,!1,!1,!0),predefined:!0}),f.isFirefox?(a.push({actionID:"scrollPageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineStart",keyBinding:new c("u",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c("w",!1,!1,!1,!0),predefined:!0})):(a.push({actionID:"pageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}),
a.push({actionID:"centerLine",keyBinding:new c("l",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"enterNoCursor",keyBinding:new c("o",!1,!1,!1,!0),predefined:!0})));var d=this;this._actions={lineUp:{defaultHandler:function(){return d._doLineUp({select:!1})}},lineDown:{defaultHandler:function(){return d._doLineDown({select:!1})}},lineStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!1})}},lineEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!1})}},charPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1,
unit:"character"})}},charNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"character"})}},pageUp:{defaultHandler:function(){return d._doPageUp({select:!1})}},pageDown:{defaultHandler:function(){return d._doPageDown({select:!1})}},scrollPageUp:{defaultHandler:function(){return d._doScroll({type:"pageUp"})}},scrollPageDown:{defaultHandler:function(){return d._doScroll({type:"pageDown"})}},wordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1,unit:"word"})}},
wordNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"word"})}},textStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!0})}},textEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!0})}},scrollTextStart:{defaultHandler:function(){return d._doScroll({type:"textStart"})}},scrollTextEnd:{defaultHandler:function(){return d._doScroll({type:"textEnd"})}},centerLine:{defaultHandler:function(){return d._doScroll({type:"centerLine"})}},selectLineUp:{defaultHandler:function(){return d._doLineUp({select:!0})}},
selectLineDown:{defaultHandler:function(){return d._doLineDown({select:!0})}},selectWholeLineUp:{defaultHandler:function(){return d._doLineUp({select:!0,wholeLine:!0})}},selectWholeLineDown:{defaultHandler:function(){return d._doLineDown({select:!0,wholeLine:!0})}},selectLineStart:{defaultHandler:function(){return d._doHome({select:!0,ctrl:!1})}},selectLineEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!1})}},selectCharPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0,
unit:"character"})}},selectCharNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"character"})}},selectPageUp:{defaultHandler:function(){return d._doPageUp({select:!0})}},selectPageDown:{defaultHandler:function(){return d._doPageDown({select:!0})}},selectWordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0,unit:"word"})}},selectWordNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"word"})}},selectTextStart:{defaultHandler:function(){return d._doHome({select:!0,
ctrl:!0})}},selectTextEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!0})}},deletePrevious:{defaultHandler:function(){return d._doBackspace({unit:"character"})}},deleteNext:{defaultHandler:function(){return d._doDelete({unit:"character"})}},deleteWordPrevious:{defaultHandler:function(){return d._doBackspace({unit:"word"})}},deleteWordNext:{defaultHandler:function(){return d._doDelete({unit:"word"})}},deleteLineStart:{defaultHandler:function(){return d._doBackspace({unit:"line"})}},
deleteLineEnd:{defaultHandler:function(){return d._doDelete({unit:"line"})}},tab:{defaultHandler:function(){return d._doTab()}},shiftTab:{defaultHandler:function(){return d._doShiftTab()}},enter:{defaultHandler:function(){return d._doEnter()}},enterNoCursor:{defaultHandler:function(){return d._doEnter({noCursor:!0})}},selectAll:{defaultHandler:function(){return d._doSelectAll()}},copy:{defaultHandler:function(){return d._doCopy()}},cut:{defaultHandler:function(){return d._doCut()}},paste:{defaultHandler:function(){return d._doPaste()}},
toggleWrapMode:{defaultHandler:function(){return d._doWrapMode()}},toggleTabMode:{defaultHandler:function(){return d._doTabMode()}}}},_createRuler:function(c,a){if(this._clientDiv){var b=c.getLocation()==="left"?this._leftDiv:this._rightDiv;b.style.display="block";var d=f.createElement(b.ownerDocument,"div");d._ruler=c;d.rulerChanged=!0;d.style.position="relative";var b=b.firstChild.rows[0],e=b.cells.length,b=b.insertCell(a===void 0||a<0||a>e?e:a);b.vAlign="top";b.style.verticalAlign="top";b.style.borderWidth=
"0px";b.style.margin="0px";b.style.padding="0px";b.style.outline="none";b.appendChild(d)}},_createView:function(){if(!this._clientDiv){for(var c=this._parent;c.hasChildNodes();)c.removeChild(c.lastChild);var a=c.ownerDocument,b=f.createElement(a,"div");this._rootDiv=b;b.tabIndex=-1;b.style.position="relative";b.style.overflow="hidden";b.style.width="100%";b.style.height="100%";c.style.overflow="hidden";b.setAttribute("role","application");c.appendChild(b);c=f.createElement(a,"div");c.className="textviewLeftRuler";
this._leftDiv=c;c.tabIndex=-1;c.style.overflow="hidden";c.style.MozUserSelect="none";c.style.WebkitUserSelect="none";c.style.position="absolute";c.style.cursor="default";c.style.display="none";c.setAttribute("aria-hidden","true");var d=f.createElement(a,"table");c.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin=
"0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";b.appendChild(c);c=f.createElement(a,"div");c.className="textview";this._viewDiv=c;c.tabIndex=-1;c.style.overflow="auto";c.style.position="absolute";c.style.top="0px";c.style.bottom="0px";c.style.borderWidth="0px";c.style.margin="0px";c.style.outline="none";b.appendChild(c);var e=f.createElement(a,"div");e.className="textviewRightRuler";this._rightDiv=e;e.tabIndex=-1;e.style.display="none";e.style.overflow="hidden";e.style.MozUserSelect=
"none";e.style.WebkitUserSelect="none";e.style.position="absolute";e.style.cursor="default";e.style.right="0px";e.setAttribute("aria-hidden","true");d=f.createElement(a,"table");e.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";
b.appendChild(e);this._scrollDiv=d=f.createElement(a,"div");d.style.margin="0px";d.style.borderWidth="0px";d.style.padding="0px";c.appendChild(d);if(f.isFirefox)this._clipboardDiv=c=f.createElement(a,"div"),c.style.position="fixed",c.style.whiteSpace="pre",c.style.left="-1000px",b.appendChild(c);if(!f.isIE&&!f.isIOS)this._clipDiv=c=f.createElement(a,"div"),c.style.position="absolute",c.style.overflow="hidden",c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",b.appendChild(c),this._clipScrollDiv=
d=f.createElement(a,"div"),d.style.position="absolute",d.style.height="1px",d.style.top="-1000px",c.appendChild(d);this._setFullSelection(this._fullSelection,!0);c=f.createElement(a,"div");c.className="textviewContent";this._clientDiv=c;c.style.position="absolute";c.style.borderWidth="0px";c.style.margin="0px";c.style.padding="0px";c.style.outline="none";c.style.zIndex="1";c.style.WebkitUserSelect="text";c.setAttribute("spellcheck","false");if(f.isIOS||f.isAndroid)c.style.WebkitTapHighlightColor=
"transparent";(this._clipDiv||b).appendChild(c);if(f.isIOS||f.isAndroid)this._vScrollDiv=d=f.createElement(a,"div"),d.style.position="absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.width="8px",d.style.display="none",b.appendChild(d),this._hScrollDiv=d=f.createElement(a,"div"),d.style.position=
"absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.height="8px",d.style.display="none",b.appendChild(d);if(f.isFirefox&&!c.setCapture)this._overlayDiv=d=f.createElement(a,"div"),d.style.position=c.style.position,d.style.borderWidth=c.style.borderWidth,d.style.margin=c.style.margin,d.style.padding=
c.style.padding,d.style.cursor="text",d.style.zIndex="2",(this._clipDiv||b).appendChild(d);c.contentEditable="true";c.setAttribute("role","textbox");c.setAttribute("aria-multiline","true");this._setWrapMode(this._wrapMode,!0);this._setReadOnly(this._readonly);this._setThemeClass(this._themeClass,!0);this._setTabSize(this._tabSize,!0);if(!a.getElementById("_textviewStyle")&&(b="",f.isWebkit&&this._metrics.scrollWidth>0&&(b+="\n.textviewContainer ::-webkit-scrollbar-corner {background: #eeeeee;}"),
f.isFirefox&&f.isMac&&this._highlightRGB&&this._highlightRGB!=="Highlight"&&(b+="\n.textviewContainer ::-moz-selection {background: "+this._highlightRGB+";}"),b))c=f.createElement(a,"style"),c.id="_textviewStyle",d=a.getElementsByTagName("head")[0]||a.documentElement,c.appendChild(a.createTextNode(b)),d.insertBefore(c,d.firstChild);this._hookEvents();a=this._rulers;for(b=0;b<a.length;b++)this._createRuler(a[b]);this._update()}},_defaultOptions:function(){return{parent:{value:void 0,update:null},model:{value:void 0,
update:this.setModel},readonly:{value:!1,update:this._setReadOnly},fullSelection:{value:!0,update:this._setFullSelection},tabMode:{value:!0,update:null},tabSize:{value:8,update:this._setTabSize},expandTab:{value:!1,update:null},wrapMode:{value:!1,update:this._setWrapMode},themeClass:{value:void 0,update:this._setThemeClass}}},_destroyRuler:function(c){var a=c.getLocation()==="left"?this._leftDiv:this._rightDiv;if(a){for(var b=a.firstChild.rows[0],d=b.cells,e=0;e<d.length;e++)if(d[e].firstChild._ruler===
c)break;if(e!==d.length&&(b.cells[e]._ruler=void 0,b.deleteCell(e),d.length===0))a.style.display="none"}},_destroyView:function(){if(this._clientDiv){this._setGrab(null);this._unhookEvents();var c=this._getWindow();if(this._autoScrollTimerID)c.clearTimeout(this._autoScrollTimerID),this._autoScrollTimerID=null;if(this._updateTimer)c.clearTimeout(this._updateTimer),this._updateTimer=null;c=this._rootDiv;c.parentNode.removeChild(c);this._hScrollDiv=this._vScrollDiv=this._rightDiv=this._leftDiv=this._overlayDiv=
this._clientDiv=this._clipScrollDiv=this._clipDiv=this._viewDiv=this._scrollDiv=this._rootDiv=this._clipboardDiv=this._selDiv3=this._selDiv2=this._selDiv1=null}},_doAutoScroll:function(c,a,b){this._autoScrollDir=c;this._autoScrollX=a;this._autoScrollY=b;this._autoScrollTimerID||this._autoScrollTimer()},_endAutoScroll:function(){this._autoScrollTimerID&&this._getWindow().clearTimeout(this._autoScrollTimerID);this._autoScrollTimerID=this._autoScrollDir=void 0},_fixCaret:function(){var c=this._clientDiv;
if(c){var a=this._hasFocus;this._ignoreFocus=!0;a&&c.blur();c.contentEditable=!1;c.contentEditable=!0;a&&c.focus();this._ignoreFocus=!1}},_getBaseText:function(c,a){var b=this._model;b.getBaseModel&&(c=b.mapOffset(c),a=b.mapOffset(a),b=b.getBaseModel());return b.getText(c,a)},_getBottomIndex:function(c){var a=this._bottomChild;if(c&&this._getClientHeight()>this._getLineHeight()){var c=a.getBoundingClientRect(),b=this._clientDiv.getBoundingClientRect();c.bottom>b.bottom&&(a=this._getLinePrevious(a)||
a)}return a.lineIndex},_getBoundsAtOffset:function(c){var a=this._getLine(this._model.getLineAtOffset(c)),c=a.getBoundingClientRect(c),b=this._getLinePixel(a.lineIndex);c.top+=b;c.bottom+=b;a.destroy();return c},_getClientHeight:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-c.top-c.bottom)},_getClientWidth:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientWidth-c.left-c.right)},_getClipboardText:function(c,a){var b=this._model.getLineDelimiter(),
d,i,g=this._getWindow();if(g.clipboardData)return d=[],i=g.clipboardData.getData("Text"),e(i,function(c){d.push(c)},function(){d.push(b)}),i=d.join(""),a&&a(i),i;if(f.isFirefox){this._ignoreFocus=!0;var n=this._clipboardDiv;n.innerHTML="<pre contenteditable=''></pre>";n.firstChild.focus();var o=this,k=function(){var c=o._getTextFromElement(n);n.innerHTML="";d=[];e(c,function(c){d.push(c)},function(){d.push(b)});return d.join("")},t=!1;this._ignorePaste=!0;if(!f.isLinux||this._lastMouseButton!==2)try{t=
n.ownerDocument.execCommand("paste",!1,null)}catch(h){t=n.childNodes.length>1||n.firstChild&&n.firstChild.childNodes.length>0}this._ignorePaste=!1;if(!t)return c?(g.setTimeout(function(){o.focus();(i=k())&&a&&a(i);o._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"");this.focus();this._ignoreFocus=!1;(i=k())&&a&&a(i);return i}return c&&c.clipboardData?(d=[],i=c.clipboardData.getData("text/plain"),e(i,function(c){d.push(c)},function(){d.push(b)}),(i=d.join(""))&&a&&a(i),i):""},_getDOMText:function(c,
a){for(var b=c.firstChild,d="",e=0;b;){var i;if(b.ignoreChars){i=b.lastChild;for(var n=0,g=[],f=-1;i;){for(var o=i.data,k=o.length-1;k>=0;k--){var h=o.substring(k,k+1);n<b.ignoreChars&&(h===" "||h==="\u200c"||h==="\ufeff")?n++:g.push(h==="\u00a0"?"\t":h)}if(a===i)f=g.length;i=i.previousSibling}g=g.reverse().join("");f!==-1&&(e=d.length+g.length-f);d+=g}else for(i=b.firstChild;i;){if(a===i)e=d.length;d+=i.data;i=i.nextSibling}b=b.nextSibling}return{text:d,offset:e}},_getTextFromElement:function(c){var a=
c.ownerDocument,b=a.defaultView;if(!b.getSelection)return c.innerText||c.textContent;a=a.createRange();a.selectNode(c);var c=b.getSelection(),b=[],d;for(d=0;d<c.rangeCount;d++)b.push(c.getRangeAt(d));this._ignoreSelect=!0;c.removeAllRanges();c.addRange(a);a=c.toString();c.removeAllRanges();for(d=0;d<b.length;d++)c.addRange(b[d]);this._ignoreSelect=!1;return a},_getViewPadding:function(){return this._metrics.viewPadding},_getLine:function(c){var a=this._getLineNode(c);return a&&!a.lineChanged&&!a.lineRemoved?
a._line:new g(this,c)},_getLineHeight:function(c,a){if(c!==void 0&&this._lineHeight){var b=this._lineHeight[c];if(b)return b;if(a||a===void 0)return this._lineHeight[c]=this._calculateLineHeight(c)}return this._metrics.lineHeight},_getLineNode:function(c){for(var a=this._clientDiv.firstChild;a;){if(c===a.lineIndex)return a;a=a.nextSibling}},_getLineNext:function(c){for(c=c?c.nextSibling:this._clientDiv.firstChild;c&&c.lineIndex===-1;)c=c.nextSibling;return c},_getLinePrevious:function(c){for(c=c?
c.previousSibling:this._clientDiv.lastChild;c&&c.lineIndex===-1;)c=c.previousSibling;return c},_getLinePixel:function(c){c=Math.min(Math.max(0,c),this._model.getLineCount());if(this._lineHeight){var a=this._getTopIndex(),b=-this._topIndexY+this._getScroll().y;if(c>a)for(;a<c;a++)b+=this._getLineHeight(a);else for(a-=1;a>=c;a--)b-=this._getLineHeight(a);return b}return this._getLineHeight()*c},_getLineIndex:function(c){var a,b=0,d=this._model.getLineCount();if(this._lineHeight){var b=this._getTopIndex(),
e=-this._topIndexY+this._getScroll().y;if(c!==e)if(c<e)for(;c<e&&b>0;)c+=this._getLineHeight(--b);else for(a=this._getLineHeight(b);c-a>=e&&b<d-1;)c-=a,a=this._getLineHeight(++b)}else a=this._getLineHeight(),b=Math.floor(c/a);return Math.max(0,Math.min(d-1,b))},_getScroll:function(){var c=this._viewDiv;return{x:c.scrollLeft,y:c.scrollTop}},_getSelection:function(){return this._selection.clone()},_getTopIndex:function(c){var a=this._topChild;if(c&&this._getClientHeight()>this._getLineHeight()){var c=
a.getBoundingClientRect(),b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect();c.top<d.top+b.top&&(a=this._getLineNext(a)||a)}return a.lineIndex},_hookEvents:function(){var c=this;this._modelListener={onChanging:function(a){c._onModelChanging(a)},onChanged:function(a){c._onModelChanged(a)}};this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);var a=this._handlers=[],b=this._clientDiv,d=this._viewDiv,
e=this._rootDiv,i=this._overlayDiv||b,n=b.ownerDocument,g=this._getWindow(),o=f.isIE?n:g;a.push({target:g,type:"resize",handler:function(a){return c._handleResize(a?a:g.event)}});a.push({target:b,type:"blur",handler:function(a){return c._handleBlur(a?a:g.event)}});a.push({target:b,type:"focus",handler:function(a){return c._handleFocus(a?a:g.event)}});a.push({target:d,type:"focus",handler:function(){b.focus()}});a.push({target:d,type:"scroll",handler:function(a){return c._handleScroll(a?a:g.event)}});
a.push({target:b,type:"textInput",handler:function(a){return c._handleTextInput(a?a:g.event)}});a.push({target:b,type:"keydown",handler:function(a){return c._handleKeyDown(a?a:g.event)}});a.push({target:b,type:"keypress",handler:function(a){return c._handleKeyPress(a?a:g.event)}});a.push({target:b,type:"keyup",handler:function(a){return c._handleKeyUp(a?a:g.event)}});a.push({target:b,type:"contextmenu",handler:function(a){return c._handleContextMenu(a?a:g.event)}});a.push({target:b,type:"copy",handler:function(a){return c._handleCopy(a?
a:g.event)}});a.push({target:b,type:"cut",handler:function(a){return c._handleCut(a?a:g.event)}});a.push({target:b,type:"paste",handler:function(a){return c._handlePaste(a?a:g.event)}});if(f.isIOS||f.isAndroid)a.push({target:n,type:"selectionchange",handler:function(a){return c._handleSelectionChange(a?a:g.event)}}),a.push({target:b,type:"touchstart",handler:function(a){return c._handleTouchStart(a?a:g.event)}}),a.push({target:b,type:"touchmove",handler:function(a){return c._handleTouchMove(a?a:g.event)}}),
a.push({target:b,type:"touchend",handler:function(a){return c._handleTouchEnd(a?a:g.event)}});else{a.push({target:b,type:"selectstart",handler:function(a){return c._handleSelectStart(a?a:g.event)}});a.push({target:b,type:"mousedown",handler:function(a){return c._handleMouseDown(a?a:g.event)}});a.push({target:b,type:"mouseover",handler:function(a){return c._handleMouseOver(a?a:g.event)}});a.push({target:b,type:"mouseout",handler:function(a){return c._handleMouseOut(a?a:g.event)}});a.push({target:o,
type:"mouseup",handler:function(a){return c._handleMouseUp(a?a:g.event)}});a.push({target:o,type:"mousemove",handler:function(a){return c._handleMouseMove(a?a:g.event)}});a.push({target:e,type:"mousedown",handler:function(a){return c._handleRootMouseDown(a?a:g.event)}});a.push({target:e,type:"mouseup",handler:function(a){return c._handleRootMouseUp(a?a:g.event)}});a.push({target:i,type:"dragstart",handler:function(a){return c._handleDragStart(a?a:g.event)}});a.push({target:i,type:"drag",handler:function(a){return c._handleDrag(a?
a:g.event)}});a.push({target:i,type:"dragend",handler:function(a){return c._handleDragEnd(a?a:g.event)}});a.push({target:i,type:"dragenter",handler:function(a){return c._handleDragEnter(a?a:g.event)}});a.push({target:i,type:"dragover",handler:function(a){return c._handleDragOver(a?a:g.event)}});a.push({target:i,type:"dragleave",handler:function(a){return c._handleDragLeave(a?a:g.event)}});a.push({target:i,type:"drop",handler:function(a){return c._handleDrop(a?a:g.event)}});a.push({target:this._clientDiv,
type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});if(f.isFirefox&&(!f.isWindows||f.isFirefox>=15))(d=g.MutationObserver||g.MozMutationObserver)?(this._mutationObserver=new d(function(a){c._handleDataModified(a)}),this._mutationObserver.observe(b,{subtree:!0,characterData:!0})):a.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(a){return c._handleDataModified(a?a:g.event)}});this._overlayDiv&&(a.push({target:this._overlayDiv,
type:"mousedown",handler:function(a){return c._handleMouseDown(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseover",handler:function(a){return c._handleMouseOver(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseout",handler:function(a){return c._handleMouseOut(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"contextmenu",handler:function(a){return c._handleContextMenu(a?a:g.event)}}));this._isW3CEvents||a.push({target:this._clientDiv,type:"dblclick",handler:function(a){return c._handleDblclick(a?
a:g.event)}})}d=this._leftDiv;e=this._rightDiv;f.isIE&&a.push({target:d,type:"selectstart",handler:function(){return!1}});a.push({target:d,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:d,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"dblclick",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:
g.event)}});a.push({target:d,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});f.isIE&&a.push({target:e,type:"selectstart",handler:function(){return!1}});a.push({target:e,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:e,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"dblclick",
handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});for(d=0;d<a.length;d++)e=a[d],h(e.target,e.type,e.handler,e.capture)},_getWindow:function(){return this._parent.ownerDocument.defaultView||this._parent.ownerDocument.parentWindow},
_init:function(a){var b=a.parent;typeof b==="string"&&(b=(a.document||document).getElementById(b));if(!b)throw"no parent";a.parent=b;a.model=a.model||new s.TextModel;var e=this._defaultOptions(),i;for(i in e)e.hasOwnProperty(i)&&(this["_"+i]=a[i]!==void 0?a[i]:e[i].value);this._rulers=[];this._selection=new d(0,0,!1);this._linksVisible=!1;this._maxLineWidth=this._redrawCount=0;this._maxLineIndex=-1;this._ignoreSelect=!0;this._hasFocus=this._ignoreFocus=!1;this._dragOffset=this._columnX=-1;this._isRangeRects=
(!f.isIE||f.isIE>=9)&&typeof b.ownerDocument.createRange().getBoundingClientRect==="function";this._isW3CEvents=b.addEventListener;this._autoScrollTimerID=this._autoScrollY=this._autoScrollX=null;this._AUTO_SCROLL_RATE=50;this._mouseUpClosure=this._moseMoveClosure=this._grabControl=null;this._clickCount=this._lastMouseTime=this._lastMouseY=this._lastMouseX=0;this._clickTime=250;this._clickDist=5;this._isMouseDown=!1;this._doubleClickSelection=null;this._vScroll=this._hScroll=0;this._imeOffset=-1;
this._createActions();this._createView()},_isOverOverlayScroll:function(){if(!f.isMac)return{};var a=this._viewDiv.getBoundingClientRect(),b=this._lastMouseMoveX,d=this._lastMouseMoveY;return{vertical:a.top<=d&&d<a.bottom&&a.right-15<=b&&b<a.right,horizontal:a.bottom-15<=d&&d<a.bottom&&a.left<=b&&b<a.right}},_modifyContent:function(a,b){if(!this._readonly||a._code)if(a.type="Verify",this.onVerify(a),!(a.text===null||a.text===void 0)){var d=this._model;try{if(a._ignoreDOMSelection)this._ignoreDOMSelection=
!0;d.setText(a.text,a.start,a.end)}finally{if(a._ignoreDOMSelection)this._ignoreDOMSelection=!1}b&&(d=this._getSelection(),d.setCaret(a.start+a.text.length),this._setSelection(d,!0));this.onModify({type:"Modify"})}},_onModelChanged:function(a){a.type="ModelChanged";this.onModelChanged(a);a.type="Changed";var b=a.start,d=a.addedCharCount,e=a.removedCharCount,i=a.addedLineCount,g=a.removedLineCount,n=this._getSelection();n.end>b&&(n.end>b&&n.start<b+e?n.setCaret(b+d):(n.start+=d-e,n.end+=d-e),this._setSelection(n,
!1,!1));b=this._model.getLineAtOffset(b);for(d=this._getLineNext();d;){e=d.lineIndex;if(b<=e&&e<=b+g)b===e&&!d.modelChangedEvent&&!d.lineRemoved?(d.modelChangedEvent=a,d.lineChanged=!0):(d.lineRemoved=!0,d.lineChanged=!1,d.modelChangedEvent=null);if(e>b+g)d.lineIndex=e+i-g,d._line.lineIndex=d.lineIndex;d=this._getLineNext(d)}if(!this._wrapMode&&b<=this._maxLineIndex&&this._maxLineIndex<=b+g)this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0;this._update()},_onModelChanging:function(a){a.type=
"ModelChanging";this.onModelChanging(a);a.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var a=this;this._updateTimer=this._getWindow().setTimeout(function(){a._updateTimer=null;a._update()},0)}},_resetLineHeight:function(a,b){if(this._wrapMode){if(a!==void 0&&b!==void 0)for(var d=a;d<b;d++)this._lineHeight[d]=void 0;else this._lineHeight=Array(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var a=
this._clientDiv;if(a)for(a=a.firstChild;a;)a.lineWidth=void 0,a=a.nextSibling},_reset:function(){this._maxLineIndex=-1;this._maxLineWidth=0;this._columnX=-1;this._bottomChild=this._topChild=null;this._topIndexY=0;this._resetLineHeight();this._setSelection(new d(0,0,!1),!1,!1);if(this._viewDiv)this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0;var a=this._clientDiv;if(a){for(var b=a.firstChild;b;)b.lineRemoved=!0,b=b.nextSibling;if(f.isFirefox)this._ignoreFocus=!1,(b=this._hasFocus)&&a.blur(),a.contentEditable=
!1,a.contentEditable=!0,b&&a.focus(),this._ignoreFocus=!1}},_scrollView:function(a,b){this._ensureCaretVisible=!1;var d=this._viewDiv;a&&(d.scrollLeft+=a);b&&(d.scrollTop+=b)},_setClipboardText:function(a,b){var d,i=this._parent.ownerDocument,g=this._getWindow();if(g.clipboardData)return d=[],e(a,function(a){d.push(a)},function(){d.push(f.platformDelimiter)}),g.clipboardData.setData("Text",d.join(""));if(b&&b.clipboardData&&(d=[],e(a,function(a){d.push(a)},function(){d.push(f.platformDelimiter)}),
b.clipboardData.setData("text/plain",d.join(""))))return!0;var o=f.createElement(i,"pre");o.style.position="fixed";o.style.left="-1000px";e(a,function(a){o.appendChild(i.createTextNode(a))},function(){o.appendChild(f.createElement(i,"br"))});o.appendChild(i.createTextNode(" "));this._clientDiv.appendChild(o);var n=i.createRange();n.setStart(o.firstChild,0);n.setEndBefore(o.lastChild);var k=g.getSelection();k.rangeCount>0&&k.removeAllRanges();k.addRange(n);var h=this,n=function(){o&&o.parentNode===
h._clientDiv&&h._clientDiv.removeChild(o);h._updateDOMSelection()},k=!1;this._ignoreCopy=!0;try{k=i.execCommand("copy",!1,null)}catch(l){}this._ignoreCopy=!1;if(!k&&b)return g.setTimeout(n,0),!1;n();return!0},_setDOMSelection:function(a,b,d,e){for(var i,g,n,o,k=0,h=a.firstChild,l,m,z=this._model.getLine(a.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(k+m>b||k+m>=z){i=l;g=b-k;h.ignoreChars&&m>0&&g===m&&(g+=h.ignoreChars);break}k+=m;h=h.nextSibling}for(var k=0,
h=d.firstChild,p=this._model.getLine(d.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(m+k>e||k+m>=p){n=l;o=e-k;h.ignoreChars&&m>0&&o===m&&(o+=h.ignoreChars);break}k+=m;h=h.nextSibling}this._setDOMFullSelection(a,b,z,d,e,p);if(this._hasFocus)if(b=this._getWindow(),a=this._parent.ownerDocument,b.getSelection){if(b=b.getSelection(),!(b.anchorNode===i&&b.anchorOffset===g&&b.focusNode===n&&b.focusOffset===o||b.anchorNode===n&&b.anchorOffset===o&&b.focusNode===i&&b.focusOffset===
g))a=a.createRange(),a.setStart(i,g),a.setEnd(n,o),this._ignoreSelect=!1,b.rangeCount>0&&b.removeAllRanges(),b.addRange(a),this._ignoreSelect=!0}else if(a.selection)b=a.body,a=f.createElement(a,"div"),b.appendChild(a),b.removeChild(a),a=b.createTextRange(),a.moveToElementText(i.parentNode),a.moveStart("character",g),i=b.createTextRange(),i.moveToElementText(n.parentNode),i.moveStart("character",o),a.setEndPoint("EndToStart",i),this._ignoreSelect=!1,a.select(),this._ignoreSelect=!0},_setDOMFullSelection:function(a,
b,d,e,i){if(this._selDiv1&&(d=this._selDiv1,d.style.width="0px",d.style.height="0px",d=this._selDiv2,d.style.width="0px",d.style.height="0px",d=this._selDiv3,d.style.width="0px",d.style.height="0px",!(a===e&&b===i))){var f=this._model,n=this._getViewPadding(),o=this._clientDiv.getBoundingClientRect(),k=this._viewDiv.getBoundingClientRect(),d=k.left+n.left,h=o.right,n=k.top+n.top,l=o.bottom,k=o=0;this._clipDiv?(k=this._clipDiv.getBoundingClientRect(),o=k.left-this._clipDiv.scrollLeft):(k=this._rootDiv.getBoundingClientRect(),
o=k.left);k=k.top;this._ignoreDOMSelection=!0;var a=(new g(this,a.lineIndex,a)).getBoundingClientRect(f.getLineStart(a.lineIndex)+b,!1),m=a.left,i=(new g(this,e.lineIndex,e)).getBoundingClientRect(f.getLineStart(e.lineIndex)+i,!1),b=i.left;this._ignoreDOMSelection=!1;var f=this._selDiv1,m=Math.min(h,Math.max(d,m)),z=Math.min(l,Math.max(n,a.top)),p=h,e=Math.min(l,Math.max(n,a.bottom));f.style.left=m-o+"px";f.style.top=z-k+"px";f.style.width=Math.max(0,p-m)+"px";f.style.height=Math.max(0,e-z)+"px";
if(a.top===i.top)p=Math.min(b,h),f.style.width=Math.max(0,p-m)+"px";else if(a=Math.min(l,Math.max(n,i.top)),b=Math.min(h,Math.max(d,b)),n=Math.min(l,Math.max(n,i.bottom)),l=this._selDiv3,l.style.left=d-o+"px",l.style.top=a-k+"px",l.style.width=Math.max(0,b-d)+"px",l.style.height=Math.max(0,n-a)+"px",a-e>0)n=this._selDiv2,n.style.left=d-o+"px",n.style.top=e-k+"px",n.style.width=Math.max(0,h-d)+"px",n.style.height=Math.max(0,a-e)+"px"}},_setGrab:function(a){if(a!==this._grabControl)a?(a.setCapture&&
a.setCapture(),this._grabControl=a):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null)},_setLinksVisible:function(a){if(this._linksVisible!==a){this._linksVisible=a;if(f.isIE&&a)this._hadFocus=this._hasFocus;var b=this._clientDiv;b.contentEditable=!a;this._hadFocus&&!a&&b.focus();if(this._overlayDiv)this._overlayDiv.style.zIndex=a?"-1":"1";for(a=this._getLineNext();a;){if(a.hasLink)for(b=a.firstChild;b;){var d=b.nextSibling,e=b.viewStyle;e&&e.tagName==="A"&&
a.replaceChild(a._line._createSpan(a,b.firstChild.data,e),b);b=d}a=this._getLineNext(a)}}},_setSelection:function(a,b,d,e){if(a){this._columnX=-1;d===void 0&&(d=!0);var i=this._selection;this._selection=a;b&&this._showCaret(!1,e);d&&this._updateDOMSelection();if(!i.equals(a))this.onSelection({type:"Selection",oldValue:{start:i.start,end:i.end},newValue:{start:a.start,end:a.end}})}},_setSelectionTo:function(a,b,d,e){var i=this._model,g=this._getSelection(),b=this.convert({x:a,y:b},"page","document"),
a=this._getLineIndex(b.y);if(this._clickCount===1){i=this._getLine(a);a=i.getOffset(b.x,b.y-this._getLinePixel(a));i.destroy();if(e&&!d&&g.start<=a&&a<g.end)return this._dragOffset=a,!1;g.extend(a);d||g.collapse()}else(this._clickCount&1)===0?(i=this._getLine(a),a=i.getOffset(b.x,b.y-this._getLinePixel(a)),this._doubleClickSelection?a>=this._doubleClickSelection.start?(d=this._doubleClickSelection.start,e=i.getNextOffset(a,"wordend",1)):(d=i.getNextOffset(a,"word",-1),e=this._doubleClickSelection.end):
(d=i.getNextOffset(a,"word",-1),e=i.getNextOffset(d,"wordend",1)),i.destroy()):this._doubleClickSelection?(e=i.getLineAtOffset(this._doubleClickSelection.start),a>=e?(d=i.getLineStart(e),e=i.getLineEnd(a)):(d=i.getLineStart(a),e=i.getLineEnd(e))):(d=i.getLineStart(a),e=i.getLineEnd(a)),g.setCaret(d),g.extend(e);this._setSelection(g,!0,!0);return!0},_setFullSelection:function(a,b){this._fullSelection=a;if(f.isWebkit)this._fullSelection=!0;var d=this._clipDiv||this._rootDiv;if(d)if(this._fullSelection){if(!this._selDiv1&&
this._fullSelection&&!f.isIOS){var e=d.ownerDocument;this._highlightRGB=f.isWebkit?"transparent":"Highlight";var i=f.createElement(e,"div");this._selDiv1=i;i.style.position="absolute";i.style.borderWidth="0px";i.style.margin="0px";i.style.padding="0px";i.style.outline="none";i.style.background=this._highlightRGB;i.style.width="0px";i.style.height="0px";i.style.zIndex="0";d.appendChild(i);var g=f.createElement(e,"div");this._selDiv2=g;g.style.position="absolute";g.style.borderWidth="0px";g.style.margin=
"0px";g.style.padding="0px";g.style.outline="none";g.style.background=this._highlightRGB;g.style.width="0px";g.style.height="0px";g.style.zIndex="0";d.appendChild(g);this._selDiv3=e=f.createElement(e,"div");e.style.position="absolute";e.style.borderWidth="0px";e.style.margin="0px";e.style.padding="0px";e.style.outline="none";e.style.background=this._highlightRGB;e.style.width="0px";e.style.height="0px";e.style.zIndex="0";d.appendChild(e);if(f.isFirefox&&f.isMac){d=this._getWindow().getComputedStyle(e,
null).getPropertyValue("background-color");switch(d){case "rgb(119, 141, 168)":d="rgb(199, 208, 218)";break;case "rgb(127, 127, 127)":d="rgb(198, 198, 198)";break;case "rgb(255, 193, 31)":d="rgb(250, 236, 115)";break;case "rgb(243, 70, 72)":d="rgb(255, 176, 139)";break;case "rgb(255, 138, 34)":d="rgb(255, 209, 129)";break;case "rgb(102, 197, 71)":d="rgb(194, 249, 144)";break;case "rgb(140, 78, 184)":d="rgb(232, 184, 255)";break;default:d="rgb(180, 213, 255)"}this._highlightRGB=d;i.style.background=
d;g.style.background=d;e.style.background=d}b||this._updateDOMSelection()}}else{if(this._selDiv1)d.removeChild(this._selDiv1),this._selDiv1=null;if(this._selDiv2)d.removeChild(this._selDiv2),this._selDiv2=null;if(this._selDiv3)d.removeChild(this._selDiv3),this._selDiv3=null}},_setReadOnly:function(a){this._readonly=a;this._clientDiv.setAttribute("aria-readonly",a?"true":"false")},_setTabSize:function(a,b){this._tabSize=a;this._customTabSize=void 0;var d=this._clientDiv;if(f.isOpera){if(d)d.style.OTabSize=
this._tabSize+""}else if(f.isWebkit>=537.1){if(d)d.style.tabSize=this._tabSize+""}else if(f.isFirefox>=4){if(d)d.style.MozTabSize=this._tabSize+""}else if(this._tabSize!==8)this._customTabSize=this._tabSize;b||(this.redrawLines(),this._resetLineWidth())},_setThemeClass:function(a,b){this._themeClass=a;var d="textviewContainer";this._themeClass&&(d+=" "+this._themeClass);this._rootDiv.className=d;this._updateStyle(b)},_setWrapMode:function(a,b){this._wrapMode=a;var d=this._clientDiv,e=this._viewDiv;
a?(d.style.whiteSpace="pre-wrap",d.style.wordWrap="break-word",e.style.overflowX="hidden",e.style.overflowY="scroll"):(d.style.whiteSpace="pre",d.style.wordWrap="normal",e.style.overflowX="auto",e.style.overflowY="auto");b||(this.redraw(),this._resetLineWidth());this._resetLineHeight()},_showCaret:function(a,b){if(this._clientDiv){var d=this._model,e=this._getSelection(),i=this._getScroll(),g=e.getCaret(),n=e.start,f=e.end,o=d.getLineAtOffset(f),k=Math.max(Math.max(n,d.getLineStart(o)),f-1),d=this._getClientWidth(),
o=this._getClientHeight(),h=d/4,l=this._getBoundsAtOffset(g===n?n:k),m=l.left,p=l.right,w=l.top,r=l.bottom;a&&!e.isEmpty()&&(l=this._getBoundsAtOffset(g===f?n:k),l.top===w?g===n?p=m+Math.min(l.right-m,d):m=p-Math.min(p-l.left,d):g===n?r=w+Math.min(l.bottom-w,o):w=r-Math.min(r-l.top,o));e=0;m<i.x&&(e=Math.min(m-i.x,-h));p>i.x+d&&(e=Math.max(p-i.x-d,h));g=0;w<i.y?g=w-i.y:r>i.y+o&&(g=r-i.y-o);b&&(b>0?g>0&&(g=Math.max(g,b)):g<0&&(g=Math.min(g,b)));return e!==0||g!==0?(this._scrollView(e,g),o!==this._getClientHeight()||
d!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0):!1}},_startIME:function(){if(this._imeOffset===-1){var a=this._getSelection();a.isEmpty()||this._modifyContent({text:"",start:a.start,end:a.end},!0);this._imeOffset=a.start}},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);this._modelListener=null;for(var a=0;a<this._handlers.length;a++){var b=
this._handlers[a],d=b.target,e=b.type,b=b.handler;typeof d.removeEventListener==="function"?d.removeEventListener(e,b,!1):d.detachEvent("on"+e,b)}this._handlers=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null},_updateDOMSelection:function(){if(!this._ignoreDOMSelection&&this._clientDiv){var a=this._getSelection(),b=this._model,d=b.getLineAtOffset(a.start),e=b.getLineAtOffset(a.end),i=this._getLineNext();if(i){var g=this._getLinePrevious(),n;d<i.lineIndex?
(n=i,d=0):d>g.lineIndex?(n=g,d=0):(n=this._getLineNode(d),d=a.start-b.getLineStart(d));e<i.lineIndex?a=0:e>g.lineIndex?(i=g,a=0):(i=this._getLineNode(e),a=a.end-b.getLineStart(e));this._setDOMSelection(n,d,i,a)}}},_update:function(a){if(!(this._redrawCount>0)){if(this._updateTimer)this._getWindow().clearTimeout(this._updateTimer),this._updateTimer=null,a=!1;var b=this._clientDiv;if(b){if(this._metrics.invalid)this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1;var d=this._model,
e=this._getScroll(),i=this._getViewPadding(),o=d.getLineCount(),n=this._getLineHeight(),k=this._getClientWidth();if(this._wrapMode)b.style.width=k+"px";var h,l,m,v,p=0,r=0;if(this._lineHeight){for(;r<o;){m=this._getLineHeight(r);if(p+m>e.y)break;p+=m;r++}h=r;l=Math.max(0,h-1);m=d=e.y-p;h>0&&(d+=this._getLineHeight(h-1))}else v=Math.max(0,e.y)/n,h=Math.floor(v),l=Math.max(0,h-1),d=Math.round((v-l)*n),m=Math.round((v-h)*n);this._topIndexY=m;v=this._parent;var w=v.clientWidth,s=v.clientHeight;v=this._getClientHeight();
if(a){l=0;this._leftDiv&&(h=this._leftDiv.getBoundingClientRect(),l=h.right-h.left);h=k;for(this._wrapMode||(h=Math.max(this._maxLineWidth,h));r<o;)m=this._getLineHeight(r,!1),p+=m,r++;o=p}else{for(var k=this._viewDiv,e=Math.min(h+Math.floor((v+m)/n),o-1),x=Math.min(e+1,o-1),n=b.firstChild;n;){m=n.lineIndex;var C=n.nextSibling;if(!(l<=m&&m<=x)||n.lineRemoved||n.lineIndex===-1)this._mouseWheelLine===n?(n.style.display="none",n.lineIndex=-1):b.removeChild(n);n=C}var n=this._getLineNext(),C=k.ownerDocument,
y=C.createDocumentFragment();for(m=l;m<=x;m++)if(!n||n.lineIndex>m)(new g(this,m)).create(y,null);else{y.firstChild&&(b.insertBefore(y,n),y=C.createDocumentFragment());if(n&&n.lineChanged)n=(new g(this,m)).create(y,n),n.lineChanged=!1;n=this._getLineNext(n)}y.firstChild&&b.insertBefore(y,n);if(f.isWebkit&&!this._wrapMode)b.style.width="0x7fffffffpx";n=this._getLineNext();m=v+d;for(C=!1;n;){l=n.lineWidth;if(l===void 0)x=n._line.getBoundingClientRect(),l=n.lineWidth=Math.ceil(x.right-x.left),this._lineHeight&&
(this._lineHeight[n.lineIndex]=Math.ceil(x.bottom-x.top));if(this._lineHeight&&!C&&(m-=this._lineHeight[n.lineIndex],m<0))e=n.lineIndex,C=!0;if(!this._wrapMode){if(l>=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=n.lineIndex;if(this._checkMaxLineIndex===n.lineIndex)this._checkMaxLineIndex=-1}if(n.lineIndex===h)this._topChild=n;if(n.lineIndex===e)this._bottomChild=n;n=this._getLineNext(n)}if(this._checkMaxLineIndex!==-1&&(m=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,0<=m&&m<o)){n=
new g(this,m);x=n.getBoundingClientRect();l=x.right-x.left;if(l>=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=m;n.destroy()}for(;r<o;)m=this._getLineHeight(r,r<=e),p+=m,r++;o=p;this._updateRuler(this._leftDiv,h,e);this._updateRuler(this._rightDiv,h,e);l=0;this._leftDiv&&(h=this._leftDiv.getBoundingClientRect(),l=h.right-h.left);e=0;this._rightDiv&&(e=this._rightDiv.getBoundingClientRect(),e=e.right-e.left);k.style.left=l+"px";k.style.right=e+"px";e=this._scrollDiv;e.style.height=o+"px";
p=k=this._getClientWidth();this._wrapMode||(p=Math.max(this._maxLineWidth,p));h=p;if((!f.isIE||f.isIE>=9)&&this._maxLineWidth>k)p+=i.right+i.left;e.style.width=p+"px";if(this._clipScrollDiv)this._clipScrollDiv.style.width=p+"px";e=this._getScroll();p=v+i.top+i.bottom;this._updateRulerSize(this._leftDiv,p);this._updateRulerSize(this._rightDiv,p)}if(this._vScrollDiv)p=v-8,r=Math.max(15,Math.ceil(Math.min(1,p/(o+i.top+i.bottom))*p)),this._vScrollDiv.style.left=l+k-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,
e.y*p/o))+"px",this._vScrollDiv.style.height=r+"px";if(!this._wrapMode&&this._hScrollDiv)p=k-8,r=Math.max(15,Math.ceil(Math.min(1,p/(this._maxLineWidth+i.left+i.right))*p)),this._hScrollDiv.style.left=l+Math.floor(Math.max(0,Math.floor(e.x*p/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=v-9+"px",this._hScrollDiv.style.width=r+"px";x=e.x;m=this._clipDiv;p=this._overlayDiv;if(m){m.scrollLeft=x;r=l+i.left;n=i.top;a=k;l=v;x=0;C=-d;if(e.x===0)r-=i.left,a+=i.left,x=i.left;e.x+k===h&&(a+=i.right);
e.y===0&&(n-=i.top,l+=i.top,C+=i.top);e.y+v===o&&(l+=i.bottom);m.style.left=r+"px";m.style.top=n+"px";i=this._isOverOverlayScroll();m.style.right=w-a-r+(this._overlayScrollTimer&&i.vertical?15:0)+"px";m.style.bottom=s-l-n+(this._overlayScrollTimer&&i.horizontal?15:0)+"px";b.style.left=x+"px";b.style.top=C+"px";b.style.width=h+"px";b.style.height=v+d+"px";if(p)p.style.left=b.style.left,p.style.top=b.style.top,p.style.width=b.style.width,p.style.height=b.style.height}else{r=x;n=d;w=x+k;s=d+v;r===0&&
(r-=i.left);n===0&&(n-=i.top);w===h&&(w+=i.right);e.y+v===o&&(s+=i.bottom);b.style.clip="rect("+n+"px,"+w+"px,"+s+"px,"+r+"px)";b.style.left=-x+l+i.left+"px";b.style.width=(f.isWebkit?h:k+x)+"px";if(!a)b.style.top=-d+i.top+"px",b.style.height=v+d+"px";if(p&&(p.style.clip=b.style.clip,p.style.left=b.style.left,p.style.width=b.style.width,!a))p.style.top=b.style.top,p.style.height=b.style.height}this._updateDOMSelection();b=this._ensureCaretVisible;this._ensureCaretVisible=!1;v!==this._getClientHeight()&&
(this._update(),b&&this._showCaret())}}},_updateRulerSize:function(a,b){if(a){for(var d=this._topIndexY,e=this._getLineHeight(),i=a.firstChild.rows[0].cells,g=0;g<i.length;g++){var n=i[g].firstChild,f=e;n._ruler.getOverview()==="page"&&(f+=d);n.style.top=-f+"px";n.style.height=b+f+"px"}a.style.height=b+"px"}},_updateRuler:function(a,b,d){if(a)for(var a=a.firstChild.rows[0].cells,e=this._parent.ownerDocument,i=this._getLineHeight(),g=this._getViewPadding(),n=0;n<a.length;n++){var o=a[n].firstChild,
k=o._ruler;o.rulerChanged&&l(k.getRulerStyle(),o);var h,m=o.firstChild;m?(h=m,m=m.nextSibling):(h=f.createElement(e,"div"),h.style.visibility="hidden",o.appendChild(h));var p,r;if(o.rulerChanged&&h){p=-1;if(r=k.getWidestAnnotation())if(l(r.style,h),r.html)h.innerHTML=r.html;h.lineIndex=p;h.style.height=i+g.top+"px"}var s,w;if(k.getOverview()==="page"){for(k=k.getAnnotations(b,d+1);m;)p=m.lineIndex,r=m.nextSibling,(!(b<=p&&p<=d)||m.lineChanged)&&o.removeChild(m),m=r;m=o.firstChild.nextSibling;w=e.createDocumentFragment();
for(p=b;p<=d;p++)if(!m||m.lineIndex>p){s=f.createElement(e,"div");if(r=k[p]){l(r.style,s);if(r.html)s.innerHTML=r.html;s.annotation=r}s.lineIndex=p;s.style.height=this._getLineHeight(p)+"px";w.appendChild(s)}else if(w.firstChild&&(o.insertBefore(w,m),w=e.createDocumentFragment()),m)m=m.nextSibling;w.firstChild&&o.insertBefore(w,m)}else{r=this._getClientHeight();p=this._model.getLineCount();m=r+g.top+g.bottom-2*this._metrics.scrollWidth;h=i*p<m?i:m/p;if(o.rulerChanged){for(r=o.childNodes.length;r>
1;)o.removeChild(o.lastChild),r--;k=k.getAnnotations(0,p);w=e.createDocumentFragment();for(var K in k)if(p=K>>>0,!(p<0)){s=f.createElement(e,"div");r=k[K];l(r.style,s);s.style.position="absolute";s.style.top=this._metrics.scrollWidth+i+Math.floor(p*h)+"px";if(r.html)s.innerHTML=r.html;s.annotation=r;s.lineIndex=p;w.appendChild(s)}o.appendChild(w)}else if(o._oldTrackHeight!==m)for(s=o.firstChild?o.firstChild.nextSibling:null;s;)s.style.top=this._metrics.scrollWidth+i+Math.floor(s.lineIndex*h)+"px",
s=s.nextSibling;o._oldTrackHeight=m}o.rulerChanged=!1}},_updateStyle:function(a){if(!a&&f.isIE)this._rootDiv.style.lineHeight="normal";var b=this._metrics=this._calculateMetrics();this._rootDiv.style.lineHeight=f.isIE?b.lineHeight-(b.lineTrim.top+b.lineTrim.bottom)+"px":"normal";a||(this.redraw(),this._resetLineWidth())}};p.EventTarget.addMixin(o.prototype);return{TextView:o}});
define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(s,r){function p(f){this._model=f;this._projections=[]}p.prototype={addProjection:function(f){if(f){var h=this._model,l=this._projections;f._lineIndex=h.getLineAtOffset(f.start);f._lineCount=h.getLineAtOffset(f.end)-f._lineIndex;var k=f.text;k||(k="");f._model=typeof k==="string"?new s.TextModel(k,h.getLineDelimiter()):k;var h=this.mapOffset(f.start,!0),k=f.end-f.start,m=f._lineCount,e=f._model.getCharCount(),
a=f._model.getLineCount()-1;this.onChanging({type:"Changing",text:f._model.getText(),start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a});var b=this._binarySearch(l,f.start);l.splice(b,0,f);this.onChanged({type:"Changed",start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a})}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(f,h){var l=this._projections,k=0,m,e;if(h){for(m=
0;m<l.length;m++){e=l[m];if(e.start>f)break;if(e.end>f)return-1;k+=e._model.getCharCount()-(e.end-e.start)}return f+k}for(m=0;m<l.length;m++){e=l[m];if(e.start>f-k)break;var a=e._model.getCharCount();if(e.start+a>f-k)return-1;k+=a-(e.end-e.start)}return f-k},removeProjection:function(f){var h,l=0;for(h=0;h<this._projections.length;h++){var k=this._projections[h];if(k===f){f=k;break}l+=k._model.getCharCount()-(k.end-k.start)}if(h<this._projections.length){var k=this._model,l=f.start+l,m=f.end-f.start,
e=f._lineCount,a=f._model.getCharCount(),b=f._model.getLineCount()-1;this.onChanging({type:"Changing",text:k.getText(f.start,f.end),start:l,removedCharCount:a,addedCharCount:m,removedLineCount:b,addedLineCount:e});this._projections.splice(h,1);this.onChanged({type:"Changed",start:l,removedCharCount:a,addedCharCount:m,removedLineCount:b,addedLineCount:e})}},_binarySearch:function(f,h){for(var l=f.length,k=-1,m;l-k>1;)m=Math.floor((l+k)/2),h<=f[m].start?l=m:k=m;return l},getCharCount:function(){for(var f=
this._model.getCharCount(),h=this._projections,l=0;l<h.length;l++){var k=h[l];f+=k._model.getCharCount()-(k.end-k.start)}return f},getLine:function(f,h){if(f<0)return null;var l=this._model,k=this._projections,m=0,e=[],a=0,b,d,i;for(b=0;b<k.length;b++){i=k[b];if(i._lineIndex>=f-m)break;d=i._model.getLineCount()-1;if(i._lineIndex+d>=f-m)if(a=f-(i._lineIndex+m),a<d)return i._model.getLine(a,h);else e.push(i._model.getLine(d));a=i.end;m+=d-i._lineCount}for(a=Math.max(a,l.getLineStart(f-m));b<k.length;b++){i=
k[b];if(i._lineIndex>f-m)break;e.push(l.getText(a,i.start));d=i._model.getLineCount()-1;if(i._lineIndex+d>f-m)return e.push(i._model.getLine(0,h)),e.join("");e.push(i._model.getText());a=i.end;m+=d-i._lineCount}k=l.getLineEnd(f-m,h);a<k&&e.push(l.getText(a,k));return e.join("")},getLineAtOffset:function(f){for(var h=this._model,l=this._projections,k=0,m=0,e=0;e<l.length;e++){var a=l[e];if(a.start>f-k)break;var b=a._model.getCharCount();if(a.start+b>f-k){l=f-(a.start+k);m+=a._model.getLineAtOffset(l);
k+=l;break}m+=a._model.getLineCount()-1-a._lineCount;k+=b-(a.end-a.start)}return h.getLineAtOffset(f-k)+m},getLineCount:function(){for(var f=this._projections,h=this._model.getLineCount(),l=0;l<f.length;l++){var k=f[l];h+=k._model.getLineCount()-1-k._lineCount}return h},getLineDelimiter:function(){return this._model.getLineDelimiter()},getLineEnd:function(f,h){if(f<0)return-1;for(var l=this._model,k=this._projections,m=0,e=0,a=0;a<k.length;a++){var b=k[a];if(b._lineIndex>f-m)break;var d=b._model.getLineCount()-
1;if(b._lineIndex+d>f-m)return b._model.getLineEnd(f-(b._lineIndex+m),h)+b.start+e;e+=b._model.getCharCount()-(b.end-b.start);m+=d-b._lineCount}return l.getLineEnd(f-m,h)+e},getLineStart:function(f){if(f<0)return-1;for(var h=this._model,l=this._projections,k=0,m=0,e=0;e<l.length;e++){var a=l[e];if(a._lineIndex>=f-k)break;var b=a._model.getLineCount()-1;if(a._lineIndex+b>=f-k)return a._model.getLineStart(f-(a._lineIndex+k))+a.start+m;m+=a._model.getCharCount()-(a.end-a.start);k+=b-a._lineCount}return h.getLineStart(f-
k)+m},getText:function(f,h){f===void 0&&(f=0);var l=this._model,k=this._projections,m=0,e=[],a,b,d;for(a=0;a<k.length;a++){b=k[a];if(b.start>f-m)break;d=b._model.getCharCount();if(b.start+d>f-m)if(h!==void 0&&b.start+d>h-m)return b._model.getText(f-(b.start+m),h-(b.start+m));else e.push(b._model.getText(f-(b.start+m))),f=b.end+m+d-(b.end-b.start);m+=d-(b.end-b.start)}var i=f-m;if(h!==void 0){for(;a<k.length;a++){b=k[a];if(b.start>h-m)break;e.push(l.getText(i,b.start));d=b._model.getCharCount();if(b.start+
d>h-m)return e.push(b._model.getText(0,h-(b.start+m))),e.join("");e.push(b._model.getText());i=b.end;m+=d-(b.end-b.start)}e.push(l.getText(i,h-m))}else{for(;a<k.length;a++)b=k[a],e.push(l.getText(i,b.start)),e.push(b._model.getText()),i=b.end;e.push(l.getText(i))}return e.join("")},_onChanging:function(f,h,l,k,m,e){for(var a=this._model,b=this._projections,d,i=0,g,o=h+l;d<b.length;d++){l=b[d];if(l.start>h)break;i+=l._model.getCharCount()-(l.end-l.start)}h+=i;for(var c=d;d<b.length;d++){l=b[d];if(l.start>
o)break;i+=l._model.getCharCount()-(l.end-l.start);g+=l._model.getLineCount()-1-l._lineCount}l=o+i;i=d;this.onChanging(h,l-h,k,m+g,e);b.splice(b,i-c);for(f=f.length-(l-h);d<b.length;d++)l=b[d],l.start+=f,l.end+=f,l._lineIndex=a.getLineAtOffset(l.start)},onChanging:function(f){return this.dispatchEvent(f)},onChanged:function(f){return this.dispatchEvent(f)},setLineDelimiter:function(f){this._model.setLineDelimiter(f)},setText:function(f,h,l){f===void 0&&(f="");h===void 0&&(h=0);var k=h,m=l,e=this._model,
a=this._projections,b=0,d=0,i,g,o,c,j,q=0;for(i=0;i<a.length;i++){g=a[i];if(g.start>h-b)break;o=g._model.getCharCount();if(g.start+o>h-b)if(l!==void 0&&g.start+o>l-b){g._model.setText(f,h-(g.start+b),l-(g.start+b));return}else q=g._model.getLineCount()-1-g._model.getLineAtOffset(h-(g.start+b)),c={projection:g,start:h-(g.start+b)},h=g.end+b+o-(g.end-g.start);d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}h-=b;var u=i,q=e.getLineAtOffset(h)+d-q;if(l!==void 0)for(;i<a.length;i++){g=a[i];
if(g.start>l-b)break;o=g._model.getCharCount();if(g.start+o>l-b){d+=g._model.getLineAtOffset(l-(g.start+b));o=l-(g.start+b);l=g.end+b;j={projection:g,end:o};break}d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}else{for(;i<a.length;i++)g=a[i],d+=g._model.getLineCount()-1-g._lineCount,b+=g._model.getCharCount()-(g.end-g.start);l=m=e.getCharCount()+b}l-=b;g=e.getLineAtOffset(l)+d;m-=k;for(var d=g-q,q=f.length,A=o=g=b=0;;){g!==-1&&g<=A&&(g=f.indexOf("\r",A));o!==-1&&o<=A&&(o=f.indexOf("\n",
A));if(o===-1&&g===-1)break;A=g!==-1&&o!==-1?g+1===o?o+1:(g<o?g:o)+1:g!==-1?g+1:o+1;b++}this.onChanging({type:"Changing",text:f,start:k,removedCharCount:m,addedCharCount:q,removedLineCount:d,addedLineCount:b});e.setText(f,h,l);if(c)g=c.projection,g._model.setText("",c.start);if(j)g=j.projection,g._model.setText("",0,j.end),g.start=g.end,g._lineCount=0;a.splice(u,i-u);for(f=f.length-(l-h);i<a.length;i++)g=a[i],g.start+=f,g.end+=f,g._lineIndex=e.getLineAtOffset(g.start);this.onChanged({type:"Changed",
start:k,removedCharCount:m,addedCharCount:q,removedLineCount:d,addedLineCount:b})}};r.EventTarget.addMixin(p.prototype);return{ProjectionTextModel:p}});
(function(){function s(f,l,k,m,e,a){l[f]&&(k.push(f),(l[f]===!0||l[f]===1)&&m.push(e+f+"/"+a))}function r(f,l,k,m,e){l=m+l+"/"+e;require._fileExists(f.toUrl(l))&&k.push(l)}var p=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/,f={};define("i18n",{version:"1.0.0",load:function(h,l,k,m){var m=m||{},e=p.exec(h),a=e[1],b=e[4],d=e[5],i=b.split("-"),g=[],o={},c,j,q="";e[5]?(a=e[1],h=a+d):(d=e[4],b=m.locale||(m.locale=typeof navigator==="undefined"?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),
i=b.split("-"));if(m.isBuild){g.push(h);r(l,"root",g,a,d);for(c=0;j=i[c];c++)q+=(q?"-":"")+j,r(l,q,g,a,d);l(g,function(){k()})}else l([h],function(b){var e=[];s("root",b,e,g,a,d);for(c=0;j=i[c];c++)q+=(q?"-":"")+j,s(q,b,e,g,a,d);l(g,function(){var c,i;for(c=e.length-1;c>-1&&(j=e[c]);c--){i=b[j];if(i===!0||i===1)i=l(a+j+"/"+d);var g=o,q=void 0;for(q in i)!(q in f)&&!(q in g)&&(g[q]=i[q])}k(o)})})}})})();
define("orion/editor/i18n",{load:function(s,r,p){r.specified&&r.specified("orion/bootstrap")?r(["orion/i18n!"+s],function(f){p(f)}):p({})}});
define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",matchingSearch:"Matching Search",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",Comment:"Comment","Flat outline":"Flat outline",incrementalFind:"Incremental find: ${0}",incrementalFindNotFound:"Incremental find: ${0} (not found)",find:"Find...",
undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",findPrevious:"Find Previous Occurrence",incrementalFindKey:"Incremental Find",indentLines:"Indent Lines",unindentLines:"Unindent Lines",moveLinesUp:"Move Lines Up",moveLinesDown:"Move Lines Down",copyLinesUp:"Copy Lines Up",copyLinesDown:"Copy Lines Down",deleteLines:"Delete Lines",gotoLine:"Goto Line...",gotoLinePrompty:"Goto Line:",nextAnnotation:"Next Annotation",prevAnnotation:"Previous Annotation",expand:"Expand",
collapse:"Collapse",expandAll:"Expand All",collapseAll:"Collapse All",lastEdit:"Last Edit Location",toggleLineComment:"Toggle Line Comment",addBlockComment:"Add Block Comment",removeBlockComment:"Remove Block Comment",linkedModeEntered:"Linked Mode entered",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",lineColumn:"Line ${0} : Col ${1}"});
define("orion/editor/nls/messages",["orion/editor/i18n!orion/editor/nls/messages","orion/editor/nls/root/messages"],function(s,r){var p={root:r},f;for(f in s)s.hasOwnProperty(f)&&typeof p[f]==="undefined"&&(p[f]=s[f]);return p});
define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(s,r){function p(a,b,d){this.start=a;this.end=b;this._projectionModel=d;this.html=this._expandedHTML;this.style=this._expandedStyle;this.expanded=!0}function f(){}function h(a,b){var d=a.lastIndexOf("."),d=a.substring(d+1),e={title:s[d],style:{styleClass:"annotation "+d},html:"<div class='annotationHTML "+d+"'></div>",overviewStyle:{styleClass:"annotationOverview "+d}};b?e.lineStyle={styleClass:"annotationLine "+
d}:e.rangeStyle={styleClass:"annotationRange "+d};f.registerType(a,e)}function l(){}function k(a){this._annotations=[];var b=this;this._listener={onChanged:function(a){b._onChanged(a)}};this.setTextModel(a)}function m(a,b){this._view=a;this._annotationModel=b;var d=this;this._listener={onDestroy:function(a){d._onDestroy(a)},onLineStyle:function(a){d._onLineStyle(a)},onChanged:function(a){d._onAnnotationModelChanged(a)}};a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("postLineStyle",
this._listener.onLineStyle);b.addEventListener("Changed",this._listener.onChanged)}p.prototype={_expandedHTML:"<div class='annotationHTML expanded'></div>",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"<div class='annotationHTML collapsed'></div>",_collapsedStyle:{styleClass:"annotation collapsed"},collapse:function(){if(this.expanded){this.expanded=!1;this.html=this._collapsedHTML;this.style=this._collapsedStyle;var a=this._projectionModel,b=a.getBaseModel();this._projection=
{start:b.getLineStart(b.getLineAtOffset(this.start)+1),end:b.getLineEnd(b.getLineAtOffset(this.end),!0)};a.addProjection(this._projection)}},expand:function(){if(!this.expanded)this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._projectionModel.removeProjection(this._projection)}};f.ANNOTATION_ERROR="orion.annotation.error";f.ANNOTATION_WARNING="orion.annotation.warning";f.ANNOTATION_TASK="orion.annotation.task";f.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint";
f.ANNOTATION_BOOKMARK="orion.annotation.bookmark";f.ANNOTATION_FOLDING="orion.annotation.folding";f.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket";f.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket";f.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine";f.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch";f.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch";f.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence";f.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence";
var e={};f.registerType=function(a,b){var d=b;if(typeof d!=="function")d=function(a,b,d){this.start=a;this.end=b;if(d)this.title=d},d.prototype=b;d.prototype.type=a;e[a]=d;return a};f.createAnnotation=function(a,b,d,e){return new (this.getType(a))(b,d,e)};f.getType=function(a){return e[a]};h(f.ANNOTATION_ERROR);h(f.ANNOTATION_WARNING);h(f.ANNOTATION_TASK);h(f.ANNOTATION_BREAKPOINT);h(f.ANNOTATION_BOOKMARK);h(f.ANNOTATION_CURRENT_BRACKET);h(f.ANNOTATION_MATCHING_BRACKET);h(f.ANNOTATION_CURRENT_SEARCH);
h(f.ANNOTATION_MATCHING_SEARCH);h(f.ANNOTATION_READ_OCCURRENCE);h(f.ANNOTATION_WRITE_OCCURRENCE);h(f.ANNOTATION_CURRENT_LINE,!0);f.registerType(f.ANNOTATION_FOLDING,p);l.addMixin=function(a){var b=l.prototype,d;for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d])};l.prototype={addAnnotationType:function(a){if(!this._annotationTypes)this._annotationTypes=[];this._annotationTypes.push(a)},getAnnotationTypePriority:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
a)return b+1;return 0},getAnnotationsByType:function(a,b,d){a=a.getAnnotations(b,d);for(d=[];a.hasNext();)b=a.next(),this.getAnnotationTypePriority(b.type)!==0&&d.push(b);var e=this;d.sort(function(a,b){return e.getAnnotationTypePriority(a.type)-e.getAnnotationTypePriority(b.type)});return d},isAnnotationTypeVisible:function(a){return this.getAnnotationTypePriority(a)!==0},removeAnnotationType:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
a){this._annotationTypes.splice(b,1);break}}};k.prototype={addAnnotation:function(a){if(a){var b=this._annotations,d=this._binarySearch(b,a.start);b.splice(d,0,a);this.onChanged({type:"Changed",added:[a],removed:[],changed:[]})}},getTextModel:function(){return this._model},getAnnotations:function(a,b){var d=this._annotations,e,g=0,f=function(){for(;g<d.length;){var c=d[g++];if(a===c.start||(a>c.start?a<c.end:c.start<b))return c;if(c.start>=b)break}return null};e=f();return{next:function(){var a=e;
a&&(e=f());return a},hasNext:function(){return e!==null}}},modifyAnnotation:function(a){if(a&&!(this._getAnnotationIndex(a)<0))this.onChanged({type:"Changed",added:[],removed:[],changed:[a]})},onChanged:function(a){return this.dispatchEvent(a)},removeAnnotations:function(a){var b=this._annotations,d,e;if(a){d=[];for(e=b.length-1;e>=0;e--){var g=b[e];g.type===a&&b.splice(e,1);d.splice(0,0,g)}}else d=b;this.onChanged({type:"Changed",removed:d,added:[],changed:[]})},removeAnnotation:function(a){if(a&&
(a=this._getAnnotationIndex(a),!(a<0)))this.onChanged({type:"Changed",removed:this._annotations.splice(a,1),added:[],changed:[]})},replaceAnnotations:function(a,b){var d=this._annotations,e,g,f,c=[];if(a)for(e=a.length-1;e>=0;e--)f=a[e],g=this._getAnnotationIndex(f),g<0||(d.splice(g,1),c.splice(0,0,f));b||(b=[]);for(e=0;e<b.length;e++)f=b[e],g=this._binarySearch(d,f.start),d.splice(g,0,f);this.onChanged({type:"Changed",removed:c,added:b,changed:[]})},setTextModel:function(a){this._model&&this._model.removeEventListener("Changed",
this._listener.onChanged);(this._model=a)&&this._model.addEventListener("Changed",this._listener.onChanged)},_binarySearch:function(a,b){for(var d=a.length,e=-1,g;d-e>1;)g=Math.floor((d+e)/2),b<=a[g].start?d=g:e=g;return d},_getAnnotationIndex:function(a){for(var b=this._annotations,d=this._binarySearch(b,a.start);d<b.length&&b[d].start===a.start;){if(b[d]===a)return d;d++}return-1},_onChanged:function(a){var b=a.start,d=a.removedCharCount,e=this._annotations,g=b+d;if(0<e.length){for(var f={type:"Changed",
added:[],removed:[],changed:[],textModelChangedEvent:a},a=a.addedCharCount-d,d=0;d<e.length;d++){var c=e[d];c.start>=g?(c.start+=a,c.end+=a,f.changed.push(c)):c.end<=b||(c.start<b&&g<c.end?(c.end+=a,f.changed.push(c)):(e.splice(d,1),f.removed.push(c),d--))}if(f.added.length>0||f.removed.length>0||f.changed.length>0)this.onChanged(f)}}};r.EventTarget.addMixin(k.prototype);m.prototype={destroy:function(){var a=this._view;if(a)a.removeEventListener("Destroy",this._listener.onDestroy),a.removeEventListener("LineStyle",
this._listener.onLineStyle),this.view=null;(a=this._annotationModel)&&a.removeEventListener("Changed",this._listener.onChanged)},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+=" "+b.styleClass:a.styleClass=b.styleClass;var d;if(b.style){if(!a.style)a.style={};for(d in b.style)a.style[d]||(a.style[d]=b.style[d])}if(b.attributes){if(!a.attributes)a.attributes={};for(d in b.attributes)a.attributes[d]||(a.attributes[d]=b.attributes[d])}}return a},
_mergeStyleRanges:function(a,b){a||(a=[]);var d,e;for(e=0;e<a.length&&b;e++){var g=a[e];if(b.end<=g.start)break;if(!(b.start>=g.end)){d=this._mergeStyle({},g.style);d=this._mergeStyle(d,b.style);var f=[];f.push(e,1);b.start<g.start&&f.push({start:b.start,end:g.start,style:b.style});b.start>g.start&&f.push({start:g.start,end:b.start,style:g.style});f.push({start:Math.max(g.start,b.start),end:Math.min(g.end,b.end),style:d});b.end<g.end&&f.push({start:b.end,end:g.end,style:g.style});b=b.end>g.end?{start:g.end,
end:b.end,style:b.style}:null;Array.prototype.splice.apply(a,f)}}b&&(d=this._mergeStyle({},b.style),a.splice(e,0,{start:b.start,end:b.end,style:d}));return a},_onAnnotationModelChanged:function(a){function b(a){for(var b=0;b<a.length;b++)if(e.isAnnotationTypeVisible(a[b].type)){var f=a[b].start,k=a[b].end;g.getBaseModel&&(f=g.mapOffset(f,!0),k=g.mapOffset(k,!0));f!==-1&&k!==-1&&d.redrawRange(f,k)}}if(!a.textModelChangedEvent){var d=this._view;if(d){var e=this,g=d.getModel();b(a.added);b(a.removed);
b(a.changed)}}},_onDestroy:function(){this.destroy()},_onLineStyle:function(a){var b=this._annotationModel,d=a.textView.getModel(),e=b.getTextModel(),g=a.lineStart,f=a.lineStart+a.lineText.length;e!==d&&(g=d.mapOffset(g),f=d.mapOffset(f));for(b=b.getAnnotations(g,f);b.hasNext();)if(g=b.next(),this.isAnnotationTypeVisible(g.type)){if(g.rangeStyle){var f=g.start,c=g.end;e!==d&&(f=d.mapOffset(f,!0),c=d.mapOffset(c,!0));a.ranges=this._mergeStyleRanges(a.ranges,{start:f,end:c,style:g.rangeStyle})}if(g.lineStyle)a.style=
this._mergeStyle({},a.style),a.style=this._mergeStyle(a.style,g.lineStyle)}}};l.addMixin(m.prototype);return{FoldingAnnotation:p,AnnotationType:f,AnnotationTypeList:l,AnnotationModel:k,AnnotationStyler:m}});
define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/textModel","orion/editor/projectionTextModel","orion/editor/util"],function(s,r,p,f,h){function l(f){this._view=f;this._create(f.getOptions("parent").ownerDocument);f.addEventListener("Destroy",this,this.destroy)}l.getTooltip=function(f){if(!f._tooltip)f._tooltip=new l(f);return f._tooltip};l.prototype={_create:function(f){if(!this._tooltipDiv){var m=this._tooltipDiv=h.createElement(f,"div");m.className=
"textviewTooltip";m.setAttribute("aria-live","assertive");m.setAttribute("aria-atomic","true");var e=this._tooltipContents=h.createElement(f,"div");m.appendChild(e);f.body.appendChild(m);this.hide()}},_getWindow:function(){var f=this._tooltipDiv.ownerDocument;return f.defaultView||f.parentWindow},destroy:function(){if(this._tooltipDiv){this.hide();var f=this._tooltipDiv.parentNode;f&&f.removeChild(this._tooltipDiv);this._tooltipDiv=null}},hide:function(){if(this._contentsView)this._contentsView.destroy(),
this._contentsView=null;if(this._tooltipContents)this._tooltipContents.innerHTML="";if(this._tooltipDiv)this._tooltipDiv.style.visibility="hidden";var f=this._getWindow();if(this._showTimeout)f.clearTimeout(this._showTimeout),this._showTimeout=null;if(this._hideTimeout)f.clearTimeout(this._hideTimeout),this._hideTimeout=null;if(this._fadeTimeout)f.clearInterval(this._fadeTimeout),this._fadeTimeout=null},isVisible:function(){return this._tooltipDiv&&this._tooltipDiv.style.visibility==="visible"},setTarget:function(f,
h){if(this.target!==f&&(this._target=f,this.hide(),f)){var e=this;if(h===0)e.show(!0);else{var a=this._getWindow();e._showTimeout=a.setTimeout(function(){e.show(!0)},h?h:500)}}},show:function(k){if(this._target){var h=this._target.getTooltipInfo();if(h){var e=this._tooltipDiv,a=this._tooltipContents;e.style.left=e.style.right=e.style.width=e.style.height=a.style.width=a.style.height="auto";var b=h.contents;b instanceof Array&&(b=this._getAnnotationContents(b));if(typeof b==="string")a.innerHTML=b;
else if(this._isNode(b))a.appendChild(b);else if(b instanceof f.ProjectionTextModel){var d=this._view,i=d.getOptions();i.wrapMode=!1;i.parent=a;var g=i.themeClass;g?((g=g.replace("tooltip",""))&&(g=" "+g),g="tooltip"+g):g="tooltip";i.themeClass=g;i=this._contentsView=new r.TextView(i);i._clientDiv.contentEditable=!1;i.addEventListener("LineStyle",function(a){d.onLineStyle(a)});i.setModel(b);b=i.computeSize();a.style.width=b.width+20+"px";a.style.height=b.height+"px";i.resize()}else return;a=e.ownerDocument.documentElement;
h.anchor==="right"?(b=a.clientWidth-h.x,e.style.right=b+"px"):(b=parseInt(this._getNodeStyle(e,"padding-left","0"),10),b+=parseInt(this._getNodeStyle(e,"border-left-width","0"),10),b=h.x-b,e.style.left=b+"px");e.style.maxWidth=a.clientWidth-b-10+"px";b=parseInt(this._getNodeStyle(e,"padding-top","0"),10);b+=parseInt(this._getNodeStyle(e,"border-top-width","0"),10);b=h.y-b;e.style.top=b+"px";e.style.maxHeight=a.clientHeight-b-10+"px";e.style.opacity="1";e.style.visibility="visible";if(k){var o=this,
c=this._getWindow();o._hideTimeout=c.setTimeout(function(){var a=parseFloat(o._getNodeStyle(e,"opacity","1"));o._fadeTimeout=c.setInterval(function(){e.style.visibility==="visible"&&a>0?(a-=0.1,e.style.opacity=a):o.hide()},50)},5E3)}}}},_getAnnotationContents:function(k){function h(b){var d=b.title;if(d==="")return null;var e="<div>";b.html&&(e+=b.html+"&nbsp;");if(!d)d=b.end,b=a.getLineStart(a.getLineAtOffset(b.start)),d=a.getLineEnd(a.getLineAtOffset(d),!0),d=a.getText(b,d);d=d.replace(/</g,"&lt;").replace(/>/g,
"&gt;");e+="<span style='vertical-align:middle;'>"+d+"</span><div>";return e}if(k.length===0)return null;var e=this._view.getModel(),a=e.getBaseModel?e.getBaseModel():e;if(k.length===1)if(e=k[0],e.title!==void 0)return h(e);else{var k=new f.ProjectionTextModel(a),b=a.getLineStart(a.getLineAtOffset(e.start)),d=a.getCharCount();e.end!==d&&k.addProjection({start:e.end,end:d});b>0&&k.addProjection({start:0,end:b});return k}else{b="<div><em>"+s.multipleAnnotations+"</em></div>";for(d=0;d<k.length;d++)e=
k[d],(e=h(e))&&(b+=e);return b}},_getNodeStyle:function(f,h,e){var a;if(f&&(a=f.style[h],!a))if(f.currentStyle){for(a=0;(a=h.indexOf("-",a))!==-1;)h=h.substring(0,a)+h.substring(a+1,a+2).toUpperCase()+h.substring(a+2);a=f.currentStyle[h]}else a=(f=f.ownerDocument.defaultView.getComputedStyle(f,null))?f.getPropertyValue(h):null;return a||e},_isNode:function(f){return typeof Node==="object"?f instanceof Node:f&&typeof f==="object"&&typeof f.nodeType==="number"&&typeof f.nodeName==="string"}};return{Tooltip:l}});
define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/annotations","orion/editor/tooltip","orion/editor/util"],function(s,r,p,f){function h(a,b,d,e){this._location=b||"left";this._overview=d||"page";this._rulerStyle=e;this._view=null;var g=this;this._listener={onTextModelChanged:function(a){g._onTextModelChanged(a)},onAnnotationModelChanged:function(a){g._onAnnotationModelChanged(a)}};this.setAnnotationModel(a)}function l(a,b,d,e,g){h.call(this,a,b,"page",d);this._oddStyle=
e||{style:{backgroundColor:"white"}};this._evenStyle=g||{style:{backgroundColor:"white"}};this._numOfDigits=0}function k(a,b,d){h.call(this,a,b,"page",d)}function m(a,b,d){h.call(this,a,b,"document",d)}function e(a,b,d){k.call(this,a,b,d)}h.prototype={getAnnotations:function(a,b){var d=this._annotationModel;if(!d)return[];var e=this._view.getModel(),g=e.getLineStart(a),f=e.getLineEnd(b-1),c=e;e.getBaseModel&&(c=e.getBaseModel(),g=e.mapOffset(g),f=e.mapOffset(f));for(var j=[],d=this.getAnnotationsByType(d,
g,f),g=0;g<d.length;g++)for(var f=d[g],k=c.getLineAtOffset(f.start),h=c.getLineAtOffset(Math.max(f.start,f.end-1)),l=k;l<=h;l++){var m=l;if(e!==c){m=c.getLineStart(l);m=e.mapOffset(m,!0);if(m===-1)continue;m=e.getLineAtOffset(m)}if(a<=m&&m<b){var n=this._mergeAnnotation(j[m],f,l-k,h-k+1);n&&(j[m]=n)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var B in j)j[B]._multiple&&(j[B].html+=this._multiAnnotationOverlay.html);return j},getAnnotationModel:function(){return this._annotationModel},
getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},getWidestAnnotation:function(){return null},setAnnotationModel:function(a){this._annotationModel&&this._annotationModel.removEventListener("Changed",this._listener.onAnnotationModelChanged);(this._annotationModel=a)&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(a){this._multiAnnotation=
a},setMultiAnnotationOverlay:function(a){this._multiAnnotationOverlay=a},setView:function(a){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged);this._view=a;this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)},onClick:function(){},onDblClick:function(){},onMouseMove:function(a,b){var d=p.Tooltip.getTooltip(this._view);if(d&&!(d.isVisible()&&this._tooltipLineIndex===a)){this._tooltipLineIndex=
a;var e=this;d.setTarget({y:b.clientY,getTooltipInfo:function(){return e._getTooltipInfo(e._tooltipLineIndex,this.y)}})}},onMouseOver:function(a,b){this.onMouseMove(a,b)},onMouseOut:function(){var a=p.Tooltip.getTooltip(this._view);a&&a.setTarget(null)},_getTooltipInfo:function(a,b){if(a!==void 0){var d=this._view,e=d.getModel(),g=this._annotationModel,f=[];if(g){var f=e.getLineStart(a),c=e.getLineEnd(a);e.getBaseModel&&(f=e.mapOffset(f),c=e.mapOffset(c));f=this.getAnnotationsByType(g,f,c)}g=this._getTooltipContents(a,
f);if(!g)return null;g={contents:g,anchor:this.getLocation()};f=d.getClientArea();f.y=this.getOverview()==="document"?d.convert({y:b},"view","document").y:d.getLocationAtOffset(e.getLineStart(a)).y;d.convert(f,"document","page");g.x=f.x;g.y=f.y;g.anchor==="right"&&(g.x+=f.width);return g}},_getTooltipContents:function(a,b){return b},_onAnnotationModelChanged:function(a){function b(a){for(var b=0;b<a.length;b++)if(g.isAnnotationTypeVisible(a[b].type)){var f=a[b].start,o=a[b].end;e.getBaseModel&&(f=
e.mapOffset(f,!0),o=e.mapOffset(o,!0));f!==-1&&o!==-1&&d.redrawLines(e.getLineAtOffset(f),e.getLineAtOffset(Math.max(f,o-1))+1,g)}}var d=this._view;if(d){var e=d.getModel(),g=this,f=e.getLineCount();a.textModelChangedEvent?(a=a.textModelChangedEvent.start,e.getBaseModel&&(a=e.mapOffset(a,!0)),a=e.getLineAtOffset(a),d.redrawLines(a,f,g)):(b(a.added),b(a.removed),b(a.changed))}},_mergeAnnotation:function(a,b,d){a||(a={});if(d===0)if(a.html&&b.html){if(b.html!==a.html&&!a._multiple&&this._multiAnnotation)a.html=
this._multiAnnotation.html;a._multiple=!0}else a.html=b.html;a.style=this._mergeStyle(a.style,b.style);return a},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+=" "+b.styleClass:a.styleClass=b.styleClass;var d;if(b.style){if(!a.style)a.style={};for(d in b.style)a.style[d]||(a.style[d]=b.style[d])}if(b.attributes){if(!a.attributes)a.attributes={};for(d in b.attributes)a.attributes[d]||(a.attributes[d]=b.attributes[d])}}return a}};r.AnnotationTypeList.addMixin(h.prototype);
l.prototype=new h;l.prototype.getAnnotations=function(a,b){for(var d=h.prototype.getAnnotations.call(this,a,b),e=this._view.getModel(),f=a;f<b;f++){var o=f&1?this._oddStyle:this._evenStyle,c=f;e.getBaseModel&&(c=e.getLineStart(c),c=e.getBaseModel().getLineAtOffset(e.mapOffset(c)));d[f]||(d[f]={});d[f].html=c+1+"";if(!d[f].style)d[f].style=o}return d};l.prototype.getWidestAnnotation=function(){var a=this._view.getModel().getLineCount();return this.getAnnotations(a-1,a)[a-1]};l.prototype._onTextModelChanged=
function(a){var a=a.start,b=this._view.getModel(),d=((b.getBaseModel?b.getBaseModel().getLineCount():b.getLineCount())+"").length;if(this._numOfDigits!==d)this._numOfDigits=d,this._view.redrawLines(b.getLineAtOffset(a),b.getLineCount(),this)};k.prototype=new h;m.prototype=new h;m.prototype.getRulerStyle=function(){var a={style:{lineHeight:"1px",fontSize:"1px"}};return a=this._mergeStyle(a,this._rulerStyle)};m.prototype.onClick=function(a){a!==void 0&&this._view.setTopIndex(a)};m.prototype._getTooltipContents=
function(a,b){if(b.length===0){var d=this._view.getModel(),e=a;d.getBaseModel&&(e=d.getLineStart(e),e=d.getBaseModel().getLineAtOffset(d.mapOffset(e)));return f.formatMessage(s.line,e+1)}return h.prototype._getTooltipContents.call(this,a,b)};m.prototype._mergeAnnotation=function(a,b,d,e){if(d===0){if(!a)a={html:"&nbsp;",style:{style:{height:3*e+"px"}}},a.style=this._mergeStyle(a.style,b.overviewStyle);return a}};e.prototype=new k;e.prototype.onClick=function(a){if(a!==void 0){var b=this._annotationModel;
if(b){var d=this._view.getModel(),e=d.getLineStart(a),a=d.getLineEnd(a,!0);d.getBaseModel&&(e=d.mapOffset(e),a=d.mapOffset(a),d=d.getBaseModel());for(var f,b=b.getAnnotations(e,a);!f&&b.hasNext();)a=b.next(),this.isAnnotationTypeVisible(a.type)&&(f=a);f&&d.getLineAtOffset(f.start)===d.getLineAtOffset(e)&&((d=p.Tooltip.getTooltip(this._view))&&d.setTarget(null),f.expanded?f.collapse():f.expand(),this._annotationModel.modifyAnnotation(f))}}};e.prototype._getTooltipContents=function(a,b){return b.length===
1&&b[0].expanded?null:k.prototype._getTooltipContents.call(this,a,b)};e.prototype._onAnnotationModelChanged=function(a){function b(a){for(o=0;o<a.length;o++)if(f.isAnnotationTypeVisible(a[o].type)){var b=a[o].start;e.getBaseModel&&(b=e.mapOffset(b,!0));b!==-1&&(j=Math.min(j,e.getLineAtOffset(b)))}}if(a.textModelChangedEvent)k.prototype._onAnnotationModelChanged.call(this,a);else{var d=this._view;if(d){var e=d.getModel(),f=this,o,c=e.getLineCount(),j=c;b(a.added);b(a.removed);b(a.changed);a=d.getRulers();
for(o=0;o<a.length;o++)d.redrawLines(j,c,a[o])}}};return{Ruler:h,AnnotationRuler:k,LineNumberRuler:l,OverviewRuler:m,FoldingRuler:e}});
define("orion/editor/undoStack",[],function(){function s(f,h,l){this.offset=f;this.text=h;this.previousText=l}function r(){this.changes=[]}function p(f,h){this.view=f;this.size=h!==void 0?h:100;this.reset();var l=f.getModel();l.getBaseModel&&(l=l.getBaseModel());this.model=l;var k=this;this._listener={onChanging:function(f){k._onChanging(f)},onDestroy:function(f){k._onDestroy(f)}};l.addEventListener("Changing",this._listener.onChanging);f.addEventListener("Destroy",this._listener.onDestroy)}s.prototype=
{undo:function(f,h){this._doUndoRedo(this.offset,this.previousText,this.text,f,h)},redo:function(f,h){this._doUndoRedo(this.offset,this.text,this.previousText,f,h)},_doUndoRedo:function(f,h,l,k,m){var e=k.getModel();if(e.mapOffset&&k.annotationModel){var a=e.mapOffset(f,!0);if(a<0)for(var b=k.annotationModel.getAnnotations(f,f+1);b.hasNext();){var d=b.next();if(d.type==="orion.annotation.folding"){d.expand();a=e.mapOffset(f,!0);break}}if(a<0)return;f=a}k.setText(h,f,f+l.length);m&&k.setSelection(f,
f+h.length)}};r.prototype={add:function(f){this.changes.push(f)},end:function(f){this.endSelection=f.getSelection();this.endCaret=f.getCaretOffset()},undo:function(f,h){for(var l=this.changes.length-1;l>=0;l--)this.changes[l].undo(f,!1);if(h){var l=this.startSelection.start,k=this.startSelection.end;f.setSelection(this.startCaret?l:k,this.startCaret?k:l)}},redo:function(f,h){for(var l=0;l<this.changes.length;l++)this.changes[l].redo(f,!1);if(h){var l=this.endSelection.start,k=this.endSelection.end;
f.setSelection(this.endCaret?l:k,this.endCaret?k:l)}},start:function(f){this.startSelection=f.getSelection();this.startCaret=f.getCaretOffset()}};p.prototype={add:function(f){this.compoundChange?this.compoundChange.add(f):(this.stack.splice(this.index,this.stack.length-this.index,f),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--,this.cleanIndex--))},markClean:function(){this.endCompoundChange();this._commitUndo();this.cleanIndex=this.index},isClean:function(){return this.cleanIndex===
this.getSize().undo},canUndo:function(){return this.getSize().undo>0},canRedo:function(){return this.getSize().redo>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view);this.compoundChange=void 0},getSize:function(){var f=this.index,h=this.stack.length;this._undoStart!==void 0&&f++;return{undo:f,redo:h-f}},undo:function(){this._commitUndo();if(this.index<=0)return!1;var f=this.stack[--this.index];this._ignoreUndo=!0;f.undo(this.view,!0);this._ignoreUndo=!1;return!0},
redo:function(){this._commitUndo();if(this.index>=this.stack.length)return!1;var f=this.stack[this.index++];this._ignoreUndo=!0;f.redo(this.view,!0);this._ignoreUndo=!1;return!0},reset:function(){this.index=this.cleanIndex=0;this.stack=[];this._undoStart=void 0;this._undoText="";this._undoType=0;this._ignoreUndo=!1;this._compoundChange=void 0},startCompoundChange:function(){this._commitUndo();var f=new r;this.add(f);this.compoundChange=f;this.compoundChange.start(this.view)},_commitUndo:function(){if(this._undoStart!==
void 0)this._undoType===-1?this.add(new s(this._undoStart,"",this._undoText)):this.add(new s(this._undoStart,this._undoText,"")),this._undoStart=void 0,this._undoText="",this._undoType=0},_onDestroy:function(){this.model.removeEventListener("Changing",this._listener.onChanging);this.view.removeEventListener("Destroy",this._listener.onDestroy)},_onChanging:function(f){var h=f.text,l=f.start,k=f.removedCharCount,f=f.addedCharCount;if(!this._ignoreUndo){this._undoStart!==void 0&&!(f===1&&k===0&&this._undoType===
1&&l===this._undoStart+this._undoText.length||f===0&&k===1&&this._undoType===-1&&(l+1===this._undoStart||l===this._undoStart))&&this._commitUndo();if(!this.compoundChange)if(f===1&&k===0){if(this._undoStart===void 0)this._undoStart=l;this._undoText+=h;this._undoType=1;return}else if(f===0&&k===1){h=this._undoText.length>0&&this._undoStart===l;this._undoStart=l;this._undoType=-1;h?this._undoText+=this.model.getText(l,l+k):this._undoText=this.model.getText(l,l+k)+this._undoText;return}this.add(new s(l,
h,this.model.getText(l,l+k)))}}};return{UndoStack:p}});
define("orion/editor/textDND",[],function(){function s(r,p){this._view=r;this._undoStack=p;this._dragSelection=null;this._dropOffset=-1;this._dropText=null;var f=this;this._listener={onDragStart:function(h){f._onDragStart(h)},onDragEnd:function(h){f._onDragEnd(h)},onDragEnter:function(h){f._onDragEnter(h)},onDragOver:function(h){f._onDragOver(h)},onDrop:function(h){f._onDrop(h)},onDestroy:function(h){f._onDestroy(h)}};r.addEventListener("DragStart",this._listener.onDragStart);r.addEventListener("DragEnd",
this._listener.onDragEnd);r.addEventListener("DragEnter",this._listener.onDragEnter);r.addEventListener("DragOver",this._listener.onDragOver);r.addEventListener("Drop",this._listener.onDrop);r.addEventListener("Destroy",this._listener.onDestroy)}s.prototype={destroy:function(){var r=this._view;if(r)r.removeEventListener("DragStart",this._listener.onDragStart),r.removeEventListener("DragEnd",this._listener.onDragEnd),r.removeEventListener("DragEnter",this._listener.onDragEnter),r.removeEventListener("DragOver",
this._listener.onDragOver),r.removeEventListener("Drop",this._listener.onDrop),r.removeEventListener("Destroy",this._listener.onDestroy),this._view=null},_onDestroy:function(){this.destroy()},_onDragStart:function(r){var p=this._view,f=p.getSelection(),p=p.getModel();if(p.getBaseModel)f.start=p.mapOffset(f.start),f.end=p.mapOffset(f.end),p=p.getBaseModel();if(p=p.getText(f.start,f.end))this._dragSelection=f,r.event.dataTransfer.effectAllowed="copyMove",r.event.dataTransfer.setData("Text",p)},_onDragEnd:function(r){var p=
this._view;if(this._dragSelection){this._undoStack&&this._undoStack.startCompoundChange();(r=r.event.dataTransfer.dropEffect==="move")&&p.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var f=this._dropText,h=this._dropOffset;if(r)if(h>=this._dragSelection.end)h-=this._dragSelection.end-this._dragSelection.start;else if(h>=this._dragSelection.start)h=this._dragSelection.start;p.setText(f,h,h);p.setSelection(h,h+f.length);this._dropText=null;this._dropOffset=-1}this._undoStack&&
this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(r){this._onDragOver(r)},_onDragOver:function(r){var p=r.event.dataTransfer.types;if(p){var f=!this._view.getOptions("readonly");f&&(f=p.contains?p.contains("text/plain"):p.indexOf("text/plain")!==-1);if(!f)r.event.dataTransfer.dropEffect="none"}},_onDrop:function(r){var p=this._view,f=r.event.dataTransfer.getData("Text");if(f)r=p.getOffsetAtLocation(r.x,r.y),this._dragSelection?(this._dropOffset=r,this._dropText=f):
(p.setText(f,r,r),p.setSelection(r,r+f.length))}};return{TextDND:s}});
define("orion/editor/editor","i18n!orion/editor/nls/messages,orion/editor/keyBinding,orion/editor/eventTarget,orion/editor/tooltip,orion/editor/annotations,orion/editor/util".split(","),function(s,r,p,f,h,l){function k(a){this._textViewFactory=a.textViewFactory;this._undoStackFactory=a.undoStackFactory;this._textDNDFactory=a.textDNDFactory;this._annotationFactory=a.annotationFactory;this._foldingRulerFactory=a.foldingRulerFactory;this._lineNumberRulerFactory=a.lineNumberRulerFactory;this._contentAssistFactory=
a.contentAssistFactory;this._keyBindingFactory=a.keyBindingFactory;this._statusReporter=a.statusReporter;this._domNode=a.domNode;this._foldingRuler=this._overviewRuler=this._lineNumberRuler=this._annotationRuler=this._annotationModel=this._annotationStyler=null;this._dirty=!1;this._title=this._contentAssist=null;this._keyModes=[]}function m(a){var b=this,d=Array.prototype.slice.call(arguments,1);return d.length?function(){return arguments.length?b.apply(a,d.concat(Array.prototype.slice.call(arguments))):
b.apply(a,d)}:function(){return arguments.length?b.apply(a,arguments):b.call(a)}}var e;k.prototype={destroy:function(){this.uninstallTextView();this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._statusReporter=this._domNode=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},
getAnnotationStyler:function(){return this._annotationStyler},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getModel:function(){var a=this._textView.getModel();a.getBaseModel&&(a=a.getBaseModel());return a},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getTitle:function(){return this._title},getKeyModes:function(){return this._keyModes},isDirty:function(){return this._dirty},
setAnnotationRulerVisible:function(a){if(this._annotationRulerVisible!==a&&(this._annotationRulerVisible=a,this._annotationRuler)){var b=this._textView;a?b.addRuler(this._annotationRuler,0):b.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(a){if(this._foldingRulerVisible!==a&&(this._foldingRulerVisible=a,this._foldingRuler)){var b=this._textView;b.getModel().getBaseModel&&(a?b.addRuler(this._foldingRuler,100):b.removeRuler(this._foldingRuler))}},setDirty:function(a){if(this._dirty!==
a)this._dirty=a,this.onDirtyChanged({type:"DirtyChanged"})},setLineNumberRulerVisible:function(a){if(this._lineNumberRulerVisible!==a&&(this._lineNumberRulerVisible=a,this._lineNumberRuler)){var b=this._textView;a?b.addRuler(this._lineNumberRuler,1):b.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(a){if(this._overviewRulerVisible!==a&&(this._overviewRulerVisible=a,this._overviewRuler)){var b=this._textView;a?b.addRuler(this._overviewRuler):b.removeRuler(this._overviewRuler)}},
mapOffset:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(a=d.mapOffset(a,b));return a},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelection:function(){var a=this._textView,b=a.getSelection(),a=a.getModel();if(a.getBaseModel)b.start=a.mapOffset(b.start),b.end=a.mapOffset(b.end);return b},getText:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(d=d.getBaseModel());return d.getText(a,b)},_expandOffset:function(a){var b=this._textView.getModel(),
d=this._annotationModel;if(d&&b.getBaseModel)for(a=d.getAnnotations(a,a+1);a.hasNext();)b=a.next(),b.type===h.AnnotationType.ANNOTATION_FOLDING&&b.expand&&(b.expand(),d.modifyAnnotation(b))},setCaretOffset:function(a){var b=this._textView,d=b.getModel();d.getBaseModel&&(this._expandOffset(a),a=d.mapOffset(a,!0));b.setCaretOffset(a)},setText:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(b!==void 0&&(this._expandOffset(b),b=f.mapOffset(b,!0)),d!==void 0&&(this._expandOffset(d),
d=f.mapOffset(d,!0)));e.setText(a,b,d)},setFoldingEnabled:function(a){this.setFoldingRulerVisible(a)},setSelection:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(this._expandOffset(a),this._expandOffset(b),a=f.mapOffset(a,!0),b=f.mapOffset(b,!0));e.setSelection(a,b,d)},moveSelection:function(a,b,d,i){var f=this._textView;this.setSelection(a,b||a,!1);var b=f.getTopPixel(),o=f.getBottomPixel(),a=this.getModel().getLineAtOffset(a),a=f.getLinePixel(a);a<b||a>o?(o=Math.max(0,a-Math.floor((a<
b?3:1)*(o-b)/4)),(new e({node:f,duration:300,curve:[b,o],onAnimate:function(a){f.setTopPixel(Math.floor(a))},onEnd:function(){f.showSelection();(i===void 0||i)&&f.focus();d&&d()}})).play()):(f.showSelection(),(i===void 0||i)&&f.focus(),d&&d())},checkDirty:function(){this.setDirty(!this._undoStack.isClean())},reportStatus:function(a,b,d){this._statusReporter&&this._statusReporter(a,b,d)},_getTooltipInfo:function(a,b){var d=this._textView,e=this.getAnnotationModel();if(!e)return null;var f=this._annotationStyler;
if(!f)return null;var o=d.getOffsetAtLocation(a,b);if(o===-1)return null;o=this.mapOffset(o);f=f.getAnnotationsByType(e,o,o+1);e=[];for(o=0;o<f.length;o++)f[o].rangeStyle&&e.push(f[o]);if(e.length===0)return null;d=d.convert({x:a,y:b},"document","page");return{contents:e,anchor:"left",x:d.x+10,y:d.y+20}},_highlightCurrentLine:function(a,b){var d=this._annotationModel;if(d){var e=this._textView.getModel(),f=b?e.getLineAtOffset(b.start):-1,o=e.getLineAtOffset(a.start),c=a.start===a.end,j=!b||b.start===
b.end,k=e.getLineStart(o),l=e.getLineEnd(o);e.getBaseModel&&(k=e.mapOffset(k),l=e.mapOffset(l));e=this._currentLineAnnotation;if(!(f===o&&j&&c&&e&&e.start===k&&e.end===l)){var f=e?[e]:null,m;c&&(e=h.AnnotationType.createAnnotation(h.AnnotationType.ANNOTATION_CURRENT_LINE,k,l),m=[e]);this._currentLineAnnotation=e;d.replaceAnnotations(f,m)}}},installTextView:function(){this._textView=this._textViewFactory();if(this._undoStackFactory)this._undoStack=this._undoStackFactory.createUndoStack(this);if(this._textDNDFactory)this._textDND=
this._textDNDFactory.createTextDND(this,this._undoStack);if(this._contentAssistFactory){var a=this._contentAssistFactory.createContentAssistMode(this);this._keyModes.push(a);this._contentAssist=a.getContentAssist()}var b=this,d=this._textView,e=this;this._listener={onModelChanged:function(){e.checkDirty()},onMouseOver:function(a){e._listener.onMouseMove(a)},onMouseMove:function(a){var b=f.Tooltip.getTooltip(d);b&&b.setTarget({x:a.x,y:a.y,getTooltipInfo:function(){return e._getTooltipInfo(this.x,this.y)}})},
onMouseOut:function(){var a=f.Tooltip.getTooltip(d);a&&a.setTarget(null)},onSelection:function(a){e._updateCursorStatus();e._highlightCurrentLine(a.newValue,a.oldValue)}};d.addEventListener("ModelChanged",this._listener.onModelChanged);d.addEventListener("Selection",this._listener.onSelection);d.addEventListener("MouseOver",this._listener.onMouseOver);d.addEventListener("MouseOut",this._listener.onMouseOut);d.addEventListener("MouseMove",this._listener.onMouseMove);this._keyBindingFactory&&this._keyBindingFactory(this,
this._keyModes,this._undoStack,this._contentAssist);d.setKeyBinding(new r.KeyBinding(27),"cancelMode");d.setAction("cancelMode",function(){for(var a=!1,b=0;b<this._keyModes.length;b++)this._keyModes[b].isActive()&&(a=this._keyModes[b].cancel()||a);return a}.bind(this),{name:s.cancelMode});d.setAction("lineUp",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].lineUp();return!1}.bind(this));d.setAction("lineDown",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].lineDown();
return!1}.bind(this));d.setAction("enter",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].enter();return!1}.bind(this));a=function(a){if(a!==void 0&&a!==-1){for(var d=this.getView().getModel(),e=this.getAnnotationModel(),f=b.mapOffset(d.getLineStart(a)),a=b.mapOffset(d.getLineEnd(a)),d=e.getAnnotations(f,a),i=null;d.hasNext();){var g=d.next();if(g.type===h.AnnotationType.ANNOTATION_BOOKMARK){i=g;break}}i?e.removeAnnotation(i):(i=h.AnnotationType.createAnnotation(h.AnnotationType.ANNOTATION_BOOKMARK,
f,a),i.title=void 0,e.addAnnotation(i))}};if(this._annotationFactory){var g=d.getModel();g.getBaseModel&&(g=g.getBaseModel());if(this._annotationModel=this._annotationFactory.createAnnotationModel(g))if(g=this._annotationStyler=this._annotationFactory.createAnnotationStyler(d,this._annotationModel))g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_SEARCH),g.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_SEARCH),g.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),g.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),
g.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_BRACKET),g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_BRACKET),g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_LINE),g.addAnnotationType(h.AnnotationType.ANNOTATION_READ_OCCURRENCE),g.addAnnotationType(h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE),g.addAnnotationType("orion.annotation.highlightError");d.annotationModel=this._annotationModel;var g=this._annotationFactory.createAnnotationRulers(this._annotationModel),o=this._annotationRuler=
g.annotationRuler;if(o)o.onClick=function(a){if(a!==void 0&&a!==-1)for(var d=this.getView().getModel(),e=this.getAnnotationModel(),f=b.mapOffset(d.getLineStart(a)),a=b.mapOffset(d.getLineEnd(a)),a=e.getAnnotations(f,a);a.hasNext();)if(e=a.next(),this.isAnnotationTypeVisible(e.type)){a=b.getModel();b.onGotoLine(a.getLineAtOffset(f),e.start-f,e.end-f);break}},o.onDblClick=a,o.setMultiAnnotationOverlay({html:"<div class='annotationHTML overlay'></div>"}),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),
o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK);this.setAnnotationRulerVisible(!0);if(o=this._overviewRuler=g.overviewRuler)o.onClick=function(a){a!==void 0&&(a=d.getModel().getLineStart(a),b.moveSelection(b.mapOffset(a)))},o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),
o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_LINE),o.addAnnotationType(h.AnnotationType.ANNOTATION_READ_OCCURRENCE),o.addAnnotationType(h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE);this.setOverviewRulerVisible(!0)}if(this._lineNumberRulerFactory)this._lineNumberRuler=
this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.onDblClick=a,this.setLineNumberRulerVisible(!0);if(this._foldingRulerFactory)this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(h.AnnotationType.ANNOTATION_FOLDING),this.setFoldingRulerVisible(!1);this.dispatchEvent({type:"TextViewInstalled",textView:d})},uninstallTextView:function(){var a=this._textView;if(a)a.destroy(),this._textView=
this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotation=this._title=null,this._dirty=!1,this._keyModes=[],this.dispatchEvent({type:"TextViewUninstalled",textView:a})},_updateCursorStatus:function(){var a=this.getModel(),b=this.getCaretOffset(),d=a.getLineAtOffset(b),a=a.getLineStart(d);b-=a;for(a=0;a<this._keyModes.length;a++){var e=this._keyModes[a];
if(e.isActive()&&e.isStatusActive&&e.isStatusActive())return}this.reportStatus(l.formatMessage(s.lineColumn,d+1,b+1))},showProblems:function(a){var b=this._annotationModel;if(b){for(var d=[],e=[],f=b.getTextModel(),o=b.getAnnotations(0,f.getCharCount()),c;o.hasNext();)c=o.next(),(c.type===h.AnnotationType.ANNOTATION_ERROR||c.type===h.AnnotationType.ANNOTATION_WARNING)&&d.push(c);if(a)for(o=0;o<a.length;o++)if(c=a[o]){var j=c.description.replace(/'/g,"&#39;").replace(/"/g,"&#34;"),k=f.getLineStart(c.line-
1);c=h.AnnotationType.createAnnotation(c.severity==="error"?h.AnnotationType.ANNOTATION_ERROR:h.AnnotationType.ANNOTATION_WARNING,k+c.start-1,k+c.end,j);e.push(c)}b.replaceAnnotations(d,e)}},showOccurrences:function(a){var b=this._annotationModel;if(b){for(var d=[],e=[],f=b.getTextModel(),o=b.getAnnotations(0,f.getCharCount()),c;o.hasNext();)c=o.next(),(c.type===h.AnnotationType.ANNOTATION_READ_OCCURRENCE||c.type===h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE)&&d.push(c);if(a)for(o=0;o<a.length;o++)if(c=
a[o]){var j=f.getLineStart(c.line-1);c=h.AnnotationType.createAnnotation(c.readAccess===!0?h.AnnotationType.ANNOTATION_READ_OCCURRENCE:h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE,j+c.start-1,j+c.end,c.description);e.push(c)}b.replaceAnnotations(d,e)}},showSelection:function(a,b,d,e,f){typeof a==="number"?(typeof b!=="number"&&(b=a),this.moveSelection(a,b)):typeof d==="number"&&(a=this.getModel().getLineStart(d-1),typeof e==="number"&&(a+=e),typeof f!=="number"&&(f=0),this.moveSelection(a,a+f))},
setInput:function(a,b,d,e){this._title=a;this._textView&&(e?(this._undoStack.markClean(),this.checkDirty()):(b?this._textView.setText(b):d!==null&&d!==void 0&&(this._textView.setText(d),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelection())),this._undoStack.reset(),this.checkDirty(),this._textView.focus()));this.onInputChanged({type:"InputChanged",title:a,message:b,contents:d,contentsSaved:e})},onInputChanged:function(a){return this.dispatchEvent(a)},
onGotoLine:function(a,b,d){if(this._textView){var e=this.getModel(),f=e.getLineStart(a),o=0;d===void 0&&(d=0);typeof b==="string"?(a=e.getLine(a).indexOf(b),a!==-1&&(o=a,d=o+b.length)):(o=b,b=e.getLineEnd(a)-f,o=Math.min(o,b),d=Math.min(d,b));this.moveSelection(f+o,f+d)}},onDirtyChanged:function(a){return this.dispatchEvent(a)}};p.EventTarget.addMixin(k.prototype);e=function(){function a(a){this.options=a}a.prototype.play=function(){var a=typeof this.options.duration==="number"?this.options.duration:
350,d=this.options.easing||this.defaultEasing,e=this.options.onAnimate||function(){},f=this.options.onEnd||function(){},o=this.options.curve[0],c=this.options.curve[1]-o,j,k,h=-1;k=setInterval(function(){h=h===-1?(new Date).getTime():h;var l=((new Date).getTime()-h)/a;l<1?(l=d(l),j=o+l*c,e(j)):(clearInterval(k),f())},typeof this.options.rate==="number"?this.options.rate:20)};a.prototype.defaultEasing=function(a){return Math.sin(a*(Math.PI/2))};return a}();if(!Function.prototype.bind)Function.prototype.bind=
m;return{Editor:k,util:{bind:m}}});define("orion/editor/regex",[],function(){return{escape:function(s){return s.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")},parse:function(s){return(s=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(s))?{pattern:s[1],flags:s[2]}:null}}});
define("orion/editor/editorFeatures","i18n!orion/editor/nls/messages,orion/editor/undoStack,orion/editor/keyBinding,orion/editor/rulers,orion/editor/annotations,orion/editor/tooltip,orion/editor/textDND,orion/editor/regex,orion/editor/util".split(","),function(s,r,p,f,h,l,k,m,e){function a(){}function b(){}function d(){}function i(){}function g(){}function o(a,b,c){this.editor=a;this.textView=a.getTextView();this.undoStack=b;this._incrementalFindActive=!1;this._incrementalFindSuccess=!0;this._incrementalFindIgnoreSelection=
!1;this._incrementalFindPrefix="";this._searcher=c;this._lastEditLocation=null;this.init()}function c(a,b,c,d){this.editor=a;this.textView=a.getTextView();this.undoStack=b;this.contentAssist=c;this.linkedMode=d;this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this));this.init()}function j(a){this.editor=a;this.textView=a.getTextView();this.linkedModeActive=!1;this.linkedModePositions=[];this.linkedModeEscapePosition=this.linkedModeCurrentPositionIndex=
0;this.linkedModeListener={onVerify:function(a){for(var b=!1,c=0,d=0;d<this.linkedModePositions.length;++d){var e=this.linkedModePositions[d];if(b)e.offset+=c;else if(a.start>=e.offset&&a.end<=e.offset+e.length)b=e.length,e.length=a.start-e.offset+a.text.length+(e.offset+e.length-a.end),c=e.length-b,b=!0}b?this.linkedModeEscapePosition+=c:this.cancel()}.bind(this)}}a.prototype={createUndoStack:function(a){var a=a.getTextView(),b=new r.UndoStack(a,200);a.setAction("undo",function(){b.undo();return!0},
{name:s.undo});a.setAction("redo",function(){b.redo();return!0},{name:s.redo});return b}};b.prototype={createLineNumberRuler:function(a){return new f.LineNumberRuler(a,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}};d.prototype={createFoldingRuler:function(a){return new f.FoldingRuler(a,"left",{styleClass:"ruler folding"})}};i.prototype={createAnnotationModel:function(a){return new h.AnnotationModel(a)},createAnnotationStyler:function(a,b){return new h.AnnotationStyler(a,
b)},createAnnotationRulers:function(a){var b=new f.AnnotationRuler(a,"left",{styleClass:"ruler annotations"}),a=new f.OverviewRuler(a,"right",{styleClass:"ruler overview"});return{annotationRuler:b,overviewRuler:a}}};g.prototype={createTextDND:function(a,b){return new k.TextDND(a.getTextView(),b)}};o.prototype={init:function(){var a=this;this._incrementalFindListener={onVerify:function(b){var c=a.editor,d=c.getModel(),f=c.mapOffset(b.start),i=c.mapOffset(b.end),f=d.getText(f,i),d=a._incrementalFindPrefix;
if((d=d.match(RegExp("^"+m.escape(f),"i")))&&d.length>0)d=a._incrementalFindPrefix+=b.text,a.editor.reportStatus(e.formatMessage(s.incrementalFind,d)),f=c.getSelection().start,(f=c.getModel().find({string:d,start:f,caseInsensitive:d.toLowerCase()===d}).next())?(a._incrementalFindSuccess=!0,a._incrementalFindIgnoreSelection=!0,c.moveSelection(f.start,f.end),a._incrementalFindIgnoreSelection=!1):(c.reportStatus(e.formatMessage(s.incrementalFindNotFound,d),"error"),a._incrementalFindSuccess=!1),b.text=
null},onSelection:function(){a._incrementalFindIgnoreSelection||a.toggleIncrementalFind()}};this._lastEditListener={onModelChanged:function(b){if(a.editor.isDirty())a._lastEditLocation=b.start+b.addedCharCount}};this.textView.addEventListener("ModelChanged",this._lastEditListener.onModelChanged);this.textView.setKeyBinding(new p.KeyBinding("k",!0),"findNext");this.textView.setAction("findNext",function(){if(this._searcher){var a=this.textView.getSelection();a.start<a.end?this._searcher.findNext(!0,
this.textView.getText(a.start,a.end)):this._searcher.findNext(!0);return!0}return!1}.bind(this),{name:s.findNext});this.textView.setKeyBinding(new p.KeyBinding("k",!0,!0),"findPrevious");this.textView.setAction("findPrevious",function(){if(this._searcher){var a=this.textView.getSelection();a.start<a.end?this._searcher.findNext(!1,this.textView.getText(a.start,a.end)):this._searcher.findNext(!1);return!0}return!1}.bind(this),{name:s.findPrevious});this.textView.setKeyBinding(new p.KeyBinding("j",!0),
"incrementalFind");this.textView.setAction("incrementalFind",function(){if(this._searcher&&this._searcher.visible())return!0;var a=this.editor;if(this._incrementalFindActive){var b=this._incrementalFindPrefix;if(b.length!==0){var c;c=0;this._incrementalFindSuccess&&(c=a.getSelection().start+1);(c=a.getModel().find({string:b,start:c,caseInsensitive:b.toLowerCase()===b}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,a.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=
!1,a.reportStatus(e.formatMessage(s.incrementalFind,b))):(a.reportStatus(e.formatMessage(s.incrementalFindNotFound,b),"error"),this._incrementalFindSuccess=!1)}}else a.setCaretOffset(a.getCaretOffset()),this.toggleIncrementalFind();return!0}.bind(this),{name:s.incrementalFindKey});this.textView.setAction("deletePrevious",function(){if(this._incrementalFindActive){var a=this.editor,b=this._incrementalFindPrefix,b=this._incrementalFindPrefix=b.substring(0,b.length-1);if(b.length===0)return this._incrementalFindIgnoreSelection=
this._incrementalFindSuccess=!0,a.setCaretOffset(a.getSelection().start),this._incrementalFindIgnoreSelection=!1,this.toggleIncrementalFind(),!0;a.reportStatus(e.formatMessage(s.incrementalFind,b));var c=a.getModel().find({string:b,start:a.getCaretOffset()-b.length-1,reverse:!0,caseInsensitive:b.toLowerCase()===b}).next();c?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,a.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=!1):a.reportStatus(e.formatMessage(s.incrementalFindNotFound,
b),"error");return!0}return!1}.bind(this));this.textView.setAction("tab",function(){if(this.textView.getOptions("readonly"))return!1;if(this.textView.getOptions("tabMode")){var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end);if(d!==e){var f=[];f.push("");for(var i=d;i<=e;i++)f.push(b.getLine(i,!0));var i=b.getLineStart(d),b=b.getLineEnd(e,!0),g=this.textView.getOptions("tabSize","expandTab"),g=g.expandTab?Array(g.tabSize+
1).join(" "):"\t";a.setText(f.join(g),i,b);a.setSelection(i===c.start?c.start:c.start+g.length,c.end+(e-d+1)*g.length);return!0}a=a.getKeyModes();for(c=0;c<a.length;c++)if(a[c].isActive())return a[c].tab();return!1}}.bind(this));this.textView.setAction("shiftTab",function(){if(this.textView.getOptions("readonly"))return!1;if(this.textView.getOptions("tabMode")){for(var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=this.textView.getOptions("tabSize"),
i=Array(f+1).join(" "),g=[],j=0,o=0,k=d;k<=e;k++){var h=b.getLine(k,!0);if(b.getLineStart(k)!==b.getLineEnd(k))if(h.indexOf("\t")===0)h=h.substring(1),j++;else if(h.indexOf(i)===0)h=h.substring(f),j+=f;else return!0;k===d&&(o=j);g.push(h)}d=b.getLineStart(d);f=b.getLineEnd(e,!0);b=b.getLineStart(e);a.setText(g.join(""),d,f);g=d===c.start?c.start:c.start-o;c=Math.max(g,c.end-j+(c.end===b+1&&c.start!==c.end?1:0));a.setSelection(g,c);return!0}}.bind(this),{name:s.unindentLines});this.textView.setKeyBinding(new p.KeyBinding(38,
!1,!1,!0),"moveLinesUp");this.textView.setAction("moveLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start);if(d===0)return!0;var e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount(),c=b.getLineStart(d-1),i=b.getLineStart(d),g=b.getLineEnd(e,!0),j=b.getText(i,g),k=0;e===f-1&&(e=b.getLineEnd(d-1),d=b.getLineEnd(d-1,!0),j+=b.getText(e,d),i=e,k=d-e);this.startUndo();a.setText("",i,g);a.setText(j,
c,c);a.setSelection(c,c+j.length-k);this.endUndo();return!0}.bind(this),{name:s.moveLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!1,!1,!0),"moveLinesDown");this.textView.setAction("moveLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount();if(e===f-1)return!0;var d=b.getLineStart(d),c=b.getLineEnd(e,!0),i=b.getLineEnd(e+1,
!0)-(c-d),g=0;e!==f-2?b=b.getText(d,c):(e=b.getLineEnd(e),b=b.getText(e,c)+b.getText(d,e),g+=c-e);this.startUndo();a.setText("",d,c);a.setText(b,i,i);a.setSelection(i+g,i+g+b.length);this.endUndo();return!0}.bind(this),{name:s.moveLinesDown});this.textView.setKeyBinding(new p.KeyBinding(38,!0,!1,!0),"copyLinesUp");this.textView.setAction("copyLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end>
c.start?c.end-1:c.end),d=b.getLineStart(d),e=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(d,e);c===f-1&&(e+=i=b.getLineDelimiter());a.setText(e,d,d);a.setSelection(d,d+e.length-i.length);return!0}.bind(this),{name:s.copyLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!0,!1,!0),"copyLinesDown");this.textView.setAction("copyLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end>
c.start?c.end-1:c.end),e=b.getLineStart(d),d=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(e,d);c===f-1&&(e=(i=b.getLineDelimiter())+e);a.setText(e,d,d);a.setSelection(d+i.length,d+e.length);return!0}.bind(this),{name:s.copyLinesDown});this.textView.setKeyBinding(new p.KeyBinding("d",!0,!1,!1),"deleteLines");this.textView.setAction("deleteLines",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getSelection(),c=a.getModel(),d=c.getLineAtOffset(b.start),b=c.getLineAtOffset(b.end>
b.start?b.end-1:b.end),d=c.getLineStart(d),c=c.getLineEnd(b,!0);a.setText("",d,c);return!0}.bind(this),{name:s.deleteLines});this.textView.setKeyBinding(new p.KeyBinding("l",!0),"gotoLine");this.textView.setAction("gotoLine",function(){var a=this.editor,b=a.getModel().getLineAtOffset(a.getCaretOffset());if(b=prompt(s.gotoLinePrompty,b+1))b=parseInt(b,10),a.onGotoLine(b-1,0);return!0}.bind(this),{name:s.gotoLine});this.textView.setKeyBinding(new p.KeyBinding(190,!0),"nextAnnotation");this.textView.setAction("nextAnnotation",
function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(d,c.getCharCount());b.hasNext();){var e=b.next();if(!(e.start<=d)&&!(e.type!==h.AnnotationType.ANNOTATION_ERROR&&e.type!==h.AnnotationType.ANNOTATION_WARNING&&e.type!==h.AnnotationType.ANNOTATION_TASK&&e.type!==h.AnnotationType.ANNOTATION_BOOKMARK)){var f=l.Tooltip.getTooltip(this.textView);if(!f){a.moveSelection(e.start);break}var i=c.getLineAtOffset(e.start),g=this.textView;
a.moveSelection(e.start,e.start,function(){setTimeout(function(){f.setTarget({getTooltipInfo:function(){var a=g.convert({x:g.getLocationAtOffset(e.start).x,y:g.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(g.getLineHeight(i)*1.33)}}},0)},0)});break}}return!0}.bind(this),{name:s.nextAnnotation});this.textView.setKeyBinding(new p.KeyBinding(188,!0),"previousAnnotation");this.textView.setAction("previousAnnotation",function(){var a=this.editor,
b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(0,d),e=null;b.hasNext();){var f=b.next();f.start>=d||f.type!==h.AnnotationType.ANNOTATION_ERROR&&f.type!==h.AnnotationType.ANNOTATION_WARNING&&f.type!==h.AnnotationType.ANNOTATION_TASK&&f.type!==h.AnnotationType.ANNOTATION_BOOKMARK||(e=f)}if(e){var i=c.getLineAtOffset(e.start),g=l.Tooltip.getTooltip(this.textView);if(!g)return a.moveSelection(e.start),!0;var j=this.textView;a.moveSelection(e.start,
e.start,function(){setTimeout(function(){g.setTarget({getTooltipInfo:function(){var a=j.convert({x:j.getLocationAtOffset(e.start).x,y:j.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(j.getLineHeight(i)*1.33)}}},0)},0)})}return!0}.bind(this),{name:s.prevAnnotation});this.textView.setKeyBinding(new p.KeyBinding("e",!0,!1,!0,!1),"expand");this.textView.setAction("expand",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var c=
a.getModel(),a=a.getCaretOffset(),d=c.getLineAtOffset(a),a=c.getLineStart(d),d=c.getLineEnd(d,!0);c.getBaseModel&&(a=c.mapOffset(a),d=c.mapOffset(d),c.getBaseModel());for(var e,c=b.getAnnotations(a,d);!e&&c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&(a.expanded||(e=a));e&&!e.expanded&&(e.expand(),b.modifyAnnotation(e));return!0}.bind(this),{name:s.expand});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!1,!0,!1),"collapse");this.textView.setAction("collapse",function(){var a=
this.editor,b=a.getAnnotationModel();if(!b)return!0;var c=a.getModel(),d=a.getCaretOffset(),e=c.getLineAtOffset(d),d=c.getLineStart(e),e=c.getLineEnd(e,!0);c.getBaseModel&&(d=c.mapOffset(d),e=c.mapOffset(e),c.getBaseModel());for(var f,c=b.getAnnotations(d,e);!f&&c.hasNext();)d=c.next(),d.type===h.AnnotationType.ANNOTATION_FOLDING&&(f=d);f&&f.expanded&&(a.setCaretOffset(f.start),f.collapse(),b.modifyAnnotation(f));return!0}.bind(this),{name:s.collapse});this.textView.setKeyBinding(new p.KeyBinding("e",
!0,!0,!0,!1),"expandAll");this.textView.setAction("expandAll",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&!a.expanded&&(a.expand(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.expandAll});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!0,!0,!1),"collapseAll");this.textView.setAction("collapseAll",
function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&a.expanded&&(a.collapse(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.collapseAll});this.textView.setKeyBinding(new p.KeyBinding("q",!e.isMac,!1,!1,e.isMac),"lastEdit");this.textView.setAction("lastEdit",function(){typeof this._lastEditLocation===
"number"&&this.editor.showSelection(this._lastEditLocation);return!0}.bind(this),{name:s.lastEdit})},toggleIncrementalFind:function(){(this._incrementalFindActive=!this._incrementalFindActive)?(this.editor.reportStatus(e.formatMessage(s.incrementalFind,this._incrementalFindPrefix)),this.textView.addEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.addEventListener("Selection",this._incrementalFindListener.onSelection)):(this._incrementalFindPrefix="",this.editor.reportStatus(""),
this.textView.removeEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.removeEventListener("Selection",this._incrementalFindListener.onSelection),this.textView.setCaretOffset(this.textView.getCaretOffset()))},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},cancel:function(){this.toggleIncrementalFind()},isActive:function(){return this._incrementalFindActive},isStatusActive:function(){return this._incrementalFindActive},
lineUp:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=b.getModel(),c=this._incrementalFindSuccess?b.getCaretOffset()-a.length-1:c.getCharCount()-1;(c=b.getModel().find({string:a,start:c,reverse:!0,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind,
a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},lineDown:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=0;this._incrementalFindSuccess&&(c=b.getSelection().start+1);(c=b.getModel().find({string:a,start:c,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end),
this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind,a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},enter:function(){return!1}};c.prototype={startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},init:function(){function a(b,c,d){var e=b.getLineAtOffset(c),f=b.getLineAtOffset(d),i,g,j,k,o,h;for(i=
e;i>=0;i--)if(g=b.getLine(i),j=i===e?c-b.getLineStart(e):g.length,k=g.lastIndexOf("/*",j),g=g.lastIndexOf("*/",j),g>k)break;else if(k!==-1){o=b.getLineStart(i)+k;break}for(i=f;i<b.getLineCount();i++)if(g=b.getLine(i),j=i===f?d-b.getLineStart(f):0,k=g.indexOf("/*",j),g=g.indexOf("*/",j),k!==-1&&k<g)break;else if(g!==-1){h=b.getLineStart(i)+g;break}return{commentStart:o,commentEnd:h}}this.textView.setAction("lineStart",function(){for(var a=this.editor,b=a.getModel(),c=a.getCaretOffset(),d=b.getLineAtOffset(c),
e=b.getLineStart(d),b=b.getLine(d),d=0;d<b.length;d++){var f=b.charCodeAt(d);if(!(f===32||f===9))break}d+=e;return c!==d?(a.setSelection(d,d),!0):!1}.bind(this));this.textView.setKeyBinding(new p.KeyBinding(191,!0),"toggleLineComment");this.textView.setAction("toggleLineComment",function(){if(this.textView.getOptions("readonly"))return!1;for(var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=!0,i=[],g,j,k=d;k<=e;k++)if(g=
b.getLine(k,!0),i.push(g),!f||(j=g.indexOf("//"))===-1)f=!1;else if(j!==0){var o;for(o=0;o<j;o++)if(f=g.charCodeAt(o),!(f===32||f===9))break;f=o===j}k=b.getLineStart(d);o=b.getLineEnd(e,!0);if(f){for(f=0;f<i.length;f++)g=i[f],j=g.indexOf("//"),i[f]=g.substring(0,j)+g.substring(j+2);i=i.join("");g=b.getLineStart(e);b=k===c.start?c.start:c.start-2;c=c.end-2*(e-d+1)+(c.end===g+1?2:0)}else i.splice(0,0,""),i=i.join("//"),b=k===c.start?c.start:c.start+2,c=c.end+2*(e-d+1);a.setText(i,k,o);a.setSelection(b,
c);return!0}.bind(this),{name:s.toggleLineComment});this.textView.setKeyBinding(new p.KeyBinding(191,!0,!e.isMac,!1,e.isMac),"addBlockComment");this.textView.setAction("addBlockComment",function(){if(this.textView.getOptions("readonly"))return!1;var b=this.editor,c=b.getModel(),d=b.getSelection(),e=RegExp("/\\*|\\*/","g"),f=a(c,d.start,d.end);if(f.commentStart!==void 0&&f.commentEnd!==void 0)return!0;c=c.getText(d.start,d.end);if(c.length===0)return!0;f=c.length;c=c.replace(e,"");e=c.length;b.setText("/*"+
c+"*/",d.start,d.end);b.setSelection(d.start+2,d.end+2+(e-f));return!0}.bind(this),{name:s.addBlockComment});this.textView.setKeyBinding(new p.KeyBinding(220,!0,!e.isMac,!1,e.isMac),"removeBlockComment");this.textView.setAction("removeBlockComment",function(){if(this.textView.getOptions("readonly"))return!1;var b=this.editor,c=b.getModel(),d=b.getSelection(),e=c.getText(d.start,d.end),f,i,g;for(g=0;g<e.length;g++)if(e.substring(g,g+2)==="/*"){f=d.start+g;break}for(;g<e.length;g++)if(e.substring(g,
g+2)==="*/"){i=d.start+g;break}if(f!==void 0&&i!==void 0)b.setText(c.getText(f+2,i),f,i+2),b.setSelection(f,i);else{e=a(c,d.start,d.end);if(e.commentStart===void 0||e.commentEnd===void 0)return!0;c=c.getText(e.commentStart+2,e.commentEnd);b.setText(c,e.commentStart,e.commentEnd+2);b.setSelection(d.start-2,d.end-2)}return!0}.bind(this),{name:s.removeBlockComment})},contentAssistProposalApplied:function(a){a=a.data.proposal;if(a.positions&&this.linkedMode){for(var b=[],c=0;c<a.positions.length;++c)b[c]=
{positions:[{offset:a.positions[c].offset,length:a.positions[c].length}]};this.linkedMode.enterLinkedMode({groups:b,escapePosition:a.escapePosition})}else a.escapePosition&&this.textView.setCaretOffset(a.escapePosition);return!0},cancel:function(){return!1},isActive:function(){return!0},isStatusActive:function(){return!1},lineUp:function(){return!1},lineDown:function(){return!1},enter:function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getSelection();if(b.start===b.end){for(var c=
a.getModel(),d=c.getLineAtOffset(b.start),e=c.getLine(d,!0),f=c.getLineStart(d),d=0,f=b.start-f,i;d<f&&((i=e.charCodeAt(d))===32||i===9);)d++;if(d>0){for(var g=e.substring(0,d),d=f;d<e.length&&((i=e.charCodeAt(d++))===32||i===9);)b.end++;a.setText(c.getLineDelimiter()+g,b.start,b.end);return!0}}return!1},tab:function(){return!1}};j.prototype={enterLinkedMode:function(a){if(!this.linkedModeActive){this.linkedModeActive=!0;this.linkedModePositions=[];for(var b=0;b<a.groups.length;++b){var c=a.groups[b];
this.linkedModePositions[b]={offset:c.positions[0].offset,length:c.positions[0].length}}this.linkedModeEscapePosition=a.escapePosition;this.linkedModeCurrentPositionIndex=0;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);this.textView.addEventListener("Verify",this.linkedModeListener.onVerify);this.textView.setKeyBinding(new p.KeyBinding(9),"nextLinkedModePosition");this.textView.setAction("nextLinkedModePosition",function(){this.linkedModeCurrentPositionIndex=
++this.linkedModeCurrentPositionIndex%this.linkedModePositions.length;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);return!0}.bind(this));this.textView.setKeyBinding(new p.KeyBinding(9,!1,!0),"previousLinkedModePosition");this.textView.setAction("previousLinkedModePosition",function(){this.linkedModeCurrentPositionIndex=this.linkedModeCurrentPositionIndex>0?this.linkedModeCurrentPositionIndex-1:this.linkedModePositions.length-1;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);
return!0}.bind(this));this.editor.reportStatus(s.linkedModeEntered,null,!0)}},isActive:function(){return this.linkedModeActive},isStatusActive:function(){return this.linkedModeActive},enter:function(){this.cancel();return!0},cancel:function(a){if(this.linkedModeActive)this.linkedModeActive=!1,this.textView.removeEventListener("Verify",this.linkedModeListener.onVerify),this.textView.setKeyBinding(new p.KeyBinding(9),"tab"),this.textView.setKeyBinding(new p.KeyBinding(9,!1,!0),"shiftTab"),a||this.textView.setCaretOffset(this.linkedModeEscapePosition,
!1),this.editor.reportStatus(s.linkedModeExited,null,!0)},lineUp:function(){this.cancel(!0);return!1},lineDown:function(){this.cancel(!0);return!1},selectTextForLinkedModePosition:function(a){this.textView.setSelection(a.offset,a.offset+a.length)}};return{UndoFactory:a,LineNumberRulerFactory:b,FoldingRulerFactory:d,AnnotationFactory:i,TextDNDFactory:g,TextActions:o,SourceCodeActions:c,LinkedMode:j}});
(function(s,r){typeof define==="function"&&define.amd?define("orion/Deferred",r):typeof exports==="object"?module.exports=r():(s.orion=s.orion||{},s.orion.Deferred=r())})(this,function(){function s(){for(var a;a=k.shift()||m.shift();)a();e=!1}function r(a,b){(b?m:k).push(a);e||(e=!0,b?setTimeout(s,0):s())}function p(a){return function(){a.apply(null,arguments)}}function f(){}function h(){var a=Error("Cancel");a.name="Cancel";return a}function l(){function a(){for(var a;a=e.shift();){var c=a.deferred,
g=d==="resolved"?"resolve":"reject";if(typeof a[g]==="function")try{var k=a[g](b);k&&typeof k.then==="function"?(c.cancel=k.cancel||f,k.then(p(c.resolve),p(c.reject),c.progress)):c.resolve(k)}catch(h){c.reject(h)}else c[g](b)}}var b,d,e=[],g=this;this.reject=function(f){d||(d="rejected",b=f,e.length&&r(a));return g.promise};this.resolve=function(f){d||(d="resolved",b=f,e.length&&r(a));return g.promise};this.progress=function(a){d||e.forEach(function(b){b.progress&&b.progress(a)});return g.promise};
this.cancel=function(){d||g.reject(h())};this.then=function(b,c,f){var b={resolve:b,reject:c,progress:f,deferred:new l},g=b.deferred,k=this.cancel.bind(this),h=function(){r(function(){(g.cancel===h?k:g.cancel)()},!0)};g.cancel=h;c=g.promise;c.cancel=function(){g.cancel()};e.push(b);d&&r(a,!0);return c};this.promise={then:this.then,cancel:this.cancel}}var k=[],m=[],e=!1;l.all=function(a,b){function d(a,b){c||(k[a]=b,--f===0&&j.resolve(k))}function e(a,f){if(!c){if(b)try{d(a,b(f));return}catch(i){f=
i}j.reject(f)}}var f=a.length,k=[],c=!1,j=new l;j.then(null,function(){c=!0;a.forEach(function(a){a.cancel&&a.cancel()})});f===0?j.resolve(k):a.forEach(function(a,b){a.then(d.bind(null,b),e.bind(null,b))});return j.promise};l.when=function(a,b,d,e){var f;if(!(a&&typeof a.then==="function"))f=new l,f.resolve(a),a=f.promise;return a.then(b,d,e)};return l});
define("orion/editor/contentAssist",["i18n!orion/editor/nls/messages","orion/editor/keyBinding","orion/editor/eventTarget","orion/Deferred","orion/editor/util"],function(s,r,p,f,h){var l,k,m;function e(a){this.textView=a;this.state=l;this.providers=[];var b=this;this.contentAssistListener={onModelChanging:function(a){b.isDeactivatingChange(a)?b.setState(l):b.state===k&&b.setState(m)},onScroll:function(){b.setState(l)},onSelection:function(){var a=b.state;if(a===k||a===m)b.computeProposals(),b.setState(m)}};
a.setKeyBinding(h.isMac?new r.KeyBinding(" ",!1,!1,!1,!0):new r.KeyBinding(" ",!0),"contentAssist");a.setAction("contentAssist",function(){b.activate();return!0},{name:s.contentAssist})}function a(a,b){this.contentAssist=a;this.widget=b;this.proposals=[];var d=this;this.contentAssist.addEventListener("ProposalsComputed",function(a){d.proposals=a.data.proposals;d.selectedIndex=d.proposals.length?0:-1})}function b(a,b){this.contentAssist=a;this.textView=this.contentAssist.getTextView();this.isShowing=
this.textViewListenerAdded=!1;var d=this.textView.getOptions("parent").ownerDocument;this.parentNode=typeof b==="string"?d.getElementById(b):b;if(!this.parentNode){this.parentNode=h.createElement(d,"div");this.parentNode.className="contentassist";var c=d.getElementsByTagName("body")[0];if(c)c.appendChild(this.parentNode);else throw Error("parentNode is required");}var e=this;this.textViewListener={onMouseDown:function(a){a.event.target.parentElement!==e.parentNode&&e.contentAssist.deactivate()}};
this.contentAssist.addEventListener("ProposalsComputed",function(a){e.setProposals(a.data.proposals);e.show();if(!e.textViewListenerAdded)e.textView.addEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!0});this.contentAssist.addEventListener("Deactivating",function(){e.setProposals([]);e.hide();if(e.textViewListenerAdded)e.textView.removeEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!1;e.textViewListenerAdded=!1});this.scrollListener=
function(){e.isShowing&&e.position()};d.addEventListener("scroll",this.scrollListener)}l=1;k=2;m=3;var d={selected:" selected",hr:"proposal-hr",emphasis:"proposal-emphasis",noemphasis:"proposal-noemphasis",dfault:"proposal-default"};e.prototype={apply:function(a){if(!a)return!1;var b=this.textView.getCaretOffset(),d={proposal:a,start:b,end:b};this.setState(l);this.textView.setText(a.proposal||a,b,b);this.dispatchEvent({type:"ProposalApplied",data:d});return!0},activate:function(){this.state===l&&
this.setState(k)},deactivate:function(){this.setState(l)},getTextView:function(){return this.textView},isActive:function(){return this.state===k||this.state===m},isDeactivatingChange:function(a){var b=a.removedCharCount>0&&a.addedCharCount===0,d=this.textView,d=a.start+1<=d.getModel().getCharCount()&&/^\s*$/.test(d.getText(a.start,a.start+1));return a.removedLineCount>0||a.addedLineCount>0||b&&d},setState:function(a){var b;a===k?b="Activating":a===l&&(b="Deactivating");b&&this.dispatchEvent({type:b});
this.state=a;this.onStateChange(a)},onStateChange:function(a){if(a===l){if(this.listenerAdded)this.textView.removeEventListener("ModelChanging",this.contentAssistListener.onModelChanging),this.textView.removeEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.removeEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!1}else if(a===k){if(!this.listenerAdded)this.textView.addEventListener("ModelChanging",this.contentAssistListener.onModelChanging),
this.textView.addEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.addEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!0;this.computeProposals()}},computeProposals:function(){var a=this;this._computeProposals(this.textView.getCaretOffset()).then(function(b){a.dispatchEvent({type:"ProposalsComputed",data:{proposals:b}})})},getPrefixStart:function(a){for(;a>0&&/[A-Za-z0-9_]/.test(this.textView.getText(a-1,a));)a--;return a},handleError:function(a){typeof console!==
"undefined"&&(console.log("Error retrieving content assist proposals"),console.log(a))},_computeProposals:function(a){var b=this.providers,d=this.textView,c=d.getModel(),e=d.getText(),k={line:c.getLine(c.getLineAtOffset(a)),prefix:d.getText(this.getPrefixStart(a),a),selection:d.getSelection()},h=this,b=b.map(function(b){var c=b.computeProposals||b.getProposals,d;try{typeof c==="function"&&(d=h.progress?h.progress.progress(c.apply(b,[e,a,k]),"Generating content assist proposal"):c.apply(b,[e,a,k]))}catch(g){h.handleError(g)}return f.when(d)});
return f.all(b,this.handleError).then(function(a){return a.reduce(function(a,b){return b instanceof Array?a.concat(b):a},[])})},setProviders:function(a){this.providers=a.slice(0)},setProgress:function(a){this.progress=a}};p.EventTarget.addMixin(e.prototype);a.prototype={cancel:function(){this.getContentAssist().deactivate()},getContentAssist:function(){return this.contentAssist},isActive:function(){return this.getContentAssist().isActive()},lineUp:function(){for(var a=this.selectedIndex===0?this.proposals.length-
1:this.selectedIndex-1;this.proposals[a].unselectable&&a>0;)a--;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},lineDown:function(){for(var a=this.selectedIndex===this.proposals.length-1?0:this.selectedIndex+1;this.proposals[a].unselectable&&a<this.proposals.length-1;)a++;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},enter:function(){return this.contentAssist.apply(this.proposals[this.selectedIndex]||null)},
tab:function(){return this.widget?(this.widget.createAccessible(this),this.widget.parentNode.focus(),!0):!1}};b.prototype={onClick:function(a){this.contentAssist.apply(this.getProposal(a.target));this.textView.focus()},createDiv:function(a,b,d,c){var e=d.ownerDocument,f=h.createElement(e,"div");f.id="contentoption"+c;f.setAttribute("role","option");a.style==="hr"?a=h.createElement(e,"hr"):(f.className=this.calculateClasses(a.style,b),a=e.createTextNode(this.getDisplayString(a)),b&&this.parentNode.setAttribute("aria-activedescendant",
f.id));f.appendChild(a,f);d.appendChild(f)},createAccessible:function(a){this._isAccessible||this.parentNode.addEventListener("keydown",function(b){b.preventDefault();if(b.keyCode===27)return a.cancel();else if(b.keyCode===38)return a.lineUp();else if(b.keyCode===40)return a.lineDown();else if(b.keyCode===13)return a.enter();return!1});this._isAccessible=!0},calculateClasses:function(a,b){var e=d[a];if(!e)e=d.dfault;return b?e+d.selected:e},getDisplayString:function(a){return typeof a==="string"?
a:a.description&&typeof a.description==="string"?a.description:a.proposal},getProposal:function(a){for(var b=0,d=this.parentNode.firstChild;d!==null;d=d.nextSibling){if(d===a)return this.proposals[b]||null;b++}return null},setSelectedIndex:function(a){this.selectedIndex=a;this.selectNode(this.parentNode.childNodes[this.selectedIndex])},selectNode:function(a){for(var b=this.parentNode.childNodes,e=0;e<b.length;e++){var c=b[e],f=c.className.indexOf(d.selected);if(f>=0)c.className=c.className.substring(0,
f)+c.className.substring(f+d.selected.length);c===a&&(c.className+=d.selected,this.parentNode.setAttribute("aria-activedescendant",c.id),c.focus(),c.offsetTop<this.parentNode.scrollTop?c.scrollIntoView(!0):c.offsetTop+c.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight&&c.scrollIntoView(!1))}},setProposals:function(a){this.proposals=a},show:function(){if(this.proposals.length===0)this.hide();else{this.parentNode.innerHTML="";for(var a=0;a<this.proposals.length;a++)this.createDiv(this.proposals[a],
a===0,this.parentNode,a);this.position();this.parentNode.onclick=this.onClick.bind(this);this.isShowing=!0}},hide:function(){this.parentNode.ownerDocument.activeElement===this.parentNode&&this.textView.focus();this.parentNode.style.display="none";this.parentNode.onclick=null;this.isShowing=!1},position:function(){var a=this.textView.getLocationAtOffset(this.textView.getCaretOffset());a.y+=this.textView.getLineHeight();this.textView.convert(a,"document","page");this.parentNode.style.position="fixed";
this.parentNode.style.left=a.x+"px";this.parentNode.style.top=a.y+"px";this.parentNode.style.display="block";this.parentNode.scrollTop=0;var b=this.parentNode.ownerDocument,d=b.documentElement.clientWidth;if(a.y+this.parentNode.offsetHeight>b.documentElement.clientHeight)this.parentNode.style.top=a.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px";if(a.x+this.parentNode.offsetWidth>d)this.parentNode.style.left=d-this.parentNode.offsetWidth+"px"}};return{ContentAssist:e,ContentAssistMode:a,
ContentAssistWidget:b}});
define("orion/editor/cssContentAssist",[],function(){function s(){}var r="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(",");s.prototype=
{computeProposals:function(p,f){var h;for(h=f;h&&/[A-Za-z\-]/.test(p.charAt(h-1));)h--;h=h?p.substring(h,f):"";for(var l=[],k=0;k<r.length;k++){var m=r[k];m.indexOf(h)===0&&l.push({proposal:m.substring(h.length),description:m})}return l}};return{CssContentAssistProvider:s}});
define("orion/editor/htmlContentAssist",[],function(){function s(){}s.prototype={leadingWhitespace:function(r,p){var f="";for(p-=1;p>0;){var h=r.charAt(p--);if(h==="\n"||h==="\r")break;f=/\s/.test(h)?h.concat(f):""}return f},computeProposals:function(r,p,f){function h(a){return a.substring(f.prefix.length)}var l=[];if(r.length===0)return l.push({proposal:'<!DOCTYPE html>\n<html lang="en">\n\t<head>\n\t\t<meta charset=utf-8>\n\t\t<title>My Document</title>\n\t</head>\n\t<body>\n\t\t<h1>A basic HTML document</h1>\n\t\t<p>\n\t\t\t\n\t\t</p>\n\t</body>\n</html>',
description:"Simple HTML document",escapePosition:p+152}),l;var k=f.prefix;if(r.charAt(p-k.length-1)!=="<")return l;for(var m,e,a="abbr,b,button,canvas,cite,command,dd,del,dfn,dt,em,embed,font,h1,h2,h3,h4,h5,h6,i,ins,kbd,label,li,mark,meter,object,option,output,progress,q,rp,rt,samp,small,strong,sub,sup,td,time,title,tt,u,var".split(","),b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+"></"+m+">",m=p+m.length-k.length+1,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="address,article,aside,audio,bdo,blockquote,body,caption,code,colgroup,datalist,details,div,fieldset,figure,footer,form,head,header,hgroup,iframe,legend,map,menu,nav,noframes,noscript,optgroup,p,pre,ruby,script,section,select,span,style,tbody,textarea,tfoot,th,thead,tr,video".split(",");
r=this.leadingWhitespace(r,p);for(b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+">\n"+r+"\t\n"+r+"</"+m+">",m=p+m.length-k.length+r.length+3,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="area,base,br,col,hr,input,link,meta,param,keygen,source".split(",");for(b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+"/>",m=p+m.length-k.length+2,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));"img".indexOf(k)===0&&(e='img src="" alt="Image"/>',l.push({proposal:h(e),description:"<"+
e,escapePosition:p+9-k.length}));k==="a"&&l.push({proposal:h('a href=""></a>'),description:"<a></a> - HTML anchor element",escapePosition:p+7});"ul".indexOf(k)===0&&(e="<ul> - unordered list",m=p-k.length+r.length+9,l.push({proposal:h("ul>\n"+r+"\t<li></li>\n"+r+"</ul>"),description:e,escapePosition:m}));"ol".indexOf(k)===0&&(e="<ol> - ordered list",m=p-k.length+r.length+9,l.push({proposal:h("ol>\n"+r+"\t<li></li>\n"+r+"</ol>"),description:e,escapePosition:m}));"dl".indexOf(k)===0&&(e="<dl> - definition list",
m=p-k.length+r.length+9,l.push({proposal:h("dl>\n"+r+"\t<dt></dt>\n"+r+"\t<dd></dd>\n"+r+"</dl>"),description:e,escapePosition:m}));"table".indexOf(k)===0&&(e="<table> - basic HTML table",m=p-k.length+r.length*2+19,l.push({proposal:h("table>\n"+r+"\t<tr>\n"+r+"\t\t<td></td>\n"+r+"\t</tr>\n"+r+"</table>"),description:e,escapePosition:m}));return l}};return{HTMLContentAssistProvider:s}});
define("orion/editor/jsTemplateContentAssist",[],function(){function s(f,l,k){var m=k-f.length,e=[],a="";for(k-=1;k>0;){var b=l.charAt(k--);if(b==="\n"||b==="\r")break;a=/\s/.test(b)?b.concat(a):""}l=a;"if".indexOf(f)===0&&(k="if - if statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="if - if else statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+
l+"\t\n"+l+"} else {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"for".indexOf(f)===0&&(k="for - iterate over array",a=[{offset:m+9,length:1},{offset:m+20,length:5}],b=m+l.length+42,e.push({proposal:("for (var i = 0; i < array.length; i++) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="for..in - iterate over properties of an object",a=[{offset:m+9,length:8},{offset:m+21,length:6}],b=m+2*l.length+73,e.push({proposal:("for (var property in object) {\n"+
l+"\tif (object.hasOwnProperty(property)) {\n"+l+"\t\t\n"+l+"\t}\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"while".indexOf(f)===0&&(k="while - while loop with condition",a=[{offset:m+7,length:9}],b=m+l.length+21,e.push({proposal:("while (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"do".indexOf(f)===0&&(k="do - do while loop with condition",a=[{offset:m+16,length:9}],b=m+l.length+6,e.push({proposal:("do {\n"+l+
"\t\n"+l+"} while (condition);").substring(f.length),description:k,positions:a,escapePosition:b}));"switch".indexOf(f)===0&&(k="switch - switch case statement",a=[{offset:m+8,length:10},{offset:m+28,length:6}],b=m+2*l.length+38,e.push({proposal:("switch (expression) {\n"+l+"\tcase value1:\n"+l+"\t\t\n"+l+"\t\tbreak;\n"+l+"\tdefault:\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"try".indexOf(f)===0&&(k="try - try..catch statement",b=m+l.length+7,e.push({proposal:("try {\n"+
l+"\t\n"+l+"} catch (err) {\n"+l+"}").substring(f.length),description:k,escapePosition:b}),k="try - try..catch statement with finally block",b=m+l.length+7,e.push({proposal:("try {\n"+l+"\t\n"+l+"} catch (err) {\n"+l+"} finally {\n"+l+"}").substring(f.length),description:k,escapePosition:b}));return e}function r(f){for(var l="break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with".split(","),k=[],
m=0;m<l.length;m++)l[m].indexOf(f)===0&&k.push({proposal:l[m].substring(f.length),description:l[m]});return k}function p(){}var f={":":":","!":"!","@":"@","#":"#",$:"$","^":"^","&":"&","*":"*",".":".","?":"?","<":"<",">":">"};p.prototype={computeProposals:function(h,l,k){for(var k=k.prefix,m=[],e=l-k.length-1,a="";e>=0;)if(a=h[e],a==="\n"||a==="\r")break;else if(/\s/.test(a))e--;else break;if(f[a])return m;m=m.concat(s(k,h,l));return m=m.concat(r(k,h,l))}};return{JSTemplateContentAssistProvider:p}});
define("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(s,r){function p(f){return f.getProperty("objectClass").indexOf(h)!==-1&&f.getProperty("type")==="highlighter"}function f(f,h,e){this.initialize(f,h,e);this.lineStyles=[]}var h="orion.edit.highlighter",l=h+" service must be an event emitter";r.AnnotationType.registerType("orion.annotation.highlightError",{title:s.syntaxError,html:"<div class='annotationHTML error'></div>",rangeStyle:{styleClass:"annotationRange error"}});
f.prototype={initialize:function(f,l,e){this.textView=f;this.serviceRegistry=l;this.annotationModel=e;this.services=[];var a=this;this.listener={onModelChanging:function(b){a.onModelChanging(b)},onModelChanged:function(b){a.onModelChanged(b)},onDestroy:function(b){a.onDestroy(b)},onLineStyle:function(b){a.onLineStyle(b)},onStyleReady:function(b){a.onStyleReady(b)},onServiceAdded:function(b){a.onServiceAdded(b.serviceReference,a.serviceRegistry.getService(b.serviceReference))},onServiceRemoved:function(b){a.onServiceRemoved(b.serviceReference,
a.serviceRegistry.getService(b.serviceReference))}};f.addEventListener("ModelChanging",this.listener.onModelChanging);f.addEventListener("ModelChanged",this.listener.onModelChanged);f.addEventListener("Destroy",this.listener.onDestroy);f.addEventListener("LineStyle",this.listener.onLineStyle);l.addEventListener("registered",this.listener.onServiceAdded);l.addEventListener("unregistering",this.listener.onServiceRemoved);f=l.getServiceReferences(h);for(e=0;e<f.length;e++){var b=f[e];p(b)&&this.addServiceListener(l.getService(b))}},
onDestroy:function(){this.destroy()},destroy:function(){if(this.textView)this.textView.removeEventListener("ModelChanging",this.listener.onModelChanging),this.textView.removeEventListener("ModelChanged",this.listener.onModelChanged),this.textView.removeEventListener("Destroy",this.listener.onDestroy),this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView=null;if(this.services){for(var f=0;f<this.services.length;f++)this.removeServiceListener(this.services[f]);this.services=
null}if(this.serviceRegistry)this.serviceRegistry.removeEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.removeEventListener("unregistering",this.listener.onServiceRemoved),this.serviceRegistry=null;this.lineStyles=this.listener=null},onModelChanging:function(f){this.startLine=this.textView.getModel().getLineAtOffset(f.start)},onModelChanged:function(f){var h=this.startLine;(f.addedLineCount||f.removedLineCount)&&Array.prototype.splice.apply(this.lineStyles,[h,f.removedLineCount].concat(this._getEmptyStyle(f.addedLineCount)))},
onStyleReady:function(f){var h=f.lineStyles||f.style,f=Number.MAX_VALUE,e=-1,a=this.textView.getModel(),b;for(b in h)h.hasOwnProperty(b)&&(this.lineStyles[b]=h[b],f=Math.min(f,b),e=Math.max(e,b));f=Math.max(f,0);e=Math.min(e,a.getLineCount());if(h=this.annotationModel){for(var d=h.getAnnotations(a.getLineStart(f),a.getLineEnd(e)),i=[];d.hasNext();){var g=d.next();g.type==="orion.annotation.highlightError"&&i.push(g)}d=[];for(g=f;g<=e;g++){b=g;var l=this.lineStyles[b],l=l&&l.errors;b=a.getLineStart(b);
if(l)for(var c=0;c<l.length;c++){var j=l[c];d.push(r.AnnotationType.createAnnotation("orion.annotation.highlightError",j.start+b,j.end+b))}}h.replaceAnnotations(i,d)}this.textView.redrawLines(f,e+1)},onLineStyle:function(f){function h(a,b){for(var d=a.length,e=[],f=0;f<d;f++){var k=a[f];e.push({start:k.start+b,end:k.end+b,style:k.style})}return e}var e=this.lineStyles[f.lineIndex];if(e)if(e.ranges)f.ranges=h(e.ranges,f.lineStart);else if(e.style)f.style=e.style},_getEmptyStyle:function(f){for(var h=
[],e=0;e<f;e++)h.push(null);return h},setContentType:function(f){this.contentType=f;if(this.services)for(f=0;f<this.services.length;f++){var h=this.services[f];if(h.setContentType){var e=this.serviceRegistry.getService("orion.page.progress");e?e.progress(h.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):h.setContentType(this.contentType)}}},onServiceAdded:function(f,h){p(f)&&this.addServiceListener(h)},onServiceRemoved:function(f,
h){this.services.indexOf(h)!==-1&&this.removeServiceListener(h)},addServiceListener:function(f){if(typeof f.addEventListener==="function"){if(f.addEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),this.services.push(f),f.setContentType&&this.contentType){var h=this.serviceRegistry.getService("orion.page.progress");h?h.progress(f.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):f.setContentType(this.contentType)}}else typeof console!==
"undefined"&&console.log(Error(l))},removeServiceListener:function(f){typeof f.removeEventListener==="function"?(f.removeEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),f=this.services.indexOf(f),f!==-1&&this.services.splice(f,1)):typeof console!=="undefined"&&console.log(Error(l))}};return f});
define("orion/editor/mirror",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/annotations"],function(s,r,p){function f(e){this.string=e;this.tokenStart=this.pos=0}function h(){this._modes={};this.mimeModes={};this.options={};this.StringStream=f}function l(e){var a=[],b;for(b in e)Object.prototype.hasOwnProperty.call(e,b)&&a.push(b);return a}function k(e,a,b){b=b||{};this.model=e;this.codeMirror=a;this.isWhitespaceVisible=typeof b.whitespacesVisible==="undefined"?!1:b.whitespacesVisible;
this.mode=null;this.isModeLoaded=!1;this.lines=[];this.dirtyLines=[];this.startLine=Number.MAX_VALUE;this.endLine=-1;this.timer=null;this.initialize(e)}function m(e,a,b){this.init(e,a,b)}f.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos===0},peek:function(){return this.string[this.pos]},next:function(){return this.string[this.pos++]},eat:function(e){var a=this.string[this.pos];return typeof a==="string"&&(a===e||e.test&&e.test(a)||typeof e==="function"&&
e(a))?this.string[this.pos++]:void 0},eatWhile:function(e){for(var a=!1;this.eat(e)!==void 0;)a=!0;return a},eatSpace:function(){return this.eatWhile(/\s/)},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){e=this.string.indexOf(e,this.pos);return e!==-1?(this.pos=e,!0):!1},match:function(e,a,b){a=a===!0||typeof a==="undefined";if(typeof e==="string"){var d=b?this.string.toLowerCase():this.string,e=b?e.toLowerCase():e,b=d.indexOf(e,this.pos);if(b!==-1&&a)this.pos=b+e.length;return b!==
-1}else return(e=this.string.substring(this.pos).match(e))&&a&&typeof e[0]==="string"&&(this.pos+=e.index+e[0].length),e},backUp:function(e){this.pos-=e},column:function(){for(var e=0,a=0;a<this.tokenStart;)e+=this.string[a++]==="\t"?4:1;return e},indentation:function(){for(var e=this.string.search(/\S/),a=0,b=0;b<e;)a+=this.string[b++]==="\t"?4:1;return a},current:function(){return this.string.substring(this.tokenStart,this.pos)},advance:function(){this.tokenStart=this.pos}};h.prototype={options:{},
setOption:function(e,a){this.options[e]=a},getOption:function(e){return this.options[e]},copyState:function(e,a){if(typeof e.copyState==="function")return e.copyState(a);var b={},d;for(d in a){var f=a[d];b[d]=f instanceof Array?f.slice():f}return b},defineMode:function(e,a){this._modes[e]=a},defineMIME:function(e,a){this.mimeModes[e]=a},getMode:function(e,a){var b={},d;typeof a==="string"&&this.mimeModes[a]&&(a=this.mimeModes[a]);typeof a==="object"&&(b=a,d=this._modes[a.name]);d=d||this._modes[a];
if(typeof d!=="function")throw"Mode not found "+a;return d(e,b)},listModes:function(){return l(this._modes)},listMIMEs:function(){return l(this.mimeModes)},_getModeName:function(e){e=this.mimeModes[e];if(typeof e==="object")e=e.name;return e}};k.prototype={initialize:function(){var e=this;this.listener={onModelChanging:function(a){e._onModelChanging(a)},onModelChanged:function(a){e._onModelChanged(a)},onDestroy:function(a){e._onDestroy(a)}};this.model.addEventListener("Changing",this.listener.onModelChanging);
this.model.addEventListener("Changed",this.listener.onModelChanged);this.model.addEventListener("Destroy",this.listener.onDestroy)},destroy:function(){this.model&&(this.model.removeEventListener("Changing",this.listener.onModelChanging),this.model.removeEventListener("Changed",this.listener.onModelChanged),this.model.removeEventListener("Destroy",this.listener.onDestroy));this.dirtyLines=this.lines=this.mode=this.codeMirror=this.model=null;clearTimeout(this.timer);this.timer=null},_onModelChanging:function(e){this.startLine=
this.model.getLineAtOffset(e.start)},_onModelChanged:function(e){this._dbgEvent(e);var a=this.startLine;(e.removedLineCount||e.addedLineCount)&&Array.prototype.splice.apply(this.lines,[a+1,e.removedLineCount].concat(this._newLines(e.addedLineCount)));this.mode&&(e=Math.max(e.addedLineCount,e.removedLineCount),e=a+Math.min(e,500),this.highlight(a,e),this.highlightLater(e+1))},_onDestroy:function(){this.destroy()},setViewportIndex:function(e){this.viewportIndex=e},_dbgEvent:function(){},_dbgStyle:function(){},
_newLines:function(e){for(var a=[],b=0;b<e;b++)a.push({style:null,eolState:null});return a},setMode:function(e,a){if(e)this.mode=this.codeMirror.getMode(this.codeMirror.options,e),this.lines=this._newLines(this.model.getLineCount()),a&&this.highlight()},highlight:function(e,a,b){if(this.mode){for(var d=this.model.getLineCount(),e=typeof e==="undefined"?0:e,a=typeof a==="undefined"?d-1:Math.min(a,d-1),d=this.mode,f=this.getState(e),g=e;g<=a;g++){var h=this.lines[g];this.highlightLine(g,h,f);h.eolState=
this.codeMirror.copyState(d,f)}this._expandRange(e,a);if(!b)this.onHighlightDone()}},highlightLater:function(e){this.dirtyLines.push(e);var a=this;this.timer=setTimeout(function(){a._highlightJob()},50)},_highlightJob:function(){for(var e=+new Date+30,a=this.mode.compareStates,b=this.model.getLineCount();this.dirtyLines.length;){var d=this.viewportIndex,f=this.lines[d],d=f&&!f.eolState?d:this.dirtyLines.pop();if(d>=b)break;this._expandRange(d,d);for(var f=this._getResumeLineIndex(d),d=f+1,f=(f=f>=
0&&this.lines[f].eolState)?this.codeMirror.copyState(this.mode,f):this.mode.startState(),g=0,h=d;h<b;h++){var c=this.lines[h],j=c.eolState,k=this.highlightLine(h,c,f);c.eolState=this.codeMirror.copyState(this.mode,f);k&&this._expandRange(d,h+1);var c=a&&j&&a(j,c.eolState),l=!a&&!k&&g++>3;if(c||l)break;else if(!j||k)g=0;j=h<b||this.dirtyLines.length;if(+new Date>e&&j){this.highlightLater(h+1);this.onHighlightDone();return}}}this.onHighlightDone()},onHighlightDone:function(){this.startLine!==Number.MAX_VALUE&&
this.endLine!==-1&&this.dispatchEvent({type:"Highlight",start:this.startLine,end:this.endLine});this.startLine=Number.MAX_VALUE;this.endLine=-1},_getResumeLineIndex:function(e){for(var a=this.lines,b=e-1;b>=0;b--)if(a[b].eolState||e-b>40)return b;return-1},getState:function(e){var a=this.mode,b=this.lines,d,f;for(d=e-1;d>=0;d--)if(f=b[d],f.eolState||e-d>40)break;var g=d>=0&&b[d].eolState;if(g){g=this.codeMirror.copyState(a,g);for(d=Math.max(0,d);d<e-1;d++)f=b[d],this.highlightLine(d,f,g),f.eolState=
this.codeMirror.copyState(a,g);return g}else return a.startState()},highlightLine:function(e,a,b){if(this.mode){var d=this.model;d.getLineStart(e)===d.getLineEnd(e)&&this.mode.blankLine&&this.mode.blankLine(b);for(var i=a.style||[],e=d.getLine(e),e=new f(e),d=!a.style,g=[],h=0;!e.eol();h++){var c=this.mode.token(e,b)||null,j=e.current();this._whitespaceStyle(c,j,e.tokenStart);c=[e.tokenStart,e.pos,c];j=i[h];g.push(c);d=d||!j||j[0]!==c[0]||j[1]!==c[1]||j[2]!==c[2];e.advance()}if(d=d||g.length!==i.length)a.style=
g.length?g:null;return d}},_whitespaceStyle:function(e,a,b){if(!e&&this.isWhitespaceVisible&&/\s+/.test(a)){for(var e=[],d,f,g=0;g<a.length;g++){var h=a[g];h!==f&&(f&&e.push([b+d,b+g,f==="\t"?"token_tab":"token_space"]),d=g,f=h)}e.push([b+d,b+g,f==="\t"?"token_tab":"token_space"]);return e}return null},_expandRange:function(e,a){this.startLine=Math.min(this.startLine,e);this.endLine=Math.max(this.endLine,a)},toStyleRangesAndErrors:function(e,a){var b=e.style;if(!b)return null;for(var d=[],f=[],g=
typeof a==="undefined"?0:this.model.getLineStart(a),h=0;h<b.length;h++){var c=b[h],j=!c[2]?null:c[2]==="token_tab"||c[2]==="token_space"?c[2]:"cm-"+c[2];j&&(c={start:g+c[0],end:g+c[1],style:{styleClass:j}},d.push(c),j==="cm-error"&&f.push(c))}return[d,f]},getLineStyle:function(e){return this.lines[e]},getLineStyles:function(){return this.lines}};r.EventTarget.addMixin(k.prototype);p.AnnotationType.registerType("orion.annotation.highlightError",{title:s.syntaxError,html:"<div class='annotationHTML error'></div>",
rangeStyle:{styleClass:"annotationRange error"}});m.prototype={init:function(e,a,b){this.textView=e;this.annotationModel=b;this.modeApplier=new k(e.getModel(),a);var d=this;this.listener={onLineStyle:function(a){d.onLineStyle(a)},onDestroy:function(a){d.onDestroy(a)},onHighlight:function(a){d.onHighlight(a)}};e.addEventListener("LineStyle",this.listener.onLineStyle);e.addEventListener("Destroy",this.listener.onDestroy);this.modeApplier.addEventListener("Highlight",this.listener.onHighlight)},destroy:function(){this.modeApplier&&
(this.modeApplier.removeEventListener("Highlight",this.listener.onHighlight),this.modeApplier.destroy());this.textView&&(this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView.removeEventListener("Destroy",this.listener.onDestroy));this.listener=this.modeApplier=this.annotationModel=this.textView=null},setMode:function(e){this.modeApplier.setMode(e)},onLineStyle:function(e){var a=e.lineIndex,b=this.modeApplier,d=b.getLineStyle(a);if(!d||!d.eolState){var f=this.textView.getModel().getLineCount();
b.highlight(a,Math.min(a+20,f-1),!0);d=b.getLineStyle(a)}f=this.textView.getModel();if(d){var g=b.toStyleRangesAndErrors(d,a);if(g&&(e.ranges=g[0],e=this.annotationModel)){b=[];d=[];if(g=g[1])for(var h=0;h<g.length;h++){var c=g[h];c.style.styleClass==="cm-error"&&d.push(p.AnnotationType.createAnnotation("orion.annotation.highlightError",c.start,c.end))}for(a=e.getAnnotations(f.getLineStart(a),f.getLineEnd(a));a.hasNext();)f=a.next(),f.type==="orion.annotation.highlightError"&&b.push(f);e.replaceAnnotations(b,
d)}}},onHighlight:function(e){this.textView.redrawLines(e.start,e.end)},onDestroy:function(){this.destroy()}};return{Mirror:h,ModeApplier:k,CodeMirrorStyler:m}});
define("orion/editor/textMateStyler",["orion/editor/regex"],function(s){function r(e,a){var b=a.textView._parent.ownerDocument,d=a._stylesheet=a.util.createElement(b,"style");d.appendChild(b.createTextNode(a._styleSheet(e,"",a.util)));(b.getElementsByTagName("head")[0]||b.documentElement).appendChild(d);a.textView.update(!0)}function p(e,a){var b,d=this;e.getPreferences("/settings",2).then(function(e){if(e.get("JavaScript Editor")!==void 0&&(b=JSON.parse(e.get("JavaScript Editor")))){if(d._stylesheet)d._stylesheet.parentNode.removeChild(d._stylesheet),
d._stylesheet=null;d._update(b,d,a)}})}function f(e,a){for(var b=[],d=0;d<e.length;d++)b[e[d].element]=e[d].value;d=[];d.push("");var f=b.fontFamily,f=f==="sans serif"?'"Menlo", "Consolas", "Vera Mono", "monospace"':"monospace";d.push(a+" .textviewContainer {");d.push("\u0008ackground-color:"+b.background+";");d.push("\tfont-family: "+f+";");d.push("\tfont-size: "+b.fontSize+";");d.push("\tmin-width: 50px;");d.push("\tmin-height: 50px;");d.push("\tcolor: "+b.text+";");d.push("}");d.push(a+" {");d.push("\tfont-family: "+
f+";");d.push("\tfont-size: "+b.fontSize+";");d.push("\tcolor: "+b.text+";");d.push("}");d.push(a+" .textview {");d.push("\tbackground-color: "+b.background+";");d.push("}");d.push(a+".ruler.annotations{");d.push("\tbackground-color: white;");d.push("}");d.push(a+" .ruler {");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines {");d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines.even {");
d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines.odd {");d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .annotationLine.currentLine {");d.push("\tbackground-color: "+b.currentLine+";");d.push("}");d.push(a+" .entity-name-tag {");d.push("color: "+b.keyword+";");d.push("}");return d.join("\n")}function h(e){var a;if(e instanceof Array){a=Array(e.length);for(var b=
0;b<e.length;b++)a[b]=h(e[b])}else for(b in a={},e)if(Object.prototype.hasOwnProperty.call(e,b)){var d=e[b];a[b]=typeof d==="object"&&d!==null?h(d):d}return a}function l(e,a,b,d,i){this.initialize(e,d);this.grammar=h(a);this.externalGrammars=b?h(b):[];this._styles={};this._tree=null;this._allGrammars={};this.preprocess(this.grammar);this._updateStylesheet=p;this._update=r;this._styleSheet=f;this.util=i}var k,m={unsupported:[{regex:/\(\?[ims\-]:/,func:function(){return"option on/off for subexp"}},
{regex:/\(\?<([=!])/,func:function(e){return e[1]==="="?"lookbehind":"negative lookbehind"}},{regex:/\(\?>/,func:function(){return"atomic group"}}],toRegExp:function(e){function a(a,b){throw Error('Unsupported regex feature "'+a+'": "'+b[0]+'" at index: '+b.index+" in "+b.input);}var b="",d,e=m.processGlobalFlag("x",e,function(a){for(var b="",c=!1,d=a.length,e=0;e<d;){var f=a.charAt(e);if(!c&&f==="#")for(;e<d&&f!=="\r"&&f!=="\n";)f=a.charAt(++e);else if(!c&&/\s/.test(f))for(;e<d&&/\s/.test(f);)f=
a.charAt(++e);else f==="\\"?(b+=f,/\s/.test(a.charAt(e+1))||(b+=a.charAt(e+1),e+=1)):(f==="["?c=!0:f==="]"&&(c=!1),b+=f),e+=1}return b}),e=m.processGlobalFlag("i",e,function(a){b+="i";return a});for(d=0;d<this.unsupported.length;d++){var f;(f=this.unsupported[d].regex.exec(e))&&a(this.unsupported[d].func(f),f)}return RegExp(e,b)},processGlobalFlag:function(e,a,b){function d(a,b){for(var c=0,d=a.length,e=-1,f=b;f<d&&e===-1;f++)switch(a.charAt(f)){case "\\":f++;break;case "(":c++;break;case ")":c--,
c===0&&(e=f)}return e}var f="(?"+e+")",e="(?"+e+":";if(a.substring(0,f.length)===f)return b(a.substring(f.length));else if(a.substring(0,e.length)===e){f=d(a,0);if(f<a.length-1)throw Error("Only a "+e+") group that encloses the entire regex is supported in: "+a);return b(a.substring(e.length,f))}return a},hasBackReference:function(e){return/\\\d+/.test(e.source)},getSubstitutedRegex:function(e,a,b){for(var b=typeof b==="undefined"?!0:!1,e=e.source.split(/(\\\d+)/g),d=[],f=0;f<e.length;f++){var g=
e[f],h=/\\(\d+)/.exec(g);h?(g=a[h[1]]||"",d.push(b?s.escape(g):g)):d.push(g)}return RegExp(d.join(""))},groupify:function(e,a){for(var b=e.source,d=b.length,f=[],g=0,h=[],c=1,j=1,k=[],l={},m={},p=0;p<d;p++){var n=f[f.length-1],r=b.charAt(p);switch(r){case "(":if(n===4)f.pop(),k.push(")"),h[h.length-1].end=p;var s=p+2<d?b.charAt(p+1)+""+b.charAt(p+2):null;if(s==="?:"||s==="?="||s==="?!"){var t;s==="?:"?t=1:(t=3,g++);f.push(t);h.push({start:p,end:-1,type:t});k.push(r);k.push(s);p+=s.length}else f.push(2),
h.push({start:p,end:-1,type:2,oldNum:c,num:j}),k.push(r),g===0&&(m[j]=null),l[c]=j,c++,j++;break;case ")":n=f.pop();n===3&&g--;h[h.length-1].end=p;k.push(r);break;case "*":case "+":case "?":case "}":var D=r,v=b.charAt(p-1),s=p-1;if(r==="}"){for(t=p-1;b.charAt(t)!=="{"&&t>=0;t--);v=b.charAt(t-1);s=t-1;D=b.substring(t,p+1)}t=h[h.length-1];if(v===")"&&(t.type===2||t.type===4)){k.splice(t.start,0,"(");k.push(D);k.push(")");r={start:t.start,end:k.length-1,type:4,num:t.num};for(v=0;v<h.length;v++)if(n=
h[v],(n.type===2||n.type===4)&&n.start>=t.start&&n.end<=s)if(n.start+=1,n.end+=1,n.num+=1,n.type===2)l[n.oldNum]=n.num;h.push(r);j++;break}default:r!=="|"&&n!==2&&n!==4&&g===0&&(f.push(4),h.push({start:p,end:-1,type:4,num:j}),k.push("("),m[j]=null,j++),k.push(r),r==="\\"&&(r=b.charAt(p+1),k.push(r),p+=1)}}for(;f.length;)f.pop(),k.push(")");var b=RegExp(k.join("")),d={},a=a||l,z;for(z in a)a.hasOwnProperty(z)&&(d[z]="\\"+a[z]);b=this.getSubstitutedRegex(b,d,!1);return[b,l,m]},complexCaptures:function(e){if(!e)return!1;
for(var a in e)if(e.hasOwnProperty(a)&&a!=="0")return!0;return!1}};l.prototype={initialize:function(e,a,b){this.textView=e;this.textView.stylerOptions=this;var d=this;this.textView&&a&&a.startup().then(function(a){k=a.preferences;d.preferences=k;d._updateStylesheet(k,b);d.storageKey=k.listenForChangedSettings(d._listener.onStorage)});this._listener={onModelChanged:function(a){d.onModelChanged(a)},onDestroy:function(a){d.onDestroy(a)},onLineStyle:function(a){d.onLineStyle(a)},onStorage:function(a){d.onStorage(a)}};
e.addEventListener("ModelChanged",this._listener.onModelChanged);e.addEventListener("Destroy",this._listener.onDestroy);e.addEventListener("LineStyle",this._listener.onLineStyle);e.redrawLines()},onDestroy:function(){this.destroy()},onStorage:function(e){e.key===this.storageKey&&this._updateStylesheet(this.preferences)},destroy:function(){if(this.textView)this.textView.removeEventListener("ModelChanged",this._listener.onModelChanged),this.textView.removeEventListener("Destroy",this._listener.onDestroy),
this.textView.removeEventListener("LineStyle",this._listener.onLineStyle),this.textView=null;this._listener=this._tree=this._styles=this.grammar=null},preprocess:function(e){for(e=[e];e.length!==0;){var a=e.pop();if(!a._resolvedRule||!a._typedRule)if(a._resolvedRule=this._resolve(a),a._typedRule=this._createTypedRule(a),this.addStyles(a.name),this.addStyles(a.contentName),this.addStylesForCaptures(a.captures),this.addStylesForCaptures(a.beginCaptures),this.addStylesForCaptures(a.endCaptures),a._resolvedRule!==
a&&e.push(a._resolvedRule),a.patterns)for(var b=0;b<a.patterns.length;b++)e.push(a.patterns[b])}},addStyles:function(e){if(e&&!this._styles[e]){this._styles[e]=[];for(var a=e.split("."),b=0;b<a.length;b++)this._styles[e].push(a.slice(0,b+1).join("-"))}},addStylesForCaptures:function(e){for(var a in e)e.hasOwnProperty(a)&&this.addStyles(e[a].name)},ContainerRule:function(){function e(a){this.rule=a;this.subrules=a.patterns}e.prototype.valueOf=function(){return"aa"};return e}(),BeginEndRule:function(){function e(a){this.rule=
a;this.beginRegex=m.toRegExp(a.begin);this.endRegex=m.toRegExp(a.end);this.subrules=a.patterns||[];this.endRegexHasBackRef=m.hasBackReference(this.endRegex);var b=m.complexCaptures(a.captures),a=m.complexCaptures(a.beginCaptures)||m.complexCaptures(a.endCaptures);if(this.isComplex=b||a)b=m.groupify(this.beginRegex),this.beginRegex=b[0],this.beginOld2New=b[1],this.beginConsuming=b[2],b=m.groupify(this.endRegex,this.beginOld2New),this.endRegex=b[0],this.endOld2New=b[1],this.endConsuming=b[2]}e.prototype.valueOf=
function(){return this.beginRegex};return e}(),MatchRule:function(){function e(a){this.rule=a;this.matchRegex=m.toRegExp(a.match);if(this.isComplex=m.complexCaptures(a.captures))a=m.groupify(this.matchRegex),this.matchRegex=a[0],this.matchOld2New=a[1],this.matchConsuming=a[2]}e.prototype.valueOf=function(){return this.matchRegex};return e}(),_createTypedRule:function(e){return e.match?new this.MatchRule(e):e.begin?new this.BeginEndRule(e):new this.ContainerRule(e)},_resolve:function(e){var a=e;if(e.include){if(e.begin||
e.end||e.match)throw Error('Unexpected regex pattern in "include" rule '+e.include);e=e.include;if(e.charAt(0)==="#"){if(a=this.grammar.repository&&this.grammar.repository[e.substring(1)],!a)throw Error("Couldn't find included rule "+e+" in grammar repository");}else if(e==="$self")a=this.grammar;else if(e==="$base")throw Error('Include "$base" is not supported');else if(a=this._allGrammars[e],!a)for(var b=0;b<this.externalGrammars.length;b++){var d=this.externalGrammars[b];if(d.scopeName===e){this.preprocess(d);
a=this._allGrammars[e]=d;break}}}return a},ContainerNode:function(){function e(a,b){this.parent=a;this.rule=b;this.children=[];this.end=this.start=null}e.prototype.addChild=function(a){this.children.push(a)};e.prototype.valueOf=function(){var a=this.rule;return"ContainerNode { "+(a.include||"")+" "+(a.name||"")+(a.comment||"")+"}"};return e}(),BeginEndNode:function(){function e(a,b,d){this.parent=a;this.rule=b;this.children=[];this.setStart(d);this.endMatch=this.end=null;this.endRegexSubstituted=
b.endRegexHasBackRef?m.getSubstitutedRegex(b.endRegex,d):null}e.prototype.addChild=function(a){this.children.push(a)};e.prototype.getIndexInParent=function(){return this.parent?this.parent.children.indexOf(this):-1};e.prototype.setStart=function(a){this.start=a.index;this.beginMatch=a};e.prototype.setEnd=function(a){a&&typeof a==="object"?(this.endMatch=a,this.end=a.index+a[0].length):(this.endMatch=null,this.end=a)};e.prototype.shiftStart=function(a){this.start+=a;this.beginMatch.index+=a};e.prototype.shiftEnd=
function(a){this.end+=a;this.endMatch&&(this.endMatch.index+=a)};e.prototype.valueOf=function(){return"{"+this.rule.beginRegex+" range="+this.start+".."+this.end+"}"};return e}(),push:function(e,a){if(a)for(var b=a.length;b>0;)e.push(a[--b])},exec:function(e,a,b){(a=e.exec(a))&&(a.index+=b);e.lastIndex=0;return a},afterMatch:function(e){return e.index+e[0].length},getEndMatch:function(e,a,b){if(e instanceof this.BeginEndNode){var d=e.rule,e=e.endRegexSubstituted||d.endRegex;return!e?null:this.exec(e,
a,b)}return null},initialParse:function(){this.textView.getModel().getCharCount();this._tree=new this.ContainerNode(null,this.grammar._typedRule);this.parse(this._tree,!1,0)},onModelChanged:function(e){var a=e.addedCharCount,b=e.removedCharCount,e=e.start;if(this._tree){var d=this.textView.getModel(),f=d.getCharCount(),d=d.getLineEnd(d.getLineAtOffset(e)-1),g=this.getFirstDamaged(d,d),d=d===-1?0:d,a=g?this.parse(g,!0,d,e,a,b):f;this.textView.redrawRange(d,a)}else this.initialParse()},getFirstDamaged:function(e,
a){if(e<0)return this._tree;for(var b=[this._tree],d=null;b.length;){var f=b.pop();if(!f.parent||this.isDamaged(f,e,a)){f instanceof this.BeginEndNode&&(d=f);for(var g=0;g<f.children.length;g++)b.push(f.children[g])}}return d||this._tree},isDamaged:function(e,a,b){return e.start<=b&&e.end>a},parse:function(e,a,b,d,f,g){var h=this.textView.getModel(),c=h.getLineStart(h.getLineCount()-1),j=h.getCharCount(),k=this.getInitialExpected(e,b),l=-1;if(a)e.repaired=!0,e.endNeedsUpdate=!0,l=(l=e.children[e.children.length-
1])?h.getLineEnd(h.getLineAtOffset(l.end+(f-g))):-1,d=h.getLineEnd(h.getLineAtOffset(d+g)),l=Math.max(l,d);for(var l=l===-1?j:l,d=k,m=e,p=!1,n=b,r=-1;m&&(!a||n<l);){var s=this.getNextMatch(h,m,n);s||(n=n>=c?j:h.getLineStart(h.getLineAtOffset(n)+1));var t=s&&s.match,D=s&&s.rule,v=s&&s.isEnd;if(s&&s.isSub){if(n=this.afterMatch(t),D instanceof this.BeginEndRule)p=!0,a&&D===d.rule&&m===d.parent?(m=d,m.setStart(t),m.repaired=!0,m.endNeedsUpdate=!0,d=this.getNextExpected(d,"begin")):(a&&(this.prune(m,d),
a=!1),t=new this.BeginEndNode(m,D,t),m.addChild(t),m=t)}else if(v||n===j){if(m instanceof this.BeginEndNode)t?(p=!0,r=Math.max(r,m.end),m.setEnd(t),n=this.afterMatch(t),a&&m===d&&m.parent===d.parent?(m.repaired=!0,delete m.endNeedsUpdate,d=this.getNextExpected(d,"end")):a&&(this.prune(m,d),a=!1)):(m.setEnd(j),delete m.endNeedsUpdate);m=m.parent}a&&n>=l&&!p&&(this.prune(e,k),a=!1)}this.removeUnrepairedChildren(e,a,b);this.cleanup(a,e,b,l,j,f,g);return a?Math.max(r,n):n},removeUnrepairedChildren:function(e,
a,b){if(a){for(var a=e.children,d=-1,f=0;f<a.length;f++){var g=a[f];if(!g.repaired&&this.isDamaged(g,b,Number.MAX_VALUE)){d=f;break}}if(d!==-1)e.children.length=d}},cleanup:function(e,a,b,d,f,g,h){if(e){e=g-h;f=this.getIntersecting(d-e+1,f);a=this.getIntersecting(b,d);for(b=0;b<f.length;b++)d=f[b],!d.repaired&&d instanceof this.BeginEndNode&&(d.shiftEnd(e),d.shiftStart(e));for(b=0;b<a.length;b++)d=a[b],d.repaired&&d.endNeedsUpdate&&d.shiftEnd(e),delete d.endNeedsUpdate,delete d.repaired}else{a=this.getIntersecting(b,
d);for(b=0;b<a.length;b++)delete a[b].repaired}},getNextMatch:function(e,a,b,d){var f=e.getLineAtOffset(b),f=e.getLineEnd(f),g=e.getText(b,f),h=[],c=[],e=[],f=[];for(this.push(h,a.rule.subrules);h.length;){var j=h.length?h.pop():null,j=j&&j._resolvedRule._typedRule;if(j instanceof this.ContainerRule&&c.indexOf(j)===-1)c.push(j),this.push(h,j.subrules);else if(!j||!d||j.matchRegex){var k=j&&this.exec(j.matchRegex||j.beginRegex,g,b);k&&(e.push(k),f.push(j))}}h=Number.MAX_VALUE;c=-1;for(j=0;j<e.length;j++)if(k=
e[j],k.index<h)h=k.index,c=j;if(!d&&(b=this.getEndMatch(a,g,b)))if(d=a.rule.applyEndPatternLast,c===-1||b.index<h||!d&&b.index===h)return{isEnd:!0,rule:a.rule,match:b};return c===-1?null:{isSub:!0,rule:f[c],match:e[c]}},getInitialExpected:function(e,a){var b,d;if(e===this._tree)for(b=0;b<e.children.length;b++){if(d=e.children[b],d.start>=a)return d}else if(e instanceof this.BeginEndNode&&e.endMatch){var f=e.endMatch.index;for(b=0;b<e.children.length;b++)if(d=e.children[b],d.start>=a)break;if(d&&d.start<
f)return d}return e},getNextExpected:function(e,a){if(a==="begin"){var b=e.children[0];return b?b:e}else if(a==="end"&&(b=e.parent)){var d=b.children[b.children.indexOf(e)+1];return d?d:b}return null},prune:function(e,a){if(a.parent===e)e.children.length=a.getIndexInParent();else if(e instanceof this.BeginEndNode)e.endMatch=null,e.end=null;if(e.parent)e.parent.children.length=e.getIndexInParent()+1},onLineStyle:function(e){this._tree||this.initialParse();var a=e.lineStart,b=this.textView.getModel(),
d=b.getLineEnd(e.lineIndex),f=b.getLineEnd(b.getLineAtOffset(a)-1),f=this.getFirstDamaged(f,f),a=this.getLineScope(b,f,a,d);e.ranges=this.toStyleRanges(a);e.ranges.sort(function(a,b){return a.start-b.start})},getLineScope:function(e,a,b,d){for(var f=b,g=this.getInitialExpected(a,b),h=[],c=[];a&&f<d;){var j=this.getNextMatch(e,a,f);if(!j)break;var k=j&&j.match,l=j&&j.rule,m=j&&j.isSub,j=j&&j.isEnd;k.index!==f&&c.push({start:f,end:k.index,node:a});if(m)f=this.afterMatch(k),l instanceof this.BeginEndRule?
(this.addBeginScope(h,k,l),a=g,g=this.getNextExpected(g,"begin")):this.addMatchScope(h,k,l);else if(j)f=this.afterMatch(k),this.addEndScope(h,k,l),g=this.getNextExpected(g,"end"),a=a.parent}f<d&&c.push({start:f,end:d,node:a});e=this.getInheritedLineScope(c,b,d);return h.concat(e)},getInheritedLineScope:function(e){for(var a=[],b=0;b<e.length;b++)for(var d=e[b],f=d.node;f;){var g=f.rule.rule,h=g.name;if(g=g.contentName||h){this.addScopeRange(a,d.start,d.end,g);break}f=f.parent}return a},addBeginScope:function(e,
a,b){var d=b.rule;this.addCapturesScope(e,a,d.beginCaptures||d.captures,b.isComplex,b.beginOld2New,b.beginConsuming)},addEndScope:function(e,a,b){var d=b.rule;this.addCapturesScope(e,a,d.endCaptures||d.captures,b.isComplex,b.endOld2New,b.endConsuming)},addMatchScope:function(e,a,b){var d=b.rule,f=d.name;(d=d.captures)?this.addCapturesScope(e,a,d,b.isComplex,b.matchOld2New,b.matchConsuming):this.addScope(e,a,f)},addScope:function(e,a,b){b&&e.push({start:a.index,end:this.afterMatch(a),scope:b})},addScopeRange:function(e,
a,b,d){d&&e.push({start:a,end:b,scope:d})},addCapturesScope:function(e,a,b,d,f,g){if(b)if(d){for(var d={1:0},h=0,c=1;a[c]!==void 0;c++)g[c]!==void 0&&(h+=a[c].length),a[c+1]!==void 0&&(d[c+1]=h);g=a.index;for(h=1;b[h];h++){var c=b[h].name,j=f[h],k=g+d[j];typeof a[j]!=="undefined"&&this.addScopeRange(e,k,k+a[j].length,c)}}else this.addScope(e,a,b[0]&&b[0].name)},getIntersecting:function(e,a){for(var b=[],d=this._tree?[this._tree]:[];d.length;){var f=d.pop(),g=!1;f instanceof this.ContainerNode?g=!0:
this.isDamaged(f,e,a)&&(g=!0,b.push(f));if(g)for(var g=f.children.length,h=0;h<g;h++)d.push(f.children[h])}return b.reverse()},toStyleRanges:function(e){for(var a=[],b=0;b<e.length;b++){var d=e[b],f=this._styles[d.scope];if(!f)throw Error("styles not found for "+d.scope);f=f.join(" ");a.push({start:d.start,end:d.end,style:{styleClass:f}})}return a}};return{RegexUtil:m,TextMateStyler:l}});
define("orion/editor/htmlGrammar",[],function(){return{HtmlGrammar:function(){return{scopeName:"source.html",uuid:"3B5C76FB-EBB5-D930-F40C-047D082CE99B",patterns:[{begin:"<!(doctype|DOCTYPE)",end:">",contentName:"entity.name.tag.doctype.html",beginCaptures:{0:{name:"entity.name.tag.doctype.html"}},endCaptures:{0:{name:"entity.name.tag.doctype.html"}}},{begin:"<\!--",end:"--\>",beginCaptures:{0:{name:"punctuation.definition.comment.html"}},endCaptures:{0:{name:"punctuation.definition.comment.html"}},
patterns:[{match:"--",name:"invalid.illegal.badcomment.html"}],contentName:"comment.block.html"},{match:"<[A-Za-z0-9_\\-:]+(?= ?)",name:"entity.name.tag.html"},{include:"#attrName"},{include:"#qString"},{include:"#qqString"},{include:"#entity"},{match:"</[A-Za-z0-9_\\-:]+>",name:"entity.name.tag.html"},{match:">",name:"entity.name.tag.html"}],repository:{attrName:{match:"[A-Za-z\\-:]+(?=\\s*=\\s*['\"])",name:"entity.other.attribute.name.html"},qqString:{match:'(")[^"]+(")',name:"token.string"},qString:{match:"(')[^']+(')",
name:"token.string"},entity:{match:"&[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}}});
define("examples/editor/textStyler",["orion/editor/annotations"],function(s){function r(a,b){this.keywords=a;this.whitespacesVisible=b;this.setText("")}function p(){r.call(this,null,!0)}function f(a){r.call(this,null,a)}function h(){r.call(this,null,!1)}function l(a,b,c){this.commentStart="/*";this.commentEnd="*/";var d=[];switch(b){case "java":d=m;break;case "js":d=k;break;case "css":d=e}this.whitespacesVisible=!1;this.detectHyperlinks=!0;this.highlightCaretLine=!1;this.detectTasks=this.foldingEnabled=
!0;this._scanner=new r(d,this.whitespacesVisible);this._firstScanner=new h;this._commentScanner=new f(this.whitespacesVisible);this._whitespaceScanner=new p;if(b==="css")this._scanner.isCSS=!0,this._firstScanner.isCSS=!0;this.view=a;this.annotationModel=c;this._bracketAnnotations=void 0;var g=this;this._listener={onChanged:function(a){g._onModelChanged(a)},onDestroy:function(a){g._onDestroy(a)},onLineStyle:function(a){g._onLineStyle(a)},onMouseDown:function(a){g._onMouseDown(a)},onSelection:function(a){g._onSelection(a)}};
b=a.getModel();b.getBaseModel&&(b=b.getBaseModel());b.addEventListener("Changed",this._listener.onChanged);a.addEventListener("MouseDown",this._listener.onMouseDown);a.addEventListener("Selection",this._listener.onSelection);a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("LineStyle",this._listener.onLineStyle);this._computeComments();this._computeFolding();a.redrawLines()}var k="break,case,class,catch,continue,const,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,undefined,var,void,while,with,yield".split(","),
m="abstract,boolean,break,byte,case,catch,char,class,continue,default,do,double,else,extends,false,final,finally,float,for,if,implements,import,instanceof,int,interface,long,native,new,null,package,private,protected,public,return,short,static,super,switch,synchronized,this,throw,throws,transient,true,try,void,volatile,while".split(","),e="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,wor
a={styleClass:"comment"},b={styleClass:"token_multiline_comment"},d={styleClass:"token_doc_comment"},i={styleClass:"token_doc_html_markup"},g={styleClass:"token_task_tag"},o={styleClass:"token_doc_tag"},c={styleClass:"token-string"},j={styleClass:"token_number"},q={styleClass:"token_keyword"},u={styleClass:"token_space"},A={styleClass:"token_tab"},E={styleClass:"line_caret"};r.prototype={getOffset:function(){return this.offset},getStartOffset:function(){return this.startOffset},getData:function(){return this.text.substring(this.startOffset,
this.offset)},getDataLength:function(){return this.offset-this.startOffset},_default:function(a){switch(a){case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===9);this._unread(a);return 9;case 123:case 125:case 40:case 41:case 91:case 93:case 60:case 62:return a;default:var b=this.isCSS,c=this.offset-1;if(!b&&48<=a&&a<=57){var d=b=!1,e=!1,f=a;do if(a=this._read(),a===46&&!b)b=!0;else if(a===101&&!d)b=d=!0,a=this._read(),a!==45&&this._unread(a);else if(a===
120&&f===48&&this.offset-c===2)b=d=e=!0;else if(!(48<=a&&a<=57||e&&(65<=a&&a<=70||97<=a&&a<=102)))break;while(1);this._unread(a);return 3}if(97<=a&&a<=122||65<=a&&a<=90||a===95||45===a&&b){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57||45===a&&b);this._unread(a);a=this.keywords;if(a.length>0){c=this.text.substring(c,this.offset);for(b=0;b<a.length;b++)if(this.keywords[b]===c)return 2}}return 1}},_read:function(){return this.offset<this.text.length?this.text.charCodeAt(this.offset++):
-1},_unread:function(a){a!==-1&&this.offset--},nextToken:function(){for(this.startOffset=this.offset;;){var a=this._read(),b;switch(a){case -1:return null;case 47:a=this._read();if(!this.isCSS&&a===47)for(;;)if(a=this._read(),a===-1||a===10||a===13)return this._unread(a),6;if(a===42){a=this._read();b=7;for(a===42&&(b=8);;){for(;a===42;)if(a=this._read(),a===47)return b;if(a===-1)return this._unread(a),b;a=this._read()}}this._unread(a);return 1;case 39:for(b=4;;)switch(a=this._read(),a){case 39:return b;
case 13:case 10:case -1:return this._unread(a),b;case 92:switch(a=this._read(),a){case 10:b=5;break;case 13:b=5,a=this._read(),a!==10&&this._unread(a)}}break;case 34:for(b=4;;)switch(a=this._read(),a){case 34:return b;case 13:case 10:case -1:return this._unread(a),b;case 92:switch(a=this._read(),a){case 10:b=5;break;case 13:b=5,a=this._read(),a!==10&&this._unread(a)}}break;default:return this._default(a)}}},setText:function(a){this.text=a;this.startOffset=this.offset=0}};p.prototype=new r(null);p.prototype.nextToken=
function(){for(this.startOffset=this.offset;;){var a=this._read();switch(a){case -1:return null;case 32:return 11;case 9:return 10;default:do a=this._read();while(!(a===32||a===9||a===-1));this._unread(a);return 1}}};f.prototype=new r(null);f.prototype.setType=function(a){this._type=a};f.prototype.nextToken=function(){for(this.startOffset=this.offset;;){var a=this._read();switch(a){case -1:return null;case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===
9);this._unread(a);return 9;case 60:if(this._type===8){do a=this._read();while(!(a===62||a===-1));if(a===62)return 12}return 1;case 64:if(this._type===8){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57);this._unread(a);return 13}return 1;case 84:if((a=this._read())===79)if((a=this._read())===68)if((a=this._read())===79)if(a=this._read(),!(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57))return this._unread(a),14;this._unread(a);default:do a=this._read();while(!(a===32||
a===9||a===-1||a===60||a===64||a===84));this._unread(a);return 1}}};h.prototype=new r(null);h.prototype._default=function(a){for(;;)switch(a=this._read(),a){case 47:case 34:case 39:case -1:return this._unread(a),1}};l.prototype={getClassNameForToken:function(e){switch(e){case "singleLineComment":return a.styleClass;case "multiLineComment":return b.styleClass;case "docComment":return d.styleClass;case "docHtmlComment":return i.styleClass;case "tasktag":return g.styleClass;case "doctag":return o.styleClass;
case "string":return c.styleClass;case "number":return j.styleClass;case "keyword":return q.styleClass;case "space":return u.styleClass;case "tab":return A.styleClass;case "caretLine":return E.styleClass;case "rulerStyle":return"ruler";case "annotationsStyle":return;case "rulerFolding":return;case "rulerOverview":return"ruler.overview";case "rulerLines":return;case "rulerLinesEven":return"rulerLines.even";case "rulerLinesOdd":return"rulerLines.odd"}return null},destroy:function(){var a=this.view;
if(a){var b=a.getModel();b.getBaseModel&&(b=b.getBaseModel());b.removeEventListener("Changed",this._listener.onChanged);a.removeEventListener("MouseDown",this._listener.onMouseDown);a.removeEventListener("Selection",this._listener.onSelection);a.removeEventListener("Destroy",this._listener.onDestroy);a.removeEventListener("LineStyle",this._listener.onLineStyle);this.view=null}},setHighlightCaretLine:function(a){this.highlightCaretLine=a},setWhitespacesVisible:function(a){this.whitespacesVisible=a;
this._scanner.whitespacesVisible=a;this._commentScanner.whitespacesVisible=a},setDetectHyperlinks:function(a){this.detectHyperlinks=a},setFoldingEnabled:function(a){this.foldingEnabled=a},setDetectTasks:function(a){this.detectTasks=a},_binarySearch:function(a,b,c,d,e){var f;d===void 0&&(d=-1);if(e===void 0)e=a.length;for(;e-d>1;)if(f=Math.floor((e+d)/2),b<=a[f].start)e=f;else if(c&&b<a[f].end){e=f;break}else d=f;return e},_computeComments:function(){var a=this.view.getModel();a.getBaseModel&&(a=a.getBaseModel());
this.comments=this._findComments(a.getText())},_computeFolding:function(){if(this.foldingEnabled){var a=this.view.getModel();if(a.getBaseModel){var b=this.annotationModel;if(b){b.removeAnnotations(s.AnnotationType.ANNOTATION_FOLDING);for(var c=[],d=a.getBaseModel(),e=this.comments,f=0;f<e.length;f++){var g=e[f];(g=this._createFoldingAnnotation(a,d,g.start,g.end))&&c.push(g)}b.replaceAnnotations(null,c)}}}},_createFoldingAnnotation:function(a,b,c,d){var e=b.getLineAtOffset(c),b=b.getLineAtOffset(d);
return e===b?null:new (s.AnnotationType.getType(s.AnnotationType.ANNOTATION_FOLDING))(c,d,a)},_computeTasks:function(a,b,c){if(this.detectTasks){var d=this.annotationModel;if(d){var e=this.view.getModel(),f=e;e.getBaseModel&&(f=e.getBaseModel());for(var g=d.getAnnotations(b,c),e=[],h=s.AnnotationType.ANNOTATION_TASK;g.hasNext();){var i=g.next();i.type===h&&e.push(i)}g=[];i=this._commentScanner;i.setText(f.getText(b,c));for(var j;j=i.nextToken();){var k=i.getStartOffset()+b;j===14&&(j=f.getLineEnd(f.getLineAtOffset(k)),
a!==6&&(j=Math.min(j,c-this.commentEnd.length)),g.push(s.AnnotationType.createAnnotation(h,k,j,f.getText(k,j))))}d.replaceAnnotations(e,g)}}},_getLineStyle:function(a){if(this.highlightCaretLine){var b=this.view,c=b.getModel(),b=b.getSelection();if(b.start===b.end&&c.getLineAtOffset(b.start)===a)return E}return null},_getStyles:function(a,e,f){a.getBaseModel&&(f=a.mapOffset(f));for(var g=f+e.length,h=[],i=f,j=this.comments,k=this._binarySearch(j,f,!0);k<j.length;k++){if(j[k].start>=g)break;var l=
j[k].start,m=j[k].end;i<l&&this._parse(e.substring(i-f,l-f),i,h);var o=j[k].type,p;switch(o){case 8:p=d;break;case 7:p=b;break;case 5:p=c}i=Math.max(i,l);l=Math.min(g,m);(o===8||o===7)&&(this.whitespacesVisible||this.detectHyperlinks)?this._parseComment(e.substring(i-f,l-f),i,h,p,o):o===5&&this.whitespacesVisible?this._parseString(e.substring(i-f,l-f),i,h,c):h.push({start:i,end:l,style:p});i=m}i<g&&this._parse(e.substring(i-f,g-f),i,h);if(a.getBaseModel)for(e=0;e<h.length;e++)f=h[e].end-h[e].start,
h[e].start=a.mapOffset(h[e].start,!0),h[e].end=h[e].start+f;return h},_parse:function(e,f,g){var h=this._scanner;for(h.setText(e);e=h.nextToken();){var i=h.getStartOffset()+f,k=null;switch(e){case 2:k=q;break;case 3:k=j;break;case 5:case 4:if(this.whitespacesVisible){this._parseString(h.getData(),i,g,c);continue}else k=c;break;case 8:this._parseComment(h.getData(),i,g,d,e);continue;case 6:this._parseComment(h.getData(),i,g,a,e);continue;case 7:this._parseComment(h.getData(),i,g,b,e);continue;case 10:this.whitespacesVisible&&
(k=A);break;case 11:this.whitespacesVisible&&(k=u)}g.push({start:i,end:h.getOffset()+f,style:k})}},_parseComment:function(a,b,c,d,e){var f=this._commentScanner;f.setText(a);for(f.setType(e);a=f.nextToken();){var e=f.getStartOffset()+b,h=d;switch(a){case 10:this.whitespacesVisible&&(h=A);break;case 11:this.whitespacesVisible&&(h=u);break;case 12:h=i;break;case 13:h=o;break;case 14:h=g;break;default:this.detectHyperlinks&&(h=this._detectHyperlinks(f.getData(),e,c,h))}h&&c.push({start:e,end:f.getOffset()+
b,style:h})}},_parseString:function(a,b,c,d){var e=this._whitespaceScanner;for(e.setText(a);a=e.nextToken();){var f=e.getStartOffset()+b,g=d;switch(a){case 10:this.whitespacesVisible&&(g=A);break;case 11:this.whitespacesVisible&&(g=u)}g&&c.push({start:f,end:e.getOffset()+b,style:g})}},_detectHyperlinks:function(a,b,c,d){var e=null,f;if((f=a.indexOf("://"))>0){for(var e=a,g=f;g>0;){f=e.charCodeAt(g-1);if(!(97<=f&&f<=122||65<=f&&f<=90||45===f||48<=f&&f<=57))break;g--}if(g>0&&(f="\"\"''(){}[]<>".indexOf(e.substring(g-
1,g)),f!==-1&&(f&1)===0&&(f=e.lastIndexOf("\"\"''(){}[]<>".substring(f+1,f+2)))!==-1)){var h=f;f=this._clone(d);f.tagName="A";f.attributes={href:e.substring(g,h)};c.push({start:b,end:b+g,style:d});c.push({start:b+g,end:b+h,style:f});c.push({start:b+h,end:b+a.length,style:d});return null}}else a.toLowerCase().indexOf("bug#")===0&&(e="https://bugs.eclipse.org/bugs/show_bug.cgi?id="+parseInt(a.substring(4),10));return e?(f=this._clone(d),f.tagName="A",f.attributes={href:e},f):d},_clone:function(a){if(!a)return a;
var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},_findComments:function(a,b){var b=b||0,c=this._firstScanner,d;c.setText(a);for(var e=[];d=c.nextToken();)(d===7||d===8||d===5)&&e.push({start:c.getStartOffset()+b,end:c.getOffset()+b,type:d}),(d===6||d===7||d===8)&&this._computeTasks(d,c.getStartOffset()+b,c.getOffset()+b);return e},_findMatchingBracket:function(a,b){var c="{}()[]<>",d=a.getText(b,b+1),e=c.indexOf(d,0);if(e===-1)return-1;var f;f=e&1?c.substring(e-1,e):c.substring(e+
1,e+2);for(var g=a.getLineAtOffset(b),c=a.getLine(g),h=a.getLineStart(g),i=a.getLineEnd(g),c=this._findBrackets(d,f,c,h,h,i),i=0;i<c.length;i++)if(h=c[i]>=0?1:-1,c[i]*h-1===b){var j=1;if(e&1){for(i--;i>=0;i--)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;for(g-=1;g>=0;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(e=c.length-1;e>=0;e--)if(h=c[e]>=0?1:-1,j+=h,j===0)return c[e]*h-1;g--}}else{for(i++;i<c.length;i++)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*
h-1;g+=1;for(e=a.getLineCount();g<e;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(i=0;i<c.length;i++)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;g++}}break}return-1},_findBrackets:function(a,b,c,d,e,f){for(var g=[],a=a.charCodeAt(0),b=b.charCodeAt(0),h=e,i=this._scanner,j,k=this.comments,l=this._binarySearch(k,e,!0);l<k.length;l++){if(k[l].start>=f)break;j=k[l].start;var m=k[l].end;if(h<j)for(i.setText(c.substring(h-e,j-e));j=i.nextToken();)j===a?g.push(i.getStartOffset()+
h-e+d+1):j===b&&g.push(-(i.getStartOffset()+h-e+d+1));h=m}if(h<f)for(i.setText(c.substring(h-e,f-e));j=i.nextToken();)j===a?g.push(i.getStartOffset()+h-e+d+1):j===b&&g.push(-(i.getStartOffset()+h-e+d+1));return g},_onDestroy:function(){this.destroy()},_onLineStyle:function(a){if(a.textView===this.view)a.style=this._getLineStyle(a.lineIndex);a.ranges=this._getStyles(a.textView.getModel(),a.lineText,a.lineStart)},_onSelection:function(a){var b=a.oldValue,c=a.newValue,d=this.view,a=d.getModel(),e;if(this.highlightCaretLine){var f=
a.getLineAtOffset(b.start);e=a.getLineAtOffset(c.start);var g=c.start===c.end,b=b.start===b.end;f===e&&b&&g||(b&&d.redrawLines(f,f+1),(f!==e||!b)&&g&&d.redrawLines(e,e+1))}if(this.annotationModel){var b=this._bracketAnnotations,h,i;if(c.start===c.end&&(i=d.getCaretOffset())>0)i-=1,a.getBaseModel&&(i=a.mapOffset(i),a=a.getBaseModel()),a=this._findMatchingBracket(a,i),a!==-1&&(h=[s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_MATCHING_BRACKET,a,a+1),s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_CURRENT_BRACKET,
i,i+1)]);this._bracketAnnotations=h;this.annotationModel.replaceAnnotations(b,h)}},_onMouseDown:function(a){if(a.clickCount===2){var b=this.view,c=b.getModel(),d=b.getOffsetAtLocation(a.x,a.y);if(d>0){var e=d-1,f=c;c.getBaseModel&&(e=c.mapOffset(e),f=c.getBaseModel());e=this._findMatchingBracket(f,e);e!==-1&&(a.preventDefault(),a=e,c.getBaseModel&&(a=c.mapOffset(a,!0)),d>a&&(d--,a++),b.setSelection(a,d))}}},_onModelChanged:function(a){var b=a.start,c=a.removedCharCount,d=a.addedCharCount-c,e=this.view,
a=e.getModel(),f=a.getBaseModel?a.getBaseModel():a,c=b+c,g=f.getCharCount(),h=this.comments.length,i=f.getLineStart(f.getLineAtOffset(b)),j=this._binarySearch(this.comments,i,!0),k=this._binarySearch(this.comments,c,!1,j-1,h);j<h&&this.comments[j].start<=i&&i<this.comments[j].end?(i=this.comments[j].start,i>b&&(i+=d)):i=j===h&&h>0&&g-d===this.comments[h-1].end?this.comments[h-1].start:i;var l;k<h?(l=this.comments[k].end,l>b&&(l+=d),k+=1):(k=h,l=g);for(var m,g=this._findComments(f.getText(i,l),i),
h=j;h<this.comments.length;h++)m=this.comments[h],m.start>b&&(m.start+=d),m.start>b&&(m.end+=d);var o=k-j!==g.length;if(!o)for(h=0;h<g.length;h++){m=this.comments[j+h];var p=g[h];if(m.start!==p.start||m.end!==p.end||m.type!==p.type){o=!0;break}}h=[j,k-j].concat(g);Array.prototype.splice.apply(this.comments,h);o&&(h=i,m=l,a!==f&&(h=a.mapOffset(h,!0),m=a.mapOffset(m,!0)),e.redrawRange(h,m));if(this.foldingEnabled&&f!==a&&this.annotationModel){e=this.annotationModel;j=e.getAnnotations(i,l);i=[];for(l=
[];j.hasNext();)if(m=j.next(),m.type===s.AnnotationType.ANNOTATION_FOLDING){l.push(m);for(h=0;h<g.length;h++)if(m.start===g[h].start&&m.end===g[h].end)break;h===g.length?(i.push(m),m.expand()):(h=m.start,k=m.end,h>b&&(h-=d),k>b&&(k-=d),h<=b&&b<k&&h<=c&&c<k&&(h=f.getLineAtOffset(m.start),k=f.getLineAtOffset(m.end),h!==k?m.expanded||(m.expand(),e.modifyAnnotation(m)):e.removeAnnotation(m)))}b=[];for(h=0;h<g.length;h++){m=g[h];for(d=0;d<l.length;d++)if(l[d].start===m.start&&l[d].end===m.end)break;d===
l.length&&(m=this._createFoldingAnnotation(a,f,m.start,m.end))&&b.push(m)}e.replaceAnnotations(i,b)}}};return{TextStyler:l}});
define("orion/editor/edit","orion/editor/textView,orion/editor/textModel,orion/editor/projectionTextModel,orion/editor/eventTarget,orion/editor/keyBinding,orion/editor/rulers,orion/editor/annotations,orion/editor/tooltip,orion/editor/undoStack,orion/editor/textDND,orion/editor/editor,orion/editor/editorFeatures,orion/editor/contentAssist,orion/editor/cssContentAssist,orion/editor/htmlContentAssist,orion/editor/jsTemplateContentAssist,orion/editor/AsyncStyler,orion/editor/mirror,orion/editor/textMateStyler,orion/editor/htmlGrammar,examples/editor/textStyler".split(","),function(s,
r,p,f,h,l,k,m,e,a,b,d,i,g,o,c,j,q,u,A,E){function n(a){var b=a.ownerDocument,c=b.defaultView||b.parentWindow;if(!c.getSelection)return a.innerText||a.textContent;b=b.createRange();b.selectNode(a);var a=c.getSelection(),c=[],d;for(d=0;d<a.rangeCount;d++)c.push(a.getRangeAt(d));a.removeAllRanges();a.addRange(b);b=a.toString();a.removeAllRanges();for(d=0;d<c.length;d++)a.addRange(c[d]);return b}function B(a){if(a.substring(0,12)==="data-editor-")return a=a.substring(12),a=a.replace(/-([a-z])/ig,function(a,
b){return b.toUpperCase()})}function J(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function t(a,b){var c={};J(c,b);for(var d,e=0,f=a.attributes,g=f.length;e<g;e++){d=f.item(e);var h=B(d.nodeName);if(h){d=d.nodeValue;if(d==="true"||d==="false")d=d==="true";c[h]=d}}return c}function D(a){var b=a.ownerDocument,b=b.defaultView||b.parentWindow,c;if(b.getComputedStyle)c=b.getComputedStyle(a,null).getPropertyValue("height");else if(a.currentStyle)c=a.currentStyle.height;return parseInt(c,10)||0}
function v(a){var e=a.parent;e||(e="editor");typeof e==="string"&&(e=(a.document||document).getElementById(e));if(!e&&a.className){var f=(a.document||document).getElementsByClassName(a.className);if(f){a.className=void 0;for(var h=[],j=0;j<f.length;j++)a.parent=f[j],h.push(v(a));return h}}if(!e)throw"no parent";var a=t(e,a),k;a.readonly||(h={createContentAssistMode:function(a){k=new i.ContentAssist(a.getTextView());a=new i.ContentAssistWidget(k);return new i.ContentAssistMode(k,a)}});f=new b.Editor({textViewFactory:function(){return new s.TextView({parent:e,
model:new p.ProjectionTextModel(new r.TextModel("")),tabSize:a.tabSize?a.tabSize:4,readonly:a.readonly,fullSelection:a.fullSelection,tabMode:a.tabMode,expandTab:a.expandTab,themeClass:a.themeClass,wrapMode:a.wrapMode})},undoStackFactory:new d.UndoFactory,annotationFactory:new d.AnnotationFactory,lineNumberRulerFactory:new d.LineNumberRulerFactory,foldingRulerFactory:new d.FoldingRulerFactory,textDNDFactory:new d.TextDNDFactory,contentAssistFactory:h,keyBindingFactory:function(a,b,c,e){var f=new d.TextActions(a,
c);b.push(f);a=new d.SourceCodeActions(a,c,e);b.push(a)},statusReporter:a.statusReporter,domNode:e});h=a.contents;h===void 0&&(h=n(e));h||(h="");f.installTextView();f.setLineNumberRulerVisible(a.showLinesRuler===void 0||a.showLinesRuler);f.setAnnotationRulerVisible(a.showAnnotationRuler===void 0||a.showFoldingRuler);f.setOverviewRulerVisible(a.showOverviewRuler===void 0||a.showOverviewRuler);f.setFoldingRulerVisible(a.showFoldingRuler===void 0||a.showFoldingRuler);f.setInput(a.title,null,h);({styler:null,
highlight:function(b,c){if(this.styler)this.styler.destroy(),this.styler=null;if(b){var d=c.getTextView(),e=c.getAnnotationModel();switch(b){case "js":case "java":case "css":this.styler=new E.TextStyler(d,b,e);c.setFoldingRulerVisible(a.showFoldingRuler===void 0||a.showFoldingRuler);break;case "html":this.styler=new u.TextMateStyler(d,new A.HtmlGrammar)}}}}).highlight(a.lang,f);if(k){var l=new g.CssContentAssistProvider,m=new c.JSTemplateContentAssistProvider;k.addEventListener("Activating",function(){/css$/.test(a.lang)?
k.setProviders([l]):/js$/.test(a.lang)&&k.setProviders([m])})}if(D(e)<=50)h=f.getTextView().computeSize().height,e.style.height=h+"px";return f}var z=this.orion?this.orion.editor:void 0;if(z)for(var H=0;H<arguments.length;H++)J(z,arguments[H]);return v});var orion=this.orion||(this.orion={}),editor=orion.editor||(orion.editor={});editor.edit=require("orion/editor/edit");