import{i as e,_ as t,n as i,e as r,t as n,s as o,b as l,I as s,a,x as c}from"./backend-ai-webui-CHZ-bl4E.js";const u=e`
  /* BASICS */
  .CodeMirror {
    /* Set height, width, borders, and global font properties here */
    font-family: monospace;
    height: auto;
    color: black;
    direction: ltr;
  }
  /* PADDING */
  .CodeMirror-lines {
    padding: 4px 0; /* Vertical padding around content */
  }
  .CodeMirror pre.CodeMirror-line,
  .CodeMirror pre.CodeMirror-line-like {
    padding: 0 4px; /* Horizontal padding of content */
  }
  .CodeMirror-scrollbar-filler,
  .CodeMirror-gutter-filler {
    background-color: white; /* The little square between H and V scrollbars */
  }
  /* GUTTER */
  .CodeMirror-gutters {
    border-right: 1px solid #ddd;
    background-color: #f7f7f7;
    white-space: nowrap;
  }
  .CodeMirror-linenumbers {
  }
  .CodeMirror-linenumber {
    padding: 0 3px 0 5px;
    min-width: 20px;
    text-align: right;
    color: #999;
    white-space: nowrap;
  }
  .CodeMirror-guttermarker {
    color: black;
  }
  .CodeMirror-guttermarker-subtle {
    color: #999;
  }
  /* CURSOR */
  .CodeMirror-cursor {
    border-left: 1px solid black;
    border-right: none;
    width: 0;
  }
  /* Shown when moving in bi-directional text */
  .CodeMirror div.CodeMirror-secondarycursor {
    border-left: 1px solid silver;
  }
  .cm-fat-cursor .CodeMirror-cursor {
    width: auto;
    border: 0 !important;
    background: #7e7;
  }
  .cm-fat-cursor div.CodeMirror-cursors {
    z-index: 1;
  }
  .cm-fat-cursor-mark {
    background-color: rgba(20, 255, 20, 0.5);
    -webkit-animation: blink 1.06s steps(1) infinite;
    -moz-animation: blink 1.06s steps(1) infinite;
    animation: blink 1.06s steps(1) infinite;
  }
  .cm-animate-fat-cursor {
    width: auto;
    border: 0;
    -webkit-animation: blink 1.06s steps(1) infinite;
    -moz-animation: blink 1.06s steps(1) infinite;
    animation: blink 1.06s steps(1) infinite;
    background-color: #7e7;
  }
  @-moz-keyframes blink {
    0% {
    }
    50% {
      background-color: transparent;
    }
    100% {
    }
  }
  @-webkit-keyframes blink {
    0% {
    }
    50% {
      background-color: transparent;
    }
    100% {
    }
  }
  @keyframes blink {
    0% {
    }
    50% {
      background-color: transparent;
    }
    100% {
    }
  }
  /* Can style cursor different in overwrite (non-insert) mode */
  .CodeMirror-overwrite .CodeMirror-cursor {
  }
  .cm-tab {
    display: inline-block;
    text-decoration: inherit;
  }
  .CodeMirror-rulers {
    position: absolute;
    left: 0;
    right: 0;
    top: -50px;
    bottom: 0;
    overflow: hidden;
  }
  .CodeMirror-ruler {
    border-left: 1px solid #ccc;
    top: 0;
    bottom: 0;
    position: absolute;
  }
  /* DEFAULT THEME */
  .cm-s-default .cm-header {
    color: blue;
  }
  .cm-s-default .cm-quote {
    color: #090;
  }
  .cm-negative {
    color: #d44;
  }
  .cm-positive {
    color: #292;
  }
  .cm-header,
  .cm-strong {
    font-weight: bold;
  }
  .cm-em {
    font-style: italic;
  }
  .cm-link {
    text-decoration: underline;
  }
  .cm-strikethrough {
    text-decoration: line-through;
  }
  .cm-s-default .cm-keyword {
    color: #708;
  }
  .cm-s-default .cm-atom {
    color: #219;
  }
  .cm-s-default .cm-number {
    color: #164;
  }
  .cm-s-default .cm-def {
    color: #00f;
  }
  .cm-s-default .cm-variable,
  .cm-s-default .cm-punctuation,
  .cm-s-default .cm-property,
  .cm-s-default .cm-operator {
  }
  .cm-s-default .cm-variable-2 {
    color: #05a;
  }
  .cm-s-default .cm-variable-3,
  .cm-s-default .cm-type {
    color: #085;
  }
  .cm-s-default .cm-comment {
    color: #a50;
  }
  .cm-s-default .cm-string {
    color: #a11;
  }
  .cm-s-default .cm-string-2 {
    color: #f50;
  }
  .cm-s-default .cm-meta {
    color: #555;
  }
  .cm-s-default .cm-qualifier {
    color: #555;
  }
  .cm-s-default .cm-builtin {
    color: #30a;
  }
  .cm-s-default .cm-bracket {
    color: #997;
  }
  .cm-s-default .cm-tag {
    color: #170;
  }
  .cm-s-default .cm-attribute {
    color: #00c;
  }
  .cm-s-default .cm-hr {
    color: #999;
  }
  .cm-s-default .cm-link {
    color: #00c;
  }
  .cm-s-default .cm-error {
    color: #f00;
  }
  .cm-invalidchar {
    color: #f00;
  }
  .CodeMirror-composing {
    border-bottom: 2px solid;
  }
  /* Default styles for common addons */
  div.CodeMirror span.CodeMirror-matchingbracket {
    color: #0b0;
  }
  div.CodeMirror span.CodeMirror-nonmatchingbracket {
    color: #a22;
  }
  .CodeMirror-matchingtag {
    background: rgba(255, 150, 0, 0.3);
  }
  .CodeMirror-activeline-background {
    background: #e8f2ff;
  }
  /* STOP */
  /* The rest of this file contains styles related to the mechanics of
      the editor. You probably shouldn't touch them. */
  .CodeMirror {
    position: relative;
    overflow: hidden;
    background: white;
  }
  .CodeMirror-scroll {
    overflow: scroll !important; /* Things will break if this is overridden */
    /* 50px is the magic margin used to hide the element's real scrollbars */
    /* See overflow: hidden in .CodeMirror */
    margin-bottom: -50px;
    margin-right: -50px;
    padding-bottom: 50px;
    height: 100%;
    outline: none; /* Prevent dragging from highlighting the element */
    position: relative;
  }
  .CodeMirror-sizer {
    position: relative;
    border-right: 50px solid transparent;
  }
  /* The fake, visible scrollbars. Used to force redraw during scrolling
      before actual scrolling happens, thus preventing shaking and
      flickering artifacts. */
  .CodeMirror-vscrollbar,
  .CodeMirror-hscrollbar,
  .CodeMirror-scrollbar-filler,
  .CodeMirror-gutter-filler {
    position: absolute;
    z-index: 6;
    display: none;
  }
  .CodeMirror-vscrollbar {
    right: 0;
    top: 0;
    overflow-x: hidden;
    overflow-y: scroll;
  }
  .CodeMirror-hscrollbar {
    bottom: 0;
    left: 0;
    overflow-y: hidden;
    overflow-x: scroll;
  }
  .CodeMirror-scrollbar-filler {
    right: 0;
    bottom: 0;
  }
  .CodeMirror-gutter-filler {
    left: 0;
    bottom: 0;
  }
  .CodeMirror-gutters {
    position: absolute;
    left: 0;
    top: 0;
    min-height: 100%;
    z-index: 3;
  }
  .CodeMirror-gutter {
    white-space: normal;
    height: 100%;
    display: inline-block;
    vertical-align: top;
    margin-bottom: -50px;
  }
  .CodeMirror-gutter-wrapper {
    position: absolute;
    z-index: 4;
    background: none !important;
    border: none !important;
  }
  .CodeMirror-gutter-background {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 4;
  }
  .CodeMirror-gutter-elt {
    position: absolute;
    cursor: default;
    z-index: 4;
  }
  .CodeMirror-gutter-wrapper ::selection {
    background-color: transparent;
  }
  .CodeMirror-gutter-wrapper ::-moz-selection {
    background-color: transparent;
  }
  .CodeMirror-lines {
    cursor: text;
    min-height: 1px; /* prevents collapsing before first draw */
  }
  .CodeMirror pre.CodeMirror-line,
  .CodeMirror pre.CodeMirror-line-like {
    /* Reset some styles that the rest of the page might have set */
    -moz-border-radius: 0;
    -webkit-border-radius: 0;
    border-radius: 0;
    border-width: 0;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    margin: 0;
    white-space: pre;
    word-wrap: normal;
    line-height: inherit;
    color: inherit;
    z-index: 2;
    position: relative;
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-variant-ligatures: contextual;
    font-variant-ligatures: contextual;
  }
  .CodeMirror-wrap pre.CodeMirror-line,
  .CodeMirror-wrap pre.CodeMirror-line-like {
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: normal;
  }
  .CodeMirror-linebackground {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 0;
  }
  .CodeMirror-linewidget {
    position: relative;
    z-index: 2;
    padding: 0.1px; /* Force widget margins to stay inside of the container */
  }
  .CodeMirror-widget {
  }
  .CodeMirror-rtl pre {
    direction: rtl;
  }
  .CodeMirror-code {
    outline: none;
  }
  /* Force content-box sizing for the elements where we expect it */
  .CodeMirror-scroll,
  .CodeMirror-sizer,
  .CodeMirror-gutter,
  .CodeMirror-gutters,
  .CodeMirror-linenumber {
    -moz-box-sizing: content-box;
    box-sizing: content-box;
  }
  .CodeMirror-measure {
    position: absolute;
    width: 100%;
    height: 0;
    overflow: hidden;
    visibility: hidden;
  }
  .CodeMirror-cursor {
    position: absolute;
    pointer-events: none;
  }
  .CodeMirror-measure pre {
    position: static;
  }
  div.CodeMirror-cursors {
    visibility: hidden;
    position: relative;
    z-index: 3;
  }
  div.CodeMirror-dragcursors {
    visibility: visible;
  }
  .CodeMirror-focused div.CodeMirror-cursors {
    visibility: visible;
  }
  .CodeMirror-selected {
    background: #d9d9d9;
  }
  .CodeMirror-focused .CodeMirror-selected {
    background: #d7d4f0;
  }
  .CodeMirror-crosshair {
    cursor: crosshair;
  }
  .CodeMirror-line::selection,
  .CodeMirror-line > span::selection,
  .CodeMirror-line > span > span::selection {
    background: #d7d4f0;
  }
  .CodeMirror-line::-moz-selection,
  .CodeMirror-line > span::-moz-selection,
  .CodeMirror-line > span > span::-moz-selection {
    background: #d7d4f0;
  }
  .cm-searching {
    background-color: #ffa;
    background-color: rgba(255, 255, 0, 0.4);
  }
  /* Used to force a border model for a node */
  .cm-force-border {
    padding-right: 0.1px;
  }
  @media print {
    /* Hide the cursor when printing */
    .CodeMirror div.CodeMirror-cursors {
      visibility: hidden;
    }
  }
  /* See issue #2901 */
  .cm-tab-wrap-hack:after {
    content: '';
  }
  /* Help users use markselection to safely style text background */
  span.CodeMirror-selectedtext {
    background: none;
  }
`,d=e`
  /* Based on Sublime Text's Monokai theme */

  .cm-s-monokai.CodeMirror {
    background: #272822;
    color: #f8f8f2;
  }
  .cm-s-monokai div.CodeMirror-selected {
    background: #49483e;
  }
  .cm-s-monokai .CodeMirror-line::selection,
  .cm-s-monokai .CodeMirror-line > span::selection,
  .cm-s-monokai .CodeMirror-line > span > span::selection {
    background: rgba(73, 72, 62, 0.99);
  }
  .cm-s-monokai .CodeMirror-line::-moz-selection,
  .cm-s-monokai .CodeMirror-line > span::-moz-selection,
  .cm-s-monokai .CodeMirror-line > span > span::-moz-selection {
    background: rgba(73, 72, 62, 0.99);
  }
  .cm-s-monokai .CodeMirror-gutters {
    background: #272822;
    border-right: 0px;
  }
  .cm-s-monokai .CodeMirror-guttermarker {
    color: white;
  }
  .cm-s-monokai .CodeMirror-guttermarker-subtle {
    color: #d0d0d0;
  }
  .cm-s-monokai .CodeMirror-linenumber {
    color: #d0d0d0;
  }
  .cm-s-monokai .CodeMirror-cursor {
    border-left: 1px solid #f8f8f0;
  }

  .cm-s-monokai span.cm-comment {
    color: #75715e;
  }
  .cm-s-monokai span.cm-atom {
    color: #ae81ff;
  }
  .cm-s-monokai span.cm-number {
    color: #ae81ff;
  }

  .cm-s-monokai span.cm-comment.cm-attribute {
    color: #97b757;
  }
  .cm-s-monokai span.cm-comment.cm-def {
    color: #bc9262;
  }
  .cm-s-monokai span.cm-comment.cm-tag {
    color: #bc6283;
  }
  .cm-s-monokai span.cm-comment.cm-type {
    color: #5998a6;
  }

  .cm-s-monokai span.cm-property,
  .cm-s-monokai span.cm-attribute {
    color: #a6e22e;
  }
  .cm-s-monokai span.cm-keyword {
    color: #f92672;
  }
  .cm-s-monokai span.cm-builtin {
    color: #66d9ef;
  }
  .cm-s-monokai span.cm-string {
    color: #e6db74;
  }

  .cm-s-monokai span.cm-variable {
    color: #f8f8f2;
  }
  .cm-s-monokai span.cm-variable-2 {
    color: #9effff;
  }
  .cm-s-monokai span.cm-variable-3,
  .cm-s-monokai span.cm-type {
    color: #66d9ef;
  }
  .cm-s-monokai span.cm-def {
    color: #fd971f;
  }
  .cm-s-monokai span.cm-bracket {
    color: #f8f8f2;
  }
  .cm-s-monokai span.cm-tag {
    color: #f92672;
  }
  .cm-s-monokai span.cm-header {
    color: #ae81ff;
  }
  .cm-s-monokai span.cm-link {
    color: #ae81ff;
  }
  .cm-s-monokai span.cm-error {
    background: #f92672;
    color: #f8f8f0;
  }

  .cm-s-monokai .CodeMirror-activeline-background {
    background: #373831;
  }
  .cm-s-monokai .CodeMirror-matchingbracket {
    text-decoration: underline;
    color: white !important;
  }
`;var h=navigator.userAgent,f=navigator.platform,p=/gecko\/\d/i.test(h),g=/MSIE \d/.test(h),m=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(h),b=/Edge\/(\d+)/.exec(h),y=g||m||b,v=y&&(g?document.documentMode||6:+(b||m)[1]),w=!b&&/WebKit\//.test(h),x=w&&/Qt\/\d+\.\d+/.test(h),C=!b&&/Chrome\//.test(h),k=/Opera\//.test(h),M=/Apple Computer/.test(navigator.vendor),S=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(h),L=/PhantomJS/.test(h),T=M&&(/Mobile\/\w+/.test(h)||navigator.maxTouchPoints>2),N=/Android/.test(h),A=T||N||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(h),O=T||/Mac/.test(f),D=/\bCrOS\b/.test(h),z=/win/i.test(f),W=k&&h.match(/Version\/(\d*\.\d*)/);W&&(W=Number(W[1])),W&&W>=15&&(k=!1,w=!0);var E=O&&(x||k&&(null==W||W<12.11)),H=p||y&&v>=9;function F(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var P,I=function(e,t){let i=e.className,r=F(t).exec(i);if(r){let t=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(t?r[1]+t:"")}};function R(e){for(let t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function B(e,t){return R(e).appendChild(t)}function _(e,t,i,r){let n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),"string"==typeof t)n.appendChild(document.createTextNode(t));else if(t)for(let e=0;e<t.length;++e)n.appendChild(t[e]);return n}function U(e,t,i,r){let n=_(e,t,i,r);return n.setAttribute("role","presentation"),n}function V(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do{if(11==t.nodeType&&(t=t.host),t==e)return!0}while(t=t.parentNode)}function G(){let e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function $(e,t){let i=e.className;F(t).test(i)||(e.className+=(i?" ":"")+t)}function K(e,t){let i=e.split(" ");for(let e=0;e<i.length;e++)i[e]&&!F(i[e]).test(t)&&(t+=" "+i[e]);return t}P=document.createRange?function(e,t,i,r){let n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:function(e,t,i){let r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(e){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};var j=function(e){e.select()};function q(e){let t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function X(e,t,i){t||(t={});for(let r in e)!e.hasOwnProperty(r)||!1===i&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function Y(e,t,i,r,n){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);for(let o=r||0,l=n||0;;){let r=e.indexOf("\t",o);if(r<0||r>=t)return l+(t-o);l+=r-o,l+=i-l%i,o=r+1}}T?j=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:y&&(j=function(e){try{e.select()}catch(e){}});var Z=class{constructor(){this.id=null,this.f=null,this.time=0,this.handler=q(this.onTimeout,this)}onTimeout(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)}set(e,t){this.f=t;const i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)}};function J(e,t){for(let i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var Q=50,ee={toString:function(){return"CodeMirror.Pass"}},te={scroll:!1},ie={origin:"*mouse"},re={origin:"+move"};function ne(e,t,i){for(let r=0,n=0;;){let o=e.indexOf("\t",r);-1==o&&(o=e.length);let l=o-r;if(o==e.length||n+l>=t)return r+Math.min(l,t-n);if(n+=o-r,n+=i-n%i,r=o+1,n>=t)return r}}var oe=[""];function le(e){for(;oe.length<=e;)oe.push(se(oe)+" ");return oe[e]}function se(e){return e[e.length-1]}function ae(e,t){let i=[];for(let r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function ce(){}function ue(e,t){let i;return Object.create?i=Object.create(e):(ce.prototype=e,i=new ce),t&&X(t,i),i}var de=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function he(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||de.test(e))}function fe(e,t){return t?!!(t.source.indexOf("\\w")>-1&&he(e))||t.test(e):he(e)}function pe(e){for(let t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ge=/[\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 me(e){return e.charCodeAt(0)>=768&&ge.test(e)}function be(e,t,i){for(;(i<0?t>0:t<e.length)&&me(e.charAt(t));)t+=i;return t}function ye(e,t,i){let r=t>i?-1:1;for(;;){if(t==i)return t;let n=(t+i)/2,o=r<0?Math.ceil(n):Math.floor(n);if(o==t)return e(o)?t:i;e(o)?i=o:t=o+r}}var ve=null;function we(e,t,i){let r;ve=null;for(let n=0;n<e.length;++n){let o=e[n];if(o.from<t&&o.to>t)return n;o.to==t&&(o.from!=o.to&&"before"==i?r=n:ve=n),o.from==t&&(o.from!=o.to&&"before"!=i?r=n:ve=n)}return null!=r?r:ve}var xe=function(){let e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,i=/[LRr]/,r=/[Lb1n]/,n=/[1n]/;function o(e,t,i){this.level=e,this.from=t,this.to=i}return function(l,s){let a="ltr"==s?"L":"R";if(0==l.length||"ltr"==s&&!e.test(l))return!1;let c=l.length,u=[];for(let e=0;e<c;++e)u.push((d=l.charCodeAt(e))<=247?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(d):1424<=d&&d<=1524?"R":1536<=d&&d<=1785?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(d-1536):1774<=d&&d<=2220?"r":8192<=d&&d<=8203?"w":8204==d?"b":"L");var d;for(let e=0,t=a;e<c;++e){let i=u[e];"m"==i?u[e]=t:t=i}for(let e=0,t=a;e<c;++e){let r=u[e];"1"==r&&"r"==t?u[e]="n":i.test(r)&&(t=r,"r"==r&&(u[e]="R"))}for(let e=1,t=u[0];e<c-1;++e){let i=u[e];"+"==i&&"1"==t&&"1"==u[e+1]?u[e]="1":","!=i||t!=u[e+1]||"1"!=t&&"n"!=t||(u[e]=t),t=i}for(let e=0;e<c;++e){let t=u[e];if(","==t)u[e]="N";else if("%"==t){let t;for(t=e+1;t<c&&"%"==u[t];++t);let i=e&&"!"==u[e-1]||t<c&&"1"==u[t]?"1":"N";for(let r=e;r<t;++r)u[r]=i;e=t-1}}for(let e=0,t=a;e<c;++e){let r=u[e];"L"==t&&"1"==r?u[e]="L":i.test(r)&&(t=r)}for(let e=0;e<c;++e)if(t.test(u[e])){let i;for(i=e+1;i<c&&t.test(u[i]);++i);let r="L"==(e?u[e-1]:a),n=r==("L"==(i<c?u[i]:a))?r?"L":"R":a;for(let t=e;t<i;++t)u[t]=n;e=i-1}let h,f=[];for(let e=0;e<c;)if(r.test(u[e])){let t=e;for(++e;e<c&&r.test(u[e]);++e);f.push(new o(0,t,e))}else{let t=e,i=f.length,r="rtl"==s?1:0;for(++e;e<c&&"L"!=u[e];++e);for(let l=t;l<e;)if(n.test(u[l])){t<l&&(f.splice(i,0,new o(1,t,l)),i+=r);let s=l;for(++l;l<e&&n.test(u[l]);++l);f.splice(i,0,new o(2,s,l)),i+=r,t=l}else++l;t<e&&f.splice(i,0,new o(1,t,e))}return"ltr"==s&&(1==f[0].level&&(h=l.match(/^\s+/))&&(f[0].from=h[0].length,f.unshift(new o(0,0,h[0].length))),1==se(f).level&&(h=l.match(/\s+$/))&&(se(f).to-=h[0].length,f.push(new o(0,c-h[0].length,c)))),"rtl"==s?f.reverse():f}}();function Ce(e,t){let i=e.order;return null==i&&(i=e.order=xe(e.text,t)),i}var ke=[],Me=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{let r=e._handlers||(e._handlers={});r[t]=(r[t]||ke).concat(i)}};function Se(e,t){return e._handlers&&e._handlers[t]||ke}function Le(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{let r=e._handlers,n=r&&r[t];if(n){let e=J(n,i);e>-1&&(r[t]=n.slice(0,e).concat(n.slice(e+1)))}}}function Te(e,t){let i=Se(e,t);if(!i.length)return;let r=Array.prototype.slice.call(arguments,2);for(let e=0;e<i.length;++e)i[e].apply(null,r)}function Ne(e,t,i){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Te(e,i||t.type,e,t),Ee(t)||t.codemirrorIgnore}function Ae(e){let t=e._handlers&&e._handlers.cursorActivity;if(!t)return;let i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(let e=0;e<t.length;++e)-1==J(i,t[e])&&i.push(t[e])}function Oe(e,t){return Se(e,t).length>0}function De(e){e.prototype.on=function(e,t){Me(this,e,t)},e.prototype.off=function(e,t){Le(this,e,t)}}function ze(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function We(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Ee(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function He(e){ze(e),We(e)}function Fe(e){return e.target||e.srcElement}function Pe(e){let t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),O&&e.ctrlKey&&1==t&&(t=3),t}var Ie,Re,Be=function(){if(y&&v<9)return!1;let e=_("div");return"draggable"in e||"dragDrop"in e}();function _e(e){if(null==Ie){let t=_("span","​");B(e,_("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ie=t.offsetWidth<=1&&t.offsetHeight>2&&!(y&&v<8))}let t=Ie?_("span","​"):_("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return t.setAttribute("cm-text",""),t}function Ue(e){if(null!=Re)return Re;let t=B(e,document.createTextNode("AخA")),i=P(t,0,1).getBoundingClientRect(),r=P(t,1,2).getBoundingClientRect();return R(e),!(!i||i.left==i.right)&&(Re=r.right-i.right<3)}var Ve=3!="\n\nb".split(/\n/).length?e=>{let t=0,i=[],r=e.length;for(;t<=r;){let r=e.indexOf("\n",t);-1==r&&(r=e.length);let n=e.slice(t,"\r"==e.charAt(r-1)?r-1:r),o=n.indexOf("\r");-1!=o?(i.push(n.slice(0,o)),t+=o+1):(i.push(n),t=r+1)}return i}:e=>e.split(/\r\n?|\n/),Ge=window.getSelection?e=>{try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:e=>{let t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},$e=(()=>{let e=_("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)})(),Ke=null;var je={},qe={};function Xe(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),je[e]=t}function Ye(e){if("string"==typeof e&&qe.hasOwnProperty(e))e=qe[e];else if(e&&"string"==typeof e.name&&qe.hasOwnProperty(e.name)){let t=qe[e.name];"string"==typeof t&&(t={name:t}),(e=ue(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ye("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ye("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ze(e,t){t=Ye(t);let i=je[t.name];if(!i)return Ze(e,"text/plain");let r=i(e,t);if(Je.hasOwnProperty(t.name)){let e=Je[t.name];for(let t in e)e.hasOwnProperty(t)&&(r.hasOwnProperty(t)&&(r["_"+t]=r[t]),r[t]=e[t])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(let e in t.modeProps)r[e]=t.modeProps[e];return r}var Je={};function Qe(e,t){X(t,Je.hasOwnProperty(e)?Je[e]:Je[e]={})}function et(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);let i={};for(let e in t){let r=t[e];r instanceof Array&&(r=r.concat([])),i[e]=r}return i}function tt(e,t){let i;for(;e.innerMode&&(i=e.innerMode(t),i&&i.mode!=e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function it(e,t,i){return!e.startState||e.startState(t,i)}var rt=class{constructor(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}eol(){return this.pos>=this.string.length}sol(){return this.pos==this.lineStart}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t,i=this.string.charAt(this.pos);if(t="string"==typeof e?i==e:i&&(e.test?e.test(i):e(i)),t)return++this.pos,i}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Y(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)}indentation(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)}match(e,t,i){if("string"!=typeof e){let i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&!1!==t&&(this.pos+=i[0].length),i)}{let r=e=>i?e.toLowerCase():e;if(r(this.string.substr(this.pos,e.length))==r(e))return!1!==t&&(this.pos+=e.length),!0}}current(){return this.string.slice(this.start,this.pos)}hideFirstChars(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}lookAhead(e){let t=this.lineOracle;return t&&t.lookAhead(e)}baseToken(){let e=this.lineOracle;return e&&e.baseToken(this.pos)}};function nt(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");let i=e;for(;!i.lines;)for(let e=0;;++e){let r=i.children[e],n=r.chunkSize();if(t<n){i=r;break}t-=n}return i.lines[t]}function ot(e,t,i){let r=[],n=t.line;return e.iter(t.line,i.line+1,(e=>{let o=e.text;n==i.line&&(o=o.slice(0,i.ch)),n==t.line&&(o=o.slice(t.ch)),r.push(o),++n})),r}function lt(e,t,i){let r=[];return e.iter(t,i,(e=>{r.push(e.text)})),r}function st(e,t){let i=t-e.height;if(i)for(let t=e;t;t=t.parent)t.height+=i}function at(e){if(null==e.parent)return null;let t=e.parent,i=J(t.lines,e);for(let e=t.parent;e;t=e,e=e.parent)for(let r=0;e.children[r]!=t;++r)i+=e.children[r].chunkSize();return i+t.first}function ct(e,t){let i=e.first;e:do{for(let r=0;r<e.children.length;++r){let n=e.children[r],o=n.height;if(t<o){e=n;continue e}t-=o,i+=n.chunkSize()}return i}while(!e.lines);let r=0;for(;r<e.lines.length;++r){let i=e.lines[r].height;if(t<i)break;t-=i}return i+r}function ut(e,t){return t>=e.first&&t<e.first+e.size}function dt(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function ht(e,t,i=null){if(!(this instanceof ht))return new ht(e,t,i);this.line=e,this.ch=t,this.sticky=i}function ft(e,t){return e.line-t.line||e.ch-t.ch}function pt(e,t){return e.sticky==t.sticky&&0==ft(e,t)}function gt(e){return ht(e.line,e.ch)}function mt(e,t){return ft(e,t)<0?t:e}function bt(e,t){return ft(e,t)<0?e:t}function yt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function vt(e,t){if(t.line<e.first)return ht(e.first,0);let i=e.first+e.size-1;return t.line>i?ht(i,nt(e,i).text.length):function(e,t){let i=e.ch;return null==i||i>t?ht(e.line,t):i<0?ht(e.line,0):e}(t,nt(e,t.line).text.length)}function wt(e,t){let i=[];for(let r=0;r<t.length;r++)i[r]=vt(e,t[r]);return i}var xt=class{constructor(e,t){this.state=e,this.lookAhead=t}},Ct=class{constructor(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1}lookAhead(e){let t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t}baseToken(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;let t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}}nextLine(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--}static fromSaved(e,t,i){return t instanceof xt?new Ct(e,et(e.mode,t.state),i,t.lookAhead):new Ct(e,et(e.mode,t),i)}save(e){let t=!1!==e?et(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new xt(t,this.maxLookAhead):t}};function kt(e,t,i,r){let n=[e.state.modeGen],o={};zt(e,t.text,e.doc.mode,i,((e,t)=>n.push(e,t)),o,r);let l=i.state;for(let r=0;r<e.state.overlays.length;++r){i.baseTokens=n;let s=e.state.overlays[r],a=1,c=0;i.state=!0,zt(e,t.text,s.mode,i,((e,t)=>{let i=a;for(;c<e;){let t=n[a];t>e&&n.splice(a,1,e,n[a+1],t),a+=2,c=Math.min(e,t)}if(t)if(s.opaque)n.splice(i,a-i,e,"overlay "+t),a=i+2;else for(;i<a;i+=2){let e=n[i+1];n[i+1]=(e?e+" ":"")+"overlay "+t}}),o),i.state=l,i.baseTokens=null,i.baseTokenPos=1}return{styles:n,classes:o.bgClass||o.textClass?o:null}}function Mt(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){let r=St(e,at(t)),n=t.text.length>e.options.maxHighlightLength&&et(e.doc.mode,r.state),o=kt(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=o.styles,o.classes?t.styleClasses=o.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 St(e,t,i){let r=e.doc,n=e.display;if(!r.mode.startState)return new Ct(r,!0,t);let o=function(e,t,i){let r,n,o=e.doc,l=i?-1:t-(e.doc.mode.innerMode?1e3:100);for(let s=t;s>l;--s){if(s<=o.first)return o.first;let t=nt(o,s-1),l=t.stateAfter;if(l&&(!i||s+(l instanceof xt?l.lookAhead:0)<=o.modeFrontier))return s;let a=Y(t.text,null,e.options.tabSize);(null==n||r>a)&&(n=s-1,r=a)}return n}(e,t,i),l=o>r.first&&nt(r,o-1).stateAfter,s=l?Ct.fromSaved(r,l,o):new Ct(r,it(r.mode),o);return r.iter(o,t,(i=>{Lt(e,i.text,s);let r=s.line;i.stateAfter=r==t-1||r%5==0||r>=n.viewFrom&&r<n.viewTo?s.save():null,s.nextLine()})),i&&(r.modeFrontier=s.line),s}function Lt(e,t,i,r){let n=e.doc.mode,o=new rt(t,e.options.tabSize,i);for(o.start=o.pos=r||0,""==t&&Tt(n,i.state);!o.eol();)Nt(n,o,i.state),o.start=o.pos}function Tt(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;let i=tt(e,t);return i.mode.blankLine?i.mode.blankLine(i.state):void 0}function Nt(e,t,i,r){for(let n=0;n<10;n++){r&&(r[0]=tt(e,i).mode);let n=e.token(t,i);if(t.pos>t.start)return n}throw new Error("Mode "+e.name+" failed to advance stream.")}var At=class{constructor(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i}};function Ot(e,t,i,r){let n,o,l=e.doc,s=l.mode,a=nt(l,(t=vt(l,t)).line),c=St(e,t.line,i),u=new rt(a.text,e.options.tabSize,c);for(r&&(o=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,n=Nt(s,u,c.state),r&&o.push(new At(u,n,et(l.mode,c.state)));return r?o:new At(u,n,c.state)}function Dt(e,t){if(e)for(;;){let i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);let r=i[1]?"bgClass":"textClass";null==t[r]?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function zt(e,t,i,r,n,o,l){let s=i.flattenSpans;null==s&&(s=e.options.flattenSpans);let a,c=0,u=null,d=new rt(t,e.options.tabSize,r),h=e.options.addModeClass&&[null];for(""==t&&Dt(Tt(i,r.state),o);!d.eol();){if(d.pos>e.options.maxHighlightLength?(s=!1,l&&Lt(e,t,r,d.pos),d.pos=t.length,a=null):a=Dt(Nt(i,d,r.state,h),o),h){let e=h[0].name;e&&(a="m-"+(a?e+" "+a:e))}if(!s||u!=a){for(;c<d.start;)c=Math.min(d.start,c+5e3),n(c,u);u=a}d.start=d.pos}for(;c<d.pos;){let e=Math.min(d.pos,c+5e3);n(e,u),c=e}}var Wt=!1,Et=!1;function Ht(e,t,i){this.marker=e,this.from=t,this.to=i}function Ft(e,t){if(e)for(let i=0;i<e.length;++i){let r=e[i];if(r.marker==t)return r}}function Pt(e,t){let i;for(let r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function It(e,t){if(t.full)return null;let i=ut(e,t.from.line)&&nt(e,t.from.line).markedSpans,r=ut(e,t.to.line)&&nt(e,t.to.line).markedSpans;if(!i&&!r)return null;let n=t.from.ch,o=t.to.ch,l=0==ft(t.from,t.to),s=function(e,t,i){let r;if(e)for(let n=0;n<e.length;++n){let o=e[n],l=o.marker;if(null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t)||o.from==t&&"bookmark"==l.type&&(!i||!o.marker.insertLeft)){let e=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(r||(r=[])).push(new Ht(l,o.from,e?null:o.to))}}return r}(i,n,l),a=function(e,t,i){let r;if(e)for(let n=0;n<e.length;++n){let o=e[n],l=o.marker;if(null==o.to||(l.inclusiveRight?o.to>=t:o.to>t)||o.from==t&&"bookmark"==l.type&&(!i||o.marker.insertLeft)){let e=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(r||(r=[])).push(new Ht(l,e?null:o.from-t,null==o.to?null:o.to-t))}}return r}(r,o,l),c=1==t.text.length,u=se(t.text).length+(c?n:0);if(s)for(let e=0;e<s.length;++e){let t=s[e];if(null==t.to){let e=Ft(a,t.marker);e?c&&(t.to=null==e.to?null:e.to+u):t.to=n}}if(a)for(let e=0;e<a.length;++e){let t=a[e];if(null!=t.to&&(t.to+=u),null==t.from){Ft(s,t.marker)||(t.from=u,c&&(s||(s=[])).push(t))}else t.from+=u,c&&(s||(s=[])).push(t)}s&&(s=Rt(s)),a&&a!=s&&(a=Rt(a));let d=[s];if(!c){let e,i=t.text.length-2;if(i>0&&s)for(let t=0;t<s.length;++t)null==s[t].to&&(e||(e=[])).push(new Ht(s[t].marker,null,null));for(let t=0;t<i;++t)d.push(e);d.push(a)}return d}function Rt(e){for(let t=0;t<e.length;++t){let i=e[t];null!=i.from&&i.from==i.to&&!1!==i.marker.clearWhenEmpty&&e.splice(t--,1)}return e.length?e:null}function Bt(e){let t=e.markedSpans;if(t){for(let i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}}function _t(e,t){if(t){for(let i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}}function Ut(e){return e.inclusiveLeft?-1:0}function Vt(e){return e.inclusiveRight?1:0}function Gt(e,t){let i=e.lines.length-t.lines.length;if(0!=i)return i;let r=e.find(),n=t.find(),o=ft(r.from,n.from)||Ut(e)-Ut(t);if(o)return-o;let l=ft(r.to,n.to)||Vt(e)-Vt(t);return l||t.id-e.id}function $t(e,t){let i,r=Et&&e.markedSpans;if(r)for(let e,n=0;n<r.length;++n)e=r[n],e.marker.collapsed&&null==(t?e.from:e.to)&&(!i||Gt(i,e.marker)<0)&&(i=e.marker);return i}function Kt(e){return $t(e,!0)}function jt(e){return $t(e,!1)}function qt(e,t){let i,r=Et&&e.markedSpans;if(r)for(let e=0;e<r.length;++e){let n=r[e];n.marker.collapsed&&(null==n.from||n.from<t)&&(null==n.to||n.to>t)&&(!i||Gt(i,n.marker)<0)&&(i=n.marker)}return i}function Xt(e,t,i,r,n){let o=nt(e,t),l=Et&&o.markedSpans;if(l)for(let e=0;e<l.length;++e){let t=l[e];if(!t.marker.collapsed)continue;let o=t.marker.find(0),s=ft(o.from,i)||Ut(t.marker)-Ut(n),a=ft(o.to,r)||Vt(t.marker)-Vt(n);if(!(s>=0&&a<=0||s<=0&&a>=0)&&(s<=0&&(t.marker.inclusiveRight&&n.inclusiveLeft?ft(o.to,i)>=0:ft(o.to,i)>0)||s>=0&&(t.marker.inclusiveRight&&n.inclusiveLeft?ft(o.from,r)<=0:ft(o.from,r)<0)))return!0}}function Yt(e){let t;for(;t=Kt(e);)e=t.find(-1,!0).line;return e}function Zt(e,t){let i=nt(e,t),r=Yt(i);return i==r?t:at(r)}function Jt(e,t){if(t>e.lastLine())return t;let i,r=nt(e,t);if(!Qt(e,r))return t;for(;i=jt(r);)r=i.find(1,!0).line;return at(r)+1}function Qt(e,t){let i=Et&&t.markedSpans;if(i)for(let r,n=0;n<i.length;++n)if(r=i[n],r.marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&ei(e,t,r))return!0}}function ei(e,t,i){if(null==i.to){let t=i.marker.find(1,!0);return ei(e,t.line,Ft(t.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(let r,n=0;n<t.markedSpans.length;++n)if(r=t.markedSpans[n],r.marker.collapsed&&!r.marker.widgetNode&&r.from==i.to&&(null==r.to||r.to!=i.from)&&(r.marker.inclusiveLeft||i.marker.inclusiveRight)&&ei(e,t,r))return!0}function ti(e){let t=0,i=(e=Yt(e)).parent;for(let r=0;r<i.lines.length;++r){let n=i.lines[r];if(n==e)break;t+=n.height}for(let e=i.parent;e;i=e,e=i.parent)for(let r=0;r<e.children.length;++r){let n=e.children[r];if(n==i)break;t+=n.height}return t}function ii(e){if(0==e.height)return 0;let t,i=e.text.length,r=e;for(;t=Kt(r);){let e=t.find(0,!0);r=e.from.line,i+=e.from.ch-e.to.ch}for(r=e;t=jt(r);){let e=t.find(0,!0);i-=r.text.length-e.from.ch,r=e.to.line,i+=r.text.length-e.to.ch}return i}function ri(e){let t=e.display,i=e.doc;t.maxLine=nt(i,i.first),t.maxLineLength=ii(t.maxLine),t.maxLineChanged=!0,i.iter((e=>{let i=ii(e);i>t.maxLineLength&&(t.maxLineLength=i,t.maxLine=e)}))}var ni=class{constructor(e,t,i){this.text=e,_t(this,t),this.height=i?i(this):1}lineNo(){return at(this)}};function oi(e){e.parent=null,Bt(e)}De(ni);var li={},si={};function ai(e,t){if(!e||/^\s*$/.test(e))return null;let i=t.addModeClass?si:li;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function ci(e,t){let i=U("span",null,null,w?"padding-right: .1px":null),r={pre:U("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(let i=0;i<=(t.rest?t.rest.length:0);i++){let n,o=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=di,Ue(e.display.measure)&&(n=Ce(o,e.doc.direction))&&(r.addToken=hi(r.addToken,n)),r.map=[],pi(o,r,Mt(e,o,t!=e.display.externalMeasured&&at(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=K(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=K(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(_e(e.display.measure))),0==i?(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(w){let e=r.content.lastChild;(/\bcm-tab\b/.test(e.className)||e.querySelector&&e.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=K(r.pre.className,r.textClass||"")),r}function ui(e){let t=_("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function di(e,t,i,r,n,o,l){if(!t)return;let s,a=e.splitSpaces?function(e,t){if(e.length>1&&!/  /.test(e))return e;let i=t,r="";for(let t=0;t<e.length;t++){let n=e.charAt(t);" "!=n||!i||t!=e.length-1&&32!=e.charCodeAt(t+1)||(n=" "),r+=n,i=" "==n}return r}(t,e.trailingSpace):t,c=e.cm.state.specialChars,u=!1;if(c.test(t)){s=document.createDocumentFragment();let i=0;for(;;){c.lastIndex=i;let r,n=c.exec(t),o=n?n.index-i:t.length-i;if(o){let t=document.createTextNode(a.slice(i,i+o));y&&v<9?s.appendChild(_("span",[t])):s.appendChild(t),e.map.push(e.pos,e.pos+o,t),e.col+=o,e.pos+=o}if(!n)break;if(i+=o+1,"\t"==n[0]){let t=e.cm.options.tabSize,i=t-e.col%t;r=s.appendChild(_("span",le(i),"cm-tab")),r.setAttribute("role","presentation"),r.setAttribute("cm-text","\t"),e.col+=i}else"\r"==n[0]||"\n"==n[0]?(r=s.appendChild(_("span","\r"==n[0]?"␍":"␤","cm-invalidchar")),r.setAttribute("cm-text",n[0]),e.col+=1):(r=e.cm.options.specialCharPlaceholder(n[0]),r.setAttribute("cm-text",n[0]),y&&v<9?s.appendChild(_("span",[r])):s.appendChild(r),e.col+=1);e.map.push(e.pos,e.pos+1,r),e.pos++}}else e.col+=t.length,s=document.createTextNode(a),e.map.push(e.pos,e.pos+t.length,s),y&&v<9&&(u=!0),e.pos+=t.length;if(e.trailingSpace=32==a.charCodeAt(t.length-1),i||r||n||u||o||l){let t=i||"";r&&(t+=r),n&&(t+=n);let a=_("span",[s],t,o);if(l)for(let e in l)l.hasOwnProperty(e)&&"style"!=e&&"class"!=e&&a.setAttribute(e,l[e]);return e.content.appendChild(a)}e.content.appendChild(s)}function hi(e,t){return(i,r,n,o,l,s,a)=>{n=n?n+" cm-force-border":"cm-force-border";let c=i.pos,u=c+r.length;for(;;){let d;for(let e=0;e<t.length&&(d=t[e],!(d.to>c&&d.from<=c));e++);if(d.to>=u)return e(i,r,n,o,l,s,a);e(i,r.slice(0,d.to-c),n,o,null,s,a),o=null,r=r.slice(d.to-c),c=d.to}}}function fi(e,t,i,r){let 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 pi(e,t,i){let r=e.markedSpans,n=e.text,o=0;if(!r){for(let e=1;e<i.length;e+=2)t.addToken(t,n.slice(o,o=i[e]),ai(i[e+1],t.cm.options));return}let l,s,a,c,u,d,h,f=n.length,p=0,g=1,m="",b=0;for(;;){if(b==p){a=c=u=s="",h=null,d=null,b=1/0;let e,i=[];for(let t=0;t<r.length;++t){let n=r[t],o=n.marker;if("bookmark"==o.type&&n.from==p&&o.widgetNode)i.push(o);else if(n.from<=p&&(null==n.to||n.to>p||o.collapsed&&n.to==p&&n.from==p)){if(null!=n.to&&n.to!=p&&b>n.to&&(b=n.to,c=""),o.className&&(a+=" "+o.className),o.css&&(s=(s?s+";":"")+o.css),o.startStyle&&n.from==p&&(u+=" "+o.startStyle),o.endStyle&&n.to==b&&(e||(e=[])).push(o.endStyle,n.to),o.title&&((h||(h={})).title=o.title),o.attributes)for(let e in o.attributes)(h||(h={}))[e]=o.attributes[e];o.collapsed&&(!d||Gt(d.marker,o)<0)&&(d=n)}else n.from>p&&b>n.from&&(b=n.from)}if(e)for(let t=0;t<e.length;t+=2)e[t+1]==b&&(c+=" "+e[t]);if(!d||d.from==p)for(let e=0;e<i.length;++e)fi(t,0,i[e]);if(d&&(d.from||0)==p){if(fi(t,(null==d.to?f+1:d.to)-p,d.marker,null==d.from),null==d.to)return;d.to==p&&(d=!1)}}if(p>=f)break;let e=Math.min(f,b);for(;;){if(m){let i=p+m.length;if(!d){let r=i>e?m.slice(0,e-p):m;t.addToken(t,r,l?l+a:a,u,p+r.length==b?c:"",s,h)}if(i>=e){m=m.slice(e-p),p=e;break}p=i,u=""}m=n.slice(o,o=i[g++]),l=ai(i[g++],t.cm.options)}}}function gi(e,t,i){this.line=t,this.rest=function(e){let t,i;for(;t=jt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}(t),this.size=this.rest?at(se(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Qt(e,t)}function mi(e,t,i){let r,n=[];for(let o=t;o<i;o=r){let t=new gi(e.doc,nt(e.doc,o),o);r=o+t.size,n.push(t)}return n}var bi=null;var yi=null;function vi(e,t){let i=Se(e,t);if(!i.length)return;let r,n=Array.prototype.slice.call(arguments,2);bi?r=bi.delayedCallbacks:yi?r=yi:(r=yi=[],setTimeout(wi,0));for(let e=0;e<i.length;++e)r.push((()=>i[e].apply(null,n)))}function wi(){let e=yi;yi=null;for(let t=0;t<e.length;++t)e[t]()}function xi(e,t,i,r){for(let n=0;n<t.changes.length;n++){let o=t.changes[n];"text"==o?Mi(e,t):"gutter"==o?Li(e,t,i,r):"class"==o?Si(e,t):"widget"==o&&Ti(e,t,r)}t.changes=null}function Ci(e){return e.node==e.text&&(e.node=_("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),y&&v<8&&(e.node.style.zIndex=2)),e.node}function ki(e,t){let i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):ci(e,t)}function Mi(e,t){let i=t.text.className,r=ki(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,Si(e,t)):i&&(t.text.className=i)}function Si(e,t){!function(e,t){let i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){let r=Ci(t);t.background=r.insertBefore(_("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}(e,t),t.line.wrapClass?Ci(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");let i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Li(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){let i=Ci(t);t.gutterBackground=_("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,`left: ${e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth}px; width: ${r.gutterTotalWidth}px`),e.display.input.setUneditable(t.gutterBackground),i.insertBefore(t.gutterBackground,t.text)}let n=t.line.gutterMarkers;if(e.options.lineNumbers||n){let o=Ci(t),l=t.gutter=_("div",null,"CodeMirror-gutter-wrapper",`left: ${e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth}px`);if(l.setAttribute("aria-hidden","true"),e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||n&&n["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(_("div",dt(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt",`left: ${r.gutterLeft["CodeMirror-linenumbers"]}px; width: ${e.display.lineNumInnerWidth}px`))),n)for(let t=0;t<e.display.gutterSpecs.length;++t){let i=e.display.gutterSpecs[t].className,o=n.hasOwnProperty(i)&&n[i];o&&l.appendChild(_("div",[o],"CodeMirror-gutter-elt",`left: ${r.gutterLeft[i]}px; width: ${r.gutterWidth[i]}px`))}}}function Ti(e,t,i){t.alignable&&(t.alignable=null);let r=F("CodeMirror-linewidget");for(let e,i=t.node.firstChild;i;i=e)e=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);Ai(e,t,i)}function Ni(e,t,i,r){let n=ki(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),Si(e,t),Li(e,t,i,r),Ai(e,t,r),t.node}function Ai(e,t,i){if(Oi(e,t.line,t,i,!0),t.rest)for(let r=0;r<t.rest.length;r++)Oi(e,t.rest[r],t,i,!1)}function Oi(e,t,i,r,n){if(!t.widgets)return;let o=Ci(i);for(let l=0,s=t.widgets;l<s.length;++l){let t=s[l],a=_("div",[t.node],"CodeMirror-linewidget"+(t.className?" "+t.className:""));t.handleMouseEvents||a.setAttribute("cm-ignore-events","true"),Di(t,a,i,r),e.display.input.setUneditable(a),n&&t.above?o.insertBefore(a,i.gutter||i.text):o.appendChild(a),vi(t,"redraw")}}function Di(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);let n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function zi(e){if(null!=e.height)return e.height;let t=e.doc.cm;if(!t)return 0;if(!V(document.body,e.node)){let i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),B(t.display.measure,_("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function Wi(e,t){for(let i=Fe(t);i!=e.wrapper;i=i.parentNode)if(!i||1==i.nodeType&&"true"==i.getAttribute("cm-ignore-events")||i.parentNode==e.sizer&&i!=e.mover)return!0}function Ei(e){return e.lineSpace.offsetTop}function Hi(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Fi(e){if(e.cachedPaddingH)return e.cachedPaddingH;let t=B(e.measure,_("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function Pi(e){return Q-e.display.nativeBarWidth}function Ii(e){return e.display.scroller.clientWidth-Pi(e)-e.display.barWidth}function Ri(e){return e.display.scroller.clientHeight-Pi(e)-e.display.barHeight}function Bi(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(let i=0;i<e.rest.length;i++)if(e.rest[i]==t)return{map:e.measure.maps[i],cache:e.measure.caches[i]};for(let t=0;t<e.rest.length;t++)if(at(e.rest[t])>i)return{map:e.measure.maps[t],cache:e.measure.caches[t],before:!0}}function _i(e,t,i,r){return Gi(e,Vi(e,t),i,r)}function Ui(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[xr(e,t)];let i=e.display.externalMeasured;return i&&t>=i.lineN&&t<i.lineN+i.size?i:void 0}function Vi(e,t){let i=at(t),r=Ui(e,i);r&&!r.text?r=null:r&&r.changes&&(xi(e,r,i,mr(e)),e.curOp.forceUpdate=!0),r||(r=function(e,t){let i=at(t=Yt(t)),r=e.display.externalMeasured=new gi(e.doc,t,i);r.lineN=i;let n=r.built=ci(e,r);return r.text=n.pre,B(e.display.lineMeasure,n.pre),r}(e,t));let n=Bi(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function Gi(e,t,i,r,n){t.before&&(i=-1);let o,l=i+(r||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(!function(e,t,i){let r=e.options.lineWrapping,n=r&&Ii(e);if(!t.measure.heights||r&&t.measure.width!=n){let e=t.measure.heights=[];if(r){t.measure.width=n;let r=t.text.firstChild.getClientRects();for(let t=0;t<r.length-1;t++){let n=r[t],o=r[t+1];Math.abs(n.bottom-o.bottom)>2&&e.push((n.bottom+o.top)/2-i.top)}}e.push(i.bottom-i.top)}}(e,t.view,t.rect),t.hasHeights=!0),o=function(e,t,i,r){let n,o=ji(t.map,i,r),l=o.node,s=o.start,a=o.end,c=o.collapse;if(3==l.nodeType){for(let e=0;e<4;e++){for(;s&&me(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&me(t.line.text.charAt(o.coverStart+a));)++a;if(n=y&&v<9&&0==s&&a==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():qi(P(l,s,a).getClientRects(),r),n.left||n.right||0==s)break;a=s,s-=1,c="right"}y&&v<11&&(n=function(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(e){if(null!=Ke)return Ke;let t=B(e,_("span","x")),i=t.getBoundingClientRect(),r=P(t,0,1).getBoundingClientRect();return Ke=Math.abs(i.left-r.left)>1}(e))return t;let i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,n))}else{let t;s>0&&(c=r="right"),n=e.options.lineWrapping&&(t=l.getClientRects()).length>1?t["right"==r?t.length-1:0]:l.getBoundingClientRect()}if(y&&v<9&&!s&&(!n||!n.left&&!n.right)){let t=l.parentNode.getClientRects()[0];n=t?{left:t.left,right:t.left+gr(e.display),top:t.top,bottom:t.bottom}:Ki}let u=n.top-t.rect.top,d=n.bottom-t.rect.top,h=(u+d)/2,f=t.view.measure.heights,p=0;for(;p<f.length-1&&!(h<f[p]);p++);let g=p?f[p-1]:0,m=f[p],b={left:("right"==c?n.right:n.left)-t.rect.left,right:("left"==c?n.left:n.right)-t.rect.left,top:g,bottom:m};n.left||n.right||(b.bogus=!0);e.options.singleCursorHeightPerLine||(b.rtop=u,b.rbottom=d);return b}(e,t,i,r),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:n?o.rtop:o.top,bottom:n?o.rbottom:o.bottom}}var $i,Ki={left:0,right:0,top:0,bottom:0};function ji(e,t,i){let r,n,o,l,s,a;for(let c=0;c<e.length;c+=3)if(s=e[c],a=e[c+1],t<s?(n=0,o=1,l="left"):t<a?(n=t-s,o=n+1):(c==e.length-3||t==a&&e[c+3]>t)&&(o=a-s,n=o-1,t>=a&&(l="right")),null!=n){if(r=e[c+2],s==a&&i==(r.insertLeft?"left":"right")&&(l=i),"left"==i&&0==n)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],l="left";if("right"==i&&n==a-s)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)r=e[(c+=3)+2],l="right";break}return{node:r,start:n,end:o,collapse:l,coverStart:s,coverEnd:a}}function qi(e,t){let i=Ki;if("left"==t)for(let t=0;t<e.length&&(i=e[t]).left==i.right;t++);else for(let t=e.length-1;t>=0&&(i=e[t]).left==i.right;t--);return i}function Xi(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(let t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function Yi(e){e.display.externalMeasure=null,R(e.display.lineMeasure);for(let t=0;t<e.display.view.length;t++)Xi(e.display.view[t])}function Zi(e){Yi(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function Ji(){return C&&N?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Qi(){return C&&N?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function er(e){let t=0;if(e.widgets)for(let i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=zi(e.widgets[i]));return t}function tr(e,t,i,r,n){if(!n){let e=er(t);i.top+=e,i.bottom+=e}if("line"==r)return i;r||(r="local");let o=ti(t);if("local"==r?o+=Ei(e.display):o-=e.display.viewOffset,"page"==r||"window"==r){let t=e.display.lineSpace.getBoundingClientRect();o+=t.top+("window"==r?0:Qi());let n=t.left+("window"==r?0:Ji());i.left+=n,i.right+=n}return i.top+=o,i.bottom+=o,i}function ir(e,t,i){if("div"==i)return t;let r=t.left,n=t.top;if("page"==i)r-=Ji(),n-=Qi();else if("local"==i||!i){let t=e.display.sizer.getBoundingClientRect();r+=t.left,n+=t.top}let o=e.display.lineSpace.getBoundingClientRect();return{left:r-o.left,top:n-o.top}}function rr(e,t,i,r,n){return r||(r=nt(e.doc,t.line)),tr(e,r,_i(e,r,t.ch,n),i)}function nr(e,t,i,r,n,o){function l(t,l){let s=Gi(e,n,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,tr(e,r,s,i)}r=r||nt(e.doc,t.line),n||(n=Vi(e,r));let s=Ce(r,e.doc.direction),a=t.ch,c=t.sticky;if(a>=r.text.length?(a=r.text.length,c="before"):a<=0&&(a=0,c="after"),!s)return l("before"==c?a-1:a,"before"==c);function u(e,t,i){return l(i?e-1:e,1==s[t].level!=i)}let d=we(s,a,c),h=ve,f=u(a,d,"before"==c);return null!=h&&(f.other=u(a,h,"before"!=c)),f}function or(e,t){let i=0;t=vt(e.doc,t),e.options.lineWrapping||(i=gr(e.display)*t.ch);let r=nt(e.doc,t.line),n=ti(r)+Ei(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function lr(e,t,i,r,n){let o=ht(e,t,i);return o.xRel=n,r&&(o.outside=r),o}function sr(e,t,i){let r=e.doc;if((i+=e.display.viewOffset)<0)return lr(r.first,0,null,-1,-1);let n=ct(r,i),o=r.first+r.size-1;if(n>o)return lr(r.first+r.size-1,nt(r,o).text.length,null,1,1);t<0&&(t=0);let l=nt(r,n);for(;;){let o=dr(e,l,n,t,i),s=qt(l,o.ch+(o.xRel>0||o.outside>0?1:0));if(!s)return o;let a=s.find(1);if(a.line==n)return a;l=nt(r,n=a.line)}}function ar(e,t,i,r){r-=er(t);let n=t.text.length,o=ye((t=>Gi(e,i,t-1).bottom<=r),n,0);return n=ye((t=>Gi(e,i,t).top>r),o,n),{begin:o,end:n}}function cr(e,t,i,r){return i||(i=Vi(e,t)),ar(e,t,i,tr(e,t,Gi(e,i,r),"line").top)}function ur(e,t,i,r){return!(e.bottom<=i)&&(e.top>i||(r?e.left:e.right)>t)}function dr(e,t,i,r,n){n-=ti(t);let o=Vi(e,t),l=er(t),s=0,a=t.text.length,c=!0,u=Ce(t,e.doc.direction);if(u){let l=(e.options.lineWrapping?fr:hr)(e,t,i,o,u,r,n);c=1!=l.level,s=c?l.from:l.to-1,a=c?l.to:l.from-1}let d,h,f=null,p=null,g=ye((t=>{let i=Gi(e,o,t);return i.top+=l,i.bottom+=l,!!ur(i,r,n,!1)&&(i.top<=n&&i.left<=r&&(f=t,p=i),!0)}),s,a),m=!1;if(p){let e=r-p.left<p.right-r,t=e==c;g=f+(t?0:1),h=t?"after":"before",d=e?p.left:p.right}else{c||g!=a&&g!=s||g++,h=0==g?"after":g==t.text.length?"before":Gi(e,o,g-(c?1:0)).bottom+l<=n==c?"after":"before";let r=nr(e,ht(i,g,h),"line",t,o);d=r.left,m=n<r.top?-1:n>=r.bottom?1:0}return g=be(t.text,g,1),lr(i,g,h,m,r-d)}function hr(e,t,i,r,n,o,l){let s=ye((s=>{let a=n[s],c=1!=a.level;return ur(nr(e,ht(i,c?a.to:a.from,c?"before":"after"),"line",t,r),o,l,!0)}),0,n.length-1),a=n[s];if(s>0){let c=1!=a.level,u=nr(e,ht(i,c?a.from:a.to,c?"after":"before"),"line",t,r);ur(u,o,l,!0)&&u.top>l&&(a=n[s-1])}return a}function fr(e,t,i,r,n,o,l){let{begin:s,end:a}=ar(e,t,r,l);/\s/.test(t.text.charAt(a-1))&&a--;let c=null,u=null;for(let t=0;t<n.length;t++){let i=n[t];if(i.from>=a||i.to<=s)continue;let l=Gi(e,r,1!=i.level?Math.min(a,i.to)-1:Math.max(s,i.from)).right,d=l<o?o-l+1e9:l-o;(!c||u>d)&&(c=i,u=d)}return c||(c=n[n.length-1]),c.from<s&&(c={from:s,to:c.to,level:c.level}),c.to>a&&(c={from:c.from,to:a,level:c.level}),c}function pr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==$i){$i=_("pre",null,"CodeMirror-line-like");for(let e=0;e<49;++e)$i.appendChild(document.createTextNode("x")),$i.appendChild(_("br"));$i.appendChild(document.createTextNode("x"))}B(e.measure,$i);let t=$i.offsetHeight/50;return t>3&&(e.cachedTextHeight=t),R(e.measure),t||1}function gr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;let t=_("span","xxxxxxxxxx"),i=_("pre",[t],"CodeMirror-line-like");B(e.measure,i);let r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function mr(e){let t=e.display,i={},r={},n=t.gutters.clientLeft;for(let o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l){let t=e.display.gutterSpecs[l].className;i[t]=o.offsetLeft+o.clientLeft+n,r[t]=o.clientWidth}return{fixedPos:br(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function br(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function yr(e){let t=pr(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/gr(e.display)-3);return n=>{if(Qt(e.doc,n))return 0;let o=0;if(n.widgets)for(let e=0;e<n.widgets.length;e++)n.widgets[e].height&&(o+=n.widgets[e].height);return i?o+(Math.ceil(n.text.length/r)||1)*t:o+t}}function vr(e){let t=e.doc,i=yr(e);t.iter((e=>{let t=i(e);t!=e.height&&st(e,t)}))}function wr(e,t,i,r){let n=e.display;if(!i&&"true"==Fe(t).getAttribute("cm-not-content"))return null;let o,l,s=n.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(e){return null}let a,c=sr(e,o,l);if(r&&c.xRel>0&&(a=nt(e.doc,c.line).text).length==c.ch){let t=Y(a,a.length,e.options.tabSize)-a.length;c=ht(c.line,Math.max(0,Math.round((o-Fi(e.display).left)/gr(e.display))-t))}return c}function xr(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;let i=e.display.view;for(let e=0;e<i.length;e++)if((t-=i[e].size)<0)return e}function Cr(e,t,i,r){null==t&&(t=e.doc.first),null==i&&(i=e.doc.first+e.doc.size),r||(r=0);let n=e.display;if(r&&i<n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)Et&&Zt(e.doc,t)<n.viewTo&&Mr(e);else if(i<=n.viewFrom)Et&&Jt(e.doc,i+r)>n.viewFrom?Mr(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Mr(e);else if(t<=n.viewFrom){let t=Sr(e,i,i+r,1);t?(n.view=n.view.slice(t.index),n.viewFrom=t.lineN,n.viewTo+=r):Mr(e)}else if(i>=n.viewTo){let i=Sr(e,t,t,-1);i?(n.view=n.view.slice(0,i.index),n.viewTo=i.lineN):Mr(e)}else{let o=Sr(e,t,t,-1),l=Sr(e,i,i+r,1);o&&l?(n.view=n.view.slice(0,o.index).concat(mi(e,o.lineN,l.lineN)).concat(n.view.slice(l.index)),n.viewTo+=r):Mr(e)}let o=n.externalMeasured;o&&(i<o.lineN?o.lineN+=r:t<o.lineN+o.size&&(n.externalMeasured=null))}function kr(e,t,i){e.curOp.viewChanged=!0;let r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;let o=r.view[xr(e,t)];if(null==o.node)return;let l=o.changes||(o.changes=[]);-1==J(l,i)&&l.push(i)}function Mr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Sr(e,t,i,r){let n,o=xr(e,t),l=e.display.view;if(!Et||i==e.doc.first+e.doc.size)return{index:o,lineN:i};let s=e.display.viewFrom;for(let e=0;e<o;e++)s+=l[e].size;if(s!=t){if(r>0){if(o==l.length-1)return null;n=s+l[o].size-t,o++}else n=s-t;t+=n,i+=n}for(;Zt(e.doc,i)!=i;){if(o==(r<0?0:l.length-1))return null;i+=r*l[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:i}}function Lr(e){let t=e.display.view,i=0;for(let e=0;e<t.length;e++){let r=t[e];r.hidden||r.node&&!r.changes||++i}return i}function Tr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Nr(e,t=!0){let i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),o=r.selection=document.createDocumentFragment();for(let r=0;r<i.sel.ranges.length;r++){if(!t&&r==i.sel.primIndex)continue;let l=i.sel.ranges[r];if(l.from().line>=e.display.viewTo||l.to().line<e.display.viewFrom)continue;let s=l.empty();(s||e.options.showCursorWhenSelecting)&&Ar(e,l.head,n),s||Dr(e,l,o)}return r}function Ar(e,t,i){let r=nr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(_("div"," ","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){let e=i.appendChild(_("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));e.style.display="",e.style.left=r.other.left+"px",e.style.top=r.other.top+"px",e.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function Or(e,t){return e.top-t.top||e.left-t.left}function Dr(e,t,i){let r=e.display,n=e.doc,o=document.createDocumentFragment(),l=Fi(e.display),s=l.left,a=Math.max(r.sizerWidth,Ii(e)-r.sizer.offsetLeft)-l.right,c="ltr"==n.direction;function u(e,t,i,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),o.appendChild(_("div",null,"CodeMirror-selected",`position: absolute; left: ${e}px;\n                             top: ${t}px; width: ${null==i?a-e:i}px;\n                             height: ${r-t}px`))}function d(t,i,r){let o,l,d=nt(n,t),h=d.text.length;function f(i,r){return rr(e,ht(t,i),"div",d,r)}function p(t,i,r){let n=cr(e,d,null,t),o="ltr"==i==("after"==r)?"left":"right";return f("after"==r?n.begin:n.end-(/\s/.test(d.text.charAt(n.end-1))?2:1),o)[o]}let g=Ce(d,n.direction);return function(e,t,i,r){if(!e)return r(t,i,"ltr",0);let n=!1;for(let o=0;o<e.length;++o){let l=e[o];(l.from<i&&l.to>t||t==i&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,i),1==l.level?"rtl":"ltr",o),n=!0)}n||r(t,i,"ltr")}(g,i||0,null==r?h:r,((e,t,n,d)=>{let m="ltr"==n,b=f(e,m?"left":"right"),y=f(t-1,m?"right":"left"),v=null==i&&0==e,w=null==r&&t==h,x=0==d,C=!g||d==g.length-1;if(y.top-b.top<=3){let e=(c?w:v)&&C,t=(c?v:w)&&x?s:(m?b:y).left,i=e?a:(m?y:b).right;u(t,b.top,i-t,b.bottom)}else{let i,r,o,l;m?(i=c&&v&&x?s:b.left,r=c?a:p(e,n,"before"),o=c?s:p(t,n,"after"),l=c&&w&&C?a:y.right):(i=c?p(e,n,"before"):s,r=!c&&v&&x?a:b.right,o=!c&&w&&C?s:y.left,l=c?p(t,n,"after"):a),u(i,b.top,r-i,b.bottom),b.bottom<y.top&&u(s,b.bottom,null,y.top),u(o,y.top,l-o,y.bottom)}(!o||Or(b,o)<0)&&(o=b),Or(y,o)<0&&(o=y),(!l||Or(b,l)<0)&&(l=b),Or(y,l)<0&&(l=y)})),{start:o,end:l}}let h=t.from(),f=t.to();if(h.line==f.line)d(h.line,h.ch,f.ch);else{let e=nt(n,h.line),t=nt(n,f.line),i=Yt(e)==Yt(t),r=d(h.line,h.ch,i?e.text.length+1:null).end,o=d(f.line,i?0:null,f.ch).start;i&&(r.top<o.top-2?(u(r.right,r.top,null,r.bottom),u(s,o.top,o.left,o.bottom)):u(r.right,r.top,o.left-r.right,r.bottom)),r.bottom<o.top&&u(s,r.bottom,null,o.top)}i.appendChild(o)}function zr(e){if(!e.state.focused)return;let t=e.display;clearInterval(t.blinker);let i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval((()=>{e.hasFocus()||Fr(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Wr(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Hr(e))}function Er(e){e.state.delayingBlurEvent=!0,setTimeout((()=>{e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&Fr(e))}),100)}function Hr(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,$(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),w&&setTimeout((()=>e.display.input.reset(!0)),20)),e.display.input.receivedFocus()),zr(e))}function Fr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,I(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((()=>{e.state.focused||(e.display.shift=!1)}),150))}function Pr(e){let t=e.display,i=t.lineDiv.offsetTop;for(let r=0;r<t.view.length;r++){let n,o=t.view[r],l=e.options.lineWrapping,s=0;if(o.hidden)continue;if(y&&v<8){let e=o.node.offsetTop+o.node.offsetHeight;n=e-i,i=e}else{let e=o.node.getBoundingClientRect();n=e.bottom-e.top,!l&&o.text.firstChild&&(s=o.text.firstChild.getBoundingClientRect().right-e.left-1)}let a=o.line.height-n;if((a>.005||a<-.005)&&(st(o.line,n),Ir(o.line),o.rest))for(let e=0;e<o.rest.length;e++)Ir(o.rest[e]);if(s>e.display.sizerWidth){let t=Math.ceil(s/gr(e.display));t>e.display.maxLineLength&&(e.display.maxLineLength=t,e.display.maxLine=o.line,e.display.maxLineChanged=!0)}}}function Ir(e){if(e.widgets)for(let t=0;t<e.widgets.length;++t){let i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Rr(e,t,i){let r=i&&null!=i.top?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Ei(e));let n=i&&null!=i.bottom?i.bottom:r+e.wrapper.clientHeight,o=ct(t,r),l=ct(t,n);if(i&&i.ensure){let r=i.ensure.from.line,n=i.ensure.to.line;r<o?(o=r,l=ct(t,ti(nt(t,r))+e.wrapper.clientHeight)):Math.min(n,t.lastLine())>=l&&(o=ct(t,ti(nt(t,n))-e.wrapper.clientHeight),l=n)}return{from:o,to:Math.max(l,o+1)}}function Br(e,t){let i=e.display,r=pr(e.display);t.top<0&&(t.top=0);let n=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:i.scroller.scrollTop,o=Ri(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);let s=e.doc.height+Hi(i),a=t.top<r,c=t.bottom>s-r;if(t.top<n)l.scrollTop=a?0:t.top;else if(t.bottom>n+o){let e=Math.min(t.top,(c?s:t.bottom)-o);e!=n&&(l.scrollTop=e)}let u=e.options.fixedGutter?0:i.gutters.offsetWidth,d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:i.scroller.scrollLeft-u,h=Ii(e)-i.gutters.offsetWidth,f=t.right-t.left>h;return f&&(t.right=t.left+h),t.left<10?l.scrollLeft=0:t.left<d?l.scrollLeft=Math.max(0,t.left+u-(f?0:10)):t.right>h+d-3&&(l.scrollLeft=t.right+(f?0:10)-h),l}function _r(e,t){null!=t&&(Gr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ur(e){Gr(e);let t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Vr(e,t,i){null==t&&null==i||Gr(e),null!=t&&(e.curOp.scrollLeft=t),null!=i&&(e.curOp.scrollTop=i)}function Gr(e){let t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null,$r(e,or(e,t.from),or(e,t.to),t.margin)}}function $r(e,t,i,r){let n=Br(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});Vr(e,n.scrollLeft,n.scrollTop)}function Kr(e,t){Math.abs(e.doc.scrollTop-t)<2||(p||yn(e,{top:t}),jr(e,t,!0),p&&yn(e),fn(e,100))}function jr(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 qr(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,xn(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Xr(e){let t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+Hi(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+Pi(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}function Yr(e,t){t||(t=Xr(e));let i=e.display.barWidth,r=e.display.barHeight;Zr(e,t);for(let t=0;t<4&&i!=e.display.barWidth||r!=e.display.barHeight;t++)i!=e.display.barWidth&&e.options.lineWrapping&&Pr(e),Zr(e,Xr(e)),i=e.display.barWidth,r=e.display.barHeight}function Zr(e,t){let 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 Jr={native:class{constructor(e,t,i){this.cm=i;let r=this.vert=_("div",[_("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=_("div",[_("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Me(r,"scroll",(()=>{r.clientHeight&&t(r.scrollTop,"vertical")})),Me(n,"scroll",(()=>{n.clientWidth&&t(n.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,y&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}update(e){let 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";let i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else 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";let t=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+t)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}}setScrollLeft(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")}setScrollTop(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")}zeroWidthHack(){let e=O&&!S?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Z,this.disableVert=new Z}enableZeroWidthBar(e,t,i){e.style.pointerEvents="auto",t.set(1e3,(function r(){let n=e.getBoundingClientRect();("vert"==i?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,r)}))}clear(){let e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},null:class{update(){return{bottom:0,right:0}}setScrollLeft(){}setScrollTop(){}clear(){}}};function Qr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&I(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Jr[e.options.scrollbarStyle]((t=>{e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Me(t,"mousedown",(()=>{e.state.focused&&setTimeout((()=>e.display.input.focus()),0)})),t.setAttribute("cm-not-content","true")}),((t,i)=>{"horizontal"==i?qr(e,t):Kr(e,t)}),e),e.display.scrollbars.addClass&&$(e.display.wrapper,e.display.scrollbars.addClass)}var en=0;function tn(e){var t;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:++en},t=e.curOp,bi?bi.ops.push(t):t.ownsGroup=bi={ops:[t],delayedCallbacks:[]}}function rn(e){let t=e.curOp;t&&function(e,t){let i=e.ownsGroup;if(i)try{!function(e){let t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(let t=0;t<e.ops.length;t++){let i=e.ops[t];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(i<t.length)}(i)}finally{bi=null,t(i)}}(t,(e=>{for(let t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;!function(e){let t=e.ops;for(let e=0;e<t.length;e++)nn(t[e]);for(let e=0;e<t.length;e++)on(t[e]);for(let e=0;e<t.length;e++)ln(t[e]);for(let e=0;e<t.length;e++)sn(t[e]);for(let e=0;e<t.length;e++)an(t[e])}(e)}))}function nn(e){let t=e.cm,i=t.display;!function(e){let t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Pi(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Pi(e)+"px",t.scrollbarsClipped=!0)}(t),e.updateMaxLine&&ri(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new gn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function on(e){e.updatedDisplay=e.mustUpdate&&mn(e.cm,e.update)}function ln(e){let t=e.cm,i=t.display;e.updatedDisplay&&Pr(t),e.barMeasure=Xr(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=_i(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+Pi(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Ii(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function sn(e){let t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&qr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);let i=e.focus&&e.focus==G();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Yr(t,e.barMeasure),e.updatedDisplay&&wn(t,e.barMeasure),e.selectionChanged&&zr(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&Wr(e.cm)}function an(e){let t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&bn(t,e.update),null==i.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(i.wheelStartX=i.wheelStartY=null),null!=e.scrollTop&&jr(t,e.scrollTop,e.forceScroll),null!=e.scrollLeft&&qr(t,e.scrollLeft,!0,!0),e.scrollToPos){let i=function(e,t,i,r){let n;null==r&&(r=0),e.options.lineWrapping||t!=i||(i="before"==(t=t.ch?ht(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?ht(t.line,t.ch+1,"before"):t);for(let o=0;o<5;o++){let o=!1,l=nr(e,t),s=i&&i!=t?nr(e,i):l;n={left:Math.min(l.left,s.left),top:Math.min(l.top,s.top)-r,right:Math.max(l.left,s.left),bottom:Math.max(l.bottom,s.bottom)+r};let a=Br(e,n),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=a.scrollTop&&(Kr(e,a.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(o=!0)),null!=a.scrollLeft&&(qr(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(o=!0)),!o)break}return n}(t,vt(r,e.scrollToPos.from),vt(r,e.scrollToPos.to),e.scrollToPos.margin);!function(e,t){if(Ne(e,"scrollCursorIntoView"))return;let i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),null!=n&&!L){let r=_("div","​",null,`position: absolute;\n                         top: ${t.top-i.viewOffset-Ei(e.display)}px;\n                         height: ${t.bottom-t.top+Pi(e)+i.barHeight}px;\n                         left: ${t.left}px; width: ${Math.max(2,t.right-t.left)}px;`);e.display.lineSpace.appendChild(r),r.scrollIntoView(n),e.display.lineSpace.removeChild(r)}}(t,i)}let n=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(n)for(let e=0;e<n.length;++e)n[e].lines.length||Te(n[e],"hide");if(o)for(let e=0;e<o.length;++e)o[e].lines.length&&Te(o[e],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Te(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function cn(e,t){if(e.curOp)return t();tn(e);try{return t()}finally{rn(e)}}function un(e,t){return function(){if(e.curOp)return t.apply(e,arguments);tn(e);try{return t.apply(e,arguments)}finally{rn(e)}}}function dn(e){return function(){if(this.curOp)return e.apply(this,arguments);tn(this);try{return e.apply(this,arguments)}finally{rn(this)}}}function hn(e){return function(){let t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);tn(t);try{return e.apply(this,arguments)}finally{rn(t)}}}function fn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,q(pn,e))}function pn(e){let t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;let i=+new Date+e.options.workTime,r=St(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),(o=>{if(r.line>=e.display.viewFrom){let i=o.styles,l=o.text.length>e.options.maxHighlightLength?et(t.mode,r.state):null,s=kt(e,o,r,!0);l&&(r.state=l),o.styles=s.styles;let a=o.styleClasses,c=s.classes;c?o.styleClasses=c:a&&(o.styleClasses=null);let u=!i||i.length!=o.styles.length||a!=c&&(!a||!c||a.bgClass!=c.bgClass||a.textClass!=c.textClass);for(let e=0;!u&&e<i.length;++e)u=i[e]!=o.styles[e];u&&n.push(r.line),o.stateAfter=r.save(),r.nextLine()}else o.text.length<=e.options.maxHighlightLength&&Lt(e,o.text,r),o.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return fn(e,e.options.workDelay),!0})),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&cn(e,(()=>{for(let t=0;t<n.length;t++)kr(e,n[t],"text")}))}var gn=class{constructor(e,t,i){let r=e.display;this.viewport=t,this.visible=Rr(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Ii(e),this.force=i,this.dims=mr(e),this.events=[]}signal(e,t){Oe(e,t)&&this.events.push(arguments)}finish(){for(let e=0;e<this.events.length;e++)Te.apply(null,this.events[e])}};function mn(e,t){let i=e.display,r=e.doc;if(t.editorIsHidden)return Mr(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==Lr(e))return!1;Cn(e)&&(Mr(e),t.dims=mr(e));let n=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<o&&o-i.viewFrom<20&&(o=Math.max(r.first,i.viewFrom)),i.viewTo>l&&i.viewTo-l<20&&(l=Math.min(n,i.viewTo)),Et&&(o=Zt(e.doc,o),l=Jt(e.doc,l));let s=o!=i.viewFrom||l!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;!function(e,t,i){let r=e.display;0==r.view.length||t>=r.viewTo||i<=r.viewFrom?(r.view=mi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=mi(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(xr(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(mi(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,xr(e,i)))),r.viewTo=i}(e,o,l),i.viewOffset=ti(nt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";let a=Lr(e);if(!s&&0==a&&!t.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;let c=function(e){if(e.hasFocus())return null;let t=G();if(!t||!V(e.display.lineDiv,t))return null;let i={activeElt:t};if(window.getSelection){let t=window.getSelection();t.anchorNode&&t.extend&&V(e.display.lineDiv,t.anchorNode)&&(i.anchorNode=t.anchorNode,i.anchorOffset=t.anchorOffset,i.focusNode=t.focusNode,i.focusOffset=t.focusOffset)}return i}(e);return a>4&&(i.lineDiv.style.display="none"),function(e,t,i){let r=e.display,n=e.options.lineNumbers,o=r.lineDiv,l=o.firstChild;function s(t){let i=t.nextSibling;return w&&O&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),i}let a=r.view,c=r.viewFrom;for(let r=0;r<a.length;r++){let u=a[r];if(u.hidden);else if(u.node&&u.node.parentNode==o){for(;l!=u.node;)l=s(l);let r=n&&null!=t&&t<=c&&u.lineNumber;u.changes&&(J(u.changes,"gutter")>-1&&(r=!1),xi(e,u,c,i)),r&&(R(u.lineNumber),u.lineNumber.appendChild(document.createTextNode(dt(e.options,c)))),l=u.node.nextSibling}else{let t=Ni(e,u,c,i);o.insertBefore(t,l)}c+=u.size}for(;l;)l=s(l)}(e,i.updateLineNumbers,t.dims),a>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,function(e){if(e&&e.activeElt&&e.activeElt!=G()&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&V(document.body,e.anchorNode)&&V(document.body,e.focusNode))){let t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}(c),R(i.cursorDiv),R(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,s&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,fn(e,400)),i.updateLineNumbers=null,!0}function bn(e,t){let i=t.viewport;for(let r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=Ii(e))r&&(t.visible=Rr(e.display,e.doc,i));else if(i&&null!=i.top&&(i={top:Math.min(e.doc.height+Hi(e.display)-Ri(e),i.top)}),t.visible=Rr(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!mn(e,t))break;Pr(e);let n=Xr(e);Tr(e),Yr(e,n),wn(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 yn(e,t){let i=new gn(e,t);if(mn(e,i)){Pr(e),bn(e,i);let t=Xr(e);Tr(e),Yr(e,t),wn(e,t),i.finish()}}function vn(e){let t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",vi(e,"gutterChanged",e)}function wn(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+Pi(e)+"px"}function xn(e){let t=e.display,i=t.view;if(!(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter))return;let r=br(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,o=r+"px";for(let t=0;t<i.length;t++)if(!i[t].hidden){e.options.fixedGutter&&(i[t].gutter&&(i[t].gutter.style.left=o),i[t].gutterBackground&&(i[t].gutterBackground.style.left=o));let r=i[t].alignable;if(r)for(let e=0;e<r.length;e++)r[e].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Cn(e){if(!e.options.lineNumbers)return!1;let t=e.doc,i=dt(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){let t=r.measure.appendChild(_("div",[_("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),n=t.firstChild.offsetWidth,o=t.offsetWidth-n;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(n,r.lineGutter.offsetWidth-o)+1,r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",vn(e.display),!0}return!1}function kn(e,t){let i=[],r=!1;for(let n=0;n<e.length;n++){let o=e[n],l=null;if("string"!=typeof o&&(l=o.style,o=o.className),"CodeMirror-linenumbers"==o){if(!t)continue;r=!0}i.push({className:o,style:l})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function Mn(e){let t=e.gutters,i=e.gutterSpecs;R(t),e.lineGutter=null;for(let r=0;r<i.length;++r){let{className:n,style:o}=i[r],l=t.appendChild(_("div",null,"CodeMirror-gutter "+n));o&&(l.style.cssText=o),"CodeMirror-linenumbers"==n&&(e.lineGutter=l,l.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",vn(e)}function Sn(e){Mn(e.display),Cr(e),xn(e)}function Ln(e,t,i,r){let n=this;this.input=i,n.scrollbarFiller=_("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=_("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=U("div",null,"CodeMirror-code"),n.selectionDiv=_("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=_("div",null,"CodeMirror-cursors"),n.measure=_("div",null,"CodeMirror-measure"),n.lineMeasure=_("div",null,"CodeMirror-measure"),n.lineSpace=U("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");let o=U("div",[n.lineSpace],"CodeMirror-lines");n.mover=_("div",[o],null,"position: relative"),n.sizer=_("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=_("div",null,null,"position: absolute; height: "+Q+"px; width: 1px;"),n.gutters=_("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=_("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=_("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),y&&v<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),w||p&&A||(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=kn(r.gutters,r.lineNumbers),Mn(n),i.init(n)}var Tn=0,Nn=null;function An(e){let t=e.wheelDeltaX,i=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==i&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:null==i&&(i=e.wheelDelta),{x:t,y:i}}function On(e){let t=An(e);return t.x*=Nn,t.y*=Nn,t}function Dn(e,t){let i=An(t),r=i.x,n=i.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(r&&s||n&&a){if(n&&O&&w)e:for(let i=t.target,r=o.view;i!=l;i=i.parentNode)for(let t=0;t<r.length;t++)if(r[t].node==i){e.display.currentWheelTarget=i;break e}if(r&&!p&&!k&&null!=Nn)return n&&a&&Kr(e,Math.max(0,l.scrollTop+n*Nn)),qr(e,Math.max(0,l.scrollLeft+r*Nn)),(!n||n&&a)&&ze(t),void(o.wheelStartX=null);if(n&&null!=Nn){let t=n*Nn,i=e.doc.scrollTop,r=i+o.wrapper.clientHeight;t<0?i=Math.max(0,i+t-50):r=Math.min(e.doc.height,r+t+50),yn(e,{top:i,bottom:r})}Tn<20&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=r,o.wheelDY=n,setTimeout((()=>{if(null==o.wheelStartX)return;let e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,i=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,i&&(Nn=(Nn*Tn+i)/(Tn+1),++Tn)}),200)):(o.wheelDX+=r,o.wheelDY+=n))}}y?Nn=-.53:p?Nn=15:C?Nn=-.7:M&&(Nn=-1/3);var zn=class{constructor(e,t){this.ranges=e,this.primIndex=t}primary(){return this.ranges[this.primIndex]}equals(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(let t=0;t<this.ranges.length;t++){let i=this.ranges[t],r=e.ranges[t];if(!pt(i.anchor,r.anchor)||!pt(i.head,r.head))return!1}return!0}deepCopy(){let e=[];for(let t=0;t<this.ranges.length;t++)e[t]=new Wn(gt(this.ranges[t].anchor),gt(this.ranges[t].head));return new zn(e,this.primIndex)}somethingSelected(){for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1}contains(e,t){t||(t=e);for(let i=0;i<this.ranges.length;i++){let r=this.ranges[i];if(ft(t,r.from())>=0&&ft(e,r.to())<=0)return i}return-1}},Wn=class{constructor(e,t){this.anchor=e,this.head=t}from(){return bt(this.anchor,this.head)}to(){return mt(this.anchor,this.head)}empty(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};function En(e,t,i){let r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(((e,t)=>ft(e.from(),t.from()))),i=J(t,n);for(let e=1;e<t.length;e++){let n=t[e],o=t[e-1],l=ft(o.to(),n.from());if(r&&!n.empty()?l>0:l>=0){let r=bt(o.from(),n.from()),l=mt(o.to(),n.to()),s=o.empty()?n.from()==n.head:o.from()==o.head;e<=i&&--i,t.splice(--e,2,new Wn(s?l:r,s?r:l))}}return new zn(t,i)}function Hn(e,t){return new zn([new Wn(e,t||e)],0)}function Fn(e){return e.text?ht(e.from.line+e.text.length-1,se(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Pn(e,t){if(ft(e,t.from)<0)return e;if(ft(e,t.to)<=0)return Fn(t);let i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fn(t).ch-t.to.ch),ht(i,r)}function In(e,t){let i=[];for(let r=0;r<e.sel.ranges.length;r++){let n=e.sel.ranges[r];i.push(new Wn(Pn(n.anchor,t),Pn(n.head,t)))}return En(e.cm,i,e.sel.primIndex)}function Rn(e,t,i){return e.line==t.line?ht(i.line,e.ch-t.ch+i.ch):ht(i.line+(e.line-t.line),e.ch)}function Bn(e){e.doc.mode=Ze(e.options,e.doc.modeOption),_n(e)}function _n(e){e.doc.iter((e=>{e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)})),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,fn(e,100),e.state.modeGen++,e.curOp&&Cr(e)}function Un(e,t){return 0==t.from.ch&&0==t.to.ch&&""==se(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Vn(e,t,i,r){function n(e){return i?i[e]:null}function o(e,i,n){!function(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Bt(e),_t(e,i);let n=r?r(e):1;n!=e.height&&st(e,n)}(e,i,n,r),vi(e,"change",e,t)}function l(e,t){let i=[];for(let o=e;o<t;++o)i.push(new ni(c[o],n(o),r));return i}let s=t.from,a=t.to,c=t.text,u=nt(e,s.line),d=nt(e,a.line),h=se(c),f=n(c.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,c.length)),e.remove(c.length,e.size-c.length);else if(Un(e,t)){let t=l(0,c.length-1);o(d,d.text,f),p&&e.remove(s.line,p),t.length&&e.insert(s.line,t)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,s.ch)+h+u.text.slice(a.ch),f);else{let t=l(1,c.length-1);t.push(new ni(h+u.text.slice(a.ch),f,r)),o(u,u.text.slice(0,s.ch)+c[0],n(0)),e.insert(s.line+1,t)}else if(1==c.length)o(u,u.text.slice(0,s.ch)+c[0]+d.text.slice(a.ch),n(0)),e.remove(s.line+1,p);else{o(u,u.text.slice(0,s.ch)+c[0],n(0)),o(d,h+d.text.slice(a.ch),f);let t=l(1,c.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,t)}vi(e,"change",e,t)}function Gn(e,t,i){!function e(r,n,o){if(r.linked)for(let l=0;l<r.linked.length;++l){let s=r.linked[l];if(s.doc==n)continue;let a=o&&s.sharedHist;i&&!a||(t(s.doc,a),e(s.doc,r,a))}}(e,null,!0)}function $n(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,vr(e),Bn(e),Kn(e),e.options.lineWrapping||ri(e),e.options.mode=t.modeOption,Cr(e)}function Kn(e){("rtl"==e.doc.direction?$:I)(e.display.lineDiv,"CodeMirror-rtl")}function jn(e){this.done=[],this.undone=[],this.undoDepth=e?e.undoDepth:1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e?e.maxGeneration:1}function qn(e,t){let i={from:gt(t.from),to:Fn(t),text:ot(e,t.from,t.to)};return Qn(e,i,t.from.line,t.to.line+1),Gn(e,(e=>Qn(e,i,t.from.line,t.to.line+1)),!0),i}function Xn(e){for(;e.length;){if(!se(e).ranges)break;e.pop()}}function Yn(e,t,i,r){let n=e.history;n.undone.length=0;let o,l,s=+new Date;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&n.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=function(e,t){return t?(Xn(e.done),se(e.done)):e.done.length&&!se(e.done).ranges?se(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),se(e.done)):void 0}(n,n.lastOp==r)))l=se(o.changes),0==ft(t.from,t.to)&&0==ft(t.from,l.to)?l.to=Fn(t):o.changes.push(qn(e,t));else{let i=se(n.done);for(i&&i.ranges||Jn(e.sel,n.done),o={changes:[qn(e,t)],generation:n.generation},n.done.push(o);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=s,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,l||Te(e,"historyAdded")}function Zn(e,t,i,r){let n=e.history,o=r&&r.origin;i==n.lastSelOp||o&&n.lastSelOrigin==o&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==o||function(e,t,i,r){let 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)}(e,o,se(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=o,n.lastSelOp=i,r&&!1!==r.clearRedo&&Xn(n.undone)}function Jn(e,t){let i=se(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Qn(e,t,i,r){let n=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),(i=>{i.markedSpans&&((n||(n=t["spans_"+e.id]={}))[o]=i.markedSpans),++o}))}function eo(e){if(!e)return null;let t;for(let i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function to(e,t){let i=function(e,t){let i=t["spans_"+e.id];if(!i)return null;let r=[];for(let e=0;e<t.text.length;++e)r.push(eo(i[e]));return r}(e,t),r=It(e,t);if(!i)return r;if(!r)return i;for(let e=0;e<i.length;++e){let t=i[e],n=r[e];if(t&&n)e:for(let e=0;e<n.length;++e){let i=n[e];for(let e=0;e<t.length;++e)if(t[e].marker==i.marker)continue e;t.push(i)}else n&&(i[e]=n)}return i}function io(e,t,i){let r=[];for(let o=0;o<e.length;++o){let l=e[o];if(l.ranges){r.push(i?zn.prototype.deepCopy.call(l):l);continue}let s=l.changes,a=[];r.push({changes:a});for(let e=0;e<s.length;++e){let i,r=s[e];if(a.push({from:r.from,to:r.to,text:r.text}),t)for(var n in r)(i=n.match(/^spans_(\d+)$/))&&J(t,Number(i[1]))>-1&&(se(a)[n]=r[n],delete r[n])}}return r}function ro(e,t,i,r){if(r){let r=e.anchor;if(i){let e=ft(t,r)<0;e!=ft(i,r)<0?(r=t,t=i):e!=ft(t,i)<0&&(t=i)}return new Wn(r,t)}return new Wn(i||t,t)}function no(e,t,i,r,n){null==n&&(n=e.cm&&(e.cm.display.shift||e.extend)),co(e,new zn([ro(e.sel.primary(),t,i,n)],0),r)}function oo(e,t,i){let r=[],n=e.cm&&(e.cm.display.shift||e.extend);for(let i=0;i<e.sel.ranges.length;i++)r[i]=ro(e.sel.ranges[i],t[i],null,n);co(e,En(e.cm,r,e.sel.primIndex),i)}function lo(e,t,i,r){let n=e.sel.ranges.slice(0);n[t]=i,co(e,En(e.cm,n,e.sel.primIndex),r)}function so(e,t,i,r){co(e,Hn(t,i),r)}function ao(e,t,i){let r=e.history.done,n=se(r);n&&n.ranges?(r[r.length-1]=t,uo(e,t,i)):co(e,t,i)}function co(e,t,i){uo(e,t,i),Zn(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function uo(e,t,i){(Oe(e,"beforeSelectionChange")||e.cm&&Oe(e.cm,"beforeSelectionChange"))&&(t=function(e,t,i){let r={ranges:t.ranges,update:function(t){this.ranges=[];for(let i=0;i<t.length;i++)this.ranges[i]=new Wn(vt(e,t[i].anchor),vt(e,t[i].head))},origin:i&&i.origin};return Te(e,"beforeSelectionChange",e,r),e.cm&&Te(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?En(e.cm,r.ranges,r.ranges.length-1):t}(e,t,i));let r=i&&i.bias||(ft(t.primary().head,e.sel.primary().head)<0?-1:1);ho(e,po(e,t,r,!0)),i&&!1===i.scroll||!e.cm||"nocursor"==e.cm.getOption("readOnly")||Ur(e.cm)}function ho(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,Ae(e.cm)),vi(e,"cursorActivity",e))}function fo(e){ho(e,po(e,e.sel,null,!1))}function po(e,t,i,r){let n;for(let o=0;o<t.ranges.length;o++){let l=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],a=mo(e,l.anchor,s&&s.anchor,i,r),c=mo(e,l.head,s&&s.head,i,r);(n||a!=l.anchor||c!=l.head)&&(n||(n=t.ranges.slice(0,o)),n[o]=new Wn(a,c))}return n?En(e.cm,n,t.primIndex):t}function go(e,t,i,r,n){let o=nt(e,t.line);if(o.markedSpans)for(let l=0;l<o.markedSpans.length;++l){let s=o.markedSpans[l],a=s.marker,c="selectLeft"in a?!a.selectLeft:a.inclusiveLeft,u="selectRight"in a?!a.selectRight:a.inclusiveRight;if((null==s.from||(c?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(u?s.to>=t.ch:s.to>t.ch))){if(n&&(Te(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(i){let l,s=a.find(r<0?1:-1);if((r<0?u:c)&&(s=bo(e,s,-r,s&&s.line==t.line?o:null)),s&&s.line==t.line&&(l=ft(s,i))&&(r<0?l<0:l>0))return go(e,s,t,r,n)}let s=a.find(r<0?-1:1);return(r<0?c:u)&&(s=bo(e,s,r,s.line==t.line?o:null)),s?go(e,s,t,r,n):null}}return t}function mo(e,t,i,r,n){let o=r||1,l=go(e,t,i,o,n)||!n&&go(e,t,i,o,!0)||go(e,t,i,-o,n)||!n&&go(e,t,i,-o,!0);return l||(e.cantEdit=!0,ht(e.first,0))}function bo(e,t,i,r){return i<0&&0==t.ch?t.line>e.first?vt(e,ht(t.line-1)):null:i>0&&t.ch==(r||nt(e,t.line)).text.length?t.line<e.first+e.size-1?ht(t.line+1,0):null:new ht(t.line,t.ch+i)}function yo(e){e.setSelection(ht(e.firstLine(),0),ht(e.lastLine()),te)}function vo(e,t,i){let r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:()=>r.canceled=!0};return i&&(r.update=(t,i,n,o)=>{t&&(r.from=vt(e,t)),i&&(r.to=vt(e,i)),n&&(r.text=n),void 0!==o&&(r.origin=o)}),Te(e,"beforeChange",e,r),e.cm&&Te(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function wo(e,t,i){if(e.cm){if(!e.cm.curOp)return un(e.cm,wo)(e,t,i);if(e.cm.state.suppressEdits)return}if((Oe(e,"beforeChange")||e.cm&&Oe(e.cm,"beforeChange"))&&!(t=vo(e,t,!0)))return;let r=Wt&&!i&&function(e,t,i){let r=null;if(e.iter(t.line,i.line+1,(e=>{if(e.markedSpans)for(let t=0;t<e.markedSpans.length;++t){let i=e.markedSpans[t].marker;!i.readOnly||r&&-1!=J(r,i)||(r||(r=[])).push(i)}})),!r)return null;let n=[{from:t,to:i}];for(let e=0;e<r.length;++e){let t=r[e],i=t.find(0);for(let e=0;e<n.length;++e){let r=n[e];if(ft(r.to,i.from)<0||ft(r.from,i.to)>0)continue;let o=[e,1],l=ft(r.from,i.from),s=ft(r.to,i.to);(l<0||!t.inclusiveLeft&&!l)&&o.push({from:r.from,to:i.from}),(s>0||!t.inclusiveRight&&!s)&&o.push({from:i.to,to:r.to}),n.splice.apply(n,o),e+=o.length-3}}return n}(e,t.from,t.to);if(r)for(let i=r.length-1;i>=0;--i)xo(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else xo(e,t)}function xo(e,t){if(1==t.text.length&&""==t.text[0]&&0==ft(t.from,t.to))return;let i=In(e,t);Yn(e,t,i,e.cm?e.cm.curOp.id:NaN),Mo(e,t,i,It(e,t));let r=[];Gn(e,((e,i)=>{i||-1!=J(r,e.history)||(No(e.history,t),r.push(e.history)),Mo(e,t,null,It(e,t))}))}function Co(e,t,i){let r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;let n,o=e.history,l=e.sel,s="undo"==t?o.done:o.undone,a="undo"==t?o.undone:o.done,c=0;for(;c<s.length&&(n=s[c],i?!n.ranges||n.equals(e.sel):n.ranges);c++);if(c==s.length)return;for(o.lastOrigin=o.lastSelOrigin=null;;){if(n=s.pop(),!n.ranges){if(r)return void s.push(n);break}if(Jn(n,a),i&&!n.equals(e.sel))return void co(e,n,{clearRedo:!1});l=n}let u=[];Jn(l,a),a.push({changes:u,generation:o.generation}),o.generation=n.generation||++o.maxGeneration;let d=Oe(e,"beforeChange")||e.cm&&Oe(e.cm,"beforeChange");for(let i=n.changes.length-1;i>=0;--i){let r=n.changes[i];if(r.origin=t,d&&!vo(e,r,!1))return void(s.length=0);u.push(qn(e,r));let o=i?In(e,r):se(s);Mo(e,r,o,to(e,r)),!i&&e.cm&&e.cm.scrollIntoView({from:r.from,to:Fn(r)});let l=[];Gn(e,((e,t)=>{t||-1!=J(l,e.history)||(No(e.history,r),l.push(e.history)),Mo(e,r,null,to(e,r))}))}}function ko(e,t){if(0!=t&&(e.first+=t,e.sel=new zn(ae(e.sel.ranges,(e=>new Wn(ht(e.anchor.line+t,e.anchor.ch),ht(e.head.line+t,e.head.ch)))),e.sel.primIndex),e.cm)){Cr(e.cm,e.first,e.first-t,t);for(let t=e.cm.display,i=t.viewFrom;i<t.viewTo;i++)kr(e.cm,i,"gutter")}}function Mo(e,t,i,r){if(e.cm&&!e.cm.curOp)return un(e.cm,Mo)(e,t,i,r);if(t.to.line<e.first)return void ko(e,t.text.length-1-(t.to.line-t.from.line));if(t.from.line>e.lastLine())return;if(t.from.line<e.first){let i=t.text.length-1-(e.first-t.from.line);ko(e,i),t={from:ht(e.first,0),to:ht(t.to.line+i,t.to.ch),text:[se(t.text)],origin:t.origin}}let n=e.lastLine();t.to.line>n&&(t={from:t.from,to:ht(n,nt(e,n).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ot(e,t.from,t.to),i||(i=In(e,t)),e.cm?function(e,t,i){let r=e.doc,n=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=at(Yt(nt(r,o.line))),r.iter(a,l.line+1,(e=>{if(e==n.maxLine)return s=!0,!0})));r.sel.contains(t.from,t.to)>-1&&Ae(e);Vn(r,t,i,yr(e)),e.options.lineWrapping||(r.iter(a,o.line+t.text.length,(e=>{let t=ii(e);t>n.maxLineLength&&(n.maxLine=e,n.maxLineLength=t,n.maxLineChanged=!0,s=!1)})),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;let i=e.first;for(let r=t-1;r>i;r--){let n=nt(e,r).stateAfter;if(n&&(!(n instanceof xt)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)})(r,o.line),fn(e,400);let c=t.text.length-(l.line-o.line)-1;t.full?Cr(e):o.line!=l.line||1!=t.text.length||Un(e.doc,t)?Cr(e,o.line,l.line+1,c):kr(e,o.line,"text");let u=Oe(e,"changes"),d=Oe(e,"change");if(d||u){let i={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};d&&vi(e,"change",e,i),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(i)}e.display.selForContextMenu=null}(e.cm,t,r):Vn(e,t,r),uo(e,i,te),e.cantEdit&&mo(e,ht(e.firstLine(),0))&&(e.cantEdit=!1)}function So(e,t,i,r,n){r||(r=i),ft(r,i)<0&&([i,r]=[r,i]),"string"==typeof t&&(t=e.splitLines(t)),wo(e,{from:i,to:r,text:t,origin:n})}function Lo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function To(e,t,i,r){for(let n=0;n<e.length;++n){let o=e[n],l=!0;if(o.ranges){o.copied||(o=e[n]=o.deepCopy(),o.copied=!0);for(let e=0;e<o.ranges.length;e++)Lo(o.ranges[e].anchor,t,i,r),Lo(o.ranges[e].head,t,i,r)}else{for(let e=0;e<o.changes.length;++e){let n=o.changes[e];if(i<n.from.line)n.from=ht(n.from.line+r,n.from.ch),n.to=ht(n.to.line+r,n.to.ch);else if(t<=n.to.line){l=!1;break}}l||(e.splice(0,n+1),n=0)}}}function No(e,t){let i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;To(e.done,i,r,n),To(e.undone,i,r,n)}function Ao(e,t,i,r){let n=t,o=t;return"number"==typeof t?o=nt(e,yt(e,t)):n=at(t),null==n?null:(r(o,n)&&e.cm&&kr(e.cm,n,i),o)}function Oo(e){this.lines=e,this.parent=null;let t=0;for(let i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}function Do(e){this.children=e;let t=0,i=0;for(let r=0;r<e.length;++r){let n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}Oo.prototype={chunkSize(){return this.lines.length},removeInner(e,t){for(let i=e,r=e+t;i<r;++i){let e=this.lines[i];this.height-=e.height,oi(e),vi(e,"delete")}this.lines.splice(e,t)},collapse(e){e.push.apply(e,this.lines)},insertInner(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(let e=0;e<t.length;++e)t[e].parent=this},iterN(e,t,i){for(let r=e+t;e<r;++e)if(i(this.lines[e]))return!0}},Do.prototype={chunkSize(){return this.size},removeInner(e,t){this.size-=t;for(let i=0;i<this.children.length;++i){let r=this.children[i],n=r.chunkSize();if(e<n){let o=Math.min(t,n-e),l=r.height;if(r.removeInner(e,o),this.height-=l-r.height,n==o&&(this.children.splice(i--,1),r.parent=null),0==(t-=o))break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Oo))){let e=[];this.collapse(e),this.children=[new Oo(e)],this.children[0].parent=this}},collapse(e){for(let t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner(e,t,i){this.size+=t.length,this.height+=i;for(let r=0;r<this.children.length;++r){let n=this.children[r],o=n.chunkSize();if(e<=o){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){let e=n.lines.length%25+25;for(let t=e;t<n.lines.length;){let e=new Oo(n.lines.slice(t,t+=25));n.height-=e.height,this.children.splice(++r,0,e),e.parent=this}n.lines=n.lines.slice(0,e),this.maybeSpill()}break}e-=o}},maybeSpill(){if(this.children.length<=10)return;let e=this;do{let t=new Do(e.children.splice(e.children.length-5,5));if(e.parent){e.size-=t.size,e.height-=t.height;let i=J(e.parent.children,e);e.parent.children.splice(i+1,0,t)}else{let i=new Do(e.children);i.parent=e,e.children=[i,t],e=i}t.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN(e,t,i){for(let r=0;r<this.children.length;++r){let n=this.children[r],o=n.chunkSize();if(e<o){let r=Math.min(t,o-e);if(n.iterN(e,r,i))return!0;if(0==(t-=r))break;e=0}else e-=o}}};var zo=class{constructor(e,t,i){if(i)for(let e in i)i.hasOwnProperty(e)&&(this[e]=i[e]);this.doc=e,this.node=t}clear(){let e=this.doc.cm,t=this.line.widgets,i=this.line,r=at(i);if(null==r||!t)return;for(let e=0;e<t.length;++e)t[e]==this&&t.splice(e--,1);t.length||(i.widgets=null);let n=zi(this);st(i,Math.max(0,i.height-n)),e&&(cn(e,(()=>{Wo(e,i,-n),kr(e,r,"widget")})),vi(e,"lineWidgetCleared",e,this,r))}changed(){let e=this.height,t=this.doc.cm,i=this.line;this.height=null;let r=zi(this)-e;r&&(Qt(this.doc,i)||st(i,i.height+r),t&&cn(t,(()=>{t.curOp.forceUpdate=!0,Wo(t,i,r),vi(t,"lineWidgetChanged",t,this,at(i))})))}};function Wo(e,t,i){ti(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&_r(e,i)}De(zo);var Eo=0,Ho=class{constructor(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++Eo}clear(){if(this.explicitlyCleared)return;let e=this.doc.cm,t=e&&!e.curOp;if(t&&tn(e),Oe(this,"clear")){let e=this.find();e&&vi(this,"clear",e.from,e.to)}let i=null,r=null;for(let t=0;t<this.lines.length;++t){let n=this.lines[t],o=Ft(n.markedSpans,this);e&&!this.collapsed?kr(e,at(n),"text"):e&&(null!=o.to&&(r=at(n)),null!=o.from&&(i=at(n))),n.markedSpans=Pt(n.markedSpans,o),null==o.from&&this.collapsed&&!Qt(this.doc,n)&&e&&st(n,pr(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(let t=0;t<this.lines.length;++t){let i=Yt(this.lines[t]),r=ii(i);r>e.display.maxLineLength&&(e.display.maxLine=i,e.display.maxLineLength=r,e.display.maxLineChanged=!0)}null!=i&&e&&this.collapsed&&Cr(e,i,r+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&fo(e.doc)),e&&vi(e,"markerCleared",e,this,i,r),t&&rn(e),this.parent&&this.parent.clear()}find(e,t){let i,r;null==e&&"bookmark"==this.type&&(e=1);for(let n=0;n<this.lines.length;++n){let o=this.lines[n],l=Ft(o.markedSpans,this);if(null!=l.from&&(i=ht(t?o:at(o),l.from),-1==e))return i;if(null!=l.to&&(r=ht(t?o:at(o),l.to),1==e))return r}return i&&{from:i,to:r}}changed(){let e=this.find(-1,!0),t=this,i=this.doc.cm;e&&i&&cn(i,(()=>{let r=e.line,n=at(e.line),o=Ui(i,n);if(o&&(Xi(o),i.curOp.selectionChanged=i.curOp.forceUpdate=!0),i.curOp.updateMaxLine=!0,!Qt(t.doc,r)&&null!=t.height){let e=t.height;t.height=null;let i=zi(t)-e;i&&st(r,r.height+i)}vi(i,"markerChanged",i,this)}))}attachLine(e){if(!this.lines.length&&this.doc.cm){let e=this.doc.cm.curOp;e.maybeHiddenMarkers&&-1!=J(e.maybeHiddenMarkers,this)||(e.maybeUnhiddenMarkers||(e.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)}detachLine(e){if(this.lines.splice(J(this.lines,e),1),!this.lines.length&&this.doc.cm){let e=this.doc.cm.curOp;(e.maybeHiddenMarkers||(e.maybeHiddenMarkers=[])).push(this)}}};function Fo(e,t,i,r,n){if(r&&r.shared)return function(e,t,i,r,n){r=X(r),r.shared=!1;let o=[Fo(e,t,i,r,n)],l=o[0],s=r.widgetNode;return Gn(e,(e=>{s&&(r.widgetNode=s.cloneNode(!0)),o.push(Fo(e,vt(e,t),vt(e,i),r,n));for(let t=0;t<e.linked.length;++t)if(e.linked[t].isParent)return;l=se(o)})),new Po(o,l)}(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return un(e.cm,Fo)(e,t,i,r,n);let o=new Ho(e,n),l=ft(t,i);if(r&&X(r,o,!1),l>0||0==l&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=U("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Xt(e,t.line,t,i,o)||t.line!=i.line&&Xt(e,i.line,t,i,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Et=!0}o.addToHistory&&Yn(e,{from:t,to:i,origin:"markText"},e.sel,NaN);let s,a=t.line,c=e.cm;if(e.iter(a,i.line+1,(e=>{c&&o.collapsed&&!c.options.lineWrapping&&Yt(e)==c.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&st(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new Ht(o,a==t.line?t.ch:null,a==i.line?i.ch:null)),++a})),o.collapsed&&e.iter(t.line,i.line+1,(t=>{Qt(e,t)&&st(t,0)})),o.clearOnEnter&&Me(o,"beforeCursorEnter",(()=>o.clear())),o.readOnly&&(Wt=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++Eo,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)Cr(c,t.line,i.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(let e=t.line;e<=i.line;e++)kr(c,e,"text");o.atomic&&fo(c.doc),vi(c,"markerAdded",c,o)}return o}De(Ho);var Po=class{constructor(e,t){this.markers=e,this.primary=t;for(let t=0;t<e.length;++t)e[t].parent=this}clear(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(let e=0;e<this.markers.length;++e)this.markers[e].clear();vi(this,"clear")}}find(e,t){return this.primary.find(e,t)}};function Io(e){return e.findMarks(ht(e.first,0),e.clipPos(ht(e.lastLine())),(e=>e.parent))}function Ro(e){for(let t=0;t<e.length;t++){let i=e[t],r=[i.primary.doc];Gn(i.primary.doc,(e=>r.push(e)));for(let e=0;e<i.markers.length;e++){let t=i.markers[e];-1==J(r,t.doc)&&(t.parent=null,i.markers.splice(e--,1))}}}De(Po);var Bo=0,_o=function(e,t,i,r,n){if(!(this instanceof _o))return new _o(e,t,i,r,n);null==i&&(i=0),Do.call(this,[new Oo([new ni("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;let o=ht(i,0);this.sel=Hn(o),this.history=new jn(null),this.id=++Bo,this.modeOption=t,this.lineSep=r,this.direction="rtl"==n?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Vn(this,{from:o,to:o,text:e}),co(this,Hn(o),te)};_o.prototype=ue(Do.prototype,{constructor:_o,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){let i=0;for(let e=0;e<t.length;++e)i+=t[e].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){let t=lt(this,this.first,this.first+this.size);return!1===e?t:t.join(e||this.lineSeparator())},setValue:hn((function(e){let t=ht(this.first,0),i=this.first+this.size-1;wo(this,{from:t,to:ht(i,nt(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&Vr(this.cm,0,0),co(this,Hn(t),te)})),replaceRange:function(e,t,i,r){So(this,e,t=vt(this,t),i=i?vt(this,i):t,r)},getRange:function(e,t,i){let r=ot(this,vt(this,e),vt(this,t));return!1===i?r:r.join(i||this.lineSeparator())},getLine:function(e){let t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(ut(this,e))return nt(this,e)},getLineNumber:function(e){return at(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=nt(this,e)),Yt(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return vt(this,e)},getCursor:function(e){let t,i=this.sel.primary();return t=null==e||"head"==e?i.head:"anchor"==e?i.anchor:"end"==e||"to"==e||!1===e?i.to():i.from(),t},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:hn((function(e,t,i){so(this,vt(this,"number"==typeof e?ht(e,t||0):e),null,i)})),setSelection:hn((function(e,t,i){so(this,vt(this,e),vt(this,t||e),i)})),extendSelection:hn((function(e,t,i){no(this,vt(this,e),t&&vt(this,t),i)})),extendSelections:hn((function(e,t){oo(this,wt(this,e),t)})),extendSelectionsBy:hn((function(e,t){oo(this,wt(this,ae(this.sel.ranges,e)),t)})),setSelections:hn((function(e,t,i){if(!e.length)return;let r=[];for(let t=0;t<e.length;t++)r[t]=new Wn(vt(this,e[t].anchor),vt(this,e[t].head||e[t].anchor));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),co(this,En(this.cm,r,t),i)})),addSelection:hn((function(e,t,i){let r=this.sel.ranges.slice(0);r.push(new Wn(vt(this,e),vt(this,t||e))),co(this,En(this.cm,r,r.length-1),i)})),getSelection:function(e){let t,i=this.sel.ranges;for(let e=0;e<i.length;e++){let r=ot(this,i[e].from(),i[e].to());t=t?t.concat(r):r}return!1===e?t:t.join(e||this.lineSeparator())},getSelections:function(e){let t=[],i=this.sel.ranges;for(let r=0;r<i.length;r++){let n=ot(this,i[r].from(),i[r].to());!1!==e&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){let r=[];for(let t=0;t<this.sel.ranges.length;t++)r[t]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:hn((function(e,t,i){let r=[],n=this.sel;for(let t=0;t<n.ranges.length;t++){let o=n.ranges[t];r[t]={from:o.from(),to:o.to(),text:this.splitLines(e[t]),origin:i}}let o=t&&"end"!=t&&function(e,t,i){let r=[],n=ht(e.first,0),o=n;for(let l=0;l<t.length;l++){let s=t[l],a=Rn(s.from,n,o),c=Rn(Fn(s),n,o);if(n=s.to,o=c,"around"==i){let t=e.sel.ranges[l],i=ft(t.head,t.anchor)<0;r[l]=new Wn(i?c:a,i?a:c)}else r[l]=new Wn(a,a)}return new zn(r,e.sel.primIndex)}(this,r,t);for(let e=r.length-1;e>=0;e--)wo(this,r[e]);o?ao(this,o):this.cm&&Ur(this.cm)})),undo:hn((function(){Co(this,"undo")})),redo:hn((function(){Co(this,"redo")})),undoSelection:hn((function(){Co(this,"undo",!0)})),redoSelection:hn((function(){Co(this,"redo",!0)})),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){let e=this.history,t=0,i=0;for(let i=0;i<e.done.length;i++)e.done[i].ranges||++t;for(let t=0;t<e.undone.length;t++)e.undone[t].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){this.history=new jn(this.history),Gn(this,(e=>e.history=this.history),!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:io(this.history.done),undone:io(this.history.undone)}},setHistory:function(e){let t=this.history=new jn(this.history);t.done=io(e.done.slice(0),null,!0),t.undone=io(e.undone.slice(0),null,!0)},setGutterMarker:hn((function(e,t,i){return Ao(this,e,"gutter",(e=>{let r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=i,!i&&pe(r)&&(e.gutterMarkers=null),!0}))})),clearGutter:hn((function(e){this.iter((t=>{t.gutterMarkers&&t.gutterMarkers[e]&&Ao(this,t,"gutter",(()=>(t.gutterMarkers[e]=null,pe(t.gutterMarkers)&&(t.gutterMarkers=null),!0)))}))})),lineInfo:function(e){let t;if("number"==typeof e){if(!ut(this,e))return null;if(t=e,!(e=nt(this,e)))return null}else if(t=at(e),null==t)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:hn((function(e,t,i){return Ao(this,e,"gutter"==t?"gutter":"class",(e=>{let r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[r]){if(F(i).test(e[r]))return!1;e[r]+=" "+i}else e[r]=i;return!0}))})),removeLineClass:hn((function(e,t,i){return Ao(this,e,"gutter"==t?"gutter":"class",(e=>{let r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",n=e[r];if(!n)return!1;if(null==i)e[r]=null;else{let t=n.match(F(i));if(!t)return!1;let o=t.index+t[0].length;e[r]=n.slice(0,t.index)+(t.index&&o!=n.length?" ":"")+n.slice(o)||null}return!0}))})),addLineWidget:hn((function(e,t,i){return function(e,t,i,r){let n=new zo(e,i,r),o=e.cm;return o&&n.noHScroll&&(o.display.alignWidgets=!0),Ao(e,t,"widget",(t=>{let i=t.widgets||(t.widgets=[]);if(null==n.insertAt?i.push(n):i.splice(Math.min(i.length,Math.max(0,n.insertAt)),0,n),n.line=t,o&&!Qt(e,t)){let i=ti(t)<e.scrollTop;st(t,t.height+zi(n)),i&&_r(o,n.height),o.curOp.forceUpdate=!0}return!0})),o&&vi(o,"lineWidgetAdded",o,n,"number"==typeof t?t:at(t)),n}(this,e,t,i)})),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Fo(this,vt(this,e),vt(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){let i={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return Fo(this,e=vt(this,e),e,i,"bookmark")},findMarksAt:function(e){let t=[],i=nt(this,(e=vt(this,e)).line).markedSpans;if(i)for(let r=0;r<i.length;++r){let n=i[r];(null==n.from||n.from<=e.ch)&&(null==n.to||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=vt(this,e),t=vt(this,t);let r=[],n=e.line;return this.iter(e.line,t.line+1,(o=>{let l=o.markedSpans;if(l)for(let o=0;o<l.length;o++){let s=l[o];null!=s.to&&n==e.line&&e.ch>=s.to||null==s.from&&n!=e.line||null!=s.from&&n==t.line&&s.from>=t.ch||i&&!i(s.marker)||r.push(s.marker.parent||s.marker)}++n})),r},getAllMarks:function(){let e=[];return this.iter((t=>{let i=t.markedSpans;if(i)for(let t=0;t<i.length;++t)null!=i[t].from&&e.push(i[t].marker)})),e},posFromIndex:function(e){let t,i=this.first,r=this.lineSeparator().length;return this.iter((n=>{let o=n.text.length+r;if(o>e)return t=e,!0;e-=o,++i})),vt(this,ht(i,t))},indexFromPos:function(e){let t=(e=vt(this,e)).ch;if(e.line<this.first||e.ch<0)return 0;let i=this.lineSeparator().length;return this.iter(this.first,e.line,(e=>{t+=e.text.length+i})),t},copy:function(e){let t=new _o(lt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});let t=this.first,i=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<i&&(i=e.to);let r=new _o(lt(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],function(e,t){for(let i=0;i<t.length;i++){let r=t[i],n=r.find(),o=e.clipPos(n.from),l=e.clipPos(n.to);if(ft(o,l)){let t=Fo(e,o,l,r.primary,r.primary.type);r.markers.push(t),t.parent=r}}}(r,Io(this)),r},unlinkDoc:function(e){if(e instanceof Fl&&(e=e.doc),this.linked)for(let t=0;t<this.linked.length;++t){if(this.linked[t].doc==e){this.linked.splice(t,1),e.unlinkDoc(this),Ro(Io(this));break}}if(e.history==this.history){let t=[e.id];Gn(e,(e=>t.push(e.id)),!0),e.history=new jn(null),e.history.done=io(this.history.done,t),e.history.undone=io(this.history.undone,t)}},iterLinkedDocs:function(e){Gn(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Ve(e)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:hn((function(e){var t;("rtl"!=e&&(e="ltr"),e!=this.direction)&&(this.direction=e,this.iter((e=>e.order=null)),this.cm&&cn(t=this.cm,(()=>{Kn(t),Cr(t)})))}))}),_o.prototype.eachLine=_o.prototype.iter;var Uo=_o,Vo=0;function Go(e){let t=this;if($o(t),Ne(t,e)||Wi(t.display,e))return;ze(e),y&&(Vo=+new Date);let i=wr(t,e,!0),r=e.dataTransfer.files;if(i&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File){let e=r.length,n=Array(e),o=0;const l=()=>{++o==e&&un(t,(()=>{i=vt(t.doc,i);let e={from:i,to:i,text:t.doc.splitLines(n.filter((e=>null!=e)).join(t.doc.lineSeparator())),origin:"paste"};wo(t.doc,e),ao(t.doc,Hn(vt(t.doc,i),vt(t.doc,Fn(e))))}))()},s=(e,i)=>{if(t.options.allowDropFileTypes&&-1==J(t.options.allowDropFileTypes,e.type))return void l();let r=new FileReader;r.onerror=()=>l(),r.onload=()=>{let e=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(e)||(n[i]=e),l()},r.readAsText(e)};for(let e=0;e<r.length;e++)s(r[e],e)}else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1)return t.state.draggingText(e),void setTimeout((()=>t.display.input.focus()),20);try{let r=e.dataTransfer.getData("Text");if(r){let e;if(t.state.draggingText&&!t.state.draggingText.copy&&(e=t.listSelections()),uo(t.doc,Hn(i,i)),e)for(let i=0;i<e.length;++i)So(t.doc,"",e[i].anchor,e[i].head,"drag");t.replaceSelection(r,"around","paste"),t.display.input.focus()}}catch(e){}}}function $o(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function Ko(e){if(!document.getElementsByClassName)return;let t=document.getElementsByClassName("CodeMirror"),i=[];for(let e=0;e<t.length;e++){let r=t[e].CodeMirror;r&&i.push(r)}i.length&&i[0].operation((()=>{for(let t=0;t<i.length;t++)e(i[t])}))}var jo=!1;function qo(){jo||(!function(){let e;Me(window,"resize",(()=>{null==e&&(e=setTimeout((()=>{e=null,Ko(Xo)}),100))})),Me(window,"blur",(()=>Ko(Fr)))}(),jo=!0)}function Xo(e){let t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}var Yo={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};for(let e=0;e<10;e++)Yo[e+48]=Yo[e+96]=String(e);for(let e=65;e<=90;e++)Yo[e]=String.fromCharCode(e);for(let e=1;e<=12;e++)Yo[e+111]=Yo[e+63235]="F"+e;var Zo={};function Jo(e){let t,i,r,n,o=e.split(/-(?!$)/);e=o[o.length-1];for(let e=0;e<o.length-1;e++){let l=o[e];if(/^(cmd|meta|m)$/i.test(l))n=!0;else if(/^a(lt)?$/i.test(l))t=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else{if(!/^s(hift)?$/i.test(l))throw new Error("Unrecognized modifier name: "+l);r=!0}}return t&&(e="Alt-"+e),i&&(e="Ctrl-"+e),n&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function Qo(e){let t={};for(let i in e)if(e.hasOwnProperty(i)){let r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if("..."==r){delete e[i];continue}let n=ae(i.split(" "),Jo);for(let e=0;e<n.length;e++){let i,o;e==n.length-1?(o=n.join(" "),i=r):(o=n.slice(0,e+1).join(" "),i="...");let l=t[o];if(l){if(l!=i)throw new Error("Inconsistent bindings for "+o)}else t[o]=i}delete e[i]}for(let i in t)e[i]=t[i];return e}function el(e,t,i,r){let n=(t=nl(t)).call?t.call(e,r):t[e];if(!1===n)return"nothing";if("..."===n)return"multi";if(null!=n&&i(n))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return el(e,t.fallthrough,i,r);for(let n=0;n<t.fallthrough.length;n++){let o=el(e,t.fallthrough[n],i,r);if(o)return o}}}function tl(e){let t="string"==typeof e?e:Yo[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function il(e,t,i){let r=e;return t.altKey&&"Alt"!=r&&(e="Alt-"+e),(E?t.metaKey:t.ctrlKey)&&"Ctrl"!=r&&(e="Ctrl-"+e),(E?t.ctrlKey:t.metaKey)&&"Mod"!=r&&(e="Cmd-"+e),!i&&t.shiftKey&&"Shift"!=r&&(e="Shift-"+e),e}function rl(e,t){if(k&&34==e.keyCode&&e.char)return!1;let i=Yo[e.keyCode];return null!=i&&!e.altGraphKey&&(3==e.keyCode&&e.code&&(i=e.code),il(i,e,t))}function nl(e){return"string"==typeof e?Zo[e]:e}function ol(e,t){let i=e.doc.sel.ranges,r=[];for(let e=0;e<i.length;e++){let n=t(i[e]);for(;r.length&&ft(n.from,se(r).to)<=0;){let e=r.pop();if(ft(e.from,n.from)<0){n.from=e.from;break}}r.push(n)}cn(e,(()=>{for(let t=r.length-1;t>=0;t--)So(e.doc,"",r[t].from,r[t].to,"+delete");Ur(e)}))}function ll(e,t,i){let r=be(e.text,t+i,i);return r<0||r>e.text.length?null:r}function sl(e,t,i){let r=ll(e,t.ch,i);return null==r?null:new ht(t.line,r,i<0?"after":"before")}function al(e,t,i,r,n){if(e){"rtl"==t.doc.direction&&(n=-n);let e=Ce(i,t.doc.direction);if(e){let o,l=n<0?se(e):e[0],s=n<0==(1==l.level)?"after":"before";if(l.level>0||"rtl"==t.doc.direction){let e=Vi(t,i);o=n<0?i.text.length-1:0;let r=Gi(t,e,o).top;o=ye((i=>Gi(t,e,i).top==r),n<0==(1==l.level)?l.from:l.to-1,o),"before"==s&&(o=ll(i,o,1))}else o=n<0?l.to:l.from;return new ht(r,o,s)}}return new ht(r,n<0?i.text.length:0,n<0?"before":"after")}Zo.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Zo.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Zo.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Zo.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Zo.default=O?Zo.macDefault:Zo.pcDefault;var cl={selectAll:yo,singleSelection:e=>e.setSelection(e.getCursor("anchor"),e.getCursor("head"),te),killLine:e=>ol(e,(t=>{if(t.empty()){let i=nt(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:ht(t.head.line+1,0)}:{from:t.head,to:ht(t.head.line,i)}}return{from:t.from(),to:t.to()}})),deleteLine:e=>ol(e,(t=>({from:ht(t.from().line,0),to:vt(e.doc,ht(t.to().line+1,0))}))),delLineLeft:e=>ol(e,(e=>({from:ht(e.from().line,0),to:e.from()}))),delWrappedLineLeft:e=>ol(e,(t=>{let i=e.charCoords(t.head,"div").top+5;return{from:e.coordsChar({left:0,top:i},"div"),to:t.from()}})),delWrappedLineRight:e=>ol(e,(t=>{let i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})),undo:e=>e.undo(),redo:e=>e.redo(),undoSelection:e=>e.undoSelection(),redoSelection:e=>e.redoSelection(),goDocStart:e=>e.extendSelection(ht(e.firstLine(),0)),goDocEnd:e=>e.extendSelection(ht(e.lastLine())),goLineStart:e=>e.extendSelectionsBy((t=>ul(e,t.head.line)),{origin:"+move",bias:1}),goLineStartSmart:e=>e.extendSelectionsBy((t=>dl(e,t.head)),{origin:"+move",bias:1}),goLineEnd:e=>e.extendSelectionsBy((t=>function(e,t){let i=nt(e.doc,t),r=function(e){let t;for(;t=jt(e);)e=t.find(1,!0).line;return e}(i);r!=i&&(t=at(r));return al(!0,e,i,t,-1)}(e,t.head.line)),{origin:"+move",bias:-1}),goLineRight:e=>e.extendSelectionsBy((t=>{let i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")}),re),goLineLeft:e=>e.extendSelectionsBy((t=>{let i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")}),re),goLineLeftSmart:e=>e.extendSelectionsBy((t=>{let i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?dl(e,t.head):r}),re),goLineUp:e=>e.moveV(-1,"line"),goLineDown:e=>e.moveV(1,"line"),goPageUp:e=>e.moveV(-1,"page"),goPageDown:e=>e.moveV(1,"page"),goCharLeft:e=>e.moveH(-1,"char"),goCharRight:e=>e.moveH(1,"char"),goColumnLeft:e=>e.moveH(-1,"column"),goColumnRight:e=>e.moveH(1,"column"),goWordLeft:e=>e.moveH(-1,"word"),goGroupRight:e=>e.moveH(1,"group"),goGroupLeft:e=>e.moveH(-1,"group"),goWordRight:e=>e.moveH(1,"word"),delCharBefore:e=>e.deleteH(-1,"codepoint"),delCharAfter:e=>e.deleteH(1,"char"),delWordBefore:e=>e.deleteH(-1,"word"),delWordAfter:e=>e.deleteH(1,"word"),delGroupBefore:e=>e.deleteH(-1,"group"),delGroupAfter:e=>e.deleteH(1,"group"),indentAuto:e=>e.indentSelection("smart"),indentMore:e=>e.indentSelection("add"),indentLess:e=>e.indentSelection("subtract"),insertTab:e=>e.replaceSelection("\t"),insertSoftTab:e=>{let t=[],i=e.listSelections(),r=e.options.tabSize;for(let n=0;n<i.length;n++){let o=i[n].from(),l=Y(e.getLine(o.line),o.ch,r);t.push(le(r-l%r))}e.replaceSelections(t)},defaultTab:e=>{e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:e=>cn(e,(()=>{let t=e.listSelections(),i=[];for(let r=0;r<t.length;r++){if(!t[r].empty())continue;let n=t[r].head,o=nt(e.doc,n.line).text;if(o)if(n.ch==o.length&&(n=new ht(n.line,n.ch-1)),n.ch>0)n=new ht(n.line,n.ch+1),e.replaceRange(o.charAt(n.ch-1)+o.charAt(n.ch-2),ht(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){let t=nt(e.doc,n.line-1).text;t&&(n=new ht(n.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+t.charAt(t.length-1),ht(n.line-1,t.length-1),n,"+transpose"))}i.push(new Wn(n,n))}e.setSelections(i)})),newlineAndIndent:e=>cn(e,(()=>{let t=e.listSelections();for(let i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(let i=0;i<t.length;i++)e.indentLine(t[i].from().line,null,!0);Ur(e)})),openLine:e=>e.replaceSelection("\n","start"),toggleOverwrite:e=>e.toggleOverwrite()};function ul(e,t){let i=nt(e.doc,t),r=Yt(i);return r!=i&&(t=at(r)),al(!0,e,r,t,1)}function dl(e,t){let i=ul(e,t.line),r=nt(e.doc,i.line),n=Ce(r,e.doc.direction);if(!n||0==n[0].level){let e=Math.max(i.ch,r.text.search(/\S/)),n=t.line==i.line&&t.ch<=e&&t.ch;return ht(i.line,n?0:e,i.sticky)}return i}function hl(e,t,i){if("string"==typeof t&&!(t=cl[t]))return!1;e.display.input.ensurePolled();let r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=ee}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}var fl=new Z;function pl(e,t,i,r){let n=e.state.keySeq;if(n){if(tl(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:fl.set(50,(()=>{e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())})),gl(e,n+" "+t,i,r))return!0}return gl(e,t,i,r)}function gl(e,t,i,r){let n=function(e,t,i){for(let r=0;r<e.state.keyMaps.length;r++){let n=el(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&el(t,e.options.extraKeys,i,e)||el(t,e.options.keyMap,i,e)}(e,t,r);return"multi"==n&&(e.state.keySeq=t),"handled"==n&&vi(e,"keyHandled",e,t,i),"handled"!=n&&"multi"!=n||(ze(i),zr(e)),!!n}function ml(e,t){let i=rl(t,!0);return!!i&&(t.shiftKey&&!e.state.keySeq?pl(e,"Shift-"+i,t,(t=>hl(e,t,!0)))||pl(e,i,t,(t=>{if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return hl(e,t)})):pl(e,i,t,(t=>hl(e,t))))}var bl=null;function yl(e){let t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=G(),Ne(t,e))return;y&&v<11&&27==e.keyCode&&(e.returnValue=!1);let i=e.keyCode;t.display.shift=16==i||e.shiftKey;let r=ml(t,e);k&&(bl=r?i:null,r||88!=i||$e||!(O?e.metaKey:e.ctrlKey)||t.replaceSelection("",null,"cut")),p&&!O&&!r&&46==i&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=i||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||function(e){let t=e.display.lineDiv;function i(e){18!=e.keyCode&&e.altKey||(I(t,"CodeMirror-crosshair"),Le(document,"keyup",i),Le(document,"mouseover",i))}$(t,"CodeMirror-crosshair"),Me(document,"keyup",i),Me(document,"mouseover",i)}(t)}function vl(e){16==e.keyCode&&(this.doc.sel.shift=!1),Ne(this,e)}function wl(e){let t=this;if(e.target&&e.target!=t.display.input.getField())return;if(Wi(t.display,e)||Ne(t,e)||e.ctrlKey&&!e.altKey||O&&e.metaKey)return;let i=e.keyCode,r=e.charCode;if(k&&i==bl)return bl=null,void ze(e);if(k&&(!e.which||e.which<10)&&ml(t,e))return;let n=String.fromCharCode(null==r?i:r);"\b"!=n&&(function(e,t,i){return pl(e,"'"+i+"'",t,(t=>hl(e,t,!0)))}(t,e,n)||t.display.input.onKeyPress(e))}var xl,Cl,kl=class{constructor(e,t,i){this.time=e,this.pos=t,this.button=i}compare(e,t,i){return this.time+400>e&&0==ft(t,this.pos)&&i==this.button}};function Ml(e){let t=this,i=t.display;if(Ne(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,Wi(i,e))return void(w||(i.scroller.draggable=!1,setTimeout((()=>i.scroller.draggable=!0),100)));if(Tl(t,e))return;let r=wr(t,e),n=Pe(e),o=r?function(e,t){let i=+new Date;return Cl&&Cl.compare(i,e,t)?(xl=Cl=null,"triple"):xl&&xl.compare(i,e,t)?(Cl=new kl(i,e,t),xl=null,"double"):(xl=new kl(i,e,t),Cl=null,"single")}(r,n):"single";window.focus(),1==n&&t.state.selectingText&&t.state.selectingText(e),r&&function(e,t,i,r,n){let o="Click";"double"==r?o="Double"+o:"triple"==r&&(o="Triple"+o);return o=(1==t?"Left":2==t?"Middle":"Right")+o,pl(e,il(o,n),n,(t=>{if("string"==typeof t&&(t=cl[t]),!t)return!1;let r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r=t(e,i)!=ee}finally{e.state.suppressEdits=!1}return r}))}(t,n,r,o,e)||(1==n?r?function(e,t,i,r){y?setTimeout(q(Wr,e),0):e.curOp.focus=G();let n,o=function(e,t,i){let r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(null==n.unit){let e=D?i.shiftKey&&i.metaKey:i.altKey;n.unit=e?"rectangle":"single"==t?"char":"double"==t?"word":"line"}(null==n.extend||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey);null==n.addNew&&(n.addNew=O?i.metaKey:i.ctrlKey);null==n.moveOnDrag&&(n.moveOnDrag=!(O?i.altKey:i.ctrlKey));return n}(e,i,r),l=e.doc.sel;e.options.dragDrop&&Be&&!e.isReadOnly()&&"single"==i&&(n=l.contains(t))>-1&&(ft((n=l.ranges[n]).from(),t)<0||t.xRel>0)&&(ft(n.to(),t)>0||t.xRel<0)?function(e,t,i,r){let n=e.display,o=!1,l=un(e,(t=>{w&&(n.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:Er(e)),Le(n.wrapper.ownerDocument,"mouseup",l),Le(n.wrapper.ownerDocument,"mousemove",s),Le(n.scroller,"dragstart",a),Le(n.scroller,"drop",l),o||(ze(t),r.addNew||no(e.doc,i,null,null,r.extend),w&&!M||y&&9==v?setTimeout((()=>{n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()}),20):n.input.focus())})),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},a=()=>o=!0;w&&(n.scroller.draggable=!0);e.state.draggingText=l,l.copy=!r.moveOnDrag,Me(n.wrapper.ownerDocument,"mouseup",l),Me(n.wrapper.ownerDocument,"mousemove",s),Me(n.scroller,"dragstart",a),Me(n.scroller,"drop",l),e.state.delayingBlurEvent=!0,setTimeout((()=>n.input.focus()),20),n.scroller.dragDrop&&n.scroller.dragDrop()}(e,r,t,o):function(e,t,i,r){y&&Er(e);let n=e.display,o=e.doc;ze(t);let l,s,a=o.sel,c=a.ranges;r.addNew&&!r.extend?(s=o.sel.contains(i),l=s>-1?c[s]:new Wn(i,i)):(l=o.sel.primary(),s=o.sel.primIndex);if("rectangle"==r.unit)r.addNew||(l=new Wn(i,i)),i=wr(e,t,!0,!0),s=-1;else{let t=Sl(e,i,r.unit);l=r.extend?ro(l,t.anchor,t.head,r.extend):t}r.addNew?-1==s?(s=c.length,co(o,En(e,c.concat([l]),s),{scroll:!1,origin:"*mouse"})):c.length>1&&c[s].empty()&&"char"==r.unit&&!r.extend?(co(o,En(e,c.slice(0,s).concat(c.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),a=o.sel):lo(o,s,l,ie):(s=0,co(o,new zn([l],0),ie),a=o.sel);let u=i;function d(t){if(0!=ft(u,t))if(u=t,"rectangle"==r.unit){let r=[],n=e.options.tabSize,l=Y(nt(o,i.line).text,i.ch,n),c=Y(nt(o,t.line).text,t.ch,n),u=Math.min(l,c),d=Math.max(l,c);for(let l=Math.min(i.line,t.line),s=Math.min(e.lastLine(),Math.max(i.line,t.line));l<=s;l++){let e=nt(o,l).text,t=ne(e,u,n);u==d?r.push(new Wn(ht(l,t),ht(l,t))):e.length>t&&r.push(new Wn(ht(l,t),ht(l,ne(e,d,n))))}r.length||r.push(new Wn(i,i)),co(o,En(e,a.ranges.slice(0,s).concat(r),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{let i,n=l,c=Sl(e,t,r.unit),u=n.anchor;ft(c.anchor,u)>0?(i=c.head,u=bt(n.from(),c.anchor)):(i=c.anchor,u=mt(n.to(),c.head));let d=a.ranges.slice(0);d[s]=function(e,t){let{anchor:i,head:r}=t,n=nt(e.doc,i.line);if(0==ft(i,r)&&i.sticky==r.sticky)return t;let o=Ce(n);if(!o)return t;let l=we(o,i.ch,i.sticky),s=o[l];if(s.from!=i.ch&&s.to!=i.ch)return t;let a,c=l+(s.from==i.ch==(1!=s.level)?0:1);if(0==c||c==o.length)return t;if(r.line!=i.line)a=(r.line-i.line)*("ltr"==e.doc.direction?1:-1)>0;else{let e=we(o,r.ch,r.sticky),t=e-l||(r.ch-i.ch)*(1==s.level?-1:1);a=e==c-1||e==c?t<0:t>0}let u=o[c+(a?-1:0)],d=a==(1==u.level),h=d?u.from:u.to,f=d?"after":"before";return i.ch==h&&i.sticky==f?t:new Wn(new ht(i.line,h,f),r)}(e,new Wn(vt(o,u),i)),co(o,En(e,d,s),ie)}}let h=n.wrapper.getBoundingClientRect(),f=0;function p(t){let i=++f,l=wr(e,t,!0,"rectangle"==r.unit);if(l)if(0!=ft(l,u)){e.curOp.focus=G(),d(l);let r=Rr(n,o);(l.line>=r.to||l.line<r.from)&&setTimeout(un(e,(()=>{f==i&&p(t)})),150)}else{let r=t.clientY<h.top?-20:t.clientY>h.bottom?20:0;r&&setTimeout(un(e,(()=>{f==i&&(n.scroller.scrollTop+=r,p(t))})),50)}}function g(t){e.state.selectingText=!1,f=1/0,t&&(ze(t),n.input.focus()),Le(n.wrapper.ownerDocument,"mousemove",m),Le(n.wrapper.ownerDocument,"mouseup",b),o.history.lastSelOrigin=null}let m=un(e,(e=>{0!==e.buttons&&Pe(e)?p(e):g(e)})),b=un(e,g);e.state.selectingText=b,Me(n.wrapper.ownerDocument,"mousemove",m),Me(n.wrapper.ownerDocument,"mouseup",b)}(e,r,t,o)}(t,r,o,e):Fe(e)==i.scroller&&ze(e):2==n?(r&&no(t.doc,r),setTimeout((()=>i.input.focus()),20)):3==n&&(H?t.display.input.onContextMenu(e):Er(t)))}function Sl(e,t,i){if("char"==i)return new Wn(t,t);if("word"==i)return e.findWordAt(t);if("line"==i)return new Wn(ht(t.line,0),vt(e.doc,ht(t.line+1,0)));let r=i(e,t);return new Wn(r.from,r.to)}function Ll(e,t,i,r){let n,o;if(t.touches)n=t.touches[0].clientX,o=t.touches[0].clientY;else try{n=t.clientX,o=t.clientY}catch(e){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ze(t);let l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Oe(e,i))return Ee(t);o-=s.top-l.viewOffset;for(let r=0;r<e.display.gutterSpecs.length;++r){let s=l.gutters.childNodes[r];if(s&&s.getBoundingClientRect().right>=n){return Te(e,i,e,ct(e.doc,o),e.display.gutterSpecs[r].className,t),Ee(t)}}}function Tl(e,t){return Ll(e,t,"gutterClick",!0)}function Nl(e,t){Wi(e.display,t)||function(e,t){return!!Oe(e,"gutterContextMenu")&&Ll(e,t,"gutterContextMenu",!1)}(e,t)||Ne(e,t,"contextmenu")||H||e.display.input.onContextMenu(t)}function Al(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Zi(e)}var Ol={toString:function(){return"CodeMirror.Init"}},Dl={},zl={};function Wl(e,t,i){if(!t!=!(i&&i!=Ol)){let i=e.display.dragFunctions,r=t?Me:Le;r(e.display.scroller,"dragstart",i.start),r(e.display.scroller,"dragenter",i.enter),r(e.display.scroller,"dragover",i.over),r(e.display.scroller,"dragleave",i.leave),r(e.display.scroller,"drop",i.drop)}}function El(e){e.options.lineWrapping?($(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(I(e.display.wrapper,"CodeMirror-wrap"),ri(e)),vr(e),Cr(e),Zi(e),setTimeout((()=>Yr(e)),100)}function Hl(e,t){if(!(this instanceof Hl))return new Hl(e,t);this.options=t=t?X(t):{},X(Dl,t,!1);let i=t.value;"string"==typeof i?i=new Uo(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode),this.doc=i;let r=new Hl.inputStyles[t.inputStyle](this),n=this.display=new Ln(e,i,r,t);n.wrapper.CodeMirror=this,Al(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Qr(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 Z,keySeq:null,specialChars:null},t.autofocus&&!A&&n.input.focus(),y&&v<11&&setTimeout((()=>this.display.input.reset(!0)),20),function(e){let t=e.display;Me(t.scroller,"mousedown",un(e,Ml)),Me(t.scroller,"dblclick",y&&v<11?un(e,(t=>{if(Ne(e,t))return;let i=wr(e,t);if(!i||Tl(e,t)||Wi(e.display,t))return;ze(t);let r=e.findWordAt(i);no(e.doc,r.anchor,r.head)})):t=>Ne(e,t)||ze(t));Me(t.scroller,"contextmenu",(t=>Nl(e,t))),Me(t.input.getField(),"contextmenu",(i=>{t.scroller.contains(i.target)||Nl(e,i)}));let i,r={end:0};function n(){t.activeTouch&&(i=setTimeout((()=>t.activeTouch=null),1e3),r=t.activeTouch,r.end=+new Date)}function o(e){if(1!=e.touches.length)return!1;let t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function l(e,t){if(null==t.left)return!0;let i=t.left-e.left,r=t.top-e.top;return i*i+r*r>400}Me(t.scroller,"touchstart",(n=>{if(!Ne(e,n)&&!o(n)&&!Tl(e,n)){t.input.ensurePolled(),clearTimeout(i);let e=+new Date;t.activeTouch={start:e,moved:!1,prev:e-r.end<=300?r:null},1==n.touches.length&&(t.activeTouch.left=n.touches[0].pageX,t.activeTouch.top=n.touches[0].pageY)}})),Me(t.scroller,"touchmove",(()=>{t.activeTouch&&(t.activeTouch.moved=!0)})),Me(t.scroller,"touchend",(i=>{let r=t.activeTouch;if(r&&!Wi(t,i)&&null!=r.left&&!r.moved&&new Date-r.start<300){let n,o=e.coordsChar(t.activeTouch,"page");n=!r.prev||l(r,r.prev)?new Wn(o,o):!r.prev.prev||l(r,r.prev.prev)?e.findWordAt(o):new Wn(ht(o.line,0),vt(e.doc,ht(o.line+1,0))),e.setSelection(n.anchor,n.head),e.focus(),ze(i)}n()})),Me(t.scroller,"touchcancel",n),Me(t.scroller,"scroll",(()=>{t.scroller.clientHeight&&(Kr(e,t.scroller.scrollTop),qr(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))})),Me(t.scroller,"mousewheel",(t=>Dn(e,t))),Me(t.scroller,"DOMMouseScroll",(t=>Dn(e,t))),Me(t.wrapper,"scroll",(()=>t.wrapper.scrollTop=t.wrapper.scrollLeft=0)),t.dragFunctions={enter:t=>{Ne(e,t)||He(t)},over:t=>{Ne(e,t)||(!function(e,t){let i=wr(e,t);if(!i)return;let r=document.createDocumentFragment();Ar(e,i,r),e.display.dragCursor||(e.display.dragCursor=_("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),B(e.display.dragCursor,r)}(e,t),He(t))},start:t=>function(e,t){if(y&&(!e.state.draggingText||+new Date-Vo<100))He(t);else if(!Ne(e,t)&&!Wi(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!M)){let i=_("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",k&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),k&&i.parentNode.removeChild(i)}}(e,t),drop:un(e,Go),leave:t=>{Ne(e,t)||$o(e)}};let s=t.input.getField();Me(s,"keyup",(t=>vl.call(e,t))),Me(s,"keydown",un(e,yl)),Me(s,"keypress",un(e,wl)),Me(s,"focus",(t=>Hr(e,t))),Me(s,"blur",(t=>Fr(e,t)))}(this),qo(),tn(this),this.curOp.forceUpdate=!0,$n(this,i),t.autofocus&&!A||this.hasFocus()?setTimeout((()=>{this.hasFocus()&&!this.state.focused&&Hr(this)}),20):Fr(this);for(let e in zl)zl.hasOwnProperty(e)&&zl[e](this,t[e],Ol);Cn(this),t.finishInit&&t.finishInit(this);for(let e=0;e<Pl.length;++e)Pl[e](this);rn(this),w&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(n.lineDiv).textRendering&&(n.lineDiv.style.textRendering="auto")}Hl.defaults=Dl,Hl.optionHandlers=zl;var Fl=Hl;var Pl=[];function Il(e,t,i,r){let n,o=e.doc;null==i&&(i="add"),"smart"==i&&(o.mode.indent?n=St(e,t).state:i="prev");let l=e.options.tabSize,s=nt(o,t),a=Y(s.text,null,l);s.stateAfter&&(s.stateAfter=null);let c,u=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==i&&(c=o.mode.indent(n,s.text.slice(u.length),s.text),c==ee||c>150)){if(!r)return;i="prev"}}else c=0,i="not";"prev"==i?c=t>o.first?Y(nt(o,t-1).text,null,l):0:"add"==i?c=a+e.options.indentUnit:"subtract"==i?c=a-e.options.indentUnit:"number"==typeof i&&(c=a+i),c=Math.max(0,c);let d="",h=0;if(e.options.indentWithTabs)for(let e=Math.floor(c/l);e;--e)h+=l,d+="\t";if(h<c&&(d+=le(c-h)),d!=u)return So(o,d,ht(t,0),ht(t,u.length),"+input"),s.stateAfter=null,!0;for(let e=0;e<o.sel.ranges.length;e++){let i=o.sel.ranges[e];if(i.head.line==t&&i.head.ch<u.length){let i=ht(t,u.length);lo(o,e,new Wn(i,i));break}}}Hl.defineInitHook=e=>Pl.push(e);var Rl=null;function Bl(e){Rl=e}function _l(e,t,i,r,n){let o=e.doc;e.display.shift=!1,r||(r=o.sel);let l=+new Date-200,s="paste"==n||e.state.pasteIncoming>l,a=Ve(t),c=null;if(s&&r.ranges.length>1)if(Rl&&Rl.text.join("\n")==t){if(r.ranges.length%Rl.text.length==0){c=[];for(let e=0;e<Rl.text.length;e++)c.push(o.splitLines(Rl.text[e]))}}else a.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(c=ae(a,(e=>[e])));let u=e.curOp.updateInput;for(let t=r.ranges.length-1;t>=0;t--){let u=r.ranges[t],d=u.from(),h=u.to();u.empty()&&(i&&i>0?d=ht(d.line,d.ch-i):e.state.overwrite&&!s?h=ht(h.line,Math.min(nt(o,h.line).text.length,h.ch+se(a).length)):s&&Rl&&Rl.lineWise&&Rl.text.join("\n")==a.join("\n")&&(d=h=ht(d.line,0)));let f={from:d,to:h,text:c?c[t%c.length]:a,origin:n||(s?"paste":e.state.cutIncoming>l?"cut":"+input")};wo(e.doc,f),vi(e,"inputRead",e,f)}t&&!s&&Vl(e,t),Ur(e),e.curOp.updateInput<2&&(e.curOp.updateInput=u),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ul(e,t){let i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||cn(t,(()=>_l(t,i,0,null,"paste"))),!0}function Vl(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;let i=e.doc.sel;for(let r=i.ranges.length-1;r>=0;r--){let n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;let o=e.getModeAt(n.head),l=!1;if(o.electricChars){for(let i=0;i<o.electricChars.length;i++)if(t.indexOf(o.electricChars.charAt(i))>-1){l=Il(e,n.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(nt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(l=Il(e,n.head.line,"smart"));l&&vi(e,"electricInput",e,n.head.line)}}function Gl(e){let t=[],i=[];for(let r=0;r<e.doc.sel.ranges.length;r++){let n=e.doc.sel.ranges[r].head.line,o={anchor:ht(n,0),head:ht(n+1,0)};i.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:i}}function $l(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Kl(){let e=_("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=_("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return w?e.style.width="1000px":e.setAttribute("wrap","off"),T&&(e.style.border="1px solid black"),$l(e),t}function jl(e,t,i,r,n){let o=t,l=i,s=nt(e,t.line),a=n&&"rtl"==e.direction?-i:i;function c(o){let l;if("codepoint"==r){let e=s.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(e))l=null;else{let r=i>0?e>=55296&&e<56320:e>=56320&&e<57343;l=new ht(t.line,Math.max(0,Math.min(s.text.length,t.ch+i*(r?2:1))),-i)}}else l=n?function(e,t,i,r){let n=Ce(t,e.doc.direction);if(!n)return sl(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");let o=we(n,i.ch,i.sticky),l=n[o];if("ltr"==e.doc.direction&&l.level%2==0&&(r>0?l.to>i.ch:l.from<i.ch))return sl(t,i,r);let s,a=(e,i)=>ll(t,e instanceof ht?e.ch:e,i),c=i=>e.options.lineWrapping?(s=s||Vi(e,t),cr(e,t,s,i)):{begin:0,end:t.text.length},u=c("before"==i.sticky?a(i,-1):i.ch);if("rtl"==e.doc.direction||1==l.level){let e=1==l.level==r<0,t=a(i,e?1:-1);if(null!=t&&(e?t<=l.to&&t<=u.end:t>=l.from&&t>=u.begin)){let r=e?"before":"after";return new ht(i.line,t,r)}}let d=(e,t,r)=>{let o=(e,t)=>t?new ht(i.line,a(e,1),"before"):new ht(i.line,e,"after");for(;e>=0&&e<n.length;e+=t){let i=n[e],l=t>0==(1!=i.level),s=l?r.begin:a(r.end,-1);if(i.from<=s&&s<i.to)return o(s,l);if(s=l?i.from:a(i.to,-1),r.begin<=s&&s<r.end)return o(s,l)}},h=d(o+r,r,u);if(h)return h;let f=r>0?u.end:a(u.begin,-1);return null==f||r>0&&f==t.text.length||(h=d(r>0?0:n.length-1,r,c(f)),!h)?null:h}(e.cm,s,t,i):sl(s,t,i);if(null==l){if(o||!function(){let i=t.line+a;return!(i<e.first||i>=e.first+e.size)&&(t=new ht(i,t.ch,t.sticky),s=nt(e,i))}())return!1;t=al(n,e.cm,s,t.line,a)}else t=l;return!0}if("char"==r||"codepoint"==r)c();else if("column"==r)c(!0);else if("word"==r||"group"==r){let n=null,o="group"==r,l=e.cm&&e.cm.getHelper(t,"wordChars");for(let e=!0;!(i<0)||c(!e);e=!1){let r=s.text.charAt(t.ch)||"\n",a=fe(r,l)?"w":o&&"\n"==r?"n":!o||/\s/.test(r)?null:"p";if(!o||e||a||(a="s"),n&&n!=a){i<0&&(i=1,c(),t.sticky="after");break}if(a&&(n=a),i>0&&!c(!e))break}}let u=mo(e,t,o,l,!0);return pt(o,u)&&(u.hitSide=!0),u}function ql(e,t,i,r){let n,o,l=e.doc,s=t.left;if("page"==r){let r=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),o=Math.max(r-.5*pr(e.display),3);n=(i>0?t.bottom:t.top)+i*o}else"line"==r&&(n=i>0?t.bottom+3:t.top-3);for(;o=sr(e,s,n),o.outside;){if(i<0?n<=0:n>=l.height){o.hitSide=!0;break}n+=5*i}return o}var Xl=class{constructor(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Z,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}init(e){let t=this,i=t.cm,r=t.div=e.lineDiv;function n(e){for(let t=e.target;t;t=t.parentNode){if(t==r)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}return!1}function o(e){if(!n(e)||Ne(i,e))return;if(i.somethingSelected())Bl({lineWise:!1,text:i.getSelections()}),"cut"==e.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;{let t=Gl(i);Bl({lineWise:!0,text:t.text}),"cut"==e.type&&i.operation((()=>{i.setSelections(t.ranges,0,te),i.replaceSelection("",null,"cut")}))}}if(e.clipboardData){e.clipboardData.clearData();let t=Rl.text.join("\n");if(e.clipboardData.setData("Text",t),e.clipboardData.getData("Text")==t)return void e.preventDefault()}let o=Kl(),l=o.firstChild;i.display.lineSpace.insertBefore(o,i.display.lineSpace.firstChild),l.value=Rl.text.join("\n");let s=G();j(l),setTimeout((()=>{i.display.lineSpace.removeChild(o),s.focus(),s==r&&t.showPrimarySelection()}),50)}r.contentEditable=!0,$l(r,i.options.spellcheck,i.options.autocorrect,i.options.autocapitalize),Me(r,"paste",(e=>{!n(e)||Ne(i,e)||Ul(e,i)||v<=11&&setTimeout(un(i,(()=>this.updateFromDOM())),20)})),Me(r,"compositionstart",(e=>{this.composing={data:e.data,done:!1}})),Me(r,"compositionupdate",(e=>{this.composing||(this.composing={data:e.data,done:!1})})),Me(r,"compositionend",(e=>{this.composing&&(e.data!=this.composing.data&&this.readFromDOMSoon(),this.composing.done=!0)})),Me(r,"touchstart",(()=>t.forceCompositionEnd())),Me(r,"input",(()=>{this.composing||this.readFromDOMSoon()})),Me(r,"copy",o),Me(r,"cut",o)}screenReaderLabelChanged(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")}prepareSelection(){let e=Nr(this.cm,!1);return e.focus=G()==this.div,e}showSelection(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))}getSelection(){return this.cm.display.wrapper.ownerDocument.getSelection()}showPrimarySelection(){let 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)return void e.removeAllRanges();let o=Ql(t,e.anchorNode,e.anchorOffset),l=Ql(t,e.focusNode,e.focusOffset);if(o&&!o.bad&&l&&!l.bad&&0==ft(bt(o,l),r)&&0==ft(mt(o,l),n))return;let s=t.display.view,a=r.line>=t.display.viewFrom&&Zl(t,r)||{node:s[0].measure.map[2],offset:0},c=n.line<t.display.viewTo&&Zl(t,n);if(!c){let e=s[s.length-1].measure,t=e.maps?e.maps[e.maps.length-1]:e.map;c={node:t[t.length-1],offset:t[t.length-2]-t[t.length-3]}}if(!a||!c)return void e.removeAllRanges();let u,d=e.rangeCount&&e.getRangeAt(0);try{u=P(a.node,a.offset,c.offset,c.node)}catch(e){}u&&(!p&&t.state.focused?(e.collapse(a.node,a.offset),u.collapsed||(e.removeAllRanges(),e.addRange(u))):(e.removeAllRanges(),e.addRange(u)),d&&null==e.anchorNode?e.addRange(d):p&&this.startGracePeriod()),this.rememberSelection()}startGracePeriod(){clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout((()=>{this.gracePeriod=!1,this.selectionChanged()&&this.cm.operation((()=>this.cm.curOp.selectionChanged=!0))}),20)}showMultipleSelections(e){B(this.cm.display.cursorDiv,e.cursors),B(this.cm.display.selectionDiv,e.selection)}rememberSelection(){let e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset}selectionInEditor(){let e=this.getSelection();if(!e.rangeCount)return!1;let t=e.getRangeAt(0).commonAncestorContainer;return V(this.div,t)}focus(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&G()==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())}blur(){this.div.blur()}getField(){return this.div}supportsTouch(){return!0}receivedFocus(){let e=this;this.selectionInEditor()?this.pollSelection():cn(this.cm,(()=>e.cm.curOp.selectionChanged=!0)),this.polling.set(this.cm.options.pollInterval,(function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}))}selectionChanged(){let e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset}pollSelection(){if(null!=this.readDOMTimeout||this.gracePeriod||!this.selectionChanged())return;let e=this.getSelection(),t=this.cm;if(N&&C&&this.cm.display.gutterSpecs.length&&function(e){for(let t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}(e.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(this.composing)return;this.rememberSelection();let i=Ql(t,e.anchorNode,e.anchorOffset),r=Ql(t,e.focusNode,e.focusOffset);i&&r&&cn(t,(()=>{co(t.doc,Hn(i,r),te),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)}))}pollContent(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);let e,t,i,r=this.cm,n=r.display,o=r.doc.sel.primary(),l=o.from(),s=o.to();if(0==l.ch&&l.line>r.firstLine()&&(l=ht(l.line-1,nt(r.doc,l.line-1).length)),s.ch==nt(r.doc,s.line).text.length&&s.line<r.lastLine()&&(s=ht(s.line+1,0)),l.line<n.viewFrom||s.line>n.viewTo-1)return!1;l.line==n.viewFrom||0==(e=xr(r,l.line))?(t=at(n.view[0].line),i=n.view[0].node):(t=at(n.view[e].line),i=n.view[e-1].node.nextSibling);let a,c,u=xr(r,s.line);if(u==n.view.length-1?(a=n.viewTo-1,c=n.lineDiv.lastChild):(a=at(n.view[u+1].line)-1,c=n.view[u+1].node.previousSibling),!i)return!1;let d=r.doc.splitLines(function(e,t,i,r,n){let o="",l=!1,s=e.doc.lineSeparator(),a=!1;function c(e){return t=>t.id==e}function u(){l&&(o+=s,a&&(o+=s),l=a=!1)}function d(e){e&&(u(),o+=e)}function h(t){if(1==t.nodeType){let i=t.getAttribute("cm-text");if(i)return void d(i);let o,f=t.getAttribute("cm-marker");if(f){let t=e.findMarks(ht(r,0),ht(n+1,0),c(+f));return void(t.length&&(o=t[0].find(0))&&d(ot(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;let p=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;p&&u();for(let e=0;e<t.childNodes.length;e++)h(t.childNodes[e]);/^(pre|p)$/i.test(t.nodeName)&&(a=!0),p&&(l=!0)}else 3==t.nodeType&&d(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;h(t),t!=i;)t=t.nextSibling,a=!1;return o}(r,i,c,t,a)),h=ot(r.doc,ht(t,0),ht(a,nt(r.doc,a).text.length));for(;d.length>1&&h.length>1;)if(se(d)==se(h))d.pop(),h.pop(),a--;else{if(d[0]!=h[0])break;d.shift(),h.shift(),t++}let f=0,p=0,g=d[0],m=h[0],b=Math.min(g.length,m.length);for(;f<b&&g.charCodeAt(f)==m.charCodeAt(f);)++f;let y=se(d),v=se(h),w=Math.min(y.length-(1==d.length?f:0),v.length-(1==h.length?f:0));for(;p<w&&y.charCodeAt(y.length-p-1)==v.charCodeAt(v.length-p-1);)++p;if(1==d.length&&1==h.length&&t==l.line)for(;f&&f>l.ch&&y.charCodeAt(y.length-p-1)==v.charCodeAt(v.length-p-1);)f--,p++;d[d.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),d[0]=d[0].slice(f).replace(/\u200b+$/,"");let x=ht(t,f),C=ht(a,h.length?se(h).length-p:0);return d.length>1||d[0]||ft(x,C)?(So(r.doc,d,x,C,"+input"),!0):void 0}ensurePolled(){this.forceCompositionEnd()}reset(){this.forceCompositionEnd()}forceCompositionEnd(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())}readFromDOMSoon(){null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((()=>{if(this.readDOMTimeout=null,this.composing){if(!this.composing.done)return;this.composing=null}this.updateFromDOM()}),80))}updateFromDOM(){!this.cm.isReadOnly()&&this.pollContent()||cn(this.cm,(()=>Cr(this.cm)))}setUneditable(e){e.contentEditable="false"}onKeyPress(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||un(this.cm,_l)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))}readOnlyChanged(e){this.div.contentEditable=String("nocursor"!=e)}onContextMenu(){}resetPosition(){}},Yl=Xl;function Zl(e,t){let i=Ui(e,t.line);if(!i||i.hidden)return null;let r=nt(e.doc,t.line),n=Bi(i,r,t.line),o=Ce(r,e.doc.direction),l="left";if(o){l=we(o,t.ch)%2?"right":"left"}let s=ji(n.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Jl(e,t){return t&&(e.bad=!0),e}function Ql(e,t,i){let r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return Jl(e.clipPos(ht(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(let n=0;n<e.display.view.length;n++){let o=e.display.view[n];if(o.node==r)return es(o,t,i)}}function es(e,t,i){let r=e.text.firstChild,n=!1;if(!t||!V(r,t))return Jl(ht(at(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){let t=e.rest?se(e.rest):e.line;return Jl(ht(at(t),t.text.length),n)}let o=3==t.nodeType?t:null,l=t;for(o||1!=t.childNodes.length||3!=t.firstChild.nodeType||(o=t.firstChild,i&&(i=o.nodeValue.length));l.parentNode!=r;)l=l.parentNode;let s=e.measure,a=s.maps;function c(t,i,r){for(let n=-1;n<(a?a.length:0);n++){let o=n<0?s.map:a[n];for(let l=0;l<o.length;l+=3){let s=o[l+2];if(s==t||s==i){let i=at(n<0?e.line:e.rest[n]),a=o[l]+r;return(r<0||s!=t)&&(a=o[l+(r?1:0)]),ht(i,a)}}}}let u=c(o,l,i);if(u)return Jl(u,n);for(let e=l.nextSibling,t=o?o.nodeValue.length-i:0;e;e=e.nextSibling){if(u=c(e,e.firstChild,0),u)return Jl(ht(u.line,u.ch-t),n);t+=e.textContent.length}for(let e=l.previousSibling,t=i;e;e=e.previousSibling){if(u=c(e,e.firstChild,-1),u)return Jl(ht(u.line,u.ch+t),n);t+=e.textContent.length}}Xl.prototype.needsContentAttribute=!0;var ts=class{constructor(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Z,this.hasSelection=!1,this.composing=null}init(e){let t=this,i=this.cm;this.createField(e);const r=this.textarea;function n(e){if(!Ne(i,e)){if(i.somethingSelected())Bl({lineWise:!1,text:i.getSelections()});else{if(!i.options.lineWiseCopyCut)return;{let n=Gl(i);Bl({lineWise:!0,text:n.text}),"cut"==e.type?i.setSelections(n.ranges,null,te):(t.prevInput="",r.value=n.text.join("\n"),j(r))}}"cut"==e.type&&(i.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),T&&(r.style.width="0px"),Me(r,"input",(()=>{y&&v>=9&&this.hasSelection&&(this.hasSelection=null),t.poll()})),Me(r,"paste",(e=>{Ne(i,e)||Ul(e,i)||(i.state.pasteIncoming=+new Date,t.fastPoll())})),Me(r,"cut",n),Me(r,"copy",n),Me(e.scroller,"paste",(n=>{if(Wi(e,n)||Ne(i,n))return;if(!r.dispatchEvent)return i.state.pasteIncoming=+new Date,void t.focus();const o=new Event("paste");o.clipboardData=n.clipboardData,r.dispatchEvent(o)})),Me(e.lineSpace,"selectstart",(t=>{Wi(e,t)||ze(t)})),Me(r,"compositionstart",(()=>{let e=i.getCursor("from");t.composing&&t.composing.range.clear(),t.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}})),Me(r,"compositionend",(()=>{t.composing&&(t.poll(),t.composing.range.clear(),t.composing=null)}))}createField(e){this.wrapper=Kl(),this.textarea=this.wrapper.firstChild}screenReaderLabelChanged(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")}prepareSelection(){let e=this.cm,t=e.display,i=e.doc,r=Nr(e);if(e.options.moveInputWithCursor){let n=nr(e,i.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+l.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+l.left-o.left))}return r}showSelection(e){let t=this.cm.display;B(t.cursorDiv,e.cursors),B(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")}reset(e){if(this.contextMenuPending||this.composing)return;let t=this.cm;if(t.somethingSelected()){this.prevInput="";let e=t.getSelection();this.textarea.value=e,t.state.focused&&j(this.textarea),y&&v>=9&&(this.hasSelection=e)}else e||(this.prevInput=this.textarea.value="",y&&v>=9&&(this.hasSelection=null))}getField(){return this.textarea}supportsTouch(){return!1}focus(){if("nocursor"!=this.cm.options.readOnly&&(!A||G()!=this.textarea))try{this.textarea.focus()}catch(e){}}blur(){this.textarea.blur()}resetPosition(){this.wrapper.style.top=this.wrapper.style.left=0}receivedFocus(){this.slowPoll()}slowPoll(){this.pollingFast||this.polling.set(this.cm.options.pollInterval,(()=>{this.poll(),this.cm.state.focused&&this.slowPoll()}))}fastPoll(){let e=!1,t=this;t.pollingFast=!0,t.polling.set(20,(function i(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,i))}))}poll(){let e=this.cm,t=this.textarea,i=this.prevInput;if(this.contextMenuPending||!e.state.focused||Ge(t)&&!i&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;let r=t.value;if(r==i&&!e.somethingSelected())return!1;if(y&&v>=9&&this.hasSelection===r||O&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){let e=r.charCodeAt(0);if(8203!=e||i||(i="​"),8666==e)return this.reset(),this.cm.execCommand("undo")}let n=0,o=Math.min(i.length,r.length);for(;n<o&&i.charCodeAt(n)==r.charCodeAt(n);)++n;return cn(e,(()=>{_l(e,r.slice(n),i.length-n,null,this.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=this.prevInput="":this.prevInput=r,this.composing&&(this.composing.range.clear(),this.composing.range=e.markText(this.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))})),!0}ensurePolled(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)}onKeyPress(){y&&v>=9&&(this.hasSelection=null),this.fastPoll()}onContextMenu(e){let t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();let o=wr(i,e),l=r.scroller.scrollTop;if(!o||k)return;i.options.resetSelectionOnContextMenu&&-1==i.doc.sel.contains(o)&&un(i,co)(i.doc,Hn(o),te);let s,a=n.style.cssText,c=t.wrapper.style.cssText,u=t.wrapper.offsetParent.getBoundingClientRect();function d(){if(null!=n.selectionStart){let e=i.somethingSelected(),o="​"+(e?n.value:"");n.value="⇚",n.value=o,t.prevInput=e?"":"​",n.selectionStart=1,n.selectionEnd=o.length,r.selForContextMenu=i.doc.sel}}function h(){if(t.contextMenuPending==h&&(t.contextMenuPending=!1,t.wrapper.style.cssText=c,n.style.cssText=a,y&&v<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=l),null!=n.selectionStart)){(!y||y&&v<9)&&d();let e=0,o=()=>{r.selForContextMenu==i.doc.sel&&0==n.selectionStart&&n.selectionEnd>0&&"​"==t.prevInput?un(i,yo)(i):e++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}if(t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;\n      top: ${e.clientY-u.top-5}px; left: ${e.clientX-u.left-5}px;\n      z-index: 1000; background: ${y?"rgba(255, 255, 255, .05)":"transparent"};\n      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`,w&&(s=window.scrollY),r.input.focus(),w&&window.scrollTo(null,s),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=h,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll),y&&v>=9&&d(),H){He(e);let t=()=>{Le(window,"mouseup",t),setTimeout(h,20)};Me(window,"mouseup",t)}else setTimeout(h,50)}readOnlyChanged(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e}setUneditable(){}},is=ts;ts.prototype.needsContentAttribute=!1,function(e){let t=e.optionHandlers;function i(i,r,n,o){e.defaults[i]=r,n&&(t[i]=o?(e,t,i)=>{i!=Ol&&n(e,t,i)}:n)}e.defineOption=i,e.Init=Ol,i("value","",((e,t)=>e.setValue(t)),!0),i("mode",null,((e,t)=>{e.doc.modeOption=t,Bn(e)}),!0),i("indentUnit",2,Bn,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,(e=>{_n(e),Zi(e),Cr(e)}),!0),i("lineSeparator",null,((e,t)=>{if(e.doc.lineSep=t,!t)return;let i=[],r=e.doc.first;e.doc.iter((e=>{for(let n=0;;){let o=e.text.indexOf(t,n);if(-1==o)break;n=o+t.length,i.push(ht(r,o))}r++}));for(let r=i.length-1;r>=0;r--)So(e.doc,t,i[r],ht(i[r].line,i[r].ch+t.length))})),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,((e,t,i)=>{e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),i!=Ol&&e.refresh()})),i("specialCharPlaceholder",ui,(e=>e.refresh()),!0),i("electricChars",!0),i("inputStyle",A?"contenteditable":"textarea",(()=>{throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),i("spellcheck",!1,((e,t)=>e.getInputField().spellcheck=t),!0),i("autocorrect",!1,((e,t)=>e.getInputField().autocorrect=t),!0),i("autocapitalize",!1,((e,t)=>e.getInputField().autocapitalize=t),!0),i("rtlMoveVisually",!z),i("wholeLineUpdateBefore",!0),i("theme","default",(e=>{Al(e),Sn(e)}),!0),i("keyMap","default",((e,t,i)=>{let r=nl(t),n=i!=Ol&&nl(i);n&&n.detach&&n.detach(e,r),r.attach&&r.attach(e,n||null)})),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,El,!0),i("gutters",[],((e,t)=>{e.display.gutterSpecs=kn(t,e.options.lineNumbers),Sn(e)}),!0),i("fixedGutter",!0,((e,t)=>{e.display.gutters.style.left=t?br(e.display)+"px":"0",e.refresh()}),!0),i("coverGutterNextToScrollbar",!1,(e=>Yr(e)),!0),i("scrollbarStyle","native",(e=>{Qr(e),Yr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),i("lineNumbers",!1,((e,t)=>{e.display.gutterSpecs=kn(e.options.gutters,t),Sn(e)}),!0),i("firstLineNumber",1,Sn,!0),i("lineNumberFormatter",(e=>e),Sn,!0),i("showCursorWhenSelecting",!1,Tr,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,((e,t)=>{"nocursor"==t&&(Fr(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),i("screenReaderLabel",null,((e,t)=>{t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)})),i("disableInput",!1,((e,t)=>{t||e.display.input.reset()}),!0),i("dragDrop",!0,Wl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,Tr,!0),i("singleCursorHeightPerLine",!0,Tr,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,_n,!0),i("addModeClass",!1,_n,!0),i("pollInterval",100),i("undoDepth",200,((e,t)=>e.doc.history.undoDepth=t)),i("historyEventDelay",1250),i("viewportMargin",10,(e=>e.refresh()),!0),i("maxHighlightLength",1e4,_n,!0),i("moveInputWithCursor",!0,((e,t)=>{t||e.display.input.resetPosition()})),i("tabindex",null,((e,t)=>e.display.input.getField().tabIndex=t||"")),i("autofocus",null),i("direction","ltr",((e,t)=>e.doc.setDirection(t)),!0),i("phrases",null)}(Hl),function(e){let t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,i){let r=this.options,n=r[e];r[e]==i&&"mode"!=e||(r[e]=i,t.hasOwnProperty(e)&&un(this,t[e])(this,i,n),Te(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](nl(e))},removeKeyMap:function(e){let t=this.state.keyMaps;for(let i=0;i<t.length;++i)if(t[i]==e||t[i].name==e)return t.splice(i,1),!0},addOverlay:dn((function(t,i){let r=t.token?t:e.getMode(this.options,t);if(r.startState)throw new Error("Overlays may not be stateful.");!function(e,t,i){let r=0,n=i(t);for(;r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}(this.state.overlays,{mode:r,modeSpec:t,opaque:i&&i.opaque,priority:i&&i.priority||0},(e=>e.priority)),this.state.modeGen++,Cr(this)})),removeOverlay:dn((function(e){let t=this.state.overlays;for(let i=0;i<t.length;++i){let r=t[i].modeSpec;if(r==e||"string"==typeof e&&r.name==e)return t.splice(i,1),this.state.modeGen++,void Cr(this)}})),indentLine:dn((function(e,t,i){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ut(this.doc,e)&&Il(this,e,t,i)})),indentSelection:dn((function(e){let t=this.doc.sel.ranges,i=-1;for(let r=0;r<t.length;r++){let n=t[r];if(n.empty())n.head.line>i&&(Il(this,n.head.line,e,!0),i=n.head.line,r==this.doc.sel.primIndex&&Ur(this));else{let o=n.from(),l=n.to(),s=Math.max(i,o.line);i=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(let t=s;t<i;++t)Il(this,t,e);let a=this.doc.sel.ranges;0==o.ch&&t.length==a.length&&a[r].from().ch>0&&lo(this.doc,r,new Wn(o,a[r].to()),te)}}})),getTokenAt:function(e,t){return Ot(this,e,t)},getLineTokens:function(e,t){return Ot(this,ht(e),t,!0)},getTokenTypeAt:function(e){e=vt(this.doc,e);let t,i=Mt(this,nt(this.doc,e.line)),r=0,n=(i.length-1)/2,o=e.ch;if(0==o)t=i[2];else for(;;){let e=r+n>>1;if((e?i[2*e-1]:0)>=o)n=e;else{if(!(i[2*e+1]<o)){t=i[2*e+2];break}r=e+1}}let l=t?t.indexOf("overlay "):-1;return l<0?t:0==l?null:t.slice(0,l-1)},getModeAt:function(t){let i=this.doc.mode;return i.innerMode?e.innerMode(i,this.getTokenAt(t).state).mode:i},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){let r=[];if(!i.hasOwnProperty(t))return r;let n=i[t],o=this.getModeAt(e);if("string"==typeof o[t])n[o[t]]&&r.push(n[o[t]]);else if(o[t])for(let e=0;e<o[t].length;e++){let i=n[o[t][e]];i&&r.push(i)}else o.helperType&&n[o.helperType]?r.push(n[o.helperType]):n[o.name]&&r.push(n[o.name]);for(let e=0;e<n._global.length;e++){let t=n._global[e];t.pred(o,this)&&-1==J(r,t.val)&&r.push(t.val)}return r},getStateAfter:function(e,t){let i=this.doc;return St(this,(e=yt(i,null==e?i.first+i.size-1:e))+1,t).state},cursorCoords:function(e,t){let i,r=this.doc.sel.primary();return i=null==e?r.head:"object"==typeof e?vt(this.doc,e):e?r.from():r.to(),nr(this,i,t||"page")},charCoords:function(e,t){return rr(this,vt(this.doc,e),t||"page")},coordsChar:function(e,t){return sr(this,(e=ir(this,e,t||"page")).left,e.top)},lineAtHeight:function(e,t){return e=ir(this,{top:e,left:0},t||"page").top,ct(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,i){let r,n=!1;if("number"==typeof e){let t=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>t&&(e=t,n=!0),r=nt(this.doc,e)}else r=e;return tr(this,r,{top:0,left:0},t||"page",i||n).top+(n?this.doc.height-ti(r):0)},defaultTextHeight:function(){return pr(this.display)},defaultCharWidth:function(){return gr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,i,r,n){let o=this.display,l=(e=nr(this,vt(this.doc,e))).bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)l=e.top;else if("above"==r||"near"==r){let i=Math.max(o.wrapper.clientHeight,this.doc.height),n=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>i)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=i&&(l=e.bottom),s+t.offsetWidth>n&&(s=n-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==n?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==n?s=0:"middle"==n&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),i&&function(e,t){let i=Br(e,t);null!=i.scrollTop&&Kr(e,i.scrollTop),null!=i.scrollLeft&&qr(e,i.scrollLeft)}(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:dn(yl),triggerOnKeyPress:dn(wl),triggerOnKeyUp:vl,triggerOnMouseDown:dn(Ml),execCommand:function(e){if(cl.hasOwnProperty(e))return cl[e].call(null,this)},triggerElectric:dn((function(e){Vl(this,e)})),findPosH:function(e,t,i,r){let n=1;t<0&&(n=-1,t=-t);let o=vt(this.doc,e);for(let e=0;e<t&&(o=jl(this.doc,o,n,i,r),!o.hitSide);++e);return o},moveH:dn((function(e,t){this.extendSelectionsBy((i=>this.display.shift||this.doc.extend||i.empty()?jl(this.doc,i.head,e,t,this.options.rtlMoveVisually):e<0?i.from():i.to()),re)})),deleteH:dn((function(e,t){let i=this.doc.sel,r=this.doc;i.somethingSelected()?r.replaceSelection("",null,"+delete"):ol(this,(i=>{let n=jl(r,i.head,e,t,!1);return e<0?{from:n,to:i.head}:{from:i.head,to:n}}))})),findPosV:function(e,t,i,r){let n=1,o=r;t<0&&(n=-1,t=-t);let l=vt(this.doc,e);for(let e=0;e<t;++e){let e=nr(this,l,"div");if(null==o?o=e.left:e.left=o,l=ql(this,e,n,i),l.hitSide)break}return l},moveV:dn((function(e,t){let i=this.doc,r=[],n=!this.display.shift&&!i.extend&&i.sel.somethingSelected();if(i.extendSelectionsBy((o=>{if(n)return e<0?o.from():o.to();let l=nr(this,o.head,"div");null!=o.goalColumn&&(l.left=o.goalColumn),r.push(l.left);let s=ql(this,l,e,t);return"page"==t&&o==i.sel.primary()&&_r(this,rr(this,s,"div").top-l.top),s}),re),r.length)for(let e=0;e<i.sel.ranges.length;e++)i.sel.ranges[e].goalColumn=r[e]})),findWordAt:function(e){let t=nt(this.doc,e.line).text,i=e.ch,r=e.ch;if(t){let n=this.getHelper(e,"wordChars");"before"!=e.sticky&&r!=t.length||!i?++r:--i;let o=t.charAt(i),l=fe(o,n)?e=>fe(e,n):/\s/.test(o)?e=>/\s/.test(e):e=>!/\s/.test(e)&&!fe(e);for(;i>0&&l(t.charAt(i-1));)--i;for(;r<t.length&&l(t.charAt(r));)++r}return new Wn(ht(e.line,i),ht(e.line,r))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?$(this.display.cursorDiv,"CodeMirror-overwrite"):I(this.display.cursorDiv,"CodeMirror-overwrite"),Te(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==G()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:dn((function(e,t){Vr(this,e,t)})),getScrollInfo:function(){let e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Pi(this)-this.display.barHeight,width:e.scrollWidth-Pi(this)-this.display.barWidth,clientHeight:Ri(this),clientWidth:Ii(this)}},scrollIntoView:dn((function(e,t){null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:ht(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line?function(e,t){Gr(e),e.curOp.scrollToPos=t}(this,e):$r(this,e.from,e.to,e.margin)})),setSize:dn((function(e,t){let i=e=>"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e;null!=e&&(this.display.wrapper.style.width=i(e)),null!=t&&(this.display.wrapper.style.height=i(t)),this.options.lineWrapping&&Yi(this);let r=this.display.viewFrom;this.doc.iter(r,this.display.viewTo,(e=>{if(e.widgets)for(let t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){kr(this,r,"widget");break}++r})),this.curOp.forceUpdate=!0,Te(this,"refresh",this)})),operation:function(e){return cn(this,e)},startOperation:function(){return tn(this)},endOperation:function(){return rn(this)},refresh:dn((function(){let e=this.display.cachedTextHeight;Cr(this),this.curOp.forceUpdate=!0,Zi(this),Vr(this,this.doc.scrollLeft,this.doc.scrollTop),vn(this.display),(null==e||Math.abs(e-pr(this.display))>.5||this.options.lineWrapping)&&vr(this),Te(this,"refresh",this)})),swapDoc:dn((function(e){let t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),$n(this,e),Zi(this),this.display.input.reset(),Vr(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,vi(this,"swapDoc",this,t),t})),phrase:function(e){let t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},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}},De(e),e.registerHelper=function(t,r,n){i.hasOwnProperty(t)||(i[t]=e[t]={_global:[]}),i[t][r]=n},e.registerGlobalHelper=function(t,r,n,o){e.registerHelper(t,r,o),i[t]._global.push({pred:n,val:o})}}(Hl);var rs,ns="iter insert remove copy getEditor constructor".split(" ");for(let e in Uo.prototype)Uo.prototype.hasOwnProperty(e)&&J(ns,e)<0&&(Hl.prototype[e]=function(e){return function(){return e.apply(this.doc,arguments)}}(Uo.prototype[e]));De(Uo),Hl.inputStyles={textarea:is,contenteditable:Yl},Hl.defineMode=function(e){Hl.defaults.mode||"null"==e||(Hl.defaults.mode=e),Xe.apply(this,arguments)},Hl.defineMIME=function(e,t){qe[e]=t},Hl.defineMode("null",(()=>({token:e=>e.skipToEnd()}))),Hl.defineMIME("text/plain","null"),Hl.defineExtension=(e,t)=>{Hl.prototype[e]=t},Hl.defineDocExtension=(e,t)=>{Uo.prototype[e]=t},Hl.fromTextArea=function(e,t){if((t=t?X(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){let i=G();t.autofocus=i==e||null!=e.getAttribute("autofocus")&&i==document.body}function i(){e.value=n.getValue()}let r;if(e.form&&(Me(e.form,"submit",i),!t.leaveSubmitMethodAlone)){let t=e.form;r=t.submit;try{let e=t.submit=()=>{i(),t.submit=r,t.submit(),t.submit=e}}catch(e){}}t.finishInit=n=>{n.save=i,n.getTextArea=()=>e,n.toTextArea=()=>{n.toTextArea=isNaN,i(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(Le(e.form,"submit",i),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=r))}},e.style.display="none";let n=Hl((t=>e.parentNode.insertBefore(t,e.nextSibling)),t);return n},(rs=Hl).off=Le,rs.on=Me,rs.wheelEventPixels=On,rs.Doc=Uo,rs.splitLines=Ve,rs.countColumn=Y,rs.findColumn=ne,rs.isWordChar=he,rs.Pass=ee,rs.signal=Te,rs.Line=ni,rs.changeEnd=Fn,rs.scrollbarModel=Jr,rs.Pos=ht,rs.cmpPos=ft,rs.modes=je,rs.mimeModes=qe,rs.resolveMode=Ye,rs.getMode=Ze,rs.modeExtensions=Je,rs.extendMode=Qe,rs.copyState=et,rs.startState=it,rs.innerMode=tt,rs.commands=cl,rs.keyMap=Zo,rs.keyName=rl,rs.isModifierKey=tl,rs.lookupKey=el,rs.normalizeKeyMap=Qo,rs.StringStream=rt,rs.SharedTextMarker=Po,rs.TextMarker=Ho,rs.LineWidget=zo,rs.e_preventDefault=ze,rs.e_stopPropagation=We,rs.e_stop=He,rs.addClass=$,rs.contains=V,rs.rmClass=I,rs.keyNames=Yo,Hl.version="5.61.0";var os=Hl;self.CodeMirror=os;var ls,ss=class extends HTMLElement{static get observedAttributes(){return["src","readonly","mode","theme"]}attributeChangedCallback(e,t,i){this.__initialized&&t!==i&&(this[e]="readonly"===e?null!==i:i)}get readonly(){return this.editor.getOption("readOnly")}set readonly(e){this.editor.setOption("readOnly",e)}get mode(){return this.editor.getOption("mode")}set mode(e){this.editor.setOption("mode",e)}get theme(){return this.editor.getOption("theme")}set theme(e){this.editor.setOption("theme",e)}get src(){return this.getAttribute("src")}set src(e){this.setAttribute("src",e),this.setSrc()}get value(){return this.editor.getValue()}set value(e){this.__initialized?this.setValueForced(e):this.__preInitValue=e}constructor(){super();const e=e=>"childList"===e.type&&(Array.from(e.addedNodes).some((e=>"LINK"===e.tagName))||Array.from(e.removedNodes).some((e=>"LINK"===e.tagName)));this.__observer=new MutationObserver(((t,i)=>{t.some(e)&&this.refreshStyles(),this.lookupInnerScript((e=>{this.value=e}))})),this.__observer.observe(this,{childList:!0,characterData:!0,subtree:!0}),this.__initialized=!1,this.__element=null,this.editor=null}async connectedCallback(){const e=this.attachShadow({mode:"open"}),t=document.createElement("template"),i=document.createElement("style");i.innerHTML="\n/* BASICS */\n\n.CodeMirror {\n  /* Set height, width, borders, and global font properties here */\n  font-family: monospace;\n  height: auto;\n  color: black;\n  direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n  padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n  padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n  background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n  border-right: 1px solid #ddd;\n  background-color: #f7f7f7;\n  white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n  padding: 0 3px 0 5px;\n  min-width: 20px;\n  text-align: right;\n  color: #999;\n  white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n  border-left: 1px solid black;\n  border-right: none;\n  width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n  border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n  width: auto;\n  border: 0 !important;\n  background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n  z-index: 1;\n}\n.cm-fat-cursor-mark {\n  background-color: rgba(20, 255, 20, 0.5);\n  -webkit-animation: blink 1.06s steps(1) infinite;\n  -moz-animation: blink 1.06s steps(1) infinite;\n  animation: blink 1.06s steps(1) infinite;\n}\n.cm-animate-fat-cursor {\n  width: auto;\n  border: 0;\n  -webkit-animation: blink 1.06s steps(1) infinite;\n  -moz-animation: blink 1.06s steps(1) infinite;\n  animation: blink 1.06s steps(1) infinite;\n  background-color: #7e7;\n}\n@-moz-keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n@-webkit-keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n@keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n  position: absolute;\n  left: 0; right: 0; top: -50px; bottom: 0;\n  overflow: hidden;\n}\n.CodeMirror-ruler {\n  border-left: 1px solid #ccc;\n  top: 0; bottom: 0;\n  position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n    the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n  position: relative;\n  overflow: hidden;\n  background: white;\n}\n\n.CodeMirror-scroll {\n  overflow: scroll !important; /* Things will break if this is overridden */\n  /* 50px is the magic margin used to hide the element's real scrollbars */\n  /* See overflow: hidden in .CodeMirror */\n  margin-bottom: -50px; margin-right: -50px;\n  padding-bottom: 50px;\n  height: 100%;\n  outline: none; /* Prevent dragging from highlighting the element */\n  position: relative;\n}\n.CodeMirror-sizer {\n  position: relative;\n  border-right: 50px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n    before actual scrolling happens, thus preventing shaking and\n    flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n  position: absolute;\n  z-index: 6;\n  display: none;\n}\n.CodeMirror-vscrollbar {\n  right: 0; top: 0;\n  overflow-x: hidden;\n  overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n  bottom: 0; left: 0;\n  overflow-y: hidden;\n  overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n  right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n  left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n  position: absolute; left: 0; top: 0;\n  min-height: 100%;\n  z-index: 3;\n}\n.CodeMirror-gutter {\n  white-space: normal;\n  height: 100%;\n  display: inline-block;\n  vertical-align: top;\n  margin-bottom: -50px;\n}\n.CodeMirror-gutter-wrapper {\n  position: absolute;\n  z-index: 4;\n  background: none !important;\n  border: none !important;\n}\n.CodeMirror-gutter-background {\n  position: absolute;\n  top: 0; bottom: 0;\n  z-index: 4;\n}\n.CodeMirror-gutter-elt {\n  position: absolute;\n  cursor: default;\n  z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n  cursor: text;\n  min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n  /* Reset some styles that the rest of the page might have set */\n  -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n  border-width: 0;\n  background: transparent;\n  font-family: inherit;\n  font-size: inherit;\n  margin: 0;\n  white-space: pre;\n  word-wrap: normal;\n  line-height: inherit;\n  color: inherit;\n  z-index: 2;\n  position: relative;\n  overflow: visible;\n  -webkit-tap-highlight-color: transparent;\n  -webkit-font-variant-ligatures: contextual;\n  font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre.CodeMirror-line,\n.CodeMirror-wrap pre.CodeMirror-line-like {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  word-break: normal;\n}\n\n.CodeMirror-linebackground {\n  position: absolute;\n  left: 0; right: 0; top: 0; bottom: 0;\n  z-index: 0;\n}\n\n.CodeMirror-linewidget {\n  position: relative;\n  z-index: 2;\n  padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n  outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n  position: absolute;\n  width: 100%;\n  height: 0;\n  overflow: hidden;\n  visibility: hidden;\n}\n\n.CodeMirror-cursor {\n  position: absolute;\n  pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n  visibility: hidden;\n  position: relative;\n  z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n  visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n  visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n  background-color: #ffa;\n  background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n  /* Hide the cursor when printing */\n  .CodeMirror div.CodeMirror-cursors {\n    visibility: hidden;\n  }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n",t.innerHTML=ss.template(),e.appendChild(i),e.appendChild(t.content.cloneNode(!0)),this.style.display="block",this.__element=e.querySelector("textarea");const r=this.hasAttribute("mode")?this.getAttribute("mode"):"null",n=this.hasAttribute("theme")?this.getAttribute("theme"):"default";let o=this.getAttribute("readonly");""===o?o=!0:"nocursor"!==o&&(o=!1),this.refreshStyles(),this.lookupInnerScript((e=>{this.value=e}));let l=os.defaults.viewportMargin;if(this.hasAttribute("viewport-margin")){const e=this.getAttribute("viewport-margin").toLowerCase();l="infinity"===e?1/0:parseInt(e)}this.editor=os.fromTextArea(this.__element,{lineNumbers:!0,readOnly:o,mode:r,theme:n,viewportMargin:l}),this.hasAttribute("src")&&this.setSrc(),await new Promise((e=>setTimeout(e,50))),this.__initialized=!0,void 0!==this.__preInitValue&&this.setValueForced(this.__preInitValue)}disconnectedCallback(){this.editor&&this.editor.toTextArea(),this.editor=null,this.__initialized=!1,this.__observer.disconnect()}async setSrc(){const e=this.getAttribute("src"),t=await this.fetchSrc(e);this.value=t}async setValueForced(e){this.editor.swapDoc(os.Doc(e,this.getAttribute("mode"))),this.editor.refresh()}async fetchSrc(e){return(await fetch(e)).text()}refreshStyles(){Array.from(this.shadowRoot.children).forEach((e=>{"LINK"===e.tagName&&"stylesheet"===e.getAttribute("rel")&&e.remove()})),Array.from(this.children).forEach((e=>{"LINK"===e.tagName&&"stylesheet"===e.getAttribute("rel")&&this.shadowRoot.appendChild(e.cloneNode(!0))}))}static template(){return'\n      <textarea style="display:inherit; width:inherit; height:inherit;"></textarea>\n    '}lookupInnerScript(e){const t=this.querySelector("script");if(t&&"wc-content"===t.getAttribute("type")){let i=ss.dedentText(t.innerHTML);i=i.replace(/&lt;(\/?script)(.*?)&gt;/g,"<$1$2>"),e(i)}}static dedentText(e){const t=e.split("\n");""===t[0]&&t.splice(0,1);const i=t[0];let r=0;const n="\t"===i[0]?"\t":" ";for(;i[r]===n;)r+=1;const o=[];for(const e of t){let t=e;for(let e=0;e<r&&t[0]===n;e++)t=t.substring(1);o.push(t)}return""===o[o.length-1]&&o.splice(o.length-1,1),o.join("\n")}};customElements.define("wc-codemirror",ss),ls=function(e){function t(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var i,r=t(["and","or","not","is"]),n=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in"],o=["abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"];function l(e){return e.scopes[e.scopes.length-1]}e.registerHelper("hintWords","python",n.concat(o)),e.defineMode("python",(function(i,s){for(var a="error",c=s.delimiters||s.singleDelimiters||/^[\(\)\[\]\{\}@,:`=;\.\\]/,u=[s.singleOperators,s.doubleOperators,s.doubleDelimiters,s.tripleDelimiters,s.operators||/^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/],d=0;d<u.length;d++)u[d]||u.splice(d--,1);var h=s.hangingIndent||i.indentUnit,f=n,p=o;null!=s.extra_keywords&&(f=f.concat(s.extra_keywords)),null!=s.extra_builtins&&(p=p.concat(s.extra_builtins));var g=!(s.version&&Number(s.version)<3);if(g){var m=s.identifiers||/^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;f=f.concat(["nonlocal","False","True","None","async","await"]),p=p.concat(["ascii","bytes","exec","print"]);var b=new RegExp("^(([rbuf]|(br)|(fr))?('{3}|\"{3}|['\"]))","i")}else m=s.identifiers||/^[_A-Za-z][_A-Za-z0-9]*/,f=f.concat(["exec","print"]),p=p.concat(["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","False","True","None"]),b=new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))","i");var y=t(f),v=t(p);function w(e,t){var i=e.sol()&&"\\"!=t.lastToken;if(i&&(t.indent=e.indentation()),i&&"py"==l(t).type){var r=l(t).offset;if(e.eatSpace()){var n=e.indentation();return n>r?C(t):n<r&&k(e,t)&&"#"!=e.peek()&&(t.errorToken=!0),null}var o=x(e,t);return r>0&&k(e,t)&&(o+=" "+a),o}return x(e,t)}function x(e,t,i){if(e.eatSpace())return null;if(!i&&e.match(/^#.*/))return"comment";if(e.match(/^[0-9\.]/,!1)){var n=!1;if(e.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)&&(n=!0),e.match(/^[\d_]+\.\d*/)&&(n=!0),e.match(/^\.\d+/)&&(n=!0),n)return e.eat(/J/i),"number";var o=!1;if(e.match(/^0x[0-9a-f_]+/i)&&(o=!0),e.match(/^0b[01_]+/i)&&(o=!0),e.match(/^0o[0-7_]+/i)&&(o=!0),e.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)&&(e.eat(/J/i),o=!0),e.match(/^0(?![\dx])/i)&&(o=!0),o)return e.eat(/L/i),"number"}if(e.match(b))return-1!==e.current().toLowerCase().indexOf("f")?(t.tokenize=function(e,t){for(;"rubf".indexOf(e.charAt(0).toLowerCase())>=0;)e=e.substr(1);var i=1==e.length,r="string";function n(e){return function(t,i){var r=x(t,i,!0);return"punctuation"==r&&("{"==t.current()?i.tokenize=n(e+1):"}"==t.current()&&(i.tokenize=e>1?n(e-1):o)),r}}function o(o,l){for(;!o.eol();)if(o.eatWhile(/[^'"\{\}\\]/),o.eat("\\")){if(o.next(),i&&o.eol())return r}else{if(o.match(e))return l.tokenize=t,r;if(o.match("{{"))return r;if(o.match("{",!1))return l.tokenize=n(0),o.current()?r:l.tokenize(o,l);if(o.match("}}"))return r;if(o.match("}"))return a;o.eat(/['"]/)}if(i){if(s.singleLineStringErrors)return a;l.tokenize=t}return r}return o.isString=!0,o}(e.current(),t.tokenize),t.tokenize(e,t)):(t.tokenize=function(e,t){for(;"rubf".indexOf(e.charAt(0).toLowerCase())>=0;)e=e.substr(1);var i=1==e.length,r="string";function n(n,o){for(;!n.eol();)if(n.eatWhile(/[^'"\\]/),n.eat("\\")){if(n.next(),i&&n.eol())return r}else{if(n.match(e))return o.tokenize=t,r;n.eat(/['"]/)}if(i){if(s.singleLineStringErrors)return a;o.tokenize=t}return r}return n.isString=!0,n}(e.current(),t.tokenize),t.tokenize(e,t));for(var l=0;l<u.length;l++)if(e.match(u[l]))return"operator";return e.match(c)?"punctuation":"."==t.lastToken&&e.match(m)?"property":e.match(y)||e.match(r)?"keyword":e.match(v)?"builtin":e.match(/^(self|cls)\b/)?"variable-2":e.match(m)?"def"==t.lastToken||"class"==t.lastToken?"def":"variable":(e.next(),i?null:a)}function C(e){for(;"py"!=l(e).type;)e.scopes.pop();e.scopes.push({offset:l(e).offset+i.indentUnit,type:"py",align:null})}function k(e,t){for(var i=e.indentation();t.scopes.length>1&&l(t).offset>i;){if("py"!=l(t).type)return!0;t.scopes.pop()}return l(t).offset!=i}function M(e,t){e.sol()&&(t.beginningOfLine=!0);var i=t.tokenize(e,t),r=e.current();if(t.beginningOfLine&&"@"==r)return e.match(m,!1)?"meta":g?"operator":a;if(/\S/.test(r)&&(t.beginningOfLine=!1),"variable"!=i&&"builtin"!=i||"meta"!=t.lastToken||(i="meta"),"pass"!=r&&"return"!=r||(t.dedent+=1),"lambda"==r&&(t.lambda=!0),":"==r&&!t.lambda&&"py"==l(t).type&&e.match(/^\s*(?:#|$)/,!1)&&C(t),1==r.length&&!/string|comment/.test(i)){var n="[({".indexOf(r);if(-1!=n&&function(e,t,i){var r=e.match(/^[\s\[\{\(]*(?:#|$)/,!1)?null:e.column()+1;t.scopes.push({offset:t.indent+h,type:i,align:r})}(e,t,"])}".slice(n,n+1)),-1!=(n="])}".indexOf(r))){if(l(t).type!=r)return a;t.indent=t.scopes.pop().offset-h}}return t.dedent>0&&e.eol()&&"py"==l(t).type&&(t.scopes.length>1&&t.scopes.pop(),t.dedent-=1),i}return{startState:function(e){return{tokenize:w,scopes:[{offset:e||0,type:"py",align:null}],indent:e||0,lastToken:null,lambda:!1,dedent:0}},token:function(e,t){var i=t.errorToken;i&&(t.errorToken=!1);var r=M(e,t);return r&&"comment"!=r&&(t.lastToken="keyword"==r||"punctuation"==r?e.current():r),"punctuation"==r&&(r=null),e.eol()&&t.lambda&&(t.lambda=!1),i?r+" "+a:r},indent:function(t,i){if(t.tokenize!=w)return t.tokenize.isString?e.Pass:0;var r=l(t),n=r.type==i.charAt(0);return null!=r.align?r.align-(n?1:0):r.offset-(n?h:0)},electricInput:/^\s*[\}\]\)]$/,closeBrackets:{triples:"'\""},lineComment:"#",fold:"indent"}})),e.defineMIME("text/x-python","python"),e.defineMIME("text/x-cython",{name:"python",extra_keywords:(i="by cdef cimport cpdef ctypedef enum except extern gil include nogil property public readonly struct union DEF IF ELIF ELSE",i.split(" "))})},"object"==typeof exports&&"object"==typeof module?ls(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],ls):ls(CodeMirror),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){e.defineMode("shell",(function(){var t={};function i(e,i){for(var r=0;r<i.length;r++)t[i[r]]=e}var r=["true","false"],n=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],o=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];function l(e,i){if(e.eatSpace())return null;var r,n=e.sol(),o=e.next();if("\\"===o)return e.next(),null;if("'"===o||'"'===o||"`"===o)return i.tokens.unshift(s(o,"`"===o?"quote":"string")),u(e,i);if("#"===o)return n&&e.eat("!")?(e.skipToEnd(),"meta"):(e.skipToEnd(),"comment");if("$"===o)return i.tokens.unshift(c),u(e,i);if("+"===o||"="===o)return"operator";if("-"===o)return e.eat("-"),e.eatWhile(/\w/),"attribute";if("<"==o){if(e.match("<<"))return"operator";var l=e.match(/^<-?\s*['"]?([^'"]*)['"]?/);if(l)return i.tokens.unshift((r=l[1],function(e,t){return e.sol()&&e.string==r&&t.tokens.shift(),e.skipToEnd(),"string-2"})),"string-2"}if(/\d/.test(o)&&(e.eatWhile(/\d/),e.eol()||!/\w/.test(e.peek())))return"number";e.eatWhile(/[\w-]/);var a=e.current();return"="===e.peek()&&/\w+/.test(a)?"def":t.hasOwnProperty(a)?t[a]:null}function s(e,t){var i="("==e?")":"{"==e?"}":e;return function(r,n){for(var o,l=!1;null!=(o=r.next());){if(o===i&&!l){n.tokens.shift();break}if("$"===o&&!l&&"'"!==e&&r.peek()!=i){l=!0,r.backUp(1),n.tokens.unshift(c);break}if(!l&&e!==i&&o===e)return n.tokens.unshift(s(e,t)),u(r,n);if(!l&&/['"]/.test(o)&&!/['"]/.test(e)){n.tokens.unshift(a(o,"string")),r.backUp(1);break}l=!l&&"\\"===o}return t}}function a(e,t){return function(i,r){return r.tokens[0]=s(e,t),i.next(),u(i,r)}}e.registerHelper("hintWords","shell",r.concat(n,o)),i("atom",r),i("keyword",n),i("builtin",o);var c=function(e,t){t.tokens.length>1&&e.eat("$");var i=e.next();return/['"({]/.test(i)?(t.tokens[0]=s(i,"("==i?"quote":"{"==i?"def":"string"),u(e,t)):(/\d/.test(i)||e.eatWhile(/\w/),t.tokens.shift(),"def")};function u(e,t){return(t.tokens[0]||l)(e,t)}return{startState:function(){return{tokens:[]}},token:function(e,t){return u(e,t)},closeBrackets:"()[]{}''\"\"``",lineComment:"#",fold:"brace"}})),e.defineMIME("text/x-sh","shell"),e.defineMIME("application/x-sh","shell")})),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){e.defineMode("yaml",(function(){var e=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");return{token:function(t,i){var r=t.peek(),n=i.escaped;if(i.escaped=!1,"#"==r&&(0==t.pos||/\s/.test(t.string.charAt(t.pos-1))))return t.skipToEnd(),"comment";if(t.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(i.literal&&t.indentation()>i.keyCol)return t.skipToEnd(),"string";if(i.literal&&(i.literal=!1),t.sol()){if(i.keyCol=0,i.pair=!1,i.pairStart=!1,t.match("---"))return"def";if(t.match("..."))return"def";if(t.match(/\s*-\s+/))return"meta"}if(t.match(/^(\{|\}|\[|\])/))return"{"==r?i.inlinePairs++:"}"==r?i.inlinePairs--:"["==r?i.inlineList++:i.inlineList--,"meta";if(i.inlineList>0&&!n&&","==r)return t.next(),"meta";if(i.inlinePairs>0&&!n&&","==r)return i.keyCol=0,i.pair=!1,i.pairStart=!1,t.next(),"meta";if(i.pairStart){if(t.match(/^\s*(\||\>)\s*/))return i.literal=!0,"meta";if(t.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable-2";if(0==i.inlinePairs&&t.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(i.inlinePairs>0&&t.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(t.match(e))return"keyword"}return!i.pair&&t.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(i.pair=!0,i.keyCol=t.indentation(),"atom"):i.pair&&t.match(/^:\s*/)?(i.pairStart=!0,"meta"):(i.pairStart=!1,i.escaped="\\"==r,t.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},lineComment:"#",fold:"indent"}})),e.defineMIME("text/x-yaml","yaml"),e.defineMIME("text/yaml","yaml")}));let as=class extends o{constructor(){super(),this.config=Object(),this.mode="shell",this.theme="monokai",this.src="",this.readonly=!1,this.useLineWrapping=!1,this.required=!1,this.validationMessage="",this.validationMessageIcon="warning",this.config={tabSize:2,indentUnit:2,cursorScrollMargin:50,lineNumbers:!0,matchBrackets:!0,styleActiveLine:!0,viewportMargin:1/0,extraKeys:{}}}firstUpdated(){this._initEditor()}_initEditor(){this.editorEl.__initialized?(this.editor=this.editorEl.editor,Object.assign(this.editor.options,this.config),this.editor.setOption("lineWrapping",this.useLineWrapping),this.refresh()):setTimeout(this._initEditor.bind(this),100)}refresh(){globalThis.setTimeout((()=>this.editor.refresh()),100)}focus(){globalThis.setTimeout((()=>{this.editor.execCommand("goDocEnd"),this.editor.focus(),this.refresh()}),100)}getValue(){return this.editor.getValue()}setValue(e){this.editor.setValue(e),this.refresh()}_validateInput(){if(this.required){if(""===this.getValue())return this.showValidationMessage(),this.editorEl.style.border="2px solid red",!1;this.hideValidationMessage(),this.editorEl.style.border="none"}return!0}showValidationMessage(){this.validationMessageEl.style.display="flex"}hideValidationMessage(){this.validationMessageEl.style.display="none"}static get styles(){return[l,s,a,d,u,e`
        .CodeMirror {
          height: auto !important;
          font-size: 15px;
        }

        #validation-message {
          font-size: var(--validation-message-font-size, 12px);
          color: var(--validation-message-color, var(--general-warning-text));
          width: var(--validation-message-width, 100%);
          font-weight: var(--validation-message-font-weight, bold);
        }

        #validation-message mwc-icon {
          font-size: var(--validation-message-font-size, 12px);
          margin-right: 2px;
        }
      `]}render(){return c`
      <div>
        <wc-codemirror
          id="codemirror-editor"
          mode="${this.mode}"
          theme="monokai"
          ?readonly="${this.readonly}"
          @input="${()=>this._validateInput()}"
        >
          <link
            rel="stylesheet"
            href="node_modules/@vanillawc/wc-codemirror/theme/monokai.css"
          />
        </wc-codemirror>
        <div
          id="validation-message"
          class="horizontal layout center"
          style="display:none;"
        >
          <mwc-icon>${this.validationMessageIcon}</mwc-icon>
          <span>${this.validationMessage}</span>
        </div>
      </div>
    `}};t([i({type:Object})],as.prototype,"config",void 0),t([i({type:String})],as.prototype,"mode",void 0),t([i({type:String})],as.prototype,"theme",void 0),t([i({type:String})],as.prototype,"src",void 0),t([i({type:Boolean})],as.prototype,"readonly",void 0),t([i({type:Boolean})],as.prototype,"useLineWrapping",void 0),t([i({type:Boolean})],as.prototype,"required",void 0),t([i({type:String})],as.prototype,"validationMessage",void 0),t([i({type:String})],as.prototype,"validationMessageIcon",void 0),t([r("#validation-message")],as.prototype,"validationMessageEl",void 0),t([r("#codemirror-editor")],as.prototype,"editorEl",void 0),as=t([n("lablup-codemirror")],as);
