(function(n,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define("codemirror.js",t):(n=n||self,n.CodeMirror=t())})(this,function(){function gr(n){return new RegExp("(^|\\s)"+n+"(?:$|\\s)\\s*")}function pi(n){for(var t=n.childNodes.length;t>0;--t)n.removeChild(n.firstChild);return n}function ct(n,t){return pi(n).appendChild(t)}function i(n,t,i,r){var u=document.createElement(n),f;if(i&&(u.className=i),r&&(u.style.cssText=r),typeof t=="string")u.appendChild(document.createTextNode(t));else if(t)for(f=0;f<t.length;++f)u.appendChild(t[f]);return u}function nu(n,t,r,u){var f=i(n,t,r,u);return f.setAttribute("role","presentation"),f}function wi(n,t){if(t.nodeType==3&&(t=t.parentNode),n.contains)return n.contains(t);do if(t.nodeType==11&&(t=t.host),t==n)return!0;while(t=t.parentNode)}function oi(){var n;try{n=document.activeElement}catch(t){n=document.body||null}while(n&&n.shadowRoot&&n.shadowRoot.activeElement)n=n.shadowRoot.activeElement;return n}function ur(n,t){var i=n.className;gr(t).test(i)||(n.className+=(i?" ":"")+t)}function ds(n,t){for(var r=n.split(" "),i=0;i<r.length;i++)r[i]&&!gr(r[i]).test(t)&&(t+=" "+r[i]);return t}function gs(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t)}}function fr(n,t,i){t||(t={});for(var r in n)n.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=n[r]);return t}function vt(n,t,i,r,u){var f,e,o;for(t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length)),f=r||0,e=u||0;;){if(o=n.indexOf("\t",f),o<0||o>=t)return e+(t-f);e+=o-f;e+=i-e%i;f=o+1}}function g(n,t){for(var i=0;i<n.length;++i)if(n[i]==t)return i;return-1}function th(n,t,i){for(var f,e,r=0,u=0;;){if(f=n.indexOf("\t",r),f==-1&&(f=n.length),e=f-r,f==n.length||u+e>=t)return r+Math.min(e,t-u);if(u+=f-r,u+=i-u%i,r=f+1,u>=t)return r}}function ih(n){while(lf.length<=n)lf.push(s(lf)+" ");return lf[n]}function s(n){return n[n.length-1]}function fo(n,t){for(var r=[],i=0;i<n.length;i++)r[i]=t(n[i],i);return r}function sk(n,t,i){for(var r=0,u=i(t);r<n.length&&i(n[r])<=u;)r++;n.splice(r,0,t)}function sa(){}function ha(n,t){var i;return Object.create?i=Object.create(n):(sa.prototype=n,i=new sa),t&&fr(t,i),i}function rh(n){return/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||ca.test(n))}function eo(n,t){return t?t.source.indexOf("\\w")>-1&&rh(n)?!0:t.test(n):rh(n)}function la(n){for(var t in n)if(n.hasOwnProperty(t)&&n[t])return!1;return!0}function uh(n){return n.charCodeAt(0)>=768&&aa.test(n)}function va(n,t,i){while((i<0?t>0:t<n.length)&&uh(n.charAt(t)))t+=i;return t}function af(n,t,i){for(var f=t>i?-1:1,u,r;;){if(t==i)return t;if(u=(t+i)/2,r=f<0?Math.ceil(u):Math.floor(u),r==t)return n(r)?t:i;n(r)?i=r:t=r+f}}function hk(n,t,i,r){var e,f,u;if(!n)return r(t,i,"ltr",0);for(e=!1,f=0;f<n.length;++f)u=n[f],(u.from<i&&u.to>t||t==i&&u.to==t)&&(r(Math.max(u.from,t),Math.min(u.to,i),u.level==1?"rtl":"ltr",f),e=!0);e||r(t,i,"ltr")}function vf(n,t,i){var f,r,u;for(ru=null,r=0;r<n.length;++r){if(u=n[r],u.from<t&&u.to>t)return r;u.to==t&&(u.from!=u.to&&i=="before"?f=r:ru=r);u.from==t&&(u.from!=u.to&&i!="before"?f=r:ru=r)}return f!=null?f:ru}function hi(n,t){var i=n.order;return i==null&&(i=n.order=ya(n.text,t)),i}function eh(n,t){return n._handlers&&n._handlers[t]||fh}function lt(n,t,i){var u,r,f;n.removeEventListener?n.removeEventListener(t,i,!1):n.detachEvent?n.detachEvent("on"+t,i):(u=n._handlers,r=u&&u[t],r&&(f=g(r,i),f>-1&&(u[t]=r.slice(0,f).concat(r.slice(f+1)))))}function p(n,t){var r=eh(n,t),u,i;if(r.length)for(u=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,u)}function w(n,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),p(n,i||t.type,n,t),oh(t)||t.codemirrorIgnore}function pa(n){var i=n._handlers&&n._handlers.cursorActivity,r,t;if(i)for(r=n.curOp.cursorActivityHandlers||(n.curOp.cursorActivityHandlers=[]),t=0;t<i.length;++t)g(r,i[t])==-1&&r.push(i[t])}function yt(n,t){return eh(n,t).length>0}function uu(n){n.prototype.on=function(n,t){r(this,n,t)};n.prototype.off=function(n,t){lt(this,n,t)}}function ft(n){n.preventDefault?n.preventDefault():n.returnValue=!1}function wa(n){n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}function oh(n){return n.defaultPrevented!=null?n.defaultPrevented:n.returnValue==!1}function yf(n){ft(n);wa(n)}function sh(n){return n.target||n.srcElement}function ba(n){var t=n.which;return t==null&&(n.button&1?t=1:n.button&2?t=3:n.button&4&&(t=2)),at&&n.ctrlKey&&t==1&&(t=3),t}function ck(n){var t,r;return hh==null&&(t=i("span","​"),ct(n,i("span",[t,document.createTextNode("x")])),n.firstChild.offsetHeight!=0&&(hh=t.offsetWidth<=1&&t.offsetHeight>2&&!(e&&l<8))),r=hh?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px"),r.setAttribute("cm-text",""),r}function lk(n){if(ch!=null)return ch;var i=ct(n,document.createTextNode("AخA")),t=tu(i,0,1).getBoundingClientRect(),r=tu(i,1,2).getBoundingClientRect();return(pi(n),!t||t.left==t.right)?!1:ch=r.right-t.right<3}function yk(n){if(ah!=null)return ah;var t=ct(n,i("span","x")),r=t.getBoundingClientRect(),u=tu(t,0,1).getBoundingClientRect();return ah=Math.abs(r.left-u.left)>1}function pk(n,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2));oo[n]=t}function wk(n,t){er[n]=t}function so(n){if(typeof n=="string"&&er.hasOwnProperty(n))n=er[n];else if(n&&typeof n.name=="string"&&er.hasOwnProperty(n.name)){var t=er[n.name];typeof t=="string"&&(t={name:t});n=ha(t,n);n.name=t.name}else{if(typeof n=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(n))return so("application/xml");if(typeof n=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(n))return so("application/json")}return typeof n=="string"?{name:n}:n||{name:"null"}}function vh(n,t){var f,i,u,r,e;if(t=so(t),f=oo[t.name],!f)return vh(n,"text/plain");if(i=f(n,t),or.hasOwnProperty(t.name)){u=or[t.name];for(r in u)u.hasOwnProperty(r)&&(i.hasOwnProperty(r)&&(i["_"+r]=i[r]),i[r]=u[r])}if(i.name=t.name,t.helperType&&(i.helperType=t.helperType),t.modeProps)for(e in t.modeProps)i[e]=t.modeProps[e];return i}function bk(n,t){var i=or.hasOwnProperty(n)?or[n]:or[n]={};fr(t,i)}function sr(n,t){var r,u,i;if(t===!0)return t;if(n.copyState)return n.copyState(t);r={};for(u in t)i=t[u],i instanceof Array&&(i=i.concat([])),r[u]=i;return r}function yh(n,t){for(var i;n.innerMode;){if(i=n.innerMode(t),!i||i.mode==n)break;t=i.state;n=i.mode}return i||{mode:n,state:t}}function da(n,t,i){return n.startState?n.startState(t,i):!0}function t(n,t){var i,r,u,f;if(t-=n.first,t<0||t>=n.size)throw new Error("There is no line "+(t+n.first)+" in the document.");for(i=n;!i.lines;)for(r=0;;++r){if(u=i.children[r],f=u.chunkSize(),t<f){i=u;break}t-=f}return i.lines[t]}function hr(n,t,i){var u=[],r=t.line;return n.iter(t.line,i.line+1,function(n){var f=n.text;r==i.line&&(f=f.slice(0,i.ch));r==t.line&&(f=f.slice(t.ch));u.push(f);++r}),u}function ph(n,t,i){var r=[];return n.iter(t,i,function(n){r.push(n.text)}),r}function ni(n,t){var r=t-n.height,i;if(r)for(i=n;i;i=i.parent)i.height+=r}function c(n){var i,u,t,r;if(n.parent==null)return null;for(i=n.parent,u=g(i.lines,n),t=i.parent;t;i=t,t=t.parent)for(r=0;;++r){if(t.children[r]==i)break;u+=t.children[r].chunkSize()}return u+i.first}function cr(n,t){var f=n.first,r,u,e,i,s,o;n:do{for(r=0;r<n.children.length;++r){if(u=n.children[r],e=u.height,t<e){n=u;continue n}t-=e;f+=u.chunkSize()}return f}while(!n.lines);for(i=0;i<n.lines.length;++i){if(s=n.lines[i],o=s.height,t<o)break;t-=o}return f+i}function pf(n,t){return t>=n.first&&t<n.first+n.size}function wh(n,t){return String(n.lineNumberFormatter(t+n.firstLineNumber))}function n(t,i,r){if(r===void 0&&(r=null),!(this instanceof n))return new n(t,i,r);this.line=t;this.ch=i;this.sticky=r}function u(n,t){return n.line-t.line||n.ch-t.ch}function bh(n,t){return n.sticky==t.sticky&&u(n,t)==0}function kh(t){return n(t.line,t.ch)}function ho(n,t){return u(n,t)<0?t:n}function co(n,t){return u(n,t)<0?n:t}function ga(n,t){return Math.max(n.first,Math.min(t,n.first+n.size-1))}function f(i,r){if(r.line<i.first)return n(i.first,0);var u=i.first+i.size-1;return r.line>u?n(u,t(i,u).text.length):kk(r,t(i,r.line).text.length)}function kk(t,i){var r=t.ch;return r==null||r>i?n(t.line,i):r<0?n(t.line,0):t}function nv(n,t){for(var r=[],i=0;i<t.length;i++)r[i]=f(n,t[i]);return r}function tv(n,t,i,r){var u=[n.state.modeGen],f={},o,s,e;for(ev(n,t.text,n.doc.mode,i,function(n,t){return u.push(n,t)},f,r),o=i.state,s=function(r){i.baseTokens=u;var s=n.state.overlays[r],e=1,h=0;i.state=!0;ev(n,t.text,s.mode,i,function(n,t){for(var i=e,r,f;h<n;)r=u[e],r>n&&u.splice(e,1,n,u[e+1],r),e+=2,h=Math.min(n,r);if(t)if(s.opaque)u.splice(i,e-i,n,"overlay "+t),e=i+2;else for(;i<e;i+=2)f=u[i+1],u[i+1]=(f?f+" ":"")+"overlay "+t},f);i.state=o;i.baseTokens=null;i.baseTokenPos=1},e=0;e<n.state.overlays.length;++e)s(e);return{styles:u,classes:f.bgClass||f.textClass?f:null}}function iv(n,t,i){if(!t.styles||t.styles[0]!=n.state.modeGen){var r=bf(n,c(t)),u=t.text.length>n.options.maxHighlightLength&&sr(n.doc.mode,r.state),f=tv(n,t,r);u&&(r.state=u);t.stateAfter=r.save(!u);t.styles=f.styles;f.classes?t.styleClasses=f.classes:t.styleClasses&&(t.styleClasses=null);i===n.doc.highlightFrontier&&(n.doc.modeFrontier=Math.max(n.doc.modeFrontier,++n.doc.highlightFrontier))}return t.styles}function bf(n,i,r){var u=n.doc,o=n.display;if(!u.mode.startState)return new bt(u,!0,i);var e=dk(n,i,r),s=e>u.first&&t(u,e-1).stateAfter,f=s?bt.fromSaved(u,s,e):new bt(u,da(u.mode),e);return u.iter(e,i,function(t){dh(n,t.text,f);var r=f.line;t.stateAfter=r==i-1||r%5==0||r>=o.viewFrom&&r<o.viewTo?f.save():null;f.nextLine()}),r&&(u.modeFrontier=f.line),f}function dh(n,t,i,r){var f=n.doc.mode,u=new y(t,n.options.tabSize,i);for(u.start=u.pos=r||0,t==""&&rv(f,i.state);!u.eol();)gh(f,u,i.state),u.start=u.pos}function rv(n,t){if(n.blankLine)return n.blankLine(t);if(n.innerMode){var i=yh(n,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}}function gh(n,t,i,r){for(var f,u=0;u<10;u++)if(r&&(r[0]=yh(n,i).mode),f=n.token(t,i),t.pos>t.start)return f;throw new Error("Mode "+n.name+" failed to advance stream.");}function uv(n,i,r,u){var o=n.doc,l=o.mode,h;i=f(o,i);var a=t(o,i.line),s=bf(n,i.line,r),e=new y(a.text,n.options.tabSize,s),c;for(u&&(c=[]);(u||e.pos<i.ch)&&!e.eol();)e.start=e.pos,h=gh(l,e,s.state),u&&c.push(new nc(e,h,sr(o.mode,s.state)));return u?c:new nc(e,h,s.state)}function fv(n,t){var i,r;if(n)for(;;){if(i=n.match(/(?:^|\s+)line-(background-)?(\S+)/),!i)break;n=n.slice(0,i.index)+n.slice(i.index+i[0].length);r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return n}function ev(n,t,i,r,u,f,e){var c=i.flattenSpans,a,p;c==null&&(c=n.options.flattenSpans);var s=0,l=null,o=new y(t,n.options.tabSize,r),h,v=n.options.addModeClass&&[null];for(t==""&&fv(rv(i,r.state),f);!o.eol();){if(o.pos>n.options.maxHighlightLength?(c=!1,e&&dh(n,t,r,o.pos),o.pos=t.length,h=null):h=fv(gh(i,o,r.state,v),f),v&&(a=v[0].name,a&&(h="m-"+(h?a+" "+h:a))),!c||l!=h){while(s<o.start)s=Math.min(o.start,s+5e3),u(s,l);l=h}o.start=o.pos}while(s<o.pos)p=Math.min(o.pos,s+5e3),u(p,l),s=p}function dk(n,i,r){for(var s,e,h,c,o,f=n.doc,l=r?-1:i-(n.doc.mode.innerMode?1e3:100),u=i;u>l;--u){if(u<=f.first)return f.first;if(s=t(f,u-1),e=s.stateAfter,e&&(!r||u+(e instanceof wf?e.lookAhead:0)<=f.modeFrontier))return u;h=vt(s.text,null,n.options.tabSize);(o==null||c>h)&&(o=u-1,c=h)}return o}function gk(n,i){var u,r,f;if(n.modeFrontier=Math.min(n.modeFrontier,i),!(n.highlightFrontier<i-10)){for(u=n.first,r=i-1;r>u;r--)if(f=t(n,r).stateAfter,f&&(!(f instanceof wf)||r+f.lookAhead<i)){u=r+1;break}n.highlightFrontier=Math.min(n.highlightFrontier,u)}}function nd(){tc=!0}function td(){ti=!0}function lo(n,t,i){this.marker=n;this.from=t;this.to=i}function kf(n,t){var i,r;if(n)for(i=0;i<n.length;++i)if(r=n[i],r.marker==t)return r}function id(n,t){for(var r,i=0;i<n.length;++i)n[i]!=t&&(r||(r=[])).push(n[i]);return r}function rd(n,t){n.markedSpans=n.markedSpans?n.markedSpans.concat([t]):[t];t.marker.attachLine(n)}function ud(n,t,i){var e,u,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t);!s&&(r.from!=t||f.type!="bookmark"||i&&r.marker.insertLeft)||(o=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t),(e||(e=[])).push(new lo(f,r.from,o?null:r.to)))}return e}function fd(n,t,i){var e,u,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t);(s||r.from==t&&f.type=="bookmark"&&(!i||r.marker.insertLeft))&&(o=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t),(e||(e=[])).push(new lo(f,o?null:r.from-t,r.to==null?null:r.to-t)))}return e}function ic(n,i){var w,b,a,h,v,y,e,it,p,d,g,c,nt;if(i.full||(w=pf(n,i.from.line)&&t(n,i.from.line).markedSpans,b=pf(n,i.to.line)&&t(n,i.to.line).markedSpans,!w&&!b))return null;var k=i.from.ch,rt=i.to.ch,tt=u(i.from,i.to)==0,r=ud(w,k,tt),f=fd(b,rt,tt),o=i.text.length==1,l=s(i.text).length+(o?k:0);if(r)for(a=0;a<r.length;++a)h=r[a],h.to==null&&(v=kf(f,h.marker),v?o&&(h.to=v.to==null?null:v.to+l):h.to=k);if(f)for(y=0;y<f.length;++y)e=f[y],e.to!=null&&(e.to+=l),e.from==null?(it=kf(r,e.marker),it||(e.from=l,o&&(r||(r=[])).push(e))):(e.from+=l,o&&(r||(r=[])).push(e));if(r&&(r=ov(r)),f&&f!=r&&(f=ov(f)),p=[r],!o){if(d=i.text.length-2,d>0&&r)for(c=0;c<r.length;++c)r[c].to==null&&(g||(g=[])).push(new lo(r[c].marker,null,null));for(nt=0;nt<d;++nt)p.push(g);p.push(f)}return p}function ov(n){for(var i,t=0;t<n.length;++t)i=n[t],i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&n.splice(t--,1);return n.length?n:null}function ed(n,t,i){var r=null,o,h,c,f,s,e;if(n.iter(t.line,i.line+1,function(n){var t,i;if(n.markedSpans)for(t=0;t<n.markedSpans.length;++t)i=n.markedSpans[t].marker,i.readOnly&&(!r||g(r,i)==-1)&&(r||(r=[])).push(i)}),!r)return null;for(o=[{from:t,to:i}],h=0;h<r.length;++h)for(c=r[h],f=c.find(0),s=0;s<o.length;++s)if(e=o[s],!(u(e.to,f.from)<0)&&!(u(e.from,f.to)>0)){var l=[s,1],a=u(e.from,f.from),v=u(e.to,f.to);(a<0||!c.inclusiveLeft&&!a)&&l.push({from:e.from,to:f.from});(v>0||!c.inclusiveRight&&!v)&&l.push({from:f.to,to:e.to});o.splice.apply(o,l);s+=l.length-3}return o}function sv(n){var i=n.markedSpans,t;if(i){for(t=0;t<i.length;++t)i[t].marker.detachLine(n);n.markedSpans=null}}function hv(n,t){if(t){for(var i=0;i<t.length;++i)t[i].marker.attachLine(n);n.markedSpans=t}}function ao(n){return n.inclusiveLeft?-1:0}function vo(n){return n.inclusiveRight?1:0}function rc(n,t){var r=n.lines.length-t.lines.length,i;if(r!=0)return r;var f=n.find(),e=t.find(),o=u(f.from,e.from)||ao(n)-ao(t);return o?-o:(i=u(f.to,e.to)||vo(n)-vo(t),i)?i:t.id-n.id}function cv(n,t){var f=ti&&n.markedSpans,r,i,u;if(f)for(i=void 0,u=0;u<f.length;++u)i=f[u],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||rc(r,i.marker)<0)&&(r=i.marker);return r}function lv(n){return cv(n,!0)}function yo(n){return cv(n,!1)}function od(n,t){var f=ti&&n.markedSpans,r,u,i;if(f)for(u=0;u<f.length;++u)i=f[u],i.marker.collapsed&&(i.from==null||i.from<t)&&(i.to==null||i.to>t)&&(!r||rc(r,i.marker)<0)&&(r=i.marker);return r}function av(n,i,r,f,e){var v=t(n,i),l=ti&&v.markedSpans,h,o;if(l)for(h=0;h<l.length;++h)if(o=l[h],o.marker.collapsed){var s=o.marker.find(0),c=u(s.from,r)||ao(o.marker)-ao(e),a=u(s.to,f)||vo(o.marker)-vo(e);if((!(c>=0)||!(a<=0))&&(!(c<=0)||!(a>=0))&&(c<=0&&(o.marker.inclusiveRight&&e.inclusiveLeft?u(s.to,r)>=0:u(s.to,r)>0)||c>=0&&(o.marker.inclusiveRight&&e.inclusiveLeft?u(s.from,f)<=0:u(s.from,f)<0)))return!0}}function ii(n){for(var t;t=lv(n);)n=t.find(-1,!0).line;return n}function sd(n){for(var t;t=yo(n);)n=t.find(1,!0).line;return n}function hd(n){for(var i,t;i=yo(n);)n=i.find(1,!0).line,(t||(t=[])).push(n);return t}function uc(n,i){var r=t(n,i),u=ii(r);return r==u?i:c(u)}function vv(n,i){if(i>n.lastLine())return i;var r=t(n,i),u;if(!bi(n,r))return i;while(u=yo(r))r=u.find(1,!0).line;return c(r)+1}function bi(n,t){var u=ti&&t.markedSpans,i,r;if(u)for(i=void 0,r=0;r<u.length;++r)if(i=u[r],i.marker.collapsed){if(i.from==null)return!0;if(!i.marker.widgetNode&&i.from==0&&i.marker.inclusiveLeft&&fc(n,t,i))return!0}}function fc(n,t,i){var f,r,u;if(i.to==null)return f=i.marker.find(1,!0),fc(n,f.line,kf(f.line.markedSpans,i.marker));if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(r=void 0,u=0;u<t.markedSpans.length;++u)if(r=t.markedSpans[u],r.marker.collapsed&&!r.marker.widgetNode&&r.from==i.to&&(r.to==null||r.to!=i.from)&&(r.marker.inclusiveLeft||i.marker.inclusiveRight)&&fc(n,t,r))return!0}function ci(n){var r,t,u,e,i,f,o;for(n=ii(n),r=0,t=n.parent,u=0;u<t.lines.length;++u)if(e=t.lines[u],e==n)break;else r+=e.height;for(i=t.parent;i;t=i,i=t.parent)for(f=0;f<i.children.length;++f)if(o=i.children[f],o==t)break;else r+=o.height;return r}function po(n){var i,r,t,u,f;if(n.height==0)return 0;for(i=n.text.length,t=n;r=lv(t);)u=r.find(0,!0),t=u.from.line,i+=u.from.ch-u.to.ch;for(t=n;r=yo(t);)f=r.find(0,!0),i-=t.text.length-f.from.ch,t=f.to.line,i+=t.text.length-f.to.ch;return i}function ec(n){var i=n.display,r=n.doc;i.maxLine=t(r,r.first);i.maxLineLength=po(i.maxLine);i.maxLineChanged=!0;r.iter(function(n){var t=po(n);t>i.maxLineLength&&(i.maxLineLength=t,i.maxLine=n)})}function cd(n,t,i,r){n.text=t;n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null);n.order!=null&&(n.order=null);sv(n);hv(n,i);var u=r?r(n):1;u!=n.height&&ni(n,u)}function ld(n){n.parent=null;sv(n)}function wv(n,t){if(!n||/^\s*$/.test(n))return null;var i=t.addModeClass?pv:yv;return i[n]||(i[n]=n.replace(/\S+/g,"cm-$&"))}function bv(n,t){var o=nu("span",null,null,tt?"padding-right: .1px":null),i={pre:nu("pre",[o],"CodeMirror-line"),content:o,col:0,pos:0,cm:n,trailingSpace:!1,splitSpaces:n.getOption("lineWrapping")},u,r,e,s,f;for(t.measure={},u=0;u<=(t.rest?t.rest.length:0);u++)r=u?t.rest[u-1]:t.line,e=void 0,i.pos=0,i.addToken=vd,lk(n.display.measure)&&(e=hi(r,n.doc.direction))&&(i.addToken=pd(i.addToken,e)),i.map=[],s=t!=n.display.externalMeasured&&c(r),wd(r,i,iv(n,r,s)),r.styleClasses&&(r.styleClasses.bgClass&&(i.bgClass=ds(r.styleClasses.bgClass,i.bgClass||"")),r.styleClasses.textClass&&(i.textClass=ds(r.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(ck(n.display.measure))),u==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}));return tt&&(f=i.content.lastChild,(/\bcm-tab\b/.test(f.className)||f.querySelector&&f.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")),p(n,"renderLine",n,t.line,i.pre),i.pre.className&&(i.textClass=ds(i.pre.className,i.textClass||"")),i}function ad(n){var t=i("span","•","cm-invalidchar");return t.title="\\u"+n.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function vd(n,t,r,u,f,o,s){var v,c,y,w,a,g,nt,b,tt,p;if(t){var k=n.splitSpaces?yd(t,n.trailingSpace):t,d=n.cm.state.specialChars,it=!1,h;if(d.test(t))for(h=document.createDocumentFragment(),v=0;;){if(d.lastIndex=v,c=d.exec(t),y=c?c.index-v:t.length-v,y&&(w=document.createTextNode(k.slice(v,v+y)),e&&l<9?h.appendChild(i("span",[w])):h.appendChild(w),n.map.push(n.pos,n.pos+y,w),n.col+=y,n.pos+=y),!c)break;v+=y+1;a=void 0;c[0]=="\t"?(g=n.cm.options.tabSize,nt=g-n.col%g,a=h.appendChild(i("span",ih(nt),"cm-tab")),a.setAttribute("role","presentation"),a.setAttribute("cm-text","\t"),n.col+=nt):c[0]=="\r"||c[0]=="\n"?(a=h.appendChild(i("span",c[0]=="\r"?"␍":"␤","cm-invalidchar")),a.setAttribute("cm-text",c[0]),n.col+=1):(a=n.cm.options.specialCharPlaceholder(c[0]),a.setAttribute("cm-text",c[0]),e&&l<9?h.appendChild(i("span",[a])):h.appendChild(a),n.col+=1);n.map.push(n.pos,n.pos+1,a);n.pos++}else n.col+=t.length,h=document.createTextNode(k),n.map.push(n.pos,n.pos+t.length,h),e&&l<9&&(it=!0),n.pos+=t.length;if(n.trailingSpace=k.charCodeAt(t.length-1)==32,r||u||f||it||o||s){if(b=r||"",u&&(b+=u),f&&(b+=f),tt=i("span",[h],b,o),s)for(p in s)s.hasOwnProperty(p)&&p!="style"&&p!="class"&&tt.setAttribute(p,s[p]);return n.content.appendChild(tt)}n.content.appendChild(h)}}function yd(n,t){var u,f,i,r;if(n.length>1&&!/  /.test(n))return n;for(u=t,f="",i=0;i<n.length;i++)r=n.charAt(i),r==" "&&u&&(i==n.length-1||n.charCodeAt(i+1)==32)&&(r=" "),f+=r,u=r==" ";return f}function pd(n,t){return function(i,r,u,f,e,o,s){var c,a,h,l;for(u=u?u+" cm-force-border":"cm-force-border",c=i.pos,a=c+r.length;;){for(h=void 0,l=0;l<t.length;l++)if(h=t[l],h.to>c&&h.from<=c)break;if(h.to>=a)return n(i,r,u,f,e,o,s);n(i,r.slice(0,h.to-c),u,f,null,o,s);f=null;r=r.slice(h.to-c);c=h.to}}}function kv(n,t,i,r){var u=!r&&i.widgetNode;u&&n.map.push(n.pos,n.pos+t,u);!r&&n.cm.display.input.needsContentAttribute&&(u||(u=n.content.appendChild(document.createElement("span"))),u.setAttribute("cm-marker",i.id));u&&(n.cm.display.input.setUneditable(u),n.content.appendChild(u));n.pos+=t;n.trailingSpace=!1}function wd(n,t,i){var it=n.markedSpans,rt=n.text,p=0,a,d,h,g,f,u,et,y,nt,l,tt,ot;if(!it){for(a=1;a<i.length;a+=2)t.addToken(t,rt.slice(p,p=i[a]),wv(i[a+1],t.cm.options));return}for(var ut=rt.length,r=0,st=1,s="",ft,v,o=0,w,b,k,e,c;;){if(o==r){for(w=b=k=v="",c=null,e=null,o=Infinity,d=[],h=void 0,g=0;g<it.length;++g)if(f=it[g],u=f.marker,u.type=="bookmark"&&f.from==r&&u.widgetNode)d.push(u);else if(f.from<=r&&(f.to==null||f.to>r||u.collapsed&&f.to==r&&f.from==r)){if(f.to!=null&&f.to!=r&&o>f.to&&(o=f.to,b=""),u.className&&(w+=" "+u.className),u.css&&(v=(v?v+";":"")+u.css),u.startStyle&&f.from==r&&(k+=" "+u.startStyle),u.endStyle&&f.to==o&&(h||(h=[])).push(u.endStyle,f.to),u.title&&((c||(c={})).title=u.title),u.attributes)for(et in u.attributes)(c||(c={}))[et]=u.attributes[et];u.collapsed&&(!e||rc(e.marker,u)<0)&&(e=f)}else f.from>r&&o>f.from&&(o=f.from);if(h)for(y=0;y<h.length;y+=2)h[y+1]==o&&(b+=" "+h[y]);if(!e||e.from==r)for(nt=0;nt<d.length;++nt)kv(t,0,d[nt]);if(e&&(e.from||0)==r){if(kv(t,(e.to==null?ut+1:e.to)-r,e.marker,e.from==null),e.to==null)return;e.to==r&&(e=!1)}}if(r>=ut)break;for(l=Math.min(ut,o);;){if(s){if(tt=r+s.length,e||(ot=tt>l?s.slice(0,l-r):s,t.addToken(t,ot,ft?ft+w:w,k,r+ot.length==o?b:"",v,c)),tt>=l){s=s.slice(l-r);r=l;break}r=tt;k=""}s=rt.slice(p,p=i[st++]);ft=wv(i[st++],t.cm.options)}}}function dv(n,t,i){this.line=t;this.rest=hd(t);this.size=this.rest?c(s(this.rest))-i+1:1;this.node=this.text=null;this.hidden=bi(n,t)}function wo(n,i,r){for(var f,e=[],o,u=i;u<r;u=o)f=new dv(n.doc,t(n.doc,u),u),o=u+f.size,e.push(f);return e}function bd(n){ar?ar.ops.push(n):n.ownsGroup=ar={ops:[n],delayedCallbacks:[]}}function kd(n){var u=n.delayedCallbacks,i=0,r,t;do{for(;i<u.length;i++)u[i].call(null);for(r=0;r<n.ops.length;r++)if(t=n.ops[r],t.cursorActivityHandlers)while(t.cursorActivityCalled<t.cursorActivityHandlers.length)t.cursorActivityHandlers[t.cursorActivityCalled++].call(null,t.cm)}while(i<u.length)}function dd(n,t){var i=n.ownsGroup;if(i)try{kd(i)}finally{ar=null;t(i)}}function d(n,t){var u=eh(n,t),f,i,e,r;if(u.length)for(f=Array.prototype.slice.call(arguments,2),ar?i=ar.delayedCallbacks:fu?i=fu:(i=fu=[],setTimeout(gd,0)),e=function(n){i.push(function(){return u[n].apply(null,f)})},r=0;r<u.length;++r)e(r)}function gd(){var t=fu,n;for(fu=null,n=0;n<t.length;++n)t[n]()}function gv(n,t,i,r){for(var u,f=0;f<t.changes.length;f++)u=t.changes[f],u=="text"?tg(n,t):u=="gutter"?ty(n,t,i,r):u=="class"?oc(n,t):u=="widget"&&ig(n,t,r);t.changes=null}function df(n){return n.node==n.text&&(n.node=i("div",null,null,"position: relative"),n.text.parentNode&&n.text.parentNode.replaceChild(n.node,n.text),n.node.appendChild(n.text),e&&l<8&&(n.node.style.zIndex=2)),n.node}function ng(n,t){var r=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass,u;r&&(r+=" CodeMirror-linebackground");t.background?r?t.background.className=r:(t.background.parentNode.removeChild(t.background),t.background=null):r&&(u=df(t),t.background=u.insertBefore(i("div",null,r),u.firstChild),n.display.input.setUneditable(t.background))}function ny(n,t){var i=n.display.externalMeasured;return i&&i.line==t.line?(n.display.externalMeasured=null,t.measure=i.measure,i.built):bv(n,t)}function tg(n,t){var r=t.text.className,i=ny(n,t);t.text==t.node&&(t.node=i.pre);t.text.parentNode.replaceChild(i.pre,t.text);t.text=i.pre;i.bgClass!=t.bgClass||i.textClass!=t.textClass?(t.bgClass=i.bgClass,t.textClass=i.textClass,oc(n,t)):r&&(t.text.className=r)}function oc(n,t){ng(n,t);t.line.wrapClass?df(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function ty(n,t,r,u){var c,f,l,e,s,o,h;if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass&&(c=df(t),t.gutterBackground=i("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(n.options.fixedGutter?u.fixedPos:-u.gutterTotalWidth)+"px; width: "+u.gutterTotalWidth+"px"),n.display.input.setUneditable(t.gutterBackground),c.insertBefore(t.gutterBackground,t.text)),f=t.line.gutterMarkers,(n.options.lineNumbers||f)&&(l=df(t),e=t.gutter=i("div",null,"CodeMirror-gutter-wrapper","left: "+(n.options.fixedGutter?u.fixedPos:-u.gutterTotalWidth)+"px"),n.display.input.setUneditable(e),l.insertBefore(e,t.text),t.line.gutterClass&&(e.className+=" "+t.line.gutterClass),!n.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||(t.lineNumber=e.appendChild(i("div",wh(n.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+u.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+n.display.lineNumInnerWidth+"px"))),f))for(s=0;s<n.display.gutterSpecs.length;++s)o=n.display.gutterSpecs[s].className,h=f.hasOwnProperty(o)&&f[o],h&&e.appendChild(i("div",[h],"CodeMirror-gutter-elt","left: "+u.gutterLeft[o]+"px; width: "+u.gutterWidth[o]+"px"))}function ig(n,t,i){var f,r,u;for(t.alignable&&(t.alignable=null),f=gr("CodeMirror-linewidget"),r=t.node.firstChild,u=void 0;r;r=u)u=r.nextSibling,f.test(r.className)&&t.node.removeChild(r);iy(n,t,i)}function rg(n,t,i,r){var u=ny(n,t);return t.text=t.node=u.pre,u.bgClass&&(t.bgClass=u.bgClass),u.textClass&&(t.textClass=u.textClass),oc(n,t),ty(n,t,i,r),iy(n,t,r),t.node}function iy(n,t,i){if(ry(n,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)ry(n,t.rest[r],t,i,!1)}function ry(n,t,r,u,f){var h,s,c,e,o;if(t.widgets)for(h=df(r),s=0,c=t.widgets;s<c.length;++s)e=c[s],o=i("div",[e.node],"CodeMirror-linewidget"+(e.className?" "+e.className:"")),e.handleMouseEvents||o.setAttribute("cm-ignore-events","true"),ug(e,o,r,u),n.display.input.setUneditable(o),f&&e.above?h.insertBefore(o,r.gutter||r.text):h.appendChild(o),d(e,"redraw")}function ug(n,t,i,r){if(n.noHScroll){(i.alignable||(i.alignable=[])).push(t);var u=r.wrapperWidth;t.style.left=r.fixedPos+"px";n.coverGutter||(u-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px");t.style.width=u+"px"}n.coverGutter&&(t.style.zIndex=5,t.style.position="relative",n.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function gf(n){var t,r;return n.height!=null?n.height:(t=n.doc.cm,!t)?0:(wi(document.body,n.node)||(r="position: relative;",n.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),n.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),ct(t.display.measure,i("div",[n.node],null,r))),n.height=n.node.parentNode.offsetHeight)}function li(n,t){for(var i=sh(t);i!=n.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==n.sizer&&i!=n.mover)return!0}function bo(n){return n.lineSpace.offsetTop}function sc(n){return n.mover.offsetHeight-n.lineSpace.offsetHeight}function uy(n){if(n.cachedPaddingH)return n.cachedPaddingH;var r=ct(n.measure,i("pre","x","CodeMirror-line-like")),u=window.getComputedStyle?window.getComputedStyle(r):r.currentStyle,t={left:parseInt(u.paddingLeft),right:parseInt(u.paddingRight)};return isNaN(t.left)||isNaN(t.right)||(n.cachedPaddingH=t),t}function ri(n){return oa-n.display.nativeBarWidth}function vr(n){return n.display.scroller.clientWidth-ri(n)-n.display.barWidth}function hc(n){return n.display.scroller.clientHeight-ri(n)-n.display.barHeight}function fg(n,t,i){var f=n.options.lineWrapping,h=f&&vr(n),e,u,r,o,s;if(!t.measure.heights||f&&t.measure.width!=h){if(e=t.measure.heights=[],f)for(t.measure.width=h,u=t.text.firstChild.getClientRects(),r=0;r<u.length-1;r++)o=u[r],s=u[r+1],Math.abs(o.bottom-s.bottom)>2&&e.push((o.bottom+s.top)/2-i.top);e.push(i.bottom-i.top)}}function fy(n,t,i){var r,u;if(n.line==t)return{map:n.measure.map,cache:n.measure.cache};for(r=0;r<n.rest.length;r++)if(n.rest[r]==t)return{map:n.measure.maps[r],cache:n.measure.caches[r]};for(u=0;u<n.rest.length;u++)if(c(n.rest[u])>i)return{map:n.measure.maps[u],cache:n.measure.caches[u],before:!0}}function eg(n,t){var r,i,u;return t=ii(t),r=c(t),i=n.display.externalMeasured=new dv(n.doc,t,r),i.lineN=r,u=i.built=bv(n,i),i.text=u.pre,ct(n.display.lineMeasure,u.pre),i}function ey(n,t,i,r){return ui(n,eu(n,t),i,r)}function cc(n,t){if(t>=n.display.viewFrom&&t<n.display.viewTo)return n.display.view[wr(n,t)];var i=n.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function eu(n,t){var u=c(t),i=cc(n,u),r;return i&&!i.text?i=null:i&&i.changes&&(gv(n,i,u,bc(n)),n.curOp.forceUpdate=!0),i||(i=eg(n,t)),r=fy(i,t,u),{line:t,view:i,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function ui(n,t,i,r,u){t.before&&(i=-1);var e=i+(r||""),f;return t.cache.hasOwnProperty(e)?f=t.cache[e]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(fg(n,t.view,t.rect),t.hasHeights=!0),f=sg(n,t,i,r),f.bogus||(t.cache[e]=f)),{left:f.left,right:f.right,top:u?f.rtop:f.top,bottom:u?f.rbottom:f.bottom}}function oy(n,t,i){for(var s,u,h,o,e,f,r=0;r<n.length;r+=3)if(e=n[r],f=n[r+1],t<e?(u=0,h=1,o="left"):t<f?(u=t-e,h=u+1):(r==n.length-3||t==f&&n[r+3]>t)&&(h=f-e,u=h-1,t>=f&&(o="right")),u!=null){if(s=n[r+2],e==f&&i==(s.insertLeft?"left":"right")&&(o=i),i=="left"&&u==0)while(r&&n[r-2]==n[r-3]&&n[r-1].insertLeft)s=n[(r-=3)+2],o="left";if(i=="right"&&u==f-e)while(r<n.length-3&&n[r+3]==n[r+4]&&!n[r+5].insertLeft)s=n[(r+=3)+2],o="right";break}return{node:s,start:u,end:h,collapse:o,coverStart:e,coverEnd:f}}function og(n,t){var i=lc,r,u;if(t=="left"){for(r=0;r<n.length;r++)if((i=n[r]).left!=i.right)break}else for(u=n.length-1;u>=0;u--)if((i=n[u]).left!=i.right)break;return i}function sg(n,t,i,r){var o=oy(t.map,i,r),s=o.node,f=o.start,h=o.end,v=o.collapse,u,w,b,c;if(s.nodeType==3){for(w=0;w<4;w++){while(f&&uh(t.line.text.charAt(o.coverStart+f)))--f;while(o.coverStart+h<o.coverEnd&&uh(t.line.text.charAt(o.coverStart+h)))++h;if(u=e&&l<9&&f==0&&h==o.coverEnd-o.coverStart?s.parentNode.getBoundingClientRect():og(tu(s,f,h).getClientRects(),r),u.left||u.right||f==0)break;h=f;f=f-1;v="right"}e&&l<11&&(u=hg(n.display.measure,u))}else f>0&&(v=r="right"),u=n.options.lineWrapping&&(b=s.getClientRects()).length>1?b[r=="right"?b.length-1:0]:s.getBoundingClientRect();e&&l<9&&!f&&(!u||!u.left&&!u.right)&&(c=s.parentNode.getClientRects()[0],u=c?{left:c.left,right:c.left+su(n.display),top:c.top,bottom:c.bottom}:lc);for(var k=u.top-t.rect.top,d=u.bottom-t.rect.top,g=(k+d)/2,y=t.view.measure.heights,a=0;a<y.length-1;a++)if(g<y[a])break;var nt=a?y[a-1]:0,tt=y[a],p={left:(v=="right"?u.right:u.left)-t.rect.left,right:(v=="left"?u.left:u.right)-t.rect.left,top:nt,bottom:tt};return u.left||u.right||(p.bogus=!0),n.options.singleCursorHeightPerLine||(p.rtop=k,p.rbottom=d),p}function hg(n,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!yk(n))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function sy(n){if(n.measure&&(n.measure.cache={},n.measure.heights=null,n.rest))for(var t=0;t<n.rest.length;t++)n.measure.caches[t]={}}function hy(n){n.display.externalMeasure=null;pi(n.display.lineMeasure);for(var t=0;t<n.display.view.length;t++)sy(n.display.view[t])}function ne(n){hy(n);n.display.cachedCharWidth=n.display.cachedTextHeight=n.display.cachedPaddingH=null;n.options.lineWrapping||(n.display.maxLineChanged=!0);n.display.lineNumChars=null}function cy(){return no&&io?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ly(){return no&&io?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ac(n){var i=0,t;if(n.widgets)for(t=0;t<n.widgets.length;++t)n.widgets[t].above&&(i+=gf(n.widgets[t]));return i}function ko(n,t,i,r,u){var e,f,o,s;return(u||(e=ac(t),i.top+=e,i.bottom+=e),r=="line")?i:(r||(r="local"),f=ci(t),r=="local"?f+=bo(n.display):f-=n.display.viewOffset,(r=="page"||r=="window")&&(o=n.display.lineSpace.getBoundingClientRect(),f+=o.top+(r=="window"?0:ly()),s=o.left+(r=="window"?0:cy()),i.left+=s,i.right+=s),i.top+=f,i.bottom+=f,i)}function ay(n,t,i){var r,u,f,e;return i=="div"?t:(r=t.left,u=t.top,i=="page"?(r-=cy(),u-=ly()):i!="local"&&i||(f=n.display.sizer.getBoundingClientRect(),r+=f.left,u+=f.top),e=n.display.lineSpace.getBoundingClientRect(),{left:r-e.left,top:u-e.top})}function vc(n,i,r,u,f){return u||(u=t(n.doc,i.line)),ko(n,u,ey(n,u,i.ch,f),r)}function kt(n,i,r,u,f,e){function c(t,i){var o=ui(n,f,t,i?"right":"left",e);return i?o.left=o.right:o.right=o.left,ko(n,u,o,r)}function l(n,t,i){var r=h[t],u=r.level==1;return c(i?n-1:n,u!=i)}u=u||t(n.doc,i.line);f||(f=eu(n,u));var h=hi(u,n.doc.direction),o=i.ch,s=i.sticky;if(o>=u.text.length?(o=u.text.length,s="before"):o<=0&&(o=0,s="after"),!h)return c(s=="before"?o-1:o,s=="before");var y=vf(h,o,s),a=ru,v=l(o,y,s=="before");return a!=null&&(v.other=l(o,a,s!="before")),v}function vy(n,i){var r=0,u,e;return i=f(n.doc,i),n.options.lineWrapping||(r=su(n.display)*i.ch),u=t(n.doc,i.line),e=ci(u)+bo(n.display),{left:r,right:r,top:e,bottom:e+u.height}}function yc(t,i,r,u,f){var e=n(t,i,r);return e.xRel=f,u&&(e.outside=u),e}function pc(n,i,r){var u=n.doc,f,h,o,e,c,s;if(r+=n.display.viewOffset,r<0)return yc(u.first,0,null,-1,-1);if(f=cr(u,r),h=u.first+u.size-1,f>h)return yc(u.first+u.size-1,t(u,h).text.length,null,1,1);for(i<0&&(i=0),o=t(u,f);;){if(e=cg(n,o,f,i,r),c=od(o,e.ch+(e.xRel>0||e.outside>0?1:0)),!c)return e;if(s=c.find(1),s.line==f)return s;o=t(u,f=s.line)}}function yy(n,t,i,r){r-=ac(t);var u=t.text.length,f=af(function(t){return ui(n,i,t-1).bottom<=r},u,0);return u=af(function(t){return ui(n,i,t).top>r},f,u),{begin:f,end:u}}function py(n,t,i,r){i||(i=eu(n,t));var u=ko(n,t,ui(n,i,r),"line").top;return yy(n,t,i,u)}function wc(n,t,i,r){return n.bottom<=i?!1:n.top>i?!0:(r?n.left:n.right)>t}function cg(t,i,r,u,f){var s,b,k,a;f-=ci(i);var c=eu(t,i),v=ac(i),y=0,p=i.text.length,o=!0,d=hi(i,t.doc.direction);d&&(s=(t.options.lineWrapping?ag:lg)(t,i,r,c,d,u,f),o=s.level!=1,y=o?s.from:s.to-1,p=o?s.to:s.from-1);var g=null,h=null,e=af(function(n){var i=ui(t,c,n);return(i.top+=v,i.bottom+=v,!wc(i,u,f,!1))?!1:(i.top<=f&&i.left<=u&&(g=n,h=i),!0)},y,p),w,l,nt=!1;return h?(b=u-h.left<h.right-u,k=b==o,e=g+(k?0:1),l=k?"after":"before",w=b?h.left:h.right):(o||e!=p&&e!=y||e++,l=e==0?"after":e==i.text.length?"before":ui(t,c,e-(o?1:0)).bottom+v<=f==o?"after":"before",a=kt(t,n(r,e,l),"line",i,c),w=a.left,nt=f<a.top?-1:f>=a.bottom?1:0),e=va(i.text,e,1),yc(r,e,l,nt,u-w)}function lg(t,i,r,u,f,e,o){var h=af(function(s){var h=f[s],c=h.level!=1;return wc(kt(t,n(r,c?h.to:h.from,c?"before":"after"),"line",i,u),e,o,!0)},0,f.length-1),s=f[h],c,l;return h>0&&(c=s.level!=1,l=kt(t,n(r,c?s.from:s.to,c?"after":"before"),"line",i,u),wc(l,e,o,!0)&&l.top>o&&(s=f[h-1])),s}function ag(n,t,i,r,u,f,e){var y=yy(n,t,r,e),c=y.begin,h=y.end,o,a,l,s;for(/\s/.test(t.text.charAt(h-1))&&h--,o=null,a=null,l=0;l<u.length;l++)if(s=u[l],!(s.from>=h)&&!(s.to<=c)){var w=s.level!=1,v=ui(n,r,w?Math.min(h,s.to)-1:Math.max(c,s.from)).right,p=v<f?f-v+1e9:v-f;(!o||a>p)&&(o=s,a=p)}return o||(o=u[u.length-1]),o.from<c&&(o={from:c,to:o.to,level:o.level}),o.to>h&&(o={from:o.from,to:h,level:o.level}),o}function ou(n){var r,t;if(n.cachedTextHeight!=null)return n.cachedTextHeight;if(yr==null){for(yr=i("pre",null,"CodeMirror-line-like"),r=0;r<49;++r)yr.appendChild(document.createTextNode("x")),yr.appendChild(i("br"));yr.appendChild(document.createTextNode("x"))}return ct(n.measure,yr),t=yr.offsetHeight/50,t>3&&(n.cachedTextHeight=t),pi(n.measure),t||1}function su(n){var r,f,u,t;return n.cachedCharWidth!=null?n.cachedCharWidth:(r=i("span","xxxxxxxxxx"),f=i("pre",[r],"CodeMirror-line-like"),ct(n.measure,f),u=r.getBoundingClientRect(),t=(u.right-u.left)/10,t>2&&(n.cachedCharWidth=t),t||10)}function bc(n){for(var r,i=n.display,u={},f={},o=i.gutters.clientLeft,t=i.gutters.firstChild,e=0;t;t=t.nextSibling,++e)r=n.display.gutterSpecs[e].className,u[r]=t.offsetLeft+t.clientLeft+o,f[r]=t.clientWidth;return{fixedPos:kc(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:f,wrapperWidth:i.wrapper.clientWidth}}function kc(n){return n.scroller.getBoundingClientRect().left-n.sizer.getBoundingClientRect().left}function wy(n){var t=ou(n.display),i=n.options.lineWrapping,r=i&&Math.max(5,n.display.scroller.clientWidth/su(n.display)-3);return function(u){var e,f;if(bi(n.doc,u))return 0;if(e=0,u.widgets)for(f=0;f<u.widgets.length;f++)u.widgets[f].height&&(e+=u.widgets[f].height);return i?e+(Math.ceil(u.text.length/r)||1)*t:e+t}}function dc(n){var t=n.doc,i=wy(n);t.iter(function(n){var t=i(n);t!=n.height&&ni(n,t)})}function pr(i,r,u,f){var a=i.display,s,c,h,e,o,l;if(!u&&sh(r).getAttribute("cm-not-content")=="true")return null;h=a.lineSpace.getBoundingClientRect();try{s=r.clientX-h.left;c=r.clientY-h.top}catch(v){return null}return e=pc(i,s,c),f&&e.xRel>0&&(o=t(i.doc,e.line).text).length==e.ch&&(l=vt(o,o.length,i.options.tabSize)-o.length,e=n(e.line,Math.max(0,Math.round((s-uy(i.display).left)/su(i.display))-l))),e}function wr(n,t){var r,i;if(t>=n.display.viewTo||(t-=n.display.viewFrom,t<0))return null;for(r=n.display.view,i=0;i<r.length;i++)if(t-=r[i].size,t<0)return i}function et(n,t,i,r){var u,e,o,s,h,f;t==null&&(t=n.doc.first);i==null&&(i=n.doc.first+n.doc.size);r||(r=0);u=n.display;r&&i<u.viewTo&&(u.updateLineNumbers==null||u.updateLineNumbers>t)&&(u.updateLineNumbers=t);n.curOp.viewChanged=!0;t>=u.viewTo?ti&&uc(n.doc,t)<u.viewTo&&di(n):i<=u.viewFrom?ti&&vv(n.doc,i+r)>u.viewFrom?di(n):(u.viewFrom+=r,u.viewTo+=r):t<=u.viewFrom&&i>=u.viewTo?di(n):t<=u.viewFrom?(e=go(n,i,i+r,1),e?(u.view=u.view.slice(e.index),u.viewFrom=e.lineN,u.viewTo+=r):di(n)):i>=u.viewTo?(o=go(n,t,t,-1),o?(u.view=u.view.slice(0,o.index),u.viewTo=o.lineN):di(n)):(s=go(n,t,t,-1),h=go(n,i,i+r,1),s&&h?(u.view=u.view.slice(0,s.index).concat(wo(n,s.lineN,h.lineN)).concat(u.view.slice(h.index)),u.viewTo+=r):di(n));f=u.externalMeasured;f&&(i<f.lineN?f.lineN+=r:t<f.lineN+f.size&&(u.externalMeasured=null))}function ki(n,t,i){var r,u,f,e;(n.curOp.viewChanged=!0,r=n.display,u=n.display.externalMeasured,u&&t>=u.lineN&&t<u.lineN+u.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)||(f=r.view[wr(n,t)],f.node!=null)&&(e=f.changes||(f.changes=[]),g(e,i)==-1&&e.push(i))}function di(n){n.display.viewFrom=n.display.viewTo=n.doc.first;n.display.view=[];n.display.viewOffset=0}function go(n,t,i,r){var u=wr(n,t),o,f=n.display.view,e,s;if(!ti||i==n.doc.first+n.doc.size)return{index:u,lineN:i};for(e=n.display.viewFrom,s=0;s<u;s++)e+=f[s].size;if(e!=t){if(r>0){if(u==f.length-1)return null;o=e+f[u].size-t;u++}else o=e-t;t+=o;i+=o}while(uc(n.doc,i)!=i){if(u==(r<0?0:f.length-1))return null;i+=r*f[u-(r<0?1:0)].size;u+=r}return{index:u,lineN:i}}function vg(n,t,i){var r=n.display,u=r.view;u.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=wo(n,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=wo(n,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(wr(n,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(wo(n,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,wr(n,i))));r.viewTo=i}function by(n){for(var t,r=n.display.view,u=0,i=0;i<r.length;i++)t=r[i],t.hidden||t.node&&!t.changes||++u;return u}function te(n){n.display.input.showSelection(n.display.input.prepareSelection())}function ky(n,t){var r,i,e;t===void 0&&(t=!0);var u=n.doc,f={},o=f.cursors=document.createDocumentFragment(),s=f.selection=document.createDocumentFragment();for(r=0;r<u.sel.ranges.length;r++)(t||r!=u.sel.primIndex)&&((i=u.sel.ranges[r],i.from().line>=n.display.viewTo||i.to().line<n.display.viewFrom)||(e=i.empty(),(e||n.options.showCursorWhenSelecting)&&dy(n,i.head,o),e||yg(n,i,s)));return f}function dy(n,t,r){var u=kt(n,t,"div",null,null,!n.options.singleCursorHeightPerLine),e=r.appendChild(i("div"," ","CodeMirror-cursor")),f;e.style.left=u.left+"px";e.style.top=u.top+"px";e.style.height=Math.max(0,u.bottom-u.top)*n.options.cursorHeight+"px";u.other&&(f=r.appendChild(i("div"," ","CodeMirror-cursor CodeMirror-secondarycursor")),f.style.display="",f.style.left=u.other.left+"px",f.style.top=u.other.top+"px",f.style.height=(u.other.bottom-u.other.top)*.85+"px")}function ns(n,t){return n.top-t.top||n.left-t.left}function yg(r,u,f){function h(n,t,r,u){t<0&&(t=0);t=Math.round(t);u=Math.round(u);k.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+n+"px;\n                             top: "+t+"px; width: "+(r==null?l-n:r)+"px;\n                             height: "+(u-t)+"px"))}function p(i,u,f){function p(t,u){return vc(r,n(i,t),"div",a,u)}function y(n,t,i){var u=py(r,a,null,n),f=t=="ltr"==(i=="after")?"left":"right",e=i=="after"?u.begin:u.end-(/\s/.test(a.text.charAt(u.end-1))?2:1);return p(e,f)[f]}var a=t(v,i),b=a.text.length,o,c,w=hi(a,v.direction);return hk(w,u||0,f==null?b:f,function(n,t,i,r){var k=i=="ltr",a=p(n,k?"left":"right"),v=p(t-1,k?"right":"left"),d=u==null&&n==0,g=f==null&&t==b,it=r==0,rt=!w||r==w.length-1,nt,ut,tt,ft;if(v.top-a.top<=3){var ot=(e?d:g)&&it,st=(e?g:d)&&rt,et=ot?s:(k?a:v).left,ht=st?l:(k?v:a).right;h(et,a.top,ht-et,a.bottom)}else k?(nt=e&&d&&it?s:a.left,ut=e?l:y(n,i,"before"),tt=e?s:y(t,i,"after"),ft=e&&g&&rt?l:v.right):(nt=e?y(n,i,"before"):s,ut=!e&&d&&it?l:a.right,tt=!e&&g&&rt?s:v.left,ft=e?y(t,i,"after"):l),h(nt,a.top,ut-nt,a.bottom),a.bottom<v.top&&h(s,a.bottom,null,v.top),h(tt,v.top,ft-tt,v.bottom);(!o||ns(a,o)<0)&&(o=a);ns(v,o)<0&&(o=v);(!c||ns(a,c)<0)&&(c=a);ns(v,c)<0&&(c=v)}),{start:o,end:c}}var b=r.display,v=r.doc,k=document.createDocumentFragment(),d=uy(r.display),s=d.left,l=Math.max(b.sizerWidth,vr(r)-b.sizer.offsetLeft)-d.right,e=v.direction=="ltr",a=u.from(),y=u.to();if(a.line==y.line)p(a.line,a.ch,y.ch);else{var g=t(v,a.line),nt=t(v,y.line),w=ii(g)==ii(nt),o=p(a.line,a.ch,w?g.text.length+1:null).end,c=p(y.line,w?0:null,y.ch).start;w&&(o.top<c.top-2?(h(o.right,o.top,null,o.bottom),h(s,c.top,c.left,c.bottom)):h(o.right,o.top,c.left-o.right,o.bottom));o.bottom<c.top&&h(s,o.bottom,null,c.top)}f.appendChild(k)}function gc(n){var t,i;n.state.focused&&(t=n.display,clearInterval(t.blinker),i=!0,t.cursorDiv.style.visibility="",n.options.cursorBlinkRate>0?t.blinker=setInterval(function(){n.hasFocus()||hu(n);t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},n.options.cursorBlinkRate):n.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden"))}function gy(n){n.hasFocus()||(n.display.input.focus(),n.state.focused||tl(n))}function nl(n){n.state.delayingBlurEvent=!0;setTimeout(function(){n.state.delayingBlurEvent&&(n.state.delayingBlurEvent=!1,n.state.focused&&hu(n))},100)}function tl(n,t){(n.state.delayingBlurEvent&&!n.state.draggingText&&(n.state.delayingBlurEvent=!1),n.options.readOnly!="nocursor")&&(n.state.focused||(p(n,"focus",n,t),n.state.focused=!0,ur(n.display.wrapper,"CodeMirror-focused"),n.curOp||n.display.selForContextMenu==n.doc.sel||(n.display.input.reset(),tt&&setTimeout(function(){return n.display.input.reset(!0)},20)),n.display.input.receivedFocus()),gc(n))}function hu(n,t){n.state.delayingBlurEvent||(n.state.focused&&(p(n,"blur",n,t),n.state.focused=!1,yi(n.display.wrapper,"CodeMirror-focused")),clearInterval(n.display.blinker),setTimeout(function(){n.state.focused||(n.display.shift=!1)},150))}function ts(n){for(var h,r,c,u,a,f=n.display,v=f.lineDiv.offsetTop,o=0;o<f.view.length;o++){var t=f.view[o],y=n.options.lineWrapping,i=void 0,s=0;if(!t.hidden){if(e&&l<8?(h=t.node.offsetTop+t.node.offsetHeight,i=h-v,v=h):(r=t.node.getBoundingClientRect(),i=r.bottom-r.top,!y&&t.text.firstChild&&(s=t.text.firstChild.getBoundingClientRect().right-r.left-1)),c=t.line.height-i,(c>.005||c<-.005)&&(ni(t.line,i),np(t.line),t.rest))for(u=0;u<t.rest.length;u++)np(t.rest[u]);s>n.display.sizerWidth&&(a=Math.ceil(s/su(n.display)),a>n.display.maxLineLength&&(n.display.maxLineLength=a,n.display.maxLine=t.line,n.display.maxLineChanged=!0))}}}function np(n){var t,i,r;if(n.widgets)for(t=0;t<n.widgets.length;++t)i=n.widgets[t],r=i.node.parentNode,r&&(i.height=r.offsetHeight)}function is(n,i,r){var f=r&&r.top!=null?Math.max(0,r.top):n.scroller.scrollTop,o,s;f=Math.floor(f-bo(n));var h=r&&r.bottom!=null?r.bottom:f+n.wrapper.clientHeight,u=cr(i,f),e=cr(i,h);return r&&r.ensure&&(o=r.ensure.from.line,s=r.ensure.to.line,o<u?(u=o,e=cr(i,ci(t(i,o))+n.wrapper.clientHeight)):Math.min(s,i.lastLine())>=e&&(u=cr(i,ci(t(i,s))-n.wrapper.clientHeight),e=s)),{from:u,to:Math.max(e,u+1)}}function pg(n,t){var u;if(!w(n,"scrollCursorIntoView")){var f=n.display,e=f.sizer.getBoundingClientRect(),r=null;t.top+e.top<0?r=!0:t.bottom+e.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1);r==null||fk||(u=i("div","​",null,"position: absolute;\n                         top: "+(t.top-f.viewOffset-bo(n.display))+"px;\n                         height: "+(t.bottom-t.top+ri(n)+f.barHeight)+"px;\n                         left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;"),n.display.lineSpace.appendChild(u),u.scrollIntoView(r),n.display.lineSpace.removeChild(u))}}function wg(t,i,r,u){var s,h;for(u==null&&(u=0),t.options.lineWrapping||i!=r||(i=i.ch?n(i.line,i.sticky=="before"?i.ch-1:i.ch,"after"):i,r=i.sticky=="before"?n(i.line,i.ch+1,"before"):i),h=0;h<5;h++){var c=!1,f=kt(t,i),e=!r||r==i?f:kt(t,r);s={left:Math.min(f.left,e.left),top:Math.min(f.top,e.top)-u,right:Math.max(f.left,e.left),bottom:Math.max(f.bottom,e.bottom)+u};var o=il(t,s),l=t.doc.scrollTop,a=t.doc.scrollLeft;if(o.scrollTop!=null&&(re(t,o.scrollTop),Math.abs(t.doc.scrollTop-l)>1&&(c=!0)),o.scrollLeft!=null&&(br(t,o.scrollLeft),Math.abs(t.doc.scrollLeft-a)>1&&(c=!0)),!c)break}return s}function bg(n,t){var i=il(n,t);i.scrollTop!=null&&re(n,i.scrollTop);i.scrollLeft!=null&&br(n,i.scrollLeft)}function il(n,t){var r=n.display,h=ou(n.display),o;t.top<0&&(t.top=0);var e=n.curOp&&n.curOp.scrollTop!=null?n.curOp.scrollTop:r.scroller.scrollTop,u=hc(n),i={};t.bottom-t.top>u&&(t.bottom=t.top+u);var c=n.doc.height+sc(r),v=t.top<h,y=t.bottom>c-h;t.top<e?i.scrollTop=v?0:t.top:t.bottom>e+u&&(o=Math.min(t.top,(y?c:t.bottom)-u),o!=e&&(i.scrollTop=o));var l=n.options.fixedGutter?0:r.gutters.offsetWidth,a=n.curOp&&n.curOp.scrollLeft!=null?n.curOp.scrollLeft:r.scroller.scrollLeft-l,f=vr(n)-r.gutters.offsetWidth,s=t.right-t.left>f;return s&&(t.right=t.left+f),t.left<10?i.scrollLeft=0:t.left<a?i.scrollLeft=Math.max(0,t.left+l-(s?0:10)):t.right>f+a-3&&(i.scrollLeft=t.right+(s?0:10)-f),i}function rl(n,t){t!=null&&(rs(n),n.curOp.scrollTop=(n.curOp.scrollTop==null?n.doc.scrollTop:n.curOp.scrollTop)+t)}function cu(n){rs(n);var t=n.getCursor();n.curOp.scrollToPos={from:t,to:t,margin:n.options.cursorScrollMargin}}function ie(n,t,i){(t!=null||i!=null)&&rs(n);t!=null&&(n.curOp.scrollLeft=t);i!=null&&(n.curOp.scrollTop=i)}function kg(n,t){rs(n);n.curOp.scrollToPos=t}function rs(n){var t=n.curOp.scrollToPos,i,r;t&&(n.curOp.scrollToPos=null,i=vy(n,t.from),r=vy(n,t.to),tp(n,i,r,t.margin))}function tp(n,t,i,r){var u=il(n,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});ie(n,u.scrollLeft,u.scrollTop)}function re(n,t){Math.abs(n.doc.scrollTop-t)<2||(ei||el(n,{top:t}),ip(n,t,!0),ei&&el(n),fe(n,100))}function ip(n,t,i){(t=Math.max(0,Math.min(n.display.scroller.scrollHeight-n.display.scroller.clientHeight,t)),n.display.scroller.scrollTop!=t||i)&&(n.doc.scrollTop=t,n.display.scrollbars.setScrollTop(t),n.display.scroller.scrollTop!=t&&(n.display.scroller.scrollTop=t))}function br(n,t,i,r){(t=Math.max(0,Math.min(t,n.display.scroller.scrollWidth-n.display.scroller.clientWidth)),(i?t==n.doc.scrollLeft:Math.abs(n.doc.scrollLeft-t)<2)&&!r)||(n.doc.scrollLeft=t,op(n),n.display.scroller.scrollLeft!=t&&(n.display.scroller.scrollLeft=t),n.display.scrollbars.setScrollLeft(t))}function ue(n){var t=n.display,i=t.gutters.offsetWidth,r=Math.round(n.doc.height+sc(n.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:n.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ri(n)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}function au(n,t){var i,r,u;for(t||(t=ue(n)),i=n.display.barWidth,r=n.display.barHeight,rp(n,t),u=0;u<4&&i!=n.display.barWidth||r!=n.display.barHeight;u++)i!=n.display.barWidth&&n.options.lineWrapping&&ts(n),rp(n,ue(n)),i=n.display.barWidth,r=n.display.barHeight}function rp(n,t){var i=n.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px";i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px";i.heightForcer.style.borderBottom=r.bottom+"px solid transparent";r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="";r.bottom&&n.options.coverGutterNextToScrollbar&&n.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}function up(n){n.display.scrollbars&&(n.display.scrollbars.clear(),n.display.scrollbars.addClass&&yi(n.display.wrapper,n.display.scrollbars.addClass));n.display.scrollbars=new ul[n.options.scrollbarStyle](function(t){n.display.wrapper.insertBefore(t,n.display.scrollbarFiller);r(t,"mousedown",function(){n.state.focused&&setTimeout(function(){return n.display.input.focus()},0)});t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?br(n,t):re(n,t)},n);n.display.scrollbars.addClass&&ur(n.display.wrapper,n.display.scrollbars.addClass)}function kr(n){n.curOp={cm:n,viewChanged:!1,startHeight:n.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++fp};bd(n.curOp)}function dr(n){var t=n.curOp;t&&dd(t,function(n){for(var t=0;t<n.ops.length;t++)n.ops[t].cm.curOp=null;dg(n)})}function dg(n){for(var i,r,u,f,t=n.ops,e=0;e<t.length;e++)gg(t[e]);for(i=0;i<t.length;i++)nn(t[i]);for(r=0;r<t.length;r++)tn(t[r]);for(u=0;u<t.length;u++)rn(t[u]);for(f=0;f<t.length;f++)un(t[f])}function gg(n){var t=n.cm,i=t.display;en(t);n.updateMaxLine&&ec(t);n.mustUpdate=n.viewChanged||n.forceUpdate||n.scrollTop!=null||n.scrollToPos&&(n.scrollToPos.from.line<i.viewFrom||n.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping;n.update=n.mustUpdate&&new ee(t,n.mustUpdate&&{top:n.scrollTop,ensure:n.scrollToPos},n.forceUpdate)}function nn(n){n.updatedDisplay=n.mustUpdate&&fl(n.cm,n.update)}function tn(n){var t=n.cm,i=t.display;n.updatedDisplay&&ts(t);n.barMeasure=ue(t);i.maxLineChanged&&!t.options.lineWrapping&&(n.adjustWidthTo=ey(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=n.adjustWidthTo,n.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+n.adjustWidthTo+ri(t)+t.display.barWidth),n.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+n.adjustWidthTo-vr(t)));(n.updatedDisplay||n.selectionChanged)&&(n.preparedSelection=i.input.prepareSelection())}function rn(n){var t=n.cm,i;n.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=n.adjustWidthTo+"px",n.maxScrollLeft<t.doc.scrollLeft&&br(t,Math.min(t.display.scroller.scrollLeft,n.maxScrollLeft),!0),t.display.maxLineChanged=!1);i=n.focus&&n.focus==oi();n.preparedSelection&&t.display.input.showSelection(n.preparedSelection,i);(n.updatedDisplay||n.startHeight!=t.doc.height)&&au(t,n.barMeasure);n.updatedDisplay&&sl(t,n.barMeasure);n.selectionChanged&&gc(t);t.state.focused&&n.updateInput&&t.display.input.reset(n.typing);i&&gy(n.cm)}function un(n){var t=n.cm,o=t.display,s=t.doc,h,i,r,u,e;if(n.updatedDisplay&&ep(t,n.update),o.wheelStartX!=null&&(n.scrollTop!=null||n.scrollLeft!=null||n.scrollToPos)&&(o.wheelStartX=o.wheelStartY=null),n.scrollTop!=null&&ip(t,n.scrollTop,n.forceScroll),n.scrollLeft!=null&&br(t,n.scrollLeft,!0,!0),n.scrollToPos&&(h=wg(t,f(s,n.scrollToPos.from),f(s,n.scrollToPos.to),n.scrollToPos.margin),pg(t,h)),i=n.maybeHiddenMarkers,r=n.maybeUnhiddenMarkers,i)for(u=0;u<i.length;++u)i[u].lines.length||p(i[u],"hide");if(r)for(e=0;e<r.length;++e)r[e].lines.length&&p(r[e],"unhide");o.wrapper.offsetHeight&&(s.scrollTop=t.display.scroller.scrollTop);n.changeObjs&&p(t,"changes",t,n.changeObjs);n.update&&n.update.finish()}function ot(n,t){if(n.curOp)return t();kr(n);try{return t()}finally{dr(n)}}function b(n,t){return function(){if(n.curOp)return t.apply(n,arguments);kr(n);try{return t.apply(n,arguments)}finally{dr(n)}}}function it(n){return function(){if(this.curOp)return n.apply(this,arguments);kr(this);try{return n.apply(this,arguments)}finally{dr(this)}}}function k(n){return function(){var t=this.cm;if(!t||t.curOp)return n.apply(this,arguments);kr(t);try{return n.apply(this,arguments)}finally{dr(t)}}}function fe(n,t){n.doc.highlightFrontier<n.display.viewTo&&n.state.highlight.set(t,gs(fn,n))}function fn(n){var i=n.doc;if(!(i.highlightFrontier>=n.display.viewTo)){var u=+new Date+n.options.workTime,t=bf(n,i.highlightFrontier),r=[];i.iter(t.line,Math.min(i.first+i.size,n.display.viewTo+500),function(f){var o,e,c,s;if(t.line>=n.display.viewFrom){var h=f.styles,l=f.text.length>n.options.maxHighlightLength?sr(i.mode,t.state):null,a=tv(n,f,t,!0);for(l&&(t.state=l),f.styles=a.styles,o=f.styleClasses,e=a.classes,e?f.styleClasses=e:o&&(f.styleClasses=null),c=!h||h.length!=f.styles.length||o!=e&&(!o||!e||o.bgClass!=e.bgClass||o.textClass!=e.textClass),s=0;!c&&s<h.length;++s)c=h[s]!=f.styles[s];c&&r.push(t.line);f.stateAfter=t.save();t.nextLine()}else f.text.length<=n.options.maxHighlightLength&&dh(n,f.text,t),f.stateAfter=t.line%5==0?t.save():null,t.nextLine();if(+new Date>u)return fe(n,n.options.workDelay),!0});i.highlightFrontier=t.line;i.modeFrontier=Math.max(i.modeFrontier,t.line);r.length&&ot(n,function(){for(var t=0;t<r.length;t++)ki(n,r[t],"text")})}}function en(n){var t=n.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ri(n)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ri(n)+"px",t.scrollbarsClipped=!0)}function on(n){var r,i,t;return n.hasFocus()?null:(r=oi(),!r||!wi(n.display.lineDiv,r))?null:(i={activeElt:r},window.getSelection&&(t=window.getSelection(),t.anchorNode&&t.extend&&wi(n.display.lineDiv,t.anchorNode)&&(i.anchorNode=t.anchorNode,i.anchorOffset=t.anchorOffset,i.focusNode=t.focusNode,i.focusOffset=t.focusOffset)),i)}function sn(n){if(n&&n.activeElt&&n.activeElt!=oi()&&(n.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(n.activeElt.nodeName)&&n.anchorNode&&wi(document.body,n.anchorNode)&&wi(document.body,n.focusNode))){var t=window.getSelection(),i=document.createRange();i.setEnd(n.anchorNode,n.anchorOffset);i.collapse(!1);t.removeAllRanges();t.addRange(i);t.extend(n.focusNode,n.focusOffset)}}function fl(n,i){var r=n.display,e=n.doc,s,o,c;if(i.editorIsHidden)return di(n),!1;if(!i.force&&i.visible.from>=r.viewFrom&&i.visible.to<=r.viewTo&&(r.updateLineNumbers==null||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&by(n)==0)return!1;sp(n)&&(di(n),i.dims=bc(n));var h=e.first+e.size,u=Math.max(i.visible.from-n.options.viewportMargin,e.first),f=Math.min(h,i.visible.to+n.options.viewportMargin);return(r.viewFrom<u&&u-r.viewFrom<20&&(u=Math.max(e.first,r.viewFrom)),r.viewTo>f&&r.viewTo-f<20&&(f=Math.min(h,r.viewTo)),ti&&(u=uc(n.doc,u),f=vv(n.doc,f)),s=u!=r.viewFrom||f!=r.viewTo||r.lastWrapHeight!=i.wrapperHeight||r.lastWrapWidth!=i.wrapperWidth,vg(n,u,f),r.viewOffset=ci(t(n.doc,r.viewFrom)),n.display.mover.style.top=r.viewOffset+"px",o=by(n),!s&&o==0&&!i.force&&r.renderedView==r.view&&(r.updateLineNumbers==null||r.updateLineNumbers>=r.viewTo))?!1:(c=on(n),o>4&&(r.lineDiv.style.display="none"),hn(n,r.updateLineNumbers,i.dims),o>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,sn(c),pi(r.cursorDiv),pi(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=i.wrapperHeight,r.lastWrapWidth=i.wrapperWidth,fe(n,400)),r.updateLineNumbers=null,!0)}function ep(n,t){for(var u,i=t.viewport,r=!0;;r=!1){if(r&&n.options.lineWrapping&&t.oldDisplayWidth!=vr(n))r&&(t.visible=is(n.display,n.doc,i));else if(i&&i.top!=null&&(i={top:Math.min(n.doc.height+sc(n.display)-hc(n),i.top)}),t.visible=is(n.display,n.doc,i),t.visible.from>=n.display.viewFrom&&t.visible.to<=n.display.viewTo)break;if(!fl(n,t))break;ts(n);u=ue(n);te(n);au(n,u);sl(n,u);t.force=!1}t.signal(n,"update",n);(n.display.viewFrom!=n.display.reportedViewFrom||n.display.viewTo!=n.display.reportedViewTo)&&(t.signal(n,"viewportChange",n,n.display.viewFrom,n.display.viewTo),n.display.reportedViewFrom=n.display.viewFrom,n.display.reportedViewTo=n.display.viewTo)}function el(n,t){var i=new ee(n,t),r;fl(n,i)&&(ts(n),ep(n,i),r=ue(n),te(n),au(n,r),sl(n,r),i.finish())}function hn(n,t,i){function c(t){var i=t.nextSibling;return tt&&at&&n.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),i}for(var r,a,h,e=n.display,v=n.options.lineNumbers,o=e.lineDiv,u=o.firstChild,l=e.view,f=e.viewFrom,s=0;s<l.length;s++){if(r=l[s],!r.hidden)if(r.node&&r.node.parentNode==o){while(u!=r.node)u=c(u);h=v&&t!=null&&t<=f&&r.lineNumber;r.changes&&(g(r.changes,"gutter")>-1&&(h=!1),gv(n,r,f,i));h&&(pi(r.lineNumber),r.lineNumber.appendChild(document.createTextNode(wh(n.options,f))));u=r.node.nextSibling}else a=rg(n,r,f,i),o.insertBefore(a,u);f+=r.size}while(u)u=c(u)}function ol(n){var t=n.gutters.offsetWidth;n.sizer.style.marginLeft=t+"px"}function sl(n,t){n.display.sizer.style.minHeight=t.docHeight+"px";n.display.heightForcer.style.top=t.docHeight+"px";n.display.gutters.style.height=t.docHeight+n.display.barHeight+ri(n)+"px"}function op(n){var i=n.display,r=i.view,t,u,f;if(i.alignWidgets||i.gutters.firstChild&&n.options.fixedGutter){var o=kc(i)-i.scroller.scrollLeft+n.doc.scrollLeft,s=i.gutters.offsetWidth,e=o+"px";for(t=0;t<r.length;t++)if(!r[t].hidden&&(n.options.fixedGutter&&(r[t].gutter&&(r[t].gutter.style.left=e),r[t].gutterBackground&&(r[t].gutterBackground.style.left=e)),u=r[t].alignable,u))for(f=0;f<u.length;f++)u[f].style.left=e;n.options.fixedGutter&&(i.gutters.style.left=o+s+"px")}}function sp(n){if(!n.options.lineNumbers)return!1;var u=n.doc,r=wh(n.options,u.first+u.size-1),t=n.display;if(r.length!=t.lineNumChars){var f=t.measure.appendChild(i("div",[i("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),e=f.firstChild.offsetWidth,o=f.offsetWidth-e;return t.lineGutter.style.width="",t.lineNumInnerWidth=Math.max(e,t.lineGutter.offsetWidth-o)+1,t.lineNumWidth=t.lineNumInnerWidth+o,t.lineNumChars=t.lineNumInnerWidth?r.length:-1,t.lineGutter.style.width=t.lineNumWidth+"px",ol(n.display),!0}return!1}function hl(n,t){for(var i,f,r=[],e=!1,u=0;u<n.length;u++){if(i=n[u],f=null,typeof i!="string"&&(f=i.style,i=i.className),i=="CodeMirror-linenumbers")if(t)e=!0;else continue;r.push({className:i,style:f})}return t&&!e&&r.push({className:"CodeMirror-linenumbers",style:null}),r}function hp(n){var r=n.gutters,u=n.gutterSpecs,t;for(pi(r),n.lineGutter=null,t=0;t<u.length;++t){var e=u[t],o=e.className,s=e.style,f=r.appendChild(i("div",null,"CodeMirror-gutter "+o));s&&(f.style.cssText=s);o=="CodeMirror-linenumbers"&&(n.lineGutter=f,f.style.width=(n.lineNumWidth||1)+"px")}r.style.display=u.length?"":"none";ol(n)}function oe(n){hp(n.display);et(n);op(n)}function cn(n,t,r,u){var f=this,o;this.input=r;f.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler");f.scrollbarFiller.setAttribute("cm-not-content","true");f.gutterFiller=i("div",null,"CodeMirror-gutter-filler");f.gutterFiller.setAttribute("cm-not-content","true");f.lineDiv=nu("div",null,"CodeMirror-code");f.selectionDiv=i("div",null,null,"position: relative; z-index: 1");f.cursorDiv=i("div",null,"CodeMirror-cursors");f.measure=i("div",null,"CodeMirror-measure");f.lineMeasure=i("div",null,"CodeMirror-measure");f.lineSpace=nu("div",[f.measure,f.lineMeasure,f.selectionDiv,f.cursorDiv,f.lineDiv],null,"position: relative; outline: none");o=nu("div",[f.lineSpace],"CodeMirror-lines");f.mover=i("div",[o],null,"position: relative");f.sizer=i("div",[f.mover],"CodeMirror-sizer");f.sizerWidth=null;f.heightForcer=i("div",null,null,"position: absolute; height: "+oa+"px; width: 1px;");f.gutters=i("div",null,"CodeMirror-gutters");f.lineGutter=null;f.scroller=i("div",[f.sizer,f.heightForcer,f.gutters],"CodeMirror-scroll");f.scroller.setAttribute("tabIndex","-1");f.wrapper=i("div",[f.scrollbarFiller,f.gutterFiller,f.scroller],"CodeMirror");e&&l<8&&(f.gutters.style.zIndex=-1,f.scroller.style.paddingRight=0);tt||ei&&hf||(f.scroller.draggable=!0);n&&(n.appendChild?n.appendChild(f.wrapper):n(f.wrapper));f.viewFrom=f.viewTo=t.first;f.reportedViewFrom=f.reportedViewTo=t.first;f.view=[];f.renderedView=null;f.externalMeasured=null;f.viewOffset=0;f.lastWrapHeight=f.lastWrapWidth=0;f.updateLineNumbers=null;f.nativeBarWidth=f.barHeight=f.barWidth=0;f.scrollbarsClipped=!1;f.lineNumWidth=f.lineNumInnerWidth=f.lineNumChars=null;f.alignWidgets=!1;f.cachedCharWidth=f.cachedTextHeight=f.cachedPaddingH=null;f.maxLine=null;f.maxLineLength=0;f.maxLineChanged=!1;f.wheelDX=f.wheelDY=f.wheelStartX=f.wheelStartY=null;f.shift=!1;f.selForContextMenu=null;f.activeTouch=null;f.gutterSpecs=hl(u.gutters,u.lineNumbers);hp(f);r.init(f)}function cp(n){var i=n.wheelDeltaX,t=n.wheelDeltaY;return i==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(i=n.detail),t==null&&n.detail&&n.axis==n.VERTICAL_AXIS?t=n.detail:t==null&&(t=n.wheelDelta),{x:i,y:t}}function ln(n){var t=cp(n);return t.x*=st,t.y*=st,t}function lp(n,t){var v=cp(t),e=v.x,u=v.y,i=n.display,r=i.scroller,y=r.scrollWidth>r.clientWidth,h=r.scrollHeight>r.clientHeight,f,c,o;if(e&&y||u&&h){if(u&&at&&tt)n:for(f=t.target,c=i.view;f!=r;f=f.parentNode)for(o=0;o<c.length;o++)if(c[o].node==f){n.display.currentWheelTarget=f;break n}if(e&&!ei&&!wt&&st!=null){u&&h&&re(n,Math.max(0,r.scrollTop+u*st));br(n,Math.max(0,r.scrollLeft+e*st));(!u||u&&h)&&ft(t);i.wheelStartX=null;return}if(u&&st!=null){var l=u*st,s=n.doc.scrollTop,a=s+i.wrapper.clientHeight;l<0?s=Math.max(0,s+l-50):a=Math.min(n.doc.height,a+l+50);el(n,{top:s,bottom:a})}se<20&&(i.wheelStartX==null?(i.wheelStartX=r.scrollLeft,i.wheelStartY=r.scrollTop,i.wheelDX=e,i.wheelDY=u,setTimeout(function(){if(i.wheelStartX!=null){var n=r.scrollLeft-i.wheelStartX,t=r.scrollTop-i.wheelStartY,u=t&&i.wheelDY&&t/i.wheelDY||n&&i.wheelDX&&n/i.wheelDX;(i.wheelStartX=i.wheelStartY=null,u)&&(st=(st*se+u)/(se+1),++se)}},200)):(i.wheelDX+=e,i.wheelDY+=u))}}function dt(n,t,i){var a=n&&n.options.selectionsMayTouch,v=t[i],r;for(t.sort(function(n,t){return u(n.from(),t.from())}),i=g(t,v),r=1;r<t.length;r++){var f=t[r],e=t[r-1],s=u(e.to(),f.from());if(a&&!f.empty()?s>0:s>=0){var h=co(e.from(),f.from()),c=ho(e.to(),f.to()),l=e.empty()?f.from()==f.head:e.from()==e.head;r<=i&&--i;t.splice(--r,2,new o(l?c:h,l?h:c))}}return new ht(t,i)}function nr(n,t){return new ht([new o(n,t||n)],0)}function tr(t){return t.text?n(t.from.line+t.text.length-1,s(t.text).length+(t.text.length==1?t.from.ch:0)):t.to}function ap(t,i){if(u(t,i.from)<0)return t;if(u(t,i.to)<=0)return tr(i);var f=t.line+i.text.length-(i.to.line-i.from.line)-1,r=t.ch;return t.line==i.to.line&&(r+=tr(i).ch-i.to.ch),n(f,r)}function cl(n,t){for(var r,u=[],i=0;i<n.sel.ranges.length;i++)r=n.sel.ranges[i],u.push(new o(ap(r.anchor,t),ap(r.head,t)));return dt(n.cm,u,n.sel.primIndex)}function vp(t,i,r){return t.line==i.line?n(r.line,t.ch-i.ch+r.ch):n(r.line+(t.line-i.line),t.ch)}function an(t,i,r){for(var v,y,h=[],e=n(t.first,0),c=e,f=0;f<i.length;f++){var l=i[f],s=vp(l.from,e,c),a=vp(tr(l),e,c);e=l.to;c=a;r=="around"?(v=t.sel.ranges[f],y=u(v.head,v.anchor)<0,h[f]=new o(y?a:s,y?s:a)):h[f]=new o(s,s)}return new ht(h,t.sel.primIndex)}function ll(n){n.doc.mode=vh(n.options,n.doc.modeOption);he(n)}function he(n){n.doc.iter(function(n){n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null)});n.doc.modeFrontier=n.doc.highlightFrontier=n.doc.first;fe(n,100);n.state.modeGen++;n.curOp&&et(n)}function yp(n,t){return t.from.ch==0&&t.to.ch==0&&s(t.text)==""&&(!n.cm||n.cm.options.wholeLineUpdateBefore)}function al(n,i,r,u){function a(n){return r?r[n]:null}function h(n,t,r){cd(n,t,r,u);d(n,"change",n,i)}function y(n,t){for(var r=[],i=n;i<t;++i)r.push(new lr(f[i],a(i),u));return r}var e=i.from,c=i.to,f=i.text,o=t(n,e.line),l=t(n,c.line),w=s(f),p=a(f.length-1),v=c.line-e.line,b,k,g;i.full?(n.insert(0,y(0,f.length)),n.remove(f.length,n.size-f.length)):yp(n,i)?(b=y(0,f.length-1),h(l,l.text,p),v&&n.remove(e.line,v),b.length&&n.insert(e.line,b)):o==l?f.length==1?h(o,o.text.slice(0,e.ch)+w+o.text.slice(c.ch),p):(k=y(1,f.length-1),k.push(new lr(w+o.text.slice(c.ch),p,u)),h(o,o.text.slice(0,e.ch)+f[0],a(0)),n.insert(e.line+1,k)):f.length==1?(h(o,o.text.slice(0,e.ch)+f[0]+l.text.slice(c.ch),a(0)),n.remove(e.line+1,v)):(h(o,o.text.slice(0,e.ch)+f[0],a(0)),h(l,w+l.text.slice(c.ch),p),g=y(1,f.length-1),v>1&&n.remove(e.line+1,v-1),n.insert(e.line+1,g));d(n,"change",n,i)}function ir(n,t,i){function r(n,u,f){var o,e,s;if(n.linked)for(o=0;o<n.linked.length;++o)(e=n.linked[o],e.doc!=u)&&(s=f&&e.sharedHist,!i||s)&&(t(e.doc,s),r(e.doc,n,s))}r(n,null,!0)}function pp(n,t){if(t.cm)throw new Error("This document is already in use.");n.doc=t;t.cm=n;dc(n);ll(n);wp(n);n.options.lineWrapping||ec(n);n.options.mode=t.modeOption;et(n)}function wp(n){(n.doc.direction=="rtl"?ur:yi)(n.display.lineDiv,"CodeMirror-rtl")}function vn(n){ot(n,function(){wp(n);et(n)})}function us(n){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=n||1}function vl(n,t){var i={from:kh(t.from),to:tr(t),text:hr(n,t.from,t.to)};return dp(n,i,t.from.line,t.to.line+1),ir(n,function(n){return dp(n,i,t.from.line,t.to.line+1)},!0),i}function bp(n){while(n.length){var t=s(n);if(t.ranges)n.pop();else break}}function yn(n,t){return t?(bp(n.done),s(n.done)):n.done.length&&!s(n.done).ranges?s(n.done):n.done.length>1&&!n.done[n.done.length-2].ranges?(n.done.pop(),s(n.done)):void 0}function kp(n,t,i,r){var f=n.history,h,e,o,c;if(f.undone.length=0,h=+new Date,(f.lastOp==r||f.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&f.lastModTime>h-(n.cm?n.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(e=yn(f,f.lastOp==r)))o=s(e.changes),u(t.from,t.to)==0&&u(t.from,o.to)==0?o.to=tr(t):e.changes.push(vl(n,t));else for(c=s(f.done),c&&c.ranges||fs(n.sel,f.done),e={changes:[vl(n,t)],generation:f.generation},f.done.push(e);f.done.length>f.undoDepth;)f.done.shift(),f.done[0].ranges||f.done.shift();f.done.push(i);f.generation=++f.maxGeneration;f.lastModTime=f.lastSelTime=h;f.lastOp=f.lastSelOp=r;f.lastOrigin=f.lastSelOrigin=t.origin;o||p(n,"historyAdded")}function pn(n,t,i,r){var u=t.charAt(0);return u=="*"||u=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-n.history.lastSelTime<=(n.cm?n.cm.options.historyEventDelay:500)}function wn(n,t,i,r){var u=n.history,f=r&&r.origin;i==u.lastSelOp||f&&u.lastSelOrigin==f&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==f||pn(n,f,s(u.done),t))?u.done[u.done.length-1]=t:fs(t,u.done);u.lastSelTime=+new Date;u.lastSelOrigin=f;u.lastSelOp=i;r&&r.clearRedo!==!1&&bp(u.undone)}function fs(n,t){var i=s(t);i&&i.ranges&&i.equals(n)||t.push(n)}function dp(n,t,i,r){var u=t["spans_"+n.id],f=0;n.iter(Math.max(n.first,i),Math.min(n.first+n.size,r),function(i){i.markedSpans&&((u||(u=t["spans_"+n.id]={}))[f]=i.markedSpans);++f})}function bn(n){var t,i;if(!n)return null;for(i=0;i<n.length;++i)n[i].marker.explicitlyCleared?t||(t=n.slice(0,i)):t&&t.push(n[i]);return t?t.length?t:null:n}function kn(n,t){var u=t["spans_"+n.id],r,i;if(!u)return null;for(r=[],i=0;i<t.text.length;++i)r.push(bn(u[i]));return r}function gp(n,t){var i=kn(n,t),s=ic(n,t),r,f,u,e,h,o;if(!i)return s;if(!s)return i;for(r=0;r<i.length;++r)if(f=i[r],u=s[r],f&&u)n:for(e=0;e<u.length;++e){for(h=u[e],o=0;o<f.length;++o)if(f[o].marker==h.marker)continue n;f.push(h)}else u&&(i[r]=u);return i}function vu(n,t,i){for(var u,l,e,o,r,a,f,h=[],c=0;c<n.length;++c){if(u=n[c],u.ranges){h.push(i?ht.prototype.deepCopy.call(u):u);continue}for(l=u.changes,e=[],h.push({changes:e}),o=0;o<l.length;++o)if(r=l[o],a=void 0,e.push({from:r.from,to:r.to,text:r.text}),t)for(f in r)(a=f.match(/^spans_(\d+)$/))&&g(t,Number(a[1]))>-1&&(s(e)[f]=r[f],delete r[f])}return h}function yl(n,t,i,r){var f,e;return r?(f=n.anchor,i&&(e=u(t,f)<0,e!=u(i,f)<0?(f=t,t=i):e!=u(t,i)<0&&(t=i)),new o(f,t)):new o(i||t,t)}function es(n,t,i,r,u){u==null&&(u=n.cm&&(n.cm.display.shift||n.extend));nt(n,new ht([yl(n.sel.primary(),t,i,u)],0),r)}function nw(n,t,i){for(var f,u=[],e=n.cm&&(n.cm.display.shift||n.extend),r=0;r<n.sel.ranges.length;r++)u[r]=yl(n.sel.ranges[r],t[r],null,e);f=dt(n.cm,u,n.sel.primIndex);nt(n,f,i)}function pl(n,t,i,r){var u=n.sel.ranges.slice(0);u[t]=i;nt(n,dt(n.cm,u,n.sel.primIndex),r)}function tw(n,t,i,r){nt(n,nr(t,i),r)}function dn(n,t,i){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var i=0;i<t.length;i++)this.ranges[i]=new o(f(n,t[i].anchor),f(n,t[i].head))},origin:i&&i.origin};return p(n,"beforeSelectionChange",n,r),n.cm&&p(n.cm,"beforeSelectionChange",n.cm,r),r.ranges!=t.ranges?dt(n.cm,r.ranges,r.ranges.length-1):t}function iw(n,t,i){var r=n.history.done,u=s(r);u&&u.ranges?(r[r.length-1]=t,os(n,t,i)):nt(n,t,i)}function nt(n,t,i){os(n,t,i);wn(n,n.sel,n.cm?n.cm.curOp.id:NaN,i)}function os(n,t,i){(yt(n,"beforeSelectionChange")||n.cm&&yt(n.cm,"beforeSelectionChange"))&&(t=dn(n,t,i));var r=i&&i.bias||(u(t.primary().head,n.sel.primary().head)<0?-1:1);rw(n,fw(n,t,r,!0));i&&i.scroll===!1||!n.cm||cu(n.cm)}function rw(n,t){t.equals(n.sel)||(n.sel=t,n.cm&&(n.cm.curOp.updateInput=1,n.cm.curOp.selectionChanged=!0,pa(n.cm)),d(n,"cursorActivity",n))}function uw(n){rw(n,fw(n,n.sel,null,!1))}function fw(n,t,i,r){for(var u,f=0;f<t.ranges.length;f++){var e=t.ranges[f],s=t.ranges.length==n.sel.ranges.length&&n.sel.ranges[f],h=ss(n,e.anchor,s&&s.anchor,i,r),c=ss(n,e.head,s&&s.head,i,r);(u||h!=e.anchor||c!=e.head)&&(u||(u=t.ranges.slice(0,f)),u[f]=new o(h,c))}return u?dt(n.cm,u,t.primIndex):t}function yu(n,i,r,f,e){var c=t(n,i.line),a,s,v,l;if(c.markedSpans)for(a=0;a<c.markedSpans.length;++a){var h=c.markedSpans[a],o=h.marker,y="selectLeft"in o?!o.selectLeft:o.inclusiveLeft,w="selectRight"in o?!o.selectRight:o.inclusiveRight;if((h.from==null||(y?h.from<=i.ch:h.from<i.ch))&&(h.to==null||(w?h.to>=i.ch:h.to>i.ch))){if(e&&(p(o,"beforeCursorEnter"),o.explicitlyCleared))if(c.markedSpans){--a;continue}else break;if(!o.atomic)continue;return r&&(s=o.find(f<0?1:-1),v=void 0,(f<0?w:y)&&(s=ew(n,s,-f,s&&s.line==i.line?c:null)),s&&s.line==i.line&&(v=u(s,r))&&(f<0?v<0:v>0))?yu(n,s,i,f,e):(l=o.find(f<0?-1:1),(f<0?y:w)&&(l=ew(n,l,f,l.line==i.line?c:null)),l?yu(n,l,i,f,e):null)}}return i}function ss(t,i,r,u,f){var e=u||1,o=yu(t,i,r,e,f)||!f&&yu(t,i,r,e,!0)||yu(t,i,r,-e,f)||!f&&yu(t,i,r,-e,!0);return o?o:(t.cantEdit=!0,n(t.first,0))}function ew(i,r,u,e){return u<0&&r.ch==0?r.line>i.first?f(i,n(r.line-1)):null:u>0&&r.ch==(e||t(i,r.line)).text.length?r.line<i.first+i.size-1?n(r.line+1,0):null:new n(r.line,r.ch+u)}function ow(t){t.setSelection(n(t.firstLine(),0),n(t.lastLine()),gt)}function sw(n,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return(i&&(r.update=function(t,i,u,e){t&&(r.from=f(n,t));i&&(r.to=f(n,i));u&&(r.text=u);e!==undefined&&(r.origin=e)}),p(n,"beforeChange",n,r),n.cm&&p(n.cm,"beforeChange",n.cm,r),r.canceled)?(n.cm&&(n.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function pu(n,t,i){var u,r;if(n.cm){if(!n.cm.curOp)return b(n.cm,pu)(n,t,i);if(n.cm.state.suppressEdits)return}if(!yt(n,"beforeChange")&&(!n.cm||!yt(n.cm,"beforeChange"))||(t=sw(n,t,!0),t))if(u=tc&&!i&&ed(n,t.from,t.to),u)for(r=u.length-1;r>=0;--r)hw(n,{from:u[r].from,to:u[r].to,text:r?[""]:t.text,origin:t.origin});else hw(n,t)}function hw(n,t){var i,r;(t.text.length!=1||t.text[0]!=""||u(t.from,t.to)!=0)&&(i=cl(n,t),kp(n,t,i,n.cm?n.cm.curOp.id:NaN),ce(n,t,i,ic(n,t)),r=[],ir(n,function(n,i){i||g(r,n.history)!=-1||(vw(n.history,t),r.push(n.history));ce(n,t,null,ic(n,t))}))}function hs(n,t,i){var a=n.cm&&n.cm.state.suppressEdits,c,y,p,o,l;if(!a||i){for(var u=n.history,r,v=n.sel,f=t=="undo"?u.done:u.undone,h=t=="undo"?u.undone:u.done,e=0;e<f.length;e++)if(r=f[e],i?r.ranges&&!r.equals(n.sel):!r.ranges)break;if(e!=f.length){for(u.lastOrigin=u.lastSelOrigin=null;;)if(r=f.pop(),r.ranges){if(fs(r,h),i&&!r.equals(n.sel)){nt(n,r,{clearRedo:!1});return}v=r}else{if(a){f.push(r);return}break}for(c=[],fs(v,h),h.push({changes:c,generation:u.generation}),u.generation=r.generation||++u.maxGeneration,y=yt(n,"beforeChange")||n.cm&&yt(n.cm,"beforeChange"),p=function(i){var u=r.changes[i],o,e;if(u.origin=t,y&&!sw(n,u,!1))return f.length=0,{};c.push(vl(n,u));o=i?cl(n,u):s(f);ce(n,u,o,gp(n,u));!i&&n.cm&&n.cm.scrollIntoView({from:u.from,to:tr(u)});e=[];ir(n,function(n,t){t||g(e,n.history)!=-1||(vw(n.history,u),e.push(n.history));ce(n,u,null,gp(n,u))})},o=r.changes.length-1;o>=0;--o)if(l=p(o),l)return l.v}}}function cw(t,i){if(i!=0&&(t.first+=i,t.sel=new ht(fo(t.sel.ranges,function(t){return new o(n(t.anchor.line+i,t.anchor.ch),n(t.head.line+i,t.head.ch))}),t.sel.primIndex),t.cm)){et(t.cm,t.first,t.first-i,i);for(var u=t.cm.display,r=u.viewFrom;r<u.viewTo;r++)ki(t.cm,r,"gutter")}}function ce(i,r,u,f){var o,e;if(i.cm&&!i.cm.curOp)return b(i.cm,ce)(i,r,u,f);if(r.to.line<i.first){cw(i,r.text.length-1-(r.to.line-r.from.line));return}r.from.line>i.lastLine()||(r.from.line<i.first&&(o=r.text.length-1-(i.first-r.from.line),cw(i,o),r={from:n(i.first,0),to:n(r.to.line+o,r.to.ch),text:[s(r.text)],origin:r.origin}),e=i.lastLine(),r.to.line>e&&(r={from:r.from,to:n(e,t(i,e).text.length),text:[r.text[0]],origin:r.origin}),r.removed=hr(i,r.from,r.to),u||(u=cl(i,r)),i.cm?gn(i.cm,r,f):al(i,r,f),os(i,u,gt),i.cantEdit&&ss(i,n(i.firstLine(),0))&&(i.cantEdit=!1))}function gn(n,i,r){var f=n.doc,e=n.display,u=i.from,o=i.to,s=!1,h=u.line,y,l,a,v;n.options.lineWrapping||(h=c(ii(t(f,u.line))),f.iter(h,o.line+1,function(n){if(n==e.maxLine)return s=!0,!0}));f.sel.contains(i.from,i.to)>-1&&pa(n);al(f,i,r,wy(n));n.options.lineWrapping||(f.iter(h,u.line+i.text.length,function(n){var t=po(n);t>e.maxLineLength&&(e.maxLine=n,e.maxLineLength=t,e.maxLineChanged=!0,s=!1)}),s&&(n.curOp.updateMaxLine=!0));gk(f,u.line);fe(n,400);y=i.text.length-(o.line-u.line)-1;i.full?et(n):u.line!=o.line||i.text.length!=1||yp(n.doc,i)?et(n,u.line,o.line+1,y):ki(n,u.line,"text");l=yt(n,"changes");a=yt(n,"change");(a||l)&&(v={from:u,to:o,text:i.text,removed:i.removed,origin:i.origin},a&&d(n,"change",n,v),l&&(n.curOp.changeObjs||(n.curOp.changeObjs=[])).push(v));n.display.selForContextMenu=null}function wu(n,t,i,r,f){var e;r||(r=i);u(r,i)<0&&(e=[r,i],i=e[0],r=e[1]);typeof t=="string"&&(t=n.splitLines(t));pu(n,{from:i,to:r,text:t,origin:f})}function lw(n,t,i,r){i<n.line?n.line+=r:t<n.line&&(n.line=t,n.ch=0)}function aw(t,i,r,u){for(var f,c,s,h,e,o=0;o<t.length;++o){if(f=t[o],c=!0,f.ranges){for(f.copied||(f=t[o]=f.deepCopy(),f.copied=!0),s=0;s<f.ranges.length;s++)lw(f.ranges[s].anchor,i,r,u),lw(f.ranges[s].head,i,r,u);continue}for(h=0;h<f.changes.length;++h)if(e=f.changes[h],r<e.from.line)e.from=n(e.from.line+u,e.from.ch),e.to=n(e.to.line+u,e.to.ch);else if(i<=e.to.line){c=!1;break}c||(t.splice(0,o+1),o=0)}}function vw(n,t){var i=t.from.line,r=t.to.line,u=t.text.length-(r-i)-1;aw(n.done,i,r,u);aw(n.undone,i,r,u)}function le(n,i,r,u){var f=i,e=i;return(typeof i=="number"?e=t(n,ga(n,i)):f=c(i),f==null)?null:(u(e,f)&&n.cm&&ki(n.cm,f,r),e)}function ae(n){var i,t;for(this.lines=n,this.parent=null,i=0,t=0;t<n.length;++t)n[t].parent=this,i+=n[t].height;this.height=i}function ve(n){var r,u,t,i;for(this.children=n,r=0,u=0,t=0;t<n.length;++t)i=n[t],r+=i.chunkSize(),u+=i.height,i.parent=this;this.size=r;this.height=u;this.parent=null}function yw(n,t,i){ci(t)<(n.curOp&&n.curOp.scrollTop||n.doc.scrollTop)&&rl(n,i)}function ntt(n,t,i,r){var u=new bu(n,i,r),f=n.cm;return f&&u.noHScroll&&(f.display.alignWidgets=!0),le(n,t,"widget",function(t){var i=t.widgets||(t.widgets=[]),r;return u.insertAt==null?i.push(u):i.splice(Math.min(i.length,Math.max(0,u.insertAt)),0,u),u.line=t,f&&!bi(n,t)&&(r=ci(t)<n.scrollTop,ni(t,t.height+gf(u)),r&&rl(f,u.height),f.curOp.forceUpdate=!0),!0}),f&&d(f,"lineWidgetAdded",f,u,typeof t=="number"?t:c(t)),u}function ku(n,t,i,f,e){var o,l,h,s,a,c;if(f&&f.shared)return ttt(n,t,i,f,e);if(n.cm&&!n.cm.curOp)return b(n.cm,ku)(n,t,i,f,e);if(o=new ai(n,e),l=u(t,i),f&&fr(f,o,!1),l>0||l==0&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=nu("span",[o.replacedWith],"CodeMirror-widget"),f.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),f.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(av(n,t.line,t,i,o)||t.line!=i.line&&av(n,i.line,t,i,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");td()}if(o.addToHistory&&kp(n,{from:t,to:i,origin:"markText"},n.sel,NaN),h=t.line,s=n.cm,n.iter(h,i.line+1,function(n){s&&o.collapsed&&!s.options.lineWrapping&&ii(n)==s.display.maxLine&&(a=!0);o.collapsed&&h!=t.line&&ni(n,0);rd(n,new lo(o,h==t.line?t.ch:null,h==i.line?i.ch:null));++h}),o.collapsed&&n.iter(t.line,i.line+1,function(t){bi(n,t)&&ni(t,0)}),o.clearOnEnter&&r(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(nd(),(n.history.done.length||n.history.undone.length)&&n.clearHistory()),o.collapsed&&(o.id=++wl,o.atomic=!0),s){if(a&&(s.curOp.updateMaxLine=!0),o.collapsed)et(s,t.line,i.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(c=t.line;c<=i.line;c++)ki(s,c,"text");o.atomic&&uw(s.doc);d(s,"markerAdded",s,o)}return o}function ttt(n,t,i,r,u){r=fr(r);r.shared=!1;var e=[ku(n,t,i,r,u)],o=e[0],h=r.widgetNode;return ir(n,function(n){h&&(r.widgetNode=h.cloneNode(!0));e.push(ku(n,f(n,t),f(n,i),r,u));for(var c=0;c<n.linked.length;++c)if(n.linked[c].isParent)return;o=s(e)}),new du(e,o)}function pw(t){return t.findMarks(n(t.first,0),t.clipPos(n(t.lastLine())),function(n){return n.parent})}function itt(n,t){for(var f,r=0;r<t.length;r++){var i=t[r],e=i.find(),o=n.clipPos(e.from),s=n.clipPos(e.to);u(o,s)&&(f=ku(n,o,s,i.primary,i.primary.type),i.markers.push(f),f.parent=i)}}function rtt(n){for(var i=function(t){var i=n[t],f=[i.primary.doc],r,u;for(ir(i.primary.doc,function(n){return f.push(n)}),r=0;r<i.markers.length;r++)u=i.markers[r],g(f,u.doc)==-1&&(u.parent=null,i.markers.splice(r--,1))},t=0;t<n.length;t++)i(t)}function utt(n){var t=this,i,r,u,c,o,s;if((bw(t),!w(t,n)&&!li(t.display,n))&&(ft(n),e&&(bl=+new Date),i=pr(t,n,!0),r=n.dataTransfer.files,i&&!t.isReadOnly()))if(r&&r.length&&window.FileReader&&window.File){var l=r.length,a=Array(l),v=0,h=function(){++v==l&&b(t,function(){i=f(t.doc,i);var n={from:i,to:i,text:t.doc.splitLines(a.filter(function(n){return n!=null}).join(t.doc.lineSeparator())),origin:"paste"};pu(t.doc,n);iw(t.doc,nr(f(t.doc,i),f(t.doc,tr(n))))})()},y=function(n,i){if(t.options.allowDropFileTypes&&g(t.options.allowDropFileTypes,n.type)==-1){h();return}var r=new FileReader;r.onerror=function(){return h()};r.onload=function(){var n=r.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(n)){h();return}a[i]=n;h()};r.readAsText(n)};for(u=0;u<r.length;u++)y(r[u],u)}else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(n);setTimeout(function(){return t.display.input.focus()},20);return}try{if(c=n.dataTransfer.getData("Text"),c){if(t.state.draggingText&&!t.state.draggingText.copy&&(o=t.listSelections()),os(t.doc,nr(i,i)),o)for(s=0;s<o.length;++s)wu(t.doc,"",o[s].anchor,o[s].head,"drag");t.replaceSelection(c,"around","paste");t.display.input.focus()}}catch(p){}}}function ftt(n,t){if(e&&(!n.state.draggingText||+new Date-bl<100)){yf(t);return}if(!w(n,t)&&!li(n.display,t)&&(t.dataTransfer.setData("Text",n.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!to)){var r=i("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";wt&&(r.width=r.height=1,n.display.wrapper.appendChild(r),r._top=r.offsetTop);t.dataTransfer.setDragImage(r,0,0);wt&&r.parentNode.removeChild(r)}}function ett(n,t){var u=pr(n,t),r;u&&(r=document.createDocumentFragment(),dy(n,u,r),n.display.dragCursor||(n.display.dragCursor=i("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),n.display.lineSpace.insertBefore(n.display.dragCursor,n.display.cursorDiv)),ct(n.display.dragCursor,r))}function bw(n){n.display.dragCursor&&(n.display.lineSpace.removeChild(n.display.dragCursor),n.display.dragCursor=null)}function kw(n){var r,t,i,u;if(document.getElementsByClassName){for(r=document.getElementsByClassName("CodeMirror"),t=[],i=0;i<r.length;i++)u=r[i].CodeMirror,u&&t.push(u);t.length&&t[0].operation(function(){for(var i=0;i<t.length;i++)n(t[i])})}}function ott(){kl||(stt(),kl=!0)}function stt(){var n;r(window,"resize",function(){n==null&&(n=setTimeout(function(){n=null;kw(htt)},100))});r(window,"blur",function(){return kw(hu)})}function htt(n){var t=n.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null;t.scrollbarsClipped=!1;n.setSize()}function ctt(n){var i=n.split(/-(?!$)/),u,f,e,o,r,t;for(n=i[i.length-1],r=0;r<i.length-1;r++)if(t=i[r],/^(cmd|meta|m)$/i.test(t))o=!0;else if(/^a(lt)?$/i.test(t))u=!0;else if(/^(c|ctrl|control)$/i.test(t))f=!0;else if(/^s(hift)?$/i.test(t))e=!0;else throw new Error("Unrecognized modifier name: "+t);return u&&(n="Alt-"+n),f&&(n="Ctrl-"+n),o&&(n="Cmd-"+n),e&&(n="Shift-"+n),n}function ltt(n){var e={},t,o,r,u,f,i,s,h;for(t in n)if(n.hasOwnProperty(t)){if(o=n[t],/^(name|fallthrough|(de|at)tach)$/.test(t))continue;if(o=="..."){delete n[t];continue}for(r=fo(t.split(" "),ctt),u=0;u<r.length;u++)if(f=void 0,i=void 0,u==r.length-1?(i=r.join(" "),f=o):(i=r.slice(0,u+1).join(" "),f="..."),s=e[i],s){if(s!=f)throw new Error("Inconsistent bindings for "+i);}else e[i]=f;delete n[t]}for(h in e)n[h]=e[h];return n}function tf(n,t,i,r){var u,f,e;if(t=cs(t),u=t.call?t.call(n,r):t[n],u===!1)return"nothing";if(u==="...")return"multi";if(u!=null&&i(u))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return tf(n,t.fallthrough,i,r);for(f=0;f<t.fallthrough.length;f++)if(e=tf(n,t.fallthrough[f],i,r),e)return e}}function dw(n){var t=typeof n=="string"?n:vi[n.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function gw(n,t,i){var r=n;return t.altKey&&r!="Alt"&&(n="Alt-"+n),(ks?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(n="Ctrl-"+n),(ks?t.ctrlKey:t.metaKey)&&r!="Mod"&&(n="Cmd-"+n),!i&&t.shiftKey&&r!="Shift"&&(n="Shift-"+n),n}function nb(n,t){if(wt&&n.keyCode==34&&n.char)return!1;var i=vi[n.keyCode];return i==null||n.altGraphKey?!1:(n.keyCode==3&&n.code&&(i=n.code),gw(i,n,t))}function cs(n){return typeof n=="string"?fi[n]:n}function rf(n,t){for(var r,e,o=n.doc.sel.ranges,i=[],f=0;f<o.length;f++){for(r=t(o[f]);i.length&&u(r.from,s(i).to)<=0;)if(e=i.pop(),u(e.from,r.from)<0){r.from=e.from;break}i.push(r)}ot(n,function(){for(var t=i.length-1;t>=0;t--)wu(n.doc,"",i[t].from,i[t].to,"+delete");cu(n)})}function dl(n,t,i){var r=va(n.text,t+i,i);return r<0||r>n.text.length?null:r}function gl(t,i,r){var u=dl(t,i.ch,r);return u==null?null:new n(i.line,u,r<0?"after":"before")}function na(t,i,r,u,f){var h,c,a;if(t&&(i.doc.direction=="rtl"&&(f=-f),h=hi(r,i.doc.direction),h)){var o=f<0?s(h):h[0],v=f<0==(o.level==1),l=v?"after":"before",e;return o.level>0||i.doc.direction=="rtl"?(c=eu(i,r),e=f<0?r.text.length-1:0,a=ui(i,c,e).top,e=af(function(n){return ui(i,c,n).top==a},f<0==(o.level==1)?o.from:o.to-1,e),l=="before"&&(e=dl(r,e,1))):e=f<0?o.to:o.from,new n(u,e,l)}return new n(u,f<0?r.text.length:0,f<0?"before":"after")}function att(t,i,r,u){var o=hi(i,t.doc.direction),v,f,l,e,b,p,h,a;if(!o||(r.ch>=i.text.length?(r.ch=i.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after"),v=vf(o,r.ch,r.sticky),f=o[v],t.doc.direction=="ltr"&&f.level%2==0&&(u>0?f.to>r.ch:f.from<r.ch)))return gl(i,r,u);var s=function(t,r){return dl(i,t instanceof n?t.ch:t,r)},y,w=function(n){return t.options.lineWrapping?(y=y||eu(t,i),py(t,i,y,n)):{begin:0,end:i.text.length}},c=w(r.sticky=="before"?s(r,-1):r.ch);return(t.doc.direction=="rtl"||f.level==1)&&(l=f.level==1==u<0,e=s(r,l?1:-1),e!=null&&(l?e<=f.to&&e<=c.end:e>=f.from&&e>=c.begin))?(b=l?"before":"after",new n(r.line,e,b)):(p=function(t,i,u){for(var c=function(t,i){return i?new n(r.line,s(t,1),"before"):new n(r.line,t,"after")};t>=0&&t<o.length;t+=i){var e=o[t],h=i>0==(e.level!=1),f=h?u.begin:s(u.end,-1);if(e.from<=f&&f<e.to||(f=h?e.from:s(e.to,-1),u.begin<=f&&f<u.end))return c(f,h)}},h=p(v+u,u,c),h)?h:(a=u>0?c.end:s(c.begin,-1),a!=null&&!(u>0&&a==i.text.length)&&(h=p(u>0?0:o.length-1,u,w(a)),h))?h:null}function tb(n,i){var u=t(n.doc,i),r=ii(u);return r!=u&&(i=c(r)),na(!0,n,r,i,1)}function vtt(n,i){var r=t(n.doc,i),u=sd(r);return u!=r&&(i=c(u)),na(!0,n,r,i,-1)}function ib(i,r){var u=tb(i,r.line),e=t(i.doc,u.line),o=hi(e,i.doc.direction),f,s;return!o||o[0].level==0?(f=Math.max(u.ch,e.text.search(/\S/)),s=r.line==u.line&&r.ch<=f&&r.ch,n(u.line,s?0:f,u.sticky)):u}function ls(n,t,i){if(typeof t=="string"&&(t=uf[t],!t))return!1;n.display.input.ensurePolled();var u=n.display.shift,r=!1;try{n.isReadOnly()&&(n.state.suppressEdits=!0);i&&(n.display.shift=!1);r=t(n)!=uo}finally{n.display.shift=u;n.state.suppressEdits=!1}return r}function ytt(n,t,i){for(var u,r=0;r<n.state.keyMaps.length;r++)if(u=tf(t,n.state.keyMaps[r],i,n),u)return u;return n.options.extraKeys&&tf(t,n.options.extraKeys,i,n)||tf(t,n.options.keyMap,i,n)}function pe(n,t,i,r){var u=n.state.keySeq;if(u){if(dw(t))return"handled";if(/\'$/.test(t)?n.state.keySeq=null:rb.set(50,function(){n.state.keySeq==u&&(n.state.keySeq=null,n.display.input.reset())}),ub(n,u+" "+t,i,r))return!0}return ub(n,t,i,r)}function ub(n,t,i,r){var u=ytt(n,t,r);return u=="multi"&&(n.state.keySeq=t),u=="handled"&&d(n,"keyHandled",n,t,i),(u=="handled"||u=="multi")&&(ft(i),gc(n)),!!u}function fb(n,t){var i=nb(t,!0);return i?t.shiftKey&&!n.state.keySeq?pe(n,"Shift-"+i,t,function(t){return ls(n,t,!0)})||pe(n,i,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return ls(n,t)}):pe(n,i,t,function(t){return ls(n,t)}):!1}function ptt(n,t,i){return pe(n,"'"+i+"'",t,function(t){return ls(n,t,!0)})}function eb(n){var t=this,i,r;n.target&&n.target!=t.display.input.getField()||(t.curOp.focus=oi(),w(t,n))||(e&&l<11&&n.keyCode==27&&(n.returnValue=!1),i=n.keyCode,t.display.shift=i==16||n.shiftKey,r=fb(t,n),wt&&(as=r?i:null,r||i!=88||vk||!(at?n.metaKey:n.ctrlKey)||t.replaceSelection("",null,"cut")),ei&&!at&&!r&&i==46&&n.shiftKey&&!n.ctrlKey&&document.execCommand&&document.execCommand("cut"),i!=18||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||wtt(t))}function wtt(n){function t(n){n.keyCode!=18&&n.altKey||(yi(i,"CodeMirror-crosshair"),lt(document,"keyup",t),lt(document,"mouseover",t))}var i=n.display.lineDiv;ur(i,"CodeMirror-crosshair");r(document,"keyup",t);r(document,"mouseover",t)}function ob(n){n.keyCode==16&&(this.doc.sel.shift=!1);w(this,n)}function sb(n){var t=this,i,r,u;if((!n.target||n.target==t.display.input.getField())&&!li(t.display,n)&&!w(t,n)&&(!n.ctrlKey||n.altKey)&&(!at||!n.metaKey)){if(i=n.keyCode,r=n.charCode,wt&&i==as){as=null;ft(n);return}if((!wt||!(!n.which||n.which<10)||!fb(t,n))&&(u=String.fromCharCode(r==null?i:r),u!="\b")&&!ptt(t,n,u))t.display.input.onKeyPress(n)}}function btt(n,t){var i=+new Date;return be&&be.compare(i,n,t)?(we=be=null,"triple"):we&&we.compare(i,n,t)?(be=new vs(i,n,t),we=null,"double"):(we=new vs(i,n,t),be=null,"single")}function cb(n){var t=this,i=t.display;if(!w(t,n)&&(!i.activeTouch||!i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=n.shiftKey,li(i,n)){tt||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(!ta(t,n)){var r=pr(t,n),u=ba(n),f=r?btt(r,u):"single";if(window.focus(),u==1&&t.state.selectingText&&t.state.selectingText(n),!r||!ktt(t,u,r,f,n))if(u==1)r?gtt(t,r,f,n):sh(n)==i.scroller&&ft(n);else if(u==2)r&&es(t.doc,r),setTimeout(function(){return i.input.focus()},20);else if(u==3)if(ro)t.display.input.onContextMenu(n);else nl(t)}}}function ktt(n,t,i,r,u){var f="Click";return r=="double"?f="Double"+f:r=="triple"&&(f="Triple"+f),f=(t==1?"Left":t==2?"Middle":"Right")+f,pe(n,gw(f,u),u,function(t){if(typeof t=="string"&&(t=uf[t]),!t)return!1;var r=!1;try{n.isReadOnly()&&(n.state.suppressEdits=!0);r=t(n,i)!=uo}finally{n.state.suppressEdits=!1}return r})}function dtt(n,t,i){var u=n.getOption("configureMouse"),r=u?u(n,t,i):{},f;return r.unit==null&&(f=ek?i.shiftKey&&i.metaKey:i.altKey,r.unit=f?"rectangle":t=="single"?"char":t=="double"?"word":"line"),(r.extend==null||n.doc.extend)&&(r.extend=n.doc.extend||i.shiftKey),r.addNew==null&&(r.addNew=at?i.metaKey:i.ctrlKey),r.moveOnDrag==null&&(r.moveOnDrag=!(at?i.altKey:i.ctrlKey)),r}function gtt(n,t,i,r){e?setTimeout(gs(gy,n),0):n.curOp.focus=oi();var o=dtt(n,i,r),s=n.doc.sel,f;n.options.dragDrop&&ka&&!n.isReadOnly()&&i=="single"&&(f=s.contains(t))>-1&&(u((f=s.ranges[f]).from(),t)<0||t.xRel>0)&&(u(f.to(),t)>0||t.xRel<0)?nit(n,r,t,o):tit(n,r,t,o)}function nit(n,t,i,u){var f=n.display,s=!1,o=b(n,function(t){tt&&(f.scroller.draggable=!1);n.state.draggingText=!1;n.state.delayingBlurEvent&&(n.hasFocus()?n.state.delayingBlurEvent=!1:nl(n));lt(f.wrapper.ownerDocument,"mouseup",o);lt(f.wrapper.ownerDocument,"mousemove",h);lt(f.scroller,"dragstart",c);lt(f.scroller,"drop",o);s||(ft(t),u.addNew||es(n.doc,i,null,null,u.extend),tt&&!to||e&&l==9?setTimeout(function(){f.wrapper.ownerDocument.body.focus({preventScroll:!0});f.input.focus()},20):f.input.focus())}),h=function(n){s=s||Math.abs(t.clientX-n.clientX)+Math.abs(t.clientY-n.clientY)>=10},c=function(){return s=!0};tt&&(f.scroller.draggable=!0);n.state.draggingText=o;o.copy=!u.moveOnDrag;r(f.wrapper.ownerDocument,"mouseup",o);r(f.wrapper.ownerDocument,"mousemove",h);r(f.scroller,"dragstart",c);r(f.scroller,"drop",o);n.state.delayingBlurEvent=!0;setTimeout(function(){return f.input.focus()},20);f.scroller.dragDrop&&f.scroller.dragDrop()}function lb(t,i,r){if(r=="char")return new o(i,i);if(r=="word")return t.findWordAt(i);if(r=="line")return new o(n(i.line,0),f(t.doc,n(i.line+1,0)));var u=r(t,i);return new o(u.from,u.to)}function tit(i,s,h,c){function ot(r){var e,st,k,v,rt;if(u(g,r)!=0)if(g=r,c.unit=="rectangle"){var s=[],b=i.options.tabSize,ut=vt(t(l,h.line).text,h.ch,b),ft=vt(t(l,r.line).text,r.ch,b),et=Math.min(ut,ft),ot=Math.max(ut,ft);for(e=Math.min(h.line,r.line),st=Math.min(i.lastLine(),Math.max(h.line,r.line));e<=st;e++)k=t(l,e).text,v=th(k,et,b),et==ot?s.push(new o(n(e,v),n(e,v))):k.length>v&&s.push(new o(n(e,v),n(e,th(k,ot,b))));s.length||s.push(new o(h,h));nt(l,dt(i,w.ranges.slice(0,a).concat(s),a),{origin:"*mouse",scroll:!1});i.scrollIntoView(r)}else{var tt=y,p=lb(i,r,c.unit),d=tt.anchor,it;u(p.anchor,d)>0?(it=p.head,d=co(tt.from(),p.anchor)):(it=p.anchor,d=ho(tt.to(),p.head));rt=w.ranges.slice(0);rt[a]=iit(i,new o(f(l,d),it));nt(l,dt(i,rt,a),nh)}}function rt(n){var e=++k,t=pr(i,n,!0,c.unit=="rectangle"),r,f;t&&(u(t,g)!=0?(i.curOp.focus=oi(),ot(t),r=is(v,l),(t.line>=r.to||t.line<r.from)&&setTimeout(b(i,function(){k==e&&rt(n)}),150)):(f=n.clientY<it.top?-20:n.clientY>it.bottom?20:0,f&&setTimeout(b(i,function(){k==e&&(v.scroller.scrollTop+=f,rt(n))}),50)))}function et(n){i.state.selectingText=!1;k=Infinity;n&&(ft(n),v.input.focus());lt(v.wrapper.ownerDocument,"mousemove",ut);lt(v.wrapper.ownerDocument,"mouseup",tt);l.history.lastSelOrigin=null}var v,l,y,a,w,p,d,g,it,k,ut,tt;e&&nl(i);v=i.display;l=i.doc;ft(s);w=l.sel;p=w.ranges;c.addNew&&!c.extend?(a=l.sel.contains(h),y=a>-1?p[a]:new o(h,h)):(y=l.sel.primary(),a=l.sel.primIndex);c.unit=="rectangle"?(c.addNew||(y=new o(h,h)),h=pr(i,s,!0,!0),a=-1):(d=lb(i,h,c.unit),y=c.extend?yl(y,d.anchor,d.head,c.extend):d);c.addNew?a==-1?(a=p.length,nt(l,dt(i,p.concat([y]),a),{scroll:!1,origin:"*mouse"})):p.length>1&&p[a].empty()&&c.unit=="char"&&!c.extend?(nt(l,dt(i,p.slice(0,a).concat(p.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),w=l.sel):pl(l,a,y,nh):(a=0,nt(l,new ht([y],0),nh),w=l.sel);g=h;it=v.wrapper.getBoundingClientRect();k=0;ut=b(i,function(n){n.buttons!==0&&ba(n)?rt(n):et(n)});tt=b(i,et);i.state.selectingText=tt;r(v.wrapper.ownerDocument,"mousemove",ut);r(v.wrapper.ownerDocument,"mouseup",tt)}function iit(i,r){var f=r.anchor,e=r.head,d=t(i.doc,f.line),s,l,h,c,a,v,y;if(u(f,e)==0&&f.sticky==e.sticky||(s=hi(d),!s)||(l=vf(s,f.ch,f.sticky),h=s[l],h.from!=f.ch&&h.to!=f.ch)||(c=l+(h.from==f.ch==(h.level!=1)?0:1),c==0||c==s.length))return r;e.line!=f.line?a=(e.line-f.line)*(i.doc.direction=="ltr"?1:-1)>0:(v=vf(s,e.ch,e.sticky),y=v-l||(e.ch-f.ch)*(h.level==1?-1:1),a=v==c-1||v==c?y<0:y>0);var p=s[c+(a?-1:0)],w=a==(p.level==1),b=w?p.from:p.to,k=w?"after":"before";return f.ch==b&&f.sticky==k?r:new o(new n(f.line,b,k),e)}function ab(n,t,i,r){var e,u,o,s,f,h,c,l;if(t.touches)e=t.touches[0].clientX,u=t.touches[0].clientY;else try{e=t.clientX;u=t.clientY}catch(a){return!1}if(e>=Math.floor(n.display.gutters.getBoundingClientRect().right))return!1;if(r&&ft(t),o=n.display,s=o.lineDiv.getBoundingClientRect(),u>s.bottom||!yt(n,i))return oh(t);for(u-=s.top-o.viewOffset,f=0;f<n.display.gutterSpecs.length;++f)if(h=o.gutters.childNodes[f],h&&h.getBoundingClientRect().right>=e)return c=cr(n.doc,u),l=n.display.gutterSpecs[f],p(n,i,n,c,l.className,t),oh(t)}function ta(n,t){return ab(n,t,"gutterClick",!0)}function vb(n,t){if(!li(n.display,t)&&!rit(n,t)&&!w(n,t,"contextmenu")&&!ro)n.display.input.onContextMenu(t)}function rit(n,t){return yt(n,"gutterContextMenu")?ab(n,t,"gutterContextMenu",!1):!1}function yb(n){n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+n.options.theme.replace(/(^|\s)\s*/g," cm-s-");ne(n)}function uit(t){function i(n,i,u,f){t.defaults[n]=i;u&&(r[n]=f?function(n,t,i){i!=ff&&u(n,t,i)}:u)}var r=t.optionHandlers;t.defineOption=i;t.Init=ff;i("value","",function(n,t){return n.setValue(t)},!0);i("mode",null,function(n,t){n.doc.modeOption=t;ll(n)},!0);i("indentUnit",2,ll,!0);i("indentWithTabs",!1);i("smartIndent",!0);i("tabSize",4,function(n){he(n);ne(n);et(n)},!0);i("lineSeparator",null,function(t,i){var r,f,u;if(t.doc.lineSep=i,i)for(r=[],f=t.doc.first,t.doc.iter(function(t){for(var u,e=0;;){if(u=t.text.indexOf(i,e),u==-1)break;e=u+i.length;r.push(n(f,u))}f++}),u=r.length-1;u>=0;u--)wu(t.doc,i,r[u],n(r[u].line,r[u].ch+i.length))});i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(n,t,i){n.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g");i!=ff&&n.refresh()});i("specialCharPlaceholder",ad,function(n){return n.refresh()},!0);i("electricChars",!0);i("inputStyle",hf?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor");},!0);i("spellcheck",!1,function(n,t){return n.getInputField().spellcheck=t},!0);i("autocorrect",!1,function(n,t){return n.getInputField().autocorrect=t},!0);i("autocapitalize",!1,function(n,t){return n.getInputField().autocapitalize=t},!0);i("rtlMoveVisually",!ok);i("wholeLineUpdateBefore",!0);i("theme","default",function(n){yb(n);oe(n)},!0);i("keyMap","default",function(n,t,i){var u=cs(t),r=i!=ff&&cs(i);r&&r.detach&&r.detach(n,u);u.attach&&u.attach(n,r||null)});i("extraKeys",null);i("configureMouse",null);i("lineWrapping",!1,eit,!0);i("gutters",[],function(n,t){n.display.gutterSpecs=hl(t,n.options.lineNumbers);oe(n)},!0);i("fixedGutter",!0,function(n,t){n.display.gutters.style.left=t?kc(n.display)+"px":"0";n.refresh()},!0);i("coverGutterNextToScrollbar",!1,function(n){return au(n)},!0);i("scrollbarStyle","native",function(n){up(n);au(n);n.display.scrollbars.setScrollTop(n.doc.scrollTop);n.display.scrollbars.setScrollLeft(n.doc.scrollLeft)},!0);i("lineNumbers",!1,function(n,t){n.display.gutterSpecs=hl(n.options.gutters,t);oe(n)},!0);i("firstLineNumber",1,oe,!0);i("lineNumberFormatter",function(n){return n},oe,!0);i("showCursorWhenSelecting",!1,te,!0);i("resetSelectionOnContextMenu",!0);i("lineWiseCopyCut",!0);i("pasteLinesPerSelection",!0);i("selectionsMayTouch",!1);i("readOnly",!1,function(n,t){t=="nocursor"&&(hu(n),n.display.input.blur());n.display.input.readOnlyChanged(t)});i("screenReaderLabel",null,function(n,t){t=t===""?null:t;n.display.input.screenReaderLabelChanged(t)});i("disableInput",!1,function(n,t){t||n.display.input.reset()},!0);i("dragDrop",!0,fit);i("allowDropFileTypes",null);i("cursorBlinkRate",530);i("cursorScrollMargin",0);i("cursorHeight",1,te,!0);i("singleCursorHeightPerLine",!0,te,!0);i("workTime",100);i("workDelay",100);i("flattenSpans",!0,he,!0);i("addModeClass",!1,he,!0);i("pollInterval",100);i("undoDepth",200,function(n,t){return n.doc.history.undoDepth=t});i("historyEventDelay",1250);i("viewportMargin",10,function(n){return n.refresh()},!0);i("maxHighlightLength",1e4,he,!0);i("moveInputWithCursor",!0,function(n,t){t||n.display.input.resetPosition()});i("tabindex",null,function(n,t){return n.display.input.getField().tabIndex=t||""});i("autofocus",null);i("direction","ltr",function(n,t){return n.doc.setDirection(t)},!0);i("phrases",null)}function fit(n,t,i){var e=i&&i!=ff,u,f;!t!=!e&&(u=n.display.dragFunctions,f=t?r:lt,f(n.display.scroller,"dragstart",u.start),f(n.display.scroller,"dragenter",u.enter),f(n.display.scroller,"dragover",u.over),f(n.display.scroller,"dragleave",u.leave),f(n.display.scroller,"drop",u.drop))}function eit(n){n.options.lineWrapping?(ur(n.display.wrapper,"CodeMirror-wrap"),n.display.sizer.style.minWidth="",n.display.sizerWidth=null):(yi(n.display.wrapper,"CodeMirror-wrap"),ec(n));dc(n);et(n);ne(n);setTimeout(function(){return au(n)},100)}function a(n,t){var u=this,i,s,r,f,o;if(!(this instanceof a))return new a(n,t);this.options=t=t?fr(t):{};fr(pb,t,!1);i=t.value;typeof i=="string"?i=new rt(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode);this.doc=i;s=new a.inputStyles[t.inputStyle](this);r=this.display=new cn(n,i,s,t);r.wrapper.CodeMirror=this;yb(this);t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");up(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new si,keySeq:null,specialChars:null};t.autofocus&&!hf&&r.input.focus();e&&l<11&&setTimeout(function(){return u.display.input.reset(!0)},20);oit(this);ott();kr(this);this.curOp.forceUpdate=!0;pp(this,i);t.autofocus&&!hf||this.hasFocus()?setTimeout(function(){u.hasFocus()&&!u.state.focused&&tl(u)},20):hu(this);for(f in ys)ys.hasOwnProperty(f)&&ys[f](this,t[f],ff);for(sp(this),t.finishInit&&t.finishInit(this),o=0;o<ps.length;++o)ps[o](this);dr(this);tt&&t.lineWrapping&&getComputedStyle(r.lineDiv).textRendering=="optimizelegibility"&&(r.lineDiv.style.textRendering="auto")}function oit(t){function c(){i.activeTouch&&(h=setTimeout(function(){return i.activeTouch=null},1e3),s=i.activeTouch,s.end=+new Date)}function v(n){if(n.touches.length!=1)return!1;var t=n.touches[0];return t.radiusX<=1&&t.radiusY<=1}function a(n,t){if(t.left==null)return!0;var i=t.left-n.left,r=t.top-n.top;return i*i+r*r>400}var i=t.display,h,s,u;r(i.scroller,"mousedown",b(t,cb));e&&l<11?r(i.scroller,"dblclick",b(t,function(n){var i,r;w(t,n)||(i=pr(t,n),!i||ta(t,n)||li(t.display,n))||(ft(n),r=t.findWordAt(i),es(t.doc,r.anchor,r.head))})):r(i.scroller,"dblclick",function(n){return w(t,n)||ft(n)});r(i.scroller,"contextmenu",function(n){return vb(t,n)});r(i.input.getField(),"contextmenu",function(n){i.scroller.contains(n.target)||vb(t,n)});s={end:0};r(i.scroller,"touchstart",function(n){if(!w(t,n)&&!v(n)&&!ta(t,n)){i.input.ensurePolled();clearTimeout(h);var r=+new Date;i.activeTouch={start:r,moved:!1,prev:r-s.end<=300?s:null};n.touches.length==1&&(i.activeTouch.left=n.touches[0].pageX,i.activeTouch.top=n.touches[0].pageY)}});r(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)});r(i.scroller,"touchend",function(r){var u=i.activeTouch,e,s;u&&!li(i,r)&&u.left!=null&&!u.moved&&new Date-u.start<300&&(e=t.coordsChar(i.activeTouch,"page"),s=!u.prev||a(u,u.prev)?new o(e,e):!u.prev.prev||a(u,u.prev.prev)?t.findWordAt(e):new o(n(e.line,0),f(t.doc,n(e.line+1,0))),t.setSelection(s.anchor,s.head),t.focus(),ft(r));c()});r(i.scroller,"touchcancel",c);r(i.scroller,"scroll",function(){i.scroller.clientHeight&&(re(t,i.scroller.scrollTop),br(t,i.scroller.scrollLeft,!0),p(t,"scroll",t))});r(i.scroller,"mousewheel",function(n){return lp(t,n)});r(i.scroller,"DOMMouseScroll",function(n){return lp(t,n)});r(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0});i.dragFunctions={enter:function(n){w(t,n)||yf(n)},over:function(n){w(t,n)||(ett(t,n),yf(n))},start:function(n){return ftt(t,n)},drop:b(t,utt),leave:function(n){w(t,n)||bw(t)}};u=i.input.getField();r(u,"keyup",function(n){return ob.call(t,n)});r(u,"keydown",b(t,eb));r(u,"keypress",b(t,sb));r(u,"focus",function(n){return tl(t,n)});r(u,"blur",function(n){return hu(t,n)})}function ke(i,r,u,f){var s=i.doc,d,c,e,l,y,w,a,b,k;u==null&&(u="add");u=="smart"&&(s.mode.indent?d=bf(i,r).state:u="prev");var v=i.options.tabSize,h=t(s,r),p=vt(h.text,null,v);if(h.stateAfter&&(h.stateAfter=null),c=h.text.match(/^\s*/)[0],f||/\S/.test(h.text)){if(u=="smart"&&(e=s.mode.indent(d,h.text.slice(c.length),h.text),e==uo||e>150)){if(!f)return;u="prev"}}else e=0,u="not";if(u=="prev"?e=r>s.first?vt(t(s,r-1).text,null,v):0:u=="add"?e=p+i.options.indentUnit:u=="subtract"?e=p-i.options.indentUnit:typeof u=="number"&&(e=p+u),e=Math.max(0,e),l="",y=0,i.options.indentWithTabs)for(w=Math.floor(e/v);w;--w)y+=v,l+="\t";if(y<e&&(l+=ih(e-y)),l!=c)return wu(s,l,n(r,0),n(r,c.length),"+input"),h.stateAfter=null,!0;for(a=0;a<s.sel.ranges.length;a++)if(b=s.sel.ranges[a],b.head.line==r&&b.head.ch<c.length){k=n(r,c.length);pl(s,a,new o(k,k));break}}function ws(n){pt=n}function ia(i,r,u,f,e){var p=i.doc,y,g,v,b;i.display.shift=!1;f||(f=p.sel);var k=+new Date-200,l=e=="paste"||i.state.pasteIncoming>k,a=lh(r),o=null;if(l&&f.ranges.length>1)if(pt&&pt.text.join("\n")==r){if(f.ranges.length%pt.text.length==0)for(o=[],y=0;y<pt.text.length;y++)o.push(p.splitLines(pt.text[y]))}else a.length==f.ranges.length&&i.options.pasteLinesPerSelection&&(o=fo(a,function(n){return[n]}));for(g=i.curOp.updateInput,v=f.ranges.length-1;v>=0;v--){var w=f.ranges[v],h=w.from(),c=w.to();w.empty()&&(u&&u>0?h=n(h.line,h.ch-u):i.state.overwrite&&!l?c=n(c.line,Math.min(t(p,c.line).text.length,c.ch+s(a).length)):l&&pt&&pt.lineWise&&pt.text.join("\n")==a.join("\n")&&(h=c=n(h.line,0)));b={from:h,to:c,text:o?o[v%o.length]:a,origin:e||(l?"paste":i.state.cutIncoming>k?"cut":"+input")};pu(i.doc,b);d(i,"inputRead",i,b)}r&&!l&&bb(i,r);cu(i);i.curOp.updateInput<2&&(i.curOp.updateInput=g);i.curOp.typing=!0;i.state.pasteIncoming=i.state.cutIncoming=-1}function wb(n,t){var i=n.clipboardData&&n.clipboardData.getData("Text");if(i)return n.preventDefault(),t.isReadOnly()||t.options.disableInput||ot(t,function(){return ia(t,i,0,null,"paste")}),!0}function bb(n,i){var e,u,r,f,o,s;if(n.options.electricChars&&n.options.smartIndent)for(e=n.doc.sel,u=e.ranges.length-1;u>=0;u--)if(r=e.ranges[u],!(r.head.ch>100)&&(!u||e.ranges[u-1].head.line!=r.head.line)){if(f=n.getModeAt(r.head),o=!1,f.electricChars){for(s=0;s<f.electricChars.length;s++)if(i.indexOf(f.electricChars.charAt(s))>-1){o=ke(n,r.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(t(n.doc,r.head.line).text.slice(0,r.head.ch))&&(o=ke(n,r.head.line,"smart"));o&&d(n,"electricInput",n,r.head.line)}}function kb(t){for(var u,i,f=[],e=[],r=0;r<t.doc.sel.ranges.length;r++)u=t.doc.sel.ranges[r].head.line,i={anchor:n(u,0),head:n(u+1,0)},e.push(i),f.push(t.getRange(i.anchor,i.head));return{text:f,ranges:e}}function db(n,t,i,r){n.setAttribute("autocorrect",i?"":"off");n.setAttribute("autocapitalize",r?"":"off");n.setAttribute("spellcheck",!!t)}function gb(){var n=i("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=i("div",[n],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return tt?n.style.width="1000px":n.setAttribute("wrap","off"),sf&&(n.style.border="1px solid black"),db(n),t}function sit(i){var u=i.optionHandlers,r=i.helpers={};i.prototype={constructor:i,focus:function(){window.focus();this.display.input.focus()},setOption:function(n,t){var i=this.options,r=i[n];(i[n]!=t||n=="mode")&&(i[n]=t,u.hasOwnProperty(n)&&b(this,u[n])(this,t,r),p(this,"optionChange",this,n))},getOption:function(n){return this.options[n]},getDoc:function(){return this.doc},addKeyMap:function(n,t){this.state.keyMaps[t?"push":"unshift"](cs(n))},removeKeyMap:function(n){for(var i=this.state.keyMaps,t=0;t<i.length;++t)if(i[t]==n||i[t].name==n)return i.splice(t,1),!0},addOverlay:it(function(n,t){var r=n.token?n:i.getMode(this.options,n);if(r.startState)throw new Error("Overlays may not be stateful.");sk(this.state.overlays,{mode:r,modeSpec:n,opaque:t&&t.opaque,priority:t&&t.priority||0},function(n){return n.priority});this.state.modeGen++;et(this)}),removeOverlay:it(function(n){for(var r,i=this.state.overlays,t=0;t<i.length;++t)if(r=i[t].modeSpec,r==n||typeof n=="string"&&r.name==n){i.splice(t,1);this.state.modeGen++;et(this);return}}),indentLine:it(function(n,t,i){typeof t!="string"&&typeof t!="number"&&(t=t==null?this.options.smartIndent?"smart":"prev":t?"add":"subtract");pf(this.doc,n)&&ke(this,n,t,i)}),indentSelection:it(function(n){for(var i,u,f,e=this.doc.sel.ranges,r=-1,t=0;t<e.length;t++)if(i=e[t],i.empty())i.head.line>r&&(ke(this,i.head.line,n,!0),r=i.head.line,t==this.doc.sel.primIndex&&cu(this));else{var s=i.from(),h=i.to(),c=Math.max(r,s.line);for(r=Math.min(this.lastLine(),h.line-(h.ch?0:1))+1,u=c;u<r;++u)ke(this,u,n);f=this.doc.sel.ranges;s.ch==0&&e.length==f.length&&f[t].from().ch>0&&pl(this.doc,t,new o(s,f[t].to()),gt)}}),getTokenAt:function(n,t){return uv(this,n,t)},getLineTokens:function(t,i){return uv(this,n(t),i,!0)},getTokenTypeAt:function(n){var i,e;n=f(this.doc,n);var u=iv(this,t(this.doc,n.line)),s=0,h=(u.length-1)/2,o=n.ch,r;if(o==0)r=u[2];else for(;;)if(i=s+h>>1,(i?u[i*2-1]:0)>=o)h=i;else if(u[i*2+1]<o)s=i+1;else{r=u[i*2+2];break}return e=r?r.indexOf("overlay "):-1,e<0?r:e==0?null:r.slice(0,e-1)},getModeAt:function(n){var t=this.doc.mode;return t.innerMode?i.innerMode(t,this.getTokenAt(n).state).mode:t},getHelper:function(n,t){return this.getHelpers(n,t)[0]},getHelpers:function(n,t){var f=[],u,i,e,h,o,s;if(!r.hasOwnProperty(t))return f;if(u=r[t],i=this.getModeAt(n),typeof i[t]=="string")u[i[t]]&&f.push(u[i[t]]);else if(i[t])for(e=0;e<i[t].length;e++)h=u[i[t][e]],h&&f.push(h);else i.helperType&&u[i.helperType]?f.push(u[i.helperType]):u[i.name]&&f.push(u[i.name]);for(o=0;o<u._global.length;o++)s=u._global[o],s.pred(i,this)&&g(f,s.val)==-1&&f.push(s.val);return f},getStateAfter:function(n,t){var i=this.doc;return n=ga(i,n==null?i.first+i.size-1:n),bf(this,n+1,t).state},cursorCoords:function(n,t){var r,i=this.doc.sel.primary();return r=n==null?i.head:typeof n=="object"?f(this.doc,n):n?i.from():i.to(),kt(this,r,t||"page")},charCoords:function(n,t){return vc(this,f(this.doc,n),t||"page")},coordsChar:function(n,t){return n=ay(this,n,t||"page"),pc(this,n.left,n.top)},lineAtHeight:function(n,t){return n=ay(this,{top:n,left:0},t||"page").top,cr(this.doc,n+this.display.viewOffset)},heightAtLine:function(n,i,r){var f=!1,u,e;return typeof n=="number"?(e=this.doc.first+this.doc.size-1,n<this.doc.first?n=this.doc.first:n>e&&(n=e,f=!0),u=t(this.doc,n)):u=n,ko(this,u,{top:0,left:0},i||"page",r||f).top+(f?this.doc.height-ci(u):0)},defaultTextHeight:function(){return ou(this.display)},defaultCharWidth:function(){return su(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(n,t,i,r,u){var s=this.display,o,e,h,c;n=kt(this,f(this.doc,n));o=n.bottom;e=n.left;t.style.position="absolute";t.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(t);s.sizer.appendChild(t);r=="over"?o=n.top:(r=="above"||r=="near")&&(h=Math.max(s.wrapper.clientHeight,this.doc.height),c=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth),(r=="above"||n.bottom+t.offsetHeight>h)&&n.top>t.offsetHeight?o=n.top-t.offsetHeight:n.bottom+t.offsetHeight<=h&&(o=n.bottom),e+t.offsetWidth>c&&(e=c-t.offsetWidth));t.style.top=o+"px";t.style.left=t.style.right="";u=="right"?(e=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(u=="left"?e=0:u=="middle"&&(e=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=e+"px");i&&bg(this,{left:e,top:o,right:e+t.offsetWidth,bottom:o+t.offsetHeight})},triggerOnKeyDown:it(eb),triggerOnKeyPress:it(sb),triggerOnKeyUp:ob,triggerOnMouseDown:it(cb),execCommand:function(n){if(uf.hasOwnProperty(n))return uf[n].call(null,this)},triggerElectric:it(function(n){bb(this,n)}),findPosH:function(n,t,i,r){var o=1,u,e;for(t<0&&(o=-1,t=-t),u=f(this.doc,n),e=0;e<t;++e)if(u=ra(this.doc,u,o,i,r),u.hitSide)break;return u},moveH:it(function(n,t){var i=this;this.extendSelectionsBy(function(r){return i.display.shift||i.doc.extend||r.empty()?ra(i.doc,r.head,n,t,i.options.rtlMoveVisually):n<0?r.from():r.to()},cf)}),deleteH:it(function(n,t){var r=this.doc.sel,i=this.doc;r.somethingSelected()?i.replaceSelection("",null,"+delete"):rf(this,function(r){var u=ra(i,r.head,n,t,!1);return n<0?{from:u,to:r.head}:{from:r.head,to:u}})}),findPosV:function(n,t,i,r){var h=1,o=r,u,s,e;for(t<0&&(h=-1,t=-t),u=f(this.doc,n),s=0;s<t;++s)if(e=kt(this,u,"div"),o==null?o=e.left:e.left=o,u=nk(this,e,h,i),u.hitSide)break;return u},moveV:it(function(n,t){var u=this,i=this.doc,f=[],e=!this.display.shift&&!i.extend&&i.sel.somethingSelected(),r;if(i.extendSelectionsBy(function(r){var o,s;return e?n<0?r.from():r.to():(o=kt(u,r.head,"div"),r.goalColumn!=null&&(o.left=r.goalColumn),f.push(o.left),s=nk(u,o,n,t),t=="page"&&r==i.sel.primary()&&rl(u,vc(u,s,"div").top-o.top),s)},cf),f.length)for(r=0;r<i.sel.ranges.length;r++)i.sel.ranges[r].goalColumn=f[r]}),findWordAt:function(i){var c=this.doc,u=t(c,i.line).text,r=i.ch,f=i.ch,e,s,h;if(u){for(e=this.getHelper(i,"wordChars"),(i.sticky=="before"||f==u.length)&&r?--r:++f,s=u.charAt(r),h=eo(s,e)?function(n){return eo(n,e)}:/\s/.test(s)?function(n){return/\s/.test(n)}:function(n){return!/\s/.test(n)&&!eo(n)};r>0&&h(u.charAt(r-1));)--r;while(f<u.length&&h(u.charAt(f)))++f}return new o(n(i.line,r),n(i.line,f))},toggleOverwrite:function(n){(n==null||n!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?ur(this.display.cursorDiv,"CodeMirror-overwrite"):yi(this.display.cursorDiv,"CodeMirror-overwrite"),p(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==oi()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:it(function(n,t){ie(this,n,t)}),getScrollInfo:function(){var n=this.display.scroller;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight-ri(this)-this.display.barHeight,width:n.scrollWidth-ri(this)-this.display.barWidth,clientHeight:hc(this),clientWidth:vr(this)}},scrollIntoView:it(function(t,i){t==null?(t={from:this.doc.sel.primary().head,to:null},i==null&&(i=this.options.cursorScrollMargin)):typeof t=="number"?t={from:n(t,0),to:null}:t.from==null&&(t={from:t,to:null});t.to||(t.to=t.from);t.margin=i||0;t.from.line!=null?kg(this,t):tp(this,t.from,t.to,t.margin)}),setSize:it(function(n,t){var u=this,r=function(n){return typeof n=="number"||/^\d+$/.test(String(n))?n+"px":n},i;n!=null&&(this.display.wrapper.style.width=r(n));t!=null&&(this.display.wrapper.style.height=r(t));this.options.lineWrapping&&hy(this);i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,function(n){if(n.widgets)for(var t=0;t<n.widgets.length;t++)if(n.widgets[t].noHScroll){ki(u,i,"widget");break}++i});this.curOp.forceUpdate=!0;p(this,"refresh",this)}),operation:function(n){return ot(this,n)},startOperation:function(){return kr(this)},endOperation:function(){return dr(this)},refresh:it(function(){var n=this.display.cachedTextHeight;et(this);this.curOp.forceUpdate=!0;ne(this);ie(this,this.doc.scrollLeft,this.doc.scrollTop);ol(this.display);(n==null||Math.abs(n-ou(this.display))>.5||this.options.lineWrapping)&&dc(this);p(this,"refresh",this)}),swapDoc:it(function(n){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),pp(this,n),ne(this),this.display.input.reset(),ie(this,n.scrollLeft,n.scrollTop),this.curOp.forceScroll=!0,d(this,"swapDoc",this,t),t}),phrase:function(n){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:n},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};uu(i);i.registerHelper=function(n,t,u){r.hasOwnProperty(n)||(r[n]=i[n]={_global:[]});r[n][t]=u};i.registerGlobalHelper=function(n,t,u,f){i.registerHelper(n,t,f);r[n]._global.push({pred:u,val:f})}}function ra(i,r,u,f,e){function k(){var u=r.line+w;return u<i.first||u>=i.first+i.size?!1:(r=new n(u,r.ch,r.sticky),o=t(i,u))}function h(t){var h,s,c;if(f=="codepoint"?(s=o.text.charCodeAt(r.ch+(f>0?0:-1)),isNaN(s)?h=null:(c=u>0?s>=55296&&s<56320:s>=56320&&s<57343,h=new n(r.line,Math.max(0,Math.min(o.text.length,r.ch+u*(c?2:1))),-u))):h=e?att(i.cm,o,r,u):gl(o,r,u),h==null)if(!t&&k())r=na(e,i.cm,o,r.line,w);else return!1;else r=h;return!0}var p=r,b=u,o=t(i,r.line),w=e&&i.direction=="rtl"?-u:u,c,l,s,a;if(f=="char"||f=="codepoint")h();else if(f=="column")h(!0);else if(f=="word"||f=="group"){var v=null,y=f=="group",d=i.cm&&i.cm.getHelper(r,"wordChars");for(c=!0;;c=!1){if(u<0&&!h(!c))break;if(l=o.text.charAt(r.ch)||"\n",s=eo(l,d)?"w":y&&l=="\n"?"n":!y||/\s/.test(l)?null:"p",!y||c||s||(s="s"),v&&v!=s){u<0&&(u=1,h(),r.sticky="after");break}if(s&&(v=s),u>0&&!h(!c))break}}return a=ss(i,r,p,b,!0),bh(p,a)&&(a.hitSide=!0),a}function nk(n,t,i,r){var s=n.doc,h=t.left,u,e,o,f;for(r=="page"?(e=Math.min(n.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),o=Math.max(e-.5*ou(n.display),3),u=(i>0?t.bottom:t.top)+i*o):r=="line"&&(u=i>0?t.bottom+3:t.top-3);;){if(f=pc(n,h,u),!f.outside)break;if(i<0?u<=0:u>=s.height){f.hitSide=!0;break}u+=i*5}return f}function tk(n,i){var u=cc(n,i.line),s,r;if(!u||u.hidden)return null;var f=t(n.doc,i.line),h=fy(u,f,i.line),e=hi(f,n.doc.direction),o="left";return e&&(s=vf(e,i.ch),o=s%2?"right":"left"),r=oy(h.map,i.ch,o),r.offset=r.collapse=="right"?r.end:r.start,r}function hit(n){for(var t=n;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ef(n,t){return t&&(n.bad=!0),n}function cit(t,i,r,u,f){function v(n){return function(t){return t.id==n}}function l(){s&&(e+=h,o&&(e+=h),s=o=!1)}function c(n){n&&(l(),e+=n)}function a(i){var e,y,p,w,b,r;if(i.nodeType==1){if(e=i.getAttribute("cm-text"),e){c(e);return}if(y=i.getAttribute("cm-marker"),y){w=t.findMarks(n(u,0),n(f+1,0),v(+y));w.length&&(p=w[0].find(0))&&c(hr(t.doc,p.from,p.to).join(h));return}if(i.getAttribute("contenteditable")=="false")return;if(b=/^(pre|div|p|li|table|br)$/i.test(i.nodeName),!/^br$/i.test(i.nodeName)&&i.textContent.length==0)return;for(b&&l(),r=0;r<i.childNodes.length;r++)a(i.childNodes[r]);/^(pre|p)$/i.test(i.nodeName)&&(o=!0);b&&(s=!0)}else i.nodeType==3&&c(i.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(var e="",s=!1,h=t.doc.lineSeparator(),o=!1;;){if(a(i),i==r)break;i=i.nextSibling;o=!1}return e}function bs(t,i,r){var u,f,e;if(i==t.display.lineDiv){if(u=t.display.lineDiv.childNodes[r],!u)return ef(t.clipPos(n(t.display.viewTo-1)),!0);i=null;r=0}else for(u=i;;u=u.parentNode){if(!u||u==t.display.lineDiv)return null;if(u.parentNode&&u.parentNode==t.display.lineDiv)break}for(f=0;f<t.display.view.length;f++)if(e=t.display.view[f],e.node==u)return lit(e,i,r)}function lit(t,i,r){function w(i,r,u){for(var o,e,s,l,h,f=-1;f<(v?v.length:0);f++)for(o=f<0?p.map:v[f],e=0;e<o.length;e+=3)if(s=o[e+2],s==i||s==r)return l=c(f<0?t.line:t.rest[f]),h=o[e]+u,(u<0||s!=i)&&(h=o[e+(u?1:0)]),n(l,h)}var a=t.text.firstChild,l=!1,y,f,e,p,v,u,o,b,h,k;if(!i||!wi(a,i))return ef(n(c(t.line),0),!0);if(i==a&&(l=!0,i=a.childNodes[r],r=0,!i))return y=t.rest?s(t.rest):t.line,ef(n(c(y),y.text.length),l);for(f=i.nodeType==3?i:null,e=i,f||i.childNodes.length!=1||i.firstChild.nodeType!=3||(f=i.firstChild,r&&(r=f.nodeValue.length));e.parentNode!=a;)e=e.parentNode;if(p=t.measure,v=p.maps,u=w(f,e,r),u)return ef(u,l);for(o=e.nextSibling,b=f?f.nodeValue.length-r:0;o;o=o.nextSibling){if(u=w(o,o.firstChild,0),u)return ef(n(u.line,u.ch-b),l);b+=o.textContent.length}for(h=e.previousSibling,k=r;h;h=h.previousSibling){if(u=w(h,h.firstChild,-1),u)return ef(n(u.line,u.ch+k),l);k+=h.textContent.length}}function ait(n,t){function u(){n.value=s.getValue()}var f,e,i,o,s;if(t=t?fr(t):{},t.value=n.value,!t.tabindex&&n.tabIndex&&(t.tabindex=n.tabIndex),!t.placeholder&&n.placeholder&&(t.placeholder=n.placeholder),t.autofocus==null&&(f=oi(),t.autofocus=f==n||n.getAttribute("autofocus")!=null&&f==document.body),n.form&&(r(n.form,"submit",u),!t.leaveSubmitMethodAlone)){i=n.form;e=i.submit;try{o=i.submit=function(){u();i.submit=e;i.submit();i.submit=o}}catch(h){}}return t.finishInit=function(i){i.save=u;i.getTextArea=function(){return n};i.toTextArea=function(){i.toTextArea=isNaN;u();n.parentNode.removeChild(i.getWrapperElement());n.style.display="";n.form&&(lt(n.form,"submit",u),t.leaveSubmitMethodAlone||typeof n.form.submit!="function"||(n.form.submit=e))}},n.style.display="none",s=a(function(t){return n.parentNode.insertBefore(t,n.nextSibling)},t)}function vit(t){t.off=lt;t.on=r;t.wheelEventPixels=ln;t.Doc=rt;t.splitLines=lh;t.countColumn=vt;t.findColumn=th;t.isWordChar=rh;t.Pass=uo;t.signal=p;t.Line=lr;t.changeEnd=tr;t.scrollbarModel=ul;t.Pos=n;t.cmpPos=u;t.modes=oo;t.mimeModes=er;t.resolveMode=so;t.getMode=vh;t.modeExtensions=or;t.extendMode=bk;t.copyState=sr;t.startState=da;t.innerMode=yh;t.commands=uf;t.keyMap=fi;t.keyName=nb;t.isModifierKey=dw;t.lookupKey=tf;t.normalizeKeyMap=ltt;t.StringStream=y;t.SharedTextMarker=du;t.TextMarker=ai;t.LineWidget=bu;t.e_preventDefault=ft;t.e_stopPropagation=wa;t.e_stop=yf;t.addClass=ur;t.contains=wi;t.rmClass=yi;t.keyNames=vi}var ut=navigator.userAgent,ua=navigator.platform,ei=/gecko\/\d/i.test(ut),fa=/MSIE \d/.test(ut),ea=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ut),ge=/Edge\/(\d+)/.exec(ut),e=fa||ea||ge,l=e&&(fa?document.documentMode||6:+(ge||ea)[1]),tt=!ge&&/WebKit\//.test(ut),rk=tt&&/Qt\/\d+\.\d+/.test(ut),no=!ge&&/Chrome\//.test(ut),wt=/Opera\//.test(ut),to=/Apple Computer/.test(navigator.vendor),uk=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ut),fk=/PhantomJS/.test(ut),sf=to&&(/Mobile\/\w+/.test(ut)||navigator.maxTouchPoints>2),io=/Android/.test(ut),hf=sf||io||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ut),at=sf||/Mac/.test(ua),ek=/\bCrOS\b/.test(ut),ok=/win/i.test(ua),rr=wt&&ut.match(/Version\/(\d*\.\d*)/),ks,ro,yi,tu,iu,si,lf,ca,aa,ru,ya,fh,r,ka,hh,ch,oo,er,or,y,wf,bt,nc,tc,ti,lr,yv,pv,ar,fu,lc,yr,gi,lu,ul,fp,ee,se,st,ht,o,bu,wl,ai,du,ww,rt,bl,kl,vi,gu,ye,nf,fi,uf,rb,as,hb,vs,we,be,ps,pt,h,v,ik,de;rr&&(rr=Number(rr[1]));rr&&rr>=15&&(wt=!1,tt=!0);ks=at&&(rk||wt&&(rr==null||rr<12.11));ro=ei||e&&l>=9;yi=function(n,t){var r=n.className,i=gr(t).exec(r),u;i&&(u=r.slice(i.index+i[0].length),n.className=r.slice(0,i.index)+(u?i[1]+u:""))};tu=document.createRange?function(n,t,i,r){var u=document.createRange();return u.setEnd(r||n,i),u.setStart(n,t),u}:function(n,t,i){var r=document.body.createTextRange();try{r.moveToElementText(n.parentNode)}catch(u){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};iu=function(n){n.select()};sf?iu=function(n){n.selectionStart=0;n.selectionEnd=n.value.length}:e&&(iu=function(n){try{n.select()}catch(t){}});si=function(){this.id=null;this.f=null;this.time=0;this.handler=gs(this.onTimeout,this)};si.prototype.onTimeout=function(n){n.id=0;n.time<=+new Date?n.f():setTimeout(n.handler,n.time-+new Date)};si.prototype.set=function(n,t){this.f=t;var i=+new Date+n;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,n),this.time=i)};var oa=50,uo={toString:function(){return"CodeMirror.Pass"}},gt={scroll:!1},nh={origin:"*mouse"},cf={origin:"+move"};lf=[""];ca=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;aa=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;ru=null;ya=function(){function o(n){return n<=247?f.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1785?e.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function n(n,t,i){this.level=n;this.from=t;this.to=i}var f="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",e="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",h=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,i=/[LRr]/,r=/[Lb1n]/,u=/[1n]/;return function(f,e){var nt=e=="ltr"?"L":"R",a,c,st,ut,vt,yt,tt,pt,ft,d,g,ht,p,wt,w,kt,ct,et,bt,lt,b,k,at,v,it,l,gt,y,ti;if(f.length==0||e=="ltr"&&!h.test(f))return!1;for(a=f.length,c=[],st=0;st<a;++st)c.push(o(f.charCodeAt(st)));for(ut=0,vt=nt;ut<a;++ut)yt=c[ut],yt=="m"?c[ut]=vt:vt=yt;for(tt=0,pt=nt;tt<a;++tt)ft=c[tt],ft=="1"&&pt=="r"?c[tt]="n":i.test(ft)&&(pt=ft,ft=="r"&&(c[tt]="R"));for(d=1,g=c[0];d<a-1;++d)ht=c[d],ht=="+"&&g=="1"&&c[d+1]=="1"?c[d]="1":ht==","&&g==c[d+1]&&(g=="1"||g=="n")&&(c[d]=g),g=ht;for(p=0;p<a;++p)if(wt=c[p],wt==",")c[p]="N";else if(wt=="%"){for(w=void 0,w=p+1;w<a&&c[w]=="%";++w);for(kt=p&&c[p-1]=="!"||w<a&&c[w]=="1"?"1":"N",ct=p;ct<w;++ct)c[ct]=kt;p=w-1}for(et=0,bt=nt;et<a;++et)lt=c[et],bt=="L"&&lt=="1"?c[et]="L":i.test(lt)&&(bt=lt);for(b=0;b<a;++b)if(t.test(c[b])){for(k=void 0,k=b+1;k<a&&t.test(c[k]);++k);var dt=(b?c[b-1]:nt)=="L",ii=(k<a?c[k]:nt)=="L",ri=dt==ii?dt?"L":"R":nt;for(at=b;at<k;++at)c[at]=ri;b=k-1}for(v=[],l=0;l<a;)if(r.test(c[l])){for(gt=l,++l;l<a&&r.test(c[l]);++l);v.push(new n(0,gt,l))}else{var rt=l,ot=v.length,ni=e=="rtl"?1:0;for(++l;l<a&&c[l]!="L";++l);for(y=rt;y<l;)if(u.test(c[y])){for(rt<y&&(v.splice(ot,0,new n(1,rt,y)),ot+=ni),ti=y,++y;y<l&&u.test(c[y]);++y);v.splice(ot,0,new n(2,ti,y));ot+=ni;rt=y}else++y;rt<l&&v.splice(ot,0,new n(1,rt,l))}return e=="ltr"&&(v[0].level==1&&(it=f.match(/^\s+/))&&(v[0].from=it[0].length,v.unshift(new n(0,0,it[0].length))),s(v).level==1&&(it=f.match(/\s+$/))&&(s(v).to-=it[0].length,v.push(new n(0,a-it[0].length,a)))),e=="rtl"?v.reverse():v}}();fh=[];r=function(n,t,i){if(n.addEventListener)n.addEventListener(t,i,!1);else if(n.attachEvent)n.attachEvent("on"+t,i);else{var r=n._handlers||(n._handlers={});r[t]=(r[t]||fh).concat(i)}};ka=function(){if(e&&l<9)return!1;var n=i("div");return"draggable"in n||"dragDrop"in n}();var lh="\n\nb".split(/\n/).length!=3?function(n){for(var i=0,f=[],e=n.length,t,r,u;i<=e;)t=n.indexOf("\n",i),t==-1&&(t=n.length),r=n.slice(i,n.charAt(t-1)=="\r"?t-1:t),u=r.indexOf("\r"),u!=-1?(f.push(r.slice(0,u)),i+=u+1):(f.push(r),i=t+1);return f}:function(n){return n.split(/\r\n?|\n/)},ak=window.getSelection?function(n){try{return n.selectionStart!=n.selectionEnd}catch(t){return!1}}:function(n){var t;try{t=n.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=n?!1:t.compareEndPoints("StartToEnd",t)!=0},vk=function(){var n=i("div");return"oncopy"in n?!0:(n.setAttribute("oncopy","return;"),typeof n.oncopy=="function")}(),ah=null;for(oo={},er={},or={},y=function(n,t,i){this.pos=this.start=0;this.string=n;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;this.lineOracle=i},y.prototype.eol=function(){return this.pos>=this.string.length},y.prototype.sol=function(){return this.pos==this.lineStart},y.prototype.peek=function(){return this.string.charAt(this.pos)||undefined},y.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},y.prototype.eat=function(n){var t=this.string.charAt(this.pos),i;return i=typeof n=="string"?t==n:t&&(n.test?n.test(t):n(t)),i?(++this.pos,t):void 0},y.prototype.eatWhile=function(n){for(var t=this.pos;this.eat(n););return this.pos>t},y.prototype.eatSpace=function(){for(var n=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>n},y.prototype.skipToEnd=function(){this.pos=this.string.length},y.prototype.skipTo=function(n){var t=this.string.indexOf(n,this.pos);if(t>-1)return this.pos=t,!0},y.prototype.backUp=function(n){this.pos-=n},y.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=vt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?vt(this.string,this.lineStart,this.tabSize):0)},y.prototype.indentation=function(){return vt(this.string,null,this.tabSize)-(this.lineStart?vt(this.string,this.lineStart,this.tabSize):0)},y.prototype.match=function(n,t,i){var u,f,r;if(typeof n=="string"){if(u=function(n){return i?n.toLowerCase():n},f=this.string.substr(this.pos,n.length),u(f)==u(n))return t!==!1&&(this.pos+=n.length),!0}else return(r=this.string.slice(this.pos).match(n),r&&r.index>0)?null:(r&&t!==!1&&(this.pos+=r[0].length),r)},y.prototype.current=function(){return this.string.slice(this.start,this.pos)},y.prototype.hideFirstChars=function(n,t){this.lineStart+=n;try{return t()}finally{this.lineStart-=n}},y.prototype.lookAhead=function(n){var t=this.lineOracle;return t&&t.lookAhead(n)},y.prototype.baseToken=function(){var n=this.lineOracle;return n&&n.baseToken(this.pos)},wf=function(n,t){this.state=n;this.lookAhead=t},bt=function(n,t,i,r){this.state=t;this.doc=n;this.line=i;this.maxLookAhead=r||0;this.baseTokens=null;this.baseTokenPos=1},bt.prototype.lookAhead=function(n){var t=this.doc.getLine(this.line+n);return t!=null&&n>this.maxLookAhead&&(this.maxLookAhead=n),t},bt.prototype.baseToken=function(n){if(!this.baseTokens)return null;while(this.baseTokens[this.baseTokenPos]<=n)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-n}},bt.prototype.nextLine=function(){this.line++;this.maxLookAhead>0&&this.maxLookAhead--},bt.fromSaved=function(n,t,i){return t instanceof wf?new bt(n,sr(n.mode,t.state),i,t.lookAhead):new bt(n,sr(n.mode,t),i)},bt.prototype.save=function(n){var t=n!==!1?sr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new wf(t,this.maxLookAhead):t},nc=function(n,t,i){this.start=n.start;this.end=n.pos;this.string=n.current();this.type=t||null;this.state=i},tc=!1,ti=!1,lr=function(n,t,i){this.text=n;hv(this,t);this.height=i?i(this):1},lr.prototype.lineNo=function(){return c(this)},uu(lr),yv={},pv={},ar=null,fu=null,lc={left:0,right:0,top:0,bottom:0},gi=function(n,t,u){this.cm=u;var f=this.vert=i("div",[i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=i("div",[i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");f.tabIndex=o.tabIndex=-1;n(f);n(o);r(f,"scroll",function(){f.clientHeight&&t(f.scrollTop,"vertical")});r(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")});this.checkedZeroWidth=!1;e&&l<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")},gi.prototype.update=function(n){var i=n.scrollWidth>n.clientWidth+1,r=n.scrollHeight>n.clientHeight+1,t=n.nativeBarWidth,u,f;return r?(this.vert.style.display="block",this.vert.style.bottom=i?t+"px":"0",u=n.viewHeight-(i?t:0),this.vert.firstChild.style.height=Math.max(0,n.scrollHeight-n.clientHeight+u)+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0"),i?(this.horiz.style.display="block",this.horiz.style.right=r?t+"px":"0",this.horiz.style.left=n.barLeft+"px",f=n.viewWidth-n.barLeft-(r?t:0),this.horiz.firstChild.style.width=Math.max(0,n.scrollWidth-n.clientWidth+f)+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedZeroWidth&&n.clientHeight>0&&(t==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?t:0,bottom:i?t:0}},gi.prototype.setScrollLeft=function(n){this.horiz.scrollLeft!=n&&(this.horiz.scrollLeft=n);this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},gi.prototype.setScrollTop=function(n){this.vert.scrollTop!=n&&(this.vert.scrollTop=n);this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},gi.prototype.zeroWidthHack=function(){var n=at&&!uk?"12px":"18px";this.horiz.style.height=this.vert.style.width=n;this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new si;this.disableVert=new si},gi.prototype.enableZeroWidthBar=function(n,t,i){function r(){var u=n.getBoundingClientRect(),f=i=="vert"?document.elementFromPoint(u.right-1,(u.top+u.bottom)/2):document.elementFromPoint((u.right+u.left)/2,u.bottom-1);f!=n?n.style.pointerEvents="none":t.set(1e3,r)}n.style.pointerEvents="auto";t.set(1e3,r)},gi.prototype.clear=function(){var n=this.horiz.parentNode;n.removeChild(this.horiz);n.removeChild(this.vert)},lu=function(){},lu.prototype.update=function(){return{bottom:0,right:0}},lu.prototype.setScrollLeft=function(){},lu.prototype.setScrollTop=function(){},lu.prototype.clear=function(){},ul={"native":gi,"null":lu},fp=0,ee=function(n,t,i){var r=n.display;this.viewport=t;this.visible=is(r,n.doc,t);this.editorIsHidden=!r.wrapper.offsetWidth;this.wrapperHeight=r.wrapper.clientHeight;this.wrapperWidth=r.wrapper.clientWidth;this.oldDisplayWidth=vr(n);this.force=i;this.dims=bc(n);this.events=[]},ee.prototype.signal=function(n,t){yt(n,t)&&this.events.push(arguments)},ee.prototype.finish=function(){for(var n=0;n<this.events.length;n++)p.apply(null,this.events[n])},se=0,st=null,e?st=-.53:ei?st=15:no?st=-.7:to&&(st=-1/3),ht=function(n,t){this.ranges=n;this.primIndex=t},ht.prototype.primary=function(){return this.ranges[this.primIndex]},ht.prototype.equals=function(n){var t,i,r;if(n==this)return!0;if(n.primIndex!=this.primIndex||n.ranges.length!=this.ranges.length)return!1;for(t=0;t<this.ranges.length;t++)if(i=this.ranges[t],r=n.ranges[t],!bh(i.anchor,r.anchor)||!bh(i.head,r.head))return!1;return!0},ht.prototype.deepCopy=function(){for(var t=[],n=0;n<this.ranges.length;n++)t[n]=new o(kh(this.ranges[n].anchor),kh(this.ranges[n].head));return new ht(t,this.primIndex)},ht.prototype.somethingSelected=function(){for(var n=0;n<this.ranges.length;n++)if(!this.ranges[n].empty())return!0;return!1},ht.prototype.contains=function(n,t){var i,r;for(t||(t=n),i=0;i<this.ranges.length;i++)if(r=this.ranges[i],u(t,r.from())>=0&&u(n,r.to())<=0)return i;return-1},o=function(n,t){this.anchor=n;this.head=t},o.prototype.from=function(){return co(this.anchor,this.head)},o.prototype.to=function(){return ho(this.anchor,this.head)},o.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},ae.prototype={chunkSize:function(){return this.lines.length},removeInner:function(n,t){for(var r,i=n,u=n+t;i<u;++i)r=this.lines[i],this.height-=r.height,ld(r),d(r,"delete");this.lines.splice(n,t)},collapse:function(n){n.push.apply(n,this.lines)},insertInner:function(n,t,i){this.height+=i;this.lines=this.lines.slice(0,n).concat(t).concat(this.lines.slice(n));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(n,t,i){for(var r=n+t;n<r;++n)if(i(this.lines[n]))return!0}},ve.prototype={chunkSize:function(){return this.size},removeInner:function(n,t){var r,i,u,f,o,e;for(this.size-=t,r=0;r<this.children.length;++r)if(i=this.children[r],u=i.chunkSize(),n<u){if(f=Math.min(t,u-n),o=i.height,i.removeInner(n,f),this.height-=o-i.height,u==f&&(this.children.splice(r--,1),i.parent=null),(t-=f)==0)break;n=0}else n-=u;this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof ae))&&(e=[],this.collapse(e),this.children=[new ae(e)],this.children[0].parent=this)},collapse:function(n){for(var t=0;t<this.children.length;++t)this.children[t].collapse(n)},insertInner:function(n,t,i){var u,r,o,s,f,e;for(this.size+=t.length,this.height+=i,u=0;u<this.children.length;++u){if(r=this.children[u],o=r.chunkSize(),n<=o){if(r.insertInner(n,t,i),r.lines&&r.lines.length>50){for(s=r.lines.length%25+25,f=s;f<r.lines.length;)e=new ae(r.lines.slice(f,f+=25)),r.height-=e.height,this.children.splice(++u,0,e),e.parent=this;r.lines=r.lines.slice(0,s);this.maybeSpill()}break}n-=o}},maybeSpill:function(){var n,r,t,i,u;if(!(this.children.length<=10)){n=this;do r=n.children.splice(n.children.length-5,5),t=new ve(r),n.parent?(n.size-=t.size,n.height-=t.height,u=g(n.parent.children,n),n.parent.children.splice(u+1,0,t)):(i=new ve(n.children),i.parent=n,n.children=[i,t],n=i),t.parent=n.parent;while(n.children.length>10);n.parent.maybeSpill()}},iterN:function(n,t,i){for(var f,u,e,r=0;r<this.children.length;++r)if(f=this.children[r],u=f.chunkSize(),n<u){if(e=Math.min(t,u-n),f.iterN(n,e,i))return!0;if((t-=e)==0)break;n=0}else n-=u}},bu=function(n,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=n;this.node=t},bu.prototype.clear=function(){var n=this.doc.cm,t=this.line.widgets,i=this.line,u=c(i),r,f;if(u!=null&&t){for(r=0;r<t.length;++r)t[r]==this&&t.splice(r--,1);t.length||(i.widgets=null);f=gf(this);ni(i,Math.max(0,i.height-f));n&&(ot(n,function(){yw(n,i,-f);ki(n,u,"widget")}),d(n,"lineWidgetCleared",n,this,u))}},bu.prototype.changed=function(){var r=this,u=this.height,n=this.doc.cm,t=this.line,i;(this.height=null,i=gf(this)-u,i)&&(bi(this.doc,t)||ni(t,t.height+i),n&&ot(n,function(){n.curOp.forceUpdate=!0;yw(n,t,i);d(n,"lineWidgetChanged",n,r,c(t))}))},uu(bu),wl=0,ai=function(n,t){this.lines=[];this.type=t;this.doc=n;this.id=++wl},ai.prototype.clear=function(){var n,s,u,i,f,e,t,r,o,h,l;if(!this.explicitlyCleared){for(n=this.doc.cm,s=n&&!n.curOp,s&&kr(n),yt(this,"clear")&&(u=this.find(),u&&d(this,"clear",u.from,u.to)),i=null,f=null,e=0;e<this.lines.length;++e)t=this.lines[e],r=kf(t.markedSpans,this),n&&!this.collapsed?ki(n,c(t),"text"):n&&(r.to!=null&&(f=c(t)),r.from!=null&&(i=c(t))),t.markedSpans=id(t.markedSpans,r),r.from==null&&this.collapsed&&!bi(this.doc,t)&&n&&ni(t,ou(n.display));if(n&&this.collapsed&&!n.options.lineWrapping)for(o=0;o<this.lines.length;++o)h=ii(this.lines[o]),l=po(h),l>n.display.maxLineLength&&(n.display.maxLine=h,n.display.maxLineLength=l,n.display.maxLineChanged=!0);i!=null&&n&&this.collapsed&&et(n,i,f+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,n&&uw(n.doc));n&&d(n,"markerCleared",n,this,i,f);s&&dr(n);this.parent&&this.parent.clear()}},ai.prototype.find=function(t,i){var f,o,e,r,u;for(t==null&&this.type=="bookmark"&&(t=1),e=0;e<this.lines.length;++e){if(r=this.lines[e],u=kf(r.markedSpans,this),u.from!=null&&(f=n(i?r:c(r),u.from),t==-1))return f;if(u.to!=null&&(o=n(i?r:c(r),u.to),t==1))return o}return f&&{from:f,to:o}},ai.prototype.changed=function(){var r=this,i=this.find(-1,!0),t=this,n=this.doc.cm;i&&n&&ot(n,function(){var u=i.line,s=c(i.line),e=cc(n,s),o,f;e&&(sy(e),n.curOp.selectionChanged=n.curOp.forceUpdate=!0);n.curOp.updateMaxLine=!0;bi(t.doc,u)||t.height==null||(o=t.height,t.height=null,f=gf(t)-o,f&&ni(u,u.height+f));d(n,"markerChanged",n,r)})},ai.prototype.attachLine=function(n){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&g(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(n)},ai.prototype.detachLine=function(n){if(this.lines.splice(g(this.lines,n),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},uu(ai),du=function(n,t){this.markers=n;this.primary=t;for(var i=0;i<n.length;++i)n[i].parent=this},du.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var n=0;n<this.markers.length;++n)this.markers[n].clear();d(this,"clear")}},du.prototype.find=function(n,t){return this.primary.find(n,t)},uu(du),ww=0,rt=function(t,i,r,u,f){if(!(this instanceof rt))return new rt(t,i,r,u,f);r==null&&(r=0);ve.call(this,[new ae([new lr("",null)])]);this.first=r;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.modeFrontier=this.highlightFrontier=r;var e=n(r,0);this.sel=nr(e);this.history=new us(null);this.id=++ww;this.modeOption=i;this.lineSep=u;this.direction=f=="rtl"?"rtl":"ltr";this.extend=!1;typeof t=="string"&&(t=this.splitLines(t));al(this,{from:e,to:e,text:t});nt(this,nr(e),gt)},rt.prototype=ha(ve.prototype,{constructor:rt,iter:function(n,t,i){i?this.iterN(n-this.first,t-n,i):this.iterN(this.first,this.first+this.size,n)},insert:function(n,t){for(var r=0,i=0;i<t.length;++i)r+=t[i].height;this.insertInner(n-this.first,t,r)},remove:function(n,t){this.removeInner(n-this.first,t)},getValue:function(n){var t=ph(this,this.first,this.first+this.size);return n===!1?t:t.join(n||this.lineSeparator())},setValue:k(function(i){var r=n(this.first,0),u=this.first+this.size-1;pu(this,{from:r,to:n(u,t(this,u).text.length),text:this.splitLines(i),origin:"setValue",full:!0},!0);this.cm&&ie(this.cm,0,0);nt(this,nr(r),gt)}),replaceRange:function(n,t,i,r){t=f(this,t);i=i?f(this,i):t;wu(this,n,t,i,r)},getRange:function(n,t,i){var r=hr(this,f(this,n),f(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(n){var t=this.getLineHandle(n);return t&&t.text},getLineHandle:function(n){if(pf(this,n))return t(this,n)},getLineNumber:function(n){return c(n)},getLineHandleVisualStart:function(n){return typeof n=="number"&&(n=t(this,n)),ii(n)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(n){return f(this,n)},getCursor:function(n){var t=this.sel.primary();return n==null||n=="head"?t.head:n=="anchor"?t.anchor:n=="end"||n=="to"||n===!1?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:k(function(t,i,r){tw(this,f(this,typeof t=="number"?n(t,i||0):t),null,r)}),setSelection:k(function(n,t,i){tw(this,f(this,n),f(this,t||n),i)}),extendSelection:k(function(n,t,i){es(this,f(this,n),t&&f(this,t),i)}),extendSelections:k(function(n,t){nw(this,nv(this,n),t)}),extendSelectionsBy:k(function(n,t){var i=fo(this.sel.ranges,n);nw(this,nv(this,i),t)}),setSelections:k(function(n,t,i){var u,r;if(n.length){for(u=[],r=0;r<n.length;r++)u[r]=new o(f(this,n[r].anchor),f(this,n[r].head));t==null&&(t=Math.min(n.length-1,this.sel.primIndex));nt(this,dt(this.cm,u,t),i)}}),addSelection:k(function(n,t,i){var r=this.sel.ranges.slice(0);r.push(new o(f(this,n),f(this,t||n)));nt(this,dt(this.cm,r,r.length-1),i)}),getSelection:function(n){for(var u,r=this.sel.ranges,t,i=0;i<r.length;i++)u=hr(this,r[i].from(),r[i].to()),t=t?t.concat(u):u;return n===!1?t:t.join(n||this.lineSeparator())},getSelections:function(n){for(var i,u=[],r=this.sel.ranges,t=0;t<r.length;t++)i=hr(this,r[t].from(),r[t].to()),n!==!1&&(i=i.join(n||this.lineSeparator())),u[t]=i;return u},replaceSelection:function(n,t,i){for(var u=[],r=0;r<this.sel.ranges.length;r++)u[r]=n;this.replaceSelections(u,t,i||"+input")},replaceSelections:k(function(n,t,i){for(var e,o,f,u=[],s=this.sel,r=0;r<s.ranges.length;r++)e=s.ranges[r],u[r]={from:e.from(),to:e.to(),text:this.splitLines(n[r]),origin:i};for(o=t&&t!="end"&&an(this,u,t),f=u.length-1;f>=0;f--)pu(this,u[f]);o?iw(this,o):this.cm&&cu(this.cm)}),undo:k(function(){hs(this,"undo")}),redo:k(function(){hs(this,"redo")}),undoSelection:k(function(){hs(this,"undo",!0)}),redoSelection:k(function(){hs(this,"redo",!0)}),setExtending:function(n){this.extend=n},getExtending:function(){return this.extend},historySize:function(){for(var t,n=this.history,r=0,u=0,i=0;i<n.done.length;i++)n.done[i].ranges||++r;for(t=0;t<n.undone.length;t++)n.undone[t].ranges||++u;return{undo:r,redo:u}},clearHistory:function(){var n=this;this.history=new us(this.history.maxGeneration);ir(this,function(t){return t.history=n.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(n){return n&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(n){return this.history.generation==(n||this.cleanGeneration)},getHistory:function(){return{done:vu(this.history.done),undone:vu(this.history.undone)}},setHistory:function(n){var t=this.history=new us(this.history.maxGeneration);t.done=vu(n.done.slice(0),null,!0);t.undone=vu(n.undone.slice(0),null,!0)},setGutterMarker:k(function(n,t,i){return le(this,n,"gutter",function(n){var r=n.gutterMarkers||(n.gutterMarkers={});return r[t]=i,!i&&la(r)&&(n.gutterMarkers=null),!0})}),clearGutter:k(function(n){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[n]&&le(t,i,"gutter",function(){return i.gutterMarkers[n]=null,la(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(n){var i;if(typeof n=="number"){if(!pf(this,n)||(i=n,n=t(this,n),!n))return null}else if(i=c(n),i==null)return null;return{line:i,handle:n,text:n.text,gutterMarkers:n.gutterMarkers,textClass:n.textClass,bgClass:n.bgClass,wrapClass:n.wrapClass,widgets:n.widgets}},addLineClass:k(function(n,t,i){return le(this,n,t=="gutter"?"gutter":"class",function(n){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(n[r]){if(gr(i).test(n[r]))return!1;n[r]+=" "+i}else n[r]=i;return!0})}),removeLineClass:k(function(n,t,i){return le(this,n,t=="gutter"?"gutter":"class",function(n){var f=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",u=n[f],r,e;if(u)if(i==null)n[f]=null;else{if(r=u.match(gr(i)),!r)return!1;e=r.index+r[0].length;n[f]=u.slice(0,r.index)+(!r.index||e==u.length?"":" ")+u.slice(e)||null}else return!1;return!0})}),addLineWidget:k(function(n,t,i){return ntt(this,n,t,i)}),removeLineWidget:function(n){n.clear()},markText:function(n,t,i){return ku(this,f(this,n),f(this,t),i,i&&i.type||"range")},setBookmark:function(n,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return n=f(this,n),ku(this,n,n,i,"bookmark")},findMarksAt:function(n){var e,r,u,i;if(n=f(this,n),e=[],r=t(this,n.line).markedSpans,r)for(u=0;u<r.length;++u)i=r[u],(i.from==null||i.from<=n.ch)&&(i.to==null||i.to>=n.ch)&&e.push(i.marker.parent||i.marker);return e},findMarks:function(n,t,i){n=f(this,n);t=f(this,t);var u=[],r=n.line;return this.iter(n.line,t.line+1,function(f){var s=f.markedSpans,o,e;if(s)for(o=0;o<s.length;o++)e=s[o],e.to!=null&&r==n.line&&n.ch>=e.to||e.from==null&&r!=n.line||e.from!=null&&r==t.line&&e.from>=t.ch||i&&!i(e.marker)||u.push(e.marker.parent||e.marker);++r}),u},getAllMarks:function(){var n=[];return this.iter(function(t){var r=t.markedSpans,i;if(r)for(i=0;i<r.length;++i)r[i].from!=null&&n.push(r[i].marker)}),n},posFromIndex:function(t){var i,r=this.first,u=this.lineSeparator().length;return this.iter(function(n){var f=n.text.length+u;if(f>t)return i=t,!0;t-=f;++r}),f(this,n(r,i))},indexFromPos:function(n){var t,i;return(n=f(this,n),t=n.ch,n.line<this.first||n.ch<0)?0:(i=this.lineSeparator().length,this.iter(this.first,n.line,function(n){t+=n.text.length+i}),t)},copy:function(n){var t=new rt(ph(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,n&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(n){var i,r,t;return n||(n={}),i=this.first,r=this.first+this.size,n.from!=null&&n.from>i&&(i=n.from),n.to!=null&&n.to<r&&(r=n.to),t=new rt(ph(this,i,r),n.mode||this.modeOption,i,this.lineSep,this.direction),n.sharedHist&&(t.history=this.history),(this.linked||(this.linked=[])).push({doc:t,sharedHist:n.sharedHist}),t.linked=[{doc:this,isParent:!0,sharedHist:n.sharedHist}],itt(t,pw(this)),t},unlinkDoc:function(n){var t,r,i;if(n instanceof a&&(n=n.doc),this.linked)for(t=0;t<this.linked.length;++t)if(r=this.linked[t],r.doc==n){this.linked.splice(t,1);n.unlinkDoc(this);rtt(pw(this));break}n.history==this.history&&(i=[n.id],ir(n,function(n){return i.push(n.id)},!0),n.history=new us(null),n.history.done=vu(this.history.done,i),n.history.undone=vu(this.history.undone,i))},iterLinkedDocs:function(n){ir(this,n)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(n){return this.lineSep?n.split(this.lineSep):lh(n)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:k(function(n){(n!="rtl"&&(n="ltr"),n!=this.direction)&&(this.direction=n,this.iter(function(n){return n.order=null}),this.cm&&vn(this.cm))})}),rt.prototype.eachLine=rt.prototype.iter,bl=0,kl=!1,vi={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},gu=0;gu<10;gu++)vi[gu+48]=vi[gu+96]=String(gu);for(ye=65;ye<=90;ye++)vi[ye]=String.fromCharCode(ye);for(nf=1;nf<=12;nf++)vi[nf+111]=vi[nf+63235]="F"+nf;fi={};fi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};fi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};fi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"};fi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};fi["default"]=at?fi.macDefault:fi.pcDefault;uf={selectAll:ow,singleSelection:function(n){return n.setSelection(n.getCursor("anchor"),n.getCursor("head"),gt)},killLine:function(i){return rf(i,function(r){if(r.empty()){var u=t(i.doc,r.head.line).text.length;return r.head.ch==u&&r.head.line<i.lastLine()?{from:r.head,to:n(r.head.line+1,0)}:{from:r.head,to:n(r.head.line,u)}}return{from:r.from(),to:r.to()}})},deleteLine:function(t){return rf(t,function(i){return{from:n(i.from().line,0),to:f(t.doc,n(i.to().line+1,0))}})},delLineLeft:function(t){return rf(t,function(t){return{from:n(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(n){return rf(n,function(t){var i=n.charCoords(t.head,"div").top+5,r=n.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(n){return rf(n,function(t){var i=n.charCoords(t.head,"div").top+5,r=n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(n){return n.undo()},redo:function(n){return n.redo()},undoSelection:function(n){return n.undoSelection()},redoSelection:function(n){return n.redoSelection()},goDocStart:function(t){return t.extendSelection(n(t.firstLine(),0))},goDocEnd:function(t){return t.extendSelection(n(t.lastLine()))},goLineStart:function(n){return n.extendSelectionsBy(function(t){return tb(n,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(n){return n.extendSelectionsBy(function(t){return ib(n,t.head)},{origin:"+move",bias:1})},goLineEnd:function(n){return n.extendSelectionsBy(function(t){return vtt(n,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(n){return n.extendSelectionsBy(function(t){var i=n.cursorCoords(t.head,"div").top+5;return n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:i},"div")},cf)},goLineLeft:function(n){return n.extendSelectionsBy(function(t){var i=n.cursorCoords(t.head,"div").top+5;return n.coordsChar({left:0,top:i},"div")},cf)},goLineLeftSmart:function(n){return n.extendSelectionsBy(function(t){var r=n.cursorCoords(t.head,"div").top+5,i=n.coordsChar({left:0,top:r},"div");return i.ch<n.getLine(i.line).search(/\S/)?ib(n,t.head):i},cf)},goLineUp:function(n){return n.moveV(-1,"line")},goLineDown:function(n){return n.moveV(1,"line")},goPageUp:function(n){return n.moveV(-1,"page")},goPageDown:function(n){return n.moveV(1,"page")},goCharLeft:function(n){return n.moveH(-1,"char")},goCharRight:function(n){return n.moveH(1,"char")},goColumnLeft:function(n){return n.moveH(-1,"column")},goColumnRight:function(n){return n.moveH(1,"column")},goWordLeft:function(n){return n.moveH(-1,"word")},goGroupRight:function(n){return n.moveH(1,"group")},goGroupLeft:function(n){return n.moveH(-1,"group")},goWordRight:function(n){return n.moveH(1,"word")},delCharBefore:function(n){return n.deleteH(-1,"codepoint")},delCharAfter:function(n){return n.deleteH(1,"char")},delWordBefore:function(n){return n.deleteH(-1,"word")},delWordAfter:function(n){return n.deleteH(1,"word")},delGroupBefore:function(n){return n.deleteH(-1,"group")},delGroupAfter:function(n){return n.deleteH(1,"group")},indentAuto:function(n){return n.indentSelection("smart")},indentMore:function(n){return n.indentSelection("add")},indentLess:function(n){return n.indentSelection("subtract")},insertTab:function(n){return n.replaceSelection("\t")},insertSoftTab:function(n){for(var r,e,u=[],f=n.listSelections(),t=n.options.tabSize,i=0;i<f.length;i++)r=f[i].from(),e=vt(n.getLine(r.line),r.ch,t),u.push(ih(t-e%t));n.replaceSelections(u)},defaultTab:function(n){n.somethingSelected()?n.indentSelection("add"):n.execCommand("insertTab")},transposeChars:function(i){return ot(i,function(){for(var r,u,f,s=i.listSelections(),h=[],e=0;e<s.length;e++)s[e].empty()&&(r=s[e].head,u=t(i.doc,r.line).text,u&&(r.ch==u.length&&(r=new n(r.line,r.ch-1)),r.ch>0?(r=new n(r.line,r.ch+1),i.replaceRange(u.charAt(r.ch-1)+u.charAt(r.ch-2),n(r.line,r.ch-2),r,"+transpose")):r.line>i.doc.first&&(f=t(i.doc,r.line-1).text,f&&(r=new n(r.line,1),i.replaceRange(u.charAt(0)+i.doc.lineSeparator()+f.charAt(f.length-1),n(r.line-1,f.length-1),r,"+transpose")))),h.push(new o(r,r)));i.setSelections(h)})},newlineAndIndent:function(n){return ot(n,function(){for(var r,t=n.listSelections(),i=t.length-1;i>=0;i--)n.replaceRange(n.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");for(t=n.listSelections(),r=0;r<t.length;r++)n.indentLine(t[r].from().line,null,!0);cu(n)})},openLine:function(n){return n.replaceSelection("\n","start")},toggleOverwrite:function(n){return n.toggleOverwrite()}};rb=new si;as=null;hb=400;vs=function(n,t,i){this.time=n;this.pos=t;this.button=i};vs.prototype.compare=function(n,t,i){return this.time+hb>n&&u(t,this.pos)==0&&i==this.button};var ff={toString:function(){return"CodeMirror.Init"}},pb={},ys={};a.defaults=pb;a.optionHandlers=ys;ps=[];a.defineInitHook=function(n){return ps.push(n)};pt=null;h=function(n){this.cm=n;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new si;this.composing=null;this.gracePeriod=!1;this.readDOMTimeout=null};h.prototype.init=function(n){function e(n){for(var t=n.target;t;t=t.parentNode){if(t==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}return!1}function o(n){var u,o,r,s,h;if(e(n)&&!w(t,n)){if(t.somethingSelected())ws({lineWise:!1,text:t.getSelections()}),n.type=="cut"&&t.replaceSelection("",null,"cut");else if(t.options.lineWiseCopyCut)u=kb(t),ws({lineWise:!0,text:u.text}),n.type=="cut"&&t.operation(function(){t.setSelections(u.ranges,0,gt);t.replaceSelection("",null,"cut")});else return;if(n.clipboardData&&(n.clipboardData.clearData(),o=pt.text.join("\n"),n.clipboardData.setData("Text",o),n.clipboardData.getData("Text")==o)){n.preventDefault();return}r=gb();s=r.firstChild;t.display.lineSpace.insertBefore(r,t.display.lineSpace.firstChild);s.value=pt.text.join("\n");h=document.activeElement;iu(s);setTimeout(function(){t.display.lineSpace.removeChild(r);h.focus();h==i&&f.showPrimarySelection()},50)}}var u=this,f=this,t=f.cm,i=f.div=n.lineDiv;db(i,t.options.spellcheck,t.options.autocorrect,t.options.autocapitalize);r(i,"paste",function(n){!e(n)||w(t,n)||wb(n,t)||l<=11&&setTimeout(b(t,function(){return u.updateFromDOM()}),20)});r(i,"compositionstart",function(n){u.composing={data:n.data,done:!1}});r(i,"compositionupdate",function(n){u.composing||(u.composing={data:n.data,done:!1})});r(i,"compositionend",function(n){u.composing&&(n.data!=u.composing.data&&u.readFromDOMSoon(),u.composing.done=!0)});r(i,"touchstart",function(){return f.forceCompositionEnd()});r(i,"input",function(){u.composing||u.readFromDOMSoon()});r(i,"copy",o);r(i,"cut",o)};h.prototype.screenReaderLabelChanged=function(n){n?this.div.setAttribute("aria-label",n):this.div.removeAttribute("aria-label")};h.prototype.prepareSelection=function(){var n=ky(this.cm,!1);return n.focus=document.activeElement==this.div,n};h.prototype.showSelection=function(n,t){n&&this.cm.display.view.length&&((n.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(n))};h.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()};h.prototype.showPrimarySelection=function(){var n=this.getSelection(),t=this.cm,y=t.doc.sel.primary(),c=y.from(),l=y.to(),r,f,s,i,v,h;if(t.display.viewTo==t.display.viewFrom||c.line>=t.display.viewTo||l.line<t.display.viewFrom){n.removeAllRanges();return}if(r=bs(t,n.anchorNode,n.anchorOffset),f=bs(t,n.focusNode,n.focusOffset),!r||r.bad||!f||f.bad||u(co(r,f),c)!=0||u(ho(r,f),l)!=0){var a=t.display.view,e=c.line>=t.display.viewFrom&&tk(t,c)||{node:a[0].measure.map[2],offset:0},o=l.line<t.display.viewTo&&tk(t,l);if(o||(s=a[a.length-1].measure,i=s.maps?s.maps[s.maps.length-1]:s.map,o={node:i[i.length-1],offset:i[i.length-2]-i[i.length-3]}),!e||!o){n.removeAllRanges();return}v=n.rangeCount&&n.getRangeAt(0);try{h=tu(e.node,e.offset,o.offset,o.node)}catch(p){}h&&(!ei&&t.state.focused?(n.collapse(e.node,e.offset),h.collapsed||(n.removeAllRanges(),n.addRange(h))):(n.removeAllRanges(),n.addRange(h)),v&&n.anchorNode==null?n.addRange(v):ei&&this.startGracePeriod());this.rememberSelection()}};h.prototype.startGracePeriod=function(){var n=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){n.gracePeriod=!1;n.selectionChanged()&&n.cm.operation(function(){return n.cm.curOp.selectionChanged=!0})},20)};h.prototype.showMultipleSelections=function(n){ct(this.cm.display.cursorDiv,n.cursors);ct(this.cm.display.selectionDiv,n.selection)};h.prototype.rememberSelection=function(){var n=this.getSelection();this.lastAnchorNode=n.anchorNode;this.lastAnchorOffset=n.anchorOffset;this.lastFocusNode=n.focusNode;this.lastFocusOffset=n.focusOffset};h.prototype.selectionInEditor=function(){var n=this.getSelection(),t;return n.rangeCount?(t=n.getRangeAt(0).commonAncestorContainer,wi(this.div,t)):!1};h.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())};h.prototype.blur=function(){this.div.blur()};h.prototype.getField=function(){return this.div};h.prototype.supportsTouch=function(){return!0};h.prototype.receivedFocus=function(){function t(){n.cm.state.focused&&(n.pollSelection(),n.polling.set(n.cm.options.pollInterval,t))}var n=this;this.selectionInEditor()?this.pollSelection():ot(this.cm,function(){return n.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,t)};h.prototype.selectionChanged=function(){var n=this.getSelection();return n.anchorNode!=this.lastAnchorNode||n.anchorOffset!=this.lastAnchorOffset||n.focusNode!=this.lastFocusNode||n.focusOffset!=this.lastFocusOffset};h.prototype.pollSelection=function(){var n,t,i,r;if(this.readDOMTimeout==null&&!this.gracePeriod&&this.selectionChanged()){if(n=this.getSelection(),t=this.cm,io&&no&&this.cm.display.gutterSpecs.length&&hit(n.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs});this.blur();this.focus();return}this.composing||(this.rememberSelection(),i=bs(t,n.anchorNode,n.anchorOffset),r=bs(t,n.focusNode,n.focusOffset),i&&r&&ot(t,function(){nt(t.doc,nr(i,r),gt);(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)}))}};h.prototype.pollContent=function(){var d,v,b,k,y,g,i,e,nt,tt;this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var r=this.cm,f=r.display,it=r.doc.sel.primary(),h=it.from(),a=it.to();if((h.ch==0&&h.line>r.firstLine()&&(h=n(h.line-1,t(r.doc,h.line-1).length)),a.ch==t(r.doc,a.line).text.length&&a.line<r.lastLine()&&(a=n(a.line+1,0)),h.line<f.viewFrom||a.line>f.viewTo-1)||(h.line==f.viewFrom||(d=wr(r,h.line))==0?(v=c(f.view[0].line),b=f.view[0].node):(v=c(f.view[d].line),b=f.view[d-1].node.nextSibling),k=wr(r,a.line),k==f.view.length-1?(y=f.viewTo-1,g=f.lineDiv.lastChild):(y=c(f.view[k+1].line)-1,g=f.view[k+1].node.previousSibling),!b))return!1;for(i=r.doc.splitLines(cit(r,b,g,v,y)),e=hr(r.doc,n(v,0),n(y,t(r.doc,y).text.length));i.length>1&&e.length>1;)if(s(i)==s(e))i.pop(),e.pop(),y--;else if(i[0]==e[0])i.shift(),e.shift(),v++;else break;for(var o=0,l=0,rt=i[0],ut=e[0],ft=Math.min(rt.length,ut.length);o<ft&&rt.charCodeAt(o)==ut.charCodeAt(o);)++o;for(var p=s(i),w=s(e),et=Math.min(p.length-(i.length==1?o:0),w.length-(e.length==1?o:0));l<et&&p.charCodeAt(p.length-l-1)==w.charCodeAt(w.length-l-1);)++l;if(i.length==1&&e.length==1&&v==h.line)while(o&&o>h.ch&&p.charCodeAt(p.length-l-1)==w.charCodeAt(w.length-l-1))o--,l++;return i[i.length-1]=p.slice(0,p.length-l).replace(/^\u200b+/,""),i[0]=i[0].slice(o).replace(/\u200b+$/,""),nt=n(v,o),tt=n(y,e.length?s(e).length-l:0),i.length>1||i[0]||u(nt,tt)?(wu(r.doc,i,nt,tt,"+input"),!0):void 0};h.prototype.ensurePolled=function(){this.forceCompositionEnd()};h.prototype.reset=function(){this.forceCompositionEnd()};h.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())};h.prototype.readFromDOMSoon=function(){var n=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(n.readDOMTimeout=null,n.composing)if(n.composing.done)n.composing=null;else return;n.updateFromDOM()},80))};h.prototype.updateFromDOM=function(){var n=this;(this.cm.isReadOnly()||!this.pollContent())&&ot(this.cm,function(){return et(n.cm)})};h.prototype.setUneditable=function(n){n.contentEditable="false"};h.prototype.onKeyPress=function(n){n.charCode==0||this.composing||(n.preventDefault(),this.cm.isReadOnly()||b(this.cm,ia)(this.cm,String.fromCharCode(n.charCode==null?n.keyCode:n.charCode),0))};h.prototype.readOnlyChanged=function(n){this.div.contentEditable=String(n!="nocursor")};h.prototype.onContextMenu=function(){};h.prototype.resetPosition=function(){};h.prototype.needsContentAttribute=!0;v=function(n){this.cm=n;this.prevInput="";this.pollingFast=!1;this.polling=new si;this.hasSelection=!1;this.composing=null};v.prototype.init=function(n){function o(n){if(!w(t,n)){if(t.somethingSelected())ws({lineWise:!1,text:t.getSelections()});else if(t.options.lineWiseCopyCut){var r=kb(t);ws({lineWise:!0,text:r.text});n.type=="cut"?t.setSelections(r.ranges,null,gt):(u.prevInput="",i.value=r.text.join("\n"),iu(i))}else return;n.type=="cut"&&(t.state.cutIncoming=+new Date)}}var f=this,u=this,t=this.cm,i;this.createField(n);i=this.textarea;n.wrapper.insertBefore(this.wrapper,n.wrapper.firstChild);sf&&(i.style.width="0px");r(i,"input",function(){e&&l>=9&&f.hasSelection&&(f.hasSelection=null);u.poll()});r(i,"paste",function(n){w(t,n)||wb(n,t)||(t.state.pasteIncoming=+new Date,u.fastPoll())});r(i,"cut",o);r(i,"copy",o);r(n.scroller,"paste",function(r){if(!li(n,r)&&!w(t,r)){if(!i.dispatchEvent){t.state.pasteIncoming=+new Date;u.focus();return}var f=new Event("paste");f.clipboardData=r.clipboardData;i.dispatchEvent(f)}});r(n.lineSpace,"selectstart",function(t){li(n,t)||ft(t)});r(i,"compositionstart",function(){var n=t.getCursor("from");u.composing&&u.composing.range.clear();u.composing={start:n,range:t.markText(n,t.getCursor("to"),{className:"CodeMirror-composing"})}});r(i,"compositionend",function(){u.composing&&(u.poll(),u.composing.range.clear(),u.composing=null)})};v.prototype.createField=function(){this.wrapper=gb();this.textarea=this.wrapper.firstChild};v.prototype.screenReaderLabelChanged=function(n){n?this.textarea.setAttribute("aria-label",n):this.textarea.removeAttribute("aria-label")};v.prototype.prepareSelection=function(){var n=this.cm,t=n.display,e=n.doc,i=ky(n);if(n.options.moveInputWithCursor){var r=kt(n,e.sel.primary().head,"div"),u=t.wrapper.getBoundingClientRect(),f=t.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+f.top-u.top));i.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+f.left-u.left))}return i};v.prototype.showSelection=function(n){var i=this.cm,t=i.display;ct(t.cursorDiv,n.cursors);ct(t.selectionDiv,n.selection);n.teTop!=null&&(this.wrapper.style.top=n.teTop+"px",this.wrapper.style.left=n.teLeft+"px")};v.prototype.reset=function(n){var t,i;this.contextMenuPending||this.composing||(t=this.cm,t.somethingSelected()?(this.prevInput="",i=t.getSelection(),this.textarea.value=i,t.state.focused&&iu(this.textarea),e&&l>=9&&(this.hasSelection=i)):n||(this.prevInput=this.textarea.value="",e&&l>=9&&(this.hasSelection=null)))};v.prototype.getField=function(){return this.textarea};v.prototype.supportsTouch=function(){return!1};v.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!hf||oi()!=this.textarea))try{this.textarea.focus()}catch(n){}};v.prototype.blur=function(){this.textarea.blur()};v.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0};v.prototype.receivedFocus=function(){this.slowPoll()};v.prototype.slowPoll=function(){var n=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){n.poll();n.cm.state.focused&&n.slowPoll()})};v.prototype.fastPoll=function(){function i(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,i))}var t=!1,n=this;n.pollingFast=!0;n.polling.set(20,i)};v.prototype.poll=function(){var i=this,n=this.cm,f=this.textarea,r=this.prevInput,t,o,u,s;if(this.contextMenuPending||!n.state.focused||ak(f)&&!r&&!this.composing||n.isReadOnly()||n.options.disableInput||n.state.keySeq||(t=f.value,t==r&&!n.somethingSelected()))return!1;if(e&&l>=9&&this.hasSelection===t||at&&/[\uf700-\uf7ff]/.test(t))return n.display.input.reset(),!1;if(n.doc.sel==n.display.selForContextMenu&&(o=t.charCodeAt(0),o!=8203||r||(r="​"),o==8666))return this.reset(),this.cm.execCommand("undo");for(u=0,s=Math.min(r.length,t.length);u<s&&r.charCodeAt(u)==t.charCodeAt(u);)++u;return ot(n,function(){ia(n,t.slice(u),r.length-u,null,i.composing?"*compose":null);t.length>1e3||t.indexOf("\n")>-1?f.value=i.prevInput="":i.prevInput=t;i.composing&&(i.composing.range.clear(),i.composing.range=n.markText(i.composing.start,n.getCursor("to"),{className:"CodeMirror-composing"}))}),!0};v.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)};v.prototype.onKeyPress=function(){e&&l>=9&&(this.hasSelection=null);this.fastPoll()};v.prototype.onContextMenu=function(n){function p(){if(f.selectionStart!=null){var n=i.somethingSelected(),r="​"+(n?f.value:"");f.value="⇚";f.value=r;t.prevInput=n?"":"​";f.selectionStart=1;f.selectionEnd=r.length;u.selForContextMenu=i.doc.sel}}function s(){if(t.contextMenuPending==s&&(t.contextMenuPending=!1,t.wrapper.style.cssText=k,f.style.cssText=w,e&&l<9&&u.scrollbars.setScrollTop(u.scroller.scrollTop=c),f.selectionStart!=null)){(!e||e&&l<9)&&p();var r=0,n=function(){u.selForContextMenu==i.doc.sel&&f.selectionStart==0&&f.selectionEnd>0&&t.prevInput=="​"?b(i,ow)(i):r++<10?u.detectingSelectAll=setTimeout(n,500):(u.selForContextMenu=null,u.input.reset())};u.detectingSelectAll=setTimeout(n,200)}}var t=this,i=t.cm,u=i.display,f=t.textarea,o,c,a,y,h;if(t.contextMenuPending&&t.contextMenuPending(),o=pr(i,n),c=u.scroller.scrollTop,o&&!wt){a=i.options.resetSelectionOnContextMenu;a&&i.doc.sel.contains(o)==-1&&b(i,nt)(i.doc,nr(o),gt);var w=f.style.cssText,k=t.wrapper.style.cssText,v=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static";f.style.cssText="position: absolute; width: 30px; height: 30px;\n      top: "+(n.clientY-v.top-5)+"px; left: "+(n.clientX-v.left-5)+"px;\n      z-index: 1000; background: "+(e?"rgba(255, 255, 255, .05)":"transparent")+";\n      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";tt&&(y=window.scrollY);u.input.focus();tt&&window.scrollTo(null,y);u.input.reset();i.somethingSelected()||(f.value=t.prevInput=" ");t.contextMenuPending=s;u.selForContextMenu=i.doc.sel;clearTimeout(u.detectingSelectAll);e&&l>=9&&p();ro?(yf(n),h=function(){lt(window,"mouseup",h);setTimeout(s,20)},r(window,"mouseup",h)):setTimeout(s,50)}};v.prototype.readOnlyChanged=function(n){n||this.reset();this.textarea.disabled=n=="nocursor";this.textarea.readOnly=!!n};v.prototype.setUneditable=function(){};v.prototype.needsContentAttribute=!1;uit(a);sit(a);ik="iter insert remove copy getEditor constructor".split(" ");for(de in rt.prototype)rt.prototype.hasOwnProperty(de)&&g(ik,de)<0&&(a.prototype[de]=function(n){return function(){return n.apply(this.doc,arguments)}}(rt.prototype[de]));return uu(rt),a.inputStyles={textarea:v,contenteditable:h},a.defineMode=function(n){a.defaults.mode||n=="null"||(a.defaults.mode=n);pk.apply(this,arguments)},a.defineMIME=wk,a.defineMode("null",function(){return{token:function(n){return n.skipToEnd()}}}),a.defineMIME("text/plain","null"),a.defineExtension=function(n,t){a.prototype[n]=t},a.defineDocExtension=function(n,t){rt.prototype[n]=t},a.fromTextArea=ait,vit(a),a.version="5.59.1",a}),function(n){"function"==typeof n.define&&n.define("core",["codemirror.js"],function(t){n.CodeMirror=t})}(this),function(n){if("undefined"==typeof n)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;n.extend(n.fn,{ckeditorGet:function(){var n=this.eq(0).data("ckeditorInstance");if(!n)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return n},ckeditor:function(t,i){var f,r,u;if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");return n.isFunction(t)||(f=i,i=t,t=f),r=[],i=i||{},this.each(function(){var u=n(this),e=u.data("ckeditorInstance"),s=u.data("_ckeditorInstanceLock"),f=this,o=new n.Deferred;if(r.push(o.promise()),e&&!s)t&&t.apply(e,[this]),o.resolve();else if(s)e.once("instanceReady",function(){setTimeout(function(){e.element?(e.element.$==f&&t&&t.apply(e,[f]),o.resolve()):setTimeout(arguments.callee,100)},0)},null,null,9999);else{(i.autoUpdateElement||"undefined"==typeof i.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)&&(i.autoUpdateElementJquery=!0);i.autoUpdateElement=!1;u.data("_ckeditorInstanceLock",!0);e=n(this).is("textarea")?CKEDITOR.replace(f,i):CKEDITOR.inline(f,i);u.data("ckeditorInstance",e);e.on("instanceReady",function(i){var r=i.editor;setTimeout(function(){if(r.element){i.removeListener();r.on("dataReady",function(){u.trigger("dataReady.ckeditor",[r])});r.on("setData",function(n){u.trigger("setData.ckeditor",[r,n.data])});r.on("getData",function(n){u.trigger("getData.ckeditor",[r,n.data])},999);r.on("destroy",function(){u.trigger("destroy.ckeditor",[r])});r.on("save",function(){return n(f.form).submit(),!1},null,null,20);if(r.config.autoUpdateElementJquery&&u.is("textarea")&&n(f.form).length){var e=function(){u.ckeditor(function(){r.updateElement()})};n(f.form).submit(e);n(f.form).bind("form-pre-serialize",e);u.bind("destroy.ckeditor",function(){n(f.form).unbind("submit",e);n(f.form).unbind("form-pre-serialize",e)})}r.on("destroy",function(){u.removeData("ckeditorInstance")});u.removeData("_ckeditorInstanceLock");u.trigger("instanceReady.ckeditor",[r]);t&&t.apply(r,[f]);o.resolve()}else setTimeout(arguments.callee,100)},0)},null,null,9999)}}),u=new n.Deferred,this.promise=u.promise(),n.when.apply(this,r).then(function(){u.resolve()}),this.editor=this.eq(0).data("ckeditorInstance"),this}});CKEDITOR.config.jqueryOverrideVal&&(n.fn.val=CKEDITOR.tools.override(n.fn.val,function(t){return function(i){var f,r,e;if(arguments.length){var o=this,u=[],r=this.each(function(){var r=n(this),e=r.data("ckeditorInstance"),f;return r.is("textarea")&&e?(f=new n.Deferred,e.setData(i,function(){f.resolve()}),u.push(f.promise()),!0):t.call(r,i)});return u.length?(f=new n.Deferred,n.when.apply(this,u).done(function(){f.resolveWith(o)}),f.promise()):r}return r=n(this).eq(0),e=r.data("ckeditorInstance"),r.is("textarea")&&e?e.getData():t.call(r)}}))}(window.jQuery),function(n){function r(){return n(this.element.$)}function u(){return n(this.container.$)}function f(){return this.getHostElement().attr("data-editorId").indexOf("{uid}")==-1}function e(){return this.getHostElement().attr("data-editorId").search("_temp[a-z0-9]+_")>0}function o(){return this.getContainer().is(":hidden")}function s(n){var i=this.getHostElement(),t,r,e,u,o,f;if(!i.is(".textEditor"))throw"current el is not WYSIWYG!";if(n==0&&(n="temp"+uuid.v4().replace(/-/g,"")),t=i.attr("data-editorId"),t.indexOf("{uid}")>0)i.attr("data-editorId",t.replace("{uid}",n));else{if(r=t.search("_[0-9]+_")+1,r>0){e=t.substring(r,t.indexOf("_",r));i.attr("data-editorId",t.replace(e,n));return}if(u=t.search("_temp[a-z0-9]+_")+1,u>0){o=t.substring(u,u+36);f=t.replace(o,n);i.attr("data-editorId",f);Notifier.get("textEditor").trigger("editorIdUpdated",t,f);return}throw'Failed to find editor Uid in "'+t+'"';}}function h(n,r){var f="",s="p;h1;h2;h3;h4;h5;h6",h="100%",c=["codemirror"],o,e,u;return _(n.widgets).each(function(n){var t=i(n);c.push(t);CKEDITOR.plugins.addExternal(t,n)}),n.toolbar?f=n.toolbar:n.mode&&n.mode!="Full"?n.mode=="Basic"?f=[{name:"basicstyles",groups:["basicstyles","cleanup"],items:["Bold","Italic","Underline","Strike","Subscript","Superscript","RemoveFormat"]},{name:"colors",items:["TextColor","BGColor"]},{name:"styles",items:["FontSize","Format","Font"]},{name:"paragraph",groups:["list","indent","blocks","align","bidi"],items:["NumberedList","BulletedList","-","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"]},{name:"clipboard",groups:["clipboard","undo"]},{name:"links",items:["Link","Unlink"]},{name:"insert",items:["Image","Media","Table"]},{name:"document",items:["Source"]}]:n.mode=="Restricted"&&(f=[{name:"basicstyles",groups:["basicstyles","cleanup"],items:["Bold","Italic","Underline","Strike","Subscript","Superscript","RemoveFormat"]},{name:"styles",items:["FontSize","Format","Font"]},{name:"paragraph",groups:["list","indent","blocks","align","bidi"],items:["NumberedList","BulletedList","-","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"]},{name:"clipboard",groups:["clipboard","undo"]}],n.allowUseLinks&&f.push({name:"links",items:["Link","Unlink"]}),n.allowViewSource&&f.push({name:"document",items:["Source"]}),h="95%"):(o=["Image","Media","-","Table","HorizontalRule","SpecialChar","Iframe"],t(n)&&o.push("-","menubutton"),f=[{name:"clipboard",groups:["clipboard","undo"],items:["Cut","Copy","-","Undo","Redo"]},{name:"links",items:["Link","Unlink","Anchor"]},{name:"insert",items:o},{name:"tools",items:["Maximize"]},{name:"document",groups:["mode","document","doctools"],items:["Source"]},"/",{name:"basicstyles",groups:["basicstyles","cleanup"],items:["Bold","Italic","Underline","Strike","Subscript","Superscript","-","RemoveFormat"]},{name:"paragraph",groups:["list","indent","blocks","align","bidi"],items:["NumberedList","BulletedList","-","Outdent","Indent","-","Blockquote","-","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"]},{name:"colors",items:["TextColor","BGColor"]},{name:"styles",items:["Styles","Format","Font","FontSize"]},{name:"about",items:["About"]}],s+=";pre"),e={format_tags:s,toolbar:f,removeButtons:null,height:n.height,width:h,readOnly:_.isBoolean(n.readOnly)?n.readOnly:Security.isReadOnly(r),extraPlugins:c.join(),resize_enabled:n.resizeEnabled},u={},n.allowedHtmlTags?_(n.allowedHtmlTags.split(/(?:\s|,|;)+/g)).each(function(n){u[n]=!0}):(u={},_(CKEDITOR.dtd).chain().keys().each(function(n){n.startsWith("$")||(u[n]=!0)})),u.b&&!u.strong&&(e.coreStyles_bold={element:"b"}),u.i&&!u.em&&(e.coreStyles_italic={element:"i"}),e.allowedContent={$1:{elements:u,attributes:!0,styles:!0,classes:!0}},u.iframe&&(delete u.iframe,e.allowedContent.iframe={match:function(n){var r="allow-scripts",u="allow-same-origin",f="allow-forms",i=" ",t=n.attributes.sandbox;return _.isUndefined(t)?(n.attributes.sandbox=[r,u,f].join(i),!0):t.contains("allow-top-navigation")?!1:(t.contains(f)||(t+=i+f),t.contains(r)||(t+=i+r),t.contains(u)||(t+=i+u),n.attributes.sandbox=t,!0)},attributes:!0,classes:!0,styles:!0}),e.disallowedContent="form",e}function c(n){var t=n.setReadOnly;n.setReadOnly=function(n){if(this.instanceReady)t.call(this,n);else this.on("instanceReady",function(i){t.call(i.editor,n)})}}function l(n){n.delayedSetDataFuncs=[];var t=n.setData;n.setData=function(n,i,r){var u,f;if(r||this.status=="unloaded"){t.call(this,n,i,r);return}u=this;this.isSetDataInProgress?this.delayedSetDataFuncs.push(function(){u.setData(n,i,r)}):(f=_.isFunction(i)?i:(i||{}).callback,i=_.extend(_.isFunction(i)?{}:i||{},{callback:function(){_.isFunction(f)&&f.call(u);u.isSetDataInProgress=!1;var n=u.delayedSetDataFuncs.shift();n&&n.call()}}),this.isSetDataInProgress=!0,t.call(this,n,i,r))}}function i(n){var t=n.split("/");return t[t.length-2]}function t(n){return!n.hideCustomWidgets&&!_.isEmpty(n.widgets)}function a(n,t){n.addMenuGroup("add_widget");var r={};return _(t).each(function(n,t){var u=CKEDITOR.plugins.registered[i(n)];u&&(r["widget_"+u.name]={label:u.label||u.name,group:"add_widget",command:u.commandName,icon:u.path+"icons/"+u.icons+".png",order:t})}),n.addMenuItems(r),_(r).mapObject(function(){return CKEDITOR.TRISTATE_OFF})}n.extend(n,{textEditor:function(t,i){var r,u="textarea[data-editorId='"+t+"']",f;return i?(f=i.is(u)?i:i.find(u),r=f.attr("id")):r=n(u).attr("id"),r||(r=t),CKEDITOR.instances[r]}});n.extend(n.fn,{textEditor:function(i){var w,y,p,b,k,v;if(_.isString(i))return n.textEditor(i,this);if(!i&&(w=this.is("textarea.textEditor")?this:this.find("textarea.textEditor"),y=CKEDITOR.instances[w.attr("id")],y))return y;p=null;CKEDITOR.on("instanceReady",function(r){var u=r.editor,f=n(u.element).attr("id");_.isUndefined(window.readyTextEditorIds)&&(window.readyTextEditorIds=[]);window.readyTextEditorIds.push(f);u.commands.image.exec=function(){CKEditorMediaPlugin.selectImage(f)};n(u.element.$).parent().find(".cke_button.cke_button__removeformat").attr("title","Remove Formatting");t(i)&&(p=a(u,i.widgets));u.readOnly&&n(u.editable().$).css({color:"rgb(187, 187, 187)","background-color":"rgb(254, 254, 254)"});_(["p","ul"]).each(function(n){r.editor.dataProcessor.writer.setRules(n,{indent:!1,breakBeforeOpen:!1,breakAfterOpen:!1,breakBeforeClose:!1,breakAfterClose:!1})})});return i=i||{},this.data("settings",i),b=h(i,this),this.ckeditor(b),this.addClass("textEditor"),k=this.attr("id"),v=CKEDITOR.instances[k],v.addCommand("insertMedia",new CKEDITOR.command(v,{exec:function(t){var i=n(t.element).attr("id");CKEditorMediaPlugin.selectMedia(i)}})),v.ui.addButton("Media",{label:"Media",command:"insertMedia",toolbar:"insert",icon:appConfig.applicationRoot+"common/Content/images/media.png"}),t(i)&&v.ui.add("menubutton",CKEDITOR.UI_MENUBUTTON,{label:"Widgets",toolbar:"insert",icon:appConfig.applicationRoot+"common/Content/images/gear.png",onMenu:function(){return p}}),l(v),c(v),_.extend(v,{getHostElement:r,getContainer:u,isUidResolved:f,hasTemporaryUid:e,bindEditorUid:s,isHidden:o}),v}})}(jQuery)