S&&(f.style.height=(C=S)+"px"),f.style.top=(v=u.top-C)+p+"px",y=!1):f.style.height=x-m.top-2+"px"}p=m.right-d;b&&(p+=l.display.nativeBarWidth);0d&&(f.style.width=d-5+"px",p-=m.right-m.left-d),f.style.left=(g=Math.max(u.left-p-h,0))+"px");if(b)for(u=f.firstChild;u;u=u.nextSibling)u.style.paddingRight=l.display.nativeBarWidth+"px";l.addKeyMap(this.keyMap=i(t,{moveFocus:function(e,t){o.changeActive(o.selectedHint+e,t)},setFocus:function(e){o.changeActive(e)},menuSize:function(){return o.screenAmount()},length:c.length,close:function(){t.close()},pick:function(){o.pick()},data:r}));if(t.options.closeOnUnfocus){var k;l.on("blur",this.onBlur=function(){k=setTimeout(function(){t.close()},100)});l.on("focus",this.onFocus=function(){clearTimeout(k)})}l.on("scroll",this.onScroll=function(){var e=l.getScrollInfo(),i=l.getWrapperElement().getBoundingClientRect();w||(w=l.getScrollInfo());var n=v+w.top-e.top,r=n-(s.pageYOffset||(a.documentElement||a.body).scrollTop);y||(r+=f.offsetHeight);if(r<=i.top||r>=i.bottom)return t.close();f.style.top=n+"px";f.style.left=g+w.left-e.left+"px"});e.on(f,"dblclick",function(e){(e=n(f,e.target||e.srcElement))&&null!=e.hintId&&(o.changeActive(e.hintId),o.pick())});e.on(f,"click",function(e){(e=n(f,e.target||e.srcElement))&&null!=e.hintId&&(o.changeActive(e.hintId),t.options.completeOnSingleClick&&o.pick())});e.on(f,"mousedown",function(){setTimeout(function(){l.focus()},20)});u=this.getSelectedHintRange();0===u.from&&0===u.to||this.scrollToActive();e.signal(r,"select",c[this.selectedHint],f.childNodes[this.selectedHint]);return!0}function o(e,t){if(!e.somethingSelected())return t;for(var i=[],n=0;n=this.data.list.length?t=i?this.data.list.length-1:0:0>t&&(t=i?0:this.data.list.length-1);if(this.selectedHint!=t){var n=this.hints.childNodes[this.selectedHint];n&&(n.className=n.className.replace(" CodeMirror-hint-active",""),n.removeAttribute("aria-selected"));n=this.hints.childNodes[this.selectedHint=t];n.className+=" CodeMirror-hint-active";n.setAttribute("aria-selected","true");this.completion.cm.getInputField().setAttribute("aria-activedescendant",n.id);this.scrollToActive();e.signal(this.data,"select",this.data.list[this.selectedHint],n)}},scrollToActive:function(){var e=this.getSelectedHintRange(),t=this.hints.childNodes[e.from];e=this.hints.childNodes[e.to];var i=this.hints.firstChild;t.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=e.offsetTop+e.offsetHeight-this.hints.clientHeight+i.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var e=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-e),to:Math.min(this.data.list.length-1,this.selectedHint+e)}}};e.registerHelper("hint","auto",{resolve:function(t,i){var n=t.getHelpers(i,"hint"),r;if(n.length){var a=function(e,t,i){function r(n){if(n==a.length)return t(null);l(a[n],e,i,function(e){e&&0,]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};e.defineOption("hintOptions",null)});(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){var t=/[\w$]+/;e.registerHelper("hint","anyword",function(i,n){for(var r=n&&n.word||t,o=n&&n.range||500,l=i.getCursor(),a=i.getLine(l.line),s=l.ch,f=s;f&&r.test(a.charAt(f-1));)--f;a=f!=s&&a.slice(f,s);var c=n&&n.list||[],u={};r=new RegExp(r.source,"g");for(var h=-1;1>=h;h+=2)for(var d=l.line,p=Math.min(Math.max(d+h*o,i.firstLine()),i.lastLine())+h;d!=p;d+=h)for(var m=i.getLine(d),g;g=r.exec(m);)d==l.line&&g[0]===a||a&&0!=g[0].lastIndexOf(a,0)||Object.prototype.hasOwnProperty.call(u,g[0])||(u[g[0]]=!0,c.push(g[0]));return{list:c,from:e.Pos(l.line,f),to:e.Pos(l.line,s)}})});(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){function t(e){for(var t=0;t=t||(s.line>=t&&(s=l(t,0)),t=a.line,null==n?this.uncomment(a,s,e)?n="un":(this.lineComment(a,s,e),n="line"):"un"==n?this.uncomment(a,s,e):this.lineComment(a,s,e))}});e.defineExtension("lineComment",function(e,a,s){s||(s=r);var f=this,c=n(f,e),u=f.getLine(e.line);if(null!=u&&!i(f,e,u)){var h=s.lineComment||c.lineComment;if(h){var d=Math.min(0!=a.ch||a.line==e.line?a.line+1:a.line,f.lastLine()+1),p=null==s.padding?" ":s.padding,m=s.commentBlankLines||e.line==a.line;f.operation(function(){if(s.indent){for(var i=null,n=e.line;nr.length)i=r}for(n=e.line;nh||s.operation(function(){if(0!=i.fullLines){var n=o.test(s.getLine(h));s.replaceRange(d+u,l(h));s.replaceRange(c+d,l(e.line,0));var r=i.blockCommentLead||f.blockCommentLead;if(null!=r)for(var p=e.line+1;p<=h;++p)(p!=h||n)&&s.replaceRange(r+d,l(p,0))}else n=0==a(s.getCursor("to"),t),r=!s.somethingSelected(),s.replaceRange(u,t),n&&s.setSelection(r?t:s.getCursor("from"),t),s.replaceRange(c,e)})}});e.defineExtension("uncomment",function(e,t,i){i||(i=r);var a=this,s=n(a,e),f=Math.min(0!=t.ch||t.line==e.line?t.line:t.line-1,a.lastLine()),c=Math.min(e.line,f),u=i.lineComment||s.lineComment,h=[],d=null==i.padding?" ":i.padding,p;e:if(u){for(var m=c;m<=f;++m){var g=a.getLine(m),v=g.indexOf(u);-1i||(t.slice(n,n+d.length)==d&&(n+=d.length),p=!0,a.replaceRange("",l(e,i),l(e,n)))}});if(p)return!0}var y=i.blockCommentStart||s.blockCommentStart,x=i.blockCommentEnd||s.blockCommentEnd;if(!y||!x)return!1;var b=i.blockCommentLead||s.blockCommentLead,w=a.getLine(c),C=w.indexOf(y);if(-1==C)return!1;var S=f==c?w:a.getLine(f),k=S.indexOf(x,f==c?C+y.length:0);i=l(c,C+1);s=l(f,k+1);if(-1==k||!/comment/.test(a.getTokenTypeAt(i))||!/comment/.test(a.getTokenTypeAt(s))||-1=d.length&&-1<(h=p.lastIndexOf(d,f.ch-d.length))&&h>m)if(i(0,p)>=h)u=p.slice(0,h);else{u=t.options.tabSize;var g;h=e.countColumn(p,h,u);u=t.options.indentWithTabs?o.call("\t",g=Math.floor(h/u))+o.call(" ",h-u*g):o.call(" ",h)}else-1<(h=p.indexOf(l.blockCommentContinue))&&h<=f.ch&&h<=i(0,p)&&(u=p.slice(0,h));null!=u&&(u+=l.blockCommentContinue)}null==u&&c&&n(t)&&((null==p&&(p=t.getLine(f.line)),h=p.indexOf(c),f.ch||h)?-1=h&&(u=-1=u||null),u&&(u=p.slice(0,h)+c+p.slice(h+c.length).match(/^\s*/)[0])):u="");if(null==u)return e.Pass;a[s]="\n"+u}t.operation(function(){for(var e=r.length-1;0<=e;e--)t.replaceRange(a[e],r[e].from(),r[e].to(),"+insert")})}function i(e,t){r.lastIndex=e;var i=r.exec(t);return i?i.index:-1}function n(e){return(e=e.getOption("continueComments"))&&"object"==typeof e?!1!==e.continueLineComment:!0}var r=/\S/g,o=String.prototype.repeat||function(e){return Array(e+1).join(this)};e.defineOption("continueComments",null,function(i,n,r){r&&r!=e.Init&&i.removeKeyMap("continueComment");n&&(r="Enter","string"==typeof n?r=n:"object"==typeof n&&n.key&&(r=n.key),n={name:"continueComment"},n[r]=t,i.addKeyMap(n))})});(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){function t(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function i(e){t(e);var i=e.state.placeholder=document.createElement("pre");i.style.cssText="height: 0; overflow: visible";i.style.direction=e.getOption("direction");i.className="CodeMirror-placeholder CodeMirror-line-like";var n=e.getOption("placeholder");"string"==typeof n&&(n=document.createTextNode(n));i.appendChild(n);e.display.lineSpace.insertBefore(i,e.display.lineSpace.firstChild)}function n(e){setTimeout(function(){var n=!1;1==e.lineCount()&&(n=e.getInputField(),n="TEXTAREA"==n.nodeName?!e.getLine(0).length:!/[^\u200b]/.test(n.querySelector(".CodeMirror-line").textContent));n?i(e):t(e)},20)}function r(e){l(e)&&i(e)}function o(e){var n=e.getWrapperElement(),r=l(e);n.className=n.className.replace(" CodeMirror-empty","")+(r?" CodeMirror-empty":"");r?i(e):t(e)}function l(e){return 1===e.lineCount()&&""===e.getLine(0)}e.defineOption("placeholder","",function(i,l,a){a=a&&a!=e.Init;l&&!a?(i.on("blur",r),i.on("change",o),i.on("swapDoc",o),e.on(i.getInputField(),"compositionupdate",i.state.placeholderCompose=function(){n(i)}),o(i)):!l&&a&&(i.off("blur",r),i.off("change",o),i.off("swapDoc",o),e.off(i.getInputField(),"compositionupdate",i.state.placeholderCompose),t(i),a=i.getWrapperElement(),a.className=a.className.replace(" CodeMirror-empty",""));l&&!i.hasFocus()&&r(i)})});(function(e){if(typeof exports=="object"&&typeof module=="object")e(require("../lib/codemirror"));else if(typeof define=="function"&&define.amd)define(["../lib/codemirror"],e);else e(CodeMirror)})(function(e){"use strict";e.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy","cbl"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded JavaScript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"],alias:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["cgi","pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var t=0;t-1&&t.substring(r+1,t.length);if(o)return e.findModeByExtension(o)};e.findModeByName=function(t){t=t.toLowerCase();for(var i=0;i2);var v=/Android/.test(e);var y=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e);var x=g||/Mac/.test(t);var b=/\bCrOS\b/.test(e);var w=/win/i.test(t);var C=h&&e.match(/Version\/(\d*\.\d*)/);if(C){C=Number(C[1])}if(C&&C>=15){h=false;s=true}var S=x&&(f||h&&(C==null||C<12.11));var k=i||l&&a>=9;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var M=function(e,t){var i=e.className;var n=L(t).exec(i);if(n){var r=i.slice(n.index+n[0].length);e.className=i.slice(0,n.index)+(r?n[1]+r:"")}};function T(e){for(var t=e.childNodes.length;t>0;--t){e.removeChild(e.firstChild)}return e}function O(e,t){return T(e).appendChild(t)}function A(e,t,i,n){var r=document.createElement(e);if(i){r.className=i}if(n){r.style.cssText=n}if(typeof t=="string"){r.appendChild(document.createTextNode(t))}else if(t){for(var o=0;o=t){return l+(t-o)}l+=a-o;l+=i-l%i;o=a+1}}var G=function(){this.id=null;this.f=null;this.time=0;this.handler=z(this.onTimeout,this)};G.prototype.onTimeout=function(e){e.id=0;if(e.time<=+new Date){e.f()}else{setTimeout(e.handler,e.time-+new Date)}};G.prototype.set=function(e,t){this.f=t;var i=+new Date+e;if(!this.id||i=t){return n+Math.min(l,t-r)}r+=o-n;r+=i-r%i;n=o+1;if(r>=t){return n}}}var Q=[""];function Z(e){while(Q.length<=e){Q.push(ee(Q)+" ")}return Q[e]}function ee(e){return e[e.length-1]}function te(e,t){var i=[];for(var n=0;n""&&(e.toUpperCase()!=e.toLowerCase()||oe.test(e))}function ae(e,t){if(!t){return le(e)}if(t.source.indexOf("\\w")>-1&&le(e)){return true}return t.test(e)}function se(e){for(var t in e){if(e.hasOwnProperty(t)&&e[t]){return false}}return true}var fe=/[\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]/;function ce(e){return e.charCodeAt(0)>=768&&fe.test(e)}function ue(e,t,i){while((i<0?t>0:ti?-1:1;for(;;){if(t==i){return t}var r=(t+i)/2,o=n<0?Math.ceil(r):Math.floor(r);if(o==t){return e(o)?t:i}if(e(o)){i=o}else{t=o+n}}}function de(e,t,i,n){if(!e){return n(t,i,"ltr",0)}var r=false;for(var o=0;ot||t==i&&l.to==t){n(Math.max(l.from,t),Math.min(l.to,i),l.level==1?"rtl":"ltr",o);r=true}}if(!r){n(t,i,"ltr")}}var pe=null;function me(e,t,i){var n;pe=null;for(var r=0;rt){return r}if(o.to==t){if(o.from!=o.to&&i=="before"){n=r}else{pe=r}}if(o.from==t){if(o.from!=o.to&&i!="before"){n=r}else{pe=r}}}return n!=null?n:pe}var ge=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(i){if(i<=247){return e.charAt(i)}else if(1424<=i&&i<=1524){return"R"}else if(1536<=i&&i<=1785){return t.charAt(i-1536)}else if(1774<=i&&i<=2220){return"r"}else if(8192<=i&&i<=8203){return"w"}else if(i==8204){return"b"}else{return"L"}}var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var r=/[stwN]/,o=/[LRr]/,l=/[Lb1n]/,a=/[1n]/;function s(e,t,i){this.level=e;this.from=t;this.to=i}return function(e,t){var f=t=="ltr"?"L":"R";if(e.length==0||t=="ltr"&&!n.test(e)){return false}var c=e.length,u=[];for(var h=0;h-1){n[t]=r.slice(0,o).concat(r.slice(o+1))}}}}function Ce(e,t){var i=be(e,t);if(!i.length){return}var n=Array.prototype.slice.call(arguments,2);for(var r=0;r0}function Me(e){e.prototype.on=function(e,t){xe(this,e,t)};e.prototype.off=function(e,t){we(this,e,t)}}function Te(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}}function Oe(e){if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}}function Ae(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==false}function Ne(e){Te(e);Oe(e)}function Pe(e){return e.target||e.srcElement}function Fe(e){var t=e.which;if(t==null){if(e.button&1){t=1}else if(e.button&2){t=3}else if(e.button&4){t=2}}if(x&&e.ctrlKey&&t==1){t=3}return t}var De=function(){if(l&&a<9){return false}var e=A("div");return"draggable"in e||"dragDrop"in e}();var He;function Ee(e){if(He==null){var t=A("span","");O(e,A("span",[t,document.createTextNode("x")]));if(e.firstChild.offsetHeight!=0){He=t.offsetWidth<=1&&t.offsetHeight>2&&!(l&&a<8)}}var i=He?A("span",""):A("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");i.setAttribute("cm-text","");return i}var We;function Ie(e){if(We!=null){return We}var t=O(e,document.createTextNode("AخA"));var i=P(t,0,1).getBoundingClientRect();var n=P(t,1,2).getBoundingClientRect();T(e);if(!i||i.left==i.right){return false}return We=n.right-i.right<3}var Re="\n\nb".split(/\n/).length!=3?function(e){var t=0,i=[],n=e.length;while(t<=n){var r=e.indexOf("\n",t);if(r==-1){r=e.length}var o=e.slice(t,e.charAt(r-1)=="\r"?r-1:r);var l=o.indexOf("\r");if(l!=-1){i.push(o.slice(0,l));t+=l+1}else{i.push(o);t=r+1}}return i}:function(e){return e.split(/\r\n?|\n/)};var Be=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return false}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}if(!t||t.parentElement()!=e){return false}return t.compareEndPoints("StartToEnd",t)!=0};var je=function(){var e=A("div");if("oncopy"in e){return true}e.setAttribute("oncopy","return;");return typeof e.oncopy=="function"}();var ze=null;function qe(e){if(ze!=null){return ze}var t=O(e,A("span","x"));var i=t.getBoundingClientRect();var n=P(t,0,1).getBoundingClientRect();return ze=Math.abs(i.left-n.left)>1}var Ue={},Ge={};function Ve(e,t){if(arguments.length>2){t.dependencies=Array.prototype.slice.call(arguments,2)}Ue[e]=t}function Ke(e,t){Ge[e]=t}function $e(e){if(typeof e=="string"&&Ge.hasOwnProperty(e)){e=Ge[e]}else if(e&&typeof e.name=="string"&&Ge.hasOwnProperty(e.name)){var t=Ge[e.name];if(typeof t=="string"){t={name:t}}e=re(t,e);e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e)){return $e("application/xml")}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e)){return $e("application/json")}if(typeof e=="string"){return{name:e}}else{return e||{name:"null"}}}function Xe(e,t){t=$e(t);var i=Ue[t.name];if(!i){return Xe(e,"text/plain")}var n=i(e,t);if(_e.hasOwnProperty(t.name)){var r=_e[t.name];for(var o in r){if(!r.hasOwnProperty(o)){continue}if(n.hasOwnProperty(o)){n["_"+o]=n[o]}n[o]=r[o]}}n.name=t.name;if(t.helperType){n.helperType=t.helperType}if(t.modeProps){for(var l in t.modeProps){n[l]=t.modeProps[l]}}return n}var _e={};function Ye(e,t){var i=_e.hasOwnProperty(e)?_e[e]:_e[e]={};q(t,i)}function Je(e,t){if(t===true){return t}if(e.copyState){return e.copyState(t)}var i={};for(var n in t){var r=t[n];if(r instanceof Array){r=r.concat([])}i[n]=r}return i}function Qe(e,t){var i;while(e.innerMode){i=e.innerMode(t);if(!i||i.mode==e){break}t=i.state;e=i.mode}return i||{mode:e,state:t}}function Ze(e,t,i){return e.startState?e.startState(t,i):true}var et=function(e,t,i){this.pos=this.start=0;this.string=e;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;this.lineOracle=i};et.prototype.eol=function(){return this.pos>=this.string.length};et.prototype.sol=function(){return this.pos==this.lineStart};et.prototype.peek=function(){return this.string.charAt(this.pos)||undefined};et.prototype.next=function(){if(this.post};et.prototype.eatSpace=function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>e};et.prototype.skipToEnd=function(){this.pos=this.string.length};et.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1){this.pos=t;return true}};et.prototype.backUp=function(e){this.pos-=e};et.prototype.column=function(){if(this.lastColumnPos0){return null}if(o&&t!==false){this.pos+=o[0].length}return o}};et.prototype.current=function(){return this.string.slice(this.start,this.pos)};et.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}};et.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)};et.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function tt(e,t){t-=e.first;if(t<0||t>=e.size){throw new Error("There is no line "+(t+e.first)+" in the document.")}var i=e;while(!i.lines){for(var n=0;;++n){var r=i.children[n],o=r.chunkSize();if(t=e.first&&ti){return ft(i,tt(e,i).text.length)}return vt(t,tt(e,t.line).text.length)}function vt(e,t){var i=e.ch;if(i==null||i>t){return ft(e.line,t)}else if(i<0){return ft(e.line,0)}else{return e}}function yt(e,t){var i=[];for(var n=0;nthis.maxLookAhead){this.maxLookAhead=e}return t};bt.prototype.baseToken=function(e){if(!this.baseTokens){return null}while(this.baseTokens[this.baseTokenPos]<=e){this.baseTokenPos+=2}var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}};bt.prototype.nextLine=function(){this.line++;if(this.maxLookAhead>0){this.maxLookAhead--}};bt.fromSaved=function(e,t,i){if(t instanceof xt){return new bt(e,Je(e.mode,t.state),i,t.lookAhead)}else{return new bt(e,Je(e.mode,t),i)}};bt.prototype.save=function(e){var t=e!==false?Je(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new xt(t,this.maxLookAhead):t};function wt(e,t,i,n){var r=[e.state.modeGen],o={};Nt(e,t.text,e.doc.mode,i,function(e,t){return r.push(e,t)},o,n);var l=i.state;var a=function(n){i.baseTokens=r;var a=e.state.overlays[n],s=1,f=0;i.state=true;Nt(e,t.text,a.mode,i,function(e,t){var i=s;while(fe){r.splice(s,1,e,r[s+1],n)}s+=2;f=Math.min(e,n)}if(!t){return}if(a.opaque){r.splice(i,s-i,e,"overlay "+t);s=i+2}else{for(;ie.options.maxHighlightLength&&Je(e.doc.mode,n.state);var o=wt(e,t,n);if(r){n.state=r}t.stateAfter=n.save(!r);t.styles=o.styles;if(o.classes){t.styleClasses=o.classes}else if(t.styleClasses){t.styleClasses=null}if(i===e.doc.highlightFrontier){e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier)}}return t.styles}function St(e,t,i){var n=e.doc,r=e.display;if(!n.mode.startState){return new bt(n,true,t)}var o=Pt(e,t,i);var l=o>n.first&&tt(n,o-1).stateAfter;var a=l?bt.fromSaved(n,l,o):new bt(n,Ze(n.mode),o);n.iter(o,t,function(i){kt(e,i.text,a);var n=a.line;i.stateAfter=n==t-1||n%5==0||n>=r.viewFrom&&nt.start){return o}}throw new Error("Mode "+e.name+" failed to advance stream.")}var Tt=function(e,t,i){this.start=e.start;this.end=e.pos;this.string=e.current();this.type=t||null;this.state=i};function Ot(e,t,i,n){var r=e.doc,o=r.mode,l;t=gt(r,t);var a=tt(r,t.line),s=St(e,t.line,i);var f=new et(a.text,e.options.tabSize,s),c;if(n){c=[]}while((n||f.pose.options.maxHighlightLength){a=false;if(l){kt(e,t,n,c.pos)}c.pos=t.length;u=null}else{u=At(Mt(i,c,n.state,h),o)}if(h){var d=h[0].name;if(d){u="m-"+(u?d+" "+u:d)}}if(!a||f!=u){while(sl;--a){if(a<=o.first){return o.first}var s=tt(o,a-1),f=s.stateAfter;if(f&&(!i||a+(f instanceof xt?f.lookAhead:0)<=o.modeFrontier)){return a}var c=U(s.text,null,e.options.tabSize);if(r==null||n>c){r=a-1;n=c}}return r}function Ft(e,t){e.modeFrontier=Math.min(e.modeFrontier,t);if(e.highlightFrontieri;n--){var r=tt(e,n).stateAfter;if(r&&(!(r instanceof xt)||n+r.lookAhead=t:o.to>t);(n||(n=[])).push(new It(l,o.from,s?null:o.to))}}}return n}function qt(e,t,i){var n;if(e){for(var r=0;r=t:o.to>t);if(a||o.from==t&&l.type=="bookmark"&&(!i||o.marker.insertLeft)){var s=o.from==null||(l.inclusiveLeft?o.from<=t:o.from0&&a){for(var b=0;b0){continue}var c=[s,1],u=ct(f.from,a.from),h=ct(f.to,a.to);if(u<0||!l.inclusiveLeft&&!u){c.push({from:f.from,to:a.from})}if(h>0||!l.inclusiveRight&&!h){c.push({from:a.to,to:f.to})}r.splice.apply(r,c);s+=c.length-3}}return r}function Kt(e){var t=e.markedSpans;if(!t){return}for(var i=0;it)&&(!n||Yt(n,o.marker)<0)){n=o.marker}}}return n}function ti(e,t,i,n,r){var o=tt(e,t);var l=Ht&&o.markedSpans;if(l){for(var a=0;a=0&&u<=0||c<=0&&u>=0){continue}if(c<=0&&(s.marker.inclusiveRight&&r.inclusiveLeft?ct(f.to,i)>=0:ct(f.to,i)>0)||c>=0&&(s.marker.inclusiveRight&&r.inclusiveLeft?ct(f.from,n)<=0:ct(f.from,n)<0)){return true}}}}function ii(e){var t;while(t=Qt(e)){e=t.find(-1,true).line}return e}function ni(e){var t;while(t=Zt(e)){e=t.find(1,true).line}return e}function ri(e){var t,i;while(t=Zt(e)){e=t.find(1,true).line;(i||(i=[])).push(e)}return i}function oi(e,t){var i=tt(e,t),n=ii(i);if(i==n){return t}return ot(n)}function li(e,t){if(t>e.lastLine()){return t}var i=tt(e,t),n;if(!ai(e,i)){return t}while(n=Zt(i)){i=n.find(1,true).line}return ot(i)+1}function ai(e,t){var i=Ht&&t.markedSpans;if(i){for(var n=void 0,r=0;rt.maxLineLength){t.maxLineLength=i;t.maxLine=e}})}var hi=function(e,t,i){this.text=e;$t(this,t);this.height=i?i(this):1};hi.prototype.lineNo=function(){return ot(this)};Me(hi);function di(e,t,i,n){e.text=t;if(e.stateAfter){e.stateAfter=null}if(e.styles){e.styles=null}if(e.order!=null){e.order=null}Kt(e);$t(e,i);var r=n?n(e):1;if(r!=e.height){rt(e,r)}}function pi(e){e.parent=null;Kt(e)}var mi={},gi={};function vi(e,t){if(!e||/^\s*$/.test(e)){return null}var i=t.addModeClass?gi:mi;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function yi(e,t){var i=N("span",null,null,s?"padding-right: .1px":null);var n={pre:N("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:false,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var r=0;r<=(t.rest?t.rest.length:0);r++){var o=r?t.rest[r-1]:t.line,l=void 0;n.pos=0;n.addToken=bi;if(Ie(e.display.measure)&&(l=ve(o,e.doc.direction))){n.addToken=Ci(n.addToken,l)}n.map=[];var a=t!=e.display.externalMeasured&&ot(o);ki(o,n,Ct(e,o,a));if(o.styleClasses){if(o.styleClasses.bgClass){n.bgClass=E(o.styleClasses.bgClass,n.bgClass||"")}if(o.styleClasses.textClass){n.textClass=E(o.styleClasses.textClass,n.textClass||"")}}if(n.map.length==0){n.map.push(0,0,n.content.appendChild(Ee(e.display.measure)))}if(r==0){t.measure.map=n.map;t.measure.cache={}}else{(t.measure.maps||(t.measure.maps=[])).push(n.map);(t.measure.caches||(t.measure.caches=[])).push({})}}if(s){var f=n.content.lastChild;if(/\bcm-tab\b/.test(f.className)||f.querySelector&&f.querySelector(".cm-tab")){n.content.className="cm-tab-wrap-hack"}}Ce(e,"renderLine",e,t.line,n.pre);if(n.pre.className){n.textClass=E(n.pre.className,n.textClass||"")}return n}function xi(e){var t=A("span","•","cm-invalidchar");t.title="\\u"+e.charCodeAt(0).toString(16);t.setAttribute("aria-label",t.title);return t}function bi(e,t,i,n,r,o,s){if(!t){return}var f=e.splitSpaces?wi(t,e.trailingSpace):t;var c=e.cm.state.specialChars,u=false;var h;if(!c.test(t)){e.col+=t.length;h=document.createTextNode(f);e.map.push(e.pos,e.pos+t.length,h);if(l&&a<9){u=true}e.pos+=t.length}else{h=document.createDocumentFragment();var d=0;while(true){c.lastIndex=d;var p=c.exec(t);var m=p?p.index-d:t.length-d;if(m){var g=document.createTextNode(f.slice(d,d+m));if(l&&a<9){h.appendChild(A("span",[g]))}else{h.appendChild(g)}e.map.push(e.pos,e.pos+m,g);e.col+=m;e.pos+=m}if(!p){break}d+=m+1;var v=void 0;if(p[0]=="\t"){var y=e.cm.options.tabSize,x=y-e.col%y;v=h.appendChild(A("span",Z(x),"cm-tab"));v.setAttribute("role","presentation");v.setAttribute("cm-text","\t");e.col+=x}else if(p[0]=="\r"||p[0]=="\n"){v=h.appendChild(A("span",p[0]=="\r"?"␍":"","cm-invalidchar"));v.setAttribute("cm-text",p[0]);e.col+=1}else{v=e.cm.options.specialCharPlaceholder(p[0]);v.setAttribute("cm-text",p[0]);if(l&&a<9){h.appendChild(A("span",[v]))}else{h.appendChild(v)}e.col+=1}e.map.push(e.pos,e.pos+1,v);e.pos++}}e.trailingSpace=f.charCodeAt(t.length-1)==32;if(i||n||r||u||o||s){var b=i||"";if(n){b+=n}if(r){b+=r}var w=A("span",[h],b,o);if(s){for(var C in s){if(s.hasOwnProperty(C)&&C!="style"&&C!="class"){w.setAttribute(C,s[C])}}}return e.content.appendChild(w)}e.content.appendChild(h)}function wi(e,t){if(e.length>1&&!/ /.test(e)){return e}var i=t,n="";for(var r=0;rf&&u.from<=f){break}}if(u.to>=c){return e(i,n,r,o,l,a,s)}e(i,n.slice(0,u.to-f),r,o,null,a,s);o=null;n=n.slice(u.to-f);f=u.to}}}function Si(e,t,i,n){var r=!n&&i.widgetNode;if(r){e.map.push(e.pos,e.pos+t,r)}if(!n&&e.cm.display.input.needsContentAttribute){if(!r){r=e.content.appendChild(document.createElement("span"))}r.setAttribute("cm-marker",i.id)}if(r){e.cm.display.input.setUneditable(r);e.content.appendChild(r)}e.pos+=t;e.trailingSpace=false}function ki(e,t,i){var n=e.markedSpans,r=e.text,o=0;if(!n){for(var l=1;ls||S.collapsed&&C.to==s&&C.from==s)){if(C.to!=null&&C.to!=s&&d>C.to){d=C.to;m=""}if(S.className){p+=" "+S.className}if(S.css){h=(h?h+";":"")+S.css}if(S.startStyle&&C.from==s){g+=" "+S.startStyle}if(S.endStyle&&C.to==d){(b||(b=[])).push(S.endStyle,C.to)}if(S.title){(y||(y={})).title=S.title}if(S.attributes){for(var k in S.attributes){(y||(y={}))[k]=S.attributes[k]}}if(S.collapsed&&(!v||Yt(v.marker,S)<0)){v=C}}else if(C.from>s&&d>C.from){d=C.from}}if(b){for(var L=0;L=a){break}var T=Math.min(a,d);while(true){if(c){var O=s+c.length;if(!v){var A=O>T?c.slice(0,T-s):c;t.addToken(t,A,u?u+p:p,g,s+A.length==d?m:"",h,y)}if(O>=T){c=c.slice(T-s);s=T;break}s=O;g=""}c=r.slice(o,o=i[f++]);u=vi(i[f++],t.cm.options)}}}function Li(e,t,i){this.line=t;this.rest=ri(t);this.size=this.rest?ot(ee(this.rest))-i+1:1;this.node=this.text=null;this.hidden=ai(e,t)}function Mi(e,t,i){var n=[],r;for(var o=t;o2){o.push((s.bottom+f.top)/2-i.top)}}}o.push(i.bottom-i.top)}}function tn(e,t,i){if(e.line==t){return{map:e.measure.map,cache:e.measure.cache}}if(e.rest){for(var n=0;ni){return{map:e.measure.maps[r],cache:e.measure.caches[r],before:true}}}}}function nn(e,t){t=ii(t);var i=ot(t);var n=e.display.externalMeasured=new Li(e.doc,t,i);n.lineN=i;var r=n.built=yi(e,n);n.text=r.pre;O(e.display.lineMeasure,r.pre);return n}function rn(e,t,i,n){return an(e,ln(e,t),i,n)}function on(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt){o=s-a;r=o-1;if(t>=s){l="right"}}if(r!=null){n=e[f+2];if(a==s&&i==(n.insertLeft?"left":"right")){l=i}if(i=="left"&&r==0){while(f&&e[f-2]==e[f-3]&&e[f-1].insertLeft){n=e[(f-=3)+2];l="left"}}if(i=="right"&&r==s-a){while(f=0;r--){if((i=e[r]).left!=i.right){break}}}return i}function un(e,t,i,n){var r=fn(t.map,i,n);var o=r.node,s=r.start,f=r.end,c=r.collapse;var u;if(o.nodeType==3){for(var h=0;h<4;h++){while(s&&ce(t.line.text.charAt(r.coverStart+s))){--s}while(r.coverStart+f0){c=n="right"}var d;if(e.options.lineWrapping&&(d=o.getClientRects()).length>1){u=d[n=="right"?d.length-1:0]}else{u=o.getBoundingClientRect()}}if(l&&a<9&&!s&&(!u||!u.left&&!u.right)){var p=o.parentNode.getClientRects()[0];if(p){u={left:p.left,right:p.left+Hn(e.display),top:p.top,bottom:p.bottom}}else{u=sn}}var m=u.top-t.rect.top,g=u.bottom-t.rect.top;var v=(m+g)/2;var y=t.view.measure.heights;var x=0;for(;x=n.text.length){s=n.text.length;f="before"}else if(s<=0){s=0;f="after"}if(!a){return l(f=="before"?s-1:s,f=="before")}function c(e,t,i){var n=a[t],r=n.level==1;return l(i?e-1:e,r!=i)}var u=me(a,s,f);var h=pe;var d=c(s,u,f=="before");if(h!=null){d.other=c(s,h,f!="before")}return d}function Sn(e,t){var i=0;t=gt(e.doc,t);if(!e.options.lineWrapping){i=Hn(e.display)*t.ch}var n=tt(e.doc,t.line);var r=fi(n)+Xi(e.display);return{left:i,right:i,top:r,bottom:r+n.height}}function kn(e,t,i,n,r){var o=ft(e,t,i);o.xRel=r;if(n){o.outside=n}return o}function Ln(e,t,i){var n=e.doc;i+=e.display.viewOffset;if(i<0){return kn(n.first,0,null,-1,-1)}var r=lt(n,i),o=n.first+n.size-1;if(r>o){return kn(n.first+n.size-1,tt(n,o).text.length,null,1,1)}if(t<0){t=0}var l=tt(n,r);for(;;){var a=An(e,l,r,t,i);var s=ei(l,a.ch+(a.xRel>0||a.outside>0?1:0));if(!s){return a}var f=s.find(1);if(f.line==r){return f}l=tt(n,r=f.line)}}function Mn(e,t,i,n){n-=yn(t);var r=t.text.length;var o=he(function(t){return an(e,i,t-1).bottom<=n},r,0);r=he(function(t){return an(e,i,t).top>n},o,r);return{begin:o,end:r}}function Tn(e,t,i,n){if(!i){i=ln(e,t)}var r=xn(e,t,an(e,i,n),"line").top;return Mn(e,t,i,r)}function On(e,t,i,n){return e.bottom<=i?false:e.top>i?true:(n?e.left:e.right)>t}function An(e,t,i,n,r){r-=fi(t);var o=ln(e,t);var l=yn(t);var a=0,s=t.text.length,f=true;var c=ve(t,e.doc.direction);if(c){var u=(e.options.lineWrapping?Pn:Nn)(e,t,i,o,c,n,r);f=u.level!=1;a=f?u.from:u.to-1;s=f?u.to:u.from-1}var h=null,d=null;var p=he(function(t){var i=an(e,o,t);i.top+=l;i.bottom+=l;if(!On(i,n,r,false)){return false}if(i.top<=r&&i.left<=n){h=t;d=i}return true},a,s);var m,g,v=false;if(d){var y=n-d.left=b.bottom?1:0}p=ue(t.text,p,1);return kn(i,p,g,v,n-m)}function Nn(e,t,i,n,r,o,l){var a=he(function(a){var s=r[a],f=s.level!=1;return On(Cn(e,ft(i,f?s.to:s.from,f?"before":"after"),"line",t,n),o,l,true)},0,r.length-1);var s=r[a];if(a>0){var f=s.level!=1;var c=Cn(e,ft(i,f?s.from:s.to,f?"after":"before"),"line",t,n);if(On(c,o,l,true)&&c.top>l){s=r[a-1]}}return s}function Pn(e,t,i,n,r,o,l){var a=Mn(e,t,n,l);var s=a.begin;var f=a.end;if(/\s/.test(t.text.charAt(f-1))){f--}var c=null,u=null;for(var h=0;h=f||d.to<=s){continue}var p=d.level!=1;var m=an(e,n,p?Math.min(f,d.to)-1:Math.max(s,d.from)).right;var g=mg){c=d;u=g}}if(!c){c=r[r.length-1]}if(c.fromf){c={from:c.from,to:f,level:c.level}}return c}var Fn;function Dn(e){if(e.cachedTextHeight!=null){return e.cachedTextHeight}if(Fn==null){Fn=A("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t){Fn.appendChild(document.createTextNode("x"));Fn.appendChild(A("br"))}Fn.appendChild(document.createTextNode("x"))}O(e.measure,Fn);var i=Fn.offsetHeight/50;if(i>3){e.cachedTextHeight=i}T(e.measure);return i||1}function Hn(e){if(e.cachedCharWidth!=null){return e.cachedCharWidth}var t=A("span","xxxxxxxxxx");var i=A("pre",[t],"CodeMirror-line-like");O(e.measure,i);var n=t.getBoundingClientRect(),r=(n.right-n.left)/10;if(r>2){e.cachedCharWidth=r}return r||10}function En(e){var t=e.display,i={},n={};var r=t.gutters.clientLeft;for(var o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l){var a=e.display.gutterSpecs[l].className;i[a]=o.offsetLeft+o.clientLeft+r;n[a]=o.clientWidth}return{fixedPos:Wn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function Wn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function In(e){var t=Dn(e.display),i=e.options.lineWrapping;var n=i&&Math.max(5,e.display.scroller.clientWidth/Hn(e.display)-3);return function(r){if(ai(e.doc,r)){return 0}var o=0;if(r.widgets){for(var l=0;l0&&(f=tt(e.doc,s.line).text).length==s.ch){var c=U(f,f.length,e.options.tabSize)-f.length;s=ft(s.line,Math.max(0,Math.round((o-Yi(e.display).left)/Hn(e.display))-c))}return s}function jn(e,t){if(t>=e.display.viewTo){return null}t-=e.display.viewFrom;if(t<0){return null}var i=e.display.view;for(var n=0;nt)){r.updateLineNumbers=t}e.curOp.viewChanged=true;if(t>=r.viewTo){if(Ht&&oi(e.doc,t)r.viewFrom){Un(e)}else{r.viewFrom+=n;r.viewTo+=n}}else if(t<=r.viewFrom&&i>=r.viewTo){Un(e)}else if(t<=r.viewFrom){var o=Gn(e,i,i+n,1);if(o){r.view=r.view.slice(o.index);r.viewFrom=o.lineN;r.viewTo+=n}else{Un(e)}}else if(i>=r.viewTo){var l=Gn(e,t,t,-1);if(l){r.view=r.view.slice(0,l.index);r.viewTo=l.lineN}else{Un(e)}}else{var a=Gn(e,t,t,-1);var s=Gn(e,i,i+n,1);if(a&&s){r.view=r.view.slice(0,a.index).concat(Mi(e,a.lineN,s.lineN)).concat(r.view.slice(s.index));r.viewTo+=n}else{Un(e)}}var f=r.externalMeasured;if(f){if(i=r.lineN&&t=n.viewTo){return}var o=n.view[jn(e,t)];if(o.node==null){return}var l=o.changes||(o.changes=[]);if(V(l,i)==-1){l.push(i)}}function Un(e){e.display.viewFrom=e.display.viewTo=e.doc.first;e.display.view=[];e.display.viewOffset=0}function Gn(e,t,i,n){var r=jn(e,t),o,l=e.display.view;if(!Ht||i==e.doc.first+e.doc.size){return{index:r,lineN:i}}var a=e.display.viewFrom;for(var s=0;s0){if(r==l.length-1){return null}o=a+l[r].size-t;r++}else{o=a-t}t+=o;i+=o}while(oi(e.doc,i)!=i){if(r==(n<0?0:l.length-1)){return null}i+=n*l[r-(n<0?1:0)].size;r+=n}return{index:r,lineN:i}}function Vn(e,t,i){var n=e.display,r=n.view;if(r.length==0||t>=n.viewTo||i<=n.viewFrom){n.view=Mi(e,t,i);n.viewFrom=t}else{if(n.viewFrom>t){n.view=Mi(e,t,n.viewFrom).concat(n.view)}else if(n.viewFromi){n.view=n.view.slice(0,jn(e,i))}}n.viewTo=i}function Kn(e){var t=e.display.view,i=0;for(var n=0;n=e.display.viewTo||s.to().line0?l:e.defaultCharWidth())+"px"}if(n.other){var a=i.appendChild(A("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="";a.style.left=n.other.left+"px";a.style.top=n.other.top+"px";a.style.height=(n.other.bottom-n.other.top)*.85+"px"}}function Yn(e,t){return e.top-t.top||e.left-t.left}function Jn(e,t,i){var n=e.display,r=e.doc;var o=document.createDocumentFragment();var l=Yi(e.display),a=l.left;var s=Math.max(n.sizerWidth,Qi(e)-n.sizer.offsetLeft)-l.right;var f=r.direction=="ltr";function c(e,t,i,n){if(t<0){t=0}t=Math.round(t);n=Math.round(n);o.appendChild(A("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(i==null?s-e:i)+"px;\n height: "+(n-t)+"px"))}function u(t,i,n){var o=tt(r,t);var l=o.text.length;var u,h;function d(i,n){return wn(e,ft(t,i),"div",o,n)}function p(t,i,n){var r=Tn(e,o,null,t);var l=i=="ltr"==(n=="after")?"left":"right";var a=n=="after"?r.begin:r.end-(/\s/.test(o.text.charAt(r.end-1))?2:1);return d(a,l)[l]}var m=ve(o,r.direction);de(m,i||0,n==null?l:n,function(e,t,r,o){var g=r=="ltr";var v=d(e,g?"left":"right");var y=d(t-1,g?"right":"left");var x=i==null&&e==0,b=n==null&&t==l;var w=o==0,C=!m||o==m.length-1;if(y.top-v.top<=3){var S=(f?x:b)&&w;var k=(f?b:x)&&C;var L=S?a:(g?v:y).left;var M=k?s:(g?y:v).right;c(L,v.top,M-L,v.bottom)}else{var T,O,A,N;if(g){T=f&&x&&w?a:v.left;O=f?s:p(e,r,"before");A=f?a:p(t,r,"after");N=f&&b&&C?s:y.right}else{T=!f?a:p(e,r,"before");O=!f&&x&&w?s:v.right;A=!f&&b&&C?a:y.left;N=!f?s:p(t,r,"after")}c(T,v.top,O-T,v.bottom);if(v.bottom0){t.blinker=setInterval(function(){if(!e.hasFocus()){ir(e)}t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate)}else if(e.options.cursorBlinkRate<0){t.cursorDiv.style.visibility="hidden"}}function Zn(e){if(!e.hasFocus()){e.display.input.focus();if(!e.state.focused){tr(e)}}}function er(e){e.state.delayingBlurEvent=true;setTimeout(function(){if(e.state.delayingBlurEvent){e.state.delayingBlurEvent=false;if(e.state.focused){ir(e)}}},100)}function tr(e,t){if(e.state.delayingBlurEvent&&!e.state.draggingText){e.state.delayingBlurEvent=false}if(e.options.readOnly=="nocursor"){return}if(!e.state.focused){Ce(e,"focus",e,t);e.state.focused=true;H(e.display.wrapper,"CodeMirror-focused");if(!e.curOp&&e.display.selForContextMenu!=e.doc.sel){e.display.input.reset();if(s){setTimeout(function(){return e.display.input.reset(true)},20)}}e.display.input.receivedFocus()}Qn(e)}function ir(e,t){if(e.state.delayingBlurEvent){return}if(e.state.focused){Ce(e,"blur",e,t);e.state.focused=false;M(e.display.wrapper,"CodeMirror-focused")}clearInterval(e.display.blinker);setTimeout(function(){if(!e.state.focused){e.display.shift=false}},150)}function nr(e){var t=e.display;var i=t.lineDiv.offsetTop;var n=Math.max(0,t.scroller.getBoundingClientRect().top);var r=t.lineDiv.getBoundingClientRect().top;var o=0;for(var s=0;s.005||m<-.005){if(re.display.sizerWidth){var v=Math.ceil(h/Hn(e.display));if(v>e.display.maxLineLength){e.display.maxLineLength=v;e.display.maxLine=f.line;e.display.maxLineChanged=true}}}if(Math.abs(o)>2){t.scroller.scrollTop+=o}}function rr(e){if(e.widgets){for(var t=0;t=l){o=lt(t,fi(tt(t,s))-e.wrapper.clientHeight);l=s}}return{from:o,to:Math.max(l,o+1)}}function lr(e,t){if(Se(e,"scrollCursorIntoView")){return}var i=e.display,n=i.sizer.getBoundingClientRect(),r=null;var o=i.wrapper.ownerDocument;if(t.top+n.top<0){r=true}else if(t.bottom+n.top>(o.defaultView.innerHeight||o.documentElement.clientHeight)){r=false}if(r!=null&&!m){var l=A("div","",null,"position: absolute;\n top: "+(t.top-i.viewOffset-Xi(e.display))+"px;\n height: "+(t.bottom-t.top+Ji(e)+i.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l);l.scrollIntoView(r);e.display.lineSpace.removeChild(l)}}function ar(e,t,i,n){if(n==null){n=0}var r;if(!e.options.lineWrapping&&t==i){i=t.sticky=="before"?ft(t.line,t.ch+1,"before"):t;t=t.ch?ft(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t}for(var o=0;o<5;o++){var l=false;var a=Cn(e,t);var s=!i||i==t?a:Cn(e,i);r={left:Math.min(a.left,s.left),top:Math.min(a.top,s.top)-n,right:Math.max(a.left,s.left),bottom:Math.max(a.bottom,s.bottom)+n};var f=fr(e,r);var c=e.doc.scrollTop,u=e.doc.scrollLeft;if(f.scrollTop!=null){gr(e,f.scrollTop);if(Math.abs(e.doc.scrollTop-c)>1){l=true}}if(f.scrollLeft!=null){yr(e,f.scrollLeft);if(Math.abs(e.doc.scrollLeft-u)>1){l=true}}if(!l){break}}return r}function sr(e,t){var i=fr(e,t);if(i.scrollTop!=null){gr(e,i.scrollTop)}if(i.scrollLeft!=null){yr(e,i.scrollLeft)}}function fr(e,t){var i=e.display,n=Dn(e.display);if(t.top<0){t.top=0}var r=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop;var o=Zi(e),l={};if(t.bottom-t.top>o){t.bottom=t.top+o}var a=e.doc.height+_i(i);var s=t.topa-n;if(t.topr+o){var c=Math.min(t.top,(f?a:t.bottom)-o);if(c!=r){l.scrollTop=c}}var u=e.options.fixedGutter?0:i.gutters.offsetWidth;var h=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-u;var d=Qi(e)-i.gutters.offsetWidth;var p=t.right-t.left>d;if(p){t.right=t.left+d}if(t.left<10){l.scrollLeft=0}else if(t.leftd+h-3){l.scrollLeft=t.right+(p?0:10)-d}return l}function cr(e,t){if(t==null){return}pr(e);e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function ur(e){pr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function hr(e,t,i){if(t!=null||i!=null){pr(e)}if(t!=null){e.curOp.scrollLeft=t}if(i!=null){e.curOp.scrollTop=i}}function dr(e,t){pr(e);e.curOp.scrollToPos=t}function pr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=Sn(e,t.from),n=Sn(e,t.to);mr(e,i,n,t.margin)}}function mr(e,t,i,n){var r=fr(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-n,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+n});hr(e,r.scrollLeft,r.scrollTop)}function gr(e,t){if(Math.abs(e.doc.scrollTop-t)<2){return}if(!i){$r(e,{top:t})}vr(e,t,true);if(i){$r(e)}Br(e,100)}function vr(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t));if(e.display.scroller.scrollTop==t&&!i){return}e.doc.scrollTop=t;e.display.scrollbars.setScrollTop(t);if(e.display.scroller.scrollTop!=t){e.display.scroller.scrollTop=t}}function yr(e,t,i,n){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth));if((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!n){return}e.doc.scrollLeft=t;Jr(e);if(e.display.scroller.scrollLeft!=t){e.display.scroller.scrollLeft=t}e.display.scrollbars.setScrollLeft(t)}function xr(e){var t=e.display,i=t.gutters.offsetWidth;var n=Math.round(e.doc.height+_i(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:n,scrollHeight:n+Ji(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var br=function(e,t,i){this.cm=i;var n=this.vert=A("div",[A("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar");var r=this.horiz=A("div",[A("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=r.tabIndex=-1;e(n);e(r);xe(n,"scroll",function(){if(n.clientHeight){t(n.scrollTop,"vertical")}});xe(r,"scroll",function(){if(r.clientWidth){t(r.scrollLeft,"horizontal")}});this.checkedZeroWidth=false;if(l&&a<8){this.horiz.style.minHeight=this.vert.style.minWidth="18px"}};br.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1;var i=e.scrollHeight>e.clientHeight+1;var n=e.nativeBarWidth;if(i){this.vert.style.display="block";this.vert.style.bottom=t?n+"px":"0";var r=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+r)+"px"}else{this.vert.scrollTop=0;this.vert.style.display="";this.vert.firstChild.style.height="0"}if(t){this.horiz.style.display="block";this.horiz.style.right=i?n+"px":"0";this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(i?n:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedZeroWidth&&e.clientHeight>0){if(n==0){this.zeroWidthHack()}this.checkedZeroWidth=true}return{right:i?n:0,bottom:t?n:0}};br.prototype.setScrollLeft=function(e){if(this.horiz.scrollLeft!=e){this.horiz.scrollLeft=e}if(this.disableHoriz){this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")}};br.prototype.setScrollTop=function(e){if(this.vert.scrollTop!=e){this.vert.scrollTop=e}if(this.disableVert){this.enableZeroWidthBar(this.vert,this.disableVert,"vert")}};br.prototype.zeroWidthHack=function(){var e=x&&!p?"12px":"18px";this.horiz.style.height=this.vert.style.width=e;this.horiz.style.visibility=this.vert.style.visibility="hidden";this.disableHoriz=new G;this.disableVert=new G};br.prototype.enableZeroWidthBar=function(e,t,i){e.style.visibility="";function n(){var r=e.getBoundingClientRect();var o=i=="vert"?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1);if(o!=e){e.style.visibility="hidden"}else{t.set(1e3,n)}}t.set(1e3,n)};br.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz);e.removeChild(this.vert)};var wr=function(){};wr.prototype.update=function(){return{bottom:0,right:0}};wr.prototype.setScrollLeft=function(){};wr.prototype.setScrollTop=function(){};wr.prototype.clear=function(){};function Cr(e,t){if(!t){t=xr(e)}var i=e.display.barWidth,n=e.display.barHeight;Sr(e,t);for(var r=0;r<4&&i!=e.display.barWidth||n!=e.display.barHeight;r++){if(i!=e.display.barWidth&&e.options.lineWrapping){nr(e)}Sr(e,xr(e));i=e.display.barWidth;n=e.display.barHeight}}function Sr(e,t){var i=e.display;var n=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=n.right)+"px";i.sizer.style.paddingBottom=(i.barHeight=n.bottom)+"px";i.heightForcer.style.borderBottom=n.bottom+"px solid transparent";if(n.right&&n.bottom){i.scrollbarFiller.style.display="block";i.scrollbarFiller.style.height=n.bottom+"px";i.scrollbarFiller.style.width=n.right+"px"}else{i.scrollbarFiller.style.display=""}if(n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter){i.gutterFiller.style.display="block";i.gutterFiller.style.height=n.bottom+"px";i.gutterFiller.style.width=t.gutterWidth+"px"}else{i.gutterFiller.style.display=""}}var kr={native:br,null:wr};function Lr(e){if(e.display.scrollbars){e.display.scrollbars.clear();if(e.display.scrollbars.addClass){M(e.display.wrapper,e.display.scrollbars.addClass)}}e.display.scrollbars=new kr[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller);xe(t,"mousedown",function(){if(e.state.focused){setTimeout(function(){return e.display.input.focus()},0)}});t.setAttribute("cm-not-content","true")},function(t,i){if(i=="horizontal"){yr(e,t)}else{gr(e,t)}},e);if(e.display.scrollbars.addClass){H(e.display.wrapper,e.display.scrollbars.addClass)}}var Mr=0;function Tr(e){e.curOp={cm:e,viewChanged:false,startHeight:e.doc.height,forceUpdate:false,updateInput:0,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:false,id:++Mr,markArrays:null};Oi(e.curOp)}function Or(e){var t=e.curOp;if(t){Ni(t,function(e){for(var t=0;t=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping;e.update=e.mustUpdate&&new zr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Pr(e){e.updatedDisplay=e.mustUpdate&&Vr(e.cm,e.update)}function Fr(e){var t=e.cm,i=t.display;if(e.updatedDisplay){nr(t)}e.barMeasure=xr(t);if(i.maxLineChanged&&!t.options.lineWrapping){e.adjustWidthTo=rn(t,i.maxLine,i.maxLine.text.length).left+3;t.display.sizerWidth=e.adjustWidthTo;e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+Ji(t)+t.display.barWidth);e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Qi(t))}if(e.updatedDisplay||e.selectionChanged){e.preparedSelection=i.input.prepareSelection()}}function Dr(e){var t=e.cm;if(e.adjustWidthTo!=null){t.display.sizer.style.minWidth=e.adjustWidthTo+"px";if(e.maxScrollLeft=e.display.viewTo){return}var i=+new Date+e.options.workTime;var n=St(e,t.highlightFrontier);var r=[];t.iter(n.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(n.line>=e.display.viewFrom){var l=o.styles;var a=o.text.length>e.options.maxHighlightLength?Je(t.mode,n.state):null;var s=wt(e,o,n,true);if(a){n.state=a}o.styles=s.styles;var f=o.styleClasses,c=s.classes;if(c){o.styleClasses=c}else if(f){o.styleClasses=null}var u=!l||l.length!=o.styles.length||f!=c&&(!f||!c||f.bgClass!=c.bgClass||f.textClass!=c.textClass);for(var h=0;!u&&hi){Br(e,e.options.workDelay);return true}});t.highlightFrontier=n.line;t.modeFrontier=Math.max(t.modeFrontier,n.line);if(r.length){Er(e,function(){for(var t=0;t=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&Kn(e)==0){return false}if(Qr(e)){Un(e);t.dims=En(e)}var r=n.first+n.size;var o=Math.max(t.visible.from-e.options.viewportMargin,n.first);var l=Math.min(r,t.visible.to+e.options.viewportMargin);if(i.viewFroml&&i.viewTo-l<20){l=Math.min(r,i.viewTo)}if(Ht){o=oi(e.doc,o);l=li(e.doc,l)}var a=o!=i.viewFrom||l!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vn(e,o,l);i.viewOffset=fi(tt(e.doc,i.viewFrom));e.display.mover.style.top=i.viewOffset+"px";var s=Kn(e);if(!a&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)){return false}var f=Ur(e);if(s>4){i.lineDiv.style.display="none"}Xr(e,i.updateLineNumbers,t.dims);if(s>4){i.lineDiv.style.display=""}i.renderedView=i.view;Gr(f);T(i.cursorDiv);T(i.selectionDiv);i.gutters.style.height=i.sizer.style.minHeight=0;if(a){i.lastWrapHeight=t.wrapperHeight;i.lastWrapWidth=t.wrapperWidth;Br(e,400)}i.updateLineNumbers=null;return true}function Kr(e,t){var i=t.viewport;for(var n=true;;n=false){if(!n||!e.options.lineWrapping||t.oldDisplayWidth==Qi(e)){if(i&&i.top!=null){i={top:Math.min(e.doc.height+_i(e.display)-Zi(e),i.top)}}t.visible=or(e.display,e.doc,i);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo){break}}else if(n){t.visible=or(e.display,e.doc,i)}if(!Vr(e,t)){break}nr(e);var r=xr(e);$n(e);Cr(e,r);Yr(e,r);t.force=false}t.signal(e,"update",e);if(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo){t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo);e.display.reportedViewFrom=e.display.viewFrom;e.display.reportedViewTo=e.display.viewTo}}function $r(e,t){var i=new zr(e,t);if(Vr(e,i)){nr(e);Kr(e,i);var n=xr(e);$n(e);Cr(e,n);Yr(e,n);i.finish()}}function Xr(e,t,i){var n=e.display,r=e.options.lineNumbers;var o=n.lineDiv,l=o.firstChild;function a(t){var i=t.nextSibling;if(s&&x&&e.display.currentWheelTarget==t){t.style.display="none"}else{t.parentNode.removeChild(t)}return i}var f=n.view,c=n.viewFrom;for(var u=0;u-1){p=false}Hi(e,h,c,i)}if(p){T(h.lineNumber);h.lineNumber.appendChild(document.createTextNode(st(e.options,c)))}l=h.node.nextSibling}c+=h.size}while(l){l=a(l)}}function _r(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px";Fi(e,"gutterChanged",e)}function Yr(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";e.display.heightForcer.style.top=t.docHeight+"px";e.display.gutters.style.height=t.docHeight+e.display.barHeight+Ji(e)+"px"}function Jr(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter)){return}var n=Wn(t)-t.scroller.scrollLeft+e.doc.scrollLeft;var r=t.gutters.offsetWidth,o=n+"px";for(var l=0;l=105){o.wrapper.style.clipPath="inset(0px)"}o.wrapper.setAttribute("translate","no");if(l&&a<8){o.gutters.style.zIndex=-1;o.scroller.style.paddingRight=0}if(!s&&!(i&&y)){o.scroller.draggable=true}if(e){if(e.appendChild){e.appendChild(o.wrapper)}else{e(o.wrapper)}}o.viewFrom=o.viewTo=t.first;o.reportedViewFrom=o.reportedViewTo=t.first;o.view=[];o.renderedView=null;o.externalMeasured=null;o.viewOffset=0;o.lastWrapHeight=o.lastWrapWidth=0;o.updateLineNumbers=null;o.nativeBarWidth=o.barHeight=o.barWidth=0;o.scrollbarsClipped=false;o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null;o.alignWidgets=false;o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null;o.maxLine=null;o.maxLineLength=0;o.maxLineChanged=false;o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null;o.shift=false;o.selForContextMenu=null;o.activeTouch=null;o.gutterSpecs=Zr(r.gutters,r.lineNumbers);eo(o);n.init(o)}var no=0,ro=null;if(l){ro=-.53}else if(i){ro=15}else if(c){ro=-.7}else if(d){ro=-1/3}function oo(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;if(t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS){t=e.detail}if(i==null&&e.detail&&e.axis==e.VERTICAL_AXIS){i=e.detail}else if(i==null){i=e.wheelDelta}return{x:t,y:i}}function lo(e){var t=oo(e);t.x*=ro;t.y*=ro;return t}function ao(e,t){if(c&&u==102){if(e.display.chromeScrollHack==null){e.display.sizer.style.pointerEvents="none"}else{clearTimeout(e.display.chromeScrollHack)}e.display.chromeScrollHack=setTimeout(function(){e.display.chromeScrollHack=null;e.display.sizer.style.pointerEvents=""},100)}var n=oo(t),r=n.x,o=n.y;var l=ro;if(t.deltaMode===0){r=t.deltaX;o=t.deltaY;l=1}var a=e.display,f=a.scroller;var d=f.scrollWidth>f.clientWidth;var p=f.scrollHeight>f.clientHeight;if(!(r&&d||o&&p)){return}if(o&&x&&s){e:for(var m=t.target,g=a.view;m!=f;m=m.parentNode){for(var v=0;v=0&&ct(e,n.to())<=0){return i}}return-1};var fo=function(e,t){this.anchor=e;this.head=t};fo.prototype.from=function(){return pt(this.anchor,this.head)};fo.prototype.to=function(){return dt(this.anchor,this.head)};fo.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function co(e,t,i){var n=e&&e.options.selectionsMayTouch;var r=t[i];t.sort(function(e,t){return ct(e.from(),t.from())});i=V(t,r);for(var o=1;o0:s>=0){var f=pt(a.from(),l.from()),c=dt(a.to(),l.to());var u=a.empty()?l.from()==l.head:a.from()==a.head;if(o<=i){--i}t.splice(--o,2,new fo(u?c:f,u?f:c))}}return new so(t,i)}function uo(e,t){return new so([new fo(e,t||e)],0)}function ho(e){if(!e.text){return e.to}return ft(e.from.line+e.text.length-1,ee(e.text).length+(e.text.length==1?e.from.ch:0))}function po(e,t){if(ct(e,t.from)<0){return e}if(ct(e,t.to)<=0){return ho(t)}var i=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;if(e.line==t.to.line){n+=ho(t).ch-t.to.ch}return ft(i,n)}function mo(e,t){var i=[];for(var n=0;n1){e.remove(a.line+1,p-1)}e.insert(a.line+1,v)}Fi(e,"change",e,t)}function Co(e,t,i){function n(e,r,o){if(e.linked){for(var l=0;l1&&!e.done[e.done.length-2].ranges){e.done.pop();return ee(e.done)}}function No(e,t,i,n){var r=e.history;r.undone.length=0;var o=+new Date,l;var a;if((r.lastOp==n||r.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&r.lastModTime>o-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(l=Ao(r,r.lastOp==n))){a=ee(l.changes);if(ct(t.from,t.to)==0&&ct(t.from,a.to)==0){a.to=ho(t)}else{l.changes.push(To(e,t))}}else{var s=ee(r.done);if(!s||!s.ranges){Do(e.sel,r.done)}l={changes:[To(e,t)],generation:r.generation};r.done.push(l);while(r.done.length>r.undoDepth){r.done.shift();if(!r.done[0].ranges){r.done.shift()}}}r.done.push(i);r.generation=++r.maxGeneration;r.lastModTime=r.lastSelTime=o;r.lastOp=r.lastSelOp=n;r.lastOrigin=r.lastSelOrigin=t.origin;if(!a){Ce(e,"historyAdded")}}function Po(e,t,i,n){var r=t.charAt(0);return r=="*"||r=="+"&&i.ranges.length==n.ranges.length&&i.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Fo(e,t,i,n){var r=e.history,o=n&&n.origin;if(i==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||Po(e,o,ee(r.done),t))){r.done[r.done.length-1]=t}else{Do(t,r.done)}r.lastSelTime=+new Date;r.lastSelOrigin=o;r.lastSelOp=i;if(n&&n.clearRedo!==false){Oo(r.undone)}}function Do(e,t){var i=ee(t);if(!(i&&i.ranges&&i.equals(e))){t.push(e)}}function Ho(e,t,i,n){var r=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,n),function(i){if(i.markedSpans){(r||(r=t["spans_"+e.id]={}))[o]=i.markedSpans}++o})}function Eo(e){if(!e){return null}var t;for(var i=0;i-1){ee(a)[u]=f[u];delete f[u]}}}}}}return n}function Bo(e,t,i,n){if(n){var r=e.anchor;if(i){var o=ct(t,r)<0;if(o!=ct(i,r)<0){r=t;t=i}else if(o!=ct(t,i)<0){t=i}}return new fo(r,t)}else{return new fo(i||t,t)}}function jo(e,t,i,n,r){if(r==null){r=e.cm&&(e.cm.display.shift||e.extend)}Ko(e,new so([Bo(e.sel.primary(),t,i,r)],0),n)}function zo(e,t,i){var n=[];var r=e.cm&&(e.cm.display.shift||e.extend);for(var o=0;o=t.ch:a.to>t.ch))){if(r){Ce(s,"beforeCursorEnter");if(s.explicitlyCleared){if(!o.markedSpans){break}else{--l;continue}}}if(!s.atomic){continue}if(i){var u=s.find(n<0?1:-1),h=void 0;if(n<0?c:f){u=Zo(e,u,-n,u&&u.line==t.line?o:null)}if(u&&u.line==t.line&&(h=ct(u,i))&&(n<0?h<0:h>0)){return Jo(e,u,t,n,r)}}var d=s.find(n<0?-1:1);if(n<0?f:c){d=Zo(e,d,n,d.line==t.line?o:null)}return d?Jo(e,d,t,n,r):null}}}return t}function Qo(e,t,i,n,r){var o=n||1;var l=Jo(e,t,i,o,r)||!r&&Jo(e,t,i,o,true)||Jo(e,t,i,-o,r)||!r&&Jo(e,t,i,-o,true);if(!l){e.cantEdit=true;return ft(e.first,0)}return l}function Zo(e,t,i,n){if(i<0&&t.ch==0){if(t.line>e.first){return gt(e,ft(t.line-1))}else{return null}}else if(i>0&&t.ch==(n||tt(e,t.line)).text.length){if(t.line=0;--r){nl(e,{from:n[r].from,to:n[r].to,text:r?[""]:t.text,origin:t.origin})}}else{nl(e,t)}}function nl(e,t){if(t.text.length==1&&t.text[0]==""&&ct(t.from,t.to)==0){return}var i=mo(e,t);No(e,t,i,e.cm?e.cm.curOp.id:NaN);ll(e,t,i,Ut(e,t));var n=[];Co(e,function(e,i){if(!i&&V(n,e.history)==-1){ul(e.history,t);n.push(e.history)}ll(e,t,null,Ut(e,t))})}function rl(e,t,i){var n=e.cm&&e.cm.state.suppressEdits;if(n&&!i){return}var r=e.history,o,l=e.sel;var a=t=="undo"?r.done:r.undone,s=t=="undo"?r.undone:r.done;var f=0;for(;f=0;--d){var p=h(d);if(p)return p.v}}function ol(e,t){if(t==0){return}e.first+=t;e.sel=new so(te(e.sel.ranges,function(e){return new fo(ft(e.anchor.line+t,e.anchor.ch),ft(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){zn(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,n=i.viewFrom;ne.lastLine()){return}if(t.from.lineo){t={from:t.from,to:ft(o,tt(e,o).text.length),text:[t.text[0]],origin:t.origin}}t.removed=it(e,t.from,t.to);if(!i){i=mo(e,t)}if(e.cm){al(e.cm,t,n)}else{wo(e,t,n)}$o(e,i,X);if(e.cantEdit&&Qo(e,ft(e.firstLine(),0))){e.cantEdit=false}}function al(e,t,i){var n=e.doc,r=e.display,o=t.from,l=t.to;var a=false,s=o.line;if(!e.options.lineWrapping){s=ot(ii(tt(n,o.line)));n.iter(s,l.line+1,function(e){if(e==r.maxLine){a=true;return true}})}if(n.sel.contains(t.from,t.to)>-1){ke(e)}wo(n,t,i,In(e));if(!e.options.lineWrapping){n.iter(s,o.line+t.text.length,function(e){var t=ci(e);if(t>r.maxLineLength){r.maxLine=e;r.maxLineLength=t;r.maxLineChanged=true;a=false}});if(a){e.curOp.updateMaxLine=true}}Ft(n,o.line);Br(e,400);var f=t.text.length-(l.line-o.line)-1;if(t.full){zn(e)}else if(o.line==l.line&&t.text.length==1&&!bo(e.doc,t)){qn(e,o.line,"text")}else{zn(e,o.line,l.line+1,f)}var c=Le(e,"changes"),u=Le(e,"change");if(u||c){var h={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};if(u){Fi(e,"change",e,h)}if(c){(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}}e.display.selForContextMenu=null}function sl(e,t,i,n,r){var o;if(!n){n=i}if(ct(n,i)<0){o=[n,i],i=o[0],n=o[1]}if(typeof t=="string"){t=e.splitLines(t)}il(e,{from:i,to:n,text:t,origin:r})}function fl(e,t,i,n){if(i1||!(this.children[0]instanceof dl))){var a=[];this.collapse(a);this.children=[new dl(a)];this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){var l=r.lines.length%25+25;for(var a=l;a10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var n=0;ne.display.maxLineLength){e.display.maxLine=f;e.display.maxLineLength=c;e.display.maxLineChanged=true}}}if(n!=null&&e&&this.collapsed){zn(e,n,r+1)}this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(e){_o(e.doc)}}if(e){Fi(e,"markerCleared",e,this,n,r)}if(t){Or(e)}if(this.parent){this.parent.clear()}};xl.prototype.find=function(e,t){if(e==null&&this.type=="bookmark"){e=1}var i,n;for(var r=0;r0||l==0&&o.clearWhenEmpty!==false){return o}if(o.replacedWith){o.collapsed=true;o.widgetNode=N("span",[o.replacedWith],"CodeMirror-widget");if(!n.handleMouseEvents){o.widgetNode.setAttribute("cm-ignore-events","true")}if(n.insertLeft){o.widgetNode.insertLeft=true}}if(o.collapsed){if(ti(e,t.line,t,i,o)||t.line!=i.line&&ti(e,i.line,t,i,o)){throw new Error("Inserting collapsed marker partially overlapping an existing one")}Wt()}if(o.addToHistory){No(e,{from:t,to:i,origin:"markText"},e.sel,NaN)}var a=t.line,s=e.cm,f;e.iter(a,i.line+1,function(n){if(s&&o.collapsed&&!s.options.lineWrapping&&ii(n)==s.display.maxLine){f=true}if(o.collapsed&&a!=t.line){rt(n,0)}jt(n,new It(o,a==t.line?t.ch:null,a==i.line?i.ch:null),e.cm&&e.cm.curOp);++a});if(o.collapsed){e.iter(t.line,i.line+1,function(t){if(ai(e,t)){rt(t,0)}})}if(o.clearOnEnter){xe(o,"beforeCursorEnter",function(){return o.clear()})}if(o.readOnly){Et();if(e.history.done.length||e.history.undone.length){e.clearHistory()}}if(o.collapsed){o.id=++yl;o.atomic=true}if(s){if(f){s.curOp.updateMaxLine=true}if(o.collapsed){zn(s,t.line,i.line+1)}else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title){for(var c=t.line;c<=i.line;c++){qn(s,c,"text")}}if(o.atomic){_o(s.doc)}Fi(s,"markerAdded",s,o)}return o}var wl=function(e,t){this.markers=e;this.primary=t;for(var i=0;i=0;s--){il(this,n[s])}if(a){Vo(this,a)}else if(this.cm){ur(this.cm)}}),undo:Rr(function(){rl(this,"undo")}),redo:Rr(function(){rl(this,"redo")}),undoSelection:Rr(function(){rl(this,"undo",true)}),redoSelection:Rr(function(){rl(this,"redo",true)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,i=0;for(var n=0;n=e.ch)){t.push(r.marker.parent||r.marker)}}}return t},findMarks:function(e,t,i){e=gt(this,e);t=gt(this,t);var n=[],r=e.line;this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l){for(var a=0;a=s.to||s.from==null&&r!=e.line||s.from!=null&&r==t.line&&s.from>=t.ch)&&(!i||i(s.marker))){n.push(s.marker.parent||s.marker)}}}++r});return n},getAllMarks:function(){var e=[];this.iter(function(t){var i=t.markedSpans;if(i){for(var n=0;ne){t=e;return true}e-=o;++i});return gt(this,ft(i,t))},indexFromPos:function(e){e=gt(this,e);var t=e.ch;if(e.linet){t=e.from}if(e.to!=null&&e.to-1){t.state.draggingText(e);setTimeout(function(){return t.display.input.focus()},20);return}try{var u=e.dataTransfer.getData("Text");if(u){var h;if(t.state.draggingText&&!t.state.draggingText.copy){h=t.listSelections()}$o(t.doc,uo(i,i));if(h){for(var d=0;d=0;t--){sl(e.doc,"",n[t].from,n[t].to,"+delete")}ur(e)})}function Jl(e,t,i){var n=ue(e.text,t+i,i);return n<0||n>e.text.length?null:n}function Ql(e,t,i){var n=Jl(e,t.ch,i);return n==null?null:new ft(t.line,n,i<0?"after":"before")}function Zl(e,t,i,n,r){if(e){if(t.doc.direction=="rtl"){r=-r}var o=ve(i,t.doc.direction);if(o){var l=r<0?ee(o):o[0];var a=r<0==(l.level==1);var s=a?"after":"before";var f;if(l.level>0||t.doc.direction=="rtl"){var c=ln(t,i);f=r<0?i.text.length-1:0;var u=an(t,c,f).top;f=he(function(e){return an(t,c,e).top==u},r<0==(l.level==1)?l.from:l.to-1,f);if(s=="before"){f=Jl(i,f,1)}}else{f=r<0?l.to:l.from}return new ft(n,f,s)}}return new ft(n,r<0?i.text.length:0,r<0?"before":"after")}function ea(e,t,i,n){var r=ve(t,e.doc.direction);if(!r){return Ql(t,i,n)}if(i.ch>=t.text.length){i.ch=t.text.length;i.sticky="before"}else if(i.ch<=0){i.ch=0;i.sticky="after"}var o=me(r,i.ch,i.sticky),l=r[o];if(e.doc.direction=="ltr"&&l.level%2==0&&(n>0?l.to>i.ch:l.from=l.from&&h>=c.begin:h<=l.to&&h<=c.end)){var d=u?"before":"after";return new ft(i.line,h,d)}}var p=function(e,t,n){var o=function(e,t){return t?new ft(i.line,a(e,1),"before"):new ft(i.line,e,"after")};for(;e>=0&&e