From bd5ad00cd4e013b4571b8f1a5d9fe8a2b0bff255 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 10 Mar 2024 17:31:10 -0700 Subject: [PATCH] Line wrapping draft --- .../{index-COa1VEgP.js => index-DWvz8hQH.js} | 72 ++++++++-------- webapp/dist/index.html | 2 +- webapp/src/merge_state.ts | 84 ++++++++++++++----- 3 files changed, 102 insertions(+), 56 deletions(-) rename webapp/dist/assets/{index-COa1VEgP.js => index-DWvz8hQH.js} (62%) diff --git a/webapp/dist/assets/index-COa1VEgP.js b/webapp/dist/assets/index-DWvz8hQH.js similarity index 62% rename from webapp/dist/assets/index-COa1VEgP.js rename to webapp/dist/assets/index-DWvz8hQH.js index 1eda116..9f8d1d3 100644 --- a/webapp/dist/assets/index-COa1VEgP.js +++ b/webapp/dist/assets/index-DWvz8hQH.js @@ -1,76 +1,76 @@ -var df=Object.defineProperty;var gf=(N,b,T)=>b in N?df(N,b,{enumerable:!0,configurable:!0,writable:!0,value:T}):N[b]=T;var Eo=(N,b,T)=>(gf(N,typeof b!="symbol"?b+"":b,T),T);(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const A of document.querySelectorAll('link[rel="modulepreload"]'))O(A);new MutationObserver(A=>{for(const G of A)if(G.type==="childList")for(const h of G.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&O(h)}).observe(document,{childList:!0,subtree:!0});function T(A){const G={};return A.integrity&&(G.integrity=A.integrity),A.referrerPolicy&&(G.referrerPolicy=A.referrerPolicy),A.crossOrigin==="use-credentials"?G.credentials="include":A.crossOrigin==="anonymous"?G.credentials="omit":G.credentials="same-origin",G}function O(A){if(A.ep)return;A.ep=!0;const G=T(A);fetch(A.href,G)}})();button_collapse_uncollapse_menu.onclick=function(){this.closest(".main-menu").classList.toggle("collapsed")};var pf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vf(N){return N&&N.__esModule&&Object.prototype.hasOwnProperty.call(N,"default")?N.default:N}var wl={exports:{}},Wo;function qo(){return Wo||(Wo=1,function(N,b){(function(T,O){N.exports=O()})(pf,function(){var T=navigator.userAgent,O=navigator.platform,A=/gecko\/\d/i.test(T),G=/MSIE \d/.test(T),h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(T),c=/Edge\/(\d+)/.exec(T),d=G||h||c,v=d&&(G?document.documentMode||6:+(c||h)[1]),m=!c&&/WebKit\//.test(T),w=m&&/Qt\/\d+\.\d+/.test(T),M=!c&&/Chrome\/(\d+)/.exec(T),D=M&&+M[1],I=/Opera\//.test(T),K=/Apple Computer/.test(navigator.vendor),Y=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(T),q=/PhantomJS/.test(T),Z=K&&(/Mobile\/\w+/.test(T)||navigator.maxTouchPoints>2),le=/Android/.test(T),ie=Z||le||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(T),ne=Z||/Mac/.test(O),he=/\bCrOS\b/.test(T),re=/win/i.test(O),J=I&&T.match(/Version\/(\d*\.\d*)/);J&&(J=Number(J[1])),J&&J>=15&&(I=!1,m=!0);var ye=ne&&(w||I&&(J==null||J<12.11)),Ie=A||d&&v>=9;function Ke(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var Me=function(e,t){var i=e.className,r=Ke(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function qe(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function De(e,t){return qe(e).appendChild(t)}function Q(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var l=0;l=t)return a+(t-l);a+=o-l,a+=i-a%i,l=o+1}}var gt=function(){this.id=null,this.f=null,this.time=0,this.handler=pr(this.onTimeout,this)};gt.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},gt.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i=t)return r+Math.min(a,t-n);if(n+=l-r,n+=i-n%i,r=l+1,n>=t)return r}}var vr=[""];function yr(e){for(;vr.length<=e;)vr.push(f(vr)+" ");return vr[e]}function f(e){return e[e.length-1]}function y(e,t){for(var i=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||_.test(e))}function H(e,t){return t?t.source.indexOf("\\w")>-1&&F(e)?!0:t.test(e):F(e)}function R(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ae=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ue(e){return e.charCodeAt(0)>=768&&ae.test(e)}function ce(e,t,i){for(;(i<0?t>0:ti?-1:1;;){if(t==i)return t;var n=(t+i)/2,l=r<0?Math.ceil(n):Math.floor(n);if(l==t)return e(l)?t:i;e(l)?i=l:t=l+r}}function Ce(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,l=0;lt||t==i&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,i),a.level==1?"rtl":"ltr",l),n=!0)}n||r(t,i,"ltr")}var be=null;function Ne(e,t,i){var r;be=null;for(var n=0;nt)return n;l.to==t&&(l.from!=l.to&&i=="before"?r=n:be=n),l.from==t&&(l.from!=l.to&&i!="before"?r=n:be=n)}return r??be}var ut=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,l=/[LRr]/,a=/[Lb1n]/,o=/[1n]/;function s(u,g,p){this.level=u,this.from=g,this.to=p}return function(u,g){var p=g=="ltr"?"L":"R";if(u.length==0||g=="ltr"&&!r.test(u))return!1;for(var L=u.length,C=[],E=0;E-1&&(r[t]=n.slice(0,l).concat(n.slice(l+1)))}}}function Te(e,t){var i=mr(e,t);if(i.length)for(var r=Array.prototype.slice.call(arguments,2),n=0;n0}function Mt(e){e.prototype.on=function(t,i){te(this,t,i)},e.prototype.off=function(t,i){je(this,t,i)}}function Oe(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Dl(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function gn(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function $r(e){Oe(e),Dl(e)}function pn(e){return e.target||e.srcElement}function Nl(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),ne&&e.ctrlKey&&t==1&&(t=3),t}var ns=function(){if(d&&v<9)return!1;var e=Q("div");return"draggable"in e||"dragDrop"in e}(),vn;function ls(e){if(vn==null){var t=Q("span","​");De(e,Q("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(vn=t.offsetWidth<=1&&t.offsetHeight>2&&!(d&&v<8))}var i=vn?Q("span","​"):Q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var yn;function as(e){if(yn!=null)return yn;var t=De(e,document.createTextNode("AخA")),i=bt(t,0,1).getBoundingClientRect(),r=bt(t,1,2).getBoundingClientRect();return qe(e),!i||i.left==i.right?!1:yn=r.right-i.right<3}var mn=` +var df=Object.defineProperty;var gf=(O,m,L)=>m in O?df(O,m,{enumerable:!0,configurable:!0,writable:!0,value:L}):O[m]=L;var fn=(O,m,L)=>(gf(O,typeof m!="symbol"?m+"":m,L),L);(function(){const m=document.createElement("link").relList;if(m&&m.supports&&m.supports("modulepreload"))return;for(const A of document.querySelectorAll('link[rel="modulepreload"]'))N(A);new MutationObserver(A=>{for(const z of A)if(z.type==="childList")for(const h of z.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&N(h)}).observe(document,{childList:!0,subtree:!0});function L(A){const z={};return A.integrity&&(z.integrity=A.integrity),A.referrerPolicy&&(z.referrerPolicy=A.referrerPolicy),A.crossOrigin==="use-credentials"?z.credentials="include":A.crossOrigin==="anonymous"?z.credentials="omit":z.credentials="same-origin",z}function N(A){if(A.ep)return;A.ep=!0;const z=L(A);fetch(A.href,z)}})();button_collapse_uncollapse_menu.onclick=function(){this.closest(".main-menu").classList.toggle("collapsed")};var pf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vf(O){return O&&O.__esModule&&Object.prototype.hasOwnProperty.call(O,"default")?O.default:O}var Cl={exports:{}},Wo;function qo(){return Wo||(Wo=1,function(O,m){(function(L,N){O.exports=N()})(pf,function(){var L=navigator.userAgent,N=navigator.platform,A=/gecko\/\d/i.test(L),z=/MSIE \d/.test(L),h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(L),c=/Edge\/(\d+)/.exec(L),d=z||h||c,v=d&&(z?document.documentMode||6:+(c||h)[1]),b=!c&&/WebKit\//.test(L),w=b&&/Qt\/\d+\.\d+/.test(L),k=!c&&/Chrome\/(\d+)/.exec(L),D=k&&+k[1],F=/Opera\//.test(L),K=/Apple Computer/.test(navigator.vendor),Y=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(L),q=/PhantomJS/.test(L),Z=K&&(/Mobile\/\w+/.test(L)||navigator.maxTouchPoints>2),le=/Android/.test(L),ie=Z||le||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(L),ne=Z||/Mac/.test(N),he=/\bCrOS\b/.test(L),re=/win/i.test(N),J=F&&L.match(/Version\/(\d*\.\d*)/);J&&(J=Number(J[1])),J&&J>=15&&(F=!1,b=!0);var ye=ne&&(w||F&&(J==null||J<12.11)),Fe=A||d&&v>=9;function Ke(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var Me=function(e,t){var i=e.className,r=Ke(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function qe(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function De(e,t){return qe(e).appendChild(t)}function Q(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var l=0;l=t)return a+(t-l);a+=o-l,a+=i-a%i,l=o+1}}var gt=function(){this.id=null,this.f=null,this.time=0,this.handler=pr(this.onTimeout,this)};gt.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},gt.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i=t)return r+Math.min(a,t-n);if(n+=l-r,n+=i-n%i,r=l+1,n>=t)return r}}var vr=[""];function yr(e){for(;vr.length<=e;)vr.push(f(vr)+" ");return vr[e]}function f(e){return e[e.length-1]}function y(e,t){for(var i=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||_.test(e))}function H(e,t){return t?t.source.indexOf("\\w")>-1&&I(e)?!0:t.test(e):I(e)}function R(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ae=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ue(e){return e.charCodeAt(0)>=768&&ae.test(e)}function ce(e,t,i){for(;(i<0?t>0:ti?-1:1;;){if(t==i)return t;var n=(t+i)/2,l=r<0?Math.ceil(n):Math.floor(n);if(l==t)return e(l)?t:i;e(l)?i=l:t=l+r}}function Ce(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,l=0;lt||t==i&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,i),a.level==1?"rtl":"ltr",l),n=!0)}n||r(t,i,"ltr")}var be=null;function Ne(e,t,i){var r;be=null;for(var n=0;nt)return n;l.to==t&&(l.from!=l.to&&i=="before"?r=n:be=n),l.from==t&&(l.from!=l.to&&i!="before"?r=n:be=n)}return r??be}var ut=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,l=/[LRr]/,a=/[Lb1n]/,o=/[1n]/;function s(u,g,p){this.level=u,this.from=g,this.to=p}return function(u,g){var p=g=="ltr"?"L":"R";if(u.length==0||g=="ltr"&&!r.test(u))return!1;for(var T=u.length,C=[],E=0;E-1&&(r[t]=n.slice(0,l).concat(n.slice(l+1)))}}}function Te(e,t){var i=mr(e,t);if(i.length)for(var r=Array.prototype.slice.call(arguments,2),n=0;n0}function Mt(e){e.prototype.on=function(t,i){te(this,t,i)},e.prototype.off=function(t,i){je(this,t,i)}}function Oe(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Nl(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function pn(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function $r(e){Oe(e),Nl(e)}function vn(e){return e.target||e.srcElement}function Ol(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),ne&&e.ctrlKey&&t==1&&(t=3),t}var ns=function(){if(d&&v<9)return!1;var e=Q("div");return"draggable"in e||"dragDrop"in e}(),yn;function ls(e){if(yn==null){var t=Q("span","​");De(e,Q("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(yn=t.offsetWidth<=1&&t.offsetHeight>2&&!(d&&v<8))}var i=yn?Q("span","​"):Q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var mn;function as(e){if(mn!=null)return mn;var t=De(e,document.createTextNode("AخA")),i=bt(t,0,1).getBoundingClientRect(),r=bt(t,1,2).getBoundingClientRect();return qe(e),!i||i.left==i.right?!1:mn=r.right-i.right<3}var bn=` b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(` -`,t);n==-1&&(n=e.length);var l=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),a=l.indexOf("\r");a!=-1?(i.push(l.slice(0,a)),t+=a+1):(i.push(l),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},os=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},ss=function(){var e=Q("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),bn=null;function us(e){if(bn!=null)return bn;var t=De(e,Q("span","x")),i=t.getBoundingClientRect(),r=bt(t,0,1).getBoundingClientRect();return bn=Math.abs(i.left-r.left)>1}var wn={},br={};function fs(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),wn[e]=t}function hs(e,t){br[e]=t}function Di(e){if(typeof e=="string"&&br.hasOwnProperty(e))e=br[e];else if(e&&typeof e.name=="string"&&br.hasOwnProperty(e.name)){var t=br[e.name];typeof t=="string"&&(t={name:t}),e=x(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Di("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Di("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Cn(e,t){t=Di(t);var i=wn[t.name];if(!i)return Cn(e,"text/plain");var r=i(e,t);if(wr.hasOwnProperty(t.name)){var n=wr[t.name];for(var l in n)n.hasOwnProperty(l)&&(r.hasOwnProperty(l)&&(r["_"+l]=r[l]),r[l]=n[l])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var wr={};function cs(e,t){var i=wr.hasOwnProperty(e)?wr[e]:wr[e]={};dt(t,i)}function jt(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Sn(e,t){for(var i;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function Ol(e,t,i){return e.startState?e.startState(t,i):!0}var Ee=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Ee.prototype.eol=function(){return this.pos>=this.string.length},Ee.prototype.sol=function(){return this.pos==this.lineStart},Ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ee.prototype.next=function(){if(this.post},Ee.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ee.prototype.skipToEnd=function(){this.pos=this.string.length},Ee.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ee.prototype.backUp=function(e){this.pos-=e},Ee.prototype.column=function(){return this.lastColumnPos0?null:(l&&t!==!1&&(this.pos+=l[0].length),l)}},Ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ee.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ee.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ee.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function j(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],l=n.chunkSize();if(t=e.first&&ti?P(i,j(e,i).text.length):ds(t,j(e,t.line).text.length)}function ds(e,t){var i=e.ch;return i==null||i>t?P(e.line,t):i<0?P(e.line,0):e}function Wl(e,t){for(var i=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},Ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ct.fromSaved=function(e,t,i){return t instanceof Ei?new Ct(e,jt(e.mode,t.state),i,t.lookAhead):new Ct(e,jt(e.mode,t),i)},Ct.prototype.save=function(e){var t=e!==!1?jt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ei(t,this.maxLookAhead):t};function Fl(e,t,i,r){var n=[e.state.modeGen],l={};zl(e,t.text,e.doc.mode,i,function(u,g){return n.push(u,g)},l,r);for(var a=i.state,o=function(u){i.baseTokens=n;var g=e.state.overlays[u],p=1,L=0;i.state=!0,zl(e,t.text,g.mode,i,function(C,E){for(var W=p;LC&&n.splice(p,1,C,n[p+1],B),p+=2,L=Math.min(C,B)}if(E)if(g.opaque)n.splice(W,p-W,C,"overlay "+E),p=W+2;else for(;We.options.maxHighlightLength&&jt(e.doc.mode,r.state),l=Fl(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=l.styles,l.classes?t.styleClasses=l.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Yr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Ct(r,!0,t);var l=gs(e,t,i),a=l>r.first&&j(r,l-1).stateAfter,o=a?Ct.fromSaved(r,a,l):new Ct(r,Ol(r.mode),l);return r.iter(l,t,function(s){An(e,s.text,o);var u=o.line;s.stateAfter=u==t-1||u%5==0||u>=n.viewFrom&&ut.start)return l}throw new Error("Mode "+e.name+" failed to advance stream.")}var Pl=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Bl(e,t,i,r){var n=e.doc,l=n.mode,a;t=se(n,t);var o=j(n,t.line),s=Yr(e,t.line,i),u=new Ee(o.text,e.options.tabSize,s),g;for(r&&(g=[]);(r||u.pose.options.maxHighlightLength?(o=!1,a&&An(e,t,r,g.pos),g.pos=t.length,p=null):p=Rl(Mn(i,g,r.state,L),l),L){var C=L[0].name;C&&(p="m-"+(p?C+" "+p:C))}if(!o||u!=p){for(;sa;--o){if(o<=l.first)return l.first;var s=j(l,o-1),u=s.stateAfter;if(u&&(!i||o+(u instanceof Ei?u.lookAhead:0)<=l.modeFrontier))return o;var g=Ze(s.text,null,e.options.tabSize);(n==null||r>g)&&(n=o-1,r=g)}return n}function ps(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontieri;r--){var n=j(e,r).stateAfter;if(n&&(!(n instanceof Ei)||r+n.lookAhead=t:l.to>t);(r||(r=[])).push(new Wi(a,l.from,s?null:l.to))}}return r}function Cs(e,t,i){var r;if(e)for(var n=0;n=t:l.to>t);if(o||l.from==t&&a.type=="bookmark"&&(!i||l.marker.insertLeft)){var s=l.from==null||(a.inclusiveLeft?l.from<=t:l.from0&&o)for(var X=0;X0)){var g=[s,1],p=oe(u.from,o.from),L=oe(u.to,o.to);(p<0||!a.inclusiveLeft&&!p)&&g.push({from:u.from,to:o.from}),(L>0||!a.inclusiveRight&&!L)&&g.push({from:o.to,to:u.to}),n.splice.apply(n,g),s+=g.length-3}}return n}function Kl(e){var t=e.markedSpans;if(t){for(var i=0;it)&&(!r||Dn(r,l.marker)<0)&&(r=l.marker)}return r}function ql(e,t,i,r,n){var l=j(e,t),a=_t&&l.markedSpans;if(a)for(var o=0;o=0&&p<=0||g<=0&&p>=0)&&(g<=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?oe(u.to,i)>=0:oe(u.to,i)>0)||g>=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?oe(u.from,r)<=0:oe(u.from,r)<0)))return!0}}}function pt(e){for(var t;t=Yl(e);)e=t.find(-1,!0).line;return e}function Ts(e){for(var t;t=Hi(e);)e=t.find(1,!0).line;return e}function ks(e){for(var t,i;t=Hi(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Nn(e,t){var i=j(e,t),r=pt(i);return i==r?t:pe(r)}function Zl(e,t){if(t>e.lastLine())return t;var i=j(e,t),r;if(!Bt(e,i))return t;for(;r=Hi(i);)i=r.find(1,!0).line;return pe(i)+1}function Bt(e,t){var i=_t&&t.markedSpans;if(i){for(var r=void 0,n=0;nt.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Cr=function(e,t,i){this.text=e,$l(this,t),this.height=i?i(this):1};Cr.prototype.lineNo=function(){return pe(this)},Mt(Cr);function xs(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Kl(e),$l(e,i);var n=r?r(e):1;n!=e.height&&wt(e,n)}function As(e){e.parent=null,Kl(e)}var Ms={},_s={};function Ql(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?_s:Ms;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Jl(e,t){var i=kt("span",null,null,m?"padding-right: .1px":null),r={pre:kt("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var l=n?t.rest[n-1]:t.line,a=void 0;r.pos=0,r.addToken=Ns,as(e.display.measure)&&(a=ge(l,e.doc.direction))&&(r.addToken=Es(r.addToken,a)),r.map=[];var o=t!=e.display.externalMeasured&&pe(l);Ws(l,r,Il(e,l,o)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=zr(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=zr(l.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(ls(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(m){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=zr(r.pre.className,r.textClass||"")),r}function Ds(e){var t=Q("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Ns(e,t,i,r,n,l,a){if(t){var o=e.splitSpaces?Os(t,e.trailingSpace):t,s=e.cm.state.specialChars,u=!1,g;if(!s.test(t))e.col+=t.length,g=document.createTextNode(o),e.map.push(e.pos,e.pos+t.length,g),d&&v<9&&(u=!0),e.pos+=t.length;else{g=document.createDocumentFragment();for(var p=0;;){s.lastIndex=p;var L=s.exec(t),C=L?L.index-p:t.length-p;if(C){var E=document.createTextNode(o.slice(p,p+C));d&&v<9?g.appendChild(Q("span",[E])):g.appendChild(E),e.map.push(e.pos,e.pos+C,E),e.col+=C,e.pos+=C}if(!L)break;p+=C+1;var W=void 0;if(L[0]==" "){var B=e.cm.options.tabSize,z=B-e.col%B;W=g.appendChild(Q("span",yr(z),"cm-tab")),W.setAttribute("role","presentation"),W.setAttribute("cm-text"," "),e.col+=z}else L[0]=="\r"||L[0]==` -`?(W=g.appendChild(Q("span",L[0]=="\r"?"␍":"␤","cm-invalidchar")),W.setAttribute("cm-text",L[0]),e.col+=1):(W=e.cm.options.specialCharPlaceholder(L[0]),W.setAttribute("cm-text",L[0]),d&&v<9?g.appendChild(Q("span",[W])):g.appendChild(W),e.col+=1);e.map.push(e.pos,e.pos+1,W),e.pos++}}if(e.trailingSpace=o.charCodeAt(t.length-1)==32,i||r||n||u||l||a){var $=i||"";r&&($+=r),n&&($+=n);var U=Q("span",[g],$,l);if(a)for(var X in a)a.hasOwnProperty(X)&&X!="style"&&X!="class"&&U.setAttribute(X,a[X]);return e.content.appendChild(U)}e.content.appendChild(g)}}function Os(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;nu&&p.from<=u));L++);if(p.to>=g)return e(i,r,n,l,a,o,s);e(i,r.slice(0,p.to-u),n,l,null,o,s),l=null,r=r.slice(p.to-u),u=p.to}}}function jl(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Ws(e,t,i){var r=e.markedSpans,n=e.text,l=0;if(!r){for(var a=1;as||fe.collapsed&&V.to==s&&V.from==s)){if(V.to!=null&&V.to!=s&&C>V.to&&(C=V.to,W=""),fe.className&&(E+=" "+fe.className),fe.css&&(L=(L?L+";":"")+fe.css),fe.startStyle&&V.from==s&&(B+=" "+fe.startStyle),fe.endStyle&&V.to==C&&(X||(X=[])).push(fe.endStyle,V.to),fe.title&&(($||($={})).title=fe.title),fe.attributes)for(var we in fe.attributes)($||($={}))[we]=fe.attributes[we];fe.collapsed&&(!z||Dn(z.marker,fe)<0)&&(z=V)}else V.from>s&&C>V.from&&(C=V.from)}if(X)for(var Ue=0;Ue=o)break;for(var st=Math.min(o,C);;){if(g){var nt=s+g.length;if(!z){var We=nt>st?g.slice(0,st-s):g;t.addToken(t,We,p?p+E:E,B,s+We.length==C?W:"",L,$)}if(nt>=st){g=g.slice(st-s),s=st;break}s=nt,B=""}g=n.slice(l,l=i[u++]),p=Ql(i[u++],t.cm.options)}}}function Vl(e,t,i){this.line=t,this.rest=ks(t),this.size=this.rest?pe(f(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Bt(e,t)}function Bi(e,t,i){for(var r=[],n,l=t;l2&&l.push((s.bottom+u.top)/2-i.top)}}l.push(i.bottom-i.top)}}function aa(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var r=0;ri)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}}function $s(e,t){t=pt(t);var i=pe(t),r=e.display.externalMeasured=new Vl(e.doc,t,i);r.lineN=i;var n=r.built=Jl(e,r);return r.text=n.pre,De(e.display.lineMeasure,n.pre),r}function oa(e,t,i,r){return Lt(e,Lr(e,t),i,r)}function Hn(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(l=s-o,n=l-1,t>=s&&(a="right")),n!=null){if(r=e[u+2],o==s&&i==(r.insertLeft?"left":"right")&&(a=i),i=="left"&&n==0)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[(u-=3)+2],a="left";if(i=="right"&&n==s-o)for(;u=0&&(i=e[n]).left==i.right;n--);return i}function Ys(e,t,i,r){var n=ua(t.map,i,r),l=n.node,a=n.start,o=n.end,s=n.collapse,u;if(l.nodeType==3){for(var g=0;g<4;g++){for(;a&&ue(t.line.text.charAt(n.coverStart+a));)--a;for(;n.coverStart+o0&&(s=r="right");var p;e.options.lineWrapping&&(p=l.getClientRects()).length>1?u=p[r=="right"?p.length-1:0]:u=l.getBoundingClientRect()}if(d&&v<9&&!a&&(!u||!u.left&&!u.right)){var L=l.parentNode.getClientRects()[0];L?u={left:L.left,right:L.left+kr(e.display),top:L.top,bottom:L.bottom}:u=sa}for(var C=u.top-t.rect.top,E=u.bottom-t.rect.top,W=(C+E)/2,B=t.view.measure.heights,z=0;z=r.text.length?(s=r.text.length,u="before"):s<=0&&(s=0,u="after"),!o)return a(u=="before"?s-1:s,u=="before");function g(E,W,B){var z=o[W],$=z.level==1;return a(B?E-1:E,$!=B)}var p=Ne(o,s,u),L=be,C=g(s,p,u=="before");return L!=null&&(C.other=g(s,L,u!="before")),C}function pa(e,t){var i=0;t=se(e.doc,t),e.options.lineWrapping||(i=kr(e.display)*t.ch);var r=j(e.doc,t.line),n=Dt(r)+Ri(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function Bn(e,t,i,r,n){var l=P(e,t,i);return l.xRel=n,r&&(l.outside=r),l}function Rn(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return Bn(r.first,0,null,-1,-1);var n=er(r,i),l=r.first+r.size-1;if(n>l)return Bn(r.first+r.size-1,j(r,l).text.length,null,1,1);t<0&&(t=0);for(var a=j(r,n);;){var o=Zs(e,a,n,t,i),s=Ls(a,o.ch+(o.xRel>0||o.outside>0?1:0));if(!s)return o;var u=s.find(1);if(u.line==n)return u;a=j(r,n=u.line)}}function va(e,t,i,r){r-=Pn(t);var n=t.text.length,l=me(function(a){return Lt(e,i,a-1).bottom<=r},n,0);return n=me(function(a){return Lt(e,i,a).top>r},l,n),{begin:l,end:n}}function ya(e,t,i,r){i||(i=Lr(e,t));var n=zi(e,t,Lt(e,i,r),"line").top;return va(e,t,i,n)}function zn(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Zs(e,t,i,r,n){n-=Dt(t);var l=Lr(e,t),a=Pn(t),o=0,s=t.text.length,u=!0,g=ge(t,e.doc.direction);if(g){var p=(e.options.lineWrapping?Js:Qs)(e,t,i,l,g,r,n);u=p.level!=1,o=u?p.from:p.to-1,s=u?p.to:p.from-1}var L=null,C=null,E=me(function(ee){var V=Lt(e,l,ee);return V.top+=a,V.bottom+=a,zn(V,r,n,!1)?(V.top<=n&&V.left<=r&&(L=ee,C=V),!0):!1},o,s),W,B,z=!1;if(C){var $=r-C.left=X.bottom?1:0}return E=ce(t.text,E,1),Bn(i,E,B,z,r-W)}function Qs(e,t,i,r,n,l,a){var o=me(function(p){var L=n[p],C=L.level!=1;return zn(vt(e,P(i,C?L.to:L.from,C?"before":"after"),"line",t,r),l,a,!0)},0,n.length-1),s=n[o];if(o>0){var u=s.level!=1,g=vt(e,P(i,u?s.from:s.to,u?"after":"before"),"line",t,r);zn(g,l,a,!0)&&g.top>a&&(s=n[o-1])}return s}function Js(e,t,i,r,n,l,a){var o=va(e,t,r,a),s=o.begin,u=o.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var g=null,p=null,L=0;L=u||C.to<=s)){var E=C.level!=1,W=Lt(e,r,E?Math.min(u,C.to)-1:Math.max(s,C.from)).right,B=WB)&&(g=C,p=B)}}return g||(g=n[n.length-1]),g.fromu&&(g={from:g.from,to:u,level:g.level}),g}var rr;function Tr(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(rr==null){rr=Q("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)rr.appendChild(document.createTextNode("x")),rr.appendChild(Q("br"));rr.appendChild(document.createTextNode("x"))}De(e.measure,rr);var i=rr.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),qe(e.measure),i||1}function kr(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Q("span","xxxxxxxxxx"),i=Q("pre",[t],"CodeMirror-line-like");De(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function Un(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,l=t.gutters.firstChild,a=0;l;l=l.nextSibling,++a){var o=e.display.gutterSpecs[a].className;i[o]=l.offsetLeft+l.clientLeft+n,r[o]=l.clientWidth}return{fixedPos:Gn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Gn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function ma(e){var t=Tr(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/kr(e.display)-3);return function(n){if(Bt(e.doc,n))return 0;var l=0;if(n.widgets)for(var a=0;a0&&(u=j(e.doc,s.line).text).length==s.ch){var g=Ze(u,u.length,e.options.tabSize)-u.length;s=P(s.line,Math.max(0,Math.round((l-la(e.display).left)/kr(e.display))-g))}return s}function nr(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom,t<0))return null;for(var i=e.display.view,r=0;rt)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)_t&&Nn(e.doc,t)n.viewFrom?zt(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)zt(e);else if(t<=n.viewFrom){var l=Gi(e,i,i+r,1);l?(n.view=n.view.slice(l.index),n.viewFrom=l.lineN,n.viewTo+=r):zt(e)}else if(i>=n.viewTo){var a=Gi(e,t,t,-1);a?(n.view=n.view.slice(0,a.index),n.viewTo=a.lineN):zt(e)}else{var o=Gi(e,t,t,-1),s=Gi(e,i,i+r,1);o&&s?(n.view=n.view.slice(0,o.index).concat(Bi(e,o.lineN,s.lineN)).concat(n.view.slice(s.index)),n.viewTo+=r):zt(e)}var u=n.externalMeasured;u&&(i=n.lineN&&t=r.viewTo)){var l=r.view[nr(e,t)];if(l.node!=null){var a=l.changes||(l.changes=[]);Se(a,i)==-1&&a.push(i)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gi(e,t,i,r){var n=nr(e,t),l,a=e.display.view;if(!_t||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var o=e.display.viewFrom,s=0;s0){if(n==a.length-1)return null;l=o+a[n].size-t,n++}else l=o-t;t+=l,i+=l}for(;Nn(e.doc,i)!=i;){if(n==(r<0?0:a.length-1))return null;i+=r*a[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function js(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Bi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Bi(e,t,r.viewFrom).concat(r.view):r.viewFromi&&(r.view=r.view.slice(0,nr(e,i)))),r.viewTo=i}function ba(e){for(var t=e.display.view,i=0,r=0;r=e.display.viewTo||s.to().line0?a:e.defaultCharWidth())+"px"}if(r.other){var o=i.appendChild(Q("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Ki(e,t){return e.top-t.top||e.left-t.left}function Vs(e,t,i){var r=e.display,n=e.doc,l=document.createDocumentFragment(),a=la(e.display),o=a.left,s=Math.max(r.sizerWidth,tr(e)-r.sizer.offsetLeft)-a.right,u=n.direction=="ltr";function g(U,X,ee,V){X<0&&(X=0),X=Math.round(X),V=Math.round(V),l.appendChild(Q("div",null,"CodeMirror-selected","position: absolute; left: "+U+`px; - top: `+X+"px; width: "+(ee??s-U)+`px; - height: `+(V-X)+"px"))}function p(U,X,ee){var V=j(n,U),fe=V.text.length,we,Ue;function ke(We,lt){return Ui(e,P(U,We),"div",V,lt)}function st(We,lt,Xe){var He=ya(e,V,null,We),Fe=lt=="ltr"==(Xe=="after")?"left":"right",Ae=Xe=="after"?He.begin:He.end-(/\s/.test(V.text.charAt(He.end-1))?2:1);return ke(Ae,Fe)[Fe]}var nt=ge(V,n.direction);return Ce(nt,X||0,ee??fe,function(We,lt,Xe,He){var Fe=Xe=="ltr",Ae=ke(We,Fe?"left":"right"),at=ke(lt-1,Fe?"right":"left"),Pr=X==null&&We==0,Yt=ee==null&<==fe,Je=He==0,Tt=!nt||He==nt.length-1;if(at.top-Ae.top<=3){var Ge=(u?Pr:Yt)&&Je,ml=(u?Yt:Pr)&&Tt,Wt=Ge?o:(Fe?Ae:at).left,ur=ml?s:(Fe?at:Ae).right;g(Wt,Ae.top,ur-Wt,Ae.bottom)}else{var fr,et,Br,bl;Fe?(fr=u&&Pr&&Je?o:Ae.left,et=u?s:st(We,Xe,"before"),Br=u?o:st(lt,Xe,"after"),bl=u&&Yt&&Tt?s:at.right):(fr=u?st(We,Xe,"before"):o,et=!u&&Pr&&Je?s:Ae.right,Br=!u&&Yt&&Tt?o:at.left,bl=u?st(lt,Xe,"after"):s),g(fr,Ae.top,et-fr,Ae.bottom),Ae.bottom0?t.blinker=setInterval(function(){e.hasFocus()||xr(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Ca(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||qn(e))}function Yn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&xr(e))},100)}function qn(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),e.options.readOnly!="nocursor"&&(e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,xt(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),m&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Xn(e))}function xr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,Me(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function $i(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=Math.max(0,t.scroller.getBoundingClientRect().top),n=t.lineDiv.getBoundingClientRect().top,l=0,a=0;a.005||C<-.005)&&(ne.display.sizerWidth){var W=Math.ceil(g/kr(e.display));W>e.display.maxLineLength&&(e.display.maxLineLength=W,e.display.maxLine=o.line,e.display.maxLineChanged=!0)}}}Math.abs(l)>2&&(t.scroller.scrollTop+=l)}function Sa(e){if(e.widgets)for(var t=0;t=a&&(l=er(t,Dt(j(t,s))-e.wrapper.clientHeight),a=s)}return{from:l,to:Math.max(a,l+1)}}function eu(e,t){if(!xe(e,"scrollCursorIntoView")){var i=e.display,r=i.sizer.getBoundingClientRect(),n=null,l=i.wrapper.ownerDocument;if(t.top+r.top<0?n=!0:t.bottom+r.top>(l.defaultView.innerHeight||l.documentElement.clientHeight)&&(n=!1),n!=null&&!q){var a=Q("div","​",null,`position: absolute; +`,t);n==-1&&(n=e.length);var l=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),a=l.indexOf("\r");a!=-1?(i.push(l.slice(0,a)),t+=a+1):(i.push(l),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},os=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},ss=function(){var e=Q("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),wn=null;function us(e){if(wn!=null)return wn;var t=De(e,Q("span","x")),i=t.getBoundingClientRect(),r=bt(t,0,1).getBoundingClientRect();return wn=Math.abs(i.left-r.left)>1}var Cn={},br={};function fs(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Cn[e]=t}function hs(e,t){br[e]=t}function Di(e){if(typeof e=="string"&&br.hasOwnProperty(e))e=br[e];else if(e&&typeof e.name=="string"&&br.hasOwnProperty(e.name)){var t=br[e.name];typeof t=="string"&&(t={name:t}),e=M(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Di("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Di("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Sn(e,t){t=Di(t);var i=Cn[t.name];if(!i)return Sn(e,"text/plain");var r=i(e,t);if(wr.hasOwnProperty(t.name)){var n=wr[t.name];for(var l in n)n.hasOwnProperty(l)&&(r.hasOwnProperty(l)&&(r["_"+l]=r[l]),r[l]=n[l])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var wr={};function cs(e,t){var i=wr.hasOwnProperty(e)?wr[e]:wr[e]={};dt(t,i)}function jt(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Ln(e,t){for(var i;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function El(e,t,i){return e.startState?e.startState(t,i):!0}var Ee=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Ee.prototype.eol=function(){return this.pos>=this.string.length},Ee.prototype.sol=function(){return this.pos==this.lineStart},Ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ee.prototype.next=function(){if(this.post},Ee.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ee.prototype.skipToEnd=function(){this.pos=this.string.length},Ee.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ee.prototype.backUp=function(e){this.pos-=e},Ee.prototype.column=function(){return this.lastColumnPos0?null:(l&&t!==!1&&(this.pos+=l[0].length),l)}},Ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ee.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ee.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ee.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function j(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],l=n.chunkSize();if(t=e.first&&ti?P(i,j(e,i).text.length):ds(t,j(e,t.line).text.length)}function ds(e,t){var i=e.ch;return i==null||i>t?P(e.line,t):i<0?P(e.line,0):e}function Il(e,t){for(var i=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},Ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ct.fromSaved=function(e,t,i){return t instanceof Ei?new Ct(e,jt(e.mode,t.state),i,t.lookAhead):new Ct(e,jt(e.mode,t),i)},Ct.prototype.save=function(e){var t=e!==!1?jt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ei(t,this.maxLookAhead):t};function Fl(e,t,i,r){var n=[e.state.modeGen],l={};Ul(e,t.text,e.doc.mode,i,function(u,g){return n.push(u,g)},l,r);for(var a=i.state,o=function(u){i.baseTokens=n;var g=e.state.overlays[u],p=1,T=0;i.state=!0,Ul(e,t.text,g.mode,i,function(C,E){for(var W=p;TC&&n.splice(p,1,C,n[p+1],B),p+=2,T=Math.min(C,B)}if(E)if(g.opaque)n.splice(W,p-W,C,"overlay "+E),p=W+2;else for(;We.options.maxHighlightLength&&jt(e.doc.mode,r.state),l=Fl(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=l.styles,l.classes?t.styleClasses=l.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Yr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Ct(r,!0,t);var l=gs(e,t,i),a=l>r.first&&j(r,l-1).stateAfter,o=a?Ct.fromSaved(r,a,l):new Ct(r,El(r.mode),l);return r.iter(l,t,function(s){Mn(e,s.text,o);var u=o.line;s.stateAfter=u==t-1||u%5==0||u>=n.viewFrom&&ut.start)return l}throw new Error("Mode "+e.name+" failed to advance stream.")}var Bl=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Rl(e,t,i,r){var n=e.doc,l=n.mode,a;t=se(n,t);var o=j(n,t.line),s=Yr(e,t.line,i),u=new Ee(o.text,e.options.tabSize,s),g;for(r&&(g=[]);(r||u.pose.options.maxHighlightLength?(o=!1,a&&Mn(e,t,r,g.pos),g.pos=t.length,p=null):p=zl(_n(i,g,r.state,T),l),T){var C=T[0].name;C&&(p="m-"+(p?C+" "+p:C))}if(!o||u!=p){for(;sa;--o){if(o<=l.first)return l.first;var s=j(l,o-1),u=s.stateAfter;if(u&&(!i||o+(u instanceof Ei?u.lookAhead:0)<=l.modeFrontier))return o;var g=Ze(s.text,null,e.options.tabSize);(n==null||r>g)&&(n=o-1,r=g)}return n}function ps(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontieri;r--){var n=j(e,r).stateAfter;if(n&&(!(n instanceof Ei)||r+n.lookAhead=t:l.to>t);(r||(r=[])).push(new Wi(a,l.from,s?null:l.to))}}return r}function Cs(e,t,i){var r;if(e)for(var n=0;n=t:l.to>t);if(o||l.from==t&&a.type=="bookmark"&&(!i||l.marker.insertLeft)){var s=l.from==null||(a.inclusiveLeft?l.from<=t:l.from0&&o)for(var X=0;X0)){var g=[s,1],p=oe(u.from,o.from),T=oe(u.to,o.to);(p<0||!a.inclusiveLeft&&!p)&&g.push({from:u.from,to:o.from}),(T>0||!a.inclusiveRight&&!T)&&g.push({from:o.to,to:u.to}),n.splice.apply(n,g),s+=g.length-3}}return n}function $l(e){var t=e.markedSpans;if(t){for(var i=0;it)&&(!r||Nn(r,l.marker)<0)&&(r=l.marker)}return r}function Zl(e,t,i,r,n){var l=j(e,t),a=_t&&l.markedSpans;if(a)for(var o=0;o=0&&p<=0||g<=0&&p>=0)&&(g<=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?oe(u.to,i)>=0:oe(u.to,i)>0)||g>=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?oe(u.from,r)<=0:oe(u.from,r)<0)))return!0}}}function pt(e){for(var t;t=ql(e);)e=t.find(-1,!0).line;return e}function Ts(e){for(var t;t=Hi(e);)e=t.find(1,!0).line;return e}function ks(e){for(var t,i;t=Hi(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function On(e,t){var i=j(e,t),r=pt(i);return i==r?t:pe(r)}function Ql(e,t){if(t>e.lastLine())return t;var i=j(e,t),r;if(!Bt(e,i))return t;for(;r=Hi(i);)i=r.find(1,!0).line;return pe(i)+1}function Bt(e,t){var i=_t&&t.markedSpans;if(i){for(var r=void 0,n=0;nt.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Cr=function(e,t,i){this.text=e,Xl(this,t),this.height=i?i(this):1};Cr.prototype.lineNo=function(){return pe(this)},Mt(Cr);function xs(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),$l(e),Xl(e,i);var n=r?r(e):1;n!=e.height&&wt(e,n)}function As(e){e.parent=null,$l(e)}var Ms={},_s={};function Jl(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?_s:Ms;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function jl(e,t){var i=kt("span",null,null,b?"padding-right: .1px":null),r={pre:kt("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var l=n?t.rest[n-1]:t.line,a=void 0;r.pos=0,r.addToken=Ns,as(e.display.measure)&&(a=ge(l,e.doc.direction))&&(r.addToken=Es(r.addToken,a)),r.map=[];var o=t!=e.display.externalMeasured&&pe(l);Ws(l,r,Hl(e,l,o)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=zr(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=zr(l.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(ls(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(b){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=zr(r.pre.className,r.textClass||"")),r}function Ds(e){var t=Q("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Ns(e,t,i,r,n,l,a){if(t){var o=e.splitSpaces?Os(t,e.trailingSpace):t,s=e.cm.state.specialChars,u=!1,g;if(!s.test(t))e.col+=t.length,g=document.createTextNode(o),e.map.push(e.pos,e.pos+t.length,g),d&&v<9&&(u=!0),e.pos+=t.length;else{g=document.createDocumentFragment();for(var p=0;;){s.lastIndex=p;var T=s.exec(t),C=T?T.index-p:t.length-p;if(C){var E=document.createTextNode(o.slice(p,p+C));d&&v<9?g.appendChild(Q("span",[E])):g.appendChild(E),e.map.push(e.pos,e.pos+C,E),e.col+=C,e.pos+=C}if(!T)break;p+=C+1;var W=void 0;if(T[0]==" "){var B=e.cm.options.tabSize,U=B-e.col%B;W=g.appendChild(Q("span",yr(U),"cm-tab")),W.setAttribute("role","presentation"),W.setAttribute("cm-text"," "),e.col+=U}else T[0]=="\r"||T[0]==` +`?(W=g.appendChild(Q("span",T[0]=="\r"?"␍":"␤","cm-invalidchar")),W.setAttribute("cm-text",T[0]),e.col+=1):(W=e.cm.options.specialCharPlaceholder(T[0]),W.setAttribute("cm-text",T[0]),d&&v<9?g.appendChild(Q("span",[W])):g.appendChild(W),e.col+=1);e.map.push(e.pos,e.pos+1,W),e.pos++}}if(e.trailingSpace=o.charCodeAt(t.length-1)==32,i||r||n||u||l||a){var $=i||"";r&&($+=r),n&&($+=n);var G=Q("span",[g],$,l);if(a)for(var X in a)a.hasOwnProperty(X)&&X!="style"&&X!="class"&&G.setAttribute(X,a[X]);return e.content.appendChild(G)}e.content.appendChild(g)}}function Os(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;nu&&p.from<=u));T++);if(p.to>=g)return e(i,r,n,l,a,o,s);e(i,r.slice(0,p.to-u),n,l,null,o,s),l=null,r=r.slice(p.to-u),u=p.to}}}function Vl(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Ws(e,t,i){var r=e.markedSpans,n=e.text,l=0;if(!r){for(var a=1;as||fe.collapsed&&V.to==s&&V.from==s)){if(V.to!=null&&V.to!=s&&C>V.to&&(C=V.to,W=""),fe.className&&(E+=" "+fe.className),fe.css&&(T=(T?T+";":"")+fe.css),fe.startStyle&&V.from==s&&(B+=" "+fe.startStyle),fe.endStyle&&V.to==C&&(X||(X=[])).push(fe.endStyle,V.to),fe.title&&(($||($={})).title=fe.title),fe.attributes)for(var we in fe.attributes)($||($={}))[we]=fe.attributes[we];fe.collapsed&&(!U||Nn(U.marker,fe)<0)&&(U=V)}else V.from>s&&C>V.from&&(C=V.from)}if(X)for(var Ue=0;Ue=o)break;for(var st=Math.min(o,C);;){if(g){var nt=s+g.length;if(!U){var We=nt>st?g.slice(0,st-s):g;t.addToken(t,We,p?p+E:E,B,s+We.length==C?W:"",T,$)}if(nt>=st){g=g.slice(st-s),s=st;break}s=nt,B=""}g=n.slice(l,l=i[u++]),p=Jl(i[u++],t.cm.options)}}}function ea(e,t,i){this.line=t,this.rest=ks(t),this.size=this.rest?pe(f(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Bt(e,t)}function Bi(e,t,i){for(var r=[],n,l=t;l2&&l.push((s.bottom+u.top)/2-i.top)}}l.push(i.bottom-i.top)}}function oa(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var r=0;ri)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}}function $s(e,t){t=pt(t);var i=pe(t),r=e.display.externalMeasured=new ea(e.doc,t,i);r.lineN=i;var n=r.built=jl(e,r);return r.text=n.pre,De(e.display.lineMeasure,n.pre),r}function sa(e,t,i,r){return Lt(e,Lr(e,t),i,r)}function Pn(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(l=s-o,n=l-1,t>=s&&(a="right")),n!=null){if(r=e[u+2],o==s&&i==(r.insertLeft?"left":"right")&&(a=i),i=="left"&&n==0)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[(u-=3)+2],a="left";if(i=="right"&&n==s-o)for(;u=0&&(i=e[n]).left==i.right;n--);return i}function Ys(e,t,i,r){var n=fa(t.map,i,r),l=n.node,a=n.start,o=n.end,s=n.collapse,u;if(l.nodeType==3){for(var g=0;g<4;g++){for(;a&&ue(t.line.text.charAt(n.coverStart+a));)--a;for(;n.coverStart+o0&&(s=r="right");var p;e.options.lineWrapping&&(p=l.getClientRects()).length>1?u=p[r=="right"?p.length-1:0]:u=l.getBoundingClientRect()}if(d&&v<9&&!a&&(!u||!u.left&&!u.right)){var T=l.parentNode.getClientRects()[0];T?u={left:T.left,right:T.left+kr(e.display),top:T.top,bottom:T.bottom}:u=ua}for(var C=u.top-t.rect.top,E=u.bottom-t.rect.top,W=(C+E)/2,B=t.view.measure.heights,U=0;U=r.text.length?(s=r.text.length,u="before"):s<=0&&(s=0,u="after"),!o)return a(u=="before"?s-1:s,u=="before");function g(E,W,B){var U=o[W],$=U.level==1;return a(B?E-1:E,$!=B)}var p=Ne(o,s,u),T=be,C=g(s,p,u=="before");return T!=null&&(C.other=g(s,T,u!="before")),C}function va(e,t){var i=0;t=se(e.doc,t),e.options.lineWrapping||(i=kr(e.display)*t.ch);var r=j(e.doc,t.line),n=Dt(r)+Ri(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function Rn(e,t,i,r,n){var l=P(e,t,i);return l.xRel=n,r&&(l.outside=r),l}function zn(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return Rn(r.first,0,null,-1,-1);var n=er(r,i),l=r.first+r.size-1;if(n>l)return Rn(r.first+r.size-1,j(r,l).text.length,null,1,1);t<0&&(t=0);for(var a=j(r,n);;){var o=Zs(e,a,n,t,i),s=Ls(a,o.ch+(o.xRel>0||o.outside>0?1:0));if(!s)return o;var u=s.find(1);if(u.line==n)return u;a=j(r,n=u.line)}}function ya(e,t,i,r){r-=Bn(t);var n=t.text.length,l=me(function(a){return Lt(e,i,a-1).bottom<=r},n,0);return n=me(function(a){return Lt(e,i,a).top>r},l,n),{begin:l,end:n}}function ma(e,t,i,r){i||(i=Lr(e,t));var n=zi(e,t,Lt(e,i,r),"line").top;return ya(e,t,i,n)}function Un(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Zs(e,t,i,r,n){n-=Dt(t);var l=Lr(e,t),a=Bn(t),o=0,s=t.text.length,u=!0,g=ge(t,e.doc.direction);if(g){var p=(e.options.lineWrapping?Js:Qs)(e,t,i,l,g,r,n);u=p.level!=1,o=u?p.from:p.to-1,s=u?p.to:p.from-1}var T=null,C=null,E=me(function(ee){var V=Lt(e,l,ee);return V.top+=a,V.bottom+=a,Un(V,r,n,!1)?(V.top<=n&&V.left<=r&&(T=ee,C=V),!0):!1},o,s),W,B,U=!1;if(C){var $=r-C.left=X.bottom?1:0}return E=ce(t.text,E,1),Rn(i,E,B,U,r-W)}function Qs(e,t,i,r,n,l,a){var o=me(function(p){var T=n[p],C=T.level!=1;return Un(vt(e,P(i,C?T.to:T.from,C?"before":"after"),"line",t,r),l,a,!0)},0,n.length-1),s=n[o];if(o>0){var u=s.level!=1,g=vt(e,P(i,u?s.from:s.to,u?"after":"before"),"line",t,r);Un(g,l,a,!0)&&g.top>a&&(s=n[o-1])}return s}function Js(e,t,i,r,n,l,a){var o=ya(e,t,r,a),s=o.begin,u=o.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var g=null,p=null,T=0;T=u||C.to<=s)){var E=C.level!=1,W=Lt(e,r,E?Math.min(u,C.to)-1:Math.max(s,C.from)).right,B=WB)&&(g=C,p=B)}}return g||(g=n[n.length-1]),g.fromu&&(g={from:g.from,to:u,level:g.level}),g}var rr;function Tr(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(rr==null){rr=Q("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)rr.appendChild(document.createTextNode("x")),rr.appendChild(Q("br"));rr.appendChild(document.createTextNode("x"))}De(e.measure,rr);var i=rr.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),qe(e.measure),i||1}function kr(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Q("span","xxxxxxxxxx"),i=Q("pre",[t],"CodeMirror-line-like");De(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function Gn(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,l=t.gutters.firstChild,a=0;l;l=l.nextSibling,++a){var o=e.display.gutterSpecs[a].className;i[o]=l.offsetLeft+l.clientLeft+n,r[o]=l.clientWidth}return{fixedPos:Kn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Kn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function ba(e){var t=Tr(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/kr(e.display)-3);return function(n){if(Bt(e.doc,n))return 0;var l=0;if(n.widgets)for(var a=0;a0&&(u=j(e.doc,s.line).text).length==s.ch){var g=Ze(u,u.length,e.options.tabSize)-u.length;s=P(s.line,Math.max(0,Math.round((l-aa(e.display).left)/kr(e.display))-g))}return s}function nr(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom,t<0))return null;for(var i=e.display.view,r=0;rt)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)_t&&On(e.doc,t)n.viewFrom?zt(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)zt(e);else if(t<=n.viewFrom){var l=Gi(e,i,i+r,1);l?(n.view=n.view.slice(l.index),n.viewFrom=l.lineN,n.viewTo+=r):zt(e)}else if(i>=n.viewTo){var a=Gi(e,t,t,-1);a?(n.view=n.view.slice(0,a.index),n.viewTo=a.lineN):zt(e)}else{var o=Gi(e,t,t,-1),s=Gi(e,i,i+r,1);o&&s?(n.view=n.view.slice(0,o.index).concat(Bi(e,o.lineN,s.lineN)).concat(n.view.slice(s.index)),n.viewTo+=r):zt(e)}var u=n.externalMeasured;u&&(i=n.lineN&&t=r.viewTo)){var l=r.view[nr(e,t)];if(l.node!=null){var a=l.changes||(l.changes=[]);Se(a,i)==-1&&a.push(i)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gi(e,t,i,r){var n=nr(e,t),l,a=e.display.view;if(!_t||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var o=e.display.viewFrom,s=0;s0){if(n==a.length-1)return null;l=o+a[n].size-t,n++}else l=o-t;t+=l,i+=l}for(;On(e.doc,i)!=i;){if(n==(r<0?0:a.length-1))return null;i+=r*a[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function js(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Bi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Bi(e,t,r.viewFrom).concat(r.view):r.viewFromi&&(r.view=r.view.slice(0,nr(e,i)))),r.viewTo=i}function wa(e){for(var t=e.display.view,i=0,r=0;r=e.display.viewTo||s.to().line0?a:e.defaultCharWidth())+"px"}if(r.other){var o=i.appendChild(Q("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Ki(e,t){return e.top-t.top||e.left-t.left}function Vs(e,t,i){var r=e.display,n=e.doc,l=document.createDocumentFragment(),a=aa(e.display),o=a.left,s=Math.max(r.sizerWidth,tr(e)-r.sizer.offsetLeft)-a.right,u=n.direction=="ltr";function g(G,X,ee,V){X<0&&(X=0),X=Math.round(X),V=Math.round(V),l.appendChild(Q("div",null,"CodeMirror-selected","position: absolute; left: "+G+`px; + top: `+X+"px; width: "+(ee??s-G)+`px; + height: `+(V-X)+"px"))}function p(G,X,ee){var V=j(n,G),fe=V.text.length,we,Ue;function ke(We,lt){return Ui(e,P(G,We),"div",V,lt)}function st(We,lt,Xe){var He=ma(e,V,null,We),Ie=lt=="ltr"==(Xe=="after")?"left":"right",Ae=Xe=="after"?He.begin:He.end-(/\s/.test(V.text.charAt(He.end-1))?2:1);return ke(Ae,Ie)[Ie]}var nt=ge(V,n.direction);return Ce(nt,X||0,ee??fe,function(We,lt,Xe,He){var Ie=Xe=="ltr",Ae=ke(We,Ie?"left":"right"),at=ke(lt-1,Ie?"right":"left"),Pr=X==null&&We==0,Yt=ee==null&<==fe,Je=He==0,Tt=!nt||He==nt.length-1;if(at.top-Ae.top<=3){var Ge=(u?Pr:Yt)&&Je,bl=(u?Yt:Pr)&&Tt,Wt=Ge?o:(Ie?Ae:at).left,ur=bl?s:(Ie?at:Ae).right;g(Wt,Ae.top,ur-Wt,Ae.bottom)}else{var fr,et,Br,wl;Ie?(fr=u&&Pr&&Je?o:Ae.left,et=u?s:st(We,Xe,"before"),Br=u?o:st(lt,Xe,"after"),wl=u&&Yt&&Tt?s:at.right):(fr=u?st(We,Xe,"before"):o,et=!u&&Pr&&Je?s:Ae.right,Br=!u&&Yt&&Tt?o:at.left,wl=u?st(lt,Xe,"after"):s),g(fr,Ae.top,et-fr,Ae.bottom),Ae.bottom0?t.blinker=setInterval(function(){e.hasFocus()||xr(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Sa(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Zn(e))}function qn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&xr(e))},100)}function Zn(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),e.options.readOnly!="nocursor"&&(e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,xt(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),b&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Yn(e))}function xr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,Me(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function $i(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=Math.max(0,t.scroller.getBoundingClientRect().top),n=t.lineDiv.getBoundingClientRect().top,l=0,a=0;a.005||C<-.005)&&(ne.display.sizerWidth){var W=Math.ceil(g/kr(e.display));W>e.display.maxLineLength&&(e.display.maxLineLength=W,e.display.maxLine=o.line,e.display.maxLineChanged=!0)}}}Math.abs(l)>2&&(t.scroller.scrollTop+=l)}function La(e){if(e.widgets)for(var t=0;t=a&&(l=er(t,Dt(j(t,s))-e.wrapper.clientHeight),a=s)}return{from:l,to:Math.max(a,l+1)}}function eu(e,t){if(!xe(e,"scrollCursorIntoView")){var i=e.display,r=i.sizer.getBoundingClientRect(),n=null,l=i.wrapper.ownerDocument;if(t.top+r.top<0?n=!0:t.bottom+r.top>(l.defaultView.innerHeight||l.documentElement.clientHeight)&&(n=!1),n!=null&&!q){var a=Q("div","​",null,`position: absolute; top: `+(t.top-i.viewOffset-Ri(e.display))+`px; height: `+(t.bottom-t.top+St(e)+i.barHeight)+`px; - left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(n),e.display.lineSpace.removeChild(a)}}}function tu(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(i=t.sticky=="before"?P(t.line,t.ch+1,"before"):t,t=t.ch?P(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t);for(var l=0;l<5;l++){var a=!1,o=vt(e,t),s=!i||i==t?o:vt(e,i);n={left:Math.min(o.left,s.left),top:Math.min(o.top,s.top)-r,right:Math.max(o.left,s.left),bottom:Math.max(o.bottom,s.bottom)+r};var u=Zn(e,n),g=e.doc.scrollTop,p=e.doc.scrollLeft;if(u.scrollTop!=null&&(ti(e,u.scrollTop),Math.abs(e.doc.scrollTop-g)>1&&(a=!0)),u.scrollLeft!=null&&(lr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-p)>1&&(a=!0)),!a)break}return n}function ru(e,t){var i=Zn(e,t);i.scrollTop!=null&&ti(e,i.scrollTop),i.scrollLeft!=null&&lr(e,i.scrollLeft)}function Zn(e,t){var i=e.display,r=Tr(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,l=In(e),a={};t.bottom-t.top>l&&(t.bottom=t.top+l);var o=e.doc.height+Fn(i),s=t.topo-r;if(t.topn+l){var g=Math.min(t.top,(u?o:t.bottom)-l);g!=n&&(a.scrollTop=g)}var p=e.options.fixedGutter?0:i.gutters.offsetWidth,L=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-p,C=tr(e)-i.gutters.offsetWidth,E=t.right-t.left>C;return E&&(t.right=t.left+C),t.left<10?a.scrollLeft=0:t.leftC+L-3&&(a.scrollLeft=t.right+(E?0:10)-C),a}function Qn(e,t){t!=null&&(Yi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ar(e){Yi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function ei(e,t,i){(t!=null||i!=null)&&Yi(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function iu(e,t){Yi(e),e.curOp.scrollToPos=t}function Yi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=pa(e,t.from),r=pa(e,t.to);La(e,i,r,t.margin)}}function La(e,t,i,r){var n=Zn(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});ei(e,n.scrollLeft,n.scrollTop)}function ti(e,t){Math.abs(e.doc.scrollTop-t)<2||(A||jn(e,{top:t}),Ta(e,t,!0),A&&jn(e),ni(e,100))}function Ta(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),!(e.display.scroller.scrollTop==t&&!i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function lr(e,t,i,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),!((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)&&(e.doc.scrollLeft=t,_a(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function ri(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+Fn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+St(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var ar=function(e,t,i){this.cm=i;var r=this.vert=Q("div",[Q("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=Q("div",[Q("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),te(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),te(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,d&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ar.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var l=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+l)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},ar.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ar.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ar.prototype.zeroWidthHack=function(){var e=ne&&!Y?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new gt,this.disableVert=new gt},ar.prototype.enableZeroWidthBar=function(e,t,i){e.style.visibility="";function r(){var n=e.getBoundingClientRect(),l=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);l!=e?e.style.visibility="hidden":t.set(1e3,r)}t.set(1e3,r)},ar.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ii=function(){};ii.prototype.update=function(){return{bottom:0,right:0}},ii.prototype.setScrollLeft=function(){},ii.prototype.setScrollTop=function(){},ii.prototype.clear=function(){};function Mr(e,t){t||(t=ri(e));var i=e.display.barWidth,r=e.display.barHeight;ka(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&$i(e),ka(e,ri(e)),i=e.display.barWidth,r=e.display.barHeight}function ka(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var xa={native:ar,null:ii};function Aa(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Me(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new xa[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),te(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?lr(e,t):ti(e,t)},e),e.display.scrollbars.addClass&&xt(e.display.wrapper,e.display.scrollbars.addClass)}var nu=0;function or(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++nu,markArrays:null},Fs(e.curOp)}function sr(e){var t=e.curOp;t&&Hs(t,function(i){for(var r=0;r=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new qi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function ou(e){e.updatedDisplay=e.mustUpdate&&Jn(e.cm,e.update)}function su(e){var t=e.cm,i=t.display;e.updatedDisplay&&$i(t),e.barMeasure=ri(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=oa(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+St(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-tr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function uu(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var i=+new Date+e.options.workTime,r=Yr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(l){if(r.line>=e.display.viewFrom){var a=l.styles,o=l.text.length>e.options.maxHighlightLength?jt(t.mode,r.state):null,s=Fl(e,l,r,!0);o&&(r.state=o),l.styles=s.styles;var u=l.styleClasses,g=s.classes;g?l.styleClasses=g:u&&(l.styleClasses=null);for(var p=!a||a.length!=l.styles.length||u!=g&&(!u||!g||u.bgClass!=g.bgClass||u.textClass!=g.textClass),L=0;!p&&Li)return ni(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&ot(e,function(){for(var l=0;l=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&ba(e)==0)return!1;Da(e)&&(zt(e),t.dims=Un(e));var n=r.first+r.size,l=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFroma&&i.viewTo-a<20&&(a=Math.min(n,i.viewTo)),_t&&(l=Nn(e.doc,l),a=Zl(e.doc,a));var o=l!=i.viewFrom||a!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;js(e,l,a),i.viewOffset=Dt(j(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var s=ba(e);if(!o&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var u=du(e);return s>4&&(i.lineDiv.style.display="none"),pu(e,i.updateLineNumbers,t.dims),s>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,gu(u),qe(i.cursorDiv),qe(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,o&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,ni(e,400)),i.updateLineNumbers=null,!0}function Ma(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==tr(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+Fn(e.display)-In(e),i.top)}),t.visible=Xi(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xi(e.display,e.doc,i));if(!Jn(e,t))break;$i(e);var n=ri(e);Vr(e),Mr(e,n),el(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function jn(e,t){var i=new qi(e,t);if(Jn(e,i)){$i(e),Ma(e,i);var r=ri(e);Vr(e),Mr(e,r),el(e,r),i.finish()}}function pu(e,t,i){var r=e.display,n=e.options.lineNumbers,l=r.lineDiv,a=l.firstChild;function o(E){var W=E.nextSibling;return m&&ne&&e.display.currentWheelTarget==E?E.style.display="none":E.parentNode.removeChild(E),W}for(var s=r.view,u=r.viewFrom,g=0;g-1&&(C=!1),ea(e,p,u,i)),C&&(qe(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(Tn(e.options,u)))),a=p.node.nextSibling}u+=p.size}for(;a;)a=o(a)}function Vn(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Be(e,"gutterChanged",e)}function el(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+St(e)+"px"}function _a(e){var t=e.display,i=t.view;if(!(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))){for(var r=Gn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,l=r+"px",a=0;a=105&&(n.wrapper.style.clipPath="inset(0px)"),n.wrapper.setAttribute("translate","no"),d&&v<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!m&&!(A&&ie)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=tl(r.gutters,r.lineNumbers),Na(n),i.init(n)}var Zi=0,Ot=null;d?Ot=-.53:A?Ot=15:M?Ot=-.7:K&&(Ot=-1/3);function Oa(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function yu(e){var t=Oa(e);return t.x*=Ot,t.y*=Ot,t}function Ea(e,t){M&&D==102&&(e.display.chromeScrollHack==null?e.display.sizer.style.pointerEvents="none":clearTimeout(e.display.chromeScrollHack),e.display.chromeScrollHack=setTimeout(function(){e.display.chromeScrollHack=null,e.display.sizer.style.pointerEvents=""},100));var i=Oa(t),r=i.x,n=i.y,l=Ot;t.deltaMode===0&&(r=t.deltaX,n=t.deltaY,l=1);var a=e.display,o=a.scroller,s=o.scrollWidth>o.clientWidth,u=o.scrollHeight>o.clientHeight;if(r&&s||n&&u){if(n&&ne&&m){e:for(var g=t.target,p=a.view;g!=o;g=g.parentNode)for(var L=0;L=0&&oe(e,r.to())<=0)return i}return-1};var de=function(e,t){this.anchor=e,this.head=t};de.prototype.from=function(){return Oi(this.anchor,this.head)},de.prototype.to=function(){return Ni(this.anchor,this.head)},de.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function yt(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(L,C){return oe(L.from(),C.from())}),i=Se(t,n);for(var l=1;l0:s>=0){var u=Oi(o.from(),a.from()),g=Ni(o.to(),a.to()),p=o.empty()?a.from()==a.head:o.from()==o.head;l<=i&&--i,t.splice(--l,2,new de(p?g:u,p?u:g))}}return new ft(t,i)}function Ut(e,t){return new ft([new de(e,t||e)],0)}function Gt(e){return e.text?P(e.from.line+e.text.length-1,f(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Wa(e,t){if(oe(e,t.from)<0)return e;if(oe(e,t.to)<=0)return Gt(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Gt(t).ch-t.to.ch),P(i,r)}function rl(e,t){for(var i=[],r=0;r1&&e.remove(o.line+1,E-1),e.insert(o.line+1,z)}Be(e,"change",e,t)}function Kt(e,t,i){function r(n,l,a){if(n.linked)for(var o=0;o1&&!e.done[e.done.length-2].ranges)return e.done.pop(),f(e.done)}function Ra(e,t,i,r){var n=e.history;n.undone.length=0;var l=+new Date,a,o;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>l-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(a=wu(n,n.lastOp==r)))o=f(a.changes),oe(t.from,t.to)==0&&oe(t.from,o.to)==0?o.to=Gt(t):a.changes.push(ll(e,t));else{var s=f(n.done);for((!s||!s.ranges)&&Ji(e.sel,n.done),a={changes:[ll(e,t)],generation:n.generation},n.done.push(a);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=l,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,o||Te(e,"historyAdded")}function Cu(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Su(e,t,i,r){var n=e.history,l=r&&r.origin;i==n.lastSelOp||l&&n.lastSelOrigin==l&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==l||Cu(e,l,f(n.done),t))?n.done[n.done.length-1]=t:Ji(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=l,n.lastSelOp=i,r&&r.clearRedo!==!1&&Ba(n.undone)}function Ji(e,t){var i=f(t);i&&i.ranges&&i.equals(e)||t.push(e)}function za(e,t,i,r){var n=t["spans_"+e.id],l=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(a){a.markedSpans&&((n||(n=t["spans_"+e.id]={}))[l]=a.markedSpans),++l})}function Lu(e){if(!e)return null;for(var t,i=0;i-1&&(f(o)[p]=u[p],delete u[p])}}return r}function al(e,t,i,r){if(r){var n=e.anchor;if(i){var l=oe(t,n)<0;l!=oe(i,n)<0?(n=t,t=i):l!=oe(t,i)<0&&(t=i)}return new de(n,t)}else return new de(i||t,t)}function ji(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Qe(e,new ft([al(e.sel.primary(),t,i,n)],0),r)}function Ga(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),l=0;l=t.ch:o.to>t.ch))){if(n&&(Te(s,"beforeCursorEnter"),s.explicitlyCleared))if(l.markedSpans){--a;continue}else break;if(!s.atomic)continue;if(i){var p=s.find(r<0?1:-1),L=void 0;if((r<0?g:u)&&(p=Za(e,p,-r,p&&p.line==t.line?l:null)),p&&p.line==t.line&&(L=oe(p,i))&&(r<0?L<0:L>0))return Dr(e,p,t,r,n)}var C=s.find(r<0?-1:1);return(r<0?u:g)&&(C=Za(e,C,r,C.line==t.line?l:null)),C?Dr(e,C,t,r,n):null}}return t}function en(e,t,i,r,n){var l=r||1,a=Dr(e,t,i,l,n)||!n&&Dr(e,t,i,l,!0)||Dr(e,t,i,-l,n)||!n&&Dr(e,t,i,-l,!0);return a||(e.cantEdit=!0,P(e.first,0))}function Za(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?se(e,P(t.line-1)):null:i>0&&t.ch==(r||j(e,t.line)).text.length?t.line=0;--n)ja(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else ja(e,t)}}function ja(e,t){if(!(t.text.length==1&&t.text[0]==""&&oe(t.from,t.to)==0)){var i=rl(e,t);Ra(e,t,i,e.cm?e.cm.curOp.id:NaN),oi(e,t,i,_n(e,t));var r=[];Kt(e,function(n,l){!l&&Se(r,n.history)==-1&&(ro(n.history,t),r.push(n.history)),oi(n,t,null,_n(n,t))})}}function tn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(!(r&&!i)){for(var n=e.history,l,a=e.sel,o=t=="undo"?n.done:n.undone,s=t=="undo"?n.undone:n.done,u=0;u=0;--C){var E=L(C);if(E)return E.v}}}}function Va(e,t){if(t!=0&&(e.first+=t,e.sel=new ft(y(e.sel.ranges,function(n){return new de(P(n.anchor.line+t,n.anchor.ch),P(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm)){rt(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;re.lastLine())){if(t.from.linel&&(t={from:t.from,to:P(l,j(e,l).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Vt(e,t.from,t.to),i||(i=rl(e,t)),e.cm?xu(e.cm,t,r):nl(e,t,r),Vi(e,i,ht),e.cantEdit&&en(e,P(e.firstLine(),0))&&(e.cantEdit=!1)}}function xu(e,t,i){var r=e.doc,n=e.display,l=t.from,a=t.to,o=!1,s=l.line;e.options.lineWrapping||(s=pe(pt(j(r,l.line))),r.iter(s,a.line+1,function(C){if(C==n.maxLine)return o=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Pt(e),nl(r,t,i,ma(e)),e.options.lineWrapping||(r.iter(s,l.line+t.text.length,function(C){var E=Pi(C);E>n.maxLineLength&&(n.maxLine=C,n.maxLineLength=E,n.maxLineChanged=!0,o=!1)}),o&&(e.curOp.updateMaxLine=!0)),ps(r,l.line),ni(e,400);var u=t.text.length-(a.line-l.line)-1;t.full?rt(e):l.line==a.line&&t.text.length==1&&!Ia(e.doc,t)?Rt(e,l.line,"text"):rt(e,l.line,a.line+1,u);var g=$e(e,"changes"),p=$e(e,"change");if(p||g){var L={from:l,to:a,text:t.text,removed:t.removed,origin:t.origin};p&&Be(e,"change",e,L),g&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(L)}e.display.selForContextMenu=null}function Or(e,t,i,r,n){var l;r||(r=i),oe(r,i)<0&&(l=[r,i],i=l[0],r=l[1]),typeof t=="string"&&(t=e.splitLines(t)),Nr(e,{from:i,to:r,text:t,origin:n})}function eo(e,t,i,r){i1||!(this.children[0]instanceof ui))){var o=[];this.collapse(o),this.children=[new ui(o)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=n.lines.length%25+25,o=a;o10);e.parent.maybeSpill()}},iterN:function(e,t,i){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=g,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&rt(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ya(e.doc)),e&&Be(e,"markerCleared",e,this,r,n),t&&sr(e),this.parent&&this.parent.clear()}},$t.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n0||a==0&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=kt("span",[l.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(ql(e,t.line,t,i,l)||t.line!=i.line&&ql(e,i.line,t,i,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");ys()}l.addToHistory&&Ra(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var o=t.line,s=e.cm,u;if(e.iter(o,i.line+1,function(p){s&&l.collapsed&&!s.options.lineWrapping&&pt(p)==s.display.maxLine&&(u=!0),l.collapsed&&o!=t.line&&wt(p,0),bs(p,new Wi(l,o==t.line?t.ch:null,o==i.line?i.ch:null),e.cm&&e.cm.curOp),++o}),l.collapsed&&e.iter(t.line,i.line+1,function(p){Bt(e,p)&&wt(p,0)}),l.clearOnEnter&&te(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(vs(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++no,l.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),l.collapsed)rt(s,t.line,i.line+1);else if(l.className||l.startStyle||l.endStyle||l.css||l.attributes||l.title)for(var g=t.line;g<=i.line;g++)Rt(s,g,"text");l.atomic&&Ya(s.doc),Be(s,"markerAdded",s,l)}return l}var ci=function(e,t){this.markers=e,this.primary=t;for(var i=0;i=0;s--)Nr(this,r[s]);o?$a(this,o):this.cm&&Ar(this.cm)}),undo:ze(function(){tn(this,"undo")}),redo:ze(function(){tn(this,"redo")}),undoSelection:ze(function(){tn(this,"undo",!0)}),redoSelection:ze(function(){tn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=se(this,e),t=se(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(l){var a=l.markedSpans;if(a)for(var o=0;o=s.to||s.from==null&&n!=e.line||s.from!=null&&n==t.line&&s.from>=t.ch)&&(!i||i(s.marker))&&r.push(s.marker.parent||s.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;re)return t=e,!0;e-=l,++i}),se(this,P(i,t))},indexFromPos:function(e){e=se(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var g=e.dataTransfer.getData("Text");if(g){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),Vi(t.doc,Ut(i,i)),p)for(var L=0;L=0;o--)Or(e.doc,"",r[o].from,r[o].to,"+delete");Ar(e)})}function sl(e,t,i){var r=ce(e.text,t+i,i);return r<0||r>e.text.length?null:r}function ul(e,t,i){var r=sl(e,t.ch,i);return r==null?null:new P(t.line,r,i<0?"after":"before")}function fl(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var l=ge(i,t.doc.direction);if(l){var a=n<0?f(l):l[0],o=n<0==(a.level==1),s=o?"after":"before",u;if(a.level>0||t.doc.direction=="rtl"){var g=Lr(t,i);u=n<0?i.text.length-1:0;var p=Lt(t,g,u).top;u=me(function(L){return Lt(t,g,L).top==p},n<0==(a.level==1)?a.from:a.to-1,u),s=="before"&&(u=sl(i,u,1))}else u=n<0?a.to:a.from;return new P(r,u,s)}}return new P(r,n<0?i.text.length:0,n<0?"before":"after")}function Ru(e,t,i,r){var n=ge(t,e.doc.direction);if(!n)return ul(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var l=Ne(n,i.ch,i.sticky),a=n[l];if(e.doc.direction=="ltr"&&a.level%2==0&&(r>0?a.to>i.ch:a.from=a.from&&L>=g.begin)){var C=p?"before":"after";return new P(i.line,L,C)}}var E=function(z,$,U){for(var X=function(we,Ue){return Ue?new P(i.line,o(we,1),"before"):new P(i.line,we,"after")};z>=0&&z0==(ee.level!=1),fe=V?U.begin:o(U.end,-1);if(ee.from<=fe&&fe0?g.end:o(g.begin,-1);return B!=null&&!(r>0&&B==t.text.length)&&(W=E(r>0?0:n.length-1,r,u(B)),W)?W:null}var pi={selectAll:Qa,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ht)},killLine:function(e){return Fr(e,function(t){if(t.empty()){var i=j(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line0)n=new P(n.line,n.ch+1),e.replaceRange(l.charAt(n.ch-1)+l.charAt(n.ch-2),P(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var a=j(e.doc,n.line-1).text;a&&(n=new P(n.line,1),e.replaceRange(l.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),P(n.line-1,a.length-1),n,"+transpose"))}}i.push(new de(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return ot(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;re&&oe(t,this.pos)==0&&i==this.button};var yi,mi;function Yu(e,t){var i=+new Date;return mi&&mi.compare(i,e,t)?(yi=mi=null,"triple"):yi&&yi.compare(i,e,t)?(mi=new cl(i,e,t),yi=null,"double"):(yi=new cl(i,e,t),mi=null,"single")}function Co(e){var t=this,i=t.display;if(!(xe(t,e)||i.activeTouch&&i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=e.shiftKey,Nt(i,e)){m||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(!dl(t,e)){var r=ir(t,e),n=Nl(e),l=r?Yu(r,n):"single";At(t).focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),!(r&&qu(t,n,r,l,e))&&(n==1?r?Qu(t,r,l,e):pn(e)==i.scroller&&Oe(e):n==2?(r&&ji(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(Ie?t.display.input.onContextMenu(e):Yn(t)))}}}function qu(e,t,i,r,n){var l="Click";return r=="double"?l="Double"+l:r=="triple"&&(l="Triple"+l),l=(t==1?"Left":t==2?"Middle":"Right")+l,vi(e,ho(l,n),n,function(a){if(typeof a=="string"&&(a=pi[a]),!a)return!1;var o=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),o=a(e,i)!=Ht}finally{e.state.suppressEdits=!1}return o})}function Zu(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var l=he?i.shiftKey&&i.metaKey:i.altKey;n.unit=l?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=ne?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(ne?i.altKey:i.ctrlKey)),n}function Qu(e,t,i,r){d?setTimeout(pr(Ca,e),0):e.curOp.focus=tt(It(e));var n=Zu(e,i,r),l=e.doc.sel,a;e.options.dragDrop&&ns&&!e.isReadOnly()&&i=="single"&&(a=l.contains(t))>-1&&(oe((a=l.ranges[a]).from(),t)<0||t.xRel>0)&&(oe(a.to(),t)>0||t.xRel<0)?Ju(e,r,t,n):ju(e,r,t,n)}function Ju(e,t,i,r){var n=e.display,l=!1,a=Re(e,function(u){m&&(n.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:Yn(e)),je(n.wrapper.ownerDocument,"mouseup",a),je(n.wrapper.ownerDocument,"mousemove",o),je(n.scroller,"dragstart",s),je(n.scroller,"drop",a),l||(Oe(u),r.addNew||ji(e.doc,i,null,null,r.extend),m&&!K||d&&v==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),o=function(u){l=l||Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)>=10},s=function(){return l=!0};m&&(n.scroller.draggable=!0),e.state.draggingText=a,a.copy=!r.moveOnDrag,te(n.wrapper.ownerDocument,"mouseup",a),te(n.wrapper.ownerDocument,"mousemove",o),te(n.scroller,"dragstart",s),te(n.scroller,"drop",a),e.state.delayingBlurEvent=!0,setTimeout(function(){return n.input.focus()},20),n.scroller.dragDrop&&n.scroller.dragDrop()}function So(e,t,i){if(i=="char")return new de(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new de(P(t.line,0),se(e.doc,P(t.line+1,0)));var r=i(e,t);return new de(r.from,r.to)}function ju(e,t,i,r){d&&Yn(e);var n=e.display,l=e.doc;Oe(t);var a,o,s=l.sel,u=s.ranges;if(r.addNew&&!r.extend?(o=l.sel.contains(i),o>-1?a=u[o]:a=new de(i,i)):(a=l.sel.primary(),o=l.sel.primIndex),r.unit=="rectangle")r.addNew||(a=new de(i,i)),i=ir(e,t,!0,!0),o=-1;else{var g=So(e,i,r.unit);r.extend?a=al(a,g.anchor,g.head,r.extend):a=g}r.addNew?o==-1?(o=u.length,Qe(l,yt(e,u.concat([a]),o),{scroll:!1,origin:"*mouse"})):u.length>1&&u[o].empty()&&r.unit=="char"&&!r.extend?(Qe(l,yt(e,u.slice(0,o).concat(u.slice(o+1)),0),{scroll:!1,origin:"*mouse"}),s=l.sel):ol(l,o,a,Ur):(o=0,Qe(l,new ft([a],0),Ur),s=l.sel);var p=i;function L(U){if(oe(p,U)!=0)if(p=U,r.unit=="rectangle"){for(var X=[],ee=e.options.tabSize,V=Ze(j(l,i.line).text,i.ch,ee),fe=Ze(j(l,U.line).text,U.ch,ee),we=Math.min(V,fe),Ue=Math.max(V,fe),ke=Math.min(i.line,U.line),st=Math.min(e.lastLine(),Math.max(i.line,U.line));ke<=st;ke++){var nt=j(l,ke).text,We=Gr(nt,we,ee);we==Ue?X.push(new de(P(ke,We),P(ke,We))):nt.length>We&&X.push(new de(P(ke,We),P(ke,Gr(nt,Ue,ee))))}X.length||X.push(new de(i,i)),Qe(l,yt(e,s.ranges.slice(0,o).concat(X),o),{origin:"*mouse",scroll:!1}),e.scrollIntoView(U)}else{var lt=a,Xe=So(e,U,r.unit),He=lt.anchor,Fe;oe(Xe.anchor,He)>0?(Fe=Xe.head,He=Oi(lt.from(),Xe.anchor)):(Fe=Xe.anchor,He=Ni(lt.to(),Xe.head));var Ae=s.ranges.slice(0);Ae[o]=Vu(e,new de(se(l,He),Fe)),Qe(l,yt(e,Ae,o),Ur)}}var C=n.wrapper.getBoundingClientRect(),E=0;function W(U){var X=++E,ee=ir(e,U,!0,r.unit=="rectangle");if(ee)if(oe(ee,p)!=0){e.curOp.focus=tt(It(e)),L(ee);var V=Xi(n,l);(ee.line>=V.to||ee.lineC.bottom?20:0;fe&&setTimeout(Re(e,function(){E==X&&(n.scroller.scrollTop+=fe,W(U))}),50)}}function B(U){e.state.selectingText=!1,E=1/0,U&&(Oe(U),n.input.focus()),je(n.wrapper.ownerDocument,"mousemove",z),je(n.wrapper.ownerDocument,"mouseup",$),l.history.lastSelOrigin=null}var z=Re(e,function(U){U.buttons===0||!Nl(U)?B(U):W(U)}),$=Re(e,B);e.state.selectingText=$,te(n.wrapper.ownerDocument,"mousemove",z),te(n.wrapper.ownerDocument,"mouseup",$)}function Vu(e,t){var i=t.anchor,r=t.head,n=j(e.doc,i.line);if(oe(i,r)==0&&i.sticky==r.sticky)return t;var l=ge(n);if(!l)return t;var a=Ne(l,i.ch,i.sticky),o=l[a];if(o.from!=i.ch&&o.to!=i.ch)return t;var s=a+(o.from==i.ch==(o.level!=1)?0:1);if(s==0||s==l.length)return t;var u;if(r.line!=i.line)u=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var g=Ne(l,r.ch,r.sticky),p=g-a||(r.ch-i.ch)*(o.level==1?-1:1);g==s-1||g==s?u=p<0:u=p>0}var L=l[s+(u?-1:0)],C=u==(L.level==1),E=C?L.from:L.to,W=C?"after":"before";return i.ch==E&&i.sticky==W?t:new de(new P(i.line,E,W),r)}function Lo(e,t,i,r){var n,l;if(t.touches)n=t.touches[0].clientX,l=t.touches[0].clientY;else try{n=t.clientX,l=t.clientY}catch{return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Oe(t);var a=e.display,o=a.lineDiv.getBoundingClientRect();if(l>o.bottom||!$e(e,i))return gn(t);l-=o.top-a.viewOffset;for(var s=0;s=n){var g=er(e.doc,l),p=e.display.gutterSpecs[s];return Te(e,i,e,g,p.className,t),gn(t)}}}function dl(e,t){return Lo(e,t,"gutterClick",!0)}function To(e,t){Nt(e.display,t)||ef(e,t)||xe(e,t,"contextmenu")||Ie||e.display.input.onContextMenu(t)}function ef(e,t){return $e(e,"gutterContextMenu")?Lo(e,t,"gutterContextMenu",!1):!1}function ko(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),jr(e)}var Ir={toString:function(){return"CodeMirror.Init"}},xo={},an={};function tf(e){var t=e.optionHandlers;function i(r,n,l,a){e.defaults[r]=n,l&&(t[r]=a?function(o,s,u){u!=Ir&&l(o,s,u)}:l)}e.defineOption=i,e.Init=Ir,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,il(r)},!0),i("indentUnit",2,il,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){ai(r),jr(r),rt(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!!n){var l=[],a=r.doc.first;r.doc.iter(function(s){for(var u=0;;){var g=s.text.indexOf(n,u);if(g==-1)break;u=g+n.length,l.push(P(a,g))}a++});for(var o=l.length-1;o>=0;o--)Or(r.doc,n,l[o],P(l[o].line,l[o].ch+n.length))}}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,function(r,n,l){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),l!=Ir&&r.refresh()}),i("specialCharPlaceholder",Ds,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",ie?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!re),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){ko(r),li(r)},!0),i("keyMap","default",function(r,n,l){var a=nn(n),o=l!=Ir&&nn(l);o&&o.detach&&o.detach(r,a),a.attach&&a.attach(r,o||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,nf,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=tl(n,r.options.lineNumbers),li(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Gn(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Mr(r)},!0),i("scrollbarStyle","native",function(r){Aa(r),Mr(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=tl(r.options.gutters,n),li(r)},!0),i("firstLineNumber",1,li,!0),i("lineNumberFormatter",function(r){return r},li,!0),i("showCursorWhenSelecting",!1,Vr,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(xr(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,rf),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,Vr,!0),i("singleCursorHeightPerLine",!0,Vr,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,ai,!0),i("addModeClass",!1,ai,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,ai,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function rf(e,t,i){var r=i&&i!=Ir;if(!t!=!r){var n=e.display.dragFunctions,l=t?te:je;l(e.display.scroller,"dragstart",n.start),l(e.display.scroller,"dragenter",n.enter),l(e.display.scroller,"dragover",n.over),l(e.display.scroller,"dragleave",n.leave),l(e.display.scroller,"drop",n.drop)}}function nf(e){e.options.lineWrapping?(xt(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Me(e.display.wrapper,"CodeMirror-wrap"),En(e)),Kn(e),rt(e),jr(e),setTimeout(function(){return Mr(e)},100)}function Le(e,t){var i=this;if(!(this instanceof Le))return new Le(e,t);this.options=t=t?dt(t):{},dt(xo,t,!1);var r=t.value;typeof r=="string"?r=new it(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Le.inputStyles[t.inputStyle](this),l=this.display=new vu(e,r,n,t);l.wrapper.CodeMirror=this,ko(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Aa(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new gt,keySeq:null,specialChars:null},t.autofocus&&!ie&&l.input.focus(),d&&v<11&&setTimeout(function(){return i.display.input.reset(!0)},20),lf(this),Fu(),or(this),this.curOp.forceUpdate=!0,Ha(this,r),t.autofocus&&!ie||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&qn(i)},20):xr(this);for(var a in an)an.hasOwnProperty(a)&&an[a](this,t[a],Ir);Da(this),t.finishInit&&t.finishInit(this);for(var o=0;o20*20}te(t.scroller,"touchstart",function(s){if(!xe(e,s)&&!l(s)&&!dl(e,s)){t.input.ensurePolled(),clearTimeout(i);var u=+new Date;t.activeTouch={start:u,moved:!1,prev:u-r.end<=300?r:null},s.touches.length==1&&(t.activeTouch.left=s.touches[0].pageX,t.activeTouch.top=s.touches[0].pageY)}}),te(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),te(t.scroller,"touchend",function(s){var u=t.activeTouch;if(u&&!Nt(t,s)&&u.left!=null&&!u.moved&&new Date-u.start<300){var g=e.coordsChar(t.activeTouch,"page"),p;!u.prev||a(u,u.prev)?p=new de(g,g):!u.prev.prev||a(u,u.prev.prev)?p=e.findWordAt(g):p=new de(P(g.line,0),se(e.doc,P(g.line+1,0))),e.setSelection(p.anchor,p.head),e.focus(),Oe(s)}n()}),te(t.scroller,"touchcancel",n),te(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ti(e,t.scroller.scrollTop),lr(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))}),te(t.scroller,"mousewheel",function(s){return Ea(e,s)}),te(t.scroller,"DOMMouseScroll",function(s){return Ea(e,s)}),te(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(s){xe(e,s)||$r(s)},over:function(s){xe(e,s)||(Wu(e,s),$r(s))},start:function(s){return Eu(e,s)},drop:Re(e,Ou),leave:function(s){xe(e,s)||oo(e)}};var o=t.input.getField();te(o,"keyup",function(s){return bo.call(e,s)}),te(o,"keydown",Re(e,mo)),te(o,"keypress",Re(e,wo)),te(o,"focus",function(s){return qn(e,s)}),te(o,"blur",function(s){return xr(e,s)})}var gl=[];Le.defineInitHook=function(e){return gl.push(e)};function bi(e,t,i,r){var n=e.doc,l;i==null&&(i="add"),i=="smart"&&(n.mode.indent?l=Yr(e,t).state:i="prev");var a=e.options.tabSize,o=j(n,t),s=Ze(o.text,null,a);o.stateAfter&&(o.stateAfter=null);var u=o.text.match(/^\s*/)[0],g;if(!r&&!/\S/.test(o.text))g=0,i="not";else if(i=="smart"&&(g=n.mode.indent(l,o.text.slice(u.length),o.text),g==Ht||g>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?g=Ze(j(n,t-1).text,null,a):g=0:i=="add"?g=s+e.options.indentUnit:i=="subtract"?g=s-e.options.indentUnit:typeof i=="number"&&(g=s+i),g=Math.max(0,g);var p="",L=0;if(e.options.indentWithTabs)for(var C=Math.floor(g/a);C;--C)L+=a,p+=" ";if(La,s=mn(t),u=null;if(o&&r.ranges.length>1)if(mt&&mt.text.join(` -`)==t){if(r.ranges.length%mt.text.length==0){u=[];for(var g=0;g=0;L--){var C=r.ranges[L],E=C.from(),W=C.to();C.empty()&&(i&&i>0?E=P(E.line,E.ch-i):e.state.overwrite&&!o?W=P(W.line,Math.min(j(l,W.line).text.length,W.ch+f(s).length)):o&&mt&&mt.lineWise&&mt.text.join(` + left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(n),e.display.lineSpace.removeChild(a)}}}function tu(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(i=t.sticky=="before"?P(t.line,t.ch+1,"before"):t,t=t.ch?P(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t);for(var l=0;l<5;l++){var a=!1,o=vt(e,t),s=!i||i==t?o:vt(e,i);n={left:Math.min(o.left,s.left),top:Math.min(o.top,s.top)-r,right:Math.max(o.left,s.left),bottom:Math.max(o.bottom,s.bottom)+r};var u=Qn(e,n),g=e.doc.scrollTop,p=e.doc.scrollLeft;if(u.scrollTop!=null&&(ti(e,u.scrollTop),Math.abs(e.doc.scrollTop-g)>1&&(a=!0)),u.scrollLeft!=null&&(lr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-p)>1&&(a=!0)),!a)break}return n}function ru(e,t){var i=Qn(e,t);i.scrollTop!=null&&ti(e,i.scrollTop),i.scrollLeft!=null&&lr(e,i.scrollLeft)}function Qn(e,t){var i=e.display,r=Tr(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,l=Hn(e),a={};t.bottom-t.top>l&&(t.bottom=t.top+l);var o=e.doc.height+Fn(i),s=t.topo-r;if(t.topn+l){var g=Math.min(t.top,(u?o:t.bottom)-l);g!=n&&(a.scrollTop=g)}var p=e.options.fixedGutter?0:i.gutters.offsetWidth,T=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-p,C=tr(e)-i.gutters.offsetWidth,E=t.right-t.left>C;return E&&(t.right=t.left+C),t.left<10?a.scrollLeft=0:t.leftC+T-3&&(a.scrollLeft=t.right+(E?0:10)-C),a}function Jn(e,t){t!=null&&(Yi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ar(e){Yi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function ei(e,t,i){(t!=null||i!=null)&&Yi(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function iu(e,t){Yi(e),e.curOp.scrollToPos=t}function Yi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=va(e,t.from),r=va(e,t.to);Ta(e,i,r,t.margin)}}function Ta(e,t,i,r){var n=Qn(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});ei(e,n.scrollLeft,n.scrollTop)}function ti(e,t){Math.abs(e.doc.scrollTop-t)<2||(A||Vn(e,{top:t}),ka(e,t,!0),A&&Vn(e),ni(e,100))}function ka(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),!(e.display.scroller.scrollTop==t&&!i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function lr(e,t,i,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),!((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)&&(e.doc.scrollLeft=t,Da(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function ri(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+Fn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+St(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var ar=function(e,t,i){this.cm=i;var r=this.vert=Q("div",[Q("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=Q("div",[Q("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),te(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),te(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,d&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ar.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var l=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+l)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},ar.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ar.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ar.prototype.zeroWidthHack=function(){var e=ne&&!Y?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new gt,this.disableVert=new gt},ar.prototype.enableZeroWidthBar=function(e,t,i){e.style.visibility="";function r(){var n=e.getBoundingClientRect(),l=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);l!=e?e.style.visibility="hidden":t.set(1e3,r)}t.set(1e3,r)},ar.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ii=function(){};ii.prototype.update=function(){return{bottom:0,right:0}},ii.prototype.setScrollLeft=function(){},ii.prototype.setScrollTop=function(){},ii.prototype.clear=function(){};function Mr(e,t){t||(t=ri(e));var i=e.display.barWidth,r=e.display.barHeight;xa(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&$i(e),xa(e,ri(e)),i=e.display.barWidth,r=e.display.barHeight}function xa(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var Aa={native:ar,null:ii};function Ma(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Me(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Aa[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),te(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?lr(e,t):ti(e,t)},e),e.display.scrollbars.addClass&&xt(e.display.wrapper,e.display.scrollbars.addClass)}var nu=0;function or(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++nu,markArrays:null},Is(e.curOp)}function sr(e){var t=e.curOp;t&&Hs(t,function(i){for(var r=0;r=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new qi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function ou(e){e.updatedDisplay=e.mustUpdate&&jn(e.cm,e.update)}function su(e){var t=e.cm,i=t.display;e.updatedDisplay&&$i(t),e.barMeasure=ri(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=sa(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+St(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-tr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function uu(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var i=+new Date+e.options.workTime,r=Yr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(l){if(r.line>=e.display.viewFrom){var a=l.styles,o=l.text.length>e.options.maxHighlightLength?jt(t.mode,r.state):null,s=Fl(e,l,r,!0);o&&(r.state=o),l.styles=s.styles;var u=l.styleClasses,g=s.classes;g?l.styleClasses=g:u&&(l.styleClasses=null);for(var p=!a||a.length!=l.styles.length||u!=g&&(!u||!g||u.bgClass!=g.bgClass||u.textClass!=g.textClass),T=0;!p&&Ti)return ni(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&ot(e,function(){for(var l=0;l=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&wa(e)==0)return!1;Na(e)&&(zt(e),t.dims=Gn(e));var n=r.first+r.size,l=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFroma&&i.viewTo-a<20&&(a=Math.min(n,i.viewTo)),_t&&(l=On(e.doc,l),a=Ql(e.doc,a));var o=l!=i.viewFrom||a!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;js(e,l,a),i.viewOffset=Dt(j(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var s=wa(e);if(!o&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var u=du(e);return s>4&&(i.lineDiv.style.display="none"),pu(e,i.updateLineNumbers,t.dims),s>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,gu(u),qe(i.cursorDiv),qe(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,o&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,ni(e,400)),i.updateLineNumbers=null,!0}function _a(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==tr(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+Fn(e.display)-Hn(e),i.top)}),t.visible=Xi(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xi(e.display,e.doc,i));if(!jn(e,t))break;$i(e);var n=ri(e);Vr(e),Mr(e,n),tl(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Vn(e,t){var i=new qi(e,t);if(jn(e,i)){$i(e),_a(e,i);var r=ri(e);Vr(e),Mr(e,r),tl(e,r),i.finish()}}function pu(e,t,i){var r=e.display,n=e.options.lineNumbers,l=r.lineDiv,a=l.firstChild;function o(E){var W=E.nextSibling;return b&&ne&&e.display.currentWheelTarget==E?E.style.display="none":E.parentNode.removeChild(E),W}for(var s=r.view,u=r.viewFrom,g=0;g-1&&(C=!1),ta(e,p,u,i)),C&&(qe(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(kn(e.options,u)))),a=p.node.nextSibling}u+=p.size}for(;a;)a=o(a)}function el(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Be(e,"gutterChanged",e)}function tl(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+St(e)+"px"}function Da(e){var t=e.display,i=t.view;if(!(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))){for(var r=Kn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,l=r+"px",a=0;a=105&&(n.wrapper.style.clipPath="inset(0px)"),n.wrapper.setAttribute("translate","no"),d&&v<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!b&&!(A&&ie)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=rl(r.gutters,r.lineNumbers),Oa(n),i.init(n)}var Zi=0,Ot=null;d?Ot=-.53:A?Ot=15:k?Ot=-.7:K&&(Ot=-1/3);function Ea(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function yu(e){var t=Ea(e);return t.x*=Ot,t.y*=Ot,t}function Wa(e,t){k&&D==102&&(e.display.chromeScrollHack==null?e.display.sizer.style.pointerEvents="none":clearTimeout(e.display.chromeScrollHack),e.display.chromeScrollHack=setTimeout(function(){e.display.chromeScrollHack=null,e.display.sizer.style.pointerEvents=""},100));var i=Ea(t),r=i.x,n=i.y,l=Ot;t.deltaMode===0&&(r=t.deltaX,n=t.deltaY,l=1);var a=e.display,o=a.scroller,s=o.scrollWidth>o.clientWidth,u=o.scrollHeight>o.clientHeight;if(r&&s||n&&u){if(n&&ne&&b){e:for(var g=t.target,p=a.view;g!=o;g=g.parentNode)for(var T=0;T=0&&oe(e,r.to())<=0)return i}return-1};var de=function(e,t){this.anchor=e,this.head=t};de.prototype.from=function(){return Oi(this.anchor,this.head)},de.prototype.to=function(){return Ni(this.anchor,this.head)},de.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function yt(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(T,C){return oe(T.from(),C.from())}),i=Se(t,n);for(var l=1;l0:s>=0){var u=Oi(o.from(),a.from()),g=Ni(o.to(),a.to()),p=o.empty()?a.from()==a.head:o.from()==o.head;l<=i&&--i,t.splice(--l,2,new de(p?g:u,p?u:g))}}return new ft(t,i)}function Ut(e,t){return new ft([new de(e,t||e)],0)}function Gt(e){return e.text?P(e.from.line+e.text.length-1,f(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ia(e,t){if(oe(e,t.from)<0)return e;if(oe(e,t.to)<=0)return Gt(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Gt(t).ch-t.to.ch),P(i,r)}function il(e,t){for(var i=[],r=0;r1&&e.remove(o.line+1,E-1),e.insert(o.line+1,U)}Be(e,"change",e,t)}function Kt(e,t,i){function r(n,l,a){if(n.linked)for(var o=0;o1&&!e.done[e.done.length-2].ranges)return e.done.pop(),f(e.done)}function za(e,t,i,r){var n=e.history;n.undone.length=0;var l=+new Date,a,o;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>l-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(a=wu(n,n.lastOp==r)))o=f(a.changes),oe(t.from,t.to)==0&&oe(t.from,o.to)==0?o.to=Gt(t):a.changes.push(al(e,t));else{var s=f(n.done);for((!s||!s.ranges)&&Ji(e.sel,n.done),a={changes:[al(e,t)],generation:n.generation},n.done.push(a);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=l,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,o||Te(e,"historyAdded")}function Cu(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Su(e,t,i,r){var n=e.history,l=r&&r.origin;i==n.lastSelOp||l&&n.lastSelOrigin==l&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==l||Cu(e,l,f(n.done),t))?n.done[n.done.length-1]=t:Ji(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=l,n.lastSelOp=i,r&&r.clearRedo!==!1&&Ra(n.undone)}function Ji(e,t){var i=f(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Ua(e,t,i,r){var n=t["spans_"+e.id],l=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(a){a.markedSpans&&((n||(n=t["spans_"+e.id]={}))[l]=a.markedSpans),++l})}function Lu(e){if(!e)return null;for(var t,i=0;i-1&&(f(o)[p]=u[p],delete u[p])}}return r}function ol(e,t,i,r){if(r){var n=e.anchor;if(i){var l=oe(t,n)<0;l!=oe(i,n)<0?(n=t,t=i):l!=oe(t,i)<0&&(t=i)}return new de(n,t)}else return new de(i||t,t)}function ji(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Qe(e,new ft([ol(e.sel.primary(),t,i,n)],0),r)}function Ka(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),l=0;l=t.ch:o.to>t.ch))){if(n&&(Te(s,"beforeCursorEnter"),s.explicitlyCleared))if(l.markedSpans){--a;continue}else break;if(!s.atomic)continue;if(i){var p=s.find(r<0?1:-1),T=void 0;if((r<0?g:u)&&(p=Qa(e,p,-r,p&&p.line==t.line?l:null)),p&&p.line==t.line&&(T=oe(p,i))&&(r<0?T<0:T>0))return Dr(e,p,t,r,n)}var C=s.find(r<0?-1:1);return(r<0?u:g)&&(C=Qa(e,C,r,C.line==t.line?l:null)),C?Dr(e,C,t,r,n):null}}return t}function en(e,t,i,r,n){var l=r||1,a=Dr(e,t,i,l,n)||!n&&Dr(e,t,i,l,!0)||Dr(e,t,i,-l,n)||!n&&Dr(e,t,i,-l,!0);return a||(e.cantEdit=!0,P(e.first,0))}function Qa(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?se(e,P(t.line-1)):null:i>0&&t.ch==(r||j(e,t.line)).text.length?t.line=0;--n)Va(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Va(e,t)}}function Va(e,t){if(!(t.text.length==1&&t.text[0]==""&&oe(t.from,t.to)==0)){var i=il(e,t);za(e,t,i,e.cm?e.cm.curOp.id:NaN),oi(e,t,i,Dn(e,t));var r=[];Kt(e,function(n,l){!l&&Se(r,n.history)==-1&&(io(n.history,t),r.push(n.history)),oi(n,t,null,Dn(n,t))})}}function tn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(!(r&&!i)){for(var n=e.history,l,a=e.sel,o=t=="undo"?n.done:n.undone,s=t=="undo"?n.undone:n.done,u=0;u=0;--C){var E=T(C);if(E)return E.v}}}}function eo(e,t){if(t!=0&&(e.first+=t,e.sel=new ft(y(e.sel.ranges,function(n){return new de(P(n.anchor.line+t,n.anchor.ch),P(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm)){rt(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;re.lastLine())){if(t.from.linel&&(t={from:t.from,to:P(l,j(e,l).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Vt(e,t.from,t.to),i||(i=il(e,t)),e.cm?xu(e.cm,t,r):ll(e,t,r),Vi(e,i,ht),e.cantEdit&&en(e,P(e.firstLine(),0))&&(e.cantEdit=!1)}}function xu(e,t,i){var r=e.doc,n=e.display,l=t.from,a=t.to,o=!1,s=l.line;e.options.lineWrapping||(s=pe(pt(j(r,l.line))),r.iter(s,a.line+1,function(C){if(C==n.maxLine)return o=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Pt(e),ll(r,t,i,ba(e)),e.options.lineWrapping||(r.iter(s,l.line+t.text.length,function(C){var E=Pi(C);E>n.maxLineLength&&(n.maxLine=C,n.maxLineLength=E,n.maxLineChanged=!0,o=!1)}),o&&(e.curOp.updateMaxLine=!0)),ps(r,l.line),ni(e,400);var u=t.text.length-(a.line-l.line)-1;t.full?rt(e):l.line==a.line&&t.text.length==1&&!Ha(e.doc,t)?Rt(e,l.line,"text"):rt(e,l.line,a.line+1,u);var g=$e(e,"changes"),p=$e(e,"change");if(p||g){var T={from:l,to:a,text:t.text,removed:t.removed,origin:t.origin};p&&Be(e,"change",e,T),g&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(T)}e.display.selForContextMenu=null}function Or(e,t,i,r,n){var l;r||(r=i),oe(r,i)<0&&(l=[r,i],i=l[0],r=l[1]),typeof t=="string"&&(t=e.splitLines(t)),Nr(e,{from:i,to:r,text:t,origin:n})}function to(e,t,i,r){i1||!(this.children[0]instanceof ui))){var o=[];this.collapse(o),this.children=[new ui(o)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=n.lines.length%25+25,o=a;o10);e.parent.maybeSpill()}},iterN:function(e,t,i){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=g,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&rt(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&qa(e.doc)),e&&Be(e,"markerCleared",e,this,r,n),t&&sr(e),this.parent&&this.parent.clear()}},$t.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n0||a==0&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=kt("span",[l.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(Zl(e,t.line,t,i,l)||t.line!=i.line&&Zl(e,i.line,t,i,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");ys()}l.addToHistory&&za(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var o=t.line,s=e.cm,u;if(e.iter(o,i.line+1,function(p){s&&l.collapsed&&!s.options.lineWrapping&&pt(p)==s.display.maxLine&&(u=!0),l.collapsed&&o!=t.line&&wt(p,0),bs(p,new Wi(l,o==t.line?t.ch:null,o==i.line?i.ch:null),e.cm&&e.cm.curOp),++o}),l.collapsed&&e.iter(t.line,i.line+1,function(p){Bt(e,p)&&wt(p,0)}),l.clearOnEnter&&te(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(vs(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++lo,l.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),l.collapsed)rt(s,t.line,i.line+1);else if(l.className||l.startStyle||l.endStyle||l.css||l.attributes||l.title)for(var g=t.line;g<=i.line;g++)Rt(s,g,"text");l.atomic&&qa(s.doc),Be(s,"markerAdded",s,l)}return l}var ci=function(e,t){this.markers=e,this.primary=t;for(var i=0;i=0;s--)Nr(this,r[s]);o?Xa(this,o):this.cm&&Ar(this.cm)}),undo:ze(function(){tn(this,"undo")}),redo:ze(function(){tn(this,"redo")}),undoSelection:ze(function(){tn(this,"undo",!0)}),redoSelection:ze(function(){tn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=se(this,e),t=se(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(l){var a=l.markedSpans;if(a)for(var o=0;o=s.to||s.from==null&&n!=e.line||s.from!=null&&n==t.line&&s.from>=t.ch)&&(!i||i(s.marker))&&r.push(s.marker.parent||s.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;re)return t=e,!0;e-=l,++i}),se(this,P(i,t))},indexFromPos:function(e){e=se(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var g=e.dataTransfer.getData("Text");if(g){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),Vi(t.doc,Ut(i,i)),p)for(var T=0;T=0;o--)Or(e.doc,"",r[o].from,r[o].to,"+delete");Ar(e)})}function ul(e,t,i){var r=ce(e.text,t+i,i);return r<0||r>e.text.length?null:r}function fl(e,t,i){var r=ul(e,t.ch,i);return r==null?null:new P(t.line,r,i<0?"after":"before")}function hl(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var l=ge(i,t.doc.direction);if(l){var a=n<0?f(l):l[0],o=n<0==(a.level==1),s=o?"after":"before",u;if(a.level>0||t.doc.direction=="rtl"){var g=Lr(t,i);u=n<0?i.text.length-1:0;var p=Lt(t,g,u).top;u=me(function(T){return Lt(t,g,T).top==p},n<0==(a.level==1)?a.from:a.to-1,u),s=="before"&&(u=ul(i,u,1))}else u=n<0?a.to:a.from;return new P(r,u,s)}}return new P(r,n<0?i.text.length:0,n<0?"before":"after")}function Ru(e,t,i,r){var n=ge(t,e.doc.direction);if(!n)return fl(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var l=Ne(n,i.ch,i.sticky),a=n[l];if(e.doc.direction=="ltr"&&a.level%2==0&&(r>0?a.to>i.ch:a.from=a.from&&T>=g.begin)){var C=p?"before":"after";return new P(i.line,T,C)}}var E=function(U,$,G){for(var X=function(we,Ue){return Ue?new P(i.line,o(we,1),"before"):new P(i.line,we,"after")};U>=0&&U0==(ee.level!=1),fe=V?G.begin:o(G.end,-1);if(ee.from<=fe&&fe0?g.end:o(g.begin,-1);return B!=null&&!(r>0&&B==t.text.length)&&(W=E(r>0?0:n.length-1,r,u(B)),W)?W:null}var pi={selectAll:Ja,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ht)},killLine:function(e){return Ir(e,function(t){if(t.empty()){var i=j(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line0)n=new P(n.line,n.ch+1),e.replaceRange(l.charAt(n.ch-1)+l.charAt(n.ch-2),P(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var a=j(e.doc,n.line-1).text;a&&(n=new P(n.line,1),e.replaceRange(l.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),P(n.line-1,a.length-1),n,"+transpose"))}}i.push(new de(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return ot(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;re&&oe(t,this.pos)==0&&i==this.button};var yi,mi;function Yu(e,t){var i=+new Date;return mi&&mi.compare(i,e,t)?(yi=mi=null,"triple"):yi&&yi.compare(i,e,t)?(mi=new dl(i,e,t),yi=null,"double"):(yi=new dl(i,e,t),mi=null,"single")}function So(e){var t=this,i=t.display;if(!(xe(t,e)||i.activeTouch&&i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=e.shiftKey,Nt(i,e)){b||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(!gl(t,e)){var r=ir(t,e),n=Ol(e),l=r?Yu(r,n):"single";At(t).focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),!(r&&qu(t,n,r,l,e))&&(n==1?r?Qu(t,r,l,e):vn(e)==i.scroller&&Oe(e):n==2?(r&&ji(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(Fe?t.display.input.onContextMenu(e):qn(t)))}}}function qu(e,t,i,r,n){var l="Click";return r=="double"?l="Double"+l:r=="triple"&&(l="Triple"+l),l=(t==1?"Left":t==2?"Middle":"Right")+l,vi(e,co(l,n),n,function(a){if(typeof a=="string"&&(a=pi[a]),!a)return!1;var o=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),o=a(e,i)!=Ht}finally{e.state.suppressEdits=!1}return o})}function Zu(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var l=he?i.shiftKey&&i.metaKey:i.altKey;n.unit=l?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=ne?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(ne?i.altKey:i.ctrlKey)),n}function Qu(e,t,i,r){d?setTimeout(pr(Sa,e),0):e.curOp.focus=tt(Ft(e));var n=Zu(e,i,r),l=e.doc.sel,a;e.options.dragDrop&&ns&&!e.isReadOnly()&&i=="single"&&(a=l.contains(t))>-1&&(oe((a=l.ranges[a]).from(),t)<0||t.xRel>0)&&(oe(a.to(),t)>0||t.xRel<0)?Ju(e,r,t,n):ju(e,r,t,n)}function Ju(e,t,i,r){var n=e.display,l=!1,a=Re(e,function(u){b&&(n.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:qn(e)),je(n.wrapper.ownerDocument,"mouseup",a),je(n.wrapper.ownerDocument,"mousemove",o),je(n.scroller,"dragstart",s),je(n.scroller,"drop",a),l||(Oe(u),r.addNew||ji(e.doc,i,null,null,r.extend),b&&!K||d&&v==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),o=function(u){l=l||Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)>=10},s=function(){return l=!0};b&&(n.scroller.draggable=!0),e.state.draggingText=a,a.copy=!r.moveOnDrag,te(n.wrapper.ownerDocument,"mouseup",a),te(n.wrapper.ownerDocument,"mousemove",o),te(n.scroller,"dragstart",s),te(n.scroller,"drop",a),e.state.delayingBlurEvent=!0,setTimeout(function(){return n.input.focus()},20),n.scroller.dragDrop&&n.scroller.dragDrop()}function Lo(e,t,i){if(i=="char")return new de(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new de(P(t.line,0),se(e.doc,P(t.line+1,0)));var r=i(e,t);return new de(r.from,r.to)}function ju(e,t,i,r){d&&qn(e);var n=e.display,l=e.doc;Oe(t);var a,o,s=l.sel,u=s.ranges;if(r.addNew&&!r.extend?(o=l.sel.contains(i),o>-1?a=u[o]:a=new de(i,i)):(a=l.sel.primary(),o=l.sel.primIndex),r.unit=="rectangle")r.addNew||(a=new de(i,i)),i=ir(e,t,!0,!0),o=-1;else{var g=Lo(e,i,r.unit);r.extend?a=ol(a,g.anchor,g.head,r.extend):a=g}r.addNew?o==-1?(o=u.length,Qe(l,yt(e,u.concat([a]),o),{scroll:!1,origin:"*mouse"})):u.length>1&&u[o].empty()&&r.unit=="char"&&!r.extend?(Qe(l,yt(e,u.slice(0,o).concat(u.slice(o+1)),0),{scroll:!1,origin:"*mouse"}),s=l.sel):sl(l,o,a,Ur):(o=0,Qe(l,new ft([a],0),Ur),s=l.sel);var p=i;function T(G){if(oe(p,G)!=0)if(p=G,r.unit=="rectangle"){for(var X=[],ee=e.options.tabSize,V=Ze(j(l,i.line).text,i.ch,ee),fe=Ze(j(l,G.line).text,G.ch,ee),we=Math.min(V,fe),Ue=Math.max(V,fe),ke=Math.min(i.line,G.line),st=Math.min(e.lastLine(),Math.max(i.line,G.line));ke<=st;ke++){var nt=j(l,ke).text,We=Gr(nt,we,ee);we==Ue?X.push(new de(P(ke,We),P(ke,We))):nt.length>We&&X.push(new de(P(ke,We),P(ke,Gr(nt,Ue,ee))))}X.length||X.push(new de(i,i)),Qe(l,yt(e,s.ranges.slice(0,o).concat(X),o),{origin:"*mouse",scroll:!1}),e.scrollIntoView(G)}else{var lt=a,Xe=Lo(e,G,r.unit),He=lt.anchor,Ie;oe(Xe.anchor,He)>0?(Ie=Xe.head,He=Oi(lt.from(),Xe.anchor)):(Ie=Xe.anchor,He=Ni(lt.to(),Xe.head));var Ae=s.ranges.slice(0);Ae[o]=Vu(e,new de(se(l,He),Ie)),Qe(l,yt(e,Ae,o),Ur)}}var C=n.wrapper.getBoundingClientRect(),E=0;function W(G){var X=++E,ee=ir(e,G,!0,r.unit=="rectangle");if(ee)if(oe(ee,p)!=0){e.curOp.focus=tt(Ft(e)),T(ee);var V=Xi(n,l);(ee.line>=V.to||ee.lineC.bottom?20:0;fe&&setTimeout(Re(e,function(){E==X&&(n.scroller.scrollTop+=fe,W(G))}),50)}}function B(G){e.state.selectingText=!1,E=1/0,G&&(Oe(G),n.input.focus()),je(n.wrapper.ownerDocument,"mousemove",U),je(n.wrapper.ownerDocument,"mouseup",$),l.history.lastSelOrigin=null}var U=Re(e,function(G){G.buttons===0||!Ol(G)?B(G):W(G)}),$=Re(e,B);e.state.selectingText=$,te(n.wrapper.ownerDocument,"mousemove",U),te(n.wrapper.ownerDocument,"mouseup",$)}function Vu(e,t){var i=t.anchor,r=t.head,n=j(e.doc,i.line);if(oe(i,r)==0&&i.sticky==r.sticky)return t;var l=ge(n);if(!l)return t;var a=Ne(l,i.ch,i.sticky),o=l[a];if(o.from!=i.ch&&o.to!=i.ch)return t;var s=a+(o.from==i.ch==(o.level!=1)?0:1);if(s==0||s==l.length)return t;var u;if(r.line!=i.line)u=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var g=Ne(l,r.ch,r.sticky),p=g-a||(r.ch-i.ch)*(o.level==1?-1:1);g==s-1||g==s?u=p<0:u=p>0}var T=l[s+(u?-1:0)],C=u==(T.level==1),E=C?T.from:T.to,W=C?"after":"before";return i.ch==E&&i.sticky==W?t:new de(new P(i.line,E,W),r)}function To(e,t,i,r){var n,l;if(t.touches)n=t.touches[0].clientX,l=t.touches[0].clientY;else try{n=t.clientX,l=t.clientY}catch{return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Oe(t);var a=e.display,o=a.lineDiv.getBoundingClientRect();if(l>o.bottom||!$e(e,i))return pn(t);l-=o.top-a.viewOffset;for(var s=0;s=n){var g=er(e.doc,l),p=e.display.gutterSpecs[s];return Te(e,i,e,g,p.className,t),pn(t)}}}function gl(e,t){return To(e,t,"gutterClick",!0)}function ko(e,t){Nt(e.display,t)||ef(e,t)||xe(e,t,"contextmenu")||Fe||e.display.input.onContextMenu(t)}function ef(e,t){return $e(e,"gutterContextMenu")?To(e,t,"gutterContextMenu",!1):!1}function xo(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),jr(e)}var Fr={toString:function(){return"CodeMirror.Init"}},Ao={},an={};function tf(e){var t=e.optionHandlers;function i(r,n,l,a){e.defaults[r]=n,l&&(t[r]=a?function(o,s,u){u!=Fr&&l(o,s,u)}:l)}e.defineOption=i,e.Init=Fr,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,nl(r)},!0),i("indentUnit",2,nl,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){ai(r),jr(r),rt(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!!n){var l=[],a=r.doc.first;r.doc.iter(function(s){for(var u=0;;){var g=s.text.indexOf(n,u);if(g==-1)break;u=g+n.length,l.push(P(a,g))}a++});for(var o=l.length-1;o>=0;o--)Or(r.doc,n,l[o],P(l[o].line,l[o].ch+n.length))}}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,function(r,n,l){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),l!=Fr&&r.refresh()}),i("specialCharPlaceholder",Ds,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",ie?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!re),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){xo(r),li(r)},!0),i("keyMap","default",function(r,n,l){var a=nn(n),o=l!=Fr&&nn(l);o&&o.detach&&o.detach(r,a),a.attach&&a.attach(r,o||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,nf,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=rl(n,r.options.lineNumbers),li(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Kn(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Mr(r)},!0),i("scrollbarStyle","native",function(r){Ma(r),Mr(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=rl(r.options.gutters,n),li(r)},!0),i("firstLineNumber",1,li,!0),i("lineNumberFormatter",function(r){return r},li,!0),i("showCursorWhenSelecting",!1,Vr,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(xr(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,rf),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,Vr,!0),i("singleCursorHeightPerLine",!0,Vr,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,ai,!0),i("addModeClass",!1,ai,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,ai,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function rf(e,t,i){var r=i&&i!=Fr;if(!t!=!r){var n=e.display.dragFunctions,l=t?te:je;l(e.display.scroller,"dragstart",n.start),l(e.display.scroller,"dragenter",n.enter),l(e.display.scroller,"dragover",n.over),l(e.display.scroller,"dragleave",n.leave),l(e.display.scroller,"drop",n.drop)}}function nf(e){e.options.lineWrapping?(xt(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Me(e.display.wrapper,"CodeMirror-wrap"),Wn(e)),$n(e),rt(e),jr(e),setTimeout(function(){return Mr(e)},100)}function Le(e,t){var i=this;if(!(this instanceof Le))return new Le(e,t);this.options=t=t?dt(t):{},dt(Ao,t,!1);var r=t.value;typeof r=="string"?r=new it(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Le.inputStyles[t.inputStyle](this),l=this.display=new vu(e,r,n,t);l.wrapper.CodeMirror=this,xo(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ma(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new gt,keySeq:null,specialChars:null},t.autofocus&&!ie&&l.input.focus(),d&&v<11&&setTimeout(function(){return i.display.input.reset(!0)},20),lf(this),Iu(),or(this),this.curOp.forceUpdate=!0,Pa(this,r),t.autofocus&&!ie||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Zn(i)},20):xr(this);for(var a in an)an.hasOwnProperty(a)&&an[a](this,t[a],Fr);Na(this),t.finishInit&&t.finishInit(this);for(var o=0;o20*20}te(t.scroller,"touchstart",function(s){if(!xe(e,s)&&!l(s)&&!gl(e,s)){t.input.ensurePolled(),clearTimeout(i);var u=+new Date;t.activeTouch={start:u,moved:!1,prev:u-r.end<=300?r:null},s.touches.length==1&&(t.activeTouch.left=s.touches[0].pageX,t.activeTouch.top=s.touches[0].pageY)}}),te(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),te(t.scroller,"touchend",function(s){var u=t.activeTouch;if(u&&!Nt(t,s)&&u.left!=null&&!u.moved&&new Date-u.start<300){var g=e.coordsChar(t.activeTouch,"page"),p;!u.prev||a(u,u.prev)?p=new de(g,g):!u.prev.prev||a(u,u.prev.prev)?p=e.findWordAt(g):p=new de(P(g.line,0),se(e.doc,P(g.line+1,0))),e.setSelection(p.anchor,p.head),e.focus(),Oe(s)}n()}),te(t.scroller,"touchcancel",n),te(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ti(e,t.scroller.scrollTop),lr(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))}),te(t.scroller,"mousewheel",function(s){return Wa(e,s)}),te(t.scroller,"DOMMouseScroll",function(s){return Wa(e,s)}),te(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(s){xe(e,s)||$r(s)},over:function(s){xe(e,s)||(Wu(e,s),$r(s))},start:function(s){return Eu(e,s)},drop:Re(e,Ou),leave:function(s){xe(e,s)||so(e)}};var o=t.input.getField();te(o,"keyup",function(s){return wo.call(e,s)}),te(o,"keydown",Re(e,bo)),te(o,"keypress",Re(e,Co)),te(o,"focus",function(s){return Zn(e,s)}),te(o,"blur",function(s){return xr(e,s)})}var pl=[];Le.defineInitHook=function(e){return pl.push(e)};function bi(e,t,i,r){var n=e.doc,l;i==null&&(i="add"),i=="smart"&&(n.mode.indent?l=Yr(e,t).state:i="prev");var a=e.options.tabSize,o=j(n,t),s=Ze(o.text,null,a);o.stateAfter&&(o.stateAfter=null);var u=o.text.match(/^\s*/)[0],g;if(!r&&!/\S/.test(o.text))g=0,i="not";else if(i=="smart"&&(g=n.mode.indent(l,o.text.slice(u.length),o.text),g==Ht||g>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?g=Ze(j(n,t-1).text,null,a):g=0:i=="add"?g=s+e.options.indentUnit:i=="subtract"?g=s-e.options.indentUnit:typeof i=="number"&&(g=s+i),g=Math.max(0,g);var p="",T=0;if(e.options.indentWithTabs)for(var C=Math.floor(g/a);C;--C)T+=a,p+=" ";if(Ta,s=bn(t),u=null;if(o&&r.ranges.length>1)if(mt&&mt.text.join(` +`)==t){if(r.ranges.length%mt.text.length==0){u=[];for(var g=0;g=0;T--){var C=r.ranges[T],E=C.from(),W=C.to();C.empty()&&(i&&i>0?E=P(E.line,E.ch-i):e.state.overwrite&&!o?W=P(W.line,Math.min(j(l,W.line).text.length,W.ch+f(s).length)):o&&mt&&mt.lineWise&&mt.text.join(` `)==s.join(` -`)&&(E=W=P(E.line,0)));var B={from:E,to:W,text:u?u[L%u.length]:s,origin:n||(o?"paste":e.state.cutIncoming>a?"cut":"+input")};Nr(e.doc,B),Be(e,"inputRead",e,B)}t&&!o&&Mo(e,t),Ar(e),e.curOp.updateInput<2&&(e.curOp.updateInput=p),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ao(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&t.hasFocus()&&ot(t,function(){return pl(t,i,0,null,"paste")}),!0}function Mo(e,t){if(!(!e.options.electricChars||!e.options.smartIndent))for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(!(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)){var l=e.getModeAt(n.head),a=!1;if(l.electricChars){for(var o=0;o-1){a=bi(e,n.head.line,"smart");break}}else l.electricInput&&l.electricInput.test(j(e.doc,n.head.line).text.slice(0,n.head.ch))&&(a=bi(e,n.head.line,"smart"));a&&Be(e,"electricInput",e,n.head.line)}}}function _o(e){for(var t=[],i=[],r=0;rl&&(bi(this,o.head.line,r,!0),l=o.head.line,a==this.doc.sel.primIndex&&Ar(this));else{var s=o.from(),u=o.to(),g=Math.max(l,s.line);l=Math.min(this.lastLine(),u.line-(u.ch?0:1))+1;for(var p=g;p0&&ol(this.doc,a,new de(s,L[a].to()),ht)}}}),getTokenAt:function(r,n){return Bl(this,r,n)},getLineTokens:function(r,n){return Bl(this,P(r),n,!0)},getTokenTypeAt:function(r){r=se(this.doc,r);var n=Il(this,j(this.doc,r.line)),l=0,a=(n.length-1)/2,o=r.ch,s;if(o==0)s=n[2];else for(;;){var u=l+a>>1;if((u?n[u*2-1]:0)>=o)a=u;else if(n[u*2+1]s&&(r=s,a=!0),o=j(this.doc,r)}else o=r;return zi(this,o,{top:0,left:0},n||"page",l||a).top+(a?this.doc.height-Dt(o):0)},defaultTextHeight:function(){return Tr(this.display)},defaultCharWidth:function(){return kr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,l,a,o){var s=this.display;r=vt(this,se(this.doc,r));var u=r.bottom,g=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),s.sizer.appendChild(n),a=="over")u=r.top;else if(a=="above"||a=="near"){var p=Math.max(s.wrapper.clientHeight,this.doc.height),L=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(a=="above"||r.bottom+n.offsetHeight>p)&&r.top>n.offsetHeight?u=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=p&&(u=r.bottom),g+n.offsetWidth>L&&(g=L-n.offsetWidth)}n.style.top=u+"px",n.style.left=n.style.right="",o=="right"?(g=s.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(o=="left"?g=0:o=="middle"&&(g=(s.sizer.clientWidth-n.offsetWidth)/2),n.style.left=g+"px"),l&&ru(this,{left:g,top:u,right:g+n.offsetWidth,bottom:u+n.offsetHeight})},triggerOnKeyDown:Ve(mo),triggerOnKeyPress:Ve(wo),triggerOnKeyUp:bo,triggerOnMouseDown:Ve(Co),execCommand:function(r){if(pi.hasOwnProperty(r))return pi[r].call(null,this)},triggerElectric:Ve(function(r){Mo(this,r)}),findPosH:function(r,n,l,a){var o=1;n<0&&(o=-1,n=-n);for(var s=se(this.doc,r),u=0;u0&&g(l.charAt(a-1));)--a;for(;o.5||this.options.lineWrapping)&&Kn(this),Te(this,"refresh",this)}),swapDoc:Ve(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Ha(this,r),jr(this),this.display.input.reset(),ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Be(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Mt(e),e.registerHelper=function(r,n,l){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=l},e.registerGlobalHelper=function(r,n,l,a){e.registerHelper(r,n,a),i[r]._global.push({pred:l,val:a})}}function yl(e,t,i,r,n){var l=t,a=i,o=j(e,t.line),s=n&&e.direction=="rtl"?-i:i;function u(){var $=t.line+s;return $=e.first+e.size?!1:(t=new P($,t.ch,t.sticky),o=j(e,$))}function g($){var U;if(r=="codepoint"){var X=o.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(X))U=null;else{var ee=i>0?X>=55296&&X<56320:X>=56320&&X<57343;U=new P(t.line,Math.max(0,Math.min(o.text.length,t.ch+i*(ee?2:1))),-i)}}else n?U=Ru(e.cm,o,t,i):U=ul(o,t,i);if(U==null)if(!$&&u())t=fl(n,e.cm,o,t.line,s);else return!1;else t=U;return!0}if(r=="char"||r=="codepoint")g();else if(r=="column")g(!0);else if(r=="word"||r=="group")for(var p=null,L=r=="group",C=e.cm&&e.cm.getHelper(t,"wordChars"),E=!0;!(i<0&&!g(!E));E=!1){var W=o.text.charAt(t.ch)||` -`,B=H(W,C)?"w":L&&W==` -`?"n":!L||/\s/.test(W)?null:"p";if(L&&!E&&!B&&(B="s"),p&&p!=B){i<0&&(i=1,g(),t.sticky="after");break}if(B&&(p=B),i>0&&!g(!E))break}var z=en(e,t,l,a,!0);return kn(l,z)&&(z.hitSide=!0),z}function No(e,t,i,r){var n=e.doc,l=t.left,a;if(r=="page"){var o=Math.min(e.display.wrapper.clientHeight,At(e).innerHeight||n(e).documentElement.clientHeight),s=Math.max(o-.5*Tr(e.display),3);a=(i>0?t.bottom:t.top)+i*s}else r=="line"&&(a=i>0?t.bottom+3:t.top-3);for(var u;u=Rn(e,l,a),!!u.outside;){if(i<0?a<=0:a>=n.height){u.hitSide=!0;break}a+=i*5}return u}var ve=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new gt,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};ve.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;n.contentEditable=!0,vl(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function l(o){for(var s=o.target;s;s=s.parentNode){if(s==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(s.className))break}return!1}te(n,"paste",function(o){!l(o)||xe(r,o)||Ao(o,r)||v<=11&&setTimeout(Re(r,function(){return t.updateFromDOM()}),20)}),te(n,"compositionstart",function(o){t.composing={data:o.data,done:!1}}),te(n,"compositionupdate",function(o){t.composing||(t.composing={data:o.data,done:!1})}),te(n,"compositionend",function(o){t.composing&&(o.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),te(n,"touchstart",function(){return i.forceCompositionEnd()}),te(n,"input",function(){t.composing||t.readFromDOMSoon()});function a(o){if(!(!l(o)||xe(r,o))){if(r.somethingSelected())on({lineWise:!1,text:r.getSelections()}),o.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var s=_o(r);on({lineWise:!0,text:s.text}),o.type=="cut"&&r.operation(function(){r.setSelections(s.ranges,0,ht),r.replaceSelection("",null,"cut")})}else return;if(o.clipboardData){o.clipboardData.clearData();var u=mt.text.join(` -`);if(o.clipboardData.setData("Text",u),o.clipboardData.getData("Text")==u){o.preventDefault();return}}var g=Do(),p=g.firstChild;vl(p),r.display.lineSpace.insertBefore(g,r.display.lineSpace.firstChild),p.value=mt.text.join(` -`);var L=tt(Pe(n));Zt(p),setTimeout(function(){r.display.lineSpace.removeChild(g),L.focus(),L==n&&i.showPrimarySelection()},50)}}te(n,"copy",a),te(n,"cut",a)},ve.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},ve.prototype.prepareSelection=function(){var e=wa(this.cm,!1);return e.focus=tt(Pe(this.div))==this.div,e},ve.prototype.showSelection=function(e,t){!e||!this.cm.display.view.length||((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},ve.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ve.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line=t.display.viewFrom&&Oo(t,r)||{node:o[0].measure.map[2],offset:0},u=n.linee.firstLine()&&(r=P(r.line-1,j(e.doc,r.line-1).length)),n.ch==j(e.doc,n.line).text.length&&n.linet.viewTo-1)return!1;var l,a,o;r.line==t.viewFrom||(l=nr(e,r.line))==0?(a=pe(t.view[0].line),o=t.view[0].node):(a=pe(t.view[l].line),o=t.view[l-1].node.nextSibling);var s=nr(e,n.line),u,g;if(s==t.view.length-1?(u=t.viewTo-1,g=t.lineDiv.lastChild):(u=pe(t.view[s+1].line)-1,g=t.view[s+1].node.previousSibling),!o)return!1;for(var p=e.doc.splitLines(sf(e,o,g,a,u)),L=Vt(e.doc,P(a,0),P(u,j(e.doc,u).text.length));p.length>1&&L.length>1;)if(f(p)==f(L))p.pop(),L.pop(),u--;else if(p[0]==L[0])p.shift(),L.shift(),a++;else break;for(var C=0,E=0,W=p[0],B=L[0],z=Math.min(W.length,B.length);Cr.ch&&$.charCodeAt($.length-E-1)==U.charCodeAt(U.length-E-1);)C--,E++;p[p.length-1]=$.slice(0,$.length-E).replace(/^\u200b+/,""),p[0]=p[0].slice(C).replace(/\u200b+$/,"");var ee=P(a,C),V=P(u,L.length?f(L).length-E:0);if(p.length>1||p[0]||oe(ee,V))return Or(e.doc,p,ee,V,"+input"),!0},ve.prototype.ensurePolled=function(){this.forceCompositionEnd()},ve.prototype.reset=function(){this.forceCompositionEnd()},ve.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ve.prototype.readFromDOMSoon=function(){var e=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80))},ve.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&ot(this.cm,function(){return rt(e.cm)})},ve.prototype.setUneditable=function(e){e.contentEditable="false"},ve.prototype.onKeyPress=function(e){e.charCode==0||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Re(this.cm,pl)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0))},ve.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},ve.prototype.onContextMenu=function(){},ve.prototype.resetPosition=function(){},ve.prototype.needsContentAttribute=!0;function Oo(e,t){var i=Hn(e,t.line);if(!i||i.hidden)return null;var r=j(e.doc,t.line),n=aa(i,r,t.line),l=ge(r,e.doc.direction),a="left";if(l){var o=Ne(l,t.ch);a=o%2?"right":"left"}var s=ua(n.map,t.ch,a);return s.offset=s.collapse=="right"?s.end:s.start,s}function of(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hr(e,t){return t&&(e.bad=!0),e}function sf(e,t,i,r,n){var l="",a=!1,o=e.doc.lineSeparator(),s=!1;function u(C){return function(E){return E.id==C}}function g(){a&&(l+=o,s&&(l+=o),a=s=!1)}function p(C){C&&(g(),l+=C)}function L(C){if(C.nodeType==1){var E=C.getAttribute("cm-text");if(E){p(E);return}var W=C.getAttribute("cm-marker"),B;if(W){var z=e.findMarks(P(r,0),P(n+1,0),u(+W));z.length&&(B=z[0].find(0))&&p(Vt(e.doc,B.from,B.to).join(o));return}if(C.getAttribute("contenteditable")=="false")return;var $=/^(pre|div|p|li|table|br)$/i.test(C.nodeName);if(!/^br$/i.test(C.nodeName)&&C.textContent.length==0)return;$&&g();for(var U=0;U=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),te(n,"paste",function(a){xe(r,a)||Ao(a,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())});function l(a){if(!xe(r,a)){if(r.somethingSelected())on({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var o=_o(r);on({lineWise:!0,text:o.text}),a.type=="cut"?r.setSelections(o.ranges,null,ht):(i.prevInput="",n.value=o.text.join(` -`),Zt(n))}else return;a.type=="cut"&&(r.state.cutIncoming=+new Date)}}te(n,"cut",l),te(n,"copy",l),te(e.scroller,"paste",function(a){if(!(Nt(e,a)||xe(r,a))){if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var o=new Event("paste");o.clipboardData=a.clipboardData,n.dispatchEvent(o)}}),te(e.lineSpace,"selectstart",function(a){Nt(e,a)||Oe(a)}),te(n,"compositionstart",function(){var a=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:a,range:r.markText(a,r.getCursor("to"),{className:"CodeMirror-composing"})}}),te(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},_e.prototype.createField=function(e){this.wrapper=Do(),this.textarea=this.wrapper.firstChild;var t=this.cm.options;vl(this.textarea,t.spellcheck,t.autocorrect,t.autocapitalize)},_e.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},_e.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=wa(e);if(e.options.moveInputWithCursor){var n=vt(e,i.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+a.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+a.left-l.left))}return r},_e.prototype.showSelection=function(e){var t=this.cm,i=t.display;De(i.cursorDiv,e.cursors),De(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},_e.prototype.reset=function(e){if(!(this.contextMenuPending||this.composing&&e)){var t=this.cm;if(this.resetting=!0,t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Zt(this.textarea),d&&v>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",d&&v>=9&&(this.hasSelection=null));this.resetting=!1}},_e.prototype.getField=function(){return this.textarea},_e.prototype.supportsTouch=function(){return!1},_e.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!ie||tt(Pe(this.textarea))!=this.textarea))try{this.textarea.focus()}catch{}},_e.prototype.blur=function(){this.textarea.blur()},_e.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},_e.prototype.receivedFocus=function(){this.slowPoll()},_e.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},_e.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},_e.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||this.resetting||!t.state.focused||os(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(d&&v>=9&&this.hasSelection===n||ne&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var l=n.charCodeAt(0);if(l==8203&&!r&&(r="​"),l==8666)return this.reset(),this.cm.execCommand("undo")}for(var a=0,o=Math.min(r.length,n.length);a1e3||n.indexOf(` -`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},_e.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},_e.prototype.onKeyPress=function(){d&&v>=9&&(this.hasSelection=null),this.fastPoll()},_e.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var l=ir(i,e),a=r.scroller.scrollTop;if(!l||I)return;var o=i.options.resetSelectionOnContextMenu;o&&i.doc.sel.contains(l)==-1&&Re(i,Qe)(i.doc,Ut(l),ht);var s=n.style.cssText,u=t.wrapper.style.cssText,g=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px; +`)&&(E=W=P(E.line,0)));var B={from:E,to:W,text:u?u[T%u.length]:s,origin:n||(o?"paste":e.state.cutIncoming>a?"cut":"+input")};Nr(e.doc,B),Be(e,"inputRead",e,B)}t&&!o&&_o(e,t),Ar(e),e.curOp.updateInput<2&&(e.curOp.updateInput=p),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Mo(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&t.hasFocus()&&ot(t,function(){return vl(t,i,0,null,"paste")}),!0}function _o(e,t){if(!(!e.options.electricChars||!e.options.smartIndent))for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(!(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)){var l=e.getModeAt(n.head),a=!1;if(l.electricChars){for(var o=0;o-1){a=bi(e,n.head.line,"smart");break}}else l.electricInput&&l.electricInput.test(j(e.doc,n.head.line).text.slice(0,n.head.ch))&&(a=bi(e,n.head.line,"smart"));a&&Be(e,"electricInput",e,n.head.line)}}}function Do(e){for(var t=[],i=[],r=0;rl&&(bi(this,o.head.line,r,!0),l=o.head.line,a==this.doc.sel.primIndex&&Ar(this));else{var s=o.from(),u=o.to(),g=Math.max(l,s.line);l=Math.min(this.lastLine(),u.line-(u.ch?0:1))+1;for(var p=g;p0&&sl(this.doc,a,new de(s,T[a].to()),ht)}}}),getTokenAt:function(r,n){return Rl(this,r,n)},getLineTokens:function(r,n){return Rl(this,P(r),n,!0)},getTokenTypeAt:function(r){r=se(this.doc,r);var n=Hl(this,j(this.doc,r.line)),l=0,a=(n.length-1)/2,o=r.ch,s;if(o==0)s=n[2];else for(;;){var u=l+a>>1;if((u?n[u*2-1]:0)>=o)a=u;else if(n[u*2+1]s&&(r=s,a=!0),o=j(this.doc,r)}else o=r;return zi(this,o,{top:0,left:0},n||"page",l||a).top+(a?this.doc.height-Dt(o):0)},defaultTextHeight:function(){return Tr(this.display)},defaultCharWidth:function(){return kr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,l,a,o){var s=this.display;r=vt(this,se(this.doc,r));var u=r.bottom,g=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),s.sizer.appendChild(n),a=="over")u=r.top;else if(a=="above"||a=="near"){var p=Math.max(s.wrapper.clientHeight,this.doc.height),T=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(a=="above"||r.bottom+n.offsetHeight>p)&&r.top>n.offsetHeight?u=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=p&&(u=r.bottom),g+n.offsetWidth>T&&(g=T-n.offsetWidth)}n.style.top=u+"px",n.style.left=n.style.right="",o=="right"?(g=s.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(o=="left"?g=0:o=="middle"&&(g=(s.sizer.clientWidth-n.offsetWidth)/2),n.style.left=g+"px"),l&&ru(this,{left:g,top:u,right:g+n.offsetWidth,bottom:u+n.offsetHeight})},triggerOnKeyDown:Ve(bo),triggerOnKeyPress:Ve(Co),triggerOnKeyUp:wo,triggerOnMouseDown:Ve(So),execCommand:function(r){if(pi.hasOwnProperty(r))return pi[r].call(null,this)},triggerElectric:Ve(function(r){_o(this,r)}),findPosH:function(r,n,l,a){var o=1;n<0&&(o=-1,n=-n);for(var s=se(this.doc,r),u=0;u0&&g(l.charAt(a-1));)--a;for(;o.5||this.options.lineWrapping)&&$n(this),Te(this,"refresh",this)}),swapDoc:Ve(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Pa(this,r),jr(this),this.display.input.reset(),ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Be(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Mt(e),e.registerHelper=function(r,n,l){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=l},e.registerGlobalHelper=function(r,n,l,a){e.registerHelper(r,n,a),i[r]._global.push({pred:l,val:a})}}function ml(e,t,i,r,n){var l=t,a=i,o=j(e,t.line),s=n&&e.direction=="rtl"?-i:i;function u(){var $=t.line+s;return $=e.first+e.size?!1:(t=new P($,t.ch,t.sticky),o=j(e,$))}function g($){var G;if(r=="codepoint"){var X=o.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(X))G=null;else{var ee=i>0?X>=55296&&X<56320:X>=56320&&X<57343;G=new P(t.line,Math.max(0,Math.min(o.text.length,t.ch+i*(ee?2:1))),-i)}}else n?G=Ru(e.cm,o,t,i):G=fl(o,t,i);if(G==null)if(!$&&u())t=hl(n,e.cm,o,t.line,s);else return!1;else t=G;return!0}if(r=="char"||r=="codepoint")g();else if(r=="column")g(!0);else if(r=="word"||r=="group")for(var p=null,T=r=="group",C=e.cm&&e.cm.getHelper(t,"wordChars"),E=!0;!(i<0&&!g(!E));E=!1){var W=o.text.charAt(t.ch)||` +`,B=H(W,C)?"w":T&&W==` +`?"n":!T||/\s/.test(W)?null:"p";if(T&&!E&&!B&&(B="s"),p&&p!=B){i<0&&(i=1,g(),t.sticky="after");break}if(B&&(p=B),i>0&&!g(!E))break}var U=en(e,t,l,a,!0);return xn(l,U)&&(U.hitSide=!0),U}function Oo(e,t,i,r){var n=e.doc,l=t.left,a;if(r=="page"){var o=Math.min(e.display.wrapper.clientHeight,At(e).innerHeight||n(e).documentElement.clientHeight),s=Math.max(o-.5*Tr(e.display),3);a=(i>0?t.bottom:t.top)+i*s}else r=="line"&&(a=i>0?t.bottom+3:t.top-3);for(var u;u=zn(e,l,a),!!u.outside;){if(i<0?a<=0:a>=n.height){u.hitSide=!0;break}a+=i*5}return u}var ve=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new gt,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};ve.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;n.contentEditable=!0,yl(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function l(o){for(var s=o.target;s;s=s.parentNode){if(s==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(s.className))break}return!1}te(n,"paste",function(o){!l(o)||xe(r,o)||Mo(o,r)||v<=11&&setTimeout(Re(r,function(){return t.updateFromDOM()}),20)}),te(n,"compositionstart",function(o){t.composing={data:o.data,done:!1}}),te(n,"compositionupdate",function(o){t.composing||(t.composing={data:o.data,done:!1})}),te(n,"compositionend",function(o){t.composing&&(o.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),te(n,"touchstart",function(){return i.forceCompositionEnd()}),te(n,"input",function(){t.composing||t.readFromDOMSoon()});function a(o){if(!(!l(o)||xe(r,o))){if(r.somethingSelected())on({lineWise:!1,text:r.getSelections()}),o.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var s=Do(r);on({lineWise:!0,text:s.text}),o.type=="cut"&&r.operation(function(){r.setSelections(s.ranges,0,ht),r.replaceSelection("",null,"cut")})}else return;if(o.clipboardData){o.clipboardData.clearData();var u=mt.text.join(` +`);if(o.clipboardData.setData("Text",u),o.clipboardData.getData("Text")==u){o.preventDefault();return}}var g=No(),p=g.firstChild;yl(p),r.display.lineSpace.insertBefore(g,r.display.lineSpace.firstChild),p.value=mt.text.join(` +`);var T=tt(Pe(n));Zt(p),setTimeout(function(){r.display.lineSpace.removeChild(g),T.focus(),T==n&&i.showPrimarySelection()},50)}}te(n,"copy",a),te(n,"cut",a)},ve.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},ve.prototype.prepareSelection=function(){var e=Ca(this.cm,!1);return e.focus=tt(Pe(this.div))==this.div,e},ve.prototype.showSelection=function(e,t){!e||!this.cm.display.view.length||((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},ve.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ve.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line=t.display.viewFrom&&Eo(t,r)||{node:o[0].measure.map[2],offset:0},u=n.linee.firstLine()&&(r=P(r.line-1,j(e.doc,r.line-1).length)),n.ch==j(e.doc,n.line).text.length&&n.linet.viewTo-1)return!1;var l,a,o;r.line==t.viewFrom||(l=nr(e,r.line))==0?(a=pe(t.view[0].line),o=t.view[0].node):(a=pe(t.view[l].line),o=t.view[l-1].node.nextSibling);var s=nr(e,n.line),u,g;if(s==t.view.length-1?(u=t.viewTo-1,g=t.lineDiv.lastChild):(u=pe(t.view[s+1].line)-1,g=t.view[s+1].node.previousSibling),!o)return!1;for(var p=e.doc.splitLines(sf(e,o,g,a,u)),T=Vt(e.doc,P(a,0),P(u,j(e.doc,u).text.length));p.length>1&&T.length>1;)if(f(p)==f(T))p.pop(),T.pop(),u--;else if(p[0]==T[0])p.shift(),T.shift(),a++;else break;for(var C=0,E=0,W=p[0],B=T[0],U=Math.min(W.length,B.length);Cr.ch&&$.charCodeAt($.length-E-1)==G.charCodeAt(G.length-E-1);)C--,E++;p[p.length-1]=$.slice(0,$.length-E).replace(/^\u200b+/,""),p[0]=p[0].slice(C).replace(/\u200b+$/,"");var ee=P(a,C),V=P(u,T.length?f(T).length-E:0);if(p.length>1||p[0]||oe(ee,V))return Or(e.doc,p,ee,V,"+input"),!0},ve.prototype.ensurePolled=function(){this.forceCompositionEnd()},ve.prototype.reset=function(){this.forceCompositionEnd()},ve.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ve.prototype.readFromDOMSoon=function(){var e=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80))},ve.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&ot(this.cm,function(){return rt(e.cm)})},ve.prototype.setUneditable=function(e){e.contentEditable="false"},ve.prototype.onKeyPress=function(e){e.charCode==0||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Re(this.cm,vl)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0))},ve.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},ve.prototype.onContextMenu=function(){},ve.prototype.resetPosition=function(){},ve.prototype.needsContentAttribute=!0;function Eo(e,t){var i=Pn(e,t.line);if(!i||i.hidden)return null;var r=j(e.doc,t.line),n=oa(i,r,t.line),l=ge(r,e.doc.direction),a="left";if(l){var o=Ne(l,t.ch);a=o%2?"right":"left"}var s=fa(n.map,t.ch,a);return s.offset=s.collapse=="right"?s.end:s.start,s}function of(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hr(e,t){return t&&(e.bad=!0),e}function sf(e,t,i,r,n){var l="",a=!1,o=e.doc.lineSeparator(),s=!1;function u(C){return function(E){return E.id==C}}function g(){a&&(l+=o,s&&(l+=o),a=s=!1)}function p(C){C&&(g(),l+=C)}function T(C){if(C.nodeType==1){var E=C.getAttribute("cm-text");if(E){p(E);return}var W=C.getAttribute("cm-marker"),B;if(W){var U=e.findMarks(P(r,0),P(n+1,0),u(+W));U.length&&(B=U[0].find(0))&&p(Vt(e.doc,B.from,B.to).join(o));return}if(C.getAttribute("contenteditable")=="false")return;var $=/^(pre|div|p|li|table|br)$/i.test(C.nodeName);if(!/^br$/i.test(C.nodeName)&&C.textContent.length==0)return;$&&g();for(var G=0;G=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),te(n,"paste",function(a){xe(r,a)||Mo(a,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())});function l(a){if(!xe(r,a)){if(r.somethingSelected())on({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var o=Do(r);on({lineWise:!0,text:o.text}),a.type=="cut"?r.setSelections(o.ranges,null,ht):(i.prevInput="",n.value=o.text.join(` +`),Zt(n))}else return;a.type=="cut"&&(r.state.cutIncoming=+new Date)}}te(n,"cut",l),te(n,"copy",l),te(e.scroller,"paste",function(a){if(!(Nt(e,a)||xe(r,a))){if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var o=new Event("paste");o.clipboardData=a.clipboardData,n.dispatchEvent(o)}}),te(e.lineSpace,"selectstart",function(a){Nt(e,a)||Oe(a)}),te(n,"compositionstart",function(){var a=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:a,range:r.markText(a,r.getCursor("to"),{className:"CodeMirror-composing"})}}),te(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},_e.prototype.createField=function(e){this.wrapper=No(),this.textarea=this.wrapper.firstChild;var t=this.cm.options;yl(this.textarea,t.spellcheck,t.autocorrect,t.autocapitalize)},_e.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},_e.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=Ca(e);if(e.options.moveInputWithCursor){var n=vt(e,i.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+a.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+a.left-l.left))}return r},_e.prototype.showSelection=function(e){var t=this.cm,i=t.display;De(i.cursorDiv,e.cursors),De(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},_e.prototype.reset=function(e){if(!(this.contextMenuPending||this.composing&&e)){var t=this.cm;if(this.resetting=!0,t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Zt(this.textarea),d&&v>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",d&&v>=9&&(this.hasSelection=null));this.resetting=!1}},_e.prototype.getField=function(){return this.textarea},_e.prototype.supportsTouch=function(){return!1},_e.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!ie||tt(Pe(this.textarea))!=this.textarea))try{this.textarea.focus()}catch{}},_e.prototype.blur=function(){this.textarea.blur()},_e.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},_e.prototype.receivedFocus=function(){this.slowPoll()},_e.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},_e.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},_e.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||this.resetting||!t.state.focused||os(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(d&&v>=9&&this.hasSelection===n||ne&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var l=n.charCodeAt(0);if(l==8203&&!r&&(r="​"),l==8666)return this.reset(),this.cm.execCommand("undo")}for(var a=0,o=Math.min(r.length,n.length);a1e3||n.indexOf(` +`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},_e.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},_e.prototype.onKeyPress=function(){d&&v>=9&&(this.hasSelection=null),this.fastPoll()},_e.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var l=ir(i,e),a=r.scroller.scrollTop;if(!l||F)return;var o=i.options.resetSelectionOnContextMenu;o&&i.doc.sel.contains(l)==-1&&Re(i,Qe)(i.doc,Ut(l),ht);var s=n.style.cssText,u=t.wrapper.style.cssText,g=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px; top: `+(e.clientY-g.top-5)+"px; left: "+(e.clientX-g.left-5)+`px; z-index: 1000; background: `+(d?"rgba(255, 255, 255, .05)":"transparent")+`; - outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var p;m&&(p=n.ownerDocument.defaultView.scrollY),r.input.focus(),m&&n.ownerDocument.defaultView.scrollTo(null,p),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=C,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function L(){if(n.selectionStart!=null){var W=i.somethingSelected(),B="​"+(W?n.value:"");n.value="⇚",n.value=B,t.prevInput=W?"":"​",n.selectionStart=1,n.selectionEnd=B.length,r.selForContextMenu=i.doc.sel}}function C(){if(t.contextMenuPending==C&&(t.contextMenuPending=!1,t.wrapper.style.cssText=u,n.style.cssText=s,d&&v<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=a),n.selectionStart!=null)){(!d||d&&v<9)&&L();var W=0,B=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="​"?Re(i,Qa)(i):W++<10?r.detectingSelectAll=setTimeout(B,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(B,200)}}if(d&&v>=9&&L(),Ie){$r(e);var E=function(){je(window,"mouseup",E),setTimeout(C,20)};te(window,"mouseup",E)}else setTimeout(C,50)},_e.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},_e.prototype.setUneditable=function(){},_e.prototype.needsContentAttribute=!1;function ff(e,t){if(t=t?dt(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=tt(Pe(e));t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=o.getValue()}var n;if(e.form&&(te(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var l=e.form;n=l.submit;try{var a=l.submit=function(){r(),l.submit=n,l.submit(),l.submit=a}}catch{}}t.finishInit=function(s){s.save=r,s.getTextArea=function(){return e},s.toTextArea=function(){s.toTextArea=isNaN,r(),e.parentNode.removeChild(s.getWrapperElement()),e.style.display="",e.form&&(je(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var o=Le(function(s){return e.parentNode.insertBefore(s,e.nextSibling)},t);return o}function hf(e){e.off=je,e.on=te,e.wheelEventPixels=yu,e.Doc=it,e.splitLines=mn,e.countColumn=Ze,e.findColumn=Gr,e.isWordChar=F,e.Pass=Ht,e.signal=Te,e.Line=Cr,e.changeEnd=Gt,e.scrollbarModel=xa,e.Pos=P,e.cmpPos=oe,e.modes=wn,e.mimeModes=br,e.resolveMode=Di,e.getMode=Cn,e.modeExtensions=wr,e.extendMode=cs,e.copyState=jt,e.startState=Ol,e.innerMode=Sn,e.commands=pi,e.keyMap=Et,e.keyName=co,e.isModifierKey=fo,e.lookupKey=Wr,e.normalizeKeyMap=Bu,e.StringStream=Ee,e.SharedTextMarker=ci,e.TextMarker=$t,e.LineWidget=hi,e.e_preventDefault=Oe,e.e_stopPropagation=Dl,e.e_stop=$r,e.addClass=xt,e.contains=ct,e.rmClass=Me,e.keyNames=Xt}tf(Le),af(Le);var cf="iter insert remove copy getEditor constructor".split(" ");for(var un in it.prototype)it.prototype.hasOwnProperty(un)&&Se(cf,un)<0&&(Le.prototype[un]=function(e){return function(){return e.apply(this.doc,arguments)}}(it.prototype[un]));return Mt(it),Le.inputStyles={textarea:_e,contenteditable:ve},Le.defineMode=function(e){!Le.defaults.mode&&e!="null"&&(Le.defaults.mode=e),fs.apply(this,arguments)},Le.defineMIME=hs,Le.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Le.defineMIME("text/plain","null"),Le.defineExtension=function(e,t){Le.prototype[e]=t},Le.defineDocExtension=function(e,t){it.prototype[e]=t},Le.fromTextArea=ff,hf(Le),Le.version="5.65.16",Le})}(wl)),wl.exports}var yf=qo();const mf=vf(yf);var Fo={exports:{}},Io;function bf(){return Io||(Io=1,function(N,b){(function(T){T(qo())})(function(T){var O=T.Pos,A="http://www.w3.org/2000/svg";function G(f,y){this.mv=f,this.type=y,this.classes=y=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}G.prototype={constructor:G,init:function(f,y,S){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=T(f,dt({value:y,readOnly:!this.mv.options.allowEditingOriginals},dt(S))),this.mv.options.connect=="align"&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new Ht(this.edit)),this.orig.state.trackAlignable=new Ht(this.orig)),this.lockButton.title=this.edit.phrase("Toggle locked scrolling"),this.lockButton.setAttribute("aria-label",this.lockButton.title),this.orig.state.diffViews=[this];var k=S.chunkClassLocation||"background";Object.prototype.toString.call(k)!="[object Array]"&&(k=[k]),this.classes.classLocation=k,this.diff=kt(De(y),De(S.value),this.mv.options.ignoreWhitespace),this.chunks=bt(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=S.showDifferences!==!1},registerEvents:function(f){this.forceUpdate=d(this),M(this,!0,!1),v(this,f)},setShowDifferences:function(f){f=f!==!1,f!=this.showDifferences&&(this.showDifferences=f,this.forceUpdate("full"))}};function h(f){f.diffOutOfDate&&(f.diff=kt(f.orig.getValue(),f.edit.getValue(),f.mv.options.ignoreWhitespace),f.chunks=bt(f.diff),f.diffOutOfDate=!1,T.signal(f.edit,"updateDiff",f.diff))}var c=!1;function d(f){var y={from:0,to:0,marked:[]},S={from:0,to:0,marked:[]},k,x=!1;function _(ue){c=!0,x=!1,ue=="full"&&(f.svg&&At(f.svg),f.copyButtons&&At(f.copyButtons),I(f.edit,y.marked,f.classes),I(f.orig,S.marked,f.classes),y.from=y.to=S.from=S.to=0),h(f),f.showDifferences&&(K(f.edit,f.diff,y,DIFF_INSERT,f.classes),K(f.orig,f.diff,S,DIFF_DELETE,f.classes)),f.mv.options.connect=="align"&&re(f),Z(f),f.needsScrollSync!=null&&m(f,f.needsScrollSync),c=!1}function F(ue){c||(f.dealigned=!0,H(ue))}function H(ue){c||x||(clearTimeout(k),ue===!0&&(x=!0),k=setTimeout(_,ue===!0?20:250))}function R(ue,ce){f.diffOutOfDate||(f.diffOutOfDate=!0,y.from=y.to=S.from=S.to=0),F(ce.text.length-1!=ce.to.line-ce.from.line)}function ae(){f.diffOutOfDate=!0,f.dealigned=!0,_("full")}return f.edit.on("change",R),f.orig.on("change",R),f.edit.on("swapDoc",ae),f.orig.on("swapDoc",ae),f.mv.options.connect=="align"&&(T.on(f.edit.state.trackAlignable,"realign",F),T.on(f.orig.state.trackAlignable,"realign",F)),f.edit.on("viewportChange",function(){H(!1)}),f.orig.on("viewportChange",function(){H(!1)}),_(),_}function v(f,y){f.edit.on("scroll",function(){m(f,!0)&&Z(f)}),f.orig.on("scroll",function(){m(f,!1)&&Z(f),y&&m(y,!0)&&Z(y)})}function m(f,y){if(f.diffOutOfDate)return f.lockScroll&&f.needsScrollSync==null&&(f.needsScrollSync=y),!1;if(f.needsScrollSync=null,!f.lockScroll)return!0;var S,k,x=+new Date;if(y?(S=f.edit,k=f.orig):(S=f.orig,k=f.edit),S.state.scrollSetBy==f&&(S.state.scrollSetAt||0)+250>x)return!1;var _=S.getScrollInfo();if(f.mv.options.connect=="align")Ce=_.top;else{var F=.5*_.clientHeight,H=_.top+F,R=S.lineAtHeight(H,"local"),ae=xt(f.chunks,R,y),ue=w(S,y?ae.edit:ae.orig),ce=w(k,y?ae.orig:ae.edit),me=(H-ue.top)/(ue.bot-ue.top),Ce=ce.top-F+me*(ce.bot-ce.top),be,Ne;if(Ce>_.top&&(Ne=_.top/F)<1)Ce=Ce*Ne+_.top*(1-Ne);else if((be=_.height-_.clientHeight-_.top)be&&(Ne=be/F)<1&&(Ce=Ce*Ne+(ut.height-ut.clientHeight-be)*(1-Ne))}}return k.scrollTo(_.left,Ce),k.state.scrollSetAt=x,k.state.scrollSetBy=f,!0}function w(f,y){var S=y.after;return S==null&&(S=f.lastLine()+1),{top:f.heightAtLine(y.before||0,"local"),bot:f.heightAtLine(S,"local")}}function M(f,y,S){f.lockScroll=y,y&&S!=!1&&m(f,DIFF_INSERT)&&Z(f),(y?T.addClass:T.rmClass)(f.lockButton,"CodeMirror-merge-scrolllock-enabled")}function D(f,y,S){for(var k=S.classLocation,x=0;x20||S.from-_.to>20?(I(f,S.marked,x),q(f,y,k,S.marked,_.from,_.to,x),S.from=_.from,S.to=_.to):(_.fromS.to&&(q(f,y,k,S.marked,S.to,_.to,x),S.to=_.to))})}function Y(f,y,S,k,x,_){for(var F=S.classLocation,H=f.getLineHandle(y),R=0;RKr&&(Ce&&(ce(me,Kr),Ce=!1),me=te)}else if(Ce=!0,ut==S){var mr=Ze(H,ge,!0),je=Ur(R,H),Te=ht(ae,mr);Jt(je,Te)||k.push(f.markText(je,Te,{className:ue})),H=mr}}Ce&&ce(me,H.line+1)}function Z(f){if(f.showDifferences){if(f.svg){At(f.svg);var y=f.gap.offsetWidth;pr(f.svg,"width",y,"height",f.gap.offsetHeight)}f.copyButtons&&At(f.copyButtons);for(var S=f.edit.getViewport(),k=f.orig.getViewport(),x=f.mv.wrap.getBoundingClientRect().top,_=x-f.edit.getScrollerElement().getBoundingClientRect().top+f.edit.getScrollInfo().top,F=x-f.orig.getScrollerElement().getBoundingClientRect().top+f.orig.getScrollInfo().top,H=0;H=S.from&&R.origFrom<=k.to&&R.origTo>=k.from&&Ie(f,R,F,_,y)}}}function le(f,y){for(var S=0,k=0,x=0;xf&&_.editFrom<=f)return null;if(_.editFrom>f)break;S=_.editTo,k=_.origTo}return k+(f-S)}function ie(f,y,S){for(var k=f.state.trackAlignable,x=f.firstLine(),_=0,F=[],H=0;;H++){for(var R=y[H],ae=R?S?R.origFrom:R.editFrom:1e9;_ce){_++,x--;continue e}if(me.editTo>ue){if(me.editFrom<=ue)continue e;break}H+=me.origTo-me.origFrom-(me.editTo-me.editFrom),F++}if(ue==ce-H)R[k]=ce,_++;else if(ue1&&k.push(ye(f[F],S[F],R))}}function ye(f,y,S){var k=!0;y>f.lastLine()&&(y--,k=!1);var x=document.createElement("div");return x.className="CodeMirror-merge-spacer",x.style.height=S+"px",x.style.minWidth="1px",f.addLineWidget(y,x,{height:S,above:k,mergeSpacer:!0,handleMouseEvents:!0})}function Ie(f,y,S,k,x){var _=f.type=="left",F=f.orig.heightAtLine(y.origFrom,"local",!0)-S;if(f.svg){var H=F,R=f.edit.heightAtLine(y.editFrom,"local",!0)-k;if(_){var ae=H;H=R,R=ae}var ue=f.orig.heightAtLine(y.origTo,"local",!0)-S,ce=f.edit.heightAtLine(y.editTo,"local",!0)-k;if(_){var ae=ue;ue=ce,ce=ae}var me=" C "+x/2+" "+R+" "+x/2+" "+H+" "+(x+2)+" "+H,Ce=" C "+x/2+" "+ue+" "+x/2+" "+ce+" -1 "+ce;pr(f.svg.appendChild(document.createElementNS(A,"path")),"d","M -1 "+R+me+" L "+(x+2)+" "+ue+Ce+" z","class",f.classes.connect)}if(f.copyButtons){var be=f.copyButtons.appendChild(Pe("div",f.type=="left"?"⇝":"⇜","CodeMirror-merge-copy")),Ne=f.mv.options.allowEditingOriginals;if(be.title=f.edit.phrase(Ne?"Push to left":"Revert chunk"),be.chunk=y,be.style.top=(y.origTo>y.origFrom?F:f.edit.heightAtLine(y.editFrom,"local")-k)+"px",be.setAttribute("role","button"),be.setAttribute("tabindex","0"),be.setAttribute("aria-label",be.title),Ne){var ut=f.edit.heightAtLine(y.editFrom,"local")-k,ge=f.copyButtons.appendChild(Pe("div",f.type=="right"?"⇝":"⇜","CodeMirror-merge-copy-reverse"));ge.title="Push to right",ge.chunk={editFrom:y.origFrom,editTo:y.origTo,origFrom:y.editFrom,origTo:y.editTo},ge.style.top=ut+"px",f.type=="right"?ge.style.left="2px":ge.style.right="2px",ge.setAttribute("role","button"),ge.setAttribute("tabindex","0"),ge.setAttribute("aria-label",ge.title)}}}function Ke(f,y,S,k){if(!f.diffOutOfDate){var x=k.origTo>S.lastLine()?O(k.origFrom-1):O(k.origFrom,0),_=O(k.origTo,0),F=k.editTo>y.lastLine()?O(k.editFrom-1):O(k.editFrom,0),H=O(k.editTo,0),R=f.mv.options.revertChunk;R?R(f.mv,S,x,_,y,F,H):y.replaceRange(S.getRange(x,_),F,H)}}var Me=T.MergeView=function(f,y){if(!(this instanceof Me))return new Me(f,y);this.options=y;var S=y.origLeft,k=y.origRight==null?y.orig:y.origRight,x=S!=null,_=k!=null,F=1+(x?1:0)+(_?1:0),H=[],R=this.left=null,ae=this.right=null,ue=this;if(x){R=this.left=new G(this,"left");var ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");H.push(ce),H.push(qe(R))}var me=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(H.push(me),_){ae=this.right=new G(this,"right"),H.push(qe(ae));var Ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");H.push(Ce)}(_?Ce:me).className+=" CodeMirror-merge-pane-rightmost",H.push(Pe("div",null,null,"height: 0; clear: both;"));var be=this.wrap=f.appendChild(Pe("div",H,"CodeMirror-merge CodeMirror-merge-"+F+"pane"));this.edit=T(me,dt(y)),R&&R.init(ce,S,y),ae&&ae.init(Ce,k,y),y.collapseIdentical&&this.editor().operation(function(){It(ue,y.collapseIdentical)}),y.connect=="align"&&(this.aligners=[],re(this.left||this.right,!0)),R&&R.registerEvents(ae),ae&&ae.registerEvents(R);var Ne=function(){R&&Z(R),ae&&Z(ae)};T.on(window,"resize",Ne);var ut=setInterval(function(){for(var ge=be.parentNode;ge&&ge!=document.body;ge=ge.parentNode);ge||(clearInterval(ut),T.off(window,"resize",Ne))},5e3)};function qe(f){var y=f.lockButton=Pe("div",null,"CodeMirror-merge-scrolllock");y.setAttribute("role","button"),y.setAttribute("tabindex","0");var S=Pe("div",[y],"CodeMirror-merge-scrolllock-wrap");T.on(y,"click",function(){M(f,!f.lockScroll)}),T.on(y,"keyup",function(F){(F.key==="Enter"||F.code==="Space")&&M(f,!f.lockScroll)});var k=[S];if(f.mv.options.revertButtons!==!1){f.copyButtons=Pe("div",null,"CodeMirror-merge-copybuttons-"+f.type);var x=function(F){var H=F.target||F.srcElement;if(H.chunk){if(H.className=="CodeMirror-merge-copy-reverse"){Ke(f,f.orig,f.edit,H.chunk);return}Ke(f,f.edit,f.orig,H.chunk)}};T.on(f.copyButtons,"click",x),T.on(f.copyButtons,"keyup",function(F){(F.key==="Enter"||F.code==="Space")&&x(F)}),k.unshift(f.copyButtons)}if(f.mv.options.connect!="align"){var _=document.createElementNS&&document.createElementNS(A,"svg");_&&!_.createSVGRect&&(_=null),f.svg=_,_&&k.push(_)}return f.gap=Pe("div",k,"CodeMirror-merge-gap")}Me.prototype={constructor:Me,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(f){this.right&&this.right.setShowDifferences(f),this.left&&this.left.setShowDifferences(f)},rightChunks:function(){if(this.right)return h(this.right),this.right.chunks},leftChunks:function(){if(this.left)return h(this.left),this.left.chunks}};function De(f){return typeof f=="string"?f:f.getValue()}var Q;function kt(f,y,S){Q||(Q=new diff_match_patch);for(var k=Q.diff_main(f,y),x=0;xue&&(F&&y.push({origFrom:k,origTo:ce,editFrom:S,editTo:ue}),S=Ce,k=be)}else Ze(R==DIFF_INSERT?x:_,H[1])}return(S<=x.line||k<=_.line)&&y.push({origFrom:k,origTo:_.line+1,editFrom:S,editTo:x.line+1}),y}function ct(f,y){if(y==f.length-1)return!0;var S=f[y+1][1];return S.length==1&&y1||y==f.length-3)&&S.charCodeAt(0)==10)}function tt(f,y){if(y==0)return!0;var S=f[y-1][1];return S.charCodeAt(S.length-1)!=10?!1:y==1?!0:(S=f[y-2][1],S.charCodeAt(S.length-1)==10)}function xt(f,y,S){for(var k,x,_,F,H=0;Hy?(x=R.editFrom,F=R.origFrom):ue>y&&(x=R.editTo,F=R.origTo)),ue<=y?(k=R.editTo,_=R.origTo):ae<=y&&(k=R.editFrom,_=R.origFrom)}return{edit:{before:k,after:x},orig:{before:_,after:F}}}function zr(f,y,S){f.addLineClass(y,"wrap","CodeMirror-merge-collapsed-line");var k=document.createElement("span");k.className="CodeMirror-merge-collapsed-widget",k.title=f.phrase("Identical text collapsed. Click to expand.");var x=f.markText(O(y,0),O(S-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:k,clearOnEnter:!0});function _(){x.clear(),f.removeLineClass(y,"wrap","CodeMirror-merge-collapsed-line")}return x.explicitlyCleared&&_(),T.on(k,"click",_),x.on("clear",_),T.on(k,"click",_),{mark:x,clear:_}}function Zt(f,y){var S=[];function k(){for(var H=0;H=0&&Hy){var ue=[{line:R,cm:k}];f.left&&ue.push({line:le(R,f.left.chunks),cm:f.left.orig}),f.right&&ue.push({line:le(R,f.right.chunks),cm:f.right.orig});var ce=Zt(ae,ue);f.options.onCollapse&&f.options.onCollapse(f,R,ae,ce)}}}function Pe(f,y,S,k){var x=document.createElement(f);if(S&&(x.className=S),k&&(x.style.cssText=k),typeof y=="string")x.appendChild(document.createTextNode(y));else if(y)for(var _=0;_0;--y)f.removeChild(f.firstChild)}function pr(f){for(var y=1;y0)break}this.signal(),this.alignable.splice(S,0,f,y)},find:function(f){for(var y=0;y-1){var ae=this.alignable[_+1];ae==Se?this.alignable.splice(_,2):this.alignable[_+1]=ae&~Se}F>-1&&S&&this.set(f+S,Se)}};function ht(f,y){return(f.line-y.line||f.ch-y.ch)<0?f:y}function Ur(f,y){return(f.line-y.line||f.ch-y.ch)>0?f:y}function Jt(f,y){return f.line==y.line&&f.ch==y.ch}function Gr(f,y,S){for(var k=f.length-1;k>=0;k--){var x=f[k],_=(S?x.origTo:x.editTo)-1;if(_y)return _}}function yr(f,y){var S=null,k=f.state.diffViews,x=f.getCursor().line;if(k)for(var _=0;_S:R"u"&&(d=!0);var v=d,m=this.diff_commonPrefix(h,c),w=h.substring(0,m);h=h.substring(m),c=c.substring(m),m=this.diff_commonSuffix(h,c);var M=h.substring(h.length-m);h=h.substring(0,h.length-m),c=c.substring(0,c.length-m);var D=this.diff_compute(h,c,v);return w&&D.unshift([A,w]),M&&D.push([A,M]),this.diff_cleanupMerge(D),D},b.prototype.diff_compute=function(h,c,d){var v;if(!h)return[[O,c]];if(!c)return[[T,h]];var m=h.length>c.length?h:c,w=h.length>c.length?c:h,M=m.indexOf(w);if(M!=-1)return v=[[O,m.substring(0,M)],[A,w],[O,m.substring(M+w.length)]],h.length>c.length&&(v[0][0]=v[2][0]=T),v;m=w=null;var D=this.diff_halfMatch(h,c);if(D){var I=D[0],K=D[1],Y=D[2],q=D[3],Z=D[4],le=this.diff_main(I,Y,d),ie=this.diff_main(K,q,d);return le.concat([[A,Z]],ie)}d&&(h.length<100||c.length<100)&&(d=!1);var ne;if(d){var he=this.diff_linesToChars(h,c);h=he[0],c=he[1],ne=he[2]}if(v=this.diff_map(h,c),v||(v=[[T,h],[O,c]]),d){this.diff_charsToLines(v,ne),this.diff_cleanupSemantic(v),v.push([A,""]);for(var re=0,J=0,ye=0,Ie="",Ke="";re=1&&ye>=1){var he=this.diff_main(Ie,Ke,!1);v.splice(re-J-ye,J+ye),re=re-J-ye;for(var Me=he.length-1;Me>=0;Me--)v.splice(re,0,he[Me]);re=re+he.length}ye=0,J=0,Ie="",Ke="";break}re++}v.pop()}return v},b.prototype.diff_linesToChars=function(h,c){var d=[],v={};d[0]="";function m(D){for(var I="",K=0,Y=-1,q=d.length;Y0&&new Date().getTime()>d)return null;D[re]={};for(var J=-re;J<=re;J+=2){for(J==-re||J!=re&&K[J-1]=0;D--)for(;;)if(h[D][m-1+","+w]!==void 0){m--,M===T?v[0][1]=c.charAt(m)+v[0][1]:v.unshift([T,c.charAt(m)]),M=T;break}else if(h[D][m+","+(w-1)]!==void 0){w--,M===O?v[0][1]=d.charAt(w)+v[0][1]:v.unshift([O,d.charAt(w)]),M=O;break}else{if(m--,w--,c.charAt(m)!=d.charAt(w))throw new Error("No diagonal. Can't happen. (diff_path1)");M===A?v[0][1]=c.charAt(m)+v[0][1]:v.unshift([A,c.charAt(m)]),M=A}return v},b.prototype.diff_path2=function(h,c,d){for(var v=[],m=0,w=c.length,M=d.length,D=null,I=h.length-2;I>=0;I--)for(;;)if(h[I][w-1+","+M]!==void 0){w--,D===T?v[m-1][1]+=c.charAt(c.length-w-1):v[m++]=[T,c.charAt(c.length-w-1)],D=T;break}else if(h[I][w+","+(M-1)]!==void 0){M--,D===O?v[m-1][1]+=d.charAt(d.length-M-1):v[m++]=[O,d.charAt(d.length-M-1)],D=O;break}else{if(w--,M--,c.charAt(c.length-w-1)!=d.charAt(d.length-M-1))throw new Error("No diagonal. Can't happen. (diff_path2)");D===A?v[m-1][1]+=c.charAt(c.length-w-1):v[m++]=[A,c.charAt(c.length-w-1)],D=A}return v},b.prototype.diff_commonPrefix=function(h,c){if(!h||!c||h.charAt(0)!=c.charAt(0))return 0;for(var d=0,v=Math.min(h.length,c.length),m=v,w=0;dc.length?h:c,v=h.length>c.length?c:h;if(d.length<10||v.length<1)return null;var m=this;function w(ie,ne,he){for(var re=ie.substring(he,he+Math.floor(ie.length/4)),J=-1,ye="",Ie,Ke,Me,qe;(J=ne.indexOf(re,J+1))!=-1;){var De=m.diff_commonPrefix(ie.substring(he),ne.substring(J)),Q=m.diff_commonSuffix(ie.substring(0,he),ne.substring(0,J));ye.length=ie.length/2?[Ie,Ke,Me,qe,ye]:null}var M=w(d,v,Math.ceil(d.length/4)),D=w(d,v,Math.ceil(d.length/2)),I;if(!M&&!D)return null;D?M?I=M[4].length>D[4].length?M:D:I=D:I=M;var K,Y,q,Z;h.length>c.length?(K=I[0],Y=I[1],q=I[2],Z=I[3]):(q=I[0],Z=I[1],K=I[2],Y=I[3]);var le=I[4];return[K,Y,q,Z,le]},b.prototype.diff_cleanupSemantic=function(h){for(var c=!1,d=[],v=0,m=null,w=0,M=0,D=0;w0?d[v-1]:-1,M=0,D=0,m=null,c=!0)),w++;c&&this.diff_cleanupMerge(h),this.diff_cleanupSemanticLossless(h)},b.prototype.diff_cleanupSemanticLossless=function(h){var c=/[^a-zA-Z0-9]/,d=/\s/,v=/[\r\n]/,m=/\n\r?\n$/,w=/^\r?\n\r?\n/;function M(J,ye){if(!J||!ye)return 5;var Ie=0;return(J.charAt(J.length-1).match(c)||ye.charAt(0).match(c))&&(Ie++,(J.charAt(J.length-1).match(d)||ye.charAt(0).match(d))&&(Ie++,(J.charAt(J.length-1).match(v)||ye.charAt(0).match(v))&&(Ie++,(J.match(m)||ye.match(w))&&Ie++))),Ie}for(var D=1;D=he&&(he=re,le=I,ie=K,ne=Y)}h[D-1][1]!=le&&(le?h[D-1][1]=le:(h.splice(D-1,1),D--),h[D][1]=ie,ne?h[D+1][1]=ne:(h.splice(D+1,1),D--))}D++}},b.prototype.diff_cleanupEfficiency=function(h){for(var c=!1,d=[],v=0,m="",w=0,M=!1,D=!1,I=!1,K=!1;w0?d[v-1]:-1,I=K=!1),c=!0)),w++;c&&this.diff_cleanupMerge(h)},b.prototype.diff_cleanupMerge=function(h){h.push([A,""]);for(var c=0,d=0,v=0,m="",w="",M;c0&&h[c-d-v-1][0]==A?h[c-d-v-1][1]+=w.substring(0,M):(h.splice(0,0,[A,w.substring(0,M)]),c++),w=w.substring(M),m=m.substring(M)),M=this.diff_commonSuffix(w,m),M!==0&&(h[c][1]=w.substring(w.length-M)+h[c][1],w=w.substring(0,w.length-M),m=m.substring(0,m.length-M))),d===0?h.splice(c-d-v,d+v,[O,w]):v===0?h.splice(c-d-v,d+v,[T,m]):h.splice(c-d-v,d+v,[T,m],[O,w]),c=c-d-v+(d?1:0)+(v?1:0)+1):c!==0&&h[c-1][0]==A?(h[c-1][1]+=h[c][1],h.splice(c,1)):c++,v=0,d=0,m="",w="";break}h[h.length-1][1]===""&&h.pop();var D=!1;for(c=1;cc));M++)m=d,w=v;return h.length!=M&&h[M][0]===T?w:w+(c-m)},b.prototype.diff_prettyHtml=function(h){for(var c=[],d=0,v=0;v/g,">").replace(/\n/g,"¶
");switch(m){case O:c[v]=''+M+"";break;case T:c[v]=''+M+"";break;case A:c[v]=''+M+"";break}m!==T&&(d+=w.length)}return c.join("")},b.prototype.diff_text1=function(h){for(var c=[],d=0;dthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var v=this.match_alphabet(c),m=this;function w(Ie,Ke){var Me=Ie/c.length,qe=Math.abs(d-Ke);return m.Match_Distance?Me+qe/m.Match_Distance:qe?1:Me}var M=this.Match_Threshold,D=h.indexOf(c,d);D!=-1&&(M=Math.min(w(0,D),M),D=h.lastIndexOf(c,d+c.length),D!=-1&&(M=Math.min(w(0,D),M)));var I=1<=ie;re--){var J=v[h.charAt(re-1)];if(le===0?he[re]=(he[re+1]<<1|1)&J:he[re]=(he[re+1]<<1|1)&J|((Z[re+1]|Z[re])<<1|1)|Z[re+1],he[re]&I){var ye=w(le,re-1);if(ye<=M)if(M=ye,D=re-1,D>d)ie=Math.max(1,2*d-D);else break}}if(w(le+1,d)>M)break;Z=he}return D},b.prototype.match_alphabet=function(h){for(var c={},d=0;d"u")v=h,m=this.diff_main(v,c,!0),m.length>2&&(this.diff_cleanupSemantic(m),this.diff_cleanupEfficiency(m));else if(h&&typeof h=="object"&&typeof c>"u"&&typeof d>"u")m=h,v=this.diff_text1(m);else if(typeof h=="string"&&c&&typeof c=="object"&&typeof d>"u")v=h,m=c;else if(typeof h=="string"&&typeof c=="string"&&d&&typeof d=="object")v=h,m=d;else throw new Error("Unknown call format to patch_make.");if(m.length===0)return[];for(var w=[],M=new G,D=0,I=0,K=0,Y=v,q=v,Z=0;Z=2*this.Patch_Margin&&D&&(this.patch_addContext(M,Y),w.push(M),M=new G,D=0,Y=q,I=K);break}le!==O&&(I+=ie.length),le!==T&&(K+=ie.length)}return D&&(this.patch_addContext(M,Y),w.push(M)),w},b.prototype.patch_deepCopy=function(h){for(var c=[],d=0;dthis.Match_MaxBits?(I=this.match_main(c,D.substring(0,this.Match_MaxBits),M),I!=-1&&(K=this.match_main(c,D.substring(D.length-this.Match_MaxBits),M+D.length-this.Match_MaxBits),(K==-1||I>=K)&&(I=-1))):I=this.match_main(c,D,M),I==-1)m[w]=!1,v-=h[w].length2-h[w].length1;else{m[w]=!0,v=I-M;var Y;if(K==-1?Y=c.substring(I,I+D.length):Y=c.substring(I,K+this.Match_MaxBits),D==Y)c=c.substring(0,I)+this.diff_text2(h[w].diffs)+c.substring(I+D.length);else{var q=this.diff_main(D,Y,!1);if(D.length>this.Match_MaxBits&&this.diff_levenshtein(q)/D.length>this.Patch_DeleteThreshold)m[w]=!1;else{this.diff_cleanupSemanticLossless(q);for(var Z=0,le,ie=0;iew[0][1].length){var M=c-w[0][1].length;w[0][1]=d.substring(w[0][1].length)+w[0][1],m.start1-=M,m.start2-=M,m.length1+=M,m.length2+=M}if(m=h[h.length-1],w=m.diffs,w.length==0||w[w.length-1][0]!=A)w.push([A,d]),m.length1+=c,m.length2+=c;else if(c>w[w.length-1][1].length){var M=c-w[w.length-1][1].length;w[w.length-1][1]+=d.substring(0,M),m.length1+=M,m.length2+=M}return d},b.prototype.patch_splitMax=function(h){for(var c=0;cthis.Match_MaxBits){var d=h[c];h.splice(c--,1);for(var v=this.Match_MaxBits,m=d.start1,w=d.start2,M="";d.diffs.length!==0;){var D=new G,I=!0;for(D.start1=m-M.length,D.start2=w-M.length,M!==""&&(D.length1=D.length2=M.length,D.diffs.push([A,M]));d.diffs.length!==0&&D.length12*v?(D.length1+=Y.length,m+=Y.length,I=!1,D.diffs.push([K,Y]),d.diffs.shift()):(Y=Y.substring(0,v-D.length1-this.Patch_Margin),D.length1+=Y.length,m+=Y.length,K===A?(D.length2+=Y.length,w+=Y.length):I=!1,D.diffs.push([K,Y]),Y==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(Y.length))}M=this.diff_text2(D.diffs),M=M.substring(M.length-this.Patch_Margin);var q=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);q!==""&&(D.length1+=q.length,D.length2+=q.length,D.diffs.length!==0&&D.diffs[D.diffs.length-1][0]===A?D.diffs[D.diffs.length-1][1]+=q:D.diffs.push([A,q])),I||h.splice(++c,0,D)}}},b.prototype.patch_toText=function(h){for(var c=[],d=0;d0&&t.prevInput=="​"?Re(i,Ja)(i):W++<10?r.detectingSelectAll=setTimeout(B,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(B,200)}}if(d&&v>=9&&T(),Fe){$r(e);var E=function(){je(window,"mouseup",E),setTimeout(C,20)};te(window,"mouseup",E)}else setTimeout(C,50)},_e.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},_e.prototype.setUneditable=function(){},_e.prototype.needsContentAttribute=!1;function ff(e,t){if(t=t?dt(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=tt(Pe(e));t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=o.getValue()}var n;if(e.form&&(te(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var l=e.form;n=l.submit;try{var a=l.submit=function(){r(),l.submit=n,l.submit(),l.submit=a}}catch{}}t.finishInit=function(s){s.save=r,s.getTextArea=function(){return e},s.toTextArea=function(){s.toTextArea=isNaN,r(),e.parentNode.removeChild(s.getWrapperElement()),e.style.display="",e.form&&(je(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var o=Le(function(s){return e.parentNode.insertBefore(s,e.nextSibling)},t);return o}function hf(e){e.off=je,e.on=te,e.wheelEventPixels=yu,e.Doc=it,e.splitLines=bn,e.countColumn=Ze,e.findColumn=Gr,e.isWordChar=I,e.Pass=Ht,e.signal=Te,e.Line=Cr,e.changeEnd=Gt,e.scrollbarModel=Aa,e.Pos=P,e.cmpPos=oe,e.modes=Cn,e.mimeModes=br,e.resolveMode=Di,e.getMode=Sn,e.modeExtensions=wr,e.extendMode=cs,e.copyState=jt,e.startState=El,e.innerMode=Ln,e.commands=pi,e.keyMap=Et,e.keyName=go,e.isModifierKey=ho,e.lookupKey=Wr,e.normalizeKeyMap=Bu,e.StringStream=Ee,e.SharedTextMarker=ci,e.TextMarker=$t,e.LineWidget=hi,e.e_preventDefault=Oe,e.e_stopPropagation=Nl,e.e_stop=$r,e.addClass=xt,e.contains=ct,e.rmClass=Me,e.keyNames=Xt}tf(Le),af(Le);var cf="iter insert remove copy getEditor constructor".split(" ");for(var un in it.prototype)it.prototype.hasOwnProperty(un)&&Se(cf,un)<0&&(Le.prototype[un]=function(e){return function(){return e.apply(this.doc,arguments)}}(it.prototype[un]));return Mt(it),Le.inputStyles={textarea:_e,contenteditable:ve},Le.defineMode=function(e){!Le.defaults.mode&&e!="null"&&(Le.defaults.mode=e),fs.apply(this,arguments)},Le.defineMIME=hs,Le.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Le.defineMIME("text/plain","null"),Le.defineExtension=function(e,t){Le.prototype[e]=t},Le.defineDocExtension=function(e,t){it.prototype[e]=t},Le.fromTextArea=ff,hf(Le),Le.version="5.65.16",Le})}(Cl)),Cl.exports}var yf=qo();const mf=vf(yf);var Io={exports:{}},Fo;function bf(){return Fo||(Fo=1,function(O,m){(function(L){L(qo())})(function(L){var N=L.Pos,A="http://www.w3.org/2000/svg";function z(f,y){this.mv=f,this.type=y,this.classes=y=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}z.prototype={constructor:z,init:function(f,y,S){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=L(f,dt({value:y,readOnly:!this.mv.options.allowEditingOriginals},dt(S))),this.mv.options.connect=="align"&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new Ht(this.edit)),this.orig.state.trackAlignable=new Ht(this.orig)),this.lockButton.title=this.edit.phrase("Toggle locked scrolling"),this.lockButton.setAttribute("aria-label",this.lockButton.title),this.orig.state.diffViews=[this];var x=S.chunkClassLocation||"background";Object.prototype.toString.call(x)!="[object Array]"&&(x=[x]),this.classes.classLocation=x,this.diff=kt(De(y),De(S.value),this.mv.options.ignoreWhitespace),this.chunks=bt(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=S.showDifferences!==!1},registerEvents:function(f){this.forceUpdate=d(this),k(this,!0,!1),v(this,f)},setShowDifferences:function(f){f=f!==!1,f!=this.showDifferences&&(this.showDifferences=f,this.forceUpdate("full"))}};function h(f){f.diffOutOfDate&&(f.diff=kt(f.orig.getValue(),f.edit.getValue(),f.mv.options.ignoreWhitespace),f.chunks=bt(f.diff),f.diffOutOfDate=!1,L.signal(f.edit,"updateDiff",f.diff))}var c=!1;function d(f){var y={from:0,to:0,marked:[]},S={from:0,to:0,marked:[]},x,M=!1;function _(ue){c=!0,M=!1,ue=="full"&&(f.svg&&At(f.svg),f.copyButtons&&At(f.copyButtons),F(f.edit,y.marked,f.classes),F(f.orig,S.marked,f.classes),y.from=y.to=S.from=S.to=0),h(f),f.showDifferences&&(K(f.edit,f.diff,y,DIFF_INSERT,f.classes),K(f.orig,f.diff,S,DIFF_DELETE,f.classes)),f.mv.options.connect=="align"&&re(f),Z(f),f.needsScrollSync!=null&&b(f,f.needsScrollSync),c=!1}function I(ue){c||(f.dealigned=!0,H(ue))}function H(ue){c||M||(clearTimeout(x),ue===!0&&(M=!0),x=setTimeout(_,ue===!0?20:250))}function R(ue,ce){f.diffOutOfDate||(f.diffOutOfDate=!0,y.from=y.to=S.from=S.to=0),I(ce.text.length-1!=ce.to.line-ce.from.line)}function ae(){f.diffOutOfDate=!0,f.dealigned=!0,_("full")}return f.edit.on("change",R),f.orig.on("change",R),f.edit.on("swapDoc",ae),f.orig.on("swapDoc",ae),f.mv.options.connect=="align"&&(L.on(f.edit.state.trackAlignable,"realign",I),L.on(f.orig.state.trackAlignable,"realign",I)),f.edit.on("viewportChange",function(){H(!1)}),f.orig.on("viewportChange",function(){H(!1)}),_(),_}function v(f,y){f.edit.on("scroll",function(){b(f,!0)&&Z(f)}),f.orig.on("scroll",function(){b(f,!1)&&Z(f),y&&b(y,!0)&&Z(y)})}function b(f,y){if(f.diffOutOfDate)return f.lockScroll&&f.needsScrollSync==null&&(f.needsScrollSync=y),!1;if(f.needsScrollSync=null,!f.lockScroll)return!0;var S,x,M=+new Date;if(y?(S=f.edit,x=f.orig):(S=f.orig,x=f.edit),S.state.scrollSetBy==f&&(S.state.scrollSetAt||0)+250>M)return!1;var _=S.getScrollInfo();if(f.mv.options.connect=="align")Ce=_.top;else{var I=.5*_.clientHeight,H=_.top+I,R=S.lineAtHeight(H,"local"),ae=xt(f.chunks,R,y),ue=w(S,y?ae.edit:ae.orig),ce=w(x,y?ae.orig:ae.edit),me=(H-ue.top)/(ue.bot-ue.top),Ce=ce.top-I+me*(ce.bot-ce.top),be,Ne;if(Ce>_.top&&(Ne=_.top/I)<1)Ce=Ce*Ne+_.top*(1-Ne);else if((be=_.height-_.clientHeight-_.top)be&&(Ne=be/I)<1&&(Ce=Ce*Ne+(ut.height-ut.clientHeight-be)*(1-Ne))}}return x.scrollTo(_.left,Ce),x.state.scrollSetAt=M,x.state.scrollSetBy=f,!0}function w(f,y){var S=y.after;return S==null&&(S=f.lastLine()+1),{top:f.heightAtLine(y.before||0,"local"),bot:f.heightAtLine(S,"local")}}function k(f,y,S){f.lockScroll=y,y&&S!=!1&&b(f,DIFF_INSERT)&&Z(f),(y?L.addClass:L.rmClass)(f.lockButton,"CodeMirror-merge-scrolllock-enabled")}function D(f,y,S){for(var x=S.classLocation,M=0;M20||S.from-_.to>20?(F(f,S.marked,M),q(f,y,x,S.marked,_.from,_.to,M),S.from=_.from,S.to=_.to):(_.fromS.to&&(q(f,y,x,S.marked,S.to,_.to,M),S.to=_.to))})}function Y(f,y,S,x,M,_){for(var I=S.classLocation,H=f.getLineHandle(y),R=0;RKr&&(Ce&&(ce(me,Kr),Ce=!1),me=te)}else if(Ce=!0,ut==S){var mr=Ze(H,ge,!0),je=Ur(R,H),Te=ht(ae,mr);Jt(je,Te)||x.push(f.markText(je,Te,{className:ue})),H=mr}}Ce&&ce(me,H.line+1)}function Z(f){if(f.showDifferences){if(f.svg){At(f.svg);var y=f.gap.offsetWidth;pr(f.svg,"width",y,"height",f.gap.offsetHeight)}f.copyButtons&&At(f.copyButtons);for(var S=f.edit.getViewport(),x=f.orig.getViewport(),M=f.mv.wrap.getBoundingClientRect().top,_=M-f.edit.getScrollerElement().getBoundingClientRect().top+f.edit.getScrollInfo().top,I=M-f.orig.getScrollerElement().getBoundingClientRect().top+f.orig.getScrollInfo().top,H=0;H=S.from&&R.origFrom<=x.to&&R.origTo>=x.from&&Fe(f,R,I,_,y)}}}function le(f,y){for(var S=0,x=0,M=0;Mf&&_.editFrom<=f)return null;if(_.editFrom>f)break;S=_.editTo,x=_.origTo}return x+(f-S)}function ie(f,y,S){for(var x=f.state.trackAlignable,M=f.firstLine(),_=0,I=[],H=0;;H++){for(var R=y[H],ae=R?S?R.origFrom:R.editFrom:1e9;_ce){_++,M--;continue e}if(me.editTo>ue){if(me.editFrom<=ue)continue e;break}H+=me.origTo-me.origFrom-(me.editTo-me.editFrom),I++}if(ue==ce-H)R[x]=ce,_++;else if(ue1&&x.push(ye(f[I],S[I],R))}}function ye(f,y,S){var x=!0;y>f.lastLine()&&(y--,x=!1);var M=document.createElement("div");return M.className="CodeMirror-merge-spacer",M.style.height=S+"px",M.style.minWidth="1px",f.addLineWidget(y,M,{height:S,above:x,mergeSpacer:!0,handleMouseEvents:!0})}function Fe(f,y,S,x,M){var _=f.type=="left",I=f.orig.heightAtLine(y.origFrom,"local",!0)-S;if(f.svg){var H=I,R=f.edit.heightAtLine(y.editFrom,"local",!0)-x;if(_){var ae=H;H=R,R=ae}var ue=f.orig.heightAtLine(y.origTo,"local",!0)-S,ce=f.edit.heightAtLine(y.editTo,"local",!0)-x;if(_){var ae=ue;ue=ce,ce=ae}var me=" C "+M/2+" "+R+" "+M/2+" "+H+" "+(M+2)+" "+H,Ce=" C "+M/2+" "+ue+" "+M/2+" "+ce+" -1 "+ce;pr(f.svg.appendChild(document.createElementNS(A,"path")),"d","M -1 "+R+me+" L "+(M+2)+" "+ue+Ce+" z","class",f.classes.connect)}if(f.copyButtons){var be=f.copyButtons.appendChild(Pe("div",f.type=="left"?"⇝":"⇜","CodeMirror-merge-copy")),Ne=f.mv.options.allowEditingOriginals;if(be.title=f.edit.phrase(Ne?"Push to left":"Revert chunk"),be.chunk=y,be.style.top=(y.origTo>y.origFrom?I:f.edit.heightAtLine(y.editFrom,"local")-x)+"px",be.setAttribute("role","button"),be.setAttribute("tabindex","0"),be.setAttribute("aria-label",be.title),Ne){var ut=f.edit.heightAtLine(y.editFrom,"local")-x,ge=f.copyButtons.appendChild(Pe("div",f.type=="right"?"⇝":"⇜","CodeMirror-merge-copy-reverse"));ge.title="Push to right",ge.chunk={editFrom:y.origFrom,editTo:y.origTo,origFrom:y.editFrom,origTo:y.editTo},ge.style.top=ut+"px",f.type=="right"?ge.style.left="2px":ge.style.right="2px",ge.setAttribute("role","button"),ge.setAttribute("tabindex","0"),ge.setAttribute("aria-label",ge.title)}}}function Ke(f,y,S,x){if(!f.diffOutOfDate){var M=x.origTo>S.lastLine()?N(x.origFrom-1):N(x.origFrom,0),_=N(x.origTo,0),I=x.editTo>y.lastLine()?N(x.editFrom-1):N(x.editFrom,0),H=N(x.editTo,0),R=f.mv.options.revertChunk;R?R(f.mv,S,M,_,y,I,H):y.replaceRange(S.getRange(M,_),I,H)}}var Me=L.MergeView=function(f,y){if(!(this instanceof Me))return new Me(f,y);this.options=y;var S=y.origLeft,x=y.origRight==null?y.orig:y.origRight,M=S!=null,_=x!=null,I=1+(M?1:0)+(_?1:0),H=[],R=this.left=null,ae=this.right=null,ue=this;if(M){R=this.left=new z(this,"left");var ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");H.push(ce),H.push(qe(R))}var me=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(H.push(me),_){ae=this.right=new z(this,"right"),H.push(qe(ae));var Ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");H.push(Ce)}(_?Ce:me).className+=" CodeMirror-merge-pane-rightmost",H.push(Pe("div",null,null,"height: 0; clear: both;"));var be=this.wrap=f.appendChild(Pe("div",H,"CodeMirror-merge CodeMirror-merge-"+I+"pane"));this.edit=L(me,dt(y)),R&&R.init(ce,S,y),ae&&ae.init(Ce,x,y),y.collapseIdentical&&this.editor().operation(function(){Ft(ue,y.collapseIdentical)}),y.connect=="align"&&(this.aligners=[],re(this.left||this.right,!0)),R&&R.registerEvents(ae),ae&&ae.registerEvents(R);var Ne=function(){R&&Z(R),ae&&Z(ae)};L.on(window,"resize",Ne);var ut=setInterval(function(){for(var ge=be.parentNode;ge&&ge!=document.body;ge=ge.parentNode);ge||(clearInterval(ut),L.off(window,"resize",Ne))},5e3)};function qe(f){var y=f.lockButton=Pe("div",null,"CodeMirror-merge-scrolllock");y.setAttribute("role","button"),y.setAttribute("tabindex","0");var S=Pe("div",[y],"CodeMirror-merge-scrolllock-wrap");L.on(y,"click",function(){k(f,!f.lockScroll)}),L.on(y,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&k(f,!f.lockScroll)});var x=[S];if(f.mv.options.revertButtons!==!1){f.copyButtons=Pe("div",null,"CodeMirror-merge-copybuttons-"+f.type);var M=function(I){var H=I.target||I.srcElement;if(H.chunk){if(H.className=="CodeMirror-merge-copy-reverse"){Ke(f,f.orig,f.edit,H.chunk);return}Ke(f,f.edit,f.orig,H.chunk)}};L.on(f.copyButtons,"click",M),L.on(f.copyButtons,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&M(I)}),x.unshift(f.copyButtons)}if(f.mv.options.connect!="align"){var _=document.createElementNS&&document.createElementNS(A,"svg");_&&!_.createSVGRect&&(_=null),f.svg=_,_&&x.push(_)}return f.gap=Pe("div",x,"CodeMirror-merge-gap")}Me.prototype={constructor:Me,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(f){this.right&&this.right.setShowDifferences(f),this.left&&this.left.setShowDifferences(f)},rightChunks:function(){if(this.right)return h(this.right),this.right.chunks},leftChunks:function(){if(this.left)return h(this.left),this.left.chunks}};function De(f){return typeof f=="string"?f:f.getValue()}var Q;function kt(f,y,S){Q||(Q=new diff_match_patch);for(var x=Q.diff_main(f,y),M=0;Mue&&(I&&y.push({origFrom:x,origTo:ce,editFrom:S,editTo:ue}),S=Ce,x=be)}else Ze(R==DIFF_INSERT?M:_,H[1])}return(S<=M.line||x<=_.line)&&y.push({origFrom:x,origTo:_.line+1,editFrom:S,editTo:M.line+1}),y}function ct(f,y){if(y==f.length-1)return!0;var S=f[y+1][1];return S.length==1&&y1||y==f.length-3)&&S.charCodeAt(0)==10)}function tt(f,y){if(y==0)return!0;var S=f[y-1][1];return S.charCodeAt(S.length-1)!=10?!1:y==1?!0:(S=f[y-2][1],S.charCodeAt(S.length-1)==10)}function xt(f,y,S){for(var x,M,_,I,H=0;Hy?(M=R.editFrom,I=R.origFrom):ue>y&&(M=R.editTo,I=R.origTo)),ue<=y?(x=R.editTo,_=R.origTo):ae<=y&&(x=R.editFrom,_=R.origFrom)}return{edit:{before:x,after:M},orig:{before:_,after:I}}}function zr(f,y,S){f.addLineClass(y,"wrap","CodeMirror-merge-collapsed-line");var x=document.createElement("span");x.className="CodeMirror-merge-collapsed-widget",x.title=f.phrase("Identical text collapsed. Click to expand.");var M=f.markText(N(y,0),N(S-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:x,clearOnEnter:!0});function _(){M.clear(),f.removeLineClass(y,"wrap","CodeMirror-merge-collapsed-line")}return M.explicitlyCleared&&_(),L.on(x,"click",_),M.on("clear",_),L.on(x,"click",_),{mark:M,clear:_}}function Zt(f,y){var S=[];function x(){for(var H=0;H=0&&Hy){var ue=[{line:R,cm:x}];f.left&&ue.push({line:le(R,f.left.chunks),cm:f.left.orig}),f.right&&ue.push({line:le(R,f.right.chunks),cm:f.right.orig});var ce=Zt(ae,ue);f.options.onCollapse&&f.options.onCollapse(f,R,ae,ce)}}}function Pe(f,y,S,x){var M=document.createElement(f);if(S&&(M.className=S),x&&(M.style.cssText=x),typeof y=="string")M.appendChild(document.createTextNode(y));else if(y)for(var _=0;_0;--y)f.removeChild(f.firstChild)}function pr(f){for(var y=1;y0)break}this.signal(),this.alignable.splice(S,0,f,y)},find:function(f){for(var y=0;y-1){var ae=this.alignable[_+1];ae==Se?this.alignable.splice(_,2):this.alignable[_+1]=ae&~Se}I>-1&&S&&this.set(f+S,Se)}};function ht(f,y){return(f.line-y.line||f.ch-y.ch)<0?f:y}function Ur(f,y){return(f.line-y.line||f.ch-y.ch)>0?f:y}function Jt(f,y){return f.line==y.line&&f.ch==y.ch}function Gr(f,y,S){for(var x=f.length-1;x>=0;x--){var M=f[x],_=(S?M.origTo:M.editTo)-1;if(_y)return _}}function yr(f,y){var S=null,x=f.state.diffViews,M=f.getCursor().line;if(x)for(var _=0;_S:R"u"&&(d=!0);var v=d,b=this.diff_commonPrefix(h,c),w=h.substring(0,b);h=h.substring(b),c=c.substring(b),b=this.diff_commonSuffix(h,c);var k=h.substring(h.length-b);h=h.substring(0,h.length-b),c=c.substring(0,c.length-b);var D=this.diff_compute(h,c,v);return w&&D.unshift([A,w]),k&&D.push([A,k]),this.diff_cleanupMerge(D),D},m.prototype.diff_compute=function(h,c,d){var v;if(!h)return[[N,c]];if(!c)return[[L,h]];var b=h.length>c.length?h:c,w=h.length>c.length?c:h,k=b.indexOf(w);if(k!=-1)return v=[[N,b.substring(0,k)],[A,w],[N,b.substring(k+w.length)]],h.length>c.length&&(v[0][0]=v[2][0]=L),v;b=w=null;var D=this.diff_halfMatch(h,c);if(D){var F=D[0],K=D[1],Y=D[2],q=D[3],Z=D[4],le=this.diff_main(F,Y,d),ie=this.diff_main(K,q,d);return le.concat([[A,Z]],ie)}d&&(h.length<100||c.length<100)&&(d=!1);var ne;if(d){var he=this.diff_linesToChars(h,c);h=he[0],c=he[1],ne=he[2]}if(v=this.diff_map(h,c),v||(v=[[L,h],[N,c]]),d){this.diff_charsToLines(v,ne),this.diff_cleanupSemantic(v),v.push([A,""]);for(var re=0,J=0,ye=0,Fe="",Ke="";re=1&&ye>=1){var he=this.diff_main(Fe,Ke,!1);v.splice(re-J-ye,J+ye),re=re-J-ye;for(var Me=he.length-1;Me>=0;Me--)v.splice(re,0,he[Me]);re=re+he.length}ye=0,J=0,Fe="",Ke="";break}re++}v.pop()}return v},m.prototype.diff_linesToChars=function(h,c){var d=[],v={};d[0]="";function b(D){for(var F="",K=0,Y=-1,q=d.length;Y0&&new Date().getTime()>d)return null;D[re]={};for(var J=-re;J<=re;J+=2){for(J==-re||J!=re&&K[J-1]=0;D--)for(;;)if(h[D][b-1+","+w]!==void 0){b--,k===L?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([L,c.charAt(b)]),k=L;break}else if(h[D][b+","+(w-1)]!==void 0){w--,k===N?v[0][1]=d.charAt(w)+v[0][1]:v.unshift([N,d.charAt(w)]),k=N;break}else{if(b--,w--,c.charAt(b)!=d.charAt(w))throw new Error("No diagonal. Can't happen. (diff_path1)");k===A?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([A,c.charAt(b)]),k=A}return v},m.prototype.diff_path2=function(h,c,d){for(var v=[],b=0,w=c.length,k=d.length,D=null,F=h.length-2;F>=0;F--)for(;;)if(h[F][w-1+","+k]!==void 0){w--,D===L?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[L,c.charAt(c.length-w-1)],D=L;break}else if(h[F][w+","+(k-1)]!==void 0){k--,D===N?v[b-1][1]+=d.charAt(d.length-k-1):v[b++]=[N,d.charAt(d.length-k-1)],D=N;break}else{if(w--,k--,c.charAt(c.length-w-1)!=d.charAt(d.length-k-1))throw new Error("No diagonal. Can't happen. (diff_path2)");D===A?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[A,c.charAt(c.length-w-1)],D=A}return v},m.prototype.diff_commonPrefix=function(h,c){if(!h||!c||h.charAt(0)!=c.charAt(0))return 0;for(var d=0,v=Math.min(h.length,c.length),b=v,w=0;dc.length?h:c,v=h.length>c.length?c:h;if(d.length<10||v.length<1)return null;var b=this;function w(ie,ne,he){for(var re=ie.substring(he,he+Math.floor(ie.length/4)),J=-1,ye="",Fe,Ke,Me,qe;(J=ne.indexOf(re,J+1))!=-1;){var De=b.diff_commonPrefix(ie.substring(he),ne.substring(J)),Q=b.diff_commonSuffix(ie.substring(0,he),ne.substring(0,J));ye.length=ie.length/2?[Fe,Ke,Me,qe,ye]:null}var k=w(d,v,Math.ceil(d.length/4)),D=w(d,v,Math.ceil(d.length/2)),F;if(!k&&!D)return null;D?k?F=k[4].length>D[4].length?k:D:F=D:F=k;var K,Y,q,Z;h.length>c.length?(K=F[0],Y=F[1],q=F[2],Z=F[3]):(q=F[0],Z=F[1],K=F[2],Y=F[3]);var le=F[4];return[K,Y,q,Z,le]},m.prototype.diff_cleanupSemantic=function(h){for(var c=!1,d=[],v=0,b=null,w=0,k=0,D=0;w0?d[v-1]:-1,k=0,D=0,b=null,c=!0)),w++;c&&this.diff_cleanupMerge(h),this.diff_cleanupSemanticLossless(h)},m.prototype.diff_cleanupSemanticLossless=function(h){var c=/[^a-zA-Z0-9]/,d=/\s/,v=/[\r\n]/,b=/\n\r?\n$/,w=/^\r?\n\r?\n/;function k(J,ye){if(!J||!ye)return 5;var Fe=0;return(J.charAt(J.length-1).match(c)||ye.charAt(0).match(c))&&(Fe++,(J.charAt(J.length-1).match(d)||ye.charAt(0).match(d))&&(Fe++,(J.charAt(J.length-1).match(v)||ye.charAt(0).match(v))&&(Fe++,(J.match(b)||ye.match(w))&&Fe++))),Fe}for(var D=1;D=he&&(he=re,le=F,ie=K,ne=Y)}h[D-1][1]!=le&&(le?h[D-1][1]=le:(h.splice(D-1,1),D--),h[D][1]=ie,ne?h[D+1][1]=ne:(h.splice(D+1,1),D--))}D++}},m.prototype.diff_cleanupEfficiency=function(h){for(var c=!1,d=[],v=0,b="",w=0,k=!1,D=!1,F=!1,K=!1;w0?d[v-1]:-1,F=K=!1),c=!0)),w++;c&&this.diff_cleanupMerge(h)},m.prototype.diff_cleanupMerge=function(h){h.push([A,""]);for(var c=0,d=0,v=0,b="",w="",k;c0&&h[c-d-v-1][0]==A?h[c-d-v-1][1]+=w.substring(0,k):(h.splice(0,0,[A,w.substring(0,k)]),c++),w=w.substring(k),b=b.substring(k)),k=this.diff_commonSuffix(w,b),k!==0&&(h[c][1]=w.substring(w.length-k)+h[c][1],w=w.substring(0,w.length-k),b=b.substring(0,b.length-k))),d===0?h.splice(c-d-v,d+v,[N,w]):v===0?h.splice(c-d-v,d+v,[L,b]):h.splice(c-d-v,d+v,[L,b],[N,w]),c=c-d-v+(d?1:0)+(v?1:0)+1):c!==0&&h[c-1][0]==A?(h[c-1][1]+=h[c][1],h.splice(c,1)):c++,v=0,d=0,b="",w="";break}h[h.length-1][1]===""&&h.pop();var D=!1;for(c=1;cc));k++)b=d,w=v;return h.length!=k&&h[k][0]===L?w:w+(c-b)},m.prototype.diff_prettyHtml=function(h){for(var c=[],d=0,v=0;v/g,">").replace(/\n/g,"¶
");switch(b){case N:c[v]=''+k+"";break;case L:c[v]=''+k+"";break;case A:c[v]=''+k+"";break}b!==L&&(d+=w.length)}return c.join("")},m.prototype.diff_text1=function(h){for(var c=[],d=0;dthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var v=this.match_alphabet(c),b=this;function w(Fe,Ke){var Me=Fe/c.length,qe=Math.abs(d-Ke);return b.Match_Distance?Me+qe/b.Match_Distance:qe?1:Me}var k=this.Match_Threshold,D=h.indexOf(c,d);D!=-1&&(k=Math.min(w(0,D),k),D=h.lastIndexOf(c,d+c.length),D!=-1&&(k=Math.min(w(0,D),k)));var F=1<=ie;re--){var J=v[h.charAt(re-1)];if(le===0?he[re]=(he[re+1]<<1|1)&J:he[re]=(he[re+1]<<1|1)&J|((Z[re+1]|Z[re])<<1|1)|Z[re+1],he[re]&F){var ye=w(le,re-1);if(ye<=k)if(k=ye,D=re-1,D>d)ie=Math.max(1,2*d-D);else break}}if(w(le+1,d)>k)break;Z=he}return D},m.prototype.match_alphabet=function(h){for(var c={},d=0;d"u")v=h,b=this.diff_main(v,c,!0),b.length>2&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(h&&typeof h=="object"&&typeof c>"u"&&typeof d>"u")b=h,v=this.diff_text1(b);else if(typeof h=="string"&&c&&typeof c=="object"&&typeof d>"u")v=h,b=c;else if(typeof h=="string"&&typeof c=="string"&&d&&typeof d=="object")v=h,b=d;else throw new Error("Unknown call format to patch_make.");if(b.length===0)return[];for(var w=[],k=new z,D=0,F=0,K=0,Y=v,q=v,Z=0;Z=2*this.Patch_Margin&&D&&(this.patch_addContext(k,Y),w.push(k),k=new z,D=0,Y=q,F=K);break}le!==N&&(F+=ie.length),le!==L&&(K+=ie.length)}return D&&(this.patch_addContext(k,Y),w.push(k)),w},m.prototype.patch_deepCopy=function(h){for(var c=[],d=0;dthis.Match_MaxBits?(F=this.match_main(c,D.substring(0,this.Match_MaxBits),k),F!=-1&&(K=this.match_main(c,D.substring(D.length-this.Match_MaxBits),k+D.length-this.Match_MaxBits),(K==-1||F>=K)&&(F=-1))):F=this.match_main(c,D,k),F==-1)b[w]=!1,v-=h[w].length2-h[w].length1;else{b[w]=!0,v=F-k;var Y;if(K==-1?Y=c.substring(F,F+D.length):Y=c.substring(F,K+this.Match_MaxBits),D==Y)c=c.substring(0,F)+this.diff_text2(h[w].diffs)+c.substring(F+D.length);else{var q=this.diff_main(D,Y,!1);if(D.length>this.Match_MaxBits&&this.diff_levenshtein(q)/D.length>this.Patch_DeleteThreshold)b[w]=!1;else{this.diff_cleanupSemanticLossless(q);for(var Z=0,le,ie=0;iew[0][1].length){var k=c-w[0][1].length;w[0][1]=d.substring(w[0][1].length)+w[0][1],b.start1-=k,b.start2-=k,b.length1+=k,b.length2+=k}if(b=h[h.length-1],w=b.diffs,w.length==0||w[w.length-1][0]!=A)w.push([A,d]),b.length1+=c,b.length2+=c;else if(c>w[w.length-1][1].length){var k=c-w[w.length-1][1].length;w[w.length-1][1]+=d.substring(0,k),b.length1+=k,b.length2+=k}return d},m.prototype.patch_splitMax=function(h){for(var c=0;cthis.Match_MaxBits){var d=h[c];h.splice(c--,1);for(var v=this.Match_MaxBits,b=d.start1,w=d.start2,k="";d.diffs.length!==0;){var D=new z,F=!0;for(D.start1=b-k.length,D.start2=w-k.length,k!==""&&(D.length1=D.length2=k.length,D.diffs.push([A,k]));d.diffs.length!==0&&D.length12*v?(D.length1+=Y.length,b+=Y.length,F=!1,D.diffs.push([K,Y]),d.diffs.shift()):(Y=Y.substring(0,v-D.length1-this.Patch_Margin),D.length1+=Y.length,b+=Y.length,K===A?(D.length2+=Y.length,w+=Y.length):F=!1,D.diffs.push([K,Y]),Y==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(Y.length))}k=this.diff_text2(D.diffs),k=k.substring(k.length-this.Patch_Margin);var q=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);q!==""&&(D.length1+=q.length,D.length2+=q.length,D.diffs.length!==0&&D.diffs[D.diffs.length-1][0]===A?D.diffs[D.diffs.length-1][1]+=q:D.diffs.push([A,q])),F||h.splice(++c,0,D)}}},m.prototype.patch_toText=function(h){for(var c=[],d=0;dN}):void 0,Zo="$lit$",qt=`lit$${(Math.random()+"").slice(9)}$`,Qo="?"+qt,Cf=`<${Qo}>`,gr=document,Ti=()=>gr.createComment(""),ki=N=>N===null||typeof N!="object"&&typeof N!="function",Jo=Array.isArray,Sf=N=>Jo(N)||typeof(N==null?void 0:N[Symbol.iterator])=="function",Sl=`[ -\f\r]`,wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Bo=/-->/g,Ro=/>/g,hr=RegExp(`>|${Sl}(?:([^\\s"'>=/]+)(${Sl}*=${Sl}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),zo=/'/g,Uo=/"/g,jo=/^(?:script|style|textarea|title)$/i,Lf=N=>(b,...T)=>({_$litType$:N,strings:b,values:T}),dr=Lf(1),xi=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),Go=new WeakMap,cr=gr.createTreeWalker(gr,129);function Vo(N,b){if(!Array.isArray(N)||!N.hasOwnProperty("raw"))throw Error("invalid template strings array");return Po!==void 0?Po.createHTML(b):b}const Tf=(N,b)=>{const T=N.length-1,O=[];let A,G=b===2?"":"",h=wi;for(let c=0;c"?(h=A??wi,w=-1):m[1]===void 0?w=-2:(w=h.lastIndex-m[2].length,v=m[1],h=m[3]===void 0?hr:m[3]==='"'?Uo:zo):h===Uo||h===zo?h=hr:h===Bo||h===Ro?h=wi:(h=hr,A=void 0);const D=h===hr&&N[c+1].startsWith("/>")?" ":"";G+=h===wi?d+Cf:w>=0?(O.push(v),d.slice(0,w)+Zo+d.slice(w)+qt+D):d+qt+(w===-2?c:D)}return[Vo(N,G+(N[T]||"")+(b===2?"":"")),O]};class Ai{constructor({strings:b,_$litType$:T},O){let A;this.parts=[];let G=0,h=0;const c=b.length-1,d=this.parts,[v,m]=Tf(b,T);if(this.el=Ai.createElement(v,O),cr.currentNode=this.el.content,T===2){const w=this.el.content.firstChild;w.replaceWith(...w.childNodes)}for(;(A=cr.nextNode())!==null&&d.length0){A.textContent=cn?cn.emptyScript:"";for(let D=0;D2||O[0]!==""||O[1]!==""?(this._$AH=Array(O.length-1).fill(new String),this.strings=O):this._$AH=Ye}_$AI(b,T=this,O,A){const G=this.strings;let h=!1;if(G===void 0)b=Rr(this,b,T,0),h=!ki(b)||b!==this._$AH&&b!==xi,h&&(this._$AH=b);else{const c=b;let d,v;for(b=G[0],d=0;d{const O=(T==null?void 0:T.renderBefore)??b;let A=O._$litPart$;if(A===void 0){const G=(T==null?void 0:T.renderBefore)??null;O._$litPart$=A=new _i(b.insertBefore(Ti(),G),G,void 0,T??{})}return A._$AI(N),A};function Df(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function xl(N,b=!1){const T=Df(),O=`_${T}`;return Object.defineProperty(window,O,{value:A=>(b&&Reflect.deleteProperty(window,O),N==null?void 0:N(A)),writable:!1,configurable:!0}),T}async function es(N,b={}){return new Promise((T,O)=>{const A=xl(h=>{T(h),Reflect.deleteProperty(window,`_${G}`)},!0),G=xl(h=>{O(h),Reflect.deleteProperty(window,`_${A}`)},!0);window.__TAURI_IPC__({cmd:N,callback:A,error:G,...b})})}async function Al(N){return es("tauri",N)}async function Nf(N=0){return Al({__tauriModule:"Process",message:{cmd:"exit",exitCode:N}})}function Tl(N){return N.type=="Text"?N.value:null}const Ml="__TAURI__"in globalThis;async function ts(N,b,T){if(Ml){let O={};return T!=null&&(O={result:T}),await es(N,O)}else return await rs(N,b,T)}async function rs(N,b,T){let O=null,A={};T!=null&&(O=JSON.stringify(T),A["Content-Type"]="application/json");const G=await fetch(`/api/${N}`,{method:b,body:O,headers:A});if(G.ok)return await G.json();{let h="";throw G.status<500&&(h=`Likely bug in the webapp: got response "${G.status} ${G.statusText}" for "${N}" request. Additional details, if any, follow. `),h+await G.text()}}async function _l(N){Ml?await Nf(N):await rs("exit","POST",N)}async function Of(){await _l(0)}async function Ko(){await _l(1)}async function Ef(){await _l(2)}async function $o(N){return await ts("save","PUT",N)}async function Wf(){const N=await ts("get_merge_data","GET");for(const b in N)N[b]={left:N[b][0],right:N[b][1],edit:N[b][2]};return N}class Ff{constructor(){Eo(this,"merge_views");this.merge_views={}}values(){const b={};for(const T in this.merge_views)b[T]=this.merge_views[T].editor().getValue();return b}createCodeMirrorMergeWidget(b,T,O){const A=document.getElementById(`collapse_${b}`),G=document.getElementById(`linewrap_${b}`),h=document.getElementById(`prevChange_${b}`),c=document.getElementById(`nextChange_${b}`),d=document.getElementById(`details_${b}`),v=document.getElementById(`cm_${b}`),m={value:Tl(O.edit)??"",origLeft:Tl(O.left)??"",orig:Tl(O.right)??"",lineNumbers:!0,lineWrapping:!1,mode:"text/plain",connect:"align",collapseIdentical:!0},w=mf.MergeView(v,m);w.editor().setOption("extraKeys",{"Alt-Down":Ci,"Option-Down":Ci,"Cmd-Down":Ci,"Alt-Up":fn,"Option-Up":fn,"Cmd-Up":fn,Tab:Ci}),A.onclick=()=>Hf(w.editor()),G.onclick=()=>Pf(w.editor()),h.onclick=()=>fn(w.editor()),c.onclick=()=>Ci(w.editor()),d.open=!1,d.ontoggle=()=>w.editor().refresh(),console.log(d),this.merge_views[T]=w}}function Xo(N){let b=Array.from([{file:N.left,side:"left"},{file:N.right,side:"right"},{file:N.edit,side:"middle"}]).find(T=>T.file.type=="Unsupported");if(b==null)return null;if(b.file.type!="Unsupported")throw new Error("this statement is unreachable; this check exists to make TS happy");return dr`error: ${b.file.value} (occurred on the - ${b.side} side)`}function If(N,b){let T=[],O=h=>`${h}_${N}`;for(const h in b){const c=Xo(b[h]);c!=null?T.push(dr`
+ */const Si=globalThis,dn=Si.trustedTypes,Po=dn?dn.createPolicy("lit-html",{createHTML:O=>O}):void 0,Zo="$lit$",qt=`lit$${(Math.random()+"").slice(9)}$`,Qo="?"+qt,Cf=`<${Qo}>`,gr=document,Ti=()=>gr.createComment(""),ki=O=>O===null||typeof O!="object"&&typeof O!="function",Jo=Array.isArray,Sf=O=>Jo(O)||typeof(O==null?void 0:O[Symbol.iterator])=="function",Ll=`[ +\f\r]`,wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Bo=/-->/g,Ro=/>/g,hr=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),zo=/'/g,Uo=/"/g,jo=/^(?:script|style|textarea|title)$/i,Lf=O=>(m,...L)=>({_$litType$:O,strings:m,values:L}),dr=Lf(1),xi=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),Go=new WeakMap,cr=gr.createTreeWalker(gr,129);function Vo(O,m){if(!Array.isArray(O)||!O.hasOwnProperty("raw"))throw Error("invalid template strings array");return Po!==void 0?Po.createHTML(m):m}const Tf=(O,m)=>{const L=O.length-1,N=[];let A,z=m===2?"":"",h=wi;for(let c=0;c"?(h=A??wi,w=-1):b[1]===void 0?w=-2:(w=h.lastIndex-b[2].length,v=b[1],h=b[3]===void 0?hr:b[3]==='"'?Uo:zo):h===Uo||h===zo?h=hr:h===Bo||h===Ro?h=wi:(h=hr,A=void 0);const D=h===hr&&O[c+1].startsWith("/>")?" ":"";z+=h===wi?d+Cf:w>=0?(N.push(v),d.slice(0,w)+Zo+d.slice(w)+qt+D):d+qt+(w===-2?c:D)}return[Vo(O,z+(O[L]||"")+(m===2?"":"")),N]};class Ai{constructor({strings:m,_$litType$:L},N){let A;this.parts=[];let z=0,h=0;const c=m.length-1,d=this.parts,[v,b]=Tf(m,L);if(this.el=Ai.createElement(v,N),cr.currentNode=this.el.content,L===2){const w=this.el.content.firstChild;w.replaceWith(...w.childNodes)}for(;(A=cr.nextNode())!==null&&d.length0){A.textContent=dn?dn.emptyScript:"";for(let D=0;D2||N[0]!==""||N[1]!==""?(this._$AH=Array(N.length-1).fill(new String),this.strings=N):this._$AH=Ye}_$AI(m,L=this,N,A){const z=this.strings;let h=!1;if(z===void 0)m=Rr(this,m,L,0),h=!ki(m)||m!==this._$AH&&m!==xi,h&&(this._$AH=m);else{const c=m;let d,v;for(m=z[0],d=0;d{const N=(L==null?void 0:L.renderBefore)??m;let A=N._$litPart$;if(A===void 0){const z=(L==null?void 0:L.renderBefore)??null;N._$litPart$=A=new _i(m.insertBefore(Ti(),z),z,void 0,L??{})}return A._$AI(O),A};function Df(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function Al(O,m=!1){const L=Df(),N=`_${L}`;return Object.defineProperty(window,N,{value:A=>(m&&Reflect.deleteProperty(window,N),O==null?void 0:O(A)),writable:!1,configurable:!0}),L}async function es(O,m={}){return new Promise((L,N)=>{const A=Al(h=>{L(h),Reflect.deleteProperty(window,`_${z}`)},!0),z=Al(h=>{N(h),Reflect.deleteProperty(window,`_${A}`)},!0);window.__TAURI_IPC__({cmd:O,callback:A,error:z,...m})})}async function Ml(O){return es("tauri",O)}async function Nf(O=0){return Ml({__tauriModule:"Process",message:{cmd:"exit",exitCode:O}})}function kl(O){return O.type=="Text"?O.value:null}const _l="__TAURI__"in globalThis;async function ts(O,m,L){if(_l){let N={};return L!=null&&(N={result:L}),await es(O,N)}else return await rs(O,m,L)}async function rs(O,m,L){let N=null,A={};L!=null&&(N=JSON.stringify(L),A["Content-Type"]="application/json");const z=await fetch(`/api/${O}`,{method:m,body:N,headers:A});if(z.ok)return await z.json();{let h="";throw z.status<500&&(h=`Likely bug in the webapp: got response "${z.status} ${z.statusText}" for "${O}" request. Additional details, if any, follow. `),h+await z.text()}}async function Dl(O){_l?await Nf(O):await rs("exit","POST",O)}async function Of(){await Dl(0)}async function Ko(){await Dl(1)}async function Ef(){await Dl(2)}async function $o(O){return await ts("save","PUT",O)}async function Wf(){const O=await ts("get_merge_data","GET");for(const m in O)O[m]={left:O[m][0],right:O[m][1],edit:O[m][2]};return O}class If{constructor(){fn(this,"merge_views");fn(this,"dom_ids");fn(this,"initial_values");this.merge_views={},this.dom_ids={},this.initial_values={}}values(){const m={};for(const L in this.merge_views)m[L]=this.merge_views[L].editor().getValue();return m}values_for(m){return{left:this.initial_values[m].left,right:this.initial_values[m].right,edit:{type:"Text",value:this.merge_views[m].editor().getValue()}}}createCodeMirrorMergeWidget(m,L,N,A){const z=document.getElementById(`collapse_${m}`),h=document.getElementById(`linewrap_${m}`),c=document.getElementById(`prevChange_${m}`),d=document.getElementById(`nextChange_${m}`),v=document.getElementById(`details_${m}`),b=document.getElementById(`cm_${m}`),w={value:kl(N.edit)??"",origLeft:kl(N.left)??"",orig:kl(N.right)??"",lineNumbers:!0,lineWrapping:A??!0,mode:"text/plain",connect:"align",collapseIdentical:!0},k=mf.MergeView(b,w);k.editor().setOption("extraKeys",{"Alt-Down":Ci,"Option-Down":Ci,"Cmd-Down":Ci,"Alt-Up":hn,"Option-Up":hn,"Cmd-Up":hn,Tab:Ci}),z.onclick=()=>Hf(k.editor()),h.onclick=()=>this.cm_toggleLineWrapping(L),c.onclick=()=>hn(k.editor()),d.onclick=()=>Ci(k.editor()),v.open=!1,v.ontoggle=()=>k.editor().refresh(),console.log(v),this.merge_views[L]=k,this.dom_ids[L]=m,this.initial_values[L]=N}cm_toggleLineWrapping(m){var d;const L=this.merge_views[m];if(L==null){console.warn("Trying to toggle line wrapping on non-existent editor",m,this);return}let N=this.dom_ids[m];const A=`cm_${N}`,z=!L.editor().getOption("lineWrapping"),h=document.createElement("div");(d=document.getElementById(A))==null||d.replaceWith(h),h.id=A,this.createCodeMirrorMergeWidget(N,m,this.values_for(m),z);const c=document.getElementById(`details_${N}`);c.open=!0}}function Xo(O){let m=Array.from([{file:O.left,side:"left"},{file:O.right,side:"right"},{file:O.edit,side:"middle"}]).find(L=>L.file.type=="Unsupported");if(m==null)return null;if(m.file.type!="Unsupported")throw new Error("this statement is unreachable; this check exists to make TS happy");return dr`error: ${m.file.value} (occurred on the + ${m.side} side)`}function Ff(O,m){let L=[],N=h=>`${h}_${O}`;for(const h in m){const c=Xo(m[h]);c!=null?L.push(dr`
${h}: ${c} -
`):T.push(dr` -
+
`):L.push(dr` +
${h} - - -
+
- `)}const A=document.getElementById(N);A.innerHTML="",Li(dr`${T}`,A);const G=new Ff;for(let h in b)Xo(b[h])==null&&G.createCodeMirrorMergeWidget(O(h),h,b[h]);return G}function Hf(N){N.setOption("collapseIdentical",!N.getOption("collapseIdentical")),N.setValue(N.getValue()),console.log(N.getOption("collapseIdentical")),N.scrollIntoView(null,50)}function Pf(N){N.setOption("lineWrapping",!N.getOption("lineWrapping")),N.setValue(N.getValue())}function Ci(N){N.execCommand("goNextDiff"),N.scrollIntoView(null,50)}function fn(N){N.execCommand("goPrevDiff"),N.scrollIntoView(null,50)}async function Bf(N,b){return Al({__tauriModule:"Event",message:{cmd:"unlisten",event:N,eventId:b}})}async function Rf(N,b,T){return Al({__tauriModule:"Event",message:{cmd:"listen",event:N,windowLabel:b,handler:xl(T)}}).then(O=>async()=>Bf(N,O))}var Yo;(function(N){N.WINDOW_RESIZED="tauri://resize",N.WINDOW_MOVED="tauri://move",N.WINDOW_CLOSE_REQUESTED="tauri://close-requested",N.WINDOW_CREATED="tauri://window-created",N.WINDOW_DESTROYED="tauri://destroyed",N.WINDOW_FOCUS="tauri://focus",N.WINDOW_BLUR="tauri://blur",N.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",N.WINDOW_THEME_CHANGED="tauri://theme-changed",N.WINDOW_FILE_DROP="tauri://file-drop",N.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",N.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",N.MENU="tauri://menu",N.CHECK_UPDATE="tauri://update",N.UPDATE_AVAILABLE="tauri://update-available",N.INSTALL_UPDATE="tauri://update-install",N.STATUS_UPDATE="tauri://update-status",N.DOWNLOAD_PROGRESS="tauri://update-download-progress"})(Yo||(Yo={}));async function hn(N,b){return Rf(N,null,b)}function is(N){console.log("Caught error, showing to user:",N);const b=document.getElementById("modal_dialog_with_message"),T=document.getElementById("message_of_modal_dialog_with_message");Li(`${String(N)}`,T),b.showModal(),console.log("Done showing error to user.")}async function kl(N){try{return await N()}catch(b){is(b)}}window.addEventListener("DOMContentLoaded",async()=>{const N=document.getElementById("loading_message");N.innerHTML="",Li(dr` + `)}const A=document.getElementById(O);A.innerHTML="",Li(dr`${L}`,A);const z=new If;for(let h in m)Xo(m[h])==null&&z.createCodeMirrorMergeWidget(N(h),h,m[h]);return z}function Hf(O){O.setOption("collapseIdentical",!O.getOption("collapseIdentical")),O.setValue(O.getValue()),console.log(O.getOption("collapseIdentical")),O.scrollIntoView(null,50)}function Ci(O){O.execCommand("goNextDiff"),O.scrollIntoView(null,50)}function hn(O){O.execCommand("goPrevDiff"),O.scrollIntoView(null,50)}async function Pf(O,m){return Ml({__tauriModule:"Event",message:{cmd:"unlisten",event:O,eventId:m}})}async function Bf(O,m,L){return Ml({__tauriModule:"Event",message:{cmd:"listen",event:O,windowLabel:m,handler:Al(L)}}).then(N=>async()=>Pf(O,N))}var Yo;(function(O){O.WINDOW_RESIZED="tauri://resize",O.WINDOW_MOVED="tauri://move",O.WINDOW_CLOSE_REQUESTED="tauri://close-requested",O.WINDOW_CREATED="tauri://window-created",O.WINDOW_DESTROYED="tauri://destroyed",O.WINDOW_FOCUS="tauri://focus",O.WINDOW_BLUR="tauri://blur",O.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",O.WINDOW_THEME_CHANGED="tauri://theme-changed",O.WINDOW_FILE_DROP="tauri://file-drop",O.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",O.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",O.MENU="tauri://menu",O.CHECK_UPDATE="tauri://update",O.UPDATE_AVAILABLE="tauri://update-available",O.INSTALL_UPDATE="tauri://update-install",O.STATUS_UPDATE="tauri://update-status",O.DOWNLOAD_PROGRESS="tauri://update-download-progress"})(Yo||(Yo={}));async function cn(O,m){return Bf(O,null,m)}function is(O){console.log("Caught error, showing to user:",O);const m=document.getElementById("modal_dialog_with_message"),L=document.getElementById("message_of_modal_dialog_with_message");Li(`${String(O)}`,L),m.showModal(),console.log("Done showing error to user.")}async function xl(O){try{return await O()}catch(m){is(m)}}window.addEventListener("DOMContentLoaded",async()=>{const O=document.getElementById("loading_message");O.innerHTML="",Li(dr`

Loading...

Getting the data we want to merge...

- `,N);let b;try{b=await Wf()}catch(v){throw is(v),await Ef(),new Error("Internal error: this statement should be unreachable")}Li(dr` + `,O);let m;try{m=await Wf()}catch(v){throw is(v),await Ef(),new Error("Internal error: this statement should be unreachable")}Li(dr`

Loading...

Rendering diffs...

- `,N);const T=If("lit",b);Li(dr``,N);const O=async()=>await kl(async()=>{await $o(T.values())}),A=document.getElementById("button_save"),G=document.getElementById("button_save_and_quit"),h=async()=>await kl(async()=>{await $o(T.values()),A.disabled=!0,G.disabled=!0,Of(),await new Promise(v=>setTimeout(v,100)),window.close()}),c=async()=>await kl(async()=>{A.disabled=!0,G.disabled=!0,Ko(),await new Promise(v=>setTimeout(v,100)),window.close()}),d=()=>(window.location.reload(),!1);A.onclick=O,G.onclick=h,document.getElementById("button_abandon_changes_and_quit").onclick=c,document.getElementById("button_revert").onclick=d,Ml?(await hn("save",async v=>O()),await hn("save_and_quit",async v=>h()),await hn("revert",async v=>d()),await hn("abandon_changes_and_quit",async v=>Ko())):document.addEventListener("keydown",async v=>{const m=v.metaKey||v.ctrlKey;return v.key=="s"&&m?(await O(),v.preventDefault(),!1):!0})}); + `,O);const L=Ff("lit",m);Li(dr``,O);const N=async()=>await xl(async()=>{await $o(L.values())}),A=document.getElementById("button_save"),z=document.getElementById("button_save_and_quit"),h=async()=>await xl(async()=>{await $o(L.values()),A.disabled=!0,z.disabled=!0,Of(),await new Promise(v=>setTimeout(v,100)),window.close()}),c=async()=>await xl(async()=>{A.disabled=!0,z.disabled=!0,Ko(),await new Promise(v=>setTimeout(v,100)),window.close()}),d=()=>(window.location.reload(),!1);A.onclick=N,z.onclick=h,document.getElementById("button_abandon_changes_and_quit").onclick=c,document.getElementById("button_revert").onclick=d,_l?(await cn("save",async v=>N()),await cn("save_and_quit",async v=>h()),await cn("revert",async v=>d()),await cn("abandon_changes_and_quit",async v=>Ko())):document.addEventListener("keydown",async v=>{const b=v.metaKey||v.ctrlKey;return v.key=="s"&&b?(await N(),v.preventDefault(),!1):!0})}); diff --git a/webapp/dist/index.html b/webapp/dist/index.html index 3795e93..f84b082 100644 --- a/webapp/dist/index.html +++ b/webapp/dist/index.html @@ -4,7 +4,7 @@ Diffedit3 - + diff --git a/webapp/src/merge_state.ts b/webapp/src/merge_state.ts index a13fd39..30f0768 100644 --- a/webapp/src/merge_state.ts +++ b/webapp/src/merge_state.ts @@ -11,12 +11,16 @@ import { class MergeState { merge_views: Record; + dom_ids: Record; + initial_values: Record; constructor() { this.merge_views = {}; + this.dom_ids = {}; + this.initial_values = {}; } - // TODO: This method should be exported, but ideally not others. + // TODO: This method should be exported, but ideally not most others. values(): Record { const result: Record = {}; for (const k in this.merge_views) { @@ -26,9 +30,26 @@ class MergeState { return result; } + values_for(filename: string): SingleFileMergeInput { + return { + left: this.initial_values[filename].left, + right: this.initial_values[filename].right, + edit: { + type: "Text", + value: this.merge_views[filename].editor().getValue(), + }, + }; + } + // This method is tightly coupled with the DOM constructed in // `render_input`. - createCodeMirrorMergeWidget (unique_id: string, filename: string, input: SingleFileMergeInput) { + createCodeMirrorMergeWidget( + unique_id: string, + filename: string, + input: SingleFileMergeInput, + // TODO: Other options. Is DOM collapsed? Cursor position? + wrap_lines?: boolean + ) { const collapseButtonEl = document.getElementById(`collapse_${unique_id}`)!; const linewrapButtonEl = document.getElementById(`linewrap_${unique_id}`)!; const prevChangeButtonEl = document.getElementById( @@ -47,10 +68,7 @@ class MergeState { origLeft: to_text(input.left) ?? "", // Set to null for 2 panes orig: to_text(input.right) ?? "", lineNumbers: true, - /* TODO: Toggling line wrapping breaks `collapseIdentical`. Need a - settings system where the user can decide whether they want line wrapping, - save, and reload. */ - lineWrapping: false, + lineWrapping: wrap_lines ?? true, mode: "text/plain", connect: "align", collapseIdentical: true, @@ -66,7 +84,7 @@ class MergeState { Tab: cm_nextChange, }); collapseButtonEl.onclick = () => cm_collapseSame(merge_view.editor()); - linewrapButtonEl.onclick = () => cm_toggleLineWrapping(merge_view.editor()); + linewrapButtonEl.onclick = () => this.cm_toggleLineWrapping(filename); prevChangeButtonEl.onclick = () => cm_prevChange(merge_view.editor()); nextChangeButtonEl.onclick = () => cm_nextChange(merge_view.editor()); // Starting with details closed breaks CodeMirror, especially line numbers @@ -76,7 +94,45 @@ class MergeState { console.log(detailsButtonEl); // TODO: Resizing. See https://codemirror.net/5/demo/merge.html - this.merge_views[filename] = merge_view + this.merge_views[filename] = merge_view; + this.dom_ids[filename] = unique_id; + this.initial_values[filename] = input; + } + + cm_toggleLineWrapping(filename: string) { + const old_merge_view = this.merge_views[filename]; + if (old_merge_view == null) { + console.warn( + "Trying to toggle line wrapping on non-existent editor", + filename, + this + ); + return; + } + let dom_id = this.dom_ids[filename]; + const codemirror_dom_id = `cm_${dom_id}`; + const desired_line_wrapping = !old_merge_view + .editor() + .getOption("lineWrapping"); + + const new_codemirror_element = document.createElement("div"); + document + .getElementById(codemirror_dom_id) + ?.replaceWith(new_codemirror_element); + new_codemirror_element.id = codemirror_dom_id; + + this.createCodeMirrorMergeWidget( + dom_id, + filename, + this.values_for(filename), + desired_line_wrapping + ); + const detailsButtonEl = ( + document.getElementById(`details_${dom_id}`)! + ); + // TODO: Perhaps one day we'll want to toggle this option when the details view is closed. + detailsButtonEl.open = true; + // cm.scrollIntoView(null, 50); // Always happens automatically } } @@ -139,7 +195,7 @@ export function render_input(unique_id: string, merge_input: MergeInput) { > ⇩ Next Change - @@ -177,16 +233,6 @@ function cm_collapseSame(cm: any) { cm.scrollIntoView(null, 50); } -function cm_toggleLineWrapping(cm: any) { - cm.setOption( - /* TODO: Interferes with collapseIdentical, always moves cursor to beginning */ - "lineWrapping", - !cm.getOption("lineWrapping") - ); - cm.setValue(cm.getValue()); - // cm.scrollIntoView(null, 50); // Always happens automatically -} - function cm_nextChange(cm: Editor) { cm.execCommand("goNextDiff"); cm.scrollIntoView(null, 50);