const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./pivot-setup.5.3.js","./main.5.3.js","./_commonjsHelpers.5.3.js","./choices.5.3.js","./csrf.5.3.js","./index.5.3.js","./favorites.5.3.js"])))=>i.map(i=>d[i]);
var o0=Object.defineProperty,l0=Object.defineProperties;var a0=Object.getOwnPropertyDescriptors;var Hc=Object.getOwnPropertySymbols;var h0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable;var Fc=n=>{throw TypeError(n)};var Zl=(n,e,t)=>e in n?o0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,zt=(n,e)=>{for(var t in e||(e={}))h0.call(e,t)&&Zl(n,t,e[t]);if(Hc)for(var t of Hc(e))c0.call(e,t)&&Zl(n,t,e[t]);return n},rr=(n,e)=>l0(n,a0(e));var ze=(n,e,t)=>Zl(n,typeof e!="symbol"?e+"":e,t),f0=(n,e,t)=>e.has(n)||Fc("Cannot "+t);var zc=(n,e,t)=>e.has(n)?Fc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t);var io=(n,e,t)=>(f0(n,e,"access private method"),t);var $c=(n,e,t)=>new Promise((i,r)=>{var s=h=>{try{l(t.next(h))}catch(f){r(f)}},o=h=>{try{l(t.throw(h))}catch(f){r(f)}},l=h=>h.done?i(h.value):Promise.resolve(h.value).then(s,o);l((t=t.apply(n,e)).next())});import{C as u0,T as d0,M as p0,_ as g0}from"./main.5.3.js";import{c as m0,g as y0}from"./_commonjsHelpers.5.3.js";import{S as Ph,g as Ih,C as b0}from"./choices.5.3.js";import{g as Nh,c as ea}from"./csrf.5.3.js";import{L as x0}from"./index.5.3.js";import{t as w0}from"./favorites.5.3.js";var ld={exports:{}};/*!
 * jQuery JavaScript Library v3.7.1
 * https://jquery.com/
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license
 * https://jquery.org/license
 *
 * Date: 2023-08-28T13:37Z
 */(function(n){(function(e,t){n.exports=e.document?t(e,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}})(typeof window!="undefined"?window:m0,function(e,t){var i=[],r=Object.getPrototypeOf,s=i.slice,o=i.flat?function(a){return i.flat.call(a)}:function(a){return i.concat.apply([],a)},l=i.push,h=i.indexOf,f={},u=f.toString,g=f.hasOwnProperty,y=g.toString,w=y.call(Object),v={},A=function(c){return typeof c=="function"&&typeof c.nodeType!="number"&&typeof c.item!="function"},O=function(c){return c!=null&&c===c.window},R=e.document,F={type:!0,src:!0,nonce:!0,noModule:!0};function W(a,c,d){d=d||R;var m,b,x=d.createElement("script");if(x.text=a,c)for(m in F)b=c[m]||c.getAttribute&&c.getAttribute(m),b&&x.setAttribute(m,b);d.head.appendChild(x).parentNode.removeChild(x)}function V(a){return a==null?a+"":typeof a=="object"||typeof a=="function"?f[u.call(a)]||"object":typeof a}var z="3.7.1",G=/HTML$/i,p=function(a,c){return new p.fn.init(a,c)};p.fn=p.prototype={jquery:z,constructor:p,length:0,toArray:function(){return s.call(this)},get:function(a){return a==null?s.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var c=p.merge(this.constructor(),a);return c.prevObject=this,c},each:function(a){return p.each(this,a)},map:function(a){return this.pushStack(p.map(this,function(c,d){return a.call(c,d,c)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(p.grep(this,function(a,c){return(c+1)%2}))},odd:function(){return this.pushStack(p.grep(this,function(a,c){return c%2}))},eq:function(a){var c=this.length,d=+a+(a<0?c:0);return this.pushStack(d>=0&&d<c?[this[d]]:[])},end:function(){return this.prevObject||this.constructor()},push:l,sort:i.sort,splice:i.splice},p.extend=p.fn.extend=function(){var a,c,d,m,b,x,k=arguments[0]||{},T=1,C=arguments.length,D=!1;for(typeof k=="boolean"&&(D=k,k=arguments[T]||{},T++),typeof k!="object"&&!A(k)&&(k={}),T===C&&(k=this,T--);T<C;T++)if((a=arguments[T])!=null)for(c in a)m=a[c],!(c==="__proto__"||k===m)&&(D&&m&&(p.isPlainObject(m)||(b=Array.isArray(m)))?(d=k[c],b&&!Array.isArray(d)?x=[]:!b&&!p.isPlainObject(d)?x={}:x=d,b=!1,k[c]=p.extend(D,x,m)):m!==void 0&&(k[c]=m));return k},p.extend({expando:"jQuery"+(z+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isPlainObject:function(a){var c,d;return!a||u.call(a)!=="[object Object]"?!1:(c=r(a),c?(d=g.call(c,"constructor")&&c.constructor,typeof d=="function"&&y.call(d)===w):!0)},isEmptyObject:function(a){var c;for(c in a)return!1;return!0},globalEval:function(a,c,d){W(a,{nonce:c&&c.nonce},d)},each:function(a,c){var d,m=0;if(he(a))for(d=a.length;m<d&&c.call(a[m],m,a[m])!==!1;m++);else for(m in a)if(c.call(a[m],m,a[m])===!1)break;return a},text:function(a){var c,d="",m=0,b=a.nodeType;if(!b)for(;c=a[m++];)d+=p.text(c);return b===1||b===11?a.textContent:b===9?a.documentElement.textContent:b===3||b===4?a.nodeValue:d},makeArray:function(a,c){var d=c||[];return a!=null&&(he(Object(a))?p.merge(d,typeof a=="string"?[a]:a):l.call(d,a)),d},inArray:function(a,c,d){return c==null?-1:h.call(c,a,d)},isXMLDoc:function(a){var c=a&&a.namespaceURI,d=a&&(a.ownerDocument||a).documentElement;return!G.test(c||d&&d.nodeName||"HTML")},merge:function(a,c){for(var d=+c.length,m=0,b=a.length;m<d;m++)a[b++]=c[m];return a.length=b,a},grep:function(a,c,d){for(var m,b=[],x=0,k=a.length,T=!d;x<k;x++)m=!c(a[x],x),m!==T&&b.push(a[x]);return b},map:function(a,c,d){var m,b,x=0,k=[];if(he(a))for(m=a.length;x<m;x++)b=c(a[x],x,d),b!=null&&k.push(b);else for(x in a)b=c(a[x],x,d),b!=null&&k.push(b);return o(k)},guid:1,support:v}),typeof Symbol=="function"&&(p.fn[Symbol.iterator]=i[Symbol.iterator]),p.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,c){f["[object "+c+"]"]=c.toLowerCase()});function he(a){var c=!!a&&"length"in a&&a.length,d=V(a);return A(a)||O(a)?!1:d==="array"||c===0||typeof c=="number"&&c>0&&c-1 in a}function Z(a,c){return a.nodeName&&a.nodeName.toLowerCase()===c.toLowerCase()}var ae=i.pop,pe=i.sort,fe=i.splice,ne="[\\x20\\t\\r\\n\\f]",xe=new RegExp("^"+ne+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ne+"+$","g");p.contains=function(a,c){var d=c&&c.parentNode;return a===d||!!(d&&d.nodeType===1&&(a.contains?a.contains(d):a.compareDocumentPosition&&a.compareDocumentPosition(d)&16))};var Be=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function ot(a,c){return c?a==="\0"?"�":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a}p.escapeSelector=function(a){return(a+"").replace(Be,ot)};var _e=R,Ze=l;(function(){var a,c,d,m,b,x=Ze,k,T,C,D,N,_=p.expando,P=0,q=0,ce=Js(),Ae=Js(),ye=Js(),gt=Js(),tt=function(S,E){return S===E&&(b=!0),0},Ai="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Ti="(?:\\\\[\\da-fA-F]{1,6}"+ne+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",Se="\\["+ne+"*("+Ti+")(?:"+ne+"*([*^$|!~]?=)"+ne+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Ti+"))|)"+ne+"*\\]",Ln=":("+Ti+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+Se+")*)|.*)\\)|)",Te=new RegExp(ne+"+","g"),Ke=new RegExp("^"+ne+"*,"+ne+"*"),Hr=new RegExp("^"+ne+"*([>+~]|"+ne+")"+ne+"*"),Ul=new RegExp(ne+"|>"),Oi=new RegExp(Ln),Fr=new RegExp("^"+Ti+"$"),Ei={ID:new RegExp("^#("+Ti+")"),CLASS:new RegExp("^\\.("+Ti+")"),TAG:new RegExp("^("+Ti+"|[*])"),ATTR:new RegExp("^"+Se),PSEUDO:new RegExp("^"+Ln),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ne+"*(even|odd|(([+-]|)(\\d*)n|)"+ne+"*(?:([+-]|)"+ne+"*(\\d+)|))"+ne+"*\\)|)","i"),bool:new RegExp("^(?:"+Ai+")$","i"),needsContext:new RegExp("^"+ne+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ne+"*((?:-\\d)?\\d*)"+ne+"*\\)|)(?=[^-]|$)","i")},an=/^(?:input|select|textarea|button)$/i,hn=/^h\d$/i,ni=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Ql=/[+~]/,Gi=new RegExp("\\\\[\\da-fA-F]{1,6}"+ne+"?|\\\\([^\\r\\n\\f])","g"),Ki=function(S,E){var L="0x"+S.slice(1)-65536;return E||(L<0?String.fromCharCode(L+65536):String.fromCharCode(L>>10|55296,L&1023|56320))},Zm=function(){cn()},e0=eo(function(S){return S.disabled===!0&&Z(S,"fieldset")},{dir:"parentNode",next:"legend"});function t0(){try{return k.activeElement}catch(S){}}try{x.apply(i=s.call(_e.childNodes),_e.childNodes),i[_e.childNodes.length].nodeType}catch(S){x={apply:function(E,L){Ze.apply(E,s.call(L))},call:function(E){Ze.apply(E,s.call(arguments,1))}}}function Pe(S,E,L,I){var B,U,K,se,X,we,le,ue=E&&E.ownerDocument,ke=E?E.nodeType:9;if(L=L||[],typeof S!="string"||!S||ke!==1&&ke!==9&&ke!==11)return L;if(!I&&(cn(E),E=E||k,C)){if(ke!==11&&(X=ni.exec(S)))if(B=X[1]){if(ke===9)if(K=E.getElementById(B)){if(K.id===B)return x.call(L,K),L}else return L;else if(ue&&(K=ue.getElementById(B))&&Pe.contains(E,K)&&K.id===B)return x.call(L,K),L}else{if(X[2])return x.apply(L,E.getElementsByTagName(S)),L;if((B=X[3])&&E.getElementsByClassName)return x.apply(L,E.getElementsByClassName(B)),L}if(!gt[S+" "]&&(!D||!D.test(S))){if(le=S,ue=E,ke===1&&(Ul.test(S)||Hr.test(S))){for(ue=Ql.test(S)&&Gl(E.parentNode)||E,(ue!=E||!v.scope)&&((se=E.getAttribute("id"))?se=p.escapeSelector(se):E.setAttribute("id",se=_)),we=zr(S),U=we.length;U--;)we[U]=(se?"#"+se:":scope")+" "+Zs(we[U]);le=we.join(",")}try{return x.apply(L,ue.querySelectorAll(le)),L}catch(oe){gt(S,!0)}finally{se===_&&E.removeAttribute("id")}}}return _c(S.replace(xe,"$1"),E,L,I)}function Js(){var S=[];function E(L,I){return S.push(L+" ")>c.cacheLength&&delete E[S.shift()],E[L+" "]=I}return E}function gi(S){return S[_]=!0,S}function ir(S){var E=k.createElement("fieldset");try{return!!S(E)}catch(L){return!1}finally{E.parentNode&&E.parentNode.removeChild(E),E=null}}function i0(S){return function(E){return Z(E,"input")&&E.type===S}}function n0(S){return function(E){return(Z(E,"input")||Z(E,"button"))&&E.type===S}}function Nc(S){return function(E){return"form"in E?E.parentNode&&E.disabled===!1?"label"in E?"label"in E.parentNode?E.parentNode.disabled===S:E.disabled===S:E.isDisabled===S||E.isDisabled!==!S&&e0(E)===S:E.disabled===S:"label"in E?E.disabled===S:!1}}function Pn(S){return gi(function(E){return E=+E,gi(function(L,I){for(var B,U=S([],L.length,E),K=U.length;K--;)L[B=U[K]]&&(L[B]=!(I[B]=L[B]))})})}function Gl(S){return S&&typeof S.getElementsByTagName!="undefined"&&S}function cn(S){var E,L=S?S.ownerDocument||S:_e;return L==k||L.nodeType!==9||!L.documentElement||(k=L,T=k.documentElement,C=!p.isXMLDoc(k),N=T.matches||T.webkitMatchesSelector||T.msMatchesSelector,T.msMatchesSelector&&_e!=k&&(E=k.defaultView)&&E.top!==E&&E.addEventListener("unload",Zm),v.getById=ir(function(I){return T.appendChild(I).id=p.expando,!k.getElementsByName||!k.getElementsByName(p.expando).length}),v.disconnectedMatch=ir(function(I){return N.call(I,"*")}),v.scope=ir(function(){return k.querySelectorAll(":scope")}),v.cssHas=ir(function(){try{return k.querySelector(":has(*,:jqfake)"),!1}catch(I){return!0}}),v.getById?(c.filter.ID=function(I){var B=I.replace(Gi,Ki);return function(U){return U.getAttribute("id")===B}},c.find.ID=function(I,B){if(typeof B.getElementById!="undefined"&&C){var U=B.getElementById(I);return U?[U]:[]}}):(c.filter.ID=function(I){var B=I.replace(Gi,Ki);return function(U){var K=typeof U.getAttributeNode!="undefined"&&U.getAttributeNode("id");return K&&K.value===B}},c.find.ID=function(I,B){if(typeof B.getElementById!="undefined"&&C){var U,K,se,X=B.getElementById(I);if(X){if(U=X.getAttributeNode("id"),U&&U.value===I)return[X];for(se=B.getElementsByName(I),K=0;X=se[K++];)if(U=X.getAttributeNode("id"),U&&U.value===I)return[X]}return[]}}),c.find.TAG=function(I,B){return typeof B.getElementsByTagName!="undefined"?B.getElementsByTagName(I):B.querySelectorAll(I)},c.find.CLASS=function(I,B){if(typeof B.getElementsByClassName!="undefined"&&C)return B.getElementsByClassName(I)},D=[],ir(function(I){var B;T.appendChild(I).innerHTML="<a id='"+_+"' href='' disabled='disabled'></a><select id='"+_+"-\r\\' disabled='disabled'><option selected=''></option></select>",I.querySelectorAll("[selected]").length||D.push("\\["+ne+"*(?:value|"+Ai+")"),I.querySelectorAll("[id~="+_+"-]").length||D.push("~="),I.querySelectorAll("a#"+_+"+*").length||D.push(".#.+[+~]"),I.querySelectorAll(":checked").length||D.push(":checked"),B=k.createElement("input"),B.setAttribute("type","hidden"),I.appendChild(B).setAttribute("name","D"),T.appendChild(I).disabled=!0,I.querySelectorAll(":disabled").length!==2&&D.push(":enabled",":disabled"),B=k.createElement("input"),B.setAttribute("name",""),I.appendChild(B),I.querySelectorAll("[name='']").length||D.push("\\["+ne+"*name"+ne+"*="+ne+`*(?:''|"")`)}),v.cssHas||D.push(":has"),D=D.length&&new RegExp(D.join("|")),tt=function(I,B){if(I===B)return b=!0,0;var U=!I.compareDocumentPosition-!B.compareDocumentPosition;return U||(U=(I.ownerDocument||I)==(B.ownerDocument||B)?I.compareDocumentPosition(B):1,U&1||!v.sortDetached&&B.compareDocumentPosition(I)===U?I===k||I.ownerDocument==_e&&Pe.contains(_e,I)?-1:B===k||B.ownerDocument==_e&&Pe.contains(_e,B)?1:m?h.call(m,I)-h.call(m,B):0:U&4?-1:1)}),k}Pe.matches=function(S,E){return Pe(S,null,null,E)},Pe.matchesSelector=function(S,E){if(cn(S),C&&!gt[E+" "]&&(!D||!D.test(E)))try{var L=N.call(S,E);if(L||v.disconnectedMatch||S.document&&S.document.nodeType!==11)return L}catch(I){gt(E,!0)}return Pe(E,k,null,[S]).length>0},Pe.contains=function(S,E){return(S.ownerDocument||S)!=k&&cn(S),p.contains(S,E)},Pe.attr=function(S,E){(S.ownerDocument||S)!=k&&cn(S);var L=c.attrHandle[E.toLowerCase()],I=L&&g.call(c.attrHandle,E.toLowerCase())?L(S,E,!C):void 0;return I!==void 0?I:S.getAttribute(E)},Pe.error=function(S){throw new Error("Syntax error, unrecognized expression: "+S)},p.uniqueSort=function(S){var E,L=[],I=0,B=0;if(b=!v.sortStable,m=!v.sortStable&&s.call(S,0),pe.call(S,tt),b){for(;E=S[B++];)E===S[B]&&(I=L.push(B));for(;I--;)fe.call(S,L[I],1)}return m=null,S},p.fn.uniqueSort=function(){return this.pushStack(p.uniqueSort(s.apply(this)))},c=p.expr={cacheLength:50,createPseudo:gi,match:Ei,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(S){return S[1]=S[1].replace(Gi,Ki),S[3]=(S[3]||S[4]||S[5]||"").replace(Gi,Ki),S[2]==="~="&&(S[3]=" "+S[3]+" "),S.slice(0,4)},CHILD:function(S){return S[1]=S[1].toLowerCase(),S[1].slice(0,3)==="nth"?(S[3]||Pe.error(S[0]),S[4]=+(S[4]?S[5]+(S[6]||1):2*(S[3]==="even"||S[3]==="odd")),S[5]=+(S[7]+S[8]||S[3]==="odd")):S[3]&&Pe.error(S[0]),S},PSEUDO:function(S){var E,L=!S[6]&&S[2];return Ei.CHILD.test(S[0])?null:(S[3]?S[2]=S[4]||S[5]||"":L&&Oi.test(L)&&(E=zr(L,!0))&&(E=L.indexOf(")",L.length-E)-L.length)&&(S[0]=S[0].slice(0,E),S[2]=L.slice(0,E)),S.slice(0,3))}},filter:{TAG:function(S){var E=S.replace(Gi,Ki).toLowerCase();return S==="*"?function(){return!0}:function(L){return Z(L,E)}},CLASS:function(S){var E=ce[S+" "];return E||(E=new RegExp("(^|"+ne+")"+S+"("+ne+"|$)"))&&ce(S,function(L){return E.test(typeof L.className=="string"&&L.className||typeof L.getAttribute!="undefined"&&L.getAttribute("class")||"")})},ATTR:function(S,E,L){return function(I){var B=Pe.attr(I,S);return B==null?E==="!=":E?(B+="",E==="="?B===L:E==="!="?B!==L:E==="^="?L&&B.indexOf(L)===0:E==="*="?L&&B.indexOf(L)>-1:E==="$="?L&&B.slice(-L.length)===L:E==="~="?(" "+B.replace(Te," ")+" ").indexOf(L)>-1:E==="|="?B===L||B.slice(0,L.length+1)===L+"-":!1):!0}},CHILD:function(S,E,L,I,B){var U=S.slice(0,3)!=="nth",K=S.slice(-4)!=="last",se=E==="of-type";return I===1&&B===0?function(X){return!!X.parentNode}:function(X,we,le){var ue,ke,oe,Fe,Ft,vt=U!==K?"nextSibling":"previousSibling",ri=X.parentNode,Mi=se&&X.nodeName.toLowerCase(),nr=!le&&!se,Et=!1;if(ri){if(U){for(;vt;){for(oe=X;oe=oe[vt];)if(se?Z(oe,Mi):oe.nodeType===1)return!1;Ft=vt=S==="only"&&!Ft&&"nextSibling"}return!0}if(Ft=[K?ri.firstChild:ri.lastChild],K&&nr){for(ke=ri[_]||(ri[_]={}),ue=ke[S]||[],Fe=ue[0]===P&&ue[1],Et=Fe&&ue[2],oe=Fe&&ri.childNodes[Fe];oe=++Fe&&oe&&oe[vt]||(Et=Fe=0)||Ft.pop();)if(oe.nodeType===1&&++Et&&oe===X){ke[S]=[P,Fe,Et];break}}else if(nr&&(ke=X[_]||(X[_]={}),ue=ke[S]||[],Fe=ue[0]===P&&ue[1],Et=Fe),Et===!1)for(;(oe=++Fe&&oe&&oe[vt]||(Et=Fe=0)||Ft.pop())&&!((se?Z(oe,Mi):oe.nodeType===1)&&++Et&&(nr&&(ke=oe[_]||(oe[_]={}),ke[S]=[P,Et]),oe===X)););return Et-=B,Et===I||Et%I===0&&Et/I>=0}}},PSEUDO:function(S,E){var L,I=c.pseudos[S]||c.setFilters[S.toLowerCase()]||Pe.error("unsupported pseudo: "+S);return I[_]?I(E):I.length>1?(L=[S,S,"",E],c.setFilters.hasOwnProperty(S.toLowerCase())?gi(function(B,U){for(var K,se=I(B,E),X=se.length;X--;)K=h.call(B,se[X]),B[K]=!(U[K]=se[X])}):function(B){return I(B,0,L)}):I}},pseudos:{not:gi(function(S){var E=[],L=[],I=Jl(S.replace(xe,"$1"));return I[_]?gi(function(B,U,K,se){for(var X,we=I(B,null,se,[]),le=B.length;le--;)(X=we[le])&&(B[le]=!(U[le]=X))}):function(B,U,K){return E[0]=B,I(E,null,K,L),E[0]=null,!L.pop()}}),has:gi(function(S){return function(E){return Pe(S,E).length>0}}),contains:gi(function(S){return S=S.replace(Gi,Ki),function(E){return(E.textContent||p.text(E)).indexOf(S)>-1}}),lang:gi(function(S){return Fr.test(S||"")||Pe.error("unsupported lang: "+S),S=S.replace(Gi,Ki).toLowerCase(),function(E){var L;do if(L=C?E.lang:E.getAttribute("xml:lang")||E.getAttribute("lang"))return L=L.toLowerCase(),L===S||L.indexOf(S+"-")===0;while((E=E.parentNode)&&E.nodeType===1);return!1}}),target:function(S){var E=e.location&&e.location.hash;return E&&E.slice(1)===S.id},root:function(S){return S===T},focus:function(S){return S===t0()&&k.hasFocus()&&!!(S.type||S.href||~S.tabIndex)},enabled:Nc(!1),disabled:Nc(!0),checked:function(S){return Z(S,"input")&&!!S.checked||Z(S,"option")&&!!S.selected},selected:function(S){return S.parentNode&&S.parentNode.selectedIndex,S.selected===!0},empty:function(S){for(S=S.firstChild;S;S=S.nextSibling)if(S.nodeType<6)return!1;return!0},parent:function(S){return!c.pseudos.empty(S)},header:function(S){return hn.test(S.nodeName)},input:function(S){return an.test(S.nodeName)},button:function(S){return Z(S,"input")&&S.type==="button"||Z(S,"button")},text:function(S){var E;return Z(S,"input")&&S.type==="text"&&((E=S.getAttribute("type"))==null||E.toLowerCase()==="text")},first:Pn(function(){return[0]}),last:Pn(function(S,E){return[E-1]}),eq:Pn(function(S,E,L){return[L<0?L+E:L]}),even:Pn(function(S,E){for(var L=0;L<E;L+=2)S.push(L);return S}),odd:Pn(function(S,E){for(var L=1;L<E;L+=2)S.push(L);return S}),lt:Pn(function(S,E,L){var I;for(L<0?I=L+E:L>E?I=E:I=L;--I>=0;)S.push(I);return S}),gt:Pn(function(S,E,L){for(var I=L<0?L+E:L;++I<E;)S.push(I);return S})}},c.pseudos.nth=c.pseudos.eq;for(a in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})c.pseudos[a]=i0(a);for(a in{submit:!0,reset:!0})c.pseudos[a]=n0(a);function Bc(){}Bc.prototype=c.filters=c.pseudos,c.setFilters=new Bc;function zr(S,E){var L,I,B,U,K,se,X,we=Ae[S+" "];if(we)return E?0:we.slice(0);for(K=S,se=[],X=c.preFilter;K;){(!L||(I=Ke.exec(K)))&&(I&&(K=K.slice(I[0].length)||K),se.push(B=[])),L=!1,(I=Hr.exec(K))&&(L=I.shift(),B.push({value:L,type:I[0].replace(xe," ")}),K=K.slice(L.length));for(U in c.filter)(I=Ei[U].exec(K))&&(!X[U]||(I=X[U](I)))&&(L=I.shift(),B.push({value:L,type:U,matches:I}),K=K.slice(L.length));if(!L)break}return E?K.length:K?Pe.error(S):Ae(S,se).slice(0)}function Zs(S){for(var E=0,L=S.length,I="";E<L;E++)I+=S[E].value;return I}function eo(S,E,L){var I=E.dir,B=E.next,U=B||I,K=L&&U==="parentNode",se=q++;return E.first?function(X,we,le){for(;X=X[I];)if(X.nodeType===1||K)return S(X,we,le);return!1}:function(X,we,le){var ue,ke,oe=[P,se];if(le){for(;X=X[I];)if((X.nodeType===1||K)&&S(X,we,le))return!0}else for(;X=X[I];)if(X.nodeType===1||K)if(ke=X[_]||(X[_]={}),B&&Z(X,B))X=X[I]||X;else{if((ue=ke[U])&&ue[0]===P&&ue[1]===se)return oe[2]=ue[2];if(ke[U]=oe,oe[2]=S(X,we,le))return!0}return!1}}function Kl(S){return S.length>1?function(E,L,I){for(var B=S.length;B--;)if(!S[B](E,L,I))return!1;return!0}:S[0]}function r0(S,E,L){for(var I=0,B=E.length;I<B;I++)Pe(S,E[I],L);return L}function to(S,E,L,I,B){for(var U,K=[],se=0,X=S.length,we=E!=null;se<X;se++)(U=S[se])&&(!L||L(U,I,B))&&(K.push(U),we&&E.push(se));return K}function Xl(S,E,L,I,B,U){return I&&!I[_]&&(I=Xl(I)),B&&!B[_]&&(B=Xl(B,U)),gi(function(K,se,X,we){var le,ue,ke,oe,Fe=[],Ft=[],vt=se.length,ri=K||r0(E||"*",X.nodeType?[X]:X,[]),Mi=S&&(K||!E)?to(ri,Fe,S,X,we):ri;if(L?(oe=B||(K?S:vt||I)?[]:se,L(Mi,oe,X,we)):oe=Mi,I)for(le=to(oe,Ft),I(le,[],X,we),ue=le.length;ue--;)(ke=le[ue])&&(oe[Ft[ue]]=!(Mi[Ft[ue]]=ke));if(K){if(B||S){if(B){for(le=[],ue=oe.length;ue--;)(ke=oe[ue])&&le.push(Mi[ue]=ke);B(null,oe=[],le,we)}for(ue=oe.length;ue--;)(ke=oe[ue])&&(le=B?h.call(K,ke):Fe[ue])>-1&&(K[le]=!(se[le]=ke))}}else oe=to(oe===se?oe.splice(vt,oe.length):oe),B?B(null,se,oe,we):x.apply(se,oe)})}function Yl(S){for(var E,L,I,B=S.length,U=c.relative[S[0].type],K=U||c.relative[" "],se=U?1:0,X=eo(function(ue){return ue===E},K,!0),we=eo(function(ue){return h.call(E,ue)>-1},K,!0),le=[function(ue,ke,oe){var Fe=!U&&(oe||ke!=d)||((E=ke).nodeType?X(ue,ke,oe):we(ue,ke,oe));return E=null,Fe}];se<B;se++)if(L=c.relative[S[se].type])le=[eo(Kl(le),L)];else{if(L=c.filter[S[se].type].apply(null,S[se].matches),L[_]){for(I=++se;I<B&&!c.relative[S[I].type];I++);return Xl(se>1&&Kl(le),se>1&&Zs(S.slice(0,se-1).concat({value:S[se-2].type===" "?"*":""})).replace(xe,"$1"),L,se<I&&Yl(S.slice(se,I)),I<B&&Yl(S=S.slice(I)),I<B&&Zs(S))}le.push(L)}return Kl(le)}function s0(S,E){var L=E.length>0,I=S.length>0,B=function(U,K,se,X,we){var le,ue,ke,oe=0,Fe="0",Ft=U&&[],vt=[],ri=d,Mi=U||I&&c.find.TAG("*",we),nr=P+=ri==null?1:Math.random()||.1,Et=Mi.length;for(we&&(d=K==k||K||we);Fe!==Et&&(le=Mi[Fe])!=null;Fe++){if(I&&le){for(ue=0,!K&&le.ownerDocument!=k&&(cn(le),se=!C);ke=S[ue++];)if(ke(le,K||k,se)){x.call(X,le);break}we&&(P=nr)}L&&((le=!ke&&le)&&oe--,U&&Ft.push(le))}if(oe+=Fe,L&&Fe!==oe){for(ue=0;ke=E[ue++];)ke(Ft,vt,K,se);if(U){if(oe>0)for(;Fe--;)Ft[Fe]||vt[Fe]||(vt[Fe]=ae.call(X));vt=to(vt)}x.apply(X,vt),we&&!U&&vt.length>0&&oe+E.length>1&&p.uniqueSort(X)}return we&&(P=nr,d=ri),Ft};return L?gi(B):B}function Jl(S,E){var L,I=[],B=[],U=ye[S+" "];if(!U){for(E||(E=zr(S)),L=E.length;L--;)U=Yl(E[L]),U[_]?I.push(U):B.push(U);U=ye(S,s0(B,I)),U.selector=S}return U}function _c(S,E,L,I){var B,U,K,se,X,we=typeof S=="function"&&S,le=!I&&zr(S=we.selector||S);if(L=L||[],le.length===1){if(U=le[0]=le[0].slice(0),U.length>2&&(K=U[0]).type==="ID"&&E.nodeType===9&&C&&c.relative[U[1].type]){if(E=(c.find.ID(K.matches[0].replace(Gi,Ki),E)||[])[0],E)we&&(E=E.parentNode);else return L;S=S.slice(U.shift().value.length)}for(B=Ei.needsContext.test(S)?0:U.length;B--&&(K=U[B],!c.relative[se=K.type]);)if((X=c.find[se])&&(I=X(K.matches[0].replace(Gi,Ki),Ql.test(U[0].type)&&Gl(E.parentNode)||E))){if(U.splice(B,1),S=I.length&&Zs(U),!S)return x.apply(L,I),L;break}}return(we||Jl(S,le))(I,E,!C,L,!E||Ql.test(S)&&Gl(E.parentNode)||E),L}v.sortStable=_.split("").sort(tt).join("")===_,cn(),v.sortDetached=ir(function(S){return S.compareDocumentPosition(k.createElement("fieldset"))&1}),p.find=Pe,p.expr[":"]=p.expr.pseudos,p.unique=p.uniqueSort,Pe.compile=Jl,Pe.select=_c,Pe.setDocument=cn,Pe.tokenize=zr,Pe.escape=p.escapeSelector,Pe.getText=p.text,Pe.isXML=p.isXMLDoc,Pe.selectors=p.expr,Pe.support=p.support,Pe.uniqueSort=p.uniqueSort})();var Qe=function(a,c,d){for(var m=[],b=d!==void 0;(a=a[c])&&a.nodeType!==9;)if(a.nodeType===1){if(b&&p(a).is(d))break;m.push(a)}return m},me=function(a,c){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==c&&d.push(a);return d},lt=p.expr.match.needsContext,Oe=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function It(a,c,d){return A(c)?p.grep(a,function(m,b){return!!c.call(m,b,m)!==d}):c.nodeType?p.grep(a,function(m){return m===c!==d}):typeof c!="string"?p.grep(a,function(m){return h.call(c,m)>-1!==d}):p.filter(c,a,d)}p.filter=function(a,c,d){var m=c[0];return d&&(a=":not("+a+")"),c.length===1&&m.nodeType===1?p.find.matchesSelector(m,a)?[m]:[]:p.find.matches(a,p.grep(c,function(b){return b.nodeType===1}))},p.fn.extend({find:function(a){var c,d,m=this.length,b=this;if(typeof a!="string")return this.pushStack(p(a).filter(function(){for(c=0;c<m;c++)if(p.contains(b[c],this))return!0}));for(d=this.pushStack([]),c=0;c<m;c++)p.find(a,b[c],d);return m>1?p.uniqueSort(d):d},filter:function(a){return this.pushStack(It(this,a||[],!1))},not:function(a){return this.pushStack(It(this,a||[],!0))},is:function(a){return!!It(this,typeof a=="string"&&lt.test(a)?p(a):a||[],!1).length}});var Ee,Zt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,nn=p.fn.init=function(a,c,d){var m,b;if(!a)return this;if(d=d||Ee,typeof a=="string")if(a[0]==="<"&&a[a.length-1]===">"&&a.length>=3?m=[null,a,null]:m=Zt.exec(a),m&&(m[1]||!c))if(m[1]){if(c=c instanceof p?c[0]:c,p.merge(this,p.parseHTML(m[1],c&&c.nodeType?c.ownerDocument||c:R,!0)),Oe.test(m[1])&&p.isPlainObject(c))for(m in c)A(this[m])?this[m](c[m]):this.attr(m,c[m]);return this}else return b=R.getElementById(m[2]),b&&(this[0]=b,this.length=1),this;else return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a);else{if(a.nodeType)return this[0]=a,this.length=1,this;if(A(a))return d.ready!==void 0?d.ready(a):a(p)}return p.makeArray(a,this)};nn.prototype=p.fn,Ee=p(R);var Is=/^(?:parents|prev(?:Until|All))/,Ar={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({has:function(a){var c=p(a,this),d=c.length;return this.filter(function(){for(var m=0;m<d;m++)if(p.contains(this,c[m]))return!0})},closest:function(a,c){var d,m=0,b=this.length,x=[],k=typeof a!="string"&&p(a);if(!lt.test(a)){for(;m<b;m++)for(d=this[m];d&&d!==c;d=d.parentNode)if(d.nodeType<11&&(k?k.index(d)>-1:d.nodeType===1&&p.find.matchesSelector(d,a))){x.push(d);break}}return this.pushStack(x.length>1?p.uniqueSort(x):x)},index:function(a){return a?typeof a=="string"?h.call(p(a),this[0]):h.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,c){return this.pushStack(p.uniqueSort(p.merge(this.get(),p(a,c))))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}});function Tr(a,c){for(;(a=a[c])&&a.nodeType!==1;);return a}p.each({parent:function(a){var c=a.parentNode;return c&&c.nodeType!==11?c:null},parents:function(a){return Qe(a,"parentNode")},parentsUntil:function(a,c,d){return Qe(a,"parentNode",d)},next:function(a){return Tr(a,"nextSibling")},prev:function(a){return Tr(a,"previousSibling")},nextAll:function(a){return Qe(a,"nextSibling")},prevAll:function(a){return Qe(a,"previousSibling")},nextUntil:function(a,c,d){return Qe(a,"nextSibling",d)},prevUntil:function(a,c,d){return Qe(a,"previousSibling",d)},siblings:function(a){return me((a.parentNode||{}).firstChild,a)},children:function(a){return me(a.firstChild)},contents:function(a){return a.contentDocument!=null&&r(a.contentDocument)?a.contentDocument:(Z(a,"template")&&(a=a.content||a),p.merge([],a.childNodes))}},function(a,c){p.fn[a]=function(d,m){var b=p.map(this,c,d);return a.slice(-5)!=="Until"&&(m=d),m&&typeof m=="string"&&(b=p.filter(m,b)),this.length>1&&(Ar[a]||p.uniqueSort(b),Is.test(a)&&b.reverse()),this.pushStack(b)}});var Vt=/[^\x20\t\r\n\f]+/g;function rn(a){var c={};return p.each(a.match(Vt)||[],function(d,m){c[m]=!0}),c}p.Callbacks=function(a){a=typeof a=="string"?rn(a):p.extend({},a);var c,d,m,b,x=[],k=[],T=-1,C=function(){for(b=b||a.once,m=c=!0;k.length;T=-1)for(d=k.shift();++T<x.length;)x[T].apply(d[0],d[1])===!1&&a.stopOnFalse&&(T=x.length,d=!1);a.memory||(d=!1),c=!1,b&&(d?x=[]:x="")},D={add:function(){return x&&(d&&!c&&(T=x.length-1,k.push(d)),function N(_){p.each(_,function(P,q){A(q)?(!a.unique||!D.has(q))&&x.push(q):q&&q.length&&V(q)!=="string"&&N(q)})}(arguments),d&&!c&&C()),this},remove:function(){return p.each(arguments,function(N,_){for(var P;(P=p.inArray(_,x,P))>-1;)x.splice(P,1),P<=T&&T--}),this},has:function(N){return N?p.inArray(N,x)>-1:x.length>0},empty:function(){return x&&(x=[]),this},disable:function(){return b=k=[],x=d="",this},disabled:function(){return!x},lock:function(){return b=k=[],!d&&!c&&(x=d=""),this},locked:function(){return!!b},fireWith:function(N,_){return b||(_=_||[],_=[N,_.slice?_.slice():_],k.push(_),c||C()),this},fire:function(){return D.fireWith(this,arguments),this},fired:function(){return!!m}};return D};function ki(a){return a}function ei(a){throw a}function Yn(a,c,d,m){var b;try{a&&A(b=a.promise)?b.call(a).done(c).fail(d):a&&A(b=a.then)?b.call(a,c,d):c.apply(void 0,[a].slice(m))}catch(x){d.apply(void 0,[x])}}p.extend({Deferred:function(a){var c=[["notify","progress",p.Callbacks("memory"),p.Callbacks("memory"),2],["resolve","done",p.Callbacks("once memory"),p.Callbacks("once memory"),0,"resolved"],["reject","fail",p.Callbacks("once memory"),p.Callbacks("once memory"),1,"rejected"]],d="pending",m={state:function(){return d},always:function(){return b.done(arguments).fail(arguments),this},catch:function(x){return m.then(null,x)},pipe:function(){var x=arguments;return p.Deferred(function(k){p.each(c,function(T,C){var D=A(x[C[4]])&&x[C[4]];b[C[1]](function(){var N=D&&D.apply(this,arguments);N&&A(N.promise)?N.promise().progress(k.notify).done(k.resolve).fail(k.reject):k[C[0]+"With"](this,D?[N]:arguments)})}),x=null}).promise()},then:function(x,k,T){var C=0;function D(N,_,P,q){return function(){var ce=this,Ae=arguments,ye=function(){var tt,Ai;if(!(N<C)){if(tt=P.apply(ce,Ae),tt===_.promise())throw new TypeError("Thenable self-resolution");Ai=tt&&(typeof tt=="object"||typeof tt=="function")&&tt.then,A(Ai)?q?Ai.call(tt,D(C,_,ki,q),D(C,_,ei,q)):(C++,Ai.call(tt,D(C,_,ki,q),D(C,_,ei,q),D(C,_,ki,_.notifyWith))):(P!==ki&&(ce=void 0,Ae=[tt]),(q||_.resolveWith)(ce,Ae))}},gt=q?ye:function(){try{ye()}catch(tt){p.Deferred.exceptionHook&&p.Deferred.exceptionHook(tt,gt.error),N+1>=C&&(P!==ei&&(ce=void 0,Ae=[tt]),_.rejectWith(ce,Ae))}};N?gt():(p.Deferred.getErrorHook?gt.error=p.Deferred.getErrorHook():p.Deferred.getStackHook&&(gt.error=p.Deferred.getStackHook()),e.setTimeout(gt))}}return p.Deferred(function(N){c[0][3].add(D(0,N,A(T)?T:ki,N.notifyWith)),c[1][3].add(D(0,N,A(x)?x:ki)),c[2][3].add(D(0,N,A(k)?k:ei))}).promise()},promise:function(x){return x!=null?p.extend(x,m):m}},b={};return p.each(c,function(x,k){var T=k[2],C=k[5];m[k[1]]=T.add,C&&T.add(function(){d=C},c[3-x][2].disable,c[3-x][3].disable,c[0][2].lock,c[0][3].lock),T.add(k[3].fire),b[k[0]]=function(){return b[k[0]+"With"](this===b?void 0:this,arguments),this},b[k[0]+"With"]=T.fireWith}),m.promise(b),a&&a.call(b,b),b},when:function(a){var c=arguments.length,d=c,m=Array(d),b=s.call(arguments),x=p.Deferred(),k=function(T){return function(C){m[T]=this,b[T]=arguments.length>1?s.call(arguments):C,--c||x.resolveWith(m,b)}};if(c<=1&&(Yn(a,x.done(k(d)).resolve,x.reject,!c),x.state()==="pending"||A(b[d]&&b[d].then)))return x.then();for(;d--;)Yn(b[d],k(d),x.reject);return x.promise()}});var Or=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;p.Deferred.exceptionHook=function(a,c){e.console&&e.console.warn&&a&&Or.test(a.name)&&e.console.warn("jQuery.Deferred exception: "+a.message,a.stack,c)},p.readyException=function(a){e.setTimeout(function(){throw a})};var vi=p.Deferred();p.fn.ready=function(a){return vi.then(a).catch(function(c){p.readyException(c)}),this},p.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--p.readyWait:p.isReady)||(p.isReady=!0,!(a!==!0&&--p.readyWait>0)&&vi.resolveWith(R,[p]))}}),p.ready.then=vi.then;function ji(){R.removeEventListener("DOMContentLoaded",ji),e.removeEventListener("load",ji),p.ready()}R.readyState==="complete"||R.readyState!=="loading"&&!R.documentElement.doScroll?e.setTimeout(p.ready):(R.addEventListener("DOMContentLoaded",ji),e.addEventListener("load",ji));var Nt=function(a,c,d,m,b,x,k){var T=0,C=a.length,D=d==null;if(V(d)==="object"){b=!0;for(T in d)Nt(a,c,T,d[T],!0,x,k)}else if(m!==void 0&&(b=!0,A(m)||(k=!0),D&&(k?(c.call(a,m),c=null):(D=c,c=function(N,_,P){return D.call(p(N),P)})),c))for(;T<C;T++)c(a[T],d,k?m:m.call(a[T],T,c(a[T],d)));return b?a:D?c.call(a):C?c(a[0],d):x},Ns=/^-ms-/,Bs=/-([a-z])/g;function Nl(a,c){return c.toUpperCase()}function Bt(a){return a.replace(Ns,"ms-").replace(Bs,Nl)}var ui=function(a){return a.nodeType===1||a.nodeType===9||!+a.nodeType};function ti(){this.expando=p.expando+ti.uid++}ti.uid=1,ti.prototype={cache:function(a){var c=a[this.expando];return c||(c={},ui(a)&&(a.nodeType?a[this.expando]=c:Object.defineProperty(a,this.expando,{value:c,configurable:!0}))),c},set:function(a,c,d){var m,b=this.cache(a);if(typeof c=="string")b[Bt(c)]=d;else for(m in c)b[Bt(m)]=c[m];return b},get:function(a,c){return c===void 0?this.cache(a):a[this.expando]&&a[this.expando][Bt(c)]},access:function(a,c,d){return c===void 0||c&&typeof c=="string"&&d===void 0?this.get(a,c):(this.set(a,c,d),d!==void 0?d:c)},remove:function(a,c){var d,m=a[this.expando];if(m!==void 0){if(c!==void 0)for(Array.isArray(c)?c=c.map(Bt):(c=Bt(c),c=c in m?[c]:c.match(Vt)||[]),d=c.length;d--;)delete m[c[d]];(c===void 0||p.isEmptyObject(m))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var c=a[this.expando];return c!==void 0&&!p.isEmptyObject(c)}};var J=new ti,ft=new ti,_s=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Hs=/[A-Z]/g;function Er(a){return a==="true"?!0:a==="false"?!1:a==="null"?null:a===+a+""?+a:_s.test(a)?JSON.parse(a):a}function Mr(a,c,d){var m;if(d===void 0&&a.nodeType===1)if(m="data-"+c.replace(Hs,"-$&").toLowerCase(),d=a.getAttribute(m),typeof d=="string"){try{d=Er(d)}catch(b){}ft.set(a,c,d)}else d=void 0;return d}p.extend({hasData:function(a){return ft.hasData(a)||J.hasData(a)},data:function(a,c,d){return ft.access(a,c,d)},removeData:function(a,c){ft.remove(a,c)},_data:function(a,c,d){return J.access(a,c,d)},_removeData:function(a,c){J.remove(a,c)}}),p.fn.extend({data:function(a,c){var d,m,b,x=this[0],k=x&&x.attributes;if(a===void 0){if(this.length&&(b=ft.get(x),x.nodeType===1&&!J.get(x,"hasDataAttrs"))){for(d=k.length;d--;)k[d]&&(m=k[d].name,m.indexOf("data-")===0&&(m=Bt(m.slice(5)),Mr(x,m,b[m])));J.set(x,"hasDataAttrs",!0)}return b}return typeof a=="object"?this.each(function(){ft.set(this,a)}):Nt(this,function(T){var C;if(x&&T===void 0)return C=ft.get(x,a),C!==void 0||(C=Mr(x,a),C!==void 0)?C:void 0;this.each(function(){ft.set(this,a,T)})},null,c,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){ft.remove(this,a)})}}),p.extend({queue:function(a,c,d){var m;if(a)return c=(c||"fx")+"queue",m=J.get(a,c),d&&(!m||Array.isArray(d)?m=J.access(a,c,p.makeArray(d)):m.push(d)),m||[]},dequeue:function(a,c){c=c||"fx";var d=p.queue(a,c),m=d.length,b=d.shift(),x=p._queueHooks(a,c),k=function(){p.dequeue(a,c)};b==="inprogress"&&(b=d.shift(),m--),b&&(c==="fx"&&d.unshift("inprogress"),delete x.stop,b.call(a,k,x)),!m&&x&&x.empty.fire()},_queueHooks:function(a,c){var d=c+"queueHooks";return J.get(a,d)||J.access(a,d,{empty:p.Callbacks("once memory").add(function(){J.remove(a,[c+"queue",d])})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length<d?p.queue(this[0],a):c===void 0?this:this.each(function(){var m=p.queue(this,a,c);p._queueHooks(this,a),a==="fx"&&m[0]!=="inprogress"&&p.dequeue(this,a)})},dequeue:function(a){return this.each(function(){p.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,m=1,b=p.Deferred(),x=this,k=this.length,T=function(){--m||b.resolveWith(x,[x])};for(typeof a!="string"&&(c=a,a=void 0),a=a||"fx";k--;)d=J.get(x[k],a+"queueHooks"),d&&d.empty&&(m++,d.empty.add(T));return T(),b.promise(c)}});var Mn=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Si=new RegExp("^(?:([+-])=|)("+Mn+")([a-z%]*)$","i"),et=["Top","Right","Bottom","Left"],_t=R.documentElement,Ci=function(a){return p.contains(a.ownerDocument,a)},Dr={composed:!0};_t.getRootNode&&(Ci=function(a){return p.contains(a.ownerDocument,a)||a.getRootNode(Dr)===a.ownerDocument});var Jn=function(a,c){return a=c||a,a.style.display==="none"||a.style.display===""&&Ci(a)&&p.css(a,"display")==="none"};function sn(a,c,d,m){var b,x,k=20,T=m?function(){return m.cur()}:function(){return p.css(a,c,"")},C=T(),D=d&&d[3]||(p.cssNumber[c]?"":"px"),N=a.nodeType&&(p.cssNumber[c]||D!=="px"&&+C)&&Si.exec(p.css(a,c));if(N&&N[3]!==D){for(C=C/2,D=D||N[3],N=+C||1;k--;)p.style(a,c,N+D),(1-x)*(1-(x=T()/C||.5))<=0&&(k=0),N=N/x;N=N*2,p.style(a,c,N+D),d=d||[]}return d&&(N=+N||+C||0,b=d[1]?N+(d[1]+1)*d[2]:+d[2],m&&(m.unit=D,m.start=N,m.end=b)),b}var Fs={};function Bl(a){var c,d=a.ownerDocument,m=a.nodeName,b=Fs[m];return b||(c=d.body.appendChild(d.createElement(m)),b=p.css(c,"display"),c.parentNode.removeChild(c),b==="none"&&(b="block"),Fs[m]=b,b)}function We(a,c){for(var d,m,b=[],x=0,k=a.length;x<k;x++)m=a[x],m.style&&(d=m.style.display,c?(d==="none"&&(b[x]=J.get(m,"display")||null,b[x]||(m.style.display="")),m.style.display===""&&Jn(m)&&(b[x]=Bl(m))):d!=="none"&&(b[x]="none",J.set(m,"display",d)));for(x=0;x<k;x++)b[x]!=null&&(a[x].style.display=b[x]);return a}p.fn.extend({show:function(){return We(this,!0)},hide:function(){return We(this)},toggle:function(a){return typeof a=="boolean"?a?this.show():this.hide():this.each(function(){Jn(this)?p(this).show():p(this).hide()})}});var ii=/^(?:checkbox|radio)$/i,Rr=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,zs=/^$|^module$|\/(?:java|ecma)script/i;(function(){var a=R.createDocumentFragment(),c=a.appendChild(R.createElement("div")),d=R.createElement("input");d.setAttribute("type","radio"),d.setAttribute("checked","checked"),d.setAttribute("name","t"),c.appendChild(d),v.checkClone=c.cloneNode(!0).cloneNode(!0).lastChild.checked,c.innerHTML="<textarea>x</textarea>",v.noCloneChecked=!!c.cloneNode(!0).lastChild.defaultValue,c.innerHTML="<option></option>",v.option=!!c.lastChild})();var Ot={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ot.tbody=Ot.tfoot=Ot.colgroup=Ot.caption=Ot.thead,Ot.th=Ot.td,v.option||(Ot.optgroup=Ot.option=[1,"<select multiple='multiple'>","</select>"]);function at(a,c){var d;return typeof a.getElementsByTagName!="undefined"?d=a.getElementsByTagName(c||"*"):typeof a.querySelectorAll!="undefined"?d=a.querySelectorAll(c||"*"):d=[],c===void 0||c&&Z(a,c)?p.merge([a],d):d}function Zn(a,c){for(var d=0,m=a.length;d<m;d++)J.set(a[d],"globalEval",!c||J.get(c[d],"globalEval"))}var $s=/<|&#?\w+;/;function Ws(a,c,d,m,b){for(var x,k,T,C,D,N,_=c.createDocumentFragment(),P=[],q=0,ce=a.length;q<ce;q++)if(x=a[q],x||x===0)if(V(x)==="object")p.merge(P,x.nodeType?[x]:x);else if(!$s.test(x))P.push(c.createTextNode(x));else{for(k=k||_.appendChild(c.createElement("div")),T=(Rr.exec(x)||["",""])[1].toLowerCase(),C=Ot[T]||Ot._default,k.innerHTML=C[1]+p.htmlPrefilter(x)+C[2],N=C[0];N--;)k=k.lastChild;p.merge(P,k.childNodes),k=_.firstChild,k.textContent=""}for(_.textContent="",q=0;x=P[q++];){if(m&&p.inArray(x,m)>-1){b&&b.push(x);continue}if(D=Ci(x),k=at(_.appendChild(x),"script"),D&&Zn(k),d)for(N=0;x=k[N++];)zs.test(x.type||"")&&d.push(x)}return _}var Lr=/^([^.]*)(?:\.(.+)|)/;function Vi(){return!0}function on(){return!1}function kt(a,c,d,m,b,x){var k,T;if(typeof c=="object"){typeof d!="string"&&(m=m||d,d=void 0);for(T in c)kt(a,T,d,m,c[T],x);return a}if(m==null&&b==null?(b=d,m=d=void 0):b==null&&(typeof d=="string"?(b=m,m=void 0):(b=m,m=d,d=void 0)),b===!1)b=on;else if(!b)return a;return x===1&&(k=b,b=function(C){return p().off(C),k.apply(this,arguments)},b.guid=k.guid||(k.guid=p.guid++)),a.each(function(){p.event.add(this,c,b,m,d)})}p.event={global:{},add:function(a,c,d,m,b){var x,k,T,C,D,N,_,P,q,ce,Ae,ye=J.get(a);if(ui(a))for(d.handler&&(x=d,d=x.handler,b=x.selector),b&&p.find.matchesSelector(_t,b),d.guid||(d.guid=p.guid++),(C=ye.events)||(C=ye.events=Object.create(null)),(k=ye.handle)||(k=ye.handle=function(gt){return typeof p!="undefined"&&p.event.triggered!==gt.type?p.event.dispatch.apply(a,arguments):void 0}),c=(c||"").match(Vt)||[""],D=c.length;D--;)T=Lr.exec(c[D])||[],q=Ae=T[1],ce=(T[2]||"").split(".").sort(),q&&(_=p.event.special[q]||{},q=(b?_.delegateType:_.bindType)||q,_=p.event.special[q]||{},N=p.extend({type:q,origType:Ae,data:m,handler:d,guid:d.guid,selector:b,needsContext:b&&p.expr.match.needsContext.test(b),namespace:ce.join(".")},x),(P=C[q])||(P=C[q]=[],P.delegateCount=0,(!_.setup||_.setup.call(a,m,ce,k)===!1)&&a.addEventListener&&a.addEventListener(q,k)),_.add&&(_.add.call(a,N),N.handler.guid||(N.handler.guid=d.guid)),b?P.splice(P.delegateCount++,0,N):P.push(N),p.event.global[q]=!0)},remove:function(a,c,d,m,b){var x,k,T,C,D,N,_,P,q,ce,Ae,ye=J.hasData(a)&&J.get(a);if(!(!ye||!(C=ye.events))){for(c=(c||"").match(Vt)||[""],D=c.length;D--;){if(T=Lr.exec(c[D])||[],q=Ae=T[1],ce=(T[2]||"").split(".").sort(),!q){for(q in C)p.event.remove(a,q+c[D],d,m,!0);continue}for(_=p.event.special[q]||{},q=(m?_.delegateType:_.bindType)||q,P=C[q]||[],T=T[2]&&new RegExp("(^|\\.)"+ce.join("\\.(?:.*\\.|)")+"(\\.|$)"),k=x=P.length;x--;)N=P[x],(b||Ae===N.origType)&&(!d||d.guid===N.guid)&&(!T||T.test(N.namespace))&&(!m||m===N.selector||m==="**"&&N.selector)&&(P.splice(x,1),N.selector&&P.delegateCount--,_.remove&&_.remove.call(a,N));k&&!P.length&&((!_.teardown||_.teardown.call(a,ce,ye.handle)===!1)&&p.removeEvent(a,q,ye.handle),delete C[q])}p.isEmptyObject(C)&&J.remove(a,"handle events")}},dispatch:function(a){var c,d,m,b,x,k,T=new Array(arguments.length),C=p.event.fix(a),D=(J.get(this,"events")||Object.create(null))[C.type]||[],N=p.event.special[C.type]||{};for(T[0]=C,c=1;c<arguments.length;c++)T[c]=arguments[c];if(C.delegateTarget=this,!(N.preDispatch&&N.preDispatch.call(this,C)===!1)){for(k=p.event.handlers.call(this,C,D),c=0;(b=k[c++])&&!C.isPropagationStopped();)for(C.currentTarget=b.elem,d=0;(x=b.handlers[d++])&&!C.isImmediatePropagationStopped();)(!C.rnamespace||x.namespace===!1||C.rnamespace.test(x.namespace))&&(C.handleObj=x,C.data=x.data,m=((p.event.special[x.origType]||{}).handle||x.handler).apply(b.elem,T),m!==void 0&&(C.result=m)===!1&&(C.preventDefault(),C.stopPropagation()));return N.postDispatch&&N.postDispatch.call(this,C),C.result}},handlers:function(a,c){var d,m,b,x,k,T=[],C=c.delegateCount,D=a.target;if(C&&D.nodeType&&!(a.type==="click"&&a.button>=1)){for(;D!==this;D=D.parentNode||this)if(D.nodeType===1&&!(a.type==="click"&&D.disabled===!0)){for(x=[],k={},d=0;d<C;d++)m=c[d],b=m.selector+" ",k[b]===void 0&&(k[b]=m.needsContext?p(b,this).index(D)>-1:p.find(b,this,null,[D]).length),k[b]&&x.push(m);x.length&&T.push({elem:D,handlers:x})}}return D=this,C<c.length&&T.push({elem:D,handlers:c.slice(C)}),T},addProp:function(a,c){Object.defineProperty(p.Event.prototype,a,{enumerable:!0,configurable:!0,get:A(c)?function(){if(this.originalEvent)return c(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[a]},set:function(d){Object.defineProperty(this,a,{enumerable:!0,configurable:!0,writable:!0,value:d})}})},fix:function(a){return a[p.expando]?a:new p.Event(a)},special:{load:{noBubble:!0},click:{setup:function(a){var c=this||a;return ii.test(c.type)&&c.click&&Z(c,"input")&&Ui(c,"click",!0),!1},trigger:function(a){var c=this||a;return ii.test(c.type)&&c.click&&Z(c,"input")&&Ui(c,"click"),!0},_default:function(a){var c=a.target;return ii.test(c.type)&&c.click&&Z(c,"input")&&J.get(c,"click")||Z(c,"a")}},beforeunload:{postDispatch:function(a){a.result!==void 0&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}}};function Ui(a,c,d){if(!d){J.get(a,c)===void 0&&p.event.add(a,c,Vi);return}J.set(a,c,!1),p.event.add(a,c,{namespace:!1,handler:function(m){var b,x=J.get(this,c);if(m.isTrigger&1&&this[c]){if(x)(p.event.special[c]||{}).delegateType&&m.stopPropagation();else if(x=s.call(arguments),J.set(this,c,x),this[c](),b=J.get(this,c),J.set(this,c,!1),x!==b)return m.stopImmediatePropagation(),m.preventDefault(),b}else x&&(J.set(this,c,p.event.trigger(x[0],x.slice(1),this)),m.stopPropagation(),m.isImmediatePropagationStopped=Vi)}})}p.removeEvent=function(a,c,d){a.removeEventListener&&a.removeEventListener(c,d)},p.Event=function(a,c){if(!(this instanceof p.Event))return new p.Event(a,c);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.defaultPrevented===void 0&&a.returnValue===!1?Vi:on,this.target=a.target&&a.target.nodeType===3?a.target.parentNode:a.target,this.currentTarget=a.currentTarget,this.relatedTarget=a.relatedTarget):this.type=a,c&&p.extend(this,c),this.timeStamp=a&&a.timeStamp||Date.now(),this[p.expando]=!0},p.Event.prototype={constructor:p.Event,isDefaultPrevented:on,isPropagationStopped:on,isImmediatePropagationStopped:on,isSimulated:!1,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Vi,a&&!this.isSimulated&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Vi,a&&!this.isSimulated&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Vi,a&&!this.isSimulated&&a.stopImmediatePropagation(),this.stopPropagation()}},p.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},p.event.addProp),p.each({focus:"focusin",blur:"focusout"},function(a,c){function d(m){if(R.documentMode){var b=J.get(this,"handle"),x=p.event.fix(m);x.type=m.type==="focusin"?"focus":"blur",x.isSimulated=!0,b(m),x.target===x.currentTarget&&b(x)}else p.event.simulate(c,m.target,p.event.fix(m))}p.event.special[a]={setup:function(){var m;if(Ui(this,a,!0),R.documentMode)m=J.get(this,c),m||this.addEventListener(c,d),J.set(this,c,(m||0)+1);else return!1},trigger:function(){return Ui(this,a),!0},teardown:function(){var m;if(R.documentMode)m=J.get(this,c)-1,m?J.set(this,c,m):(this.removeEventListener(c,d),J.remove(this,c));else return!1},_default:function(m){return J.get(m.target,a)},delegateType:c},p.event.special[c]={setup:function(){var m=this.ownerDocument||this.document||this,b=R.documentMode?this:m,x=J.get(b,c);x||(R.documentMode?this.addEventListener(c,d):m.addEventListener(a,d,!0)),J.set(b,c,(x||0)+1)},teardown:function(){var m=this.ownerDocument||this.document||this,b=R.documentMode?this:m,x=J.get(b,c)-1;x?J.set(b,c,x):(R.documentMode?this.removeEventListener(c,d):m.removeEventListener(a,d,!0),J.remove(b,c))}}}),p.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,c){p.event.special[a]={delegateType:c,bindType:c,handle:function(d){var m,b=this,x=d.relatedTarget,k=d.handleObj;return(!x||x!==b&&!p.contains(b,x))&&(d.type=k.origType,m=k.handler.apply(this,arguments),d.type=c),m}}}),p.fn.extend({on:function(a,c,d,m){return kt(this,a,c,d,m)},one:function(a,c,d,m){return kt(this,a,c,d,m,1)},off:function(a,c,d){var m,b;if(a&&a.preventDefault&&a.handleObj)return m=a.handleObj,p(a.delegateTarget).off(m.namespace?m.origType+"."+m.namespace:m.origType,m.selector,m.handler),this;if(typeof a=="object"){for(b in a)this.off(b,c,a[b]);return this}return(c===!1||typeof c=="function")&&(d=c,c=void 0),d===!1&&(d=on),this.each(function(){p.event.remove(this,a,d,c)})}});var qs=/<script|<style|<link/i,js=/checked\s*(?:[^=]|=\s*.checked.)/i,Vs=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Pr(a,c){return Z(a,"table")&&Z(c.nodeType!==11?c:c.firstChild,"tr")&&p(a).children("tbody")[0]||a}function di(a){return a.type=(a.getAttribute("type")!==null)+"/"+a.type,a}function Us(a){return(a.type||"").slice(0,5)==="true/"?a.type=a.type.slice(5):a.removeAttribute("type"),a}function Ir(a,c){var d,m,b,x,k,T,C;if(c.nodeType===1){if(J.hasData(a)&&(x=J.get(a),C=x.events,C)){J.remove(c,"handle events");for(b in C)for(d=0,m=C[b].length;d<m;d++)p.event.add(c,b,C[b][d])}ft.hasData(a)&&(k=ft.access(a),T=p.extend({},k),ft.set(c,T))}}function Qs(a,c){var d=c.nodeName.toLowerCase();d==="input"&&ii.test(a.type)?c.checked=a.checked:(d==="input"||d==="textarea")&&(c.defaultValue=a.defaultValue)}function Qi(a,c,d,m){c=o(c);var b,x,k,T,C,D,N=0,_=a.length,P=_-1,q=c[0],ce=A(q);if(ce||_>1&&typeof q=="string"&&!v.checkClone&&js.test(q))return a.each(function(Ae){var ye=a.eq(Ae);ce&&(c[0]=q.call(this,Ae,ye.html())),Qi(ye,c,d,m)});if(_&&(b=Ws(c,a[0].ownerDocument,!1,a,m),x=b.firstChild,b.childNodes.length===1&&(b=x),x||m)){for(k=p.map(at(b,"script"),di),T=k.length;N<_;N++)C=b,N!==P&&(C=p.clone(C,!0,!0),T&&p.merge(k,at(C,"script"))),d.call(a[N],C,N);if(T)for(D=k[k.length-1].ownerDocument,p.map(k,Us),N=0;N<T;N++)C=k[N],zs.test(C.type||"")&&!J.access(C,"globalEval")&&p.contains(D,C)&&(C.src&&(C.type||"").toLowerCase()!=="module"?p._evalUrl&&!C.noModule&&p._evalUrl(C.src,{nonce:C.nonce||C.getAttribute("nonce")},D):W(C.textContent.replace(Vs,""),C,D))}return a}function Gs(a,c,d){for(var m,b=c?p.filter(c,a):a,x=0;(m=b[x])!=null;x++)!d&&m.nodeType===1&&p.cleanData(at(m)),m.parentNode&&(d&&Ci(m)&&Zn(at(m,"script")),m.parentNode.removeChild(m));return a}p.extend({htmlPrefilter:function(a){return a},clone:function(a,c,d){var m,b,x,k,T=a.cloneNode(!0),C=Ci(a);if(!v.noCloneChecked&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a))for(k=at(T),x=at(a),m=0,b=x.length;m<b;m++)Qs(x[m],k[m]);if(c)if(d)for(x=x||at(a),k=k||at(T),m=0,b=x.length;m<b;m++)Ir(x[m],k[m]);else Ir(a,T);return k=at(T,"script"),k.length>0&&Zn(k,!C&&at(a,"script")),T},cleanData:function(a){for(var c,d,m,b=p.event.special,x=0;(d=a[x])!==void 0;x++)if(ui(d)){if(c=d[J.expando]){if(c.events)for(m in c.events)b[m]?p.event.remove(d,m):p.removeEvent(d,m,c.handle);d[J.expando]=void 0}d[ft.expando]&&(d[ft.expando]=void 0)}}}),p.fn.extend({detach:function(a){return Gs(this,a,!0)},remove:function(a){return Gs(this,a)},text:function(a){return Nt(this,function(c){return c===void 0?p.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=c)})},null,a,arguments.length)},append:function(){return Qi(this,arguments,function(a){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var c=Pr(this,a);c.appendChild(a)}})},prepend:function(){return Qi(this,arguments,function(a){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var c=Pr(this,a);c.insertBefore(a,c.firstChild)}})},before:function(){return Qi(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Qi(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,c=0;(a=this[c])!=null;c++)a.nodeType===1&&(p.cleanData(at(a,!1)),a.textContent="");return this},clone:function(a,c){return a=a==null?!1:a,c=c==null?a:c,this.map(function(){return p.clone(this,a,c)})},html:function(a){return Nt(this,function(c){var d=this[0]||{},m=0,b=this.length;if(c===void 0&&d.nodeType===1)return d.innerHTML;if(typeof c=="string"&&!qs.test(c)&&!Ot[(Rr.exec(c)||["",""])[1].toLowerCase()]){c=p.htmlPrefilter(c);try{for(;m<b;m++)d=this[m]||{},d.nodeType===1&&(p.cleanData(at(d,!1)),d.innerHTML=c);d=0}catch(x){}}d&&this.empty().append(c)},null,a,arguments.length)},replaceWith:function(){var a=[];return Qi(this,arguments,function(c){var d=this.parentNode;p.inArray(this,a)<0&&(p.cleanData(at(this)),d&&d.replaceChild(c,this))},a)}}),p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,c){p.fn[a]=function(d){for(var m,b=[],x=p(d),k=x.length-1,T=0;T<=k;T++)m=T===k?this:this.clone(!0),p(x[T])[c](m),l.apply(b,m.get());return this.pushStack(b)}});var re=new RegExp("^("+Mn+")(?!px)[a-z%]+$","i"),M=/^--/,$=function(a){var c=a.ownerDocument.defaultView;return(!c||!c.opener)&&(c=e),c.getComputedStyle(a)},Y=function(a,c,d){var m,b,x={};for(b in c)x[b]=a.style[b],a.style[b]=c[b];m=d.call(a);for(b in c)a.style[b]=x[b];return m},ge=new RegExp(et.join("|"),"i");(function(){function a(){if(D){C.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",D.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",_t.appendChild(C).appendChild(D);var N=e.getComputedStyle(D);d=N.top!=="1%",T=c(N.marginLeft)===12,D.style.right="60%",x=c(N.right)===36,m=c(N.width)===36,D.style.position="absolute",b=c(D.offsetWidth/3)===12,_t.removeChild(C),D=null}}function c(N){return Math.round(parseFloat(N))}var d,m,b,x,k,T,C=R.createElement("div"),D=R.createElement("div");D.style&&(D.style.backgroundClip="content-box",D.cloneNode(!0).style.backgroundClip="",v.clearCloneStyle=D.style.backgroundClip==="content-box",p.extend(v,{boxSizingReliable:function(){return a(),m},pixelBoxStyles:function(){return a(),x},pixelPosition:function(){return a(),d},reliableMarginLeft:function(){return a(),T},scrollboxSize:function(){return a(),b},reliableTrDimensions:function(){var N,_,P,q;return k==null&&(N=R.createElement("table"),_=R.createElement("tr"),P=R.createElement("div"),N.style.cssText="position:absolute;left:-11111px;border-collapse:separate",_.style.cssText="box-sizing:content-box;border:1px solid",_.style.height="1px",P.style.height="9px",P.style.display="block",_t.appendChild(N).appendChild(_).appendChild(P),q=e.getComputedStyle(_),k=parseInt(q.height,10)+parseInt(q.borderTopWidth,10)+parseInt(q.borderBottomWidth,10)===_.offsetHeight,_t.removeChild(N)),k}}))})();function Ge(a,c,d){var m,b,x,k,T=M.test(c),C=a.style;return d=d||$(a),d&&(k=d.getPropertyValue(c)||d[c],T&&k&&(k=k.replace(xe,"$1")||void 0),k===""&&!Ci(a)&&(k=p.style(a,c)),!v.pixelBoxStyles()&&re.test(k)&&ge.test(c)&&(m=C.width,b=C.minWidth,x=C.maxWidth,C.minWidth=C.maxWidth=C.width=k,k=d.width,C.width=m,C.minWidth=b,C.maxWidth=x)),k!==void 0?k+"":k}function Ye(a,c){return{get:function(){if(a()){delete this.get;return}return(this.get=c).apply(this,arguments)}}}var ut=["Webkit","Moz","ms"],dt=R.createElement("div").style,ln={};function pt(a){for(var c=a[0].toUpperCase()+a.slice(1),d=ut.length;d--;)if(a=ut[d]+c,a in dt)return a}function er(a){var c=p.cssProps[a]||ln[a];return c||(a in dt?a:ln[a]=pt(a)||a)}var Ks=/^(none|table(?!-c[ea]).+)/,Mm={position:"absolute",visibility:"hidden",display:"block"},wc={letterSpacing:"0",fontWeight:"400"};function kc(a,c,d){var m=Si.exec(c);return m?Math.max(0,m[2]-(d||0))+(m[3]||"px"):c}function _l(a,c,d,m,b,x){var k=c==="width"?1:0,T=0,C=0,D=0;if(d===(m?"border":"content"))return 0;for(;k<4;k+=2)d==="margin"&&(D+=p.css(a,d+et[k],!0,b)),m?(d==="content"&&(C-=p.css(a,"padding"+et[k],!0,b)),d!=="margin"&&(C-=p.css(a,"border"+et[k]+"Width",!0,b))):(C+=p.css(a,"padding"+et[k],!0,b),d!=="padding"?C+=p.css(a,"border"+et[k]+"Width",!0,b):T+=p.css(a,"border"+et[k]+"Width",!0,b));return!m&&x>=0&&(C+=Math.max(0,Math.ceil(a["offset"+c[0].toUpperCase()+c.slice(1)]-x-C-T-.5))||0),C+D}function vc(a,c,d){var m=$(a),b=!v.boxSizingReliable()||d,x=b&&p.css(a,"boxSizing",!1,m)==="border-box",k=x,T=Ge(a,c,m),C="offset"+c[0].toUpperCase()+c.slice(1);if(re.test(T)){if(!d)return T;T="auto"}return(!v.boxSizingReliable()&&x||!v.reliableTrDimensions()&&Z(a,"tr")||T==="auto"||!parseFloat(T)&&p.css(a,"display",!1,m)==="inline")&&a.getClientRects().length&&(x=p.css(a,"boxSizing",!1,m)==="border-box",k=C in a,k&&(T=a[C])),T=parseFloat(T)||0,T+_l(a,c,d||(x?"border":"content"),k,m,T)+"px"}p.extend({cssHooks:{opacity:{get:function(a,c){if(c){var d=Ge(a,"opacity");return d===""?"1":d}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(a,c,d,m){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var b,x,k,T=Bt(c),C=M.test(c),D=a.style;if(C||(c=er(T)),k=p.cssHooks[c]||p.cssHooks[T],d!==void 0){if(x=typeof d,x==="string"&&(b=Si.exec(d))&&b[1]&&(d=sn(a,c,b),x="number"),d==null||d!==d)return;x==="number"&&!C&&(d+=b&&b[3]||(p.cssNumber[T]?"":"px")),!v.clearCloneStyle&&d===""&&c.indexOf("background")===0&&(D[c]="inherit"),(!k||!("set"in k)||(d=k.set(a,d,m))!==void 0)&&(C?D.setProperty(c,d):D[c]=d)}else return k&&"get"in k&&(b=k.get(a,!1,m))!==void 0?b:D[c]}},css:function(a,c,d,m){var b,x,k,T=Bt(c),C=M.test(c);return C||(c=er(T)),k=p.cssHooks[c]||p.cssHooks[T],k&&"get"in k&&(b=k.get(a,!0,d)),b===void 0&&(b=Ge(a,c,m)),b==="normal"&&c in wc&&(b=wc[c]),d===""||d?(x=parseFloat(b),d===!0||isFinite(x)?x||0:b):b}}),p.each(["height","width"],function(a,c){p.cssHooks[c]={get:function(d,m,b){if(m)return Ks.test(p.css(d,"display"))&&(!d.getClientRects().length||!d.getBoundingClientRect().width)?Y(d,Mm,function(){return vc(d,c,b)}):vc(d,c,b)},set:function(d,m,b){var x,k=$(d),T=!v.scrollboxSize()&&k.position==="absolute",C=T||b,D=C&&p.css(d,"boxSizing",!1,k)==="border-box",N=b?_l(d,c,b,D,k):0;return D&&T&&(N-=Math.ceil(d["offset"+c[0].toUpperCase()+c.slice(1)]-parseFloat(k[c])-_l(d,c,"border",!1,k)-.5)),N&&(x=Si.exec(m))&&(x[3]||"px")!=="px"&&(d.style[c]=m,m=p.css(d,c)),kc(d,m,N)}}}),p.cssHooks.marginLeft=Ye(v.reliableMarginLeft,function(a,c){if(c)return(parseFloat(Ge(a,"marginLeft"))||a.getBoundingClientRect().left-Y(a,{marginLeft:0},function(){return a.getBoundingClientRect().left}))+"px"}),p.each({margin:"",padding:"",border:"Width"},function(a,c){p.cssHooks[a+c]={expand:function(d){for(var m=0,b={},x=typeof d=="string"?d.split(" "):[d];m<4;m++)b[a+et[m]+c]=x[m]||x[m-2]||x[0];return b}},a!=="margin"&&(p.cssHooks[a+c].set=kc)}),p.fn.extend({css:function(a,c){return Nt(this,function(d,m,b){var x,k,T={},C=0;if(Array.isArray(m)){for(x=$(d),k=m.length;C<k;C++)T[m[C]]=p.css(d,m[C],!1,x);return T}return b!==void 0?p.style(d,m,b):p.css(d,m)},a,c,arguments.length>1)}});function Ht(a,c,d,m,b){return new Ht.prototype.init(a,c,d,m,b)}p.Tween=Ht,Ht.prototype={constructor:Ht,init:function(a,c,d,m,b,x){this.elem=a,this.prop=d,this.easing=b||p.easing._default,this.options=c,this.start=this.now=this.cur(),this.end=m,this.unit=x||(p.cssNumber[d]?"":"px")},cur:function(){var a=Ht.propHooks[this.prop];return a&&a.get?a.get(this):Ht.propHooks._default.get(this)},run:function(a){var c,d=Ht.propHooks[this.prop];return this.options.duration?this.pos=c=p.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=c=a,this.now=(this.end-this.start)*c+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),d&&d.set?d.set(this):Ht.propHooks._default.set(this),this}},Ht.prototype.init.prototype=Ht.prototype,Ht.propHooks={_default:{get:function(a){var c;return a.elem.nodeType!==1||a.elem[a.prop]!=null&&a.elem.style[a.prop]==null?a.elem[a.prop]:(c=p.css(a.elem,a.prop,""),!c||c==="auto"?0:c)},set:function(a){p.fx.step[a.prop]?p.fx.step[a.prop](a):a.elem.nodeType===1&&(p.cssHooks[a.prop]||a.elem.style[er(a.prop)]!=null)?p.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Ht.propHooks.scrollTop=Ht.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},p.easing={linear:function(a){return a},swing:function(a){return .5-Math.cos(a*Math.PI)/2},_default:"swing"},p.fx=Ht.prototype.init,p.fx.step={};var tr,Xs,Dm=/^(?:toggle|show|hide)$/,Rm=/queueHooks$/;function Hl(){Xs&&(R.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(Hl):e.setTimeout(Hl,p.fx.interval),p.fx.tick())}function Sc(){return e.setTimeout(function(){tr=void 0}),tr=Date.now()}function Ys(a,c){var d,m=0,b={height:a};for(c=c?1:0;m<4;m+=2-c)d=et[m],b["margin"+d]=b["padding"+d]=a;return c&&(b.opacity=b.width=a),b}function Cc(a,c,d){for(var m,b=(pi.tweeners[c]||[]).concat(pi.tweeners["*"]),x=0,k=b.length;x<k;x++)if(m=b[x].call(d,c,a))return m}function Lm(a,c,d){var m,b,x,k,T,C,D,N,_="width"in c||"height"in c,P=this,q={},ce=a.style,Ae=a.nodeType&&Jn(a),ye=J.get(a,"fxshow");d.queue||(k=p._queueHooks(a,"fx"),k.unqueued==null&&(k.unqueued=0,T=k.empty.fire,k.empty.fire=function(){k.unqueued||T()}),k.unqueued++,P.always(function(){P.always(function(){k.unqueued--,p.queue(a,"fx").length||k.empty.fire()})}));for(m in c)if(b=c[m],Dm.test(b)){if(delete c[m],x=x||b==="toggle",b===(Ae?"hide":"show"))if(b==="show"&&ye&&ye[m]!==void 0)Ae=!0;else continue;q[m]=ye&&ye[m]||p.style(a,m)}if(C=!p.isEmptyObject(c),!(!C&&p.isEmptyObject(q))){_&&a.nodeType===1&&(d.overflow=[ce.overflow,ce.overflowX,ce.overflowY],D=ye&&ye.display,D==null&&(D=J.get(a,"display")),N=p.css(a,"display"),N==="none"&&(D?N=D:(We([a],!0),D=a.style.display||D,N=p.css(a,"display"),We([a]))),(N==="inline"||N==="inline-block"&&D!=null)&&p.css(a,"float")==="none"&&(C||(P.done(function(){ce.display=D}),D==null&&(N=ce.display,D=N==="none"?"":N)),ce.display="inline-block")),d.overflow&&(ce.overflow="hidden",P.always(function(){ce.overflow=d.overflow[0],ce.overflowX=d.overflow[1],ce.overflowY=d.overflow[2]})),C=!1;for(m in q)C||(ye?"hidden"in ye&&(Ae=ye.hidden):ye=J.access(a,"fxshow",{display:D}),x&&(ye.hidden=!Ae),Ae&&We([a],!0),P.done(function(){Ae||We([a]),J.remove(a,"fxshow");for(m in q)p.style(a,m,q[m])})),C=Cc(Ae?ye[m]:0,m,P),m in ye||(ye[m]=C.start,Ae&&(C.end=C.start,C.start=0))}}function Pm(a,c){var d,m,b,x,k;for(d in a)if(m=Bt(d),b=c[m],x=a[d],Array.isArray(x)&&(b=x[1],x=a[d]=x[0]),d!==m&&(a[m]=x,delete a[d]),k=p.cssHooks[m],k&&"expand"in k){x=k.expand(x),delete a[m];for(d in x)d in a||(a[d]=x[d],c[d]=b)}else c[m]=b}function pi(a,c,d){var m,b,x=0,k=pi.prefilters.length,T=p.Deferred().always(function(){delete C.elem}),C=function(){if(b)return!1;for(var _=tr||Sc(),P=Math.max(0,D.startTime+D.duration-_),q=P/D.duration||0,ce=1-q,Ae=0,ye=D.tweens.length;Ae<ye;Ae++)D.tweens[Ae].run(ce);return T.notifyWith(a,[D,ce,P]),ce<1&&ye?P:(ye||T.notifyWith(a,[D,1,0]),T.resolveWith(a,[D]),!1)},D=T.promise({elem:a,props:p.extend({},c),opts:p.extend(!0,{specialEasing:{},easing:p.easing._default},d),originalProperties:c,originalOptions:d,startTime:tr||Sc(),duration:d.duration,tweens:[],createTween:function(_,P){var q=p.Tween(a,D.opts,_,P,D.opts.specialEasing[_]||D.opts.easing);return D.tweens.push(q),q},stop:function(_){var P=0,q=_?D.tweens.length:0;if(b)return this;for(b=!0;P<q;P++)D.tweens[P].run(1);return _?(T.notifyWith(a,[D,1,0]),T.resolveWith(a,[D,_])):T.rejectWith(a,[D,_]),this}}),N=D.props;for(Pm(N,D.opts.specialEasing);x<k;x++)if(m=pi.prefilters[x].call(D,a,N,D.opts),m)return A(m.stop)&&(p._queueHooks(D.elem,D.opts.queue).stop=m.stop.bind(m)),m;return p.map(N,Cc,D),A(D.opts.start)&&D.opts.start.call(a,D),D.progress(D.opts.progress).done(D.opts.done,D.opts.complete).fail(D.opts.fail).always(D.opts.always),p.fx.timer(p.extend(C,{elem:a,anim:D,queue:D.opts.queue})),D}p.Animation=p.extend(pi,{tweeners:{"*":[function(a,c){var d=this.createTween(a,c);return sn(d.elem,a,Si.exec(c),d),d}]},tweener:function(a,c){A(a)?(c=a,a=["*"]):a=a.match(Vt);for(var d,m=0,b=a.length;m<b;m++)d=a[m],pi.tweeners[d]=pi.tweeners[d]||[],pi.tweeners[d].unshift(c)},prefilters:[Lm],prefilter:function(a,c){c?pi.prefilters.unshift(a):pi.prefilters.push(a)}}),p.speed=function(a,c,d){var m=a&&typeof a=="object"?p.extend({},a):{complete:d||!d&&c||A(a)&&a,duration:a,easing:d&&c||c&&!A(c)&&c};return p.fx.off?m.duration=0:typeof m.duration!="number"&&(m.duration in p.fx.speeds?m.duration=p.fx.speeds[m.duration]:m.duration=p.fx.speeds._default),(m.queue==null||m.queue===!0)&&(m.queue="fx"),m.old=m.complete,m.complete=function(){A(m.old)&&m.old.call(this),m.queue&&p.dequeue(this,m.queue)},m},p.fn.extend({fadeTo:function(a,c,d,m){return this.filter(Jn).css("opacity",0).show().end().animate({opacity:c},a,d,m)},animate:function(a,c,d,m){var b=p.isEmptyObject(a),x=p.speed(c,d,m),k=function(){var T=pi(this,p.extend({},a),x);(b||J.get(this,"finish"))&&T.stop(!0)};return k.finish=k,b||x.queue===!1?this.each(k):this.queue(x.queue,k)},stop:function(a,c,d){var m=function(b){var x=b.stop;delete b.stop,x(d)};return typeof a!="string"&&(d=c,c=a,a=void 0),c&&this.queue(a||"fx",[]),this.each(function(){var b=!0,x=a!=null&&a+"queueHooks",k=p.timers,T=J.get(this);if(x)T[x]&&T[x].stop&&m(T[x]);else for(x in T)T[x]&&T[x].stop&&Rm.test(x)&&m(T[x]);for(x=k.length;x--;)k[x].elem===this&&(a==null||k[x].queue===a)&&(k[x].anim.stop(d),b=!1,k.splice(x,1));(b||!d)&&p.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var c,d=J.get(this),m=d[a+"queue"],b=d[a+"queueHooks"],x=p.timers,k=m?m.length:0;for(d.finish=!0,p.queue(this,a,[]),b&&b.stop&&b.stop.call(this,!0),c=x.length;c--;)x[c].elem===this&&x[c].queue===a&&(x[c].anim.stop(!0),x.splice(c,1));for(c=0;c<k;c++)m[c]&&m[c].finish&&m[c].finish.call(this);delete d.finish})}}),p.each(["toggle","show","hide"],function(a,c){var d=p.fn[c];p.fn[c]=function(m,b,x){return m==null||typeof m=="boolean"?d.apply(this,arguments):this.animate(Ys(c,!0),m,b,x)}}),p.each({slideDown:Ys("show"),slideUp:Ys("hide"),slideToggle:Ys("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,c){p.fn[a]=function(d,m,b){return this.animate(c,d,m,b)}}),p.timers=[],p.fx.tick=function(){var a,c=0,d=p.timers;for(tr=Date.now();c<d.length;c++)a=d[c],!a()&&d[c]===a&&d.splice(c--,1);d.length||p.fx.stop(),tr=void 0},p.fx.timer=function(a){p.timers.push(a),p.fx.start()},p.fx.interval=13,p.fx.start=function(){Xs||(Xs=!0,Hl())},p.fx.stop=function(){Xs=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fn.delay=function(a,c){return a=p.fx&&p.fx.speeds[a]||a,c=c||"fx",this.queue(c,function(d,m){var b=e.setTimeout(d,a);m.stop=function(){e.clearTimeout(b)}})},function(){var a=R.createElement("input"),c=R.createElement("select"),d=c.appendChild(R.createElement("option"));a.type="checkbox",v.checkOn=a.value!=="",v.optSelected=d.selected,a=R.createElement("input"),a.value="t",a.type="radio",v.radioValue=a.value==="t"}();var Ac,Nr=p.expr.attrHandle;p.fn.extend({attr:function(a,c){return Nt(this,p.attr,a,c,arguments.length>1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})}}),p.extend({attr:function(a,c,d){var m,b,x=a.nodeType;if(!(x===3||x===8||x===2)){if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);if((x!==1||!p.isXMLDoc(a))&&(b=p.attrHooks[c.toLowerCase()]||(p.expr.match.bool.test(c)?Ac:void 0)),d!==void 0){if(d===null){p.removeAttr(a,c);return}return b&&"set"in b&&(m=b.set(a,d,c))!==void 0?m:(a.setAttribute(c,d+""),d)}return b&&"get"in b&&(m=b.get(a,c))!==null?m:(m=p.find.attr(a,c),m==null?void 0:m)}},attrHooks:{type:{set:function(a,c){if(!v.radioValue&&c==="radio"&&Z(a,"input")){var d=a.value;return a.setAttribute("type",c),d&&(a.value=d),c}}}},removeAttr:function(a,c){var d,m=0,b=c&&c.match(Vt);if(b&&a.nodeType===1)for(;d=b[m++];)a.removeAttribute(d)}}),Ac={set:function(a,c,d){return c===!1?p.removeAttr(a,d):a.setAttribute(d,d),d}},p.each(p.expr.match.bool.source.match(/\w+/g),function(a,c){var d=Nr[c]||p.find.attr;Nr[c]=function(m,b,x){var k,T,C=b.toLowerCase();return x||(T=Nr[C],Nr[C]=k,k=d(m,b,x)!=null?C:null,Nr[C]=T),k}});var Im=/^(?:input|select|textarea|button)$/i,Nm=/^(?:a|area)$/i;p.fn.extend({prop:function(a,c){return Nt(this,p.prop,a,c,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[p.propFix[a]||a]})}}),p.extend({prop:function(a,c,d){var m,b,x=a.nodeType;if(!(x===3||x===8||x===2))return(x!==1||!p.isXMLDoc(a))&&(c=p.propFix[c]||c,b=p.propHooks[c]),d!==void 0?b&&"set"in b&&(m=b.set(a,d,c))!==void 0?m:a[c]=d:b&&"get"in b&&(m=b.get(a,c))!==null?m:a[c]},propHooks:{tabIndex:{get:function(a){var c=p.find.attr(a,"tabindex");return c?parseInt(c,10):Im.test(a.nodeName)||Nm.test(a.nodeName)&&a.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),v.optSelected||(p.propHooks.selected={get:function(a){var c=a.parentNode;return c&&c.parentNode&&c.parentNode.selectedIndex,null},set:function(a){var c=a.parentNode;c&&(c.selectedIndex,c.parentNode&&c.parentNode.selectedIndex)}}),p.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){p.propFix[this.toLowerCase()]=this});function Dn(a){var c=a.match(Vt)||[];return c.join(" ")}function Rn(a){return a.getAttribute&&a.getAttribute("class")||""}function Fl(a){return Array.isArray(a)?a:typeof a=="string"?a.match(Vt)||[]:[]}p.fn.extend({addClass:function(a){var c,d,m,b,x,k;return A(a)?this.each(function(T){p(this).addClass(a.call(this,T,Rn(this)))}):(c=Fl(a),c.length?this.each(function(){if(m=Rn(this),d=this.nodeType===1&&" "+Dn(m)+" ",d){for(x=0;x<c.length;x++)b=c[x],d.indexOf(" "+b+" ")<0&&(d+=b+" ");k=Dn(d),m!==k&&this.setAttribute("class",k)}}):this)},removeClass:function(a){var c,d,m,b,x,k;return A(a)?this.each(function(T){p(this).removeClass(a.call(this,T,Rn(this)))}):arguments.length?(c=Fl(a),c.length?this.each(function(){if(m=Rn(this),d=this.nodeType===1&&" "+Dn(m)+" ",d){for(x=0;x<c.length;x++)for(b=c[x];d.indexOf(" "+b+" ")>-1;)d=d.replace(" "+b+" "," ");k=Dn(d),m!==k&&this.setAttribute("class",k)}}):this):this.attr("class","")},toggleClass:function(a,c){var d,m,b,x,k=typeof a,T=k==="string"||Array.isArray(a);return A(a)?this.each(function(C){p(this).toggleClass(a.call(this,C,Rn(this),c),c)}):typeof c=="boolean"&&T?c?this.addClass(a):this.removeClass(a):(d=Fl(a),this.each(function(){if(T)for(x=p(this),b=0;b<d.length;b++)m=d[b],x.hasClass(m)?x.removeClass(m):x.addClass(m);else(a===void 0||k==="boolean")&&(m=Rn(this),m&&J.set(this,"__className__",m),this.setAttribute&&this.setAttribute("class",m||a===!1?"":J.get(this,"__className__")||""))}))},hasClass:function(a){var c,d,m=0;for(c=" "+a+" ";d=this[m++];)if(d.nodeType===1&&(" "+Dn(Rn(d))+" ").indexOf(c)>-1)return!0;return!1}});var Bm=/\r/g;p.fn.extend({val:function(a){var c,d,m,b=this[0];return arguments.length?(m=A(a),this.each(function(x){var k;this.nodeType===1&&(m?k=a.call(this,x,p(this).val()):k=a,k==null?k="":typeof k=="number"?k+="":Array.isArray(k)&&(k=p.map(k,function(T){return T==null?"":T+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()],(!c||!("set"in c)||c.set(this,k,"value")===void 0)&&(this.value=k))})):b?(c=p.valHooks[b.type]||p.valHooks[b.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(b,"value"))!==void 0?d:(d=b.value,typeof d=="string"?d.replace(Bm,""):d==null?"":d)):void 0}}),p.extend({valHooks:{option:{get:function(a){var c=p.find.attr(a,"value");return c!=null?c:Dn(p.text(a))}},select:{get:function(a){var c,d,m,b=a.options,x=a.selectedIndex,k=a.type==="select-one",T=k?null:[],C=k?x+1:b.length;for(x<0?m=C:m=k?x:0;m<C;m++)if(d=b[m],(d.selected||m===x)&&!d.disabled&&(!d.parentNode.disabled||!Z(d.parentNode,"optgroup"))){if(c=p(d).val(),k)return c;T.push(c)}return T},set:function(a,c){for(var d,m,b=a.options,x=p.makeArray(c),k=b.length;k--;)m=b[k],(m.selected=p.inArray(p.valHooks.option.get(m),x)>-1)&&(d=!0);return d||(a.selectedIndex=-1),x}}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]={set:function(a,c){if(Array.isArray(c))return a.checked=p.inArray(p(a).val(),c)>-1}},v.checkOn||(p.valHooks[this].get=function(a){return a.getAttribute("value")===null?"on":a.value})});var Br=e.location,Tc={guid:Date.now()},zl=/\?/;p.parseXML=function(a){var c,d;if(!a||typeof a!="string")return null;try{c=new e.DOMParser().parseFromString(a,"text/xml")}catch(m){}return d=c&&c.getElementsByTagName("parsererror")[0],(!c||d)&&p.error("Invalid XML: "+(d?p.map(d.childNodes,function(m){return m.textContent}).join(`
`):a)),c};var Oc=/^(?:focusinfocus|focusoutblur)$/,Ec=function(a){a.stopPropagation()};p.extend(p.event,{trigger:function(a,c,d,m){var b,x,k,T,C,D,N,_,P=[d||R],q=g.call(a,"type")?a.type:a,ce=g.call(a,"namespace")?a.namespace.split("."):[];if(x=_=k=d=d||R,!(d.nodeType===3||d.nodeType===8)&&!Oc.test(q+p.event.triggered)&&(q.indexOf(".")>-1&&(ce=q.split("."),q=ce.shift(),ce.sort()),C=q.indexOf(":")<0&&"on"+q,a=a[p.expando]?a:new p.Event(q,typeof a=="object"&&a),a.isTrigger=m?2:3,a.namespace=ce.join("."),a.rnamespace=a.namespace?new RegExp("(^|\\.)"+ce.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,a.result=void 0,a.target||(a.target=d),c=c==null?[a]:p.makeArray(c,[a]),N=p.event.special[q]||{},!(!m&&N.trigger&&N.trigger.apply(d,c)===!1))){if(!m&&!N.noBubble&&!O(d)){for(T=N.delegateType||q,Oc.test(T+q)||(x=x.parentNode);x;x=x.parentNode)P.push(x),k=x;k===(d.ownerDocument||R)&&P.push(k.defaultView||k.parentWindow||e)}for(b=0;(x=P[b++])&&!a.isPropagationStopped();)_=x,a.type=b>1?T:N.bindType||q,D=(J.get(x,"events")||Object.create(null))[a.type]&&J.get(x,"handle"),D&&D.apply(x,c),D=C&&x[C],D&&D.apply&&ui(x)&&(a.result=D.apply(x,c),a.result===!1&&a.preventDefault());return a.type=q,!m&&!a.isDefaultPrevented()&&(!N._default||N._default.apply(P.pop(),c)===!1)&&ui(d)&&C&&A(d[q])&&!O(d)&&(k=d[C],k&&(d[C]=null),p.event.triggered=q,a.isPropagationStopped()&&_.addEventListener(q,Ec),d[q](),a.isPropagationStopped()&&_.removeEventListener(q,Ec),p.event.triggered=void 0,k&&(d[C]=k)),a.result}},simulate:function(a,c,d){var m=p.extend(new p.Event,d,{type:a,isSimulated:!0});p.event.trigger(m,null,c)}}),p.fn.extend({trigger:function(a,c){return this.each(function(){p.event.trigger(a,c,this)})},triggerHandler:function(a,c){var d=this[0];if(d)return p.event.trigger(a,c,d,!0)}});var _m=/\[\]$/,Mc=/\r?\n/g,Hm=/^(?:submit|button|image|reset|file)$/i,Fm=/^(?:input|select|textarea|keygen)/i;function $l(a,c,d,m){var b;if(Array.isArray(c))p.each(c,function(x,k){d||_m.test(a)?m(a,k):$l(a+"["+(typeof k=="object"&&k!=null?x:"")+"]",k,d,m)});else if(!d&&V(c)==="object")for(b in c)$l(a+"["+b+"]",c[b],d,m);else m(a,c)}p.param=function(a,c){var d,m=[],b=function(x,k){var T=A(k)?k():k;m[m.length]=encodeURIComponent(x)+"="+encodeURIComponent(T==null?"":T)};if(a==null)return"";if(Array.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){b(this.name,this.value)});else for(d in a)$l(d,a[d],c,b);return m.join("&")},p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=p.prop(this,"elements");return a?p.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!p(this).is(":disabled")&&Fm.test(this.nodeName)&&!Hm.test(a)&&(this.checked||!ii.test(a))}).map(function(a,c){var d=p(this).val();return d==null?null:Array.isArray(d)?p.map(d,function(m){return{name:c.name,value:m.replace(Mc,`\r
`)}}):{name:c.name,value:d.replace(Mc,`\r
`)}}).get()}});var zm=/%20/g,$m=/#.*$/,Wm=/([?&])_=[^&]*/,qm=/^(.*?):[ \t]*([^\r\n]*)$/mg,jm=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Vm=/^(?:GET|HEAD)$/,Um=/^\/\//,Dc={},Wl={},Rc="*/".concat("*"),ql=R.createElement("a");ql.href=Br.href;function Lc(a){return function(c,d){typeof c!="string"&&(d=c,c="*");var m,b=0,x=c.toLowerCase().match(Vt)||[];if(A(d))for(;m=x[b++];)m[0]==="+"?(m=m.slice(1)||"*",(a[m]=a[m]||[]).unshift(d)):(a[m]=a[m]||[]).push(d)}}function Pc(a,c,d,m){var b={},x=a===Wl;function k(T){var C;return b[T]=!0,p.each(a[T]||[],function(D,N){var _=N(c,d,m);if(typeof _=="string"&&!x&&!b[_])return c.dataTypes.unshift(_),k(_),!1;if(x)return!(C=_)}),C}return k(c.dataTypes[0])||!b["*"]&&k("*")}function jl(a,c){var d,m,b=p.ajaxSettings.flatOptions||{};for(d in c)c[d]!==void 0&&((b[d]?a:m||(m={}))[d]=c[d]);return m&&p.extend(!0,a,m),a}function Qm(a,c,d){for(var m,b,x,k,T=a.contents,C=a.dataTypes;C[0]==="*";)C.shift(),m===void 0&&(m=a.mimeType||c.getResponseHeader("Content-Type"));if(m){for(b in T)if(T[b]&&T[b].test(m)){C.unshift(b);break}}if(C[0]in d)x=C[0];else{for(b in d){if(!C[0]||a.converters[b+" "+C[0]]){x=b;break}k||(k=b)}x=x||k}if(x)return x!==C[0]&&C.unshift(x),d[x]}function Gm(a,c,d,m){var b,x,k,T,C,D={},N=a.dataTypes.slice();if(N[1])for(k in a.converters)D[k.toLowerCase()]=a.converters[k];for(x=N.shift();x;)if(a.responseFields[x]&&(d[a.responseFields[x]]=c),!C&&m&&a.dataFilter&&(c=a.dataFilter(c,a.dataType)),C=x,x=N.shift(),x){if(x==="*")x=C;else if(C!=="*"&&C!==x){if(k=D[C+" "+x]||D["* "+x],!k){for(b in D)if(T=b.split(" "),T[1]===x&&(k=D[C+" "+T[0]]||D["* "+T[0]],k)){k===!0?k=D[b]:D[b]!==!0&&(x=T[0],N.unshift(T[1]));break}}if(k!==!0)if(k&&a.throws)c=k(c);else try{c=k(c)}catch(_){return{state:"parsererror",error:k?_:"No conversion from "+C+" to "+x}}}}return{state:"success",data:c}}p.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Br.href,type:"GET",isLocal:jm.test(Br.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Rc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":p.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,c){return c?jl(jl(a,p.ajaxSettings),c):jl(p.ajaxSettings,a)},ajaxPrefilter:Lc(Dc),ajaxTransport:Lc(Wl),ajax:function(a,c){typeof a=="object"&&(c=a,a=void 0),c=c||{};var d,m,b,x,k,T,C,D,N,_,P=p.ajaxSetup({},c),q=P.context||P,ce=P.context&&(q.nodeType||q.jquery)?p(q):p.event,Ae=p.Deferred(),ye=p.Callbacks("once memory"),gt=P.statusCode||{},tt={},Ai={},Ti="canceled",Se={readyState:0,getResponseHeader:function(Te){var Ke;if(C){if(!x)for(x={};Ke=qm.exec(b);)x[Ke[1].toLowerCase()+" "]=(x[Ke[1].toLowerCase()+" "]||[]).concat(Ke[2]);Ke=x[Te.toLowerCase()+" "]}return Ke==null?null:Ke.join(", ")},getAllResponseHeaders:function(){return C?b:null},setRequestHeader:function(Te,Ke){return C==null&&(Te=Ai[Te.toLowerCase()]=Ai[Te.toLowerCase()]||Te,tt[Te]=Ke),this},overrideMimeType:function(Te){return C==null&&(P.mimeType=Te),this},statusCode:function(Te){var Ke;if(Te)if(C)Se.always(Te[Se.status]);else for(Ke in Te)gt[Ke]=[gt[Ke],Te[Ke]];return this},abort:function(Te){var Ke=Te||Ti;return d&&d.abort(Ke),Ln(0,Ke),this}};if(Ae.promise(Se),P.url=((a||P.url||Br.href)+"").replace(Um,Br.protocol+"//"),P.type=c.method||c.type||P.method||P.type,P.dataTypes=(P.dataType||"*").toLowerCase().match(Vt)||[""],P.crossDomain==null){T=R.createElement("a");try{T.href=P.url,T.href=T.href,P.crossDomain=ql.protocol+"//"+ql.host!=T.protocol+"//"+T.host}catch(Te){P.crossDomain=!0}}if(P.data&&P.processData&&typeof P.data!="string"&&(P.data=p.param(P.data,P.traditional)),Pc(Dc,P,c,Se),C)return Se;D=p.event&&P.global,D&&p.active++===0&&p.event.trigger("ajaxStart"),P.type=P.type.toUpperCase(),P.hasContent=!Vm.test(P.type),m=P.url.replace($m,""),P.hasContent?P.data&&P.processData&&(P.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(P.data=P.data.replace(zm,"+")):(_=P.url.slice(m.length),P.data&&(P.processData||typeof P.data=="string")&&(m+=(zl.test(m)?"&":"?")+P.data,delete P.data),P.cache===!1&&(m=m.replace(Wm,"$1"),_=(zl.test(m)?"&":"?")+"_="+Tc.guid+++_),P.url=m+_),P.ifModified&&(p.lastModified[m]&&Se.setRequestHeader("If-Modified-Since",p.lastModified[m]),p.etag[m]&&Se.setRequestHeader("If-None-Match",p.etag[m])),(P.data&&P.hasContent&&P.contentType!==!1||c.contentType)&&Se.setRequestHeader("Content-Type",P.contentType),Se.setRequestHeader("Accept",P.dataTypes[0]&&P.accepts[P.dataTypes[0]]?P.accepts[P.dataTypes[0]]+(P.dataTypes[0]!=="*"?", "+Rc+"; q=0.01":""):P.accepts["*"]);for(N in P.headers)Se.setRequestHeader(N,P.headers[N]);if(P.beforeSend&&(P.beforeSend.call(q,Se,P)===!1||C))return Se.abort();if(Ti="abort",ye.add(P.complete),Se.done(P.success),Se.fail(P.error),d=Pc(Wl,P,c,Se),!d)Ln(-1,"No Transport");else{if(Se.readyState=1,D&&ce.trigger("ajaxSend",[Se,P]),C)return Se;P.async&&P.timeout>0&&(k=e.setTimeout(function(){Se.abort("timeout")},P.timeout));try{C=!1,d.send(tt,Ln)}catch(Te){if(C)throw Te;Ln(-1,Te)}}function Ln(Te,Ke,Hr,Ul){var Oi,Fr,Ei,an,hn,ni=Ke;C||(C=!0,k&&e.clearTimeout(k),d=void 0,b=Ul||"",Se.readyState=Te>0?4:0,Oi=Te>=200&&Te<300||Te===304,Hr&&(an=Qm(P,Se,Hr)),!Oi&&p.inArray("script",P.dataTypes)>-1&&p.inArray("json",P.dataTypes)<0&&(P.converters["text script"]=function(){}),an=Gm(P,an,Se,Oi),Oi?(P.ifModified&&(hn=Se.getResponseHeader("Last-Modified"),hn&&(p.lastModified[m]=hn),hn=Se.getResponseHeader("etag"),hn&&(p.etag[m]=hn)),Te===204||P.type==="HEAD"?ni="nocontent":Te===304?ni="notmodified":(ni=an.state,Fr=an.data,Ei=an.error,Oi=!Ei)):(Ei=ni,(Te||!ni)&&(ni="error",Te<0&&(Te=0))),Se.status=Te,Se.statusText=(Ke||ni)+"",Oi?Ae.resolveWith(q,[Fr,ni,Se]):Ae.rejectWith(q,[Se,ni,Ei]),Se.statusCode(gt),gt=void 0,D&&ce.trigger(Oi?"ajaxSuccess":"ajaxError",[Se,P,Oi?Fr:Ei]),ye.fireWith(q,[Se,ni]),D&&(ce.trigger("ajaxComplete",[Se,P]),--p.active||p.event.trigger("ajaxStop")))}return Se},getJSON:function(a,c,d){return p.get(a,c,d,"json")},getScript:function(a,c){return p.get(a,void 0,c,"script")}}),p.each(["get","post"],function(a,c){p[c]=function(d,m,b,x){return A(m)&&(x=x||b,b=m,m=void 0),p.ajax(p.extend({url:d,type:c,dataType:x,data:m,success:b},p.isPlainObject(d)&&d))}}),p.ajaxPrefilter(function(a){var c;for(c in a.headers)c.toLowerCase()==="content-type"&&(a.contentType=a.headers[c]||"")}),p._evalUrl=function(a,c,d){return p.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(m){p.globalEval(m,c,d)}})},p.fn.extend({wrapAll:function(a){var c;return this[0]&&(A(a)&&(a=a.call(this[0])),c=p(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&c.insertBefore(this[0]),c.map(function(){for(var d=this;d.firstElementChild;)d=d.firstElementChild;return d}).append(this)),this},wrapInner:function(a){return A(a)?this.each(function(c){p(this).wrapInner(a.call(this,c))}):this.each(function(){var c=p(this),d=c.contents();d.length?d.wrapAll(a):c.append(a)})},wrap:function(a){var c=A(a);return this.each(function(d){p(this).wrapAll(c?a.call(this,d):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){p(this).replaceWith(this.childNodes)}),this}}),p.expr.pseudos.hidden=function(a){return!p.expr.pseudos.visible(a)},p.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},p.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(a){}};var Km={0:200,1223:204},_r=p.ajaxSettings.xhr();v.cors=!!_r&&"withCredentials"in _r,v.ajax=_r=!!_r,p.ajaxTransport(function(a){var c,d;if(v.cors||_r&&!a.crossDomain)return{send:function(m,b){var x,k=a.xhr();if(k.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(x in a.xhrFields)k[x]=a.xhrFields[x];a.mimeType&&k.overrideMimeType&&k.overrideMimeType(a.mimeType),!a.crossDomain&&!m["X-Requested-With"]&&(m["X-Requested-With"]="XMLHttpRequest");for(x in m)k.setRequestHeader(x,m[x]);c=function(T){return function(){c&&(c=d=k.onload=k.onerror=k.onabort=k.ontimeout=k.onreadystatechange=null,T==="abort"?k.abort():T==="error"?typeof k.status!="number"?b(0,"error"):b(k.status,k.statusText):b(Km[k.status]||k.status,k.statusText,(k.responseType||"text")!=="text"||typeof k.responseText!="string"?{binary:k.response}:{text:k.responseText},k.getAllResponseHeaders()))}},k.onload=c(),d=k.onerror=k.ontimeout=c("error"),k.onabort!==void 0?k.onabort=d:k.onreadystatechange=function(){k.readyState===4&&e.setTimeout(function(){c&&d()})},c=c("abort");try{k.send(a.hasContent&&a.data||null)}catch(T){if(c)throw T}},abort:function(){c&&c()}}}),p.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===void 0&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),p.ajaxTransport("script",function(a){if(a.crossDomain||a.scriptAttrs){var c,d;return{send:function(m,b){c=p("<script>").attr(a.scriptAttrs||{}).prop({charset:a.scriptCharset,src:a.url}).on("load error",d=function(x){c.remove(),d=null,x&&b(x.type==="error"?404:200,x.type)}),R.head.appendChild(c[0])},abort:function(){d&&d()}}}});var Ic=[],Vl=/(=)\?(?=&|$)|\?\?/;p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Ic.pop()||p.expando+"_"+Tc.guid++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(a,c,d){var m,b,x,k=a.jsonp!==!1&&(Vl.test(a.url)?"url":typeof a.data=="string"&&(a.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Vl.test(a.data)&&"data");if(k||a.dataTypes[0]==="jsonp")return m=a.jsonpCallback=A(a.jsonpCallback)?a.jsonpCallback():a.jsonpCallback,k?a[k]=a[k].replace(Vl,"$1"+m):a.jsonp!==!1&&(a.url+=(zl.test(a.url)?"&":"?")+a.jsonp+"="+m),a.converters["script json"]=function(){return x||p.error(m+" was not called"),x[0]},a.dataTypes[0]="json",b=e[m],e[m]=function(){x=arguments},d.always(function(){b===void 0?p(e).removeProp(m):e[m]=b,a[m]&&(a.jsonpCallback=c.jsonpCallback,Ic.push(m)),x&&A(b)&&b(x[0]),x=b=void 0}),"script"}),v.createHTMLDocument=function(){var a=R.implementation.createHTMLDocument("").body;return a.innerHTML="<form></form><form></form>",a.childNodes.length===2}(),p.parseHTML=function(a,c,d){if(typeof a!="string")return[];typeof c=="boolean"&&(d=c,c=!1);var m,b,x;return c||(v.createHTMLDocument?(c=R.implementation.createHTMLDocument(""),m=c.createElement("base"),m.href=R.location.href,c.head.appendChild(m)):c=R),b=Oe.exec(a),x=!d&&[],b?[c.createElement(b[1])]:(b=Ws([a],c,x),x&&x.length&&p(x).remove(),p.merge([],b.childNodes))},p.fn.load=function(a,c,d){var m,b,x,k=this,T=a.indexOf(" ");return T>-1&&(m=Dn(a.slice(T)),a=a.slice(0,T)),A(c)?(d=c,c=void 0):c&&typeof c=="object"&&(b="POST"),k.length>0&&p.ajax({url:a,type:b||"GET",dataType:"html",data:c}).done(function(C){x=arguments,k.html(m?p("<div>").append(p.parseHTML(C)).find(m):C)}).always(d&&function(C,D){k.each(function(){d.apply(this,x||[C.responseText,D,C])})}),this},p.expr.pseudos.animated=function(a){return p.grep(p.timers,function(c){return a===c.elem}).length},p.offset={setOffset:function(a,c,d){var m,b,x,k,T,C,D,N=p.css(a,"position"),_=p(a),P={};N==="static"&&(a.style.position="relative"),T=_.offset(),x=p.css(a,"top"),C=p.css(a,"left"),D=(N==="absolute"||N==="fixed")&&(x+C).indexOf("auto")>-1,D?(m=_.position(),k=m.top,b=m.left):(k=parseFloat(x)||0,b=parseFloat(C)||0),A(c)&&(c=c.call(a,d,p.extend({},T))),c.top!=null&&(P.top=c.top-T.top+k),c.left!=null&&(P.left=c.left-T.left+b),"using"in c?c.using.call(a,P):_.css(P)}},p.fn.extend({offset:function(a){if(arguments.length)return a===void 0?this:this.each(function(b){p.offset.setOffset(this,a,b)});var c,d,m=this[0];if(m)return m.getClientRects().length?(c=m.getBoundingClientRect(),d=m.ownerDocument.defaultView,{top:c.top+d.pageYOffset,left:c.left+d.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var a,c,d,m=this[0],b={top:0,left:0};if(p.css(m,"position")==="fixed")c=m.getBoundingClientRect();else{for(c=this.offset(),d=m.ownerDocument,a=m.offsetParent||d.documentElement;a&&(a===d.body||a===d.documentElement)&&p.css(a,"position")==="static";)a=a.parentNode;a&&a!==m&&a.nodeType===1&&(b=p(a).offset(),b.top+=p.css(a,"borderTopWidth",!0),b.left+=p.css(a,"borderLeftWidth",!0))}return{top:c.top-b.top-p.css(m,"marginTop",!0),left:c.left-b.left-p.css(m,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent;a&&p.css(a,"position")==="static";)a=a.offsetParent;return a||_t})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=c==="pageYOffset";p.fn[a]=function(m){return Nt(this,function(b,x,k){var T;if(O(b)?T=b:b.nodeType===9&&(T=b.defaultView),k===void 0)return T?T[c]:b[x];T?T.scrollTo(d?T.pageXOffset:k,d?k:T.pageYOffset):b[x]=k},a,m,arguments.length)}}),p.each(["top","left"],function(a,c){p.cssHooks[c]=Ye(v.pixelPosition,function(d,m){if(m)return m=Ge(d,c),re.test(m)?p(d).position()[c]+"px":m})}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,m){p.fn[m]=function(b,x){var k=arguments.length&&(d||typeof b!="boolean"),T=d||(b===!0||x===!0?"margin":"border");return Nt(this,function(C,D,N){var _;return O(C)?m.indexOf("outer")===0?C["inner"+a]:C.document.documentElement["client"+a]:C.nodeType===9?(_=C.documentElement,Math.max(C.body["scroll"+a],_["scroll"+a],C.body["offset"+a],_["offset"+a],_["client"+a])):N===void 0?p.css(C,D,T):p.style(C,D,N,T)},c,k?b:void 0,k)}})}),p.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,c){p.fn[c]=function(d){return this.on(c,d)}}),p.fn.extend({bind:function(a,c,d){return this.on(a,null,c,d)},unbind:function(a,c){return this.off(a,null,c)},delegate:function(a,c,d,m){return this.on(c,a,d,m)},undelegate:function(a,c,d){return arguments.length===1?this.off(a,"**"):this.off(c,a||"**",d)},hover:function(a,c){return this.on("mouseenter",a).on("mouseleave",c||a)}}),p.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,c){p.fn[c]=function(d,m){return arguments.length>0?this.on(c,null,d,m):this.trigger(c)}});var Xm=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;p.proxy=function(a,c){var d,m,b;if(typeof c=="string"&&(d=a[c],c=a,a=d),!!A(a))return m=s.call(arguments,2),b=function(){return a.apply(c||this,m.concat(s.call(arguments)))},b.guid=a.guid=a.guid||p.guid++,b},p.holdReady=function(a){a?p.readyWait++:p.ready(!0)},p.isArray=Array.isArray,p.parseJSON=JSON.parse,p.nodeName=Z,p.isFunction=A,p.isWindow=O,p.camelCase=Bt,p.type=V,p.now=Date.now,p.isNumeric=function(a){var c=p.type(a);return(c==="number"||c==="string")&&!isNaN(a-parseFloat(a))},p.trim=function(a){return a==null?"":(a+"").replace(Xm,"$1")};var Ym=e.jQuery,Jm=e.$;return p.noConflict=function(a){return e.$===p&&(e.$=Jm),a&&e.jQuery===p&&(e.jQuery=Ym),p},typeof t=="undefined"&&(e.jQuery=e.$=p),p})})(ld);var k0=ld.exports;const Me=y0(k0);class Re{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=br(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Ni.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=br(this,e,t);let i=[];return this.decompose(e,t,i,0),Ni.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new ns(this),s=new ns(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new ns(this,e)}iterRange(e,t=this.length){return new ad(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new hd(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Re.empty:e.length<=32?new Xe(e):Ni.from(Xe.split(e,[]))}}class Xe extends Re{constructor(e,t=v0(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new S0(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new Xe(Wc(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Lo(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new Xe(l,o.length+s.length));else{let h=l.length>>1;i.push(new Xe(l.slice(0,h)),new Xe(l.slice(h)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof Xe))return super.replace(e,t,i);[e,t]=br(this,e,t);let r=Lo(this.text,Lo(i.text,Wc(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new Xe(r,s):Ni.from(Xe.split(r,[]),s)}sliceString(e,t=this.length,i=`
`){[e,t]=br(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],h=s+l.length;s>e&&o&&(r+=i),e<h&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=h+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new Xe(i,r)),i=[],r=-1);return r>-1&&t.push(new Xe(i,r)),t}}class Ni extends Re{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,h=i+o.lines-1;if((t?h:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=h+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],h=o+l.length;if(e<=h&&t>=o){let f=r&((o<=e?1:0)|(h>=t?2:0));o>=e&&h<=t&&!f?i.push(l):l.decompose(e-o,t-o,i,f)}o=h+1}}replace(e,t,i){if([e,t]=br(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let h=o.replace(e-s,t-s,i),f=this.lines-o.lines+h.lines;if(h.lines<f>>4&&h.lines>f>>6){let u=this.children.slice();return u[r]=h,new Ni(u,this.length-(t-e)+i.length)}return super.replace(s,l,h)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
`){[e,t]=br(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],h=o+l.length;o>e&&s&&(r+=i),e<h&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=h+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ni))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let h=this.children[r],f=e.children[s];if(h!=f)return i+h.scanIdentical(f,t);i+=h.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let w of e)i+=w.lines;if(i<32){let w=[];for(let v of e)v.flatten(w);return new Xe(w,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],h=0,f=-1,u=[];function g(w){let v;if(w.lines>s&&w instanceof Ni)for(let A of w.children)g(A);else w.lines>o&&(h>o||!h)?(y(),l.push(w)):w instanceof Xe&&h&&(v=u[u.length-1])instanceof Xe&&w.lines+v.lines<=32?(h+=w.lines,f+=w.length+1,u[u.length-1]=new Xe(v.text.concat(w.text),v.length+1+w.length)):(h+w.lines>r&&y(),h+=w.lines,f+=w.length+1,u.push(w))}function y(){h!=0&&(l.push(u.length==1?u[0]:Ni.from(u,f)),f=-1,h=u.length=0)}for(let w of e)g(w);return y(),l.length==1?l[0]:new Ni(l,t)}}Re.empty=new Xe([""],0);function v0(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Lo(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],h=r+l.length;h>=t&&(h>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=h+1}return e}function Wc(n,e,t){return Lo(n,[""],e,t)}class ns{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Xe?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Xe?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof Xe){let h=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,h.length>Math.max(0,e))return this.value=e==0?h:t>0?h.slice(e):h.slice(0,h.length-e),this;e-=h.length}else{let h=r.children[o+(t<0?-1:0)];e>h.length?(e-=h.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(h),this.offsets.push(t>0?1:(h instanceof Xe?h.text.length:h.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class ad{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ns(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class hd{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol!="undefined"&&(Re.prototype[Symbol.iterator]=function(){return this.iter()},ns.prototype[Symbol.iterator]=ad.prototype[Symbol.iterator]=hd.prototype[Symbol.iterator]=function(){return this});class S0{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}}function br(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}let fr="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;n<fr.length;n++)fr[n]+=fr[n-1];function C0(n){for(let e=1;e<fr.length;e+=2)if(fr[e]>n)return fr[e-1]<=n;return!1}function qc(n){return n>=127462&&n<=127487}const jc=8205;function xt(n,e,t=!0,i=!0){return(t?cd:A0)(n,e,i)}function cd(n,e,t){if(e==n.length)return e;e&&fd(n.charCodeAt(e))&&ud(n.charCodeAt(e-1))&&e--;let i=yt(n,e);for(e+=si(i);e<n.length;){let r=yt(n,e);if(i==jc||r==jc||t&&C0(r))e+=si(r),i=r;else if(qc(r)){let s=0,o=e-2;for(;o>=0&&qc(yt(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function A0(n,e,t){for(;e>0;){let i=cd(n,e-2,t);if(i<e)return i;e--}return 0}function fd(n){return n>=56320&&n<57344}function ud(n){return n>=55296&&n<56320}function yt(n,e){let t=n.charCodeAt(e);if(!ud(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return fd(i)?(t-55296<<10)+(i-56320)+65536:t}function Bh(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function si(n){return n<65536?1:2}const Ia=/\r\n?|\n/;var Dt=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Dt||(Dt={}));class $i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Na(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new $i(e)}composeDesc(e){return this.empty?e:e.empty?this:dd(this,e)}mapDesc(e,t=!1){return e.empty?this:Ba(this,e,t)}mapPos(e,t=-1,i=Dt.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],h=this.sections[o++],f=r+l;if(h<0){if(f>e)return s+(e-r);s+=l}else{if(i!=Dt.Simple&&f>=e&&(i==Dt.TrackDel&&r<e&&f>e||i==Dt.TrackBefore&&r<e||i==Dt.TrackAfter&&f>e))return null;if(f>e||f==e&&t<0&&!l)return e==r||t<0?s:s+h;s+=h}r=f}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new $i(e)}static create(e){return new $i(e)}}class nt extends $i{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Na(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Ba(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let h=r>>1;for(;i.length<h;)i.push(Re.empty);i.push(o?e.slice(s,s+o):Re.empty)}s+=o}return new nt(t,i)}compose(e){return this.empty?e:e.empty?this:dd(this,e,!0)}map(e,t=!1){return e.empty?this:Ba(this,e,t,!0)}iterChanges(e,t=!1){Na(this,e,t)}get desc(){return $i.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new hs(this);e:for(let o=0,l=0;;){let h=o==e.length?1e9:e[o++];for(;l<h||l==h&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,h-l);St(r,u,-1);let g=s.ins==-1?-1:s.off==0?s.ins:0;St(t,u,g),g>0&&pn(i,t,s.text),s.forward(u),l+=u}let f=e[o++];for(;l<f;){if(s.done)break e;let u=Math.min(s.len,f-l);St(t,u,-1),St(r,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),l+=u}}return{changes:new nt(t,i),filtered:$i.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function h(u=!1){if(!u&&!r.length)return;o<t&&St(r,t-o,-1);let g=new nt(r,s);l=l?l.compose(g.map(l)):g,r=[],s=[],o=0}function f(u){if(Array.isArray(u))for(let g of u)f(g);else if(u instanceof nt){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);h(),l=l?l.compose(u.map(l)):u}else{let{from:g,to:y=g,insert:w}=u;if(g>y||g<0||y>t)throw new RangeError(`Invalid change range ${g} to ${y} (in doc of length ${t})`);let v=w?typeof w=="string"?Re.of(w.split(i||Ia)):w:Re.empty,A=v.length;if(g==y&&A==0)return;g<o&&h(),g>o&&St(r,g-o,-1),St(r,y-g,A),pn(s,r,v),o=y}}return f(e),h(!l),l}static empty(e){return new nt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Re.empty);i[r]=Re.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new nt(t,i)}static createSet(e,t){return new nt(e,t)}}function St(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function pn(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Re.empty);n.push(t)}}function Na(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],h=n.sections[o++];if(h<0)r+=l,s+=l;else{let f=r,u=s,g=Re.empty;for(;f+=l,u+=h,h&&i&&(g=g.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],h=n.sections[o++];e(r,f,s,u,g),r=f,s=u}}}function Ba(n,e,t,i=!1){let r=[],s=i?[]:null,o=new hs(n),l=new hs(e);for(let h=-1;;)if(o.ins==-1&&l.ins==-1){let f=Math.min(o.len,l.len);St(r,f,-1),o.forward(f),l.forward(f)}else if(l.ins>=0&&(o.ins<0||h==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let f=l.len;for(St(r,l.ins,-1);f;){let u=Math.min(o.len,f);o.ins>=0&&h<o.i&&o.len<=u&&(St(r,0,o.ins),s&&pn(s,r,o.text),h=o.i),o.forward(u),f-=u}l.next()}else if(o.ins>=0){let f=0,u=o.len;for(;u;)if(l.ins==-1){let g=Math.min(u,l.len);f+=g,u-=g,l.forward(g)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;St(r,f,h<o.i?o.ins:0),s&&h<o.i&&pn(s,r,o.text),h=o.i,o.forward(o.len-u)}else{if(o.done&&l.done)return s?nt.createSet(r,s):$i.create(r);throw new Error("Mismatched change set lengths")}}function dd(n,e,t=!1){let i=[],r=t?[]:null,s=new hs(n),o=new hs(e);for(let l=!1;;){if(s.done&&o.done)return r?nt.createSet(i,r):$i.create(i);if(s.ins==0)St(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)St(i,0,o.ins,l),r&&pn(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let h=Math.min(s.len2,o.len),f=i.length;if(s.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;St(i,h,u,l),r&&u&&pn(r,i,o.text)}else o.ins==-1?(St(i,s.off?0:s.len,h,l),r&&pn(r,i,s.textBit(h))):(St(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&pn(r,i,o.text));l=(s.ins>h||o.ins>=0&&o.len>h)&&(l||i.length>f),s.forward2(h),o.forward(h)}}}}class hs{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Re.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Re.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class $n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new $n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return H.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return H.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return H.range(e.anchor,e.head)}static create(e,t,i){return new $n(e,t,i)}}class H{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:H.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new H([this.main],0)}addRange(e,t=!0){return H.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,H.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new H(e.ranges.map(t=>$n.fromJSON(t)),e.main)}static single(e,t=e){return new H([H.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return H.normalized(e.slice(),t);i=s.to}return new H(e,t)}static cursor(e,t=0,i,r){return $n.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?$n.create(t,e,48|s):$n.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,h=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?H.range(h,l):H.range(l,h))}}return new H(e,t)}}function pd(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let _h=0;class ee{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=_h++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ee(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Hh),!!e.static,e.enables)}of(e){return new Po([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Po(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Po(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Hh(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Po{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=_h++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,h=!1,f=!1,u=[];for(let g of this.dependencies)g=="doc"?h=!0:g=="selection"?f=!0:((t=e[g.id])!==null&&t!==void 0?t:1)&1||u.push(e[g.id]);return{create(g){return g.values[o]=i(g),1},update(g,y){if(h&&y.docChanged||f&&(y.docChanged||y.selection)||_a(g,u)){let w=i(g);if(l?!Vc(w,g.values[o],r):!r(w,g.values[o]))return g.values[o]=w,1}return 0},reconfigure:(g,y)=>{let w,v=y.config.address[s];if(v!=null){let A=jo(y,v);if(this.dependencies.every(O=>O instanceof ee?y.facet(O)===g.facet(O):O instanceof wt?y.field(O,!1)==g.field(O,!1):!0)||(l?Vc(w=i(g),A,r):r(w=i(g),A)))return g.values[o]=A,0}else w=i(g);return g.values[o]=w,1}}}}function Vc(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function _a(n,e){let t=!1;for(let i of e)rs(n,i)&1&&(t=!0);return t}function T0(n,e,t){let i=t.map(h=>n[h.id]),r=t.map(h=>h.type),s=i.filter(h=>!(h&1)),o=n[e.id]>>1;function l(h){let f=[];for(let u=0;u<i.length;u++){let g=jo(h,i[u]);if(r[u]==2)for(let y of g)f.push(y);else f.push(g)}return e.combine(f)}return{create(h){for(let f of i)rs(h,f);return h.values[o]=l(h),1},update(h,f){if(!_a(h,s))return 0;let u=l(h);return e.compare(u,h.values[o])?0:(h.values[o]=u,1)},reconfigure(h,f){let u=_a(h,i),g=f.config.facets[e.id],y=f.facet(e);if(g&&!u&&Hh(t,g))return h.values[o]=y,0;let w=l(h);return e.compare(w,y)?(h.values[o]=y,0):(h.values[o]=w,1)}}}const Uc=ee.define({static:!0});class wt{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new wt(_h++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Uc).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Uc.of({field:this,create:e})]}get extension(){return this}}const Fn={lowest:4,low:3,default:2,high:1,highest:0};function $r(n){return e=>new gd(e,n)}const Kn={highest:$r(Fn.highest),high:$r(Fn.high),default:$r(Fn.default),low:$r(Fn.low),lowest:$r(Fn.lowest)};class gd{constructor(e,t){this.inner=e,this.prec=t}}class xl{of(e){return new Ha(this,e)}reconfigure(e){return xl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ha{constructor(e,t){this.compartment=e,this.inner=t}}class qo{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let y of O0(e,t,o))y instanceof wt?r.push(y):(s[y.facet.id]||(s[y.facet.id]=[])).push(y);let l=Object.create(null),h=[],f=[];for(let y of r)l[y.id]=f.length<<1,f.push(w=>y.slot(w));let u=i==null?void 0:i.config.facets;for(let y in s){let w=s[y],v=w[0].facet,A=u&&u[y]||[];if(w.every(O=>O.type==0))if(l[v.id]=h.length<<1|1,Hh(A,w))h.push(i.facet(v));else{let O=v.combine(w.map(R=>R.value));h.push(i&&v.compare(O,i.facet(v))?i.facet(v):O)}else{for(let O of w)O.type==0?(l[O.id]=h.length<<1|1,h.push(O.value)):(l[O.id]=f.length<<1,f.push(R=>O.dynamicSlot(R)));l[v.id]=f.length<<1,f.push(O=>T0(O,v,w))}}let g=f.map(y=>y(l));return new qo(e,o,g,l,h,s)}}function O0(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let h=r.get(o);if(h!=null){if(h<=l)return;let f=i[h].indexOf(o);f>-1&&i[h].splice(f,1),o instanceof Ha&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let f of o)s(f,l);else if(o instanceof Ha){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(o.compartment)||o.inner;t.set(o.compartment,f),s(f,l)}else if(o instanceof gd)s(o.inner,o.prec);else if(o instanceof wt)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Po)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Fn.default);else{let f=o.extension;if(!f)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(f,l)}}return s(n,Fn.default),i.reduce((o,l)=>o.concat(l))}function rs(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function jo(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const md=ee.define(),Fa=ee.define({combine:n=>n.some(e=>e),static:!0}),yd=ee.define({combine:n=>n.length?n[0]:void 0,static:!0}),bd=ee.define(),xd=ee.define(),wd=ee.define(),kd=ee.define({combine:n=>n.length?n[0]:!1});class tn{constructor(e,t){this.type=e,this.value=t}static define(){return new E0}}class E0{of(e){return new tn(this,e)}}class M0{constructor(e){this.map=e}of(e){return new be(this,e)}}class be{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new be(this.type,t)}is(e){return this.type==e}static define(e={}){return new M0(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}be.reconfigure=be.define();be.appendConfig=be.define();class rt{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&pd(i,t.newLength),s.some(l=>l.type==rt.time)||(this.annotations=s.concat(rt.time.of(Date.now())))}static create(e,t,i,r,s,o){return new rt(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(rt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}rt.time=tn.define();rt.userEvent=tn.define();rt.addToHistory=tn.define();rt.remote=tn.define();function D0(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function vd(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=nt.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:be.mapEffects(n.effects,r).concat(be.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function za(n,e,t){let i=e.selection,r=ur(e.annotations);return e.userEvent&&(r=r.concat(rt.userEvent.of(e.userEvent))),{changes:e.changes instanceof nt?e.changes:nt.of(e.changes||[],t,n.facet(yd)),selection:i&&(i instanceof H?i:H.single(i.anchor,i.head)),effects:ur(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Sd(n,e,t){let i=za(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=vd(i,za(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=rt.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return L0(t?R0(r):r)}function R0(n){let e=n.startState,t=!0;for(let r of e.facet(bd)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:D0(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=nt.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=rt.create(e,r,n.selection&&n.selection.map(s),be.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(xd);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof rt?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof rt?n=s[0]:n=Sd(e,ur(s),!1)}return n}function L0(n){let e=n.startState,t=e.facet(wd),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=vd(i,za(e,s,n.changes.newLength),!0))}return i==n?n:rt.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const P0=[];function ur(n){return n==null?P0:Array.isArray(n)?n:[n]}var Ve=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Ve||(Ve={}));const I0=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let $a;try{$a=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function N0(n){if($a)return $a.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||I0.test(t)))return!0}return!1}function B0(n){return e=>{if(!/\S/.test(e))return Ve.Space;if(N0(e))return Ve.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Ve.Word;return Ve.Other}}class De{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)rs(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return rs(this,i),jo(this,i)}update(...e){return Sd(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(xl.reconfigure)?(t&&(r=new Map,t.compartments.forEach((h,f)=>r.set(f,h)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(be.reconfigure)?(t=null,i=l.value):l.is(be.appendConfig)&&(t=null,i=ur(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=qo.resolve(i,r,this),s=new De(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(h,f)=>f.reconfigure(h,this),null).values);let o=e.startState.facet(Fa)?e.newSelection:e.newSelection.asSingle();new De(t,e.newDoc,o,s,(l,h)=>h.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:H.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=ur(i.effects);for(let l=1;l<t.ranges.length;l++){let h=e(t.ranges[l]),f=this.changes(h.changes),u=f.map(r);for(let y=0;y<l;y++)s[y]=s[y].map(u);let g=r.mapDesc(f,!0);s.push(h.range.map(g)),r=r.compose(u),o=be.mapEffects(o,u).concat(be.mapEffects(ur(h.effects),g))}return{changes:r,selection:H.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof nt?e:nt.of(e,this.doc.length,this.facet(De.lineSeparator))}toText(e){return Re.of(e.split(this.facet(De.lineSeparator)||Ia))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(rs(this,t),jo(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof wt&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(h=>o.spec.fromJSON(l,h)))}}return De.create({doc:e.doc,selection:H.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=qo.resolve(e.extensions||[],new Map),i=e.doc instanceof Re?e.doc:Re.of((e.doc||"").split(t.staticFacet(De.lineSeparator)||Ia)),r=e.selection?e.selection instanceof H?e.selection:H.single(e.selection.anchor,e.selection.head):H.single(0);return pd(r,i.length),t.staticFacet(Fa)||(r=r.asSingle()),new De(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(De.tabSize)}get lineBreak(){return this.facet(De.lineSeparator)||`
`}get readOnly(){return this.facet(kd)}phrase(e,...t){for(let i of this.facet(De.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(md))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return B0(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let h=xt(t,o,!1);if(s(t.slice(h,o))!=Ve.Word)break;o=h}for(;l<r;){let h=xt(t,l);if(s(t.slice(l,h))!=Ve.Word)break;l=h}return o==l?null:H.range(o+i,l+i)}}De.allowMultipleSelections=Fa;De.tabSize=ee.define({combine:n=>n.length?n[0]:4});De.lineSeparator=yd;De.readOnly=kd;De.phrases=ee.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});De.languageData=md;De.changeFilter=bd;De.transactionFilter=xd;De.transactionExtender=wd;xl.reconfigure=be.define();function Wi(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class jn{eq(e){return this==e}range(e,t=e){return Wa.create(e,t,this)}}jn.prototype.startSide=jn.prototype.endSide=0;jn.prototype.point=!1;jn.prototype.mapMode=Dt.TrackDel;let Wa=class Cd{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Cd(e,t,i)}};function qa(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Fh{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let h=o+l>>1,f=s[h]-e||(i?this.value[h].endSide:this.value[h].startSide)-t;if(h==o)return f>=0?o:l;f>=0?l=h:o=h+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let h=0;h<this.value.length;h++){let f=this.value[h],u=this.from[h]+e,g=this.to[h]+e,y,w;if(u==g){let v=t.mapPos(u,f.startSide,f.mapMode);if(v==null||(y=w=v,f.startSide!=f.endSide&&(w=t.mapPos(u,f.endSide),w<y)))continue}else if(y=t.mapPos(u,f.startSide),w=t.mapPos(g,f.endSide),y>w||y==w&&f.startSide>0&&f.endSide<=0)continue;(w-y||f.endSide-f.startSide)<0||(o<0&&(o=y),f.point&&(l=Math.max(l,w-y)),i.push(f),r.push(y-o),s.push(w-o))}return{mapped:i.length?new Fh(r,s,i,l):null,pos:o}}}class Ie{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new Ie(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(qa)),this.isEmpty)return t.length?Ie.of(t):this;let l=new Ad(this,null,-1).goto(0),h=0,f=[],u=new kn;for(;l.value||h<t.length;)if(h<t.length&&(l.from-t[h].from||l.startSide-t[h].value.startSide)>=0){let g=t[h++];u.addInner(g.from,g.to,g.value)||f.push(g)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(h==t.length||this.chunkEnd(l.chunkIndex)<t[h].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||f.push(Wa.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!f.length?Ie.empty:this.nextLayer.update({add:f,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],h=this.chunk[o],f=e.touchesRange(l,l+h.length);if(f===!1)r=Math.max(r,h.maxPoint),t.push(h),i.push(e.mapPos(l));else if(f===!0){let{mapped:u,pos:g}=h.map(l,e);u&&(r=Math.max(r,u.maxPoint),t.push(u),i.push(g))}}let s=this.nextLayer.map(e);return t.length==0?s:new Ie(i,t,s||Ie.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return cs.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return cs.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=s),l=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=s),h=Qc(o,l,i),f=new Wr(o,h,s),u=new Wr(l,h,s);i.iterGaps((g,y,w)=>Gc(f,g,u,y,w,r)),i.empty&&i.length==0&&Gc(f,0,u,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Qc(s,o),h=new Wr(s,l,0).goto(i),f=new Wr(o,l,0).goto(i);for(;;){if(h.to!=f.to||!ja(h.active,f.active)||h.point&&(!f.point||!h.point.eq(f.point)))return!1;if(h.to>r)return!0;h.next(),f.next()}}static spans(e,t,i,r,s=-1){let o=new Wr(e,null,s).goto(t),l=t,h=o.openStart;for(;;){let f=Math.min(o.to,i);if(o.point){let u=o.activeForPoint(o.to),g=o.pointFrom<t?u.length+1:Math.min(u.length,h);r.point(l,f,o.point,u,g,o.pointRank),h=Math.min(o.openEnd(f),u.length)}else f>l&&(r.span(l,f,o.active,h),h=o.openEnd(f));if(o.to>i)return h+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new kn;for(let r of e instanceof Wa?[e]:t?_0(e):e)i.add(r.from,r.to,r.value);return i.finish()}}Ie.empty=new Ie([],[],null,-1);function _0(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(qa(e,i)>0)return n.slice().sort(qa);e=i}return n}Ie.empty.nextLayer=Ie.empty;class kn{finishChunk(e){this.chunks.push(new Fh(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new kn)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Qc(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}class Ad{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class cs{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new Ad(o,t,i,s));return r.length==1?r[0]:new cs(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)ta(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)ta(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ta(this.heap,0)}}}function ta(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}class Wr{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=cs.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){no(this.active,e),no(this.activeTo,e),no(this.activeRank,e),this.minActive=Kc(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;ro(this.active,t,i),ro(this.activeTo,t,r),ro(this.activeRank,t,s),e&&ro(e,t,this.cursor.from),this.minActive=Kc(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&no(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Gc(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,h=i-e;for(;;){let f=n.to+h-t.to||n.endSide-t.endSide,u=f<0?n.to+h:t.to,g=Math.min(u,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&ja(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,g,n.point,t.point):g>l&&!ja(n.active,t.active)&&s.compareRange(l,g,n.active,t.active),u>o)break;l=u,f<=0&&n.next(),f>=0&&t.next()}}function ja(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function no(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function ro(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Kc(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function As(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=xt(n,r));return i}function H0(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=xt(n,r)}return i===!0?-1:n.length}const Va="ͼ",Xc=typeof Symbol=="undefined"?"__"+Va:Symbol.for(Va),Ua=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Yc=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};class vn{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,h,f){let u=[],g=/^@(\w+)\b/.exec(o[0]),y=g&&g[1]=="keyframes";if(g&&l==null)return h.push(o[0]+";");for(let w in l){let v=l[w];if(/&/.test(w))s(w.split(/,\s*/).map(A=>o.map(O=>A.replace(/&/,O))).reduce((A,O)=>A.concat(O)),v,h);else if(v&&typeof v=="object"){if(!g)throw new RangeError("The value of a property ("+w+") should be a primitive value.");s(r(w),v,u,y)}else v!=null&&u.push(w.replace(/_.*/,"").replace(/[A-Z]/g,A=>"-"+A.toLowerCase())+": "+v+";")}(u.length||y)&&h.push((i&&!g&&!f?o.map(i):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=Yc[Xc]||1;return Yc[Xc]=e+1,Va+e.toString(36)}static mount(e,t,i){let r=e[Ua],s=i&&i.nonce;r?s&&r.setNonce(s):r=new F0(e,s),r.mount(Array.isArray(t)?t:[t])}}let Jc=new Map;class F0{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Jc.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[Ua]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Jc.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[Ua]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),t)for(let h=0;h<o.rules.length;h++)t.insertRule(o.rules[h],i++)}else{for(;r<l;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Sn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},z0=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),$0=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var bt=0;bt<10;bt++)Sn[48+bt]=Sn[96+bt]=String(bt);for(var bt=1;bt<=24;bt++)Sn[bt+111]="F"+bt;for(var bt=65;bt<=90;bt++)Sn[bt]=String.fromCharCode(bt+32),fs[bt]=String.fromCharCode(bt);for(var ia in Sn)fs.hasOwnProperty(ia)||(fs[ia]=Sn[ia]);function W0(n){var e=z0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||$0&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?fs:Sn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Vo(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Qa(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function q0(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Io(n,e){if(!e.anchorNode)return!1;try{return Qa(n,e.anchorNode)}catch(t){return!1}}function us(n){return n.nodeType==3?Vn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Uo(n,e,t,i){return t?Zc(n,e,t,i,-1)||Zc(n,e,t,i,1):!1}function ds(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Zc(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Yi(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=ds(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?Yi(n):0}else return!1}}function Yi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function zh(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function j0(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Td(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function V0(n,e,t,i,r,s,o,l){let h=n.ownerDocument,f=h.defaultView||window;for(let u=n,g=!1;u&&!g;)if(u.nodeType==1){let y,w=u==h.body,v=1,A=1;if(w)y=j0(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(g=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let F=u.getBoundingClientRect();({scaleX:v,scaleY:A}=Td(u,F)),y={left:F.left,right:F.left+u.clientWidth*v,top:F.top,bottom:F.top+u.clientHeight*A}}let O=0,R=0;if(r=="nearest")e.top<y.top?(R=-(y.top-e.top+o),t>0&&e.bottom>y.bottom+R&&(R=e.bottom-y.bottom+R+o)):e.bottom>y.bottom&&(R=e.bottom-y.bottom+o,t<0&&e.top-R<y.top&&(R=-(y.top+R-e.top+o)));else{let F=e.bottom-e.top,W=y.bottom-y.top;R=(r=="center"&&F<=W?e.top+F/2-W/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-W+o)-y.top}if(i=="nearest"?e.left<y.left?(O=-(y.left-e.left+s),t>0&&e.right>y.right+O&&(O=e.right-y.right+O+s)):e.right>y.right&&(O=e.right-y.right+s,t<0&&e.left<y.left+O&&(O=-(y.left+O-e.left+s))):O=(i=="center"?e.left+(e.right-e.left)/2-(y.right-y.left)/2:i=="start"==l?e.left-s:e.right-(y.right-y.left)+s)-y.left,O||R)if(w)f.scrollBy(O,R);else{let F=0,W=0;if(R){let V=u.scrollTop;u.scrollTop+=R/A,W=(u.scrollTop-V)*A}if(O){let V=u.scrollLeft;u.scrollLeft+=O/v,F=(u.scrollLeft-V)*v}e={left:e.left-F,top:e.top-W,right:e.right-F,bottom:e.bottom-W},F&&Math.abs(F-O)<1&&(i="nearest"),W&&Math.abs(W-R)<1&&(r="nearest")}if(w)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function U0(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class Q0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Yi(t):0),i,Math.min(e.focusOffset,i?Yi(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}}let sr=null;function Od(n){if(n.setActive)return n.setActive();if(sr)return n.focus(sr);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(sr==null?{get preventScroll(){return sr={preventScroll:!0},!0}}:void 0),!sr){sr=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}let ef;function Vn(n,e,t=e){let i=ef||(ef=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function dr(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function G0(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Ed(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function K0(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Yi(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Yi(t))}else{if(t==n)return!0;i=ds(t),t=t.parentNode}}function Md(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}class Ct{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Ct(e.parentNode,ds(e),t)}static after(e,t){return new Ct(e.parentNode,ds(e)+1,t)}}const $h=[];class je{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=je.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=tf(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=tf(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=Yi(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!je.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let h=0,f=i,u=i;h<this.children.length;h++){let g=this.children[h],y=f+g.length;if(f<e&&y>t)return g.domBoundsAround(e,t,f);if(y>=e&&r==-1&&(r=h,s=f),f>t&&g.dom.parentNode==this.dom){o=h,l=u;break}u=y,f=y+g.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=$h){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Dd(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}je.prototype.breakAfter=0;function tf(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Dd{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Rd(n,e,t,i,r,s,o,l,h){let{children:f}=n,u=f.length?f[e]:null,g=s.length?s[s.length-1]:null,y=g?g.breakAfter:o;if(!(e==i&&u&&!o&&!y&&s.length<2&&u.merge(t,r,s.length?g:null,t==0,l,h))){if(i<f.length){let w=f[i];w&&(r<w.length||w.breakAfter&&(g!=null&&g.breakAfter))?(e==i&&(w=w.split(r),r=0),!y&&g&&w.merge(0,r,g,!0,0,h)?s[s.length-1]=w:((r||w.children.length&&!w.children[0].length)&&w.merge(0,r,null,!1,0,h),s.push(w))):w!=null&&w.breakAfter&&(g?g.breakAfter=1:o=1),i++}for(u&&(u.breakAfter=o,t>0&&(!o&&s.length&&u.merge(t,u.length,s[0],!1,l,0)?u.breakAfter=s.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<i&&s.length;)if(f[i-1].become(s[s.length-1]))i--,s.pop(),h=s.length?0:l;else if(f[e].become(s[0]))e++,s.shift(),l=s.length?0:h;else break;!s.length&&e&&i<f.length&&!f[e-1].breakAfter&&f[i].merge(0,0,f[e-1],!1,l,h)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function Ld(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:h}=o.findPos(t,1),{i:f,off:u}=o.findPos(e,-1),g=e-t;for(let y of i)g+=y.length;n.length+=g,Rd(n,f,u,l,h,i,0,r,s)}let Yt=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},Ga=typeof document!="undefined"?document:{documentElement:{style:{}}};const Ka=/Edge\/(\d+)/.exec(Yt.userAgent),Pd=/MSIE \d/.test(Yt.userAgent),Xa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yt.userAgent),wl=!!(Pd||Xa||Ka),nf=!wl&&/gecko\/(\d+)/i.test(Yt.userAgent),na=!wl&&/Chrome\/(\d+)/.exec(Yt.userAgent),rf="webkitFontSmoothing"in Ga.documentElement.style,Id=!wl&&/Apple Computer/.test(Yt.vendor),sf=Id&&(/Mobile\/\w+/.test(Yt.userAgent)||Yt.maxTouchPoints>2);var ie={mac:sf||/Mac/.test(Yt.platform),windows:/Win/.test(Yt.platform),linux:/Linux|X11/.test(Yt.platform),ie:wl,ie_version:Pd?Ga.documentMode||6:Xa?+Xa[1]:Ka?+Ka[1]:0,gecko:nf,gecko_version:nf?+(/Firefox\/(\d+)/.exec(Yt.userAgent)||[0,0])[1]:0,chrome:!!na,chrome_version:na?+na[1]:0,ios:sf,android:/Android\b/.test(Yt.userAgent),webkit:rf,safari:Id,webkit_version:rf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ga.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const X0=256;class Ji extends je{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof Ji)||this.length-(t-e)+i.length>X0||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Ji(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Ct(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Y0(this.dom,e,t)}}class Zi extends je{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Ed(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,r,s,o){return i&&(!(i instanceof Zi&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(Ld(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let h=i+l.length;h>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=h,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new Zi(this.mark,t,o)}domAtPos(e){return Nd(this,e)}coordsAt(e,t){return _d(this,e,t)}}function Y0(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?ie.chrome||ie.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Vn(n,r,s).getClientRects();if(!l.length)return null;let h=l[(o?o<0:t>=0)?0:l.length-1];return ie.safari&&!o&&h.width==0&&(h=Array.prototype.find.call(l,f=>f.width)||h),o?zh(h,o<0):h||null}class gn extends je{static create(e,t,i){return new gn(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=gn.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof gn)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof gn&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Re.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Re.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Ct.before(this.dom):Ct.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return zh(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class xr extends je{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof xr&&e.side==this.side}split(){return new xr(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Ct.before(this.dom):Ct.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Re.empty}get isHidden(){return!0}}Ji.prototype.children=gn.prototype.children=xr.prototype.children=$h;function Nd(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Ct(t,0)}function Bd(n,e,t){let i,{children:r}=n;t>0&&e instanceof Zi&&r.length&&(i=r[r.length-1])instanceof Zi&&i.mark.eq(e.mark)?Bd(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function _d(n,e,t){let i=null,r=-1,s=null,o=-1;function l(f,u){for(let g=0,y=0;g<f.children.length&&y<=u;g++){let w=f.children[g],v=y+w.length;v>=u&&(w.children.length?l(w,u-y):(!s||s.isHidden&&t>0)&&(v>u||y==v&&w.getSide()>0)?(s=w,o=u-y):(y<u||y==v&&w.getSide()<0&&!w.isHidden)&&(i=w,r=u-y)),y=v}}l(n,e);let h=(t<0?i:s)||i||s;return h?h.coordsAt(Math.max(0,h==i?r:o),t):J0(n)}function J0(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=us(e);return t[t.length-1]||null}function Ya(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const of=Object.create(null);function Wh(n,e,t){if(n==e)return!0;n||(n=of),e||(e=of);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Ja(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Z0(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}class it extends je{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof it))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),Ld(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new it;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Wh(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Bd(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Ya(t,this.attrs||{})),i&&(this.attrs=Ya({class:i},this.attrs||{}))}domAtPos(e){return Nd(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Ed(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Ja(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&je.get(r)instanceof Zi;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=je.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!ie.ios||!this.children.some(s=>s instanceof Ji))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Ji)||/[^ -~]/.test(i.text))return null;let r=us(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=_d(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof it)return s;if(o>t)break}r=o+s.breakAfter}return null}}class bn extends je{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof bn)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Ct.before(this.dom):Ct.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new bn(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return $h}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Re.empty}domBoundsAround(){return null}become(e){return e instanceof bn&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}}class On{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}destroy(e){}}var Rt=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Rt||(Rt={}));class de extends jn{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Ts(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Cn(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Hd(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Cn(e,i,r,t,e.widget||null,!0)}static line(e){return new Os(e)}static set(e,t=!1){return Ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}de.none=Ie.empty;class Ts extends de{constructor(e){let{start:t,end:i}=Hd(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof Ts&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&Wh(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Ts.prototype.point=!1;class Os extends de{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Os&&this.spec.class==e.spec.class&&Wh(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Os.prototype.mapMode=Dt.TrackBefore;Os.prototype.point=!0;class Cn extends de{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Dt.TrackBefore:Dt.TrackAfter:Dt.TrackDel}get type(){return this.startSide!=this.endSide?Rt.WidgetRange:this.startSide<=0?Rt.WidgetBefore:Rt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Cn&&ey(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Cn.prototype.point=!0;function Hd(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function ey(n,e){return n==e||!!(n&&e&&n.compare(e))}function Za(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}class ss{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof bn&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new it),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(so(new xr(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof bn)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(so(new Ji(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Cn){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Cn)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new bn(i.widget||new lf("div"),l,i));else{let h=gn.create(i.widget||new lf("span"),l,l?0:i.startSide),f=this.atCursorPos&&!h.isEditable&&s<=r.length&&(e<t||i.startSide>0),u=!h.isEditable&&(e<t||s>r.length||i.startSide<=0),g=this.getLine();this.pendingBuffer==2&&!f&&!h.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),f&&(g.append(so(new xr(1),r),s),s=r.length+Math.max(0,s-r.length)),g.append(so(h,r),s),this.atCursorPos=u,this.pendingBuffer=u?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,i,r,s){let o=new ss(e,t,i,s);return o.openEnd=Ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function so(n,e){for(let t of e)n=new Zi(t,[n],n.length);return n}class lf extends On{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const Fd=ee.define(),zd=ee.define(),$d=ee.define(),Wd=ee.define(),eh=ee.define(),qd=ee.define(),jd=ee.define(),Vd=ee.define({combine:n=>n.some(e=>e)}),Ud=ee.define({combine:n=>n.some(e=>e)});class pr{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new pr(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new pr(H.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oo=be.define({map:(n,e)=>n.map(e)});function li(n,e,t){let i=n.facet(Wd);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const kl=ee.define({combine:n=>n.length?n[0]:!0});let ty=0;const Jr=ee.define();class st{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){const{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new st(ty++,e,i,r,l=>{let h=[Jr.of(l)];return o&&h.push(ps.of(f=>{let u=f.plugin(l);return u?o(u):de.none})),s&&h.push(s(l)),h})}static fromClass(e,t){return st.define(i=>new e(i),t)}}class ra{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(li(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){li(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){li(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Qd=ee.define(),qh=ee.define(),ps=ee.define(),jh=ee.define(),Gd=ee.define();function af(n,e,t){let i=n.state.facet(Gd);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return Ie.spans(r,e,t,{point(){},span(o,l,h,f){let u=s;for(let g=h.length-1;g>=0;g--,f--){let y=h[g].spec.bidiIsolate,w;if(y!=null)if(f>0&&u.length&&(w=u[u.length-1]).to==o&&w.direction==y)w.to=l,u=w.inner;else{let v={from:o,to:l,direction:y,inner:[]};u.push(v),u=v.inner}}}}),s}const Kd=ee.define();function Xd(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Kd)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}const Zr=ee.define();class ai{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new ai(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let h=r==e.length?null:e[r],f=o-l,u=h?h.fromB:1e9;for(;s<t.length&&t[s]<u;){let g=t[s],y=t[s+1],w=Math.max(l,g),v=Math.min(u,y);if(w<=v&&new ai(w+f,v+f,w,v).addToSet(i),y>u)break;s+=2}if(!h)return i;new ai(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),o=h.toA,l=h.toB}}}class Qo{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=nt.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,h)=>r.push(new ai(s,o,l,h))),this.changedRanges=r}static create(e,t,i){return new Qo(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}var Ue=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(Ue||(Ue={}));const gs=Ue.LTR,Yd=Ue.RTL;function Jd(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}const iy=Jd("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ny=Jd("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),th=Object.create(null),Di=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);th[e]=t,th[t]=-e}function ry(n){return n<=247?iy[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?ny[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}const sy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class mn{get dir(){return this.level%2?Yd:gs}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Zd(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Zd(i.inner,r.inner))return!1}return!0}const He=[];function oy(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,h=s?256:r;for(let f=o,u=h,g=h;f<l;f++){let y=ry(n.charCodeAt(f));y==512?y=u:y==8&&g==4&&(y=16),He[f]=y==4?2:y,y&7&&(g=y),u=y}for(let f=o,u=h,g=h;f<l;f++){let y=He[f];if(y==128)f<l-1&&u==He[f+1]&&u&24?y=He[f]=u:He[f]=256;else if(y==64){let w=f+1;for(;w<l&&He[w]==64;)w++;let v=f&&u==8||w<t&&He[w]==8?g==1?1:8:256;for(let A=f;A<w;A++)He[A]=v;f=w-1}else y==8&&g==1&&(He[f]=1);u=y,y&7&&(g=y)}}}function ly(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,h=0;o<=i.length;o++){let f=o?i[o-1].to:e,u=o<i.length?i[o].from:t;for(let g=f,y,w,v;g<u;g++)if(w=th[y=n.charCodeAt(g)])if(w<0){for(let A=l-3;A>=0;A-=3)if(Di[A+1]==-w){let O=Di[A+2],R=O&2?r:O&4?O&1?s:r:0;R&&(He[g]=He[Di[A]]=R),l=A;break}}else{if(Di.length==189)break;Di[l++]=g,Di[l++]=y,Di[l++]=h}else if((v=He[g])==2||v==1){let A=v==r;h=A?0:1;for(let O=l-3;O>=0;O-=3){let R=Di[O+2];if(R&2)break;if(A)Di[O+2]|=2;else{if(R&4)break;Di[O+2]|=4}}}}}function ay(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let h=o;h<l;){let f=He[h];if(f==256){let u=h+1;for(;;)if(u==l){if(r==t.length)break;u=t[r++].to,l=r<t.length?t[r].from:e}else if(He[u]==256)u++;else break;let g=s==1,y=(u<e?He[u]:i)==1,w=g==y?g?1:2:i;for(let v=u,A=r,O=A?t[A-1].to:n;v>h;)v==O&&(v=t[--A].from,O=A?t[A-1].to:n),He[--v]=w;h=u}else s=f,h++}}}function ih(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let h=e,f=0;h<t;){let u=!0,g=!1;if(f==s.length||h<s[f].from){let A=He[h];A!=l&&(u=!1,g=A==16)}let y=!u&&l==1?[]:null,w=u?i:i+1,v=h;e:for(;;)if(f<s.length&&v==s[f].from){if(g)break e;let A=s[f];if(!u)for(let O=A.to,R=f+1;;){if(O==t)break e;if(R<s.length&&s[R].from==O)O=s[R++].to;else{if(He[O]==l)break e;break}}if(f++,y)y.push(A);else{A.from>h&&o.push(new mn(h,A.from,w));let O=A.direction==gs!=!(w%2);nh(n,O?i+1:i,r,A.inner,A.from,A.to,o),h=A.to}v=A.to}else{if(v==t||(u?He[v]!=l:He[v]==l))break;v++}y?ih(n,h,v,i+1,r,y,o):h<v&&o.push(new mn(h,v,w)),h=v}else for(let h=t,f=s.length;h>e;){let u=!0,g=!1;if(!f||h>s[f-1].to){let A=He[h-1];A!=l&&(u=!1,g=A==16)}let y=!u&&l==1?[]:null,w=u?i:i+1,v=h;e:for(;;)if(f&&v==s[f-1].to){if(g)break e;let A=s[--f];if(!u)for(let O=A.from,R=f;;){if(O==e)break e;if(R&&s[R-1].to==O)O=s[--R].from;else{if(He[O-1]==l)break e;break}}if(y)y.push(A);else{A.to<h&&o.push(new mn(A.to,h,w));let O=A.direction==gs!=!(w%2);nh(n,O?i+1:i,r,A.inner,A.from,A.to,o),h=A.from}v=A.from}else{if(v==e||(u?He[v-1]!=l:He[v-1]==l))break;v--}y?ih(n,v,h,i+1,r,y,o):v<h&&o.push(new mn(v,h,w)),h=v}}function nh(n,e,t,i,r,s,o){let l=e%2?2:1;oy(n,r,s,i,l),ly(n,r,s,i,l),ay(r,s,i,l),ih(n,r,s,e,t,i,o)}function hy(n,e,t){if(!n)return[new mn(0,0,e==Yd?1:0)];if(e==gs&&!t.length&&!sy.test(n))return ep(n.length);if(t.length)for(;n.length>He.length;)He[He.length]=256;let i=[],r=e==gs?0:1;return nh(n,r,r,t,0,n.length,i),i}function ep(n){return[new mn(0,n,0)]}let tp="";function cy(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let y=e[e.length-1];y.level!=t&&(o=y.side(!0,t),l=e.length-1)}l<0&&(l=mn.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let h=e[l];o==h.side(r,t)&&(h=e[l+=r?1:-1],o=h.side(!r,t));let f=r==(h.dir==t),u=xt(n.text,o,f);if(tp=n.text.slice(Math.min(o,u),Math.max(o,u)),u>h.from&&u<h.to)return H.cursor(u+n.from,f?-1:1,h.level);let g=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!g&&h.level!=t?H.cursor(r?n.to:n.from,r?-1:1,t):g&&g.level<h.level?H.cursor(g.side(!r,t)+n.from,r?1:-1,g.level):H.cursor(u+n.from,r?-1:1,h.level)}class hf extends je{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new it],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ai(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:u})=>u<this.minWidthFrom||f>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!yy(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?uy(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:f,to:u}=this.hasComposition;i=new ai(f,u,e.changes.mapPos(f,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(ie.ie||ie.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),h=gy(o,l,e.changes);return i=ai.extendWithRanges(i,h),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=ie.chrome||ie.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof bn&&o.widget instanceof cf&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:h,toA:f,fromB:u,toB:g}=l,y,w,v,A;if(i&&i.range.fromB<g&&i.range.toB>u){let V=ss.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),z=ss.build(this.view.state.doc,i.range.toB,g,this.decorations,this.dynamicDecorationMap);w=V.breakAtStart,v=V.openStart,A=z.openEnd;let G=this.compositionView(i);z.breakAtStart?G.breakAfter=1:z.content.length&&G.merge(G.length,G.length,z.content[0],!1,z.openStart,0)&&(G.breakAfter=z.content[0].breakAfter,z.content.shift()),V.content.length&&G.merge(0,0,V.content[V.content.length-1],!0,0,V.openEnd)&&V.content.pop(),y=V.content.concat(G).concat(z.content)}else({content:y,breakAtStart:w,openStart:v,openEnd:A}=ss.build(this.view.state.doc,u,g,this.decorations,this.dynamicDecorationMap));let{i:O,off:R}=s.findPos(f,1),{i:F,off:W}=s.findPos(h,-1);Rd(this,F,W,O,R,y,w,v,A)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Ji(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Zi(r,[t],t.length);let i=new it;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(h=>h.flags&7)?1:0),this.markedForComposition.add(o);let l=je.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&Io(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(l.anchor)),f=l.empty?h:this.moveToLine(this.domAtPos(l.head));if(ie.gecko&&l.empty&&!this.hasComposition&&fy(h)){let g=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(g,h.node.childNodes[h.offset]||null)),h=f=new Ct(g,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||!Uo(h.node,h.offset,u.anchorNode,u.anchorOffset)||!Uo(f.node,f.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{ie.android&&ie.chrome&&this.dom.contains(u.focusNode)&&my(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let g=Vo(this.view.root);if(g)if(l.empty){if(ie.gecko){let y=dy(h.node,h.offset);if(y&&y!=3){let w=np(h.node,h.offset,y==1?1:-1);w&&(h=new Ct(w.node,w.offset))}}g.collapse(h.node,h.offset),l.bidiLevel!=null&&g.caretBidiLevel!==void 0&&(g.caretBidiLevel=l.bidiLevel)}else if(g.extend){g.collapse(h.node,h.offset);try{g.extend(f.node,f.offset)}catch(y){}}else{let y=document.createRange();l.anchor>l.head&&([h,f]=[f,h]),y.setEnd(f.node,f.offset),y.setStart(h.node,h.offset),g.removeAllRanges(),g.addRange(y)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new Ct(u.anchorNode,u.anchorOffset),this.impreciseHead=f.precise?null:new Ct(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Vo(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=it.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let h=this.coordsAt(t.head,-1),f=this.coordsAt(t.head,1);if(!h||!f||h.bottom>f.top)return;let u=this.domAtPos(t.head+t.assoc);i.collapse(u.node,u.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let g=e.observer.selectionRange;e.docView.posFromDOM(g.anchorNode,g.anchorOffset)!=t.from&&i.collapse(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=je.get(t.childNodes[r]);s instanceof it&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=je.get(t.childNodes[r]);s instanceof it&&(i=s.domAtPos(s.length))}return i?new Ct(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=je.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof it)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],h=s-l.breakAfter,f=h-l.length;if(h<e)break;f<=e&&(f<e||l.covers(-1))&&(h>e||l.covers(1))&&(!i||l instanceof it&&!(i instanceof it&&t>=0))&&(i=l,r=f),s=f}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof it))return null;for(;r.children.length;){let{i:l,off:h}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=h}if(!(r instanceof Ji))return null;let s=xt(r.text,i);if(s==i)return null;let o=Vn(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let h=o[l];if(l==o.length-1||h.top<h.bottom&&h.left<h.right)return h}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,h=this.view.textDirection==Ue.LTR;for(let f=0,u=0;u<this.children.length;u++){let g=this.children[u],y=f+g.length;if(y>r)break;if(f>=i){let w=g.dom.getBoundingClientRect();if(t.push(w.height),o){let v=g.dom.lastChild,A=v?us(v):[];if(A.length){let O=A[A.length-1],R=h?O.right-w.left:w.right-O.left;R>l&&(l=R,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=y)}}}f=y+g.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?Ue.RTL:Ue.LTR}measureTextSize(){for(let s of this.children)if(s instanceof it){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=us(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Dd(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(de.replace({widget:new cf(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return de.set(e)}updateDeco(){let e=this.view.state.facet(ps).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let f=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=f.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Xd(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:h}=this.view.scrollDOM;V0(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,h),-h),this.view.textDirection==Ue.LTR)}}function fy(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}class cf extends On{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function ip(n,e){let t=n.observer.selectionRange,i=t.focusNode&&np(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function uy(n,e,t){let i=ip(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let h=e.invertedDesc,f=new ai(h.mapPos(s),h.mapPos(o),s,o),u=[];for(let g=r.parentNode;;g=g.parentNode){let y=je.get(g);if(y instanceof Zi)u.push({node:g,deco:y.mark});else{if(y instanceof it||g.nodeName=="DIV"&&g.parentNode==n.contentDOM)return{range:f,text:r,marks:u,line:g};if(g!=n.contentDOM)u.push({node:g,deco:new Ts({inclusive:!0,attributes:Z0(g),tagName:g.tagName.toLowerCase()})});else return null}}}function np(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=Yi(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function dy(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}let py=class{constructor(){this.changes=[]}compareRange(e,t){Za(e,t,this.changes)}comparePoint(e,t){Za(e,t,this.changes)}};function gy(n,e,t){let i=new py;return Ie.compare(n,e,t,i),i.changes}function my(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function yy(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function by(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return H.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=xt(r.text,s,!1):l=xt(r.text,s);let h=i(r.text.slice(o,l));for(;o>0;){let f=xt(r.text,o,!1);if(i(r.text.slice(f,o))!=h)break;o=f}for(;l<r.length;){let f=xt(r.text,l);if(i(r.text.slice(l,f))!=h)break;l=f}return H.range(o+r.from,l+r.from)}function xy(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function wy(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function sa(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function ff(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function uf(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function rh(n,e,t){let i,r,s,o,l=!1,h,f,u,g;for(let v=n.firstChild;v;v=v.nextSibling){let A=us(v);for(let O=0;O<A.length;O++){let R=A[O];r&&sa(r,R)&&(R=ff(uf(R,r.bottom),r.top));let F=xy(e,R),W=wy(t,R);if(F==0&&W==0)return v.nodeType==3?df(v,e,t):rh(v,e,t);if(!i||o>W||o==W&&s>F){i=v,r=R,s=F,o=W;let V=W?t<R.top?-1:1:F?e<R.left?-1:1:0;l=!V||(V>0?O<A.length-1:O>0)}F==0?t>R.bottom&&(!u||u.bottom<R.bottom)?(h=v,u=R):t<R.top&&(!g||g.top>R.top)&&(f=v,g=R):u&&sa(u,R)?u=uf(u,R.bottom):g&&sa(g,R)&&(g=ff(g,R.top))}}if(u&&u.bottom>=t?(i=h,r=u):g&&g.top<=t&&(i=f,r=g),!i)return{node:n,offset:0};let y=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return df(i,y,t);if(l&&i.contentEditable!="false")return rh(i,y,t);let w=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:w}}function df(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let h=Vn(n,l,l+1).getClientRects();for(let f=0;f<h.length;f++){let u=h[f];if(u.top==u.bottom)continue;o||(o=e-u.left);let g=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&g<s){let y=e>=(u.left+u.right)/2,w=y;if((ie.chrome||ie.gecko)&&Vn(n,l).getBoundingClientRect().left==u.right&&(w=!y),g<=0)return{node:n,offset:l+(w?1:0)};r=l+(w?1:0),s=g}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function rp(n,e,t,i=-1){var r,s;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,h,{docHeight:f}=n.viewState,{x:u,y:g}=e,y=g-l;if(y<0)return 0;if(y>f)return n.state.doc.length;for(let V=n.viewState.heightOracle.textHeight/2,z=!1;h=n.elementAtHeight(y),h.type!=Rt.Text;)for(;y=i>0?h.bottom+V:h.top-V,!(y>=0&&y<=f);){if(z)return t?null:0;z=!0,i=-i}g=l+y;let w=h.from;if(w<n.viewport.from)return n.viewport.from==0?0:t?null:pf(n,o,h,u,g);if(w>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:pf(n,o,h,u,g);let v=n.dom.ownerDocument,A=n.root.elementFromPoint?n.root:v,O=A.elementFromPoint(u,g);O&&!n.contentDOM.contains(O)&&(O=null),O||(u=Math.max(o.left+1,Math.min(o.right-1,u)),O=A.elementFromPoint(u,g),O&&!n.contentDOM.contains(O)&&(O=null));let R,F=-1;if(O&&((r=n.docView.nearest(O))===null||r===void 0?void 0:r.isEditable)!=!1){if(v.caretPositionFromPoint){let V=v.caretPositionFromPoint(u,g);V&&({offsetNode:R,offset:F}=V)}else if(v.caretRangeFromPoint){let V=v.caretRangeFromPoint(u,g);V&&({startContainer:R,startOffset:F}=V,(!n.contentDOM.contains(R)||ie.safari&&ky(R,F,u)||ie.chrome&&vy(R,F,u))&&(R=void 0))}}if(!R||!n.docView.dom.contains(R)){let V=it.find(n.docView,w);if(!V)return y>h.top+h.height/2?h.to:h.from;({node:R,offset:F}=rh(V.dom,u,g))}let W=n.docView.nearest(R);if(!W)return null;if(W.isWidget&&((s=W.dom)===null||s===void 0?void 0:s.nodeType)==1){let V=W.dom.getBoundingClientRect();return e.y<V.top||e.y<=V.bottom&&e.x<=(V.left+V.right)/2?W.posAtStart:W.posAtEnd}else return W.localPosFromDOM(R,F)+W.posAtStart}function pf(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,h=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=h*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+H0(o,s,n.state.tabSize)}function ky(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Vn(n,i-1,i).getBoundingClientRect().left>t}function vy(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():Vn(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function sh(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Rt.Text))return i}return t}function Sy(n,e,t,i){let r=sh(n,e.head),s=!i||r.type!=Rt.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),h=n.posAtCoords({x:t==(l==Ue.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(h!=null)return H.cursor(h,t?-1:1)}return H.cursor(t?r.to:r.from,t?-1:1)}function gf(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,h=null;;){let f=cy(r,s,o,l,t),u=tp;if(!f){if(r.number==(t?n.state.doc.lines:1))return l;u=`
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),f=H.cursor(t?r.from:r.to)}if(h){if(!h(u))return l}else{if(!i)return f;h=i(u)}l=f}}function Cy(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==Ve.Space&&(r=o),r==o}}function Ay(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return H.cursor(r,e.assoc);let o=e.goalColumn,l,h=n.contentDOM.getBoundingClientRect(),f=n.coordsAtPos(r,e.assoc||-1),u=n.documentTop;if(f)o==null&&(o=f.left-h.left),l=s<0?f.top:f.bottom;else{let w=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(h.right-h.left,n.defaultCharacterWidth*(r-w.from))),l=(s<0?w.top:w.bottom)+u}let g=h.left+o,y=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let w=0;;w+=10){let v=l+(y+w)*s,A=rp(n,{x:g,y:v},!1,s);if(v<h.top||v>h.bottom||(s<0?A<r:A>r)){let O=n.docView.coordsForChar(A),R=!O||v<O.top?-1:1;return H.cursor(A,R,void 0,o)}}}function No(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let h=i||t||(e-s<o-e?-1:1);e=h<0?s:o,i=h}});if(!i)return e}}function oa(n,e,t){let i=No(n.state.facet(jh).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:H.cursor(i,i<t.from?1:-1)}class Ty{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ie.safari&&e.contentDOM.addEventListener("input",()=>null),ie.gecko&&Wy(e.contentDOM.ownerDocument)}handleEvent(e){!Iy(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Oy(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&op.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),ie.android&&ie.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return ie.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=sp.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||Ey.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,dr(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:ie.safari&&!ie.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mf(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){li(t.state,r)}}}function Oy(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(mf(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(mf(i.value,o))}}for(let i in bi)t(i).handlers.push(bi[i]);for(let i in xi)t(i).observers.push(xi[i]);return e}const sp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ey="dthko",op=[16,17,18,20,91,92,224,225],lo=6;function ao(n){return Math.max(0,n)*.7+8}function My(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class Dy{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=U0(e.contentDOM),this.atoms=e.state.facet(jh).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(De.allowMultipleSelections)&&Ry(e,t),this.dragging=Py(e,t)&&cp(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&My(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=Xd(this.view);e.clientX-o.left<=s.left+lo?i=-ao(s.left-e.clientX):e.clientX+o.right>=s.right-lo&&(i=ao(e.clientX-s.right)),e.clientY-o.top<=s.top+lo?r=-ao(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-lo&&(r=ao(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=No(this.atoms,r.from,0);o!=r.from&&(s=H.cursor(o,-1))}else{let o=No(this.atoms,r.from,-1),l=No(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=H.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?H.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Ry(n,e){let t=n.state.facet(Fd);return t.length?t[0](e):ie.mac?e.metaKey:e.ctrlKey}function Ly(n,e){let t=n.state.facet(zd);return t.length?t[0](e):ie.mac?!e.altKey:!e.ctrlKey}function Py(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Vo(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Iy(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=je.get(t))&&i.ignoreEvent(e))return!1;return!0}const bi=Object.create(null),xi=Object.create(null),lp=ie.ie&&ie.ie_version<15||ie.ios&&ie.webkit_version<604;function Ny(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),ap(n,t.value)},50)}function ap(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(oh!=null&&t.selection.ranges.every(h=>h.empty)&&oh==s.toString()){let h=-1;i=t.changeByRange(f=>{let u=t.doc.lineAt(f.from);if(u.from==h)return{range:f};h=u.from;let g=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:g},range:H.cursor(f.from+g.length)}})}else o?i=t.changeByRange(h=>{let f=s.line(r++);return{changes:{from:h.from,to:h.to,insert:f.text},range:H.cursor(h.from+f.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}xi.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};bi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);xi.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};xi.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};bi.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet($d))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Hy(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Dy(n,e,t,i)),i&&n.observer.ignore(()=>Od(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function yf(n,e,t,i){if(i==1)return H.cursor(e,t);if(i==2)return by(n.state,e,t);{let r=it.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,H.range(o,l)}}let hp=(n,e)=>n>=e.top&&n<=e.bottom,bf=(n,e,t)=>hp(e,t)&&n>=t.left&&n<=t.right;function By(n,e,t,i){let r=it.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&bf(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&bf(t,i,l)?1:o&&hp(i,o)?-1:1}function xf(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:By(n,t,e.clientX,e.clientY)}}const _y=ie.ie&&ie.ie_version<=11;let wf=null,kf=0,vf=0;function cp(n){if(!_y)return n.detail;let e=wf,t=vf;return wf=n,vf=Date.now(),kf=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(kf+1)%3:1}function Hy(n,e){let t=xf(n,e),i=cp(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let h=xf(n,s),f,u=yf(n,h.pos,h.bias,i);if(t.pos!=h.pos&&!o){let g=yf(n,t.pos,t.bias,i),y=Math.min(g.from,u.from),w=Math.max(g.to,u.to);u=y<u.from?H.range(y,w):H.range(w,y)}return o?r.replaceRange(r.main.extend(u.from,u.to)):l&&i==1&&r.ranges.length>1&&(f=Fy(r,h.pos))?f:l?r.addRange(u):H.create([u])}}}function Fy(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return H.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}bi.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=H.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};bi.dragend=n=>(n.inputState.draggedContent=null,!1);function Sf(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&Ly(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},h=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:h,selection:{anchor:h.mapPos(r,-1),head:h.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}bi.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&Sf(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Sf(n,e,i,!0),!0}return!1};bi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=lp?null:e.clipboardData;return t?(ap(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(Ny(n),!1)};function zy(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function $y(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let oh=null;bi.copy=bi.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=$y(n.state);if(!t&&!r)return!1;oh=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=lp?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(zy(n,t),!1)};const fp=tn.define();function up(n,e){let t=[];for(let i of n.facet(jd)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:fp.of(!0)}):null}function dp(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=up(n.state,e);t?n.dispatch(t):n.update([])}},10)}xi.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),dp(n)};xi.blur=n=>{n.observer.clearSelectionRange(),dp(n)};xi.compositionstart=xi.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};xi.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,ie.chrome&&ie.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};xi.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};bi.beforeinput=(n,e)=>{var t;let i;if(ie.chrome&&ie.android&&(i=sp.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};const Cf=new Set;function Wy(n){Cf.has(n)||(Cf.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Af=["pre-wrap","normal","pre-line","break-spaces"];class qy{constructor(e){this.lineWrapping=e,this.doc=Re.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Af.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=Af.indexOf(e)>-1,h=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,h){this.heightSamples={};for(let f=0;f<o.length;f++){let u=o[f];u<0?f++:this.heightSamples[Math.floor(u*10)]=!0}}return h}}class jy{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Bi{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Rt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Cn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Bi(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var qe=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(qe||(qe={}));const Bo=.001;class Lt{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Bo&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return Lt.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:h,toA:f,fromB:u,toB:g}=r[l],y=s.lineAt(h,qe.ByPosNoHeight,i.setDoc(t),0,0),w=y.to>=f?y:s.lineAt(f,qe.ByPosNoHeight,i,0,0);for(g+=w.to-f,f=w.to;l>0&&y.from<=r[l-1].toA;)h=r[l-1].fromA,u=r[l-1].fromB,l--,h<y.from&&(y=s.lineAt(h,qe.ByPosNoHeight,i,0,0));u+=y.from-h,h=y.from;let v=Vh.build(i.setDoc(o),e,u,g);s=s.replace(h,f,v)}return s.updateHeight(i,0)}static empty(){return new Gt(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Vy(Lt.of(e.slice(0,t)),o,Lt.of(e.slice(i)))}}Lt.prototype.size=1;class pp extends Lt{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new Bi(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Gt extends pp{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new Bi(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof Gt||r instanceof mt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof mt?r=new Gt(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Lt.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class mt extends Lt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let h=Math.min(this.height,e.lineHeight*s);o=h/s,this.length>s+1&&(l=(this.height-h)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:h}=this.heightMetrics(t,r);if(t.lineWrapping){let f=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),u=t.doc.lineAt(f),g=l+u.length*h,y=Math.max(i,e-g/2);return new Bi(u.from,u.length,y,g,0)}else{let f=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:u,length:g}=t.doc.line(s+f);return new Bi(u,g,i+l*f,l,0)}}lineAt(e,t,i,r,s){if(t==qe.ByHeight)return this.blockAt(e,i,r,s);if(t==qe.ByPosNoHeight){let{from:w,to:v}=i.doc.lineAt(e);return new Bi(w,v-w,0,0,0)}let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,s),f=i.doc.lineAt(e),u=l+f.length*h,g=f.number-o,y=r+l*g+h*(f.from-s-g);return new Bi(f.from,f.length,Math.max(r,Math.min(y,r+this.height-u)),u,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:h,perChar:f}=this.heightMetrics(i,s);for(let u=e,g=r;u<=t;){let y=i.doc.lineAt(u);if(u==e){let v=y.number-l;g+=h*v+f*(e-s-v)}let w=h+f*y.length;o(new Bi(y.from,y.length,g,w,0)),g+=w,u=y.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof mt?i[i.length-1]=new mt(s.length+r):i.push(null,new mt(r-1))}if(e>0){let s=i[0];s instanceof mt?i[0]=new mt(e+s.length):i.unshift(new mt(e-1),null)}return Lt.of(i)}decomposeLeft(e,t){t.push(new mt(e-1),null)}decomposeRight(e,t){t.push(null,new mt(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),h=-1;for(r.from>t&&o.push(new mt(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let u=e.doc.lineAt(l).length;o.length&&o.push(null);let g=r.heights[r.index++];h==-1?h=g:Math.abs(g-h)>=Bo&&(h=-2);let y=new Gt(u,g);y.outdated=!1,o.push(y),l+=u+1}l<=s&&o.push(null,new mt(s-l).updateHeight(e,l));let f=Lt.of(o);return(h<0||Math.abs(f.height-this.height)>=Bo||Math.abs(h-this.heightMetrics(e,t).perLine)>=Bo)&&(e.heightChanged=!0),f}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Vy extends Lt{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,h=t==qe.ByHeight?e<o:e<l,f=h?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(h?f.to<l:f.from>l))return f;let u=t==qe.ByPosNoHeight?qe.ByPosNoHeight:qe.ByPos;return h?f.join(this.right.lineAt(l,u,i,o,l)):this.left.lineAt(l,u,i,r,s).join(f)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,h=s+this.left.length+this.break;if(this.break)e<h&&this.left.forEachLine(e,t,i,r,s,o),t>=h&&this.right.forEachLine(e,t,i,l,h,o);else{let f=this.lineAt(h,qe.ByPos,i,r,s);e<f.from&&this.left.forEachLine(e,f.from-1,i,r,s,o),f.to>=e&&f.from<=t&&o(f),t>f.to&&this.right.forEachLine(f.to+1,t,i,l,h,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Tf(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Tf(s,l)}return Lt.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Lt.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,h=null;return r&&r.from<=t+s.length&&r.more?h=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?h=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),h?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Tf(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof mt&&(i=n[e+1])instanceof mt&&n.splice(e-1,3,new mt(t.length+1+i.length))}const Uy=5;class Vh{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Gt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Gt(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new pp(o,r,i)):(o||s||r>=Uy)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Gt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new mt(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Gt)return e;let t=new Gt(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Gt)&&!this.isCovered?this.nodes.push(new Gt(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Gt&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new Vh(i,e);return Ie.spans(t,i,r,s,0),s.finish(i)}}function Qy(n,e,t){let i=new Gy;return Ie.compare(n,e,t,i,0),i.changes}class Gy{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&Za(e,t,this.changes,5)}}function Ky(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),h=Math.min(r.innerHeight,t.bottom);for(let f=n.parentNode;f&&f!=i.body;)if(f.nodeType==1){let u=f,g=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&g.overflow!="visible"){let y=u.getBoundingClientRect();s=Math.max(s,y.left),o=Math.min(o,y.right),l=Math.max(l,y.top),h=f==n.parentNode?y.bottom:Math.min(h,y.bottom)}f=g.position=="absolute"||g.position=="fixed"?u.offsetParent:u.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,h)-(t.top+e)}}function Xy(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class la{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return de.replace({widget:new Yy(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Yy extends On{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Of{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ef,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ue.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(qh).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new qy(t),this.stateDeco=e.facet(ps).filter(i=>typeof i!="function"),this.heightMap=Lt.empty().applyChanges(this.stateDeco,Re.empty,this.heightOracle.setDoc(e.doc),[new ai(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=de.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new ho(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?Ef:new eb(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:es(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ps).filter(u=>typeof u!="function");let r=e.changedRanges,s=ai.extendWithRanges(r,Qy(i,this.stateDeco,e?e.changes:nt.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<h.from||t.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,t));let f=!e.changes.empty||e.flags&2||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),f&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ud)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Ue.RTL:Ue.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let f=0,u=0;if(l.width&&l.height){let{scaleX:V,scaleY:z}=Td(t,l);(this.scaleX!=V||this.scaleY!=z)&&(this.scaleX=V,this.scaleY=z,f|=8,o=h=!0)}let g=(parseInt(i.paddingTop)||0)*this.scaleY,y=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=g||this.paddingBottom!=y)&&(this.paddingTop=g,this.paddingBottom=y,f|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=8);let w=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=w&&(this.scrollAnchorHeight=-1,this.scrollTop=w),this.scrolledToBottom=Md(e.scrollDOM);let v=(this.printing?Xy:Ky)(t,this.paddingTop),A=v.top-this.pixelViewport.top,O=v.bottom-this.pixelViewport.bottom;this.pixelViewport=v;let R=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(R!=this.inView&&(this.inView=R,R&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let F=l.width;if((this.contentDOMWidth!=F||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,f|=8),h){let V=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(V)&&(o=!0),o||r.lineWrapping&&Math.abs(F-this.contentDOMWidth)>r.charWidth){let{lineHeight:z,charWidth:G,textHeight:p}=e.docView.measureTextSize();o=z>0&&r.refresh(s,z,G,p,F/G,V),o&&(e.docView.minWidth=0,f|=8)}A>0&&O>0?u=Math.max(A,O):A<0&&O<0&&(u=Math.min(A,O)),r.heightChanged=!1;for(let z of this.viewports){let G=z.from==this.viewport.from?V:e.docView.measureVisibleLineHeights(z);this.heightMap=(o?Lt.empty().applyChanges(this.stateDeco,Re.empty,this.heightOracle,[new ai(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new jy(z.from,G))}r.heightChanged&&(f|=2)}let W=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return W&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(f&2||W)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,h=new ho(r.lineAt(o-i*1e3,qe.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,qe.ByHeight,s,0,0).to);if(t){let{head:f}=t.range;if(f<h.from||f>h.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),g=r.lineAt(f,qe.ByPos,s,0,0),y;t.y=="center"?y=(g.top+g.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&f<h.from?y=g.top:y=g.bottom-u,h=new ho(r.lineAt(y-1e3/2,qe.ByHeight,s,0,0).from,r.lineAt(y+u+1e3/2,qe.ByHeight,s,0,0).to)}}return h}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new ho(this.heightMap.lineAt(i,qe.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,qe.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,qe.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,qe.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new la(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Ue.LTR&&!i)return[];let l=[],h=(f,u,g,y)=>{if(u-f<s)return;let w=this.state.selection.main,v=[w.from];w.empty||v.push(w.to);for(let O of v)if(O>f&&O<u){h(f,O-10,g,y),h(O+10,u,g,y);return}let A=Zy(e,O=>O.from>=g.from&&O.to<=g.to&&Math.abs(O.from-f)<s&&Math.abs(O.to-u)<s&&!v.some(R=>O.from<R&&O.to>R));if(!A){if(u<g.to&&t&&i&&t.visibleRanges.some(O=>O.from<=u&&O.to>=u)){let O=t.moveToLineBoundary(H.cursor(u),!1,!0).head;O>f&&(u=O)}A=new la(f,u,this.gapSize(g,f,u,y))}l.push(A)};for(let f of this.viewportLines){if(f.length<o)continue;let u=Jy(f.from,f.to,this.stateDeco);if(u.total<o)continue;let g=this.scrollTarget?this.scrollTarget.range.head:null,y,w;if(i){let v=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,A,O;if(g!=null){let R=fo(u,g),F=((this.visibleBottom-this.visibleTop)/2+v)/f.height;A=R-F,O=R+F}else A=(this.visibleTop-f.top-v)/f.height,O=(this.visibleBottom-f.top+v)/f.height;y=co(u,A),w=co(u,O)}else{let v=u.total*this.heightOracle.charWidth,A=r*this.heightOracle.charWidth,O,R;if(g!=null){let F=fo(u,g),W=((this.pixelViewport.right-this.pixelViewport.left)/2+A)/v;O=F-W,R=F+W}else O=(this.pixelViewport.left-A)/v,R=(this.pixelViewport.right+A)/v;y=co(u,O),w=co(u,R)}y>f.from&&h(f.from,y,f,u),w<f.to&&h(w,f.to,f,u)}return l}gapSize(e,t,i,r){let s=fo(r,i)-fo(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){la.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=de.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||es(this.heightMap.lineAt(e,qe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return es(this.heightMap.lineAt(this.scaler.fromDOM(e),qe.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return es(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ho{constructor(e,t){this.from=e,this.to=t}}function Jy(n,e,t){let i=[],r=n,s=0;return Ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function co({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function fo(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Zy(n,e){for(let t of n)if(e(t))return t}const Ef={toDOM(n){return n},fromDOM(n){return n},scale:1};class eb{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:h})=>{let f=t.lineAt(l,qe.ByPos,e,0,0).top,u=t.lineAt(h,qe.ByPos,e,0,0).bottom;return r+=u-f,{from:l,to:h,top:f,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}}function es(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Bi(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>es(r,e)):n._content)}const uo=ee.define({combine:n=>n.join(" ")}),lh=ee.define({combine:n=>n.indexOf(!0)>-1}),ah=vn.newName(),gp=vn.newName(),mp=vn.newName(),yp={"&light":"."+gp,"&dark":"."+mp};function hh(n,e,t){return new vn(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}const tb=hh("."+ah,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},yp),ts="";class ib{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(De.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ts}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=je.get(r),h=je.get(o);(l&&h?l.breakAfter:(l?l.breakAfter:Mf(r))||Mf(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let h of this.points)h.node==e&&h.pos>this.text.length&&(h.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=je.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(nb(e,i.node,i.offset)?t:0))}}function nb(n,e,t){for(;;){if(!e||t<Yi(e))return!1;if(e==n)return!0;t=ds(e)+1,e=e.parentNode}}function Mf(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}class Df{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class rb{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:lb(e),h=new ib(l,e.state);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=ab(l,this.bounds.from)}else{let l=e.observer.selectionRange,h=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Qa(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),f=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Qa(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=H.single(f,h)}}}function bp(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,h=r.from,f=null;(s===8||ie.android&&e.text.length<l-o)&&(h=r.to,f="end");let u=ob(n.state.doc.sliceString(o,l,ts),e.text,h-o,f);u&&(ie.chrome&&s==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==ts+ts&&u.toB--,t={from:o+u.from,to:o+u.toA,insert:Re.of(e.text.slice(u.from,u.toB).split(ts))})}else i&&(!n.hasFocus&&n.state.facet(kl)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(ie.mac||ie.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=H.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Re.of([" "])}):ie.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
 `&&n.lineWrapping&&(i&&(i=H.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Re.of([" "])}),t){if(ie.ios&&n.inputState.flushIOSKey()||ie.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&dr(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&dr(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&dr(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,h=()=>l||(l=sb(n,t,i));return n.state.facet(qd).some(f=>f(n,t.from,t.to,o,h))||n.dispatch(h()),!0}else if(i&&!i.main.eq(r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function sb(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let l=r.changes(e),h=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let f=n.state.sliceDoc(e.from,e.to),u,g=t&&ip(n,t.main.head);if(g){let v=e.insert.length-(e.to-e.from);u={from:g.from,to:g.to-v}}else u=n.state.doc.lineAt(s.head);let y=s.to-e.to,w=s.to-s.from;i=r.changeByRange(v=>{if(v.from==s.from&&v.to==s.to)return{changes:l,range:h||v.map(l)};let A=v.to-y,O=A-f.length;if(v.to-v.from!=w||n.state.sliceDoc(O,A)!=f||v.to>=u.from&&v.from<=u.to)return{range:v};let R=r.changes({from:O,to:A,insert:e.insert}),F=v.to-s.to;return{changes:R,range:h?H.range(Math.max(0,h.anchor+F),Math.max(0,h.head+F)):v.map(R)}})}else i={changes:l,selection:h&&r.selection.replaceRange(h)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function ob(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let h=Math.max(0,s-Math.min(o,l));t-=o+h-s}if(o<s&&n.length<e.length){let h=t<=s&&t>=o?s-t:0;s-=h,l=s+(l-o),o=s}else if(l<s){let h=t<=s&&t>=l?s-t:0;s-=h,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function lb(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Df(t,i)),(r!=t||s!=i)&&e.push(new Df(r,s))),e}function ab(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?H.single(t+e,i+e):null}const hb={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},aa=ie.ie&&ie.ie_version<=11;class cb{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Q0,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(ie.ie&&ie.ie_version<=11||ie.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),aa&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(kl)?i.root.activeElement!=this.dom:!Io(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(ie.ie&&ie.ie_version<=11||ie.android&&ie.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Uo(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ie.safari&&e.root.nodeType==11&&q0(this.dom.ownerDocument)==this.dom&&fb(this.view)||Vo(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=Io(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&K0(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,hb),aa&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),aa&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&dr(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Io(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new rb(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=bp(this.view,t);return this.view.state==i&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=Rf(t,e.previousSibling||e.target.previousSibling,-1),r=Rf(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Rf(n,e,t){for(;e;){let i=je.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function fb(n){let e=null;function t(h){h.preventDefault(),h.stopImmediatePropagation(),e=h.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return Uo(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}class te{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||G0(e.parent)||document,this.viewState=new Of(e.state||De.create(e)),e.scrollTo&&e.scrollTo.is(oo)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Jr).map(i=>new ra(i));for(let i of this.plugins)i.update(this);this.observer=new cb(this),this.inputState=new Ty(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hf(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof rt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let y of e){if(y.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=y.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,h=null;e.some(y=>y.annotation(fp))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=up(s,o),h||(l=1));let f=this.observer.delayedAndroidKey,u=null;if(f?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(De.phrases)!=this.state.facet(De.phrases))return this.setState(s);r=Qo.create(this,s,e),r.flags|=l;let g=this.viewState.scrollTarget;try{this.updateState=2;for(let y of e){if(g&&(g=g.map(y.changes)),y.scrollIntoView){let{main:w}=y.state.selection;g=new pr(w.empty?w:H.cursor(w.head,w.head>w.anchor?-1:1))}for(let w of y.effects)w.is(oo)&&(g=w.value.clip(this.state))}this.viewState.update(r,g),this.bidiCache=Go.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Zr)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(y=>y.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(uo)!=r.state.facet(uo)&&(this.viewState.mustMeasureContent=!0),(t||i||g||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let y of this.state.facet(eh))try{y(r)}catch(w){li(this.state,w,"update listener")}(h||u)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),u&&!bp(this,u)&&f.force&&dr(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Of(e),this.plugins=e.facet(Jr).map(i=>new ra(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new hf(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Jr),i=e.state.facet(Jr);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new ra(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Md(i))s=-1,o=this.viewState.heightMap.height;else{let w=this.viewState.scrollAnchorAt(r);s=w.from,o=w.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];h&4||([this.measureRequests,f]=[f,this.measureRequests]);let u=f.map(w=>{try{return w.read(this)}catch(v){return li(this.state,v),Lf}}),g=Qo.create(this,this.state,[]),y=!1;g.flags|=h,t?t.flags|=h:t=g,this.updateState=2,g.empty||(this.updatePlugins(g),this.inputState.update(g),this.updateAttrs(),y=this.docView.update(g));for(let w=0;w<f.length;w++)if(u[w]!=Lf)try{let v=f[w];v.write&&v.write(u[w],this)}catch(v){li(this.state,v)}if(y&&this.docView.updateSelection(!0),!g.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let v=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(v>1||v<-1){r=r+v,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(eh))l(t)}get themeClasses(){return ah+" "+(this.state.facet(lh)?mp:gp)+" "+this.state.facet(uo)}updateAttrs(){let e=Pf(this,Qd,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(kl)?"true":"false",class:"cm-content",style:`${ie.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Pf(this,qh,t);let i=this.observer.ignore(()=>{let r=Ja(this.contentDOM,this.contentAttrs,t),s=Ja(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(te.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Zr);let e=this.state.facet(te.cspNonce);vn.mount(this.root,this.styleModules.concat(tb).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return oa(this,e,gf(this,e,t,i))}moveByGroup(e,t){return oa(this,e,gf(this,e,t,i=>Cy(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return Sy(this,e,t,i)}moveVertically(e,t,i){return oa(this,e,Ay(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),rp(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[mn.find(s,e-r.from,-1,t)];return zh(i,o.dir==Ue.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Vd)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ub)return ep(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Zd(s.isolates,i=af(this,e.from,e.to))))return s.order;i||(i=af(this,e.from,e.to));let r=hy(e.text,t,i);return this.bidiCache.push(new Go(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ie.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Od(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return oo.of(new pr(typeof e=="number"?H.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return oo.of(new pr(H.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return st.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return st.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=vn.newName(),r=[uo.of(i),Zr.of(hh(`.${i}`,e))];return t&&t.dark&&r.push(lh.of(!0)),r}static baseTheme(e){return Kn.lowest(Zr.of(hh("."+ah,e,yp)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&je.get(i)||je.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}}te.styleModule=Zr;te.inputHandler=qd;te.focusChangeEffect=jd;te.perLineTextDirection=Vd;te.exceptionSink=Wd;te.updateListener=eh;te.editable=kl;te.mouseSelectionStyle=$d;te.dragMovesSelection=zd;te.clickAddsSelectionRange=Fd;te.decorations=ps;te.atomicRanges=jh;te.bidiIsolatedRanges=Gd;te.scrollMargins=Kd;te.darkTheme=lh;te.cspNonce=ee.define({combine:n=>n.length?n[0]:""});te.contentAttributes=qh;te.editorAttributes=Qd;te.lineWrapping=te.contentAttributes.of({class:"cm-lineWrapping"});te.announce=be.define();const ub=4096,Lf={};class Go{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:Ue.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new Go(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Pf(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Ya(o,t)}return t}const db=ie.mac?"mac":ie.windows?"win":ie.linux?"linux":"key";function pb(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let h=0;h<t.length-1;++h){const f=t[h];if(/^(cmd|meta|m)$/i.test(f))l=!0;else if(/^a(lt)?$/i.test(f))r=!0;else if(/^(c|ctrl|control)$/i.test(f))s=!0;else if(/^s(hift)?$/i.test(f))o=!0;else if(/^mod$/i.test(f))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+f)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function po(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const gb=Kn.default(te.domEventHandlers({keydown(n,e){return wp(xp(e.state),n,e,"editor")}})),vl=ee.define({enables:gb}),If=new WeakMap;function xp(n){let e=n.facet(vl),t=If.get(e);return t||If.set(e,t=bb(e.reduce((i,r)=>i.concat(r),[]))),t}function mb(n,e,t){return wp(xp(n.state),e,n,t)}let dn=null;const yb=4e3;function bb(n,e=db){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,h,f,u)=>{var g,y;let w=t[o]||(t[o]=Object.create(null)),v=l.split(/ (?!$)/).map(R=>pb(R,e));for(let R=1;R<v.length;R++){let F=v.slice(0,R).join(" ");r(F,!0),w[F]||(w[F]={preventDefault:!0,stopPropagation:!1,run:[W=>{let V=dn={view:W,prefix:F,scope:o};return setTimeout(()=>{dn==V&&(dn=null)},yb),!0}]})}let A=v.join(" ");r(A,!1);let O=w[A]||(w[A]={preventDefault:!1,stopPropagation:!1,run:((y=(g=w._any)===null||g===void 0?void 0:g.run)===null||y===void 0?void 0:y.slice())||[]});h&&O.run.push(h),f&&(O.preventDefault=!0),u&&(O.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of l){let u=t[f]||(t[f]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let g in u)u[g].run.push(o.any)}let h=o[e]||o.key;if(h)for(let f of l)s(f,h,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(f,"Shift-"+h,o.shift,o.preventDefault,o.stopPropagation)}return t}function wp(n,e,t,i){let r=W0(e),s=yt(r,0),o=si(s)==r.length&&r!=" ",l="",h=!1,f=!1,u=!1;dn&&dn.view==t&&dn.scope==i&&(l=dn.prefix+" ",op.indexOf(e.keyCode)<0&&(f=!0,dn=null));let g=new Set,y=O=>{if(O){for(let R of O.run)if(!g.has(R)&&(g.add(R),R(t,e)))return O.stopPropagation&&(u=!0),!0;O.preventDefault&&(O.stopPropagation&&(u=!0),f=!0)}return!1},w=n[i],v,A;return w&&(y(w[l+po(r,e,!o)])?h=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ie.windows&&e.ctrlKey&&e.altKey)&&(v=Sn[e.keyCode])&&v!=r?(y(w[l+po(v,e,!0)])||e.shiftKey&&(A=fs[e.keyCode])!=r&&A!=v&&y(w[l+po(A,e,!1)]))&&(h=!0):o&&e.shiftKey&&y(w[l+po(r,e,!0)])&&(h=!0),!h&&y(w._any)&&(h=!0)),f&&(h=!0),h&&u&&e.stopPropagation(),h}class Es{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=kp(e);return[new Es(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return xb(e,t,i)}}function kp(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==Ue.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Nf(n,e,t){let i=H.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Rt.Text}}function xb(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==Ue.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),h=kp(n),f=o.querySelector(".cm-line"),u=f&&window.getComputedStyle(f),g=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),y=l.right-(u?parseInt(u.paddingRight):0),w=sh(n,i),v=sh(n,r),A=w.type==Rt.Text?w:null,O=v.type==Rt.Text?v:null;if(A&&(n.lineWrapping||w.widgetLineBreaks)&&(A=Nf(n,i,A)),O&&(n.lineWrapping||v.widgetLineBreaks)&&(O=Nf(n,r,O)),A&&O&&A.from==O.from)return F(W(t.from,t.to,A));{let z=A?W(t.from,null,A):V(w,!1),G=O?W(null,t.to,O):V(v,!0),p=[];return(A||w).to<(O||v).from-(A&&O?1:0)||w.widgetLineBreaks>1&&z.bottom+n.defaultLineHeight/2<G.top?p.push(R(g,z.bottom,y,G.top)):z.bottom<G.top&&n.elementAtHeight((z.bottom+G.top)/2).type==Rt.Text&&(z.bottom=G.top=(z.bottom+G.top)/2),F(z).concat(p).concat(F(G))}function R(z,G,p,he){return new Es(e,z-h.left,G-h.top-.01,p-z,he-G+.01)}function F({top:z,bottom:G,horizontal:p}){let he=[];for(let Z=0;Z<p.length;Z+=2)he.push(R(p[Z],z,p[Z+1],G));return he}function W(z,G,p){let he=1e9,Z=-1e9,ae=[];function pe(xe,Be,ot,_e,Ze){let Qe=n.coordsAtPos(xe,xe==p.to?-2:2),me=n.coordsAtPos(ot,ot==p.from?2:-2);!Qe||!me||(he=Math.min(Qe.top,me.top,he),Z=Math.max(Qe.bottom,me.bottom,Z),Ze==Ue.LTR?ae.push(s&&Be?g:Qe.left,s&&_e?y:me.right):ae.push(!s&&_e?g:me.left,!s&&Be?y:Qe.right))}let fe=z!=null?z:p.from,ne=G!=null?G:p.to;for(let xe of n.visibleRanges)if(xe.to>fe&&xe.from<ne)for(let Be=Math.max(xe.from,fe),ot=Math.min(xe.to,ne);;){let _e=n.state.doc.lineAt(Be);for(let Ze of n.bidiSpans(_e)){let Qe=Ze.from+_e.from,me=Ze.to+_e.from;if(Qe>=ot)break;me>Be&&pe(Math.max(Qe,Be),z==null&&Qe<=fe,Math.min(me,ot),G==null&&me>=ne,Ze.dir)}if(Be=_e.to+1,Be>=ot)break}return ae.length==0&&pe(fe,z==null,ne,G==null,n.textDirection),{top:he,bottom:Z,horizontal:ae}}function V(z,G){let p=l.top+(G?z.top:z.bottom);return{top:p,bottom:p,horizontal:[]}}}function wb(n,e){return n.constructor==e.constructor&&n.eq(e)}class kb{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(_o)!=e.state.facet(_o)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}setOrder(e){let t=0,i=e.facet(_o);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!wb(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const _o=ee.define();function vp(n){return[st.define(e=>new kb(e,n)),_o.of(n)]}const Sp=!ie.ios,ms=ee.define({combine(n){return Wi(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function vb(n={}){return[ms.of(n),Sb,Cb,Ab,Ud.of(!0)]}function Cp(n){return n.startState.facet(ms)!=n.state.facet(ms)}const Sb=vp({above:!0,markers(n){let{state:e}=n,t=e.facet(ms),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||Sp:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:H.cursor(r.head,r.head>r.anchor?-1:1);for(let h of Es.forRange(n,o,l))i.push(h)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Cp(n);return t&&Bf(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Bf(e.state,n)},class:"cm-cursorLayer"});function Bf(n,e){e.style.animationDuration=n.facet(ms).cursorBlinkRate+"ms"}const Cb=vp({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:Es.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Cp(n)},class:"cm-selectionLayer"}),ch={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Sp&&(ch[".cm-line"].caretColor="transparent !important",ch[".cm-content"]={caretColor:"transparent !important"});const Ab=Kn.highest(te.theme(ch)),Ap=be.define({map(n,e){return n==null?null:e.mapPos(n)}}),is=wt.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Ap)?i.value:t,n)}}),Tb=st.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(is);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(is)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(is),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(is)!=n&&this.view.dispatch({effects:Ap.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Ob(){return[is,Tb]}function _f(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function Eb(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class Mb{constructor(e){const{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,h,f,u)=>r(u,f,f+l[0].length,l,h);else if(typeof i=="function")this.addMatch=(l,h,f,u)=>{let g=i(l,h,f);g&&u(f,f+l[0].length,g)};else if(i)this.addMatch=(l,h,f,u)=>u(f,f+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new kn,i=t.add.bind(t);for(let{from:r,to:s}of Eb(e,this.maxLength))_f(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,h)=>{h>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(h,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let h=e.state.doc.lineAt(o),f=h.to<l?e.state.doc.lineAt(l):h,u=Math.max(s.from,h.from),g=Math.min(s.to,f.to);if(this.boundary){for(;o>h.from;o--)if(this.boundary.test(h.text[o-1-h.from])){u=o;break}for(;l<f.to;l++)if(this.boundary.test(f.text[l-f.from])){g=l;break}}let y=[],w,v=(A,O,R)=>y.push(R.range(A,O));if(h==f)for(this.regexp.lastIndex=u-h.from;(w=this.regexp.exec(h.text))&&w.index<g-h.from;)this.addMatch(w,e,w.index+h.from,v);else _f(e.state.doc,this.regexp,u,g,(A,O)=>this.addMatch(O,e,A,v));t=t.update({filterFrom:u,filterTo:g,filter:(A,O)=>A<u||O>g,add:y})}}return t}}const fh=/x/.unicode!=null?"gu":"g",Db=new RegExp(`[\0-\b
--­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF￹-￼]`,fh),Rb={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ha=null;function Lb(){var n;if(ha==null&&typeof document!="undefined"&&document.body){let e=document.body.style;ha=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return ha||!1}const Ho=ee.define({combine(n){let e=Wi(n,{render:null,specialChars:Db,addSpecialChars:null});return(e.replaceTabs=!Lb())&&(e.specialChars=new RegExp("	|"+e.specialChars.source,fh)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,fh)),e}});function Pb(n={}){return[Ho.of(n),Ib()]}let Hf=null;function Ib(){return Hf||(Hf=st.fromClass(class{constructor(n){this.view=n,this.decorations=de.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Ho)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Mb({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=yt(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,h=As(o.text,l,i-o.from);return de.replace({widget:new Hb((l-h%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=de.replace({widget:new _b(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Ho);n.startState.facet(Ho)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const Nb="•";function Bb(n){return n>=32?Nb:n==10?"␤":String.fromCharCode(9216+n)}class _b extends On{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Bb(this.code),i=e.state.phrase("Control character")+" "+(Rb[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class Hb extends On{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="	",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function Fb(){return $b}const zb=de.line({class:"cm-activeLine"}),$b=st.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(zb.range(r.from)),e=r.from)}return de.set(t)}},{decorations:n=>n.decorations}),qr="-10000px";class Tp{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(h=>h);if(r===this.input){for(let h of this.tooltipViews)h.update&&h.update(e);return!1}let o=[],l=t?[]:null;for(let h=0;h<s.length;h++){let f=s[h],u=-1;if(f){for(let g=0;g<this.tooltips.length;g++){let y=this.tooltips[g];y&&y.create==f.create&&(u=g)}if(u<0)o[h]=this.createTooltipView(f),l&&(l[h]=!!f.above);else{let g=o[h]=this.tooltipViews[u];l&&(l[h]=t[u]),g.update&&g.update(e)}}}for(let h of this.tooltipViews)o.indexOf(h)<0&&(h.dom.remove(),(i=h.destroy)===null||i===void 0||i.call(h));return t&&(l.forEach((h,f)=>t[f]=h),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function Wb(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const ca=ee.define({combine:n=>{var e,t,i;return{position:ie.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Wb}}}),Ff=new WeakMap,Uh=st.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(ca);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Tp(n,Qh,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(ca);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=qr,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(ie.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==qr&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(ca).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let h=this.manager.tooltips[l],f=this.manager.tooltipViews[l],{dom:u}=f,g=n.pos[l],y=n.size[l];if(!g||g.bottom<=Math.max(t.top,i.top)||g.top>=Math.min(t.bottom,i.bottom)||g.right<Math.max(t.left,i.left)-.1||g.left>Math.min(t.right,i.right)+.1){u.style.top=qr;continue}let w=h.arrow?f.dom.querySelector(".cm-tooltip-arrow"):null,v=w?7:0,A=y.right-y.left,O=(e=Ff.get(f))!==null&&e!==void 0?e:y.bottom-y.top,R=f.offset||jb,F=this.view.textDirection==Ue.LTR,W=y.width>i.right-i.left?F?i.left:i.right-y.width:F?Math.min(g.left-(w?14:0)+R.x,i.right-A):Math.max(i.left,g.left-A+(w?14:0)-R.x),V=this.above[l];!h.strictSide&&(V?g.top-(y.bottom-y.top)-R.y<i.top:g.bottom+(y.bottom-y.top)+R.y>i.bottom)&&V==i.bottom-g.bottom>g.top-i.top&&(V=this.above[l]=!V);let z=(V?g.top-i.top:i.bottom-g.bottom)-v;if(z<O&&f.resize!==!1){if(z<this.view.defaultLineHeight){u.style.top=qr;continue}Ff.set(f,O),u.style.height=(O=z)/s+"px"}else u.style.height&&(u.style.height="");let G=V?g.top-O-v-R.y:g.bottom+v+R.y,p=W+A;if(f.overlap!==!0)for(let he of o)he.left<p&&he.right>W&&he.top<G+O&&he.bottom>G&&(G=V?he.top-O-2-v:he.bottom+v+2);if(this.position=="absolute"?(u.style.top=(G-n.parent.top)/s+"px",u.style.left=(W-n.parent.left)/r+"px"):(u.style.top=G/s+"px",u.style.left=W/r+"px"),w){let he=g.left+(F?R.x:-R.x)-(W+14-7);w.style.left=he/r+"px"}f.overlap!==!0&&o.push({left:W,top:G,right:p,bottom:G+O}),u.classList.toggle("cm-tooltip-above",V),u.classList.toggle("cm-tooltip-below",!V),f.positioned&&f.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=qr}},{eventObservers:{scroll(){this.maybeMeasure()}}}),qb=te.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),jb={x:0,y:0},Qh=ee.define({enables:[Uh,qb]}),Ko=ee.define();class Sl{static create(e){return new Sl(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tp(e,Ko,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Vb=Qh.compute([Ko],n=>{let e=n.facet(Ko).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Sl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Ub{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof gn)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let h=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),f=h&&h.dir==Ue.RTL?-1:1;s=t.x<l.left?-f:f}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(h=>{this.pending==l&&(this.pending=null,h&&e.dispatch({effects:this.setHover.of(h)}))},h=>li(e.state,h,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(Uh),t=e?e.manager.tooltips.findIndex(i=>i.create==Sl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i&&r&&!Qb(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!Gb(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const go=4;function Qb(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-go&&e.clientX<=t.right+go&&e.clientY>=t.top-go&&e.clientY<=t.bottom+go}function Gb(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let h=n.posAtCoords({x:i,y:r},!1);return h>=e&&h<=t}function Kb(n,e={}){let t=be.define(),i=wt.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Dt.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(Xb)&&(r=null);return r},provide:r=>Ko.from(r)});return[i,st.define(r=>new Ub(r,n,i,t,e.hoverTime||300)),Vb]}function Op(n,e){let t=n.plugin(Uh);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Xb=be.define(),zf=ee.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ys(n,e){let t=n.plugin(Ep),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Ep=st.fromClass(class{constructor(n){this.input=n.state.facet(bs),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(zf);this.top=new mo(n,!0,e.topContainer),this.bottom=new mo(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(zf);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new mo(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new mo(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(bs);if(t!=this.input){let i=t.filter(h=>h),r=[],s=[],o=[],l=[];for(let h of i){let f=this.specs.indexOf(h),u;f<0?(u=h(n.view),l.push(u)):(u=this.panels[f],u.update&&u.update(n)),r.push(u),(u.top?s:o).push(u)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let h of l)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>te.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class mo{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=$f(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=$f(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function $f(n){let e=n.nextSibling;return n.remove(),e}const bs=ee.define({enables:Ep});class en extends jn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}en.prototype.elementClass="";en.prototype.toDOM=void 0;en.prototype.mapMode=Dt.TrackBefore;en.prototype.startSide=en.prototype.endSide=-1;en.prototype.point=!0;const Fo=ee.define(),Yb={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},os=ee.define();function Jb(n){return[Mp(),os.of(Object.assign(Object.assign({},Yb),n))]}const Wf=ee.define({combine:n=>n.some(e=>e)});function Mp(n){return[Zb]}const Zb=st.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(os).map(e=>new jf(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Wf),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Wf)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=Ie.iter(this.view.state.facet(Fo),this.view.viewport.from),i=[],r=this.gutters.map(s=>new ex(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Rt.Text&&o){uh(t,i,l.from);for(let h of r)h.line(this.view,l,i);o=!1}else if(l.widget)for(let h of r)h.widget(this.view,l)}else if(s.type==Rt.Text){uh(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(os),t=n.state.facet(os),i=n.docChanged||n.heightChanged||n.viewportChanged||!Ie.eq(n.startState.facet(Fo),n.state.facet(Fo),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new jf(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>te.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Ue.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function qf(n){return Array.isArray(n)?n:[n]}function uh(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class ex{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Dp(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];uh(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class jf{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let h=s.getBoundingClientRect();o=(h.top+h.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=qf(t.markers(e)),t.initialSpacer&&(this.spacer=new Dp(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=qf(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!Ie.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Dp{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),tx(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,h=s<t.length?t[s++]:null,f=!1;if(h){let u=h.elementClass;u&&(i+=" "+u);for(let g=o;g<this.markers.length;g++)if(this.markers[g].compare(h)){l=g,f=!0;break}}else l=this.markers.length;for(;o<l;){let u=this.markers[o++];if(u.toDOM){u.destroy(r);let g=r.nextSibling;r.remove(),r=g}}if(!h)break;h.toDOM&&(f?r=r.nextSibling:this.dom.insertBefore(h.toDOM(e),r)),f&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function tx(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const ix=ee.define(),ar=ee.define({combine(n){return Wi(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,h,f)=>s(l,h,f)||o(l,h,f):o}return i}})}});class fa extends en{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ua(n,e){return n.state.facet(ar).formatNumber(e,n.state)}const nx=os.compute([ar],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(ix)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new fa(ua(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(ar)!=e.state.facet(ar),initialSpacer(e){return new fa(ua(e,Vf(e.state.doc.lines)))},updateSpacer(e,t){let i=ua(t.view,Vf(t.view.state.doc.lines));return i==e.number?e:new fa(i)},domEventHandlers:n.facet(ar).domEventHandlers}));function rx(n={}){return[ar.of(n),Mp(),nx]}function Vf(n){let e=9;for(;e<n;)e=e*10+9;return e}const sx=new class extends en{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},ox=Fo.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(sx.range(r)))}return Ie.of(e)});function lx(){return ox}const Rp=1024;let ax=0;class da{constructor(e,t){this.from=e,this.to=t}}class Ce{constructor(e={}){this.id=ax++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=qt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}Ce.closedBy=new Ce({deserialize:n=>n.split(" ")});Ce.openedBy=new Ce({deserialize:n=>n.split(" ")});Ce.group=new Ce({deserialize:n=>n.split(" ")});Ce.contextHash=new Ce({perNode:!0});Ce.lookAhead=new Ce({perNode:!0});Ce.mounted=new Ce({perNode:!0});class Xo{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Ce.mounted.id]}}const hx=Object.create(null);class qt{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):hx,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new qt(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(Ce.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(Ce.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}}qt.none=new qt("",Object.create(null),0,8);class Gh{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new qt(i.name,r,i.id,i.flags):i)}return new Gh(t)}}const yo=new WeakMap,Uf=new WeakMap;var ht;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ht||(ht={}));class Je{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Xo.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ph(this.topNode,e)}cursorAt(e,t=0,i=0){let r=yo.get(this)||this.topNode,s=new ph(r);return s.moveTo(e,t),yo.set(this,s._tree),s}get topNode(){return new hi(this,0,0,null)}resolve(e,t=0){let i=xs(yo.get(this)||this.topNode,e,t,!1);return yo.set(this,i),i}resolveInner(e,t=0){let i=xs(Uf.get(this)||this.topNode,e,t,!0);return Uf.set(this,i),i}resolveStack(e,t=0){return ux(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ht.IncludeAnonymous)>0;for(let h=this.cursor(o|ht.IncludeAnonymous);;){let f=!1;if(h.from<=s&&h.to>=r&&(!l&&h.type.isAnonymous||t(h)!==!1)){if(h.firstChild())continue;f=!0}for(;f&&i&&(l||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.parent())return;f=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Yh(qt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new Je(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new Je(qt.none,t,i,r)))}static build(e){return dx(e)}}Je.empty=new Je(qt.none,[],[],0);class Kh{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Kh(this.buffer,this.index)}}class An{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return qt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let h=e;h!=t&&!(Lp(s,r,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,h=0;l<t;){s[h++]=r[l++],s[h++]=r[l++]-i;let f=s[h++]=r[l++]-i;s[h++]=r[l++]-e,o=Math.max(o,f)}return new An(s,o,this.set)}}function Lp(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function xs(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof hi&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ht.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof hi&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}class Pp{cursor(e=0){return new ph(this,e)}getChild(e,t=null,i=null){let r=Qf(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Qf(this,e,t,i)}resolve(e,t=0){return xs(this,e,t,!1)}resolveInner(e,t=0){return xs(this,e,t,!0)}matchContext(e){return dh(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}}class hi extends Pp{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,f=t>0?l.length:-1;e!=f;e+=t){let u=l[e],g=h[e]+o.from;if(Lp(r,i,g,g+u.length)){if(u instanceof An){if(s&ht.ExcludeBuffers)continue;let y=u.findChild(0,u.buffer.length,t,i-g,r);if(y>-1)return new yn(new cx(o,u,e,g),null,y)}else if(s&ht.IncludeAnonymous||!u.type.isAnonymous||Xh(u)){let y;if(!(s&ht.IgnoreMounts)&&(y=Xo.get(u))&&!y.overlay)return new hi(y.tree,g,e,o);let w=new hi(u,g,e,o);return s&ht.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?u.children.length-1:0,t,i,r)}}}if(s&ht.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let r;if(!(i&ht.IgnoreOverlays)&&(r=Xo.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new hi(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Qf(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function dh(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class cx{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}}class yn extends Pp{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new yn(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ht.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new yn(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new yn(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new yn(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new Je(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ip(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof hi&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new fx(r,t)}class fx{constructor(e,t){this.heads=e,this.node=t}get next(){return Ip(this.heads)}}function ux(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof hi?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Xo.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new hi(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(xs(l,e,t,!1))}}return r?Ip(r):i}class ph{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof hi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof hi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ht.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ht.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ht.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ht.IncludeAnonymous||l instanceof An||!l.type.isAnonymous||Xh(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new yn(this.buffer,t,this.stack[r]);return this.bufferNode=new yn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return dh(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return dh(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Xh(n){return n.children.some(e=>e instanceof An||!e.type.isAnonymous||Xh(e))}function dx(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=Rp,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Kh(t,t.length):t,h=i.types,f=0,u=0;function g(z,G,p,he,Z,ae){let{id:pe,start:fe,end:ne,size:xe}=l,Be=u;for(;xe<0;)if(l.next(),xe==-1){let me=s[pe];p.push(me),he.push(fe-z);return}else if(xe==-3){f=pe;return}else if(xe==-4){u=pe;return}else throw new RangeError(`Unrecognized record size: ${xe}`);let ot=h[pe],_e,Ze,Qe=fe-z;if(ne-fe<=r&&(Ze=O(l.pos-G,Z))){let me=new Uint16Array(Ze.size-Ze.skip),lt=l.pos-Ze.size,Oe=me.length;for(;l.pos>lt;)Oe=R(Ze.start,me,Oe);_e=new An(me,ne-Ze.start,i),Qe=Ze.start-z}else{let me=l.pos-xe;l.next();let lt=[],Oe=[],It=pe>=o?pe:-1,Ee=0,Zt=ne;for(;l.pos>me;)It>=0&&l.id==It&&l.size>=0?(l.end<=Zt-r&&(v(lt,Oe,fe,Ee,l.end,Zt,It,Be),Ee=lt.length,Zt=l.end),l.next()):ae>2500?y(fe,me,lt,Oe):g(fe,me,lt,Oe,It,ae+1);if(It>=0&&Ee>0&&Ee<lt.length&&v(lt,Oe,fe,Ee,fe,Zt,It,Be),lt.reverse(),Oe.reverse(),It>-1&&Ee>0){let nn=w(ot);_e=Yh(ot,lt,Oe,0,lt.length,0,ne-fe,nn,nn)}else _e=A(ot,lt,Oe,ne-fe,Be-ne)}p.push(_e),he.push(Qe)}function y(z,G,p,he){let Z=[],ae=0,pe=-1;for(;l.pos>G;){let{id:fe,start:ne,end:xe,size:Be}=l;if(Be>4)l.next();else{if(pe>-1&&ne<pe)break;pe<0&&(pe=xe-r),Z.push(fe,ne,xe),ae++,l.next()}}if(ae){let fe=new Uint16Array(ae*4),ne=Z[Z.length-2];for(let xe=Z.length-3,Be=0;xe>=0;xe-=3)fe[Be++]=Z[xe],fe[Be++]=Z[xe+1]-ne,fe[Be++]=Z[xe+2]-ne,fe[Be++]=Be;p.push(new An(fe,Z[2]-ne,i)),he.push(ne-z)}}function w(z){return(G,p,he)=>{let Z=0,ae=G.length-1,pe,fe;if(ae>=0&&(pe=G[ae])instanceof Je){if(!ae&&pe.type==z&&pe.length==he)return pe;(fe=pe.prop(Ce.lookAhead))&&(Z=p[ae]+pe.length+fe)}return A(z,G,p,he,Z)}}function v(z,G,p,he,Z,ae,pe,fe){let ne=[],xe=[];for(;z.length>he;)ne.push(z.pop()),xe.push(G.pop()+p-Z);z.push(A(i.types[pe],ne,xe,ae-Z,fe-ae)),G.push(Z-p)}function A(z,G,p,he,Z=0,ae){if(f){let pe=[Ce.contextHash,f];ae=ae?[pe].concat(ae):[pe]}if(Z>25){let pe=[Ce.lookAhead,Z];ae=ae?[pe].concat(ae):[pe]}return new Je(z,G,p,he,ae)}function O(z,G){let p=l.fork(),he=0,Z=0,ae=0,pe=p.end-r,fe={size:0,start:0,skip:0};e:for(let ne=p.pos-z;p.pos>ne;){let xe=p.size;if(p.id==G&&xe>=0){fe.size=he,fe.start=Z,fe.skip=ae,ae+=4,he+=4,p.next();continue}let Be=p.pos-xe;if(xe<0||Be<ne||p.start<pe)break;let ot=p.id>=o?4:0,_e=p.start;for(p.next();p.pos>Be;){if(p.size<0)if(p.size==-3)ot+=4;else break e;else p.id>=o&&(ot+=4);p.next()}Z=_e,he+=xe,ae+=ot}return(G<0||he==z)&&(fe.size=he,fe.start=Z,fe.skip=ae),fe.size>4?fe:void 0}function R(z,G,p){let{id:he,start:Z,end:ae,size:pe}=l;if(l.next(),pe>=0&&he<o){let fe=p;if(pe>4){let ne=l.pos-(pe-4);for(;l.pos>ne;)p=R(z,G,p)}G[--p]=fe,G[--p]=ae-z,G[--p]=Z-z,G[--p]=he}else pe==-3?f=he:pe==-4&&(u=he);return p}let F=[],W=[];for(;l.pos>0;)g(n.start||0,n.bufferStart||0,F,W,-1,0);let V=(e=n.length)!==null&&e!==void 0?e:F.length?W[0]+F[0].length:0;return new Je(h[n.topID],F.reverse(),W.reverse(),V)}const Gf=new WeakMap;function zo(n,e){if(!n.isAnonymous||e instanceof An||e.type!=n)return 1;let t=Gf.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof Je)){t=1;break}t+=zo(n,i)}Gf.set(e,t)}return t}function Yh(n,e,t,i,r,s,o,l,h){let f=0;for(let v=i;v<r;v++)f+=zo(n,e[v]);let u=Math.ceil(f*1.5/8),g=[],y=[];function w(v,A,O,R,F){for(let W=O;W<R;){let V=W,z=A[W],G=zo(n,v[W]);for(W++;W<R;W++){let p=zo(n,v[W]);if(G+p>=u)break;G+=p}if(W==V+1){if(G>u){let p=v[V];w(p.children,p.positions,0,p.children.length,A[V]+F);continue}g.push(v[V])}else{let p=A[W-1]+v[W-1].length-z;g.push(Yh(n,v,A,V,W,z,p,null,h))}y.push(z+F-s)}}return w(e,t,i,r,0),(l||h)(g,y,o)}class qn{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new qn(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,h=0,f=0;;l++){let u=l<t.length?t[l]:null,g=u?u.fromA:1e9;if(g-h>=i)for(;o&&o.from<g;){let y=o;if(h>=y.from||g<=y.to||f){let w=Math.max(y.from,h)-f,v=Math.min(y.to,g)-f;y=w>=v?null:new qn(w,v,y.tree,y.offset+f,l>0,!!u)}if(y&&r.push(y),o.to>g)break;o=s<e.length?e[s++]:null}if(!u)break;h=u.toA,f=u.toA-u.toB}return r}}class Np{startParse(e,t,i){return typeof e=="string"&&(e=new px(e)),i=i?i.length?i.map(r=>new da(r.from,r.to)):[new da(0,0)]:[new da(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}}class px{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Ce({perNode:!0});let gx=0;class Ii{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=gx++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new Ii([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Yo;return t=>t.modified.indexOf(e)>-1?t:Yo.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}}let mx=0;class Yo{constructor(){this.instances=[],this.id=mx++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&yx(t,l.modified));if(i)return i;let r=[],s=new Ii(r,e,t);for(let l of t)l.instances.push(s);let o=bx(t);for(let l of e.set)if(!l.modified.length)for(let h of o)r.push(Yo.get(l,h));return s}}function yx(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function bx(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Bp(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let g=0;;){if(l=="..."&&g>0&&g+3==r.length){o=1;break}let y=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!y)throw new RangeError("Invalid path: "+r);if(s.push(y[0]=="*"?"":y[0][0]=='"'?JSON.parse(y[0]):y[0]),g+=y[0].length,g==r.length)break;let w=r[g++];if(g==r.length&&w=="!"){o=0;break}if(w!="/")throw new RangeError("Invalid path: "+r);l=r.slice(g)}let h=s.length-1,f=s[h];if(!f)throw new RangeError("Invalid path: "+r);let u=new Jo(i,o,h>0?s.slice(0,h):null);e[f]=u.sort(e[f])}}return _p.add(e)}const _p=new Ce;class Jo{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Jo.empty=new Jo([],2,null);function Hp(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let h of l.set){let f=t[h.id];if(f){o=o?o+" "+f:f;break}}return o},scope:i}}function xx(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function wx(n,e,t,i=0,r=n.length){let s=new kx(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}class kx{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:h}=e;if(l>=i||h<=t)return;o.isTop&&(s=this.highlighters.filter(w=>!w.scope||w.scope(o)));let f=r,u=vx(e)||Jo.empty,g=xx(s,u.tags);if(g&&(f&&(f+=" "),f+=g,u.mode==1&&(r+=(r?" ":"")+g)),this.startSpan(Math.max(t,l),f),u.opaque)return;let y=e.tree&&e.tree.prop(Ce.mounted);if(y&&y.overlay){let w=e.node.enter(y.overlay[0].from+l,1),v=this.highlighters.filter(O=>!O.scope||O.scope(y.tree.type)),A=e.firstChild();for(let O=0,R=l;;O++){let F=O<y.overlay.length?y.overlay[O]:null,W=F?F.from+l:h,V=Math.max(t,R),z=Math.min(i,W);if(V<z&&A)for(;e.from<z&&(this.highlightRange(e,V,z,r,s),this.startSpan(Math.min(z,e.to),f),!(e.to>=W||!e.nextSibling())););if(!F||W>i)break;R=F.to+l,R>t&&(this.highlightRange(w.cursor(),Math.max(t,F.from+l),Math.min(i,R),"",v),this.startSpan(Math.min(i,R),f))}A&&e.parent()}else if(e.firstChild()){y&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),f)}while(e.nextSibling());e.parent()}}}function vx(n){let e=n.type.prop(_p);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const Q=Ii.define,bo=Q(),fn=Q(),Kf=Q(fn),Xf=Q(fn),un=Q(),xo=Q(un),pa=Q(un),Pi=Q(),In=Q(Pi),Ri=Q(),Li=Q(),gh=Q(),jr=Q(gh),wo=Q(),j={comment:bo,lineComment:Q(bo),blockComment:Q(bo),docComment:Q(bo),name:fn,variableName:Q(fn),typeName:Kf,tagName:Q(Kf),propertyName:Xf,attributeName:Q(Xf),className:Q(fn),labelName:Q(fn),namespace:Q(fn),macroName:Q(fn),literal:un,string:xo,docString:Q(xo),character:Q(xo),attributeValue:Q(xo),number:pa,integer:Q(pa),float:Q(pa),bool:Q(un),regexp:Q(un),escape:Q(un),color:Q(un),url:Q(un),keyword:Ri,self:Q(Ri),null:Q(Ri),atom:Q(Ri),unit:Q(Ri),modifier:Q(Ri),operatorKeyword:Q(Ri),controlKeyword:Q(Ri),definitionKeyword:Q(Ri),moduleKeyword:Q(Ri),operator:Li,derefOperator:Q(Li),arithmeticOperator:Q(Li),logicOperator:Q(Li),bitwiseOperator:Q(Li),compareOperator:Q(Li),updateOperator:Q(Li),definitionOperator:Q(Li),typeOperator:Q(Li),controlOperator:Q(Li),punctuation:gh,separator:Q(gh),bracket:jr,angleBracket:Q(jr),squareBracket:Q(jr),paren:Q(jr),brace:Q(jr),content:Pi,heading:In,heading1:Q(In),heading2:Q(In),heading3:Q(In),heading4:Q(In),heading5:Q(In),heading6:Q(In),contentSeparator:Q(Pi),list:Q(Pi),quote:Q(Pi),emphasis:Q(Pi),strong:Q(Pi),link:Q(Pi),monospace:Q(Pi),strikethrough:Q(Pi),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:wo,documentMeta:Q(wo),annotation:Q(wo),processingInstruction:Q(wo),definition:Ii.defineModifier(),constant:Ii.defineModifier(),function:Ii.defineModifier(),standard:Ii.defineModifier(),local:Ii.defineModifier(),special:Ii.defineModifier()};Hp([{tag:j.link,class:"tok-link"},{tag:j.heading,class:"tok-heading"},{tag:j.emphasis,class:"tok-emphasis"},{tag:j.strong,class:"tok-strong"},{tag:j.keyword,class:"tok-keyword"},{tag:j.atom,class:"tok-atom"},{tag:j.bool,class:"tok-bool"},{tag:j.url,class:"tok-url"},{tag:j.labelName,class:"tok-labelName"},{tag:j.inserted,class:"tok-inserted"},{tag:j.deleted,class:"tok-deleted"},{tag:j.literal,class:"tok-literal"},{tag:j.string,class:"tok-string"},{tag:j.number,class:"tok-number"},{tag:[j.regexp,j.escape,j.special(j.string)],class:"tok-string2"},{tag:j.variableName,class:"tok-variableName"},{tag:j.local(j.variableName),class:"tok-variableName tok-local"},{tag:j.definition(j.variableName),class:"tok-variableName tok-definition"},{tag:j.special(j.variableName),class:"tok-variableName2"},{tag:j.definition(j.propertyName),class:"tok-propertyName tok-definition"},{tag:j.typeName,class:"tok-typeName"},{tag:j.namespace,class:"tok-namespace"},{tag:j.className,class:"tok-className"},{tag:j.macroName,class:"tok-macroName"},{tag:j.propertyName,class:"tok-propertyName"},{tag:j.operator,class:"tok-operator"},{tag:j.comment,class:"tok-comment"},{tag:j.meta,class:"tok-meta"},{tag:j.invalid,class:"tok-invalid"},{tag:j.punctuation,class:"tok-punctuation"}]);var ga;const hr=new Ce;function Sx(n){return ee.define({combine:n?e=>e.concat(n):void 0})}const Cx=new Ce;class yi{constructor(e,t,i=[],r=""){this.data=e,this.name=r,De.prototype.hasOwnProperty("tree")||Object.defineProperty(De.prototype,"tree",{get(){return ct(this)}}),this.parser=t,this.extension=[Tn.of(this),De.languageData.of((s,o,l)=>{let h=Yf(s,o,l),f=h.type.prop(hr);if(!f)return[];let u=s.facet(f),g=h.type.prop(Cx);if(g){let y=h.resolve(o-h.from,l);for(let w of g)if(w.test(y,s)){let v=s.facet(w.facet);return w.type=="replace"?v:v.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return Yf(e,t,i).type.prop(hr)==this.data}findRegions(e){let t=e.facet(Tn);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(hr)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(Ce.mounted);if(l){if(l.tree.prop(hr)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let h=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<s.children.length;h++){let f=s.children[h];f instanceof Je&&r(f,s.positions[h]+o)}};return r(ct(e),0),i}get allowsNesting(){return!0}}yi.setState=be.define();function Yf(n,e,t){let i=n.facet(Tn),r=ct(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ht.ExcludeBuffers))s.type.isTop&&(r=s);return r}class Zo extends yi{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Sx(e.languageData);return new Zo(t,e.parser.configure({props:[hr.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Zo(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ct(n){let e=n.field(yi.state,!1);return e?e.tree:Je.empty}class Ax{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Vr=null;class el{constructor(e,t,i=[],r,s,o,l,h){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new el(e,t,[],Je.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Ax(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Je.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(qn.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(qn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Vr;Vr=this;try{return e()}finally{Vr=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Jf(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let h=[];if(e.iterChangedRanges((f,u,g,y)=>h.push({fromA:f,toA:u,fromB:g,toB:y})),i=qn.applyChanges(i,h),r=Je.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let u=e.mapPos(f.from,1),g=e.mapPos(f.to,-1);u<g&&l.push({from:u,to:g})}}}return new el(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Jf(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Np{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let h=Vr;if(h){for(let f of r)h.tempSkipped.push(f);e&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,e]):e)}return this.parsedPos=o,new Je(qt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Vr}}function Jf(n,e,t){return qn.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class wr{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new wr(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=el.create(e.facet(Tn).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new wr(i)}}yi.state=wt.define({create:wr.init,update(n,e){for(let t of e.effects)if(t.is(yi.setState))return t.value;return e.startState.facet(Tn)!=e.state.facet(Tn)?wr.init(e.state):n.apply(e)}});let Fp=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(Fp=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ma=typeof navigator!="undefined"&&(!((ga=navigator.scheduling)===null||ga===void 0)&&ga.isInputPending)?()=>navigator.scheduling.isInputPending():null,Tx=st.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(yi.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(yi.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Fp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(yi.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ma?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,h=s.context.work(()=>ma&&ma()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:yi.setState.of(new wr(s.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>li(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Tn=ee.define({combine(n){return n.length?n[0]:null},enables:n=>[yi.state,Tx,te.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Ox{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Ex=ee.define(),Jh=ee.define({combine:n=>{if(!n.length)return"  ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function tl(n){let e=n.facet(Jh);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function ws(n,e){let t="",i=n.tabSize,r=n.facet(Jh)[0];if(r=="	"){for(;e>=i;)t+="	",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function Zh(n,e){n instanceof De&&(n=new Cl(n));for(let i of n.state.facet(Ex)){let r=i(n,e);if(r!==void 0)return r}let t=ct(n.state);return t.length>=e?Mx(n,t,e):null}class Cl{constructor(e,t={}){this.state=e,this.options=t,this.unit=tl(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return As(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const zp=new Ce;function Mx(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return $p(i,n,t)}function $p(n,e,t){for(let i=n;i;i=i.next){let r=Rx(i.node);if(r)return r(ec.create(e,t,i))}return 0}function Dx(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Rx(n){let e=n.type.prop(zp);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Ce.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Nx(o,!0,1,void 0,s&&!Dx(o)?r.from:void 0)}return n.parent==null?Lx:null}function Lx(){return 0}class ec extends Cl{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new ec(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Px(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return $p(this.context.next,this.base,this.pos)}}function Px(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Ix(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let h=e.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped)return h.from<o?t:null;l=h.to}}function Nx(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=r==n.pos+o,h=Ix(n);return h?l?n.column(h.from):n.column(h.to):n.baseIndent+(l?0:n.unit*t)}function Bx({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const _x=200;function Hx(){return De.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+_x)return n;let s=t.sliceString(r.from,i);if(!e.some(f=>f.test(s)))return n;let{state:o}=n,l=-1,h=[];for(let{head:f}of o.selection.ranges){let u=o.doc.lineAt(f);if(u.from==l)continue;l=u.from;let g=Zh(o,u.from);if(g==null)continue;let y=/^\s*/.exec(u.text)[0],w=ws(o,g);y!=w&&h.push({from:u.from,to:u.from+y.length,insert:w})}return h.length?[n,{changes:h,sequential:!0}]:n})}const Fx=ee.define(),Wp=new Ce;function zx(n,e,t){let i=ct(n);if(i.length<t)return null;let r=i.resolveStack(t,1),s=null;for(let o=r;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let h=l.type.prop(Wp);if(h&&(l.to<i.length-50||i.length==n.doc.length||!$x(l))){let f=h(l,n);f&&f.from<=t&&f.from>=e&&f.to>t&&(s=f)}}return s}function $x(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function il(n,e,t){for(let i of n.facet(Fx)){let r=i(n,e,t);if(r)return r}return zx(n,e,t)}function qp(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Al=be.define({map:qp}),Ms=be.define({map:qp});function jp(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Un=wt.define({create(){return de.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(Al)&&!Wx(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(Qp),r=i?de.replace({widget:new Kx(i(e.state,t.value))}):Zf;n=n.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Ms)&&(n=n.update({filter:(i,r)=>t.value.from!=i||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(r,s)=>{r<i&&s>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(r,s)=>s<=i||r>=i}))}return n},provide:n=>te.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],r=n[t++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(Zf.range(i,r))}return de.set(e,!0)}});function nl(n,e,t){var i;let r=null;return(i=n.field(Un,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Wx(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}function Vp(n,e){return n.field(Un,!1)?e:e.concat(be.appendConfig.of(Gp()))}const qx=n=>{for(let e of jp(n)){let t=il(n.state,e.from,e.to);if(t)return n.dispatch({effects:Vp(n.state,[Al.of(t),Up(n,t)])}),!0}return!1},jx=n=>{if(!n.state.field(Un,!1))return!1;let e=[];for(let t of jp(n)){let i=nl(n.state,t.from,t.to);i&&e.push(Ms.of(i),Up(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Up(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,r=n.state.doc.lineAt(e.to).number;return te.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${r}.`)}const Vx=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let r=n.lineBlockAt(i),s=il(e,r.from,r.to);s&&t.push(Al.of(s)),i=(s?n.lineBlockAt(s.to):r).to+1}return t.length&&n.dispatch({effects:Vp(n.state,t)}),!!t.length},Ux=n=>{let e=n.state.field(Un,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Ms.of({from:i,to:r}))}),n.dispatch({effects:t}),!0},Qx=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qx},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:jx},{key:"Ctrl-Alt-[",run:Vx},{key:"Ctrl-Alt-]",run:Ux}],Gx={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Qp=ee.define({combine(n){return Wi(n,Gx)}});function Gp(n){return[Un,Jx]}function Kp(n,e){let{state:t}=n,i=t.facet(Qp),r=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),h=nl(n.state,l.from,l.to);h&&n.dispatch({effects:Ms.of(h)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const Zf=de.replace({widget:new class extends On{toDOM(n){return Kp(n,null)}}});class Kx extends On{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Kp(e,this.value)}}const Xx={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ya extends en{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Yx(n={}){let e=Object.assign(Object.assign({},Xx),n),t=new ya(e,!0),i=new ya(e,!1),r=st.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Tn)!=o.state.facet(Tn)||o.startState.field(Un,!1)!=o.state.field(Un,!1)||ct(o.startState)!=ct(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new kn;for(let h of o.viewportLineBlocks){let f=nl(o.state,h.from,h.to)?i:il(o.state,h.from,h.to)?t:null;f&&l.add(h.from,h.from,f)}return l.finish()}}),{domEventHandlers:s}=e;return[r,Jb({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||Ie.empty},initialSpacer(){return new ya(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,l,h)=>{if(s.click&&s.click(o,l,h))return!0;let f=nl(o.state,l.from,l.to);if(f)return o.dispatch({effects:Ms.of(f)}),!0;let u=il(o.state,l.from,l.to);return u?(o.dispatch({effects:Al.of(u)}),!0):!1}})}),Gp()]}const Jx=te.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Tl{constructor(e,t){this.specs=e;let i;function r(l){let h=vn.newName();return(i||(i=Object.create(null)))["."+h]=l,h}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof yi?l=>l.prop(hr)==o.data:o?l=>l==o:void 0,this.style=Hp(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new vn(i):null,this.themeType=t.themeType}static define(e,t){return new Tl(e,t||{})}}const mh=ee.define(),Xp=ee.define({combine(n){return n.length?[n[0]]:null}});function ba(n){let e=n.facet(mh);return e.length?e:n.facet(Xp)}function Zx(n,e){let t=[t1],i;return n instanceof Tl&&(n.module&&t.push(te.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Xp.of(n)):i?t.push(mh.computeN([te.darkTheme],r=>r.facet(te.darkTheme)==(i=="dark")?[n]:[])):t.push(mh.of(n)),t}class e1{constructor(e){this.markCache=Object.create(null),this.tree=ct(e.state),this.decorations=this.buildDeco(e,ba(e.state))}update(e){let t=ct(e.state),i=ba(e.state),r=i!=ba(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return de.none;let i=new kn;for(let{from:r,to:s}of e.visibleRanges)wx(this.tree,t,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=de.mark({class:h})))},r,s);return i.finish()}}const t1=Kn.high(st.fromClass(e1,{decorations:n=>n.decorations})),i1=Tl.define([{tag:j.meta,color:"#404740"},{tag:j.link,textDecoration:"underline"},{tag:j.heading,textDecoration:"underline",fontWeight:"bold"},{tag:j.emphasis,fontStyle:"italic"},{tag:j.strong,fontWeight:"bold"},{tag:j.strikethrough,textDecoration:"line-through"},{tag:j.keyword,color:"#708"},{tag:[j.atom,j.bool,j.url,j.contentSeparator,j.labelName],color:"#219"},{tag:[j.literal,j.inserted],color:"#164"},{tag:[j.string,j.deleted],color:"#a11"},{tag:[j.regexp,j.escape,j.special(j.string)],color:"#e40"},{tag:j.definition(j.variableName),color:"#00f"},{tag:j.local(j.variableName),color:"#30a"},{tag:[j.typeName,j.namespace],color:"#085"},{tag:j.className,color:"#167"},{tag:[j.special(j.variableName),j.macroName],color:"#256"},{tag:j.definition(j.propertyName),color:"#00c"},{tag:j.comment,color:"#940"},{tag:j.invalid,color:"#f00"}]),n1=te.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Yp=1e4,Jp="()[]{}",Zp=ee.define({combine(n){return Wi(n,{afterCursor:!0,brackets:Jp,maxScanDistance:Yp,renderMatch:o1})}}),r1=de.mark({class:"cm-matchingBracket"}),s1=de.mark({class:"cm-nonmatchingBracket"});function o1(n){let e=[],t=n.matched?r1:s1;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const l1=wt.define({create(){return de.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Zp);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=_i(e.state,r.head,-1,i)||r.head>0&&_i(e.state,r.head-1,1,i)||i.afterCursor&&(_i(e.state,r.head,1,i)||r.head<e.state.doc.length&&_i(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return de.set(t,!0)},provide:n=>te.decorations.from(n)}),a1=[l1,n1];function h1(n={}){return[Zp.of(n),a1]}const c1=new Ce;function yh(n,e,t){let i=n.prop(e<0?Ce.openedBy:Ce.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function bh(n){let e=n.type.prop(c1);return e?e(n.node):n}function _i(n,e,t,i={}){let r=i.maxScanDistance||Yp,s=i.brackets||Jp,o=ct(n),l=o.resolveInner(e,t);for(let h=l;h;h=h.parent){let f=yh(h.type,t,s);if(f&&h.from<h.to){let u=bh(h);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return f1(n,e,t,h,u,f,s)}}return u1(n,e,t,o,l.type,r,s)}function f1(n,e,t,i,r,s,o){let l=i.parent,h={from:r.from,to:r.to},f=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(i.from):u.childAfter(i.to)))do if(t<0?u.to<=i.from:u.from>=i.to){if(f==0&&s.indexOf(u.type.name)>-1&&u.from<u.to){let g=bh(u);return{start:h,end:g?{from:g.from,to:g.to}:void 0,matched:!0}}else if(yh(u.type,t,o))f++;else if(yh(u.type,-t,o)){if(f==0){let g=bh(u);return{start:h,end:g&&g.from<g.to?{from:g.from,to:g.to}:void 0,matched:!1}}f--}}while(t<0?u.prevSibling():u.nextSibling());return{start:h,matched:!1}}function u1(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=t>0)return null;let f={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),g=0;for(let y=0;!u.next().done&&y<=s;){let w=u.value;t<0&&(y+=w.length);let v=e+y*t;for(let A=t>0?0:w.length-1,O=t>0?w.length:-1;A!=O;A+=t){let R=o.indexOf(w[A]);if(!(R<0||i.resolveInner(v+A,1).type!=r))if(R%2==0==t>0)g++;else{if(g==1)return{start:f,end:{from:v+A,to:v+A+1},matched:R>>1==h>>1};g--}}t>0&&(y+=w.length)}return u.done?{start:f,matched:!1}:null}const d1=Object.create(null),eu=[qt.none],tu=[],iu=Object.create(null),p1=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])p1[n]=g1(d1,e);function xa(n,e){tu.indexOf(n)>-1||(tu.push(n),console.warn(e))}function g1(n,e){let t=[];for(let l of e.split(" ")){let h=[];for(let f of l.split(".")){let u=n[f]||j[f];u?typeof u=="function"?h.length?h=h.map(u):xa(f,`Modifier ${f} used at start of tag`):h.length?xa(f,`Tag ${f} used as modifier`):h=Array.isArray(u)?u:[u]:xa(f,`Unknown highlighting tag ${f}`)}for(let f of h)t.push(f)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=iu[r];if(s)return s.id;let o=iu[r]=qt.define({id:eu.length,name:i,props:[Bp({[i]:t})]});return eu.push(o),o.id}const m1=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=ic(n.state,t.from);return i.line?y1(n):i.block?x1(n):!1};function tc(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}const y1=tc(v1,0),b1=tc(eg,0),x1=tc((n,e)=>eg(n,e,k1(e)),0);function ic(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const Ur=50;function w1(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Ur,i),o=n.sliceDoc(r,r+Ur),l=/\s*$/.exec(s)[0].length,h=/^\s*/.exec(o)[0].length,f=s.length-l;if(s.slice(f-e.length,f)==e&&o.slice(h,h+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+h,margin:h&&1}};let u,g;r-i<=2*Ur?u=g=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+Ur),g=n.sliceDoc(r-Ur,r));let y=/^\s*/.exec(u)[0].length,w=/\s*$/.exec(g)[0].length,v=g.length-w-t.length;return u.slice(y,y+e.length)==e&&g.slice(v,v+t.length)==t?{open:{pos:i+y+e.length,margin:/\s/.test(u.charAt(y+e.length))?1:0},close:{pos:r-w-t.length,margin:/\s/.test(g.charAt(v-1))?1:0}}:null}function k1(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function eg(n,e,t=e.selection.ranges){let i=t.map(s=>ic(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>w1(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let h=i[o],{open:f,close:u}=l;s.push({from:f.pos-h.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+h.close.length})}return{changes:s}}return null}function v1(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,h=1e9,f=ic(e,s).line;if(f){for(let u=s;u<=o;){let g=e.doc.lineAt(u);if(g.from>r&&(s==o||o>g.from)){r=g.from;let y=/^\s*/.exec(g.text)[0].length,w=y==g.length,v=g.text.slice(y,y+f.length)==f?y:-1;y<g.text.length&&y<h&&(h=y),i.push({line:g,comment:v,token:f,indent:y,empty:w,single:!1})}u=g.to+1}if(h<1e9)for(let u=l;u<i.length;u++)i[u].indent<i[u].line.text.length&&(i[u].indent=h);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:h,indent:f,empty:u,single:g}of i)(g||!u)&&s.push({from:l.from+f,insert:h+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:h}of i)if(l>=0){let f=o.from+l,u=f+h.length;o.text[u-o.from]==" "&&u++,s.push({from:f,to:u})}return{changes:s}}return null}const xh=tn.define(),S1=tn.define(),C1=ee.define(),tg=ee.define({combine(n){return Wi(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),ig=wt.define({create(){return Hi.empty},update(n,e){let t=e.state.facet(tg),i=e.annotation(xh);if(i){let h=Wt.fromTransaction(e,i.selection),f=i.side,u=f==0?n.undone:n.done;return h?u=rl(u,u.length,t.minDepth,h):u=sg(u,e.startState.selection),new Hi(f==0?i.rest:u,f==0?u:i.rest)}let r=e.annotation(S1);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(rt.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=Wt.fromTransaction(e),o=e.annotation(rt.time),l=e.annotation(rt.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Hi(n.done.map(Wt.fromJSON),n.undone.map(Wt.fromJSON))}});function A1(n={}){return[ig,tg.of(n),te.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?ng:e.inputType=="historyRedo"?wh:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ol(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(ig,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}const ng=Ol(0,!1),wh=Ol(1,!1),T1=Ol(0,!0),O1=Ol(1,!0);class Wt{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new Wt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new Wt(e.changes&&nt.fromJSON(e.changes),[],e.mapped&&$i.fromJSON(e.mapped),e.startSelection&&H.fromJSON(e.startSelection),e.selectionsAfter.map(H.fromJSON))}static fromTransaction(e,t){let i=oi;for(let r of e.startState.facet(C1)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new Wt(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,oi)}static selection(e){return new Wt(void 0,oi,void 0,void 0,e)}}function rl(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function E1(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let h=0;h<t.length;){let f=t[h++],u=t[h++];l>=f&&o<=u&&(i=!0)}}),i}function M1(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function rg(n,e){return n.length?e.length?n.concat(e):n:e}const oi=[],D1=200;function sg(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-D1));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),rl(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Wt.selection([e])]}function R1(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function wa(n,e){if(!n.length)return n;let t=n.length,i=oi;for(;t;){let r=L1(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Wt.selection(i)]:oi}function L1(n,e,t){let i=rg(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):oi,t);if(!n.changes)return Wt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new Wt(r,be.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}const P1=/^(input\.type|delete)($|\.)/;class Hi{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Hi(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||P1.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,E1(l.changes,e.changes))||i=="input.type.compose")?o=rl(o,o.length-1,r.minDepth,new Wt(e.changes.compose(l.changes),rg(e.effects,l.effects),l.mapped,l.startSelection,oi)):o=rl(o,o.length,r.minDepth,e),new Hi(o,oi,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:oi;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&M1(s[s.length-1],e)?this:new Hi(sg(this.done,e),this.undone,t,i)}addMapping(e){return new Hi(wa(this.done,e),wa(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:xh.of({side:e,rest:R1(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?oi:r.slice(0,r.length-1);return s.mapped&&(l=wa(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:xh.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Hi.empty=new Hi(oi,oi);const I1=[{key:"Mod-z",run:ng,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:wh,preventDefault:!0},{linux:"Ctrl-Shift-z",run:wh,preventDefault:!0},{key:"Mod-u",run:T1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:O1,preventDefault:!0}];function Sr(n,e){return H.create(n.ranges.map(e),n.mainIndex)}function qi(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function wi({state:n,dispatch:e},t){let i=Sr(n.selection,t);return i.eq(n.selection)?!1:(e(qi(n,i)),!0)}function El(n,e){return H.cursor(e?n.to:n.from)}function og(n,e){return wi(n,t=>t.empty?n.moveByChar(t,e):El(t,e))}function Tt(n){return n.textDirectionAt(n.state.selection.main.head)==Ue.LTR}const lg=n=>og(n,!Tt(n)),ag=n=>og(n,Tt(n));function hg(n,e){return wi(n,t=>t.empty?n.moveByGroup(t,e):El(t,e))}const N1=n=>hg(n,!Tt(n)),B1=n=>hg(n,Tt(n));function _1(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ml(n,e,t){let i=ct(n).resolveInner(e.head),r=t?Ce.closedBy:Ce.openedBy;for(let h=e.head;;){let f=t?i.childAfter(h):i.childBefore(h);if(!f)break;_1(n,f,r)?i=f:h=t?f.to:f.from}let s=i.type.prop(r),o,l;return s&&(o=t?_i(n,i.from,1):_i(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,H.cursor(l,t?-1:1)}const H1=n=>wi(n,e=>Ml(n.state,e,!Tt(n))),F1=n=>wi(n,e=>Ml(n.state,e,Tt(n)));function cg(n,e){return wi(n,t=>{if(!t.empty)return El(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const fg=n=>cg(n,!1),ug=n=>cg(n,!0);function dg(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(te.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function pg(n,e){let t=dg(n),{state:i}=n,r=Sr(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):El(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),h=l.top+t.marginTop,f=l.bottom-t.marginBottom;o&&o.top>h&&o.bottom<f&&(s=te.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-h}))}return n.dispatch(qi(i,r),{effects:s}),!0}const nu=n=>pg(n,!1),kh=n=>pg(n,!0);function En(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=H.cursor(i.from+s))}return r}const z1=n=>wi(n,e=>En(n,e,!0)),$1=n=>wi(n,e=>En(n,e,!1)),W1=n=>wi(n,e=>En(n,e,!Tt(n))),q1=n=>wi(n,e=>En(n,e,Tt(n))),j1=n=>wi(n,e=>H.cursor(n.lineBlockAt(e.head).from,1)),V1=n=>wi(n,e=>H.cursor(n.lineBlockAt(e.head).to,-1));function U1(n,e,t){let i=!1,r=Sr(n.selection,s=>{let o=_i(n,s.head,-1)||_i(n,s.head,1)||s.head>0&&_i(n,s.head-1,1)||s.head<n.doc.length&&_i(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return H.cursor(l)});return i?(e(qi(n,r)),!0):!1}const Q1=({state:n,dispatch:e})=>U1(n,e);function fi(n,e){let t=Sr(n.state.selection,i=>{let r=e(i);return H.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(qi(n.state,t)),!0)}function gg(n,e){return fi(n,t=>n.moveByChar(t,e))}const mg=n=>gg(n,!Tt(n)),yg=n=>gg(n,Tt(n));function bg(n,e){return fi(n,t=>n.moveByGroup(t,e))}const G1=n=>bg(n,!Tt(n)),K1=n=>bg(n,Tt(n)),X1=n=>fi(n,e=>Ml(n.state,e,!Tt(n))),Y1=n=>fi(n,e=>Ml(n.state,e,Tt(n)));function xg(n,e){return fi(n,t=>n.moveVertically(t,e))}const wg=n=>xg(n,!1),kg=n=>xg(n,!0);function vg(n,e){return fi(n,t=>n.moveVertically(t,e,dg(n).height))}const ru=n=>vg(n,!1),su=n=>vg(n,!0),J1=n=>fi(n,e=>En(n,e,!0)),Z1=n=>fi(n,e=>En(n,e,!1)),ew=n=>fi(n,e=>En(n,e,!Tt(n))),tw=n=>fi(n,e=>En(n,e,Tt(n))),iw=n=>fi(n,e=>H.cursor(n.lineBlockAt(e.head).from)),nw=n=>fi(n,e=>H.cursor(n.lineBlockAt(e.head).to)),ou=({state:n,dispatch:e})=>(e(qi(n,{anchor:0})),!0),lu=({state:n,dispatch:e})=>(e(qi(n,{anchor:n.doc.length})),!0),au=({state:n,dispatch:e})=>(e(qi(n,{anchor:n.selection.main.anchor,head:0})),!0),hu=({state:n,dispatch:e})=>(e(qi(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),rw=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),sw=({state:n,dispatch:e})=>{let t=Dl(n).map(({from:i,to:r})=>H.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:H.create(t),userEvent:"select"})),!0},ow=({state:n,dispatch:e})=>{let t=Sr(n.selection,i=>{var r;let s=ct(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return H.range(l.to,l.from)}return i});return e(qi(n,t)),!0},lw=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=H.create([t.main]):t.main.empty||(i=H.create([H.cursor(t.main.head)])),i?(e(qi(n,i)),!0):!1};function Ds(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let h=e(s);h<o?(t="delete.backward",h=ko(n,h,!1)):h>o&&(t="delete.forward",h=ko(n,h,!0)),o=Math.min(o,h),l=Math.max(l,h)}else o=ko(n,o,!1),l=ko(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:H.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?te.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function ko(n,e,t){if(n instanceof te)for(let i of n.state.facet(te.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}const Sg=(n,e)=>Ds(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]=="	")return i-1;let h=As(o,r.tabSize),f=h%tl(r)||tl(r);for(let u=0;u<f&&o[o.length-1-u]==" ";u++)i--;l=i}else l=xt(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=xt(s.text,l-s.from,!1,!1)+s.from);return l}),vh=n=>Sg(n,!1),Cg=n=>Sg(n,!0),Ag=(n,e)=>Ds(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let h=xt(s.text,i-s.from,e)+s.from,f=s.text.slice(Math.min(i,h)-s.from,Math.max(i,h)-s.from),u=o(f);if(l!=null&&u!=l)break;(f!=" "||i!=t.head)&&(l=u),i=h}return i}),Tg=n=>Ag(n,!1),aw=n=>Ag(n,!0),hw=n=>Ds(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),cw=n=>Ds(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fw=n=>Ds(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),uw=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Re.of(["",""])},range:H.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},dw=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:xt(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:xt(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:H.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Dl(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Og(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Dl(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let h of s.ranges)r.push(H.range(Math.min(n.doc.length,h.anchor+l),Math.min(n.doc.length,h.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let h of s.ranges)r.push(H.range(h.anchor-l,h.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:H.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const pw=({state:n,dispatch:e})=>Og(n,e,!1),gw=({state:n,dispatch:e})=>Og(n,e,!0);function Eg(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Dl(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const mw=({state:n,dispatch:e})=>Eg(n,e,!1),yw=({state:n,dispatch:e})=>Eg(n,e,!0),bw=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Dl(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Sr(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function xw(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ct(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(Ce.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const ww=Mg(!1),kw=Mg(!0);function Mg(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),h=!n&&s==o&&xw(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let f=new Cl(e,{simulateBreak:s,simulateDoubleBreak:!!h}),u=Zh(f,s);for(u==null&&(u=As(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;h?{from:s,to:o}=h:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let g=["",ws(e,u)];return h&&g.push(ws(e,f.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Re.of(g)},range:H.cursor(s+1+g[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function nc(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:H.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const vw=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Cl(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=nc(n,(s,o,l)=>{let h=Zh(i,s.from);if(h==null)return;/\S/.test(s.text)||(h=0);let f=/^\s*/.exec(s.text)[0],u=ws(n,h);(f!=u||l.from<s.from+f.length)&&(t[s.from]=h,o.push({from:s.from,to:s.from+f.length,insert:u}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},Sw=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(nc(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Jh)})}),{userEvent:"input.indent"})),!0),Cw=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(nc(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=As(r,n.tabSize),o=0,l=ws(n,Math.max(0,s-tl(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Aw=[{key:"Ctrl-b",run:lg,shift:mg,preventDefault:!0},{key:"Ctrl-f",run:ag,shift:yg},{key:"Ctrl-p",run:fg,shift:wg},{key:"Ctrl-n",run:ug,shift:kg},{key:"Ctrl-a",run:j1,shift:iw},{key:"Ctrl-e",run:V1,shift:nw},{key:"Ctrl-d",run:Cg},{key:"Ctrl-h",run:vh},{key:"Ctrl-k",run:hw},{key:"Ctrl-Alt-h",run:Tg},{key:"Ctrl-o",run:uw},{key:"Ctrl-t",run:dw},{key:"Ctrl-v",run:kh}],Tw=[{key:"ArrowLeft",run:lg,shift:mg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:N1,shift:G1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:W1,shift:ew,preventDefault:!0},{key:"ArrowRight",run:ag,shift:yg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:B1,shift:K1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:q1,shift:tw,preventDefault:!0},{key:"ArrowUp",run:fg,shift:wg,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ou,shift:au},{mac:"Ctrl-ArrowUp",run:nu,shift:ru},{key:"ArrowDown",run:ug,shift:kg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:lu,shift:hu},{mac:"Ctrl-ArrowDown",run:kh,shift:su},{key:"PageUp",run:nu,shift:ru},{key:"PageDown",run:kh,shift:su},{key:"Home",run:$1,shift:Z1,preventDefault:!0},{key:"Mod-Home",run:ou,shift:au},{key:"End",run:z1,shift:J1,preventDefault:!0},{key:"Mod-End",run:lu,shift:hu},{key:"Enter",run:ww},{key:"Mod-a",run:rw},{key:"Backspace",run:vh,shift:vh},{key:"Delete",run:Cg},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Tg},{key:"Mod-Delete",mac:"Alt-Delete",run:aw},{mac:"Mod-Backspace",run:cw},{mac:"Mod-Delete",run:fw}].concat(Aw.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Ow=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:H1,shift:X1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:F1,shift:Y1},{key:"Alt-ArrowUp",run:pw},{key:"Shift-Alt-ArrowUp",run:mw},{key:"Alt-ArrowDown",run:gw},{key:"Shift-Alt-ArrowDown",run:yw},{key:"Escape",run:lw},{key:"Mod-Enter",run:kw},{key:"Alt-l",mac:"Ctrl-l",run:sw},{key:"Mod-i",run:ow,preventDefault:!0},{key:"Mod-[",run:Cw},{key:"Mod-]",run:Sw},{key:"Mod-Alt-\\",run:vw},{key:"Shift-Mod-k",run:bw},{key:"Shift-Mod-\\",run:Q1},{key:"Mod-/",run:m1},{key:"Alt-A",run:b1}].concat(Tw);function $e(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)Dg(n,arguments[e]);return n}function Dg(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Dg(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const cu=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class kr{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(cu(l)):cu,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return yt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Bh(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=si(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),h=this.match(l,o);if(s==r.length-1){if(h)return this.value=h,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol!="undefined"&&(kr.prototype[Symbol.iterator]=function(){return this});const Rg={from:-1,to:-1,match:/.*/.exec("")},rc="gm"+(/x/.unicode==null?"":"u");class Lg{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Rg,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Pg(e,t,i,r,s);this.re=new RegExp(t,rc+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=sl(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=sl(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ka=new WeakMap;class gr{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=ka.get(e);if(!r||r.from>=i||r.to<=t){let l=new gr(t,e.sliceString(t,i));return ka.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),ka.set(e,new gr(o,s)),new gr(t,s.slice(t-o,i-o))}}class Pg{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=Rg,this.matchPos=sl(e,r),this.re=new RegExp(t,rc+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=gr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=sl(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=gr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol!="undefined"&&(Lg.prototype[Symbol.iterator]=Pg.prototype[Symbol.iterator]=function(){return this});function Ew(n){try{return new RegExp(n,rc),!0}catch(e){return!1}}function sl(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Sh(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=$e("input",{class:"cm-textfield",name:"line",value:e}),i=$e("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:ol.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},$e("label",n.state.phrase("Go to line"),": ",t)," ",$e("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,h,f,u,g]=s,y=u?+u.slice(1):0,w=f?+f:l.number;if(f&&g){let O=w/100;h&&(O=O*(h=="-"?-1:1)+l.number/o.doc.lines),w=Math.round(o.doc.lines*O)}else f&&h&&(w=w*(h=="-"?-1:1)+l.number);let v=o.doc.line(Math.max(1,Math.min(o.doc.lines,w))),A=H.cursor(v.from+Math.max(0,Math.min(y,v.length)));n.dispatch({effects:[ol.of(!1),te.scrollIntoView(A.from,{y:"center"})],selection:A}),n.focus()}return{dom:i}}const ol=be.define(),fu=wt.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(ol)&&(n=t.value);return n},provide:n=>bs.from(n,e=>e?Sh:null)}),Mw=n=>{let e=ys(n,Sh);if(!e){let t=[ol.of(!0)];n.state.field(fu,!1)==null&&t.push(be.appendConfig.of([fu,Dw])),n.dispatch({effects:t}),e=ys(n,Sh)}return e&&e.dom.querySelector("input").select(),!0},Dw=te.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Rw={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Lw=ee.define({combine(n){return Wi(n,Rw,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Pw(n){return[Hw,_w]}const Iw=de.mark({class:"cm-selectionMatch"}),Nw=de.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uu(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=Ve.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=Ve.Word)}function Bw(n,e,t,i){return n(e.sliceDoc(t,t+1))==Ve.Word&&n(e.sliceDoc(i-1,i))==Ve.Word}const _w=st.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Lw),{state:t}=n,i=t.selection;if(i.ranges.length>1)return de.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return de.none;let h=t.wordAt(r.head);if(!h)return de.none;o=t.charCategorizer(r.head),s=t.sliceDoc(h.from,h.to)}else{let h=r.to-r.from;if(h<e.minSelectionLength||h>200)return de.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(uu(o,t,r.from,r.to)&&Bw(o,t,r.from,r.to)))return de.none}else if(s=t.sliceDoc(r.from,r.to).trim(),!s)return de.none}let l=[];for(let h of n.visibleRanges){let f=new kr(t.doc,s,h.from,h.to);for(;!f.next().done;){let{from:u,to:g}=f.value;if((!o||uu(o,t,u,g))&&(r.empty&&u<=r.from&&g>=r.to?l.push(Nw.range(u,g)):(u>=r.to||g<=r.from)&&l.push(Iw.range(u,g)),l.length>e.maxMatches))return de.none}}return de.set(l)}},{decorations:n=>n.decorations}),Hw=te.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Fw=({state:n,dispatch:e})=>{let{selection:t}=n,i=H.create(t.ranges.map(r=>n.wordAt(r.head)||H.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function zw(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new kr(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new kr(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(h=>h.from==l.value.from))continue;if(s){let h=n.wordAt(l.value.from);if(!h||h.from!=l.value.from||h.to!=l.value.to)continue}return l.value}}const $w=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return Fw({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=zw(n,i);return r?(e(n.update({selection:n.selection.addRange(H.range(r.from,r.to),!1),effects:te.scrollIntoView(r.to)})),!0):!1},Cr=ee.define({combine(n){return Wi(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Zw(e),scrollToMatch:e=>te.scrollIntoView(e)})}});class Ig{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Ew(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
`:i=="r"?"\r":i=="t"?"	":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Vw(this):new qw(this)}getCursor(e,t=0,i){let r=e.doc?e:De.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?lr(this,r,t,i):or(this,r,t,i)}}class Ng{constructor(e){this.spec=e}}function or(n,e,t,i){return new kr(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?Ww(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Ww(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(ll(r,t-s))!=Ve.Word||e(al(r,t-s))!=Ve.Word)&&(e(al(r,i-s))!=Ve.Word||e(ll(r,i-s))!=Ve.Word))}class qw extends Ng{constructor(e){super(e)}nextMatch(e,t,i){let r=or(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=or(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=or(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=or(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=or(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function lr(n,e,t,i){return new Lg(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?jw(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ll(n,e){return n.slice(xt(n,e,!1),e)}function al(n,e){return n.slice(e,xt(n,e))}function jw(n){return(e,t,i)=>!i[0].length||(n(ll(i.input,i.index))!=Ve.Word||n(al(i.input,i.index))!=Ve.Word)&&(n(al(i.input,i.index+i[0].length))!=Ve.Word||n(ll(i.input,i.index+i[0].length))!=Ve.Word)}class Vw extends Ng{nextMatch(e,t,i){let r=lr(this.spec,e,i,e.doc.length).next();return r.done&&(r=lr(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=lr(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=lr(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=lr(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const ks=be.define(),sc=be.define(),xn=wt.define({create(n){return new va(Ch(n).create(),null)},update(n,e){for(let t of e.effects)t.is(ks)?n=new va(t.value.create(),n.panel):t.is(sc)&&(n=new va(n.query,t.value?oc:null));return n},provide:n=>bs.from(n,e=>e.panel)});class va{constructor(e,t){this.query=e,this.panel=t}}const Uw=de.mark({class:"cm-searchMatch"}),Qw=de.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Gw=st.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(xn))}update(n){let e=n.state.field(xn);(e!=n.startState.field(xn)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return de.none;let{view:t}=this,i=new kn;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:h}=s[r];for(;r<o-1&&h>s[r+1].from-2*250;)h=s[++r].to;n.highlight(t.state,l,h,(f,u)=>{let g=t.state.selection.ranges.some(y=>y.from==f&&y.to==u);i.add(f,u,g?Qw:Uw)})}return i.finish()}},{decorations:n=>n.decorations});function Rs(n){return e=>{let t=e.state.field(xn,!1);return t&&t.query.spec.valid?n(e,t):Hg(e)}}const hl=Rs((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=H.single(i.from,i.to),s=n.state.facet(Cr);return n.dispatch({selection:r,effects:[lc(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),_g(n),!0}),cl=Rs((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=H.single(r.from,r.to),o=n.state.facet(Cr);return n.dispatch({selection:s,effects:[lc(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),_g(n),!0}),Kw=Rs((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:H.create(t.map(i=>H.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Xw=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new kr(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(H.range(l.value.from,l.value.to))}return e(n.update({selection:H.create(s,o),userEvent:"select.search.matches"})),!0},du=Rs((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,h,f=[];if(s.from==i&&s.to==r&&(h=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:h}),s=e.nextMatch(t,s.from,s.to),f.push(te.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let u=o.length==0||o[0].from>=s.to?0:s.to-s.from-h.length;l=H.single(s.from-u,s.to-u),f.push(lc(n,s)),f.push(t.facet(Cr).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:f,userEvent:"input.replace"}),!0}),Yw=Rs((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:te.announce.of(i),userEvent:"input.replace.all"}),!0});function oc(n){return n.state.facet(Cr).createPanel(n)}function Ch(n,e){var t,i,r,s,o;let l=n.selection.main,h=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!h)return e;let f=n.facet(Cr);return new Ig({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:f.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:f.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:f.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:f.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:f.wholeWord})}function Bg(n){let e=ys(n,oc);return e&&e.dom.querySelector("[main-field]")}function _g(n){let e=Bg(n);e&&e==n.root.activeElement&&e.select()}const Hg=n=>{let e=n.state.field(xn,!1);if(e&&e.panel){let t=Bg(n);if(t&&t!=n.root.activeElement){let i=Ch(n.state,e.query.spec);i.valid&&n.dispatch({effects:ks.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[sc.of(!0),e?ks.of(Ch(n.state,e.query.spec)):be.appendConfig.of(tk)]});return!0},Fg=n=>{let e=n.state.field(xn,!1);if(!e||!e.panel)return!1;let t=ys(n,oc);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:sc.of(!1)}),!0},Jw=[{key:"Mod-f",run:Hg,scope:"editor search-panel"},{key:"F3",run:hl,shift:cl,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hl,shift:cl,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Fg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Xw},{key:"Mod-Alt-g",run:Mw},{key:"Mod-d",run:$w,preventDefault:!0}];class Zw{constructor(e){this.view=e;let t=this.query=e.state.field(xn).query.spec;this.commit=this.commit.bind(this),this.searchField=$e("input",{value:t.search,placeholder:Ut(e,"Find"),"aria-label":Ut(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=$e("input",{value:t.replace,placeholder:Ut(e,"Replace"),"aria-label":Ut(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=$e("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=$e("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=$e("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return $e("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=$e("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>hl(e),[Ut(e,"next")]),i("prev",()=>cl(e),[Ut(e,"previous")]),i("select",()=>Kw(e),[Ut(e,"all")]),$e("label",null,[this.caseField,Ut(e,"match case")]),$e("label",null,[this.reField,Ut(e,"regexp")]),$e("label",null,[this.wordField,Ut(e,"by word")]),...e.state.readOnly?[]:[$e("br"),this.replaceField,i("replace",()=>du(e),[Ut(e,"replace")]),i("replaceAll",()=>Yw(e),[Ut(e,"replace all")])],$e("button",{name:"close",onclick:()=>Fg(e),"aria-label":Ut(e,"close"),type:"button"},["×"])])}commit(){let e=new Ig({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ks.of(e)}))}keydown(e){mb(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?cl:hl)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),du(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(ks)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Cr).top}}function Ut(n,e){return n.state.phrase(e)}const vo=30,So=/[\s\.,:;?!]/;function lc(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-vo),o=Math.min(r,t+vo),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let h=0;h<vo;h++)if(!So.test(l[h+1])&&So.test(l[h])){l=l.slice(h);break}}if(o!=r){for(let h=l.length-1;h>l.length-vo;h--)if(!So.test(l[h-1])&&So.test(l[h])){l=l.slice(0,h);break}}return te.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const ek=te.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),tk=[xn,Kn.low(Gw),ek];class zg{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=ct(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(Wg(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function pu(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function ik(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let i=pu(e)+pu(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function $g(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:ik(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}function nk(n,e){return t=>{for(let i=ct(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class gu{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}}function wn(n){return n.selection.main.from}function Wg(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const rk=tn.define();function sk(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=r&&t!=i&&n.sliceDoc(l.from+s,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:e},range:H.cursor(l.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const mu=new WeakMap;function ok(n){if(!Array.isArray(n))return n;let e=mu.get(n);return e||mu.set(n,e=$g(n)),e}const ac=be.define(),vs=be.define();class lk{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=yt(e,t),r=si(i);this.chars.push(i);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(yt(o==s?s.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:i,any:r,precise:s,byWord:o}=this;if(t.length==1){let F=yt(e,0),W=si(F),V=W==e.length?0:-100;if(F!=t[0])if(F==i[0])V+=-200;else return!1;return this.ret(V,[0,W])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let h=t.length,f=0;if(l<0){for(let F=0,W=Math.min(e.length,200);F<W&&f<h;){let V=yt(e,F);(V==t[f]||V==i[f])&&(r[f++]=F),F+=si(V)}if(f<h)return!1}let u=0,g=0,y=!1,w=0,v=-1,A=-1,O=/[a-z]/.test(e),R=!0;for(let F=0,W=Math.min(e.length,200),V=0;F<W&&g<h;){let z=yt(e,F);l<0&&(u<h&&z==t[u]&&(s[u++]=F),w<h&&(z==t[w]||z==i[w]?(w==0&&(v=F),A=F+1,w++):w=0));let G,p=z<255?z>=48&&z<=57||z>=97&&z<=122?2:z>=65&&z<=90?1:0:(G=Bh(z))!=G.toLowerCase()?1:G!=G.toUpperCase()?2:0;(!F||p==1&&O||V==0&&p!=0)&&(t[g]==z||i[g]==z&&(y=!0)?o[g++]=F:o.length&&(R=!1)),V=p,F+=si(z)}return g==h&&o[0]==0&&R?this.result(-100+(y?-200:0),o,e):w==h&&v==0?this.ret(-200-e.length+(A==e.length?0:-100),[0,A]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):w==h?this.ret(-900-e.length,[v,A]):g==h?this.result(-100+(y?-200:0)+-700+(R?0:-1100),o,e):t.length==2?!1:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let l=o+(this.astral?si(yt(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}}const At=ee.define({combine(n){return Wi(n,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ak,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>yu(e(i),t(i)),optionClass:(e,t)=>i=>yu(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function yu(n,e){return n?e?n+" "+e:n:e}function ak(n,e,t,i,r,s){let o=n.textDirection==Ue.RTL,l=o,h=!1,f="top",u,g,y=e.left-r.left,w=r.right-e.right,v=i.right-i.left,A=i.bottom-i.top;if(l&&y<Math.min(v,w)?l=!1:!l&&w<Math.min(v,y)&&(l=!0),v<=(l?y:w))u=Math.max(r.top,Math.min(t.top,r.bottom-A))-e.top,g=Math.min(400,l?y:w);else{h=!0,g=Math.min(400,(o?e.right:r.right-e.left)-30);let F=r.bottom-e.bottom;F>=A||F>e.top?u=t.bottom-e.top:(f="bottom",u=e.bottom-t.top)}let O=(e.bottom-e.top)/s.offsetHeight,R=(e.right-e.left)/s.offsetWidth;return{style:`${f}: ${u/O}px; max-width: ${g/R}px`,class:"cm-completionInfo-"+(h?o?"left-narrow":"right-narrow":l?"left":"right")}}function hk(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,h=0;for(let f=0;f<s.length;){let u=s[f++],g=s[f++];u>h&&o.appendChild(document.createTextNode(l.slice(h,u)));let y=o.appendChild(document.createElement("span"));y.appendChild(document.createTextNode(l.slice(u,g))),y.className="cm-completionMatchedText",h=g}return h<l.length&&o.appendChild(document.createTextNode(l.slice(h))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function Sa(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class ck{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:h=>this.placeInfo(h),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(At);this.optionContent=hk(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Sa(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",h=>{let{options:f}=e.state.field(t).open;for(let u=h.target,g;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(g=/-(\d+)$/.exec(u.id))&&+g[1]<f.length){this.applyCompletion(e,f[+g[1]]),h.preventDefault();return}}),this.dom.addEventListener("focusout",h=>{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(At).closeOnBlur&&h.relatedTarget!=e.contentDOM&&e.dispatch({effects:vs.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=Sa(s.length,o,e.state.facet(At).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Sa(t.options.length,t.selected,this.view.state.facet(At).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:r}=i;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(i);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>li(this.view.state,o,"completion info")):this.addInfoPane(s,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&uk(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(At).positionInfo(this.view,t,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:h}=e[o],{section:f}=l;if(f){let y=typeof f=="string"?f:f.name;if(y!=s&&(o>i.from||i.from==0))if(s=y,typeof f!="string"&&f.header)r.appendChild(f.header(f));else{let w=r.appendChild(document.createElement("completion-section"));w.textContent=y}}const u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let g=this.optionClass(l);g&&(u.className=g);for(let y of this.optionContent){let w=y(l,this.view.state,this.view,h);w&&u.appendChild(w)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function fk(n,e){return t=>new ck(t,n,e)}function uk(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function bu(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function dk(n,e){let t=[],i=null,r=h=>{t.push(h);let{section:f}=h.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(g=>g.name==u)||i.push(typeof f=="string"?{name:u}:f)}};for(let h of n)if(h.hasResult()){let f=h.result.getMatch;if(h.result.filter===!1)for(let u of h.result.options)r(new gu(u,h.source,f?f(u):[],1e9-t.length));else{let u=new lk(e.sliceDoc(h.from,h.to));for(let g of h.result.options)if(u.match(g.label)){let y=g.displayLabel?f?f(g,u.matched):[]:u.matched;r(new gu(g,h.source,y,u.score+(g.boost||0)))}}}if(i){let h=Object.create(null),f=0,u=(g,y)=>{var w,v;return((w=g.rank)!==null&&w!==void 0?w:1e9)-((v=y.rank)!==null&&v!==void 0?v:1e9)||(g.name<y.name?-1:1)};for(let g of i.sort(u))f-=1e5,h[g.name]=f;for(let g of t){let{section:y}=g.completion;y&&(g.score+=h[typeof y=="string"?y:y.name])}}let s=[],o=null,l=e.facet(At).compareCompletions;for(let h of t.sort((f,u)=>u.score-f.score||l(f.completion,u.completion))){let f=h.completion;!o||o.label!=f.label||o.detail!=f.detail||o.type!=null&&f.type!=null&&o.type!=f.type||o.apply!=f.apply||o.boost!=f.boost?s.push(h):bu(h.completion)>bu(o)&&(s[s.length-1]=h),o=h.completion}return s}class cr{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new cr(this.options,xu(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s){let o=dk(e,t);if(!o.length)return r&&e.some(h=>h.state==1)?new cr(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let l=t.facet(At).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let h=r.options[r.selected].completion;for(let f=0;f<o.length;f++)if(o[f].completion==h){l=f;break}}return new cr(o,xu(i,l),{pos:e.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:bk,above:s.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new cr(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class fl{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new fl(mk,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(At),s=(i.override||t.languageDataAt("autocomplete",wn(t)).map(ok)).map(l=>(this.active.find(f=>f.source==l)||new $t(l,this.active.some(f=>f.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((l,h)=>l==this.active[h])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!pk(s,this.active)?o=cr.build(s,t,this.id,o,i):o&&o.disabled&&!s.some(l=>l.state==1)&&(o=null),!o&&s.every(l=>l.state!=1)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new $t(l.source,0):l));for(let l of e.effects)l.is(jg)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new fl(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:gk}}function pk(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let r=t==n.length,s=i==e.length;if(r||s)return r==s;if(n[t++].result!=e[i++].result)return!1}}const gk={"aria-autocomplete":"list"};function xu(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const mk=[];function Ah(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class $t{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=Ah(e),r=this;i?r=r.handleUserEvent(e,i,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new $t(r.source,0));for(let s of e.effects)if(s.is(ac))r=new $t(r.source,1,s.value?wn(e.state):-1);else if(s.is(vs))r=new $t(r.source,0);else if(s.is(qg))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new $t(this.source,1)}handleChange(e){return e.changes.touchesRange(wn(e.startState))?new $t(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new $t(this.source,this.state,e.mapPos(this.explicitPos))}}class mr extends $t{constructor(e,t,i,r,s){super(e,2,t),this.result=i,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,i){var r;let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=wn(e.state);if((this.explicitPos<0?l<=s:l<this.from)||l>o||t=="delete"&&wn(e.startState)==this.from)return new $t(this.source,t=="input"&&i.activateOnTyping?1:0);let h=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),f;return yk(this.result.validFor,e.state,s,o)?new mr(this.source,h,this.result,s,o):this.result.update&&(f=this.result.update(this.result,s,o,new zg(e.state,l,h>=0)))?new mr(this.source,h,f,f.from,(r=f.to)!==null&&r!==void 0?r:wn(e.state)):new $t(this.source,1,h)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new $t(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new mr(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function yk(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):Wg(n,!0).test(r)}const qg=be.define({map(n,e){return n.map(t=>t.map(e))}}),jg=be.define(),Xt=wt.define({create(){return fl.start()},update(n,e){return n.update(e)},provide:n=>[Qh.from(n,e=>e.tooltip),te.contentAttributes.from(n,e=>e.attrs)]});function Vg(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Xt).active.find(r=>r.source==e.source);return i instanceof mr?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},sk(n.state,t,i.from,i.to)),{annotations:rk.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const bk=fk(Xt,Vg);function Co(n,e="option"){return t=>{let i=t.state.field(Xt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(At).interactionDelay)return!1;let r=1,s;e=="page"&&(s=Op(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:jg.of(l)}),!0}}const Ug=n=>{let e=n.state.field(Xt,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(At).interactionDelay?!1:Vg(n,e.open.options[e.open.selected])},xk=n=>n.state.field(Xt,!1)?(n.dispatch({effects:ac.of(!0)}),!0):!1,wk=n=>{let e=n.state.field(Xt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:vs.of(null)}),!0)};class kk{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const vk=50,Sk=1e3,Ck=st.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of n.state.field(Xt).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Xt);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Xt)==e)return;let t=n.transactions.some(i=>(i.selection||i.docChanged)&&!Ah(i));for(let i=0;i<this.running.length;i++){let r=this.running[i];if(t||r.updates.length+n.transactions.length>vk&&Date.now()-r.time>Sk){for(let s of r.context.abortListeners)try{s()}catch(o){li(this.view.state,o)}r.context.abortListeners=null,this.running.splice(i--,1)}else r.updates.push(...n.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(r=>r.active.source==i.source))?setTimeout(()=>this.startUpdate(),50):-1,this.composing!=0)for(let i of n.transactions)Ah(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:n}=this.view,e=n.field(Xt);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=wn(e),i=new zg(e,t,n.explicitPos==t),r=new kk(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:vs.of(null)}),li(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(At).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(At);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(r.done===void 0)continue;if(this.running.splice(i--,1),r.done){let o=new mr(r.active.source,r.active.explicitPos,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:wn(r.updates.length?r.updates[0].startState:this.view.state));for(let l of r.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(Xt).active.find(o=>o.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new $t(r.active.source,0);for(let l of r.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:qg.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Xt,!1);if(e&&e.tooltip&&this.view.state.facet(At).closeOnBlur){let t=e.open&&Op(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&this.view.dispatch({effects:vs.of(null)})}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ac.of(!1)}),20),this.composing=0}}}),Ak=te.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Ss={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Wn=be.define({map(n,e){let t=e.mapPos(n,-1,Dt.TrackAfter);return t==null?void 0:t}}),hc=new class extends jn{};hc.startSide=1;hc.endSide=-1;const Qg=wt.define({create(){return Ie.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Wn)&&(n=n.update({add:[hc.range(t.value,t.value+1)]}));return n}});function Tk(){return[Ek,Qg]}const Ca="()[]{}<>";function Gg(n){for(let e=0;e<Ca.length;e+=2)if(Ca.charCodeAt(e)==n)return Ca.charAt(e+1);return Bh(n<128?n:n+1)}function Kg(n,e){return n.languageDataAt("closeBrackets",e)[0]||Ss}const Ok=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ek=te.inputHandler.of((n,e,t,i)=>{if((Ok?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&si(yt(i,0))==1||e!=r.from||t!=r.to)return!1;let s=Rk(n.state,i);return s?(n.dispatch(s),!0):!1}),Mk=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Kg(n,n.selection.main.head).brackets||Ss.brackets,r=null,s=n.changeByRange(o=>{if(o.empty){let l=Lk(n.doc,o.head);for(let h of i)if(h==l&&Rl(n.doc,o.head)==Gg(yt(h,0)))return{changes:{from:o.head-h.length,to:o.head+h.length},range:H.cursor(o.head-h.length)}}return{range:r=o}});return r||e(n.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},Dk=[{key:"Backspace",run:Mk}];function Rk(n,e){let t=Kg(n,n.selection.main.head),i=t.brackets||Ss.brackets;for(let r of i){let s=Gg(yt(r,0));if(e==r)return s==r?Nk(n,r,i.indexOf(r+r+r)>-1,t):Pk(n,r,s,t.before||Ss.before);if(e==s&&Xg(n,n.selection.main.from))return Ik(n,r,s)}return null}function Xg(n,e){let t=!1;return n.field(Qg).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Rl(n,e){let t=n.sliceString(e,e+2);return t.slice(0,si(yt(t,0)))}function Lk(n,e){let t=n.sliceString(e-2,e);return si(yt(t,0))==t.length?t:t.slice(1)}function Pk(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Wn.of(o.to+e.length),range:H.range(o.anchor+e.length,o.head+e.length)};let l=Rl(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Wn.of(o.head+e.length),range:H.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Ik(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Rl(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:H.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Nk(n,e,t,i){let r=i.stringPrefixes||Ss.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Wn.of(l.to+e.length),range:H.range(l.anchor+e.length,l.head+e.length)};let h=l.head,f=Rl(n.doc,h),u;if(f==e){if(wu(n,h))return{changes:{insert:e+e,from:h},effects:Wn.of(h+e.length),range:H.cursor(h+e.length)};if(Xg(n,h)){let y=t&&n.sliceDoc(h,h+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+y.length,insert:y},range:H.cursor(h+y.length)}}}else{if(t&&n.sliceDoc(h-2*e.length,h)==e+e&&(u=ku(n,h-2*e.length,r))>-1&&wu(n,u))return{changes:{insert:e+e+e+e,from:h},effects:Wn.of(h+e.length),range:H.cursor(h+e.length)};if(n.charCategorizer(h)(f)!=Ve.Word&&ku(n,h,r)>-1&&!Bk(n,h,e,r))return{changes:{insert:e+e,from:h},effects:Wn.of(h+e.length),range:H.cursor(h+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function wu(n,e){let t=ct(n).resolveInner(e+1);return t.parent&&t.from==e}function Bk(n,e,t,i){let r=ct(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),h=l.indexOf(t);if(!h||h>-1&&i.indexOf(l.slice(0,h))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+h;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let f=r.to==e&&r.parent;if(!f)break;r=f}return!1}function ku(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Ve.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=Ve.Word)return s}return-1}function _k(n={}){return[Xt,At.of(n),Ck,Hk,Ak]}const Yg=[{key:"Ctrl-Space",run:xk},{key:"Escape",run:wk},{key:"ArrowDown",run:Co(!0)},{key:"ArrowUp",run:Co(!1)},{key:"PageDown",run:Co(!0,"page")},{key:"PageUp",run:Co(!1,"page")},{key:"Enter",run:Ug}],Hk=Kn.highest(vl.computeN([At],n=>n.facet(At).defaultKeymap?[Yg]:[]));class Fk{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class zn{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(em).markerFilter;s&&(r=s(r));let o=de.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?de.widget({widget:new Gk(l),diagnostic:l}).range(l.from):de.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new zn(o,t,vr(o))}}function vr(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new Fk(r,s,o.diagnostic),!1}),i}function zk(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(Jg))||n.changes.touchesRange(t.from,t.to))}function $k(n,e){return n.field(Jt,!1)?e:e.concat(be.appendConfig.of(Yk))}const Jg=be.define(),cc=be.define(),Zg=be.define(),Jt=wt.define({create(){return new zn(de.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=vr(t,n.selected.diagnostic,r)||vr(t,null,r)}n=new zn(t,n.panel,i)}for(let t of e.effects)t.is(Jg)?n=zn.init(t.value,n.panel,e.state):t.is(cc)?n=new zn(n.diagnostics,t.value?Ll.open:null,n.selected):t.is(Zg)&&(n=new zn(n.diagnostics,n.panel,t.value));return n},provide:n=>[bs.from(n,e=>e.panel),te.decorations.from(n,e=>e.diagnostics)]}),Wk=de.mark({class:"cm-lintRange cm-lintRange-active"});function qk(n,e,t){let{diagnostics:i}=n.state.field(Jt),r=[],s=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(h,f,{spec:u})=>{e>=h&&e<=f&&(h==f||(e>h||t>0)&&(e<f||t<0))&&(r.push(u.diagnostic),s=Math.min(h,s),o=Math.max(f,o))});let l=n.state.facet(em).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:jk(n,r)}}}:null}function jk(n,e){return $e("ul",{class:"cm-tooltip-lint"},e.map(t=>im(n,t,!1)))}const Vk=n=>{let e=n.state.field(Jt,!1);(!e||!e.panel)&&n.dispatch({effects:$k(n.state,[cc.of(!0)])});let t=ys(n,Ll.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},vu=n=>{let e=n.state.field(Jt,!1);return!e||!e.panel?!1:(n.dispatch({effects:cc.of(!1)}),!0)},Uk=n=>{let e=n.state.field(Jt,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Qk=[{key:"Mod-Shift-m",run:Vk,preventDefault:!0},{key:"F8",run:Uk}],em=ee.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},Wi(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function tm(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function im(n,e,t){var i;let r=t?tm(e.actions):[];return $e("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},$e("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,h=y=>{if(y.preventDefault(),l)return;l=!0;let w=vr(n.state.field(Jt).diagnostics,e);w&&s.apply(n,w.from,w.to)},{name:f}=s,u=r[o]?f.indexOf(r[o]):-1,g=u<0?f:[f.slice(0,u),$e("u",f.slice(u,u+1)),f.slice(u+1)];return $e("button",{type:"button",class:"cm-diagnosticAction",onclick:h,onmousedown:h,"aria-label":` Action: ${f}${u<0?"":` (access key "${r[o]})"`}.`},g)}),e.source&&$e("div",{class:"cm-diagnosticSource"},e.source))}class Gk extends On{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return $e("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Su{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=im(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ll{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)vu(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=tm(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let h=vr(this.view.state.field(Jt).diagnostics,s);h&&s.actions[l].apply(e,h.from,h.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=$e("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=$e("div",{class:"cm-panel-lint"},this.list,$e("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>vu(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Jt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Jt),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:h})=>{let f=-1,u;for(let g=i;g<this.items.length;g++)if(this.items[g].diagnostic==h.diagnostic){f=g;break}f<0?(u=new Su(this.view,h.diagnostic),this.items.splice(i,0,u),r=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),r=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Su(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let h=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/h:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Jt),i=vr(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Zg.of(i)})}static open(e){return new Ll(e)}}function Kk(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Ao(n){return Kk(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Xk=te.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ao("#d11")},".cm-lintRange-warning":{backgroundImage:Ao("orange")},".cm-lintRange-info":{backgroundImage:Ao("#999")},".cm-lintRange-hint":{backgroundImage:Ao("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),Yk=[Jt,te.decorations.compute([Jt],n=>{let{selected:e,panel:t}=n.field(Jt);return!e||!t||e.from==e.to?de.none:de.set([Wk.range(e.from,e.to)])}),Kb(qk,{hideOn:zk}),Xk];var Cu={};class ul{constructor(e,t,i,r,s,o,l,h,f,u=0,g){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=f,this.lookAhead=u,this.parent=g}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new ul(e,[],t,i,i,0,[],0,r?new Au(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:s}=this.p,o=s.dynamicPrecedence(r);if(o&&(this.score+=o),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(e&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let u=l?this.stack[l-1]:0,g=this.bufferBase+this.buffer.length-u;if(r<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,y,g+4,!0)}if(e&262144)this.state=this.stack[l];else{let y=this.stack[l-3];this.state=s.getGoto(y,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4);else{let s=e,{parser:o}=this.p;(r>this.pos||t<=o.maxNode)&&(this.pos=r,o.stateFlag(s,1)||(this.reducePos=r)),this.pushState(s,i),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,r,4)}}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new ul(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Jk(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if(!(i&65536))return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(t[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<t.length;s+=2){let o=t[s+1];r.some((l,h)=>h&1&&l==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r<t.length&&i.length<4;r+=2){let s=t[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let i=t>>19,r=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let h=o&65535,f=this.stack.length-l*3;if(f>=0&&e.getGoto(this.stack[f],h,!1)>=0)return l<<19|65536|h}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Au(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Au{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Jk{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class dl{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new dl(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new dl(this.stack,this.pos,this.index)}}function To(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i<n.length;){let s=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),s+=h,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class $o{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Tu=new $o;class Zk{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Tu,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;t<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Tu,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class yr{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;tv(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}yr.prototype.contextual=yr.prototype.fallback=yr.prototype.extend=!1;yr.prototype.fallback=yr.prototype.extend=!1;class ev{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function tv(n,e,t,i,r,s){let o=0,l=1<<i,{dialect:h}=t.p.parser;e:for(;l&n[o];){let f=n[o+1];for(let w=o+3;w<f;w+=2)if((n[w+1]&l)>0){let v=n[w];if(h.allows(v)&&(e.token.value==-1||e.token.value==v||iv(v,e.token.value,r,s))){e.acceptToken(v);break}}let u=e.next,g=0,y=n[o+2];if(e.next<0&&y>g&&n[f+y*3-3]==65535){o=n[f+y*3-1];continue e}for(;g<y;){let w=g+y>>1,v=f+w+(w<<1),A=n[v],O=n[v+1]||65536;if(u<A)y=w;else if(u>=O)g=w+1;else{o=n[v+2],e.advance();continue e}}break}}function Ou(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function iv(n,e,t,i){let r=Ou(t,i,e);return r<0||Ou(t,i,n)<r}const Qt=typeof process!="undefined"&&Cu&&/\bparse\b/.test(Cu.LOG);let Aa=null;function Eu(n,e,t){let i=n.cursor(ht.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class nv{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Eu(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Eu(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],r=this.index[t];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[t]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof Je){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let h=s.prop(Ce.lookAhead);if(!h||l+h<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class rv{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new $o)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,h=0;for(let f=0;f<s.length;f++){if(!(1<<f&o))continue;let u=s[f],g=this.tokens[f];if(!(i&&!u.fallback)&&((u.contextual||g.start!=e.pos||g.mask!=o||g.context!=l)&&(this.updateCachedToken(g,u,e),g.mask=o,g.context=l),g.lookAhead>g.end+25&&(h=Math.max(g.lookAhead,h)),g.value!=0)){let y=t;if(g.extended>-1&&(t=this.addActions(e,g.extended,g.end,t)),t=this.addActions(e,g.value,g.end,t),!u.extend&&(i=g,t>y))break}}for(;this.actions.length>t;)this.actions.pop();return h&&e.setLookAhead(h),!i&&e.pos==this.stream.end&&(i=new $o,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new $o,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=i,r}addActions(e,t,i,r){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let h=0;h<2;h++)for(let f=o.stateSlot(s,h?2:1);;f+=3){if(l[f]==65535)if(l[f+1]==1)f=Xi(l,f+2);else{r==0&&l[f+1]==2&&(r=this.putAction(Xi(l,f+2),t,i,r));break}l[f]==t&&(r=this.putAction(Xi(l,f+1),t,i,r))}return r}}class sv{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Zk(t,r),this.tokens=new rv(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ul.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new nv(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let h=this.tokens.getMainToken(l);s.push(h.value,h.end)}}break}}if(!i.length){let o=r&&lv(r);if(o)return Qt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Qt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return Qt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let f=i[h];if(l.sameState(f)||l.buffer.length>500&&f.buffer.length>500)if((l.score-f.score||l.buffer.length-f.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue e}}}i.length>12&&i.splice(12,i.length-12)}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let r=e.pos,{parser:s}=this,o=Qt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,u=f?e.curContext.hash:0;for(let g=this.fragments.nodeAt(r);g;){let y=this.parser.nodeSet.types[g.type.id]==g.type?s.getGoto(e.state,g.type.id):-1;if(y>-1&&g.length&&(!f||(g.prop(Ce.contextHash)||0)==u))return e.useNode(g,y),Qt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(g.type.id)})`),!0;if(!(g instanceof Je)||g.children.length==0||g.positions[0]>0)break;let w=g.children[0];if(w instanceof Je&&g.positions[0]==0)g=w;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Qt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let h=this.tokens.getActions(e);for(let f=0;f<h.length;){let u=h[f++],g=h[f++],y=h[f++],w=f==h.length||!i,v=w?e:e.split(),A=this.tokens.mainToken;if(v.apply(u,g,A?A.start:v.pos,y),Qt&&console.log(o+this.stackID(v)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(g)} @ ${r}${v==e?"":", split"})`),w)return!0;v.pos>r?t.push(v):i.push(v)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Mu(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],h=t[o<<1],f=t[(o<<1)+1],u=Qt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Qt&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let g=l.split(),y=u;for(let w=0;g.forceReduce()&&w<10&&(Qt&&console.log(y+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));w++)Qt&&(y=this.stackID(g)+" -> ");for(let w of l.recoverByInsert(h))Qt&&console.log(u+this.stackID(w)+" (via recover-insert)"),this.advanceFully(w,i);this.stream.end>l.pos?(f==l.pos&&(f++,h=0),l.recoverByDelete(h,f),Qt&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),Mu(l,i)):(!r||r.score<l.score)&&(r=l)}return r}stackToTree(e){return e.close(),Je.build({buffer:dl.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Aa||(Aa=new WeakMap)).get(e);return t||Aa.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Mu(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class ov{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class pl extends Np{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),r=[];for(let l=0;l<t.length;l++)r.push([]);function s(l,h,f){r[l].push([h,h.deserialize(String(f))])}if(e.nodeProps)for(let l of e.nodeProps){let h=l[0];typeof h=="string"&&(h=Ce[h]);for(let f=1;f<l.length;){let u=l[f++];if(u>=0)s(u,h,l[f++]);else{let g=l[f+-u];for(let y=-u;y>0;y--)s(l[f++],h,g);f++}}}this.nodeSet=new Gh(t.map((l,h)=>qt.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:r[h],top:i.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Rp;let o=To(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Du),this.states=To(e.states,Uint32Array),this.data=To(e.stateData),this.goto=To(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new yr(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new sv(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,h=r[s++];if(l&&i)return h;for(let f=s+(o>>1);s<f;s++)if(r[s]==e)return h;if(l)return-1}}hasAction(e,t){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Xi(i,s+2)];else{if(i[s+1]==2)return Xi(i,s+2);break}if(o==t||o==0)return Xi(i,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Xi(this.data,s+2);else break;r=t(Xi(this.data,s+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Xi(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(pl.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Du(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<t.length;s++)if(!i[s])for(let o=this.dialects[t[s]],l;(l=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new ov(e,i,r)}static deserialize(e){return new pl(e)}}function Xi(n,e){return n[e]|n[e+1]<<16}function lv(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Du(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}const av=36,Ru=1,hv=2,Qr=3,Ta=4,cv=5,fv=6,uv=7,dv=8,pv=9,gv=10,mv=11,yv=12,bv=13,xv=14,wv=15,kv=16,vv=17,Lu=18,Sv=19,nm=20,rm=21,Pu=22,Cv=23,Av=24;function Th(n){return n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57}function Tv(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function _n(n,e,t){for(let i=!1;;){if(n.next<0)return;if(n.next==e&&!i){n.advance();return}i=t&&!i&&n.next==92,n.advance()}}function Ov(n){for(;;){if(n.next<0||n.peek(1)<0)return;if(n.next==36&&n.peek(1)==36){n.advance(2);return}n.advance()}}function Ev(n,e){let t="[{<(".indexOf(String.fromCharCode(e)),i=t<0?e:"]}>)".charCodeAt(t);for(;;){if(n.next<0)return;if(n.next==i&&n.peek(1)==39){n.advance(2);return}n.advance()}}function sm(n,e){for(;!(n.next!=95&&!Th(n.next));)e!=null&&(e+=String.fromCharCode(n.next)),n.advance();return e}function Mv(n){if(n.next==39||n.next==34||n.next==96){let e=n.next;n.advance(),_n(n,e,!1)}else sm(n)}function Iu(n,e){for(;n.next==48||n.next==49;)n.advance();e&&n.next==e&&n.advance()}function Nu(n,e){for(;;){if(n.next==46){if(e)break;e=!0}else if(n.next<48||n.next>57)break;n.advance()}if(n.next==69||n.next==101)for(n.advance(),(n.next==43||n.next==45)&&n.advance();n.next>=48&&n.next<=57;)n.advance()}function Bu(n){for(;!(n.next<0||n.next==10);)n.advance()}function Nn(n,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==n)return!0;return!1}const Oa=` 	\r
`;function om(n,e,t){let i=Object.create(null);i.true=i.false=cv,i.null=i.unknown=fv;for(let r of n.split(" "))r&&(i[r]=nm);for(let r of e.split(" "))r&&(i[r]=rm);for(let r of(t||"").split(" "))r&&(i[r]=Av);return i}const Dv="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",Rv="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",Oh={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',words:om(Rv,Dv)};function Lv(n,e,t,i){let r={};for(let s in Oh)r[s]=(n.hasOwnProperty(s)?n:Oh)[s];return e&&(r.words=om(e,t||"",i)),r}function lm(n){return new ev(e=>{var t;let{next:i}=e;if(e.advance(),Nn(i,Oa)){for(;Nn(e.next,Oa);)e.advance();e.acceptToken(av)}else if(i==36&&e.next==36&&n.doubleDollarQuotedStrings)Ov(e),e.acceptToken(Qr);else if(i==39||i==34&&n.doubleQuotedStrings)_n(e,i,n.backslashEscapes),e.acceptToken(Qr);else if(i==35&&n.hashComments||i==47&&e.next==47&&n.slashComments)Bu(e),e.acceptToken(Ru);else if(i==45&&e.next==45&&(!n.spaceAfterDashes||e.peek(1)==32))Bu(e),e.acceptToken(Ru);else if(i==47&&e.next==42){e.advance();for(let r=1;;){let s=e.next;if(e.next<0)break;if(e.advance(),s==42&&e.next==47){if(r--,e.advance(),!r)break}else s==47&&e.next==42&&(r++,e.advance())}e.acceptToken(hv)}else if((i==101||i==69)&&e.next==39)e.advance(),_n(e,39,!0);else if((i==110||i==78)&&e.next==39&&n.charSetCasts)e.advance(),_n(e,39,n.backslashEscapes),e.acceptToken(Qr);else if(i==95&&n.charSetCasts)for(let r=0;;r++){if(e.next==39&&r>1){e.advance(),_n(e,39,n.backslashEscapes),e.acceptToken(Qr);break}if(!Th(e.next))break;e.advance()}else if(n.plsqlQuotingMechanism&&(i==113||i==81)&&e.next==39&&e.peek(1)>0&&!Nn(e.peek(1),Oa)){let r=e.peek(1);e.advance(2),Ev(e,r),e.acceptToken(Qr)}else if(i==40)e.acceptToken(uv);else if(i==41)e.acceptToken(dv);else if(i==123)e.acceptToken(pv);else if(i==125)e.acceptToken(gv);else if(i==91)e.acceptToken(mv);else if(i==93)e.acceptToken(yv);else if(i==59)e.acceptToken(bv);else if(n.unquotedBitLiterals&&i==48&&e.next==98)e.advance(),Iu(e),e.acceptToken(Pu);else if((i==98||i==66)&&(e.next==39||e.next==34)){const r=e.next;e.advance(),n.treatBitsAsBytes?(_n(e,r,n.backslashEscapes),e.acceptToken(Cv)):(Iu(e,r),e.acceptToken(Pu))}else if(i==48&&(e.next==120||e.next==88)||(i==120||i==88)&&e.next==39){let r=e.next==39;for(e.advance();Tv(e.next);)e.advance();r&&e.next==39&&e.advance(),e.acceptToken(Ta)}else if(i==46&&e.next>=48&&e.next<=57)Nu(e,!0),e.acceptToken(Ta);else if(i==46)e.acceptToken(xv);else if(i>=48&&i<=57)Nu(e,!1),e.acceptToken(Ta);else if(Nn(i,n.operatorChars)){for(;Nn(e.next,n.operatorChars);)e.advance();e.acceptToken(wv)}else if(Nn(i,n.specialVar))e.next==i&&e.advance(),Mv(e),e.acceptToken(vv);else if(Nn(i,n.identifierQuotes))_n(e,i,!1),e.acceptToken(Sv);else if(i==58||i==44)e.acceptToken(kv);else if(Th(i)){let r=sm(e,String.fromCharCode(i));e.acceptToken(e.next==46?Lu:(t=n.words[r.toLowerCase()])!==null&&t!==void 0?t:Lu)}})}const am=lm(Oh),Pv=pl.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,am],topRules:{Script:[0,25]},tokenPrec:0});function Eh(n){let e=n.cursor().moveTo(n.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function Cs(n,e){let t=n.sliceString(e.from,e.to),i=/^([`'"])(.*)\1$/.exec(t);return i?i[2]:t}function gl(n){return n&&(n.name=="Identifier"||n.name=="QuotedIdentifier")}function Iv(n,e){if(e.name=="CompositeIdentifier"){let t=[];for(let i=e.firstChild;i;i=i.nextSibling)gl(i)&&t.push(Cs(n,i));return t}return[Cs(n,e)]}function _u(n,e){for(let t=[];;){if(!e||e.name!=".")return t;let i=Eh(e);if(!gl(i))return t;t.unshift(Cs(n,i)),e=Eh(i)}}function Nv(n,e){let t=ct(n).resolveInner(e,-1),i=_v(n.doc,t);return t.name=="Identifier"||t.name=="QuotedIdentifier"||t.name=="Keyword"?{from:t.from,quoted:t.name=="QuotedIdentifier"?n.doc.sliceString(t.from,t.from+1):null,parents:_u(n.doc,Eh(t)),aliases:i}:t.name=="."?{from:e,quoted:null,parents:_u(n.doc,t),aliases:i}:{from:e,quoted:null,parents:[],empty:!0,aliases:i}}const Bv=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function _v(n,e){let t;for(let r=e;!t;r=r.parent){if(!r)return null;r.name=="Statement"&&(t=r)}let i=null;for(let r=t.firstChild,s=!1,o=null;r;r=r.nextSibling){let l=r.name=="Keyword"?n.sliceString(r.from,r.to).toLowerCase():null,h=null;if(!s)s=l=="from";else if(l=="as"&&o&&gl(r.nextSibling))h=Cs(n,r.nextSibling);else{if(l&&Bv.has(l))break;o&&gl(r)&&(h=Cs(n,r))}h&&(i||(i=Object.create(null)),i[h]=Iv(n,o)),o=/Identifier$/.test(r.name)?r:null}return i}function Hv(n,e){return n?e.map(t=>Object.assign(Object.assign({},t),{label:n+t.label+n,apply:void 0})):e}const Fv=/^\w*$/,zv=/^[`'"]?\w*[`'"]?$/;class fc{constructor(){this.list=[],this.children=void 0}child(e,t){let i=this.children||(this.children=Object.create(null)),r=i[e];return r||(e&&this.list.push(hm(e,"type",t)),i[e]=new fc)}addCompletions(e){for(let t of e){let i=this.list.findIndex(r=>r.label==t.label);i>-1?this.list[i]=t:this.list.push(t)}}}function hm(n,e,t){return/[^\w\xb5-\uffff]/.test(n)?{label:n,type:e,apply:t+n+t}:{label:n,type:e}}function $v(n,e,t,i,r,s){var o;let l=new fc,h=((o=s==null?void 0:s.spec.identifierQuotes)===null||o===void 0?void 0:o[0])||'"',f=l.child(r||"",h);for(let u in n){let g=u.replace(/\\?\./g,w=>w=="."?"\0":w).split("\0"),y=g.length==1?f:l;for(let w of g)y=y.child(w.replace(/\\\./g,"."),h);for(let w of n[u])w&&y.list.push(typeof w=="string"?hm(w,"property",h):w)}return e&&f.addCompletions(e),t&&l.addCompletions(t),l.addCompletions(f.list),i&&l.addCompletions(f.child(i,h).list),u=>{let{parents:g,from:y,quoted:w,empty:v,aliases:A}=Nv(u.state,u.pos);if(v&&!u.explicit)return null;A&&g.length==1&&(g=A[g[0]]||g);let O=l;for(let W of g){for(;!O.children||!O.children[W];)if(O==l)O=f;else if(O==f&&i)O=O.child(i,h);else return null;O=O.child(W,h)}let R=w&&u.state.sliceDoc(u.pos,u.pos+1)==w,F=O.list;return O==l&&A&&(F=F.concat(Object.keys(A).map(W=>({label:W,type:"constant"})))),{from:y,to:R?u.pos+1:void 0,options:Hv(w,F),validFor:w?zv:Fv}}}function Wv(n,e){let t=Object.keys(n).map(i=>({label:e?i.toUpperCase():i,type:n[i]==rm?"type":n[i]==nm?"keyword":"variable",boost:-1}));return nk(["QuotedIdentifier","SpecialVar","String","LineComment","BlockComment","."],$g(t))}let qv=Pv.configure({props:[zp.add({Statement:Bx()}),Wp.add({Statement(n){return{from:n.firstChild.to,to:n.to}},BlockComment(n){return{from:n.from+2,to:n.to-2}}}),Bp({Keyword:j.keyword,Type:j.typeName,Builtin:j.standard(j.name),Bits:j.number,Bytes:j.string,Bool:j.bool,Null:j.null,Number:j.number,String:j.string,Identifier:j.name,QuotedIdentifier:j.special(j.string),SpecialVar:j.special(j.name),LineComment:j.lineComment,BlockComment:j.blockComment,Operator:j.operator,"Semi Punctuation":j.punctuation,"( )":j.paren,"{ }":j.brace,"[ ]":j.squareBracket})]});class uc{constructor(e,t,i){this.dialect=e,this.language=t,this.spec=i}get extension(){return this.language.extension}static define(e){let t=Lv(e,e.keywords,e.types,e.builtin),i=Zo.define({name:"sql",parser:qv.configure({tokenizers:[{from:am,to:lm(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new uc(t,i,e)}}function jv(n,e=!1){return Wv(n.dialect.words,e)}function Vv(n,e=!1){return n.language.data.of({autocomplete:jv(n,e)})}function cm(n){return n.schema?$v(n.schema,n.tables,n.schemas,n.defaultTable,n.defaultSchema,n.dialect||Pl):()=>null}function Uv(n){return n.schema?(n.dialect||Pl).language.data.of({autocomplete:cm(n)}):[]}function Qv(n={}){let e=n.dialect||Pl;return new Ox(e.language,[Uv(n),Vv(e,!!n.upperCaseKeywords)])}const Pl=uc.define({});let Gv=te.updateListener.of(n=>{n.docChanged&&document.dispatchEvent(new CustomEvent("docChanged",{}))});const Kv=te.domEventHandlers({keydown(n,e){if(n.code==="Escape"){const t=document.getElementById("schema_tooltip");return t&&(t.classList.add("d-none"),t.classList.remove("d-block")),!0}return!1}});function Hu(n){let e=document.getElementById("schema_tooltip");e&&(e.classList.remove("d-none"),e.classList.add("d-block"),e.textContent="",n.forEach(t=>{let i=document.createElement("span");i.textContent=t,i.classList.add("mx-1"),e.appendChild(i)}))}function Fu(n){const{state:e}=n,t=e.selection.main.head,i=e.wordAt(t);if(i){const r=e.doc.sliceString(i.from,i.to);Ph.get().then(s=>{if(s.hasOwnProperty(r))Hu(s[r]);else{const o=[`Table '${r}' not found in schema for connection`];Hu(o)}})}return!0}const Xv=[{key:"Ctrl-S",mac:"Cmd-S",run:n=>(Fu(n),!0)},{key:"Cmd-S",run:n=>(Fu(n),!0)}],zu=new CustomEvent("submitEventFromCM",{}),Yv=[{key:"Ctrl-Enter",run:()=>(document.dispatchEvent(zu),!0)},{key:"Cmd-Enter",run:()=>(document.dispatchEvent(zu),!0)}],$u=new CustomEvent("formatEventFromCM",{}),Jv=[{key:"Ctrl-F",mac:"Cmd-F",run:()=>(document.dispatchEvent($u),!0)},{key:"Ctrl-F",mac:"Cmd-F",run:()=>(document.dispatchEvent($u),!0)}],Zv=Kn.highest(vl.of(Yv)),eS=[{key:"Tab",run:Ug}],tS=[Qv({}),rx(),lx(),Pb(),A1(),Yx(),vb(),Ob(),Hx(),Zx(i1,{fallback:!0}),h1(),Tk(),_k(),Fb(),Pw(),Zv,Gv,Kv,vl.of([...Dk,...Ow,...Jw,...I1,...Qx,...Yg,...Qk,...eS,...Xv,...Jv])];function dc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Xn=dc();function fm(n){Xn=n}const um=/[&<>"']/,iS=new RegExp(um.source,"g"),dm=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,nS=new RegExp(dm.source,"g"),rS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wu=n=>rS[n];function Kt(n,e){if(e){if(um.test(n))return n.replace(iS,Wu)}else if(dm.test(n))return n.replace(nS,Wu);return n}const sS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function oS(n){return n.replace(sS,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const lS=/(^|[^\[])\^/g;function Ne(n,e){let t=typeof n=="string"?n:n.source;e=e||"";const i={replace:(r,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(lS,"$1"),t=t.replace(r,o),i},getRegex:()=>new RegExp(t,e)};return i}function qu(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}const ls={exec:()=>null};function ju(n,e){const t=n.replace(/\|/g,(s,o,l)=>{let h=!1,f=o;for(;--f>=0&&l[f]==="\\";)h=!h;return h?"|":" |"}),i=t.split(/ \|/);let r=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(/\\\|/g,"|");return i}function Oo(n,e,t){const i=n.length;if(i===0)return"";let r=0;for(;r<i;){const s=n.charAt(i-r-1);if(s===e&&!t)r++;else if(s!==e&&t)r++;else break}return n.slice(0,i-r)}function aS(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<n.length;i++)if(n[i]==="\\")i++;else if(n[i]===e[0])t++;else if(n[i]===e[1]&&(t--,t<0))return i;return-1}function Vu(n,e,t,i){const r=e.href,s=e.title?Kt(e.title):null,o=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){i.state.inLink=!0;const l={type:"link",raw:t,href:r,title:s,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}return{type:"image",raw:t,href:r,title:s,text:Kt(o)}}function hS(n,e){const t=n.match(/^(\s+)(?:```)/);if(t===null)return e;const i=t[1];return e.split(`
`).map(r=>{const s=r.match(/^\s+/);if(s===null)return r;const[o]=s;return o.length>=i.length?r.slice(i.length):r}).join(`
`)}class ml{constructor(e){ze(this,"options");ze(this,"rules");ze(this,"lexer");this.options=e||Xn}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const i=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?i:Oo(i,`
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const i=t[0],r=hS(i,t[3]||"");return{type:"code",raw:i,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let i=t[2].trim();if(/#$/.test(i)){const r=Oo(i,"#");(this.options.pedantic||!r||/ $/.test(r))&&(i=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const i=Oo(t[0].replace(/^ *>[ \t]?/gm,""),`
`),r=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(i);return this.lexer.state.top=r,{type:"blockquote",raw:t[0],tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const r=i.length>1,s={type:"list",raw:"",ordered:r,start:r?+i.slice(0,-1):"",loose:!1,items:[]};i=r?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=r?i:"[*+-]");const o=new RegExp(`^( {0,3}${i})((?:[	 ][^\\n]*)?(?:\\n|$))`);let l="",h="",f=!1;for(;e;){let u=!1;if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let g=t[2].split(`
`,1)[0].replace(/^\t+/,R=>" ".repeat(3*R.length)),y=e.split(`
`,1)[0],w=0;this.options.pedantic?(w=2,h=g.trimStart()):(w=t[2].search(/[^ ]/),w=w>4?1:w,h=g.slice(w),w+=t[1].length);let v=!1;if(!g&&/^ *$/.test(y)&&(l+=y+`
`,e=e.substring(y.length+1),u=!0),!u){const R=new RegExp(`^ {0,${Math.min(3,w-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`),F=new RegExp(`^ {0,${Math.min(3,w-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),W=new RegExp(`^ {0,${Math.min(3,w-1)}}(?:\`\`\`|~~~)`),V=new RegExp(`^ {0,${Math.min(3,w-1)}}#`);for(;e;){const z=e.split(`
`,1)[0];if(y=z,this.options.pedantic&&(y=y.replace(/^ {1,4}(?=( {4})*[^ ])/g,"  ")),W.test(y)||V.test(y)||R.test(y)||F.test(e))break;if(y.search(/[^ ]/)>=w||!y.trim())h+=`
`+y.slice(w);else{if(v||g.search(/[^ ]/)>=4||W.test(g)||V.test(g)||F.test(g))break;h+=`
`+y}!v&&!y.trim()&&(v=!0),l+=z+`
`,e=e.substring(z.length+1),g=y.slice(w)}}s.loose||(f?s.loose=!0:/\n *\n *$/.test(l)&&(f=!0));let A=null,O;this.options.gfm&&(A=/^\[[ xX]\] /.exec(h),A&&(O=A[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),s.items.push({type:"list_item",raw:l,task:!!A,checked:O,loose:!1,text:h,tokens:[]}),s.raw+=l}s.items[s.items.length-1].raw=l.trimEnd(),s.items[s.items.length-1].text=h.trimEnd(),s.raw=s.raw.trimEnd();for(let u=0;u<s.items.length;u++)if(this.lexer.state.top=!1,s.items[u].tokens=this.lexer.blockTokens(s.items[u].text,[]),!s.loose){const g=s.items[u].tokens.filter(w=>w.type==="space"),y=g.length>0&&g.some(w=>/\n.*\n/.test(w.raw));s.loose=y}if(s.loose)for(let u=0;u<s.items.length;u++)s.items[u].loose=!0;return s}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const i=t[1].toLowerCase().replace(/\s+/g," "),r=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:i,raw:t[0],href:r,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;const i=ju(t[1]),r=t[2].replace(/^\||\| *$/g,"").split("|"),s=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===r.length){for(const l of r)/^ *-+: *$/.test(l)?o.align.push("right"):/^ *:-+: *$/.test(l)?o.align.push("center"):/^ *:-+ *$/.test(l)?o.align.push("left"):o.align.push(null);for(const l of i)o.header.push({text:l,tokens:this.lexer.inline(l)});for(const l of s)o.rows.push(ju(l,o.header.length).map(h=>({text:h,tokens:this.lexer.inline(h)})));return o}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const i=t[1].charAt(t[1].length-1)===`
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:i,tokens:this.lexer.inline(i)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Kt(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const i=t[2].trim();if(!this.options.pedantic&&/^</.test(i)){if(!/>$/.test(i))return;const o=Oo(i.slice(0,-1),"\\");if((i.length-o.length)%2===0)return}else{const o=aS(t[2],"()");if(o>-1){const h=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,h).trim(),t[3]=""}}let r=t[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r);o&&(r=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return r=r.trim(),/^</.test(r)&&(this.options.pedantic&&!/>$/.test(i)?r=r.slice(1):r=r.slice(1,-1)),Vu(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){const r=(i[2]||i[1]).replace(/\s+/g," "),s=t[r.toLowerCase()];if(!s){const o=i[0].charAt(0);return{type:"text",raw:o,text:o}}return Vu(i,s,i[0],this.lexer)}}emStrong(e,t,i=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&i.match(/[\p{L}\p{N}]/u))return;if(!(r[1]||r[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const o=[...r[0]].length-1;let l,h,f=o,u=0;const g=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,t=t.slice(-1*e.length+o);(r=g.exec(t))!=null;){if(l=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!l)continue;if(h=[...l].length,r[3]||r[4]){f+=h;continue}else if((r[5]||r[6])&&o%3&&!((o+h)%3)){u+=h;continue}if(f-=h,f>0)continue;h=Math.min(h,h+f+u);const y=[...r[0]][0].length,w=e.slice(0,o+r.index+y+h);if(Math.min(o,h)%2){const A=w.slice(1,-1);return{type:"em",raw:w,text:A,tokens:this.lexer.inlineTokens(A)}}const v=w.slice(2,-2);return{type:"strong",raw:w,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(/\n/g," ");const r=/[^ ]/.test(i),s=/^ /.test(i)&&/ $/.test(i);return r&&s&&(i=i.substring(1,i.length-1)),i=Kt(i,!0),{type:"codespan",raw:t[0],text:i}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let i,r;return t[2]==="@"?(i=Kt(t[1]),r="mailto:"+i):(i=Kt(t[1]),r=i),{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}url(e){var i,r;let t;if(t=this.rules.inline.url.exec(e)){let s,o;if(t[2]==="@")s=Kt(t[0]),o="mailto:"+s;else{let l;do l=t[0],t[0]=(r=(i=this.rules.inline._backpedal.exec(t[0]))==null?void 0:i[0])!=null?r:"";while(l!==t[0]);s=Kt(t[0]),t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let i;return this.lexer.state.inRawBlock?i=t[0]:i=Kt(t[0]),{type:"text",raw:t[0],text:i}}}}const cS=/^(?: *(?:\n|$))+/,fS=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,uS=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ls=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dS=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pm=/(?:[*+-]|\d{1,9}[.)])/,gm=Ne(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,pm).getRegex(),pc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pS=/^[^\n]+/,gc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,gS=Ne(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",gc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),mS=Ne(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,pm).getRegex(),Il="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",mc=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,yS=Ne("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",mc).replace("tag",Il).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mm=Ne(pc).replace("hr",Ls).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Il).getRegex(),bS=Ne(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mm).getRegex(),yc={blockquote:bS,code:fS,def:gS,fences:uS,heading:dS,hr:Ls,html:yS,lheading:gm,list:mS,newline:cS,paragraph:mm,table:ls,text:pS},Uu=Ne("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ls).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Il).getRegex(),xS=rr(zt({},yc),{table:Uu,paragraph:Ne(pc).replace("hr",Ls).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Uu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Il).getRegex()}),wS=rr(zt({},yc),{html:Ne(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",mc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ls,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ne(pc).replace("hr",Ls).replace("heading",` *#{1,6} *[^
]`).replace("lheading",gm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),ym=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,kS=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bm=/^( {2,}|\\)\n(?!\s*$)/,vS=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ps="\\p{P}$+<=>`^|~",SS=Ne(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Ps).getRegex(),CS=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,AS=Ne(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Ps).getRegex(),TS=Ne("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Ps).getRegex(),OS=Ne("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Ps).getRegex(),ES=Ne(/\\([punct])/,"gu").replace(/punct/g,Ps).getRegex(),MS=Ne(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),DS=Ne(mc).replace("(?:-->|$)","-->").getRegex(),RS=Ne("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",DS).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yl=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,LS=Ne(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",yl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),xm=Ne(/^!?\[(label)\]\[(ref)\]/).replace("label",yl).replace("ref",gc).getRegex(),wm=Ne(/^!?\[(ref)\](?:\[\])?/).replace("ref",gc).getRegex(),PS=Ne("reflink|nolink(?!\\()","g").replace("reflink",xm).replace("nolink",wm).getRegex(),bc={_backpedal:ls,anyPunctuation:ES,autolink:MS,blockSkip:CS,br:bm,code:kS,del:ls,emStrongLDelim:AS,emStrongRDelimAst:TS,emStrongRDelimUnd:OS,escape:ym,link:LS,nolink:wm,punctuation:SS,reflink:xm,reflinkSearch:PS,tag:RS,text:vS,url:ls},IS=rr(zt({},bc),{link:Ne(/^!?\[(label)\]\((.*?)\)/).replace("label",yl).getRegex(),reflink:Ne(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yl).getRegex()}),Mh=rr(zt({},bc),{escape:Ne(ym).replace("])","~|])").getRegex(),url:Ne(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),NS=rr(zt({},Mh),{br:Ne(bm).replace("{2,}","*").getRegex(),text:Ne(Mh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),Eo={normal:yc,gfm:xS,pedantic:wS},Gr={normal:bc,gfm:Mh,breaks:NS,pedantic:IS};class Fi{constructor(e){ze(this,"tokens");ze(this,"options");ze(this,"state");ze(this,"tokenizer");ze(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Xn,this.options.tokenizer=this.options.tokenizer||new ml,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Eo.normal,inline:Gr.normal};this.options.pedantic?(t.block=Eo.pedantic,t.inline=Gr.pedantic):this.options.gfm&&(t.block=Eo.gfm,this.options.breaks?t.inline=Gr.breaks:t.inline=Gr.gfm),this.tokenizer.rules=t}static get rules(){return{block:Eo,inline:Gr}}static lex(e,t){return new Fi(t).lex(e)}static lexInline(e,t){return new Fi(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g,"    ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,h,f)=>h+"    ".repeat(f.length));let i,r,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(i=l.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))){if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length),i.raw.length===1&&t.length>0?t[t.length-1].raw+=`
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length),r=t[t.length-1],r&&(r.type==="paragraph"||r.type==="text")?(r.raw+=`
`+i.raw,r.text+=`
`+i.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length),r=t[t.length-1],r&&(r.type==="paragraph"||r.type==="text")?(r.raw+=`
`+i.raw,r.text+=`
`+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const h=e.slice(1);let f;this.options.extensions.startBlock.forEach(u=>{f=u.call({lexer:this},h),typeof f=="number"&&f>=0&&(l=Math.min(l,f))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){r=t[t.length-1],o&&r.type==="paragraph"?(r.raw+=`
`+i.raw,r.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(i),o=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length),r=t[t.length-1],r&&r.type==="text"?(r.raw+=`
`+i.raw,r.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(i);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,r,s,o=e,l,h,f;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)u.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,l.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(h||(f=""),h=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(i=u.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))){if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),r=t[t.length-1],r&&i.type==="text"&&r.type==="text"?(r.raw+=i.raw,r.text+=i.text):t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length),r=t[t.length-1],r&&i.type==="text"&&r.type==="text"?(r.raw+=i.raw,r.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,o,f)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0;const g=e.slice(1);let y;this.options.extensions.startInline.forEach(w=>{y=w.call({lexer:this},g),typeof y=="number"&&y>=0&&(u=Math.min(u,y))}),u<1/0&&u>=0&&(s=e.substring(0,u+1))}if(i=this.tokenizer.inlineText(s)){e=e.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(f=i.raw.slice(-1)),h=!0,r=t[t.length-1],r&&r.type==="text"?(r.raw+=i.raw,r.text+=i.text):t.push(i);continue}if(e){const u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}}class bl{constructor(e){ze(this,"options");this.options=e||Xn}code(e,t,i){var s;const r=(s=(t||"").match(/^\S*/))==null?void 0:s[0];return e=e.replace(/\n$/,"")+`
`,r?'<pre><code class="language-'+Kt(r)+'">'+(i?e:Kt(e,!0))+`</code></pre>
`:"<pre><code>"+(i?e:Kt(e,!0))+`</code></pre>
`}blockquote(e){return`<blockquote>
${e}</blockquote>
`}html(e,t){return e}heading(e,t,i){return`<h${t}>${e}</h${t}>
`}hr(){return`<hr>
`}list(e,t,i){const r=t?"ol":"ul",s=t&&i!==1?' start="'+i+'"':"";return"<"+r+s+`>
`+e+"</"+r+`>
`}listitem(e,t,i){return`<li>${e}</li>
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
<thead>
`+e+`</thead>
`+t+`</table>
`}tablerow(e){return`<tr>
${e}</tr>
`}tablecell(e,t){const i=t.header?"th":"td";return(t.align?`<${i} align="${t.align}">`:`<${i}>`)+e+`</${i}>
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,i){const r=qu(e);if(r===null)return i;e=r;let s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+i+"</a>",s}image(e,t,i){const r=qu(e);if(r===null)return i;e=r;let s=`<img src="${e}" alt="${i}"`;return t&&(s+=` title="${t}"`),s+=">",s}text(e){return e}}class xc{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class zi{constructor(e){ze(this,"options");ze(this,"renderer");ze(this,"textRenderer");this.options=e||Xn,this.options.renderer=this.options.renderer||new bl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new xc}static parse(e,t){return new zi(t).parse(e)}static parseInline(e,t){return new zi(t).parseInline(e)}parse(e,t=!0){let i="";for(let r=0;r<e.length;r++){const s=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){const o=s,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){i+=l||"";continue}}switch(s.type){case"space":continue;case"hr":{i+=this.renderer.hr();continue}case"heading":{const o=s;i+=this.renderer.heading(this.parseInline(o.tokens),o.depth,oS(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=s;i+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=s;let l="",h="";for(let u=0;u<o.header.length;u++)h+=this.renderer.tablecell(this.parseInline(o.header[u].tokens),{header:!0,align:o.align[u]});l+=this.renderer.tablerow(h);let f="";for(let u=0;u<o.rows.length;u++){const g=o.rows[u];h="";for(let y=0;y<g.length;y++)h+=this.renderer.tablecell(this.parseInline(g[y].tokens),{header:!1,align:o.align[y]});f+=this.renderer.tablerow(h)}i+=this.renderer.table(l,f);continue}case"blockquote":{const o=s,l=this.parse(o.tokens);i+=this.renderer.blockquote(l);continue}case"list":{const o=s,l=o.ordered,h=o.start,f=o.loose;let u="";for(let g=0;g<o.items.length;g++){const y=o.items[g],w=y.checked,v=y.task;let A="";if(y.task){const O=this.renderer.checkbox(!!w);f?y.tokens.length>0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=O+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=O+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:O+" "}):A+=O+" "}A+=this.parse(y.tokens,f),u+=this.renderer.listitem(A,v,!!w)}i+=this.renderer.list(u,l,h);continue}case"html":{const o=s;i+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=s;i+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=s,l=o.tokens?this.parseInline(o.tokens):o.text;for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],l+=`
`+(o.tokens?this.parseInline(o.tokens):o.text);i+=t?this.renderer.paragraph(l):l;continue}default:{const o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}parseInline(e,t){t=t||this.renderer;let i="";for(let r=0;r<e.length;r++){const s=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){const o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=o||"";continue}}switch(s.type){case"escape":{const o=s;i+=t.text(o.text);break}case"html":{const o=s;i+=t.html(o.text);break}case"link":{const o=s;i+=t.link(o.href,o.title,this.parseInline(o.tokens,t));break}case"image":{const o=s;i+=t.image(o.href,o.title,o.text);break}case"strong":{const o=s;i+=t.strong(this.parseInline(o.tokens,t));break}case"em":{const o=s;i+=t.em(this.parseInline(o.tokens,t));break}case"codespan":{const o=s;i+=t.codespan(o.text);break}case"br":{i+=t.br();break}case"del":{const o=s;i+=t.del(this.parseInline(o.tokens,t));break}case"text":{const o=s;i+=t.text(o.text);break}default:{const o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}}class as{constructor(e){ze(this,"options");this.options=e||Xn}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}ze(as,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Gn,Dh,km;class BS{constructor(...e){zc(this,Gn);ze(this,"defaults",dc());ze(this,"options",this.setOptions);ze(this,"parse",io(this,Gn,Dh).call(this,Fi.lex,zi.parse));ze(this,"parseInline",io(this,Gn,Dh).call(this,Fi.lexInline,zi.parseInline));ze(this,"Parser",zi);ze(this,"Renderer",bl);ze(this,"TextRenderer",xc);ze(this,"Lexer",Fi);ze(this,"Tokenizer",ml);ze(this,"Hooks",as);this.use(...e)}walkTokens(e,t){var r,s;let i=[];for(const o of e)switch(i=i.concat(t.call(this,o)),o.type){case"table":{const l=o;for(const h of l.header)i=i.concat(this.walkTokens(h.tokens,t));for(const h of l.rows)for(const f of h)i=i.concat(this.walkTokens(f.tokens,t));break}case"list":{const l=o;i=i.concat(this.walkTokens(l.items,t));break}default:{const l=o;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[l.type]?this.defaults.extensions.childTokens[l.type].forEach(h=>{i=i.concat(this.walkTokens(l[h],t))}):l.tokens&&(i=i.concat(this.walkTokens(l.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(i=>{const r=zt({},i);if(r.async=this.defaults.async||r.async||!1,i.extensions&&(i.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const o=t.renderers[s.name];o?t.renderers[s.name]=function(...l){let h=s.renderer.apply(this,l);return h===!1&&(h=o.apply(this,l)),h}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),r.extensions=t),i.renderer){const s=this.defaults.renderer||new bl(this.defaults);for(const o in i.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const l=o,h=i.renderer[l],f=s[l];s[l]=(...u)=>{let g=h.apply(s,u);return g===!1&&(g=f.apply(s,u)),g||""}}r.renderer=s}if(i.tokenizer){const s=this.defaults.tokenizer||new ml(this.defaults);for(const o in i.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const l=o,h=i.tokenizer[l],f=s[l];s[l]=(...u)=>{let g=h.apply(s,u);return g===!1&&(g=f.apply(s,u)),g}}r.tokenizer=s}if(i.hooks){const s=this.defaults.hooks||new as;for(const o in i.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const l=o,h=i.hooks[l],f=s[l];as.passThroughHooks.has(o)?s[l]=u=>{if(this.defaults.async)return Promise.resolve(h.call(s,u)).then(y=>f.call(s,y));const g=h.call(s,u);return f.call(s,g)}:s[l]=(...u)=>{let g=h.apply(s,u);return g===!1&&(g=f.apply(s,u)),g}}r.hooks=s}if(i.walkTokens){const s=this.defaults.walkTokens,o=i.walkTokens;r.walkTokens=function(l){let h=[];return h.push(o.call(this,l)),s&&(h=h.concat(s.call(this,l))),h}}this.defaults=zt(zt({},this.defaults),r)}),this}setOptions(e){return this.defaults=zt(zt({},this.defaults),e),this}lexer(e,t){return Fi.lex(e,t!=null?t:this.defaults)}parser(e,t){return zi.parse(e,t!=null?t:this.defaults)}}Gn=new WeakSet,Dh=function(e,t){return(i,r)=>{const s=zt({},r),o=zt(zt({},this.defaults),s);this.defaults.async===!0&&s.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const l=io(this,Gn,km).call(this,!!o.silent,!!o.async);if(typeof i=="undefined"||i===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(i):i).then(h=>e(h,o)).then(h=>o.hooks?o.hooks.processAllTokens(h):h).then(h=>o.walkTokens?Promise.all(this.walkTokens(h,o.walkTokens)).then(()=>h):h).then(h=>t(h,o)).then(h=>o.hooks?o.hooks.postprocess(h):h).catch(l);try{o.hooks&&(i=o.hooks.preprocess(i));let h=e(i,o);o.hooks&&(h=o.hooks.processAllTokens(h)),o.walkTokens&&this.walkTokens(h,o.walkTokens);let f=t(h,o);return o.hooks&&(f=o.hooks.postprocess(f)),f}catch(h){return l(h)}}},km=function(e,t){return i=>{if(i.message+=`
Please report this to https://github.com/markedjs/marked.`,e){const r="<p>An error occurred:</p><pre>"+Kt(i.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(i);throw i}};const Qn=new BS;function Le(n,e){return Qn.parse(n,e)}Le.options=Le.setOptions=function(n){return Qn.setOptions(n),Le.defaults=Qn.defaults,fm(Le.defaults),Le};Le.getDefaults=dc;Le.defaults=Xn;Le.use=function(...n){return Qn.use(...n),Le.defaults=Qn.defaults,fm(Le.defaults),Le};Le.walkTokens=function(n,e){return Qn.walkTokens(n,e)};Le.parseInline=Qn.parseInline;Le.Parser=zi;Le.parser=zi.parse;Le.Renderer=bl;Le.TextRenderer=xc;Le.Lexer=Fi;Le.lexer=Fi.lex;Le.Tokenizer=ml;Le.Hooks=as;Le.parse=Le;Le.options;Le.setOptions;Le.use;Le.walkTokens;Le.parseInline;zi.parse;Fi.lex;/*! @license DOMPurify 3.1.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.3/LICENSE */const{entries:vm,setPrototypeOf:Qu,isFrozen:_S,getPrototypeOf:HS,getOwnPropertyDescriptor:FS}=Object;let{freeze:Pt,seal:ci,create:Sm}=Object,{apply:Rh,construct:Lh}=typeof Reflect!="undefined"&&Reflect;Pt||(Pt=function(e){return e});ci||(ci=function(e){return e});Rh||(Rh=function(e,t,i){return e.apply(t,i)});Lh||(Lh=function(e,t){return new e(...t)});const Mo=jt(Array.prototype.forEach),Gu=jt(Array.prototype.pop),Kr=jt(Array.prototype.push),Wo=jt(String.prototype.toLowerCase),Ea=jt(String.prototype.toString),Ku=jt(String.prototype.match),Xr=jt(String.prototype.replace),zS=jt(String.prototype.indexOf),$S=jt(String.prototype.trim),mi=jt(Object.prototype.hasOwnProperty),Mt=jt(RegExp.prototype.test),Yr=WS(TypeError),Xu=jt(Number.isNaN);function jt(n){return function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Rh(n,e,i)}}function WS(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Lh(n,t)}}function ve(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Wo;Qu&&Qu(n,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const s=t(r);s!==r&&(_S(e)||(e[i]=s),r=s)}n[r]=!0}return n}function qS(n){for(let e=0;e<n.length;e++)mi(n,e)||(n[e]=null);return n}function Hn(n){const e=Sm(null);for(const[t,i]of vm(n))mi(n,t)&&(Array.isArray(i)?e[t]=qS(i):i&&typeof i=="object"&&i.constructor===Object?e[t]=Hn(i):e[t]=i);return e}function Do(n,e){for(;n!==null;){const i=FS(n,e);if(i){if(i.get)return jt(i.get);if(typeof i.value=="function")return jt(i.value)}n=HS(n)}function t(){return null}return t}const Yu=Pt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ma=Pt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Da=Pt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),jS=Pt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ra=Pt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),VS=Pt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ju=Pt(["#text"]),Zu=Pt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),La=Pt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ed=Pt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ro=Pt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),US=ci(/\{\{[\w\W]*|[\w\W]*\}\}/gm),QS=ci(/<%[\w\W]*|[\w\W]*%>/gm),GS=ci(/\${[\w\W]*}/gm),KS=ci(/^data-[\-\w.\u00B7-\uFFFF]/),XS=ci(/^aria-[\-\w]+$/),Cm=ci(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),YS=ci(/^(?:\w+script|data):/i),JS=ci(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Am=ci(/^html$/i),ZS=ci(/^[a-z][.\w]*(-[.\w]+)+$/i);var td=Object.freeze({__proto__:null,MUSTACHE_EXPR:US,ERB_EXPR:QS,TMPLIT_EXPR:GS,DATA_ATTR:KS,ARIA_ATTR:XS,IS_ALLOWED_URI:Cm,IS_SCRIPT_OR_DATA:YS,ATTR_WHITESPACE:JS,DOCTYPE_NAME:Am,CUSTOM_ELEMENT:ZS});const Bn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},eC=function(){return typeof window=="undefined"?null:window},tC=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch(o){return console.warn("TrustedTypes policy "+s+" could not be created."),null}};function Tm(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eC();const e=re=>Tm(re);if(e.version="3.1.3",e.removed=[],!n||!n.document||n.document.nodeType!==Bn.document)return e.isSupported=!1,e;let{document:t}=n;const i=t,r=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:l,Element:h,NodeFilter:f,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:g,DOMParser:y,trustedTypes:w}=n,v=h.prototype,A=Do(v,"cloneNode"),O=Do(v,"nextSibling"),R=Do(v,"childNodes"),F=Do(v,"parentNode");if(typeof o=="function"){const re=t.createElement("template");re.content&&re.content.ownerDocument&&(t=re.content.ownerDocument)}let W,V="";const{implementation:z,createNodeIterator:G,createDocumentFragment:p,getElementsByTagName:he}=t,{importNode:Z}=i;let ae={};e.isSupported=typeof vm=="function"&&typeof F=="function"&&z&&z.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:pe,ERB_EXPR:fe,TMPLIT_EXPR:ne,DATA_ATTR:xe,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:ot,ATTR_WHITESPACE:_e,CUSTOM_ELEMENT:Ze}=td;let{IS_ALLOWED_URI:Qe}=td,me=null;const lt=ve({},[...Yu,...Ma,...Da,...Ra,...Ju]);let Oe=null;const It=ve({},[...Zu,...La,...ed,...Ro]);let Ee=Object.seal(Sm(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Zt=null,nn=null,Is=!0,Ar=!0,Tr=!1,Vt=!0,rn=!1,ki=!0,ei=!1,Yn=!1,Or=!1,vi=!1,ji=!1,Nt=!1,Ns=!0,Bs=!1;const Nl="user-content-";let Bt=!0,ui=!1,ti={},J=null;const ft=ve({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _s=null;const Hs=ve({},["audio","video","img","source","image","track"]);let Er=null;const Mr=ve({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mn="http://www.w3.org/1998/Math/MathML",Si="http://www.w3.org/2000/svg",et="http://www.w3.org/1999/xhtml";let _t=et,Ci=!1,Dr=null;const Jn=ve({},[Mn,Si,et],Ea);let sn=null;const Fs=["application/xhtml+xml","text/html"],Bl="text/html";let We=null,ii=null;const Rr=255,zs=t.createElement("form"),Ot=function(M){return M instanceof RegExp||M instanceof Function},at=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ii&&ii===M)){if((!M||typeof M!="object")&&(M={}),M=Hn(M),sn=Fs.indexOf(M.PARSER_MEDIA_TYPE)===-1?Bl:M.PARSER_MEDIA_TYPE,We=sn==="application/xhtml+xml"?Ea:Wo,me=mi(M,"ALLOWED_TAGS")?ve({},M.ALLOWED_TAGS,We):lt,Oe=mi(M,"ALLOWED_ATTR")?ve({},M.ALLOWED_ATTR,We):It,Dr=mi(M,"ALLOWED_NAMESPACES")?ve({},M.ALLOWED_NAMESPACES,Ea):Jn,Er=mi(M,"ADD_URI_SAFE_ATTR")?ve(Hn(Mr),M.ADD_URI_SAFE_ATTR,We):Mr,_s=mi(M,"ADD_DATA_URI_TAGS")?ve(Hn(Hs),M.ADD_DATA_URI_TAGS,We):Hs,J=mi(M,"FORBID_CONTENTS")?ve({},M.FORBID_CONTENTS,We):ft,Zt=mi(M,"FORBID_TAGS")?ve({},M.FORBID_TAGS,We):{},nn=mi(M,"FORBID_ATTR")?ve({},M.FORBID_ATTR,We):{},ti=mi(M,"USE_PROFILES")?M.USE_PROFILES:!1,Is=M.ALLOW_ARIA_ATTR!==!1,Ar=M.ALLOW_DATA_ATTR!==!1,Tr=M.ALLOW_UNKNOWN_PROTOCOLS||!1,Vt=M.ALLOW_SELF_CLOSE_IN_ATTR!==!1,rn=M.SAFE_FOR_TEMPLATES||!1,ki=M.SAFE_FOR_XML!==!1,ei=M.WHOLE_DOCUMENT||!1,vi=M.RETURN_DOM||!1,ji=M.RETURN_DOM_FRAGMENT||!1,Nt=M.RETURN_TRUSTED_TYPE||!1,Or=M.FORCE_BODY||!1,Ns=M.SANITIZE_DOM!==!1,Bs=M.SANITIZE_NAMED_PROPS||!1,Bt=M.KEEP_CONTENT!==!1,ui=M.IN_PLACE||!1,Qe=M.ALLOWED_URI_REGEXP||Cm,_t=M.NAMESPACE||et,Ee=M.CUSTOM_ELEMENT_HANDLING||{},M.CUSTOM_ELEMENT_HANDLING&&Ot(M.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ee.tagNameCheck=M.CUSTOM_ELEMENT_HANDLING.tagNameCheck),M.CUSTOM_ELEMENT_HANDLING&&Ot(M.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ee.attributeNameCheck=M.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),M.CUSTOM_ELEMENT_HANDLING&&typeof M.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Ee.allowCustomizedBuiltInElements=M.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),rn&&(Ar=!1),ji&&(vi=!0),ti&&(me=ve({},Ju),Oe=[],ti.html===!0&&(ve(me,Yu),ve(Oe,Zu)),ti.svg===!0&&(ve(me,Ma),ve(Oe,La),ve(Oe,Ro)),ti.svgFilters===!0&&(ve(me,Da),ve(Oe,La),ve(Oe,Ro)),ti.mathMl===!0&&(ve(me,Ra),ve(Oe,ed),ve(Oe,Ro))),M.ADD_TAGS&&(me===lt&&(me=Hn(me)),ve(me,M.ADD_TAGS,We)),M.ADD_ATTR&&(Oe===It&&(Oe=Hn(Oe)),ve(Oe,M.ADD_ATTR,We)),M.ADD_URI_SAFE_ATTR&&ve(Er,M.ADD_URI_SAFE_ATTR,We),M.FORBID_CONTENTS&&(J===ft&&(J=Hn(J)),ve(J,M.FORBID_CONTENTS,We)),Bt&&(me["#text"]=!0),ei&&ve(me,["html","head","body"]),me.table&&(ve(me,["tbody"]),delete Zt.tbody),M.TRUSTED_TYPES_POLICY){if(typeof M.TRUSTED_TYPES_POLICY.createHTML!="function")throw Yr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof M.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Yr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');W=M.TRUSTED_TYPES_POLICY,V=W.createHTML("")}else W===void 0&&(W=tC(w,r)),W!==null&&typeof V=="string"&&(V=W.createHTML(""));Pt&&Pt(M),ii=M}},Zn=ve({},["mi","mo","mn","ms","mtext"]),$s=ve({},["foreignobject","annotation-xml"]),Ws=ve({},["title","style","font","a","script"]),Lr=ve({},[...Ma,...Da,...jS]),Vi=ve({},[...Ra,...VS]),on=function(M){let $=F(M);(!$||!$.tagName)&&($={namespaceURI:_t,tagName:"template"});const Y=Wo(M.tagName),ge=Wo($.tagName);return Dr[M.namespaceURI]?M.namespaceURI===Si?$.namespaceURI===et?Y==="svg":$.namespaceURI===Mn?Y==="svg"&&(ge==="annotation-xml"||Zn[ge]):!!Lr[Y]:M.namespaceURI===Mn?$.namespaceURI===et?Y==="math":$.namespaceURI===Si?Y==="math"&&$s[ge]:!!Vi[Y]:M.namespaceURI===et?$.namespaceURI===Si&&!$s[ge]||$.namespaceURI===Mn&&!Zn[ge]?!1:!Vi[Y]&&(Ws[Y]||!Lr[Y]):!!(sn==="application/xhtml+xml"&&Dr[M.namespaceURI]):!1},kt=function(M){Kr(e.removed,{element:M});try{M.parentNode.removeChild(M)}catch($){M.remove()}},Ui=function(M,$){try{Kr(e.removed,{attribute:$.getAttributeNode(M),from:$})}catch(Y){Kr(e.removed,{attribute:null,from:$})}if($.removeAttribute(M),M==="is"&&!Oe[M])if(vi||ji)try{kt($)}catch(Y){}else try{$.setAttribute(M,"")}catch(Y){}},qs=function(M){let $=null,Y=null;if(Or)M="<remove></remove>"+M;else{const Ye=Ku(M,/^[\r\n\t ]+/);Y=Ye&&Ye[0]}sn==="application/xhtml+xml"&&_t===et&&(M='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+M+"</body></html>");const ge=W?W.createHTML(M):M;if(_t===et)try{$=new y().parseFromString(ge,sn)}catch(Ye){}if(!$||!$.documentElement){$=z.createDocument(_t,"template",null);try{$.documentElement.innerHTML=Ci?V:ge}catch(Ye){}}const Ge=$.body||$.documentElement;return M&&Y&&Ge.insertBefore(t.createTextNode(Y),Ge.childNodes[0]||null),_t===et?he.call($,ei?"html":"body")[0]:ei?$.documentElement:Ge},js=function(M){return G.call(M.ownerDocument||M,M,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Vs=function(M){return M instanceof g&&(typeof M.__depth!="undefined"&&typeof M.__depth!="number"||typeof M.__removalCount!="undefined"&&typeof M.__removalCount!="number"||typeof M.nodeName!="string"||typeof M.textContent!="string"||typeof M.removeChild!="function"||!(M.attributes instanceof u)||typeof M.removeAttribute!="function"||typeof M.setAttribute!="function"||typeof M.namespaceURI!="string"||typeof M.insertBefore!="function"||typeof M.hasChildNodes!="function")},Pr=function(M){return typeof l=="function"&&M instanceof l},di=function(M,$,Y){ae[M]&&Mo(ae[M],ge=>{ge.call(e,$,Y,ii)})},Us=function(M){let $=null;if(di("beforeSanitizeElements",M,null),Vs(M))return kt(M),!0;const Y=We(M.nodeName);if(di("uponSanitizeElement",M,{tagName:Y,allowedTags:me}),M.hasChildNodes()&&!Pr(M.firstElementChild)&&Mt(/<[/\w]/g,M.innerHTML)&&Mt(/<[/\w]/g,M.textContent)||M.nodeType===Bn.progressingInstruction||ki&&M.nodeType===Bn.comment&&Mt(/<[/\w]/g,M.data))return kt(M),!0;if(!me[Y]||Zt[Y]){if(!Zt[Y]&&Qs(Y)&&(Ee.tagNameCheck instanceof RegExp&&Mt(Ee.tagNameCheck,Y)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(Y)))return!1;if(Bt&&!J[Y]){const ge=F(M)||M.parentNode,Ge=R(M)||M.childNodes;if(Ge&&ge){const Ye=Ge.length;for(let ut=Ye-1;ut>=0;--ut){const dt=A(Ge[ut],!0);dt.__removalCount=(M.__removalCount||0)+1,ge.insertBefore(dt,O(M))}}}return kt(M),!0}return M instanceof h&&!on(M)||(Y==="noscript"||Y==="noembed"||Y==="noframes")&&Mt(/<\/no(script|embed|frames)/i,M.innerHTML)?(kt(M),!0):(rn&&M.nodeType===Bn.text&&($=M.textContent,Mo([pe,fe,ne],ge=>{$=Xr($,ge," ")}),M.textContent!==$&&(Kr(e.removed,{element:M.cloneNode()}),M.textContent=$)),di("afterSanitizeElements",M,null),!1)},Ir=function(M,$,Y){if(Ns&&($==="id"||$==="name")&&(Y in t||Y in zs||Y==="__depth"||Y==="__removalCount"))return!1;if(!(Ar&&!nn[$]&&Mt(xe,$))){if(!(Is&&Mt(Be,$))){if(!Oe[$]||nn[$]){if(!(Qs(M)&&(Ee.tagNameCheck instanceof RegExp&&Mt(Ee.tagNameCheck,M)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(M))&&(Ee.attributeNameCheck instanceof RegExp&&Mt(Ee.attributeNameCheck,$)||Ee.attributeNameCheck instanceof Function&&Ee.attributeNameCheck($))||$==="is"&&Ee.allowCustomizedBuiltInElements&&(Ee.tagNameCheck instanceof RegExp&&Mt(Ee.tagNameCheck,Y)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(Y))))return!1}else if(!Er[$]){if(!Mt(Qe,Xr(Y,_e,""))){if(!(($==="src"||$==="xlink:href"||$==="href")&&M!=="script"&&zS(Y,"data:")===0&&_s[M])){if(!(Tr&&!Mt(ot,Xr(Y,_e,"")))){if(Y)return!1}}}}}}return!0},Qs=function(M){return M!=="annotation-xml"&&Ku(M,Ze)},Qi=function(M){di("beforeSanitizeAttributes",M,null);const{attributes:$}=M;if(!$)return;const Y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe};let ge=$.length;for(;ge--;){const Ge=$[ge],{name:Ye,namespaceURI:ut,value:dt}=Ge,ln=We(Ye);let pt=Ye==="value"?dt:$S(dt);if(Y.attrName=ln,Y.attrValue=pt,Y.keepAttr=!0,Y.forceKeepAttr=void 0,di("uponSanitizeAttribute",M,Y),pt=Y.attrValue,Y.forceKeepAttr||(Ui(Ye,M),!Y.keepAttr))continue;if(!Vt&&Mt(/\/>/i,pt)){Ui(Ye,M);continue}if(ki&&Mt(/((--!?|])>)|<\/(style|title)/i,pt)){Ui(Ye,M);continue}rn&&Mo([pe,fe,ne],Ks=>{pt=Xr(pt,Ks," ")});const er=We(M.nodeName);if(Ir(er,ln,pt)){if(Bs&&(ln==="id"||ln==="name")&&(Ui(Ye,M),pt=Nl+pt),W&&typeof w=="object"&&typeof w.getAttributeType=="function"&&!ut)switch(w.getAttributeType(er,ln)){case"TrustedHTML":{pt=W.createHTML(pt);break}case"TrustedScriptURL":{pt=W.createScriptURL(pt);break}}try{ut?M.setAttributeNS(ut,Ye,pt):M.setAttribute(Ye,pt),Vs(M)?kt(M):Gu(e.removed)}catch(Ks){}}}di("afterSanitizeAttributes",M,null)},Gs=function re(M){let $=null;const Y=js(M);for(di("beforeSanitizeShadowDOM",M,null);$=Y.nextNode();){if(di("uponSanitizeShadowNode",$,null),Us($))continue;const ge=F($);$.nodeType===Bn.element&&(ge&&ge.__depth?$.__depth=($.__removalCount||0)+ge.__depth+1:$.__depth=1),($.__depth>=Rr||$.__depth<0||Xu($.__depth))&&kt($),$.content instanceof s&&($.content.__depth=$.__depth,re($.content)),Qi($)}di("afterSanitizeShadowDOM",M,null)};return e.sanitize=function(re){let M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,Y=null,ge=null,Ge=null;if(Ci=!re,Ci&&(re="<!-->"),typeof re!="string"&&!Pr(re))if(typeof re.toString=="function"){if(re=re.toString(),typeof re!="string")throw Yr("dirty is not a string, aborting")}else throw Yr("toString is not a function");if(!e.isSupported)return re;if(Yn||at(M),e.removed=[],typeof re=="string"&&(ui=!1),ui){if(re.nodeName){const dt=We(re.nodeName);if(!me[dt]||Zt[dt])throw Yr("root node is forbidden and cannot be sanitized in-place")}}else if(re instanceof l)$=qs("<!---->"),Y=$.ownerDocument.importNode(re,!0),Y.nodeType===Bn.element&&Y.nodeName==="BODY"||Y.nodeName==="HTML"?$=Y:$.appendChild(Y);else{if(!vi&&!rn&&!ei&&re.indexOf("<")===-1)return W&&Nt?W.createHTML(re):re;if($=qs(re),!$)return vi?null:Nt?V:""}$&&Or&&kt($.firstChild);const Ye=js(ui?re:$);for(;ge=Ye.nextNode();){if(Us(ge))continue;const dt=F(ge);ge.nodeType===Bn.element&&(dt&&dt.__depth?ge.__depth=(ge.__removalCount||0)+dt.__depth+1:ge.__depth=1),(ge.__depth>=Rr||ge.__depth<0||Xu(ge.__depth))&&kt(ge),ge.content instanceof s&&(ge.content.__depth=ge.__depth,Gs(ge.content)),Qi(ge)}if(ui)return re;if(vi){if(ji)for(Ge=p.call($.ownerDocument);$.firstChild;)Ge.appendChild($.firstChild);else Ge=$;return(Oe.shadowroot||Oe.shadowrootmode)&&(Ge=Z.call(i,Ge,!0)),Ge}let ut=ei?$.outerHTML:$.innerHTML;return ei&&me["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&Mt(Am,$.ownerDocument.doctype.name)&&(ut="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
`+ut),rn&&Mo([pe,fe,ne],dt=>{ut=Xr(ut,dt," ")}),W&&Nt?W.createHTML(ut):ut},e.setConfig=function(){let re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};at(re),Yn=!0},e.clearConfig=function(){ii=null,Yn=!1},e.isValidAttribute=function(re,M,$){ii||at({});const Y=We(re),ge=We(M);return Ir(Y,ge,$)},e.addHook=function(re,M){typeof M=="function"&&(ae[re]=ae[re]||[],Kr(ae[re],M))},e.removeHook=function(re){if(ae[re])return Gu(ae[re])},e.removeHooks=function(re){ae[re]&&(ae[re]=[])},e.removeAllHooks=function(){ae={}},e}var Om=Tm();function Em(){const n=document.querySelector(".alert-danger.db-error");return n?n.textContent.trim():null}function id(n,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>n.apply(this,i),e)}}function nd(){window.assistantChoices&&window.assistantChoices.destroy(),Ph.get().then(n=>{const e=Object.keys(n),t=document.createElement("select");t.className="js-choice",t.toggleAttribute("multiple"),t.toggleAttribute("data-trigger"),e.forEach(h=>{const f=document.createElement("option");f.value=h,f.textContent=h,t.appendChild(f)});const i=document.getElementById("table-list");i.innerHTML="",i.appendChild(t);const r=new b0(".js-choice",{removeItemButton:!0,searchEnabled:!0,shouldSort:!1,position:"bottom",placeholderValue:"Click to search for relevant tables"});window.assistantChoices=r,document.getElementById("select_all_button").addEventListener("click",h=>{h.preventDefault(),r.setChoiceByValue(e)}),document.getElementById("deselect_all_button").addEventListener("click",h=>{h.preventDefault(),e.forEach(f=>{r.removeActiveItemsByValue(f)})}),document.getElementById("refresh_tables_button").addEventListener("click",h=>{h.preventDefault(),e.forEach(f=>{r.removeActiveItemsByValue(f)}),Pa(r,e),rd(r,e)}),Pa(r,e),document.addEventListener("docChanged",id(()=>Pa(r,e),500)),document.getElementById("id_assistant_input").addEventListener("input",id(()=>rd(r,e),300))}).catch(n=>{console.error("Error retrieving JSON schema:",n)})}function Pa(n,e){const t=window.editor.state.doc.toString().toLowerCase(),i=new Set(t.split(/\s+/)),r=e.filter(s=>i.has(s.toLowerCase()));n.setChoiceByValue(r)}function rd(n,e){const t=document.getElementById("id_assistant_input").value,i=new Set(t.toLowerCase().split(/\s+/)),r=e.filter(s=>i.has(s.toLowerCase()));n.setChoiceByValue(r)}function iC(n=!1){Ih().addEventListener("change",nd),nd();const e=Em();if(n||e){const i=document.getElementById("assistant_collapse");new u0(i,{toggle:!1}).show(),e&&document.getElementById("id_error_help_message").classList.remove("d-none")}[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(i=>new d0(i)),document.getElementById("id_assistant_input").addEventListener("keydown",function(i){(i.ctrlKey||i.metaKey)&&i.key==="Enter"&&(i.preventDefault(),sd())}),document.getElementById("ask_assistant_btn").addEventListener("click",sd),document.getElementById("assistant_history").addEventListener("click",nC)}function nC(){var i,r;const n="historyModal",e=document.getElementById(n);e&&e.remove();const t={connection_id:(r=(i=document.getElementById("id_database_connection"))==null?void 0:i.value)!=null?r:null};fetch(`${window.baseUrlPath}assistant/history/`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":Nh()},body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.json()}).then(s=>{let o="";s.logs.forEach(u=>{let g=Om.sanitize(Le.parse(u.response));o+=`
                <tr>
                    <td>${u.user_request}</td>
                    <td>${g}</td>
                </tr>
            `});const l=`
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>User Request</th>
                        <th>Response</th>
                    </tr>
                </thead>
                <tbody>
                    ${o}
                </tbody>
            </table>
        `,h=`
            <div class="modal fade" id="${n}" tabindex="-1" aria-labelledby="historyModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="historyModalLabel">Assistant History</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            ${l}
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                        </div>
                    </div>
                </div>
            </div>
        `;document.body.insertAdjacentHTML("beforeend",h),new p0(document.getElementById(n)).show()}).catch(s=>{console.error("There was a problem with the fetch operation:",s)})}function sd(){var e,t,i,r,s,o;const n={sql:(t=(e=window.editor)==null?void 0:e.state.doc.toString())!=null?t:null,connection_id:(r=(i=document.getElementById("id_database_connection"))==null?void 0:i.value)!=null?r:null,assistant_request:(o=(s=document.getElementById("id_assistant_input"))==null?void 0:s.value)!=null?o:null,selected_tables:assistantChoices.getValue(!0),db_error:Em()};document.getElementById("assistant_response").innerHTML="",document.getElementById("response_block").classList.remove("d-none"),document.getElementById("assistant_spinner").classList.remove("d-none"),fetch(`${window.baseUrlPath}assistant/`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":Nh()},body:JSON.stringify(n)}).then(l=>{if(!l.ok)throw new Error("Network response was not ok");return l.json()}).then(l=>{var y,w;const h=Om.sanitize(Le.parse(l.message));document.getElementById("assistant_response").innerHTML=h,document.getElementById("assistant_spinner").classList.add("d-none");const f=document.querySelectorAll("#assistant_response pre");f.length===1&&((y=window.editor)==null?void 0:y.state.doc.toString().trim())===""&&window.editor.dispatch({changes:{from:0,insert:f[0].textContent}});const u=(w=document.getElementById("id_assistant_input"))==null?void 0:w.value,g=document.getElementById("id_description");(g==null?void 0:g.value)===""&&(g.value=u),rC()}).catch(l=>{console.error("Error:",l)})}function rC(){document.querySelectorAll("#assistant_response pre").forEach(n=>{const e=document.createElement("i");e.classList.add("copy-btn"),e.classList.add("bi-copy");const t=document.createElement("span");t.textContent="Copied!",t.style.display="none",t.style.marginLeft="8px",e.appendChild(t),n.appendChild(e),e.addEventListener("click",function(){const i=this.parentNode.firstElementChild.innerText;navigator.clipboard.writeText(i).then(()=>{t.style.display="inline",setTimeout(()=>{t.style.display="none"},2e3)}).catch(r=>{console.error("Error in copying text: ",r)})})})}function od(){Ph.get().then(n=>{window.editor.dispatch({effects:be.appendConfig.of(Pl.language.data.of({autocomplete:cm({schema:n})}))})}),Me("#schema_frame").attr("src",`${window.baseUrlPath}schema/${Ih().value}`)}function sC(n){let e=new te({doc:n.value,extensions:[tS]});return n.parentNode.insertBefore(e.dom,n),n.style.display="none",n.form&&n.form.addEventListener("submit",()=>{n.value=e.state.doc.toString()}),e}function oC(){var n=new URLSearchParams(window.location.search),e=n.get("connection");if(e){var t=document.getElementById("id_database_connection");t&&(t.value=e)}}class mC{constructor(e){ze(this,"handleBeforeUnload",e=>{if(clientRoute==="query_detail"&&this.docChanged){const t="You have unsaved changes to your query.";return e.returnValue=t,t}});oC();const t=document.getElementById("assistant_accordion"),i=document.getElementById("nav-preview");t&&iC(!i&&e==="new"),this.queryId=e,this.$rows=Me("#rows"),this.$form=Me("form"),this.$snapshotField=Me("#id_snapshot"),this.docChanged=!1,this.$submit=Me("#refresh_play_button, #save_button"),this.$submit.length||(this.$submit=Me("#refresh_button")),this.editor=sC(document.getElementById("id_sql")),window.editor=this.editor,document.addEventListener("submitEventFromCM",r=>{this.$submit.click()}),document.addEventListener("formatEventFromCM",r=>{this.formatSql()}),document.addEventListener("docChanged",r=>{this.docChanged=!0}),this.bind(),ea.get("schema_sidebar_open")==="true"&&this.showSchema(!0)}getParams(){let e=!1;const t=document.querySelectorAll("form .param");return t.length&&(e={},t.forEach(i=>{e[i.dataset.param]=i.value})),e}serializeParams(e){var t=[];for(var i in e)t.push(i+":"+e[i]);return encodeURIComponent(t.join("|"))}updateQueryString(e,t,i){i||(i=window.location.href);var r=new RegExp("([?&])"+e+"=.*?(&|#|$)(.*)","gi"),s=i.split("#");if(r.test(i))return typeof t!="undefined"&&t!==null?i.replace(r,"$1"+e+"="+t+"$2$3"):(i=s[0].replace(r,"$1$3").replace(/(&|\?)$/,""),typeof s[1]!="undefined"&&s[1]!==null&&(i+="#"+s[1]),i);if(typeof t!="undefined"&&t!==null){var o=i.indexOf("?")!==-1?"&":"?";return i=s[0]+o+e+"="+t,typeof s[1]!="undefined"&&s[1]!==null&&(i+="#"+s[1]),i}else return i}formatSql(){let e=this.editor.state.doc.toString(),t=this.editor;var i=new FormData;i.append("sql",e),fetch(`${window.baseUrlPath}format/`,{method:"POST",headers:{"X-CSRFToken":Nh()},body:i}).then(r=>r.json()).then(r=>{t.dispatch({changes:{from:0,to:t.state.doc.length,insert:r.formatted}})}).catch(r=>console.error("Error:",r))}showRows(){let e=document.getElementById("rows").value,t=document.getElementById("editor");t.setAttribute("action",this.updateQueryString("rows",e,window.location.href)),t.submit()}showSchema(e){e===!0&&Me("#schema_frame").addClass("no-autofocus"),Me("#query_area").removeClass("col").addClass("col-9");var t=Me("#schema");return t.addClass("col-md-3"),t.show(),Me("#show_schema_button").hide(),Me("#hide_schema_button").show(),ea.set("schema_sidebar_open","true"),!1}hideSchema(){Me("#query_area").removeClass("col-9").addClass("col");var e=Me("#schema");return e.removeClass("col-3"),e.hide(),Me("#hide_schema_button").hide(),Me("#show_schema_button").show(),ea.set("schema_sidebar_open","false"),!1}bind(){var r,s;window.addEventListener("beforeunload",this.handleBeforeUnload),document.addEventListener("submit",o=>{o.target.id==="editor"&&window.removeEventListener("beforeunload",this.handleBeforeUnload)}),document.querySelectorAll(".query_favorite_toggle").forEach(function(o){o.addEventListener("click",w0)}),(r=document.getElementById("show_schema_button"))==null||r.addEventListener("click",this.showSchema.bind(this)),(s=document.getElementById("hide_schema_button"))==null||s.addEventListener("click",this.hideSchema.bind(this)),Me("#format_button").click(function(o){o.preventDefault(),this.formatSql()}.bind(this)),Me("#rows").keyup(function(){var o=Me("#fullscreen").attr("href"),l=o.replace(/rows=\d+/,"rows="+Me("#rows").val());Me("#fullscreen").attr("href",l)}.bind(this)),Me("#save_button").click(function(){var o=this.getParams(this);o&&this.$form.attr("action","../"+this.queryId+"/?params="+this.serializeParams(o)),this.$snapshotField.hide(),this.$form.append(this.$snapshotField)}.bind(this)),Me("#save_only_button").click(function(){var o=this.getParams(this);o?this.$form.attr("action","../"+this.queryId+"/?show=0&params="+this.serializeParams(o)):this.$form.attr("action","../"+this.queryId+"/?show=0"),this.$snapshotField.hide(),this.$form.append(this.$snapshotField)}.bind(this)),Me("#refresh_button").click(function(o){o.preventDefault();var l=this.getParams();l?window.location.href="../"+this.queryId+"/?params="+this.serializeParams(l):window.location.href="../"+this.queryId+"/"}.bind(this)),Me("#refresh_play_button").click(function(){this.$form.attr("action","../play/")}.bind(this)),Me("#playground_button").click(function(o){o.preventDefault(),this.$form.attr("action","../play/?show=0"),this.$form.submit()}.bind(this)),Me("#create_button").click(function(){this.$form.attr("action","../new/")}.bind(this)),Me(".download-button").click(function(o){var l="../download?format="+Me(o.target).data("format"),h=this.getParams();h&&(l=l+"&params="+h),this.$form.attr("action",l)}.bind(this)),Me(".download-query-button").click(function(o){var l="../download?format="+Me(o.target).data("format"),h=this.getParams();h&&(l=l+"&params="+h),this.$form.attr("action",l)}.bind(this)),document.querySelectorAll(".stats-expand").forEach(o=>{o.addEventListener("click",function(l){l.preventDefault(),document.querySelectorAll(".stats-expand").forEach(h=>h.style.display="none"),document.querySelectorAll(".stats-wrapper").forEach(h=>h.style.display="")})});let e=document.getElementById("counter-toggle");e&&e.addEventListener("click",function(o){o.preventDefault(),document.querySelectorAll(".counter").forEach(l=>{l.style.display=l.style.display==="none"?"":"none"})});let t=document.querySelector("#preview");if(t){let o=t.querySelectorAll("th");new x0("preview",{valueNames:Array.from(o,(l,h)=>h)})}document.querySelectorAll(".sort").forEach(o=>{o.addEventListener("click",function(l){const h=l.target;document.querySelectorAll(".sort").forEach(f=>{f.classList.add("bi-chevron-expand"),f.classList.remove("bi-chevron-down","bi-chevron-up")}),h.classList.contains("asc")?(h.classList.replace("bi-chevron-expand","bi-chevron-up"),h.classList.remove("bi-chevron-down")):(h.classList.replace("bi-chevron-expand","bi-chevron-down"),h.classList.remove("bi-chevron-up"))}.bind(this))});const i=document.querySelector('button[data-bs-target="#nav-pivot"]');i&&i.addEventListener("shown.bs.tab",o=>{g0(()=>$c(this,null,function*(){const{pivotSetup:l}=yield import("./pivot-setup.5.3.js");return{pivotSetup:l}}),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(({pivotSetup:l})=>l(Me))}),window.location.hash&&document.querySelector("#nav-pivot-tab").click(),this.$rows.change(function(){this.showRows()}.bind(this)),this.$rows.keyup(function(o){o.keyCode===13&&this.showRows()}.bind(this)),Ih().addEventListener("change",od),od()}}export{mC as ExplorerEditor};
