From 4631aab53b108ec7f1629e8ddcc06b3c90b5f1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com> Date: Thu, 15 Apr 2021 10:33:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/function.php | 2 +- package.json | 2 +- typecho/write/js/_actions.js | 5 +++++ typecho/write/js/_tools.js | 5 +++++ typecho/write/js/joe.parse.js | 20 +++++++++----------- typecho/write/js/joe.parse.min.js | 2 +- typecho/write/js/joe.write.chunk.js | 6 +++--- typecho/write/js/joe.write.js | 3 +++ 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/core/function.php b/core/function.php index 10e2dd6..082d3c4 100644 --- a/core/function.php +++ b/core/function.php @@ -2,7 +2,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "6.3.8"; + return "6.3.9"; }; /* 判断是否是手机 */ diff --git a/package.json b/package.json index 9b532fd..e097cb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typecho-joe-next", - "version": "6.3.8", + "version": "6.3.9", "description": "A Theme Of Typecho", "main": "index.php", "keywords": [ diff --git a/typecho/write/js/_actions.js b/typecho/write/js/_actions.js index a719b0b..ee0bb2d 100644 --- a/typecho/write/js/_actions.js +++ b/typecho/write/js/_actions.js @@ -471,4 +471,9 @@ export default class JoeAction { } }); } + handleHtml(cm) { + const str = `${this._getLineCh(cm) ? '\n' : ''}!!!\n

居中

\n

居右

\n颜色大小\n!!!\n`; + this._replaceSelection(cm, str); + cm.focus(); + } } diff --git a/typecho/write/js/_tools.js b/typecho/write/js/_tools.js index 69b7a4c..40581cf 100644 --- a/typecho/write/js/_tools.js +++ b/typecho/write/js/_tools.js @@ -89,6 +89,11 @@ export default [ title: '代码块', innerHTML: '' }, + { + type: 'html', + title: '原生HTML', + innerHTML: '' + }, { type: 'expression', title: '图片表情', diff --git a/typecho/write/js/joe.parse.js b/typecho/write/js/joe.parse.js index 3e727f5..9efee04 100644 --- a/typecho/write/js/joe.parse.js +++ b/typecho/write/js/joe.parse.js @@ -652,18 +652,16 @@ Parser.prototype.parseBlockShtml = function (block, key, line, state) { var matches; - if (this.html) { - if (!!(matches = line.match(/^(\s*)!!!(\s*)$/))) { - if (this.isBlock('shtml')) { - this.setBlock(key).endBlock(); - } else { - this.startBlock('shtml', key); - } - return false; - } else if (this.isBlock('shtml')) { - this.setBlock(key); - return false; + if (!!(matches = line.match(/^(\s*)!!!(\s*)$/))) { + if (this.isBlock('shtml')) { + this.setBlock(key).endBlock(); + } else { + this.startBlock('shtml', key); } + return false; + } else if (this.isBlock('shtml')) { + this.setBlock(key); + return false; } return true; }; diff --git a/typecho/write/js/joe.parse.min.js b/typecho/write/js/joe.parse.min.js index def115b..f900d84 100644 --- a/typecho/write/js/joe.parse.min.js +++ b/typecho/write/js/joe.parse.min.js @@ -1 +1 @@ -(function(){var t,e=[].slice;t=function(){function t(){this.commonWhiteList="kbd|b|i|strong|em|sup|sub|br|code|del|a|hr|small",this.blockHtmlTags="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|svg|script|noscript",this.specialWhiteList={table:"table|tbody|thead|tfoot|tr|td|th"},this.hooks={},this.html=!1,this.line=!1,this.blockParsers=[["code",10],["shtml",20],["pre",30],["ahtml",40],["shr",50],["list",60],["math",70],["html",80],["footnote",90],["definition",100],["quote",110],["table",120],["sh",130],["mh",140],["dhr",150],["default",9999]],this.parsers={}}var n,r,s,l,i,o,a,c;return c=function(t){return t.charAt(0).toUpperCase()+t.substring(1)},i=function(t){return t.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},l="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",o=function(t,e,n){var r,s,l,a,c,h;if(t instanceof Array)if(e instanceof Array)for(r=s=0,a=t.length;s/g,">").replace(/"/g,""")},a=function(t,e){var n,r,s,l,o;if(null==e&&(e=null),null!=e){for(o="",r=s=0,l=e.length-1;0<=l?s<=l:s>=l;r=0<=l?++s:--s)n=e[r],n=i(n),o+=n;return o="["+o+"]*",t.replace(new RegExp("^"+o),"").replace(new RegExp(o+"$"),"")}return t.replace(/^\s*/,"").replace(/\s*$/,"")},n=function(t){var e,n,r,s;if(s=[],t instanceof Array)for(n=e=0,r=t.length;e0){for(t+='

    ',e=1;n=this.footnotes.shift();)"string"==typeof n?n+=' ':(n[n.length-1]+=' ',n=n.length>1?this.parse(n.join("\n")):this.parseInline(n[0])),t+='
  1. '+n+"
  2. ",e+=1;t+="
"}return t},t.prototype.parse=function(t,e,n){var r,s,l,i,o,a,h,u,p,f,k,m,g;for(null==e&&(e=!1),null==n&&(n=0),u=[],s=this.parseBlock(t,u),o="",e&&1===s.length&&"normal"===s[0][0]&&(s[0][3]=!0),a=0,h=s.length;a=0&&s<10;)t=o(n(this.holders),r(this.holders),t),s+=1;return e&&(this.holders={}),t},t.prototype.markLine=function(t,e){return null==e&&(e=-1),this.line?(e=e<0?t:e,''):""},t.prototype.markLines=function(t,e){var n,r;return n=-1,this.line?t.map((r=this,function(t){return n+=1,r.markLine(e+n)+t})):t},t.prototype.optimizeLines=function(t){var n,r;return n=0,r=new RegExp('class="line" data\\-start="([0-9]+)" data\\-end="([0-9]+)" (data\\-id="'+this.uniqid+'")',"g"),this.line?t.replace(r,function(){var t,r;return t=1<=arguments.length?e.call(arguments,0):[],r=n!==parseInt(t[1])?'class="line" data-start="'+n+'" data-start-original="'+t[1]+'" data-end="'+t[2]+'" '+t[3]:t[0],n=1+parseInt(t[2]),r}):t},t.prototype.parseInline=function(t,n,r,i){var a,c;return null==n&&(n=""),null==r&&(r=!0),null==i&&(i=!0),t=this.call("beforeParseInline",t),t=t.replace(/(^|[^\\])(`+)(.+?)\2/gm,(c=this,function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],t[1]+c.makeHolder(""+s(t[3])+"")})),t=t.replace(/(^|[^\\])(\$+)(.+?)\2/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+t.makeHolder(n[2]+s(n[3])+n[2])}}(this)),t=t.replace(/\\(.)/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],l=r[1].match(/^[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]$/)?"":"\\",n=s(r[1]),n=n.replace(/\$/g,"$"),t.makeHolder(l+n)}}(this)),t=t.replace(/<(https?:\/\/.+)>/gi,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],s=t.cleanUrl(r[1]),n=t.call("parseLink",r[1]),t.makeHolder(''+n+"")}}(this)),t=t.replace(/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/gi,function(t){return function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],t.html||("|"+t.commonWhiteList+"|"+n+"|").indexOf("|"+r[2].toLowerCase()+"|")>=0?t.makeHolder(r[0]):t.makeHolder(s(r[0]))}}(this)),this.html&&(t=t.replace(//g,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],t.makeHolder(n[0])}}(this))),t=o(["<",">"],["<",">"],t),t=t.replace(/\[\^((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r;return r=1<=arguments.length?e.call(arguments,0):[],n=t.footnotes.indexOf(r[1]),n<0&&(n=t.footnotes.length+1,t.footnotes.push(t.parseInline(r[1],"",!1))),t.makeHolder(''+n+"")}}(this)),t=t.replace(/!\[((?:[^\]]|\\\]|\\\[)*?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],n=s(t.escapeBracket(r[1])),l=t.escapeBracket(r[2]),l=t.cleanUrl(l),t.makeHolder(''+n+'')}}(this)),t=t.replace(/!\[((?:[^\]]|\\\]|\\\[)*?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],n=s(t.escapeBracket(r[1])),l=null!=t.definitions[r[2]]?''+n+'':n,t.makeHolder(l)}}(this)),t=t.replace(/\[((?:[^\]]|\\\]|\\\[)+?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],n=t.parseInline(t.escapeBracket(r[1]),"",!1,!1),s=t.escapeBracket(r[2]),s=t.cleanUrl(s),t.makeHolder(''+n+"")}}(this)),t=t.replace(/\[((?:[^\]]|\\\]|\\\[)+?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],n=t.parseInline(t.escapeBracket(r[1]),"",!1,!1),s=null!=t.definitions[r[2]]?''+n+"":n,t.makeHolder(s)}}(this)),t=this.parseInlineCallback(t),t=t.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/gi,'$1'),i&&(a=new RegExp('(^|[^"])((https?):['+l+'_0-9-\\./%#!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)($|[^"])',"ig"),t=t.replace(a,function(t){return function(){var n,r;return r=1<=arguments.length?e.call(arguments,0):[],n=t.call("parseLink",r[2]),r[1]+''+n+""+r[4]}}(this))),t=this.call("afterParseInlineBeforeRelease",t),t=this.releaseHolder(t,r),t=this.call("afterParseInline",t),t},t.prototype.parseInlineCallback=function(t){var n;return t=t.replace(/(\*{3})((?:.|\r)+?)\1/gm,(n=this,function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],""+n.parseInlineCallback(t[2])+""})),t=t.replace(/(\*{2})((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t=t.replace(/(\*)((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t=t.replace(/(\s+|^)(_{3})((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(\s+|^)(_{2})((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(\s+|^)(_)((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(~{2})((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t},t.prototype.parseBlock=function(t,e){var r,s,l,i,o,a,c,h,u,p,f,k,m;for(f=t.split("\n"),s=0,o=f.length;st[3])return r.empty=0,this.setBlock(e),!1;if(n.match(/^\s*$/)&&0===r.empty)return r.empty+=1,this.setBlock(e),!1}return!(s=n.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))||(l=s[1].length,r.empty=0,this.isBlock("list")?this.setBlock(e,l):this.startBlock("list",e,l),!1)},t.prototype.parseBlockCode=function(t,e,n){var r,s,l;return(s=n.match(/^(\s*)(~{3,}|`{3,})([^`~]*)$/i))?(this.isBlock("code")?(r=t[3][2],r?this.combineBlock().setBlock(e):this.setBlock(e).endBlock()):(r=!1,this.isBlock("list")&&(l=t[3],r=l>0&&s[1].length>=l||s[1].length>l),this.startBlock("code",e,[s[1],s[3],r])),!1):!this.isBlock("code")||(this.setBlock(e),!1)},t.prototype.parseBlockShtml=function(t,e,n,r){if(this.html){if(n.match(/^(\s*)!!!(\s*)$/))return this.isBlock("shtml")?this.setBlock(e).endBlock():this.startBlock("shtml",e),!1;if(this.isBlock("shtml"))return this.setBlock(e),!1}return!0},t.prototype.parseBlockAhtml=function(t,e,n,r){var s,l,i,o,a;if(this.html)if(l=new RegExp("^\\s*<("+this.blockHtmlTags+")(\\s+[^>]*)?>","i"),a=n.match(l)){if(this.isBlock("ahtml"))return this.setBlock(e),!1;if(void 0===a[2]||"/"!==a[2]){for(this.startBlock("ahtml",e),s=new RegExp("\\s*<("+this.blockHtmlTags+")(\\s+[^>]*)?>","ig");o=s.exec(n),o;)i=o[1];return 0<=n.indexOf("")?this.endBlock():r.html=i,!1}}else{if(r.html&&0<=n.indexOf(""))return this.setBlock(e).endBlock(),r.html=!1,!1;if(this.isBlock("ahtml"))return this.setBlock(e),!1;if(a=n.match(/^\s*\s*$/))return this.startBlock("ahtml",e).endBlock(),!1}return!0},t.prototype.parseBlockMath=function(t,e,n){return n.match(/^(\s*)\$\$(\s*)$/)?(this.isBlock("math")?this.setBlock(e).endBlock():this.startBlock("math",e),!1):!this.isBlock("math")||(this.setBlock(e),!1)},t.prototype.parseBlockPre=function(t,e,n,r){return n.match(/^ {4}/)?(this.isBlock("pre")?this.setBlock(e):this.startBlock("pre",e),!1):!this.isBlock("pre")||!n.match(/^\s*$/)||(this.setBlock(e),!1)},t.prototype.parseBlockHtml=function(t,e,n,r){var s,l;return(s=n.match(new RegExp("^\\s*<("+r.special+")(\\s+[^>]*)?>","i")))?(l=s[1].toLowerCase(),this.isBlock("html",l)||this.isBlock("pre")||this.startBlock("html",e,l),!1):(s=n.match(new RegExp("\\s*$","i")))?(l=s[1].toLowerCase(),this.isBlock("html",l)&&this.setBlock(e).endBlock(),!1):!this.isBlock("html")||(this.setBlock(e),!1)},t.prototype.parseBlockFootnote=function(t,e,n){var r,s;return!(r=n.match(/^\[\^((?:[^\]]|\\\]|\\\[)+?)\]:/))||(s=r[0].length-1,this.startBlock("footnote",e,[s,r[1]]),!1)},t.prototype.parseBlockDefinition=function(t,e,n){var r;return!(r=n.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/))||(this.definitions[r[1]]=this.cleanUrl(r[2]),this.startBlock("definition",e).endBlock(),!1)},t.prototype.parseBlockQuote=function(t,e,n){var r;return!(r=n.match(/^(\s*)>/))||(this.isBlock("list")&&r[1].length>0?this.setBlock(e):this.isBlock("quote")?this.setBlock(e):this.startBlock("quote",e),!1)},t.prototype.parseBlockTable=function(t,e,n,r,s){var l,i,o,a,c,h,u,p;if(h=n.match(/^((?:(?:(?:\||\+)(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:[ :]*\-+[ :]*)(?:\||\+)(?:[ :]*\-+[ :]*))|(?:(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-+[ :]*)))+)$/)){if(this.isBlock("table"))t[3][0].push(t[3][2]),t[3][2]+=1,this.setBlock(e,t[3]);else{for(o=0,null==t||"normal"!==t[0]||s[t[2]].match(/^\s*$/)?this.startBlock("table",e):(o=1,this.backBlock(1,"table")),"|"===h[1][0]&&(h[1]=h[1].substring(1),"|"===h[1][h[1].length-1]&&(h[1]=h[1].substring(0,h[1].length-1))),p=h[1].split(/\+|\|/),i=[],a=0,c=p.length;a=t[3][0]?this.setBlock(e):this.startBlock("normal",e)):this.isBlock("table")?0<=n.indexOf("|")?(t[3][2]+=1,this.setBlock(e,t[3])):this.startBlock("normal",e):this.isBlock("quote")?n.match(/^(\s*)$/)?this.startBlock("normal",e):this.setBlock(e):null==t||"normal"!==t[0]?this.startBlock("normal",e):this.setBlock(e),!0},t.prototype.optimizeBlocks=function(t,e){var n,r,s,l,i,o,a,c,h,u,p,f;for(r=t.slice(0),o=e.slice(0),r=this.call("beforeOptimizeBlocks",r,o),i=0;null!=r[i];)a=!1,n=r[i],h=null!=r[i-1]?r[i-1]:null,c=null!=r[i+1]?r[i+1]:null,p=n[0],s=n[1],u=n[2],"pre"===p&&(l=o.slice(n[1],n[2]+1).reduce(function(t,e){return e.match(/^\s*$/)&&t},!0),l&&(n[0]=p="normal")),"normal"===p&&(f=["list","quote"],s===u&&o[s].match(/^\s*$/)&&null!=h&&null!=c&&h[0]===c[0]&&f.indexOf(h[0])>=0&&(r[i-1]=[h[0],h[1],c[2],null],r.splice(i,2),a=!0)),a||(i+=1);return this.call("afterOptimizeBlocks",r,o)},t.prototype.parseCode=function(t,e,n){var r,l,i,o,c,h;return r=e[0],o=e[1],o=a(o),l=r.length,o.match(/^[_a-z0-9-\+\#\:\.]+$/i)?(e=o.split(":"),e.length>1&&(o=e[0],c=e[1],o=a(o),c=a(c))):o=null,i=!0,t=t.slice(1,-1).map(function(t){return t=t.replace(new RegExp("/^[ ]{"+l+"}/"),""),i&&!t.match(/^\s*$/)&&(i=!1),s(t)}),h=this.markLines(t,n+1).join("\n"),i?"":"
"+h+"
"},t.prototype.parsePre=function(t,e,n){var r;return t=t.map(function(t){return s(t.substring(4))}),r=this.markLines(t,n).join("\n"),r.match(/^\s*$/)?"":"
"+r+"
"},t.prototype.parseAhtml=function(t,e,n){return a(this.markLines(t,n).join("\n"))},t.prototype.parseShtml=function(t,e,n){return a(this.markLines(t.slice(1,-1),n+1).join("\n"))},t.prototype.parseMath=function(t,e,n,r){return"

"+this.markLine(n,r)+s(t.join("\n"))+"

"},t.prototype.parseSh=function(t,e,n,r){var s;return s=this.markLine(n,r)+this.parseInline(a(t[0],"# ")),s.match(/^\s*$/)?"":""+s+""},t.prototype.parseMh=function(t,e,n,r){return this.parseSh(t,e,n,r)},t.prototype.parseQuote=function(t,e,n){var r;return t=t.map(function(t){return t.replace(/^\s*> ?/,"")}),r=t.join("\n"),r.match(/^\s*$/)?"":"
"+this.parse(r,!0,n)+"
"},t.prototype.parseList=function(t,e,n){var r,s,l,i,o,a,c,h,u,p,f,k,m,g,d,B,b,y,v,$;for(s="",m=99999,b=99999,r=!1,B=!1,d=[],i=l=0,u=t.length;l0&&(b=Math.min(y,b),B=!0),d.push([y,$,f,k[4]])):(d.push(f),(k=f.match(/^(\s*)/))&&(y=k[1].length,y>0&&(b=Math.min(y,b),B=!0)));for(m=r?m:0,b=B?b:m,a="",c=[],h=0,i=o=0,p=d.length;o0&&(s+="
  • "+this.parse(c.join("\n"),!0,n+h)+"
  • "),a!==$&&(a&&(s+=""),s+="<"+$+">"),h=i,c=[v],a=$)):c.push(g.replace(new RegExp("^\\s{"+b+"}"),""));return c.length>0&&(s+="
  • "+this.parse(c.join("\n"),!0,n+h)+"
  • "),s},t.prototype.parseTable=function(t,e,n){var r,s,l,i,o,c,h,u,p,f,k,m,g,d,B,b,y,v,$,x;for(h=e[0],r=e[1],o=h.length>0&&h.reduce(function(t,e){return e+t})>0,c="",s=!o||null,b=!1,p=u=0,m=t.length;u0?(k+=1,i[k]=[null!=i[k]?i[k][0]+1:1,y]):null!=i[k]?i[k][0]+=1:i[0]=[1,y];for(p in o?c+="":s&&(c+=""),c+="1&&(c+=' colspan="'+B+'"'),null!=r[p]&&"none"!==r[p]&&(c+=' align="'+r[p]+'"'),c+=">"+this.parseInline(x)+"";c+="",o?c+="":s&&(s=!1)}return null!==s&&(c+=""),c+"
    "},t.prototype.parseHr=function(t,e,n){return this.line?'
    ':"
    "},t.prototype.parseNormal=function(t,e,n){var r,s,l;return null==e&&(e=!1),r=0,t=t.map((l=this,function(t){return t=l.parseInline(t),t.match(/^\s*$/)||(t=l.markLine(n+r)+t),r+=1,t})),s=a(t.join("\n")),s=s.replace(/(\n\s*){2,}/g,"

    "),s=s.replace(/\n/g,"
    "),s.match(/^\s*$/)?"":e?s:"

    "+s+"

    "},t.prototype.parseFootnote=function(t,e){var n,r;return e[0],r=e[1],n=this.footnotes.indexOf(r),n>=0&&(t=t.slice(0),t[0]=t[0].replace(/^\[\^((?:[^\]]|\]|\[)+?)\]:/,""),this.footnotes[n]=t),""},t.prototype.parseDefinition=function(){return""},t.prototype.parseHtml=function(t,e,n){var r;return t=t.map((r=this,function(t){return r.parseInline(t,null!=r.specialWhiteList[e]?r.specialWhiteList[e]:"")})),this.markLines(t,n).join("\n")},t.prototype.cleanUrl=function(t){var e,n,r;return n=new RegExp("^\\s*((http|https|ftp|mailto):["+l+"_a-z0-9-:\\.\\*/%#;!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)","i"),r=new RegExp("^\\s*(["+l+"_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)","i"),(e=t.match(n))?e[1]:(e=t.match(r))?e[1]:"#"},t.prototype.escapeBracket=function(t){return o(["\\[","\\]","\\(","\\)"],["[","]","(",")"],t)},t.prototype.startBlock=function(t,e,n){return null==n&&(n=null),this.pos+=1,this.current=t,this.blocks.push([t,e,e,n]),this},t.prototype.endBlock=function(){return this.current="normal",this},t.prototype.isBlock=function(t,e){return null==e&&(e=null),this.current===t&&(null===e||this.blocks[this.pos][3]===e)},t.prototype.getBlock=function(){return null!=this.blocks[this.pos]?this.blocks[this.pos]:null},t.prototype.setBlock=function(t,e){return null==t&&(t=null),null==e&&(e=null),null!==t&&(this.blocks[this.pos][2]=t),null!==e&&(this.blocks[this.pos][3]=e),this},t.prototype.backBlock=function(t,e,n){var r,s;return null==n&&(n=null),this.pos<0?this.startBlock(e,0,n):(s=this.blocks[this.pos][2],this.blocks[this.pos][2]=s-t,r=[e,s-t+1,s,n],this.blocks[this.pos][1]<=this.blocks[this.pos][2]?(this.pos+=1,this.blocks.push(r)):this.blocks[this.pos]=r,this.current=e,this)},t.prototype.combineBlock=function(){var t,e;return this.pos<1?this:(e=this.blocks[this.pos-1].slice(0),t=this.blocks[this.pos].slice(0),e[2]=t[2],this.blocks[this.pos-1]=e,this.current=e[0],this.blocks=this.blocks.slice(0,-1),this.pos-=1,this)},t}(),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.HyperDown=t)}).call(this); \ No newline at end of file +(function(){var t,e=[].slice;t=function(){function t(){this.commonWhiteList="kbd|b|i|strong|em|sup|sub|br|code|del|a|hr|small",this.blockHtmlTags="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|svg|script|noscript",this.specialWhiteList={table:"table|tbody|thead|tfoot|tr|td|th"},this.hooks={},this.html=!1,this.line=!1,this.blockParsers=[["code",10],["shtml",20],["pre",30],["ahtml",40],["shr",50],["list",60],["math",70],["html",80],["footnote",90],["definition",100],["quote",110],["table",120],["sh",130],["mh",140],["dhr",150],["default",9999]],this.parsers={}}var n,r,s,l,i,o,a,c;return c=function(t){return t.charAt(0).toUpperCase()+t.substring(1)},i=function(t){return t.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},l="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",o=function(t,e,n){var r,s,l,a,c,h;if(t instanceof Array)if(e instanceof Array)for(r=s=0,a=t.length;s/g,">").replace(/"/g,""")},a=function(t,e){var n,r,s,l,o;if(null==e&&(e=null),null!=e){for(o="",r=s=0,l=e.length-1;0<=l?s<=l:s>=l;r=0<=l?++s:--s)n=e[r],n=i(n),o+=n;return o="["+o+"]*",t.replace(new RegExp("^"+o),"").replace(new RegExp(o+"$"),"")}return t.replace(/^\s*/,"").replace(/\s*$/,"")},n=function(t){var e,n,r,s;if(s=[],t instanceof Array)for(n=e=0,r=t.length;e0){for(t+='

      ',e=1;n=this.footnotes.shift();)"string"==typeof n?n+=' ':(n[n.length-1]+=' ',n=n.length>1?this.parse(n.join("\n")):this.parseInline(n[0])),t+='
    1. '+n+"
    2. ",e+=1;t+="
    "}return t},t.prototype.parse=function(t,e,n){var r,s,l,i,o,a,h,p,u,f,k,m,g;for(null==e&&(e=!1),null==n&&(n=0),p=[],s=this.parseBlock(t,p),o="",e&&1===s.length&&"normal"===s[0][0]&&(s[0][3]=!0),a=0,h=s.length;a=0&&s<10;)t=o(n(this.holders),r(this.holders),t),s+=1;return e&&(this.holders={}),t},t.prototype.markLine=function(t,e){return null==e&&(e=-1),this.line?(e=e<0?t:e,''):""},t.prototype.markLines=function(t,e){var n,r;return n=-1,this.line?t.map((r=this,function(t){return n+=1,r.markLine(e+n)+t})):t},t.prototype.optimizeLines=function(t){var n,r;return n=0,r=new RegExp('class="line" data\\-start="([0-9]+)" data\\-end="([0-9]+)" (data\\-id="'+this.uniqid+'")',"g"),this.line?t.replace(r,function(){var t,r;return t=1<=arguments.length?e.call(arguments,0):[],r=n!==parseInt(t[1])?'class="line" data-start="'+n+'" data-start-original="'+t[1]+'" data-end="'+t[2]+'" '+t[3]:t[0],n=1+parseInt(t[2]),r}):t},t.prototype.parseInline=function(t,n,r,i){var a,c;return null==n&&(n=""),null==r&&(r=!0),null==i&&(i=!0),t=this.call("beforeParseInline",t),t=t.replace(/(^|[^\\])(`+)(.+?)\2/gm,(c=this,function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],t[1]+c.makeHolder(""+s(t[3])+"")})),t=t.replace(/(^|[^\\])(\$+)(.+?)\2/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+t.makeHolder(n[2]+s(n[3])+n[2])}}(this)),t=t.replace(/\\(.)/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],l=r[1].match(/^[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]$/)?"":"\\",n=s(r[1]),n=n.replace(/\$/g,"$"),t.makeHolder(l+n)}}(this)),t=t.replace(/<(https?:\/\/.+)>/gi,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],s=t.cleanUrl(r[1]),n=t.call("parseLink",r[1]),t.makeHolder(''+n+"")}}(this)),t=t.replace(/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/gi,function(t){return function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],t.html||("|"+t.commonWhiteList+"|"+n+"|").indexOf("|"+r[2].toLowerCase()+"|")>=0?t.makeHolder(r[0]):t.makeHolder(s(r[0]))}}(this)),this.html&&(t=t.replace(//g,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],t.makeHolder(n[0])}}(this))),t=o(["<",">"],["<",">"],t),t=t.replace(/\[\^((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r;return r=1<=arguments.length?e.call(arguments,0):[],n=t.footnotes.indexOf(r[1]),n<0&&(n=t.footnotes.length+1,t.footnotes.push(t.parseInline(r[1],"",!1))),t.makeHolder(''+n+"")}}(this)),t=t.replace(/!\[((?:[^\]]|\\\]|\\\[)*?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],n=s(t.escapeBracket(r[1])),l=t.escapeBracket(r[2]),l=t.cleanUrl(l),t.makeHolder(''+n+'')}}(this)),t=t.replace(/!\[((?:[^\]]|\\\]|\\\[)*?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r,l;return r=1<=arguments.length?e.call(arguments,0):[],n=s(t.escapeBracket(r[1])),l=null!=t.definitions[r[2]]?''+n+'':n,t.makeHolder(l)}}(this)),t=t.replace(/\[((?:[^\]]|\\\]|\\\[)+?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],n=t.parseInline(t.escapeBracket(r[1]),"",!1,!1),s=t.escapeBracket(r[2]),s=t.cleanUrl(s),t.makeHolder(''+n+"")}}(this)),t=t.replace(/\[((?:[^\]]|\\\]|\\\[)+?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g,function(t){return function(){var n,r,s;return r=1<=arguments.length?e.call(arguments,0):[],n=t.parseInline(t.escapeBracket(r[1]),"",!1,!1),s=null!=t.definitions[r[2]]?''+n+"":n,t.makeHolder(s)}}(this)),t=this.parseInlineCallback(t),t=t.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/gi,'$1'),i&&(a=new RegExp('(^|[^"])((https?):['+l+'_0-9-\\./%#!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)($|[^"])',"ig"),t=t.replace(a,function(t){return function(){var n,r;return r=1<=arguments.length?e.call(arguments,0):[],n=t.call("parseLink",r[2]),r[1]+''+n+""+r[4]}}(this))),t=this.call("afterParseInlineBeforeRelease",t),t=this.releaseHolder(t,r),t=this.call("afterParseInline",t),t},t.prototype.parseInlineCallback=function(t){var n;return t=t.replace(/(\*{3})((?:.|\r)+?)\1/gm,(n=this,function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],""+n.parseInlineCallback(t[2])+""})),t=t.replace(/(\*{2})((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t=t.replace(/(\*)((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t=t.replace(/(\s+|^)(_{3})((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(\s+|^)(_{2})((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(\s+|^)(_)((?:.|\r)+?)\2(\s+|$)/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],n[1]+""+t.parseInlineCallback(n[3])+""+n[4]}}(this)),t=t.replace(/(~{2})((?:.|\r)+?)\1/gm,function(t){return function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],""+t.parseInlineCallback(n[2])+""}}(this)),t},t.prototype.parseBlock=function(t,e){var r,s,l,i,o,a,c,h,p,u,f,k,m;for(f=t.split("\n"),s=0,o=f.length;st[3])return r.empty=0,this.setBlock(e),!1;if(n.match(/^\s*$/)&&0===r.empty)return r.empty+=1,this.setBlock(e),!1}return!(s=n.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))||(l=s[1].length,r.empty=0,this.isBlock("list")?this.setBlock(e,l):this.startBlock("list",e,l),!1)},t.prototype.parseBlockCode=function(t,e,n){var r,s,l;return(s=n.match(/^(\s*)(~{3,}|`{3,})([^`~]*)$/i))?(this.isBlock("code")?(r=t[3][2],r?this.combineBlock().setBlock(e):this.setBlock(e).endBlock()):(r=!1,this.isBlock("list")&&(l=t[3],r=l>0&&s[1].length>=l||s[1].length>l),this.startBlock("code",e,[s[1],s[3],r])),!1):!this.isBlock("code")||(this.setBlock(e),!1)},t.prototype.parseBlockShtml=function(t,e,n,r){return n.match(/^(\s*)!!!(\s*)$/)?(this.isBlock("shtml")?this.setBlock(e).endBlock():this.startBlock("shtml",e),!1):!this.isBlock("shtml")||(this.setBlock(e),!1)},t.prototype.parseBlockAhtml=function(t,e,n,r){var s,l,i,o,a;if(this.html)if(l=new RegExp("^\\s*<("+this.blockHtmlTags+")(\\s+[^>]*)?>","i"),a=n.match(l)){if(this.isBlock("ahtml"))return this.setBlock(e),!1;if(void 0===a[2]||"/"!==a[2]){for(this.startBlock("ahtml",e),s=new RegExp("\\s*<("+this.blockHtmlTags+")(\\s+[^>]*)?>","ig");o=s.exec(n),o;)i=o[1];return 0<=n.indexOf("")?this.endBlock():r.html=i,!1}}else{if(r.html&&0<=n.indexOf(""))return this.setBlock(e).endBlock(),r.html=!1,!1;if(this.isBlock("ahtml"))return this.setBlock(e),!1;if(a=n.match(/^\s*\s*$/))return this.startBlock("ahtml",e).endBlock(),!1}return!0},t.prototype.parseBlockMath=function(t,e,n){return n.match(/^(\s*)\$\$(\s*)$/)?(this.isBlock("math")?this.setBlock(e).endBlock():this.startBlock("math",e),!1):!this.isBlock("math")||(this.setBlock(e),!1)},t.prototype.parseBlockPre=function(t,e,n,r){return n.match(/^ {4}/)?(this.isBlock("pre")?this.setBlock(e):this.startBlock("pre",e),!1):!this.isBlock("pre")||!n.match(/^\s*$/)||(this.setBlock(e),!1)},t.prototype.parseBlockHtml=function(t,e,n,r){var s,l;return(s=n.match(new RegExp("^\\s*<("+r.special+")(\\s+[^>]*)?>","i")))?(l=s[1].toLowerCase(),this.isBlock("html",l)||this.isBlock("pre")||this.startBlock("html",e,l),!1):(s=n.match(new RegExp("\\s*$","i")))?(l=s[1].toLowerCase(),this.isBlock("html",l)&&this.setBlock(e).endBlock(),!1):!this.isBlock("html")||(this.setBlock(e),!1)},t.prototype.parseBlockFootnote=function(t,e,n){var r,s;return!(r=n.match(/^\[\^((?:[^\]]|\\\]|\\\[)+?)\]:/))||(s=r[0].length-1,this.startBlock("footnote",e,[s,r[1]]),!1)},t.prototype.parseBlockDefinition=function(t,e,n){var r;return!(r=n.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/))||(this.definitions[r[1]]=this.cleanUrl(r[2]),this.startBlock("definition",e).endBlock(),!1)},t.prototype.parseBlockQuote=function(t,e,n){var r;return!(r=n.match(/^(\s*)>/))||(this.isBlock("list")&&r[1].length>0?this.setBlock(e):this.isBlock("quote")?this.setBlock(e):this.startBlock("quote",e),!1)},t.prototype.parseBlockTable=function(t,e,n,r,s){var l,i,o,a,c,h,p,u;if(h=n.match(/^((?:(?:(?:\||\+)(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:[ :]*\-+[ :]*)(?:\||\+)(?:[ :]*\-+[ :]*))|(?:(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-+[ :]*)))+)$/)){if(this.isBlock("table"))t[3][0].push(t[3][2]),t[3][2]+=1,this.setBlock(e,t[3]);else{for(o=0,null==t||"normal"!==t[0]||s[t[2]].match(/^\s*$/)?this.startBlock("table",e):(o=1,this.backBlock(1,"table")),"|"===h[1][0]&&(h[1]=h[1].substring(1),"|"===h[1][h[1].length-1]&&(h[1]=h[1].substring(0,h[1].length-1))),u=h[1].split(/\+|\|/),i=[],a=0,c=u.length;a=t[3][0]?this.setBlock(e):this.startBlock("normal",e)):this.isBlock("table")?0<=n.indexOf("|")?(t[3][2]+=1,this.setBlock(e,t[3])):this.startBlock("normal",e):this.isBlock("quote")?n.match(/^(\s*)$/)?this.startBlock("normal",e):this.setBlock(e):null==t||"normal"!==t[0]?this.startBlock("normal",e):this.setBlock(e),!0},t.prototype.optimizeBlocks=function(t,e){var n,r,s,l,i,o,a,c,h,p,u,f;for(r=t.slice(0),o=e.slice(0),r=this.call("beforeOptimizeBlocks",r,o),i=0;null!=r[i];)a=!1,n=r[i],h=null!=r[i-1]?r[i-1]:null,c=null!=r[i+1]?r[i+1]:null,u=n[0],s=n[1],p=n[2],"pre"===u&&(l=o.slice(n[1],n[2]+1).reduce(function(t,e){return e.match(/^\s*$/)&&t},!0),l&&(n[0]=u="normal")),"normal"===u&&(f=["list","quote"],s===p&&o[s].match(/^\s*$/)&&null!=h&&null!=c&&h[0]===c[0]&&f.indexOf(h[0])>=0&&(r[i-1]=[h[0],h[1],c[2],null],r.splice(i,2),a=!0)),a||(i+=1);return this.call("afterOptimizeBlocks",r,o)},t.prototype.parseCode=function(t,e,n){var r,l,i,o,c,h;return r=e[0],o=e[1],o=a(o),l=r.length,o.match(/^[_a-z0-9-\+\#\:\.]+$/i)?(e=o.split(":"),e.length>1&&(o=e[0],c=e[1],o=a(o),c=a(c))):o=null,i=!0,t=t.slice(1,-1).map(function(t){return t=t.replace(new RegExp("/^[ ]{"+l+"}/"),""),i&&!t.match(/^\s*$/)&&(i=!1),s(t)}),h=this.markLines(t,n+1).join("\n"),i?"":"
    "+h+"
    "},t.prototype.parsePre=function(t,e,n){var r;return t=t.map(function(t){return s(t.substring(4))}),r=this.markLines(t,n).join("\n"),r.match(/^\s*$/)?"":"
    "+r+"
    "},t.prototype.parseAhtml=function(t,e,n){return a(this.markLines(t,n).join("\n"))},t.prototype.parseShtml=function(t,e,n){return a(this.markLines(t.slice(1,-1),n+1).join("\n"))},t.prototype.parseMath=function(t,e,n,r){return"

    "+this.markLine(n,r)+s(t.join("\n"))+"

    "},t.prototype.parseSh=function(t,e,n,r){var s;return s=this.markLine(n,r)+this.parseInline(a(t[0],"# ")),s.match(/^\s*$/)?"":""+s+""},t.prototype.parseMh=function(t,e,n,r){return this.parseSh(t,e,n,r)},t.prototype.parseQuote=function(t,e,n){var r;return t=t.map(function(t){return t.replace(/^\s*> ?/,"")}),r=t.join("\n"),r.match(/^\s*$/)?"":"
    "+this.parse(r,!0,n)+"
    "},t.prototype.parseList=function(t,e,n){var r,s,l,i,o,a,c,h,p,u,f,k,m,g,d,B,b,y,v,$;for(s="",m=99999,b=99999,r=!1,B=!1,d=[],i=l=0,p=t.length;l0&&(b=Math.min(y,b),B=!0),d.push([y,$,f,k[4]])):(d.push(f),(k=f.match(/^(\s*)/))&&(y=k[1].length,y>0&&(b=Math.min(y,b),B=!0)));for(m=r?m:0,b=B?b:m,a="",c=[],h=0,i=o=0,u=d.length;o0&&(s+="
  • "+this.parse(c.join("\n"),!0,n+h)+"
  • "),a!==$&&(a&&(s+=""),s+="<"+$+">"),h=i,c=[v],a=$)):c.push(g.replace(new RegExp("^\\s{"+b+"}"),""));return c.length>0&&(s+="
  • "+this.parse(c.join("\n"),!0,n+h)+"
  • "),s},t.prototype.parseTable=function(t,e,n){var r,s,l,i,o,c,h,p,u,f,k,m,g,d,B,b,y,v,$,x;for(h=e[0],r=e[1],o=h.length>0&&h.reduce(function(t,e){return e+t})>0,c="",s=!o||null,b=!1,u=p=0,m=t.length;p0?(k+=1,i[k]=[null!=i[k]?i[k][0]+1:1,y]):null!=i[k]?i[k][0]+=1:i[0]=[1,y];for(u in o?c+="":s&&(c+=""),c+="1&&(c+=' colspan="'+B+'"'),null!=r[u]&&"none"!==r[u]&&(c+=' align="'+r[u]+'"'),c+=">"+this.parseInline(x)+"";c+="",o?c+="":s&&(s=!1)}return null!==s&&(c+=""),c+"
    "},t.prototype.parseHr=function(t,e,n){return this.line?'
    ':"
    "},t.prototype.parseNormal=function(t,e,n){var r,s,l;return null==e&&(e=!1),r=0,t=t.map((l=this,function(t){return t=l.parseInline(t),t.match(/^\s*$/)||(t=l.markLine(n+r)+t),r+=1,t})),s=a(t.join("\n")),s=s.replace(/(\n\s*){2,}/g,"

    "),s=s.replace(/\n/g,"
    "),s.match(/^\s*$/)?"":e?s:"

    "+s+"

    "},t.prototype.parseFootnote=function(t,e){var n,r;return e[0],r=e[1],n=this.footnotes.indexOf(r),n>=0&&(t=t.slice(0),t[0]=t[0].replace(/^\[\^((?:[^\]]|\]|\[)+?)\]:/,""),this.footnotes[n]=t),""},t.prototype.parseDefinition=function(){return""},t.prototype.parseHtml=function(t,e,n){var r;return t=t.map((r=this,function(t){return r.parseInline(t,null!=r.specialWhiteList[e]?r.specialWhiteList[e]:"")})),this.markLines(t,n).join("\n")},t.prototype.cleanUrl=function(t){var e,n,r;return n=new RegExp("^\\s*((http|https|ftp|mailto):["+l+"_a-z0-9-:\\.\\*/%#;!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)","i"),r=new RegExp("^\\s*(["+l+"_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)","i"),(e=t.match(n))?e[1]:(e=t.match(r))?e[1]:"#"},t.prototype.escapeBracket=function(t){return o(["\\[","\\]","\\(","\\)"],["[","]","(",")"],t)},t.prototype.startBlock=function(t,e,n){return null==n&&(n=null),this.pos+=1,this.current=t,this.blocks.push([t,e,e,n]),this},t.prototype.endBlock=function(){return this.current="normal",this},t.prototype.isBlock=function(t,e){return null==e&&(e=null),this.current===t&&(null===e||this.blocks[this.pos][3]===e)},t.prototype.getBlock=function(){return null!=this.blocks[this.pos]?this.blocks[this.pos]:null},t.prototype.setBlock=function(t,e){return null==t&&(t=null),null==e&&(e=null),null!==t&&(this.blocks[this.pos][2]=t),null!==e&&(this.blocks[this.pos][3]=e),this},t.prototype.backBlock=function(t,e,n){var r,s;return null==n&&(n=null),this.pos<0?this.startBlock(e,0,n):(s=this.blocks[this.pos][2],this.blocks[this.pos][2]=s-t,r=[e,s-t+1,s,n],this.blocks[this.pos][1]<=this.blocks[this.pos][2]?(this.pos+=1,this.blocks.push(r)):this.blocks[this.pos]=r,this.current=e,this)},t.prototype.combineBlock=function(){var t,e;return this.pos<1?this:(e=this.blocks[this.pos-1].slice(0),t=this.blocks[this.pos].slice(0),e[2]=t[2],this.blocks[this.pos-1]=e,this.current=e[0],this.blocks=this.blocks.slice(0,-1),this.pos-=1,this)},t}(),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.HyperDown=t)}).call(this); \ No newline at end of file diff --git a/typecho/write/js/joe.write.chunk.js b/typecho/write/js/joe.write.chunk.js index 3ecf72c..f943cf9 100644 --- a/typecho/write/js/joe.write.chunk.js +++ b/typecho/write/js/joe.write.chunk.js @@ -1,4 +1,4 @@ -!function(){"use strict";let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;te)return r[t-1]<=e}(e))n+=d(e),t=e;else{if(!s(e))break;{let t=0,e=n-2;for(;0<=e&&s(c(i,e));)t++,e-=2;if(t%2==0)break;n+=2}}}return n}function a(t,e){for(;0this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){var n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),m.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){var i=[];return this.decompose(t,e,i,0),m.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=new v(this),i=new v(t);for(;;){if(e.next(),i.next(),e.lineBreak!=i.lineBreak||e.done!=i.done||e.value!=i.value)return!1;if(e.done)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new i(this,t,e)}toString(){return this.sliceString(0)}toJSON(){var t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new g(t):m.from(g.split(t,[])):u.empty}}"undefined"!=typeof Symbol&&(u.prototype[Symbol.iterator]=function(){return this.iter()});class g extends u{constructor(t,e=function(t){let e=-1;for(var i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let t=0;;t++){var s=this.text[t],o=r+s.length;if(e<=(i?n:o))return new w(r,o,n,s);r=o+1,n++}}decompose(i,t,n,r){i=i<=0&&t>=this.length?this:new g(p(this.text,i,t),Math.min(t,this.length)-Math.max(0,i));if(1&r){let t=n.pop(),e=f(i.text,t.text.slice(),0,i.length);e.length<=32?n.push(new g(e,t.length+i.length)):(r=e.length>>1,n.push(new g(e.slice(0,r)),new g(e.slice(r))))}else n.push(i)}replace(t,e,i){if(!(i instanceof g))return super.replace(t,e,i);var n=f(this.text,f(i.text,p(this.text,0,t)),e),t=this.length+i.length-(e-t);return n.length<=32?new g(n,t):m.from(g.split(n,[]),t)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;i<=s&&nr&&n&&(a+=o),ri&&(a+=t.slice(Math.max(0,r-i),s-i)),i=e+1}return a}flatten(t){for(var e of this.text)t.push(e)}static split(t,e){let i=[],n=-1;for(var r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new g(i,n)),i=[],n=-1);return-1=n&&(h=a&((n<=r?1:0)|(s<=e?2:0)),n>=r&&e<=s&&!h?o.push(t):t.decompose(r-n,s-n,o,h)),n=e+1}}replace(r,s,o){if(o.lines=n&&s<=e){var a=t.replace(r-n,s-n,o),h=this.lines-t.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let t=this.children.slice();return t[i]=a,new m(t,this.length-(s-r)+o.length)}return super.replace(n,e,a)}n=e+1}return super.replace(r,s,o)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;ir&&i&&(a+=o),rn&&(a+=t.sliceString(r-n,s-n,o)),n=e+1}return a}flatten(t){for(var e of this.children)e.flatten(t)}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(var n of t)i+=n.lines;if(i<32){var r,s=[];for(r of t)r.flatten(s);return new g(s,e)}let o=Math.max(32,i>>5),a=o<<1,h=o>>1,l=[],c=0,d=-1,u=[];function f(){0!=c&&(l.push(1==u.length?u[0]:m.from(u,d)),d=-1,c=u.length=0)}for(var p of t)!function t(e){let i;if(e.lines>a&&e instanceof m)for(var n of e.children)t(n);else e.lines>h&&(c>h||!c)?(f(),l.push(e)):e instanceof g&&c&&(i=u[u.length-1])instanceof g&&e.lines+i.lines<=32?(c+=e.lines,d+=e.length+1,u[u.length-1]=new g(i.text.concat(e.text),i.length+1+e.length)):(c+e.lines>o&&f(),c+=e.lines,d+=e.length+1,u.push(e))}(p);return f(),1==l.length?l[0]:new m(l,e)}}function f(s,o,a=0,h=1e9){for(let i=0,n=0,r=!0;nMath.max(0,n))return this.value=0==n?t:0t.length?n-=t.length:(this.nodes.push(t),this.offsets.push(0this.limit&&(this.value=0r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(i,n=i){for(let t=0,e=0;t"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new x(t)}}class k extends x{constructor(t,e){super(t),this.inserted=e}apply(s){if(this.length!=s.length)throw new RangeError("Applying change set to a document with the wrong length");return T(this,(t,e,i,n,r)=>s=s.replace(i,i+(e-t),r),!1),s}mapDesc(t,e=!1){return D(this,t,e,!0)}invert(i){let n=this.sections.slice(),r=[];for(let t=0,e=0;t>1;r.length>1].toJSON()))}return n}static of(t,s,o){let a=[],h=[],l=0,i=null;function c(t=!1){if(t||a.length){ll&&M(a,t-l,-1),M(a,e-t,n),C(h,a,r),l=e)}}(t),c(!i),i}static empty(t){return new k(t?[t,-1]:[],[])}static fromJSON(i){if(!Array.isArray(i))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let e=0;ee&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==t.length)n.push(t[0],0);else{for(;r.length>1;if(n>1])),!(c||a==h.sections.length||h.sections[a+1]<0);)n=h.sections[a++],r=h.sections[a++];l(s,t,o,e,i),s=t,o=e}}}function D(t,e,r,i=!1){var s=[],o=i?[]:null;let a=new O(t),h=new O(e);for(let i=0,n=0;;)if(-1==a.ins)i+=a.len,a.next();else if(-1==h.ins&&nn&&!a.done&&i+a.leni&&n+h.lenh||0<=o.ins&&o.len>h)&&(t||l>1;return e>=t.length?u.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?u.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class L{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){var t=3&this.flags;return 3==t?null:t}get goalColumn(){var t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){var i=t.mapPos(this.from,e),e=t.mapPos(this.to,e);return i==this.from&&e==this.to?this:new L(i,e,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return B.range(t,e);e=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return B.range(this.anchor,e)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return B.range(t.anchor,t.head)}}class B{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(e,i=-1){return e.empty?this:B.create(this.ranges.map(t=>t.map(e,i)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;tt.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new B(t.ranges.map(t=>L.fromJSON(t)),t.main)}static single(t,e=t){return new B([B.range(t,e)],0)}static create(i,n=0){if(0==i.length)throw new RangeError("A selection needs at least one range");for(let t=0,e=0;et.from-e.from),i=e.indexOf(t);for(let t=1;tr.head?B.range(s,n):B.range(n,s)))}return new B(e,i)}(i.slice(),n);t=r.to}return new B(i,n)}static cursor(t,e=0,i,n){return new L(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i){i=(null!=i?i:33554431)<<5;return ee)throw new RangeError("Selection points outside of document")}let H=0;class P{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.extensions=r,this.id=H++,this.default=t([])}static define(t={}){return new P(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:_),!!t.static,t.enables)}of(t){return new N([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new N(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new N(t,this,2,e)}from(e,i){return i=i||(t=>t),this.compute([e],t=>i(t.field(e)))}}function _(t,i){return t==i||t.length==i.length&&t.every((t,e)=>t===i[e])}class N{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=H++}dynamicSlot(t){var e,i;let n=this.value,r=this.facet.compareInput,s=t[this.id]>>1,o=2==this.type,a=!1,h=!1,l=[];for(i of this.dependencies)"doc"==i?a=!0:"selection"==i?h=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&l.push(t[i.id]);return(e,t)=>{if(!t||t.reconfigured)return e.values[s]=n(e),1;if(!(a&&t.docChanged||h&&(t.docChanged||t.selection)||l.some(t=>0<(1&J(e,t)))))return 0;var i=n(e),t=t.startState.values[s];return(o?function(e,i,n){if(e.length!=i.length)return!1;for(let t=0;tt===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(R).find(t=>t.field==this);return((null===e||void 0===e?void 0:e.create)||this.createF)(t)}slot(t){let o=t[this.id]>>1;return(t,e)=>{if(!e)return t.values[o]=this.create(t),1;let i,n=0;var r,s;e.reconfigured?(r=e.startState,s=this.id,s=null==(s=r.config.address[s])?null:s>>1,i=null==s?this.create(e.startState):e.startState.values[s],n=1):i=e.startState.values[o];e=this.updateF(i,e);return n||this.compareF(i,e)||(n=1),n&&(t.values[o]=e),n}}init(t){return[this,R.of({field:this,create:t})]}get extension(){return this}}const V={fallback:3,default:2,extend:1,override:0};function t(e){return t=>new W(t,e)}const I={fallback:t(V.fallback),default:t(V.default),extend:t(V.extend),override:t(V.override)};class W{constructor(t,e){this.inner=t,this.prec=e}}class F{of(t){return new q(this,t)}reconfigure(t){return F.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class q{constructor(t,e){this.compartment=t,this.inner=e}}class j{constructor(t,e,i,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,n){let i=[],r=Object.create(null);var s,o,a=new Map;for(s of function(t,a,h){let l=[[],[],[],[]],c=new Map;return function t(e,i){var n=c.get(e);if(null!=n){if(i<=n)return;var r=l[n].indexOf(e);-1t.concat(e))}(t,e,a))(s instanceof z?i:r[s.facet.id]||(r[s.facet.id]=[])).push(s);let h=Object.create(null),l=[],c=[];for(let e of i)h[e.id]=c.length<<1,c.push(t=>e.slot(t));for(o in r){let i=r[o],e=i[0].facet;if(i.every(t=>0==t.type)){h[e.id]=l.length<<1|1;let t=e.combine(i.map(t=>t.value));var d=n?n.config.address[e.id]:null;null!=d&&(d=U(n,d),e.compare(t,d)&&(t=d)),l.push(t)}else{for(let e of i)0==e.type?(h[e.id]=l.length<<1|1,l.push(e.value)):(h[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));h[e.id]=c.length<<1,c.push(t=>function(e,l,t){let c=t.map(t=>e[t.id]),d=t.map(t=>t.type),u=c.filter(t=>!(1&t)),f=e[l.id]>>1;return(e,t)=>{var i,n=t?t.reconfigured?t.startState.config.address[l.id]:f<<1:null;let r=null==n;for(i of u)1&J(e,i)&&(r=!0);if(!r)return 0;let s=[];for(let t=0;tt(h)),h,l)}}function J(t,e){if(1&e)return 2;var i=e>>1,e=t.status[i];if(4==e)throw new Error("Cyclic dependency between fields and/or facets");if(2&e)return e;t.status[i]=4;e=t.config.dynamicSlots[i](t,t.applying);return t.status[i]=2|e}function U(t,e){return(1&e?t.config.staticValues:t.values)[e>>1]}const K=P.define(),G=P.define({combine:t=>t.some(t=>t),static:!0}),X=P.define({combine:t=>t.length?t[0]:void 0,static:!0}),Y=P.define(),Q=P.define(),Z=P.define();class tt{constructor(t,e){this.type=t,this.value=e}static define(){return new et}}class et{of(t){return new tt(this,t)}}class it{constructor(t){this.map=t}of(t){return new nt(this,t)}}class nt{constructor(t,e){this.type=t,this.value=e}map(t){t=this.type.map(this.value,t);return void 0===t?void 0:t==this.value?this:new nt(this.type,t)}is(t){return this.type==t}static define(t={}){return new it(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(var n of t){n=n.map(e);n&&i.push(n)}return i}}nt.reconfigure=nt.define(),nt.appendConfig=nt.define();class rt{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&E(i,e.newLength),r.some(t=>t.type==rt.time)||(this.annotations=r.concat(rt.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(var e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}}function st(t,e,i){let n,r,s;return s=i?(n=e.changes,r=k.empty(e.changes.length),t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),t.changes.compose(n)),{changes:s,selection:e.selection?e.selection.map(r):null===(i=t.selection)||void 0===i?void 0:i.map(n),effects:nt.mapEffects(t.effects,n).concat(nt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ot(t,e,i){var n=e.selection;return{changes:e.changes instanceof k?e.changes:k.of(e.changes||[],i,t.facet(X)),selection:n&&(n instanceof B?n:B.single(n.anchor,n.head)),effects:lt(e.effects),annotations:lt(e.annotations),scrollIntoView:!!e.scrollIntoView}}function at(e,i,n){let r=ot(e,i.length?i[0]:{},e.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let t=1;t=r[i]))t=r[i++],e=r[i++];else{if(!(n{if(!/\S/.test(e))return ct.Space;if(function(i){if(ut)return ut.test(i);for(let e=0;enull),n)for(var r in t.address){var s=t.address[r],r=n.startState.config.address[r];null!=r&&0==(1&s)&&(this.values[s>>1]=U(n.startState,r))}(this.applying=n)&&(n._state=this);for(let t=0;tn.set(e,t)),e=null),n.set(r.value.compartment,r.value.extension)):r.is(nt.reconfigure)?(e=null,i=r.value):r.is(nt.appendConfig)&&(e=null,i=lt(i).concat(r.value));new pt(e||j.resolve(i,n,this),t.newDoc,t.newSelection,t)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:B.cursor(t.from+e.length)}))}changeByRange(r){var s=this.selection,t=r(s.ranges[0]);let o=this.changes(t.changes),a=[t.range],h=lt(t.effects);for(let n=1;ne.spec.fromJSON(i,t)))}return pt.create({doc:t.doc,selection:B.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=j.resolve(t.extensions||[],new Map);var i=t.doc instanceof u?t.doc:u.of((t.doc||"").split(e.staticFacet(pt.lineSeparator)||y));let n=t.selection?t.selection instanceof B?t.selection:B.single(t.selection.anchor,t.selection.head):B.single(0);return E(n,i.length),e.staticFacet(G)||(n=n.asSingle()),new pt(e,i,n)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||"\n"}phrase(t){for(var e of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e){let i=[];for(var n of this.facet(K))for(var r of n(this,e))Object.prototype.hasOwnProperty.call(r,t)&&i.push(r[t]);return i}charCategorizer(t){return ft(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-i,o=t-i;for(;0t.length?t[0]:4}),pt.lineSeparator=X,pt.phrases=P.define(),pt.languageData=K,pt.changeFilter=Y,pt.transactionFilter=Q,pt.transactionExtender=Z,F.reconfigure=nt.define();const mt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),vt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class yt{constructor(t,e){this.rules=[];let{finish:c}=e||{};function d(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(var i in t)!function t(i,e,n,r){let s=[],o=/^@(\w+)\b/.exec(i[0]),a=o&&"keyframes"==o[1];if(o&&null==e)return n.push(i[0]+";");for(var h in e){var l=e[h];if(/&/.test(h))t(h.split(/,\s*/).map(e=>i.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),l,n);else if(l&&"object"==typeof l){if(!o)throw new RangeError("The value of a property ("+h+") should be a primitive value.");t(d(h),l,s,a)}else null!=l&&s.push(h.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+l+";")}(s.length||a)&&n.push((!c||o||r?i:i.map(c)).join(", ")+" {"+s.join(" ")+"}")}(d(i),t[i],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=wt[mt]||1;return wt[mt]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[vt]||new xt(t)).mount(Array.isArray(e)?e:[e])}}let bt=null;class xt{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(bt)return e.adoptedStyleSheets=[bt.sheet].concat(e.adoptedStyleSheets),e[vt]=bt;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),bt=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[vt]=this}mount(n){let r=this.sheet,s=0,o=0;for(let i=0;i>1,h=o[a]-i||(n<0?this.value[a].startSide:this.value[a].endSide)-r;if(a==t)return 0<=h?t:e;0<=h?e=a:t=1+a}}between(i,n,r,s){for(let t=this.findIndex(n,-1),e=this.findIndex(r,1,void 0,t);tr||n==r&&0this.chunkEnd(o.chunkIndex)||ro.to||r500<=t.maxPoint||t!=Ct.empty&&i.indexOf(t)<0&&t.maxPoint>=r),o=i.filter(t=>500<=t.maxPoint||t!=Ct.empty&&e.indexOf(t)<0&&t.maxPoint>=r),a=function(t,e){let i=new Map;for(var n of t)for(let t=0;tEt(h,t,l,e,i,n)),t.empty&&0==t.length&&Et(h,0,l,0,0,n)}static spans(t,e,i,n,r=-1){let s=new Bt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){var h=Math.min(s.to,i);if(s.point?(n.point(o,h,s.point,s.activeForPoint(s.to),a),a=s.openEnd(h)+(s.to>h?1:0)):h>o&&(n.span(o,h,s.active,a),a=s.openEnd(h)),s.to>i)break;o=s.to,s.next()}return a}static of(t,e=!1){let i=new Tt;for(var n of t instanceof St?[t]:e?t.slice().sort(At):t)i.add(n.from,n.to,n.value);return i.finish()}}Ct.empty=new Ct([],[],null,-1),Ct.empty.nextLayer=Ct.empty;class Tt{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(t){this.chunks.push(new Mt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(t,e,i)}addInner(t,e,i){var n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);var i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Ct.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;t=new Ct(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,t}}class Dt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex=this.minPoint)break}}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class Ot{constructor(t){this.heap=t}static from(i,n=null,r=-1){let s=[];for(let e=0;e=r&&s.push(new Dt(t,n,r,e));return 1==s.length?s[0]:new Ot(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(var i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(var i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(n,r){for(let i=n[r];;){let t=1+(r<<1);if(t>=n.length)break;let e=n[t];if(t+1e){this.to=this.activeTo[t],this.endSide=this.active[t].endSide;break}this.removeActive(t),i&&Ht(i,t)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}t=this.cursor.value;if(t.point){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.frome&&this.forward(this.to,this.endSide);break}this.addActive(i),this.cursor.next()}}if(i){let t=0;for(;tthis.pointRank);t++)(this.activeTo[t]>e||this.activeTo[t]==e&&this.active[t].endSide>this.point.endSide)&&i.push(this.active[t]);return i}openEnd(t){let e=0;for(;et;)e++;return e}}function Et(t,e,i,n,r,s){t.goto(e),i.goto(n);var o=n+r;let a=n,h=n-e;for(;;){var l=t.to+h-i.to||t.endSide-i.endSide,c=l<0?t.to+h:i.to,d=Math.min(c,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))||s.comparePoint(a,d,t.point,i.point):d>a&&!function(e,i){if(e.length!=i.length)return!1;for(let t=0;t=i;t--)e[t+1]=e[t];e[i]=t}function _t(e,i){let n=-1,r=1e9;for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},$t="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),zt="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Vt="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),It="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ft=$t&&(It||+$t[1]<57)||Vt&&It,qt=0;qt<10;qt++)Nt[48+qt]=Nt[96+qt]=String(qt);for(qt=1;qt<=24;qt++)Nt[qt+111]="F"+qt;for(var jt,qt=65;qt<=90;qt++)Nt[qt]=String.fromCharCode(qt+32),Rt[qt]=String.fromCharCode(qt);for(jt in Nt)Rt.hasOwnProperty(jt)||(Rt[jt]=Nt[jt]);var[Jt,Ut]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],Kt=/Edge\/(\d+)/.exec(Jt.userAgent),Gt=/MSIE \d/.test(Jt.userAgent),Xt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Jt.userAgent),Yt=!!(Gt||Xt||Kt),Qt=!Yt&&/gecko\/(\d+)/i.test(Jt.userAgent),Zt=!Yt&&/Chrome\/(\d+)/.exec(Jt.userAgent),te="webkitFontSmoothing"in Ut.documentElement.style,ee=!Yt&&/Apple Computer/.test(Jt.vendor),ie={mac:/Mac/.test(Jt.platform),ie:Yt,ie_version:Gt?Ut.documentMode||6:Xt?+Xt[1]:Kt?+Kt[1]:0,gecko:Qt,gecko_version:Qt?+(/Firefox\/(\d+)/.exec(Jt.userAgent)||[0,0])[1]:0,chrome:!!Zt,chrome_version:Zt?+Zt[1]:0,ios:ee&&(/Mobile\/\w+/.test(Jt.userAgent)||2this.pos||t==this.pos&&(0t.width)||a),o?ue(a,o<0):a}class De extends Ae{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||De)(t,e,i)}slice(t){return De.create(this.widget,this.length-t,this.side)}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r){return!(i&&(!(i instanceof De&&this.widget.compare(i.widget))||0i&&st?i[r]=Math.max(i[r],e):i.push(t,e)}Ie.prototype.point=!0;class qe extends be{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof qe))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Le(this,t,e,i?i.children:je,r,s),!0}split(t){let e=new qe;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].slice(n),0),this.children[i].merge(n,this.children[i].length,null,0,0),i++);for(let t=i;t!t.length||t[0]});class ri{constructor(t,e){this.field=t,this.get=e}}class si{from(t){return new ri(this,t)}static define(){return new si}}si.decorations=si.define(),si.scrollMargins=si.define();let oi=0;const ai=P.define();class hi{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=ai.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:r}=e||{},s=[];if(n)for(var o of Array.isArray(n)?n:[n])s.push(o);return i&&s.push(li.from(t=>({plugin:t,handlers:i}))),r&&s.push(si.decorations.from(r)),new hi(oi++,t,s)}static fromClass(e,t){return hi.define(t=>new e(t),t)}}const li=si.define();class ci{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){for(var{field:i,get:n}of this.spec.fields)i==t&&e.push(n(this.value))}update(e){if(this.value){if(this.mustUpdate){var i=this.mustUpdate;if(this.mustUpdate=null,!this.value.update)return this;try{this.value.update(i)}catch(t){if(ii(i.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}return ci.dummy}}}else try{this.value=this.spec.create(e)}catch(t){return ii(e.state,t,"CodeMirror plugin crashed"),ci.dummy}return this}destroy(e){var t;if(null!==(t=this.value)&&void 0!==t&&t.destroy)try{this.value.destroy()}catch(t){ii(e.state,t,"CodeMirror plugin crashed")}}}ci.dummy=new ci(hi.define(()=>({})));const di=P.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),ui=P.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),fi=P.define(),pi=P.define();class gi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new gi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;0i.toA)){if(n.toAr.push(new gi(t,e,i,n))),this.changedRanges=r;i=t.hasFocus;i!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=i,this.flags|=1),this.docChanged&&(this.flags|=2)}get viewportChanged(){return 0<(4&this.flags)}get heightChanged(){return 0<(2&this.flags)}get geometryChanged(){return this.docChanged||0<(18&this.flags)}get focusChanged(){return 0<(1&this.flags)}get docChanged(){return this.transactions.some(t=>t.docChanged)}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class vi extends be{constructor(t){super(),this.view=t,this.compositionDeco=$e.none,this.decorations=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.setDOM(t.contentDOM),this.children=[new qe],this.children[0].setParent(this),this.updateInner([new gi(0,0,0,t.state.doc.length)],this.updateDeco(),0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;0ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=0),this.view.inputState.composing<0?this.compositionDeco=$e.none:t.transactions.length&&(this.compositionDeco=function(t,e){var i=ne(t.root),i=i.focusNode&&bi(i.focusNode,i.focusOffset,0);if(!i)return $e.none;let n=t.docView.nearest(i),r,s,o=i;if(n instanceof Ae){for(;n.parent instanceof Ae;)n=n.parent;r=n.posAtStart,s=r+n.length,o=n.dom}else{if(!(n instanceof qe))return $e.none;{for(;o.parentNode!=n.dom;)o=o.parentNode;let t=o.previousSibling;for(;t&&!be.get(t);)t=t.previousSibling;r=s=t?be.get(t).posAtEnd:n.posAtStart}}let a=e.mapPos(r,1),h=Math.max(a,e.mapPos(s,-1)),l=i.nodeValue,{state:c}=t;if(h-a"pointerselection"==t.annotation(rt.userEvent));return 0==this.dirty&&0==e.length&&!(12&t.flags)&&t.state.selection.main.from>=this.view.viewport.from&&t.state.selection.main.to<=this.view.viewport.to?(this.updateSelection(s,o),!1):(this.updateInner(e,a,t.startState.doc.length,s,o),!0)}updateInner(t,e,i,n=!1,r=!1){this.updateChildren(t,e,i),this.view.observer.ignore(()=>{this.dom.style.height=this.view.viewState.domHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";var t=ie.chrome?{node:ne(this.view.root).focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,null!=t&&t.written&&(n=!0),this.updateSelection(n,r),this.dom.style.height=""})}updateChildren(e,i,t){let n=this.childCursor(t);for(let t=e.length-1;;t--){var r=0<=t?e[t]:null;if(!r)break;var{fromA:s,toA:o,fromB:a,toB:h}=r,{content:l,breakAtStart:c,openStart:d,openEnd:r}=Ue.build(this.view.state.doc,a,h,i),{i:a,off:h}=n.findPos(o,1),{i:o,off:s}=n.findPos(s,-1);this.replaceRange(o,s,a,h,l,c,d,r)}}replaceRange(e,i,n,r,s,o,a,h){let l=this.children[e],c=s.length?s[s.length-1]:null;var d=c?c.breakAfter:o;if(e!=n||o||d||!(s.length<2)||!l.merge(i,r,s.length?c:null,0==i,a,h)){let t=this.children[n];for(rn.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new we(t,0),e=!0}let s=ne(this.root);!(e||!s.focusNode||ie.gecko&&i.empty&&xi(s.focusNode,s.focusOffset))&&ae(n.node,n.offset,s.anchorNode,s.anchorOffset)&&ae(r.node,r.offset,s.focusNode,s.focusOffset)||this.view.observer.ignore(()=>{var t,e;if(i.empty)ie.gecko&&(!(t=xi(n.node,n.offset))||3==t||(e=bi(n.node,n.offset,1==t?1:-1))&&(n=new we(e,1==t?0:e.nodeValue.length))),s.collapse(n.node,n.offset),null!=i.bidiLevel&&null!=s.cursorBidiLevel&&(s.cursorBidiLevel=i.bidiLevel);else if(s.extend)s.collapse(n.node,n.offset),s.extend(r.node,r.offset);else{let t=document.createRange();i.anchor>i.head&&([n,r]=[r,n]),t.setEnd(r.node,r.offset),t.setStart(n.node,n.offset),s.removeAllRanges(),s.addRange(t)}}),this.impreciseAnchor=n.precise?null:new we(s.anchorNode,s.anchorOffset),this.impreciseHead=r.precise?null:new we(s.focusNode,s.focusOffset)}}enforceCursorAssoc(){var t,e,i=this.view.state.selection.main;let n=ne(this.root);i.empty&&i.assoc&&n.modify&&((e=qe.find(this,i.head))&&(t=e.posAtStart,i.head!=t&&i.head!=t+e.length&&(t=this.coordsAt(i.head,-1),e=this.coordsAt(i.head,1),!t||!e||t.bottom>e.top||(e=this.domAtPos(i.head+i.assoc),n.collapse(e.node,e.offset),n.modify("move",i.assoc<0?"forward":"backward","lineboundary")))))}mayControlSelection(){return this.view.state.facet(ni)?this.root.activeElement==this.dom:se(this.dom,ne(this.root))}nearest(e){for(let t=e;t;){var i=be.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=s&&(r.push(t.dom.getBoundingClientRect().height),(h=t.dom.scrollWidth)>a&&(this.minWidth=a=h,this.minWidthFrom=i,this.minWidthTo=e)),i=e+t.breakAfter}return r}measureTextSize(){for(var t of this.children)if(t instanceof qe){t=t.measureTextSize();if(t)return t}let e=document.createElement("div"),i,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);var t=oe(e.firstChild)[0];i=e.getBoundingClientRect().height,n=t?t.width/27:7,e.remove()}),{lineHeight:i,charWidth:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ke(this.children,t,e)}computeBlockGapDeco(){let i=[],n=this.view.viewState;for(let t=0,e=0;;e++){var r,s=e==n.viewports.length?null:n.viewports[e],o=s?s.from-1:this.length;if(o>t&&(r=n.lineAt(o,0).bottom-n.lineAt(t,0).top,i.push($e.replace({widget:new wi(r),block:!0,inclusive:!0}).range(t,o))),!s)break;t=s.to+1}return $e.set(i)}updateDeco(){return this.decorations=[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco,this.compositionDeco,...this.view.state.facet(fi),...this.view.pluginField(si.decorations)]}scrollPosIntoView(t,r){var s,o,a,r=this.coordsAt(t,r);if(r){let t=0,e=0,i=0,n=0;for(var h of this.view.pluginField(si.scrollMargins))h&&({left:s,right:o,top:a,bottom:h}=h,null!=s&&(t=Math.max(t,s)),null!=o&&(e=Math.max(e,o)),null!=a&&(i=Math.max(i,a)),null!=h&&(n=Math.max(n,h)));!function(t,s){let e=t.ownerDocument,o=e.defaultView;for(let r=t.parentNode;r;)if(1==r.nodeType){let t,e=r==document.body;if(e)t={left:0,right:(h=o).innerWidth,top:0,bottom:h.innerHeight};else{if(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth){r=r.parentNode;continue}h=r.getBoundingClientRect();t={left:h.left,right:h.left+r.clientWidth,top:h.top,bottom:h.top+r.clientHeight}}let i=0,n=0;var a;if(s.topt.bottom&&(n=s.bottom-t.bottom+5),s.leftt.right&&(i=s.right-t.right+5),(i||n)&&(e?o.scrollBy(i,n):(n&&(a=r.scrollTop,r.scrollTop+=n,n=r.scrollTop-a),i&&(a=r.scrollLeft,r.scrollLeft+=i,i=r.scrollLeft-a),s={left:s.left-i,top:s.top-n,right:s.right-i,bottom:s.bottom-n})),e)break;r=r.parentNode}else{if(11!=r.nodeType)break;r=r.host}var h}(this.dom,{left:r.left-t,top:r.top-i,right:r.right+e,bottom:r.bottom+n})}}}class wi extends Ne{constructor(t){super(),this.height=t}toDOM(){var t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}class yi extends Ne{constructor(t,e){super(),this.top=t,this.text=e}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Oe}}function bi(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0=i){if(o.level==n)return t;(s<0||(0!=r?r<0?o.fromi:e[s].level>o.level))&&(s=t)}}if(s<0)throw new RangeError("Index out of range");return s}}const Ni=[];function Ri(o,t){var r,a=o.length,h=t==Mi?1:2,l=t==Mi?2:1;if(!o||1==h&&!Pi.test(o))return $i(a);for(let e=0,i=h,n=h;ep;){for(var m=t,v=2!=Ni[--t];t>p&&v==(2!=Ni[t-1]);)t--;i.push(new _i(t,m,v?2:1))}else i.push(new _i(p,e,0))}else for(let t=0;te.top+1}function Ii(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Fi(t,n,r){let s,o,a,h,l,c,d,u;for(let i=t.firstChild;i;i=i.nextSibling){var f=oe(i);for(let e=0;em?g.left-m:Math.max(0,m-g.right)),g=(m=r,(g=t).top>m?g.top-m:Math.max(0,m-g.bottom));if(0==p&&0==g)return(3==i.nodeType?qi:Fi)(i,n,r);(!s||h>g||h==g&&a>p)&&(s=i,o=t,a=p,h=g),0==p?r>t.bottom&&(!d||d.bottomt.top)&&(c=i,u=t):d&&Vi(d,t)?d=Wi(d,t.bottom):u&&Vi(u,t)&&(u=Ii(u,t.top))}}var m,g;if(d&&d.bottom>=r?(s=l,o=d):u&&u.top<=r&&(s=c,o=u),!s)return{node:t,offset:0};var e=Math.max(o.left,Math.min(o.right,n));return 3==s.nodeType?qi(s,e,r):a||"true"!=s.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,s)+(n>=(o.left+o.right)/2?1:0)}:Fi(s,e,r)}function qi(n,r,e){var t=n.nodeValue.length;let s=-1,o=1e9,a=0;for(let i=0;ie?l.top-e:e-l.bottom)-1;if(l.left-1<=r&&l.right+1>=r&&c=(l.left+l.right)/2,e=t;if((ie.chrome||ie.gecko)&&ve(n,i).getBoundingClientRect().left==l.right&&(e=!t),c<=0)return{node:n,offset:i+(e?1:0)};s=i+(e?1:0),o=c}}}}return{node:n,offset:-1i||s.bottomi?-1:1,i=Math.min(s.bottom-o,Math.max(s.top+o,i)),t)return-1;t=!0}if(s.type==Re.Text)break;i=0e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:null;t=Math.max(r.left+1,Math.min(r.right-1,t));let l=e.root,c=l.elementFromPoint(t,i),d,u=-1;return!c||!e.contentDOM.contains(c)||e.docView.nearest(c)instanceof De||(l.caretPositionFromPoint?(a=l.caretPositionFromPoint(t,i))&&({offsetNode:d,offset:u}=a):!l.caretRangeFromPoint||(a=l.caretRangeFromPoint(t,i))&&({startContainer:d,startOffset:u}=a,ie.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=e.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return ve(e,n-1,n).getBoundingClientRect().left>i}(d,u,t)&&(d=void 0))),d&&e.docView.dom.contains(d)||(h=qe.find(e.docView,h),{node:d,offset:u}=Fi(h.dom,t,i)),e.docView.posFromDOM(d,u)}function Ji(r,t,s,o){let a=r.state.doc.lineAt(t.head),h=r.bidiSpans(a);for(let i=t,n=null;;){let t=function(t,e,i,n,r){let s=n.head-t.from,o=-1;if(0==s){if(!r||!t.length)return null;e[0].level!=i&&(s=e[0].side(!1,i),o=0)}else if(s==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(s=t.side(!0,i),o=e.length-1)}o<0&&(o=_i.find(e,s,null!==(h=n.bidiLevel)&&void 0!==h?h:-1,n.assoc));let a=e[o];s==a.side(r,i)&&(a=e[o+=r?1:-1],s=a.side(!r,i));var h=r==(a.dir==i),n=S(t.text,s,h);if(zi=t.text.slice(Math.min(s,n),Math.max(s,n)),n!=a.side(r,i))return B.cursor(n+t.from,h?-1:1,a.level);let l=o==(r?e.length-1:0)?null:e[o+(r?1:-1)];return l||a.level==i?l&&l.level>1;for(let t=s<0?o.top:o.bottom,e=0;e<50;e+=10){var d=ji(i,{x:l,y:t+(c+e)*s},s);if(null==d)break;if(d!=r)return B.cursor(d,void 0,void 0,h)}}let{doc:u}=i.state,f=u.lineAt(r),p=i.state.tabSize,g=t.goalColumn,m=0;if(null==g){for(const x=u.iterRange(f.from,r);!x.next().done;)m=A(x.value,m,p);g=m*i.defaultCharacterWidth}else m=Math.round(g/i.defaultCharacterWidth);if(s<0&&0==f.from)return B.cursor(0);if(0=m&&!k.next().done;){var{offset:y,leftOver:b}=function(e,i,n,r){for(let t=0;t{"keydown"==i&&this.keydown(n,t)||Yi(n,t)&&!this.ignoreDuringComposition(t)&&(this.mustFlushObserver(t)&&n.observer.forceFlush(),this.runCustomHandlers(i,n,t)?t.preventDefault():e(n,t))}),this.registeredEvents.push(i)}this.notifiedFocused=n.hasFocus,this.ensureHandlers(n)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(i){var t;for(t of this.customHandlers=i.pluginField(li))for(let e in t.handlers)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),i.contentDOM.addEventListener(e,t=>{Yi(i,t)&&this.runCustomHandlers(e,i,t)&&t.preventDefault()}))}runCustomHandlers(i,n,r){for(var s of this.customHandlers){let t=s.handlers[i],e=!1;if(t){try{e=t.call(s.plugin,r,n)}catch(t){ii(n.state,t)}if(e||r.defaultPrevented)return ie.android&&"keydown"==i&&13==r.keyCode&&n.observer.flushSoon(),!0}}return!1}runScrollHandlers(e,i){for(var n of this.customHandlers){let t=n.handlers.scroll;if(t)try{t.call(n.plugin,i,e)}catch(t){ii(e.state,t)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!this.screenKeyEvent(t,e))return!(!ie.ios||13!=e.keyCode&&8!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this[13==e.keyCode?"lastIOSEnter":"lastIOSBackspace"]=Date.now(),!0)}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(0=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}(e,i)&&null,!1===this.dragging&&(i.preventDefault(),this.select(i))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(t)}up(t){null==this.dragging&&this.select(this.startEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,annotations:rt.userEvent.of("pointerselection"),scrollIntoView:!0})}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)}}function Yi(i,n){if(!n.bubbles)return 1;if(!n.defaultPrevented){for(let t=n.target,e;t!=i.contentDOM;t=t.parentNode)if(!t||11==t.nodeType||(e=be.get(t))&&e.ignoreEvent(n))return;return 1}}const Qi=Object.create(null),Zi=ie.ie&&ie.ie_version<15||ie.ios&&ie.webkit_version<604;function tn(t,r){let{state:s}=t,e,o=1,a=s.toText(r),h=a.lines==s.selection.ranges.length;if(cn&&s.selection.ranges.every(t=>t.empty)&&cn==a.toString()){let n=-1;e=s.changeByRange(t=>{var e=s.doc.lineAt(t.from);if(e.from==n)return{range:t};n=e.from;var i=s.toText((h?a.line(o++).text:r)+s.lineBreak);return{changes:{from:e.from,insert:i},range:B.cursor(t.from+i.length)}})}else e=h?s.changeByRange(t=>{var e=a.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:B.cursor(t.from+e.length)}}):s.replaceSelection(a);t.dispatch(e,{annotations:rt.userEvent.of("paste"),scrollIntoView:!0})}Qi.keydown=(t,e)=>{t.inputState.setSelectionOrigin("keyboardselection")};let en=0;function nn(i,n,r,t){if(1==t)return B.cursor(n,r);if(2==t)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return B.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=S(r.text,s,!1):a=S(r.text,s);for(var h=n(r.text.slice(o,a));0{1==(e=e).touches.length&&e.touches[0].radiusX<=1&&e.touches[0].radiusY<=1||(en=Date.now()),t.inputState.setSelectionOrigin("pointerselection")},Qi.touchmove=t=>{t.inputState.setSelectionOrigin("pointerselection")},Qi.mousedown=(e,i)=>{if(e.observer.flush(),!(en>Date.now()-2e3)){let t=null;for(var n of e.state.facet(Qe))if(t=n(e,i),t)break;t||0!=i.button||(t=function(o,t){let a=on(o,t),h=function(t){if(!an)return t.detail;var e=hn;return hn=t,ln=!e||e.timeStamp>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(ln+1)%3:1}(t),l=o.state.selection,c=a,d=t;return{update(t){t.changes&&(a&&(a.pos=t.changes.mapPos(a.pos)),l=l.map(t.changes))},get(t,e,i){let n;if(t.clientX==d.clientX&&t.clientY==d.clientY?n=c:(n=c=on(o,t),d=t),!n||!a)return l;let r=nn(o,n.pos,n.bias,h);var s;return a.pos==n.pos||e||(s=nn(o,a.pos,a.bias,h),t=Math.min(s.from,r.from),s=Math.max(s.to,r.to),r=tge(e.contentDOM)),e.inputState.startMouseSelection(e,i,t))}};let rn=(t,e)=>t>=e.top&&t<=e.bottom,sn=(t,e,i)=>rn(e,i)&&t>=i.left&&t<=i.right;function on(t,e){var i=t.posAtCoords({x:e.clientX,y:e.clientY});return null==i?null:{pos:i,bias:function(t,e,i,n){let r=qe.find(t.docView,e);return r&&0!=(t=e-r.posAtStart)&&(t==r.length||(e=r.coordsAt(t,-1))&&sn(i,n,e)||(!(t=r.coordsAt(t,1))||!sn(i,n,t))&&e&&rn(n,e))?-1:1}(t,i,e.clientX,e.clientY)}}const an=ie.ie&&ie.ie_version<=11;let hn=null,ln=0;Qi.dragstart=(t,e)=>{var{selection:{main:i}}=t.state;let{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Qi.drop=(e,i)=>{if(i.dataTransfer&&e.state.facet(ni)){var n=e.posAtCoords({x:i.clientX,y:i.clientY}),r=i.dataTransfer.getData("Text");if(null!=n&&r){i.preventDefault();var{mouseSelection:i}=e.inputState,i=i&&i.dragging&&i.dragMove?{from:i.dragging.from,to:i.dragging.to}:null,r={from:n,insert:r};let t=e.state.changes(i?[i,r]:r);e.focus(),e.dispatch({changes:t,selection:{anchor:t.mapPos(n,-1),head:t.mapPos(n,1)},annotations:rt.userEvent.of("drop")})}}},Qi.paste=(e,i)=>{if(e.state.facet(ni)){e.observer.flush();let t=Zi?null:i.clipboardData;var n=t&&t.getData("text/plain");n?(tn(e,n),i.preventDefault()):function(e){let i=e.dom.parentNode;if(i){let t=i.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{e.focus(),t.remove(),tn(e,t.value)},50)}}(e)}};let cn=null;function dn(t){t.docView.compositionDeco.size&&t.update([])}Qi.copy=Qi.cut=(e,i)=>{var{text:n,ranges:r,linewise:s}=function(e){let i=[],n=[],r=!1;for(var t of e.selection.ranges)t.empty||(i.push(e.sliceDoc(t.from,t.to)),n.push(t));if(!i.length){let t=-1;for(var{from:s}of e.selection.ranges){s=e.doc.lineAt(s);s.number>t&&(i.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),t=s.number}r=!0}return{text:i.join(e.lineBreak),ranges:n,linewise:r}}(e.state);if(n){cn=s?n:null;let t=Zi?null:i.clipboardData;t?(i.preventDefault(),t.clearData(),t.setData("text/plain",n)):function(e,i){let n=e.dom.parentNode;if(n){let t=n.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.value=i,t.focus(),t.selectionEnd=i.length,t.selectionStart=0,setTimeout(()=>{t.remove(),e.focus()},50)}}(e,n),"cut"==i.type&&e.state.facet(ni)&&e.dispatch({changes:r,scrollIntoView:!0,annotations:rt.userEvent.of("cut")})}},Qi.focus=Qi.blur=t=>{setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)},Qi.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout(()=>{t.viewState.printing=!1,t.requestMeasure()},2e3)},Qi.compositionstart=Qi.compositionupdate=t=>{t.inputState.composing<0&&(t.docView.compositionDeco.size&&(t.observer.flush(),dn(t)),t.inputState.composing=0)},Qi.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),setTimeout(()=>{t.inputState.composing<0&&dn(t)},50)};const un=["pre-wrap","normal","pre-line"];class fn{constructor(){this.doc=u.empty,this.lineWrapping=!1,this.direction=Ai.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefresh(e,t,i){let n=!1;for(let t=0;t=e?r:c.lineAt(e,mn.ByPosNoHeight,a,0,0);for(n+=d.to-e,e=d.to;02*r){var o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(r>2*n))break;o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,r-=o.size}else nt&&e.push(new bn(r.from-t-1).updateHeight(n,t));i<=s&&r.more;){var o=n.doc.lineAt(i).length;e.length&&e.push(null);let t=new yn(o,r.heights[r.index++]);t.outdated=!1,e.push(t),i+=o+1}return i<=s&&e.push(null,new bn(s-i).updateHeight(n,i)),n.heightChanged=!0,vn.of(e)}return(e||this.outdated)&&(this.setHeight(n,n.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class xn extends vn{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){var r=i+this.left.height;return to))return h;e=e==mn.ByPosNoHeight?mn.ByPosNoHeight:mn.ByPos;return a?h.join(this.right.lineAt(o,e,i,s,o)):this.left.lineAt(o,e,i,n,r).join(h)}forEachLine(t,e,i,n,r,s){var o,a=n+this.left.height,h=r+this.left.length+this.break;this.break?(t=t&&o.from<=e&&s(o),e>o.to&&this.right.forEachLine(o.to+1,e,i,a,h,s))}replace(t,e,i){var n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];0=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){var i=this.left.length,n=i+this.break;if(n<=t)return this.right.decomposeRight(t-n,e);t2*e.size||e.size>2*t.size?vn.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function kn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof bn&&(n=t[e+1])instanceof bn&&t.splice(e-1,3,new bn(i.length+1+n.length))}class Sn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,i){if(-1this.pos||!this.isCovered)&&this.nodes.push(new yn(t-this.pos,-1)),(this.writtenTo=t)t&&this.nodes.push(new yn(this.pos-t,-1)),this.writtenTo=this.pos)}blankContent(t,e){let i=new bn(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();var t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof yn)return t;t=new yn(0,-1);return this.nodes.push(t),t}addBlock(t){this.enterLine(),t.type!=Re.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=Re.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){var e,i=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(-1t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let t=0;t<=1;t++){let i=t?n.head:n.anchor;var r,s;e.some(({from:t,to:e})=>i>=t&&i<=e)||({from:r,to:s}=this.lineAt(i,0),e.push(new Dn(r,s)))}this.viewports=e.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?En:new Hn(this.heightOracle.doc,this.heightMap,this.viewports)}update(t,e=null){var i=this.state;this.state=t.state;var n,r,s,o=this.state.facet(fi),a=t.changedRanges,s=gi.extendWithRanges(a,(n=t.startState.facet(fi),r=o,s=t?t.changes:k.empty(this.state.doc.length),a=new An,Ct.compare(n,r,s,a,0),a.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(o,i.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=a&&(t.flags|=2);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e)),h.eq(this.viewport)||(this.viewport=h,t.flags|=4),this.updateForViewport(),(this.lineGaps.length||15e3t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=window.getComputedStyle(t).overflow&&(i=t.getBoundingClientRect(),r=Math.max(r,i.left),s=Math.min(s,i.right),o=Math.max(o,i.top),a=Math.min(a,i.bottom)),t=t.parentNode;else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:s-n.left,top:o-(n.top+t),bottom:a-(n.top+t)}}(i,this.paddingTop),o=s.top-this.pixelViewport.top,a=s.bottom-this.pixelViewport.bottom;if(this.pixelViewport=s,this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left,!this.inView)return 0;var h,l=t.measureVisibleLineHeights();let c=!1,d=0,u=0,f=this.heightOracle;return e||(h=t.dom.clientWidth,(f.mustRefresh(l,n,r)||f.lineWrapping&&Math.abs(h-this.contentWidth)>f.charWidth)&&({lineHeight:s,charWidth:e}=t.measureTextSize(),c=f.refresh(n,r,s,e,h/e,l),c&&(t.minWidth=0,u|=16)),this.contentWidth!=h&&(this.contentWidth=h,u|=16),0this.viewport.to))&&((l=this.getViewport(d,this.scrollTo)).from==this.viewport.from&&l.to==this.viewport.to||(this.viewport=l,u|=4)),this.updateForViewport(),(this.lineGaps.length||15e3o.to&&({bottom:e}=i.lineAt(e.head,mn.ByPos,n,0,0),o=new Dn(i.lineAt(e-(s-r)-500,mn.ByHeight,n,0,0).from,i.lineAt(e+500,mn.ByHeight,n,0,0).to))),o}mapViewport(t,e){var i=e.mapPos(t.from,-1),t=e.mapPos(t.to,1);return new Dn(this.heightMap.lineAt(i,mn.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(t,mn.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){var{top:n}=this.heightMap.lineAt(t,mn.ByPos,this.state.doc,0,0),{bottom:r}=this.heightMap.lineAt(e,mn.ByPos,this.state.doc,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&s-2e3{if(!(r.length<1e4)){var s=function(t,e,i){let n=[],r=t,s=0;Ct.spans(i.facet(fi),t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r=r.from&&(t=o.from),o.from<=r.to&&o.to>=e&&(e=o.to);let i=t-1e4,n=e+1e4;i>r.from+5e3&&h.push(Bn(a,t=>t.from==r.from&&t.to>i-5e3&&t.to<5e3+i)||new Mn(r.from,i,this.gapSize(r,i,!0,s))),nt.to==r.to&&t.from>n-5e3&&t.fromt.draw(this.heightOracle.lineWrapping))),8)}computeVisibleRanges(){let t=this.state.facet(fi);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Ct.spans(t,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20),this.visibleRanges=i}lineAt(t,e){return e+=this.paddingTop,Pn(this.heightMap.lineAt(t,mn.ByPos,this.state.doc,e,0),this.scaler,e)}lineAtHeight(t,e){return e+=this.paddingTop,Pn(this.heightMap.lineAt(this.scaler.fromDOM(t,e),mn.ByHeight,this.state.doc,e,0),this.scaler,e)}blockAtHeight(t,e){return e+=this.paddingTop,Pn(this.heightMap.blockAt(this.scaler.fromDOM(t,e),this.state.doc,e,0),this.scaler,e)}forEachLine(t,e,i,n){return n+=this.paddingTop,this.heightMap.forEachLine(t,e,this.state.doc,n,0,1==this.scaler.scale?i:t=>i(Pn(t,this.scaler,n)))}get contentHeight(){return this.domHeight+this.paddingTop+this.paddingBottom}get domHeight(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop)}}class Dn{constructor(t,e){this.from=t,this.to=e}eq(t){return this.from==t.from&&this.to==t.to}}function On({total:t,ranges:e},i){if(i<=0)return e[0].from;if(1<=i)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){var{from:r,to:s}=e[t],s=s-r;if(n<=s)return r+n;n-=s}}function Ln(t,e){let i=0;for(var{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function Bn(t,e){for(var i of t)if(e(i))return i}const En={toDOM(t){return t},fromDOM(t){return t},scale:1};class Hn{constructor(r,s,t){let o=0,e=0,i=0;this.viewports=t.map(({from:t,to:e})=>{var i=s.lineAt(t,mn.ByPos,r,0,0).top,n=s.lineAt(e,mn.ByPos,r,0,0).bottom;return o+=n-i,{from:t,to:e,top:i,bottom:n,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(s.height-o);for(var n of this.viewports)n.domTop=i+(n.top-e)*this.scale,i=n.domBottom=n.domTop+(n.bottom-n.top),e=n.bottom}toDOM(n,r){n-=r;for(let t=0,e=0,i=0;;t++){var s=tPn(t,e,i)):t.type)}const _n=P.define({combine:t=>t.join(" ")}),Nn=P.define({combine:t=>-1{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t}})}const Wn=In("."+Rn,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,flexGrow:2,overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none"},".cm-lineWrapping":{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Vn),Fn={childList:!0,characterData:!0,subtree:!0,characterDataOldValue:!0},qn=ie.ie&&ie.ie_version<=11;class jn{constructor(i,t,e){this.view=i,this.onChange=t,this.onScrollChanged=e,this.active=!1,this.ignoreSelection=new fe,this.delayedFlush=-1,this.queue=[],this.scrollTargets=[],this.intersection=null,this.intersecting=!1,this.parentCheck=-1,this.dom=i.contentDOM,this.observer=new MutationObserver(t=>{for(var e of t)this.queue.push(e);(ie.ie&&ie.ie_version<=11||ie.ios&&i.composing)&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),qn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),0{this.delayedFlush=-1,this.flush()},20))}forceFlush(){0<=this.delayedFlush&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}flush(){if(!(0<=this.delayedFlush)){let n=this.queue;for(var t of this.observer.takeRecords())n.push(t);n.length&&(this.queue=[]);var r=ne(this.view.root),s=!this.ignoreSelection.eq(r)&&se(this.dom,r);if(0!=n.length||s){let t=-1,e=-1,i=!1;for(var o of n){o=this.readMutation(o);o&&(o.typeOver&&(i=!0),-1==t?{from:t,to:e}=o:(t=Math.min(o.from,t),e=Math.max(o.to,e)))}r=this.view.state;(-1this.view.docView.sync()),this.view.docView.dirty=0),this.view.docView.updateSelection()),this.clearSelection()}}}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(),"childList"!=t.type)return{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue};var i=Jn(e,t.previousSibling||t.target.previousSibling,-1),t=Jn(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:t?e.posBefore(t):e.posAtEnd,typeOver:!1}}destroy(){this.stop(),this.intersection&&this.intersection.disconnect();for(var t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),clearTimeout(this.parentCheck)}}function Jn(t,e,i){for(;e;){var n=be.get(e);if(n&&n.parent==t)return n;n=e.parentNode;e=n!=t.dom?n:0Date.now()-100||ie.android&&t.text.length=o?s-i:0,s-=h,a=s+(a-o),o=s):a=a?s-i:0,s-=i,o=s+(o-a),a=s)}return{from:s,toA:o,toB:a}}(n.state.sliceDoc(l,c),t.text,e-l,i);d&&(s={from:l+d.from,to:l+d.toA,insert:n.state.toText(t.text.slice(d.from,d.toB))})}else!n.hasFocus&&n.state.facet(ni)||(c=ne(n.root),{impreciseHead:l,impreciseAnchor:d}=n.docView,l=l&&l.node==c.focusNode&&l.offset==c.focusOffset||!re(n.contentDOM,c.focusNode)?n.state.selection.main.head:n.docView.posFromDOM(c.focusNode,c.focusOffset),c=d&&d.node==c.anchorNode&&d.offset==c.anchorOffset||!re(n.contentDOM,c.anchorNode)?n.state.selection.main.anchor:function(t){let e=t.isCollapsed;return e&&ie.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}(c)?l:n.docView.posFromDOM(c.anchorNode,c.anchorOffset),l==a.head&&c==a.anchor||(o=B.single(c,l)));if(s||o)if(!s&&r&&!a.empty&&o&&o.main.empty&&(s={from:a.from,to:a.to,insert:n.state.doc.slice(a.from,a.to)}),s){let i=n.state;if(!(ie.android&&(s.from==a.from&&s.to==a.to&&1==s.insert.length&&2==s.insert.lines&&Yn(n,"Enter",13)||s.from==a.from-1&&s.to==a.to&&0==s.insert.length&&Yn(n,"Backspace",8)||s.from==a.from&&s.to==a.to+1&&0==s.insert.length&&Yn(n,"Delete",46))||ie.ios&&(n.inputState.lastIOSEnter>Date.now()-225&&1Date.now()-225&&!s.insert.length&&Yn(n,"Backspace",8)))){let e=s.insert.toString();if(!n.state.facet(ei).some(t=>t(n,s.from,s.to,e))){0<=n.inputState.composing&&n.inputState.composing++;let t;var u;t=s.from>=a.from&&s.to<=a.to&&s.to-s.from>=(a.to-a.from)/3&&(!o||o.main.empty&&o.main.from==s.from+s.insert.length)?(r=a.froms.to?i.sliceDoc(s.to,a.to):"",i.replaceSelection(n.state.toText(r+s.insert.sliceString(0,void 0,n.state.lineBreak)+u))):{changes:u=i.changes(s),selection:o&&!i.selection.main.eq(o.main)&&o.main.to<=u.newLength?i.selection.replaceRange(o.main):void 0},n.dispatch(t,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})}}}else if(o&&!o.main.eq(a)){let t=!1,e;n.inputState.lastSelectionTime>Date.now()-50&&("keyboardselection"==n.inputState.lastSelectionOrigin?t=!0:e=rt.userEvent.of(n.inputState.lastSelectionOrigin)),n.dispatch({selection:o,scrollIntoView:t,annotations:e})}}class Kn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(e,i){if(e){var n=e.parentNode;for(let t=e;;){this.findPointBefore(n,t),this.readNode(t);var r=t.nextSibling;if(r==i)break;var s=be.get(t),o=be.get(r);((s?s.breakAfter:Gn(t))||(o?o.breakAfter:Gn(r))&&("BR"!=t.nodeName||t.cmIgnore))&&(this.text+=this.lineBreak),t=r}this.findPointBefore(n,i)}}readNode(i){if(!i.cmIgnore){var n=be.get(i);let t=n&&n.overrideDOMText,e;null!=t?e=t.sliceString(0,void 0,this.lineBreak):3==i.nodeType?e=i.nodeValue:"BR"==i.nodeName?e=i.nextSibling?this.lineBreak:"":1==i.nodeType&&this.readRange(i.firstChild,null),null!=e&&(this.findPointIn(i,e.length),this.text+=e,ie.chrome&&13==this.view.inputState.lastKeyCode&&!i.nextSibling&&/\n\n$/.test(this.text)&&(this.text=this.text.slice(0,-1)))}}findPointBefore(t,e){for(var i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointIn(t,e){for(var i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e))}}function Gn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Xn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}function Yn(t,e,i){i={key:e,code:e,keyCode:i,which:i,cancelable:!0};let n=new KeyboardEvent("keydown",i);n.synthetic=!0,t.contentDOM.dispatchEvent(n);let r=new KeyboardEvent("keyup",i);return r.synthetic=!0,t.contentDOM.dispatchEvent(r),n.defaultPrevented||r.defaultPrevented}class Qn{constructor(t={}){this.plugins=[],this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=t.root||document,this.viewState=new Tn(t.state||pt.create()),this.plugins=this.state.facet(ai).map(t=>new ci(t).update(this)),this.observer=new jn(this,(t,e,i)=>{Un(this,t,e,i)},t=>{this.inputState.runScrollHandlers(this,t),this.measure()}),this.inputState=new Ki(this),this.docView=new vi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,window.addEventListener("resize",()=>{-1==er&&(er=setTimeout(ir,50))}),this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return 0t.scrollIntoView)?n.selection.main:null;this.viewState.update(i,s),this.bidiCache=rr.update(this.bidiCache,i.changes),i.empty||this.updatePlugins(i),e=this.docView.update(i),this.state.facet(pi)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t)}finally{this.updateState=0}if((e||scrollTo||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!i.empty)for(var o of this.state.facet(ti))o(i)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");this.updateState=2;try{for(var e of this.plugins)e.destroy(this);this.viewState=new Tn(t),this.plugins=t.facet(ai).map(t=>new ci(t).update(this)),this.docView=new vi(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}this.requestMeasure()}updatePlugins(i){let t=i.startState.facet(ai),n=i.state.facet(ai);if(t!=n){let e=[];for(var r of n){var s=t.indexOf(r);if(s<0)e.push(new ci(r));else{let t=this.plugins[s];t.mustUpdate=i,e.push(t)}}for(var o of this.plugins)o.mustUpdate!=i&&o.destroy(this);this.plugins=e,this.inputState.ensureHandlers(this)}else for(var e of this.plugins)e.mustUpdate=i;for(let t=0;t{try{return t.read(this)}catch(t){return ii(this.state,t),nr}});let t=new mi(this,this.state);t.flags|=r,n?n.flags|=r:n=t,this.updateState=2,t.empty||this.updatePlugins(t),this.updateAttrs(),r&&this.docView.update(t);for(let t=0;tthis.measure())),e){if(null!=e.key)for(let t=0;tfunction(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{t=n(t);return r==ct.Space&&(r=t),r==t}}(this,e.head,t))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){var r=t.state.doc.lineAt(e.head),s=n&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){n=t.dom.getBoundingClientRect(),s=t.posAtCoords({x:i==(t.textDirection==Ai.LTR)?n.right-1:n.left+1,y:(s.top+s.bottom)/2});if(null!=s)return B.cursor(s,i?-1:1)}return e=qe.find(t.docView,e.head),r=e?i?e.posAtEnd:e.posAtStart:i?r.to:r.from,B.cursor(r,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Ui(this,t,e,i)}scrollPosIntoView(t){this.viewState.scrollTo=B.cursor(t),this.requestMeasure()}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t){return this.readMeasured(),ji(this,t)}coordsAtPos(t,e=1){this.readMeasured();var i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;var n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return ue(i,r[_i.find(r,t-n.from,-1,e)].dir==Ai.LTR==0Zn)return $i(t.length);var e,i=this.textDirection;for(e of this.bidiCache)if(e.from==t.from&&e.dir==i)return e.order;var n=Ri(t.text,this.textDirection);return this.bidiCache.push(new rr(t.from,t.to,i,n)),n}get hasFocus(){return document.hasFocus()&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ge(this.contentDOM),this.docView.updateSelection()})}destroy(){for(var t of this.plugins)t.destroy(this);this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),-1({}),{eventHandlers:t})}static theme(t,e){var i=yt.newName();let n=[_n.of(i),pi.of(In(`.${i}`,t))];return e&&e.dark&&n.push(Nn.of(!0)),n}static baseTheme(t){return I.fallback(pi.of(In("."+Rn,t,Vn)))}}Qn.styleModule=pi,Qn.inputHandler=ei,Qn.exceptionSink=Ze,Qn.updateListener=ti,Qn.editable=ni,Qn.mouseSelectionStyle=Qe,Qn.dragMovesSelection=Ye,Qn.clickAddsSelectionRange=Xe,Qn.decorations=fi,Qn.contentAttributes=ui,Qn.editorAttributes=di,Qn.lineWrapping=Qn.contentAttributes.of({class:"cm-lineWrapping"}),Qn.announce=nt.define();const Zn=4096;function tr(t,e){return null==t?e.getBoundingClientRect().top:t}let er=-1;function ir(){er=-1;var i=document.querySelectorAll(".cm-content");for(let e=0;e{if(t){for(var e of t.commands)if(e(i))return!0;t.preventDefault&&(a=!0)}return!1},l=t[n],c;if(l){if(h(l[o+or(r,e,!s)]))return!0;if(s&&(e.shiftKey||e.altKey||e.metaKey)&&(c=Nt[e.keyCode])&&c!=r){if(h(l[o+or(c,e,!0)]))return!0}else if(s&&e.shiftKey&&h(l[o+or(r,e,!0)]))return!0}return a}(function(t){let e=t.facet(ar),i=hr.get(e);i||hr.set(e,i=function(t,a=sr){let h=Object.create(null),n=Object.create(null),l=(t,e)=>{var i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},e=(n,t,e,i)=>{let r=h[n]||(h[n]=Object.create(null)),s=t.split(/ (?!$)/).map(t=>function(t,e){var i=t.split(/-(?!$)/);let n=i[i.length-1];"Space"==n&&(n=" ");let r,s,o,a;for(let t=0;t{let e=lr={view:t,prefix:i,scope:n};return setTimeout(()=>{lr==e&&(lr=null)},cr),!0}]})}t=s.join(" ");l(t,!1);let o=r[t]||(r[t]={preventDefault:!1,commands:[]});o.commands.push(e),i&&(o.preventDefault=!0)};for(var i of t){var r=i[a]||i.key;if(r)for(var s of i.scope?i.scope.split(" "):["editor"])e(s,r,i.run,i.preventDefault),i.shift&&e(s,"Shift-"+r,i.shift,i.preventDefault)}return h}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")}})}),hr=new WeakMap;let lr=null;const cr=4e3;ie.ios;let dr=0;const ur=new WeakMap;class fr{constructor({deserialize:t}={}){this.id=dr++,this.deserialize=t||(()=>{throw new Error("This node type doesn't define a deserialize function")})}static string(){return new fr({deserialize:t=>t})}static number(){return new fr({deserialize:Number})}static flag(){return new fr({deserialize:()=>!0})}set(t,e){return t[this.id]=e,t}add(e){return"function"!=typeof e&&(e=gr.match(e)),t=>{t=e(t);return void 0===t?null:[this,t]}}}fr.closedBy=new fr({deserialize:t=>t.split(" ")}),fr.openedBy=new fr({deserialize:t=>t.split(" ")}),fr.group=new fr({deserialize:t=>t.split(" ")});const pr=Object.create(null);class gr{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){var e=t.props&&t.props.length?Object.create(null):pr,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new gr(t.name||"",e,t.id,i);if(t.props)for(var r of t.props)Array.isArray(r)||(r=r(n)),r&&r[0].set(e,r[1]);return n}prop(t){return this.props[t.id]}get isTop(){return 0<(1&this.flags)}get isSkipped(){return 0<(2&this.flags)}get isError(){return 0<(4&this.flags)}get isAnonymous(){return 0<(8&this.flags)}is(e){if("string"!=typeof e)return this.id==e;{if(this.name==e)return!0;let t=this.prop(fr.group);return!!t&&-1{for(let t=i.prop(fr.group),e=-1;e<(t?t.length:0);e++){var n=r[e<0?i.name:t[e]];if(n)return n}}}}gr.none=new gr("",Object.create(null),0,8);class mr{constructor(t,e,i,n){this.type=t,this.children=e,this.positions=i,this.length=n}toString(){var t=this.children.map(t=>t.toString()).join();return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(t,e=0){var i=null!=t&&ur.get(this)||this.topNode;let n=new Sr(i);return null!=t&&(n.moveTo(t,e),ur.set(this,n._tree)),n}fullCursor(){return new Sr(this.topNode,!0)}get topNode(){return new yr(this,0,0,null)}resolve(t,e=0){return this.cursor(t,e).node}iterate(t){let{enter:i,leave:n,from:r=0,to:s=this.length}=t;for(let e=this.cursor();;){let t=!1;if(e.from<=s&&e.to>=r&&(e.type.isAnonymous||!1!==i(e.type,e.from,e.to))){if(e.firstChild())continue;e.type.isAnonymous||(t=!0)}for(;t&&n&&n(e.type,e.from,e.to),t=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;t=!0}}}balance(t=1024){return this.children.length<=Cr?this:Tr(this.type,gr.none,this.children,this.positions,0,this.children.length,0,t,this.length,0)}static build(t){let{buffer:e,nodeSet:m,topID:i=0,maxBufferLength:v=1024,reused:w=[],minRepeatType:y=m.types.length}=t,b=Array.isArray(e)?new Mr(e,e.length):e,x=m.types,k=0;function S(i,t,e,n,r){var{id:s,start:o,end:a,size:h}=b;let l=o-i;if(h<0)return-1==h?(e.push(w[s]),n.push(l)):k=s,void b.next();let c=x[s],d,u;if(a-o<=v&&(u=function(t,e){let i=b.fork(),n=0,r=0,s=0,o=i.end-v,a={size:0,start:0,skip:0};t:for(var h=i.pos-t;i.pos>h;)if(i.id!=e){var l=i.size,c=i.pos-l;if(l<0||c=y?4:0;var d=i.start;for(i.next();i.pos>c;){if(i.size<0)break t;i.id>=y&&(t+=4),i.next()}r=d,n+=l,s+=t}else a.size=n,a.start=r,a.skip=s,s+=4,n+=4,i.next();(e<0||n==t)&&(a.size=n,a.start=r,a.skip=s);return 4t;)e=function t(e,i,n,r){var{id:s,start:o,end:a,size:h}=b;b.next();if(s==r)return n;var l=n;if(4c;)n=t(e,i,n,r);s=y?s:-1;b.pos>p;)b.id==g?b.next():S(o,p,t,e,g);t.reverse(),e.reverse(),d=-1Cr?Tr(c,c,t,e,0,t.length,0,v,a-o,k):vr(new mr(c,t,e,a-o),k)}e.push(d),n.push(l)}let n=[],r=[];for(;0=t:this.from>t)||(-1=t:this.from>t)||(-1!t.type.isAnonymous||t instanceof wr||Ar(t))}class Mr{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Mr(this.buffer,this.index)}}const Cr=8;function Tr(t,i,n,r,s,o,a,h,e,l){let c=[],d=[];if(e<=h)for(let t=s;tu<<1){for(let t=0;t=i)for(;s&&s.from=t.from||u<=t.to||h)&&(l=Math.max(t.from,a)-h,c=Math.min(t.to,u)-h,t=c<=l?null:new Dr(l,c,t.tree,t.offset+h,(0u)break;s=rt.length&&n.push(r);return n}}const Or=new fr;class Lr{constructor(t,e,i,n=[]){this.data=t,this.topNode=i,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return Er(this)}}),this.parser=e,this.extension=[Vr.of(this),pt.languageData.of((t,e)=>t.facet(Br(t,e)))].concat(n)}isActiveAt(t,e){return Br(t,e)==this.data}findRegions(t){var e=t.facet(Vr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[];return Er(t).iterate({enter:(t,e,i)=>{if(t.isTop&&t.prop(Or)==this.data)return n.push({from:e,to:i}),!1}}),n}get allowsNesting(){return!0}parseString(t){var e=u.of(t.split("\n"));let i=this.parser.startParse(new Hr(e),0,new Pr(this.parser,pt.create({doc:e}),[],mr.empty,{from:0,to:t.length},[],null)),n;for(;!(n=i.advance()););return n}}function Br(t,e){var i=t.facet(Vr);if(!i)return null;if(!i.allowsNesting)return i.data;let n=Er(t),r=n.resolve(e,-1);for(;r;){var s=r.type.prop(Or);if(s)return s;r=r.parent}return i.data}function Er(t){t=t.field(Lr.state,!1);return t?t.tree:mr.empty}Lr.setState=nt.define();class Hr{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.prevString="",this.cursor=t.iter()}syncTo(t){return t=this.length)return-1;let e=this.cursorPos-this.string.length;if(t=this.cursorPos){if(t=e-this.prevString.length)return this.prevString.charCodeAt(t-(e-this.prevString.length));e=this.syncTo(t)}return this.string.charCodeAt(t-e)}lineAfter(t){if(t>=this.length||t<0)return"";let e=this.cursorPos-this.string.length;return(t=this.cursorPos)&&(e=this.syncTo(t)),this.cursor.lineBreak?"":this.string.slice(t-e,Math.min(this.length-e,this.string.length))}read(t,e){var i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}clip(t){return new Hr(this.doc,t)}}class Pr{constructor(t,e,i=[],n,r,s,o){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.viewport=r,this.skipped=s,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}work(t,e){if(this.tree!=mr.empty&&(null==e?this.tree.length==this.state.doc.length:this.tree.length>=e))return this.takeTree(),!0;this.parse||(this.parse=this.parser.startParse(new Hr(this.state.doc),0,this));for(var i=Date.now()+t;;){var n=this.parse.advance();if(n)return this.fragments=this.withoutTempSkipped(Dr.addTree(n)),this.parse=null,this.tree=n,!0;if(null!=e&&this.parse.pos>=e)return this.takeTree(),!0;if(Date.now()>i)return!1}}takeTree(){this.parse&&this.parse.pos>this.tree.length&&(this.tree=this.parse.forceFinish(),this.fragments=this.withoutTempSkipped(Dr.addTree(this.tree,this.fragments,!0)))}withoutTempSkipped(t){for(var e;e=this.tempSkipped.pop();)t=_r(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let r=[];if(t.iterChangedRanges((t,e,i,n)=>r.push({fromA:t,toA:e,fromB:i,toB:n})),i=Dr.applyChanges(i,r),n=mr.empty,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(var a of this.skipped){var h=t.mapPos(a.from,1),a=t.mapPos(a.to,-1);he.from&&(this.fragments=_r(this.fragments,i,n),this.skipped.splice(t--,1))}return this.skipped.length=t}}function _r(t,e,i){return Dr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}Pr.skippingParser=Pr.getSkippingParser();class Nr{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state);t=this.context.tree.length==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.tree.length),e.viewport.to);return e.work(25,t)||e.takeTree(),new Nr(e)}static init(t){let e=new Pr(t.facet(Vr).parser,t,[],mr.empty,{from:0,to:t.doc.length},[],null);return e.work(25)||e.takeTree(),new Nr(e)}}Lr.state=z.define({create:Nr.init,update(t,e){for(var i of e.effects)if(i.is(Lr.setState))return i.value;return e.startState.facet(Vr)!=e.state.facet(Vr)?Nr.init(e.state):t.apply(e)}});let Rr="undefined"!=typeof window&&window.requestIdleCallback||((t,{timeout:e})=>setTimeout(t,e)),$r="undefined"!=typeof window&&window.cancelIdleCallback||clearTimeout;var zr=hi.fromClass(class{constructor(t){this.view=t,this.working=-1,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Lr.state).context;t.viewportChanged&&(e.updateViewport(t.view.viewport)&&e.reset(),this.view.viewport.to>e.tree.length&&this.scheduleWork()),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(i=!1){if(!(-1=t.doc.length||(this.working=Rr(this.work,{timeout:500}))}}work(n){this.working=-1;var r=Date.now();if(this.chunkEnd=e+1e6||(n=Math.min(this.chunkBudget,n?Math.max(25,n.timeRemaining()):100),n=i.context.work(n,e+1e6),this.chunkBudget-=Date.now()-r,(n||this.chunkBudget<=0||i.context.movedPast(e))&&(i.context.takeTree(),this.view.dispatch({effects:Lr.setState.of(new Nr(i.context))})),!n&&0this.scheduleWork(!0)),t.scheduleOn=null)}destroy(){0<=this.working&&$r(this.working)}},{eventHandlers:{focus(){this.scheduleWork()}}});const Vr=P.define({combine(t){return t.length?t[0]:null},enables:[Lr.state,zr]}),Ir=P.define(),Wr=P.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function Fr(t){let e=t.facet(Wr);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function qr(t,e){let i="",n=t.tabSize;if(9==t.facet(Wr).charCodeAt(0))for(;n<=e;)i+="\t",e-=n;for(let t=0;tfunction(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;var r=null===(r=t.options)||void 0===r?void 0:r.simulateBreak,t=t.state.doc.lineAt(i.from),s=null==r||r<=t.from?t.to:Math.min(t.to,r);for(let t=i.to;;){var o=e.childAfter(t);if(!o||o==n)return null;if(!o.type.isSkipped)return o.fromQn.decorations.from(t)}),Qr];function ss(t,e,i){var n=t.prop(e<0?fr.openedBy:fr.closedBy);if(n)return n;if(1==t.name.length){t=i.indexOf(t.name);if(-1=e.to){if(0==o&&-1>1==h>>1};d--}}0"},hs=nt.define({map(t,e){t=e.mapPos(t,-1,b.TrackAfter);return null==t?void 0:t}}),ls=nt.define({map(t,e){return e.mapPos(t)}}),cs=new class extends kt{};cs.startSide=1,cs.endSide=-1;const ds=z.define({create(){return Ct.empty},update(t,i){var e,n;i.selection&&(e=i.state.doc.lineAt(i.selection.main.head).from,n=i.startState.doc.lineAt(i.startState.selection.main.head).from,e!=i.changes.mapPos(n,-1)&&(t=Ct.empty)),t=t.map(i.changes);for(let e of i.effects)e.is(hs)?t=t.update({add:[cs.range(e.value,e.value+1)]}):e.is(ls)&&(t=t.update({filter:t=>t!=e.value}));return t}});const us="()[]{}<>";function fs(e){for(let t=0;t>10),56320+(1023&t)));var t}function ps(t,e){return t.languageDataAt("closeBrackets",e)[0]||as}function gs(t,e,i,n){if(t.composing)return!1;var r=t.state.selection.main;if(2{if(!t.empty)return{changes:[{insert:s,from:t.from},{insert:s,from:t.to}],effects:hs.of(t.to+s.length),range:B.range(t.anchor+s.length,t.head+s.length)};var e=t.head,i=ws(r.doc,e);if(i==s){if(ys(r,e))return{changes:{insert:s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)};if(vs(r,e)){var n=o&&r.sliceDoc(e,e+3*s.length)==s+s+s;return{range:B.cursor(e+s.length*(n?3:1)),effects:ls.of(e)}}}else{if(o&&r.sliceDoc(e-2*s.length,e)==s+s&&ys(r,e-2*s.length))return{changes:{insert:s+s+s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)};if(r.charCategorizer(e)(i)!=ct.Word){i=r.sliceDoc(e-1,e);if(i!=s&&r.charCategorizer(e)(i)!=ct.Word)return{changes:{insert:s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)}}}return{range:a=t}});return a?null:r.update(t,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})}(t,r,-1{if(!t.empty)return{changes:[{insert:n,from:t.from},{insert:r,from:t.to}],effects:hs.of(t.to+n.length),range:B.range(t.anchor+n.length,t.head+n.length)};var e=ws(i.doc,t.head);return!e||/\s/.test(e)||-1t.empty&&ws(e.doc,t.head)==i?B.cursor(t.head+i.length):n=t);return n?null:e.update({selection:B.create(t,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map(({from:t})=>ls.of(t))})}(t,(r,s))}return null}(t.state,n);return!!n&&(t.dispatch(n),!0)}const ms=[{key:"Backspace",run:({state:n,dispatch:t})=>{let r=ps(n,n.selection.main.head).brackets||as.brackets,s=null,e=n.changeByRange(t=>{if(t.empty){var e,i=function(t,e){let i=t.sliceString(e-2,e);return d(c(i,0))==i.length?i:i.slice(1)}(n.doc,t.head);for(e of r)if(e==i&&ws(n.doc,t.head)==fs(c(e,0)))return{changes:{from:t.head-e.length,to:t.head+e.length},range:B.cursor(t.head-e.length),annotations:rt.userEvent.of("delete")}}return{range:s=t}});return s||t(n.update(e,{scrollIntoView:!0})),!s}}];function vs(t,e){let i=!1;return t.field(ds).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function ws(t,e){let i=t.sliceString(e,e+2);return i.slice(0,d(c(i,0)))}function ys(t,e){t=Er(t).resolve(e+1);return t.parent&&t.from==e}function bs(t,e){return B.create(t.ranges.map(e),t.mainIndex)}function xs(t,e){return t.update({selection:e,scrollIntoView:!0,annotations:rt.userEvent.of("keyboardselection")})}function ks({state:t,dispatch:e},i){let n=bs(t.selection,i);return!n.eq(t.selection)&&(e(xs(t,n)),!0)}function Ss(t,e){return B.cursor(e?t.to:t.from)}function As(e,i){return ks(e,t=>t.empty?e.moveByChar(t,i):Ss(t,i))}var Ms=t=>As(t,t.textDirection!=Ai.LTR),Cs=t=>As(t,t.textDirection==Ai.LTR);function Ts(e,i){return ks(e,t=>t.empty?e.moveByGroup(t,i):Ss(t,i))}function Ds(e,i,n){let r=Er(e).resolve(i.head);var s,o,a,h=n?fr.closedBy:fr.openedBy;for(let t=i.head;;){var l=n?r.childAfter(t):r.childBefore(t);if(!l)break;s=e,a=h,(o=l).type.prop(a)||((a=o.to-o.from)&&(2t.empty?e.moveVertically(t,i):Ss(t,i))}var Ls=t=>Os(t,!1),Bs=t=>Os(t,!0);function Es(e,i){return ks(e,t=>t.empty?e.moveVertically(t,i,e.dom.clientHeight):Ss(t,i))}var Hs=t=>Es(t,!1),Ps=t=>Es(t,!0);function _s(t,e,i){let n=t.visualLineAt(e.head),r=t.moveToLineBoundary(e,i);return r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),i||r.head!=n.from||!n.length||(t=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length)&&e.head!=n.from+t&&(r=B.cursor(n.from+t)),r}var Ns=e=>ks(e,t=>B.cursor(e.visualLineAt(t.head).from,1)),Rs=e=>ks(e,t=>B.cursor(e.visualLineAt(t.head).to,-1));function $s(t,i){let e=bs(t.state.selection,t=>{var e=i(t);return B.range(t.anchor,e.head,e.goalColumn)});return!e.eq(t.state.selection)&&(t.dispatch(xs(t.state,e)),!0)}function zs(e,i){return $s(e,t=>e.moveByChar(t,i))}var Vs=t=>zs(t,t.textDirection!=Ai.LTR),Is=t=>zs(t,t.textDirection==Ai.LTR);function Ws(e,i){return $s(e,t=>e.moveByGroup(t,i))}function Fs(e,i){return $s(e,t=>e.moveVertically(t,i))}var qs=t=>Fs(t,!1),$t=t=>Fs(t,!0);function js(e,i){return $s(e,t=>e.moveVertically(t,i,e.dom.clientHeight))}Vt=t=>js(t,!1),It=t=>js(t,!0),Yt=e=>$s(e,t=>B.cursor(e.visualLineAt(t.head).from)),Gt=e=>$s(e,t=>B.cursor(e.visualLineAt(t.head).to)),Xt=({state:t,dispatch:e})=>(e(xs(t,{anchor:0})),!0),Kt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.doc.length})),!0),Qt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.selection.main.anchor,head:0})),!0),Zt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Js({state:t,dispatch:e},r){var i=t.changeByRange(t=>{let{from:e,to:i}=t;var n;return e==i&&(n=r(e),e=Math.min(e,n),i=Math.max(i,n)),e==i?{range:t}:{changes:{from:e,to:i},range:B.cursor(e)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,annotations:rt.userEvent.of("delete")})),!0)}const Us=(a,h,l)=>Js(a,e=>{let{state:t}=a,i=t.doc.lineAt(e),n;if(!h&&e>i.from&&eUs(t,!1,!0),ee=t=>Us(t,!0,!1);const Ks=(t,l)=>Js(t,e=>{let i=e,{state:n}=t,r=n.doc.lineAt(i),s=n.charCategorizer(i);for(let t=null;;){if(i==(l?r.to:r.from)){i==e&&r.number!=(l?n.doc.lines:1)&&(i+=l?1:-1);break}var o=S(r.text,i-r.from,l)+r.from,a=r.text.slice(Math.min(i,o)-r.from,Math.max(i,o)-r.from),h=s(a);if(null!=t&&h!=t)break;" "==a&&i==e||(t=h),i=o}return i});te=t=>Ks(t,!1),Ut=t=>Ks(t,!0),zr=i=>Js(i,t=>{var e=i.visualLineAt(t).to;return t{var i=[];for(let t=e.from;t<=e.to;){var n=r.doc.lineAt(t);n.number>o&&(e.empty||e.to>n.from)&&(s(n,i,e),o=n.number),t=n.to+1}let t=r.changes(i);return{changes:i,range:B.range(t.mapPos(e.anchor,1),t.mapPos(e.head,1))}})}Qr=({state:o,dispatch:t})=>{let a=Object.create(null),h=new Jr(o,{overrideIndentation:t=>{t=a[t];return null==t?-1:t}});var e=Qs(o,(t,e,i)=>{var n,r,s=jr(h,t.from);null==s||((n=/^\s*/.exec(t.text)[0])!=(r=qr(o,s))||i.from(t(i.update(Qs(i,(t,e)=>{e.push({from:t.from,insert:i.facet(Wr)})}))),!0);const to=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>ks(e,t=>Ds(e.state,t,e.textDirection!=Ai.LTR)),shift:e=>$s(e,t=>Ds(e.state,t,e.textDirection!=Ai.LTR))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>ks(e,t=>Ds(e.state,t,e.textDirection==Ai.LTR)),shift:e=>$s(e,t=>Ds(e.state,t,e.textDirection==Ai.LTR))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Xs(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Ys(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Xs(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Ys(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return 1{var e=Gs(i).map(({from:t,to:e})=>B.range(t,Math.min(e+1,i.doc.length)));return t(i.update({selection:B.create(e),annotations:rt.userEvent.of("keyboardselection")})),!0}},{key:"Mod-i",run:({state:n,dispatch:t})=>{var e=bs(n.selection,t=>{var e;let i=Er(n).resolve(t.head,1);for(;!(i.from=t.to||i.to>t.to&&i.from<=t.from||null===(e=i.parent)||void 0===e)&&e.parent;)i=i.parent;return B.range(i.to,i.from)});return t(xs(n,e)),!0}},{key:"Mod-[",run:({state:o,dispatch:t})=>(t(o.update(Qs(o,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(s){let t=A(s,0,o.tabSize),e=0,i=qr(o,Math.max(0,t-Fr(o)));for(;e{let{state:i}=e,t=i.changes(Gs(i).map(({from:t,to:e})=>(0e.moveVertically(t,!0)).map(t);return e.dispatch({changes:t,selection:n,scrollIntoView:!0}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(i,t,n){let r=!1,e=bs(i.selection,t=>{var e=os(i,t.head,-1)||os(i,t.head,1)||0Ts(t,t.textDirection!=Ai.LTR),shift:t=>Ws(t,t.textDirection!=Ai.LTR)},{mac:"Cmd-ArrowLeft",run:Ns,shift:Yt},{key:"ArrowRight",run:Cs,shift:Is},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Ts(t,t.textDirection==Ai.LTR),shift:t=>Ws(t,t.textDirection==Ai.LTR)},{mac:"Cmd-ArrowRight",run:Rs,shift:Gt},{key:"ArrowUp",run:Ls,shift:qs},{mac:"Cmd-ArrowUp",run:Xt,shift:Qt},{mac:"Ctrl-ArrowUp",run:Hs,shift:Vt},{key:"ArrowDown",run:Bs,shift:$t},{mac:"Cmd-ArrowDown",run:Kt,shift:Zt},{mac:"Ctrl-ArrowDown",run:Ps,shift:It},{key:"PageUp",run:Hs,shift:Vt},{key:"PageDown",run:Ps,shift:It},{key:"Home",run:e=>ks(e,t=>_s(e,t,!1)),shift:e=>$s(e,t=>_s(e,t,!1))},{key:"Mod-Home",run:Xt,shift:Qt},{key:"End",run:e=>ks(e,t=>_s(e,t,!0)),shift:e=>$s(e,t=>_s(e,t,!0))},{key:"Mod-End",run:Kt,shift:Zt},{key:"Enter",run:({state:a,dispatch:t})=>{var e=a.changeByRange(({from:t,to:e})=>{var i=t==e&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Er(t).resolve(e),n=i.childBefore(e),r=i.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(fr.closedBy))&&-1s.from&&t(e(t.update({selection:{anchor:0,head:t.doc.length},annotations:rt.userEvent.of("keyboardselection")})),!0)},{key:"Backspace",run:Jt,shift:Jt},{key:"Delete",run:ee,shift:ee},{key:"Mod-Backspace",mac:"Alt-Backspace",run:te},{key:"Mod-Delete",mac:"Alt-Delete",run:Ut},{mac:"Mod-Backspace",run:i=>Js(i,t=>{var e=i.visualLineAt(t).from;return eUs(t,!1,!1)},{key:"Ctrl-k",run:zr},{key:"Alt-d",run:Ut},{key:"Ctrl-Alt-h",run:te},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{var i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:u.of(["",""])},range:B.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})),!0}},{key:"Ctrl-t",run:({state:n,dispatch:t})=>{var e=n.changeByRange(t=>{if(!t.empty||0==t.from||t.from==n.doc.length)return{range:t};var e=t.from,i=n.doc.lineAt(e),t=e==i.from?e-1:S(i.text,e-i.from,!1)+i.from,i=e==i.to?e+1:S(i.text,e-i.from,!0)+i.from;return{changes:{from:t,to:i,insert:n.doc.slice(e,i).append(n.doc.slice(t,e))},range:B.cursor(i)}});return!e.changes.empty&&(t(n.update(e,{scrollIntoView:!0})),!0)}},{key:"Alt-f",run:t=>Ts(t,!0),shift:t=>Ws(t,!0)},{key:"Alt-b",run:t=>Ts(t,!1),shift:t=>Ws(t,!1)},{key:"Alt-<",run:Xt},{key:"Alt->",run:Kt},{key:"Ctrl-v",run:Ps},{key:"Alt-v",run:Hs}].map(t=>({mac:t.key,run:t.run,shift:t.shift})))),eo={key:"Tab",run:({state:t,dispatch:e})=>t.selection.ranges.some(t=>!t.empty)?Zs({state:t,dispatch:e}):(e(t.update(t.replaceSelection("\t"),{scrollIntoView:!0,annotations:rt.userEvent.of("input")})),!0),shift:Qr},io=tt.define(),no=tt.define(),ro=P.define(),so=P.define({combine(t){return gt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}}),oo=z.define({create(){return wo.empty},update(e,i){var n=i.state.facet(so),r=i.annotation(io);if(r){var s=co.fromTransaction(i),o=r.side;let t=0==o?e.undone:e.done;return t=s?uo(t,t.length,n.minDepth,s):mo(t,i.startState.selection),new wo(0==o?r.rest:t,0==o?t:r.rest)}var t=i.annotation(no);if("full"!=t&&"before"!=t||(e=e.isolate()),!1===i.annotation(rt.addToHistory))return i.changes.empty?e:e.addMapping(i.changes.desc);s=co.fromTransaction(i),o=i.annotation(rt.time),r=i.annotation(rt.userEvent);return s?e=e.addChanges(s,o,r,n.newGroupDelay,n.minDepth):i.selection&&(e=e.addSelection(i.startState.selection,o,r,n.newGroupDelay)),e="full"==t||"after"==t?e.isolate():e},toJSON(t){return{done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}},fromJSON(t){return new wo(t.done.map(co.fromJSON),t.undone.map(co.fromJSON))}});function ao(n,r){return function({state:t,dispatch:e}){let i=t.field(oo,!1);if(!i)return!1;t=i.pop(n,t,r);return!!t&&(e(t),!0)}}const ho=ao(0,!1),lo=ao(1,!1);Ns=ao(0,!0),Yt=ao(1,!0);class co{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new co(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(t=this.startSelection)||void 0===t?void 0:t.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new co(t.changes&&k.fromJSON(t.changes),[],t.mapped&&x.fromJSON(t.mapped),t.startSelection&&B.fromJSON(t.startSelection),t.selectionsAfter.map(B.fromJSON))}static fromTransaction(t){let e=po;for(var i of t.startState.facet(ro)){i=i(t);i.length&&(e=e.concat(i))}return!e.length&&t.changes.empty?null:new co(t.changes.invert(t.startState.doc),e,void 0,t.startState.selection,po)}static selection(t){return new co(void 0,po,void 0,void 0,t)}}function uo(t,e,i,n){let r=t.slice(i+20t.map(e)):po,i);if(!t.changes)return co.selection(n);var r=t.changes.map(e),s=e.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(s):s;return new co(r,nt.mapEffects(t.effects,e),i,t.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[co.selection(n)]:po}class wo{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new wo(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&e-this.prevTimeo.push(t,e)),e.iterChangedRanges((t,e,i,n)=>{for(let t=0;tt.empty!=r.ranges[e].empty).length)?this:new wo(mo(this.done,t),this.undone,e,i)}addMapping(t){return new wo(vo(this.done,t),vo(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,i,t){let n=0==e?this.done:this.undone;if(0==n.length)return null;var r=n[n.length-1];if(t&&r.selectionsAfter.length)return i.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:io.of({side:e,rest:function(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}(n)})});if(r.changes){let t=1==n.length?po:n.slice(0,n.length-1);return r.mapped&&(t=vo(t,r.mapped)),i.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:io.of({side:e,rest:t}),filter:!1})}return null}}wo.empty=new wo(po,po);const yo=[{key:"Mod-z",run:ho,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:lo,preventDefault:!0},{key:"Mod-u",run:Ns,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Yt,preventDefault:!0}];let bo=0;class xo{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=bo++}static define(t){if(null!=t&&t.base)throw new Error("Can not derive from a modified tag");let e=new xo([],null,[]);if(e.set.push(e),t)for(var i of t.set)e.set.push(i);return e}static defineModifier(){let e=new So;return t=>-1t.id-e.id))}}let ko=0;class So{constructor(){this.instances=[],this.id=ko++}static get(e,i){if(!i.length)return e;var t,n=i[0].instances.find(t=>t.base==e&&function(t,i){return t.length==i.length&&t.every((t,e)=>t==i[e])}(i,t.modified));if(n)return n;let r=[],s=new xo(r,e,i);for(t of i)t.instances.push(s);var o,a=function e(i){let n=[i];for(let t=0;tt.scope)?void 0:Object.create(null);return(t,e)=>{var i,n=a&&a[t.id];if(void 0!==n)return n;let r=null;for(i of o){var s=i.match(t,e);s&&(r=r?r+" "+s:s)}return a&&(a[t.id]=r),r}}static define(t,e){return new Oo(t,e||{})}static get(t,e,i){return Do(t)(e,i||gr.none)}}const Lo=I.fallback(hi.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=Er(t.state),this.decorations=this.buildDeco(t,Do(t.state))}update(t){var e=Er(t.state),i=Do(t.state),n=i!=t.startState.facet(Mo);e.lengthr-1)){for(let t=r-1,e=i.length-1;0<=e;e--,t--){var s=i[e];if(s&&s!=n[t])return}return 1}}(e.context,Bo,s)){for(var l of e.tags)(l=u(l,o))&&(t&&(t+=" "),t+=l,1==e.mode?r+=(r?" ":"")+l:0==e.mode&&(i=!0));break}e=e.next}if(t!=g&&(h>p&&g&&f(p,m.from,g),p=h,g=t),!i&&m.firstChild()){do{var c=m.to;n(r,s+1,o),g!=t&&((c=Math.min(d,c))>p&&g&&f(p,c,g),p=c,g=t)}while(m.nextSibling());m.parent()}}}("",0,t.type)}(this.tree,i,r,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=$e.mark({class:i})))});return n.finish()}},{decorations:t=>t.decorations})),Bo=[""];const Eo=xo.define;Rs=Eo(),Gt=Eo(),ee=Eo(Gt),zr=Eo(),Ut=Eo(zr),te=Eo(zr),Xt=Eo(),Kt=Eo(Xt),Ps=Eo(),Hs=Eo(),Qr=Eo(),Ns=Eo(Qr),Yt=Eo();const Ho={comment:Rs,lineComment:Eo(Rs),blockComment:Eo(Rs),docComment:Eo(Rs),name:Gt,variableName:Eo(Gt),typeName:ee,tagName:Eo(ee),propertyName:Eo(Gt),className:Eo(Gt),labelName:Eo(Gt),namespace:Eo(Gt),macroName:Eo(Gt),literal:zr,string:Ut,docString:Eo(Ut),character:Eo(Ut),number:te,integer:Eo(te),float:Eo(te),bool:Eo(zr),regexp:Eo(zr),escape:Eo(zr),color:Eo(zr),url:Eo(zr),keyword:Ps,self:Eo(Ps),null:Eo(Ps),atom:Eo(Ps),unit:Eo(Ps),modifier:Eo(Ps),operatorKeyword:Eo(Ps),controlKeyword:Eo(Ps),definitionKeyword:Eo(Ps),operator:Hs,derefOperator:Eo(Hs),arithmeticOperator:Eo(Hs),logicOperator:Eo(Hs),bitwiseOperator:Eo(Hs),compareOperator:Eo(Hs),updateOperator:Eo(Hs),definitionOperator:Eo(Hs),typeOperator:Eo(Hs),controlOperator:Eo(Hs),punctuation:Qr,separator:Eo(Qr),bracket:Ns,angleBracket:Eo(Ns),squareBracket:Eo(Ns),paren:Eo(Ns),brace:Eo(Ns),content:Xt,heading:Kt,heading1:Eo(Kt),heading2:Eo(Kt),heading3:Eo(Kt),heading4:Eo(Kt),heading5:Eo(Kt),heading6:Eo(Kt),contentSeparator:Eo(Xt),list:Eo(Xt),quote:Eo(Xt),emphasis:Eo(Xt),strong:Eo(Xt),link:Eo(Xt),monospace:Eo(Xt),inserted:Eo(),deleted:Eo(),changed:Eo(),invalid:Eo(),meta:Yt,documentMeta:Eo(Yt),annotation:Eo(Yt),processingInstruction:Eo(Yt),definition:xo.defineModifier(),constant:xo.defineModifier(),function:xo.defineModifier(),standard:xo.defineModifier(),local:xo.defineModifier(),special:xo.defineModifier()};Oo.define([{tag:Ho.link,textDecoration:"underline"},{tag:Ho.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Ho.emphasis,fontStyle:"italic"},{tag:Ho.strong,fontWeight:"bold"},{tag:Ho.keyword,color:"#708"},{tag:[Ho.atom,Ho.bool,Ho.url,Ho.contentSeparator,Ho.labelName],color:"#219"},{tag:[Ho.literal,Ho.inserted],color:"#164"},{tag:[Ho.string,Ho.deleted],color:"#a11"},{tag:[Ho.regexp,Ho.escape,Ho.special(Ho.string)],color:"#e40"},{tag:Ho.definition(Ho.variableName),color:"#00f"},{tag:Ho.local(Ho.variableName),color:"#30a"},{tag:[Ho.typeName,Ho.namespace],color:"#085"},{tag:Ho.className,color:"#167"},{tag:[Ho.special(Ho.variableName),Ho.macroName],color:"#256"},{tag:Ho.definition(Ho.propertyName),color:"#00c"},{tag:Ho.comment,color:"#940"},{tag:Ho.meta,color:"#7a757a"},{tag:Ho.invalid,color:"#f00"}]);const Po=Oo.define([{tag:Ho.link,class:"cmt-link"},{tag:Ho.heading,class:"cmt-heading"},{tag:Ho.emphasis,class:"cmt-emphasis"},{tag:Ho.strong,class:"cmt-strong"},{tag:Ho.keyword,class:"cmt-keyword"},{tag:Ho.atom,class:"cmt-atom"},{tag:Ho.bool,class:"cmt-bool"},{tag:Ho.url,class:"cmt-url"},{tag:Ho.labelName,class:"cmt-labelName"},{tag:Ho.inserted,class:"cmt-inserted"},{tag:Ho.deleted,class:"cmt-deleted"},{tag:Ho.literal,class:"cmt-literal"},{tag:Ho.string,class:"cmt-string"},{tag:Ho.number,class:"cmt-number"},{tag:[Ho.regexp,Ho.escape,Ho.special(Ho.string)],class:"cmt-string2"},{tag:Ho.variableName,class:"cmt-variableName"},{tag:Ho.local(Ho.variableName),class:"cmt-variableName cmt-local"},{tag:Ho.definition(Ho.variableName),class:"cmt-variableName cmt-definition"},{tag:Ho.special(Ho.variableName),class:"cmt-variableName2"},{tag:Ho.typeName,class:"cmt-typeName"},{tag:Ho.namespace,class:"cmt-namespace"},{tag:Ho.macroName,class:"cmt-macroName"},{tag:Ho.propertyName,class:"cmt-propertyName"},{tag:Ho.operator,class:"cmt-operator"},{tag:Ho.comment,class:"cmt-comment"},{tag:Ho.meta,class:"cmt-meta"},{tag:Ho.invalid,class:"cmt-invalid"},{tag:Ho.punctuation,class:"cmt-punctuation"}]);var _o=[{type:"undo",title:"撤销",innerHTML:''},{type:"redo",title:"重做",innerHTML:''},{type:"bold",title:"加粗",innerHTML:''},{type:"italic",title:"倾斜",innerHTML:''},{type:"delete",title:"删除",innerHTML:''},{type:"code-inline",title:"行内代码",innerHTML:''},{type:"indent",title:"缩进",innerHTML:''},{type:"hr",title:"横线",innerHTML:''},{type:"quote",title:"引用",innerHTML:''},{type:"title",title:"标题",innerHTML:''},{type:"ordered-list",title:"有序列表",innerHTML:''},{type:"unordered-list",title:"无序列表",innerHTML:''},{type:"link",title:"超链接",innerHTML:''},{type:"image",title:"插入图片",innerHTML:''},{type:"character",title:"实体符号",innerHTML:''},{type:"table",title:"表格",innerHTML:''},{type:"emoji",title:"符号表情",innerHTML:''},{type:"code-block",title:"代码块",innerHTML:''},{type:"expression",title:"图片表情",innerHTML:''},{type:"mtitle",title:"居中标题",innerHTML:''},{type:"task-no",title:"任务 - 未完成",innerHTML:''},{type:"task-yes",title:"任务 - 已完成",innerHTML:''},{type:"dplayer",title:"M3U8/MP4视频",innerHTML:''},{type:"netease-list",title:"网易云列表",innerHTML:''},{type:"netease-single",title:"网易云单首",innerHTML:''},{type:"bilibili",title:"哔哩哔哩视频",innerHTML:''},{type:"time",title:"当前时间",innerHTML:''},{type:"clean",title:"清屏",innerHTML:''},{type:"download",title:"下载",innerHTML:''},{type:"fullScreen",title:"全屏/取消全屏",innerHTML:''},{type:"draft",title:"保存草稿",innerHTML:''},{type:"publish",title:"发布文章",innerHTML:''},{type:"about",title:"关于",innerHTML:''}];const No=new HyperDown,Ro=window.JoeConfig.playerAPI;function $o(t){t=t.replace(/ /g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=No.makeHtml(t)).replace(/{x}/g,'')).replace(/{ }/g,'')).replace(/{music-list([^}]*)\/}/g,"")).replace(/{music([^}]*)\/}/g,"")).replace(/{bilibili([^}]*)\/}/g,"")).replace(/{dplayer([^}]*)\/}/g,'')).replace(/{mtitle([^}]*)\/}/g,"")).replace(/\:\:\(\s*(呵呵|哈哈|吐舌|太开心|笑眼|花心|小乖|乖|捂嘴笑|滑稽|你懂的|不高兴|怒|汗|黑线|泪|真棒|喷|惊哭|阴险|鄙视|酷|啊|狂汗|what|疑问|酸爽|呀咩爹|委屈|惊讶|睡觉|笑尿|挖鼻|吐|犀利|小红脸|懒得理|勉强|爱心|心碎|玫瑰|礼物|彩虹|太阳|星星月亮|钱币|茶杯|蛋糕|大拇指|胜利|haha|OK|沙发|手纸|香蕉|便便|药丸|红领巾|蜡烛|音乐|灯泡|开心|钱|咦|呼|冷|生气|弱|吐血|狗头)\s*\)/g,function(t,e){return e=encodeURI(e).replace(/%/g,""),``})).replace(/\:\@\(\s*(高兴|小怒|脸红|内伤|装大款|赞一个|害羞|汗|吐血倒地|深思|不高兴|无语|亲亲|口水|尴尬|中指|想一想|哭泣|便便|献花|皱眉|傻笑|狂汗|吐|喷水|看不见|鼓掌|阴暗|长草|献黄瓜|邪恶|期待|得意|吐舌|喷血|无所谓|观察|暗地观察|肿包|中枪|大囧|呲牙|抠鼻|不说话|咽气|欢呼|锁眉|蜡烛|坐等|击掌|惊喜|喜极而泣|抽烟|不出所料|愤怒|无奈|黑线|投降|看热闹|扇耳光|小眼睛|中刀)\s*\)/g,function(t,e){return e=encodeURI(e).replace(/%/g,""),``}),$(".cm-preview-content").html(t),$(".cm-preview-content pre code").each((t,e)=>Prism.highlightElement(e))}class zo extends class{constructor(){$("body").append(` +!function(){"use strict";let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;te)return r[t-1]<=e}(e))n+=d(e),t=e;else{if(!s(e))break;{let t=0,e=n-2;for(;0<=e&&s(c(i,e));)t++,e-=2;if(t%2==0)break;n+=2}}}return n}function a(t,e){for(;0this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){var n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),m.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){var i=[];return this.decompose(t,e,i,0),m.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=new v(this),i=new v(t);for(;;){if(e.next(),i.next(),e.lineBreak!=i.lineBreak||e.done!=i.done||e.value!=i.value)return!1;if(e.done)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new i(this,t,e)}toString(){return this.sliceString(0)}toJSON(){var t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new g(t):m.from(g.split(t,[])):u.empty}}"undefined"!=typeof Symbol&&(u.prototype[Symbol.iterator]=function(){return this.iter()});class g extends u{constructor(t,e=function(t){let e=-1;for(var i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let t=0;;t++){var s=this.text[t],o=r+s.length;if(e<=(i?n:o))return new w(r,o,n,s);r=o+1,n++}}decompose(i,t,n,r){i=i<=0&&t>=this.length?this:new g(p(this.text,i,t),Math.min(t,this.length)-Math.max(0,i));if(1&r){let t=n.pop(),e=f(i.text,t.text.slice(),0,i.length);e.length<=32?n.push(new g(e,t.length+i.length)):(r=e.length>>1,n.push(new g(e.slice(0,r)),new g(e.slice(r))))}else n.push(i)}replace(t,e,i){if(!(i instanceof g))return super.replace(t,e,i);var n=f(this.text,f(i.text,p(this.text,0,t)),e),t=this.length+i.length-(e-t);return n.length<=32?new g(n,t):m.from(g.split(n,[]),t)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;i<=s&&nr&&n&&(a+=o),ri&&(a+=t.slice(Math.max(0,r-i),s-i)),i=e+1}return a}flatten(t){for(var e of this.text)t.push(e)}static split(t,e){let i=[],n=-1;for(var r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new g(i,n)),i=[],n=-1);return-1=n&&(h=a&((n<=r?1:0)|(s<=e?2:0)),n>=r&&e<=s&&!h?o.push(t):t.decompose(r-n,s-n,o,h)),n=e+1}}replace(r,s,o){if(o.lines=n&&s<=e){var a=t.replace(r-n,s-n,o),h=this.lines-t.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let t=this.children.slice();return t[i]=a,new m(t,this.length-(s-r)+o.length)}return super.replace(n,e,a)}n=e+1}return super.replace(r,s,o)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;ir&&i&&(a+=o),rn&&(a+=t.sliceString(r-n,s-n,o)),n=e+1}return a}flatten(t){for(var e of this.children)e.flatten(t)}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(var n of t)i+=n.lines;if(i<32){var r,s=[];for(r of t)r.flatten(s);return new g(s,e)}let o=Math.max(32,i>>5),a=o<<1,h=o>>1,l=[],c=0,d=-1,u=[];function f(){0!=c&&(l.push(1==u.length?u[0]:m.from(u,d)),d=-1,c=u.length=0)}for(var p of t)!function t(e){let i;if(e.lines>a&&e instanceof m)for(var n of e.children)t(n);else e.lines>h&&(c>h||!c)?(f(),l.push(e)):e instanceof g&&c&&(i=u[u.length-1])instanceof g&&e.lines+i.lines<=32?(c+=e.lines,d+=e.length+1,u[u.length-1]=new g(i.text.concat(e.text),i.length+1+e.length)):(c+e.lines>o&&f(),c+=e.lines,d+=e.length+1,u.push(e))}(p);return f(),1==l.length?l[0]:new m(l,e)}}function f(s,o,a=0,h=1e9){for(let i=0,n=0,r=!0;nMath.max(0,n))return this.value=0==n?t:0t.length?n-=t.length:(this.nodes.push(t),this.offsets.push(0this.limit&&(this.value=0r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(i,n=i){for(let t=0,e=0;t"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new x(t)}}class k extends x{constructor(t,e){super(t),this.inserted=e}apply(s){if(this.length!=s.length)throw new RangeError("Applying change set to a document with the wrong length");return T(this,(t,e,i,n,r)=>s=s.replace(i,i+(e-t),r),!1),s}mapDesc(t,e=!1){return D(this,t,e,!0)}invert(i){let n=this.sections.slice(),r=[];for(let t=0,e=0;t>1;r.length>1].toJSON()))}return n}static of(t,s,o){let a=[],h=[],l=0,i=null;function c(t=!1){if(t||a.length){ll&&M(a,t-l,-1),M(a,e-t,n),C(h,a,r),l=e)}}(t),c(!i),i}static empty(t){return new k(t?[t,-1]:[],[])}static fromJSON(i){if(!Array.isArray(i))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let e=0;ee&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==t.length)n.push(t[0],0);else{for(;r.length>1;if(n>1])),!(c||a==h.sections.length||h.sections[a+1]<0);)n=h.sections[a++],r=h.sections[a++];l(s,t,o,e,i),s=t,o=e}}}function D(t,e,r,i=!1){var s=[],o=i?[]:null;let a=new O(t),h=new O(e);for(let i=0,n=0;;)if(-1==a.ins)i+=a.len,a.next();else if(-1==h.ins&&nn&&!a.done&&i+a.leni&&n+h.lenh||0<=o.ins&&o.len>h)&&(t||l>1;return e>=t.length?u.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?u.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class L{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){var t=3&this.flags;return 3==t?null:t}get goalColumn(){var t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){var i=t.mapPos(this.from,e),e=t.mapPos(this.to,e);return i==this.from&&e==this.to?this:new L(i,e,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return B.range(t,e);e=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return B.range(this.anchor,e)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return B.range(t.anchor,t.head)}}class B{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(e,i=-1){return e.empty?this:B.create(this.ranges.map(t=>t.map(e,i)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;tt.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new B(t.ranges.map(t=>L.fromJSON(t)),t.main)}static single(t,e=t){return new B([B.range(t,e)],0)}static create(i,n=0){if(0==i.length)throw new RangeError("A selection needs at least one range");for(let t=0,e=0;et.from-e.from),i=e.indexOf(t);for(let t=1;tr.head?B.range(s,n):B.range(n,s)))}return new B(e,i)}(i.slice(),n);t=r.to}return new B(i,n)}static cursor(t,e=0,i,n){return new L(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i){i=(null!=i?i:33554431)<<5;return ee)throw new RangeError("Selection points outside of document")}let H=0;class P{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.extensions=r,this.id=H++,this.default=t([])}static define(t={}){return new P(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:_),!!t.static,t.enables)}of(t){return new N([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new N(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new N(t,this,2,e)}from(e,i){return i=i||(t=>t),this.compute([e],t=>i(t.field(e)))}}function _(t,i){return t==i||t.length==i.length&&t.every((t,e)=>t===i[e])}class N{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=H++}dynamicSlot(t){var e,i;let n=this.value,r=this.facet.compareInput,s=t[this.id]>>1,o=2==this.type,a=!1,h=!1,l=[];for(i of this.dependencies)"doc"==i?a=!0:"selection"==i?h=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&l.push(t[i.id]);return(e,t)=>{if(!t||t.reconfigured)return e.values[s]=n(e),1;if(!(a&&t.docChanged||h&&(t.docChanged||t.selection)||l.some(t=>0<(1&J(e,t)))))return 0;var i=n(e),t=t.startState.values[s];return(o?function(e,i,n){if(e.length!=i.length)return!1;for(let t=0;tt===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(R).find(t=>t.field==this);return((null===e||void 0===e?void 0:e.create)||this.createF)(t)}slot(t){let o=t[this.id]>>1;return(t,e)=>{if(!e)return t.values[o]=this.create(t),1;let i,n=0;var r,s;e.reconfigured?(r=e.startState,s=this.id,s=null==(s=r.config.address[s])?null:s>>1,i=null==s?this.create(e.startState):e.startState.values[s],n=1):i=e.startState.values[o];e=this.updateF(i,e);return n||this.compareF(i,e)||(n=1),n&&(t.values[o]=e),n}}init(t){return[this,R.of({field:this,create:t})]}get extension(){return this}}const V={fallback:3,default:2,extend:1,override:0};function t(e){return t=>new W(t,e)}const I={fallback:t(V.fallback),default:t(V.default),extend:t(V.extend),override:t(V.override)};class W{constructor(t,e){this.inner=t,this.prec=e}}class F{of(t){return new q(this,t)}reconfigure(t){return F.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class q{constructor(t,e){this.compartment=t,this.inner=e}}class j{constructor(t,e,i,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,n){let i=[],r=Object.create(null);var s,o,a=new Map;for(s of function(t,a,h){let l=[[],[],[],[]],c=new Map;return function t(e,i){var n=c.get(e);if(null!=n){if(i<=n)return;var r=l[n].indexOf(e);-1t.concat(e))}(t,e,a))(s instanceof z?i:r[s.facet.id]||(r[s.facet.id]=[])).push(s);let h=Object.create(null),l=[],c=[];for(let e of i)h[e.id]=c.length<<1,c.push(t=>e.slot(t));for(o in r){let i=r[o],e=i[0].facet;if(i.every(t=>0==t.type)){h[e.id]=l.length<<1|1;let t=e.combine(i.map(t=>t.value));var d=n?n.config.address[e.id]:null;null!=d&&(d=U(n,d),e.compare(t,d)&&(t=d)),l.push(t)}else{for(let e of i)0==e.type?(h[e.id]=l.length<<1|1,l.push(e.value)):(h[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));h[e.id]=c.length<<1,c.push(t=>function(e,l,t){let c=t.map(t=>e[t.id]),d=t.map(t=>t.type),u=c.filter(t=>!(1&t)),f=e[l.id]>>1;return(e,t)=>{var i,n=t?t.reconfigured?t.startState.config.address[l.id]:f<<1:null;let r=null==n;for(i of u)1&J(e,i)&&(r=!0);if(!r)return 0;let s=[];for(let t=0;tt(h)),h,l)}}function J(t,e){if(1&e)return 2;var i=e>>1,e=t.status[i];if(4==e)throw new Error("Cyclic dependency between fields and/or facets");if(2&e)return e;t.status[i]=4;e=t.config.dynamicSlots[i](t,t.applying);return t.status[i]=2|e}function U(t,e){return(1&e?t.config.staticValues:t.values)[e>>1]}const K=P.define(),G=P.define({combine:t=>t.some(t=>t),static:!0}),X=P.define({combine:t=>t.length?t[0]:void 0,static:!0}),Y=P.define(),Q=P.define(),Z=P.define();class tt{constructor(t,e){this.type=t,this.value=e}static define(){return new et}}class et{of(t){return new tt(this,t)}}class it{constructor(t){this.map=t}of(t){return new nt(this,t)}}class nt{constructor(t,e){this.type=t,this.value=e}map(t){t=this.type.map(this.value,t);return void 0===t?void 0:t==this.value?this:new nt(this.type,t)}is(t){return this.type==t}static define(t={}){return new it(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(var n of t){n=n.map(e);n&&i.push(n)}return i}}nt.reconfigure=nt.define(),nt.appendConfig=nt.define();class rt{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&E(i,e.newLength),r.some(t=>t.type==rt.time)||(this.annotations=r.concat(rt.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(var e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}}function st(t,e,i){let n,r,s;return s=i?(n=e.changes,r=k.empty(e.changes.length),t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),t.changes.compose(n)),{changes:s,selection:e.selection?e.selection.map(r):null===(i=t.selection)||void 0===i?void 0:i.map(n),effects:nt.mapEffects(t.effects,n).concat(nt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ot(t,e,i){var n=e.selection;return{changes:e.changes instanceof k?e.changes:k.of(e.changes||[],i,t.facet(X)),selection:n&&(n instanceof B?n:B.single(n.anchor,n.head)),effects:lt(e.effects),annotations:lt(e.annotations),scrollIntoView:!!e.scrollIntoView}}function at(e,i,n){let r=ot(e,i.length?i[0]:{},e.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let t=1;t=r[i]))t=r[i++],e=r[i++];else{if(!(n{if(!/\S/.test(e))return ct.Space;if(function(i){if(ut)return ut.test(i);for(let e=0;enull),n)for(var r in t.address){var s=t.address[r],r=n.startState.config.address[r];null!=r&&0==(1&s)&&(this.values[s>>1]=U(n.startState,r))}(this.applying=n)&&(n._state=this);for(let t=0;tn.set(e,t)),e=null),n.set(r.value.compartment,r.value.extension)):r.is(nt.reconfigure)?(e=null,i=r.value):r.is(nt.appendConfig)&&(e=null,i=lt(i).concat(r.value));new pt(e||j.resolve(i,n,this),t.newDoc,t.newSelection,t)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:B.cursor(t.from+e.length)}))}changeByRange(r){var s=this.selection,t=r(s.ranges[0]);let o=this.changes(t.changes),a=[t.range],h=lt(t.effects);for(let n=1;ne.spec.fromJSON(i,t)))}return pt.create({doc:t.doc,selection:B.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=j.resolve(t.extensions||[],new Map);var i=t.doc instanceof u?t.doc:u.of((t.doc||"").split(e.staticFacet(pt.lineSeparator)||y));let n=t.selection?t.selection instanceof B?t.selection:B.single(t.selection.anchor,t.selection.head):B.single(0);return E(n,i.length),e.staticFacet(G)||(n=n.asSingle()),new pt(e,i,n)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||"\n"}phrase(t){for(var e of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e){let i=[];for(var n of this.facet(K))for(var r of n(this,e))Object.prototype.hasOwnProperty.call(r,t)&&i.push(r[t]);return i}charCategorizer(t){return ft(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-i,o=t-i;for(;0t.length?t[0]:4}),pt.lineSeparator=X,pt.phrases=P.define(),pt.languageData=K,pt.changeFilter=Y,pt.transactionFilter=Q,pt.transactionExtender=Z,F.reconfigure=nt.define();const mt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),vt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class yt{constructor(t,e){this.rules=[];let{finish:c}=e||{};function d(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(var i in t)!function t(i,e,n,r){let s=[],o=/^@(\w+)\b/.exec(i[0]),a=o&&"keyframes"==o[1];if(o&&null==e)return n.push(i[0]+";");for(var h in e){var l=e[h];if(/&/.test(h))t(h.split(/,\s*/).map(e=>i.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),l,n);else if(l&&"object"==typeof l){if(!o)throw new RangeError("The value of a property ("+h+") should be a primitive value.");t(d(h),l,s,a)}else null!=l&&s.push(h.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+l+";")}(s.length||a)&&n.push((!c||o||r?i:i.map(c)).join(", ")+" {"+s.join(" ")+"}")}(d(i),t[i],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=wt[mt]||1;return wt[mt]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[vt]||new xt(t)).mount(Array.isArray(e)?e:[e])}}let bt=null;class xt{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(bt)return e.adoptedStyleSheets=[bt.sheet].concat(e.adoptedStyleSheets),e[vt]=bt;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),bt=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[vt]=this}mount(n){let r=this.sheet,s=0,o=0;for(let i=0;i>1,h=o[a]-i||(n<0?this.value[a].startSide:this.value[a].endSide)-r;if(a==t)return 0<=h?t:e;0<=h?e=a:t=1+a}}between(i,n,r,s){for(let t=this.findIndex(n,-1),e=this.findIndex(r,1,void 0,t);tr||n==r&&0this.chunkEnd(o.chunkIndex)||ro.to||r500<=t.maxPoint||t!=Ct.empty&&i.indexOf(t)<0&&t.maxPoint>=r),o=i.filter(t=>500<=t.maxPoint||t!=Ct.empty&&e.indexOf(t)<0&&t.maxPoint>=r),a=function(t,e){let i=new Map;for(var n of t)for(let t=0;tEt(h,t,l,e,i,n)),t.empty&&0==t.length&&Et(h,0,l,0,0,n)}static spans(t,e,i,n,r=-1){let s=new Bt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){var h=Math.min(s.to,i);if(s.point?(n.point(o,h,s.point,s.activeForPoint(s.to),a),a=s.openEnd(h)+(s.to>h?1:0)):h>o&&(n.span(o,h,s.active,a),a=s.openEnd(h)),s.to>i)break;o=s.to,s.next()}return a}static of(t,e=!1){let i=new Tt;for(var n of t instanceof St?[t]:e?t.slice().sort(At):t)i.add(n.from,n.to,n.value);return i.finish()}}Ct.empty=new Ct([],[],null,-1),Ct.empty.nextLayer=Ct.empty;class Tt{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(t){this.chunks.push(new Mt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(t,e,i)}addInner(t,e,i){var n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);var i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Ct.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;t=new Ct(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,t}}class Dt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex=this.minPoint)break}}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class Ot{constructor(t){this.heap=t}static from(i,n=null,r=-1){let s=[];for(let e=0;e=r&&s.push(new Dt(t,n,r,e));return 1==s.length?s[0]:new Ot(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(var i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(var i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(n,r){for(let i=n[r];;){let t=1+(r<<1);if(t>=n.length)break;let e=n[t];if(t+1e){this.to=this.activeTo[t],this.endSide=this.active[t].endSide;break}this.removeActive(t),i&&Ht(i,t)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}t=this.cursor.value;if(t.point){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.frome&&this.forward(this.to,this.endSide);break}this.addActive(i),this.cursor.next()}}if(i){let t=0;for(;tthis.pointRank);t++)(this.activeTo[t]>e||this.activeTo[t]==e&&this.active[t].endSide>this.point.endSide)&&i.push(this.active[t]);return i}openEnd(t){let e=0;for(;et;)e++;return e}}function Et(t,e,i,n,r,s){t.goto(e),i.goto(n);var o=n+r;let a=n,h=n-e;for(;;){var l=t.to+h-i.to||t.endSide-i.endSide,c=l<0?t.to+h:i.to,d=Math.min(c,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))||s.comparePoint(a,d,t.point,i.point):d>a&&!function(e,i){if(e.length!=i.length)return!1;for(let t=0;t=i;t--)e[t+1]=e[t];e[i]=t}function _t(e,i){let n=-1,r=1e9;for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},$t="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),zt="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Vt="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),It="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ft=$t&&(It||+$t[1]<57)||Vt&&It,qt=0;qt<10;qt++)Nt[48+qt]=Nt[96+qt]=String(qt);for(qt=1;qt<=24;qt++)Nt[qt+111]="F"+qt;for(var jt,qt=65;qt<=90;qt++)Nt[qt]=String.fromCharCode(qt+32),Rt[qt]=String.fromCharCode(qt);for(jt in Nt)Rt.hasOwnProperty(jt)||(Rt[jt]=Nt[jt]);var[Jt,Ut]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],Kt=/Edge\/(\d+)/.exec(Jt.userAgent),Gt=/MSIE \d/.test(Jt.userAgent),Xt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Jt.userAgent),Yt=!!(Gt||Xt||Kt),Qt=!Yt&&/gecko\/(\d+)/i.test(Jt.userAgent),Zt=!Yt&&/Chrome\/(\d+)/.exec(Jt.userAgent),te="webkitFontSmoothing"in Ut.documentElement.style,ee=!Yt&&/Apple Computer/.test(Jt.vendor),ie={mac:/Mac/.test(Jt.platform),ie:Yt,ie_version:Gt?Ut.documentMode||6:Xt?+Xt[1]:Kt?+Kt[1]:0,gecko:Qt,gecko_version:Qt?+(/Firefox\/(\d+)/.exec(Jt.userAgent)||[0,0])[1]:0,chrome:!!Zt,chrome_version:Zt?+Zt[1]:0,ios:ee&&(/Mobile\/\w+/.test(Jt.userAgent)||2this.pos||t==this.pos&&(0t.width)||a),o?ue(a,o<0):a}class De extends Ae{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||De)(t,e,i)}slice(t){return De.create(this.widget,this.length-t,this.side)}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r){return!(i&&(!(i instanceof De&&this.widget.compare(i.widget))||0i&&st?i[r]=Math.max(i[r],e):i.push(t,e)}Ie.prototype.point=!0;class qe extends be{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof qe))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Le(this,t,e,i?i.children:je,r,s),!0}split(t){let e=new qe;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].slice(n),0),this.children[i].merge(n,this.children[i].length,null,0,0),i++);for(let t=i;t!t.length||t[0]});class ri{constructor(t,e){this.field=t,this.get=e}}class si{from(t){return new ri(this,t)}static define(){return new si}}si.decorations=si.define(),si.scrollMargins=si.define();let oi=0;const ai=P.define();class hi{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=ai.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:r}=e||{},s=[];if(n)for(var o of Array.isArray(n)?n:[n])s.push(o);return i&&s.push(li.from(t=>({plugin:t,handlers:i}))),r&&s.push(si.decorations.from(r)),new hi(oi++,t,s)}static fromClass(e,t){return hi.define(t=>new e(t),t)}}const li=si.define();class ci{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){for(var{field:i,get:n}of this.spec.fields)i==t&&e.push(n(this.value))}update(e){if(this.value){if(this.mustUpdate){var i=this.mustUpdate;if(this.mustUpdate=null,!this.value.update)return this;try{this.value.update(i)}catch(t){if(ii(i.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}return ci.dummy}}}else try{this.value=this.spec.create(e)}catch(t){return ii(e.state,t,"CodeMirror plugin crashed"),ci.dummy}return this}destroy(e){var t;if(null!==(t=this.value)&&void 0!==t&&t.destroy)try{this.value.destroy()}catch(t){ii(e.state,t,"CodeMirror plugin crashed")}}}ci.dummy=new ci(hi.define(()=>({})));const di=P.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),ui=P.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),fi=P.define(),pi=P.define();class gi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new gi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;0i.toA)){if(n.toAr.push(new gi(t,e,i,n))),this.changedRanges=r;i=t.hasFocus;i!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=i,this.flags|=1),this.docChanged&&(this.flags|=2)}get viewportChanged(){return 0<(4&this.flags)}get heightChanged(){return 0<(2&this.flags)}get geometryChanged(){return this.docChanged||0<(18&this.flags)}get focusChanged(){return 0<(1&this.flags)}get docChanged(){return this.transactions.some(t=>t.docChanged)}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class vi extends be{constructor(t){super(),this.view=t,this.compositionDeco=$e.none,this.decorations=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.setDOM(t.contentDOM),this.children=[new qe],this.children[0].setParent(this),this.updateInner([new gi(0,0,0,t.state.doc.length)],this.updateDeco(),0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;0ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=0),this.view.inputState.composing<0?this.compositionDeco=$e.none:t.transactions.length&&(this.compositionDeco=function(t,e){var i=ne(t.root),i=i.focusNode&&bi(i.focusNode,i.focusOffset,0);if(!i)return $e.none;let n=t.docView.nearest(i),r,s,o=i;if(n instanceof Ae){for(;n.parent instanceof Ae;)n=n.parent;r=n.posAtStart,s=r+n.length,o=n.dom}else{if(!(n instanceof qe))return $e.none;{for(;o.parentNode!=n.dom;)o=o.parentNode;let t=o.previousSibling;for(;t&&!be.get(t);)t=t.previousSibling;r=s=t?be.get(t).posAtEnd:n.posAtStart}}let a=e.mapPos(r,1),h=Math.max(a,e.mapPos(s,-1)),l=i.nodeValue,{state:c}=t;if(h-a"pointerselection"==t.annotation(rt.userEvent));return 0==this.dirty&&0==e.length&&!(12&t.flags)&&t.state.selection.main.from>=this.view.viewport.from&&t.state.selection.main.to<=this.view.viewport.to?(this.updateSelection(s,o),!1):(this.updateInner(e,a,t.startState.doc.length,s,o),!0)}updateInner(t,e,i,n=!1,r=!1){this.updateChildren(t,e,i),this.view.observer.ignore(()=>{this.dom.style.height=this.view.viewState.domHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";var t=ie.chrome?{node:ne(this.view.root).focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,null!=t&&t.written&&(n=!0),this.updateSelection(n,r),this.dom.style.height=""})}updateChildren(e,i,t){let n=this.childCursor(t);for(let t=e.length-1;;t--){var r=0<=t?e[t]:null;if(!r)break;var{fromA:s,toA:o,fromB:a,toB:h}=r,{content:l,breakAtStart:c,openStart:d,openEnd:r}=Ue.build(this.view.state.doc,a,h,i),{i:a,off:h}=n.findPos(o,1),{i:o,off:s}=n.findPos(s,-1);this.replaceRange(o,s,a,h,l,c,d,r)}}replaceRange(e,i,n,r,s,o,a,h){let l=this.children[e],c=s.length?s[s.length-1]:null;var d=c?c.breakAfter:o;if(e!=n||o||d||!(s.length<2)||!l.merge(i,r,s.length?c:null,0==i,a,h)){let t=this.children[n];for(rn.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new we(t,0),e=!0}let s=ne(this.root);!(e||!s.focusNode||ie.gecko&&i.empty&&xi(s.focusNode,s.focusOffset))&&ae(n.node,n.offset,s.anchorNode,s.anchorOffset)&&ae(r.node,r.offset,s.focusNode,s.focusOffset)||this.view.observer.ignore(()=>{var t,e;if(i.empty)ie.gecko&&(!(t=xi(n.node,n.offset))||3==t||(e=bi(n.node,n.offset,1==t?1:-1))&&(n=new we(e,1==t?0:e.nodeValue.length))),s.collapse(n.node,n.offset),null!=i.bidiLevel&&null!=s.cursorBidiLevel&&(s.cursorBidiLevel=i.bidiLevel);else if(s.extend)s.collapse(n.node,n.offset),s.extend(r.node,r.offset);else{let t=document.createRange();i.anchor>i.head&&([n,r]=[r,n]),t.setEnd(r.node,r.offset),t.setStart(n.node,n.offset),s.removeAllRanges(),s.addRange(t)}}),this.impreciseAnchor=n.precise?null:new we(s.anchorNode,s.anchorOffset),this.impreciseHead=r.precise?null:new we(s.focusNode,s.focusOffset)}}enforceCursorAssoc(){var t,e,i=this.view.state.selection.main;let n=ne(this.root);i.empty&&i.assoc&&n.modify&&((e=qe.find(this,i.head))&&(t=e.posAtStart,i.head!=t&&i.head!=t+e.length&&(t=this.coordsAt(i.head,-1),e=this.coordsAt(i.head,1),!t||!e||t.bottom>e.top||(e=this.domAtPos(i.head+i.assoc),n.collapse(e.node,e.offset),n.modify("move",i.assoc<0?"forward":"backward","lineboundary")))))}mayControlSelection(){return this.view.state.facet(ni)?this.root.activeElement==this.dom:se(this.dom,ne(this.root))}nearest(e){for(let t=e;t;){var i=be.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=s&&(r.push(t.dom.getBoundingClientRect().height),(h=t.dom.scrollWidth)>a&&(this.minWidth=a=h,this.minWidthFrom=i,this.minWidthTo=e)),i=e+t.breakAfter}return r}measureTextSize(){for(var t of this.children)if(t instanceof qe){t=t.measureTextSize();if(t)return t}let e=document.createElement("div"),i,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);var t=oe(e.firstChild)[0];i=e.getBoundingClientRect().height,n=t?t.width/27:7,e.remove()}),{lineHeight:i,charWidth:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ke(this.children,t,e)}computeBlockGapDeco(){let i=[],n=this.view.viewState;for(let t=0,e=0;;e++){var r,s=e==n.viewports.length?null:n.viewports[e],o=s?s.from-1:this.length;if(o>t&&(r=n.lineAt(o,0).bottom-n.lineAt(t,0).top,i.push($e.replace({widget:new wi(r),block:!0,inclusive:!0}).range(t,o))),!s)break;t=s.to+1}return $e.set(i)}updateDeco(){return this.decorations=[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco,this.compositionDeco,...this.view.state.facet(fi),...this.view.pluginField(si.decorations)]}scrollPosIntoView(t,r){var s,o,a,r=this.coordsAt(t,r);if(r){let t=0,e=0,i=0,n=0;for(var h of this.view.pluginField(si.scrollMargins))h&&({left:s,right:o,top:a,bottom:h}=h,null!=s&&(t=Math.max(t,s)),null!=o&&(e=Math.max(e,o)),null!=a&&(i=Math.max(i,a)),null!=h&&(n=Math.max(n,h)));!function(t,s){let e=t.ownerDocument,o=e.defaultView;for(let r=t.parentNode;r;)if(1==r.nodeType){let t,e=r==document.body;if(e)t={left:0,right:(h=o).innerWidth,top:0,bottom:h.innerHeight};else{if(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth){r=r.parentNode;continue}h=r.getBoundingClientRect();t={left:h.left,right:h.left+r.clientWidth,top:h.top,bottom:h.top+r.clientHeight}}let i=0,n=0;var a;if(s.topt.bottom&&(n=s.bottom-t.bottom+5),s.leftt.right&&(i=s.right-t.right+5),(i||n)&&(e?o.scrollBy(i,n):(n&&(a=r.scrollTop,r.scrollTop+=n,n=r.scrollTop-a),i&&(a=r.scrollLeft,r.scrollLeft+=i,i=r.scrollLeft-a),s={left:s.left-i,top:s.top-n,right:s.right-i,bottom:s.bottom-n})),e)break;r=r.parentNode}else{if(11!=r.nodeType)break;r=r.host}var h}(this.dom,{left:r.left-t,top:r.top-i,right:r.right+e,bottom:r.bottom+n})}}}class wi extends Ne{constructor(t){super(),this.height=t}toDOM(){var t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}class yi extends Ne{constructor(t,e){super(),this.top=t,this.text=e}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Oe}}function bi(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0=i){if(o.level==n)return t;(s<0||(0!=r?r<0?o.fromi:e[s].level>o.level))&&(s=t)}}if(s<0)throw new RangeError("Index out of range");return s}}const Ni=[];function Ri(o,t){var r,a=o.length,h=t==Mi?1:2,l=t==Mi?2:1;if(!o||1==h&&!Pi.test(o))return $i(a);for(let e=0,i=h,n=h;ep;){for(var m=t,v=2!=Ni[--t];t>p&&v==(2!=Ni[t-1]);)t--;i.push(new _i(t,m,v?2:1))}else i.push(new _i(p,e,0))}else for(let t=0;te.top+1}function Ii(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Fi(t,n,r){let s,o,a,h,l,c,d,u;for(let i=t.firstChild;i;i=i.nextSibling){var f=oe(i);for(let e=0;em?g.left-m:Math.max(0,m-g.right)),g=(m=r,(g=t).top>m?g.top-m:Math.max(0,m-g.bottom));if(0==p&&0==g)return(3==i.nodeType?qi:Fi)(i,n,r);(!s||h>g||h==g&&a>p)&&(s=i,o=t,a=p,h=g),0==p?r>t.bottom&&(!d||d.bottomt.top)&&(c=i,u=t):d&&Vi(d,t)?d=Wi(d,t.bottom):u&&Vi(u,t)&&(u=Ii(u,t.top))}}var m,g;if(d&&d.bottom>=r?(s=l,o=d):u&&u.top<=r&&(s=c,o=u),!s)return{node:t,offset:0};var e=Math.max(o.left,Math.min(o.right,n));return 3==s.nodeType?qi(s,e,r):a||"true"!=s.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,s)+(n>=(o.left+o.right)/2?1:0)}:Fi(s,e,r)}function qi(n,r,e){var t=n.nodeValue.length;let s=-1,o=1e9,a=0;for(let i=0;ie?l.top-e:e-l.bottom)-1;if(l.left-1<=r&&l.right+1>=r&&c=(l.left+l.right)/2,e=t;if((ie.chrome||ie.gecko)&&ve(n,i).getBoundingClientRect().left==l.right&&(e=!t),c<=0)return{node:n,offset:i+(e?1:0)};s=i+(e?1:0),o=c}}}}return{node:n,offset:-1i||s.bottomi?-1:1,i=Math.min(s.bottom-o,Math.max(s.top+o,i)),t)return-1;t=!0}if(s.type==Re.Text)break;i=0e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:null;t=Math.max(r.left+1,Math.min(r.right-1,t));let l=e.root,c=l.elementFromPoint(t,i),d,u=-1;return!c||!e.contentDOM.contains(c)||e.docView.nearest(c)instanceof De||(l.caretPositionFromPoint?(a=l.caretPositionFromPoint(t,i))&&({offsetNode:d,offset:u}=a):!l.caretRangeFromPoint||(a=l.caretRangeFromPoint(t,i))&&({startContainer:d,startOffset:u}=a,ie.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=e.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return ve(e,n-1,n).getBoundingClientRect().left>i}(d,u,t)&&(d=void 0))),d&&e.docView.dom.contains(d)||(h=qe.find(e.docView,h),{node:d,offset:u}=Fi(h.dom,t,i)),e.docView.posFromDOM(d,u)}function Ji(r,t,s,o){let a=r.state.doc.lineAt(t.head),h=r.bidiSpans(a);for(let i=t,n=null;;){let t=function(t,e,i,n,r){let s=n.head-t.from,o=-1;if(0==s){if(!r||!t.length)return null;e[0].level!=i&&(s=e[0].side(!1,i),o=0)}else if(s==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(s=t.side(!0,i),o=e.length-1)}o<0&&(o=_i.find(e,s,null!==(h=n.bidiLevel)&&void 0!==h?h:-1,n.assoc));let a=e[o];s==a.side(r,i)&&(a=e[o+=r?1:-1],s=a.side(!r,i));var h=r==(a.dir==i),n=S(t.text,s,h);if(zi=t.text.slice(Math.min(s,n),Math.max(s,n)),n!=a.side(r,i))return B.cursor(n+t.from,h?-1:1,a.level);let l=o==(r?e.length-1:0)?null:e[o+(r?1:-1)];return l||a.level==i?l&&l.level>1;for(let t=s<0?o.top:o.bottom,e=0;e<50;e+=10){var d=ji(i,{x:l,y:t+(c+e)*s},s);if(null==d)break;if(d!=r)return B.cursor(d,void 0,void 0,h)}}let{doc:u}=i.state,f=u.lineAt(r),p=i.state.tabSize,g=t.goalColumn,m=0;if(null==g){for(const x=u.iterRange(f.from,r);!x.next().done;)m=A(x.value,m,p);g=m*i.defaultCharacterWidth}else m=Math.round(g/i.defaultCharacterWidth);if(s<0&&0==f.from)return B.cursor(0);if(0=m&&!k.next().done;){var{offset:y,leftOver:b}=function(e,i,n,r){for(let t=0;t{"keydown"==i&&this.keydown(n,t)||Yi(n,t)&&!this.ignoreDuringComposition(t)&&(this.mustFlushObserver(t)&&n.observer.forceFlush(),this.runCustomHandlers(i,n,t)?t.preventDefault():e(n,t))}),this.registeredEvents.push(i)}this.notifiedFocused=n.hasFocus,this.ensureHandlers(n)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(i){var t;for(t of this.customHandlers=i.pluginField(li))for(let e in t.handlers)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),i.contentDOM.addEventListener(e,t=>{Yi(i,t)&&this.runCustomHandlers(e,i,t)&&t.preventDefault()}))}runCustomHandlers(i,n,r){for(var s of this.customHandlers){let t=s.handlers[i],e=!1;if(t){try{e=t.call(s.plugin,r,n)}catch(t){ii(n.state,t)}if(e||r.defaultPrevented)return ie.android&&"keydown"==i&&13==r.keyCode&&n.observer.flushSoon(),!0}}return!1}runScrollHandlers(e,i){for(var n of this.customHandlers){let t=n.handlers.scroll;if(t)try{t.call(n.plugin,i,e)}catch(t){ii(e.state,t)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!this.screenKeyEvent(t,e))return!(!ie.ios||13!=e.keyCode&&8!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this[13==e.keyCode?"lastIOSEnter":"lastIOSBackspace"]=Date.now(),!0)}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(0=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}(e,i)&&null,!1===this.dragging&&(i.preventDefault(),this.select(i))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(t)}up(t){null==this.dragging&&this.select(this.startEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,annotations:rt.userEvent.of("pointerselection"),scrollIntoView:!0})}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)}}function Yi(i,n){if(!n.bubbles)return 1;if(!n.defaultPrevented){for(let t=n.target,e;t!=i.contentDOM;t=t.parentNode)if(!t||11==t.nodeType||(e=be.get(t))&&e.ignoreEvent(n))return;return 1}}const Qi=Object.create(null),Zi=ie.ie&&ie.ie_version<15||ie.ios&&ie.webkit_version<604;function tn(t,r){let{state:s}=t,e,o=1,a=s.toText(r),h=a.lines==s.selection.ranges.length;if(cn&&s.selection.ranges.every(t=>t.empty)&&cn==a.toString()){let n=-1;e=s.changeByRange(t=>{var e=s.doc.lineAt(t.from);if(e.from==n)return{range:t};n=e.from;var i=s.toText((h?a.line(o++).text:r)+s.lineBreak);return{changes:{from:e.from,insert:i},range:B.cursor(t.from+i.length)}})}else e=h?s.changeByRange(t=>{var e=a.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:B.cursor(t.from+e.length)}}):s.replaceSelection(a);t.dispatch(e,{annotations:rt.userEvent.of("paste"),scrollIntoView:!0})}Qi.keydown=(t,e)=>{t.inputState.setSelectionOrigin("keyboardselection")};let en=0;function nn(i,n,r,t){if(1==t)return B.cursor(n,r);if(2==t)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return B.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=S(r.text,s,!1):a=S(r.text,s);for(var h=n(r.text.slice(o,a));0{1==(e=e).touches.length&&e.touches[0].radiusX<=1&&e.touches[0].radiusY<=1||(en=Date.now()),t.inputState.setSelectionOrigin("pointerselection")},Qi.touchmove=t=>{t.inputState.setSelectionOrigin("pointerselection")},Qi.mousedown=(e,i)=>{if(e.observer.flush(),!(en>Date.now()-2e3)){let t=null;for(var n of e.state.facet(Qe))if(t=n(e,i),t)break;t||0!=i.button||(t=function(o,t){let a=on(o,t),h=function(t){if(!an)return t.detail;var e=hn;return hn=t,ln=!e||e.timeStamp>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(ln+1)%3:1}(t),l=o.state.selection,c=a,d=t;return{update(t){t.changes&&(a&&(a.pos=t.changes.mapPos(a.pos)),l=l.map(t.changes))},get(t,e,i){let n;if(t.clientX==d.clientX&&t.clientY==d.clientY?n=c:(n=c=on(o,t),d=t),!n||!a)return l;let r=nn(o,n.pos,n.bias,h);var s;return a.pos==n.pos||e||(s=nn(o,a.pos,a.bias,h),t=Math.min(s.from,r.from),s=Math.max(s.to,r.to),r=tge(e.contentDOM)),e.inputState.startMouseSelection(e,i,t))}};let rn=(t,e)=>t>=e.top&&t<=e.bottom,sn=(t,e,i)=>rn(e,i)&&t>=i.left&&t<=i.right;function on(t,e){var i=t.posAtCoords({x:e.clientX,y:e.clientY});return null==i?null:{pos:i,bias:function(t,e,i,n){let r=qe.find(t.docView,e);return r&&0!=(t=e-r.posAtStart)&&(t==r.length||(e=r.coordsAt(t,-1))&&sn(i,n,e)||(!(t=r.coordsAt(t,1))||!sn(i,n,t))&&e&&rn(n,e))?-1:1}(t,i,e.clientX,e.clientY)}}const an=ie.ie&&ie.ie_version<=11;let hn=null,ln=0;Qi.dragstart=(t,e)=>{var{selection:{main:i}}=t.state;let{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Qi.drop=(e,i)=>{if(i.dataTransfer&&e.state.facet(ni)){var n=e.posAtCoords({x:i.clientX,y:i.clientY}),r=i.dataTransfer.getData("Text");if(null!=n&&r){i.preventDefault();var{mouseSelection:i}=e.inputState,i=i&&i.dragging&&i.dragMove?{from:i.dragging.from,to:i.dragging.to}:null,r={from:n,insert:r};let t=e.state.changes(i?[i,r]:r);e.focus(),e.dispatch({changes:t,selection:{anchor:t.mapPos(n,-1),head:t.mapPos(n,1)},annotations:rt.userEvent.of("drop")})}}},Qi.paste=(e,i)=>{if(e.state.facet(ni)){e.observer.flush();let t=Zi?null:i.clipboardData;var n=t&&t.getData("text/plain");n?(tn(e,n),i.preventDefault()):function(e){let i=e.dom.parentNode;if(i){let t=i.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{e.focus(),t.remove(),tn(e,t.value)},50)}}(e)}};let cn=null;function dn(t){t.docView.compositionDeco.size&&t.update([])}Qi.copy=Qi.cut=(e,i)=>{var{text:n,ranges:r,linewise:s}=function(e){let i=[],n=[],r=!1;for(var t of e.selection.ranges)t.empty||(i.push(e.sliceDoc(t.from,t.to)),n.push(t));if(!i.length){let t=-1;for(var{from:s}of e.selection.ranges){s=e.doc.lineAt(s);s.number>t&&(i.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),t=s.number}r=!0}return{text:i.join(e.lineBreak),ranges:n,linewise:r}}(e.state);if(n){cn=s?n:null;let t=Zi?null:i.clipboardData;t?(i.preventDefault(),t.clearData(),t.setData("text/plain",n)):function(e,i){let n=e.dom.parentNode;if(n){let t=n.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.value=i,t.focus(),t.selectionEnd=i.length,t.selectionStart=0,setTimeout(()=>{t.remove(),e.focus()},50)}}(e,n),"cut"==i.type&&e.state.facet(ni)&&e.dispatch({changes:r,scrollIntoView:!0,annotations:rt.userEvent.of("cut")})}},Qi.focus=Qi.blur=t=>{setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)},Qi.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout(()=>{t.viewState.printing=!1,t.requestMeasure()},2e3)},Qi.compositionstart=Qi.compositionupdate=t=>{t.inputState.composing<0&&(t.docView.compositionDeco.size&&(t.observer.flush(),dn(t)),t.inputState.composing=0)},Qi.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),setTimeout(()=>{t.inputState.composing<0&&dn(t)},50)};const un=["pre-wrap","normal","pre-line"];class fn{constructor(){this.doc=u.empty,this.lineWrapping=!1,this.direction=Ai.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefresh(e,t,i){let n=!1;for(let t=0;t=e?r:c.lineAt(e,mn.ByPosNoHeight,a,0,0);for(n+=d.to-e,e=d.to;02*r){var o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(r>2*n))break;o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,r-=o.size}else nt&&e.push(new bn(r.from-t-1).updateHeight(n,t));i<=s&&r.more;){var o=n.doc.lineAt(i).length;e.length&&e.push(null);let t=new yn(o,r.heights[r.index++]);t.outdated=!1,e.push(t),i+=o+1}return i<=s&&e.push(null,new bn(s-i).updateHeight(n,i)),n.heightChanged=!0,vn.of(e)}return(e||this.outdated)&&(this.setHeight(n,n.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class xn extends vn{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){var r=i+this.left.height;return to))return h;e=e==mn.ByPosNoHeight?mn.ByPosNoHeight:mn.ByPos;return a?h.join(this.right.lineAt(o,e,i,s,o)):this.left.lineAt(o,e,i,n,r).join(h)}forEachLine(t,e,i,n,r,s){var o,a=n+this.left.height,h=r+this.left.length+this.break;this.break?(t=t&&o.from<=e&&s(o),e>o.to&&this.right.forEachLine(o.to+1,e,i,a,h,s))}replace(t,e,i){var n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];0=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){var i=this.left.length,n=i+this.break;if(n<=t)return this.right.decomposeRight(t-n,e);t2*e.size||e.size>2*t.size?vn.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function kn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof bn&&(n=t[e+1])instanceof bn&&t.splice(e-1,3,new bn(i.length+1+n.length))}class Sn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,i){if(-1this.pos||!this.isCovered)&&this.nodes.push(new yn(t-this.pos,-1)),(this.writtenTo=t)t&&this.nodes.push(new yn(this.pos-t,-1)),this.writtenTo=this.pos)}blankContent(t,e){let i=new bn(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();var t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof yn)return t;t=new yn(0,-1);return this.nodes.push(t),t}addBlock(t){this.enterLine(),t.type!=Re.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=Re.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){var e,i=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(-1t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let t=0;t<=1;t++){let i=t?n.head:n.anchor;var r,s;e.some(({from:t,to:e})=>i>=t&&i<=e)||({from:r,to:s}=this.lineAt(i,0),e.push(new Dn(r,s)))}this.viewports=e.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?En:new Hn(this.heightOracle.doc,this.heightMap,this.viewports)}update(t,e=null){var i=this.state;this.state=t.state;var n,r,s,o=this.state.facet(fi),a=t.changedRanges,s=gi.extendWithRanges(a,(n=t.startState.facet(fi),r=o,s=t?t.changes:k.empty(this.state.doc.length),a=new An,Ct.compare(n,r,s,a,0),a.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(o,i.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=a&&(t.flags|=2);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e)),h.eq(this.viewport)||(this.viewport=h,t.flags|=4),this.updateForViewport(),(this.lineGaps.length||15e3t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=window.getComputedStyle(t).overflow&&(i=t.getBoundingClientRect(),r=Math.max(r,i.left),s=Math.min(s,i.right),o=Math.max(o,i.top),a=Math.min(a,i.bottom)),t=t.parentNode;else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:s-n.left,top:o-(n.top+t),bottom:a-(n.top+t)}}(i,this.paddingTop),o=s.top-this.pixelViewport.top,a=s.bottom-this.pixelViewport.bottom;if(this.pixelViewport=s,this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left,!this.inView)return 0;var h,l=t.measureVisibleLineHeights();let c=!1,d=0,u=0,f=this.heightOracle;return e||(h=t.dom.clientWidth,(f.mustRefresh(l,n,r)||f.lineWrapping&&Math.abs(h-this.contentWidth)>f.charWidth)&&({lineHeight:s,charWidth:e}=t.measureTextSize(),c=f.refresh(n,r,s,e,h/e,l),c&&(t.minWidth=0,u|=16)),this.contentWidth!=h&&(this.contentWidth=h,u|=16),0this.viewport.to))&&((l=this.getViewport(d,this.scrollTo)).from==this.viewport.from&&l.to==this.viewport.to||(this.viewport=l,u|=4)),this.updateForViewport(),(this.lineGaps.length||15e3o.to&&({bottom:e}=i.lineAt(e.head,mn.ByPos,n,0,0),o=new Dn(i.lineAt(e-(s-r)-500,mn.ByHeight,n,0,0).from,i.lineAt(e+500,mn.ByHeight,n,0,0).to))),o}mapViewport(t,e){var i=e.mapPos(t.from,-1),t=e.mapPos(t.to,1);return new Dn(this.heightMap.lineAt(i,mn.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(t,mn.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){var{top:n}=this.heightMap.lineAt(t,mn.ByPos,this.state.doc,0,0),{bottom:r}=this.heightMap.lineAt(e,mn.ByPos,this.state.doc,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&s-2e3{if(!(r.length<1e4)){var s=function(t,e,i){let n=[],r=t,s=0;Ct.spans(i.facet(fi),t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r=r.from&&(t=o.from),o.from<=r.to&&o.to>=e&&(e=o.to);let i=t-1e4,n=e+1e4;i>r.from+5e3&&h.push(Bn(a,t=>t.from==r.from&&t.to>i-5e3&&t.to<5e3+i)||new Mn(r.from,i,this.gapSize(r,i,!0,s))),nt.to==r.to&&t.from>n-5e3&&t.fromt.draw(this.heightOracle.lineWrapping))),8)}computeVisibleRanges(){let t=this.state.facet(fi);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Ct.spans(t,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20),this.visibleRanges=i}lineAt(t,e){return e+=this.paddingTop,Pn(this.heightMap.lineAt(t,mn.ByPos,this.state.doc,e,0),this.scaler,e)}lineAtHeight(t,e){return e+=this.paddingTop,Pn(this.heightMap.lineAt(this.scaler.fromDOM(t,e),mn.ByHeight,this.state.doc,e,0),this.scaler,e)}blockAtHeight(t,e){return e+=this.paddingTop,Pn(this.heightMap.blockAt(this.scaler.fromDOM(t,e),this.state.doc,e,0),this.scaler,e)}forEachLine(t,e,i,n){return n+=this.paddingTop,this.heightMap.forEachLine(t,e,this.state.doc,n,0,1==this.scaler.scale?i:t=>i(Pn(t,this.scaler,n)))}get contentHeight(){return this.domHeight+this.paddingTop+this.paddingBottom}get domHeight(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop)}}class Dn{constructor(t,e){this.from=t,this.to=e}eq(t){return this.from==t.from&&this.to==t.to}}function On({total:t,ranges:e},i){if(i<=0)return e[0].from;if(1<=i)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){var{from:r,to:s}=e[t],s=s-r;if(n<=s)return r+n;n-=s}}function Ln(t,e){let i=0;for(var{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function Bn(t,e){for(var i of t)if(e(i))return i}const En={toDOM(t){return t},fromDOM(t){return t},scale:1};class Hn{constructor(r,s,t){let o=0,e=0,i=0;this.viewports=t.map(({from:t,to:e})=>{var i=s.lineAt(t,mn.ByPos,r,0,0).top,n=s.lineAt(e,mn.ByPos,r,0,0).bottom;return o+=n-i,{from:t,to:e,top:i,bottom:n,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(s.height-o);for(var n of this.viewports)n.domTop=i+(n.top-e)*this.scale,i=n.domBottom=n.domTop+(n.bottom-n.top),e=n.bottom}toDOM(n,r){n-=r;for(let t=0,e=0,i=0;;t++){var s=tPn(t,e,i)):t.type)}const _n=P.define({combine:t=>t.join(" ")}),Nn=P.define({combine:t=>-1{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t}})}const Wn=In("."+Rn,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,flexGrow:2,overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none"},".cm-lineWrapping":{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Vn),Fn={childList:!0,characterData:!0,subtree:!0,characterDataOldValue:!0},qn=ie.ie&&ie.ie_version<=11;class jn{constructor(i,t,e){this.view=i,this.onChange=t,this.onScrollChanged=e,this.active=!1,this.ignoreSelection=new fe,this.delayedFlush=-1,this.queue=[],this.scrollTargets=[],this.intersection=null,this.intersecting=!1,this.parentCheck=-1,this.dom=i.contentDOM,this.observer=new MutationObserver(t=>{for(var e of t)this.queue.push(e);(ie.ie&&ie.ie_version<=11||ie.ios&&i.composing)&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),qn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),0{this.delayedFlush=-1,this.flush()},20))}forceFlush(){0<=this.delayedFlush&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}flush(){if(!(0<=this.delayedFlush)){let n=this.queue;for(var t of this.observer.takeRecords())n.push(t);n.length&&(this.queue=[]);var r=ne(this.view.root),s=!this.ignoreSelection.eq(r)&&se(this.dom,r);if(0!=n.length||s){let t=-1,e=-1,i=!1;for(var o of n){o=this.readMutation(o);o&&(o.typeOver&&(i=!0),-1==t?{from:t,to:e}=o:(t=Math.min(o.from,t),e=Math.max(o.to,e)))}r=this.view.state;(-1this.view.docView.sync()),this.view.docView.dirty=0),this.view.docView.updateSelection()),this.clearSelection()}}}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(),"childList"!=t.type)return{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue};var i=Jn(e,t.previousSibling||t.target.previousSibling,-1),t=Jn(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:t?e.posBefore(t):e.posAtEnd,typeOver:!1}}destroy(){this.stop(),this.intersection&&this.intersection.disconnect();for(var t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),clearTimeout(this.parentCheck)}}function Jn(t,e,i){for(;e;){var n=be.get(e);if(n&&n.parent==t)return n;n=e.parentNode;e=n!=t.dom?n:0Date.now()-100||ie.android&&t.text.length=o?s-i:0,s-=h,a=s+(a-o),o=s):a=a?s-i:0,s-=i,o=s+(o-a),a=s)}return{from:s,toA:o,toB:a}}(n.state.sliceDoc(l,c),t.text,e-l,i);d&&(s={from:l+d.from,to:l+d.toA,insert:n.state.toText(t.text.slice(d.from,d.toB))})}else!n.hasFocus&&n.state.facet(ni)||(c=ne(n.root),{impreciseHead:l,impreciseAnchor:d}=n.docView,l=l&&l.node==c.focusNode&&l.offset==c.focusOffset||!re(n.contentDOM,c.focusNode)?n.state.selection.main.head:n.docView.posFromDOM(c.focusNode,c.focusOffset),c=d&&d.node==c.anchorNode&&d.offset==c.anchorOffset||!re(n.contentDOM,c.anchorNode)?n.state.selection.main.anchor:function(t){let e=t.isCollapsed;return e&&ie.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}(c)?l:n.docView.posFromDOM(c.anchorNode,c.anchorOffset),l==a.head&&c==a.anchor||(o=B.single(c,l)));if(s||o)if(!s&&r&&!a.empty&&o&&o.main.empty&&(s={from:a.from,to:a.to,insert:n.state.doc.slice(a.from,a.to)}),s){let i=n.state;if(!(ie.android&&(s.from==a.from&&s.to==a.to&&1==s.insert.length&&2==s.insert.lines&&Yn(n,"Enter",13)||s.from==a.from-1&&s.to==a.to&&0==s.insert.length&&Yn(n,"Backspace",8)||s.from==a.from&&s.to==a.to+1&&0==s.insert.length&&Yn(n,"Delete",46))||ie.ios&&(n.inputState.lastIOSEnter>Date.now()-225&&1Date.now()-225&&!s.insert.length&&Yn(n,"Backspace",8)))){let e=s.insert.toString();if(!n.state.facet(ei).some(t=>t(n,s.from,s.to,e))){0<=n.inputState.composing&&n.inputState.composing++;let t;var u;t=s.from>=a.from&&s.to<=a.to&&s.to-s.from>=(a.to-a.from)/3&&(!o||o.main.empty&&o.main.from==s.from+s.insert.length)?(r=a.froms.to?i.sliceDoc(s.to,a.to):"",i.replaceSelection(n.state.toText(r+s.insert.sliceString(0,void 0,n.state.lineBreak)+u))):{changes:u=i.changes(s),selection:o&&!i.selection.main.eq(o.main)&&o.main.to<=u.newLength?i.selection.replaceRange(o.main):void 0},n.dispatch(t,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})}}}else if(o&&!o.main.eq(a)){let t=!1,e;n.inputState.lastSelectionTime>Date.now()-50&&("keyboardselection"==n.inputState.lastSelectionOrigin?t=!0:e=rt.userEvent.of(n.inputState.lastSelectionOrigin)),n.dispatch({selection:o,scrollIntoView:t,annotations:e})}}class Kn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(e,i){if(e){var n=e.parentNode;for(let t=e;;){this.findPointBefore(n,t),this.readNode(t);var r=t.nextSibling;if(r==i)break;var s=be.get(t),o=be.get(r);((s?s.breakAfter:Gn(t))||(o?o.breakAfter:Gn(r))&&("BR"!=t.nodeName||t.cmIgnore))&&(this.text+=this.lineBreak),t=r}this.findPointBefore(n,i)}}readNode(i){if(!i.cmIgnore){var n=be.get(i);let t=n&&n.overrideDOMText,e;null!=t?e=t.sliceString(0,void 0,this.lineBreak):3==i.nodeType?e=i.nodeValue:"BR"==i.nodeName?e=i.nextSibling?this.lineBreak:"":1==i.nodeType&&this.readRange(i.firstChild,null),null!=e&&(this.findPointIn(i,e.length),this.text+=e,ie.chrome&&13==this.view.inputState.lastKeyCode&&!i.nextSibling&&/\n\n$/.test(this.text)&&(this.text=this.text.slice(0,-1)))}}findPointBefore(t,e){for(var i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointIn(t,e){for(var i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e))}}function Gn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Xn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}function Yn(t,e,i){i={key:e,code:e,keyCode:i,which:i,cancelable:!0};let n=new KeyboardEvent("keydown",i);n.synthetic=!0,t.contentDOM.dispatchEvent(n);let r=new KeyboardEvent("keyup",i);return r.synthetic=!0,t.contentDOM.dispatchEvent(r),n.defaultPrevented||r.defaultPrevented}class Qn{constructor(t={}){this.plugins=[],this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=t.root||document,this.viewState=new Tn(t.state||pt.create()),this.plugins=this.state.facet(ai).map(t=>new ci(t).update(this)),this.observer=new jn(this,(t,e,i)=>{Un(this,t,e,i)},t=>{this.inputState.runScrollHandlers(this,t),this.measure()}),this.inputState=new Ki(this),this.docView=new vi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,window.addEventListener("resize",()=>{-1==er&&(er=setTimeout(ir,50))}),this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return 0t.scrollIntoView)?n.selection.main:null;this.viewState.update(i,s),this.bidiCache=rr.update(this.bidiCache,i.changes),i.empty||this.updatePlugins(i),e=this.docView.update(i),this.state.facet(pi)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t)}finally{this.updateState=0}if((e||scrollTo||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!i.empty)for(var o of this.state.facet(ti))o(i)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");this.updateState=2;try{for(var e of this.plugins)e.destroy(this);this.viewState=new Tn(t),this.plugins=t.facet(ai).map(t=>new ci(t).update(this)),this.docView=new vi(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}this.requestMeasure()}updatePlugins(i){let t=i.startState.facet(ai),n=i.state.facet(ai);if(t!=n){let e=[];for(var r of n){var s=t.indexOf(r);if(s<0)e.push(new ci(r));else{let t=this.plugins[s];t.mustUpdate=i,e.push(t)}}for(var o of this.plugins)o.mustUpdate!=i&&o.destroy(this);this.plugins=e,this.inputState.ensureHandlers(this)}else for(var e of this.plugins)e.mustUpdate=i;for(let t=0;t{try{return t.read(this)}catch(t){return ii(this.state,t),nr}});let t=new mi(this,this.state);t.flags|=r,n?n.flags|=r:n=t,this.updateState=2,t.empty||this.updatePlugins(t),this.updateAttrs(),r&&this.docView.update(t);for(let t=0;tthis.measure())),e){if(null!=e.key)for(let t=0;tfunction(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{t=n(t);return r==ct.Space&&(r=t),r==t}}(this,e.head,t))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){var r=t.state.doc.lineAt(e.head),s=n&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){n=t.dom.getBoundingClientRect(),s=t.posAtCoords({x:i==(t.textDirection==Ai.LTR)?n.right-1:n.left+1,y:(s.top+s.bottom)/2});if(null!=s)return B.cursor(s,i?-1:1)}return e=qe.find(t.docView,e.head),r=e?i?e.posAtEnd:e.posAtStart:i?r.to:r.from,B.cursor(r,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Ui(this,t,e,i)}scrollPosIntoView(t){this.viewState.scrollTo=B.cursor(t),this.requestMeasure()}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t){return this.readMeasured(),ji(this,t)}coordsAtPos(t,e=1){this.readMeasured();var i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;var n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return ue(i,r[_i.find(r,t-n.from,-1,e)].dir==Ai.LTR==0Zn)return $i(t.length);var e,i=this.textDirection;for(e of this.bidiCache)if(e.from==t.from&&e.dir==i)return e.order;var n=Ri(t.text,this.textDirection);return this.bidiCache.push(new rr(t.from,t.to,i,n)),n}get hasFocus(){return document.hasFocus()&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ge(this.contentDOM),this.docView.updateSelection()})}destroy(){for(var t of this.plugins)t.destroy(this);this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),-1({}),{eventHandlers:t})}static theme(t,e){var i=yt.newName();let n=[_n.of(i),pi.of(In(`.${i}`,t))];return e&&e.dark&&n.push(Nn.of(!0)),n}static baseTheme(t){return I.fallback(pi.of(In("."+Rn,t,Vn)))}}Qn.styleModule=pi,Qn.inputHandler=ei,Qn.exceptionSink=Ze,Qn.updateListener=ti,Qn.editable=ni,Qn.mouseSelectionStyle=Qe,Qn.dragMovesSelection=Ye,Qn.clickAddsSelectionRange=Xe,Qn.decorations=fi,Qn.contentAttributes=ui,Qn.editorAttributes=di,Qn.lineWrapping=Qn.contentAttributes.of({class:"cm-lineWrapping"}),Qn.announce=nt.define();const Zn=4096;function tr(t,e){return null==t?e.getBoundingClientRect().top:t}let er=-1;function ir(){er=-1;var i=document.querySelectorAll(".cm-content");for(let e=0;e{if(t){for(var e of t.commands)if(e(i))return!0;t.preventDefault&&(a=!0)}return!1},l=t[n],c;if(l){if(h(l[o+or(r,e,!s)]))return!0;if(s&&(e.shiftKey||e.altKey||e.metaKey)&&(c=Nt[e.keyCode])&&c!=r){if(h(l[o+or(c,e,!0)]))return!0}else if(s&&e.shiftKey&&h(l[o+or(r,e,!0)]))return!0}return a}(function(t){let e=t.facet(ar),i=hr.get(e);i||hr.set(e,i=function(t,a=sr){let h=Object.create(null),n=Object.create(null),l=(t,e)=>{var i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},e=(n,t,e,i)=>{let r=h[n]||(h[n]=Object.create(null)),s=t.split(/ (?!$)/).map(t=>function(t,e){var i=t.split(/-(?!$)/);let n=i[i.length-1];"Space"==n&&(n=" ");let r,s,o,a;for(let t=0;t{let e=lr={view:t,prefix:i,scope:n};return setTimeout(()=>{lr==e&&(lr=null)},cr),!0}]})}t=s.join(" ");l(t,!1);let o=r[t]||(r[t]={preventDefault:!1,commands:[]});o.commands.push(e),i&&(o.preventDefault=!0)};for(var i of t){var r=i[a]||i.key;if(r)for(var s of i.scope?i.scope.split(" "):["editor"])e(s,r,i.run,i.preventDefault),i.shift&&e(s,"Shift-"+r,i.shift,i.preventDefault)}return h}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")}})}),hr=new WeakMap;let lr=null;const cr=4e3;ie.ios;let dr=0;const ur=new WeakMap;class fr{constructor({deserialize:t}={}){this.id=dr++,this.deserialize=t||(()=>{throw new Error("This node type doesn't define a deserialize function")})}static string(){return new fr({deserialize:t=>t})}static number(){return new fr({deserialize:Number})}static flag(){return new fr({deserialize:()=>!0})}set(t,e){return t[this.id]=e,t}add(e){return"function"!=typeof e&&(e=gr.match(e)),t=>{t=e(t);return void 0===t?null:[this,t]}}}fr.closedBy=new fr({deserialize:t=>t.split(" ")}),fr.openedBy=new fr({deserialize:t=>t.split(" ")}),fr.group=new fr({deserialize:t=>t.split(" ")});const pr=Object.create(null);class gr{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){var e=t.props&&t.props.length?Object.create(null):pr,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new gr(t.name||"",e,t.id,i);if(t.props)for(var r of t.props)Array.isArray(r)||(r=r(n)),r&&r[0].set(e,r[1]);return n}prop(t){return this.props[t.id]}get isTop(){return 0<(1&this.flags)}get isSkipped(){return 0<(2&this.flags)}get isError(){return 0<(4&this.flags)}get isAnonymous(){return 0<(8&this.flags)}is(e){if("string"!=typeof e)return this.id==e;{if(this.name==e)return!0;let t=this.prop(fr.group);return!!t&&-1{for(let t=i.prop(fr.group),e=-1;e<(t?t.length:0);e++){var n=r[e<0?i.name:t[e]];if(n)return n}}}}gr.none=new gr("",Object.create(null),0,8);class mr{constructor(t,e,i,n){this.type=t,this.children=e,this.positions=i,this.length=n}toString(){var t=this.children.map(t=>t.toString()).join();return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(t,e=0){var i=null!=t&&ur.get(this)||this.topNode;let n=new Sr(i);return null!=t&&(n.moveTo(t,e),ur.set(this,n._tree)),n}fullCursor(){return new Sr(this.topNode,!0)}get topNode(){return new yr(this,0,0,null)}resolve(t,e=0){return this.cursor(t,e).node}iterate(t){let{enter:i,leave:n,from:r=0,to:s=this.length}=t;for(let e=this.cursor();;){let t=!1;if(e.from<=s&&e.to>=r&&(e.type.isAnonymous||!1!==i(e.type,e.from,e.to))){if(e.firstChild())continue;e.type.isAnonymous||(t=!0)}for(;t&&n&&n(e.type,e.from,e.to),t=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;t=!0}}}balance(t=1024){return this.children.length<=Cr?this:Tr(this.type,gr.none,this.children,this.positions,0,this.children.length,0,t,this.length,0)}static build(t){let{buffer:e,nodeSet:m,topID:i=0,maxBufferLength:v=1024,reused:w=[],minRepeatType:y=m.types.length}=t,b=Array.isArray(e)?new Mr(e,e.length):e,x=m.types,k=0;function S(i,t,e,n,r){var{id:s,start:o,end:a,size:h}=b;let l=o-i;if(h<0)return-1==h?(e.push(w[s]),n.push(l)):k=s,void b.next();let c=x[s],d,u;if(a-o<=v&&(u=function(t,e){let i=b.fork(),n=0,r=0,s=0,o=i.end-v,a={size:0,start:0,skip:0};t:for(var h=i.pos-t;i.pos>h;)if(i.id!=e){var l=i.size,c=i.pos-l;if(l<0||c=y?4:0;var d=i.start;for(i.next();i.pos>c;){if(i.size<0)break t;i.id>=y&&(t+=4),i.next()}r=d,n+=l,s+=t}else a.size=n,a.start=r,a.skip=s,s+=4,n+=4,i.next();(e<0||n==t)&&(a.size=n,a.start=r,a.skip=s);return 4t;)e=function t(e,i,n,r){var{id:s,start:o,end:a,size:h}=b;b.next();if(s==r)return n;var l=n;if(4c;)n=t(e,i,n,r);s=y?s:-1;b.pos>p;)b.id==g?b.next():S(o,p,t,e,g);t.reverse(),e.reverse(),d=-1Cr?Tr(c,c,t,e,0,t.length,0,v,a-o,k):vr(new mr(c,t,e,a-o),k)}e.push(d),n.push(l)}let n=[],r=[];for(;0=t:this.from>t)||(-1=t:this.from>t)||(-1!t.type.isAnonymous||t instanceof wr||Ar(t))}class Mr{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Mr(this.buffer,this.index)}}const Cr=8;function Tr(t,i,n,r,s,o,a,h,e,l){let c=[],d=[];if(e<=h)for(let t=s;tu<<1){for(let t=0;t=i)for(;s&&s.from=t.from||u<=t.to||h)&&(l=Math.max(t.from,a)-h,c=Math.min(t.to,u)-h,t=c<=l?null:new Dr(l,c,t.tree,t.offset+h,(0u)break;s=rt.length&&n.push(r);return n}}const Or=new fr;class Lr{constructor(t,e,i,n=[]){this.data=t,this.topNode=i,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return Er(this)}}),this.parser=e,this.extension=[Vr.of(this),pt.languageData.of((t,e)=>t.facet(Br(t,e)))].concat(n)}isActiveAt(t,e){return Br(t,e)==this.data}findRegions(t){var e=t.facet(Vr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[];return Er(t).iterate({enter:(t,e,i)=>{if(t.isTop&&t.prop(Or)==this.data)return n.push({from:e,to:i}),!1}}),n}get allowsNesting(){return!0}parseString(t){var e=u.of(t.split("\n"));let i=this.parser.startParse(new Hr(e),0,new Pr(this.parser,pt.create({doc:e}),[],mr.empty,{from:0,to:t.length},[],null)),n;for(;!(n=i.advance()););return n}}function Br(t,e){var i=t.facet(Vr);if(!i)return null;if(!i.allowsNesting)return i.data;let n=Er(t),r=n.resolve(e,-1);for(;r;){var s=r.type.prop(Or);if(s)return s;r=r.parent}return i.data}function Er(t){t=t.field(Lr.state,!1);return t?t.tree:mr.empty}Lr.setState=nt.define();class Hr{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.prevString="",this.cursor=t.iter()}syncTo(t){return t=this.length)return-1;let e=this.cursorPos-this.string.length;if(t=this.cursorPos){if(t=e-this.prevString.length)return this.prevString.charCodeAt(t-(e-this.prevString.length));e=this.syncTo(t)}return this.string.charCodeAt(t-e)}lineAfter(t){if(t>=this.length||t<0)return"";let e=this.cursorPos-this.string.length;return(t=this.cursorPos)&&(e=this.syncTo(t)),this.cursor.lineBreak?"":this.string.slice(t-e,Math.min(this.length-e,this.string.length))}read(t,e){var i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}clip(t){return new Hr(this.doc,t)}}class Pr{constructor(t,e,i=[],n,r,s,o){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.viewport=r,this.skipped=s,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}work(t,e){if(this.tree!=mr.empty&&(null==e?this.tree.length==this.state.doc.length:this.tree.length>=e))return this.takeTree(),!0;this.parse||(this.parse=this.parser.startParse(new Hr(this.state.doc),0,this));for(var i=Date.now()+t;;){var n=this.parse.advance();if(n)return this.fragments=this.withoutTempSkipped(Dr.addTree(n)),this.parse=null,this.tree=n,!0;if(null!=e&&this.parse.pos>=e)return this.takeTree(),!0;if(Date.now()>i)return!1}}takeTree(){this.parse&&this.parse.pos>this.tree.length&&(this.tree=this.parse.forceFinish(),this.fragments=this.withoutTempSkipped(Dr.addTree(this.tree,this.fragments,!0)))}withoutTempSkipped(t){for(var e;e=this.tempSkipped.pop();)t=_r(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let r=[];if(t.iterChangedRanges((t,e,i,n)=>r.push({fromA:t,toA:e,fromB:i,toB:n})),i=Dr.applyChanges(i,r),n=mr.empty,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(var a of this.skipped){var h=t.mapPos(a.from,1),a=t.mapPos(a.to,-1);he.from&&(this.fragments=_r(this.fragments,i,n),this.skipped.splice(t--,1))}return this.skipped.length=t}}function _r(t,e,i){return Dr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}Pr.skippingParser=Pr.getSkippingParser();class Nr{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state);t=this.context.tree.length==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.tree.length),e.viewport.to);return e.work(25,t)||e.takeTree(),new Nr(e)}static init(t){let e=new Pr(t.facet(Vr).parser,t,[],mr.empty,{from:0,to:t.doc.length},[],null);return e.work(25)||e.takeTree(),new Nr(e)}}Lr.state=z.define({create:Nr.init,update(t,e){for(var i of e.effects)if(i.is(Lr.setState))return i.value;return e.startState.facet(Vr)!=e.state.facet(Vr)?Nr.init(e.state):t.apply(e)}});let Rr="undefined"!=typeof window&&window.requestIdleCallback||((t,{timeout:e})=>setTimeout(t,e)),$r="undefined"!=typeof window&&window.cancelIdleCallback||clearTimeout;var zr=hi.fromClass(class{constructor(t){this.view=t,this.working=-1,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Lr.state).context;t.viewportChanged&&(e.updateViewport(t.view.viewport)&&e.reset(),this.view.viewport.to>e.tree.length&&this.scheduleWork()),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(i=!1){if(!(-1=t.doc.length||(this.working=Rr(this.work,{timeout:500}))}}work(n){this.working=-1;var r=Date.now();if(this.chunkEnd=e+1e6||(n=Math.min(this.chunkBudget,n?Math.max(25,n.timeRemaining()):100),n=i.context.work(n,e+1e6),this.chunkBudget-=Date.now()-r,(n||this.chunkBudget<=0||i.context.movedPast(e))&&(i.context.takeTree(),this.view.dispatch({effects:Lr.setState.of(new Nr(i.context))})),!n&&0this.scheduleWork(!0)),t.scheduleOn=null)}destroy(){0<=this.working&&$r(this.working)}},{eventHandlers:{focus(){this.scheduleWork()}}});const Vr=P.define({combine(t){return t.length?t[0]:null},enables:[Lr.state,zr]}),Ir=P.define(),Wr=P.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function Fr(t){let e=t.facet(Wr);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function qr(t,e){let i="",n=t.tabSize;if(9==t.facet(Wr).charCodeAt(0))for(;n<=e;)i+="\t",e-=n;for(let t=0;tfunction(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;var r=null===(r=t.options)||void 0===r?void 0:r.simulateBreak,t=t.state.doc.lineAt(i.from),s=null==r||r<=t.from?t.to:Math.min(t.to,r);for(let t=i.to;;){var o=e.childAfter(t);if(!o||o==n)return null;if(!o.type.isSkipped)return o.fromQn.decorations.from(t)}),Qr];function ss(t,e,i){var n=t.prop(e<0?fr.openedBy:fr.closedBy);if(n)return n;if(1==t.name.length){t=i.indexOf(t.name);if(-1=e.to){if(0==o&&-1>1==h>>1};d--}}0"},hs=nt.define({map(t,e){t=e.mapPos(t,-1,b.TrackAfter);return null==t?void 0:t}}),ls=nt.define({map(t,e){return e.mapPos(t)}}),cs=new class extends kt{};cs.startSide=1,cs.endSide=-1;const ds=z.define({create(){return Ct.empty},update(t,i){var e,n;i.selection&&(e=i.state.doc.lineAt(i.selection.main.head).from,n=i.startState.doc.lineAt(i.startState.selection.main.head).from,e!=i.changes.mapPos(n,-1)&&(t=Ct.empty)),t=t.map(i.changes);for(let e of i.effects)e.is(hs)?t=t.update({add:[cs.range(e.value,e.value+1)]}):e.is(ls)&&(t=t.update({filter:t=>t!=e.value}));return t}});const us="()[]{}<>";function fs(e){for(let t=0;t>10),56320+(1023&t)));var t}function ps(t,e){return t.languageDataAt("closeBrackets",e)[0]||as}function gs(t,e,i,n){if(t.composing)return!1;var r=t.state.selection.main;if(2{if(!t.empty)return{changes:[{insert:s,from:t.from},{insert:s,from:t.to}],effects:hs.of(t.to+s.length),range:B.range(t.anchor+s.length,t.head+s.length)};var e=t.head,i=ws(r.doc,e);if(i==s){if(ys(r,e))return{changes:{insert:s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)};if(vs(r,e)){var n=o&&r.sliceDoc(e,e+3*s.length)==s+s+s;return{range:B.cursor(e+s.length*(n?3:1)),effects:ls.of(e)}}}else{if(o&&r.sliceDoc(e-2*s.length,e)==s+s&&ys(r,e-2*s.length))return{changes:{insert:s+s+s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)};if(r.charCategorizer(e)(i)!=ct.Word){i=r.sliceDoc(e-1,e);if(i!=s&&r.charCategorizer(e)(i)!=ct.Word)return{changes:{insert:s+s,from:e},effects:hs.of(e+s.length),range:B.cursor(e+s.length)}}}return{range:a=t}});return a?null:r.update(t,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})}(t,r,-1{if(!t.empty)return{changes:[{insert:n,from:t.from},{insert:r,from:t.to}],effects:hs.of(t.to+n.length),range:B.range(t.anchor+n.length,t.head+n.length)};var e=ws(i.doc,t.head);return!e||/\s/.test(e)||-1t.empty&&ws(e.doc,t.head)==i?B.cursor(t.head+i.length):n=t);return n?null:e.update({selection:B.create(t,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map(({from:t})=>ls.of(t))})}(t,(r,s))}return null}(t.state,n);return!!n&&(t.dispatch(n),!0)}const ms=[{key:"Backspace",run:({state:n,dispatch:t})=>{let r=ps(n,n.selection.main.head).brackets||as.brackets,s=null,e=n.changeByRange(t=>{if(t.empty){var e,i=function(t,e){let i=t.sliceString(e-2,e);return d(c(i,0))==i.length?i:i.slice(1)}(n.doc,t.head);for(e of r)if(e==i&&ws(n.doc,t.head)==fs(c(e,0)))return{changes:{from:t.head-e.length,to:t.head+e.length},range:B.cursor(t.head-e.length),annotations:rt.userEvent.of("delete")}}return{range:s=t}});return s||t(n.update(e,{scrollIntoView:!0})),!s}}];function vs(t,e){let i=!1;return t.field(ds).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function ws(t,e){let i=t.sliceString(e,e+2);return i.slice(0,d(c(i,0)))}function ys(t,e){t=Er(t).resolve(e+1);return t.parent&&t.from==e}function bs(t,e){return B.create(t.ranges.map(e),t.mainIndex)}function xs(t,e){return t.update({selection:e,scrollIntoView:!0,annotations:rt.userEvent.of("keyboardselection")})}function ks({state:t,dispatch:e},i){let n=bs(t.selection,i);return!n.eq(t.selection)&&(e(xs(t,n)),!0)}function Ss(t,e){return B.cursor(e?t.to:t.from)}function As(e,i){return ks(e,t=>t.empty?e.moveByChar(t,i):Ss(t,i))}var Ms=t=>As(t,t.textDirection!=Ai.LTR),Cs=t=>As(t,t.textDirection==Ai.LTR);function Ts(e,i){return ks(e,t=>t.empty?e.moveByGroup(t,i):Ss(t,i))}function Ds(e,i,n){let r=Er(e).resolve(i.head);var s,o,a,h=n?fr.closedBy:fr.openedBy;for(let t=i.head;;){var l=n?r.childAfter(t):r.childBefore(t);if(!l)break;s=e,a=h,(o=l).type.prop(a)||((a=o.to-o.from)&&(2t.empty?e.moveVertically(t,i):Ss(t,i))}var Ls=t=>Os(t,!1),Bs=t=>Os(t,!0);function Es(e,i){return ks(e,t=>t.empty?e.moveVertically(t,i,e.dom.clientHeight):Ss(t,i))}var Hs=t=>Es(t,!1),Ps=t=>Es(t,!0);function _s(t,e,i){let n=t.visualLineAt(e.head),r=t.moveToLineBoundary(e,i);return r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),i||r.head!=n.from||!n.length||(t=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length)&&e.head!=n.from+t&&(r=B.cursor(n.from+t)),r}var Ns=e=>ks(e,t=>B.cursor(e.visualLineAt(t.head).from,1)),Rs=e=>ks(e,t=>B.cursor(e.visualLineAt(t.head).to,-1));function $s(t,i){let e=bs(t.state.selection,t=>{var e=i(t);return B.range(t.anchor,e.head,e.goalColumn)});return!e.eq(t.state.selection)&&(t.dispatch(xs(t.state,e)),!0)}function zs(e,i){return $s(e,t=>e.moveByChar(t,i))}var Vs=t=>zs(t,t.textDirection!=Ai.LTR),Is=t=>zs(t,t.textDirection==Ai.LTR);function Ws(e,i){return $s(e,t=>e.moveByGroup(t,i))}function Fs(e,i){return $s(e,t=>e.moveVertically(t,i))}var qs=t=>Fs(t,!1),$t=t=>Fs(t,!0);function js(e,i){return $s(e,t=>e.moveVertically(t,i,e.dom.clientHeight))}Vt=t=>js(t,!1),It=t=>js(t,!0),Yt=e=>$s(e,t=>B.cursor(e.visualLineAt(t.head).from)),Gt=e=>$s(e,t=>B.cursor(e.visualLineAt(t.head).to)),Xt=({state:t,dispatch:e})=>(e(xs(t,{anchor:0})),!0),Kt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.doc.length})),!0),Qt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.selection.main.anchor,head:0})),!0),Zt=({state:t,dispatch:e})=>(e(xs(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Js({state:t,dispatch:e},r){var i=t.changeByRange(t=>{let{from:e,to:i}=t;var n;return e==i&&(n=r(e),e=Math.min(e,n),i=Math.max(i,n)),e==i?{range:t}:{changes:{from:e,to:i},range:B.cursor(e)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,annotations:rt.userEvent.of("delete")})),!0)}const Us=(a,h,l)=>Js(a,e=>{let{state:t}=a,i=t.doc.lineAt(e),n;if(!h&&e>i.from&&eUs(t,!1,!0),ee=t=>Us(t,!0,!1);const Ks=(t,l)=>Js(t,e=>{let i=e,{state:n}=t,r=n.doc.lineAt(i),s=n.charCategorizer(i);for(let t=null;;){if(i==(l?r.to:r.from)){i==e&&r.number!=(l?n.doc.lines:1)&&(i+=l?1:-1);break}var o=S(r.text,i-r.from,l)+r.from,a=r.text.slice(Math.min(i,o)-r.from,Math.max(i,o)-r.from),h=s(a);if(null!=t&&h!=t)break;" "==a&&i==e||(t=h),i=o}return i});te=t=>Ks(t,!1),Ut=t=>Ks(t,!0),zr=i=>Js(i,t=>{var e=i.visualLineAt(t).to;return t{var i=[];for(let t=e.from;t<=e.to;){var n=r.doc.lineAt(t);n.number>o&&(e.empty||e.to>n.from)&&(s(n,i,e),o=n.number),t=n.to+1}let t=r.changes(i);return{changes:i,range:B.range(t.mapPos(e.anchor,1),t.mapPos(e.head,1))}})}Qr=({state:o,dispatch:t})=>{let a=Object.create(null),h=new Jr(o,{overrideIndentation:t=>{t=a[t];return null==t?-1:t}});var e=Qs(o,(t,e,i)=>{var n,r,s=jr(h,t.from);null==s||((n=/^\s*/.exec(t.text)[0])!=(r=qr(o,s))||i.from(t(i.update(Qs(i,(t,e)=>{e.push({from:t.from,insert:i.facet(Wr)})}))),!0);const to=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>ks(e,t=>Ds(e.state,t,e.textDirection!=Ai.LTR)),shift:e=>$s(e,t=>Ds(e.state,t,e.textDirection!=Ai.LTR))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>ks(e,t=>Ds(e.state,t,e.textDirection==Ai.LTR)),shift:e=>$s(e,t=>Ds(e.state,t,e.textDirection==Ai.LTR))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Xs(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Ys(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Xs(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Ys(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return 1{var e=Gs(i).map(({from:t,to:e})=>B.range(t,Math.min(e+1,i.doc.length)));return t(i.update({selection:B.create(e),annotations:rt.userEvent.of("keyboardselection")})),!0}},{key:"Mod-i",run:({state:n,dispatch:t})=>{var e=bs(n.selection,t=>{var e;let i=Er(n).resolve(t.head,1);for(;!(i.from=t.to||i.to>t.to&&i.from<=t.from||null===(e=i.parent)||void 0===e)&&e.parent;)i=i.parent;return B.range(i.to,i.from)});return t(xs(n,e)),!0}},{key:"Mod-[",run:({state:o,dispatch:t})=>(t(o.update(Qs(o,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(s){let t=A(s,0,o.tabSize),e=0,i=qr(o,Math.max(0,t-Fr(o)));for(;e{let{state:i}=e,t=i.changes(Gs(i).map(({from:t,to:e})=>(0e.moveVertically(t,!0)).map(t);return e.dispatch({changes:t,selection:n,scrollIntoView:!0}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(i,t,n){let r=!1,e=bs(i.selection,t=>{var e=os(i,t.head,-1)||os(i,t.head,1)||0Ts(t,t.textDirection!=Ai.LTR),shift:t=>Ws(t,t.textDirection!=Ai.LTR)},{mac:"Cmd-ArrowLeft",run:Ns,shift:Yt},{key:"ArrowRight",run:Cs,shift:Is},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Ts(t,t.textDirection==Ai.LTR),shift:t=>Ws(t,t.textDirection==Ai.LTR)},{mac:"Cmd-ArrowRight",run:Rs,shift:Gt},{key:"ArrowUp",run:Ls,shift:qs},{mac:"Cmd-ArrowUp",run:Xt,shift:Qt},{mac:"Ctrl-ArrowUp",run:Hs,shift:Vt},{key:"ArrowDown",run:Bs,shift:$t},{mac:"Cmd-ArrowDown",run:Kt,shift:Zt},{mac:"Ctrl-ArrowDown",run:Ps,shift:It},{key:"PageUp",run:Hs,shift:Vt},{key:"PageDown",run:Ps,shift:It},{key:"Home",run:e=>ks(e,t=>_s(e,t,!1)),shift:e=>$s(e,t=>_s(e,t,!1))},{key:"Mod-Home",run:Xt,shift:Qt},{key:"End",run:e=>ks(e,t=>_s(e,t,!0)),shift:e=>$s(e,t=>_s(e,t,!0))},{key:"Mod-End",run:Kt,shift:Zt},{key:"Enter",run:({state:a,dispatch:t})=>{var e=a.changeByRange(({from:t,to:e})=>{var i=t==e&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Er(t).resolve(e),n=i.childBefore(e),r=i.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(fr.closedBy))&&-1s.from&&t(e(t.update({selection:{anchor:0,head:t.doc.length},annotations:rt.userEvent.of("keyboardselection")})),!0)},{key:"Backspace",run:Jt,shift:Jt},{key:"Delete",run:ee,shift:ee},{key:"Mod-Backspace",mac:"Alt-Backspace",run:te},{key:"Mod-Delete",mac:"Alt-Delete",run:Ut},{mac:"Mod-Backspace",run:i=>Js(i,t=>{var e=i.visualLineAt(t).from;return eUs(t,!1,!1)},{key:"Ctrl-k",run:zr},{key:"Alt-d",run:Ut},{key:"Ctrl-Alt-h",run:te},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{var i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:u.of(["",""])},range:B.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,annotations:rt.userEvent.of("input")})),!0}},{key:"Ctrl-t",run:({state:n,dispatch:t})=>{var e=n.changeByRange(t=>{if(!t.empty||0==t.from||t.from==n.doc.length)return{range:t};var e=t.from,i=n.doc.lineAt(e),t=e==i.from?e-1:S(i.text,e-i.from,!1)+i.from,i=e==i.to?e+1:S(i.text,e-i.from,!0)+i.from;return{changes:{from:t,to:i,insert:n.doc.slice(e,i).append(n.doc.slice(t,e))},range:B.cursor(i)}});return!e.changes.empty&&(t(n.update(e,{scrollIntoView:!0})),!0)}},{key:"Alt-f",run:t=>Ts(t,!0),shift:t=>Ws(t,!0)},{key:"Alt-b",run:t=>Ts(t,!1),shift:t=>Ws(t,!1)},{key:"Alt-<",run:Xt},{key:"Alt->",run:Kt},{key:"Ctrl-v",run:Ps},{key:"Alt-v",run:Hs}].map(t=>({mac:t.key,run:t.run,shift:t.shift})))),eo={key:"Tab",run:({state:t,dispatch:e})=>t.selection.ranges.some(t=>!t.empty)?Zs({state:t,dispatch:e}):(e(t.update(t.replaceSelection("\t"),{scrollIntoView:!0,annotations:rt.userEvent.of("input")})),!0),shift:Qr},io=tt.define(),no=tt.define(),ro=P.define(),so=P.define({combine(t){return gt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}}),oo=z.define({create(){return wo.empty},update(e,i){var n=i.state.facet(so),r=i.annotation(io);if(r){var s=co.fromTransaction(i),o=r.side;let t=0==o?e.undone:e.done;return t=s?uo(t,t.length,n.minDepth,s):mo(t,i.startState.selection),new wo(0==o?r.rest:t,0==o?t:r.rest)}var t=i.annotation(no);if("full"!=t&&"before"!=t||(e=e.isolate()),!1===i.annotation(rt.addToHistory))return i.changes.empty?e:e.addMapping(i.changes.desc);s=co.fromTransaction(i),o=i.annotation(rt.time),r=i.annotation(rt.userEvent);return s?e=e.addChanges(s,o,r,n.newGroupDelay,n.minDepth):i.selection&&(e=e.addSelection(i.startState.selection,o,r,n.newGroupDelay)),e="full"==t||"after"==t?e.isolate():e},toJSON(t){return{done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}},fromJSON(t){return new wo(t.done.map(co.fromJSON),t.undone.map(co.fromJSON))}});function ao(n,r){return function({state:t,dispatch:e}){let i=t.field(oo,!1);if(!i)return!1;t=i.pop(n,t,r);return!!t&&(e(t),!0)}}const ho=ao(0,!1),lo=ao(1,!1);Ns=ao(0,!0),Yt=ao(1,!0);class co{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new co(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(t=this.startSelection)||void 0===t?void 0:t.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new co(t.changes&&k.fromJSON(t.changes),[],t.mapped&&x.fromJSON(t.mapped),t.startSelection&&B.fromJSON(t.startSelection),t.selectionsAfter.map(B.fromJSON))}static fromTransaction(t){let e=po;for(var i of t.startState.facet(ro)){i=i(t);i.length&&(e=e.concat(i))}return!e.length&&t.changes.empty?null:new co(t.changes.invert(t.startState.doc),e,void 0,t.startState.selection,po)}static selection(t){return new co(void 0,po,void 0,void 0,t)}}function uo(t,e,i,n){let r=t.slice(i+20t.map(e)):po,i);if(!t.changes)return co.selection(n);var r=t.changes.map(e),s=e.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(s):s;return new co(r,nt.mapEffects(t.effects,e),i,t.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[co.selection(n)]:po}class wo{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new wo(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&e-this.prevTimeo.push(t,e)),e.iterChangedRanges((t,e,i,n)=>{for(let t=0;tt.empty!=r.ranges[e].empty).length)?this:new wo(mo(this.done,t),this.undone,e,i)}addMapping(t){return new wo(vo(this.done,t),vo(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,i,t){let n=0==e?this.done:this.undone;if(0==n.length)return null;var r=n[n.length-1];if(t&&r.selectionsAfter.length)return i.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:io.of({side:e,rest:function(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}(n)})});if(r.changes){let t=1==n.length?po:n.slice(0,n.length-1);return r.mapped&&(t=vo(t,r.mapped)),i.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:io.of({side:e,rest:t}),filter:!1})}return null}}wo.empty=new wo(po,po);const yo=[{key:"Mod-z",run:ho,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:lo,preventDefault:!0},{key:"Mod-u",run:Ns,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Yt,preventDefault:!0}];let bo=0;class xo{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=bo++}static define(t){if(null!=t&&t.base)throw new Error("Can not derive from a modified tag");let e=new xo([],null,[]);if(e.set.push(e),t)for(var i of t.set)e.set.push(i);return e}static defineModifier(){let e=new So;return t=>-1t.id-e.id))}}let ko=0;class So{constructor(){this.instances=[],this.id=ko++}static get(e,i){if(!i.length)return e;var t,n=i[0].instances.find(t=>t.base==e&&function(t,i){return t.length==i.length&&t.every((t,e)=>t==i[e])}(i,t.modified));if(n)return n;let r=[],s=new xo(r,e,i);for(t of i)t.instances.push(s);var o,a=function e(i){let n=[i];for(let t=0;tt.scope)?void 0:Object.create(null);return(t,e)=>{var i,n=a&&a[t.id];if(void 0!==n)return n;let r=null;for(i of o){var s=i.match(t,e);s&&(r=r?r+" "+s:s)}return a&&(a[t.id]=r),r}}static define(t,e){return new Oo(t,e||{})}static get(t,e,i){return Do(t)(e,i||gr.none)}}const Lo=I.fallback(hi.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=Er(t.state),this.decorations=this.buildDeco(t,Do(t.state))}update(t){var e=Er(t.state),i=Do(t.state),n=i!=t.startState.facet(Mo);e.lengthr-1)){for(let t=r-1,e=i.length-1;0<=e;e--,t--){var s=i[e];if(s&&s!=n[t])return}return 1}}(e.context,Bo,s)){for(var l of e.tags)(l=u(l,o))&&(t&&(t+=" "),t+=l,1==e.mode?r+=(r?" ":"")+l:0==e.mode&&(i=!0));break}e=e.next}if(t!=g&&(h>p&&g&&f(p,m.from,g),p=h,g=t),!i&&m.firstChild()){do{var c=m.to;n(r,s+1,o),g!=t&&((c=Math.min(d,c))>p&&g&&f(p,c,g),p=c,g=t)}while(m.nextSibling());m.parent()}}}("",0,t.type)}(this.tree,i,r,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=$e.mark({class:i})))});return n.finish()}},{decorations:t=>t.decorations})),Bo=[""];const Eo=xo.define;Rs=Eo(),Gt=Eo(),ee=Eo(Gt),zr=Eo(),Ut=Eo(zr),te=Eo(zr),Xt=Eo(),Kt=Eo(Xt),Ps=Eo(),Hs=Eo(),Qr=Eo(),Ns=Eo(Qr),Yt=Eo();const Ho={comment:Rs,lineComment:Eo(Rs),blockComment:Eo(Rs),docComment:Eo(Rs),name:Gt,variableName:Eo(Gt),typeName:ee,tagName:Eo(ee),propertyName:Eo(Gt),className:Eo(Gt),labelName:Eo(Gt),namespace:Eo(Gt),macroName:Eo(Gt),literal:zr,string:Ut,docString:Eo(Ut),character:Eo(Ut),number:te,integer:Eo(te),float:Eo(te),bool:Eo(zr),regexp:Eo(zr),escape:Eo(zr),color:Eo(zr),url:Eo(zr),keyword:Ps,self:Eo(Ps),null:Eo(Ps),atom:Eo(Ps),unit:Eo(Ps),modifier:Eo(Ps),operatorKeyword:Eo(Ps),controlKeyword:Eo(Ps),definitionKeyword:Eo(Ps),operator:Hs,derefOperator:Eo(Hs),arithmeticOperator:Eo(Hs),logicOperator:Eo(Hs),bitwiseOperator:Eo(Hs),compareOperator:Eo(Hs),updateOperator:Eo(Hs),definitionOperator:Eo(Hs),typeOperator:Eo(Hs),controlOperator:Eo(Hs),punctuation:Qr,separator:Eo(Qr),bracket:Ns,angleBracket:Eo(Ns),squareBracket:Eo(Ns),paren:Eo(Ns),brace:Eo(Ns),content:Xt,heading:Kt,heading1:Eo(Kt),heading2:Eo(Kt),heading3:Eo(Kt),heading4:Eo(Kt),heading5:Eo(Kt),heading6:Eo(Kt),contentSeparator:Eo(Xt),list:Eo(Xt),quote:Eo(Xt),emphasis:Eo(Xt),strong:Eo(Xt),link:Eo(Xt),monospace:Eo(Xt),inserted:Eo(),deleted:Eo(),changed:Eo(),invalid:Eo(),meta:Yt,documentMeta:Eo(Yt),annotation:Eo(Yt),processingInstruction:Eo(Yt),definition:xo.defineModifier(),constant:xo.defineModifier(),function:xo.defineModifier(),standard:xo.defineModifier(),local:xo.defineModifier(),special:xo.defineModifier()};Oo.define([{tag:Ho.link,textDecoration:"underline"},{tag:Ho.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Ho.emphasis,fontStyle:"italic"},{tag:Ho.strong,fontWeight:"bold"},{tag:Ho.keyword,color:"#708"},{tag:[Ho.atom,Ho.bool,Ho.url,Ho.contentSeparator,Ho.labelName],color:"#219"},{tag:[Ho.literal,Ho.inserted],color:"#164"},{tag:[Ho.string,Ho.deleted],color:"#a11"},{tag:[Ho.regexp,Ho.escape,Ho.special(Ho.string)],color:"#e40"},{tag:Ho.definition(Ho.variableName),color:"#00f"},{tag:Ho.local(Ho.variableName),color:"#30a"},{tag:[Ho.typeName,Ho.namespace],color:"#085"},{tag:Ho.className,color:"#167"},{tag:[Ho.special(Ho.variableName),Ho.macroName],color:"#256"},{tag:Ho.definition(Ho.propertyName),color:"#00c"},{tag:Ho.comment,color:"#940"},{tag:Ho.meta,color:"#7a757a"},{tag:Ho.invalid,color:"#f00"}]);const Po=Oo.define([{tag:Ho.link,class:"cmt-link"},{tag:Ho.heading,class:"cmt-heading"},{tag:Ho.emphasis,class:"cmt-emphasis"},{tag:Ho.strong,class:"cmt-strong"},{tag:Ho.keyword,class:"cmt-keyword"},{tag:Ho.atom,class:"cmt-atom"},{tag:Ho.bool,class:"cmt-bool"},{tag:Ho.url,class:"cmt-url"},{tag:Ho.labelName,class:"cmt-labelName"},{tag:Ho.inserted,class:"cmt-inserted"},{tag:Ho.deleted,class:"cmt-deleted"},{tag:Ho.literal,class:"cmt-literal"},{tag:Ho.string,class:"cmt-string"},{tag:Ho.number,class:"cmt-number"},{tag:[Ho.regexp,Ho.escape,Ho.special(Ho.string)],class:"cmt-string2"},{tag:Ho.variableName,class:"cmt-variableName"},{tag:Ho.local(Ho.variableName),class:"cmt-variableName cmt-local"},{tag:Ho.definition(Ho.variableName),class:"cmt-variableName cmt-definition"},{tag:Ho.special(Ho.variableName),class:"cmt-variableName2"},{tag:Ho.typeName,class:"cmt-typeName"},{tag:Ho.namespace,class:"cmt-namespace"},{tag:Ho.macroName,class:"cmt-macroName"},{tag:Ho.propertyName,class:"cmt-propertyName"},{tag:Ho.operator,class:"cmt-operator"},{tag:Ho.comment,class:"cmt-comment"},{tag:Ho.meta,class:"cmt-meta"},{tag:Ho.invalid,class:"cmt-invalid"},{tag:Ho.punctuation,class:"cmt-punctuation"}]);var _o=[{type:"undo",title:"撤销",innerHTML:''},{type:"redo",title:"重做",innerHTML:''},{type:"bold",title:"加粗",innerHTML:''},{type:"italic",title:"倾斜",innerHTML:''},{type:"delete",title:"删除",innerHTML:''},{type:"code-inline",title:"行内代码",innerHTML:''},{type:"indent",title:"缩进",innerHTML:''},{type:"hr",title:"横线",innerHTML:''},{type:"quote",title:"引用",innerHTML:''},{type:"title",title:"标题",innerHTML:''},{type:"ordered-list",title:"有序列表",innerHTML:''},{type:"unordered-list",title:"无序列表",innerHTML:''},{type:"link",title:"超链接",innerHTML:''},{type:"image",title:"插入图片",innerHTML:''},{type:"character",title:"实体符号",innerHTML:''},{type:"table",title:"表格",innerHTML:''},{type:"emoji",title:"符号表情",innerHTML:''},{type:"code-block",title:"代码块",innerHTML:''},{type:"html",title:"原生HTML",innerHTML:''},{type:"expression",title:"图片表情",innerHTML:''},{type:"mtitle",title:"居中标题",innerHTML:''},{type:"task-no",title:"任务 - 未完成",innerHTML:''},{type:"task-yes",title:"任务 - 已完成",innerHTML:''},{type:"dplayer",title:"M3U8/MP4视频",innerHTML:''},{type:"netease-list",title:"网易云列表",innerHTML:''},{type:"netease-single",title:"网易云单首",innerHTML:''},{type:"bilibili",title:"哔哩哔哩视频",innerHTML:''},{type:"time",title:"当前时间",innerHTML:''},{type:"clean",title:"清屏",innerHTML:''},{type:"download",title:"下载",innerHTML:''},{type:"fullScreen",title:"全屏/取消全屏",innerHTML:''},{type:"draft",title:"保存草稿",innerHTML:''},{type:"publish",title:"发布文章",innerHTML:''},{type:"about",title:"关于",innerHTML:''}];const No=new HyperDown,Ro=window.JoeConfig.playerAPI;function $o(t){t=t.replace(/ /g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=No.makeHtml(t)).replace(/{x}/g,'')).replace(/{ }/g,'')).replace(/{music-list([^}]*)\/}/g,"")).replace(/{music([^}]*)\/}/g,"")).replace(/{bilibili([^}]*)\/}/g,"")).replace(/{dplayer([^}]*)\/}/g,'')).replace(/{mtitle([^}]*)\/}/g,"")).replace(/\:\:\(\s*(呵呵|哈哈|吐舌|太开心|笑眼|花心|小乖|乖|捂嘴笑|滑稽|你懂的|不高兴|怒|汗|黑线|泪|真棒|喷|惊哭|阴险|鄙视|酷|啊|狂汗|what|疑问|酸爽|呀咩爹|委屈|惊讶|睡觉|笑尿|挖鼻|吐|犀利|小红脸|懒得理|勉强|爱心|心碎|玫瑰|礼物|彩虹|太阳|星星月亮|钱币|茶杯|蛋糕|大拇指|胜利|haha|OK|沙发|手纸|香蕉|便便|药丸|红领巾|蜡烛|音乐|灯泡|开心|钱|咦|呼|冷|生气|弱|吐血|狗头)\s*\)/g,function(t,e){return e=encodeURI(e).replace(/%/g,""),``})).replace(/\:\@\(\s*(高兴|小怒|脸红|内伤|装大款|赞一个|害羞|汗|吐血倒地|深思|不高兴|无语|亲亲|口水|尴尬|中指|想一想|哭泣|便便|献花|皱眉|傻笑|狂汗|吐|喷水|看不见|鼓掌|阴暗|长草|献黄瓜|邪恶|期待|得意|吐舌|喷血|无所谓|观察|暗地观察|肿包|中枪|大囧|呲牙|抠鼻|不说话|咽气|欢呼|锁眉|蜡烛|坐等|击掌|惊喜|喜极而泣|抽烟|不出所料|愤怒|无奈|黑线|投降|看热闹|扇耳光|小眼睛|中刀)\s*\)/g,function(t,e){return e=encodeURI(e).replace(/%/g,""),``}),$(".cm-preview-content").html(t),$(".cm-preview-content pre code").each((t,e)=>Prism.highlightElement(e))}class zo extends class{constructor(){$("body").append(`
    @@ -94,7 +94,7 @@
    - `,confirm:()=>{var t=`\n{mtitle title="${$(".cm-modal input[name='text']").val()}"/}\n\n`;this._getLineCh(e)?this._replaceSelection(e,"\n"+t):this._replaceSelection(e,t),e.focus()}})}}{constructor(){var t;super(),this.plugins=[(t={},[oo,so.of(t),Qn.domEventHandlers({beforeinput(t,e){return"historyUndo"==t.inputType?ho(e):"historyRedo"==t.inputType&&lo(e)}})]),Po,(t={},[es.of(t),rs]),[Qn.inputHandler.of(gs),ds]],this._isPasting=!1,this.init_ViewPort(),this.init_Editor(),this.init_Preview(),this.init_Tools(),this.init_Insert(),this.init_AutoSave()}init_ViewPort(){0<$('meta[name="viewport"]').length?$('meta[name="viewport"]').attr("content","width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover"):$("head").append('')}init_Editor(){$("#text").before(` + `,confirm:()=>{var t=`\n{mtitle title="${$(".cm-modal input[name='text']").val()}"/}\n\n`;this._getLineCh(e)?this._replaceSelection(e,"\n"+t):this._replaceSelection(e,t),e.focus()}})}handleHtml(t){var e=`${this._getLineCh(t)?"\n":""}!!!\n

    居中

    \n

    居右

    \n颜色大小\n!!!\n`;this._replaceSelection(t,e),t.focus()}}{constructor(){var t;super(),this.plugins=[(t={},[oo,so.of(t),Qn.domEventHandlers({beforeinput(t,e){return"historyUndo"==t.inputType?ho(e):"historyRedo"==t.inputType&&lo(e)}})]),Po,(t={},[es.of(t),rs]),[Qn.inputHandler.of(gs),ds]],this._isPasting=!1,this.init_ViewPort(),this.init_Editor(),this.init_Preview(),this.init_Tools(),this.init_Insert(),this.init_AutoSave()}init_ViewPort(){0<$('meta[name="viewport"]').length?$('meta[name="viewport"]').attr("content","width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover"):$("head").append('')}init_Editor(){$("#text").before(`
    @@ -105,4 +105,4 @@
    - `),$o($("#text").val());const s=new Qn({state:pt.create({doc:$("#text").val(),extensions:[...this.plugins,ar.of([eo,...to,...yo,...ms]),Qn.updateListener.of(t=>{t.docChanged&&(window.requestAnimationFrame?window.requestAnimationFrame(()=>$o(t.state.doc.toString())):$o(t.state.doc.toString()))}),Qn.domEventHandlers({paste:e=>{var n=e.clipboardData;if(n&&n.items){const r=n.items;if(r.length){let i=null;for(let t=0;t{const t=$.ajaxSettings.xhr();if(t.upload)return t.upload.addEventListener("progress",t=>{t=t.loaded/t.total*100;$(".cm-progress-left").width(t/2+"%"),$(".cm-progress-right").width(t/2+"%")},!1),t},success:t=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1;t=`${super._getLineCh(s)?"\n":""}![${t[1].title}](${t[0]})\n`;super._replaceSelection(s,t),s.focus()},error:()=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1}})}}}}}}})],tabSize:4})});$(".cm-mainer").prepend(s.dom),$("#text")[0].form&&$("#text")[0].form.addEventListener("submit",()=>$("#text").val(s.state.doc.toString())),this.cm=s}init_Preview(){const n=(t,e,i)=>{let n=e+(t-i);n<=0&&(n=0),n>=$(".cm-mainer").outerWidth()-16&&(n=$(".cm-mainer").outerWidth()-16),$(".cm-preview").width(n)};$(".cm-resize").on({mousedown:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.clientX;return $(".cm-preview").addClass("move"),document.onmousemove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.clientX)):n(i,e,t.clientX)},!(document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,$(".cm-preview").removeClass("move")})},touchstart:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.originalEvent.targetTouches[0].clientX;return $(".cm-preview").addClass("move"),document.ontouchmove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.targetTouches[0].clientX)):n(i,e,t.targetTouches[0].clientX)},!(document.ontouchend=()=>{document.ontouchmove=null,document.ontouchend=null,$(".cm-preview").removeClass("move")})}})}init_Tools(){_o.forEach(e=>{if("title"===e.type)super.handleTitle(this.cm,e);else{const i=$(`
    ${e.innerHTML}
    `);i.on("click",t=>{switch(t.preventDefault(),e.type){case"fullScreen":super.handleFullScreen(i);break;case"publish":super.handlePublish();break;case"undo":super.handleUndo(this.cm);break;case"redo":super.handleRedo(this.cm);break;case"time":super.handleTime(this.cm);break;case"bold":super._insetAmboText(this.cm,"**");break;case"italic":super._insetAmboText(this.cm,"*");break;case"delete":super._insetAmboText(this.cm,"~~");break;case"code-inline":super._insetAmboText(this.cm,"`");break;case"indent":super.handleIndent(this.cm);break;case"hr":super.handleHr(this.cm);break;case"clean":super.handleClean(this.cm);break;case"ordered-list":super.handleOrdered(this.cm);break;case"unordered-list":super.handleUnordered(this.cm);break;case"quote":super.handleQuote(this.cm);break;case"download":super.handleDownload(this.cm);break;case"link":super.handleLink(this.cm);break;case"image":super.handleImage(this.cm);break;case"table":super.handleTable(this.cm);break;case"code-block":super.handleCodeBlock(this.cm);break;case"about":super.handleAbout();break;case"character":super._createTableLists(this.cm,JoeConfig.characterAPI,"星星符号","字符大全");break;case"emoji":super._createTableLists(this.cm,JoeConfig.emojiAPI,"表情","符号表情(需数据库支持)");break;case"task-no":super.handleTask(this.cm,!1);break;case"task-yes":super.handleTask(this.cm,!0);break;case"netease-list":super.handleNetease(this.cm,!0);break;case"netease-single":super.handleNetease(this.cm,!1);break;case"bilibili":super.handleBilibili(this.cm);break;case"dplayer":super.handleDplayer(this.cm);break;case"draft":super.handleDraft();break;case"expression":super.handleExpression(this.cm);break;case"mtitle":super.handleMtitle(this.cm)}}),$(".cm-tools").append(i)}})}init_Insert(){Typecho.insertFileToEditor=(t,e,i)=>{e=`${super._getLineCh(this.cm)?"\n":""}${i?"!":""}[${t}](${e})\n`;super._replaceSelection(this.cm,e),this.cm.focus()}}init_AutoSave(){if(1===window.JoeConfig.autoSave){const t=$("#text")[0].form;let n=$('input[name="cid"]').val(),r=null;setInterval(()=>{$('input[name="cid"]').val(n),$("#text").val(this.cm.state.doc.toString());let i=$(t).serialize();i!==r&&($(".cm-autosave").addClass("active"),$.ajax({url:t.action,type:"POST",data:i+"&do=save",dataType:"json",success:t=>{n=t.cid,r=i;let e=setTimeout(()=>{$(".cm-autosave").removeClass("active"),clearTimeout(e)},1e3)}}))},5e3)}}}document.addEventListener("DOMContentLoaded",()=>new zo)}(); + `),$o($("#text").val());const s=new Qn({state:pt.create({doc:$("#text").val(),extensions:[...this.plugins,ar.of([eo,...to,...yo,...ms]),Qn.updateListener.of(t=>{t.docChanged&&(window.requestAnimationFrame?window.requestAnimationFrame(()=>$o(t.state.doc.toString())):$o(t.state.doc.toString()))}),Qn.domEventHandlers({paste:e=>{var n=e.clipboardData;if(n&&n.items){const r=n.items;if(r.length){let i=null;for(let t=0;t{const t=$.ajaxSettings.xhr();if(t.upload)return t.upload.addEventListener("progress",t=>{t=t.loaded/t.total*100;$(".cm-progress-left").width(t/2+"%"),$(".cm-progress-right").width(t/2+"%")},!1),t},success:t=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1;t=`${super._getLineCh(s)?"\n":""}![${t[1].title}](${t[0]})\n`;super._replaceSelection(s,t),s.focus()},error:()=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1}})}}}}}}})],tabSize:4})});$(".cm-mainer").prepend(s.dom),$("#text")[0].form&&$("#text")[0].form.addEventListener("submit",()=>$("#text").val(s.state.doc.toString())),this.cm=s}init_Preview(){const n=(t,e,i)=>{let n=e+(t-i);n<=0&&(n=0),n>=$(".cm-mainer").outerWidth()-16&&(n=$(".cm-mainer").outerWidth()-16),$(".cm-preview").width(n)};$(".cm-resize").on({mousedown:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.clientX;return $(".cm-preview").addClass("move"),document.onmousemove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.clientX)):n(i,e,t.clientX)},!(document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,$(".cm-preview").removeClass("move")})},touchstart:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.originalEvent.targetTouches[0].clientX;return $(".cm-preview").addClass("move"),document.ontouchmove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.targetTouches[0].clientX)):n(i,e,t.targetTouches[0].clientX)},!(document.ontouchend=()=>{document.ontouchmove=null,document.ontouchend=null,$(".cm-preview").removeClass("move")})}})}init_Tools(){_o.forEach(e=>{if("title"===e.type)super.handleTitle(this.cm,e);else{const i=$(`
    ${e.innerHTML}
    `);i.on("click",t=>{switch(t.preventDefault(),e.type){case"fullScreen":super.handleFullScreen(i);break;case"publish":super.handlePublish();break;case"undo":super.handleUndo(this.cm);break;case"redo":super.handleRedo(this.cm);break;case"time":super.handleTime(this.cm);break;case"bold":super._insetAmboText(this.cm,"**");break;case"italic":super._insetAmboText(this.cm,"*");break;case"delete":super._insetAmboText(this.cm,"~~");break;case"code-inline":super._insetAmboText(this.cm,"`");break;case"indent":super.handleIndent(this.cm);break;case"hr":super.handleHr(this.cm);break;case"clean":super.handleClean(this.cm);break;case"ordered-list":super.handleOrdered(this.cm);break;case"unordered-list":super.handleUnordered(this.cm);break;case"quote":super.handleQuote(this.cm);break;case"download":super.handleDownload(this.cm);break;case"link":super.handleLink(this.cm);break;case"image":super.handleImage(this.cm);break;case"table":super.handleTable(this.cm);break;case"code-block":super.handleCodeBlock(this.cm);break;case"about":super.handleAbout();break;case"character":super._createTableLists(this.cm,JoeConfig.characterAPI,"星星符号","字符大全");break;case"emoji":super._createTableLists(this.cm,JoeConfig.emojiAPI,"表情","符号表情(需数据库支持)");break;case"task-no":super.handleTask(this.cm,!1);break;case"task-yes":super.handleTask(this.cm,!0);break;case"netease-list":super.handleNetease(this.cm,!0);break;case"netease-single":super.handleNetease(this.cm,!1);break;case"bilibili":super.handleBilibili(this.cm);break;case"dplayer":super.handleDplayer(this.cm);break;case"draft":super.handleDraft();break;case"expression":super.handleExpression(this.cm);break;case"mtitle":super.handleMtitle(this.cm);break;case"html":super.handleHtml(this.cm)}}),$(".cm-tools").append(i)}})}init_Insert(){Typecho.insertFileToEditor=(t,e,i)=>{e=`${super._getLineCh(this.cm)?"\n":""}${i?"!":""}[${t}](${e})\n`;super._replaceSelection(this.cm,e),this.cm.focus()}}init_AutoSave(){if(1===window.JoeConfig.autoSave){const t=$("#text")[0].form;let n=$('input[name="cid"]').val(),r=null;setInterval(()=>{$('input[name="cid"]').val(n),$("#text").val(this.cm.state.doc.toString());let i=$(t).serialize();i!==r&&($(".cm-autosave").addClass("active"),$.ajax({url:t.action,type:"POST",data:i+"&do=save",dataType:"json",success:t=>{n=t.cid,r=i;let e=setTimeout(()=>{$(".cm-autosave").removeClass("active"),clearTimeout(e)},1e3)}}))},5e3)}}}document.addEventListener("DOMContentLoaded",()=>new zo)}(); diff --git a/typecho/write/js/joe.write.js b/typecho/write/js/joe.write.js index eb08d6e..7c18c5a 100644 --- a/typecho/write/js/joe.write.js +++ b/typecho/write/js/joe.write.js @@ -277,6 +277,9 @@ class Joe extends JoeAction { case 'mtitle': super.handleMtitle(this.cm); break; + case 'html': + super.handleHtml(this.cm); + break; } }); $('.cm-tools').append(el);