diff --git a/dist/assets/index-B-HByrTS.js b/dist/assets/index-B-HByrTS.js deleted file mode 100644 index 889aa32..0000000 --- a/dist/assets/index-B-HByrTS.js +++ /dev/null @@ -1,84 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function i(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(s){if(s.ep)return;s.ep=!0;const n=i(s);fetch(s.href,n)}})();function gp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dd={exports:{}},uo={},fd={exports:{}},V={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var As=Symbol.for("react.element"),vp=Symbol.for("react.portal"),mp=Symbol.for("react.fragment"),Sp=Symbol.for("react.strict_mode"),yp=Symbol.for("react.profiler"),wp=Symbol.for("react.provider"),Cp=Symbol.for("react.context"),kp=Symbol.for("react.forward_ref"),xp=Symbol.for("react.suspense"),bp=Symbol.for("react.memo"),Ep=Symbol.for("react.lazy"),sc=Symbol.iterator;function Dp(e){return e===null||typeof e!="object"?null:(e=sc&&e[sc]||e["@@iterator"],typeof e=="function"?e:null)}var _d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},pd=Object.assign,gd={};function Br(e,t,i){this.props=e,this.context=t,this.refs=gd,this.updater=i||_d}Br.prototype.isReactComponent={};Br.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Br.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function vd(){}vd.prototype=Br.prototype;function Za(e,t,i){this.props=e,this.context=t,this.refs=gd,this.updater=i||_d}var Ja=Za.prototype=new vd;Ja.constructor=Za;pd(Ja,Br.prototype);Ja.isPureReactComponent=!0;var nc=Array.isArray,md=Object.prototype.hasOwnProperty,eh={current:null},Sd={key:!0,ref:!0,__self:!0,__source:!0};function yd(e,t,i){var r,s={},n=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(n=""+t.key),t)md.call(t,r)&&!Sd.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=i;else if(1>>1,J=w[X];if(0>>1;Xs(Qe,I))ves(dt,Qe)?(w[X]=dt,w[ve]=I,X=ve):(w[X]=Qe,w[ue]=I,X=ue);else if(ves(dt,I))w[X]=dt,w[ve]=I,X=ve;else break e}}return N}function s(w,N){var I=w.sortIndex-N.sortIndex;return I!==0?I:w.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var n=performance;e.unstable_now=function(){return n.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var h=[],a=[],u=1,c=null,d=3,p=!1,_=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(w){for(var N=i(a);N!==null;){if(N.callback===null)r(a);else if(N.startTime<=w)r(a),N.sortIndex=N.expirationTime,t(h,N);else break;N=i(a)}}function y(w){if(v=!1,m(w),!_)if(i(h)!==null)_=!0,A(S);else{var N=i(a);N!==null&&F(y,N.startTime-w)}}function S(w,N){_=!1,v&&(v=!1,f(R),R=-1),p=!0;var I=d;try{for(m(N),c=i(h);c!==null&&(!(c.expirationTime>N)||w&&!U());){var X=c.callback;if(typeof X=="function"){c.callback=null,d=c.priorityLevel;var J=X(c.expirationTime<=N);N=e.unstable_now(),typeof J=="function"?c.callback=J:c===i(h)&&r(h),m(N)}else r(h);c=i(h)}if(c!==null)var Te=!0;else{var ue=i(a);ue!==null&&F(y,ue.startTime-N),Te=!1}return Te}finally{c=null,d=I,p=!1}}var C=!1,b=null,R=-1,W=5,$=-1;function U(){return!(e.unstable_now()-$w||125X?(w.sortIndex=I,t(a,w),i(h)===null&&w===i(a)&&(v?(f(R),R=-1):v=!0,F(y,I-X))):(w.sortIndex=J,t(h,w),_||p||(_=!0,A(S))),w},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(w){var N=d;return function(){var I=d;d=N;try{return w.apply(this,arguments)}finally{d=I}}}})(bd);xd.exports=bd;var Fp=xd.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Hp=Y,ht=Fp;function D(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cl=Object.prototype.hasOwnProperty,$p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lc={},ac={};function Wp(e){return Cl.call(ac,e)?!0:Cl.call(lc,e)?!1:$p.test(e)?ac[e]=!0:(lc[e]=!0,!1)}function Up(e,t,i,r){if(i!==null&&i.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Kp(e,t,i,r){if(t===null||typeof t>"u"||Up(e,t,i,r))return!0;if(r)return!1;if(i!==null)switch(i.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function qe(e,t,i,r,s,n,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=i,this.propertyName=e,this.type=t,this.sanitizeURL=n,this.removeEmptyString=o}var ze={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ze[e]=new qe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ze[t]=new qe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ze[e]=new qe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ze[e]=new qe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ze[e]=new qe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ze[e]=new qe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ze[e]=new qe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ze[e]=new qe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ze[e]=new qe(e,5,!1,e.toLowerCase(),null,!1,!1)});var ih=/[\-:]([a-z])/g;function rh(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ih,rh);ze[t]=new qe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ih,rh);ze[t]=new qe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ih,rh);ze[t]=new qe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ze[e]=new qe(e,1,!1,e.toLowerCase(),null,!1,!1)});ze.xlinkHref=new qe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ze[e]=new qe(e,1,!1,e.toLowerCase(),null,!0,!0)});function sh(e,t,i,r){var s=ze.hasOwnProperty(t)?ze[t]:null;(s!==null?s.type!==0:r||!(2l||s[o]!==n[l]){var h=` -`+s[o].replace(" at new "," at ");return e.displayName&&h.includes("")&&(h=h.replace("",e.displayName)),h}while(1<=o&&0<=l);break}}}finally{Ao=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?Qr(e):""}function jp(e){switch(e.tag){case 5:return Qr(e.type);case 16:return Qr("Lazy");case 13:return Qr("Suspense");case 19:return Qr("SuspenseList");case 0:case 2:case 15:return e=Io(e.type,!1),e;case 11:return e=Io(e.type.render,!1),e;case 1:return e=Io(e.type,!0),e;default:return""}}function El(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case sr:return"Fragment";case rr:return"Portal";case kl:return"Profiler";case nh:return"StrictMode";case xl:return"Suspense";case bl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Rd:return(e.displayName||"Context")+".Consumer";case Dd:return(e._context.displayName||"Context")+".Provider";case oh:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case lh:return t=e.displayName||null,t!==null?t:El(e.type)||"Memo";case hi:t=e._payload,e=e._init;try{return El(e(t))}catch{}}return null}function Vp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return El(t);case 8:return t===nh?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Ei(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ld(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Yp(e){var t=Ld(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var s=i.get,n=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,n.call(this,o)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Xs(e){e._valueTracker||(e._valueTracker=Yp(e))}function Bd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),r="";return e&&(r=Ld(e)?e.checked?"true":"false":e.value),e=r,e!==i?(t.setValue(e),!0):!1}function On(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Dl(e,t){var i=t.checked;return ce({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function cc(e,t){var i=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;i=Ei(t.value!=null?t.value:i),e._wrapperState={initialChecked:r,initialValue:i,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Md(e,t){t=t.checked,t!=null&&sh(e,"checked",t,!1)}function Rl(e,t){Md(e,t);var i=Ei(t.value),r=t.type;if(i!=null)r==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Pl(e,t.type,i):t.hasOwnProperty("defaultValue")&&Pl(e,t.type,Ei(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function uc(e,t,i){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,i||t===e.value||(e.value=t),e.defaultValue=t}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Pl(e,t,i){(t!=="number"||On(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Zr=Array.isArray;function gr(e,t,i,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Gs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function vs(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var os={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qp=["Webkit","ms","Moz","O"];Object.keys(os).forEach(function(e){qp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),os[t]=os[e]})});function Ad(e,t,i){return t==null||typeof t=="boolean"||t===""?"":i||typeof t!="number"||t===0||os.hasOwnProperty(e)&&os[e]?(""+t).trim():t+"px"}function Id(e,t){e=e.style;for(var i in t)if(t.hasOwnProperty(i)){var r=i.indexOf("--")===0,s=Ad(i,t[i],r);i==="float"&&(i="cssFloat"),r?e.setProperty(i,s):e[i]=s}}var Xp=ce({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ml(e,t){if(t){if(Xp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(D(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(D(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(D(61))}if(t.style!=null&&typeof t.style!="object")throw Error(D(62))}}function Tl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Nl=null;function ah(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ol=null,vr=null,mr=null;function _c(e){if(e=Fs(e)){if(typeof Ol!="function")throw Error(D(280));var t=e.stateNode;t&&(t=vo(t),Ol(e.stateNode,e.type,t))}}function zd(e){vr?mr?mr.push(e):mr=[e]:vr=e}function Fd(){if(vr){var e=vr,t=mr;if(mr=vr=null,_c(e),t)for(e=0;e>>=0,e===0?32:31-(og(e)/lg|0)|0}var Qs=64,Zs=4194304;function Jr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Fn(e,t){var i=e.pendingLanes;if(i===0)return 0;var r=0,s=e.suspendedLanes,n=e.pingedLanes,o=i&268435455;if(o!==0){var l=o&~s;l!==0?r=Jr(l):(n&=o,n!==0&&(r=Jr(n)))}else o=i&~s,o!==0?r=Jr(o):n!==0&&(r=Jr(n));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,n=t&-t,s>=n||s===16&&(n&4194240)!==0))return t;if(r&4&&(r|=i&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0i;i++)t.push(e);return t}function Is(e,t,i){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Pt(t),e[t]=i}function ug(e,t){var i=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=as),kc=" ",xc=!1;function of(e,t){switch(e){case"keyup":return Fg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var nr=!1;function $g(e,t){switch(e){case"compositionend":return lf(t);case"keypress":return t.which!==32?null:(xc=!0,kc);case"textInput":return e=t.data,e===kc&&xc?null:e;default:return null}}function Wg(e,t){if(nr)return e==="compositionend"||!gh&&of(e,t)?(e=sf(),yn=fh=_i=null,nr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:i,offset:t-e};e=r}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Rc(i)}}function uf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function df(){for(var e=window,t=On();t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=On(e.document)}return t}function vh(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Qg(e){var t=df(),i=e.focusedElem,r=e.selectionRange;if(t!==i&&i&&i.ownerDocument&&uf(i.ownerDocument.documentElement,i)){if(r!==null&&vh(i)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in i)i.selectionStart=t,i.selectionEnd=Math.min(e,i.value.length);else if(e=(t=i.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=i.textContent.length,n=Math.min(r.start,s);r=r.end===void 0?n:Math.min(r.end,s),!e.extend&&n>r&&(s=r,r=n,n=s),s=Pc(i,n);var o=Pc(i,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),n>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=i;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,or=null,$l=null,cs=null,Wl=!1;function Lc(e,t,i){var r=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Wl||or==null||or!==On(r)||(r=or,"selectionStart"in r&&vh(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),cs&&ks(cs,r)||(cs=r,r=Wn($l,"onSelect"),0hr||(e.current=ql[hr],ql[hr]=null,hr--)}function ee(e,t){hr++,ql[hr]=e.current,e.current=t}var Di={},Ue=Pi(Di),tt=Pi(!1),Ui=Di;function xr(e,t){var i=e.type.contextTypes;if(!i)return Di;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},n;for(n in i)s[n]=t[n];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function it(e){return e=e.childContextTypes,e!=null}function Kn(){re(tt),re(Ue)}function Ic(e,t,i){if(Ue.current!==Di)throw Error(D(168));ee(Ue,t),ee(tt,i)}function wf(e,t,i){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return i;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(D(108,Vp(e)||"Unknown",s));return ce({},i,r)}function jn(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Di,Ui=Ue.current,ee(Ue,e),ee(tt,tt.current),!0}function zc(e,t,i){var r=e.stateNode;if(!r)throw Error(D(169));i?(e=wf(e,t,Ui),r.__reactInternalMemoizedMergedChildContext=e,re(tt),re(Ue),ee(Ue,e)):re(tt),ee(tt,i)}var jt=null,mo=!1,Qo=!1;function Cf(e){jt===null?jt=[e]:jt.push(e)}function hv(e){mo=!0,Cf(e)}function Li(){if(!Qo&&jt!==null){Qo=!0;var e=0,t=Q;try{var i=jt;for(Q=1;e>=o,s-=o,Vt=1<<32-Pt(t)+s|i<R?(W=b,b=null):W=b.sibling;var $=d(f,b,m[R],y);if($===null){b===null&&(b=W);break}e&&b&&$.alternate===null&&t(f,b),g=n($,g,R),C===null?S=$:C.sibling=$,C=$,b=W}if(R===m.length)return i(f,b),se&&Mi(f,R),S;if(b===null){for(;RR?(W=b,b=null):W=b.sibling;var U=d(f,b,$.value,y);if(U===null){b===null&&(b=W);break}e&&b&&U.alternate===null&&t(f,b),g=n(U,g,R),C===null?S=U:C.sibling=U,C=U,b=W}if($.done)return i(f,b),se&&Mi(f,R),S;if(b===null){for(;!$.done;R++,$=m.next())$=c(f,$.value,y),$!==null&&(g=n($,g,R),C===null?S=$:C.sibling=$,C=$);return se&&Mi(f,R),S}for(b=r(f,b);!$.done;R++,$=m.next())$=p(b,f,R,$.value,y),$!==null&&(e&&$.alternate!==null&&b.delete($.key===null?R:$.key),g=n($,g,R),C===null?S=$:C.sibling=$,C=$);return e&&b.forEach(function(L){return t(f,L)}),se&&Mi(f,R),S}function x(f,g,m,y){if(typeof m=="object"&&m!==null&&m.type===sr&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case qs:e:{for(var S=m.key,C=g;C!==null;){if(C.key===S){if(S=m.type,S===sr){if(C.tag===7){i(f,C.sibling),g=s(C,m.props.children),g.return=f,f=g;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===hi&&$c(S)===C.type){i(f,C.sibling),g=s(C,m.props),g.ref=Wr(f,C,m),g.return=f,f=g;break e}i(f,C);break}else t(f,C);C=C.sibling}m.type===sr?(g=$i(m.props.children,f.mode,y,m.key),g.return=f,f=g):(y=Rn(m.type,m.key,m.props,null,f.mode,y),y.ref=Wr(f,g,m),y.return=f,f=y)}return o(f);case rr:e:{for(C=m.key;g!==null;){if(g.key===C)if(g.tag===4&&g.stateNode.containerInfo===m.containerInfo&&g.stateNode.implementation===m.implementation){i(f,g.sibling),g=s(g,m.children||[]),g.return=f,f=g;break e}else{i(f,g);break}else t(f,g);g=g.sibling}g=nl(m,f.mode,y),g.return=f,f=g}return o(f);case hi:return C=m._init,x(f,g,C(m._payload),y)}if(Zr(m))return _(f,g,m,y);if(Ir(m))return v(f,g,m,y);on(f,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,g!==null&&g.tag===6?(i(f,g.sibling),g=s(g,m),g.return=f,f=g):(i(f,g),g=sl(m,f.mode,y),g.return=f,f=g),o(f)):i(f,g)}return x}var Er=Ef(!0),Df=Ef(!1),qn=Pi(null),Xn=null,dr=null,wh=null;function Ch(){wh=dr=Xn=null}function kh(e){var t=qn.current;re(qn),e._currentValue=t}function Ql(e,t,i){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===i)break;e=e.return}}function yr(e,t){Xn=e,wh=dr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(et=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(wh!==e)if(e={context:e,memoizedValue:t,next:null},dr===null){if(Xn===null)throw Error(D(308));dr=e,Xn.dependencies={lanes:0,firstContext:e}}else dr=dr.next=e;return t}var Ii=null;function xh(e){Ii===null?Ii=[e]:Ii.push(e)}function Rf(e,t,i,r){var s=t.interleaved;return s===null?(i.next=i,xh(t)):(i.next=s.next,s.next=i),t.interleaved=i,Zt(e,r)}function Zt(e,t){e.lanes|=t;var i=e.alternate;for(i!==null&&(i.lanes|=t),i=e,e=e.return;e!==null;)e.childLanes|=t,i=e.alternate,i!==null&&(i.childLanes|=t),i=e,e=e.return;return i.tag===3?i.stateNode:null}var ci=!1;function bh(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pf(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wi(e,t,i){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,q&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Zt(e,i)}return s=r.interleaved,s===null?(t.next=t,xh(r)):(t.next=s.next,s.next=t),r.interleaved=t,Zt(e,i)}function Cn(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,i|=r,t.lanes=i,ch(e,i)}}function Wc(e,t){var i=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,i===r)){var s=null,n=null;if(i=i.firstBaseUpdate,i!==null){do{var o={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};n===null?s=n=o:n=n.next=o,i=i.next}while(i!==null);n===null?s=n=t:n=n.next=t}else s=n=t;i={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:n,shared:r.shared,effects:r.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}function Gn(e,t,i,r){var s=e.updateQueue;ci=!1;var n=s.firstBaseUpdate,o=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var h=l,a=h.next;h.next=null,o===null?n=a:o.next=a,o=h;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==o&&(l===null?u.firstBaseUpdate=a:l.next=a,u.lastBaseUpdate=h))}if(n!==null){var c=s.baseState;o=0,u=a=h=null,l=n;do{var d=l.lane,p=l.eventTime;if((r&d)===d){u!==null&&(u=u.next={eventTime:p,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var _=e,v=l;switch(d=t,p=i,v.tag){case 1:if(_=v.payload,typeof _=="function"){c=_.call(p,c,d);break e}c=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=v.payload,d=typeof _=="function"?_.call(p,c,d):_,d==null)break e;c=ce({},c,d);break e;case 2:ci=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=s.effects,d===null?s.effects=[l]:d.push(l))}else p={eventTime:p,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(a=u=p,h=c):u=u.next=p,o|=d;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;d=l,l=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(u===null&&(h=c),s.baseState=h,s.firstBaseUpdate=a,s.lastBaseUpdate=u,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else n===null&&(s.shared.lanes=0);Vi|=o,e.lanes=o,e.memoizedState=c}}function Uc(e,t,i){if(e=t.effects,t.effects=null,e!==null)for(t=0;ti?i:4,e(!0);var r=Jo.transition;Jo.transition={};try{e(!1),t()}finally{Q=i,Jo.transition=r}}function Vf(){return Ct().memoizedState}function fv(e,t,i){var r=ki(e);if(i={lane:r,action:i,hasEagerState:!1,eagerState:null,next:null},Yf(e))qf(t,i);else if(i=Rf(e,t,i,r),i!==null){var s=Ve();Lt(i,e,r,s),Xf(i,t,r)}}function _v(e,t,i){var r=ki(e),s={lane:r,action:i,hasEagerState:!1,eagerState:null,next:null};if(Yf(e))qf(t,s);else{var n=e.alternate;if(e.lanes===0&&(n===null||n.lanes===0)&&(n=t.lastRenderedReducer,n!==null))try{var o=t.lastRenderedState,l=n(o,i);if(s.hasEagerState=!0,s.eagerState=l,Bt(l,o)){var h=t.interleaved;h===null?(s.next=s,xh(t)):(s.next=h.next,h.next=s),t.interleaved=s;return}}catch{}finally{}i=Rf(e,t,s,r),i!==null&&(s=Ve(),Lt(i,e,r,s),Xf(i,t,r))}}function Yf(e){var t=e.alternate;return e===he||t!==null&&t===he}function qf(e,t){us=Zn=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Xf(e,t,i){if(i&4194240){var r=t.lanes;r&=e.pendingLanes,i|=r,t.lanes=i,ch(e,i)}}var Jn={readContext:wt,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},pv={readContext:wt,useCallback:function(e,t){return At().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:jc,useImperativeHandle:function(e,t,i){return i=i!=null?i.concat([e]):null,xn(4194308,4,$f.bind(null,t,e),i)},useLayoutEffect:function(e,t){return xn(4194308,4,e,t)},useInsertionEffect:function(e,t){return xn(4,2,e,t)},useMemo:function(e,t){var i=At();return t=t===void 0?null:t,e=e(),i.memoizedState=[e,t],e},useReducer:function(e,t,i){var r=At();return t=i!==void 0?i(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=fv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=At();return e={current:e},t.memoizedState=e},useState:Kc,useDebugValue:Th,useDeferredValue:function(e){return At().memoizedState=e},useTransition:function(){var e=Kc(!1),t=e[0];return e=dv.bind(null,e[1]),At().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,i){var r=he,s=At();if(se){if(i===void 0)throw Error(D(407));i=i()}else{if(i=t(),Be===null)throw Error(D(349));ji&30||Tf(r,t,i)}s.memoizedState=i;var n={value:i,getSnapshot:t};return s.queue=n,jc(Of.bind(null,r,n,e),[e]),r.flags|=2048,Bs(9,Nf.bind(null,r,n,i,t),void 0,null),i},useId:function(){var e=At(),t=Be.identifierPrefix;if(se){var i=Yt,r=Vt;i=(r&~(1<<32-Pt(r)-1)).toString(32)+i,t=":"+t+"R"+i,i=Ps++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(i,{is:r.is}):(e=o.createElement(i),i==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,i),e[It]=t,e[Es]=r,n_(e,t,!1,!1),t.stateNode=e;e:{switch(o=Tl(i,r),i){case"dialog":te("cancel",e),te("close",e),s=r;break;case"iframe":case"object":case"embed":te("load",e),s=r;break;case"video":case"audio":for(s=0;sPr&&(t.flags|=128,r=!0,Ur(n,!1),t.lanes=4194304)}else{if(!r)if(e=Qn(o),e!==null){if(t.flags|=128,r=!0,i=e.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),Ur(n,!0),n.tail===null&&n.tailMode==="hidden"&&!o.alternate&&!se)return He(t),null}else 2*ge()-n.renderingStartTime>Pr&&i!==1073741824&&(t.flags|=128,r=!0,Ur(n,!1),t.lanes=4194304);n.isBackwards?(o.sibling=t.child,t.child=o):(i=n.last,i!==null?i.sibling=o:t.child=o,n.last=o)}return n.tail!==null?(t=n.tail,n.rendering=t,n.tail=t.sibling,n.renderingStartTime=ge(),t.sibling=null,i=ae.current,ee(ae,r?i&1|2:i&1),t):(He(t),null);case 22:case 23:return Fh(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ot&1073741824&&(He(t),t.subtreeFlags&6&&(t.flags|=8192)):He(t),null;case 24:return null;case 25:return null}throw Error(D(156,t.tag))}function kv(e,t){switch(Sh(t),t.tag){case 1:return it(t.type)&&Kn(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Dr(),re(tt),re(Ue),Rh(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Dh(t),null;case 13:if(re(ae),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(D(340));br()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return re(ae),null;case 4:return Dr(),null;case 10:return kh(t.type._context),null;case 22:case 23:return Fh(),null;case 24:return null;default:return null}}var an=!1,We=!1,xv=typeof WeakSet=="function"?WeakSet:Set,O=null;function fr(e,t){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(r){fe(e,t,r)}else i.current=null}function oa(e,t,i){try{i()}catch(r){fe(e,t,r)}}var iu=!1;function bv(e,t){if(Ul=Hn,e=df(),vh(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var r=i.getSelection&&i.getSelection();if(r&&r.rangeCount!==0){i=r.anchorNode;var s=r.anchorOffset,n=r.focusNode;r=r.focusOffset;try{i.nodeType,n.nodeType}catch{i=null;break e}var o=0,l=-1,h=-1,a=0,u=0,c=e,d=null;t:for(;;){for(var p;c!==i||s!==0&&c.nodeType!==3||(l=o+s),c!==n||r!==0&&c.nodeType!==3||(h=o+r),c.nodeType===3&&(o+=c.nodeValue.length),(p=c.firstChild)!==null;)d=c,c=p;for(;;){if(c===e)break t;if(d===i&&++a===s&&(l=o),d===n&&++u===r&&(h=o),(p=c.nextSibling)!==null)break;c=d,d=c.parentNode}c=p}i=l===-1||h===-1?null:{start:l,end:h}}else i=null}i=i||{start:0,end:0}}else i=null;for(Kl={focusedElem:e,selectionRange:i},Hn=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var _=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var v=_.memoizedProps,x=_.memoizedState,f=t.stateNode,g=f.getSnapshotBeforeUpdate(t.elementType===t.type?v:bt(t.type,v),x);f.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(D(163))}}catch(y){fe(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return _=iu,iu=!1,_}function ds(e,t,i){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var n=s.destroy;s.destroy=void 0,n!==void 0&&oa(t,i,n)}s=s.next}while(s!==r)}}function wo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var r=i.create;i.destroy=r()}i=i.next}while(i!==t)}}function la(e){var t=e.ref;if(t!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof t=="function"?t(e):t.current=e}}function a_(e){var t=e.alternate;t!==null&&(e.alternate=null,a_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[Es],delete t[Yl],delete t[lv],delete t[av])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function h_(e){return e.tag===5||e.tag===3||e.tag===4}function ru(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||h_(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function aa(e,t,i){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?i.nodeType===8?i.parentNode.insertBefore(e,t):i.insertBefore(e,t):(i.nodeType===8?(t=i.parentNode,t.insertBefore(e,i)):(t=i,t.appendChild(e)),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=Un));else if(r!==4&&(e=e.child,e!==null))for(aa(e,t,i),e=e.sibling;e!==null;)aa(e,t,i),e=e.sibling}function ha(e,t,i){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ha(e,t,i),e=e.sibling;e!==null;)ha(e,t,i),e=e.sibling}var Ne=null,Et=!1;function ni(e,t,i){for(i=i.child;i!==null;)c_(e,t,i),i=i.sibling}function c_(e,t,i){if(Ft&&typeof Ft.onCommitFiberUnmount=="function")try{Ft.onCommitFiberUnmount(fo,i)}catch{}switch(i.tag){case 5:We||fr(i,t);case 6:var r=Ne,s=Et;Ne=null,ni(e,t,i),Ne=r,Et=s,Ne!==null&&(Et?(e=Ne,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Ne.removeChild(i.stateNode));break;case 18:Ne!==null&&(Et?(e=Ne,i=i.stateNode,e.nodeType===8?Go(e.parentNode,i):e.nodeType===1&&Go(e,i),ws(e)):Go(Ne,i.stateNode));break;case 4:r=Ne,s=Et,Ne=i.stateNode.containerInfo,Et=!0,ni(e,t,i),Ne=r,Et=s;break;case 0:case 11:case 14:case 15:if(!We&&(r=i.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var n=s,o=n.destroy;n=n.tag,o!==void 0&&(n&2||n&4)&&oa(i,t,o),s=s.next}while(s!==r)}ni(e,t,i);break;case 1:if(!We&&(fr(i,t),r=i.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=i.memoizedProps,r.state=i.memoizedState,r.componentWillUnmount()}catch(l){fe(i,t,l)}ni(e,t,i);break;case 21:ni(e,t,i);break;case 22:i.mode&1?(We=(r=We)||i.memoizedState!==null,ni(e,t,i),We=r):ni(e,t,i);break;default:ni(e,t,i)}}function su(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new xv),t.forEach(function(r){var s=Nv.bind(null,e,r);i.has(r)||(i.add(r),r.then(s,s))})}}function kt(e,t){var i=t.deletions;if(i!==null)for(var r=0;rs&&(s=o),r&=~n}if(r=s,r=ge()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Dv(r/1960))-r,10e?16:e,pi===null)var r=!1;else{if(e=pi,pi=null,io=0,q&6)throw Error(D(331));var s=q;for(q|=4,O=e.current;O!==null;){var n=O,o=n.child;if(O.flags&16){var l=n.deletions;if(l!==null){for(var h=0;hge()-Ih?Hi(e,0):Ah|=i),rt(e,t)}function m_(e,t){t===0&&(e.mode&1?(t=Zs,Zs<<=1,!(Zs&130023424)&&(Zs=4194304)):t=1);var i=Ve();e=Zt(e,t),e!==null&&(Is(e,t,i),rt(e,i))}function Tv(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),m_(e,i)}function Nv(e,t){var i=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(i=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(D(314))}r!==null&&r.delete(t),m_(e,i)}var S_;S_=function(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps||tt.current)et=!0;else{if(!(e.lanes&i)&&!(t.flags&128))return et=!1,wv(e,t,i);et=!!(e.flags&131072)}else et=!1,se&&t.flags&1048576&&kf(t,Yn,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;bn(e,t),e=t.pendingProps;var s=xr(t,Ue.current);yr(t,i),s=Lh(null,t,r,e,s,i);var n=Bh();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,it(r)?(n=!0,jn(t)):n=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,bh(t),s.updater=yo,t.stateNode=s,s._reactInternals=t,Jl(t,r,e,i),t=ia(null,t,r,!0,n,i)):(t.tag=0,se&&n&&mh(t),je(null,t,s,i),t=t.child),t;case 16:r=t.elementType;e:{switch(bn(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Av(r),e=bt(r,e),s){case 0:t=ta(null,t,r,e,i);break e;case 1:t=Jc(null,t,r,e,i);break e;case 11:t=Qc(null,t,r,e,i);break e;case 14:t=Zc(null,t,r,bt(r.type,e),i);break e}throw Error(D(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:bt(r,s),ta(e,t,r,s,i);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:bt(r,s),Jc(e,t,r,s,i);case 3:e:{if(i_(t),e===null)throw Error(D(387));r=t.pendingProps,n=t.memoizedState,s=n.element,Pf(e,t),Gn(t,r,null,i);var o=t.memoizedState;if(r=o.element,n.isDehydrated)if(n={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=n,t.memoizedState=n,t.flags&256){s=Rr(Error(D(423)),t),t=eu(e,t,r,i,s);break e}else if(r!==s){s=Rr(Error(D(424)),t),t=eu(e,t,r,i,s);break e}else for(lt=yi(t.stateNode.containerInfo.firstChild),at=t,se=!0,Dt=null,i=Df(t,null,r,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(br(),r===s){t=Jt(e,t,i);break e}je(e,t,r,i)}t=t.child}return t;case 5:return Lf(t),e===null&&Gl(t),r=t.type,s=t.pendingProps,n=e!==null?e.memoizedProps:null,o=s.children,jl(r,s)?o=null:n!==null&&jl(r,n)&&(t.flags|=32),t_(e,t),je(e,t,o,i),t.child;case 6:return e===null&&Gl(t),null;case 13:return r_(e,t,i);case 4:return Eh(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Er(t,null,r,i):je(e,t,r,i),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:bt(r,s),Qc(e,t,r,s,i);case 7:return je(e,t,t.pendingProps,i),t.child;case 8:return je(e,t,t.pendingProps.children,i),t.child;case 12:return je(e,t,t.pendingProps.children,i),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,n=t.memoizedProps,o=s.value,ee(qn,r._currentValue),r._currentValue=o,n!==null)if(Bt(n.value,o)){if(n.children===s.children&&!tt.current){t=Jt(e,t,i);break e}}else for(n=t.child,n!==null&&(n.return=t);n!==null;){var l=n.dependencies;if(l!==null){o=n.child;for(var h=l.firstContext;h!==null;){if(h.context===r){if(n.tag===1){h=Xt(-1,i&-i),h.tag=2;var a=n.updateQueue;if(a!==null){a=a.shared;var u=a.pending;u===null?h.next=h:(h.next=u.next,u.next=h),a.pending=h}}n.lanes|=i,h=n.alternate,h!==null&&(h.lanes|=i),Ql(n.return,i,t),l.lanes|=i;break}h=h.next}}else if(n.tag===10)o=n.type===t.type?null:n.child;else if(n.tag===18){if(o=n.return,o===null)throw Error(D(341));o.lanes|=i,l=o.alternate,l!==null&&(l.lanes|=i),Ql(o,i,t),o=n.sibling}else o=n.child;if(o!==null)o.return=n;else for(o=n;o!==null;){if(o===t){o=null;break}if(n=o.sibling,n!==null){n.return=o.return,o=n;break}o=o.return}n=o}je(e,t,s.children,i),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,yr(t,i),s=wt(s),r=r(s),t.flags|=1,je(e,t,r,i),t.child;case 14:return r=t.type,s=bt(r,t.pendingProps),s=bt(r.type,s),Zc(e,t,r,s,i);case 15:return Jf(e,t,t.type,t.pendingProps,i);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:bt(r,s),bn(e,t),t.tag=1,it(r)?(e=!0,jn(t)):e=!1,yr(t,i),Gf(t,r,s),Jl(t,r,s,i),ia(null,t,r,!0,e,i);case 19:return s_(e,t,i);case 22:return e_(e,t,i)}throw Error(D(156,t.tag))};function y_(e,t){return Vd(e,t)}function Ov(e,t,i,r){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mt(e,t,i,r){return new Ov(e,t,i,r)}function $h(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Av(e){if(typeof e=="function")return $h(e)?1:0;if(e!=null){if(e=e.$$typeof,e===oh)return 11;if(e===lh)return 14}return 2}function xi(e,t){var i=e.alternate;return i===null?(i=mt(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function Rn(e,t,i,r,s,n){var o=2;if(r=e,typeof e=="function")$h(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case sr:return $i(i.children,s,n,t);case nh:o=8,s|=8;break;case kl:return e=mt(12,i,t,s|2),e.elementType=kl,e.lanes=n,e;case xl:return e=mt(13,i,t,s),e.elementType=xl,e.lanes=n,e;case bl:return e=mt(19,i,t,s),e.elementType=bl,e.lanes=n,e;case Pd:return ko(i,s,n,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Dd:o=10;break e;case Rd:o=9;break e;case oh:o=11;break e;case lh:o=14;break e;case hi:o=16,r=null;break e}throw Error(D(130,e==null?e:typeof e,""))}return t=mt(o,i,t,s),t.elementType=e,t.type=r,t.lanes=n,t}function $i(e,t,i,r){return e=mt(7,e,r,t),e.lanes=i,e}function ko(e,t,i,r){return e=mt(22,e,r,t),e.elementType=Pd,e.lanes=i,e.stateNode={isHidden:!1},e}function sl(e,t,i){return e=mt(6,e,null,t),e.lanes=i,e}function nl(e,t,i){return t=mt(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Iv(e,t,i,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Fo(0),this.expirationTimes=Fo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Fo(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Wh(e,t,i,r,s,n,o,l,h){return e=new Iv(e,t,i,l,h),t===1?(t=1,n===!0&&(t|=8)):t=0,n=mt(3,null,null,t),e.current=n,n.stateNode=e,n.memoizedState={element:r,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},bh(n),e}function zv(e,t,i){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(x_)}catch(e){console.error(e)}}x_(),kd.exports=ct;var Uv=kd.exports,du=Uv;wl.createRoot=du.createRoot,wl.hydrateRoot=du.hydrateRoot;const b_=Y.createContext({x:0,y:0,scale:1}),$s=()=>Y.useContext(b_);function Vh(e,t){const i=$s(),r=Y.useRef(null),s=l=>{l.button===0&&(l.stopPropagation(),l.target.setPointerCapture(l.pointerId),r.current={startX:l.clientX,startY:l.clientY,cardX:e.x,cardY:e.y})},n=l=>{const h=r.current;if(!h)return;const a=(l.clientX-h.startX)/i.scale,u=(l.clientY-h.startY)/i.scale;t({x:h.cardX+a,y:h.cardY+u})},o=l=>{if(r.current){try{l.target.releasePointerCapture(l.pointerId)}catch{}r.current=null}};return{onPointerDown:s,onPointerMove:n,onPointerUp:o,onPointerCancel:o}}const ol=120,ll=80;function Kv(e,t,i){const r=$s(),s=Y.useRef(null),n=h=>{h.button===0&&(h.stopPropagation(),h.target.setPointerCapture(h.pointerId),s.current={startX:h.clientX,startY:h.clientY,cardX:e.x,cardY:e.y,cardW:e.width,cardH:e.height})},o=h=>{const a=s.current;if(!a)return;const u=(h.clientX-a.startX)/r.scale,c=(h.clientY-a.startY)/r.scale;let d=a.cardX,p=a.cardY,_=a.cardW,v=a.cardH;t.includes("e")&&(_=a.cardW+u),t.includes("w")&&(d=a.cardX+u,_=a.cardW-u),t.includes("s")&&(v=a.cardH+c),t.includes("n")&&(p=a.cardY+c,v=a.cardH-c),_{if(s.current){try{h.target.releasePointerCapture(h.pointerId)}catch{}s.current=null}};return{onPointerDown:n,onPointerMove:o,onPointerUp:l,onPointerCancel:l}}const jv=["n","s","e","w","ne","nw","se","sw"];function Yh({card:e,onUpdate:t}){return z.jsx(z.Fragment,{children:jv.map(i=>z.jsx(Vv,{dir:i,card:e,onUpdate:t},i))})}function Vv({dir:e,card:t,onUpdate:i}){const r=Kv(t,e,i);return z.jsx("div",{className:`resize-handle resize-${e}`,...r})}const Yv=13;function qv({card:e,onUpdate:t}){const i=$s(),r=Vh(e,s=>t(s));return z.jsxs("div",{className:"card note-card",style:{left:i.x+e.x*i.scale,top:i.y+e.y*i.scale,width:e.width*i.scale,height:e.height*i.scale,zIndex:e.z,fontSize:Yv*i.scale,"--scale":i.scale},children:[z.jsx("div",{className:"card-header",...r,children:"note"}),z.jsx("div",{className:"card-body",children:z.jsx("textarea",{value:e.text,onChange:s=>t({text:s.target.value}),onPointerDown:s=>s.stopPropagation()})}),z.jsx(Yh,{card:e,onUpdate:s=>t(s)})]})}/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var E_=Object.defineProperty,Xv=Object.getOwnPropertyDescriptor,Gv=(e,t)=>{for(var i in t)E_(e,i,{get:t[i],enumerable:!0})},_e=(e,t,i,r)=>{for(var s=r>1?void 0:r?Xv(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(s=(r?o(t,i,s):o(s))||s);return r&&s&&E_(t,i,s),s},M=(e,t)=>(i,r)=>t(i,r,e),fu="Terminal input",_a={get:()=>fu,set:e=>fu=e},_u="Too much output to announce, navigate to rows manually to read",pa={get:()=>_u,set:e=>_u=e};function Qv(e){return e.replace(/\r?\n/g,"\r")}function Zv(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Jv(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function em(e,t,i,r){if(e.stopPropagation(),e.clipboardData){let s=e.clipboardData.getData("text/plain");D_(s,t,i,r)}}function D_(e,t,i,r){e=Qv(e),e=Zv(e,i.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function R_(e,t,i){let r=i.getBoundingClientRect(),s=e.clientX-r.left-10,n=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${s}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function pu(e,t,i,r,s){R_(e,t,i),s&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ui(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ro(e,t=0,i=e.length){let r="";for(let s=t;s65535?(n-=65536,r+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r}var tm=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s=0;if(this._interim){let n=e.charCodeAt(s++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let n=s;n=i)return this._interim=o,r;let l=e.charCodeAt(n);56320<=l&&l<=57343?t[r++]=(o-55296)*1024+l-56320+65536:(t[r++]=o,t[r++]=l);continue}o!==65279&&(t[r++]=o)}return r}},im=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let r=0,s,n,o,l,h=0,a=0;if(this.interim[0]){let d=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let _=0,v;for(;(v=this.interim[++_]&63)&&_<4;)p<<=6,p|=v;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,f=x-_;for(;a=i)return 0;if(v=e[a++],(v&192)!==128){a--,d=!0;break}else this.interim[_++]=v,p<<=6,p|=v&63}d||(x===2?p<128?a--:t[r++]=p:x===3?p<2048||p>=55296&&p<=57343||p===65279||(t[r++]=p):p<65536||p>1114111||(t[r++]=p)),this.interim.fill(0)}let u=i-4,c=a;for(;c=i)return this.interim[0]=s,r;if(n=e[c++],(n&192)!==128){c--;continue}if(h=(s&31)<<6|n&63,h<128){c--;continue}t[r++]=h}else if((s&240)===224){if(c>=i)return this.interim[0]=s,r;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[c++],(o&192)!==128){c--;continue}if(h=(s&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[r++]=h}else if((s&248)===240){if(c>=i)return this.interim[0]=s,r;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=s,this.interim[1]=n,this.interim[2]=o,r;if(l=e[c++],(l&192)!==128){c--;continue}if(h=(s&7)<<18|(n&63)<<12|(o&63)<<6|l&63,h<65536||h>1114111)continue;t[r++]=h}}return r}},P_="",gi=" ",Ws=class L_{constructor(){this.fg=0,this.bg=0,this.extended=new no}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new L_;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},no=class B_{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new B_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},yt=class M_ extends Ws{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new no,this.combinedData=""}static fromCharData(t){let i=new M_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ui(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=t[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},gu="di$target",ga="di$dependencies",al=new Map;function rm(e){return e[ga]||[]}function Me(e){if(al.has(e))return al.get(e);let t=function(i,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");sm(t,i,s)};return t._id=e,al.set(e,t),t}function sm(e,t,i){t[gu]===t?t[ga].push({id:e,index:i}):(t[ga]=[{id:e,index:i}],t[gu]=t)}var Xe=Me("BufferService"),T_=Me("CoreMouseService"),Zi=Me("CoreService"),nm=Me("CharsetService"),qh=Me("InstantiationService"),N_=Me("LogService"),Ge=Me("OptionsService"),O_=Me("OscLinkService"),om=Me("UnicodeService"),Us=Me("DecorationService"),va=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var u;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let r=[],s=this._optionsService.rawOptions.linkHandler,n=new yt,o=i.getTrimmedLength(),l=-1,h=-1,a=!1;for(let c=0;cs?s.activate(v,x,p):lm(v,x),hover:(v,x)=>{var f;return(f=s==null?void 0:s.hover)==null?void 0:f.call(s,v,x,p)},leave:(v,x)=>{var f;return(f=s==null?void 0:s.leave)==null?void 0:f.call(s,v,x,p)}})}a=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=c,l=n.extended.urlId):(h=-1,l=-1)}}t(r)}};va=_e([M(0,Xe),M(1,Ge),M(2,O_)],va);function lm(e,t){if(confirm(`Do you want to navigate to ${t}? - -WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Po=Me("CharSizeService"),ti=Me("CoreBrowserService"),Xh=Me("MouseService"),ii=Me("RenderService"),am=Me("SelectionService"),A_=Me("CharacterJoinerService"),Nr=Me("ThemeService"),I_=Me("LinkProviderService"),hm=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?vu.isErrorNoTelemetry(e)?new vu(e.message+` - -`+e.stack):new Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},cm=new hm;function Pn(e){um(e)||cm.onUnexpectedError(e)}var ma="Canceled";function um(e){return e instanceof dm?!0:e instanceof Error&&e.name===ma&&e.message===ma}var dm=class extends Error{constructor(){super(ma),this.name=this.message}};function fm(e){return new Error(`Illegal argument: ${e}`)}var vu=class Sa extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Sa)return t;let i=new Sa;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ya=class z_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,z_.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var _m;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function r(n){return n>0}e.isGreaterThan=r;function s(n){return n===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(_m||(_m={}));function pm(e,t){let i=this,r=!1,s;return function(){return r||(r=!0,t||(s=e.apply(i,arguments))),s}}var F_;(e=>{function t(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function r(){return i}e.empty=r;function*s(y){yield y}e.single=s;function n(y){return t(y)?y:s(y)}e.wrap=n;function o(y){return y||i}e.from=o;function*l(y){for(let S=y.length-1;S>=0;S--)yield y[S]}e.reverse=l;function h(y){return!y||y[Symbol.iterator]().next().done===!0}e.isEmpty=h;function a(y){return y[Symbol.iterator]().next().value}e.first=a;function u(y,S){let C=0;for(let b of y)if(S(b,C++))return!0;return!1}e.some=u;function c(y,S){for(let C of y)if(S(C))return C}e.find=c;function*d(y,S){for(let C of y)S(C)&&(yield C)}e.filter=d;function*p(y,S){let C=0;for(let b of y)yield S(b,C++)}e.map=p;function*_(y,S){let C=0;for(let b of y)yield*S(b,C++)}e.flatMap=_;function*v(...y){for(let S of y)yield*S}e.concat=v;function x(y,S,C){let b=C;for(let R of y)b=S(b,R);return b}e.reduce=x;function*f(y,S,C=y.length){for(S<0&&(S+=y.length),C<0?C+=y.length:C>y.length&&(C=y.length);S1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function gm(...e){return ne(()=>qi(e))}function ne(e){return{dispose:pm(()=>{e()})}}var H_=class $_{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qi(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?$_.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};H_.DISABLE_DISPOSED_WARNING=!1;var bi=H_,j=class{constructor(){this._store=new bi,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};j.None=Object.freeze({dispose(){}});var Lr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},qt=typeof window=="object"?window:globalThis,wa=class Ca{constructor(t){this.element=t,this.next=Ca.Undefined,this.prev=Ca.Undefined}};wa.Undefined=new wa(void 0);var oe=wa,mu=class{constructor(){this._first=oe.Undefined,this._last=oe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===oe.Undefined}clear(){let e=this._first;for(;e!==oe.Undefined;){let t=e.next;e.prev=oe.Undefined,e.next=oe.Undefined,e=t}this._first=oe.Undefined,this._last=oe.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new oe(e);if(this._first===oe.Undefined)this._first=i,this._last=i;else if(t){let s=this._last;this._last=i,i.prev=s,s.next=i}else{let s=this._first;this._first=i,i.next=s,s.prev=i}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(i))}}shift(){if(this._first!==oe.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==oe.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==oe.Undefined&&e.next!==oe.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===oe.Undefined&&e.next===oe.Undefined?(this._first=oe.Undefined,this._last=oe.Undefined):e.next===oe.Undefined?(this._last=this._last.prev,this._last.next=oe.Undefined):e.prev===oe.Undefined&&(this._first=this._first.next,this._first.prev=oe.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==oe.Undefined;)yield e.element,e=e.next}},vm=globalThis.performance&&typeof globalThis.performance.now=="function",mm=class W_{static create(t){return new W_(t)}constructor(t){this._now=vm&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ae;(e=>{e.None=()=>j.None;function t(L,E){return c(L,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function i(L){return(E,T=null,B)=>{let A=!1,F;return F=L(w=>{if(!A)return F?F.dispose():A=!0,E.call(T,w)},null,B),A&&F.dispose(),F}}e.once=i;function r(L,E,T){return a((B,A=null,F)=>L(w=>B.call(A,E(w)),null,F),T)}e.map=r;function s(L,E,T){return a((B,A=null,F)=>L(w=>{E(w),B.call(A,w)},null,F),T)}e.forEach=s;function n(L,E,T){return a((B,A=null,F)=>L(w=>E(w)&&B.call(A,w),null,F),T)}e.filter=n;function o(L){return L}e.signal=o;function l(...L){return(E,T=null,B)=>{let A=gm(...L.map(F=>F(w=>E.call(T,w))));return u(A,B)}}e.any=l;function h(L,E,T,B){let A=T;return r(L,F=>(A=E(A,F),A),B)}e.reduce=h;function a(L,E){let T,B={onWillAddFirstListener(){T=L(A.fire,A)},onDidRemoveLastListener(){T==null||T.dispose()}},A=new P(B);return E==null||E.add(A),A.event}function u(L,E){return E instanceof Array?E.push(L):E&&E.add(L),L}function c(L,E,T=100,B=!1,A=!1,F,w){let N,I,X,J=0,Te,ue={leakWarningThreshold:F,onWillAddFirstListener(){N=L(ve=>{J++,I=E(I,ve),B&&!X&&(Qe.fire(I),I=void 0),Te=()=>{let dt=I;I=void 0,X=void 0,(!B||J>1)&&Qe.fire(dt),J=0},typeof T=="number"?(clearTimeout(X),X=setTimeout(Te,T)):X===void 0&&(X=0,queueMicrotask(Te))})},onWillRemoveListener(){A&&J>0&&(Te==null||Te())},onDidRemoveLastListener(){Te=void 0,N.dispose()}},Qe=new P(ue);return w==null||w.add(Qe),Qe.event}e.debounce=c;function d(L,E=0,T){return e.debounce(L,(B,A)=>B?(B.push(A),B):[A],E,void 0,!0,void 0,T)}e.accumulate=d;function p(L,E=(B,A)=>B===A,T){let B=!0,A;return n(L,F=>{let w=B||!E(F,A);return B=!1,A=F,w},T)}e.latch=p;function _(L,E,T){return[e.filter(L,E,T),e.filter(L,B=>!E(B),T)]}e.split=_;function v(L,E=!1,T=[],B){let A=T.slice(),F=L(I=>{A?A.push(I):N.fire(I)});B&&B.add(F);let w=()=>{A==null||A.forEach(I=>N.fire(I)),A=null},N=new P({onWillAddFirstListener(){F||(F=L(I=>N.fire(I)),B&&B.add(F))},onDidAddFirstListener(){A&&(E?setTimeout(w):w())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return B&&B.add(N),N.event}e.buffer=v;function x(L,E){return(T,B,A)=>{let F=E(new g);return L(function(w){let N=F.evaluate(w);N!==f&&T.call(B,N)},void 0,A)}}e.chain=x;let f=Symbol("HaltChainable");class g{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(T=>(E(T),T)),this}filter(E){return this.steps.push(T=>E(T)?T:f),this}reduce(E,T){let B=T;return this.steps.push(A=>(B=E(B,A),B)),this}latch(E=(T,B)=>T===B){let T=!0,B;return this.steps.push(A=>{let F=T||!E(A,B);return T=!1,B=A,F?A:f}),this}evaluate(E){for(let T of this.steps)if(E=T(E),E===f)break;return E}}function m(L,E,T=B=>B){let B=(...N)=>w.fire(T(...N)),A=()=>L.on(E,B),F=()=>L.removeListener(E,B),w=new P({onWillAddFirstListener:A,onDidRemoveLastListener:F});return w.event}e.fromNodeEventEmitter=m;function y(L,E,T=B=>B){let B=(...N)=>w.fire(T(...N)),A=()=>L.addEventListener(E,B),F=()=>L.removeEventListener(E,B),w=new P({onWillAddFirstListener:A,onDidRemoveLastListener:F});return w.event}e.fromDOMEventEmitter=y;function S(L){return new Promise(E=>i(L)(E))}e.toPromise=S;function C(L){let E=new P;return L.then(T=>{E.fire(T)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=C;function b(L,E){return L(T=>E.fire(T))}e.forward=b;function R(L,E,T){return E(T),L(B=>E(B))}e.runAndSubscribe=R;class W{constructor(E,T){this._observable=E,this._counter=0,this._hasChanged=!1;let B={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new P(B),T&&T.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,T){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function $(L,E){return new W(L,E).emitter.event}e.fromObservable=$;function U(L){return(E,T,B)=>{let A=0,F=!1,w={beginUpdate(){A++},endUpdate(){A--,A===0&&(L.reportChanges(),F&&(F=!1,E.call(T)))},handlePossibleChange(){},handleChange(){F=!0}};L.addObserver(w),L.reportChanges();let N={dispose(){L.removeObserver(w)}};return B instanceof bi?B.add(N):Array.isArray(B)&&B.push(N),N}}e.fromObservableLight=U})(Ae||(Ae={}));var ka=class xa{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xa._idPool++}`,xa.all.add(this)}start(t){this._stopWatch=new mm,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};ka.all=new Set,ka._idPool=0;var Sm=ka,ym=-1,U_=class K_{constructor(t,i,r=(K_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let r=this.threshold;if(r<=0||i{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[r,s]of this._stacks)(!t||i{var o,l,h,a,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let c=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(c);let d=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new xm(`${c}. HINT: Stack shows most frequent listener (${d[1]}-times)`,d[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Pn)(p),j.None}if(this._disposed)return j.None;t&&(e=e.bind(t));let r=new hl(e),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Cm.create(),s=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof hl?(this._deliveryQueue??(this._deliveryQueue=new Rm),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=r,(u=(a=this._options)==null?void 0:a.onDidAddFirstListener)==null||u.call(a,this)),this._size++;let n=ne(()=>{s==null||s(),this._removeListener(r)});return i instanceof bi?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var s,n,o,l;if((n=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||n.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Em<=t.length){let h=0;for(let a=0;a0}},Rm=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ba=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new P,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new P,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ba.INSTANCE=new ba;var Gh=ba;function Pm(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Gh.INSTANCE.onDidChangeZoomLevel;function Lm(e){return Gh.INSTANCE.getZoomFactor(e)}Gh.INSTANCE.onDidChangeFullscreen;var Or=typeof navigator=="object"?navigator.userAgent:"",Ea=Or.indexOf("Firefox")>=0,Bm=Or.indexOf("AppleWebKit")>=0,Qh=Or.indexOf("Chrome")>=0,Mm=!Qh&&Or.indexOf("Safari")>=0;Or.indexOf("Electron/")>=0;Or.indexOf("Android")>=0;var cl=!1;if(typeof qt.matchMedia=="function"){let e=qt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=qt.matchMedia("(display-mode: fullscreen)");cl=e.matches,Pm(qt,e,({matches:i})=>{cl&&t.matches||(cl=i)})}var pr="en",Da=!1,Ra=!1,Ln=!1,V_=!1,un,Bn=pr,Su=pr,Tm,xt,Wi=globalThis,Oe,hd;typeof Wi.vscode<"u"&&typeof Wi.vscode.process<"u"?Oe=Wi.vscode.process:typeof process<"u"&&typeof((hd=process==null?void 0:process.versions)==null?void 0:hd.node)=="string"&&(Oe=process);var cd,Nm=typeof((cd=Oe==null?void 0:Oe.versions)==null?void 0:cd.electron)=="string",Om=Nm&&(Oe==null?void 0:Oe.type)==="renderer",ud;if(typeof Oe=="object"){Da=Oe.platform==="win32",Ra=Oe.platform==="darwin",Ln=Oe.platform==="linux",Ln&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,un=pr,Bn=pr;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);un=t.userLocale,Su=t.osLocale,Bn=t.resolvedLanguage||pr,Tm=(ud=t.languagePack)==null?void 0:ud.translationsConfigFile}catch{}V_=!0}else typeof navigator=="object"&&!Om?(xt=navigator.userAgent,Da=xt.indexOf("Windows")>=0,Ra=xt.indexOf("Macintosh")>=0,(xt.indexOf("Macintosh")>=0||xt.indexOf("iPad")>=0||xt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ln=xt.indexOf("Linux")>=0,(xt==null?void 0:xt.indexOf("Mobi"))>=0,Bn=globalThis._VSCODE_NLS_LANGUAGE||pr,un=navigator.language.toLowerCase(),Su=un):console.error("Unable to resolve platform.");var Y_=Da,$t=Ra,Am=Ln,yu=V_,Wt=xt,oi=Bn,Im;(e=>{function t(){return oi}e.value=t;function i(){return oi.length===2?oi==="en":oi.length>=3?oi[0]==="e"&&oi[1]==="n"&&oi[2]==="-":!1}e.isDefaultVariant=i;function r(){return oi==="en"}e.isDefault=r})(Im||(Im={}));var zm=typeof Wi.postMessage=="function"&&!Wi.importScripts;(()=>{if(zm){let e=[];Wi.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r{let r=++t;e.push({id:r,callback:i}),Wi.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var Fm=!!(Wt&&Wt.indexOf("Chrome")>=0);Wt&&Wt.indexOf("Firefox")>=0;!Fm&&Wt&&Wt.indexOf("Safari")>=0;Wt&&Wt.indexOf("Edg/")>=0;Wt&&Wt.indexOf("Android")>=0;var er=typeof navigator=="object"?navigator:{};yu||document.queryCommandSupported&&document.queryCommandSupported("copy")||er&&er.clipboard&&er.clipboard.writeText,yu||er&&er.clipboard&&er.clipboard.readText;var Zh=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ul=new Zh,wu=new Zh,Cu=new Zh,Hm=new Array(230),q_;(e=>{function t(l){return ul.keyCodeToStr(l)}e.toString=t;function i(l){return ul.strToKeyCode(l)}e.fromString=i;function r(l){return wu.keyCodeToStr(l)}e.toUserSettingsUS=r;function s(l){return Cu.keyCodeToStr(l)}e.toUserSettingsGeneral=s;function n(l){return wu.strToKeyCode(l)||Cu.strToKeyCode(l)}e.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ul.keyCodeToStr(l)}e.toElectronAccelerator=o})(q_||(q_={}));var $m=class X_{constructor(t,i,r,s,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(t){return t instanceof X_&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${t}${i}${r}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Wm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Wm=class{constructor(e){if(e.length===0)throw fm("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t{function t(i){return i===e.None||i===e.Cancelled||i instanceof Qm?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ae.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:G_})})(Gm||(Gm={}));var Qm=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?G_:(this._emitter||(this._emitter=new P),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Jh=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new ya("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ya("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Zm=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new ya("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=i.setInterval(()=>{e()},t);this.disposable=ne(()=>{i.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Jm;(e=>{async function t(r){let s,n=await Promise.all(r.map(o=>o.then(l=>l,l=>{s||(s=l)})));if(typeof s<"u")throw s;return n}e.settled=t;function i(r){return new Promise(async(s,n)=>{try{await r(s,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Jm||(Jm={}));var Eu=class _t{static fromArray(t){return new _t(i=>{i.emitMany(t)})}static fromPromise(t){return new _t(async i=>{i.emitMany(await t)})}static fromPromises(t){return new _t(async i=>{await Promise.all(t.map(async r=>i.emitOne(await r)))})}static merge(t){return new _t(async i=>{await Promise.all(t.map(async r=>{for await(let s of r)i.emitOne(s)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new P,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(t(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new _t(async r=>{for await(let s of t)r.emitOne(i(s))})}map(t){return _t.map(this,t)}static filter(t,i){return new _t(async r=>{for await(let s of t)i(s)&&r.emitOne(s)})}filter(t){return _t.filter(this,t)}static coalesce(t){return _t.filter(t,i=>!!i)}coalesce(){return _t.coalesce(this)}static async toPromise(t){let i=[];for await(let r of t)i.push(r);return i}toPromise(){return _t.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Eu.EMPTY=Eu.fromArray([]);var{getWindow:zt,getWindowId:eS,onDidRegisterWindow:tS}=function(){let e=new Map,t={window:qt,disposables:new bi};e.set(qt.vscodeWindowId,t);let i=new P,r=new P,s=new P;function n(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(o){if(e.has(o.vscodeWindowId))return j.None;let l=new bi,h={window:o,disposables:l.add(new bi)};return e.set(o.vscodeWindowId,h),l.add(ne(()=>{e.delete(o.vscodeWindowId),r.fire(o)})),l.add(H(o,Ee.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var a;let l=o;if((a=l==null?void 0:l.ownerDocument)!=null&&a.defaultView)return l.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:qt},getDocument(o){return zt(o).document}}}(),iS=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function H(e,t,i,r){return new iS(e,t,i,r)}var Du=function(e,t,i,r){return H(e,t,i,r)},ec,rS=class extends Zm{constructor(e){super(),this.defaultTarget=e&&zt(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Ru=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Pn(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,r=new Map,s=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),r.set(n,!0);o.length>0;)o.sort(Ru.sort),o.shift().execute();r.set(n,!1)};ec=(n,o,l=0)=>{let h=eS(n),a=new Ru(o,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(a),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>s(h))),a}})();function sS(e){let t=e.getBoundingClientRect(),i=zt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Ee={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},nS=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Ze(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ze(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ze(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ze(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ze(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ze(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ze(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ze(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ze(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ze(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ze(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Ze(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Ze(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ze(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Ze(e){return typeof e=="number"?`${e}px`:e}function ps(e){return new nS(e)}var Q_=class{constructor(){this._hooks=new bi,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let n=e;try{e.setPointerCapture(t),this._hooks.add(ne(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=zt(e)}this._hooks.add(H(n,Ee.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(H(n,Ee.POINTER_UP,o=>this.stopMonitoring(!0)))}};function oS(e,t,i){let r=null,s=null;if(typeof i.value=="function"?(r="value",s=i.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(r="get",s=i.get),!s)throw new Error("not supported");let n=`$memoize$${t}`;i[r]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,o)}),this[n]}}var Ot;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ot||(Ot={}));var ts=class $e extends j{constructor(){super(),this.dispatched=!1,this.targets=new mu,this.ignoreTargets=new mu,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ae.runAndSubscribe(tS,({window:t,disposables:i})=>{i.add(H(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),i.add(H(t.document,"touchend",r=>this.onTouchEnd(t,r))),i.add(H(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:qt,disposables:this._store}))}static addTarget(t){if(!$e.isTouchDevice())return j.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.targets.push(t);return ne(i)}static ignoreTarget(t){if(!$e.isTouchDevice())return j.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.ignoreTargets.push(t);return ne(i)}static isTouchDevice(){return"ontouchstart"in qt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=t.targetTouches.length;r=$e.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(Ot.Contextmenu,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(s===1){let u=st(h.rollingPageX),c=st(h.rollingPageY),d=st(h.rollingTimestamps)-h.rollingTimestamps[0],p=u-h.rollingPageX[0],_=c-h.rollingPageY[0],v=[...this.targets].filter(x=>h.initialTarget instanceof Node&&x.contains(h.initialTarget));this.inertia(t,v,r,Math.abs(p)/d,p>0?1:-1,u,Math.abs(_)/d,_>0?1:-1,c)}this.dispatchEvent(this.newGestureEvent(Ot.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(t){if(t.type===Ot.Tap){let i=new Date().getTime(),r=0;i-this._lastSetTapCountTime>$e.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=i,t.tapCount=r}else(t.type===Ot.Change||t.type===Ot.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let i=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let s=0,n=t.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;i.push([s,r])}i.sort((r,s)=>r[0]-s[0]);for(let[r,s]of i)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,r,s,n,o,l,h,a){this.handle=ec(t,()=>{let u=Date.now(),c=u-r,d=0,p=0,_=!0;s+=$e.SCROLL_FRICTION*c,l+=$e.SCROLL_FRICTION*c,s>0&&(_=!1,d=n*s*c),l>0&&(_=!1,p=h*l*c);let v=this.newGestureEvent(Ot.Change);v.translationX=d,v.translationY=p,i.forEach(x=>x.dispatchEvent(v)),_||this.inertia(t,i,u,s,n,o+d,l,h,a+p)})}onTouchMove(t){let i=Date.now();for(let r=0,s=t.changedTouches.length;r3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ts.SCROLL_FRICTION=-.005,ts.HOLD_DELAY=700,ts.CLEAR_TAP_COUNT_TIME=400,_e([oS],ts,"isTouchDevice",1);var lS=ts,tc=class extends j{onclick(e,t){this._register(H(e,Ee.CLICK,i=>t(new dn(zt(e),i))))}onmousedown(e,t){this._register(H(e,Ee.MOUSE_DOWN,i=>t(new dn(zt(e),i))))}onmouseover(e,t){this._register(H(e,Ee.MOUSE_OVER,i=>t(new dn(zt(e),i))))}onmouseleave(e,t){this._register(H(e,Ee.MOUSE_LEAVE,i=>t(new dn(zt(e),i))))}onkeydown(e,t){this._register(H(e,Ee.KEY_DOWN,i=>t(new ku(i))))}onkeyup(e,t){this._register(H(e,Ee.KEY_UP,i=>t(new ku(i))))}oninput(e,t){this._register(H(e,Ee.INPUT,t))}onblur(e,t){this._register(H(e,Ee.BLUR,t))}onfocus(e,t){this._register(H(e,Ee.FOCUS,t))}onchange(e,t){this._register(H(e,Ee.CHANGE,t))}ignoreGesture(e){return lS.ignoreTarget(e)}},Pu=11,aS=class extends tc{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Pu+"px",this.domNode.style.height=Pu+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Q_),this._register(Du(this.bgDomNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Du(this.domNode,Ee.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new rS),this._pointerdownScheduleRepeatTimer=this._register(new Jh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,zt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hS=class Pa{constructor(t,i,r,s,n,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,r=r|0,s=s|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=s,this.rawScrollTop=l,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Pa(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Pa(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let r=this.width!==t.width,s=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:h}}},cS=class extends j{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new P),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hS(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let r;t?r=new Bu(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Bu.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Lu=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function dl(e,t){let i=t-e;return function(r){return e+i*fS(r)}}function uS(e,t,i){return function(r){return r2.5*r){let s,n;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},pS=140,Z_=class extends tc{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new _S(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Q_),this._shouldRender=!0,this.domNode=ps(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(H(this.domNode.domNode,Ee.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new aS(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,r){this.slider=ps(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(H(this.slider.domNode,Ee.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);i<=s&&s<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let s=sS(this.domNode.domNode);t=e.pageX-s.left,i=e.pageY-s.top}let r=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let n=this._sliderOrthogonalPointerPosition(s),o=Math.abs(n-i);if(Y_&&o>pS){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(s)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},J_=class Ba{constructor(t,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ba(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,r,s,n){let o=Math.max(0,r-t),l=Math.max(0,o-2*i),h=s>0&&s>r;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let a=Math.round(Math.max(20,Math.floor(r*l/s))),u=(l-a)/(s-r),c=n*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:u,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let t=Ba._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,r=this._scrollPosition;return i0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),i){let s=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),l=Math.abs(i.deltaY),h=Math.max(Math.min(s,o),1),a=Math.max(Math.min(n,l),1),u=Math.max(s,o),c=Math.max(n,l);u%h===0&&c%a===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ma.INSTANCE=new Ma;var yS=Ma,wS=class extends tc{constructor(e,t,i){super(),this._onScroll=this._register(new P),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new P),this.onWillScroll=this._onWillScroll.event,this._options=kS(t),this._scrollable=i,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let r={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new vS(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new gS(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ps(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ps(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ps(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new Jh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=qi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,$t&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new bu(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=qi(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new bu(i))};this._mouseWheelToDispose.push(H(this._listenOnDomNode,Ee.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let t=yS.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!$t&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),a={};if(n){let u=Mu*n,c=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(a,c)}if(o){let u=Mu*o,c=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(a,c)}a=this._scrollable.validateScrollPosition(a),(h.scrollLeft!==a.scrollLeft||h.scrollTop!==a.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(a):this._scrollable.setScrollPositionNow(a),i=!0)}let r=i;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,r=i?" left":"",s=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),mS)}},CS=class extends wS{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function kS(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,$t&&(t.className+=" mac"),t}var Ta=class extends j{constructor(e,t,i,r,s,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new P),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new cS({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:a=>ec(r.window,a)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new CS(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(a=>{this._scrollableElement.updateOptions({handleMouseWheel:!(a&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ae.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ne(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ne(()=>this._styleElement.remove())),this._register(Ae.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(a=>this._handleScroll(a)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Ta=_e([M(2,Xe),M(3,ti),M(4,T_),M(5,Nr),M(6,Ge),M(7,ii)],Ta);var Na=class extends j{constructor(e,t,i,r,s){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=r,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(ne(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Na=_e([M(1,Xe),M(2,ti),M(3,Us),M(4,ii)],Na);var xS=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Tt={full:0,left:0,center:0,right:0},li={full:0,left:0,center:0,right:0},jr={full:0,left:0,center:0,right:0},oo=class extends j{constructor(e,t,i,r,s,n,o,l){var a;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=r,this._renderService=s,this._optionsService=n,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new xS,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(a=this._viewportElement.parentElement)==null||a.insertBefore(this._canvas,this._viewportElement),this._register(ne(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);li.full=this._canvas.width,li.left=e,li.center=t,li.right=e,this._refreshDrawHeightConstants(),jr.full=1,jr.left=1,jr.center=1+li.left,jr.right=1+li.left+li.center}_refreshDrawHeightConstants(){Tt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Tt.left=t,Tt.center=t,Tt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(jr[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Tt[e.position||"full"]/2),li[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Tt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};oo=_e([M(2,Xe),M(3,Us),M(4,ii),M(5,Ge),M(6,Nr),M(7,ti)],oo);var k;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(k||(k={}));var Mn;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Mn||(Mn={}));var ep;(e=>e.ST=`${k.ESC}\\`)(ep||(ep={}));var Oa=class{constructor(e,t,i,r,s,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=r,this._coreService=s,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.lengththis.updateCompositionElements(!0),0)}}};Oa=_e([M(2,Xe),M(3,Ge),M(4,Zi),M(5,ii)],Oa);var Re=0,Pe=0,Le=0,de=0,Tu={css:"#00000000",rgba:0},Se;(e=>{function t(s,n,o,l){return l!==void 0?`#${Bi(s)}${Bi(n)}${Bi(o)}${Bi(l)}`:`#${Bi(s)}${Bi(n)}${Bi(o)}`}e.toCss=t;function i(s,n,o,l=255){return(s<<24|n<<16|o<<8|l)>>>0}e.toRgba=i;function r(s,n,o,l){return{css:e.toCss(s,n,o,l),rgba:e.toRgba(s,n,o,l)}}e.toColor=r})(Se||(Se={}));var ie;(e=>{function t(h,a){if(de=(a.rgba&255)/255,de===1)return{css:a.css,rgba:a.rgba};let u=a.rgba>>24&255,c=a.rgba>>16&255,d=a.rgba>>8&255,p=h.rgba>>24&255,_=h.rgba>>16&255,v=h.rgba>>8&255;Re=p+Math.round((u-p)*de),Pe=_+Math.round((c-_)*de),Le=v+Math.round((d-v)*de);let x=Se.toCss(Re,Pe,Le),f=Se.toRgba(Re,Pe,Le);return{css:x,rgba:f}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function r(h,a,u){let c=Tn.ensureContrastRatio(h.rgba,a.rgba,u);if(c)return Se.toColor(c>>24&255,c>>16&255,c>>8&255)}e.ensureContrastRatio=r;function s(h){let a=(h.rgba|255)>>>0;return[Re,Pe,Le]=Tn.toChannels(a),{css:Se.toCss(Re,Pe,Le),rgba:a}}e.opaque=s;function n(h,a){return de=Math.round(a*255),[Re,Pe,Le]=Tn.toChannels(h.rgba),{css:Se.toCss(Re,Pe,Le,de),rgba:Se.toRgba(Re,Pe,Le,de)}}e.opacity=n;function o(h,a){return de=h.rgba&255,n(h,de*a/255)}e.multiplyOpacity=o;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(ie||(ie={}));var le;(e=>{let t,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let n=s.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Re=parseInt(s.slice(1,2).repeat(2),16),Pe=parseInt(s.slice(2,3).repeat(2),16),Le=parseInt(s.slice(3,4).repeat(2),16),Se.toColor(Re,Pe,Le);case 5:return Re=parseInt(s.slice(1,2).repeat(2),16),Pe=parseInt(s.slice(2,3).repeat(2),16),Le=parseInt(s.slice(3,4).repeat(2),16),de=parseInt(s.slice(4,5).repeat(2),16),Se.toColor(Re,Pe,Le,de);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let n=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Re=parseInt(n[1]),Pe=parseInt(n[2]),Le=parseInt(n[3]),de=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Se.toColor(Re,Pe,Le,de);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Re,Pe,Le,de]=t.getImageData(0,0,1,1).data,de!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Se.toRgba(Re,Pe,Le,de),css:s}}e.toColor=r})(le||(le={}));var Ke;(e=>{function t(r){return i(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function i(r,s,n){let o=r/255,l=s/255,h=n/255,a=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),c=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return a*.2126+u*.7152+c*.0722}e.relativeLuminance2=i})(Ke||(Ke={}));var Tn;(e=>{function t(o,l){if(de=(l&255)/255,de===1)return l;let h=l>>24&255,a=l>>16&255,u=l>>8&255,c=o>>24&255,d=o>>16&255,p=o>>8&255;return Re=c+Math.round((h-c)*de),Pe=d+Math.round((a-d)*de),Le=p+Math.round((u-p)*de),Se.toRgba(Re,Pe,Le)}e.blend=t;function i(o,l,h){let a=Ke.relativeLuminance(o>>8),u=Ke.relativeLuminance(l>>8);if(Ut(a,u)>8));if(_>8));return _>x?p:v}return p}let c=s(o,l,h),d=Ut(a,Ke.relativeLuminance(c>>8));if(d>8));return d>_?c:p}return c}}e.ensureContrastRatio=i;function r(o,l,h){let a=o>>24&255,u=o>>16&255,c=o>>8&255,d=l>>24&255,p=l>>16&255,_=l>>8&255,v=Ut(Ke.relativeLuminance2(d,p,_),Ke.relativeLuminance2(a,u,c));for(;v0||p>0||_>0);)d-=Math.max(0,Math.ceil(d*.1)),p-=Math.max(0,Math.ceil(p*.1)),_-=Math.max(0,Math.ceil(_*.1)),v=Ut(Ke.relativeLuminance2(d,p,_),Ke.relativeLuminance2(a,u,c));return(d<<24|p<<16|_<<8|255)>>>0}e.reduceLuminance=r;function s(o,l,h){let a=o>>24&255,u=o>>16&255,c=o>>8&255,d=l>>24&255,p=l>>16&255,_=l>>8&255,v=Ut(Ke.relativeLuminance2(d,p,_),Ke.relativeLuminance2(a,u,c));for(;v>>0}e.increaseLuminance=s;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Tn||(Tn={}));function Bi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ut(e,t){return e1){let u=this._getJoinedRanges(r,o,n,t,s);for(let c=0;c1){let a=this._getJoinedRanges(r,o,n,t,s);for(let u=0;u=$,F=E,w=this._workCell;if(d.length>0&&E===d[0][0]&&A){let G=d.shift(),To=this._isCellInSelection(G[0],t);for(g=G[0]+1;g=G[1]),A?(B=!0,w=new bS(this._workCell,e.translateToString(!0,G[0],G[1]),G[1]-G[0]),F=G[1]-1,T=w.getWidth()):$=G[1]}let N=this._isCellInSelection(E,t),I=i&&E===n,X=L&&E>=a&&E<=u,J=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,G=>{J=!0});let Te=w.getChars()||gi;if(Te===" "&&(w.isUnderline()||w.isOverline())&&(Te=" "),W=T*l-h.get(Te,w.isBold(),w.isItalic()),!v)v=this._document.createElement("span");else if(x&&(N&&R||!N&&!R&&w.bg===m)&&(N&&R&&p.selectionForeground||w.fg===y)&&w.extended.ext===S&&X===C&&W===b&&!I&&!B&&!J&&A){w.isInvisible()?f+=gi:f+=Te,x++;continue}else x&&(v.textContent=f),v=this._document.createElement("span"),x=0,f="";if(m=w.bg,y=w.fg,S=w.extended.ext,C=X,b=W,R=N,B&&n>=E&&n<=F&&(n=E),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(U.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&U.push("xterm-cursor-blink"),U.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":U.push("xterm-cursor-outline");break;case"block":U.push("xterm-cursor-block");break;case"bar":U.push("xterm-cursor-bar");break;case"underline":U.push("xterm-cursor-underline");break}}if(w.isBold()&&U.push("xterm-bold"),w.isItalic()&&U.push("xterm-italic"),w.isDim()&&U.push("xterm-dim"),w.isInvisible()?f=gi:f=w.getChars()||gi,w.isUnderline()&&(U.push(`xterm-underline-${w.extended.underlineStyle}`),f===" "&&(f=" "),!w.isUnderlineColorDefault()))if(w.isUnderlineColorRGB())v.style.textDecorationColor=`rgb(${Ws.toColorRGB(w.getUnderlineColor()).join(",")})`;else{let G=w.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&w.isBold()&&G<8&&(G+=8),v.style.textDecorationColor=p.ansi[G].css}w.isOverline()&&(U.push("xterm-overline"),f===" "&&(f=" ")),w.isStrikethrough()&&U.push("xterm-strikethrough"),X&&(v.style.textDecoration="underline");let ue=w.getFgColor(),Qe=w.getFgColorMode(),ve=w.getBgColor(),dt=w.getBgColorMode(),Mo=!!w.isInverse();if(Mo){let G=ue;ue=ve,ve=G;let To=Qe;Qe=dt,dt=To}let ri,Vs,Ar=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,G=>{G.options.layer!=="top"&&Ar||(G.backgroundColorRGB&&(dt=50331648,ve=G.backgroundColorRGB.rgba>>8&16777215,ri=G.backgroundColorRGB),G.foregroundColorRGB&&(Qe=50331648,ue=G.foregroundColorRGB.rgba>>8&16777215,Vs=G.foregroundColorRGB),Ar=G.options.layer==="top")}),!Ar&&N&&(ri=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ve=ri.rgba>>8&16777215,dt=50331648,Ar=!0,p.selectionForeground&&(Qe=50331648,ue=p.selectionForeground.rgba>>8&16777215,Vs=p.selectionForeground)),Ar&&U.push("xterm-decoration-top");let si;switch(dt){case 16777216:case 33554432:si=p.ansi[ve],U.push(`xterm-bg-${ve}`);break;case 50331648:si=Se.toColor(ve>>16,ve>>8&255,ve&255),this._addStyle(v,`background-color:#${Nu((ve>>>0).toString(16),"0",6)}`);break;case 0:default:Mo?(si=p.foreground,U.push("xterm-bg-257")):si=p.background}switch(ri||w.isDim()&&(ri=ie.multiplyOpacity(si,.5)),Qe){case 16777216:case 33554432:w.isBold()&&ue<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ue+=8),this._applyMinimumContrast(v,si,p.ansi[ue],w,ri,void 0)||U.push(`xterm-fg-${ue}`);break;case 50331648:let G=Se.toColor(ue>>16&255,ue>>8&255,ue&255);this._applyMinimumContrast(v,si,G,w,ri,Vs)||this._addStyle(v,`color:#${Nu(ue.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(v,si,p.foreground,w,ri,Vs)||Mo&&U.push("xterm-fg-257")}U.length&&(v.className=U.join(" "),U.length=0),!I&&!B&&!J&&A?x++:v.textContent=f,W!==this.defaultSpacing&&(v.style.letterSpacing=`${W}px`),c.push(v),E=F}return v&&x&&(v.textContent=f),c}_applyMinimumContrast(e,t,i,r,s,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||RS(r.getCode()))return!1;let o=this._getContrastCache(r),l;if(!s&&!n&&(l=o.getColor(t.rgba,i.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ie.ensureContrastRatio(s||t,n||i,h),o.setColor((s||t).rgba,(n||i).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,r=this._selectionEnd;return!i||!r?!1:this._columnSelectMode?i[0]<=r[0]?e>=i[0]&&t>=i[1]&&e=i[1]&&e>=r[0]&&t<=r[1]:t>i[1]&&t=i[0]&&e=i[0]}};Aa=_e([M(1,A_),M(2,Ge),M(3,ti),M(4,Zi),M(5,Us),M(6,Nr)],Aa);function Nu(e,t,i){for(;e.length0&&(this._flat[r]=o),o}let s=e;t&&(s+="B"),i&&(s+="I");let n=this._holey.get(s);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(s,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},BS=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,l=Math.max(n,0),h=Math.min(o,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i=this.startCol&&t=this.startCol):!1}};function MS(){return new BS}var fl="xterm-dom-renderer-owner-",ft="xterm-rows",_n="xterm-fg-",Ou="xterm-bg-",Vr="xterm-focus",pn="xterm-selection",TS=1,Ia=class extends j{constructor(e,t,i,r,s,n,o,l,h,a,u,c,d,p){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=r,this._viewportElement=s,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=a,this._bufferService=u,this._coreService=c,this._coreBrowserService=d,this._themeService=p,this._terminalClass=TS++,this._rowElements=[],this._selectionRenderModel=MS(),this.onRequestRedraw=this._register(new P).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ft),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(pn),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=PS(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Aa,document),this._element.classList.add(fl+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(ne(()=>{this._element.classList.remove(fl+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new LS(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ft} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${ft} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${ft} .xterm-dim { color: ${ie.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ft}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ft}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ft} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${pn} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${pn} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${pn} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${_n}${n} { color: ${o.css}; }${this._terminalSelector} .${_n}${n}.xterm-dim { color: ${ie.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Ou}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${_n}257 { color: ${ie.opaque(e.background).css}; }${this._terminalSelector} .${_n}257.xterm-dim { color: ${ie.multiplyOpacity(ie.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ou}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Vr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=r===n?e[0]:0,a=n===s?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,a));let u=o-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,u)),n!==o){let c=s===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,c))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,i,r=1){let s=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${n}px`,s.style.width=`${o}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,r=i.ybase+i.y,s=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let a=h+i.ydisp,u=this._rowElements[h],c=i.lines.get(a);if(!u||!c)break;u.replaceChildren(...this._rowFactory.createRow(c,a,a===r,o,l,s,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${fl}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,r,s,n){i<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),r=Math.max(Math.min(r,o),0),s=Math.min(s,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,a=Math.min(l.x,s-1),u=this._optionsService.rawOptions.cursorBlink,c=this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=i;p<=r;++p){let _=p+l.ydisp,v=this._rowElements[p],x=l.lines.get(_);if(!v||!x)break;v.replaceChildren(...this._rowFactory.createRow(x,_,_===h,c,d,a,u,this.dimensions.css.cell.width,this._widthCache,n?p===i?e:0:-1,n?(p===r?t:s)-1:-1))}}};Ia=_e([M(7,qh),M(8,Po),M(9,Ge),M(10,Xe),M(11,Zi),M(12,ti),M(13,Nr)],Ia);var za=class extends j{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new P),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new OS(this._optionsService))}catch{this._measureStrategy=this._register(new NS(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};za=_e([M(2,Ge)],za);var tp=class extends j{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},NS=class extends tp{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},OS=class extends tp{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},AS=class extends j{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new IS(this._window)),this._onDprChange=this._register(new P),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new P),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ae.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(H(this._textarea,"focus",()=>this._isFocused=!0)),this._register(H(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},IS=class extends j{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Lr),this._onDprChange=this._register(new P),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ne(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=H(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},zS=class extends j{constructor(){super(),this.linkProviders=[],this._register(ne(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ic(e,t,i){let r=i.getBoundingClientRect(),s=e.getComputedStyle(i),n=parseInt(s.getPropertyValue("padding-left")),o=parseInt(s.getPropertyValue("padding-top"));return[t.clientX-r.left-n,t.clientY-r.top-o]}function FS(e,t,i,r,s,n,o,l,h){if(!n)return;let a=ic(e,t,i);if(a)return a[0]=Math.ceil((a[0]+(h?o/2:0))/o),a[1]=Math.ceil(a[1]/l),a[0]=Math.min(Math.max(a[0],1),r+(h?1:0)),a[1]=Math.min(Math.max(a[1],1),s),a}var Fa=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,r,s){return FS(window,e,t,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,t){let i=ic(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Fa=_e([M(0,ii),M(1,Po)],Fa);var HS=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ip={};Gv(ip,{getSafariVersion:()=>WS,isChromeOS:()=>op,isFirefox:()=>rp,isIpad:()=>US,isIphone:()=>KS,isLegacyEdge:()=>$S,isLinux:()=>rc,isMac:()=>ao,isNode:()=>Lo,isSafari:()=>sp,isWindows:()=>np});var Lo=typeof process<"u"&&"title"in process,Ks=Lo?"node":navigator.userAgent,js=Lo?"node":navigator.platform,rp=Ks.includes("Firefox"),$S=Ks.includes("Edge"),sp=/^((?!chrome|android).)*safari/i.test(Ks);function WS(){if(!sp)return 0;let e=Ks.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ao=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(js),US=js==="iPad",KS=js==="iPhone",np=["Windows","Win16","Win32","WinCE"].includes(js),rc=js.indexOf("Linux")>=0,op=/\bCrOS\b/.test(Ks),lp=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._is){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=s}this.clear()}},jS=class extends lp{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},VS=class extends lp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ho=!Lo&&"requestIdleCallback"in window?VS:jS,YS=class{constructor(){this._queue=new ho}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Ha=class extends j{constructor(e,t,i,r,s,n,o,l,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=r,this._coreService=s,this._coreBrowserService=l,this._renderer=this._register(new Lr),this._pausedResizeTask=new YS,this._observerDisposable=this._register(new Lr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new P),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new P),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new P),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new P),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new HS((a,u)=>this._renderRows(a,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new qS(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ne(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var a;return(a=this._renderer.value)==null?void 0:a.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(a=>this._registerIntersectionObserver(a,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=ne(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Ha=_e([M(2,Ge),M(3,Po),M(4,Zi),M(5,Us),M(6,Xe),M(7,ti),M(8,Nr)],Ha);var qS=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function XS(e,t,i,r){let s=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return ZS(s,n,e,t,i,r)+Bo(n,t,i,r)+JS(s,n,e,t,i,r);let o;if(n===t)return o=s>e?"D":"C",Ns(Math.abs(s-e),Ts(o,r));o=n>t?"D":"C";let l=Math.abs(n-t),h=QS(n>t?e:s,i)+(l-1)*i.cols+1+GS(n>t?s:e);return Ns(h,Ts(o,r))}function GS(e,t){return e-1}function QS(e,t){return t.cols-e}function ZS(e,t,i,r,s,n){return Bo(t,r,s,n).length===0?"":Ns(hp(e,t,e,t-Xi(t,s),!1,s).length,Ts("D",n))}function Bo(e,t,i,r){let s=e-Xi(e,i),n=t-Xi(t,i),o=Math.abs(s-n)-e0(e,t,i);return Ns(o,Ts(ap(e,t),r))}function JS(e,t,i,r,s,n){let o;Bo(t,r,s,n).length>0?o=r-Xi(r,s):o=t;let l=r,h=t0(e,t,i,r,s,n);return Ns(hp(e,o,i,l,h==="C",s).length,Ts(h,n))}function e0(e,t,i){var o;let r=0,s=e-Xi(e,i),n=t-Xi(t,i);for(let l=0;l=0&&e0?o=r-Xi(r,s):o=t,e=i&&ot?"A":"B"}function hp(e,t,i,r,s,n){let o=e,l=t,h="";for(;(o!==i||l!==r)&&l>=0&&ln.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!s&&o<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,e+1),o=n.cols-1,e=o,l--);return h+n.buffer.translateBufferLineToString(l,!1,e,o)}function Ts(e,t){let i=t?"O":"[";return k.ESC+i+e}function Ns(e,t){e=Math.floor(e);let i="";for(let r=0;rthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Au(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var _l=50,r0=15,s0=50,n0=500,o0=" ",l0=new RegExp(o0,"g"),$a=class extends j{constructor(e,t,i,r,s,n,o,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=r,this._coreService=s,this._mouseService=n,this._optionsService=o,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new yt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new P),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new P),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new P),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new P),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=a=>this._handleMouseMove(a),this._mouseUpListener=a=>this._handleMouseUp(a),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(a=>this._handleTrim(a)),this._register(this._bufferService.buffers.onBufferActivate(a=>this._handleBufferActivate(a))),this.enable(),this._model=new i0(this._bufferService),this._activeSelectionMode=0,this._register(ne(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(a=>{a.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let s=e[0]s.replace(l0," ")).join(np?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),rc&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r||!t?!1:this._areCoordsInSelection(t,i,r)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r?!1:this._areCoordsInSelection([e,t],i,r)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var s,n;let i=(n=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Au(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ic(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-_l),_l),t/=_l,t/Math.abs(t)+Math.round(t*(r0-1)))}shouldForceSelection(e){return ao?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),s0)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ao&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let r=0;t>=r;r++){let s=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:s>1&&t!==r&&(i+=s-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,n=s.lines.get(e[1]);if(!n)return;let o=s.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(n,e[0]),h=l,a=e[0]-l,u=0,c=0,d=0,p=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;h1&&(p+=g-1,h+=g-1);x>0&&l>0&&!this._isCharWordSeparator(n.loadCell(x-1,this._workCell));){n.loadCell(x-1,this._workCell);let m=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,x--):m>1&&(d+=m-1,l-=m-1),l--,x--}for(;f1&&(p+=m-1,h+=m-1),h++,f++}}h++;let _=l+a-u+d,v=Math.min(this._bufferService.cols,h-l+u+c-d-p);if(!(!t&&o.slice(l,h).trim()==="")){if(i&&_===0&&n.getCodePoint(0)!==32){let x=s.lines.get(e[1]-1);if(x&&n.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let f=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(f){let g=this._bufferService.cols-f.start;_-=g,v+=g}}}if(r&&_+v===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let x=s.lines.get(e[1]+1);if(x!=null&&x.isWrapped&&x.getCodePoint(0)!==32){let f=this._getWordAt([0,e[1]+1],!1,!1,!0);f&&(v+=f.length)}}return{start:_,length:v}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Au(i,this._bufferService.cols)}};$a=_e([M(3,Xe),M(4,Zi),M(5,Xh),M(6,Ge),M(7,ii),M(8,ti)],$a);var Iu=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},zu=class{constructor(){this._color=new Iu,this._css=new Iu}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},we=Object.freeze((()=>{let e=[le.toColor("#2e3436"),le.toColor("#cc0000"),le.toColor("#4e9a06"),le.toColor("#c4a000"),le.toColor("#3465a4"),le.toColor("#75507b"),le.toColor("#06989a"),le.toColor("#d3d7cf"),le.toColor("#555753"),le.toColor("#ef2929"),le.toColor("#8ae234"),le.toColor("#fce94f"),le.toColor("#729fcf"),le.toColor("#ad7fa8"),le.toColor("#34e2e2"),le.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let r=t[i/36%6|0],s=t[i/6%6|0],n=t[i%6];e.push({css:Se.toCss(r,s,n),rgba:Se.toRgba(r,s,n)})}for(let i=0;i<24;i++){let r=8+i*10;e.push({css:Se.toCss(r,r,r),rgba:Se.toRgba(r,r,r)})}return e})()),Ni=le.toColor("#ffffff"),is=le.toColor("#000000"),Fu=le.toColor("#ffffff"),Hu=is,Yr={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},a0=Ni,Wa=class extends j{constructor(e){super(),this._optionsService=e,this._contrastCache=new zu,this._halfContrastCache=new zu,this._onChangeColors=this._register(new P),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ni,background:is,cursor:Fu,cursorAccent:Hu,selectionForeground:void 0,selectionBackgroundTransparent:Yr,selectionBackgroundOpaque:ie.blend(is,Yr),selectionInactiveBackgroundTransparent:Yr,selectionInactiveBackgroundOpaque:ie.blend(is,Yr),scrollbarSliderBackground:ie.opacity(Ni,.2),scrollbarSliderHoverBackground:ie.opacity(Ni,.4),scrollbarSliderActiveBackground:ie.opacity(Ni,.5),overviewRulerBorder:Ni,ansi:we.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Z(e.foreground,Ni),t.background=Z(e.background,is),t.cursor=ie.blend(t.background,Z(e.cursor,Fu)),t.cursorAccent=ie.blend(t.background,Z(e.cursorAccent,Hu)),t.selectionBackgroundTransparent=Z(e.selectionBackground,Yr),t.selectionBackgroundOpaque=ie.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Z(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ie.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Z(e.selectionForeground,Tu):void 0,t.selectionForeground===Tu&&(t.selectionForeground=void 0),ie.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ie.opacity(t.selectionBackgroundTransparent,.3)),ie.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ie.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Z(e.scrollbarSliderBackground,ie.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Z(e.scrollbarSliderHoverBackground,ie.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Z(e.scrollbarSliderActiveBackground,ie.opacity(t.foreground,.5)),t.overviewRulerBorder=Z(e.overviewRulerBorder,a0),t.ansi=we.slice(),t.ansi[0]=Z(e.black,we[0]),t.ansi[1]=Z(e.red,we[1]),t.ansi[2]=Z(e.green,we[2]),t.ansi[3]=Z(e.yellow,we[3]),t.ansi[4]=Z(e.blue,we[4]),t.ansi[5]=Z(e.magenta,we[5]),t.ansi[6]=Z(e.cyan,we[6]),t.ansi[7]=Z(e.white,we[7]),t.ansi[8]=Z(e.brightBlack,we[8]),t.ansi[9]=Z(e.brightRed,we[9]),t.ansi[10]=Z(e.brightGreen,we[10]),t.ansi[11]=Z(e.brightYellow,we[11]),t.ansi[12]=Z(e.brightBlue,we[12]),t.ansi[13]=Z(e.brightMagenta,we[13]),t.ansi[14]=Z(e.brightCyan,we[14]),t.ansi[15]=Z(e.brightWhite,we[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;rn.index-o.index),r=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);r.push(o)}let s=i.length>0?i[0].index:t.length;if(t.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},u0={trace:0,debug:1,info:2,warn:3,error:4,off:5},d0="xterm.js: ",Ua=class extends j{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=u0[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+i.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+i.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let s=t-1;s>=0;s--)this.set(e+s+i,this.get(e+s));let r=e+t+i-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,i){this._data[t*K+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*K+0]=t|2097152|i[2]<<22):this._data[t*K+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*K+0]>>22}hasWidth(t){return this._data[t*K+0]&12582912}getFg(t){return this._data[t*K+1]}getBg(t){return this._data[t*K+2]}hasContent(t){return this._data[t*K+0]&4194303}getCodePoint(t){let i=this._data[t*K+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*K+0]&2097152}getString(t){let i=this._data[t*K+0];return i&2097152?this._combined[t]:i&2097151?ui(i&2097151):""}isProtected(t){return this._data[t*K+2]&536870912}loadCell(t,i){return gn=t*K,i.content=this._data[gn+0],i.fg=this._data[gn+1],i.bg=this._data[gn+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*K+0]=i.content,this._data[t*K+1]=i.fg,this._data[t*K+2]=i.bg}setCellFromCodepoint(t,i,r,s){s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*K+0]=i|r<<22,this._data[t*K+1]=s.fg,this._data[t*K+2]=s.bg}addCodepointToCell(t,i,r){let s=this._data[t*K+0];s&2097152?this._combined[t]+=ui(i):s&2097151?(this._combined[t]=ui(s&2097151)+ui(i),s&=-2097152,s|=2097152):s=i|1<<22,r&&(s&=-12582913,s|=r<<22),this._data[t*K+0]=s}insertCells(t,i,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i=0;--n)this.setCell(t+i+n,this.loadCell(t+n,s));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let s=new Uint32Array(r);s.set(this._data),this._data=s}for(let s=this.length;s=t&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*pl=0;--t)if(this._data[t*K+0]&4194303)return t+(this._data[t*K+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*K+0]&4194303||this._data[t*K+2]&50331648)return t+(this._data[t*K+0]>>22);return 0}copyCellsFrom(t,i,r,s,n){let o=t._data;if(n)for(let h=s-1;h>=0;h--){for(let a=0;a=i&&(this._combined[a-i+r]=t._combined[a])}}translateToString(t,i,r,s){i=i??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i>22||1}return s&&s.push(i),n}};function f0(e,t,i,r,s,n){let o=[];for(let l=0;l=l&&r0&&(x>c||u[x].getTrimmedLength()===0);x--)v++;v>0&&(o.push(l+u.length-v),o.push(v)),l+=u.length-1}return o}function _0(e,t){let i=[],r=0,s=t[r],n=0;for(let o=0;oOs(e,a,t)).reduce((h,a)=>h+a),n=0,o=0,l=0;for(;lh&&(n-=h,o++);let a=e[o].getWidth(n-1)===2;a&&n--;let u=a?i-1:i;r.push(u),l+=u}return r}function Os(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,s=e[t+1].getWidth(0)===2;return r&&s?i-1:i}var up=class dp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=dp._nextId++,this._onDispose=this.register(new P),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),qi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};up._nextId=1;var v0=up,be={},Oi=be.B;be[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};be.A={"#":"£"};be.B=void 0;be[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};be.C=be[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};be.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};be.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};be.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};be.E=be[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};be.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};be.H=be[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Wu=4294967295,Uu=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=me.clone(),this.savedCharset=Oi,this.markers=[],this._nullCell=yt.fromCharData([0,P_,1,0]),this._whitespaceCell=yt.fromCharData([0,gi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ho,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $u(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new no),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new no),this._whitespaceCell}getBlankLine(e,t){return new rs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&eWu?Wu:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=me);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new $u(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(me),r=0,s=this._getCorrectBufferLength(t);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new rs(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=f0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(me),i);if(r.length>0){let s=_0(this.lines,r);p0(this.lines,s.layout),this._reflowLargerAdjustViewport(e,t,s.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let r=this.getNullCell(me),s=i;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),h.unshift(l);if(!i){let m=this.ybase+this.y;if(m>=o&&m0&&(s.push({start:o+h.length+n,newLines:p}),n+=p.length),h.push(...p);let _=u.length-1,v=u[_];v===0&&(_--,v=u[_]);let x=h.length-c-1,f=a;for(;x>=0;){let m=Math.min(f,v);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[x],f-m,v-m,m,!0),v-=m,v===0&&(_--,v=u[_]),f-=m,f===0){x--;let y=Math.max(x,0);f=Os(h,y,this._cols)}}for(let m=0;m0;)this.ybase===0?this.y0){let o=[],l=[];for(let v=0;v=0;v--)if(c&&c.start>a+d){for(let x=c.newLines.length-1;x>=0;x--)this.lines.set(v--,c.newLines[x]);v++,o.push({index:a+1,amount:c.newLines.length}),d+=c.newLines.length,c=s[++u]}else this.lines.set(v,l[a--]);let p=0;for(let v=o.length-1;v>=0;v--)o[v].index+=p,this.lines.onInsertEmitter.fire(o[v]),p+=o[v].amount;let _=Math.max(0,h+n-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,i=0,r){let s=this.lines.get(e);return s?s.translateToString(t,i,r):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.linei.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},m0=class extends j{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new P),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Uu(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Uu(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},fp=2,_p=1,Ka=class extends j{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new P),this.onResize=this._onResize.event,this._onScroll=this._register(new P),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,fp),this.rows=Math.max(e.rawOptions.rows||0,_p),this.buffers=this._register(new m0(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let s=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(n+1,0,r.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-s+1;i.lines.shiftElements(s+1,o-1,-1),i.lines.set(n,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let r=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),r!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Ka=_e([M(0,Ge)],Ka);var tr={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ao,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},S0=["normal","bold","100","200","300","400","500","600","700","800","900"],y0=class extends j{constructor(e){super(),this._onOptionChange=this._register(new P),this.onOptionChange=this._onOptionChange.event;let t={...tr};for(let i in e)if(i in t)try{let r=e[i];t[i]=this._sanitizeAndValidateOption(i,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ne(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in tr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,r)=>{if(!(i in tr))throw new Error(`No option with key "${i}"`);r=this._sanitizeAndValidateOption(i,r),this.rawOptions[i]!==r&&(this.rawOptions[i]=r,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let r={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=tr[e]),!w0(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=tr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=S0.includes(t)?t:tr[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function w0(e){return e==="block"||e==="underline"||e==="bar"}function ss(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let r in e)i[r]=t<=1?e[r]:e[r]&&ss(e[r],t-1);return i}var Ku=Object.freeze({insertMode:!1}),ju=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ja=class extends j{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new P),this.onData=this._onData.event,this._onUserInput=this._register(new P),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new P),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new P),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ss(Ku),this.decPrivateModes=ss(ju)}reset(){this.modes=ss(Ku),this.decPrivateModes=ss(ju)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ja=_e([M(0,Xe),M(1,N_),M(2,Ge)],ja);var Vu={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function gl(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var vl=String.fromCharCode,Yu={DEFAULT:e=>{let t=[gl(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${vl(t[0])}${vl(t[1])}${vl(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${gl(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${gl(e,!0)};${e.x};${e.y}${t}`}},Va=class extends j{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new P),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Vu))this.addProtocol(r,Vu[r]);for(let r of Object.keys(Yu))this.addEncoding(r,Yu[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let r=t/i,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=r+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Va=_e([M(0,Xe),M(1,Zi),M(2,Ge)],Va);var ml=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],C0=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ce;function k0(e,t){let i=0,r=t.length-1,s;if(et[r][1])return!1;for(;r>=i;)if(s=i+r>>1,e>t[s][1])i=s+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),r=i===0&&t!==0;if(r){let s=Fi.extractWidth(t);s===0?r=!1:s>i&&(i=s)}return Fi.createPropertyValue(0,i,r)}},Fi=class Nn{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new P,this.onChange=this._onChange.event;let t=new x0;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,r=!1){return(t&16777215)<<3|(i&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,r=0,s=t.length;for(let n=0;n=s)return i+this.wcwidth(o);let a=t.charCodeAt(n);56320<=a&&a<=57343?o=(o-55296)*1024+a-56320+65536:i+=this.wcwidth(a)}let l=this.charProperties(o,r),h=Nn.extractWidth(l);Nn.extractShouldJoin(l)&&(h-=Nn.extractWidth(r)),i+=h,r=l}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},b0=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function qu(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var qr=2147483647,E0=256,pp=class Ya{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>E0)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Ya;if(!t.length)return i;for(let r=Array.isArray(t[0])?1:0;r>8,s=this._subParamsIdx[i]&255;s-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,s))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>qr?qr:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>qr?qr:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let t={};for(let i=0;i>8,s=this._subParamsIdx[i]&255;s-r>0&&(t[i]=this._subParams.slice(r,s))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(s*10+t,qr):t}},Xr=[],D0=class{constructor(){this._state=0,this._active=Xr,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xr}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Xr,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Xr,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Ro(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].end(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=Xr,this._id=-1,this._state=0}}},nt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ro(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Gr=[],R0=class{constructor(){this._handlers=Object.create(null),this._active=Gr,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gr}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gr,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gr,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ro(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].unhook(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=Gr,this._ident=0}},ns=new pp;ns.addParam(0);var Xu=class{constructor(e){this._handler=e,this._data="",this._params=ns,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ns,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ro(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=ns,this._data="",this._hitLimit=!1,i));return this._params=ns,this._data="",this._hitLimit=!1,t}},P0=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,r){this.table[t<<8|e]=i<<4|r}addMany(e,t,i,r){for(let s=0;sh),i=(l,h)=>t.slice(l,h),r=i(32,127),s=i(0,24);s.push(25),s.push.apply(s,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(r,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(pt,0,2,0),e.add(pt,8,5,8),e.add(pt,6,0,6),e.add(pt,11,0,11),e.add(pt,13,13,13),e}(),B0=class extends j{constructor(e=L0){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new pp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ne(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new D0),this._dcsParser=this._register(new R0),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;sn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=r,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let r=this._escHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let r=this._csiHandlers[i];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,r,s){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(e,t,i){let r=0,s=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=l[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l>4){case 2:for(let d=l+1;;++d){if(d>=t||(r=e[d])<32||r>126&&r=t||(r=e[d])<32||r>126&&r=t||(r=e[d])<32||r>126&&r=t||(r=e[d])<32||r>126&&r=0&&(o=h[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._preserveStack(3,h,a,s,l),o;a<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let u=this._escHandlers[this._collect<<8|r],c=u?u.length-1:-1;for(;c>=0&&(o=u[c](),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(4,u,c,s,l),o;c<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let d=l+1;;++d)if(d>=t||(r=e[d])===24||r===26||r===27||r>127&&r=t||(r=e[d])<32||r>127&&r>4:n>>8}return r}}function Sl(e,t){let i=e.toString(16),r=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function N0(e,t=16){let[i,r,s]=e;return`rgb:${Sl(i,t)}/${Sl(r,t)}/${Sl(s,t)}`}var O0={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ai=131072,Qu=10;function Zu(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Ju=5e3,ed=0,A0=class extends j{constructor(e,t,i,r,s,n,o,l,h=new B0){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=r,this._optionsService=s,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new tm,this._utf8Decoder=new im,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone(),this._onRequestBell=this._register(new P),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new P),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new P),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new P),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new P),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new P),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new P),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new P),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new P),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new P),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new P),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new P),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new P),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new qa(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:u.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,u,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:u,data:c})}),this._parser.setDcsHandlerFallback((a,u,c)=>{u==="HOOK"&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:u,payload:c})}),this._parser.setPrintHandler((a,u,c)=>this.print(a,u,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(k.BEL,()=>this.bell()),this._parser.setExecuteHandler(k.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(k.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(k.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(k.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(k.BS,()=>this.backspace()),this._parser.setExecuteHandler(k.HT,()=>this.tab()),this._parser.setExecuteHandler(k.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(k.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Mn.IND,()=>this.index()),this._parser.setExecuteHandler(Mn.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Mn.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new nt(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new nt(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new nt(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new nt(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new nt(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new nt(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new nt(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new nt(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new nt(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new nt(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new nt(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new nt(a=>this.restoreCursorColor(a))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let a in be)this._parser.registerEscHandler({intermediates:"(",final:a},()=>this.selectCharset("("+a)),this._parser.registerEscHandler({intermediates:")",final:a},()=>this.selectCharset(")"+a)),this._parser.registerEscHandler({intermediates:"*",final:a},()=>this.selectCharset("*"+a)),this._parser.registerEscHandler({intermediates:"+",final:a},()=>this.selectCharset("+"+a)),this._parser.registerEscHandler({intermediates:"-",final:a},()=>this.selectCharset("-"+a)),this._parser.registerEscHandler({intermediates:".",final:a},()=>this.selectCharset("."+a)),this._parser.registerEscHandler({intermediates:"/",final:a},()=>this.selectCharset("/"+a));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Xu((a,u)=>this.requestStatusString(a,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Ju))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Ju} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,r=this._activeBuffer.x,s=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ai&&(n=this._parseStack.position+ai)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,a=>String.fromCharCode(a)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(a=>a.charCodeAt(0)):e),this._parseBuffer.lengthai)for(let a=n;a0&&c.getWidth(this._activeBuffer.x-1)===2&&c.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let d=this._parser.precedingJoinState;for(let p=t;pl){if(h){let f=c,g=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&c instanceof rs&&c.copyCellsFrom(f,g,0,x,!1);g=0;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(a&&(c.insertCells(this._activeBuffer.x,s-x,this._activeBuffer.getNullCell(u)),c.getWidth(l-1)===2&&c.setCellFromCodepoint(l-1,0,1,u)),c.setCellFromCodepoint(this._activeBuffer.x++,r,s,u),s>0)for(;--s;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=d,this._activeBuffer.x0&&c.getWidth(this._activeBuffer.x)===0&&!c.hasContent(this._activeBuffer.x)&&c.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Zu(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Xu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new nt(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,r=!1,s=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&r.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let h=l;for(let a=1;a0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(k.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(k.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(k.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(k.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(k.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(v[v.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",v[v.SET=1]="SET",v[v.RESET=2]="RESET",v[v.PERMANENTLY_SET=3]="PERMANENTLY_SET",v[v.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let r=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:a,alt:u}=l,c=this._optionsService.rawOptions,d=(v,x)=>(o.triggerDataEvent(`${k.ESC}[${t?"":"?"}${v};${x}$y`),!0),p=v=>v?1:2,_=e.params[0];return t?_===2?d(_,4):_===4?d(_,p(o.modes.insertMode)):_===12?d(_,3):_===20?d(_,p(c.convertEol)):d(_,0):_===1?d(_,p(r.applicationCursorKeys)):_===3?d(_,c.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?d(_,p(r.origin)):_===7?d(_,p(r.wraparound)):_===8?d(_,3):_===9?d(_,p(s==="X10")):_===12?d(_,p(c.cursorBlink)):_===25?d(_,p(!o.isCursorHidden)):_===45?d(_,p(r.reverseWraparound)):_===66?d(_,p(r.applicationKeypad)):_===67?d(_,4):_===1e3?d(_,p(s==="VT200")):_===1002?d(_,p(s==="DRAG")):_===1003?d(_,p(s==="ANY")):_===1004?d(_,p(r.sendFocus)):_===1005?d(_,4):_===1006?d(_,p(n==="SGR")):_===1015?d(_,4):_===1016?d(_,p(n==="SGR_PIXELS")):_===1048?d(_,1):_===47||_===1047||_===1049?d(_,p(a===u)):_===2004?d(_,p(r.bracketedPasteMode)):_===2026?d(_,p(r.synchronizedOutput)):d(_,0)}_updateAttrColor(e,t,i,r,s){return t===2?(e|=50331648,e&=-16777216,e|=Ws.fromColorRGB([i,r,s])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let r=[0,0,-1,0,0,0],s=0,n=0;do{if(r[n+s]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),l=0;do r[1]===5&&(s=1),r[n+l+1+s]=o[l];while(++l=2||r[1]===2&&n+s>=5)break;r[1]&&(s=1)}while(++n+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=me.fg,e.bg=me.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,r=this._curAttrData;for(let s=0;s=30&&i<=37?(r.fg&=-50331904,r.fg|=16777216|i-30):i>=40&&i<=47?(r.bg&=-50331904,r.bg|=16777216|i-40):i>=90&&i<=97?(r.fg&=-50331904,r.fg|=16777216|i-90|8):i>=100&&i<=107?(r.bg&=-50331904,r.bg|=16777216|i-100|8):i===0?this._processSGR0(r):i===1?r.fg|=134217728:i===3?r.bg|=67108864:i===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,r)):i===5?r.fg|=536870912:i===7?r.fg|=67108864:i===8?r.fg|=1073741824:i===9?r.fg|=2147483648:i===2?r.bg|=134217728:i===21?this._processUnderline(2,r):i===22?(r.fg&=-134217729,r.bg&=-134217729):i===23?r.bg&=-67108865:i===24?(r.fg&=-268435457,this._processUnderline(0,r)):i===25?r.fg&=-536870913:i===27?r.fg&=-67108865:i===28?r.fg&=-1073741825:i===29?r.fg&=2147483647:i===39?(r.fg&=-67108864,r.fg|=me.fg&16777215):i===49?(r.bg&=-67108864,r.bg|=me.bg&16777215):i===38||i===48||i===58?s+=this._extractColor(e,s,r):i===53?r.bg|=1073741824:i===55?r.bg&=-1073741825:i===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):i===100?(r.fg&=-67108864,r.fg|=me.fg&16777215,r.bg&=-67108864,r.bg|=me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${k.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${k.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${k.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=me.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Zu(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${k.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Qu&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Qu&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let r=i.shift(),s=i.shift();if(/^\d+$/.exec(r)){let n=parseInt(r);if(td(n))if(s==="?")t.push({type:0,index:n});else{let o=Gu(s);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(i,r):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),r,s=i.findIndex(n=>n.startsWith("id="));return s!==-1&&(r=i[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let r=0;r=this._specialColors.length);++r,++t)if(i[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let s=Gu(i[r]);s&&this._onColor.fire([{type:1,index:this._specialColors[t],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let r=0;r=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new yt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${k.ESC}${o}${k.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},qa=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(ed=e,e=t,t=ed),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};qa=_e([M(0,Xe)],qa);function td(e){return 0<=e&&e<256}var I0=5e7,id=12,z0=50,F0=class extends j{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new P),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>I0)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],s=this._action(r,t);if(s){let o=l=>performance.now()-i>=id?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(i,l);s.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-i>=id)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>z0&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Xa=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let i=e,r=this._getEntryIdKey(i),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,t.ybase+t.y),s.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);i.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(i,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Xa=_e([M(0,Xe)],Xa);var rd=!1,H0=class extends j{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Lr),this._onBinary=this._register(new P),this.onBinary=this._onBinary.event,this._onData=this._register(new P),this.onData=this._onData.event,this._onLineFeed=this._register(new P),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new P),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new P),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new P),this._instantiationService=new c0,this.optionsService=this._register(new y0(e)),this._instantiationService.setService(Ge,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ka)),this._instantiationService.setService(Xe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ua)),this._instantiationService.setService(N_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ja)),this._instantiationService.setService(Zi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Va)),this._instantiationService.setService(T_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Fi)),this._instantiationService.setService(om,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b0),this._instantiationService.setService(nm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Xa),this._instantiationService.setService(O_,this._oscLinkService),this._inputHandler=this._register(new A0(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ae.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ae.forward(this._bufferService.onResize,this._onResize)),this._register(Ae.forward(this.coreService.onData,this._onData)),this._register(Ae.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new F0((t,i)=>this._inputHandler.parse(t,i))),this._register(Ae.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new P),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!rd&&(this._logService.warn("writeSync is unreliable and will be removed soon."),rd=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,fp),t=Math.max(t,_p),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(qu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(qu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ne(()=>{for(let t of e)t.dispose()})}}},$0={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function W0(e,t,i,r){var o;let s={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?s.key=k.ESC+"OA":s.key=k.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?s.key=k.ESC+"OD":s.key=k.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?s.key=k.ESC+"OC":s.key=k.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?s.key=k.ESC+"OB":s.key=k.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":k.DEL,e.altKey&&(s.key=k.ESC+s.key);break;case 9:if(e.shiftKey){s.key=k.ESC+"[Z";break}s.key=k.HT,s.cancel=!0;break;case 13:s.key=e.altKey?k.ESC+k.CR:k.CR,s.cancel=!0;break;case 27:s.key=k.ESC,e.altKey&&(s.key=k.ESC+k.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;n?s.key=k.ESC+"[1;"+(n+1)+"D":t?s.key=k.ESC+"OD":s.key=k.ESC+"[D";break;case 39:if(e.metaKey)break;n?s.key=k.ESC+"[1;"+(n+1)+"C":t?s.key=k.ESC+"OC":s.key=k.ESC+"[C";break;case 38:if(e.metaKey)break;n?s.key=k.ESC+"[1;"+(n+1)+"A":t?s.key=k.ESC+"OA":s.key=k.ESC+"[A";break;case 40:if(e.metaKey)break;n?s.key=k.ESC+"[1;"+(n+1)+"B":t?s.key=k.ESC+"OB":s.key=k.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=k.ESC+"[2~");break;case 46:n?s.key=k.ESC+"[3;"+(n+1)+"~":s.key=k.ESC+"[3~";break;case 36:n?s.key=k.ESC+"[1;"+(n+1)+"H":t?s.key=k.ESC+"OH":s.key=k.ESC+"[H";break;case 35:n?s.key=k.ESC+"[1;"+(n+1)+"F":t?s.key=k.ESC+"OF":s.key=k.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=k.ESC+"[5;"+(n+1)+"~":s.key=k.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=k.ESC+"[6;"+(n+1)+"~":s.key=k.ESC+"[6~";break;case 112:n?s.key=k.ESC+"[1;"+(n+1)+"P":s.key=k.ESC+"OP";break;case 113:n?s.key=k.ESC+"[1;"+(n+1)+"Q":s.key=k.ESC+"OQ";break;case 114:n?s.key=k.ESC+"[1;"+(n+1)+"R":s.key=k.ESC+"OR";break;case 115:n?s.key=k.ESC+"[1;"+(n+1)+"S":s.key=k.ESC+"OS";break;case 116:n?s.key=k.ESC+"[15;"+(n+1)+"~":s.key=k.ESC+"[15~";break;case 117:n?s.key=k.ESC+"[17;"+(n+1)+"~":s.key=k.ESC+"[17~";break;case 118:n?s.key=k.ESC+"[18;"+(n+1)+"~":s.key=k.ESC+"[18~";break;case 119:n?s.key=k.ESC+"[19;"+(n+1)+"~":s.key=k.ESC+"[19~";break;case 120:n?s.key=k.ESC+"[20;"+(n+1)+"~":s.key=k.ESC+"[20~";break;case 121:n?s.key=k.ESC+"[21;"+(n+1)+"~":s.key=k.ESC+"[21~";break;case 122:n?s.key=k.ESC+"[23;"+(n+1)+"~":s.key=k.ESC+"[23~";break;case 123:n?s.key=k.ESC+"[24;"+(n+1)+"~":s.key=k.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=k.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=k.DEL:e.keyCode===219?s.key=k.ESC:e.keyCode===220?s.key=k.FS:e.keyCode===221&&(s.key=k.GS);else if((!i||r)&&e.altKey&&!e.metaKey){let l=(o=$0[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)s.key=k.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,a=String.fromCharCode(h);e.shiftKey&&(a=a.toUpperCase()),s.key=k.ESC+a}else if(e.keyCode===32)s.key=k.ESC+(e.ctrlKey?k.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),s.key=k.ESC+h,s.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=k.US),e.key==="@"&&(s.key=k.NUL));break}return s}var pe=0,U0=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ho,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ho,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,n)=>this._getKey(s)-this._getKey(n)),t=0,i=0,r=new Array(this._array.length+this._insertedValues.length);for(let s=0;s=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(r[s]=e[t],t++):r[s]=this._array[i++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(pe=this._search(t),pe===-1)||this._getKey(this._array[pe])!==t)return!1;do if(this._array[pe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pe),!0;while(++pes-n),t=0,i=new Array(this._array.length-e.length),r=0;for(let s=0;s0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pe=this._search(e),!(pe<0||pe>=this._array.length)&&this._getKey(this._array[pe])===e))do yield this._array[pe];while(++pe=this._array.length)&&this._getKey(this._array[pe])===e))do t(this._array[pe]);while(++pe=t;){let r=t+i>>1,s=this._getKey(this._array[r]);if(s>e)i=r-1;else if(s0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},yl=0,sd=0,K0=class extends j{constructor(){super(),this._decorations=new U0(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new P),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new P),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ne(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new j0(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let r=0,s=0;for(let n of this._decorations.getKeyIterator(t))r=n.options.x??0,s=r+(n.options.width??1),e>=r&&e{yl=s.options.x??0,sd=yl+(s.options.width??1),e>=yl&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=r-this._lastRefreshMs,n=this._debounceThresholdMS-s;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},nd=20,co=class extends j{constructor(e,t,i,r){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Y0(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(H(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ne(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===nd+1&&(this._liveRegion.textContent+=pa.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,r=i.lines.length.toString();for(let s=e;s<=t;s++){let n=i.lines.get(i.ydisp+s),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+s+1).toString(),a=this._rowElements[s];a&&(l.length===0?(a.textContent=" ",this._rowColumns.set(a,[0,1])):(a.textContent=l,this._rowColumns.set(a,o)),a.setAttribute("aria-posinset",h),a.setAttribute("aria-setsize",r),this._alignRowWidth(a))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],s=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(s===n||e.relatedTarget!==r)return;let o,l;if(t===0?(o=i,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(i.node))return;let s=({node:h,offset:a})=>{let u=h instanceof Text?h.parentNode:h,c=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(u);if(!d)return console.warn("columns is null. Race condition?"),null;let p=a=this._terminal.cols&&(++c,p=0),{row:c,column:p}},n=s(t),o=s(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var n;qi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(H(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(H(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(H(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(H(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let r=0;r{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(s=this._activeProviderReplies)!=null&&s.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,l=>{var a,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(c=>({link:c}));(a=this._activeProviderReplies)==null||a.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let r=0;re?this._bufferService.cols:o.link.range.end.x;for(let a=l;a<=h;a++){if(i.has(a)){s.splice(n--,1);break}i.add(a)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(e),s=!1;for(let o=0;othis._linkAtPosition(l.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;othis._linkAtPosition(h.link,t));if(l){i=!0,this._handleNewLink(l);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&q0(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,qi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.pointerCursor},set:i=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.underline},set:i=>{var r,s,n;(r=this._currentLink)!=null&&r.state&&((n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let r=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-r-1,i.end.x,i.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,t,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,s=t.y*this._bufferService.cols+t.x;return i<=s&&s<=r}_positionFromMouseEvent(e,t,i){let r=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,r,s){return{x1:e,y1:t,x2:i,y2:r,cols:this._bufferService.cols,fg:s}}};Ga=_e([M(1,Xh),M(2,ii),M(3,Xe),M(4,I_)],Ga);function q0(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var X0=class extends H0{constructor(e={}){super(e),this._linkifier=this._register(new Lr),this.browser=ip,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Lr),this._onCursorMove=this._register(new P),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new P),this.onKey=this._onKey.event,this._onRender=this._register(new P),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new P),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new P),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new P),this.onBell=this._onBell.event,this._onFocus=this._register(new P),this._onBlur=this._register(new P),this._onA11yCharEmitter=this._register(new P),this._onA11yTabEmitter=this._register(new P),this._onWillOpen=this._register(new P),this._setup(),this._decorationService=this._instantiationService.createInstance(K0),this._instantiationService.setService(Us,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(zS),this._instantiationService.setService(I_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(va)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ae.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ae.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ae.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ae.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ne(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,r="";switch(t.index){case 256:i="foreground",r="10";break;case 257:i="background",r="11";break;case 258:i="cursor",r="12";break;default:i="ansi",r="4;"+t.index}switch(t.type){case 0:let s=ie.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${k.ESC}]${r};${N0(s)}${ep.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Se.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Se.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(co,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(k.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(k.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*s,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(H(this.element,"copy",t=>{this.hasSelection()&&Jv(t,this._selectionService)}));let e=t=>em(t,this.textarea,this.coreService,this.optionsService);this._register(H(this.textarea,"paste",e)),this._register(H(this.element,"paste",e)),rp?this._register(H(this.element,"mousedown",t=>{t.button===2&&pu(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(H(this.element,"contextmenu",t=>{pu(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),rc&&this._register(H(this.element,"auxclick",t=>{t.button===1&&R_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(H(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(H(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(H(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(H(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(H(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(H(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(H(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(H(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_a.get()),op||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(AS,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ti,this._coreBrowserService),this._register(H(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(H(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(za,this._document,this._helperContainer),this._instantiationService.setService(Po,this._charSizeService),this._themeService=this._instantiationService.createInstance(Wa),this._instantiationService.setService(Nr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lo),this._instantiationService.setService(A_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ha,this.rows,this.screenElement)),this._instantiationService.setService(ii,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Oa,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Fa),this._instantiationService.setService(Xh,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Ga,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Ta,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance($a,this.element,this.screenElement,r)),this._instantiationService.setService(am,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ae.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Na,this.screenElement)),this._register(H(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(co,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(oo,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(oo,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ia,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var a,u,c,d,p;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let _=n.deltaY;if(_===0||e.coreMouseService.consumeWheelEvent(n,(d=(c=(u=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:u.device)==null?void 0:c.cell)==null?void 0:d.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;h=_<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?r.mousemove||(t.addEventListener("mousemove",s.mousemove),r.mousemove=s.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),n&16?r.wheel||(t.addEventListener("wheel",s.wheel,{passive:!1}),r.wheel=s.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),n&2?r.mouseup||(r.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),n&4?r.mousedrag||(r.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(H(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(n)})),this._register(H(t,"wheel",n=>{var o,l,h,a,u;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(a=(h=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:a.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let c=k.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){D_(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=W0(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===k.ETX||i.key===k.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(G0(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new yt)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},od=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Z0(t)}getNullCell(){return new yt}},J0=class extends j{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new P),this.onBufferChange=this._onBufferChange.event,this._normal=new od(this._core.buffers.normal,"normal"),this._alternate=new od(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},ey=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,r)=>t(i,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},ty=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},iy=["cols","rows"],Nt=0,ry=class extends j{constructor(e){super(),this._core=this._register(new X0(e)),this._addonManager=this._register(new Q0),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],i=(r,s)=>{this._checkReadonlyOptions(r),this._core.options[r]=s};for(let r in this._core.options){let s={get:t.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,s)}}_checkReadonlyOptions(e){if(iy.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new ey(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ty(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new J0(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return _a.get()},set promptLabel(e){_a.set(e)},get tooMuchOutput(){return pa.get()},set tooMuchOutput(e){pa.set(e)}}}_verifyIntegers(...e){for(Nt of e)if(Nt===1/0||isNaN(Nt)||Nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Nt of e)if(Nt&&(Nt===1/0||isNaN(Nt)||Nt%1!==0||Nt<0))throw new Error("This API only accepts positive integers")}};/** - * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. - * @license MIT - * - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - */var sy=2,ny=1,oy=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var c;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((c=this._terminal.options.overviewRuler)==null?void 0:c.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=o.top+o.bottom,h=o.right+o.left,a=r-l,u=s-h-t;return{cols:Math.max(sy,Math.floor(u/e.css.cell.width)),rows:Math.max(ny,Math.floor(a/e.css.cell.height))}}};function ly(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function Rt(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}var ld;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_SUSPENDED="tauri://suspended",e.WINDOW_RESUMED="tauri://resumed",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(ld||(ld={}));async function ay(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await Rt("plugin:event|unlisten",{event:e,eventId:t})}async function Qa(e,t,i){var r;const s=(r=void 0)!==null&&r!==void 0?r:{kind:"Any"};return Rt("plugin:event|listen",{event:e,target:s,handler:ly(t)}).then(n=>async()=>ay(e,n))}const ir={spawn:e=>Rt("pty_spawn",{opts:e}),write:(e,t)=>Rt("pty_write",{id:e,data:t}),resize:(e,t,i)=>Rt("pty_resize",{id:e,cols:t,rows:i}),kill:e=>Rt("pty_kill",{id:e}),onData:e=>Qa("pty:data",t=>e(t.payload)),onExit:e=>Qa("pty:exit",t=>e(t.payload))};function hy(e){let t="";for(let i=0;iRt("app_launch",{opts:{command:e}}),setGeometry:(e,t,i,r,s)=>Rt("app_set_geometry",{xid:e,x:t,y:i,width:r,height:s}),setVisible:(e,t)=>Rt("app_set_visible",{xid:e,visible:t}),setAllVisible:e=>Rt("app_set_all_visible",{visible:e}),close:e=>Rt("app_close",{xid:e}),onDestroyed:e=>Qa("app:destroyed",t=>e(t.payload))},ad=13;function dy({card:e,onUpdate:t}){const i=$s(),r=Vh(e,u=>t(u)),s=Y.useRef(null),n=Y.useRef(null),o=Y.useRef(null),l=Y.useRef(e.ptyId),[h,a]=Y.useState(!1);return Y.useEffect(()=>{let u,c,d=!1;const p=new ry({fontSize:ad*i.scale,fontFamily:'Menlo, "Cascadia Code", Consolas, monospace',theme:{background:"#1d1d23",foreground:"#e8e8ec",cursor:"#e8e8ec"},cursorBlink:!0,allowProposedApi:!0}),_=new oy;return p.loadAddon(_),p.open(s.current),_.fit(),n.current=p,o.current=_,(async()=>{let v=l.current;if(!v){if(v=await ir.spawn({cols:p.cols,rows:p.rows}),d){await ir.kill(v);return}l.current=v,t({ptyId:v})}u=await ir.onData(x=>{x.id===v&&p.write(cy(x.data))}),c=await ir.onExit(x=>{x.id===v&&p.write(`\r -\x1B[2m[process exited]\x1B[0m\r -`)}),p.onData(x=>{ir.write(v,uy(x)).catch(f=>console.error("pty_write",f))}),p.onResize(({cols:x,rows:f})=>{ir.resize(v,x,f).catch(()=>{})}),a(!0)})(),()=>{d=!0,u==null||u(),c==null||c(),p.dispose()}},[]),Y.useEffect(()=>{if(!h)return;const u=n.current,c=o.current;!u||!c||(u.options.fontSize=ad*i.scale,c.fit())},[i.scale,h]),Y.useEffect(()=>{var u;h&&((u=o.current)==null||u.fit())},[e.width,e.height,h]),z.jsxs("div",{className:"card terminal-card",style:{left:i.x+e.x*i.scale,top:i.y+e.y*i.scale,width:e.width*i.scale,height:e.height*i.scale,zIndex:e.z,"--scale":i.scale},children:[z.jsx("div",{className:"card-header",...r,children:"terminal"}),z.jsx("div",{className:"card-body terminal-body",ref:s,onPointerDown:u=>u.stopPropagation(),onWheel:u=>u.stopPropagation()}),z.jsx(Yh,{card:e,onUpdate:u=>t(u)})]})}const fy=26,_y=.4;function py({card:e,onUpdate:t}){const i=$s(),r=Vh(e,c=>t(c)),s=Y.useRef(null),n=i.x+e.x*i.scale,o=i.y+e.y*i.scale,l=e.width*i.scale,h=e.height*i.scale,a=fy*i.scale,u=i.scale>=_y;return Y.useEffect(()=>{e.xWindowId&&(s.current!==u&&(Cr.setVisible(e.xWindowId,u).catch(()=>{}),s.current=u),u&&Cr.setGeometry(e.xWindowId,n,o+a,l,Math.max(1,h-a)).catch(()=>{}))},[e.xWindowId,n,o,l,h,a,u]),Y.useEffect(()=>()=>{e.xWindowId&&Cr.close(e.xWindowId).catch(()=>{})},[]),z.jsxs("div",{className:"card app-card",style:{left:n,top:o,width:l,height:h,zIndex:e.z,fontSize:13*i.scale,"--scale":i.scale},children:[z.jsx("div",{className:"card-header",...r,children:e.title||"app"}),z.jsx("div",{className:"card-body app-body",children:!u&&z.jsxs("div",{className:"app-placeholder",children:[z.jsx("div",{className:"app-placeholder-title",children:e.title||e.command}),z.jsx("div",{className:"app-placeholder-hint",children:"zoom in to view"})]})}),z.jsx(Yh,{card:e,onUpdate:c=>t(c)})]})}const gy=[{label:"VSCode",cmd:"code --new-window"},{label:"Firefox",cmd:"firefox --new-instance"},{label:"Files",cmd:"nautilus --new-window"},{label:"Calculator",cmd:"gnome-calculator"},{label:"xterm",cmd:"xterm"}];function vy({open:e,onClose:t,onLaunched:i}){const[r,s]=Y.useState(""),[n,o]=Y.useState(!1),[l,h]=Y.useState(null),a=Y.useRef(null);if(Y.useEffect(()=>{e&&(h(null),s(""),o(!1),setTimeout(()=>{var c;return(c=a.current)==null?void 0:c.focus()},0))},[e]),!e)return null;const u=async c=>{if(c.trim()){o(!0),h(null);try{const d=await Cr.launch(c);i({...d,command:c}),t()}catch(d){h(String(d)),o(!1)}}};return z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"launch-dialog-backdrop",onClick:t}),z.jsxs("div",{className:"launch-dialog",onPointerDown:c=>c.stopPropagation(),children:[z.jsx("h3",{children:"Launch app"}),z.jsx("input",{ref:a,value:r,onChange:c=>s(c.target.value),onKeyDown:c=>{c.key==="Enter"&&u(r),c.key==="Escape"&&t()},placeholder:"e.g. code --new-window /path/to/repo",disabled:n}),z.jsx("div",{className:"launch-dialog-presets",children:gy.map(c=>z.jsx("button",{onClick:()=>u(c.cmd),disabled:n,children:c.label},c.label))}),l&&z.jsx("div",{className:"launch-dialog-error",children:l}),z.jsxs("div",{className:"launch-dialog-actions",children:[z.jsx("button",{onClick:t,disabled:n,children:"Cancel"}),z.jsx("button",{className:"primary",onClick:()=>u(r),disabled:n||!r.trim(),children:n?"Launching…":"Launch"})]})]})]})}const my=.1,Sy=4,yy=.0015;function wy({initialCards:e}){const[t,i]=Y.useState(e),[r,s]=Y.useState({x:0,y:0,scale:1}),[n,o]=Y.useState(!1),[l,h]=Y.useState(!1),a=Y.useRef(null),u=Y.useRef(null),c=Y.useRef(e.reduce((S,C)=>Math.max(S,C.z),0));Y.useEffect(()=>{const S=b=>{b.code==="Space"&&!b.repeat&&o(!0)},C=b=>{b.code==="Space"&&o(!1)};return window.addEventListener("keydown",S),window.addEventListener("keyup",C),()=>{window.removeEventListener("keydown",S),window.removeEventListener("keyup",C)}},[]),Y.useEffect(()=>{const S=a.current;if(!S)return;const C=b=>{b.button===1&&b.preventDefault()};return S.addEventListener("mousedown",C),S.addEventListener("auxclick",C),()=>{S.removeEventListener("mousedown",C),S.removeEventListener("auxclick",C)}},[]),Y.useEffect(()=>{let S;return Cr.onDestroyed(C=>{i(b=>b.filter(R=>!(R.kind==="app"&&R.xWindowId===C)))}).then(C=>S=C),()=>S==null?void 0:S()},[]),Y.useEffect(()=>{Cr.setAllVisible(!l).catch(()=>{})},[l]);const d=Y.useCallback(S=>{if(!S.ctrlKey&&!S.metaKey)return;S.preventDefault();const C=a.current.getBoundingClientRect(),b=S.clientX-C.left,R=S.clientY-C.top;s(W=>{const $=Math.exp(-S.deltaY*yy),U=Math.max(my,Math.min(Sy,W.scale*$)),L=U/W.scale;return{x:b-(b-W.x)*L,y:R-(R-W.y)*L,scale:U}})},[]),p=S=>{var b;(S.button===1||S.button===0&&n)&&(S.preventDefault(),(b=a.current)==null||b.setPointerCapture(S.pointerId),u.current={startX:S.clientX,startY:S.clientY,vpX:r.x,vpY:r.y})},_=S=>{const C=u.current;if(!C)return;const b=C.vpX+(S.clientX-C.startX),R=C.vpY+(S.clientY-C.startY);s(W=>({...W,x:b,y:R}))},v=S=>{var C;if(u.current){try{(C=a.current)==null||C.releasePointerCapture(S.pointerId)}catch{}u.current=null}},x=(S,C)=>{i(b=>b.map(R=>R.id===S?{...R,...C}:R))},f=S=>{const C=window.innerWidth/2,b=window.innerHeight/2,R=(C-r.x)/r.scale,W=(b-r.y)/r.scale,$=crypto.randomUUID();c.current+=1;const U=S($,R,W,c.current);i(L=>[...L,U])},g=()=>f((S,C,b,R)=>({id:S,kind:"note",x:C-160,y:b-90,width:320,height:180,z:R,text:""})),m=()=>f((S,C,b,R)=>({id:S,kind:"terminal",x:C-280,y:b-180,width:560,height:360,z:R,ptyId:""})),y=S=>f((C,b,R,W)=>({id:C,kind:"app",x:b-400,y:R-260,width:800,height:520,z:W,xWindowId:S.xid,command:S.command,title:S.title}));return z.jsxs("div",{ref:a,className:`canvas-container ${n?"pan-mode":""} ${u.current?"panning":""}`,onWheel:d,onPointerDown:p,onPointerMove:_,onPointerUp:v,onPointerCancel:v,children:[z.jsx("div",{className:"canvas-grid",style:{backgroundPosition:`${r.x}px ${r.y}px`,backgroundSize:`${40*r.scale}px ${40*r.scale}px`}}),z.jsx(b_.Provider,{value:r,children:t.map(S=>S.kind==="note"?z.jsx(qv,{card:S,onUpdate:C=>x(S.id,C)},S.id):S.kind==="terminal"?z.jsx(dy,{card:S,onUpdate:C=>x(S.id,C)},S.id):S.kind==="app"?z.jsx(py,{card:S,onUpdate:C=>x(S.id,C)},S.id):null)}),z.jsxs("div",{className:"toolbar",children:[z.jsx("button",{onClick:g,children:"+ Note"}),z.jsx("button",{onClick:m,children:"+ Terminal"}),z.jsx("button",{onClick:()=>h(!0),children:"+ App"})]}),z.jsx(vy,{open:l,onClose:()=>h(!1),onLaunched:y}),z.jsxs("div",{className:"canvas-hud",children:[z.jsxs("span",{children:["x ",r.x.toFixed(0)]}),z.jsxs("span",{children:["y ",r.y.toFixed(0)]}),z.jsxs("span",{children:[(r.scale*100).toFixed(0),"%"]})]})]})}const Cy=[{id:"welcome",kind:"note",x:200,y:200,width:340,height:200,z:1,text:`Welcome to Infinite. - -Pan: middle-drag or Space + drag -Zoom: Ctrl + scroll - -Use the toolbar to add notes and terminals.`}];function ky(){return z.jsx(wy,{initialCards:Cy})}wl.createRoot(document.getElementById("root")).render(z.jsx(Mp.StrictMode,{children:z.jsx(ky,{})})); diff --git a/dist/assets/index-fBlcXAv5.css b/dist/assets/index-BRF-Y_tu.css similarity index 62% rename from dist/assets/index-fBlcXAv5.css rename to dist/assets/index-BRF-Y_tu.css index 70df276..832018b 100644 --- a/dist/assets/index-fBlcXAv5.css +++ b/dist/assets/index-BRF-Y_tu.css @@ -29,4 +29,4 @@ * The original design remains. The terminal itself * has been extended to include xterm CSI codes, among * other features. - */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.canvas-container{position:fixed;top:0;right:0;bottom:0;left:0;overflow:hidden;cursor:default;background:var(--bg);touch-action:none;overscroll-behavior:contain}.canvas-container.pan-mode{cursor:grab}.canvas-container.panning{cursor:grabbing}.canvas-grid{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;background-image:radial-gradient(circle,var(--bg-grid) 1px,transparent 1px);background-repeat:repeat}.canvas-hud{position:fixed;bottom:12px;left:12px;display:flex;gap:12px;padding:6px 10px;background:#00000080;border-radius:6px;font-size:11px;font-family:ui-monospace,Menlo,monospace;color:var(--text);pointer-events:none;z-index:1000}.card{position:absolute;background:var(--card-bg);border:calc(1px * var(--scale, 1)) solid var(--card-border);border-radius:calc(8px * var(--scale, 1));box-shadow:0 calc(4px * var(--scale, 1)) calc(16px * var(--scale, 1)) #0000004d;overflow:hidden;display:flex;flex-direction:column}.card-header{padding:.46em .77em;background:#0003;border-bottom:calc(1px * var(--scale, 1)) solid var(--card-border);font-size:.85em;cursor:move;flex-shrink:0}.card-body{flex:1;overflow:auto}.note-card textarea{width:100%;height:100%;background:transparent;border:none;outline:none;resize:none;color:var(--text);font-family:inherit;font-size:1em;padding:.77em}.terminal-body{background:#1d1d23;padding:calc(4px * var(--scale, 1));height:100%}.app-body{background:transparent;position:relative}.app-placeholder{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;background:#2a2a32;color:var(--text)}.app-placeholder-title{font-size:1.1em;opacity:.9}.app-placeholder-hint{font-size:.85em;opacity:.5}.launch-dialog{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:var(--card-bg);border:1px solid var(--card-border);border-radius:10px;padding:18px;min-width:380px;box-shadow:0 12px 40px #00000080;z-index:2000}.launch-dialog-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#0006;z-index:1999}.launch-dialog h3{margin-bottom:12px;font-weight:500;font-size:14px}.launch-dialog input{width:100%;padding:8px 10px;background:var(--bg);color:var(--text);border:1px solid var(--card-border);border-radius:6px;font-family:ui-monospace,Menlo,monospace;font-size:13px;outline:none}.launch-dialog input:focus{border-color:var(--accent)}.launch-dialog-presets{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}.launch-dialog-presets button{background:#ffffff0a;color:var(--text);border:1px solid var(--card-border);border-radius:5px;padding:4px 9px;font-size:11px;cursor:pointer}.launch-dialog-presets button:hover{border-color:var(--accent)}.launch-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:10px}.launch-dialog-actions button{background:var(--card-bg);color:var(--text);border:1px solid var(--card-border);border-radius:5px;padding:6px 14px;font-size:12px;cursor:pointer}.launch-dialog-actions button.primary{background:var(--accent);border-color:var(--accent)}.launch-dialog-error{color:#ff6464;font-size:12px;margin-top:8px}.terminal-body .xterm,.terminal-body .xterm-viewport,.terminal-body .xterm-screen{height:100%!important;width:100%!important}.resize-handle{position:absolute;z-index:5;background:transparent}.resize-n,.resize-s{left:0;right:0;height:8px;cursor:ns-resize}.resize-n{top:-4px}.resize-s{bottom:-4px}.resize-e,.resize-w{top:0;bottom:0;width:8px;cursor:ew-resize}.resize-e{right:-4px}.resize-w{left:-4px}.resize-ne,.resize-nw,.resize-se,.resize-sw{width:14px;height:14px;z-index:6}.resize-ne{top:-4px;right:-4px;cursor:nesw-resize}.resize-nw{top:-4px;left:-4px;cursor:nwse-resize}.resize-se{bottom:-4px;right:-4px;cursor:nwse-resize}.resize-sw{bottom:-4px;left:-4px;cursor:nesw-resize}.toolbar{position:fixed;top:12px;left:12px;display:flex;gap:6px;padding:6px;background:#00000080;border-radius:8px;z-index:1000}.toolbar button{background:var(--card-bg);color:var(--text);border:1px solid var(--card-border);border-radius:5px;padding:6px 10px;font-size:12px;cursor:pointer;font-family:inherit}.toolbar button:hover{border-color:var(--accent)}:root{--bg: #1a1a1f;--bg-grid: #25252c;--card-bg: #2a2a32;--card-border: #3a3a45;--text: #e8e8ec;--accent: #6a8cff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;color-scheme:dark}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{width:100%;height:100%;overflow:hidden;background:var(--bg);color:var(--text);-webkit-user-select:none;user-select:none} + */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.canvas-container{position:fixed;top:0;right:0;bottom:0;left:0;overflow:hidden;cursor:default;background:var(--bg);touch-action:none;overscroll-behavior:contain}.canvas-container.pan-mode{cursor:grab}.canvas-container.panning{cursor:grabbing}.canvas-grid{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;background-image:radial-gradient(circle,var(--bg-grid) 1px,transparent 1px);background-repeat:repeat}.canvas-hud{position:fixed;bottom:12px;left:12px;display:flex;gap:12px;padding:6px 10px;background:#00000080;border-radius:6px;font-size:11px;font-family:ui-monospace,Menlo,monospace;color:var(--text);pointer-events:none;z-index:1000}.card{position:absolute;background:var(--card-bg);border:calc(1px * var(--scale, 1)) solid var(--card-border);border-radius:calc(8px * var(--scale, 1));box-shadow:0 calc(4px * var(--scale, 1)) calc(16px * var(--scale, 1)) #0000004d;display:flex;flex-direction:column}.card-header{padding:.46em .77em;background:#0003;border-bottom:calc(1px * var(--scale, 1)) solid var(--card-border);font-size:.85em;cursor:move;flex-shrink:0;overflow:hidden;border-top-left-radius:inherit;border-top-right-radius:inherit}.card-body{flex:1;overflow:hidden;border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.note-body .cm-editor{height:100%}.note-body .cm-editor.cm-focused{outline:none}.terminal-body{background:#1d1d23;padding:calc(4px * var(--scale, 1));height:100%}.terminal-body .xterm,.terminal-body .xterm-viewport,.terminal-body .xterm-screen{height:100%!important;width:100%!important}.resize-handle{position:absolute;z-index:5;background:transparent}.resize-n,.resize-s{left:0;right:0;height:8px;cursor:ns-resize}.resize-n{top:-4px}.resize-s{bottom:-4px}.resize-e,.resize-w{top:0;bottom:0;width:8px;cursor:ew-resize}.resize-e{right:-4px}.resize-w{left:-4px}.resize-ne,.resize-nw,.resize-se,.resize-sw{width:14px;height:14px;z-index:6}.resize-ne{top:-4px;right:-4px;cursor:nesw-resize}.resize-nw{top:-4px;left:-4px;cursor:nwse-resize}.resize-se{bottom:-4px;right:-4px;cursor:nwse-resize}.resize-sw{bottom:-4px;left:-4px;cursor:nesw-resize}.toolbar{position:fixed;top:12px;left:12px;display:flex;gap:6px;padding:6px;background:#00000080;border-radius:8px;z-index:1000}.toolbar button{background:var(--card-bg);color:var(--text);border:1px solid var(--card-border);border-radius:5px;padding:6px 10px;font-size:12px;cursor:pointer;font-family:inherit}.toolbar button:hover{border-color:var(--accent)}:root{--bg: #1a1a1f;--bg-grid: #25252c;--card-bg: #2a2a32;--card-border: #3a3a45;--text: #e8e8ec;--accent: #6a8cff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;color-scheme:dark}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{width:100%;height:100%;overflow:hidden;background:var(--bg);color:var(--text);-webkit-user-select:none;user-select:none} diff --git a/dist/assets/index-D6iqmLrm.js b/dist/assets/index-D6iqmLrm.js new file mode 100644 index 0000000..7574333 --- /dev/null +++ b/dist/assets/index-D6iqmLrm.js @@ -0,0 +1,110 @@ +var ix=Object.defineProperty;var rx=(t,e,i)=>e in t?ix(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var QO=(t,e,i)=>rx(t,typeof e!="symbol"?e+"":e,i);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function i(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(s){if(s.ep)return;s.ep=!0;const n=i(s);fetch(s.href,n)}})();function sx(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Zv={exports:{}},gc={},Xv={exports:{}},ie={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Al=Symbol.for("react.element"),nx=Symbol.for("react.portal"),ox=Symbol.for("react.fragment"),lx=Symbol.for("react.strict_mode"),ax=Symbol.for("react.profiler"),hx=Symbol.for("react.provider"),cx=Symbol.for("react.context"),ux=Symbol.for("react.forward_ref"),fx=Symbol.for("react.suspense"),dx=Symbol.for("react.memo"),px=Symbol.for("react.lazy"),TO=Symbol.iterator;function gx(t){return t===null||typeof t!="object"?null:(t=TO&&t[TO]||t["@@iterator"],typeof t=="function"?t:null)}var Iv={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Wv=Object.assign,Nv={};function Vn(t,e,i){this.props=t,this.context=e,this.refs=Nv,this.updater=i||Iv}Vn.prototype.isReactComponent={};Vn.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Vn.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function jv(){}jv.prototype=Vn.prototype;function Ip(t,e,i){this.props=t,this.context=e,this.refs=Nv,this.updater=i||Iv}var Wp=Ip.prototype=new jv;Wp.constructor=Ip;Wv(Wp,Vn.prototype);Wp.isPureReactComponent=!0;var EO=Array.isArray,Vv=Object.prototype.hasOwnProperty,Np={current:null},Yv={key:!0,ref:!0,__self:!0,__source:!0};function qv(t,e,i){var r,s={},n=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(n=""+e.key),e)Vv.call(e,r)&&!Yv.hasOwnProperty(r)&&(s[r]=e[r]);var l=arguments.length-2;if(l===1)s.children=i;else if(1>>1,J=b[K];if(0>>1;Ks(Be,V))yes(kt,Be)?(b[K]=kt,b[ye]=V,K=ye):(b[K]=Be,b[ae]=V,K=ae);else if(yes(kt,V))b[K]=kt,b[ye]=V,K=ye;else break e}}return B}function s(b,B){var V=b.sortIndex-B.sortIndex;return V!==0?V:b.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var n=performance;t.unstable_now=function(){return n.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],h=[],c=1,u=null,f=3,d=!1,p=!1,g=!1,v=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(b){for(var B=i(h);B!==null;){if(B.callback===null)r(h);else if(B.startTime<=b)r(h),B.sortIndex=B.expirationTime,e(a,B);else break;B=i(h)}}function S(b){if(g=!1,_(b),!p)if(i(a)!==null)p=!0,z(w);else{var B=i(h);B!==null&&q(S,B.startTime-b)}}function w(b,B){p=!1,g&&(g=!1,O(T),T=-1),d=!0;var V=f;try{for(_(B),u=i(a);u!==null&&(!(u.expirationTime>B)||b&&!X());){var K=u.callback;if(typeof K=="function"){u.callback=null,f=u.priorityLevel;var J=K(u.expirationTime<=B);B=t.unstable_now(),typeof J=="function"?u.callback=J:u===i(a)&&r(a),_(B)}else r(a);u=i(a)}if(u!==null)var pe=!0;else{var ae=i(h);ae!==null&&q(S,ae.startTime-B),pe=!1}return pe}finally{u=null,f=V,d=!1}}var k=!1,x=null,T=-1,N=5,j=-1;function X(){return!(t.unstable_now()-jb||125K?(b.sortIndex=V,e(h,b),i(a)===null&&b===i(h)&&(g?(O(T),T=-1):g=!0,q(S,V-K))):(b.sortIndex=J,e(a,b),p||d||(p=!0,z(w))),b},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(b){var B=f;return function(){var V=f;f=B;try{return b.apply(this,arguments)}finally{f=V}}}})(Kv);Gv.exports=Kv;var Px=Gv.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var $x=ue,ei=Px;function E(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_f=Object.prototype.hasOwnProperty,Qx=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,AO={},MO={};function Tx(t){return _f.call(MO,t)?!0:_f.call(AO,t)?!1:Qx.test(t)?MO[t]=!0:(AO[t]=!0,!1)}function Ex(t,e,i,r){if(i!==null&&i.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Rx(t,e,i,r){if(e===null||typeof e>"u"||Ex(t,e,i,r))return!0;if(r)return!1;if(i!==null)switch(i.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Et(t,e,i,r,s,n,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=i,this.propertyName=t,this.type=e,this.sanitizeURL=n,this.removeEmptyString=o}var dt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){dt[t]=new Et(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];dt[e]=new Et(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){dt[t]=new Et(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){dt[t]=new Et(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){dt[t]=new Et(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){dt[t]=new Et(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){dt[t]=new Et(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){dt[t]=new Et(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){dt[t]=new Et(t,5,!1,t.toLowerCase(),null,!1,!1)});var Vp=/[\-:]([a-z])/g;function Yp(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Vp,Yp);dt[e]=new Et(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Vp,Yp);dt[e]=new Et(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Vp,Yp);dt[e]=new Et(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){dt[t]=new Et(t,1,!1,t.toLowerCase(),null,!1,!1)});dt.xlinkHref=new Et("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){dt[t]=new Et(t,1,!1,t.toLowerCase(),null,!0,!0)});function qp(t,e,i,r){var s=dt.hasOwnProperty(e)?dt[e]:null;(s!==null?s.type!==0:r||!(2l||s[o]!==n[l]){var a=` +`+s[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{eu=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?ko(t):""}function Ax(t){switch(t.tag){case 5:return ko(t.type);case 16:return ko("Lazy");case 13:return ko("Suspense");case 19:return ko("SuspenseList");case 0:case 2:case 15:return t=tu(t.type,!1),t;case 11:return t=tu(t.type.render,!1),t;case 1:return t=tu(t.type,!0),t;default:return""}}function wf(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Hs:return"Fragment";case Fs:return"Portal";case vf:return"Profiler";case Fp:return"StrictMode";case Sf:return"Suspense";case yf:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case tS:return(t.displayName||"Context")+".Consumer";case eS:return(t._context.displayName||"Context")+".Provider";case Hp:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Up:return e=t.displayName||null,e!==null?e:wf(t.type)||"Memo";case Mr:e=t._payload,t=t._init;try{return wf(t(e))}catch{}}return null}function Mx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return wf(e);case 8:return e===Fp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ts(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function rS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Lx(t){var e=rS(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var s=i.get,n=i.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,n.call(this,o)}}),Object.defineProperty(t,e,{enumerable:i.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ta(t){t._valueTracker||(t._valueTracker=Lx(t))}function sS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var i=e.getValue(),r="";return t&&(r=rS(t)?t.checked?"true":"false":t.value),t=r,t!==i?(e.setValue(t),!0):!1}function dh(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function kf(t,e){var i=e.checked;return Re({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function DO(t,e){var i=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;i=ts(e.value!=null?e.value:i),t._wrapperState={initialChecked:r,initialValue:i,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function nS(t,e){e=e.checked,e!=null&&qp(t,"checked",e,!1)}function bf(t,e){nS(t,e);var i=ts(e.value),r=e.type;if(i!=null)r==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?xf(t,e.type,i):e.hasOwnProperty("defaultValue")&&xf(t,e.type,ts(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function BO(t,e,i){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,i||e===t.value||(t.value=e),t.defaultValue=e}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function xf(t,e,i){(e!=="number"||dh(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var bo=Array.isArray;function fn(t,e,i,r){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=ia.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Jo(t,e){if(e){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=e;return}}t.textContent=e}var Lo={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Dx=["Webkit","ms","Moz","O"];Object.keys(Lo).forEach(function(t){Dx.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Lo[e]=Lo[t]})});function hS(t,e,i){return e==null||typeof e=="boolean"||e===""?"":i||typeof e!="number"||e===0||Lo.hasOwnProperty(t)&&Lo[t]?(""+e).trim():e+"px"}function cS(t,e){t=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=i.indexOf("--")===0,s=hS(i,e[i],r);i==="float"&&(i="cssFloat"),r?t.setProperty(i,s):t[i]=s}}var Bx=Re({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $f(t,e){if(e){if(Bx[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(E(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(E(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(E(61))}if(e.style!=null&&typeof e.style!="object")throw Error(E(62))}}function Qf(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Tf=null;function Gp(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ef=null,dn=null,pn=null;function XO(t){if(t=Dl(t)){if(typeof Ef!="function")throw Error(E(280));var e=t.stateNode;e&&(e=Sc(e),Ef(t.stateNode,t.type,e))}}function uS(t){dn?pn?pn.push(t):pn=[t]:dn=t}function fS(){if(dn){var t=dn,e=pn;if(pn=dn=null,XO(t),e)for(t=0;t>>=0,t===0?32:31-(Fx(t)/Hx|0)|0}var ra=64,sa=4194304;function xo(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function mh(t,e){var i=t.pendingLanes;if(i===0)return 0;var r=0,s=t.suspendedLanes,n=t.pingedLanes,o=i&268435455;if(o!==0){var l=o&~s;l!==0?r=xo(l):(n&=o,n!==0&&(r=xo(n)))}else o=i&~s,o!==0?r=xo(o):n!==0&&(r=xo(n));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,n=e&-e,s>=n||s===16&&(n&4194240)!==0))return e;if(r&4&&(r|=i&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0i;i++)e.push(t);return e}function Ml(t,e,i){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-$i(e),t[e]=i}function Jx(t,e){var i=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Bo),HO=" ",UO=!1;function RS(t,e){switch(t){case"keyup":return PC.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function AS(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Us=!1;function QC(t,e){switch(t){case"compositionend":return AS(e);case"keypress":return e.which!==32?null:(UO=!0,HO);case"textInput":return t=e.data,t===HO&&UO?null:t;default:return null}}function TC(t,e){if(Us)return t==="compositionend"||!ng&&RS(t,e)?(t=TS(),Na=ig=Wr=null,Us=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:i,offset:e-t};t=r}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=em(i)}}function BS(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?BS(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function zS(){for(var t=window,e=dh();e instanceof t.HTMLIFrameElement;){try{var i=typeof e.contentWindow.location.href=="string"}catch{i=!1}if(i)t=e.contentWindow;else break;e=dh(t.document)}return e}function og(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function ZC(t){var e=zS(),i=t.focusedElem,r=t.selectionRange;if(e!==i&&i&&i.ownerDocument&&BS(i.ownerDocument.documentElement,i)){if(r!==null&&og(i)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in i)i.selectionStart=e,i.selectionEnd=Math.min(t,i.value.length);else if(t=(e=i.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=i.textContent.length,n=Math.min(r.start,s);r=r.end===void 0?n:Math.min(r.end,s),!t.extend&&n>r&&(s=r,r=n,n=s),s=tm(i,n);var o=tm(i,r);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),n>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=i;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Gs=null,Bf=null,Zo=null,zf=!1;function im(t,e,i){var r=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;zf||Gs==null||Gs!==dh(r)||(r=Gs,"selectionStart"in r&&og(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Zo&&nl(Zo,r)||(Zo=r,r=Sh(Bf,"onSelect"),0en||(t.current=jf[en],jf[en]=null,en--)}function ve(t,e){en++,jf[en]=t.current,t.current=e}var is={},yt=as(is),Xt=as(!1),Qs=is;function xn(t,e){var i=t.type.contextTypes;if(!i)return is;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},n;for(n in i)s[n]=e[n];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function It(t){return t=t.childContextTypes,t!=null}function wh(){be(Xt),be(yt)}function hm(t,e,i){if(yt.current!==is)throw Error(E(168));ve(yt,e),ve(Xt,i)}function qS(t,e,i){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return i;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(E(108,Mx(t)||"Unknown",s));return Re({},i,r)}function kh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||is,Qs=yt.current,ve(yt,t),ve(Xt,Xt.current),!0}function cm(t,e,i){var r=t.stateNode;if(!r)throw Error(E(169));i?(t=qS(t,e,Qs),r.__reactInternalMemoizedMergedChildContext=t,be(Xt),be(yt),ve(yt,t)):be(Xt),ve(Xt,i)}var or=null,yc=!1,gu=!1;function FS(t){or===null?or=[t]:or.push(t)}function GC(t){yc=!0,FS(t)}function hs(){if(!gu&&or!==null){gu=!0;var t=0,e=de;try{var i=or;for(de=1;t>=o,s-=o,hr=1<<32-$i(e)+s|i<T?(N=x,x=null):N=x.sibling;var j=f(O,x,_[T],S);if(j===null){x===null&&(x=N);break}t&&x&&j.alternate===null&&e(O,x),m=n(j,m,T),k===null?w=j:k.sibling=j,k=j,x=N}if(T===_.length)return i(O,x),xe&&ds(O,T),w;if(x===null){for(;T<_.length;T++)x=u(O,_[T],S),x!==null&&(m=n(x,m,T),k===null?w=x:k.sibling=x,k=x);return xe&&ds(O,T),w}for(x=r(O,x);T<_.length;T++)N=d(x,O,T,_[T],S),N!==null&&(t&&N.alternate!==null&&x.delete(N.key===null?T:N.key),m=n(N,m,T),k===null?w=N:k.sibling=N,k=N);return t&&x.forEach(function(X){return e(O,X)}),xe&&ds(O,T),w}function g(O,m,_,S){var w=eo(_);if(typeof w!="function")throw Error(E(150));if(_=w.call(_),_==null)throw Error(E(151));for(var k=w=null,x=m,T=m=0,N=null,j=_.next();x!==null&&!j.done;T++,j=_.next()){x.index>T?(N=x,x=null):N=x.sibling;var X=f(O,x,j.value,S);if(X===null){x===null&&(x=N);break}t&&x&&X.alternate===null&&e(O,x),m=n(X,m,T),k===null?w=X:k.sibling=X,k=X,x=N}if(j.done)return i(O,x),xe&&ds(O,T),w;if(x===null){for(;!j.done;T++,j=_.next())j=u(O,j.value,S),j!==null&&(m=n(j,m,T),k===null?w=j:k.sibling=j,k=j);return xe&&ds(O,T),w}for(x=r(O,x);!j.done;T++,j=_.next())j=d(x,O,T,j.value,S),j!==null&&(t&&j.alternate!==null&&x.delete(j.key===null?T:j.key),m=n(j,m,T),k===null?w=j:k.sibling=j,k=j);return t&&x.forEach(function($){return e(O,$)}),xe&&ds(O,T),w}function v(O,m,_,S){if(typeof _=="object"&&_!==null&&_.type===Hs&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case ea:e:{for(var w=_.key,k=m;k!==null;){if(k.key===w){if(w=_.type,w===Hs){if(k.tag===7){i(O,k.sibling),m=s(k,_.props.children),m.return=O,O=m;break e}}else if(k.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===Mr&&dm(w)===k.type){i(O,k.sibling),m=s(k,_.props),m.ref=no(O,k,_),m.return=O,O=m;break e}i(O,k);break}else e(O,k);k=k.sibling}_.type===Hs?(m=Ps(_.props.children,O.mode,S,_.key),m.return=O,O=m):(S=Ga(_.type,_.key,_.props,null,O.mode,S),S.ref=no(O,m,_),S.return=O,O=S)}return o(O);case Fs:e:{for(k=_.key;m!==null;){if(m.key===k)if(m.tag===4&&m.stateNode.containerInfo===_.containerInfo&&m.stateNode.implementation===_.implementation){i(O,m.sibling),m=s(m,_.children||[]),m.return=O,O=m;break e}else{i(O,m);break}else e(O,m);m=m.sibling}m=ku(_,O.mode,S),m.return=O,O=m}return o(O);case Mr:return k=_._init,v(O,m,k(_._payload),S)}if(bo(_))return p(O,m,_,S);if(eo(_))return g(O,m,_,S);ua(O,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,m!==null&&m.tag===6?(i(O,m.sibling),m=s(m,_),m.return=O,O=m):(i(O,m),m=wu(_,O.mode,S),m.return=O,O=m),o(O)):i(O,m)}return v}var Pn=KS(!0),JS=KS(!1),Ch=as(null),Ph=null,sn=null,cg=null;function ug(){cg=sn=Ph=null}function fg(t){var e=Ch.current;be(Ch),t._currentValue=e}function qf(t,e,i){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===i)break;t=t.return}}function On(t,e){Ph=t,cg=sn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(zt=!0),t.firstContext=null)}function Oi(t){var e=t._currentValue;if(cg!==t)if(t={context:t,memoizedValue:e,next:null},sn===null){if(Ph===null)throw Error(E(308));sn=t,Ph.dependencies={lanes:0,firstContext:t}}else sn=sn.next=t;return e}var ys=null;function dg(t){ys===null?ys=[t]:ys.push(t)}function e1(t,e,i,r){var s=e.interleaved;return s===null?(i.next=i,dg(e)):(i.next=s.next,s.next=i),e.interleaved=i,_r(t,r)}function _r(t,e){t.lanes|=e;var i=t.alternate;for(i!==null&&(i.lanes|=e),i=t,t=t.return;t!==null;)t.childLanes|=e,i=t.alternate,i!==null&&(i.childLanes|=e),i=t,t=t.return;return i.tag===3?i.stateNode:null}var Lr=!1;function pg(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function t1(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function dr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Ur(t,e,i){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,se&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,_r(t,i)}return s=r.interleaved,s===null?(e.next=e,dg(r)):(e.next=s.next,s.next=e),r.interleaved=e,_r(t,i)}function Va(t,e,i){if(e=e.updateQueue,e!==null&&(e=e.shared,(i&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,i|=r,e.lanes=i,Jp(t,i)}}function pm(t,e){var i=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,i===r)){var s=null,n=null;if(i=i.firstBaseUpdate,i!==null){do{var o={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};n===null?s=n=o:n=n.next=o,i=i.next}while(i!==null);n===null?s=n=e:n=n.next=e}else s=n=e;i={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:n,shared:r.shared,effects:r.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=e:t.next=e,i.lastBaseUpdate=e}function $h(t,e,i,r){var s=t.updateQueue;Lr=!1;var n=s.firstBaseUpdate,o=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var a=l,h=a.next;a.next=null,o===null?n=h:o.next=h,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=h:l.next=h,c.lastBaseUpdate=a))}if(n!==null){var u=s.baseState;o=0,c=h=a=null,l=n;do{var f=l.lane,d=l.eventTime;if((r&f)===f){c!==null&&(c=c.next={eventTime:d,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,g=l;switch(f=e,d=i,g.tag){case 1:if(p=g.payload,typeof p=="function"){u=p.call(d,u,f);break e}u=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,f=typeof p=="function"?p.call(d,u,f):p,f==null)break e;u=Re({},u,f);break e;case 2:Lr=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else d={eventTime:d,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(h=c=d,a=u):c=c.next=d,o|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(c===null&&(a=u),s.baseState=a,s.firstBaseUpdate=h,s.lastBaseUpdate=c,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else n===null&&(s.shared.lanes=0);Rs|=o,t.lanes=o,t.memoizedState=u}}function gm(t,e,i){if(t=e.effects,e.effects=null,t!==null)for(e=0;ei?i:4,t(!0);var r=mu.transition;mu.transition={};try{t(!1),e()}finally{de=i,mu.transition=r}}function _1(){return mi().memoizedState}function tP(t,e,i){var r=Kr(t);if(i={lane:r,action:i,hasEagerState:!1,eagerState:null,next:null},v1(t))S1(e,i);else if(i=e1(t,e,i,r),i!==null){var s=$t();Qi(i,t,r,s),y1(i,e,r)}}function iP(t,e,i){var r=Kr(t),s={lane:r,action:i,hasEagerState:!1,eagerState:null,next:null};if(v1(t))S1(e,s);else{var n=t.alternate;if(t.lanes===0&&(n===null||n.lanes===0)&&(n=e.lastRenderedReducer,n!==null))try{var o=e.lastRenderedState,l=n(o,i);if(s.hasEagerState=!0,s.eagerState=l,Ti(l,o)){var a=e.interleaved;a===null?(s.next=s,dg(e)):(s.next=a.next,a.next=s),e.interleaved=s;return}}catch{}finally{}i=e1(t,e,s,r),i!==null&&(s=$t(),Qi(i,t,r,s),y1(i,e,r))}}function v1(t){var e=t.alternate;return t===Ee||e!==null&&e===Ee}function S1(t,e){Xo=Th=!0;var i=t.pending;i===null?e.next=e:(e.next=i.next,i.next=e),t.pending=e}function y1(t,e,i){if(i&4194240){var r=e.lanes;r&=t.pendingLanes,i|=r,e.lanes=i,Jp(t,i)}}var Eh={readContext:Oi,useCallback:pt,useContext:pt,useEffect:pt,useImperativeHandle:pt,useInsertionEffect:pt,useLayoutEffect:pt,useMemo:pt,useReducer:pt,useRef:pt,useState:pt,useDebugValue:pt,useDeferredValue:pt,useTransition:pt,useMutableSource:pt,useSyncExternalStore:pt,useId:pt,unstable_isNewReconciler:!1},rP={readContext:Oi,useCallback:function(t,e){return Wi().memoizedState=[t,e===void 0?null:e],t},useContext:Oi,useEffect:mm,useImperativeHandle:function(t,e,i){return i=i!=null?i.concat([t]):null,qa(4194308,4,d1.bind(null,e,t),i)},useLayoutEffect:function(t,e){return qa(4194308,4,t,e)},useInsertionEffect:function(t,e){return qa(4,2,t,e)},useMemo:function(t,e){var i=Wi();return e=e===void 0?null:e,t=t(),i.memoizedState=[t,e],t},useReducer:function(t,e,i){var r=Wi();return e=i!==void 0?i(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=tP.bind(null,Ee,t),[r.memoizedState,t]},useRef:function(t){var e=Wi();return t={current:t},e.memoizedState=t},useState:Om,useDebugValue:wg,useDeferredValue:function(t){return Wi().memoizedState=t},useTransition:function(){var t=Om(!1),e=t[0];return t=eP.bind(null,t[1]),Wi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,i){var r=Ee,s=Wi();if(xe){if(i===void 0)throw Error(E(407));i=i()}else{if(i=e(),nt===null)throw Error(E(349));Es&30||n1(r,e,i)}s.memoizedState=i;var n={value:i,getSnapshot:e};return s.queue=n,mm(l1.bind(null,r,n,t),[t]),r.flags|=2048,dl(9,o1.bind(null,r,n,i,e),void 0,null),i},useId:function(){var t=Wi(),e=nt.identifierPrefix;if(xe){var i=cr,r=hr;i=(r&~(1<<32-$i(r)-1)).toString(32)+i,e=":"+e+"R"+i,i=ul++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(i,{is:r.is}):(t=o.createElement(i),i==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,i),t[Ni]=e,t[al]=r,E1(t,e,!1,!1),e.stateNode=t;e:{switch(o=Qf(i,r),i){case"dialog":we("cancel",t),we("close",t),s=r;break;case"iframe":case"object":case"embed":we("load",t),s=r;break;case"video":case"audio":for(s=0;sTn&&(e.flags|=128,r=!0,oo(n,!1),e.lanes=4194304)}else{if(!r)if(t=Qh(o),t!==null){if(e.flags|=128,r=!0,i=t.updateQueue,i!==null&&(e.updateQueue=i,e.flags|=4),oo(n,!0),n.tail===null&&n.tailMode==="hidden"&&!o.alternate&&!xe)return gt(e),null}else 2*Xe()-n.renderingStartTime>Tn&&i!==1073741824&&(e.flags|=128,r=!0,oo(n,!1),e.lanes=4194304);n.isBackwards?(o.sibling=e.child,e.child=o):(i=n.last,i!==null?i.sibling=o:e.child=o,n.last=o)}return n.tail!==null?(e=n.tail,n.rendering=e,n.tail=e.sibling,n.renderingStartTime=Xe(),e.sibling=null,i=Te.current,ve(Te,r?i&1|2:i&1),e):(gt(e),null);case 22:case 23:return $g(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ft&1073741824&&(gt(e),e.subtreeFlags&6&&(e.flags|=8192)):gt(e),null;case 24:return null;case 25:return null}throw Error(E(156,e.tag))}function uP(t,e){switch(ag(e),e.tag){case 1:return It(e.type)&&wh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return $n(),be(Xt),be(yt),mg(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Og(e),null;case 13:if(be(Te),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(E(340));Cn()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return be(Te),null;case 4:return $n(),null;case 10:return fg(e.type._context),null;case 22:case 23:return $g(),null;case 24:return null;default:return null}}var da=!1,_t=!1,fP=typeof WeakSet=="function"?WeakSet:Set,I=null;function nn(t,e){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(r){Me(t,e,r)}else i.current=null}function id(t,e,i){try{i()}catch(r){Me(t,e,r)}}var $m=!1;function dP(t,e){if(Zf=_h,t=zS(),og(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var r=i.getSelection&&i.getSelection();if(r&&r.rangeCount!==0){i=r.anchorNode;var s=r.anchorOffset,n=r.focusNode;r=r.focusOffset;try{i.nodeType,n.nodeType}catch{i=null;break e}var o=0,l=-1,a=-1,h=0,c=0,u=t,f=null;t:for(;;){for(var d;u!==i||s!==0&&u.nodeType!==3||(l=o+s),u!==n||r!==0&&u.nodeType!==3||(a=o+r),u.nodeType===3&&(o+=u.nodeValue.length),(d=u.firstChild)!==null;)f=u,u=d;for(;;){if(u===t)break t;if(f===i&&++h===s&&(l=o),f===n&&++c===r&&(a=o),(d=u.nextSibling)!==null)break;u=f,f=u.parentNode}u=d}i=l===-1||a===-1?null:{start:l,end:a}}else i=null}i=i||{start:0,end:0}}else i=null;for(Xf={focusedElem:t,selectionRange:i},_h=!1,I=e;I!==null;)if(e=I,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,I=t;else for(;I!==null;){e=I;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,v=p.memoizedState,O=e.stateNode,m=O.getSnapshotBeforeUpdate(e.elementType===e.type?g:wi(e.type,g),v);O.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var _=e.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(S){Me(e,e.return,S)}if(t=e.sibling,t!==null){t.return=e.return,I=t;break}I=e.return}return p=$m,$m=!1,p}function Io(t,e,i){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var n=s.destroy;s.destroy=void 0,n!==void 0&&id(e,i,n)}s=s.next}while(s!==r)}}function bc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var i=e=e.next;do{if((i.tag&t)===t){var r=i.create;i.destroy=r()}i=i.next}while(i!==e)}}function rd(t){var e=t.ref;if(e!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof e=="function"?e(t):e.current=t}}function M1(t){var e=t.alternate;e!==null&&(t.alternate=null,M1(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Ni],delete e[al],delete e[Nf],delete e[HC],delete e[UC])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function L1(t){return t.tag===5||t.tag===3||t.tag===4}function Qm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||L1(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function sd(t,e,i){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?i.nodeType===8?i.parentNode.insertBefore(t,e):i.insertBefore(t,e):(i.nodeType===8?(e=i.parentNode,e.insertBefore(t,i)):(e=i,e.appendChild(t)),i=i._reactRootContainer,i!=null||e.onclick!==null||(e.onclick=yh));else if(r!==4&&(t=t.child,t!==null))for(sd(t,e,i),t=t.sibling;t!==null;)sd(t,e,i),t=t.sibling}function nd(t,e,i){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?i.insertBefore(t,e):i.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(nd(t,e,i),t=t.sibling;t!==null;)nd(t,e,i),t=t.sibling}var lt=null,ki=!1;function Qr(t,e,i){for(i=i.child;i!==null;)D1(t,e,i),i=i.sibling}function D1(t,e,i){if(Gi&&typeof Gi.onCommitFiberUnmount=="function")try{Gi.onCommitFiberUnmount(Oc,i)}catch{}switch(i.tag){case 5:_t||nn(i,e);case 6:var r=lt,s=ki;lt=null,Qr(t,e,i),lt=r,ki=s,lt!==null&&(ki?(t=lt,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):lt.removeChild(i.stateNode));break;case 18:lt!==null&&(ki?(t=lt,i=i.stateNode,t.nodeType===8?pu(t.parentNode,i):t.nodeType===1&&pu(t,i),rl(t)):pu(lt,i.stateNode));break;case 4:r=lt,s=ki,lt=i.stateNode.containerInfo,ki=!0,Qr(t,e,i),lt=r,ki=s;break;case 0:case 11:case 14:case 15:if(!_t&&(r=i.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var n=s,o=n.destroy;n=n.tag,o!==void 0&&(n&2||n&4)&&id(i,e,o),s=s.next}while(s!==r)}Qr(t,e,i);break;case 1:if(!_t&&(nn(i,e),r=i.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=i.memoizedProps,r.state=i.memoizedState,r.componentWillUnmount()}catch(l){Me(i,e,l)}Qr(t,e,i);break;case 21:Qr(t,e,i);break;case 22:i.mode&1?(_t=(r=_t)||i.memoizedState!==null,Qr(t,e,i),_t=r):Qr(t,e,i);break;default:Qr(t,e,i)}}function Tm(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new fP),e.forEach(function(r){var s=wP.bind(null,t,r);i.has(r)||(i.add(r),r.then(s,s))})}}function Si(t,e){var i=e.deletions;if(i!==null)for(var r=0;rs&&(s=o),r&=~n}if(r=s,r=Xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*gP(r/1960))-r,10t?16:t,Nr===null)var r=!1;else{if(t=Nr,Nr=null,Mh=0,se&6)throw Error(E(331));var s=se;for(se|=4,I=t.current;I!==null;){var n=I,o=n.child;if(I.flags&16){var l=n.deletions;if(l!==null){for(var a=0;aXe()-Cg?Cs(t,0):xg|=i),Wt(t,e)}function j1(t,e){e===0&&(t.mode&1?(e=sa,sa<<=1,!(sa&130023424)&&(sa=4194304)):e=1);var i=$t();t=_r(t,e),t!==null&&(Ml(t,e,i),Wt(t,i))}function yP(t){var e=t.memoizedState,i=0;e!==null&&(i=e.retryLane),j1(t,i)}function wP(t,e){var i=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(i=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(e),j1(t,i)}var V1;V1=function(t,e,i){if(t!==null)if(t.memoizedProps!==e.pendingProps||Xt.current)zt=!0;else{if(!(t.lanes&i)&&!(e.flags&128))return zt=!1,hP(t,e,i);zt=!!(t.flags&131072)}else zt=!1,xe&&e.flags&1048576&&HS(e,xh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Fa(t,e),t=e.pendingProps;var s=xn(e,yt.current);On(e,i),s=vg(null,e,r,t,s,i);var n=Sg();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,It(r)?(n=!0,kh(e)):n=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,pg(e),s.updater=kc,e.stateNode=s,s._reactInternals=e,Hf(e,r,t,i),e=Kf(null,e,r,!0,n,i)):(e.tag=0,xe&&n&&lg(e),xt(null,e,s,i),e=e.child),e;case 16:r=e.elementType;e:{switch(Fa(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=bP(r),t=wi(r,t),s){case 0:e=Gf(null,e,r,t,i);break e;case 1:e=xm(null,e,r,t,i);break e;case 11:e=km(null,e,r,t,i);break e;case 14:e=bm(null,e,r,wi(r.type,t),i);break e}throw Error(E(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:wi(r,s),Gf(t,e,r,s,i);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:wi(r,s),xm(t,e,r,s,i);case 3:e:{if($1(e),t===null)throw Error(E(387));r=e.pendingProps,n=e.memoizedState,s=n.element,t1(t,e),$h(e,r,null,i);var o=e.memoizedState;if(r=o.element,n.isDehydrated)if(n={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=n,e.memoizedState=n,e.flags&256){s=Qn(Error(E(423)),e),e=Cm(t,e,r,i,s);break e}else if(r!==s){s=Qn(Error(E(424)),e),e=Cm(t,e,r,i,s);break e}else for(Kt=Hr(e.stateNode.containerInfo.firstChild),Jt=e,xe=!0,bi=null,i=JS(e,null,r,i),e.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Cn(),r===s){e=vr(t,e,i);break e}xt(t,e,r,i)}e=e.child}return e;case 5:return i1(e),t===null&&Yf(e),r=e.type,s=e.pendingProps,n=t!==null?t.memoizedProps:null,o=s.children,If(r,s)?o=null:n!==null&&If(r,n)&&(e.flags|=32),P1(t,e),xt(t,e,o,i),e.child;case 6:return t===null&&Yf(e),null;case 13:return Q1(t,e,i);case 4:return gg(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Pn(e,null,r,i):xt(t,e,r,i),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:wi(r,s),km(t,e,r,s,i);case 7:return xt(t,e,e.pendingProps,i),e.child;case 8:return xt(t,e,e.pendingProps.children,i),e.child;case 12:return xt(t,e,e.pendingProps.children,i),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,n=e.memoizedProps,o=s.value,ve(Ch,r._currentValue),r._currentValue=o,n!==null)if(Ti(n.value,o)){if(n.children===s.children&&!Xt.current){e=vr(t,e,i);break e}}else for(n=e.child,n!==null&&(n.return=e);n!==null;){var l=n.dependencies;if(l!==null){o=n.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(n.tag===1){a=dr(-1,i&-i),a.tag=2;var h=n.updateQueue;if(h!==null){h=h.shared;var c=h.pending;c===null?a.next=a:(a.next=c.next,c.next=a),h.pending=a}}n.lanes|=i,a=n.alternate,a!==null&&(a.lanes|=i),qf(n.return,i,e),l.lanes|=i;break}a=a.next}}else if(n.tag===10)o=n.type===e.type?null:n.child;else if(n.tag===18){if(o=n.return,o===null)throw Error(E(341));o.lanes|=i,l=o.alternate,l!==null&&(l.lanes|=i),qf(o,i,e),o=n.sibling}else o=n.child;if(o!==null)o.return=n;else for(o=n;o!==null;){if(o===e){o=null;break}if(n=o.sibling,n!==null){n.return=o.return,o=n;break}o=o.return}n=o}xt(t,e,s.children,i),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,On(e,i),s=Oi(s),r=r(s),e.flags|=1,xt(t,e,r,i),e.child;case 14:return r=e.type,s=wi(r,e.pendingProps),s=wi(r.type,s),bm(t,e,r,s,i);case 15:return x1(t,e,e.type,e.pendingProps,i);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:wi(r,s),Fa(t,e),e.tag=1,It(r)?(t=!0,kh(e)):t=!1,On(e,i),w1(e,r,s),Hf(e,r,s,i),Kf(null,e,r,!0,t,i);case 19:return T1(t,e,i);case 22:return C1(t,e,i)}throw Error(E(156,e.tag))};function Y1(t,e){return vS(t,e)}function kP(t,e,i,r){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hi(t,e,i,r){return new kP(t,e,i,r)}function Tg(t){return t=t.prototype,!(!t||!t.isReactComponent)}function bP(t){if(typeof t=="function")return Tg(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Hp)return 11;if(t===Up)return 14}return 2}function Jr(t,e){var i=t.alternate;return i===null?(i=hi(t.tag,e,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=e,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,e=t.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function Ga(t,e,i,r,s,n){var o=2;if(r=t,typeof t=="function")Tg(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Hs:return Ps(i.children,s,n,e);case Fp:o=8,s|=8;break;case vf:return t=hi(12,i,e,s|2),t.elementType=vf,t.lanes=n,t;case Sf:return t=hi(13,i,e,s),t.elementType=Sf,t.lanes=n,t;case yf:return t=hi(19,i,e,s),t.elementType=yf,t.lanes=n,t;case iS:return Cc(i,s,n,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case eS:o=10;break e;case tS:o=9;break e;case Hp:o=11;break e;case Up:o=14;break e;case Mr:o=16,r=null;break e}throw Error(E(130,t==null?t:typeof t,""))}return e=hi(o,i,e,s),e.elementType=t,e.type=r,e.lanes=n,e}function Ps(t,e,i,r){return t=hi(7,t,r,e),t.lanes=i,t}function Cc(t,e,i,r){return t=hi(22,t,r,e),t.elementType=iS,t.lanes=i,t.stateNode={isHidden:!1},t}function wu(t,e,i){return t=hi(6,t,null,e),t.lanes=i,t}function ku(t,e,i){return e=hi(4,t.children!==null?t.children:[],t.key,e),e.lanes=i,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function xP(t,e,i,r,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ru(0),this.expirationTimes=ru(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ru(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Eg(t,e,i,r,s,n,o,l,a){return t=new xP(t,e,i,l,a),e===1?(e=1,n===!0&&(e|=8)):e=0,n=hi(3,null,null,e),t.current=n,n.stateNode=t,n.memoizedState={element:r,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},pg(n),t}function CP(t,e,i){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U1)}catch(t){console.error(t)}}U1(),Uv.exports=ti;var EP=Uv.exports,zm=EP;mf.createRoot=zm.createRoot,mf.hydrateRoot=zm.hydrateRoot;const G1=ue.createContext({x:0,y:0,scale:1}),Ec=()=>ue.useContext(G1);function K1(t,e){const i=Ec(),r=ue.useRef(null),s=l=>{l.button===0&&(l.stopPropagation(),l.target.setPointerCapture(l.pointerId),r.current={startX:l.clientX,startY:l.clientY,cardX:t.x,cardY:t.y})},n=l=>{const a=r.current;if(!a)return;const h=(l.clientX-a.startX)/i.scale,c=(l.clientY-a.startY)/i.scale;e({x:a.cardX+h,y:a.cardY+c})},o=l=>{if(r.current){try{l.target.releasePointerCapture(l.pointerId)}catch{}r.current=null}};return{onPointerDown:s,onPointerMove:n,onPointerUp:o,onPointerCancel:o}}const bu=120,xu=80;function RP(t,e,i){const r=Ec(),s=ue.useRef(null),n=a=>{a.button===0&&(a.stopPropagation(),a.target.setPointerCapture(a.pointerId),s.current={startX:a.clientX,startY:a.clientY,cardX:t.x,cardY:t.y,cardW:t.width,cardH:t.height})},o=a=>{const h=s.current;if(!h)return;const c=(a.clientX-h.startX)/r.scale,u=(a.clientY-h.startY)/r.scale;let f=h.cardX,d=h.cardY,p=h.cardW,g=h.cardH;e.includes("e")&&(p=h.cardW+c),e.includes("w")&&(f=h.cardX+c,p=h.cardW-c),e.includes("s")&&(g=h.cardH+u),e.includes("n")&&(d=h.cardY+u,g=h.cardH-u),p{if(s.current){try{a.target.releasePointerCapture(a.pointerId)}catch{}s.current=null}};return{onPointerDown:n,onPointerMove:o,onPointerUp:l,onPointerCancel:l}}const AP=["n","s","e","w","ne","nw","se","sw"];function J1({card:t,onUpdate:e}){return Oe.jsx(Oe.Fragment,{children:AP.map(i=>Oe.jsx(MP,{dir:i,card:t,onUpdate:e},i))})}function MP({dir:t,card:e,onUpdate:i}){const r=RP(e,t,i);return Oe.jsx("div",{className:`resize-handle resize-${t}`,...r})}let cd=[],ey=[];(()=>{let t="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(e=>e?parseInt(e,36):1);for(let e=0,i=0;e>1;if(t=ey[r])e=r+1;else return!0;if(e==i)return!1}}function Zm(t){return t>=127462&&t<=127487}const Xm=8205;function DP(t,e,i=!0,r=!0){return(i?ty:BP)(t,e,r)}function ty(t,e,i){if(e==t.length)return e;e&&iy(t.charCodeAt(e))&&ry(t.charCodeAt(e-1))&&e--;let r=Cu(t,e);for(e+=Im(r);e=0&&Zm(Cu(t,o));)n++,o-=2;if(n%2==0)break;e+=2}else break}return e}function BP(t,e,i){for(;e>0;){let r=ty(t,e-2,i);if(r=56320&&t<57344}function ry(t){return t>=55296&&t<56320}function Im(t){return t<65536?1:2}let ne=class sy{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,i,r){[e,i]=En(this,e,i);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(i,this.length,s,1),ji.from(s,this.length-(i-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=En(this,e,i);let r=[];return this.decompose(e,i,r,0),ji.from(r,i-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let i=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new jo(this),n=new jo(e);for(let o=i,l=i;;){if(s.next(o),n.next(o),o=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(l+=s.value.length,s.done||l>=r)return!0}}iter(e=1){return new jo(this,e)}iterRange(e,i=this.length){return new ny(this,e,i)}iterLines(e,i){let r;if(e==null)r=this.iter();else{i==null&&(i=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new oy(r)}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]?sy.empty:e.length<=32?new Ze(e):ji.from(Ze.split(e,[]))}};class Ze extends ne{constructor(e,i=zP(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,r,s){for(let n=0;;n++){let o=this.text[n],l=s+o.length;if((i?r:l)>=e)return new ZP(s,l,r,o);s=l+1,r++}}decompose(e,i,r,s){let n=e<=0&&i>=this.length?this:new Ze(Wm(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(s&1){let o=r.pop(),l=Ka(n.text,o.text.slice(),0,n.length);if(l.length<=32)r.push(new Ze(l,o.length+n.length));else{let a=l.length>>1;r.push(new Ze(l.slice(0,a)),new Ze(l.slice(a)))}}else r.push(n)}replace(e,i,r){if(!(r instanceof Ze))return super.replace(e,i,r);[e,i]=En(this,e,i);let s=Ka(this.text,Ka(r.text,Wm(this.text,0,e)),i),n=this.length+r.length-(i-e);return s.length<=32?new Ze(s,n):ji.from(Ze.split(s,[]),n)}sliceString(e,i=this.length,r=` +`){[e,i]=En(this,e,i);let s="";for(let n=0,o=0;n<=i&&oe&&o&&(s+=r),en&&(s+=l.slice(Math.max(0,e-n),i-n)),n=a+1}return s}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let r=[],s=-1;for(let n of e)r.push(n),s+=n.length+1,r.length==32&&(i.push(new Ze(r,s)),r=[],s=-1);return s>-1&&i.push(new Ze(r,s)),i}}class ji extends ne{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,i,r,s){for(let n=0;;n++){let o=this.children[n],l=s+o.length,a=r+o.lines-1;if((i?a:l)>=e)return o.lineInner(e,i,r,s);s=l+1,r=a+1}}decompose(e,i,r,s){for(let n=0,o=0;o<=i&&n=o){let h=s&((o<=e?1:0)|(a>=i?2:0));o>=e&&a<=i&&!h?r.push(l):l.decompose(e-o,i-o,r,h)}o=a+1}}replace(e,i,r){if([e,i]=En(this,e,i),r.lines=n&&i<=l){let a=o.replace(e-n,i-n,r),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new ji(c,this.length-(i-e)+r.length)}return super.replace(n,l,a)}n=l+1}return super.replace(e,i,r)}sliceString(e,i=this.length,r=` +`){[e,i]=En(this,e,i);let s="";for(let n=0,o=0;ne&&n&&(s+=r),eo&&(s+=l.sliceString(e-o,i-o,r)),o=a+1}return s}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof ji))return 0;let r=0,[s,n,o,l]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=i,n+=i){if(s==o||n==l)return r;let a=this.children[s],h=e.children[n];if(a!=h)return r+a.scanIdentical(h,i);r+=a.length+1}}static from(e,i=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new Ze(d,i)}let s=Math.max(32,r>>5),n=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function u(d){let p;if(d.lines>n&&d instanceof ji)for(let g of d.children)u(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof Ze&&a&&(p=c[c.length-1])instanceof Ze&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new Ze(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&f(),a+=d.lines,h+=d.length+1,c.push(d))}function f(){a!=0&&(l.push(c.length==1?c[0]:ji.from(c,h)),h=-1,a=c.length=0)}for(let d of e)u(d);return f(),l.length==1?l[0]:new ji(l,i)}}ne.empty=new Ze([""],0);function zP(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Ka(t,e,i=0,r=1e9){for(let s=0,n=0,o=!0;n=i&&(a>r&&(l=l.slice(0,r-s)),s0?1:(e instanceof Ze?e.text.length:e.children.length)<<1]}nextInner(e,i){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],n=this.offsets[r],o=n>>1,l=s instanceof Ze?s.text.length:s.children.length;if(o==(i>0?l:0)){if(r==0)return this.done=!0,this.value="",this;i>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(i>0?0:1)){if(this.offsets[r]+=i,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Ze){let a=s.text[o+(i<0?-1:0)];if(this.offsets[r]+=i,a.length>Math.max(0,e))return this.value=e==0?a:i>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(i<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=i):(i<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(i>0?1:(a instanceof Ze?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class ny{constructor(e,i,r){this.value="",this.done=!1,this.cursor=new jo(e,i>r?-1:1),this.pos=i>r?e.length:0,this.from=Math.min(i,r),this.to=Math.max(i,r)}nextInner(e,i){if(i<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,i<0?this.pos-this.to:this.from-this.pos);let r=i<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*i,this.value=s.length<=r?s:i<0?s.slice(s.length-r):s.slice(0,r),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 oy{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:i,lineBreak:r,value:s}=this.inner.next(e);return i&&this.afterBreak?(this.value="",this.afterBreak=!1):i?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ne.prototype[Symbol.iterator]=function(){return this.iter()},jo.prototype[Symbol.iterator]=ny.prototype[Symbol.iterator]=oy.prototype[Symbol.iterator]=function(){return this});let ZP=class{constructor(e,i,r,s){this.from=e,this.to=i,this.number=r,this.text=s}get length(){return this.to-this.from}};function En(t,e,i){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,i))]}function vt(t,e,i=!0,r=!0){return DP(t,e,i,r)}function XP(t){return t>=56320&&t<57344}function IP(t){return t>=55296&&t<56320}function WP(t,e){let i=t.charCodeAt(e);if(!IP(i)||e+1==t.length)return i;let r=t.charCodeAt(e+1);return XP(r)?(i-55296<<10)+(r-56320)+65536:i}function NP(t){return t<65536?1:2}const ud=/\r\n?|\n/;var Pt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Pt||(Pt={}));class Ji{constructor(e){this.sections=e}get length(){let e=0;for(let i=0;ie)return n+(e-s);n+=l}else{if(r!=Pt.Simple&&h>=e&&(r==Pt.TrackDel&&se||r==Pt.TrackBefore&&se))return null;if(h>e||h==e&&i<0&&!l)return e==s||i<0?n:n+a;n+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return n}touchesRange(e,i=e){for(let r=0,s=0;r=0&&s<=i&&l>=e)return si?"cover":!0;s=l}return!1}toString(){let e="";for(let i=0;i=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(i=>typeof i!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ji(e)}static create(e){return new Ji(e)}}class Ue extends Ji{constructor(e,i){super(e),this.inserted=i}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return fd(this,(i,r,s,n,o)=>e=e.replace(s,s+(r-i),o),!1),e}mapDesc(e,i=!1){return dd(this,e,i,!0)}invert(e){let i=this.sections.slice(),r=[];for(let s=0,n=0;s=0){i[s]=l,i[s+1]=o;let a=s>>1;for(;r.length0&&jr(r,i,n.text),n.forward(c),l+=c}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,i,r){let s=[],n=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;of||u<0||f>i)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${i})`);let p=d?typeof d=="string"?ne.of(d.split(r||ud)):d:ne.empty,g=p.length;if(u==f&&g==0)return;uo&&mt(s,u-o,-1),mt(s,f-u,g),jr(n,s,p),o=f}}return h(e),a(!l),l}static empty(e){return new Ue(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],r=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(n.length==1)i.push(n[0],0);else{for(;r.length=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=i:r?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function jr(t,e,i){if(i.length==0)return;let r=e.length-2>>1;if(r>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(s,h,n,c,u),s=h,n=c}}}function dd(t,e,i,r=!1){let s=[],n=r?[]:null,o=new gl(t),l=new gl(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);mt(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let u=Math.min(c,l.len);h+=u,c-=u,l.forward(u)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>h),n.forward2(a),o.forward(a)}}}}class gl{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return i>=e.length?ne.empty:e[i]}textBit(e){let{inserted:i}=this.set,r=this.i-2>>1;return r>=i.length&&!e?ne.empty:i[r].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 ks{constructor(e,i,r){this.from=e,this.to=i,this.flags=r}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,i=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,i):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new ks(r,s,this.flags)}extend(e,i=e,r=0){if(e<=this.anchor&&i>=this.anchor)return Q.range(e,i,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return Q.range(this.anchor,s,void 0,void 0,r)}eq(e,i=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!i||!this.empty||this.assoc==e.assoc)}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 Q.range(e.anchor,e.head)}static create(e,i,r){return new ks(e,i,r)}}class Q{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:Q.create(this.ranges.map(r=>r.map(e,i)),this.mainIndex)}eq(e,i=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.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 Q(e.ranges.map(i=>ks.fromJSON(i)),e.main)}static single(e,i=e){return new Q([Q.range(e,i)],0)}static create(e,i=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-n.from),i=e.indexOf(r);for(let s=1;sn.head?Q.range(a,l):Q.range(l,a))}}return new Q(e,i)}}function ay(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let Lg=0;class H{constructor(e,i,r,s,n){this.combine=e,this.compareInput=i,this.compare=r,this.isStatic=s,this.id=Lg++,this.default=e([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(e={}){return new H(e.combine||(i=>i),e.compareInput||((i,r)=>i===r),e.compare||(e.combine?(i,r)=>i===r:Dg),!!e.static,e.enables)}of(e){return new Ja([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ja(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ja(e,this,2,i)}from(e,i){return i||(i=r=>r),this.compute([e],r=>i(r.field(e)))}}function Dg(t,e){return t==e||t.length==e.length&&t.every((i,r)=>i===e[r])}class Ja{constructor(e,i,r,s){this.dependencies=e,this.facet=i,this.type=r,this.value=s,this.id=Lg++}dynamicSlot(e){var i;let r=this.value,s=this.facet.compareInput,n=this.id,o=e[n]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?h=!0:((i=e[u.id])!==null&&i!==void 0?i:1)&1||c.push(e[u.id]);return{create(u){return u.values[o]=r(u),1},update(u,f){if(a&&f.docChanged||h&&(f.docChanged||f.selection)||pd(u,c)){let d=r(u);if(l?!Nm(d,u.values[o],s):!s(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[n];if(p!=null){let g=zh(f,p);if(this.dependencies.every(v=>v instanceof H?f.facet(v)===u.facet(v):v instanceof kr?f.field(v,!1)==u.field(v,!1):!0)||(l?Nm(d=r(u),g,s):s(d=r(u),g)))return u.values[o]=g,0}else d=r(u);return u.values[o]=d,1}}}}function Nm(t,e,i){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),s=i.map(a=>a.type),n=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let h=[];for(let c=0;cr===s),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(Oa).find(r=>r.field==this);return((i==null?void 0:i.create)||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:r=>(r.values[i]=this.create(r),1),update:(r,s)=>{let n=r.values[i],o=this.updateF(n,s);return this.compareF(n,o)?0:(r.values[i]=o,1)},reconfigure:(r,s)=>{let n=r.facet(Oa),o=s.facet(Oa),l;return(l=n.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[i]=l.create(r),1):s.config.address[this.id]!=null?(r.values[i]=s.field(this),0):(r.values[i]=this.create(r),1)}}}init(e){return[this,Oa.of({field:this,create:e})]}get extension(){return this}}const _s={lowest:4,low:3,default:2,high:1,highest:0};function ao(t){return e=>new hy(e,t)}const Rc={highest:ao(_s.highest),high:ao(_s.high),default:ao(_s.default),low:ao(_s.low),lowest:ao(_s.lowest)};class hy{constructor(e,i){this.inner=e,this.prec=i}}class Ac{of(e){return new gd(this,e)}reconfigure(e){return Ac.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class gd{constructor(e,i){this.compartment=e,this.inner=i}}class Bh{constructor(e,i,r,s,n,o){for(this.base=e,this.compartments=i,this.dynamicSlots=r,this.address=s,this.staticValues=n,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,i,r){let s=[],n=Object.create(null),o=new Map;for(let f of VP(e,i,o))f instanceof kr?s.push(f):(n[f.facet.id]||(n[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],h=[];for(let f of s)l[f.id]=h.length<<1,h.push(d=>f.slot(d));let c=r==null?void 0:r.config.facets;for(let f in n){let d=n[f],p=d[0].facet,g=c&&c[f]||[];if(d.every(v=>v.type==0))if(l[p.id]=a.length<<1|1,Dg(g,d))a.push(r.facet(p));else{let v=p.combine(d.map(O=>O.value));a.push(r&&p.compare(v,r.facet(p))?r.facet(p):v)}else{for(let v of d)v.type==0?(l[v.id]=a.length<<1|1,a.push(v.value)):(l[v.id]=h.length<<1,h.push(O=>v.dynamicSlot(O)));l[p.id]=h.length<<1,h.push(v=>jP(v,p,d))}}let u=h.map(f=>f(l));return new Bh(e,o,u,l,a,n)}}function VP(t,e,i){let r=[[],[],[],[],[]],s=new Map;function n(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=r[a].indexOf(o);h>-1&&r[a].splice(h,1),o instanceof gd&&i.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)n(h,l);else if(o instanceof gd){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;i.set(o.compartment,h),n(h,l)}else if(o instanceof hy)n(o.inner,o.prec);else if(o instanceof kr)r[l].push(o),o.provides&&n(o.provides,l);else if(o instanceof Ja)r[l].push(o),o.facet.extensions&&n(o.facet.extensions,_s.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(h,l)}}return n(t,_s.default),r.reduce((o,l)=>o.concat(l))}function Vo(t,e){if(e&1)return 2;let i=e>>1,r=t.status[i];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function zh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const cy=H.define(),Od=H.define({combine:t=>t.some(e=>e),static:!0}),uy=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),fy=H.define(),dy=H.define(),py=H.define(),gy=H.define({combine:t=>t.length?t[0]:!1});class br{constructor(e,i){this.type=e,this.value=i}static define(){return new YP}}class YP{of(e){return new br(this,e)}}class qP{constructor(e){this.map=e}of(e){return new Ce(this,e)}}class Ce{constructor(e,i){this.type=e,this.value=i}map(e){let i=this.type.map(this.value,e);return i===void 0?void 0:i==this.value?this:new Ce(this.type,i)}is(e){return this.type==e}static define(e={}){return new qP(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let r=[];for(let s of e){let n=s.map(i);n&&r.push(n)}return r}}Ce.reconfigure=Ce.define();Ce.appendConfig=Ce.define();class Ve{constructor(e,i,r,s,n,o){this.startState=e,this.changes=i,this.selection=r,this.effects=s,this.annotations=n,this.scrollIntoView=o,this._doc=null,this._state=null,r&&ay(r,i.newLength),n.some(l=>l.type==Ve.time)||(this.annotations=n.concat(Ve.time.of(Date.now())))}static create(e,i,r,s,n,o){return new Ve(e,i,r,s,n,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 i of this.annotations)if(i.type==e)return i.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let i=this.annotation(Ve.userEvent);return!!(i&&(i==e||i.length>e.length&&i.slice(0,e.length)==e&&i[e.length]=="."))}}Ve.time=br.define();Ve.userEvent=br.define();Ve.addToHistory=br.define();Ve.remote=br.define();function FP(t,e){let i=[];for(let r=0,s=0;;){let n,o;if(r=t[r]))n=t[r++],o=t[r++];else if(s=0;s--){let n=r[s](t);n instanceof Ve?t=n:Array.isArray(n)&&n.length==1&&n[0]instanceof Ve?t=n[0]:t=my(e,_n(n),!1)}return t}function UP(t){let e=t.startState,i=e.facet(py),r=t;for(let s=i.length-1;s>=0;s--){let n=i[s](t);n&&Object.keys(n).length&&(r=Oy(r,md(e,n,t.changes.newLength),!0))}return r==t?t:Ve.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const GP=[];function _n(t){return t==null?GP:Array.isArray(t)?t:[t]}var ur=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(ur||(ur={}));const KP=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _d;try{_d=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function JP(t){if(_d)return _d.test(t);for(let e=0;e"€"&&(i.toUpperCase()!=i.toLowerCase()||KP.test(i)))return!0}return!1}function e$(t){return e=>{if(!/\S/.test(e))return ur.Space;if(JP(e))return ur.Word;for(let i=0;i-1)return ur.Word;return ur.Other}}class oe{constructor(e,i,r,s,n,o){this.config=e,this.doc=i,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=n,o&&(o._state=this);for(let l=0;ls.set(h,a)),i=null),s.set(l.value.compartment,l.value.extension)):l.is(Ce.reconfigure)?(i=null,r=l.value):l.is(Ce.appendConfig)&&(i=null,r=_n(r).concat(l.value));let n;i?n=e.startState.values.slice():(i=Bh.resolve(r,s,this),n=new oe(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Od)?e.newSelection:e.newSelection.asSingle();new oe(i,e.newDoc,o,n,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:e},range:Q.cursor(i.from+e.length)}))}changeByRange(e){let i=this.selection,r=e(i.ranges[0]),s=this.changes(r.changes),n=[r.range],o=_n(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return oe.create({doc:e.doc,selection:Q.fromJSON(e.selection),extensions:i.extensions?s.concat([i.extensions]):s})}static create(e={}){let i=Bh.resolve(e.extensions||[],new Map),r=e.doc instanceof ne?e.doc:ne.of((e.doc||"").split(i.staticFacet(oe.lineSeparator)||ud)),s=e.selection?e.selection instanceof Q?e.selection:Q.single(e.selection.anchor,e.selection.head):Q.single(0);return ay(s,r.length),i.staticFacet(Od)||(s=s.asSingle()),new oe(i,r,s,i.dynamicSlots.map(()=>null),(n,o)=>o.create(n),null)}get tabSize(){return this.facet(oe.tabSize)}get lineBreak(){return this.facet(oe.lineSeparator)||` +`}get readOnly(){return this.facet(gy)}phrase(e,...i){for(let r of this.facet(oe.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let n=+(s||1);return!n||n>i.length?r:i[n-1]})),e}languageDataAt(e,i,r=-1){let s=[];for(let n of this.facet(cy))for(let o of n(this,i,r))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let i=this.languageDataAt("wordChars",e);return e$(i.length?i[0]:"")}wordAt(e){let{text:i,from:r,length:s}=this.doc.lineAt(e),n=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=vt(i,o,!1);if(n(i.slice(a,o))!=ur.Word)break;o=a}for(;lt.length?t[0]:4});oe.lineSeparator=uy;oe.readOnly=gy;oe.phrases=H.define({compare(t,e){let i=Object.keys(t),r=Object.keys(e);return i.length==r.length&&i.every(s=>t[s]==e[s])}});oe.languageData=cy;oe.changeFilter=fy;oe.transactionFilter=dy;oe.transactionExtender=py;Ac.reconfigure=Ce.define();function t$(t,e,i={}){let r={};for(let s of t)for(let n of Object.keys(s)){let o=s[n],l=r[n];if(l===void 0)r[n]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(i,n))r[n]=i[n](l,o);else throw new Error("Config merge conflict for field "+n)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class rs{eq(e){return this==e}range(e,i=e){return vd.create(e,i,this)}}rs.prototype.startSide=rs.prototype.endSide=0;rs.prototype.point=!1;rs.prototype.mapMode=Pt.TrackDel;function Bg(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let vd=class _y{constructor(e,i,r){this.from=e,this.to=i,this.value=r}static create(e,i,r){return new _y(e,i,r)}};function Sd(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class zg{constructor(e,i,r,s){this.from=e,this.to=i,this.value=r,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,i,r,s=0){let n=r?this.to:this.from;for(let o=s,l=n.length;;){if(o==l)return o;let a=o+l>>1,h=n[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-i;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,i,r,s){for(let n=this.findIndex(i,-1e9,!0),o=this.findIndex(r,1e9,!1,n);nd||f==d&&h.startSide>0&&h.endSide<=0)continue;(d-f||h.endSide-h.startSide)<0||(o<0&&(o=f),h.point&&(l=Math.max(l,d-f)),r.push(h),s.push(f-o),n.push(d-o))}return{mapped:r.length?new zg(s,n,r,l):null,pos:o}}}class fe{constructor(e,i,r,s){this.chunkPos=e,this.chunk=i,this.nextLayer=r,this.maxPoint=s}static create(e,i,r,s){return new fe(e,i,r,s)}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 i of this.chunk)e+=i.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:i=[],sort:r=!1,filterFrom:s=0,filterTo:n=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(r&&(i=i.slice().sort(Sd)),this.isEmpty)return i.length?fe.of(i):this;let l=new vy(this,null,-1).goto(0),a=0,h=[],c=new Ol;for(;l.value||a=0){let u=i[a++];c.addInner(u.from,u.to,u.value)||h.push(u)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||nl.to||n=n&&e<=n+o.length&&o.between(n,e-n,i-n,r)===!1)return}this.nextLayer.between(e,i,r)}}iter(e=0){return ml.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return ml.from(e).goto(i)}static compare(e,i,r,s,n=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=n),l=i.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=n),a=jm(o,l,r),h=new ho(o,a,n),c=new ho(l,a,n);r.iterGaps((u,f,d)=>Vm(h,u,c,f,d,s)),r.empty&&r.length==0&&Vm(h,0,c,0,0,s)}static eq(e,i,r=0,s){s==null&&(s=999999999);let n=e.filter(c=>!c.isEmpty&&i.indexOf(c)<0),o=i.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(n.length!=o.length)return!1;if(!n.length)return!0;let l=jm(n,o),a=new ho(n,l,0).goto(r),h=new ho(o,l,0).goto(r);for(;;){if(a.to!=h.to||!yd(a.active,h.active)||a.point&&(!h.point||!Bg(a.point,h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,i,r,s,n=-1){let o=new ho(e,null,n).goto(i),l=i,a=o.openStart;for(;;){let h=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),u=o.pointFroml&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,i=!1){let r=new Ol;for(let s of e instanceof vd?[e]:i?i$(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return fe.empty;let i=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=fe.empty;s=s.nextLayer)i=new fe(s.chunkPos,s.chunk,i,Math.max(s.maxPoint,i.maxPoint));return i}}fe.empty=new fe([],[],null,-1);function i$(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(Sd);e=r}return t}fe.empty.nextLayer=fe.empty;class Ol{finishChunk(e){this.chunks.push(new zg(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,i,r){this.addInner(e,i,r)||(this.nextLayer||(this.nextLayer=new Ol)).add(e,i,r)}addInner(e,i,r){let s=e-this.lastTo||r.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(i-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=i,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,i-e)),!0)}addChunk(e,i){if((e-this.lastTo||i.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,i.maxPoint),this.chunks.push(i),this.chunkPos.push(e);let r=i.value.length-1;return this.last=i.value[r],this.lastFrom=i.from[r]+e,this.lastTo=i.to[r]+e,!0}finish(){return this.finishInner(fe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=fe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}}function jm(t,e,i){let r=new Map;for(let n of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new vy(o,i,r,n));return s.length==1?s[0]:new ml(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,i=-1e9){for(let r of this.heap)r.goto(e,i);for(let r=this.heap.length>>1;r>=0;r--)Pu(this.heap,r);return this.next(),this}forward(e,i){for(let r of this.heap)r.forward(e,i);for(let r=this.heap.length>>1;r>=0;r--)Pu(this.heap,r);(this.to-e||this.value.endSide-i)<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(),Pu(this.heap,0)}}}function Pu(t,e){for(let i=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),i.compare(s)<0)break;t[r]=i,t[e]=s,e=r}}class ho{constructor(e,i,r){this.minPoint=r,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=ml.from(e,i,r)}goto(e,i=-1e9){return this.cursor.goto(e,i),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=i,this.openStart=-1,this.next(),this}forward(e,i){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-i)<0;)this.removeActive(this.minActive);this.cursor.forward(e,i)}removeActive(e){ma(this.active,e),ma(this.activeTo,e),ma(this.activeRank,e),this.minActive=Ym(this.active,this.activeTo)}addActive(e){let i=0,{value:r,to:s,rank:n}=this.cursor;for(;i0;)i++;_a(this.active,i,r),_a(this.activeTo,i,s),_a(this.activeRank,i,n),e&&_a(e,i,this.cursor.from),this.minActive=Ym(this.active,this.activeTo)}next(){let e=this.to,i=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ma(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let n=this.cursor.value;if(!n.point)this.addActive(r),this.cursor.next();else if(i&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&i.push(this.active[r]);return i.reverse()}openEnd(e){let i=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)i++;return i}}function Vm(t,e,i,r,s,n){t.goto(e),i.goto(r);let o=r+s,l=r,a=r-e,h=!!n.boundChange;for(let c=!1;;){let u=t.to+a-i.to,f=u||t.endSide-i.endSide,d=f<0?t.to+a:i.to,p=Math.min(d,o);if(t.point||i.point?(t.point&&i.point&&Bg(t.point,i.point)&&yd(t.activeForPoint(t.to),i.activeForPoint(i.to))||n.comparePoint(l,p,t.point,i.point),c=!1):(c&&n.boundChange(l),p>l&&!yd(t.active,i.active)&&n.compareRange(l,p,t.active,i.active),h&&po)break;l=d,f<=0&&t.next(),f>=0&&i.next()}}function yd(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;r--)t[r+1]=t[r];t[e]=i}function Ym(t,e){let i=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;n+=t.charCodeAt(s)==9?i-n%i:1,s=vt(t,s)}return t.length}const wd="ͼ",qm=typeof Symbol>"u"?"__"+wd:Symbol.for(wd),kd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Rn{constructor(e,i){this.rules=[];let{finish:r}=i||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function n(o,l,a,h){let c=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))n(d.split(/,\s*/).map(g=>o.map(v=>g.replace(/&/,v))).reduce((g,v)=>g.concat(v)),p,a);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");n(s(d),p,c,f)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||f)&&a.push((r&&!u&&!h?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)n(s(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Fm[qm]||1;return Fm[qm]=e+1,wd+e.toString(36)}static mount(e,i,r){let s=e[kd],n=r&&r.nonce;s?n&&s.setNonce(n):s=new s$(e,n),s.mount(Array.isArray(i)?i:[i],e)}}let Hm=new Map;class s${constructor(e,i){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let n=Hm.get(r);if(n)return e[kd]=n;this.sheet=new s.CSSStyleSheet,Hm.set(r,this)}else this.styleTag=r.createElement("style"),i&&this.styleTag.setAttribute("nonce",i);this.modules=[],e[kd]=this}mount(e,i){let r=this.sheet,s=0,n=0;for(let o=0;o-1&&(this.modules.splice(a,1),n--,a=-1),a==-1){if(this.modules.splice(n++,0,l),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},n$=typeof navigator<"u"&&/Mac/.test(navigator.platform),o$=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ct=0;ct<10;ct++)ss[48+ct]=ss[96+ct]=String(ct);for(var ct=1;ct<=24;ct++)ss[ct+111]="F"+ct;for(var ct=65;ct<=90;ct++)ss[ct]=String.fromCharCode(ct+32),_l[ct]=String.fromCharCode(ct);for(var $u in ss)_l.hasOwnProperty($u)||(_l[$u]=ss[$u]);function l$(t){var e=n$&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||o$&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",i=!e&&t.key||(t.shiftKey?_l:ss)[t.keyCode]||t.key||"Unidentified";return i=="Esc"&&(i="Escape"),i=="Del"&&(i="Delete"),i=="Left"&&(i="ArrowLeft"),i=="Up"&&(i="ArrowUp"),i=="Right"&&(i="ArrowRight"),i=="Down"&&(i="ArrowDown"),i}let Ct=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},bd=typeof document<"u"?document:{documentElement:{style:{}}};const xd=/Edge\/(\d+)/.exec(Ct.userAgent),Sy=/MSIE \d/.test(Ct.userAgent),Cd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ct.userAgent),Mc=!!(Sy||Cd||xd),Um=!Mc&&/gecko\/(\d+)/i.test(Ct.userAgent),Qu=!Mc&&/Chrome\/(\d+)/.exec(Ct.userAgent),a$="webkitFontSmoothing"in bd.documentElement.style,Pd=!Mc&&/Apple Computer/.test(Ct.vendor),Gm=Pd&&(/Mobile\/\w+/.test(Ct.userAgent)||Ct.maxTouchPoints>2);var W={mac:Gm||/Mac/.test(Ct.platform),windows:/Win/.test(Ct.platform),linux:/Linux|X11/.test(Ct.platform),ie:Mc,ie_version:Sy?bd.documentMode||6:Cd?+Cd[1]:xd?+xd[1]:0,gecko:Um,gecko_version:Um?+(/Firefox\/(\d+)/.exec(Ct.userAgent)||[0,0])[1]:0,chrome:!!Qu,chrome_version:Qu?+Qu[1]:0,ios:Gm,android:/Android\b/.test(Ct.userAgent),webkit_version:a$?+(/\bAppleWebKit\/(\d+)/.exec(Ct.userAgent)||[0,0])[1]:0,safari:Pd,safari_version:Pd?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ct.userAgent)||[0,0])[1]:0,tabSize:bd.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Zg(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const Zh=Object.create(null);function Xg(t,e,i){if(t==e)return!0;t||(t=Zh),e||(e=Zh);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let n of r)if(n!=i&&(s.indexOf(n)==-1||t[n]!==e[n]))return!1;return!0}function h$(t,e){for(let i=t.attributes.length-1;i>=0;i--){let r=t.attributes[i].name;e[r]==null&&t.removeAttribute(r)}for(let i in e){let r=e[i];i=="style"?t.style.cssText=r:t.getAttribute(i)!=r&&t.setAttribute(i,r)}}function Km(t,e,i){let r=!1;if(e)for(let s in e)i&&s in i||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(r=!0,s=="style"?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return r}function c$(t){let e=Object.create(null);for(let i=0;i0?3e8:-4e8:i>0?1e8:-1e8,new Ms(e,i,i,r,e.widget||null,!1)}static replace(e){let i=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:n,end:o}=yy(e,i);r=(n?i?-3e8:-1:5e8)-1,s=(o?i?2e8:1:-6e8)+1}return new Ms(e,r,s,i,e.widget||null,!0)}static line(e){return new Xl(e)}static set(e,i=!1){return fe.of(e,i)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Se.none=fe.empty;class Zl extends Se{constructor(e){let{start:i,end:r}=yy(e);super(i?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Zg(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Zh}eq(e){return this==e||e instanceof Zl&&this.tagName==e.tagName&&Xg(this.attrs,e.attrs)}range(e,i=e){if(e>=i)throw new RangeError("Mark decorations may not be empty");return super.range(e,i)}}Zl.prototype.point=!1;class Xl extends Se{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Xl&&this.spec.class==e.spec.class&&Xg(this.spec.attributes,e.spec.attributes)}range(e,i=e){if(i!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,i)}}Xl.prototype.mapMode=Pt.TrackBefore;Xl.prototype.point=!0;class Ms extends Se{constructor(e,i,r,s,n,o){super(i,r,n,e),this.block=s,this.isReplace=o,this.mapMode=s?i<=0?Pt.TrackBefore:Pt.TrackAfter:Pt.TrackDel}get type(){return this.startSide!=this.endSide?pi.WidgetRange:this.startSide<=0?pi.WidgetBefore:pi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ms&&u$(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,i=e){if(this.isReplace&&(e>i||e==i&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&i!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,i)}}Ms.prototype.point=!0;function yy(t,e=!1){let{inclusiveStart:i,inclusiveEnd:r}=t;return i==null&&(i=t.inclusive),r==null&&(r=t.inclusive),{start:i??e,end:r??e}}function u$(t,e){return t==e||!!(t&&e&&t.compare(e))}function vn(t,e,i,r=0){let s=i.length-1;s>=0&&i[s]+r>=t?i[s]=Math.max(i[s],e):i.push(t,e)}class vl extends rs{constructor(e,i,r){super(),this.tagName=e,this.attributes=i,this.rank=r}eq(e){return e==this||e instanceof vl&&this.tagName==e.tagName&&Xg(this.attributes,e.attributes)}static create(e){return new vl(e.tagName,e.attributes||Zh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,i=!1){return fe.of(e,i)}}vl.prototype.startSide=vl.prototype.endSide=-1;function Sl(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function $d(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Yo(t,e){if(!e.anchorNode)return!1;try{return $d(t,e.anchorNode)}catch{return!1}}function eh(t){return t.nodeType==3?yl(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function qo(t,e,i,r){return i?Jm(t,e,i,r,-1)||Jm(t,e,i,r,1):!1}function ns(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Xh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Jm(t,e,i,r,s){for(;;){if(t==i&&e==r)return!0;if(e==(s<0?0:yr(t))){if(t.nodeName=="DIV")return!1;let n=t.parentNode;if(!n||n.nodeType!=1)return!1;e=ns(t)+(s<0?0:1),t=n}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?yr(t):0}else return!1}}function yr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ih(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function f$(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function wy(t,e){let i=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:i,scaleY:r}}function d$(t,e,i,r,s,n,o,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,u=!1;c&&!u;)if(c.nodeType==1){let f,d=c==a.body,p=1,g=1;if(d)f=f$(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let m=c.getBoundingClientRect();({scaleX:p,scaleY:g}=wy(c,m)),f={left:m.left,right:m.left+c.clientWidth*p,top:m.top,bottom:m.top+c.clientHeight*g}}let v=0,O=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+O&&(O=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(O=e.bottom-f.bottom+o,i<0&&e.top-O0&&e.right>f.right+v&&(v=e.right-f.right+n)):e.right>f.right-n&&(v=e.right-f.right+n,i<0&&e.leftf.bottom||e.leftf.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function ky(t,e=!0){let i=t.ownerDocument,r=null,s=null;for(let n=t.parentNode;n&&!(n==i.body||(!e||r)&&s);)if(n.nodeType==1)!s&&n.scrollHeight>n.clientHeight&&(s=n),e&&!r&&n.scrollWidth>n.clientWidth&&(r=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:r,y:s}}class p${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:i,focusNode:r}=e;this.set(i,Math.min(e.anchorOffset,i?yr(i):0),r,Math.min(e.focusOffset,r?yr(r):0))}set(e,i,r,s){this.anchorNode=e,this.anchorOffset=i,this.focusNode=r,this.focusOffset=s}}let gs=null;W.safari&&W.safari_version>=26&&(gs=!1);function by(t){if(t.setActive)return t.setActive();if(gs)return t.focus(gs);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(gs==null?{get preventScroll(){return gs={preventScroll:!0},!0}}:void 0),!gs){gs=!1;for(let i=0;iMath.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Cy(t,e){for(let i=t,r=e;;){if(i.nodeType==3&&r>0)return{node:i,offset:r};if(i.nodeType==1&&r>0){if(i.contentEditable=="false")return null;i=i.childNodes[r-1],r=yr(i)}else if(i.parentNode&&!Xh(i))r=ns(i),i=i.parentNode;else return null}}function Py(t,e){for(let i=t,r=e;;){if(i.nodeType==3&&r=i){if(l.level==r)return o;(n<0||(s!=0?s<0?l.fromi:e[n].level>l.level))&&(n=o)}}if(n<0)throw new RangeError("Index out of range");return n}}function Ty(t,e){if(t.length!=e.length)return!1;for(let i=0;i=0;g-=3)if(Li[g+1]==-d){let v=Li[g+2],O=v&2?s:v&4?v&1?n:s:0;O&&(me[u]=me[Li[g]]=O),l=g;break}}else{if(Li.length==189)break;Li[l++]=u,Li[l++]=f,Li[l++]=a}else if((p=me[u])==2||p==1){let g=p==s;a=g?0:1;for(let v=l-3;v>=0;v-=3){let O=Li[v+2];if(O&2)break;if(g)Li[v+2]|=2;else{if(O&4)break;Li[v+2]|=4}}}}}function w$(t,e,i,r){for(let s=0,n=r;s<=i.length;s++){let o=s?i[s-1].to:t,l=sa;)p==v&&(p=i[--g].from,v=g?i[g-1].to:t),me[--p]=d;a=c}else n=h,a++}}}function Td(t,e,i,r,s,n,o){let l=r%2?2:1;if(r%2==s%2)for(let a=e,h=0;aa&&o.push(new Yi(a,g.from,d));let v=g.direction==Ls!=!(d%2);Ed(t,v?r+1:r,s,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==i||(c?me[p]!=l:me[p]==l))break;p++}f?Td(t,a,p,r+1,s,f,o):ae;){let c=!0,u=!1;if(!h||a>n[h-1].to){let g=me[a-1];g!=l&&(c=!1,u=g==16)}let f=!c&&l==1?[]:null,d=c?r:r+1,p=a;e:for(;;)if(h&&p==n[h-1].to){if(u)break e;let g=n[--h];if(!c)for(let v=g.from,O=h;;){if(v==e)break e;if(O&&n[O-1].to==v)v=n[--O].from;else{if(me[v-1]==l)break e;break}}if(f)f.push(g);else{g.tome.length;)me[me.length]=256;let r=[],s=e==Ls?0:1;return Ed(t,s,s,i,0,t.length,r),r}function Ey(t){return[new Yi(0,t,0)]}let Ry="";function b$(t,e,i,r,s){var n;let o=r.head-t.from,l=Yi.find(e,o,(n=r.bidiLevel)!==null&&n!==void 0?n:-1,r.assoc),a=e[l],h=a.side(s,i);if(o==h){let f=l+=s?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!s,i),h=a.side(s,i)}let c=vt(t.text,o,a.forward(s,i));(ca.to)&&(c=h),Ry=t.text.slice(Math.min(o,c),Math.max(o,c));let u=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return u&&c==h&&u.level+(s?0:1)t.some(e=>e)}),C$=H.define({combine:t=>t.some(e=>e)}),Xy=H.define();class yn{constructor(e,i,r,s,n,o=!1){this.range=e,this.y=i,this.x=r,this.yMargin=s,this.xMargin=n,this.isSnapshot=o}map(e){return e.empty?this:new yn(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 yn(Q.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const va=Ce.define({map:(t,e)=>t.map(e)}),Iy=Ce.define();function qi(t,e,i){let r=t.facet(Dy);r.length?r[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const ar=H.define({combine:t=>t.length?t[0]:!0});let P$=0;const ln=H.define({combine(t){return t.filter((e,i)=>{for(let r=0;r{let a=[];return o&&a.push(Lc.of(h=>{let c=h.plugin(l);return c?o(c):Se.none})),n&&a.push(n(l)),a})}static fromClass(e,i){return Ds.define((r,s)=>new e(r,s),i)}}class Tu{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let i=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(i)}catch(r){if(qi(i.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(i){qi(e.state,i,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var i;if(!((i=this.value)===null||i===void 0)&&i.destroy)try{this.value.destroy()}catch(r){qi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Wy=H.define(),jg=H.define(),Lc=H.define(),Ny=H.define(),Vg=H.define(),Il=H.define(),jy=H.define();function t_(t,e){let i=t.state.facet(jy);if(!i.length)return i;let r=i.map(n=>n instanceof Function?n(t):n),s=[];return fe.spans(r,e.from,e.to,{point(){},span(n,o,l,a){let h=n-e.from,c=o-e.from,u=s;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=x$(e.text,h,c)),a>0&&u.length&&(p=u[u.length-1]).to==h&&p.direction==d)p.to=c,u=p.inner;else{let g={from:h,to:c,direction:d,inner:[]};u.push(g),u=g.inner}}}}),s}const Vy=H.define();function Yy(t){let e=0,i=0,r=0,s=0;for(let n of t.state.facet(Vy)){let o=n(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(i=Math.max(i,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:r,bottom:s}}const Po=H.define();class ci{constructor(e,i,r,s){this.fromA=e,this.toA=i,this.fromB=r,this.toB=s}join(e){return new ci(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 i=e.length,r=this;for(;i>0;i--){let s=e[i-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new ci(n,o,l,a))),this.changedRanges=s}static create(e,i,r){return new Wh(e,i,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>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}}const $$=[];class Le{constructor(e,i,r=0){this.dom=e,this.length=i,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return $$}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let i=this.domAttrs;i&&h$(this.dom,i)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,i=this.posAtStart){let r=i;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,i){return null}domPosFor(e,i){let r=ns(this.dom),s=this.length?e>0:i>0;return new Ci(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Bc)return e;return null}static get(e){return e.cmTile}}class Dc extends Le{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let i=this.dom,r=null,s,n=(e==null?void 0:e.node)==i?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,s=r?r.nextSibling:i.firstChild,n&&s!=l.dom&&(n.written=!0),l.dom.parentNode==i)for(;s&&s!=l.dom;)s=i_(s);else i.insertBefore(l.dom,s);r=l.dom}for(s=r?r.nextSibling:i.firstChild,n&&s&&(n.written=!0);s;)s=i_(s);this.length=o}}function i_(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Bc extends Dc{constructor(e,i){super(i),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let i=Le.get(e);if(i&&this.owns(i))return i;e=e.parentNode}}blockTiles(e){for(let i=[],r=this,s=0,n=0;;)if(s==r.children.length){if(!i.length)return;r=r.parent,r.breakAfter&&n++,s=i.pop()}else{let o=r.children[s++];if(o instanceof pr)i.push(s),r=o,s=0;else{let l=n+o.length,a=e(o,n);if(a!==void 0)return a;n=l+o.breakAfter}}}resolveBlock(e,i){let r,s=-1,n,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&i>=-1&&i<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(i>1?l.length:l.covers(-1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,o=e-a)}}),!r&&!n)throw new Error("No tile at position "+e);return r&&i<0||!n?{tile:r,offset:s}:{tile:n,offset:o}}}class pr extends Dc{constructor(e,i){super(e),this.wrapper=i}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,i){let r=new pr(i||document.createElement(e.tagName),e);return i||(r.flags|=4),r}}class An extends Dc{constructor(e,i){super(e),this.attrs=i}isLine(){return!0}static start(e,i,r){let s=new An(i||document.createElement("div"),e);return(!i||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,i,r){let s=null,n=-1,o=null,l=-1;function a(c,u){for(let f=0,d=0;f=u&&(p.isComposite()?a(p,u-d):(!o||o.isHidden&&(i>0||r&&T$(o,p)))&&(g>u||p.flags&32)?(o=p,l=u-d):(dr&&(e=r);let s=e,n=e,o=0;e==0&&i<0||e==r&&i>=0?W.chrome||W.gecko||(e?(s--,o=1):n=0)?0:l.length-1];return W.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Ih(a,o<0):a||null}static of(e,i){let r=new bs(i||document.createTextNode(e),e);return i||(r.flags|=2),r}}class Bs extends Le{constructor(e,i,r,s){super(e,i,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,i){return this.coordsInWidget(e,i,!1)}coordsInWidget(e,i,r){let s=this.widget.coordsAt(this.dom,e,i);if(s)return s;if(r)return Ih(this.dom.getBoundingClientRect(),this.length?e==0:i<=0);{let n=this.dom.getClientRects(),o=null;if(!n.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?n.length-1:0;o=n[a],!(e>0?a==0:a==n.length-1||o.top0;)if(s.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(n==s.children.length){if(!e&&!l.length)break;r&&r.leave(s),o=!!s.breakAfter,{tile:s,index:n}=l.pop(),n++}else{let a=s.children[n],h=a.breakAfter;(i>0?a.length<=e:a.length=0;l--){let a=i.marks[l],h=s.lastChild;if(h instanceof Bt&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Eu(a.dom)),s=h;else{if(this.cache.reused.get(a)){let u=Le.get(a.dom);u&&u.setDOM(Eu(a.dom))}let c=Bt.of(a.mark,a.dom);s.append(c),s=c}this.cache.reused.set(a,2)}let n=Le.get(e.text);n&&this.cache.reused.set(n,2);let o=new bs(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,i,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let n=this.ensureMarks(i,r);!s&&!(e.flags&16)&&n.append(this.getBuffer(1)),n.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,i,r){this.flushBuffer(),this.ensureMarks(i,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let i=this.afterWidget||this.lastBlock;i.length+=e,this.pos+=e}addLineStart(e,i){var r;e||(e=qy);let s=An.start(e,i||((r=this.cache.find(An))===null||r===void 0?void 0:r.dom),!!i);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,i){var r;let s=this.curLine;for(let n=e.length-1;n>=0;n--){let o=e[n],l;if(i>0&&(l=s.lastChild)&&l instanceof Bt&&l.mark.eq(o))s=l,i--;else{let a=Bt.of(o,(r=this.cache.find(Bt,h=>h.mark.eq(o)))===null||r===void 0?void 0:r.dom);s.append(a),s=a,i=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!r_(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(W.ios&&r_(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ru,0,32)||new Bs(Ru.toDOM(),0,Ru,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let i=e.rank*102+e.value.rank,r=new R$(e.from,e.to,e.value,i),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let i=this.root;for(let r of this.wrappers){let s=i.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);i.append(n),i=n}}return i}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let i=2|(e<0?16:32),r=this.cache.find(Nh,void 0,1);return r&&(r.flags=i),r||new Nh(i)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class M${constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:n,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(e,s.length);return n?null:s.slice(0,l)}let i=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,i);return this.textOff=i,r}}const jh=[Bs,An,bs,Bt,Nh,pr,Bc];for(let t=0;t[]),this.index=jh.map(()=>0),this.reused=new Map}add(e){let i=e.constructor.bucket,r=this.buckets[i];r.length<6?r.push(e):r[this.index[i]=(this.index[i]+1)%6]=e}find(e,i,r=2){let s=e.bucket,n=this.buckets[s],o=this.index[s];for(let l=n.length-1;l>=0;l--){let a=(l+o)%n.length,h=n[a];if((!i||i(h))&&!this.reused.has(h))return n.splice(a,1),a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,i){let r=i&&this.getCompositionContext(i.text);for(let s=0,n=0,o=0;;){let l=os){let h=a-s;this.preserve(h,!o,!l),s=a,n+=h}if(!l)break;i&&l.fromA<=i.range.fromA&&l.toA>=i.range.toA?(this.forward(l.fromA,i.range.fromA,i.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Bt&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=n=0):o instanceof Bt&&(s.shift(),n=Math.min(n,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,i){let r=null,s=this.builder,n=0,o=fe.spans(this.decorations,e,i,{point:(l,a,h,c,u,f)=>{if(h instanceof Ms){if(this.disallowBlockEffectsFor[f]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=c.length,u>c.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?Mn.block:Mn.inline),p=B$(h),g=this.cache.findWidget(d,a-l,p)||Bs.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(g)):(s.ensureLine(r),s.addInlineWidget(g,c,u))}r=null}else r=z$(r,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let u=l;un,this.openMarks=o}forward(e,i,r=1){i-e<=10?this.old.advance(i-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(i-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let i=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let n=Le.get(s);if(s==this.view.contentDOM)break;n instanceof Bt?i.push(n):n!=null&&n.isLine()?r=n:n instanceof pr||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new An(s,qy):r||i.push(Bt.of(new Zl({tagName:s.nodeName.toLowerCase(),attributes:c$(s)}),s)))}return{line:r,marks:i}}}function r_(t,e){let i=r=>{for(let s of r.children)if((e?s.isText():s.length)||i(s))return!0;return!1};return i(t)}function B$(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qy={class:"cm-line"};function z$(t,e){let i=e.spec.attributes,r=e.spec.class;return!i&&!r||(t||(t={class:"cm-line"}),i&&Zg(i,t),r&&(t.class+=" "+r)),t}function Z$(t){let e=[];for(let i=t.parents.length;i>1;i--){let r=i==t.parents.length?t.tile:t.parents[i].tile;r instanceof Bt&&e.push(r.mark)}return e}function Eu(t){let e=Le.get(t);return e&&e.setDOM(t.cloneNode()),t}class Mn extends zl{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}}Mn.inline=new Mn("span");Mn.block=new Mn("div");const Ru=new class extends zl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class s_{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Se.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Bc(e,e.contentDOM),this.updateInner([new ci(0,0,0,e.state.doc.length)],null)}update(e){var i;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((i=this.domChanged)===null||i===void 0)&&i.newSel?s=this.domChanged.newSel.head:!F$(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let n=s>-1?I$(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:u}=this.hasComposition;r=new ci(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(r.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(W.ie||W.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=j$(o,this.decorations,e.changes);a.length&&(r=ci.extendWithRanges(r,a));let h=Y$(l,this.blockWrappers,e.changes);return h.length&&(r=ci.extendWithRanges(r,h)),n&&!r.some(c=>c.fromA<=n.range.fromA&&c.toA>=n.range.toA)&&(r=n.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,i){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(i||e.length){let o=this.tile,l=new D$(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);i&&Le.get(i.text)&&l.cache.reused.set(Le.get(i.text),2),this.tile=l.run(e,i),Ad(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=W.chrome||W.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||r.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Yo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(n||i||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),W.gecko&&a.empty&&!this.hasComposition&&X$(h)){let f=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(f,h.node.childNodes[h.offset]||null)),h=c=new Ci(f,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!qo(h.node,h.offset,u.anchorNode,u.anchorOffset)||!qo(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{W.android&&W.chrome&&r.contains(u.focusNode)&&q$(u.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let f=Sl(this.view.root);if(f)if(a.empty){if(W.gecko){let d=W$(h.node,h.offset);if(d&&d!=3){let p=(d==1?Cy:Py)(h.node,h.offset);p&&(h=new Ci(p.node,p.offset))}}f.collapse(h.node,h.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(h.node,h.offset);try{f.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new Ci(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Ci(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,i){return this.hasComposition&&i.empty&&qo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==i.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,i=e.state.selection.main,r=Sl(e.root),{anchorNode:s,anchorOffset:n}=e.observer.selectionRange;if(!r||!i.empty||!i.assoc||!r.modify)return;let o=this.lineAt(i.head,i.assoc);if(!o)return;let l=o.posAtStart;if(i.head==l||i.head==l+o.length)return;let a=this.coordsAt(i.head,-1),h=this.coordsAt(i.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(i.head+i.assoc,i.assoc);r.collapse(c.node,c.offset),r.modify("move",i.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=i.from&&r.collapse(s,n)}posFromDOM(e,i){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let n;if(e==r.dom)n=r.dom.childNodes[i];else{let o=yr(e)==0?0:i==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?n=e:n=e.nextSibling}if(n==r.dom.firstChild)return s;for(;n&&!Le.get(n);)n=n.nextSibling;if(!n)return s+r.length;for(let o=0,l=s;;o++){let a=r.children[o];if(a.dom==n)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?s+i:s+(i?r.length:0):s}domAtPos(e,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,i);return r.isWidget()?r.domPosFor(e,i):r.domIn(s,i)}inlineDOMNearPos(e,i){let r,s=-1,n=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(n=!0)}else{let u=c+h.length;if(c<=e&&(r=h,s=e-c,n=u=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,i):(n&&o?r=null:a&&r&&(o=null),r&&i<0||!o?r.domIn(s,i):o.domIn(l,i))}coordsAt(e,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,i);return r.isWidget()?r.widget instanceof Au?null:r.coordsInWidget(s,i,!0):r.coordsIn(s,i)}lineAt(e,i){let{tile:r}=this.tile.resolveBlock(e,i);return r.isLine()?r:null}coordsForChar(e){let{tile:i,offset:r}=this.tile.resolveBlock(e,1);if(!i.isLine())return null;function s(n,o){if(n.isComposite())for(let l of n.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(n.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Ye.LTR,h=0,c=(u,f,d)=>{for(let p=0;ps);p++){let g=u.children[p],v=f+g.length,O=g.dom.getBoundingClientRect(),{height:m}=O;if(d&&!p&&(h+=O.top-d.top),g instanceof pr)v>r&&c(g,f,O);else if(f>=r&&(h>0&&i.push(-h),i.push(m+h),h=0,o)){let _=g.dom.lastChild,S=_?eh(_):[];if(S.length){let w=S[S.length-1],k=a?w.right-O.left:O.right-w.left;k>l&&(l=k,this.minWidth=n,this.minWidthFrom=f,this.minWidthTo=v)}}d&&p==u.children.length-1&&(h+=d.bottom-O.bottom),f=v+g.breakAfter}};return c(this.tile,0,null),i}textDirectionAt(e){let{tile:i}=this.tile.resolveBlock(e,1);return getComputedStyle(i.dom).direction=="rtl"?Ye.RTL:Ye.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=eh(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let i=document.createElement("div"),r,s,n;return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let o=eh(i.firstChild)[0];r=i.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,n=o&&o.height?o.height:r,i.remove()}),{lineHeight:r,charWidth:s,textHeight:n}}computeBlockGapDeco(){let e=[],i=this.view.viewState;for(let r=0,s=0;;s++){let n=s==i.viewports.length?null:i.viewports[s],o=n?n.from-1:this.view.state.doc.length;if(o>r){let l=(i.lineBlockAt(o).bottom-i.lineBlockAt(r).top)/this.view.scaleY;e.push(Se.replace({widget:new Au(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!n)break;r=n.to+1}return Se.set(e)}updateDeco(){let e=1,i=this.view.state.facet(Lc).map(n=>(this.dynamicDecorationMap[e++]=typeof n=="function")?n(this.view):n),r=!1,s=this.view.state.facet(Vg).map((n,o)=>{let l=typeof n=="function";return l&&(r=!0),l?n(this.view):n});for(s.length&&(this.dynamicDecorationMap[e++]=r,i.push(fe.join(s))),this.decorations=[this.editContextFormatting,...i,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof n=="function"?n(this.view):n)}scrollIntoView(e){var i;if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(Xy))try{if(c(this.view,e.range,e))return!0}catch(u){qi(this.view.state,u,"scroll handler")}let{range:r}=e,s=this.coordsAt(r.head,(i=r.assoc)!==null&&i!==void 0?i:r.empty?0:r.head>r.anchor?-1:1),n;if(!s)return;!r.empty&&(n=this.coordsAt(r.anchor,r.anchor>r.head?-1:1))&&(s={left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.max(s.right,n.right),bottom:Math.max(s.bottom,n.bottom)});let o=Yy(this.view),l={left:s.left-o.left,top:s.top-o.top,right:s.right+o.right,bottom:s.bottom+o.bottom},{offsetWidth:a,offsetHeight:h}=this.view.scrollDOM;if(d$(this.view.scrollDOM,l,r.head1&&(s.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||s.bottomr.isWidget()||r.children.some(i);return i(this.tile.resolveBlock(e,1).tile)}destroy(){Ad(this.tile)}}function Ad(t,e){let i=e==null?void 0:e.get(t);if(i!=1){i==null&&t.destroy();for(let r of t.children)Ad(r,e)}}function X$(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function Fy(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let r=Cy(i.focusNode,i.focusOffset),s=Py(i.focusNode,i.focusOffset),n=r||s;if(s&&r&&s.node!=r.node){let l=Le.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)n=s;else if(t.docView.lastCompositionAfterCursor){let a=Le.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(n=s)}}if(t.docView.lastCompositionAfterCursor=n!=r,!n)return null;let o=e-n.offset;return{from:o,to:o+n.node.nodeValue.length,node:n.node}}function I$(t,e,i){let r=Fy(t,i);if(!r)return null;let{node:s,from:n,to:o}=r,l=s.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new ci(a.mapPos(n),a.mapPos(o),n,o),text:s}}function W$(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(i=!0)}),i}class Au extends zl{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function H$(t,e,i=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),n=e-s.from;if(s.length==0)return Q.cursor(e);n==0?i=1:n==s.length&&(i=-1);let o=n,l=n;i<0?o=vt(s.text,n,!1):l=vt(s.text,n);let a=r(s.text.slice(o,l));for(;o>0;){let h=vt(s.text,o,!1);if(r(s.text.slice(h,o))!=a)break;o=h}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((s-i.top-(t.defaultLineHeight-l)*.5)/l);n+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+r$(o,n,t.state.tabSize)}function G$(t,e,i){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let n of r.type){if(n.from>e)break;if(!(n.toe)return n;(!s||n.type==pi.Text&&(s.type!=n.type||(i<0?n.frome)))&&(s=n)}}return s||r}return r}function K$(t,e,i,r){let s=G$(t,e.head,e.assoc||-1),n=!r||s.type!=pi.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(n){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(s.from),a=t.posAtCoords({x:i==(l==Ye.LTR)?o.right-1:o.left+1,y:(n.top+n.bottom)/2});if(a!=null)return Q.cursor(a,i?-1:1)}return Q.cursor(i?s.to:s.from,i?-1:1)}function n_(t,e,i,r){let s=t.state.doc.lineAt(e.head),n=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let l=e,a=null;;){let h=b$(s,n,o,l,i),c=Ry;if(!h){if(s.number==(i?t.state.doc.lines:1))return l;c=` +`,s=t.state.doc.line(s.number+(i?1:-1)),n=t.bidiSpans(s),h=t.visualLineSide(s,!i)}if(a){if(!a(c))return l}else{if(!r)return h;a=r(c)}l=h}}function J$(t,e,i){let r=t.state.charCategorizer(e),s=r(i);return n=>{let o=r(n);return s==ur.Space&&(s=o),s==o}}function e2(t,e,i,r){let s=e.head,n=i?1:-1;if(s==(i?t.state.doc.length:0))return Q.cursor(s,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?i:e.head==e.from)?1:-1)),c=t.documentTop;if(h)o==null&&(o=h.left-a.left),l=n<0?h.top:h.bottom;else{let p=t.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-p.from))),l=(n<0?p.top:p.bottom)+c}let u=a.left+o,f=t.viewState.heightOracle.textHeight>>1,d=r??f;for(let p=0;;p+=f){let g=l+(d+p)*n,v=Md(t,{x:u,y:g},!1,n);if(i?g>a.bottom:gl:m{if(e>n&&es(t)),i.from,e.head>i.from?-1:1);return r==i.from?i:Q.cursor(r,rt.viewState.docHeight)return new Vi(t.state.doc.length,-1);if(h=t.elementAtHeight(a),r==null)break;if(h.type==pi.Text){if(r<0?h.tot.viewport.to)break;let f=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(f&&(r<0?f.top<=a+n:f.bottom>=a+n))break}let u=t.viewState.heightOracle.textHeight/2;a=r>0?h.bottom+u:h.top-u}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(i)return null;if(h.type==pi.Text){let u=U$(t,s,h,o,l);return new Vi(u,u==h.from?1:-1)}}if(h.type!=pi.Text)return a<(h.top+h.bottom)/2?new Vi(h.from,1):new Vi(h.to,-1);let c=t.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=t.docView.lineAt(h.from,-2)),new t2(t,o,l,t.textDirectionAt(h.from)).scanTile(c,h.from)}class t2{constructor(e,i,r,s){this.view=e,this.x=i,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(o.has(g)){let O=s+Math.floor(Math.random()*p);for(let m=0;m1)){if(m.bottomthis.y)(!h||h.top>m.top)&&(h=m),_=-1;else{let S=m.left>this.x?this.x-m.left:m.right(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,i,!0);if(h&&h.top<(p+g+g)/3)return this.y=h.top+1,this.scan(e,i,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==Ye.LTR;return{i:c,after:this.x>(f.left+f.right)/2==d}}scanText(e,i){let r=[];for(let n=0;n{let o=r[n]-i,l=r[n+1]-i;return yl(e.dom,o,l).getClientRects()});return s.after?new Vi(r[s.i+1],-1):new Vi(r[s.i],1)}scanTile(e,i){if(!e.length)return new Vi(i,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,i);if(l.isComposite())return this.scanTile(l,i)}let r=[i];for(let l=0,a=i;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:yl(a.dom,0,a.length)).getClientRects()}),n=e.children[s.i],o=r[s.i];return n.isText()?this.scanText(n,o):n.isComposite()?this.scanTile(n,o):s.after?new Vi(r[s.i+1],-1):new Vi(o,1)}}const qs="￿";class i2{constructor(e,i){this.points=e,this.view=i,this.text="",this.lineSeparator=i.state.facet(oe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=qs}readRange(e,i){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let n=this.text.length;this.readNode(s);let o=Le.get(s),l=s.nextSibling;if(l==i){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=Le.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Xh(s))||Xh(l)&&(s.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>n)&&!s2(l,i)&&this.lineBreak(),s=l}return this.findPointBefore(r,i),this}readTextNode(e){let i=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,i.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,o=1,l;if(this.lineSeparator?(n=i.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=s.exec(i))&&(n=l.index,o=l[0].length),this.append(i.slice(r,n<0?i.length:n)),n<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=n+o}}readNode(e){let i=Le.get(e),r=i&&i.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,i){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==i&&(r.pos=this.text.length)}findPointInside(e,i){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(r2(e,r.node,r.offset)?i:0))}}function r2(t,e,i){for(;;){if(!e||i-1;let{impreciseHead:n,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&i>-1)this.newSel=null;else if(i>-1&&(this.bounds=Uy(e.docView.tile,i,r,0))){let a=n||o?[]:l2(e),h=new i2(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=a2(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=n&&n.node==a.focusNode&&n.offset==a.focusOffset||!$d(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!$d(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((W.ios||W.chrome)&&l.main.empty&&h!=c&&(u.from>0||u.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(Q.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(h,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=Q.create([Q.cursor(h,d)])}else this.newSel=Q.single(c,h)}}}function Uy(t,e,i,r){if(t.isComposite()){let s=-1,n=-1,o=-1,l=-1;for(let a=0,h=r,c=r;ai)return Uy(u,e,i,h);if(f>=e&&s==-1&&(s=a,n=h),h>i&&u.dom.parentNode==t.dom){o=a,l=c;break}c=f,h=f+u.breakAfter}return{from:n,to:l<0?r+t.length:l,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Gy(t,e){let i,{newSel:r}=e,{state:s}=t,n=s.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=n.from,c=null;(o===8||W.android&&e.text.length=l&&n.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,n.from-l)==e.text.slice(0,n.from-l)&&u.slice(n.to-l)==e.text.slice(f=e.text.length-(u.length-(n.to-l)))?i={from:n.from,to:n.to,insert:ne.of(e.text.slice(n.from-l,f).split(qs))}:(d=Ky(u,e.text,h-l,c))&&(W.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==qs+qs&&d.toB--,i={from:l+d.from,to:l+d.toA,insert:ne.of(e.text.slice(d.from,d.toB).split(qs))})}else r&&(!t.hasFocus&&s.facet(ar)||Vh(r,n))&&(r=null);if(!i&&!r)return!1;if((W.mac||W.android)&&i&&i.from==i.to&&i.from==n.head-1&&/^\. ?$/.test(i.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&i.insert.length==2&&(r=Q.single(r.main.anchor-1,r.main.head-1)),i={from:i.from,to:i.to,insert:ne.of([i.insert.toString().replace("."," ")])}):s.doc.lineAt(n.from).toDate.now()-50?i={from:n.from,to:n.to,insert:s.toText(t.inputState.insertingText)}:W.chrome&&i&&i.from==i.to&&i.from==n.head&&i.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=Q.single(r.main.anchor-1,r.main.head-1)),i={from:n.from,to:n.to,insert:ne.of([" "])}),i)return Yg(t,i,r,o);if(r&&!Vh(r,n)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=Hy(s.facet(Il).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function Yg(t,e,i,r=-1){if(W.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(W.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Sn(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&Sn(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Sn(t.contentDOM,"Delete",46)))return!0;let n=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=o2(t,e,i));return t.state.facet(By).some(a=>a(t,e.from,e.to,n,l))||t.dispatch(l()),!0}function o2(t,e,i){let r,s=t.state,n=s.selection.main,o=-1;if(e.from==e.to&&e.fromn.to){let a=e.fromu(t)),h,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:Q.cursor(e.from+e.insert.length,-1)};else if(e.from>=n.from&&e.to<=n.to&&e.to-e.from>=(n.to-n.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=n.frome.to?s.sliceDoc(e.to,n.to):"";r=s.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let a=s.changes(e),h=i&&i.main.to<=a.newLength?i.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=n.to+10&&e.to>=n.to-10){let c=t.state.sliceDoc(e.from,e.to),u,f=i&&Fy(t,i.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=t.state.doc.lineAt(n.head);let d=n.to-e.to;r=s.changeByRange(p=>{if(p.from==n.from&&p.to==n.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,v=g-c.length;if(t.state.sliceDoc(v,g)!=c||g>=u.from&&v<=u.to)return{range:p};let O=s.changes({from:v,to:g,insert:e.insert}),m=p.to-n.to;return{changes:O,range:h?Q.range(Math.max(0,h.anchor+m),Math.max(0,h.head+m)):p.map(O)}})}else r={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:l,scrollIntoView:!0})}function Ky(t,e,i,r){let s=Math.min(t.length,e.length),n=0;for(;n0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,n-Math.min(o,l));i-=o+a-n}if(o=o?n-i:0;n-=a,l=n+(l-o),o=n}else if(l=l?n-i:0;n-=a,o=n+(o-l),l=n}return{from:n,toA:o,toB:l}}function l2(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new o_(i,r)),(s!=i||n!=r)&&e.push(new o_(s,n))),e}function a2(t,e){if(t.length==0)return null;let i=t[0].pos,r=t.length==2?t[1].pos:i;return i>-1&&r>-1?Q.single(i+e,r+e):null}function Vh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class h2{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,W.safari&&e.contentDOM.addEventListener("input",()=>null),W.gecko&&b2(e.contentDOM.ownerDocument)}handleEvent(e){!m2(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,i){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,i);for(let s of r.handlers){if(i.defaultPrevented)break;if(s(this.view,i)){i.preventDefault();break}}}}ensureHandlers(e){let i=c2(e),r=this.handlers,s=this.view.contentDOM;for(let n in i)if(n!="scroll"){let o=!i[n].handlers.length,l=r[n];l&&o!=!l.handlers.length&&(s.removeEventListener(n,this.handleEvent),l=null),l||s.addEventListener(n,this.handleEvent,{passive:o})}for(let n in r)n!="scroll"&&!i[n]&&s.removeEventListener(n,this.handleEvent);this.handlers=i}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ew.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),W.android&&W.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return W.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((i=Jy.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||u2.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=i||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let i=this.pendingIOSKey;return!i||i.key=="Enter"&&e&&e.from0?!0:W.safari&&!W.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.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 l_(t,e){return(i,r)=>{try{return e.call(t,r,i)}catch(s){qi(i.state,s)}}}function c2(t){let e=Object.create(null);function i(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,n=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(n)for(let l in n){let a=n[l];a&&i(l).handlers.push(l_(r.value,a))}if(o)for(let l in o){let a=o[l];a&&i(l).observers.push(l_(r.value,a))}}for(let r in Ei)i(r).handlers.push(Ei[r]);for(let r in Nt)i(r).observers.push(Nt[r]);return e}const Jy=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],u2="dthko",ew=[16,17,18,20,91,92,224,225],Sa=6;function ya(t){return Math.max(0,t)*.7+8}function f2(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class d2{constructor(e,i,r,s){this.view=e,this.startEvent=i,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=i,this.scrollParents=ky(e.contentDOM),this.atoms=e.state.facet(Il).map(o=>o(e));let n=e.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=i.shiftKey,this.multiple=e.state.facet(oe.allowMultipleSelections)&&p2(e,i),this.dragging=O2(e,i)&&rw(i)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&f2(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=0,n=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:n,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Yy(this.view);e.clientX-a.left<=s+Sa?i=-ya(s-e.clientX):e.clientX+a.right>=o-Sa&&(i=ya(e.clientX-o)),e.clientY-a.top<=n+Sa?r=-ya(n-e.clientY):e.clientY+a.bottom>=l-Sa&&(r=ya(e.clientY-l)),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,i){this.scrollSpeed={x:e,y:i},e||i?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:i}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),i&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=i,i=0),(e||i)&&this.view.win.scrollBy(e,i),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:i}=this,r=Hy(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(i.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(i=>i.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function p2(t,e){let i=t.state.facet(Ay);return i.length?i[0](e):W.mac?e.metaKey:e.ctrlKey}function g2(t,e){let i=t.state.facet(My);return i.length?i[0](e):W.mac?!e.altKey:!e.ctrlKey}function O2(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let r=Sl(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let n=0;n=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function m2(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,r;i!=t.contentDOM;i=i.parentNode)if(!i||i.nodeType==11||(r=Le.get(i))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Ei=Object.create(null),Nt=Object.create(null),tw=W.ie&&W.ie_version<15||W.ios&&W.webkit_version<604;function _2(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),iw(t,i.value)},50)}function zc(t,e,i){for(let r of t.facet(e))i=r(i,t);return i}function iw(t,e){e=zc(t.state,Wg,e);let{state:i}=t,r,s=1,n=i.toText(e),o=n.lines==i.selection.ranges.length;if(Ld!=null&&i.selection.ranges.every(a=>a.empty)&&Ld==n.toString()){let a=-1;r=i.changeByRange(h=>{let c=i.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let u=i.toText((o?n.line(s++).text:e)+i.lineBreak);return{changes:{from:c.from,insert:u},range:Q.cursor(h.from+u.length)}})}else o?r=i.changeByRange(a=>{let h=n.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:Q.cursor(a.from+h.length)}}):r=i.replaceSelection(n);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Nt.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Nt.wheel=Nt.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ei.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Nt.touchstart=(t,e)=>{let i=t.inputState,r=e.targetTouches[0];i.lastTouchTime=Date.now(),r&&(i.lastTouchX=r.clientX,i.lastTouchY=r.clientY),i.setSelectionOrigin("select.pointer")};Nt.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Ei.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let r of t.state.facet(Ly))if(i=r(t,e),i)break;if(!i&&e.button==0&&(i=S2(t,e)),i){let r=!t.hasFocus;t.inputState.startMouseSelection(new d2(t,e,i,r)),r&&t.observer.ignore(()=>{by(t.contentDOM);let n=t.root.activeElement;n&&!n.contains(t.contentDOM)&&n.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function a_(t,e,i,r){if(r==1)return Q.cursor(e,i);if(r==2)return H$(t.state,e,i);{let s=t.docView.lineAt(e,i),n=t.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:n.from,l=s?s.posAtEnd:n.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(c_+1)%3:1}function S2(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=rw(e),s=t.state.selection;return{update(n){n.docChanged&&(i.pos=n.changes.mapPos(i.pos),s=s.map(n.changes))},get(n,o,l){let a=t.posAndSideAtCoords({x:n.clientX,y:n.clientY},!1),h,c=a_(t,a.pos,a.assoc,r);if(i.pos!=a.pos&&!o){let u=a_(t,i.pos,i.assoc,r),f=Math.min(u.from,c.from),d=Math.max(u.to,c.to);c=f1&&(h=y2(s,a.pos))?h:l?s.addRange(c):Q.create([c])}}}function y2(t,e){for(let i=0;i=e)return Q.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}Ei.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let n=s.posAtStart,o=n+s.length;(n>=i.to||o<=i.from)&&(i=Q.range(n,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",zc(t.state,Ng,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ei.dragend=t=>(t.inputState.draggedContent=null,!1);function f_(t,e,i,r){if(i=zc(t.state,Wg,i),!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:n}=t.inputState,o=r&&n&&g2(t,e)?{from:n.from,to:n.to}:null,l={from:s,insert:i},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ei.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let r=Array(i.length),s=0,n=()=>{++s==i.length&&f_(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),n()},l.readAsText(i[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return f_(t,e,r,!0),!0}return!1};Ei.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=tw?null:e.clipboardData;return i?(iw(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(_2(t),!1)};function w2(t,e){let i=t.dom.parentNode;if(!i)return;let r=i.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function k2(t){let e=[],i=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let o=t.doc.lineAt(n);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}r=!0}return{text:zc(t,Ng,e.join(t.lineBreak)),ranges:i,linewise:r}}let Ld=null;Ei.copy=Ei.cut=(t,e)=>{if(!Yo(t.contentDOM,t.observer.selectionRange))return!1;let{text:i,ranges:r,linewise:s}=k2(t.state);if(!i&&!s)return!1;Ld=s?i:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let n=tw?null:e.clipboardData;return n?(n.clearData(),n.setData("text/plain",i),!0):(w2(t,i),!1)};const sw=br.define();function nw(t,e){let i=[];for(let r of t.facet(zy)){let s=r(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:sw.of(!0)}):null}function ow(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=nw(t.state,e);i?t.dispatch(i):t.update([])}},10)}Nt.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),ow(t)};Nt.blur=t=>{t.observer.clearSelectionRange(),ow(t)};Nt.compositionstart=Nt.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Nt.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,W.chrome&&W.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Nt.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ei.beforeinput=(t,e)=>{var i,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let n=(i=e.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(n&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),h=t.posAtDOM(l.endContainer,l.endOffset);return Yg(t,{from:a,to:h,insert:t.state.toText(n)},null),!0}}let s;if(W.chrome&&W.android&&(s=Jy.find(n=>n.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let n=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>n+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return W.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),W.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Nt.compositionend(t,e),20),!1};const d_=new Set;function b2(t){d_.has(t)||(d_.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const p_=["pre-wrap","normal","pre-line","break-spaces"];let Ln=!1;function g_(){Ln=!1}class x2{constructor(e){this.lineWrapping=e,this.doc=ne.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,i){let r=this.doc.lineAt(i).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((i-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return p_.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let i=!1;for(let r=0;r-1,a=Math.abs(i-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=i,this.charWidth=r,this.textHeight=s,this.lineLength=n,a){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>th&&(Ln=!0),this.height=e)}replace(e,i,r){return Qt.of(r)}decomposeLeft(e,i){i.push(this)}decomposeRight(e,i){i.push(this)}applyChanges(e,i,r,s){let n=this,o=r.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:u}=s[l],f=n.lineAt(a,_e.ByPosNoHeight,r.setDoc(i),0,0),d=f.to>=h?f:n.lineAt(h,_e.ByPosNoHeight,r,0,0);for(u+=d.to-h,h=d.to;l>0&&f.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,an*2){let l=e[i-1];l.break?e.splice(--i,1,l.left,null,l.right):e.splice(--i,1,l.left,l.right),r+=1+l.break,s-=l.size}else if(n>s*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,n-=l.size}else break;else if(s=n&&o(this.lineAt(0,_e.ByPos,r,s,n))}setMeasuredHeight(e){let i=e.heights[e.index++];i<0?(this.spaceAbove=-i,i=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(i)}updateHeight(e,i=0,r=!1,s){return s&&s.from<=i&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ht extends lw{constructor(e,i,r){super(e,i,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,i){return new xi(i,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,i,r){let s=r[0];return r.length==1&&(s instanceof Ht||s instanceof at&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof at?s=new Ht(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Qt.of(r)}updateHeight(e,i=0,r=!1,s){return s&&s.from<=i&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(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 at extends Qt{constructor(e){super(e,0)}heightMetrics(e,i){let r=e.doc.lineAt(i).number,s=e.doc.lineAt(i+this.length).number,n=s-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*n);o=a/n,this.length>n+1&&(l=(this.height-a)/(this.length-n-1))}else o=this.height/n;return{firstLine:r,lastLine:s,perLine:o,perChar:l}}blockAt(e,i,r,s){let{firstLine:n,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s);if(i.lineWrapping){let h=s+(e0){let n=r[r.length-1];n instanceof at?r[r.length-1]=new at(n.length+s):r.push(null,new at(s-1))}if(e>0){let n=r[0];n instanceof at?r[0]=new at(e+n.length):r.unshift(new at(e-1),null)}return Qt.of(r)}decomposeLeft(e,i){i.push(new at(e-1),null)}decomposeRight(e,i){i.push(null,new at(this.length-e-1))}updateHeight(e,i=0,r=!1,s){let n=i+this.length;if(s&&s.from<=i+this.length&&s.more){let o=[],l=Math.max(i,s.from),a=-1;for(s.from>i&&o.push(new at(s.from-i-1).updateHeight(e,i));l<=n&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let u=s.heights[s.index++],f=0;u<0&&(f=-u,u=s.heights[s.index++]),a==-1?a=u:Math.abs(u-a)>=th&&(a=-2);let d=new Ht(c,u,f);d.outdated=!1,o.push(d),l+=c+1}l<=n&&o.push(null,new at(n-l).updateHeight(e,l));let h=Qt.of(o);return(a<0||Math.abs(h.height-this.height)>=th||Math.abs(a-this.heightMetrics(e,i).perLine)>=th)&&(Ln=!0),Yh(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(i,i+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class $2 extends Qt{constructor(e,i,r){super(e.length+i+r.length,e.height+r.height,i|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,i,r,s){let n=r+this.left.height;return el))return h;let c=i==_e.ByPosNoHeight?_e.ByPosNoHeight:_e.ByPos;return a?h.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,s,n).join(h)}forEachLine(e,i,r,s,n,o){let l=s+this.left.height,a=n+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,i,r,l,a,o);else{let h=this.lineAt(a,_e.ByPos,r,s,n);e=e&&h.from<=i&&o(h),i>h.to&&this.right.forEachLine(h.to+1,i,r,l,a,o)}}replace(e,i,r){let s=this.left.length+this.break;if(ithis.left.length)return this.balanced(this.left,this.right.replace(e-s,i-s,r));let n=[];e>0&&this.decomposeLeft(e,n);let o=n.length;for(let l of r)n.push(l);if(e>0&&O_(n,o-1),i=r&&i.push(null)),e>r&&this.right.decomposeLeft(e-r,i)}decomposeRight(e,i){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,i);e2*i.size||i.size>2*e.size?Qt.of(this.break?[e,null,i]:[e,i]):(this.left=Yh(this.left,e),this.right=Yh(this.right,i),this.setHeight(e.height+i.height),this.outdated=e.outdated||i.outdated,this.size=e.size+i.size,this.length=e.length+this.break+i.length,this)}updateHeight(e,i=0,r=!1,s){let{left:n,right:o}=this,l=i+n.length+this.break,a=null;return s&&s.from<=i+n.length&&s.more?a=n=n.updateHeight(e,i,r,s):n.updateHeight(e,i,r),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,r,s):o.updateHeight(e,l,r),a?this.balanced(n,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function O_(t,e){let i,r;t[e]==null&&(i=t[e-1])instanceof at&&(r=t[e+1])instanceof at&&t.splice(e-1,3,new at(i.length+1+r.length))}const Q2=5;class qg{constructor(e,i){this.pos=e,this.oracle=i,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,i){if(this.lineStart>-1){let r=Math.min(i,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Ht?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Ht(r-this.pos,-1,0)),this.writtenTo=r,i>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=i}point(e,i,r){if(e=Q2)&&this.addLineDeco(s,n,o)}else i>e&&this.span(e,i);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:i}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=i,this.writtenToe&&this.nodes.push(new Ht(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,i){let r=new at(i-e);return this.oracle.doc.lineAt(e).to==i&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ht)return e;let i=new Ht(0,-1,0);return this.nodes.push(i),i}addBlock(e){this.enterLine();let i=e.deco;i&&i.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,i&&i.endSide>0&&(this.covering=e)}addLineDeco(e,i,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=i,this.writtenTo=this.pos=this.pos+r}finish(e){let i=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(i instanceof Ht)&&!this.isCovered?this.nodes.push(new Ht(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&u.overflow!="visible"){let f=c.getBoundingClientRect();n=Math.max(n,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(h==t.parentNode?s.innerHeight:a,f.bottom)}h=u.position=="absolute"||u.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:n-i.left,right:Math.max(n,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function A2(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function M2(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Lu{constructor(e,i,r,s){this.from=e,this.to=i,this.size=r,this.displaySize=s}static same(e,i){if(e.length!=i.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new x2(r),this.stateDeco=v_(i),this.heightMap=Qt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle.setDoc(i.doc),[new ci(0,0,0,i.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Se.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:i}=this.state.selection;for(let r=0;r<=1;r++){let s=r?i.head:i.anchor;if(!e.some(({from:n,to:o})=>s>=n&&s<=o)){let{from:n,to:o}=this.lineBlockAt(s);e.push(new wa(n,o))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?__:new Fg(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push($o(e,this.scaler))})}update(e,i=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=v_(this.state);let s=e.changedRanges,n=ci.extendWithRanges(s,T2(r,this.stateDeco,e?e.changes:Ue.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);g_(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=o||Ln)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=n.length?this.mapViewport(this.viewport,e.changes):this.viewport;(i&&(i.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,i));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),i&&(this.scrollTarget=i),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(C$)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,i=e.contentDOM,r=window.getComputedStyle(i),s=this.heightOracle,n=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Ye.RTL:Ye.LTR;let o=this.heightOracle.mustRefreshForWrapping(n)||this.mustMeasureContent==="refresh",l=i.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:w,scaleY:k}=wy(i,l);(w>.005&&Math.abs(this.scaleX-w)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=w,this.scaleY=k,h|=16,o=a=!0)}let u=(parseInt(r.paddingTop)||0)*this.scaleY,f=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=ky(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=xy(this.scrollParent||e.win);let g=(this.printing?M2:R2)(i,this.paddingTop),v=g.top-this.pixelViewport.top,O=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget&&!A2(e.dom))return 0;let _=l.width;if((this.contentDOMWidth!=_||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(w)&&(o=!0),o||s.lineWrapping&&Math.abs(_-this.contentDOMWidth)>s.charWidth){let{lineHeight:k,charWidth:x,textHeight:T}=e.docView.measureTextSize();o=k>0&&s.refresh(n,k,x,T,Math.max(5,_/x),w),o&&(e.docView.minWidth=0,h|=16)}v>0&&O>0?c=Math.max(v,O):v<0&&O<0&&(c=Math.min(v,O)),g_();for(let k of this.viewports){let x=k.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?Qt.empty().applyChanges(this.stateDeco,ne.empty,this.heightOracle,[new ci(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new C2(k.from,x))}Ln&&(h|=2)}let S=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return S&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||S)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,i){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,n=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new wa(s.lineAt(o-r*1e3,_e.ByHeight,n,0,0).from,s.lineAt(l+(1-r)*1e3,_e.ByHeight,n,0,0).to);if(i){let{head:h}=i.range;if(ha.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=s.lineAt(h,_e.ByPos,n,0,0),f;i.y=="center"?f=(u.top+u.bottom)/2-c/2:i.y=="start"||i.y=="nearest"&&h=l+Math.max(10,Math.min(r,250)))&&s>o-2*1e3&&n>1,o=s<<1;if(this.defaultTextDirection!=Ye.LTR&&!r)return[];let l=[],a=(c,u,f,d)=>{if(u-cc&&OO.from>=f.from&&O.to<=f.to&&Math.abs(O.from-c)O.fromm));if(!v){if(u_.from<=u&&_.to>=u)){let _=i.moveToLineBoundary(Q.cursor(u),!1,!0).head;_>c&&(u=_)}let O=this.gapSize(f,c,u,d),m=r||O<2e6?O:2e6;v=new Lu(c,u,O,m)}l.push(v)},h=c=>{if(c.length2e6)for(let k of e)k.from>=c.from&&k.fromc.from&&a(c.from,d,c,u),pi.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let i=this.stateDeco;this.lineGaps.length&&(i=i.concat(this.lineGapDeco));let r=[];fe.spans(i,this.viewport.from,this.viewport.to,{span(n,o){r.push({from:n,to:o})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let n=0;n=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(i=>i.from<=e&&i.to>=e)||$o(this.heightMap.lineAt(e,_e.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(i=>i.top<=e&&i.bottom>=e)||$o(this.heightMap.lineAt(this.scaler.fromDOM(e),_e.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let i=this.lineBlockAtHeight(e+8);return i.from>=this.viewport.from||this.viewportLines[0].top-e>200?i:this.viewportLines[0]}elementAtHeight(e){return $o(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 wa{constructor(e,i){this.from=e,this.to=i}}function D2(t,e,i){let r=[],s=t,n=0;return fe.spans(i,t,e,{span(){},point(o,l){o>s&&(r.push({from:s,to:o}),n+=o-s),s=l}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*i);for(let s=0;;s++){let{from:n,to:o}=e[s],l=o-n;if(r<=l)return n+r;r-=l}}function ba(t,e){let i=0;for(let{from:r,to:s}of t.ranges){if(e<=s){i+=e-r;break}i+=s-r}return i/t.total}function B2(t,e){for(let i of t)if(e(i))return i}const __={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function v_(t){let e=t.facet(Lc).filter(r=>typeof r!="function"),i=t.facet(Vg).filter(r=>typeof r!="function");return i.length&&e.push(fe.join(i)),e}class Fg{constructor(e,i,r){let s=0,n=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let h=i.lineAt(l,_e.ByPos,e,0,0).top,c=i.lineAt(a,_e.ByPos,e,0,0).bottom;return s+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(i.height-s);for(let l of this.viewports)l.domTop=o+(l.top-n)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),n=l.bottom}toDOM(e){for(let i=0,r=0,s=0;;i++){let n=ii.from==e.viewports[r].from&&i.to==e.viewports[r].to):!1}}function $o(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),r=e.toDOM(t.bottom);return new xi(t.from,t.length,i,r-i,Array.isArray(t._content)?t._content.map(s=>$o(s,e)):t._content)}const xa=H.define({combine:t=>t.join(" ")}),Dd=H.define({combine:t=>t.indexOf(!0)>-1}),Bd=Rn.newName(),aw=Rn.newName(),hw=Rn.newName(),cw={"&light":"."+aw,"&dark":"."+hw};function zd(t,e,i){return new Rn(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!i||!i[s])throw new RangeError(`Unsupported selector: ${s}`);return i[s]}):t+" "+r}})}const z2=zd("."+Bd,{"&":{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,overflowAnchor:"none"},".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:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".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",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&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-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},cw),Z2={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Du=W.ie&&W.ie_version<=11;class X2{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new p$,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.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(i=>{for(let r of i)this.queue.push(r);(W.ie&&W.ie_version<=11||W.ios&&e.composing)&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&W.android&&e.constructor.EDIT_CONTEXT!==!1&&!(W.chrome&&W.chrome_version<126)&&(this.editContext=new W2(e),e.state.facet(ar)&&(e.contentDOM.editContext=this.editContext.editContext)),Du&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var i;((i=this.view.docView)===null||i===void 0?void 0:i.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),i.length>0&&i[i.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(i=>{i.length>0&&i[i.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.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((i,r)=>i!=e[r]))){this.gapIntersection.disconnect();for(let i of e)this.gapIntersection.observe(i);this.gaps=e}}onSelectionChange(e){let i=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(ar)?r.root.activeElement!=this.dom:!Yo(this.dom,s))return;let n=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(n&&n.isWidget()&&n.widget.ignoreEvent(e)){i||(this.selectionChanged=!1);return}(W.ie&&W.ie_version<=11||W.android&&W.chrome)&&!r.state.selection.main.empty&&s.focusNode&&qo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,i=Sl(e.root);if(!i)return!1;let r=W.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&I2(this.view,i)||i;if(!r||this.selectionRange.eq(r))return!1;let s=Yo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let n=this.delayedAndroidKey;n&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=n.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&n.force&&Sn(this.dom,n.key,n.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:i,force:this.lastChange{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 i=-1,r=-1,s=!1;for(let n of e){let o=this.readMutation(n);o&&(o.typeOver&&(s=!0),i==-1?{from:i,to:r}=o:(i=Math.min(o.from,i),r=Math.max(o.to,r)))}return{from:i,to:r,typeOver:s}}readChange(){let{from:e,to:i,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Yo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new n2(this.view,e,i,r);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let r=this.view.state,s=Gy(this.view,i);return this.view.state==r&&(i.domChanged||i.newSel&&!Vh(this.view.state.selection,i.newSel.main))&&this.view.update([]),s}readMutation(e){let i=this.view.docView.tile.nearest(e.target);if(!i||i.isWidget())return null;if(i.markDirty(e.type=="attributes"),e.type=="childList"){let r=S_(i,e.previousSibling||e.target.previousSibling,-1),s=S_(i,e.nextSibling||e.target.nextSibling,1);return{from:r?i.posAfter(r):i.posAtStart,to:s?i.posBefore(s):i.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:i.posAtStart,to:i.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),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):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),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ar)!=e.state.facet(ar)&&(e.view.contentDOM.editContext=e.state.facet(ar)?this.editContext.editContext:null))}destroy(){var e,i,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(i=this.gapIntersection)===null||i===void 0||i.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function S_(t,e,i){for(;e;){let r=Le.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function y_(t,e){let i=e.startContainer,r=e.startOffset,s=e.endContainer,n=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return qo(o.node,o.offset,s,n)&&([i,r,s,n]=[s,n,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:n}}function I2(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return y_(t,s)}let i=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),i=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),i?y_(t,i):null}class W2{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let i=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:n,head:o}=s,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>r.text.length;l==this.from&&nthis.to&&(a=n);let c=Ky(e.state.sliceDoc(l,a),r.text,(h?s.from:s.to)-l,h?"end":null);if(!c){let f=Q.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Vh(f,s)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:c.from+l,to:c.toA+l,insert:ne.of(r.text.slice(c.from,c.toB).split(` +`))};if((W.mac||W.android)&&u.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:ne.of([r.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);Yg(e,u,Q.single(this.toEditorPos(r.selectionStart,f),this.toEditorPos(r.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(i.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(i.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],n=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let s=[];for(let n of r.getTextFormats()){let o=n.underlineStyle,l=n.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(n.rangeStart),h=this.toEditorPos(n.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)i.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let s=Sl(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let i=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((n,o,l,a,h)=>{if(r)return;let c=h.length-(o-n);if(s&&o>=s.to)if(s.from==n&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,i+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(n+=i,o+=i,o<=this.from)this.from+=c,this.to+=c;else if(nthis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(o),h.toString()),this.to+=c}i+=c}),s&&!r&&this.revertPending(e.state),!r}update(e){let i=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||i)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:i}=e.selection.main;this.from=Math.max(0,i-1e4),this.to=Math.min(e.doc.length,i+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let i=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(i.from),this.toContextPos(i.from+i.insert.length),e.doc.sliceString(i.from,i.to))}setSelection(e){let{main:i}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,i.anchor))),s=this.toContextPos(i.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:i}=e.selection.main;return!(this.from>0&&i-this.from<500||this.to1e4*3)}toEditorPos(e,i=this.to-this.from){e=Math.min(e,i);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let i=this.composing;return i&&i.drifted?i.contextBase+(e-i.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class F{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var i;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(n=>r(n,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||g$(e.parent)||document,this.viewState=new m_(this,e.state||oe.create(e)),e.scrollTo&&e.scrollTo.is(va)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ln).map(s=>new Tu(s));for(let s of this.plugins)s.update(this);this.observer=new X2(this),this.inputState=new h2(this),this.inputState.ensureHandlers(this.plugins),this.docView=new s_(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((i=document.fonts)===null||i===void 0)&&i.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let i=e.length==1&&e[0]instanceof Ve?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(i,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let i=!1,r=!1,s,n=this.state;for(let f of e){if(f.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=f.state}if(this.destroyed){this.viewState.state=n;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(sw))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=nw(n,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(c=null)):this.observer.clear(),n.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(n);s=Wh.create(this,n,e),s.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:g}=this.state.facet(F.cursorScrollMargin);u=new yn(d.empty?d:Q.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of f.effects)d.is(va)&&(u=d.value.clip(this.state))}this.viewState.update(s,u),this.bidiCache=qh.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),i=this.docView.update(s),this.state.facet(Po)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(xa)!=s.state.facet(xa)&&(this.viewState.mustMeasureContent=!0),(i||r||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(Rd))try{f(s)}catch(d){qi(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Gy(this,c)&&h.force&&Sn(this.contentDOM,h.key,h.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 i=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new m_(this,e),this.plugins=e.facet(ln).map(r=>new Tu(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new s_(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}i&&this.focus(),this.requestMeasure()}updatePlugins(e){let i=e.startState.facet(ln),r=e.state.facet(ln);if(i!=r){let s=[];for(let n of r){let o=i.indexOf(n);if(o<0)s.push(new Tu(n));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let n of this.plugins)n.mustUpdate!=e&&n.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let i=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(xy(r||this.win))n=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);n=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!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 h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return qi(this.state,p),w_}}),u=Wh.create(this,this.state,[]),f=!1;u.flags|=a,i?i.flags|=a:i=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d1||p<-1)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,r?r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(i&&!i.empty)for(let l of this.state.facet(Rd))l(i)}get themeClasses(){return Bd+" "+(this.state.facet(Dd)?hw:aw)+" "+this.state.facet(xa)}updateAttrs(){let e=k_(this,Wy,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),i={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ar)?"true":"false",class:"cm-content",style:`${W.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(i["aria-readonly"]="true"),k_(this,jg,i);let r=this.observer.ignore(()=>{let s=Km(this.contentDOM,this.contentAttrs,i),n=Km(this.dom,this.editorAttrs,e);return s||n});return this.editorAttrs=e,this.contentAttrs=i,r}showAnnouncements(e){let i=!0;for(let r of e)for(let s of r.effects)if(s.is(F.announce)){i&&(this.announceDOM.textContent=""),i=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Po);let e=this.state.facet(F.cspNonce);Rn.mount(this.root,this.styleModules.concat(z2).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 i=0;ir.plugin==e)||null),i&&i.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,i,r){return Mu(this,e,n_(this,e,i,r))}moveByGroup(e,i){return Mu(this,e,n_(this,e,i,r=>J$(this,e.head,r)))}visualLineSide(e,i){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),n=r[i?r.length-1:0];return Q.cursor(n.side(i,s)+e.from,n.forward(!i,s)?1:-1)}moveToLineBoundary(e,i,r=!0){return K$(this,e,i,r)}moveVertically(e,i,r){return Mu(this,e,e2(this,e,i,r))}domAtPos(e,i=1){return this.docView.domAtPos(e,i)}posAtDOM(e,i=0){return this.docView.posFromDOM(e,i)}posAtCoords(e,i=!0){this.readMeasured();let r=Md(this,e,i);return r&&r.pos}posAndSideAtCoords(e,i=!0){return this.readMeasured(),Md(this,e,i)}coordsAtPos(e,i=1){this.readMeasured();let r=this.docView.coordsAt(e,i);if(!r||r.left==r.right)return r;let s=this.state.doc.lineAt(e),n=this.bidiSpans(s),o=n[Yi.find(n,e-s.from,-1,i)];return Ih(r,o.dir==Ye.LTR==i>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(Zy)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>N2)return Ey(e.length);let i=this.textDirectionAt(e.from),r;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==i&&(n.fresh||Ty(n.isolates,r=t_(this,e))))return n.order;r||(r=t_(this,e));let s=k$(e.text,i,r);return this.bidiCache.push(new qh(e.from,e.to,i,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||W.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{by(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(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();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,i={}){var r,s,n,o;return va.of(new yn(typeof e=="number"?Q.cursor(e):e,(r=i.y)!==null&&r!==void 0?r:"nearest",(s=i.x)!==null&&s!==void 0?s:"nearest",(n=i.yMargin)!==null&&n!==void 0?n:5,(o=i.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:i}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return va.of(new yn(Q.cursor(r.from),"start","start",r.top-e,i,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ds.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ds.define(()=>({}),{eventObservers:e})}static theme(e,i){let r=Rn.newName(),s=[xa.of(r),Po.of(zd(`.${r}`,e))];return i&&i.dark&&s.push(Dd.of(!0)),s}static baseTheme(e){return Rc.lowest(Po.of(zd("."+Bd,e,cw)))}static findFromDOM(e){var i;let r=e.querySelector(".cm-content"),s=r&&Le.get(r)||Le.get(e);return((i=s==null?void 0:s.root)===null||i===void 0?void 0:i.view)||null}}F.styleModule=Po;F.inputHandler=By;F.clipboardInputFilter=Wg;F.clipboardOutputFilter=Ng;F.scrollHandler=Xy;F.focusChangeEffect=zy;F.perLineTextDirection=Zy;F.exceptionSink=Dy;F.updateListener=Rd;F.editable=ar;F.mouseSelectionStyle=Ly;F.dragMovesSelection=My;F.clickAddsSelectionRange=Ay;F.decorations=Lc;F.blockWrappers=Ny;F.outerDecorations=Vg;F.atomicRanges=Il;F.bidiIsolatedRanges=jy;F.cursorScrollMargin=H.define({combine:t=>{let e=5,i=5;for(let r of t)typeof r=="number"?e=i=r:{x:e,y:i}=r;return{x:e,y:i}}});F.scrollMargins=Vy;F.darkTheme=Dd;F.cspNonce=H.define({combine:t=>t.length?t[0]:""});F.contentAttributes=jg;F.editorAttributes=Wy;F.lineWrapping=F.contentAttributes.of({class:"cm-lineWrapping"});F.announce=Ce.define();const N2=4096,w_={};class qh{constructor(e,i,r,s,n,o){this.from=e,this.to=i,this.dir=r,this.isolates=s,this.fresh=n,this.order=o}static update(e,i){if(i.empty&&!e.some(n=>n.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Ye.LTR;for(let n=Math.max(0,e.length-10);n=0;s--){let n=r[s],o=typeof n=="function"?n(t):n;o&&Zg(o,i)}return i}const j2=W.mac?"mac":W.windows?"win":W.linux?"linux":"key";function V2(t,e){const i=t.split(/-(?!$)/);let r=i[i.length-1];r=="Space"&&(r=" ");let s,n,o,l;for(let a=0;ar.concat(s),[]))),i}let Ir=null;const F2=4e3;function H2(t,e=j2){let i=Object.create(null),r=Object.create(null),s=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},n=(o,l,a,h,c)=>{var u,f;let d=i[o]||(i[o]=Object.create(null)),p=l.split(/ (?!$)/).map(O=>V2(O,e));for(let O=1;O{let S=Ir={view:_,prefix:m,scope:o};return setTimeout(()=>{Ir==S&&(Ir=null)},F2),!0}]})}let g=p.join(" ");s(g,!1);let v=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});a&&v.run.push(a),h&&(v.preventDefault=!0),c&&(v.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=i[h]||(i[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in c)c[f].run.push(d=>u(d,Zd))}let a=o[e]||o.key;if(a)for(let h of l)n(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&n(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return i}let Zd=null;function U2(t,e,i,r){Zd=e;let s=l$(e),n=WP(s,0),o=NP(n)==s.length&&s!=" ",l="",a=!1,h=!1,c=!1;Ir&&Ir.view==i&&Ir.scope==r&&(l=Ir.prefix+" ",ew.indexOf(e.keyCode)<0&&(h=!0,Ir=null));let u=new Set,f=v=>{if(v){for(let O of v.run)if(!u.has(O)&&(u.add(O),O(i)))return v.stopPropagation&&(c=!0),!0;v.preventDefault&&(v.stopPropagation&&(c=!0),h=!0)}return!1},d=t[r],p,g;return d&&(f(d[l+Ca(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(W.windows&&e.ctrlKey&&e.altKey)&&!(W.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ss[e.keyCode])&&p!=s?(f(d[l+Ca(p,e,!0)])||e.shiftKey&&(g=_l[e.keyCode])!=s&&g!=p&&f(d[l+Ca(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+Ca(s,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),Zd=null,a}class Dn extends rs{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Dn.prototype.elementClass="";Dn.prototype.toDOM=void 0;Dn.prototype.mapMode=Pt.TrackBefore;Dn.prototype.startSide=Dn.prototype.endSide=-1;Dn.prototype.point=!0;const uw=1024;let G2=0;class ui{constructor(e,i){this.from=e,this.to=i}}class G{constructor(e={}){this.id=G2++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ke.match(e)),i=>{let r=e(i);return r===void 0?null:[this,r]}}}G.closedBy=new G({deserialize:t=>t.split(" ")});G.openedBy=new G({deserialize:t=>t.split(" ")});G.group=new G({deserialize:t=>t.split(" ")});G.isolate=new G({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});G.contextHash=new G({perNode:!0});G.lookAhead=new G({perNode:!0});G.mounted=new G({perNode:!0});class wn{constructor(e,i,r,s=!1){this.tree=e,this.overlay=i,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[G.mounted.id]}}const K2=Object.create(null);class Ke{constructor(e,i,r,s=0){this.name=e,this.props=i,this.id=r,this.flags=s}static define(e){let i=e.props&&e.props.length?Object.create(null):K2,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Ke(e.name||"",i,e.id,r);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(s)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");i[n[0].id]=n[1]}}return s}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 i=this.prop(G.group);return i?i.indexOf(e)>-1:!1}return this.id==e}static match(e){let i=Object.create(null);for(let r in e)for(let s of r.split(" "))i[s]=e[r];return r=>{for(let s=r.prop(G.group),n=-1;n<(s?s.length:0);n++){let o=i[n<0?r.name:s[n]];if(o)return o}}}}Ke.none=new Ke("",Object.create(null),0,8);class Wl{constructor(e){this.types=e;for(let i=0;i0;for(let a=this.cursor(o|he.IncludeAnonymous);;){let h=!1;if(a.from<=n&&a.to>=s&&(!l&&a.type.isAnonymous||i(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;h=!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 i in this.props)e.push([+i,this.props[i]]);return e}balance(e={}){return this.children.length<=8?this:Gg(Ke.none,this.children,this.positions,0,this.children.length,0,this.length,(i,r,s)=>new le(this.type,i,r,s,this.propValues),e.makeTree||((i,r,s)=>new le(Ke.none,i,r,s)))}static build(e){return iQ(e)}}le.empty=new le(Ke.none,[],[],0);class Hg{constructor(e,i){this.buffer=e,this.index=i}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 Hg(this.buffer,this.index)}}class os{constructor(e,i,r){this.buffer=e,this.length=i,this.set=r}get type(){return Ke.none}toString(){let e=[];for(let i=0;i0));a=o[a+3]);return l}slice(e,i,r){let s=this.buffer,n=new Uint16Array(i-e),o=0;for(let l=e,a=0;l=e&&ie;case 1:return i<=e&&r>e;case 2:return r>e;case 4:return!0}}function wl(t,e,i,r){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?l.length:-1;e!=h;e+=i){let c=l[e],u=a[e]+o.from,f;if(!(!(n&he.EnterBracketed&&c instanceof le&&(f=wn.get(c))&&!f.overlay&&f.bracketed&&r>=u&&r<=u+c.length)&&!fw(s,r,u,u+c.length))){if(c instanceof os){if(n&he.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,i,r-u,s);if(d>-1)return new Fi(new J2(o,c,e,u),null,d)}else if(n&he.IncludeAnonymous||!c.type.isAnonymous||Ug(c)){let d;if(!(n&he.IgnoreMounts)&&(d=wn.get(c))&&!d.overlay)return new St(d.tree,u,e,o);let p=new St(c,u,e,o);return n&he.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(i<0?c.children.length-1:0,i,r,s,n)}}}if(n&he.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+i:e=i<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)}prop(e){return this._tree.prop(e)}enter(e,i,r=0){let s;if(!(r&he.IgnoreOverlays)&&(s=wn.get(this._tree))&&s.overlay){let n=e-this.from,o=r&he.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((i>0||o?l<=n:l=n:a>n))return new St(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,i,r)}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 C_(t,e,i,r){let s=t.cursor(),n=[];if(!s.firstChild())return n;if(i!=null){for(let o=!1;!o;)if(o=s.type.is(i),!s.nextSibling())return n}for(;;){if(r!=null&&s.type.is(r))return n;if(s.type.is(e)&&n.push(s.node),!s.nextSibling())return r==null?n:[]}}function Xd(t,e,i=e.length-1){for(let r=t;i>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}class J2{constructor(e,i,r,s){this.parent=e,this.buffer=i,this.index=r,this.start=s}}class Fi extends dw{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,i,r){super(),this.context=e,this._parent=i,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,i,r){let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e,i-this.context.start,r);return n<0?null:new Fi(this.context,this,n)}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)}prop(e){return this.type.prop(e)}enter(e,i,r=0){if(r&he.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],i>0?1:-1,e-this.context.start,i);return n<0?null:new Fi(this.context,this,n)}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,i=e.buffer[this.index+3];return i<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Fi(this.context,this._parent,i):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,i=this._parent?this._parent.index+4:0;return this.index==i?this.externalSibling(-1):new Fi(this.context,this._parent,e.findChild(i,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],i=[],{buffer:r}=this.context,s=this.index+4,n=r.buffer[this.index+3];if(n>s){let o=r.buffer[this.index+1];e.push(r.slice(s,n,o)),i.push(0)}return new le(this.type,e,i,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function pw(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;ni.from||o.to=e){let l=new St(o.tree,o.overlay[0].from+n.from,-1,n);(s||(s=[r])).push(wl(l,e,i,!1))}}return s?pw(s):r}class Fh{get name(){return this.type.name}constructor(e,i=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=i&~he.EnterBracketed,e instanceof St)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,i){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=i||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof St?(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,i,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,i,r,this.mode));let{buffer:s}=this.buffer,n=s.findChild(this.index+4,s.buffer[this.index+3],e,i-this.buffer.start,r);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}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,i,r=this.mode){return this.buffer?r&he.ExcludeBuffers?!1:this.enterChild(1,e,i):this.yield(this._tree.enter(e,i,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&he.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&he.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:i}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(i.findChild(s,this.index,-1,0,4))}else{let s=i.buffer[this.index+3];if(s<(r<0?i.buffer.length:i.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 i,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let n=i+e,o=e<0?-1:r._tree.children.length;n!=o;n+=e){let l=r._tree.children[n];if(this.mode&he.IncludeAnonymous||l instanceof os||!l.type.isAnonymous||Ug(l))return!1}return!0}move(e,i){if(i&&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,i=0){for(;(this.from==this.to||(i<1?this.from>=e:this.from>e)||(i>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;i=o,r=n+1;break e}s=this.stack[--n]}for(let s=r;s=0;n--){if(n<0)return Xd(this._tree,e,s);let o=r[i.buffer[this.stack[n]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function Ug(t){return t.children.some(e=>e instanceof os||!e.type.isAnonymous||Ug(e))}function iQ(t){var e;let{buffer:i,nodeSet:r,maxBufferLength:s=uw,reused:n=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(i)?new Hg(i,i.length):i,a=r.types,h=0,c=0;function u(w,k,x,T,N,j){let{id:X,start:$,end:C,size:R}=l,A=c,z=h;if(R<0)if(l.next(),R==-1){let K=n[X];x.push(K),T.push($-w);return}else if(R==-3){h=X;return}else if(R==-4){c=X;return}else throw new RangeError(`Unrecognized record size: ${R}`);let q=a[X],b,B,V=$-w;if(C-$<=s&&(B=v(l.pos-k,N))){let K=new Uint16Array(B.size-B.skip),J=l.pos-B.size,pe=K.length;for(;l.pos>J;)pe=O(B.start,K,pe);b=new os(K,C-B.start,r),V=B.start-w}else{let K=l.pos-R;l.next();let J=[],pe=[],ae=X>=o?X:-1,Be=0,ye=C;for(;l.pos>K;)ae>=0&&l.id==ae&&l.size>=0?(l.end<=ye-s&&(p(J,pe,$,Be,l.end,ye,ae,A,z),Be=J.length,ye=l.end),l.next()):j>2500?f($,K,J,pe):u($,K,J,pe,ae,j+1);if(ae>=0&&Be>0&&Be-1&&Be>0){let kt=d(q,z);b=Gg(q,J,pe,0,J.length,0,C-$,kt,kt)}else b=g(q,J,pe,C-$,A-C,z)}x.push(b),T.push(V)}function f(w,k,x,T){let N=[],j=0,X=-1;for(;l.pos>k;){let{id:$,start:C,end:R,size:A}=l;if(A>4)l.next();else{if(X>-1&&C=0;R-=3)$[A++]=N[R],$[A++]=N[R+1]-C,$[A++]=N[R+2]-C,$[A++]=A;x.push(new os($,N[2]-C,r)),T.push(C-w)}}function d(w,k){return(x,T,N)=>{let j=0,X=x.length-1,$,C;if(X>=0&&($=x[X])instanceof le){if(!X&&$.type==w&&$.length==N)return $;(C=$.prop(G.lookAhead))&&(j=T[X]+$.length+C)}return g(w,x,T,N,j,k)}}function p(w,k,x,T,N,j,X,$,C){let R=[],A=[];for(;w.length>T;)R.push(w.pop()),A.push(k.pop()+x-N);w.push(g(r.types[X],R,A,j-N,$-j,C)),k.push(N-x)}function g(w,k,x,T,N,j,X){if(j){let $=[G.contextHash,j];X=X?[$].concat(X):[$]}if(N>25){let $=[G.lookAhead,N];X=X?[$].concat(X):[$]}return new le(w,k,x,T,X)}function v(w,k){let x=l.fork(),T=0,N=0,j=0,X=x.end-s,$={size:0,start:0,skip:0};e:for(let C=x.pos-w;x.pos>C;){let R=x.size;if(x.id==k&&R>=0){$.size=T,$.start=N,$.skip=j,j+=4,T+=4,x.next();continue}let A=x.pos-R;if(R<0||A=o?4:0,q=x.start;for(x.next();x.pos>A;){if(x.size<0)if(x.size==-3||x.size==-4)z+=4;else break e;else x.id>=o&&(z+=4);x.next()}N=q,T+=R,j+=z}return(k<0||T==w)&&($.size=T,$.start=N,$.skip=j),$.size>4?$:void 0}function O(w,k,x){let{id:T,start:N,end:j,size:X}=l;if(l.next(),X>=0&&T4){let C=l.pos-(X-4);for(;l.pos>C;)x=O(w,k,x)}k[--x]=$,k[--x]=j-w,k[--x]=N-w,k[--x]=T}else X==-3?h=T:X==-4&&(c=T);return x}let m=[],_=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,m,_,-1,0);let S=(e=t.length)!==null&&e!==void 0?e:m.length?_[0]+m[0].length:0;return new le(a[t.topID],m.reverse(),_.reverse(),S)}const P_=new WeakMap;function ih(t,e){if(!t.isAnonymous||e instanceof os||e.type!=t)return 1;let i=P_.get(e);if(i==null){i=1;for(let r of e.children){if(r.type!=t||!(r instanceof le)){i=1;break}i+=ih(t,r)}P_.set(e,i)}return i}function Gg(t,e,i,r,s,n,o,l,a){let h=0;for(let p=r;p=c)break;k+=x}if(_==S+1){if(k>c){let x=p[S];d(x.children,x.positions,0,x.children.length,g[S]+m);continue}u.push(p[S])}else{let x=g[_-1]+p[_-1].length-w;u.push(Gg(t,p,g,S,_,w,x,null,a))}f.push(w+m-n)}}return d(e,i,r,s,0),(l||a)(u,f,o)}class gw{constructor(){this.map=new WeakMap}setBuffer(e,i,r){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(i,r)}getBuffer(e,i){let r=this.map.get(e);return r&&r.get(i)}set(e,i){e instanceof Fi?this.setBuffer(e.context.buffer,e.index,i):e instanceof St&&this.map.set(e.tree,i)}get(e){return e instanceof Fi?this.getBuffer(e.context.buffer,e.index):e instanceof St?this.map.get(e.tree):void 0}cursorSet(e,i){e.buffer?this.setBuffer(e.buffer.buffer,e.index,i):this.map.set(e.tree,i)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class gr{constructor(e,i,r,s,n=!1,o=!1){this.from=e,this.to=i,this.tree=r,this.offset=s,this.open=(n?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,i=[],r=!1){let s=[new gr(0,e.length,e,0,!1,r)];for(let n of i)n.to>e.length&&s.push(n);return s}static applyChanges(e,i,r=128){if(!i.length)return e;let s=[],n=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=r)for(;o&&o.from=f.from||u<=f.to||h){let d=Math.max(f.from,a)-h,p=Math.min(f.to,u)-h;f=d>=p?null:new gr(d,p,f.tree,f.offset+h,l>0,!!c)}if(f&&s.push(f),o.to>u)break;o=nnew ui(s.from,s.to)):[new ui(0,0)]:[new ui(0,e.length)],this.createParse(e,i||[],r)}parse(e,i,r){let s=this.startParse(e,i,r);for(;;){let n=s.advance();if(n)return n}}}class rQ{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,i){return this.string.slice(e,i)}}function Ow(t){return(e,i,r,s)=>new nQ(e,t,i,r,s)}class $_{constructor(e,i,r,s,n,o){this.parser=e,this.parse=i,this.overlay=r,this.bracketed=s,this.target=n,this.from=o}}function Q_(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class sQ{constructor(e,i,r,s,n,o,l,a){this.parser=e,this.predicate=i,this.mounts=r,this.index=s,this.start=n,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Id=new G({perNode:!0});class nQ{constructor(e,i,r,s,n){this.nest=i,this.input=r,this.fragments=s,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new le(r.type,r.children,r.positions,r.length,r.propValues.concat([[Id,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],i=e.parse.advance();if(i){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[G.mounted.id]=new wn(i,e.overlay,e.parser,e.bracketed),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let i=this.innerDone;i=this.stoppedAt)l=!1;else if(e.hasNode(s)){if(i){let h=i.mounts.find(c=>c.frag.from<=s.from&&c.frag.to>=s.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let u=c.from+h.pos,f=c.to+h.pos;u>=s.from&&f<=s.to&&!i.ranges.some(d=>d.fromu)&&i.ranges.push({from:u,to:f})}}l=!1}else if(r&&(o=oQ(r.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&(n=this.nest(s,this.input))&&(s.fromnew ui(u.from-s.from,u.to-s.from)):null,!!n.bracketed,s.tree,c.length?c[0].from:s.from)),n.overlay?c.length&&(r={ranges:c,depth:0,prev:r}):l=!1}}else if(i&&(a=i.predicate(s))&&(a===!0&&(a=new ui(s.from,s.to)),a.from=0&&i.ranges[h].to==a.from?i.ranges[h]={from:i.ranges[h].from,to:a.to}:i.ranges.push(a)}if(l&&s.firstChild())i&&i.depth++,r&&r.depth++;else for(;!s.nextSibling();){if(!s.parent())break e;if(i&&!--i.depth){let h=R_(this.ranges,i.ranges);h.length&&(Q_(h),this.inner.splice(i.index,0,new $_(i.parser,i.parser.startParse(this.input,A_(i.mounts,h),h),i.ranges.map(c=>new ui(c.from-i.start,c.to-i.start)),i.bracketed,i.target,h[0].from))),i=i.prev}r&&!--r.depth&&(r=r.prev)}}}}function oQ(t,e,i){for(let r of t){if(r.from>=i)break;if(r.to>e)return r.from<=e&&r.to>=i?2:1}return 0}function T_(t,e,i,r,s,n){if(e=e&&i.enter(r,1,he.IgnoreOverlays|he.ExcludeBuffers)))if(i.to<=e)i.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let i=this.cursor.tree;;){if(i==e.tree)return!0;if(i.children.length&&i.positions[0]==0&&i.children[0]instanceof le)i=i.children[0];else break}return!1}}let aQ=class{constructor(e){var i;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(i=r.tree.prop(Id))!==null&&i!==void 0?i:r.to,this.inner=new E_(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let i=this.curFrag=this.fragments[this.fragI];this.curTo=(e=i.tree.prop(Id))!==null&&e!==void 0?e:i.to,this.inner=new E_(i.tree,-i.offset)}}findMounts(e,i){var r;let s=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let o=(r=n.tree)===null||r===void 0?void 0:r.prop(G.mounted);if(o&&o.parser==i)for(let l=this.fragI;l=n.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:n.from-a.offset,mount:o})}}}return s}};function R_(t,e){let i=null,r=e;for(let s=1,n=0;s=l)break;a.to<=o||(i||(r=i=e.slice()),a.froml&&i.splice(n+1,0,new ui(l,a.to))):a.to>l?i[n--]=new ui(l,a.to):i.splice(n--,1))}}return r}function hQ(t,e,i,r){let s=0,n=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=s==t.length?1e9:o?t[s].to:t[s].from,u=n==e.length?1e9:l?e[n].to:e[n].from;if(o!=l){let f=Math.max(a,i),d=Math.min(c,u,r);fnew ui(f.from+r,f.to+r)),u=hQ(e,c,a,h);for(let f=0,d=a;;f++){let p=f==u.length,g=p?h:u[f].from;if(g>d&&i.push(new gr(d,g,s.tree,-o,n.from>=d||n.openStart,n.to<=g||n.openEnd)),p)break;d=u[f].to}}else i.push(new gr(a,h,s.tree,-o,n.from>=o||n.openStart,n.to<=l||n.openEnd))}return i}let cQ=0;class Gt{constructor(e,i,r,s){this.name=e,this.set=i,this.base=r,this.modified=s,this.id=cQ++}toString(){let{name:e}=this;for(let i of this.modified)i.name&&(e=`${i.name}(${e})`);return e}static define(e,i){let r=typeof e=="string"?e:"?";if(e instanceof Gt&&(i=e),i!=null&&i.base)throw new Error("Can not derive from a modified tag");let s=new Gt(r,[],null,[]);if(s.set.push(s),i)for(let n of i.set)s.set.push(n);return s}static defineModifier(e){let i=new Hh(e);return r=>r.modified.indexOf(i)>-1?r:Hh.get(r.base||r,r.modified.concat(i).sort((s,n)=>s.id-n.id))}}let uQ=0;class Hh{constructor(e){this.name=e,this.instances=[],this.id=uQ++}static get(e,i){if(!i.length)return e;let r=i[0].instances.find(l=>l.base==e&&fQ(i,l.modified));if(r)return r;let s=[],n=new Gt(e.name,s,e,i);for(let l of i)l.instances.push(n);let o=dQ(i);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(Hh.get(l,a));return n}}function fQ(t,e){return t.length==e.length&&t.every((i,r)=>i==e[r])}function dQ(t){let e=[[]];for(let i=0;ir.length-i.length)}function Fn(t){let e=Object.create(null);for(let i in t){let r=t[i];Array.isArray(r)||(r=[r]);for(let s of i.split(" "))if(s){let n=[],o=2,l=s;for(let u=0;;){if(l=="..."&&u>0&&u+3==s.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+s);if(n.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==s.length)break;let d=s[u++];if(u==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(u)}let a=n.length-1,h=n[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new Uh(r,o,a>0?n.slice(0,a):null);e[h]=c.sort(e[h])}}return pQ.add(e)}const pQ=new G({combine(t,e){let i,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),i&&i.mode==s.mode&&!s.context&&!i.context)continue;let n=new Uh(s.tags,s.mode,s.context);i?i.next=n:r=n,i=n}return r}});class Uh{constructor(e,i,r,s){this.tags=e,this.mode=i,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let l of n)for(let a of l.set){let h=i[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:r}}const D=Gt.define,$a=D(),Dr=D(),M_=D(Dr),L_=D(Dr),Br=D(),Qa=D(Br),Bu=D(Br),Xi=D(),us=D(Xi),Di=D(),Bi=D(),Wd=D(),co=D(Wd),Ta=D(),y={comment:$a,lineComment:D($a),blockComment:D($a),docComment:D($a),name:Dr,variableName:D(Dr),typeName:M_,tagName:D(M_),propertyName:L_,attributeName:D(L_),className:D(Dr),labelName:D(Dr),namespace:D(Dr),macroName:D(Dr),literal:Br,string:Qa,docString:D(Qa),character:D(Qa),attributeValue:D(Qa),number:Bu,integer:D(Bu),float:D(Bu),bool:D(Br),regexp:D(Br),escape:D(Br),color:D(Br),url:D(Br),keyword:Di,self:D(Di),null:D(Di),atom:D(Di),unit:D(Di),modifier:D(Di),operatorKeyword:D(Di),controlKeyword:D(Di),definitionKeyword:D(Di),moduleKeyword:D(Di),operator:Bi,derefOperator:D(Bi),arithmeticOperator:D(Bi),logicOperator:D(Bi),bitwiseOperator:D(Bi),compareOperator:D(Bi),updateOperator:D(Bi),definitionOperator:D(Bi),typeOperator:D(Bi),controlOperator:D(Bi),punctuation:Wd,separator:D(Wd),bracket:co,angleBracket:D(co),squareBracket:D(co),paren:D(co),brace:D(co),content:Xi,heading:us,heading1:D(us),heading2:D(us),heading3:D(us),heading4:D(us),heading5:D(us),heading6:D(us),contentSeparator:D(Xi),list:D(Xi),quote:D(Xi),emphasis:D(Xi),strong:D(Xi),link:D(Xi),monospace:D(Xi),strikethrough:D(Xi),inserted:D(),deleted:D(),changed:D(),invalid:D(),meta:Ta,documentMeta:D(Ta),annotation:D(Ta),processingInstruction:D(Ta),definition:Gt.defineModifier("definition"),constant:Gt.defineModifier("constant"),function:Gt.defineModifier("function"),standard:Gt.defineModifier("standard"),local:Gt.defineModifier("local"),special:Gt.defineModifier("special")};for(let t in y){let e=y[t];e instanceof Gt&&(e.name=t)}gQ([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var zu;const an=new G;function Jg(t){return H.define({combine:t?e=>e.concat(t):void 0})}const eO=new G;class Pi{constructor(e,i,r=[],s=""){this.data=e,this.name=s,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return Ie(this)}}),this.parser=i,this.extension=[Zn.of(this),oe.languageData.of((n,o,l)=>{let a=D_(n,o,l),h=a.type.prop(an);if(!h)return[];let c=n.facet(h),u=a.type.prop(eO);if(u){let f=a.resolve(o-a.from,l);for(let d of u)if(d.test(f,n)){let p=n.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,i,r=-1){return D_(e,i,r).type.prop(an)==this.data}findRegions(e){let i=e.facet(Zn);if((i==null?void 0:i.data)==this.data)return[{from:0,to:e.doc.length}];if(!i||!i.allowsNesting)return[];let r=[],s=(n,o)=>{if(n.prop(an)==this.data){r.push({from:o,to:o+n.length});return}let l=n.prop(G.mounted);if(l){if(l.tree.prop(an)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+n.length});return}else if(l.overlay){let a=r.length;if(s(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?i:void 0)]}),e.name)}configure(e,i){return new Bn(this.data,this.parser.configure(e),i||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ie(t){let e=t.field(Pi.state,!1);return e?e.tree:le.empty}class OQ{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,i){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,i):this.string.slice(e-r,i-r)}}let uo=null;class kl{constructor(e,i,r=[],s,n,o,l,a){this.parser=e,this.state=i,this.fragments=r,this.tree=s,this.treeLen=n,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,i,r){return new kl(e,i,[],le.empty,0,r,[],null)}startParse(){return this.parser.startParse(new OQ(this.state.doc),this.fragments)}work(e,i){return i!=null&&i>=this.state.doc.length&&(i=void 0),this.tree!=le.empty&&this.isDone(i??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),i!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>i)&&i=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(i=this.parse.advance()););}),this.treeLen=e,this.tree=i,this.fragments=this.withoutTempSkipped(gr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let i=uo;uo=this;try{return e()}finally{uo=i}}withoutTempSkipped(e){for(let i;i=this.tempSkipped.pop();)e=B_(e,i.from,i.to);return e}changes(e,i){let{fragments:r,tree:s,treeLen:n,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,u,f)=>a.push({fromA:h,toA:c,fromB:u,toB:f})),r=gr.applyChanges(r,a),s=le.empty,n=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),u=e.mapPos(h.to,-1);ce.from&&(this.fragments=B_(this.fragments,s,n),this.skipped.splice(r--,1))}return this.skipped.length>=i?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,i){this.skipped.push({from:e,to:i})}static getSkippingParser(e){return new class extends Kg{createParse(i,r,s){let n=s[0].from,o=s[s.length-1].to;return{parsedPos:n,advance(){let a=uo;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new le(Ke.none,[],[],o-n)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let i=this.fragments;return this.treeLen>=e&&i.length&&i[0].from==0&&i[0].to>=e}static get(){return uo}}function B_(t,e,i){return gr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class zn{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let i=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),i.viewport.to);return i.work(20,r)||i.takeTree(),new zn(i)}static init(e){let i=Math.min(3e3,e.doc.length),r=kl.create(e.facet(Zn).parser,e,{from:0,to:i});return r.work(20,i)||r.takeTree(),new zn(r)}}Pi.state=kr.define({create:zn.init,update(t,e){for(let i of e.effects)if(i.is(Pi.setState))return i.value;return e.startState.facet(Zn)!=e.state.facet(Zn)?zn.init(e.state):t.apply(e)}});let mw=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(mw=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Zu=typeof navigator<"u"&&(!((zu=navigator.scheduling)===null||zu===void 0)&&zu.isInputPending)?()=>navigator.scheduling.isInputPending():null,mQ=Ds.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 i=this.view.state.field(Pi.state).context;(i.updateViewport(e.view.viewport)||this.view.viewport.to>i.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(i)}scheduleWork(){if(this.working)return;let{state:e}=this.view,i=e.field(Pi.state);(i.tree!=i.context.tree||!i.context.isDone(e.doc.length))&&(this.working=mw(this.work))}work(e){this.working=null;let i=Date.now();if(this.chunkEnds+1e3,a=n.context.work(()=>Zu&&Zu()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-i,(a||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:Pi.setState.of(new zn(n.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(i=>qi(this.view.state,i)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Zn=H.define({combine(t){return t.length?t[0]:null},enables:t=>[Pi.state,mQ,F.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class bl{constructor(e,i=[]){this.language=e,this.support=i,this.extension=[e,i]}}class Gh{constructor(e,i,r,s,n,o=void 0){this.name=e,this.alias=i,this.extensions=r,this.filename=s,this.loadFunc=n,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:i,support:r}=e;if(!i){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");i=()=>Promise.resolve(r)}return new Gh(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,i,r)}static matchFilename(e,i){for(let s of e)if(s.filename&&s.filename.test(i))return s;let r=/\.([^.]+)$/.exec(i);if(r){for(let s of e)if(s.extensions.indexOf(r[1])>-1)return s}return null}static matchLanguageName(e,i,r=!0){i=i.toLowerCase();for(let s of e)if(s.alias.some(n=>n==i))return s;if(r)for(let s of e)for(let n of s.alias){let o=i.indexOf(n);if(o>-1&&(n.length>2||!/\w/.test(i[o-1])&&!/\w/.test(i[o+n.length])))return s}return null}}const _Q=H.define(),Nl=H.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(i=>i!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Kh(t){let e=t.facet(Nl);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Jh(t,e){let i="",r=t.tabSize,s=t.facet(Nl)[0];if(s==" "){for(;e>=r;)i+=" ",e-=r;s=" "}for(let n=0;n=e?vQ(t,i,e):null}class Xc{constructor(e,i={}){this.state=e,this.options=i,this.unit=Kh(e)}lineAt(e,i=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:n}=this.options;return s!=null&&s>=r.from&&s<=r.to?n&&s==e?{text:"",from:e}:(i<0?s-1&&(n+=o-this.countColumn(r,r.search(/\S|$/))),n}countColumn(e,i=e.length){return Sr(e,this.state.tabSize,i)}lineIndent(e,i=1){let{text:r,from:s}=this.lineAt(e,i),n=this.options.overrideIndentation;if(n){let o=n(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const jl=new G;function vQ(t,e,i){let r=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=r.node){let n=[];for(let o=s;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)n.push(o);for(let o=n.length-1;o>=0;o--)r={node:n[o],next:r}}return vw(r,t,i)}function vw(t,e,i){for(let r=t;r;r=r.next){let s=yQ(r.node);if(s)return s(tO.create(e,i,r))}return 0}function SQ(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function yQ(t){let e=t.type.prop(jl);if(e)return e;let i=t.firstChild,r;if(i&&(r=i.type.prop(G.closedBy))){let s=t.lastChild,n=s&&r.indexOf(s.name)>-1;return o=>Sw(o,!0,1,void 0,n&&!SQ(o)?s.from:void 0)}return t.parent==null?wQ:null}function wQ(){return 0}class tO extends Xc{constructor(e,i,r){super(e.state,e.options),this.base=e,this.pos=i,this.context=r}get node(){return this.context.node}static create(e,i,r){return new tO(e,i,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let i=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(i.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(kQ(r,e))break;i=this.state.doc.lineAt(r.from)}return this.lineIndent(i.from)}continue(){return vw(this.context.next,this.base,this.pos)}}function kQ(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function bQ(t){let e=t.node,i=e.childAfter(e.from),r=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,n=t.state.doc.lineAt(i.from),o=s==null||s<=n.from?n.to:Math.min(n.to,s);for(let l=i.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(n.text.slice(i.to-n.from))[0].length;return{from:i.from,to:i.to+h}}l=a.to}}function xQ({closing:t,align:e=!0,units:i=1}){return r=>Sw(r,e,i,t)}function Sw(t,e,i,r,s){let n=t.textAfter,o=n.match(/^\s*/)[0].length,l=r&&n.slice(o,o+r.length)==r||s==t.pos+o,a=e?bQ(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}const CQ=t=>t.baseIndent;function rh({except:t,units:e=1}={}){return i=>{let r=t&&t.test(i.textAfter);return i.baseIndent+(r?0:e*i.unit)}}const PQ=H.define(),Vl=new G;function yw(t){let e=t.firstChild,i=t.lastChild;return e&&e.to-1&&s%2==(e<0?1:0))return[i[s+e]]}return null}function jd(t){let e=t.type.prop(ww);return e?e(t.node):t}function hn(t,e,i,r={}){let s=r.maxScanDistance||$Q,n=r.brackets||QQ,o=Ie(t),l=o.resolveInner(e,i);for(let a=l;a;a=a.parent){let h=Nd(a.type,i,n);if(h&&a.from0?e>=c.from&&ec.from&&e<=c.to))return TQ(t,e,i,a,c,h,n)}}return EQ(t,e,i,o,l.type,s,n)}function TQ(t,e,i,r,s,n,o){let l=r.parent,a={from:s.from,to:s.to},h=0,c=l==null?void 0:l.cursor();if(c&&(i<0?c.childBefore(r.from):c.childAfter(r.to)))do if(i<0?c.to<=r.from:c.from>=r.to){if(h==0&&n.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let f=0;!c.next().done&&f<=n;){let d=c.value;i<0&&(f+=d.length);let p=e+f*i;for(let g=i>0?0:d.length-1,v=i>0?d.length:-1;g!=v;g+=i){let O=o.indexOf(d[g]);if(!(O<0||r.resolveInner(p+g,1).type!=s))if(O%2==0==i>0)u++;else{if(u==1)return{start:h,end:{from:p+g,to:p+g+1},matched:O>>1==a>>1};u--}}i>0&&(f+=d.length)}return c.done?{start:h,matched:!1}:null}const RQ=Object.create(null),z_=[Ke.none],Z_=[],X_=Object.create(null),AQ=Object.create(null);for(let[t,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"]])AQ[t]=MQ(RQ,e);function Xu(t,e){Z_.indexOf(t)>-1||(Z_.push(t),console.warn(e))}function MQ(t,e){let i=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=t[h]||y[h];c?typeof c=="function"?a.length?a=a.map(c):Xu(h,`Modifier ${h} used at start of tag`):a.length?Xu(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:Xu(h,`Unknown highlighting tag ${h}`)}for(let h of a)i.push(h)}if(!i.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+i.map(l=>l.id),n=X_[s];if(n)return n.id;let o=X_[s]=Ke.define({id:z_.length,name:r,props:[Fn({[r]:i})]});return z_.push(o),o.id}Ye.RTL,Ye.LTR;const LQ=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),r=rO(t.state,i.from);return r.line?DQ(t):r.block?zQ(t):!1};function iO(t,e){return({state:i,dispatch:r})=>{if(i.readOnly)return!1;let s=t(e,i);return s?(r(i.update(s)),!0):!1}}const DQ=iO(IQ,0),BQ=iO(kw,0),zQ=iO((t,e)=>kw(t,e,XQ(e)),0);function rO(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}const fo=50;function ZQ(t,{open:e,close:i},r,s){let n=t.sliceDoc(r-fo,r),o=t.sliceDoc(s,s+fo),l=/\s*$/.exec(n)[0].length,a=/^\s*/.exec(o)[0].length,h=n.length-l;if(n.slice(h-e.length,h)==e&&o.slice(a,a+i.length)==i)return{open:{pos:r-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,u;s-r<=2*fo?c=u=t.sliceDoc(r,s):(c=t.sliceDoc(r,r+fo),u=t.sliceDoc(s-fo,s));let f=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-i.length;return c.slice(f,f+e.length)==e&&u.slice(p,p+i.length)==i?{open:{pos:r+f+e.length,margin:/\s/.test(c.charAt(f+e.length))?1:0},close:{pos:s-d-i.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function XQ(t){let e=[];for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=i.to<=r.to?r:t.doc.lineAt(i.to);s.from>r.from&&s.from==i.to&&(s=i.to==r.to+1?r:t.doc.lineAt(i.to-1));let n=e.length-1;n>=0&&e[n].to>r.from?e[n].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function kw(t,e,i=e.selection.ranges){let r=i.map(n=>rO(e,n.from).block);if(!r.every(n=>n))return null;let s=i.map((n,o)=>ZQ(e,r[o],n.from,n.to));if(t!=2&&!s.every(n=>n))return{changes:e.changes(i.map((n,o)=>s[o]?[]:[{from:n.from,insert:r[o].open+" "},{from:n.to,insert:" "+r[o].close}]))};if(t!=1&&s.some(n=>n)){let n=[];for(let o=0,l;os&&(n==o||o>u.from)){s=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,p=u.text.slice(f,f+h.length)==h?f:-1;fn.comment<0&&(!n.empty||n.single))){let n=[];for(let{line:l,token:a,indent:h,empty:c,single:u}of r)(u||!c)&&n.push({from:l.from+h,insert:a+" "});let o=e.changes(n);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(n=>n.comment>=0)){let n=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,n.push({from:h,to:c})}return{changes:n}}return null}const Vd=br.define(),WQ=br.define(),NQ=H.define(),bw=H.define({combine(t){return t$(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(r,s)=>e(r,s)||i(r,s)})}}),xw=kr.define({create(){return Hi.empty},update(t,e){let i=e.state.facet(bw),r=e.annotation(Vd);if(r){let a=Zt.fromTransaction(e,r.selection),h=r.side,c=h==0?t.undone:t.done;return a?c=ec(c,c.length,i.minDepth,a):c=$w(c,e.startState.selection),new Hi(h==0?r.rest:c,h==0?c:r.rest)}let s=e.annotation(WQ);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(Ve.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let n=Zt.fromTransaction(e),o=e.annotation(Ve.time),l=e.annotation(Ve.userEvent);return n?t=t.addChanges(n,o,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,i.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Hi(t.done.map(Zt.fromJSON),t.undone.map(Zt.fromJSON))}});function jQ(t={}){return[xw,bw.of(t),F.domEventHandlers({beforeinput(e,i){let r=e.inputType=="historyUndo"?Cw:e.inputType=="historyRedo"?Yd:null;return r?(e.preventDefault(),r(i)):!1}})]}function Ic(t,e){return function({state:i,dispatch:r}){if(!e&&i.readOnly)return!1;let s=i.field(xw,!1);if(!s)return!1;let n=s.pop(t,i,e);return n?(r(n),!0):!1}}const Cw=Ic(0,!1),Yd=Ic(1,!1),VQ=Ic(0,!0),YQ=Ic(1,!0);class Zt{constructor(e,i,r,s,n){this.changes=e,this.effects=i,this.mapped=r,this.startSelection=s,this.selectionsAfter=n}setSelAfter(e){return new Zt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Zt(e.changes&&Ue.fromJSON(e.changes),[],e.mapped&&Ji.fromJSON(e.mapped),e.startSelection&&Q.fromJSON(e.startSelection),e.selectionsAfter.map(Q.fromJSON))}static fromTransaction(e,i){let r=fi;for(let s of e.startState.facet(NQ)){let n=s(e);n.length&&(r=r.concat(n))}return!r.length&&e.changes.empty?null:new Zt(e.changes.invert(e.startState.doc),r,void 0,i||e.startState.selection,fi)}static selection(e){return new Zt(void 0,fi,void 0,void 0,e)}}function ec(t,e,i,r){let s=e+1>i+20?e-i-1:0,n=t.slice(s,e);return n.push(r),n}function qQ(t,e){let i=[],r=!1;return t.iterChangedRanges((s,n)=>i.push(s,n)),e.iterChangedRanges((s,n,o,l)=>{for(let a=0;a=h&&o<=c&&(r=!0)}}),r}function FQ(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,r)=>i.empty!=e.ranges[r].empty).length===0}function Pw(t,e){return t.length?e.length?t.concat(e):t:e}const fi=[],HQ=200;function $w(t,e){if(t.length){let i=t[t.length-1],r=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-HQ));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),ec(t,t.length-1,1e9,i.setSelAfter(r)))}else return[Zt.selection([e])]}function UQ(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Iu(t,e){if(!t.length)return t;let i=t.length,r=fi;for(;i;){let s=GQ(t[i-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let n=t.slice(0,i);return n[i-1]=s,n}else e=s.mapped,i--,r=s.selectionsAfter}return r.length?[Zt.selection(r)]:fi}function GQ(t,e,i){let r=Pw(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):fi,i);if(!t.changes)return Zt.selection(r);let s=t.changes.map(e),n=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(n):n;return new Zt(s,Ce.mapEffects(t.effects,e),o,t.startSelection.map(n),r)}const KQ=/^(input\.type|delete)($|\.)/;class Hi{constructor(e,i,r=0,s=void 0){this.done=e,this.undone=i,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Hi(this.done,this.undone):this}addChanges(e,i,r,s,n){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||KQ.test(r))&&(!l.selectionsAfter.length&&i-this.prevTime0&&i-this.prevTimei.empty?t.moveByChar(i,e):Wc(i,e))}function wt(t){return t.textDirectionAt(t.state.selection.main.head)==Ye.LTR}const Tw=t=>Qw(t,!wt(t)),Ew=t=>Qw(t,wt(t));function Rw(t,e){return Ai(t,i=>i.empty?t.moveByGroup(i,e):Wc(i,e))}const eT=t=>Rw(t,!wt(t)),tT=t=>Rw(t,wt(t));function iT(t,e,i){if(e.type.prop(i))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Nc(t,e,i){let r=Ie(t).resolveInner(e.head),s=i?G.closedBy:G.openedBy;for(let a=e.head;;){let h=i?r.childAfter(a):r.childBefore(a);if(!h)break;iT(t,h,s)?r=h:a=i?h.to:h.from}let n=r.type.prop(s),o,l;return n&&(o=i?hn(t,r.from,1):hn(t,r.to,-1))&&o.matched?l=i?o.end.to:o.end.from:l=i?r.to:r.from,Q.cursor(l,i?-1:1)}const rT=t=>Ai(t,e=>Nc(t.state,e,!wt(t))),sT=t=>Ai(t,e=>Nc(t.state,e,wt(t)));function Aw(t,e){return Ai(t,i=>{if(!i.empty)return Wc(i,e);let r=t.moveVertically(i,e);return r.head!=i.head?r:t.moveToLineBoundary(i,e)})}const Mw=t=>Aw(t,!1),Lw=t=>Aw(t,!0);function Dw(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,i.height):Wc(o,e));if(s.eq(r.selection))return!1;let n;if(i.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+i.marginTop,h=l.bottom-i.marginBottom;o&&o.top>a&&o.bottomBw(t,!1),qd=t=>Bw(t,!0);function cs(t,e,i){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?r.to:r.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==r.from&&r.length){let n=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&e.head!=r.from+n&&(s=Q.cursor(r.from+n))}return s}const nT=t=>Ai(t,e=>cs(t,e,!0)),oT=t=>Ai(t,e=>cs(t,e,!1)),lT=t=>Ai(t,e=>cs(t,e,!wt(t))),aT=t=>Ai(t,e=>cs(t,e,wt(t))),hT=t=>Ai(t,e=>Q.cursor(t.lineBlockAt(e.head).from,1)),cT=t=>Ai(t,e=>Q.cursor(t.lineBlockAt(e.head).to,-1));function uT(t,e,i){let r=!1,s=Hn(t.selection,n=>{let o=hn(t,n.head,-1)||hn(t,n.head,1)||n.head>0&&hn(t,n.head-1,1)||n.headuT(t,e);function _i(t,e){let i=Hn(t.state.selection,r=>{let s=e(r);return Q.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(t.state.selection)?!1:(t.dispatch(Ri(t.state,i)),!0)}function zw(t,e){return _i(t,i=>t.moveByChar(i,e))}const Zw=t=>zw(t,!wt(t)),Xw=t=>zw(t,wt(t));function Iw(t,e){return _i(t,i=>t.moveByGroup(i,e))}const dT=t=>Iw(t,!wt(t)),pT=t=>Iw(t,wt(t)),gT=t=>_i(t,e=>Nc(t.state,e,!wt(t))),OT=t=>_i(t,e=>Nc(t.state,e,wt(t)));function Ww(t,e){return _i(t,i=>t.moveVertically(i,e))}const Nw=t=>Ww(t,!1),jw=t=>Ww(t,!0);function Vw(t,e){return _i(t,i=>t.moveVertically(i,e,Dw(t).height))}const W_=t=>Vw(t,!1),N_=t=>Vw(t,!0),mT=t=>_i(t,e=>cs(t,e,!0)),_T=t=>_i(t,e=>cs(t,e,!1)),vT=t=>_i(t,e=>cs(t,e,!wt(t))),ST=t=>_i(t,e=>cs(t,e,wt(t))),yT=t=>_i(t,e=>Q.cursor(t.lineBlockAt(e.head).from)),wT=t=>_i(t,e=>Q.cursor(t.lineBlockAt(e.head).to)),j_=({state:t,dispatch:e})=>(e(Ri(t,{anchor:0})),!0),V_=({state:t,dispatch:e})=>(e(Ri(t,{anchor:t.doc.length})),!0),Y_=({state:t,dispatch:e})=>(e(Ri(t,{anchor:t.selection.main.anchor,head:0})),!0),q_=({state:t,dispatch:e})=>(e(Ri(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),kT=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),bT=({state:t,dispatch:e})=>{let i=jc(t).map(({from:r,to:s})=>Q.range(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Q.create(i),userEvent:"select"})),!0},xT=({state:t,dispatch:e})=>{let i=Hn(t.selection,r=>{let s=Ie(t),n=s.resolveStack(r.from,1);if(r.empty){let o=s.resolveStack(r.from,-1);o.node.from>=n.node.from&&o.node.to<=n.node.to&&(n=o)}for(let o=n;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return Q.range(l.to,l.from)}return r});return i.eq(t.selection)?!1:(e(Ri(t,i)),!0)};function Yw(t,e){let{state:i}=t,r=i.selection,s=i.selection.ranges.slice();for(let n of i.selection.ranges){let o=i.doc.lineAt(n.head);if(e?o.to0)for(let l=n;;){let a=t.moveVertically(l,e);if(a.heado.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==r.ranges.length?!1:(t.dispatch(Ri(i,Q.create(s,s.length-1))),!0)}const CT=t=>Yw(t,!1),PT=t=>Yw(t,!0),$T=({state:t,dispatch:e})=>{let i=t.selection,r=null;return i.ranges.length>1?r=Q.create([i.main]):i.main.empty||(r=Q.create([Q.cursor(i.main.head)])),r?(e(Ri(t,r)),!0):!1};function Yl(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,s=r.changeByRange(n=>{let{from:o,to:l}=n;if(o==l){let a=e(n);ao&&(i="delete.forward",a=Ea(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ea(t,o,!1),l=Ea(t,l,!0);return o==l?{range:n}:{changes:{from:o,to:l},range:Q.cursor(o,os(t)))r.between(e,e,(s,n)=>{se&&(e=i?n:s)});return e}const qw=(t,e,i)=>Yl(t,r=>{let s=r.from,{state:n}=t,o=n.doc.lineAt(s),l,a;if(i&&!e&&s>o.from&&sqw(t,!1,!0),Fw=t=>qw(t,!0,!1),Hw=(t,e)=>Yl(t,i=>{let r=i.head,{state:s}=t,n=s.doc.lineAt(r),o=s.charCategorizer(r);for(let l=null;;){if(r==(e?n.to:n.from)){r==i.head&&n.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let a=vt(n.text,r-n.from,e)+n.from,h=n.text.slice(Math.min(r,a)-n.from,Math.max(r,a)-n.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||r!=i.head)&&(l=c),r=a}return r}),Uw=t=>Hw(t,!1),QT=t=>Hw(t,!0),TT=t=>Yl(t,e=>{let i=t.lineBlockAt(e.head).to;return e.headYl(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}),RT=t=>Yl(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let i=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ne.of(["",""])},range:Q.cursor(r.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},MT=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,n=t.doc.lineAt(s),o=s==n.from?s-1:vt(n.text,s-n.from,!1)+n.from,l=s==n.to?s+1:vt(n.text,s-n.from,!0)+n.from;return{changes:{from:o,to:l,insert:t.doc.slice(s,l).append(t.doc.slice(o,s))},range:Q.cursor(l)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function jc(t){let e=[],i=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),n=t.doc.lineAt(r.to);if(!r.empty&&r.to==n.from&&(n=t.doc.lineAt(r.to-1)),i>=s.number){let o=e[e.length-1];o.to=n.to,o.ranges.push(r)}else e.push({from:s.from,to:n.to,ranges:[r]});i=n.number+1}return e}function Gw(t,e,i){if(t.readOnly)return!1;let r=[],s=[];for(let n of jc(t)){if(i?n.to==t.doc.length:n.from==0)continue;let o=t.doc.lineAt(i?n.to+1:n.from-1),l=o.length+1;if(i){r.push({from:n.to,to:o.to},{from:n.from,insert:o.text+t.lineBreak});for(let a of n.ranges)s.push(Q.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:n.from},{from:n.to,insert:t.lineBreak+o.text});for(let a of n.ranges)s.push(Q.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Q.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const LT=({state:t,dispatch:e})=>Gw(t,e,!1),DT=({state:t,dispatch:e})=>Gw(t,e,!0);function Kw(t,e,i){if(t.readOnly)return!1;let r=[];for(let n of jc(t))i?r.push({from:n.from,insert:t.doc.slice(n.from,n.to)+t.lineBreak}):r.push({from:n.to,insert:t.lineBreak+t.doc.slice(n.from,n.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,i?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const BT=({state:t,dispatch:e})=>Kw(t,e,!1),zT=({state:t,dispatch:e})=>Kw(t,e,!0),ZT=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(jc(e).map(({from:s,to:n})=>(s>0?s--:n{let n;if(t.lineWrapping){let o=t.lineBlockAt(s.head),l=t.coordsAtPos(s.head,s.assoc||1);l&&(n=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,n)}).map(i);return t.dispatch({changes:i,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function XT(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Ie(t).resolveInner(e),r=i.childBefore(e),s=i.childAfter(e),n;return r&&s&&r.to<=e&&s.from>=e&&(n=r.type.prop(G.closedBy))&&n.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const F_=Jw(!1),IT=Jw(!0);function Jw(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:n,to:o}=s,l=e.doc.lineAt(n),a=!t&&n==o&&XT(e,n);t&&(n=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Xc(e,{simulateBreak:n,simulateDoubleBreak:!!a}),c=_w(h,n);for(c==null&&(c=Sr(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));ol.from&&n{let s=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>i&&(r.empty||r.to>l.from)&&(e(l,s,r),i=l.number),o=l.to+1}let n=t.changes(s);return{changes:s,range:Q.range(n.mapPos(r.anchor,1),n.mapPos(r.head,1))}})}const WT=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),r=new Xc(t,{overrideIndentation:n=>{let o=i[n];return o??-1}}),s=sO(t,(n,o,l)=>{let a=_w(r,n.from);if(a==null)return;/\S/.test(n.text)||(a=0);let h=/^\s*/.exec(n.text)[0],c=Jh(t,a);(h!=c||l.fromt.readOnly?!1:(e(t.update(sO(t,(i,r)=>{r.push({from:i.from,insert:t.facet(Nl)})}),{userEvent:"input.indent"})),!0),jT=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(sO(t,(i,r)=>{let s=/^\s*/.exec(i.text)[0];if(!s)return;let n=Sr(s,t.tabSize),o=0,l=Jh(t,Math.max(0,n-Kh(t)));for(;o(t.setTabFocusMode(),!0),YT=[{key:"Ctrl-b",run:Tw,shift:Zw,preventDefault:!0},{key:"Ctrl-f",run:Ew,shift:Xw},{key:"Ctrl-p",run:Mw,shift:Nw},{key:"Ctrl-n",run:Lw,shift:jw},{key:"Ctrl-a",run:hT,shift:yT},{key:"Ctrl-e",run:cT,shift:wT},{key:"Ctrl-d",run:Fw},{key:"Ctrl-h",run:Fd},{key:"Ctrl-k",run:TT},{key:"Ctrl-Alt-h",run:Uw},{key:"Ctrl-o",run:AT},{key:"Ctrl-t",run:MT},{key:"Ctrl-v",run:qd}],qT=[{key:"ArrowLeft",run:Tw,shift:Zw,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:eT,shift:dT,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:lT,shift:vT,preventDefault:!0},{key:"ArrowRight",run:Ew,shift:Xw,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:tT,shift:pT,preventDefault:!0},{mac:"Cmd-ArrowRight",run:aT,shift:ST,preventDefault:!0},{key:"ArrowUp",run:Mw,shift:Nw,preventDefault:!0},{mac:"Cmd-ArrowUp",run:j_,shift:Y_},{mac:"Ctrl-ArrowUp",run:I_,shift:W_},{key:"ArrowDown",run:Lw,shift:jw,preventDefault:!0},{mac:"Cmd-ArrowDown",run:V_,shift:q_},{mac:"Ctrl-ArrowDown",run:qd,shift:N_},{key:"PageUp",run:I_,shift:W_},{key:"PageDown",run:qd,shift:N_},{key:"Home",run:oT,shift:_T,preventDefault:!0},{key:"Mod-Home",run:j_,shift:Y_},{key:"End",run:nT,shift:mT,preventDefault:!0},{key:"Mod-End",run:V_,shift:q_},{key:"Enter",run:F_,shift:F_},{key:"Mod-a",run:kT},{key:"Backspace",run:Fd,shift:Fd,preventDefault:!0},{key:"Delete",run:Fw,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Uw,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QT,preventDefault:!0},{mac:"Mod-Backspace",run:ET,preventDefault:!0},{mac:"Mod-Delete",run:RT,preventDefault:!0}].concat(YT.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),FT=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:rT,shift:gT},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:sT,shift:OT},{key:"Alt-ArrowUp",run:LT},{key:"Shift-Alt-ArrowUp",run:BT},{key:"Alt-ArrowDown",run:DT},{key:"Shift-Alt-ArrowDown",run:zT},{key:"Mod-Alt-ArrowUp",run:CT},{key:"Mod-Alt-ArrowDown",run:PT},{key:"Escape",run:$T},{key:"Mod-Enter",run:IT},{key:"Alt-l",mac:"Ctrl-l",run:bT},{key:"Mod-i",run:xT,preventDefault:!0},{key:"Mod-[",run:jT},{key:"Mod-]",run:NT},{key:"Mod-Alt-\\",run:WT},{key:"Shift-Mod-k",run:ZT},{key:"Shift-Mod-\\",run:fT},{key:"Mod-/",run:LQ},{key:"Alt-A",run:BQ},{key:"Ctrl-m",mac:"Shift-Alt-m",run:VT}].concat(qT);class HT{constructor(e,i,r,s){this.state=e,this.pos=i,this.explicit=r,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let i=Ie(this.state).resolveInner(this.pos,-1);for(;i&&e.indexOf(i.name)<0;)i=i.parent;return i?{from:i.from,to:this.pos,text:this.state.sliceDoc(i.from,this.pos),type:i.type}:null}matchBefore(e){let i=this.state.doc.lineAt(this.pos),r=Math.max(i.from,this.pos-250),s=i.text.slice(r-i.from,this.pos-i.from),n=s.search(JT(e));return n<0?null:{from:r+n,to:this.pos,text:s.slice(n)}}get aborted(){return this.abortListeners==null}addEventListener(e,i,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(i),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function H_(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function UT(t){let e=Object.create(null),i=Object.create(null);for(let{label:s}of t){e[s[0]]=!0;for(let n=1;ntypeof s=="string"?{label:s}:s),[i,r]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:UT(e);return s=>{let n=s.matchBefore(r);return n||s.explicit?{from:n?n.from:s.pos,options:e,validFor:i}:null}}function KT(t,e){return i=>{for(let r=Ie(i.state).resolveInner(i.pos,-1);r;r=r.parent){if(t.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(i)}}function JT(t,e){var i;let{source:r}=t,s=r[r.length-1]!="$";return s?new RegExp(`(?:${r})${s?"$":""}`,(i=t.flags)!==null&&i!==void 0?i:t.ignoreCase?"i":""):t}const eE=br.define(),tE=F.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",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".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"}}});class iE{constructor(e,i,r,s){this.field=e,this.line=i,this.from=r,this.to=s}}class nO{constructor(e,i,r){this.field=e,this.from=i,this.to=r}map(e){let i=e.mapPos(this.from,-1,Pt.TrackDel),r=e.mapPos(this.to,1,Pt.TrackDel);return i==null||r==null?null:new nO(this.field,i,r)}}class oO{constructor(e,i){this.lines=e,this.fieldPositions=i}instantiate(e,i){let r=[],s=[i],n=e.doc.lineAt(i),o=/^\s*/.exec(n.text)[0];for(let a of this.lines){if(r.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let u=0;unew nO(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:r,ranges:l}}static parse(e){let i=[],r=[],s=[],n;for(let o of e.split(/\r\n?|\n/)){for(;n=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=n[1]?+n[1]:null,a=n[2]||n[3]||"",h=-1,c=a.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u=h&&f.field++}for(let u of s)if(u.line==r.length&&u.from>n.index){let f=n[2]?3+(n[1]||"").length:2;u.from-=f,u.to-=f}s.push(new iE(h,r.length,n.index,n.index+c.length)),o=o.slice(0,n.index)+a+o.slice(n.index+n[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of s)c.line==r.length&&c.from>h&&(c.from--,c.to--);return a}),r.push(o)}return new oO(r,s)}}let rE=Se.widget({widget:new class extends zl{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),sE=Se.mark({class:"cm-snippetField"});class Un{constructor(e,i){this.ranges=e,this.active=i,this.deco=Se.set(e.map(r=>(r.from==r.to?rE:sE).range(r.from,r.to)),!0)}map(e){let i=[];for(let r of this.ranges){let s=r.map(e);if(!s)return null;i.push(s)}return new Un(i,this.active)}selectionInsideField(e){return e.ranges.every(i=>this.ranges.some(r=>r.field==this.active&&r.from<=i.from&&r.to>=i.to))}}const ql=Ce.define({map(t,e){return t&&t.map(e)}}),nE=Ce.define(),xl=kr.define({create(){return null},update(t,e){for(let i of e.effects){if(i.is(ql))return i.value;if(i.is(nE)&&t)return new Un(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>F.decorations.from(t,e=>e?e.deco:Se.none)});function lO(t,e){return Q.create(t.filter(i=>i.field==e).map(i=>Q.range(i.from,i.to)))}function oE(t){let e=oO.parse(t);return(i,r,s,n)=>{let{text:o,ranges:l}=e.instantiate(i.state,s),{main:a}=i.state.selection,h={changes:{from:s,to:n==a.from?a.to:n,insert:ne.of(o)},scrollIntoView:!0,annotations:r?[eE.of(r),Ve.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=lO(l,0)),l.some(c=>c.field>0)){let c=new Un(l,0),u=h.effects=[ql.of(c)];i.state.field(xl,!1)===void 0&&u.push(Ce.appendConfig.of([xl,uE,fE,tE]))}i.dispatch(i.state.update(h))}}function ek(t){return({state:e,dispatch:i})=>{let r=e.field(xl,!1);if(!r||t<0&&r.active==0)return!1;let s=r.active+t,n=t>0&&!r.ranges.some(o=>o.field==s+t);return i(e.update({selection:lO(r.ranges,s),effects:ql.of(n?null:new Un(r.ranges,s)),scrollIntoView:!0})),!0}}const lE=({state:t,dispatch:e})=>t.field(xl,!1)?(e(t.update({effects:ql.of(null)})),!0):!1,aE=ek(1),hE=ek(-1),cE=[{key:"Tab",run:aE,shift:hE},{key:"Escape",run:lE}],U_=H.define({combine(t){return t.length?t[0]:cE}}),uE=Rc.highest(Zc.compute([U_],t=>t.facet(U_)));function Lt(t,e){return{...e,apply:oE(t)}}const fE=F.domEventHandlers({mousedown(t,e){let i=e.state.field(xl,!1),r;if(!i||(r=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let s=i.ranges.find(n=>n.from<=r&&n.to>=r);return!s||s.field==i.active?!1:(e.dispatch({selection:lO(i.ranges,s.field),effects:ql.of(i.ranges.some(n=>n.field>s.field)?new Un(i.ranges,s.field):null),scrollIntoView:!0}),!0)}}),tk=new class extends rs{};tk.startSide=1;tk.endSide=-1;class tc{static create(e,i,r,s,n){let o=s+(s<<8)+e+(i<<4)|0;return new tc(e,i,r,o,n,[],[])}constructor(e,i,r,s,n,o,l){this.type=e,this.value=i,this.from=r,this.hash=s,this.end=n,this.children=o,this.positions=l,this.hashProp=[[G.contextHash,s]]}addChild(e,i){e.prop(G.contextHash)!=this.hash&&(e=new le(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(i)}toTree(e,i=this.end){let r=this.children.length-1;return r>=0&&(i=Math.max(i,this.positions[r]+this.children[r].length+this.from)),new le(e.types[this.type],this.children,this.positions,i-this.from).balance({makeTree:(s,n,o)=>new le(Ke.none,s,n,o,this.hashProp)})}}var M;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(M||(M={}));class dE{constructor(e,i){this.start=e,this.content=i,this.marks=[],this.parsers=[]}}class pE{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Ho(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,i=0,r=0){for(let s=i;s=e.stack[i.depth+1].value+i.baseIndent)return!0;if(i.indent>=i.baseIndent+4)return!1;let r=(t.type==M.OrderedList?cO:hO)(i,e,!1);return r>0&&(t.type!=M.BulletList||aO(i,e,!1)<0)&&i.text.charCodeAt(i.pos+r-1)==t.value}const ik={[M.Blockquote](t,e,i){return i.next!=62?!1:(i.markers.push(re(M.QuoteMark,e.lineStart+i.pos,e.lineStart+i.pos+1)),i.moveBase(i.pos+(vi(i.text.charCodeAt(i.pos+1))?2:1)),t.end=e.lineStart+i.text.length,!0)},[M.ListItem](t,e,i){return i.indent-1?!1:(i.moveBaseColumn(i.baseIndent+t.value),!0)},[M.OrderedList]:G_,[M.BulletList]:G_,[M.Document](){return!0}};function vi(t){return t==32||t==9||t==10||t==13}function Ho(t,e=0){for(;ei&&vi(t.charCodeAt(e-1));)e--;return e}function rk(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(uk.SetextHeading)>-1||r<3?-1:1}function nk(t,e){for(let i=t.stack.length-1;i>=0;i--)if(t.stack[i].type==e)return!0;return!1}function hO(t,e,i){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||vi(t.text.charCodeAt(t.pos+1)))&&(!i||nk(e,M.BulletList)||t.skipSpace(t.pos+2)=48&&s<=57;){r++;if(r==t.text.length)return-1;s=t.text.charCodeAt(r)}return r==t.pos||r>t.pos+9||s!=46&&s!=41||rt.pos+1||t.next!=49)?-1:r+1-t.pos}function ok(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e6?-1:i}function lk(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e/,hk=/\?>/,Ud=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(r);if(n)return t.append(re(M.Comment,i,i+1+n[0].length));let o=/^\?[^]*?\?>/.exec(r);if(o)return t.append(re(M.ProcessingInstruction,i,i+1+o[0].length));let l=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return l?t.append(re(M.HTMLTag,i,i+1+l[0].length)):-1},Emphasis(t,e,i){if(e!=95&&e!=42)return-1;let r=i+1;for(;t.char(r)==e;)r++;let s=t.slice(i-1,i),n=t.slice(r,r+1),o=Pl.test(s),l=Pl.test(n),a=/\s|^$/.test(s),h=/\s|^$/.test(n),c=!h&&(!l||a||o),u=!a&&(!o||h||l),f=c&&(e==42||!u||o),d=u&&(e==42||!c||l);return t.append(new Ut(e==95?Ok:mk,i,r,(f?1:0)|(d?2:0)))},HardBreak(t,e,i){if(e==92&&t.char(i+1)==10)return t.append(re(M.HardBreak,i,i+2));if(e==32){let r=i+1;for(;t.char(r)==32;)r++;if(t.char(r)==10&&r>=i+2)return t.append(re(M.HardBreak,i,r+1))}return-1},Link(t,e,i){return e==91?t.append(new Ut(vs,i,i+1,1)):-1},Image(t,e,i){return e==33&&t.char(i+1)==91?t.append(new Ut(ic,i,i+2,1)):-1},LinkEnd(t,e,i){if(e!=93)return-1;for(let r=t.parts.length-1;r>=0;r--){let s=t.parts[r];if(s instanceof Ut&&(s.type==vs||s.type==ic)){if(!s.side||t.skipSpace(s.to)==i&&!/[(\[]/.test(t.slice(i+1,i+2)))return t.parts[r]=null,-1;let n=t.takeContent(r),o=t.parts[r]=SE(t,n,s.type==vs?M.Link:M.Image,s.from,i+1);if(s.type==vs)for(let l=0;le?re(M.URL,e+i,n+i):n==t.length?null:!1}}function vk(t,e,i){let r=t.charCodeAt(e);if(r!=39&&r!=34&&r!=40)return!1;let s=r==40?41:r;for(let n=e+1,o=!1;n=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,i){return this.text.slice(e-this.offset,i-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,i,r,s,n){return this.append(new Ut(e,i,r,(s?1:0)|(n?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let i=this.parts[e];if(i instanceof Ut&&(i.type==vs||i.type==ic))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let r=e;r=e;a--){let g=this.parts[a];if(g instanceof Ut&&g.side&1&&g.type==s.type&&!(n&&(s.side&1||g.side&2)&&(g.to-g.from+o)%3==0&&((g.to-g.from)%3||o%3))){l=g;break}}if(!l)continue;let h=s.type.resolve,c=[],u=l.from,f=s.to;if(n){let g=Math.min(2,l.to-l.from,o);u=l.to-g,f=s.from+g,h=g==1?"Emphasis":"StrongEmphasis"}l.type.mark&&c.push(this.elt(l.type.mark,u,l.to));for(let g=a+1;g=0;i--){let r=this.parts[i];if(r instanceof Ut&&r.type==e&&r.side&1)return i}return null}takeContent(e){let i=this.resolveMarkers(e);return this.parts.length=e,i}getDelimiterAt(e){let i=this.parts[e];return i instanceof Ut?i:null}skipSpace(e){return Ho(this.text,e-this.offset)+this.offset}elt(e,i,r,s){return typeof e=="string"?re(this.parser.getNodeType(e),i,r,s):new gk(e,i)}}uO.linkStart=vs;uO.imageStart=ic;function Kd(t,e){if(!e.length)return t;if(!t.length)return e;let i=t.slice(),r=0;for(let s of e){for(;r(e?e-1:0))return!1;if(this.fragmentEnd<0){let n=this.fragment.to;for(;n>0&&this.input.read(n-1,n)!=` +`;)n--;this.fragmentEnd=n?n-1:0}let r=this.cursor;r||(r=this.cursor=this.fragment.tree.cursor(),r.firstChild());let s=e+this.fragment.offset;for(;r.to<=s;)if(!r.parent())return!1;for(;;){if(r.from>=s)return this.fragment.from<=i;if(!r.childAfter(s))return!1}}matches(e){let i=this.cursor.tree;return i&&i.prop(G.contextHash)==e}takeNodes(e){let i=this.cursor,r=this.fragment.offset,s=this.fragmentEnd-(this.fragment.openEnd?1:0),n=e.absoluteLineStart,o=n,l=e.block.children.length,a=o,h=l;for(;;){if(i.to-r>s){if(i.type.isAnonymous&&i.firstChild())continue;break}let c=yk(i.from-r,e.ranges);if(i.to-r<=e.ranges[e.rangeI].to)e.addNode(i.tree,c);else{let u=new le(e.parser.nodeSet.types[M.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(u,i.tree),e.addNode(u,c)}if(i.type.is("Block")&&(yE.indexOf(i.type.id)<0?(o=i.to-r,l=e.block.children.length):(o=a,l=h),a=i.to-r,h=e.block.children.length),!i.nextSibling())break}for(;e.block.children.length>l;)e.block.children.pop(),e.block.positions.pop();return o-n}};function yk(t,e){let i=t;for(let r=1;rRa[t]),Object.keys(Ra).map(t=>uk[t]),Object.keys(Ra),mE,ik,Object.keys(Nu).map(t=>Nu[t]),Object.keys(Nu),[]);function xE(t,e,i){let r=[];for(let s=t.firstChild,n=e;;s=s.nextSibling){let o=s?s.from:i;if(o>n&&r.push({from:n,to:o}),!s)break;n=s.to}return r}function CE(t){let{codeParser:e,htmlParser:i}=t;return{wrap:Ow((s,n)=>{let o=s.type.id;if(e&&(o==M.CodeBlock||o==M.FencedCode)){let l="";if(o==M.FencedCode){let h=s.node.getChild(M.CodeInfo);h&&(l=n.read(h.from,h.to))}let a=e(l);if(a)return{parser:a,overlay:h=>h.type.id==M.CodeText,bracketed:o==M.FencedCode}}else if(i&&(o==M.HTMLBlock||o==M.HTMLTag||o==M.CommentBlock))return{parser:i,overlay:xE(s.node,s.from,s.to)};return null})}}const PE={resolve:"Strikethrough",mark:"StrikethroughMark"},$E={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":y.strikethrough}},{name:"StrikethroughMark",style:y.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,e,i){if(e!=126||t.char(i+1)!=126||t.char(i+2)==126)return-1;let r=t.slice(i-1,i),s=t.slice(i+2,i+3),n=/\s|^$/.test(r),o=/\s|^$/.test(s),l=Pl.test(r),a=Pl.test(s);return t.addDelimiter(PE,i,i+2,!o&&(!a||n||l),!n&&(!l||o||a))},after:"Emphasis"}]};function Uo(t,e,i=0,r,s=0){let n=0,o=!0,l=-1,a=-1,h=!1,c=()=>{r.push(t.elt("TableCell",s+l,s+a,t.parser.parseInline(e.slice(l,a),s+l)))};for(let u=i;u-1)&&n++,o=!1,r&&(l>-1&&c(),r.push(t.elt("TableDelimiter",u+s,u+s+1))),l=a=-1):(h||f!=32&&f!=9)&&(l<0&&(l=u),a=u+1),h=!h&&f==92}return l>-1&&(n++,r&&c()),n}function t0(t,e){for(let i=e;is instanceof i0)||!t0(e.text,e.basePos))return!1;let r=t.peekLine();return wk.test(r)&&Uo(t,e.text,e.basePos)==Uo(t,r,e.basePos)},before:"SetextHeading"}]};class TE{nextLine(){return!1}finish(e,i){return e.addLeafElement(i,e.elt("Task",i.start,i.start+i.content.length,[e.elt("TaskMarker",i.start,i.start+3),...e.parser.parseInline(i.content.slice(3),i.start+3)])),!0}}const EE={defineNodes:[{name:"Task",block:!0,style:y.list},{name:"TaskMarker",style:y.atom}],parseBlock:[{name:"TaskList",leaf(t,e){return/^\[[ xX]\][ \t]/.test(e.content)&&t.parentType().name=="ListItem"?new TE:null},after:"SetextHeading"}]},r0=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,s0=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,RE=/[\w-]+\.[\w-]+($|\/)/,n0=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,o0=/\/[a-zA-Z\d@.]+/gy;function l0(t,e,i,r){let s=0;for(let n=e;n-1)return-1;let r=e+i[0].length;for(;;){let s=t[r-1],n;if(/[?!.,:*_~]/.test(s)||s==")"&&l0(t,e,r,")")>l0(t,e,r,"("))r--;else if(s==";"&&(n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e,r))))r=e+n.index;else break}return r}function a0(t,e){n0.lastIndex=e;let i=n0.exec(t);if(!i)return-1;let r=i[0][i[0].length-1];return r=="_"||r=="-"?-1:e+i[0].length-(r=="."?1:0)}const ME={parseInline:[{name:"Autolink",parse(t,e,i){let r=i-t.offset;if(r&&/\w/.test(t.text[r-1]))return-1;r0.lastIndex=r;let s=r0.exec(t.text),n=-1;if(!s)return-1;if(s[1]||s[2]){if(n=AE(t.text,r+s[0].length),n>-1&&t.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(r,n));n=r+o[0].length}}else s[3]?n=a0(t.text,r):(n=a0(t.text,r+s[0].length),n>-1&&s[0]=="xmpp:"&&(o0.lastIndex=n,s=o0.exec(t.text),s&&(n=s.index+s[0].length)));return n<0?-1:(t.addElement(t.elt("URL",i,n+t.offset)),n+t.offset)}}]},LE=[QE,EE,$E,ME];function kk(t,e,i){return(r,s,n)=>{if(s!=t||r.char(n+1)==t)return-1;let o=[r.elt(i,n,n+1)];for(let l=n+1;li%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,i,r=0){let s=e.parser.context;return new rc(e,[],i,r,r,0,[],0,s?new c0(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,i){this.stack.push(this.state,i,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var i;let r=e>>19,s=e&65535,{parser:n}=this.p,o=this.reducePos=2e3&&!(!((i=this.p.parser.nodeSet.types[s])===null||i===void 0)&&i.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(s,h)}storeNode(e,i,r,s=4,n=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(i==r)return;if(this.buffer[o-2]>=i){this.buffer[o-2]=r;return}}}if(!n||this.pos==r)this.buffer.push(e,i,r,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)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,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=i,this.buffer[o+2]=r,this.buffer[o+3]=s}}shift(e,i,r,s){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(i,r),i<=this.p.parser.maxNode&&this.buffer.push(i,r,s,4);else{let n=e,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(n,1);!l&&(s>r||i<=o.maxNode)&&(this.reducePos=s),this.pushState(n,l?r:Math.min(r,this.reducePos)),this.shiftContext(i,r),i<=o.maxNode&&this.buffer.push(i,r,s,4)}}apply(e,i,r,s){e&65536?this.reduce(e):this.shift(e,i,r,s)}useNode(e,i){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(i,s),this.buffer.push(r,s,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,i=e.buffer.length;for(i&&e.buffer[i-4]==0&&(i-=4);i>0&&e.buffer[i-2]>e.reducePos;)i-=4;let r=e.buffer.slice(i),s=e.bufferBase+i;for(;e&&s==e.bufferBase;)e=e.parent;return new rc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,i){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,i,4),this.storeNode(0,this.pos,i,r?8:4),this.pos=this.reducePos=i,this.score-=190}canShift(e){for(let i=new ZE(this);;){let r=this.p.parser.stateSlot(i.state,4)||this.p.parser.hasAction(i.state,e);if(r==0)return!1;if(!(r&65536))return!0;i.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let i=this.p.parser.nextStates(this.state);if(i.length>8||this.stack.length>=120){let s=[];for(let n=0,o;na&1&&l==o)||s.push(i[n],o)}i=s}let r=[];for(let s=0;s>19,s=i&65535,n=this.stack.length-r*3;if(n<0||e.getGoto(this.stack[n],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;i=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(i),!0}findForcedReduction(){let{parser:e}=this.p,i=[],r=(s,n)=>{if(!i.includes(s))return i.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-n;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,n+1);if(l!=null)return l}})};return r(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 i=0;i0&&this.emitLookAhead()}}class c0{constructor(e,i){this.tracker=e,this.context=i,this.hash=e.strict?e.hash(i):0}}class ZE{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let i=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],i,!0);this.state=s}}class sc{constructor(e,i,r){this.stack=e,this.pos=i,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,i=e.bufferBase+e.buffer.length){return new sc(e,i,i-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 sc(this.stack,this.pos,this.index)}}function Qo(t,e=Uint16Array){if(typeof t!="string")return t;let i=null;for(let r=0,s=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),n+=a,l)break;n*=46}i?i[s++]=n:i=new e(n)}return i}class sh{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const u0=new sh;class XE{constructor(e,i){this.input=e,this.ranges=i,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=u0,this.rangeIndex=0,this.pos=this.chunkPos=i[0].from,this.range=i[0],this.end=i[i.length-1].to,this.readNext()}resolveOffset(e,i){let r=this.range,s=this.rangeIndex,n=this.pos+e;for(;nr.to:n>=r.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];n+=o.from-r.to,r=o}return n}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,i.from);return this.end}peek(e){let i=this.chunkOff+e,r,s;if(i>=0&&i=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),s=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),s}acceptToken(e,i=0){let r=i?this.resolveOffset(i,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.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,i){if(i?(this.token=i,i.start=e,i.lookAhead=e+1,i.value=i.extended=-1):this.token=u0,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&i<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,i-this.chunkPos);if(e>=this.chunk2Pos&&i<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,i-this.chunk2Pos);if(e>=this.range.from&&i<=this.range.to)return this.input.read(e,i);let r="";for(let s of this.ranges){if(s.from>=i)break;s.to>e&&(r+=this.input.read(Math.max(s.from,e),Math.min(s.to,i)))}return r}}class kn{constructor(e,i){this.data=e,this.id=i}token(e,i){let{parser:r}=i.p;bk(this.data,e,i,this.id,r.data,r.tokenPrecTable)}}kn.prototype.contextual=kn.prototype.fallback=kn.prototype.extend=!1;class nc{constructor(e,i,r){this.precTable=i,this.elseToken=r,this.data=typeof e=="string"?Qo(e):e}token(e,i){let r=e.pos,s=0;for(;;){let n=e.next<0,o=e.resolveOffset(1,1);if(bk(this.data,e,i,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(r,e.token),e.acceptToken(this.elseToken,s))}}nc.prototype.contextual=kn.prototype.fallback=kn.prototype.extend=!1;class ri{constructor(e,i={}){this.token=e,this.contextual=!!i.contextual,this.fallback=!!i.fallback,this.extend=!!i.extend}}function bk(t,e,i,r,s,n){let o=0,l=1<0){let p=t[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||IE(p,e.token.value,s,n))){e.acceptToken(p);break}}let c=e.next,u=0,f=t[o+2];if(e.next<0&&f>u&&t[h+f*3-3]==65535){o=t[h+f*3-1];continue e}for(;u>1,p=h+d+(d<<1),g=t[p],v=t[p+1]||65536;if(c=v)u=d+1;else{o=t[p+2],e.advance();continue e}}break}}function f0(t,e,i){for(let r=e,s;(s=t[r])!=65535;r++)if(s==i)return r-e;return-1}function IE(t,e,i,r){let s=f0(i,r,e);return s<0||f0(i,r,t)e)&&!r.type.isError)return i<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(i<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return i<0?0:t.length}}class WE{constructor(e,i){this.fragments=e,this.nodeSet=i,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?d0(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?d0(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(ee)return this.nextStart=o,null;if(n instanceof le){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[i]++,this.nextStart=o+n.length}}}class NE{constructor(e,i){this.stream=i,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new sh)}getActions(e){let i=0,r=null,{parser:s}=e.p,{tokenizers:n}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;hu.end+25&&(a=Math.max(u.lookAhead,a)),u.value!=0)){let f=i;if(u.extended>-1&&(i=this.addActions(e,u.extended,u.end,i)),i=this.addActions(e,u.value,u.end,i),!c.extend&&(r=u,i>f))break}}for(;this.actions.length>i;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new sh,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,i=this.addActions(e,r.value,r.end,i)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let i=new sh,{pos:r,p:s}=e;return i.start=r,i.end=Math.min(r+1,s.stream.end),i.value=r==s.stream.end?s.parser.eofTerm:0,i}updateCachedToken(e,i,r){let s=this.stream.clipPos(r.pos);if(i.token(this.stream.reset(s,e),r),e.value>-1){let{parser:n}=r.p;for(let o=0;o=0&&r.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(s+1)}putAction(e,i,r,s){for(let n=0;ne.bufferLength*4?new WE(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,i=this.minStackPos,r=this.stacks=[],s,n;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;oi)r.push(l);else{if(this.advanceStack(l,r,e))continue;{s||(s=[],n=[]),s.push(l);let a=this.tokens.getMainToken(l);n.push(a.value,a.end)}}break}}if(!r.length){let o=s&&YE(s);if(o)return jt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw jt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,n,r);if(o)return jt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>i)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let u=this.fragments.nodeAt(s);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?n.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!h||(u.prop(G.contextHash)||0)==c))return e.useNode(u,f),jt&&console.log(o+this.stackID(e)+` (via reuse of ${n.getName(u.type.id)})`),!0;if(!(u instanceof le)||u.children.length==0||u.positions[0]>0)break;let d=u.children[0];if(d instanceof le&&u.positions[0]==0)u=d;else break}}let l=n.stateSlot(e.state,4);if(l>0)return e.reduce(l),jt&&console.log(o+this.stackID(e)+` (via always-reduce ${n.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;hs?i.push(p):r.push(p)}return!1}advanceFully(e,i){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return p0(e,i),!0}}runRecovery(e,i,r){let s=null,n=!1;for(let o=0;o ":"";if(l.deadEnd&&(n||(n=!0,l.restart(),jt&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let u=l.split(),f=c;for(let d=0;d<10&&u.forceReduce()&&(jt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,r));d++)jt&&(f=this.stackID(u)+" -> ");for(let d of l.recoverByInsert(a))jt&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,r);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),jt&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),p0(l,r)):(!s||s.scoret;class xk{constructor(e){this.start=e.start,this.shift=e.shift||Vu,this.reduce=e.reduce||Vu,this.reuse=e.reuse||Vu,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class In extends Kg{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let i=e.nodeNames.split(" ");this.minRepeatTerm=i.length;for(let l=0;le.topRules[l][1]),s=[];for(let l=0;l=0)n(c,a,l[h++]);else{let u=l[h+-c];for(let f=-c;f>0;f--)n(l[h++],a,u);h++}}}this.nodeSet=new Wl(i.map((l,a)=>Ke.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=uw;let o=Qo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new kn(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,i,r){let s=new jE(this,e,i,r);for(let n of this.wrappers)s=n(s,e,i,r);return s}getGoto(e,i,r=!1){let s=this.goto;if(i>=s[0])return-1;for(let n=s[i+1];;){let o=s[n++],l=o&1,a=s[n++];if(l&&r)return a;for(let h=n+(o>>1);n0}validAction(e,i){return!!this.allActions(e,r=>r==i?!0:null)}allActions(e,i){let r=this.stateSlot(e,4),s=r?i(r):void 0;for(let n=this.stateSlot(e,1);s==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=lr(this.data,n+2);else break;s=i(lr(this.data,n+1))}return s}nextStates(e){let i=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=lr(this.data,r+2);else break;if(!(this.data[r+2]&1)){let s=this.data[r+1];i.some((n,o)=>o&1&&n==s)||i.push(this.data[r],s)}}return i}configure(e){let i=Object.assign(Object.create(In.prototype),this);if(e.props&&(i.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);i.top=r}return e.tokenizers&&(i.tokenizers=this.tokenizers.map(r=>{let s=e.tokenizers.find(n=>n.from==r);return s?s.to:r})),e.specializers&&(i.specializers=this.specializers.slice(),i.specializerSpecs=this.specializerSpecs.map((r,s)=>{let n=e.specializers.find(l=>l.from==r.external);if(!n)return r;let o=Object.assign(Object.assign({},r),{external:n.to});return i.specializers[s]=g0(o),o})),e.contextTracker&&(i.context=e.contextTracker),e.dialect&&(i.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(i.strict=e.strict),e.wrap&&(i.wrappers=i.wrappers.concat(e.wrap)),e.bufferLength!=null&&(i.bufferLength=e.bufferLength),i}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 i=this.dynamicPrecedences;return i==null?0:i[e]||0}parseDialect(e){let i=Object.keys(this.dialects),r=i.map(()=>!1);if(e)for(let n of e.split(" ")){let o=i.indexOf(n);o>=0&&(r[o]=!0)}let s=null;for(let n=0;nr)&&i.p.parser.stateFlag(i.state,2)&&(!e||e.scoret.external(i,r)<<1|e}return t.get}const qE=55,FE=1,HE=56,UE=2,GE=57,KE=3,O0=4,JE=5,fO=6,Ck=7,Pk=8,$k=9,Qk=10,eR=11,tR=12,iR=13,Yu=58,rR=14,sR=15,m0=59,Tk=21,nR=23,Ek=24,oR=25,Jd=27,Rk=28,lR=29,aR=32,hR=35,cR=37,uR=38,fR=0,dR=1,pR={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},gR={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},_0={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function OR(t){return t==45||t==46||t==58||t>=65&&t<=90||t==95||t>=97&&t<=122||t>=161}let v0=null,S0=null,y0=0;function ep(t,e){let i=t.pos+e;if(y0==i&&S0==t)return v0;let r=t.peek(e),s="";for(;OR(r);)s+=String.fromCharCode(r),r=t.peek(++e);return S0=t,y0=i,v0=s?s.toLowerCase():r==mR||r==_R?void 0:null}const Ak=60,oc=62,dO=47,mR=63,_R=33,vR=45;function w0(t,e){this.name=t,this.parent=e}const SR=[fO,Qk,Ck,Pk,$k],yR=new xk({start:null,shift(t,e,i,r){return SR.indexOf(e)>-1?new w0(ep(r,1)||"",t):t},reduce(t,e){return e==Tk&&t?t.parent:t},reuse(t,e,i,r){let s=e.type.id;return s==fO||s==cR?new w0(ep(r,1)||"",t):t},strict:!1}),wR=new ri((t,e)=>{if(t.next!=Ak){t.next<0&&e.context&&t.acceptToken(Yu);return}t.advance();let i=t.next==dO;i&&t.advance();let r=ep(t,0);if(r===void 0)return;if(!r)return t.acceptToken(i?sR:rR);let s=e.context?e.context.name:null;if(i){if(r==s)return t.acceptToken(eR);if(s&&gR[s])return t.acceptToken(Yu,-2);if(e.dialectEnabled(fR))return t.acceptToken(tR);for(let n=e.context;n;n=n.parent)if(n.name==r)return;t.acceptToken(iR)}else{if(r=="script")return t.acceptToken(Ck);if(r=="style")return t.acceptToken(Pk);if(r=="textarea")return t.acceptToken($k);if(pR.hasOwnProperty(r))return t.acceptToken(Qk);s&&_0[s]&&_0[s][r]?t.acceptToken(Yu,-1):t.acceptToken(fO)}},{contextual:!0}),kR=new ri(t=>{for(let e=0,i=0;;i++){if(t.next<0){i&&t.acceptToken(m0);break}if(t.next==vR)e++;else if(t.next==oc&&e>=2){i>=3&&t.acceptToken(m0,-2);break}else e=0;t.advance()}});function bR(t){for(;t;t=t.parent)if(t.name=="svg"||t.name=="math")return!0;return!1}const xR=new ri((t,e)=>{if(t.next==dO&&t.peek(1)==oc){let i=e.dialectEnabled(dR)||bR(e.context);t.acceptToken(i?JE:O0,2)}else t.next==oc&&t.acceptToken(O0,1)});function pO(t,e,i){let r=2+t.length;return new ri(s=>{for(let n=0,o=0,l=0;;l++){if(s.next<0){l&&s.acceptToken(e);break}if(n==0&&s.next==Ak||n==1&&s.next==dO||n>=2&&no?s.acceptToken(e,-o):s.acceptToken(i,-(o-2));break}else if((s.next==10||s.next==13)&&l){s.acceptToken(e,1);break}else n=o=0;s.advance()}})}const CR=pO("script",qE,FE),PR=pO("style",HE,UE),$R=pO("textarea",GE,KE),QR=Fn({"Text RawText IncompleteTag IncompleteCloseTag":y.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":y.angleBracket,TagName:y.tagName,"MismatchedCloseTag/TagName":[y.tagName,y.invalid],AttributeName:y.attributeName,"AttributeValue UnquotedAttributeValue":y.attributeValue,Is:y.definitionOperator,"EntityReference CharacterReference":y.character,Comment:y.blockComment,ProcessingInst:y.processingInstruction,DoctypeDecl:y.documentMeta}),TR=In.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",stateData:",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:yR,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[QR],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let h=l.type.id;if(h==lR)return qu(l,a,i);if(h==aR)return qu(l,a,r);if(h==hR)return qu(l,a,s);if(h==Tk&&n.length){let c=l.node,u=c.firstChild,f=u&&k0(u,a),d;if(f){for(let p of n)if(p.tag==f&&(!p.attrs||p.attrs(d||(d=Mk(u,a))))){let g=c.lastChild,v=g.type.id==uR?g.from:c.to;if(v>u.to)return{parser:p.parser,overlay:[{from:u.to,to:v}]}}}}if(o&&h==Ek){let c=l.node,u;if(u=c.firstChild){let f=o[a.read(u.from,u.to)];if(f)for(let d of f){if(d.tagName&&d.tagName!=k0(c.parent,a))continue;let p=c.lastChild;if(p.type.id==Jd){let g=p.from+1,v=p.lastChild,O=p.to-(v&&v.isError?0:1);if(O>g)return{parser:d.parser,overlay:[{from:g,to:O}],bracketed:!0}}else if(p.type.id==Rk)return{parser:d.parser,overlay:[{from:p.from,to:p.to}]}}}}return null})}const ER=135,b0=1,RR=136,AR=137,Dk=2,MR=138,LR=3,DR=4,Bk=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],BR=58,zR=40,zk=95,ZR=91,nh=45,XR=46,IR=35,WR=37,NR=38,jR=92,VR=10,YR=42;function $l(t){return t>=65&&t<=90||t>=97&&t<=122||t>=161}function gO(t){return t>=48&&t<=57}function x0(t){return gO(t)||t>=97&&t<=102||t>=65&&t<=70}const Zk=(t,e,i)=>(r,s)=>{for(let n=!1,o=0,l=0;;l++){let{next:a}=r;if($l(a)||a==nh||a==zk||n&&gO(a))!n&&(a!=nh||l>0)&&(n=!0),o===l&&a==nh&&o++,r.advance();else if(a==jR&&r.peek(1)!=VR){if(r.advance(),x0(r.next)){do r.advance();while(x0(r.next));r.next==32&&r.advance()}else r.next>-1&&r.advance();n=!0}else{n&&r.acceptToken(o==2&&s.canShift(Dk)?e:a==zR?i:t);break}}},qR=new ri(Zk(RR,Dk,AR),{contextual:!0}),FR=new ri(Zk(MR,LR,DR),{contextual:!0}),HR=new ri(t=>{if(Bk.includes(t.peek(-1))){let{next:e}=t;($l(e)||e==zk||e==IR||e==XR||e==YR||e==ZR||e==BR&&$l(t.peek(1))||e==nh||e==NR)&&t.acceptToken(ER)}}),UR=new ri(t=>{if(!Bk.includes(t.peek(-1))){let{next:e}=t;if(e==WR&&(t.advance(),t.acceptToken(b0)),$l(e)){do t.advance();while($l(t.next)||gO(t.next));t.acceptToken(b0)}}}),GR=Fn({"AtKeyword import charset namespace keyframes media supports font-feature-values":y.definitionKeyword,"from to selector scope MatchFlag":y.keyword,NamespaceName:y.namespace,KeyframeName:y.labelName,KeyframeRangeName:y.operatorKeyword,TagName:y.tagName,ClassName:y.className,PseudoClassName:y.constant(y.className),IdName:y.labelName,"FeatureName PropertyName":y.propertyName,AttributeName:y.attributeName,NumberLiteral:y.number,KeywordQuery:y.keyword,UnaryQueryOp:y.operatorKeyword,"CallTag ValueName FontName":y.atom,VariableName:y.variableName,Callee:y.operatorKeyword,Unit:y.unit,"UniversalSelector NestingSelector":y.definitionOperator,"MatchOp CompareOp":y.compareOperator,"ChildOp SiblingOp, LogicOp":y.logicOperator,BinOp:y.arithmeticOperator,Important:y.modifier,Comment:y.blockComment,ColorLiteral:y.color,"ParenthesizedContent StringLiteral":y.string,":":y.punctuation,"PseudoOp #":y.derefOperator,"; , |":y.separator,"( )":y.paren,"[ ]":y.squareBracket,"{ }":y.brace}),KR={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:132,"url-prefix":132,domain:132,regexp:132},JR={__proto__:null,or:104,and:104,not:112,only:112,layer:186},e5={__proto__:null,selector:118,layer:182},t5={__proto__:null,"@import":178,"@media":190,"@charset":194,"@namespace":198,"@keyframes":204,"@supports":216,"@scope":220,"@font-feature-values":226},i5={__proto__:null,to:223},r5=In.deserialize({version:14,states:"IpQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FdO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#DtO'dQdO'#DvO'oQdO'#D}O'oQdO'#EQOOQP'#Fd'#FdO)OQhO'#EsOOQS'#Fc'#FcOOQS'#Ev'#EvQYQdOOO)VQdO'#EWO*cQhO'#E^O)VQdO'#E`O*jQdO'#EbO*uQdO'#EeO)zQhO'#EkO*}QdO'#EmO+YQdO'#EpO+_QaO'#CfO+fQ`O'#ETO+kQ`O'#FnO+vQdO'#FnQOQ`OOP,QO&jO'#CaPOOO)CAR)CAROOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,]QdO,59YO'_QdO,5:`O'dQdO,5:bO'oQdO,5:iO'oQdO,5:kO'oQdO,5:lO'oQdO'#E}O,hQ`O,58}O,pQdO'#ESOOQS,58},58}OOQP'#Cq'#CqOOQO'#Dr'#DrOOQP,59Y,59YO,wQ`O,59YO,|Q`O,59YOOQP'#Du'#DuOOQP,5:`,5:`O-RQpO'#DwO-^QdO'#DxO-cQ`O'#DxO-hQpO,5:bO.RQaO,5:iO.iQaO,5:lOOQW'#D^'#D^O/eQhO'#DgO/xQhO,5;_O)zQhO'#DeO0VQ`O'#DkO0[QhO'#DnOOQW'#Fj'#FjOOQS,5;_,5;_O0aQ`O'#DhOOQS-E8t-E8tOOQ['#Cv'#CvO0fQdO'#CwO0|QdO'#C}O1dQdO'#DQO1zQ!pO'#DSO4TQ!jO,5:rOOQO'#DX'#DXO,|Q`O'#DWO4eQ!nO'#FgO6hQ`O'#DYO6mQ`O'#DoOOQ['#Fg'#FgO6rQhO'#FqO7QQ`O,5:xO7VQ!bO,5:zOOQS'#Ed'#EdO7_Q`O,5:|O7dQdO,5:|OOQO'#Eg'#EgO7lQ`O,5;PO7qQhO,5;VO'oQdO'#DjOOQS,5;X,5;XO0aQ`O,5;XO7yQdO,5;XOOQS'#FU'#FUO8RQdO'#ErO7QQ`O,5;[O8ZQdO,5:oO8kQdO'#FPO8xQ`O,5QQhO'#DlOOQW,5:V,5:VOOQW,5:Y,5:YOOQW,5:S,5:SO>[Q!fO'#FhOOQS'#Fh'#FhOOQS'#Ex'#ExO?lQdO,59cOOQ[,59c,59cO@SQdO,59iOOQ[,59i,59iO@jQdO,59lOOQ[,59l,59lOOQ[,59n,59nO)VQdO,59pOAQQhO'#EYOOQW'#EY'#EYOAlQ`O1G0^O4^QhO1G0^OOQ[,59r,59rO)zQhO'#D[OOQ[,59t,59tOAqQ#tO,5:ZOA|QhO'#FROBZQ`O,5<]OOQS1G0d1G0dOOQS1G0f1G0fOOQS1G0h1G0hOBfQ`O1G0hOBkQdO'#EhOOQS1G0k1G0kOOQS1G0q1G0qOBvQaO,5:UO7QQ`O1G0sOOQS1G0s1G0sO0aQ`O1G0sOOQS-E9S-E9SOOQS1G0v1G0vOB}Q!fO1G0ZOCeQ`O'#EVOOQO1G0Z1G0ZOOQO,5;k,5;kOCjQdO,5;kOOQO-E8}-E8}OCwQ`O1G1tPOOO-E8s-E8sPOOO1G.g1G.gOOQP7+$`7+$`OOQP7+%h7+%hO)VQdO7+%hOOQS1G0Y1G0YODSQaO'#FmOD^Q`O,5:_ODcQ!fO'#EwOEaQdO'#FfOEkQ`O,59aOOQO1G0O1G0OOEpQ!bO7+%hO)VQdO1G/eOE{QhO1G/iOOQW1G/m1G/mOOQW1G/g1G/gOF^QhO,5;qOOQW-E9T-E9TOOQS7+&e7+&eOGRQhO'#D^OGaQhO'#FlOGlQ`O'#FlOGqQ`O,5:WOOQS-E8v-E8vOOQ[1G.}1G.}OOQ[1G/T1G/TOOQ[1G/W1G/WOOQ[1G/[1G/[OGvQdO,5:tOOQS7+%x7+%xOG{Q`O7+%xOHQQhO'#D]OHYQ`O,59vO)zQhO,59vOOQ[1G/u1G/uOHbQ`O1G/uOHgQhO,5;mOOQO-E9P-E9POOQS7+&S7+&SOHuQbO'#DSOOQO'#Ej'#EjOITQ`O'#EiOOQO'#Ei'#EiOI`Q`O'#FSOIhQdO,5;SOOQS,5;S,5;SOOQ[1G/p1G/pOOQS7+&_7+&_O7QQ`O7+&_OIsQ!fO'#FOO)VQdO'#FOOJzQdO7+%uOOQO7+%u7+%uOOQO,5:q,5:qOOQO1G1V1G1VOK_Q!bO<nAN>nO! bQ`OAN>nO! gQaO,5;hOOQO-E8z-E8zO! qQdO,5;gOOQO-E8y-E8yOOQW<ZO)VQdO1G1QO!#nQ`O7+'^OOQO,5;l,5;lOOQO-E9O-E9OOOQW<Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!e`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$Q~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%j~'yh$Q~!e`OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%jj)jS$dYOy%jz;'S%j;'S;=`%{<%lO%j~)yWOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d<%lO)v~*hOw~~*kRO;'S)v;'S;=`*t;=`O)v~*wXOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d;=`<%l)v<%lO)v~+gP;=`<%l)vj+oYmYOy%jz!Q%j!Q![,_![!c%j!c!i,_!i#T%j#T#Z,_#Z;'S%j;'S;=`%{<%lO%jj,dY!e`Oy%jz!Q%j!Q![-S![!c%j!c!i-S!i#T%j#T#Z-S#Z;'S%j;'S;=`%{<%lO%jj-XY!e`Oy%jz!Q%j!Q![-w![!c%j!c!i-w!i#T%j#T#Z-w#Z;'S%j;'S;=`%{<%lO%jj.OYuY!e`Oy%jz!Q%j!Q![.n![!c%j!c!i.n!i#T%j#T#Z.n#Z;'S%j;'S;=`%{<%lO%jj.uYuY!e`Oy%jz!Q%j!Q![/e![!c%j!c!i/e!i#T%j#T#Z/e#Z;'S%j;'S;=`%{<%lO%jj/jY!e`Oy%jz!Q%j!Q![0Y![!c%j!c!i0Y!i#T%j#T#Z0Y#Z;'S%j;'S;=`%{<%lO%jj0aYuY!e`Oy%jz!Q%j!Q![1P![!c%j!c!i1P!i#T%j#T#Z1P#Z;'S%j;'S;=`%{<%lO%jj1UY!e`Oy%jz!Q%j!Q![1t![!c%j!c!i1t!i#T%j#T#Z1t#Z;'S%j;'S;=`%{<%lO%jj1{SuY!e`Oy%jz;'S%j;'S;=`%{<%lO%jd2[UOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jd2uS!oS!e`Oy%jz;'S%j;'S;=`%{<%lO%jb3WS^QOy%jz;'S%j;'S;=`%{<%lO%j~3gWOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{<%lO3d~4SRO;'S3d;'S;=`4];=`O3d~4`XOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{;=`<%l3d<%lO3d~5OP;=`<%l3dj5WShYOy%jz;'S%j;'S;=`%{<%lO%j~5iOg~n5pUWQyWOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jj6ZWyW!uQOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj6xU!e`Oy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%jj7cY!e`$]YOy%jz!Q%j!Q![7[![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj8WY!e`Oy%jz{%j{|8v|}%j}!O8v!O!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj8{U!e`Oy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj9fU!e`$]YOy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj:P[!e`$]YOy%jz!O%j!O!P7[!P!Q%j!Q![9x![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj:zS!aYOy%jz;'S%j;'S;=`%{<%lO%jj;]WyWOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj;zU`YOy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%j~VUcYOy%jz![%j![!]>i!];'S%j;'S;=`%{<%lO%jj>pSdY!e`Oy%jz;'S%j;'S;=`%{<%lO%jj?RSnYOy%jz;'S%j;'S;=`%{<%lO%jh?dU!WWOy%jz!_%j!_!`?v!`;'S%j;'S;=`%{<%lO%jh?}S!WW!e`Oy%jz;'S%j;'S;=`%{<%lO%jl@bS!WW!oSOy%jz;'S%j;'S;=`%{<%lO%jj@uV!rQ!WWOy%jz!_%j!_!`?v!`!aA[!a;'S%j;'S;=`%{<%lO%jbAcS!rQ!e`Oy%jz;'S%j;'S;=`%{<%lO%jjArYOy%jz}%j}!OBb!O!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjBgW!e`Oy%jz!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjCW[lY!e`Oy%jz}%j}!OCP!O!Q%j!Q![CP![!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jhDRS!pWOy%jz;'S%j;'S;=`%{<%lO%jjDdSpYOy%jz;'S%j;'S;=`%{<%lO%jnDuSo^Oy%jz;'S%j;'S;=`%{<%lO%jjEWU!pWOy%jz#a%j#a#bEj#b;'S%j;'S;=`%{<%lO%jbEoU!e`Oy%jz#d%j#d#eFR#e;'S%j;'S;=`%{<%lO%jbFWU!e`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!e`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!e`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!e`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!e`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!e`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$cQ!e`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$XUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU!uQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[HR,UR,qR,FR,1,2,3,4,new nc("m~RRYZ[z{a~~g~aO$T~~dP!P!Qg~lO$U~~",28,142)],topRules:{StyleSheet:[0,6],Styles:[1,116]},dynamicPrecedences:{84:1},specialized:[{term:137,get:t=>KR[t]||-1},{term:138,get:t=>JR[t]||-1},{term:4,get:t=>e5[t]||-1},{term:28,get:t=>t5[t]||-1},{term:136,get:t=>i5[t]||-1}],tokenPrec:2256});let Fu=null;function Hu(){if(!Fu&&typeof document=="object"&&document.body){let{style:t}=document.body,e=[],i=new Set;for(let r in t)r!="cssText"&&r!="cssFloat"&&typeof t[r]=="string"&&(/[A-Z]/.test(r)&&(r=r.replace(/[A-Z]/g,s=>"-"+s.toLowerCase())),i.has(r)||(e.push(r),i.add(r)));Fu=e.sort().map(r=>({type:"property",label:r,apply:r+": "}))}return Fu||[]}const C0=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(t=>({type:"class",label:t})),P0=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(t=>({type:"keyword",label:t})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(t=>({type:"constant",label:t}))),s5=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(t=>({type:"type",label:t})),n5=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(t=>({type:"keyword",label:t})),rr=/^(\w[\w-]*|-\w[\w-]*|)$/,o5=/^-(-[\w-]*)?$/;function l5(t,e){var i;if((t.name=="("||t.type.isError)&&(t=t.parent||t),t.name!="ArgList")return!1;let r=(i=t.parent)===null||i===void 0?void 0:i.firstChild;return(r==null?void 0:r.name)!="Callee"?!1:e.sliceString(r.from,r.to)=="var"}const $0=new gw,a5=["Declaration"];function h5(t){for(let e=t;;){if(e.type.isTop)return e;if(!(e=e.parent))return t}}function Xk(t,e,i){if(e.to-e.from>4096){let r=$0.get(e);if(r)return r;let s=[],n=new Set,o=e.cursor(he.IncludeAnonymous);if(o.firstChild())do for(let l of Xk(t,o.node,i))n.has(l.label)||(n.add(l.label),s.push(l));while(o.nextSibling());return $0.set(e,s),s}else{let r=[],s=new Set;return e.cursor().iterate(n=>{var o;if(i(n)&&n.matchContext(a5)&&((o=n.node.nextSibling)===null||o===void 0?void 0:o.name)==":"){let l=t.sliceString(n.from,n.to);s.has(l)||(s.add(l),r.push({label:l,type:"variable"}))}}),r}}const c5=t=>e=>{let{state:i,pos:r}=e,s=Ie(i).resolveInner(r,-1),n=s.type.isError&&s.from==s.to-1&&i.doc.sliceString(s.from,s.to)=="-";if(s.name=="PropertyName"||(n||s.name=="TagName")&&/^(Block|Styles)$/.test(s.resolve(s.to).name))return{from:s.from,options:Hu(),validFor:rr};if(s.name=="ValueName")return{from:s.from,options:P0,validFor:rr};if(s.name=="PseudoClassName")return{from:s.from,options:C0,validFor:rr};if(t(s)||(e.explicit||n)&&l5(s,i.doc))return{from:t(s)||n?s.from:r,options:Xk(i.doc,h5(s),t),validFor:o5};if(s.name=="TagName"){for(let{parent:a}=s;a;a=a.parent)if(a.name=="Block")return{from:s.from,options:Hu(),validFor:rr};return{from:s.from,options:s5,validFor:rr}}if(s.name=="AtKeyword")return{from:s.from,options:n5,validFor:rr};if(!e.explicit)return null;let o=s.resolve(r),l=o.childBefore(r);return l&&l.name==":"&&o.name=="PseudoClassSelector"?{from:r,options:C0,validFor:rr}:l&&l.name==":"&&o.name=="Declaration"||o.name=="ArgList"?{from:r,options:P0,validFor:rr}:o.name=="Block"||o.name=="Styles"?{from:r,options:Hu(),validFor:rr}:null},u5=c5(t=>t.name=="VariableName"),lc=Bn.define({name:"css",parser:r5.configure({props:[jl.add({Declaration:rh()}),Vl.add({"Block KeyframeList":yw})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function f5(){return new bl(lc,lc.data.of({autocomplete:u5}))}const d5=316,p5=317,Q0=1,g5=2,O5=3,m5=4,_5=318,v5=320,S5=321,y5=5,w5=6,k5=0,tp=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Ik=125,b5=59,ip=47,x5=42,C5=43,P5=45,$5=60,Q5=44,T5=63,E5=46,R5=91,A5=new xk({start:!1,shift(t,e){return e==y5||e==w5||e==v5?t:e==S5},strict:!1}),M5=new ri((t,e)=>{let{next:i}=t;(i==Ik||i==-1||e.context)&&t.acceptToken(_5)},{contextual:!0,fallback:!0}),L5=new ri((t,e)=>{let{next:i}=t,r;tp.indexOf(i)>-1||i==ip&&((r=t.peek(1))==ip||r==x5)||i!=Ik&&i!=b5&&i!=-1&&!e.context&&t.acceptToken(d5)},{contextual:!0}),D5=new ri((t,e)=>{t.next==R5&&!e.context&&t.acceptToken(p5)},{contextual:!0}),B5=new ri((t,e)=>{let{next:i}=t;if(i==C5||i==P5){if(t.advance(),i==t.next){t.advance();let r=!e.context&&e.canShift(Q0);t.acceptToken(r?Q0:g5)}}else i==T5&&t.peek(1)==E5&&(t.advance(),t.advance(),(t.next<48||t.next>57)&&t.acceptToken(O5))},{contextual:!0});function Uu(t,e){return t>=65&&t<=90||t>=97&&t<=122||t==95||t>=192||!e&&t>=48&&t<=57}const z5=new ri((t,e)=>{if(t.next!=$5||!e.dialectEnabled(k5)||(t.advance(),t.next==ip))return;let i=0;for(;tp.indexOf(t.next)>-1;)t.advance(),i++;if(Uu(t.next,!0)){for(t.advance(),i++;Uu(t.next,!1);)t.advance(),i++;for(;tp.indexOf(t.next)>-1;)t.advance(),i++;if(t.next==Q5)return;for(let r=0;;r++){if(r==7){if(!Uu(t.next,!0))return;break}if(t.next!="extends".charCodeAt(r))break;t.advance(),i++}}t.acceptToken(m5,-i)}),Z5=Fn({"get set async static":y.modifier,"for while do if else switch try catch finally return throw break continue default case defer":y.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":y.operatorKeyword,"let var const using function class extends":y.definitionKeyword,"import export from":y.moduleKeyword,"with debugger new":y.keyword,TemplateString:y.special(y.string),super:y.atom,BooleanLiteral:y.bool,this:y.self,null:y.null,Star:y.modifier,VariableName:y.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":y.function(y.variableName),VariableDefinition:y.definition(y.variableName),Label:y.labelName,PropertyName:y.propertyName,PrivatePropertyName:y.special(y.propertyName),"CallExpression/MemberExpression/PropertyName":y.function(y.propertyName),"FunctionDeclaration/VariableDefinition":y.function(y.definition(y.variableName)),"ClassDeclaration/VariableDefinition":y.definition(y.className),"NewExpression/VariableName":y.className,PropertyDefinition:y.definition(y.propertyName),PrivatePropertyDefinition:y.definition(y.special(y.propertyName)),UpdateOp:y.updateOperator,"LineComment Hashbang":y.lineComment,BlockComment:y.blockComment,Number:y.number,String:y.string,Escape:y.escape,ArithOp:y.arithmeticOperator,LogicOp:y.logicOperator,BitOp:y.bitwiseOperator,CompareOp:y.compareOperator,RegExp:y.regexp,Equals:y.definitionOperator,Arrow:y.function(y.punctuation),": Spread":y.punctuation,"( )":y.paren,"[ ]":y.squareBracket,"{ }":y.brace,"InterpolationStart InterpolationEnd":y.special(y.brace),".":y.derefOperator,", ;":y.separator,"@":y.meta,TypeName:y.typeName,TypeDefinition:y.definition(y.typeName),"type enum interface implements namespace module declare":y.definitionKeyword,"abstract global Privacy readonly override":y.modifier,"is keyof unique infer asserts":y.operatorKeyword,JSXAttributeValue:y.attributeValue,JSXText:y.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":y.angleBracket,"JSXIdentifier JSXNameSpacedName":y.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":y.attributeName,"JSXBuiltin/JSXIdentifier":y.standard(y.tagName)}),X5={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},I5={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},W5={__proto__:null,"<":193},N5=In.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:A5,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[Z5],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[L5,D5,B5,z5,2,3,4,5,6,7,8,9,10,11,12,13,14,M5,new nc("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new nc("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:t=>X5[t]||-1},{term:343,get:t=>I5[t]||-1},{term:95,get:t=>W5[t]||-1}],tokenPrec:15201}),Wk=[Lt("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Lt("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Lt("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Lt("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Lt("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Lt(`try { + \${} +} catch (\${error}) { + \${} +}`,{label:"try",detail:"/ catch block",type:"keyword"}),Lt("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Lt(`if (\${}) { + \${} +} else { + \${} +}`,{label:"if",detail:"/ else block",type:"keyword"}),Lt(`class \${name} { + constructor(\${params}) { + \${} + } +}`,{label:"class",detail:"definition",type:"keyword"}),Lt('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Lt('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],j5=Wk.concat([Lt("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Lt("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Lt("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),T0=new gw,Nk=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function go(t){return(e,i)=>{let r=e.node.getChild("VariableDefinition");return r&&i(r,t),!0}}const V5=["FunctionDeclaration"],Y5={FunctionDeclaration:go("function"),ClassDeclaration:go("class"),ClassExpression:()=>!0,EnumDeclaration:go("constant"),TypeAliasDeclaration:go("type"),NamespaceDeclaration:go("namespace"),VariableDefinition(t,e){t.matchContext(V5)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function jk(t,e){let i=T0.get(e);if(i)return i;let r=[],s=!0;function n(o,l){let a=t.sliceString(o.from,o.to);r.push({label:a,type:l})}return e.cursor(he.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=Y5[o.name];if(l&&l(o,n)||Nk.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of jk(t,o.node))r.push(l);return!1}}),T0.set(e,r),r}const E0=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Vk=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function q5(t){let e=Ie(t.state).resolveInner(t.pos,-1);if(Vk.indexOf(e.name)>-1)return null;let i=e.name=="VariableName"||e.to-e.from<20&&E0.test(t.state.sliceDoc(e.from,e.to));if(!i&&!t.explicit)return null;let r=[];for(let s=e;s;s=s.parent)Nk.has(s.name)&&(r=r.concat(jk(t.state.doc,s)));return{options:r,from:i?e.from:t.pos,validFor:E0}}const er=Bn.define({name:"javascript",parser:N5.configure({props:[jl.add({IfStatement:rh({except:/^\s*({|else\b)/}),TryStatement:rh({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:CQ,SwitchBody:t=>{let e=t.textAfter,i=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return t.baseIndent+(i?0:r?1:2)*t.unit},Block:xQ({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":rh({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),Vl.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":yw,BlockComment(t){return{from:t.from+2,to:t.to-2}},JSXElement(t){let e=t.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let i=t.lastChild;return{from:e.to,to:i.type.isError?t.to:i.from}},"JSXSelfClosingTag JSXOpenTag"(t){var e;let i=(e=t.firstChild)===null||e===void 0?void 0:e.nextSibling,r=t.lastChild;return!i||i.type.isError?null:{from:i.to,to:r.type.isError?t.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Yk={test:t=>/^JSX/.test(t.name),facet:Jg({commentTokens:{block:{open:"{/*",close:"*/}"}}})},qk=er.configure({dialect:"ts"},"typescript"),Fk=er.configure({dialect:"jsx",props:[eO.add(t=>t.isTop?[Yk]:void 0)]}),Hk=er.configure({dialect:"jsx ts",props:[eO.add(t=>t.isTop?[Yk]:void 0)]},"typescript");let Uk=t=>({label:t,type:"keyword"});const Gk="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Uk),F5=Gk.concat(["declare","implements","private","protected","public"].map(Uk));function H5(t={}){let e=t.jsx?t.typescript?Hk:Fk:t.typescript?qk:er,i=t.typescript?j5.concat(F5):Wk.concat(Gk);return new bl(e,[er.data.of({autocomplete:KT(Vk,GT(i))}),er.data.of({autocomplete:q5}),t.jsx?K5:[]])}function U5(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function R0(t,e,i=t.length){for(let r=e==null?void 0:e.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return t.sliceString(r.from,Math.min(r.to,i));return""}const G5=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),K5=F.inputHandler.of((t,e,i,r,s)=>{if((G5?t.composing:t.compositionStarted)||t.state.readOnly||e!=i||r!=">"&&r!="/"||!er.isActiveAt(t.state,e,-1))return!1;let n=s(),{state:o}=n,l=o.changeByRange(a=>{var h;let{head:c}=a,u=Ie(o).resolveInner(c-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(c-1,c)!=r||u.name=="JSXAttributeValue"&&u.to>c)){if(r==">"&&u.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:""}};if(r=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,p=d.parent;if(p&&d.from==c-2&&((f=R0(o.doc,p.firstChild,c))||((h=p.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let g=`${f}>`;return{range:Q.cursor(c+g.length,-1),changes:{from:c,insert:g}}}}else if(r==">"){let d=U5(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(f=R0(o.doc,d,c)))return{range:a,changes:{from:c,insert:``}}}}return{range:a}});return l.changes.empty?!1:(t.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Oo=["_blank","_self","_top","_parent"],Gu=["ascii","utf-8","utf-16","latin1","latin1"],Ku=["get","post","put","delete"],Ju=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Vt=["true","false"],Y={},J5={a:{attrs:{href:null,ping:null,type:null,media:null,target:Oo,hreflang:null}},abbr:Y,address:Y,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:Y,aside:Y,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:Y,base:{attrs:{href:null,target:Oo}},bdi:Y,bdo:Y,blockquote:{attrs:{cite:null}},body:Y,br:Y,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Ju,formmethod:Ku,formnovalidate:["novalidate"],formtarget:Oo,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:Y,center:Y,cite:Y,code:Y,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:Y,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:Y,div:Y,dl:Y,dt:Y,em:Y,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:Y,figure:Y,footer:Y,form:{attrs:{action:null,name:null,"accept-charset":Gu,autocomplete:["on","off"],enctype:Ju,method:Ku,novalidate:["novalidate"],target:Oo}},h1:Y,h2:Y,h3:Y,h4:Y,h5:Y,h6:Y,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:Y,hgroup:Y,hr:Y,html:{attrs:{manifest:null}},i:Y,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Ju,formmethod:Ku,formnovalidate:["novalidate"],formtarget:Oo,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:Y,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:Y,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:Y,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Gu,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Y,noscript:Y,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Y,param:{attrs:{name:null,value:null}},pre:Y,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Y,rt:Y,ruby:Y,samp:Y,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Gu}},section:Y,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:Y,source:{attrs:{src:null,type:null,media:null}},span:Y,strong:Y,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:Y,summary:Y,sup:Y,table:Y,tbody:Y,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Y,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:Y,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:Y,time:{attrs:{datetime:null}},title:Y,tr:Y,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:Y,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:Y},Kk={accesskey:null,class:null,contenteditable:Vt,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Vt,autocorrect:Vt,autocapitalize:Vt,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Vt,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Vt,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Vt,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Vt,"aria-hidden":Vt,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Vt,"aria-multiselectable":Vt,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Vt,"aria-relevant":null,"aria-required":Vt,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Jk="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of Jk)Kk[t]=null;class Ql{constructor(e,i){this.tags={...J5,...e},this.globalAttrs={...Kk,...i},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Ql.default=new Ql;function Wn(t,e,i=t.length){if(!e)return"";let r=e.firstChild,s=r&&r.getChild("TagName");return s?t.sliceString(s.from,Math.min(s.to,i)):""}function Nn(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function eb(t,e,i){let r=i.tags[Wn(t,Nn(e))];return(r==null?void 0:r.children)||i.allTags}function OO(t,e){let i=[];for(let r=Nn(e);r&&!r.type.isTop;r=Nn(r.parent)){let s=Wn(t,r);if(s&&r.lastChild.name=="CloseTag")break;s&&i.indexOf(s)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&i.push(s)}return i}const tb=/^[:\-\.\w\u00b7-\uffff]*$/;function A0(t,e,i,r,s){let n=/\s*>/.test(t.sliceDoc(s,s+5))?"":">",o=Nn(i,i.name=="StartTag"||i.name=="TagName");return{from:r,to:s,options:eb(t.doc,o,e).map(l=>({label:l,type:"type"})).concat(OO(t.doc,i).map((l,a)=>({label:"/"+l,apply:"/"+l+n,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function M0(t,e,i,r){let s=/\s*>/.test(t.sliceDoc(r,r+5))?"":">";return{from:i,to:r,options:OO(t.doc,e).map((n,o)=>({label:n,apply:n+s,type:"type",boost:99-o})),validFor:tb}}function eA(t,e,i,r){let s=[],n=0;for(let o of eb(t.doc,i,e))s.push({label:"<"+o,type:"type"});for(let o of OO(t.doc,i))s.push({label:"",type:"type",boost:99-n++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function tA(t,e,i,r,s){let n=Nn(i),o=n?e.tags[Wn(t.doc,n)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],a=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:s,options:a.map(h=>({label:h,type:"property"})),validFor:tb}}function iA(t,e,i,r,s){var n;let o=(n=i.parent)===null||n===void 0?void 0:n.getChild("AttributeName"),l=[],a;if(o){let h=t.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let u=Nn(i),f=u?e.tags[Wn(t.doc,u)]:null;c=(f==null?void 0:f.attrs)&&f.attrs[h]}if(c){let u=t.sliceDoc(r,s).toLowerCase(),f='"',d='"';/^['"]/.test(u)?(a=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",d=t.sliceDoc(s,s+1)==u[0]?"":u[0],u=u.slice(1),r++):a=/^[^\s<>='"]*$/;for(let p of c)l.push({label:p,apply:f+p+d,type:"constant"})}}return{from:r,to:s,options:l,validFor:a}}function ib(t,e){let{state:i,pos:r}=e,s=Ie(i).resolveInner(r,-1),n=s.resolve(r);for(let o=r,l;n==s&&(l=s.childBefore(o));){let a=l.lastChild;if(!a||!a.type.isError||a.fromib(r,s)}const nA=er.parser.configure({top:"SingleExpression"}),rb=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:qk.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:Fk.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:Hk.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:nA},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:er.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:lc.parser}],sb=[{name:"style",parser:lc.parser.configure({top:"Styles"})}].concat(Jk.map(t=>({name:t,parser:er.parser}))),nb=Bn.define({name:"html",parser:TR.configure({props:[jl.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].lengtht.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),oh=nb.configure({wrap:Lk(rb,sb)});function oA(t={}){let e="",i;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(i=Lk((t.nestedLanguages||[]).concat(rb),(t.nestedAttributes||[]).concat(sb)));let r=i?nb.configure({wrap:i,dialect:e}):e?oh.configure({dialect:e}):oh;return new bl(r,[oh.data.of({autocomplete:sA(t)}),t.autoCloseTags!==!1?lA:[],H5().support,f5().support])}const L0=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),lA=F.inputHandler.of((t,e,i,r,s)=>{if(t.composing||t.state.readOnly||e!=i||r!=">"&&r!="/"||!oh.isActiveAt(t.state,e,-1))return!1;let n=s(),{state:o}=n,l=o.changeByRange(a=>{var h,c,u;let f=o.doc.sliceString(a.from-1,a.to)==r,{head:d}=a,p=Ie(o).resolveInner(d,-1),g;if(f&&r==">"&&p.name=="EndTag"){let v=p.parent;if(((c=(h=v.parent)===null||h===void 0?void 0:h.lastChild)===null||c===void 0?void 0:c.name)!="CloseTag"&&(g=Wn(o.doc,v.parent,d))&&!L0.has(g)){let O=d+(o.doc.sliceString(d,d+1)===">"?1:0),m=``;return{range:a,changes:{from:d,to:O,insert:m}}}}else if(f&&r=="/"&&p.name=="IncompleteCloseTag"){let v=p.parent;if(p.from==d-2&&((u=v.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(g=Wn(o.doc,v,d))&&!L0.has(g)){let O=d+(o.doc.sliceString(d,d+1)===">"?1:0),m=`${g}>`;return{range:Q.cursor(d+m.length,-1),changes:{from:d,to:O,insert:m}}}}return{range:a}});return l.changes.empty?!1:(t.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),ob=Jg({commentTokens:{block:{open:""}}}),lb=new G,ab=bE.configure({props:[Vl.add(t=>!t.is("Block")||t.is("Document")||rp(t)!=null||aA(t)?void 0:(e,i)=>({from:i.doc.lineAt(e.from).to,to:e.to})),lb.add(rp),jl.add({Document:()=>null}),an.add({Document:ob})]});function rp(t){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(t.name);return e?+e[1]:void 0}function aA(t){return t.name=="OrderedList"||t.name=="BulletList"}function hA(t,e){let i=t;for(;;){let r=i.nextSibling,s;if(!r||(s=rp(r.type))!=null&&s<=e)break;i=r}return i.to}const cA=PQ.of((t,e,i)=>{for(let r=Ie(t).resolveInner(i,-1);r&&!(r.fromi)return{from:i,to:n}}return null});function mO(t){return new Pi(ob,t,[],"markdown")}const uA=mO(ab),fA=ab.configure([LE,BE,DE,zE,{props:[Vl.add({Table:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}]),ac=mO(fA);function dA(t,e){return i=>{if(i&&t){let r=null;if(i=/\S*/.exec(i)[0],typeof t=="function"?r=t(i):r=Gh.matchLanguageName(t,i,!0),r instanceof Gh)return r.support?r.support.language.parser:kl.getSkippingParser(r.load());if(r)return r.parser}return e?e.parser:null}}class ef{constructor(e,i,r,s,n,o,l){this.node=e,this.from=i,this.to=r,this.spaceBefore=s,this.spaceAfter=n,this.type=o,this.item=l}blank(e,i=!0){let r=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;r.length0;s--)r+=" ";return r+(i?this.spaceAfter:"")}}marker(e,i){let r=this.node.name=="OrderedList"?String(+cb(this.item,e)[2]+i):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function hb(t,e){let i=[],r=[];for(let s=t;s;s=s.parent){if(s.name=="FencedCode")return r;(s.name=="ListItem"||s.name=="Blockquote")&&i.push(s)}for(let s=i.length-1;s>=0;s--){let n=i[s],o,l=e.lineAt(n.from),a=n.from-l.from;if(n.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(a))))r.push(new ef(n,a,a+o[0].length,"",o[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(a)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),r.push(new ef(n.parent,a,a+c,o[1],h,o[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(a)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),r.push(new ef(n.parent,a,a+c,o[1],h,u,n))}}return r}function cb(t,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from,t.from+10))}function tf(t,e,i,r=0){for(let s=-1,n=t;;){if(n.name=="ListItem"){let l=cb(n,e),a=+l[2];if(s>=0){if(a!=s+1)return;i.push({from:n.from+l[1].length,to:n.from+l[0].length,insert:String(s+2+r)})}s=a}let o=n.nextSibling;if(!o)break;n=o}}function _O(t,e){let i=/^[ \t]*/.exec(t)[0].length;if(!i||e.facet(Nl)!=" ")return t;let r=Sr(t,4,i),s="";for(let n=r;n>0;)n>=4?(s+=" ",n-=4):(s+=" ",n--);return s+t.slice(i)}const pA=(t={})=>({state:e,dispatch:i})=>{let r=Ie(e),{doc:s}=e,n=null,o=e.changeByRange(l=>{if(!l.empty||!ac.isActiveAt(e,l.from,-1)&&!ac.isActiveAt(e,l.from,1))return n={range:l};let a=l.from,h=s.lineAt(a),c=hb(r.resolveInner(a,-1),s);for(;c.length&&c[c.length-1].from>a-h.from;)c.pop();if(!c.length)return n={range:l};let u=c[c.length-1];if(u.to-u.spaceAfter.length>a-h.from)return n={range:l};let f=a>=u.to-u.spaceAfter.length&&!/\S/.test(h.text.slice(u.to));if(u.item&&f){let O=u.node.firstChild,m=u.node.getChild("ListItem","ListItem");if(O.to>=a||m&&m.to0&&!/[^\s>]/.test(s.lineAt(h.from-1).text)||t.nonTightLists===!1){let _=c.length>1?c[c.length-2]:null,S,w="";_&&_.item?(S=h.from+_.from,w=_.marker(s,1)):S=h.from+(_?_.to:0);let k=[{from:S,to:a,insert:w}];return u.node.name=="OrderedList"&&tf(u.item,s,k,-2),_&&_.node.name=="OrderedList"&&tf(_.item,s,k),{range:Q.cursor(S+w.length),changes:k}}else{let _=B0(c,e,h);return{range:Q.cursor(a+_.length+1),changes:{from:h.from,insert:_+e.lineBreak}}}}if(u.node.name=="Blockquote"&&f&&h.from){let O=s.lineAt(h.from-1),m=/>\s*$/.exec(O.text);if(m&&m.index==u.from){let _=e.changes([{from:O.from+m.index,to:O.to},{from:h.from+u.from,to:h.to}]);return{range:l.map(_),changes:_}}}let d=[];u.node.name=="OrderedList"&&tf(u.item,s,d);let p=u.item&&u.item.from]*/.exec(h.text)[0].length>=u.to)for(let O=0,m=c.length-1;O<=m;O++)g+=O==m&&!p?c[O].marker(s,1):c[O].blank(Oh.from&&/\s/.test(h.text.charAt(v-h.from-1));)v--;return g=_O(g,e),OA(u.node,e.doc)&&(g=B0(c,e,h)+e.lineBreak+g),d.push({from:v,to:a,insert:e.lineBreak+g}),{range:Q.cursor(v+g.length+1),changes:d}});return n?!1:(i(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},gA=pA();function D0(t){return t.name=="QuoteMark"||t.name=="ListMark"}function OA(t,e){if(t.name!="OrderedList"&&t.name!="BulletList")return!1;let i=t.firstChild,r=t.getChild("ListItem","ListItem");if(!r)return!1;let s=e.lineAt(i.to),n=e.lineAt(r.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1){let i=Ie(t),r=null,s=t.changeByRange(n=>{let o=n.from,{doc:l}=t;if(n.empty&&ac.isActiveAt(t,n.from)){let a=l.lineAt(o),h=hb(mA(i,o),l);if(h.length){let c=h[h.length-1],u=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-a.from>u&&!/\S/.test(a.text.slice(u,o-a.from)))return{range:Q.cursor(a.from+u),changes:{from:a.from+u,to:o}};if(o-a.from==u&&(!c.item||a.from<=c.item.from||!/\S/.test(a.text.slice(0,c.to)))){let f=a.from+c.from;if(c.item&&c.node.from{var i;let{main:r}=e.state.selection;if(r.empty)return!1;let s=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!ac.isActiveAt(e.state,r.from,1)))return!1;let n=Ie(e.state),o=!1;return n.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||kA.test(l.name))&&(o=!0)},leave:l=>{l.to=r.from&&l.to<=r.to)){let f=l.to;a==="HeaderMark"&&t.state.sliceDoc(f,f+1)===" "&&(f+=1),s.push({from:l.from,to:f,deco:xA})}return}}});s.sort((n,o)=>{if(n.from!==o.from)return n.from-o.from;const l=n.from===n.to,a=o.from===o.to;return l!==a?l?-1:1:n.to-o.to});for(const n of s)e.add(n.from,n.to,n.deco);return e.finish()}const CA=Ds.fromClass(class{constructor(t){QO(this,"decorations");this.decorations=z0(t)}update(t){(t.docChanged||t.viewportChanged||t.selectionSet)&&(this.decorations=z0(t.view))}},{decorations:t=>t.decorations}),PA=F.theme({"&":{height:"100%",backgroundColor:"transparent",color:"var(--text)",fontSize:"inherit",fontFamily:"inherit"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.45",padding:"0.6em 0.77em"},".cm-content":{caretColor:"var(--text)"},".cm-focused":{outline:"none"},".cm-line":{padding:0},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:"rgba(255,255,255,0.18)"},".cm-md-h1":{fontSize:"1.7em",fontWeight:"600",lineHeight:"1.2"},".cm-md-h2":{fontSize:"1.45em",fontWeight:"600",lineHeight:"1.25"},".cm-md-h3":{fontSize:"1.25em",fontWeight:"600"},".cm-md-h4":{fontSize:"1.1em",fontWeight:"600"},".cm-md-h5":{fontSize:"1.0em",fontWeight:"600"},".cm-md-h6":{fontSize:"0.95em",fontWeight:"600",opacity:"0.85"},".cm-md-strong":{fontWeight:"700"},".cm-md-em":{fontStyle:"italic"},".cm-md-strike":{textDecoration:"line-through",opacity:"0.7"},".cm-md-inline-code":{fontFamily:"ui-monospace, Menlo, monospace",background:"rgba(255,255,255,0.08)",padding:"0 4px",borderRadius:"3px",fontSize:"0.92em"}},{dark:!0});function $A(t,e,i){const r=ue.useRef(null),s=ue.useRef(i);s.current=i,ue.useEffect(()=>{const n=t.current;if(!n)return;const o=new F({parent:n,state:oe.create({doc:e,extensions:[jQ(),Zc.of([...FT,...JQ]),SA(),CA,PA,F.lineWrapping,F.updateListener.of(l=>{l.docChanged&&s.current(l.state.doc.toString())})]})});return r.current=o,()=>{o.destroy(),r.current=null}},[]),ue.useEffect(()=>{const n=r.current;if(!n)return;const o=n.state.doc.toString();o!==e&&n.dispatch({changes:{from:0,to:o.length,insert:e}})},[e])}const QA=13;function TA({card:t,onUpdate:e}){const i=Ec(),r=K1(t,n=>e(n)),s=ue.useRef(null);return $A(s,t.text,n=>e({text:n})),Oe.jsxs("div",{className:"card note-card",style:{left:i.x+t.x*i.scale,top:i.y+t.y*i.scale,width:t.width*i.scale,height:t.height*i.scale,zIndex:t.z,fontSize:QA*i.scale,"--scale":i.scale},children:[Oe.jsx("div",{className:"card-header",...r,children:"note"}),Oe.jsx("div",{className:"card-body note-body",ref:s,onPointerDown:n=>n.stopPropagation()}),Oe.jsx(J1,{card:t,onUpdate:n=>e(n)})]})}/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var fb=Object.defineProperty,EA=Object.getOwnPropertyDescriptor,RA=(t,e)=>{for(var i in e)fb(t,i,{get:e[i],enumerable:!0})},De=(t,e,i,r)=>{for(var s=r>1?void 0:r?EA(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(e,i,s):o(s))||s);return r&&s&&fb(e,i,s),s},Z=(t,e)=>(i,r)=>e(i,r,t),Z0="Terminal input",sp={get:()=>Z0,set:t=>Z0=t},X0="Too much output to announce, navigate to rows manually to read",np={get:()=>X0,set:t=>X0=t};function AA(t){return t.replace(/\r?\n/g,"\r")}function MA(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function LA(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function DA(t,e,i,r){if(t.stopPropagation(),t.clipboardData){let s=t.clipboardData.getData("text/plain");db(s,e,i,r)}}function db(t,e,i,r){t=AA(t),t=MA(t,i.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function pb(t,e,i){let r=i.getBoundingClientRect(),s=t.clientX-r.left-10,n=t.clientY-r.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${s}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function I0(t,e,i,r,s){pb(t,e,i),s&&r.rightClickSelect(t),e.value=r.selectionText,e.select()}function zr(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Yc(t,e=0,i=t.length){let r="";for(let s=e;s65535?(n-=65536,r+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r}var BA=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let i=t.length;if(!i)return 0;let r=0,s=0;if(this._interim){let n=t.charCodeAt(s++);56320<=n&&n<=57343?e[r++]=(this._interim-55296)*1024+n-56320+65536:(e[r++]=this._interim,e[r++]=n),this._interim=0}for(let n=s;n=i)return this._interim=o,r;let l=t.charCodeAt(n);56320<=l&&l<=57343?e[r++]=(o-55296)*1024+l-56320+65536:(e[r++]=o,e[r++]=l);continue}o!==65279&&(e[r++]=o)}return r}},zA=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let i=t.length;if(!i)return 0;let r=0,s,n,o,l,a=0,h=0;if(this.interim[0]){let f=!1,d=this.interim[0];d&=(d&224)===192?31:(d&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)d<<=6,d|=g;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,O=v-p;for(;h=i)return 0;if(g=t[h++],(g&192)!==128){h--,f=!0;break}else this.interim[p++]=g,d<<=6,d|=g&63}f||(v===2?d<128?h--:e[r++]=d:v===3?d<2048||d>=55296&&d<=57343||d===65279||(e[r++]=d):d<65536||d>1114111||(e[r++]=d)),this.interim.fill(0)}let c=i-4,u=h;for(;u=i)return this.interim[0]=s,r;if(n=t[u++],(n&192)!==128){u--;continue}if(a=(s&31)<<6|n&63,a<128){u--;continue}e[r++]=a}else if((s&240)===224){if(u>=i)return this.interim[0]=s,r;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=t[u++],(o&192)!==128){u--;continue}if(a=(s&15)<<12|(n&63)<<6|o&63,a<2048||a>=55296&&a<=57343||a===65279)continue;e[r++]=a}else if((s&248)===240){if(u>=i)return this.interim[0]=s,r;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,r;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=n,this.interim[2]=o,r;if(l=t[u++],(l&192)!==128){u--;continue}if(a=(s&7)<<18|(n&63)<<12|(o&63)<<6|l&63,a<65536||a>1114111)continue;e[r++]=a}}return r}},gb="",Vr=" ",Fl=class Ob{constructor(){this.fg=0,this.bg=0,this.extended=new hc}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Ob;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},hc=class mb{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new mb(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},gi=class _b extends Fl{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new hc,this.combinedData=""}static fromCharData(e){let i=new _b;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?zr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let r=e[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},W0="di$target",op="di$dependencies",sf=new Map;function ZA(t){return t[op]||[]}function ot(t){if(sf.has(t))return sf.get(t);let e=function(i,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");XA(e,i,s)};return e._id=t,sf.set(t,e),e}function XA(t,e,i){e[W0]===e?e[op].push({id:t,index:i}):(e[op]=[{id:t,index:i}],e[W0]=e)}var Rt=ot("BufferService"),vb=ot("CoreMouseService"),Ws=ot("CoreService"),IA=ot("CharsetService"),vO=ot("InstantiationService"),Sb=ot("LogService"),At=ot("OptionsService"),yb=ot("OscLinkService"),WA=ot("UnicodeService"),Hl=ot("DecorationService"),lp=class{constructor(t,e,i){this._bufferService=t,this._optionsService=e,this._oscLinkService=i}provideLinks(t,e){var c;let i=this._bufferService.buffer.lines.get(t-1);if(!i){e(void 0);return}let r=[],s=this._optionsService.rawOptions.linkHandler,n=new gi,o=i.getTrimmedLength(),l=-1,a=-1,h=!1;for(let u=0;us?s.activate(g,v,d):NA(g,v),hover:(g,v)=>{var O;return(O=s==null?void 0:s.hover)==null?void 0:O.call(s,g,v,d)},leave:(g,v)=>{var O;return(O=s==null?void 0:s.leave)==null?void 0:O.call(s,g,v,d)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(a=u,l=n.extended.urlId):(a=-1,l=-1)}}e(r)}};lp=De([Z(0,Rt),Z(1,At),Z(2,yb)],lp);function NA(t,e){if(confirm(`Do you want to navigate to ${e}? + +WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var qc=ot("CharSizeService"),xr=ot("CoreBrowserService"),SO=ot("MouseService"),Cr=ot("RenderService"),jA=ot("SelectionService"),wb=ot("CharacterJoinerService"),Gn=ot("ThemeService"),kb=ot("LinkProviderService"),VA=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?N0.isErrorNoTelemetry(t)?new N0(t.message+` + +`+t.stack):new Error(t.message+` + +`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},YA=new VA;function lh(t){qA(t)||YA.onUnexpectedError(t)}var ap="Canceled";function qA(t){return t instanceof FA?!0:t instanceof Error&&t.name===ap&&t.message===ap}var FA=class extends Error{constructor(){super(ap),this.name=this.message}};function HA(t){return new Error(`Illegal argument: ${t}`)}var N0=class hp extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof hp)return e;let i=new hp;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},cp=class bb extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,bb.prototype)}};function Yt(t,e=0){return t[t.length-(1+e)]}var UA;(t=>{function e(n){return n<0}t.isLessThan=e;function i(n){return n<=0}t.isLessThanOrEqual=i;function r(n){return n>0}t.isGreaterThan=r;function s(n){return n===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(UA||(UA={}));function GA(t,e){let i=this,r=!1,s;return function(){return r||(r=!0,e||(s=t.apply(i,arguments))),s}}var xb;(t=>{function e(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function r(){return i}t.empty=r;function*s(S){yield S}t.single=s;function n(S){return e(S)?S:s(S)}t.wrap=n;function o(S){return S||i}t.from=o;function*l(S){for(let w=S.length-1;w>=0;w--)yield S[w]}t.reverse=l;function a(S){return!S||S[Symbol.iterator]().next().done===!0}t.isEmpty=a;function h(S){return S[Symbol.iterator]().next().value}t.first=h;function c(S,w){let k=0;for(let x of S)if(w(x,k++))return!0;return!1}t.some=c;function u(S,w){for(let k of S)if(w(k))return k}t.find=u;function*f(S,w){for(let k of S)w(k)&&(yield k)}t.filter=f;function*d(S,w){let k=0;for(let x of S)yield w(x,k++)}t.map=d;function*p(S,w){let k=0;for(let x of S)yield*w(x,k++)}t.flatMap=p;function*g(...S){for(let w of S)yield*w}t.concat=g;function v(S,w,k){let x=k;for(let T of S)x=w(x,T);return x}t.reduce=v;function*O(S,w,k=S.length){for(w<0&&(w+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);w1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function KA(...t){return Pe(()=>zs(t))}function Pe(t){return{dispose:GA(()=>{t()})}}var Cb=class Pb{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{zs(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Pb.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};Cb.DISABLE_DISPOSED_WARNING=!1;var es=Cb,te=class{constructor(){this._store=new es,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};te.None=Object.freeze({dispose(){}});var jn=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){var e;this._isDisposed||t===this._value||((e=this._value)==null||e.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){var t;this._isDisposed=!0,(t=this._value)==null||t.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},fr=typeof window=="object"?window:globalThis,up=class fp{constructor(e){this.element=e,this.next=fp.Undefined,this.prev=fp.Undefined}};up.Undefined=new up(void 0);var $e=up,j0=class{constructor(){this._first=$e.Undefined,this._last=$e.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===$e.Undefined}clear(){let t=this._first;for(;t!==$e.Undefined;){let e=t.next;t.prev=$e.Undefined,t.next=$e.Undefined,t=e}this._first=$e.Undefined,this._last=$e.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let i=new $e(t);if(this._first===$e.Undefined)this._first=i,this._last=i;else if(e){let s=this._last;this._last=i,i.prev=s,s.next=i}else{let s=this._first;this._first=i,i.next=s,s.prev=i}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(i))}}shift(){if(this._first!==$e.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==$e.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==$e.Undefined&&t.next!==$e.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===$e.Undefined&&t.next===$e.Undefined?(this._first=$e.Undefined,this._last=$e.Undefined):t.next===$e.Undefined?(this._last=this._last.prev,this._last.next=$e.Undefined):t.prev===$e.Undefined&&(this._first=this._first.next,this._first.prev=$e.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==$e.Undefined;)yield t.element,t=t.next}},JA=globalThis.performance&&typeof globalThis.performance.now=="function",eM=class $b{static create(e){return new $b(e)}constructor(e){this._now=JA&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},ut;(t=>{t.None=()=>te.None;function e($,C){return u($,()=>{},0,void 0,!0,void 0,C)}t.defer=e;function i($){return(C,R=null,A)=>{let z=!1,q;return q=$(b=>{if(!z)return q?q.dispose():z=!0,C.call(R,b)},null,A),z&&q.dispose(),q}}t.once=i;function r($,C,R){return h((A,z=null,q)=>$(b=>A.call(z,C(b)),null,q),R)}t.map=r;function s($,C,R){return h((A,z=null,q)=>$(b=>{C(b),A.call(z,b)},null,q),R)}t.forEach=s;function n($,C,R){return h((A,z=null,q)=>$(b=>C(b)&&A.call(z,b),null,q),R)}t.filter=n;function o($){return $}t.signal=o;function l(...$){return(C,R=null,A)=>{let z=KA(...$.map(q=>q(b=>C.call(R,b))));return c(z,A)}}t.any=l;function a($,C,R,A){let z=R;return r($,q=>(z=C(z,q),z),A)}t.reduce=a;function h($,C){let R,A={onWillAddFirstListener(){R=$(z.fire,z)},onDidRemoveLastListener(){R==null||R.dispose()}},z=new L(A);return C==null||C.add(z),z.event}function c($,C){return C instanceof Array?C.push($):C&&C.add($),$}function u($,C,R=100,A=!1,z=!1,q,b){let B,V,K,J=0,pe,ae={leakWarningThreshold:q,onWillAddFirstListener(){B=$(ye=>{J++,V=C(V,ye),A&&!K&&(Be.fire(V),V=void 0),pe=()=>{let kt=V;V=void 0,K=void 0,(!A||J>1)&&Be.fire(kt),J=0},typeof R=="number"?(clearTimeout(K),K=setTimeout(pe,R)):K===void 0&&(K=0,queueMicrotask(pe))})},onWillRemoveListener(){z&&J>0&&(pe==null||pe())},onDidRemoveLastListener(){pe=void 0,B.dispose()}},Be=new L(ae);return b==null||b.add(Be),Be.event}t.debounce=u;function f($,C=0,R){return t.debounce($,(A,z)=>A?(A.push(z),A):[z],C,void 0,!0,void 0,R)}t.accumulate=f;function d($,C=(A,z)=>A===z,R){let A=!0,z;return n($,q=>{let b=A||!C(q,z);return A=!1,z=q,b},R)}t.latch=d;function p($,C,R){return[t.filter($,C,R),t.filter($,A=>!C(A),R)]}t.split=p;function g($,C=!1,R=[],A){let z=R.slice(),q=$(V=>{z?z.push(V):B.fire(V)});A&&A.add(q);let b=()=>{z==null||z.forEach(V=>B.fire(V)),z=null},B=new L({onWillAddFirstListener(){q||(q=$(V=>B.fire(V)),A&&A.add(q))},onDidAddFirstListener(){z&&(C?setTimeout(b):b())},onDidRemoveLastListener(){q&&q.dispose(),q=null}});return A&&A.add(B),B.event}t.buffer=g;function v($,C){return(R,A,z)=>{let q=C(new m);return $(function(b){let B=q.evaluate(b);B!==O&&R.call(A,B)},void 0,z)}}t.chain=v;let O=Symbol("HaltChainable");class m{constructor(){this.steps=[]}map(C){return this.steps.push(C),this}forEach(C){return this.steps.push(R=>(C(R),R)),this}filter(C){return this.steps.push(R=>C(R)?R:O),this}reduce(C,R){let A=R;return this.steps.push(z=>(A=C(A,z),A)),this}latch(C=(R,A)=>R===A){let R=!0,A;return this.steps.push(z=>{let q=R||!C(z,A);return R=!1,A=z,q?z:O}),this}evaluate(C){for(let R of this.steps)if(C=R(C),C===O)break;return C}}function _($,C,R=A=>A){let A=(...B)=>b.fire(R(...B)),z=()=>$.on(C,A),q=()=>$.removeListener(C,A),b=new L({onWillAddFirstListener:z,onDidRemoveLastListener:q});return b.event}t.fromNodeEventEmitter=_;function S($,C,R=A=>A){let A=(...B)=>b.fire(R(...B)),z=()=>$.addEventListener(C,A),q=()=>$.removeEventListener(C,A),b=new L({onWillAddFirstListener:z,onDidRemoveLastListener:q});return b.event}t.fromDOMEventEmitter=S;function w($){return new Promise(C=>i($)(C))}t.toPromise=w;function k($){let C=new L;return $.then(R=>{C.fire(R)},()=>{C.fire(void 0)}).finally(()=>{C.dispose()}),C.event}t.fromPromise=k;function x($,C){return $(R=>C.fire(R))}t.forward=x;function T($,C,R){return C(R),$(A=>C(A))}t.runAndSubscribe=T;class N{constructor(C,R){this._observable=C,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{C.addObserver(this)},onDidRemoveLastListener:()=>{C.removeObserver(this)}};this.emitter=new L(A),R&&R.add(this.emitter)}beginUpdate(C){this._counter++}handlePossibleChange(C){}handleChange(C,R){this._hasChanged=!0}endUpdate(C){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function j($,C){return new N($,C).emitter.event}t.fromObservable=j;function X($){return(C,R,A)=>{let z=0,q=!1,b={beginUpdate(){z++},endUpdate(){z--,z===0&&($.reportChanges(),q&&(q=!1,C.call(R)))},handlePossibleChange(){},handleChange(){q=!0}};$.addObserver(b),$.reportChanges();let B={dispose(){$.removeObserver(b)}};return A instanceof es?A.add(B):Array.isArray(A)&&A.push(B),B}}t.fromObservableLight=X})(ut||(ut={}));var dp=class pp{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${pp._idPool++}`,pp.all.add(this)}start(e){this._stopWatch=new eM,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};dp.all=new Set,dp._idPool=0;var tM=dp,iM=-1,Qb=class Tb{constructor(e,i,r=(Tb._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,i){let r=this.threshold;if(r<=0||i{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[r,s]of this._stacks)(!e||i{var o,l,a,h,c;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],d=new oM(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||lh)(d),te.None}if(this._disposed)return te.None;e&&(t=t.bind(e));let r=new nf(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=sM.create(),s=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof nf?(this._deliveryQueue??(this._deliveryQueue=new cM),this._listeners=[this._listeners,r]):this._listeners.push(r):((a=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||a.call(l,this),this._listeners=r,(c=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||c.call(h,this)),this._size++;let n=Pe(()=>{s==null||s(),this._removeListener(r)});return i instanceof es?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(t){var s,n,o,l;if((n=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||n.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*aM<=e.length){let a=0;for(let h=0;h0}},cM=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,i){this.i=0,this.end=i,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},gp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new L,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new L,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,e),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,e),this._onDidChangeFullscreen.fire(r)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};gp.INSTANCE=new gp;var yO=gp;function uM(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}yO.INSTANCE.onDidChangeZoomLevel;function fM(t){return yO.INSTANCE.getZoomFactor(t)}yO.INSTANCE.onDidChangeFullscreen;var Kn=typeof navigator=="object"?navigator.userAgent:"",Op=Kn.indexOf("Firefox")>=0,dM=Kn.indexOf("AppleWebKit")>=0,wO=Kn.indexOf("Chrome")>=0,pM=!wO&&Kn.indexOf("Safari")>=0;Kn.indexOf("Electron/")>=0;Kn.indexOf("Android")>=0;var of=!1;if(typeof fr.matchMedia=="function"){let t=fr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=fr.matchMedia("(display-mode: fullscreen)");of=t.matches,uM(fr,t,({matches:i})=>{of&&e.matches||(of=i)})}var cn="en",mp=!1,_p=!1,ah=!1,Rb=!1,Ma,hh=cn,V0=cn,gM,yi,$s=globalThis,ht,Dv;typeof $s.vscode<"u"&&typeof $s.vscode.process<"u"?ht=$s.vscode.process:typeof process<"u"&&typeof((Dv=process==null?void 0:process.versions)==null?void 0:Dv.node)=="string"&&(ht=process);var Bv,OM=typeof((Bv=ht==null?void 0:ht.versions)==null?void 0:Bv.electron)=="string",mM=OM&&(ht==null?void 0:ht.type)==="renderer",zv;if(typeof ht=="object"){mp=ht.platform==="win32",_p=ht.platform==="darwin",ah=ht.platform==="linux",ah&&ht.env.SNAP&&ht.env.SNAP_REVISION,ht.env.CI||ht.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ma=cn,hh=cn;let t=ht.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Ma=e.userLocale,V0=e.osLocale,hh=e.resolvedLanguage||cn,gM=(zv=e.languagePack)==null?void 0:zv.translationsConfigFile}catch{}Rb=!0}else typeof navigator=="object"&&!mM?(yi=navigator.userAgent,mp=yi.indexOf("Windows")>=0,_p=yi.indexOf("Macintosh")>=0,(yi.indexOf("Macintosh")>=0||yi.indexOf("iPad")>=0||yi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ah=yi.indexOf("Linux")>=0,(yi==null?void 0:yi.indexOf("Mobi"))>=0,hh=globalThis._VSCODE_NLS_LANGUAGE||cn,Ma=navigator.language.toLowerCase(),V0=Ma):console.error("Unable to resolve platform.");var Ab=mp,tr=_p,_M=ah,Y0=Rb,ir=yi,Er=hh,vM;(t=>{function e(){return Er}t.value=e;function i(){return Er.length===2?Er==="en":Er.length>=3?Er[0]==="e"&&Er[1]==="n"&&Er[2]==="-":!1}t.isDefaultVariant=i;function r(){return Er==="en"}t.isDefault=r})(vM||(vM={}));var SM=typeof $s.postMessage=="function"&&!$s.importScripts;(()=>{if(SM){let t=[];$s.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,s=t.length;r{let r=++e;t.push({id:r,callback:i}),$s.postMessage({vscodeScheduleAsyncWork:r},"*")}}return t=>setTimeout(t)})();var yM=!!(ir&&ir.indexOf("Chrome")>=0);ir&&ir.indexOf("Firefox")>=0;!yM&&ir&&ir.indexOf("Safari")>=0;ir&&ir.indexOf("Edg/")>=0;ir&&ir.indexOf("Android")>=0;var js=typeof navigator=="object"?navigator:{};Y0||document.queryCommandSupported&&document.queryCommandSupported("copy")||js&&js.clipboard&&js.clipboard.writeText,Y0||js&&js.clipboard&&js.clipboard.readText;var kO=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},lf=new kO,q0=new kO,F0=new kO,wM=new Array(230),Mb;(t=>{function e(l){return lf.keyCodeToStr(l)}t.toString=e;function i(l){return lf.strToKeyCode(l)}t.fromString=i;function r(l){return q0.keyCodeToStr(l)}t.toUserSettingsUS=r;function s(l){return F0.keyCodeToStr(l)}t.toUserSettingsGeneral=s;function n(l){return q0.strToKeyCode(l)||F0.strToKeyCode(l)}t.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return lf.keyCodeToStr(l)}t.toElectronAccelerator=o})(Mb||(Mb={}));var kM=class Lb{constructor(e,i,r,s,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=r,this.metaKey=s,this.keyCode=n}equals(e){return e instanceof Lb&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${i}${r}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bM([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bM=class{constructor(t){if(t.length===0)throw HA("chords");this.chords=t}getHashCode(){let t="";for(let e=0,i=this.chords.length;e{function e(i){return i===t.None||i===t.Cancelled||i instanceof AM?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ut.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Db})})(RM||(RM={}));var AM=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Db:(this._emitter||(this._emitter=new L),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},bO=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new cp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new cp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},MM=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var t;(t=this.disposable)==null||t.dispose(),this.disposable=void 0}cancelAndSet(t,e,i=globalThis){if(this.isDisposed)throw new cp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=i.setInterval(()=>{t()},e);this.disposable=Pe(()=>{i.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},LM;(t=>{async function e(r){let s,n=await Promise.all(r.map(o=>o.then(l=>l,l=>{s||(s=l)})));if(typeof s<"u")throw s;return n}t.settled=e;function i(r){return new Promise(async(s,n)=>{try{await r(s,n)}catch(o){n(o)}})}t.withAsyncBody=i})(LM||(LM={}));var K0=class ni{static fromArray(e){return new ni(i=>{i.emitMany(e)})}static fromPromise(e){return new ni(async i=>{i.emitMany(await e)})}static fromPromises(e){return new ni(async i=>{await Promise.all(e.map(async r=>i.emitOne(await r)))})}static merge(e){return new ni(async i=>{await Promise.all(e.map(async r=>{for await(let s of r)i.emitOne(s)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new L,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(e,i){return new ni(async r=>{for await(let s of e)r.emitOne(i(s))})}map(e){return ni.map(this,e)}static filter(e,i){return new ni(async r=>{for await(let s of e)i(s)&&r.emitOne(s)})}filter(e){return ni.filter(this,e)}static coalesce(e){return ni.filter(e,i=>!!i)}coalesce(){return ni.coalesce(this)}static async toPromise(e){let i=[];for await(let r of e)i.push(r);return i}toPromise(){return ni.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};K0.EMPTY=K0.fromArray([]);var{getWindow:Ui,getWindowId:DM,onDidRegisterWindow:BM}=function(){let t=new Map,e={window:fr,disposables:new es};t.set(fr.vscodeWindowId,e);let i=new L,r=new L,s=new L;function n(o,l){return(typeof o=="number"?t.get(o):void 0)??(l?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(o){if(t.has(o.vscodeWindowId))return te.None;let l=new es,a={window:o,disposables:l.add(new es)};return t.set(o.vscodeWindowId,a),l.add(Pe(()=>{t.delete(o.vscodeWindowId),r.fire(o)})),l.add(U(o,et.BEFORE_UNLOAD,()=>{s.fire(o)})),i.fire(a),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){var h;let l=o;if((h=l==null?void 0:l.ownerDocument)!=null&&h.defaultView)return l.ownerDocument.defaultView.window;let a=o;return a!=null&&a.view?a.view.window:fr},getDocument(o){return Ui(o).document}}}(),zM=class{constructor(t,e,i,r){this._node=t,this._type=e,this._handler=i,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function U(t,e,i,r){return new zM(t,e,i,r)}var J0=function(t,e,i,r){return U(t,e,i,r)},xO,ZM=class extends MM{constructor(t){super(),this.defaultTarget=t&&Ui(t)}cancelAndSet(t,e,i){return super.cancelAndSet(t,e,i??this.defaultTarget)}},ev=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){lh(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,i=new Map,r=new Map,s=n=>{i.set(n,!1);let o=t.get(n)??[];for(e.set(n,o),t.set(n,[]),r.set(n,!0);o.length>0;)o.sort(ev.sort),o.shift().execute();r.set(n,!1)};xO=(n,o,l=0)=>{let a=DM(n),h=new ev(o,l),c=t.get(a);return c||(c=[],t.set(a,c)),c.push(h),i.get(a)||(i.set(a,!0),n.requestAnimationFrame(()=>s(a))),h}})();function XM(t){let e=t.getBoundingClientRect(),i=Ui(t);return{left:e.left+i.scrollX,top:e.top+i.scrollY,width:e.width,height:e.height}}var et={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},IM=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Mt(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Mt(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Mt(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Mt(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Mt(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Mt(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Mt(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Mt(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Mt(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Mt(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Mt(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Mt(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Mt(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Mt(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Mt(t){return typeof t=="number"?`${t}px`:t}function Go(t){return new IM(t)}var Bb=class{constructor(){this._hooks=new es,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,t&&i&&i(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,i,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let n=t;try{t.setPointerCapture(e),this._hooks.add(Pe(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{n=Ui(t)}this._hooks.add(U(n,et.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(U(n,et.POINTER_UP,o=>this.stopMonitoring(!0)))}};function WM(t,e,i){let r=null,s=null;if(typeof i.value=="function"?(r="value",s=i.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(r="get",s=i.get),!s)throw new Error("not supported");let n=`$memoize$${e}`;i[r]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,o)}),this[n]}}var Ii;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(Ii||(Ii={}));var To=class Ot extends te{constructor(){super(),this.dispatched=!1,this.targets=new j0,this.ignoreTargets=new j0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ut.runAndSubscribe(BM,({window:e,disposables:i})=>{i.add(U(e.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),i.add(U(e.document,"touchend",r=>this.onTouchEnd(e,r))),i.add(U(e.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:fr,disposables:this._store}))}static addTarget(e){if(!Ot.isTouchDevice())return te.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.targets.push(e);return Pe(i)}static ignoreTarget(e){if(!Ot.isTouchDevice())return te.None;Ot.INSTANCE||(Ot.INSTANCE=new Ot);let i=Ot.INSTANCE.ignoreTargets.push(e);return Pe(i)}static isTouchDevice(){return"ontouchstart"in fr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=e.targetTouches.length;r=Ot.HOLD_DELAY&&Math.abs(a.initialPageX-Yt(a.rollingPageX))<30&&Math.abs(a.initialPageY-Yt(a.rollingPageY))<30){let c=this.newGestureEvent(Ii.Contextmenu,a.initialTarget);c.pageX=Yt(a.rollingPageX),c.pageY=Yt(a.rollingPageY),this.dispatchEvent(c)}else if(s===1){let c=Yt(a.rollingPageX),u=Yt(a.rollingPageY),f=Yt(a.rollingTimestamps)-a.rollingTimestamps[0],d=c-a.rollingPageX[0],p=u-a.rollingPageY[0],g=[...this.targets].filter(v=>a.initialTarget instanceof Node&&v.contains(a.initialTarget));this.inertia(e,g,r,Math.abs(d)/f,d>0?1:-1,c,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Ii.End,a.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let r=document.createEvent("CustomEvent");return r.initEvent(e,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(e){if(e.type===Ii.Tap){let i=new Date().getTime(),r=0;i-this._lastSetTapCountTime>Ot.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=i,e.tapCount=r}else(e.type===Ii.Change||e.type===Ii.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(e.initialTarget))return;let i=[];for(let r of this.targets)if(r.contains(e.initialTarget)){let s=0,n=e.initialTarget;for(;n&&n!==r;)s++,n=n.parentElement;i.push([s,r])}i.sort((r,s)=>r[0]-s[0]);for(let[r,s]of i)s.dispatchEvent(e),this.dispatched=!0}}inertia(e,i,r,s,n,o,l,a,h){this.handle=xO(e,()=>{let c=Date.now(),u=c-r,f=0,d=0,p=!0;s+=Ot.SCROLL_FRICTION*u,l+=Ot.SCROLL_FRICTION*u,s>0&&(p=!1,f=n*s*u),l>0&&(p=!1,d=a*l*u);let g=this.newGestureEvent(Ii.Change);g.translationX=f,g.translationY=d,i.forEach(v=>v.dispatchEvent(g)),p||this.inertia(e,i,c,s,n,o+f,l,a,h+d)})}onTouchMove(e){let i=Date.now();for(let r=0,s=e.changedTouches.length;r3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};To.SCROLL_FRICTION=-.005,To.HOLD_DELAY=700,To.CLEAR_TAP_COUNT_TIME=400,De([WM],To,"isTouchDevice",1);var NM=To,CO=class extends te{onclick(t,e){this._register(U(t,et.CLICK,i=>e(new La(Ui(t),i))))}onmousedown(t,e){this._register(U(t,et.MOUSE_DOWN,i=>e(new La(Ui(t),i))))}onmouseover(t,e){this._register(U(t,et.MOUSE_OVER,i=>e(new La(Ui(t),i))))}onmouseleave(t,e){this._register(U(t,et.MOUSE_LEAVE,i=>e(new La(Ui(t),i))))}onkeydown(t,e){this._register(U(t,et.KEY_DOWN,i=>e(new H0(i))))}onkeyup(t,e){this._register(U(t,et.KEY_UP,i=>e(new H0(i))))}oninput(t,e){this._register(U(t,et.INPUT,e))}onblur(t,e){this._register(U(t,et.BLUR,e))}onfocus(t,e){this._register(U(t,et.FOCUS,e))}onchange(t,e){this._register(U(t,et.CHANGE,e))}ignoreGesture(t){return NM.ignoreTarget(t)}},tv=11,jM=class extends CO{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=tv+"px",this.domNode.style.height=tv+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new Bb),this._register(J0(this.bgDomNode,et.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(J0(this.domNode,et.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ZM),this._pointerdownScheduleRepeatTimer=this._register(new bO)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ui(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},VM=class vp{constructor(e,i,r,s,n,o,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,r=r|0,s=s|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=s,this.rawScrollTop=l,i<0&&(i=0),s+i>r&&(s=r-i),s<0&&(s=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=i,this.scrollWidth=r,this.scrollLeft=s,this.height=n,this.scrollHeight=o,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,i){return new vp(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new vp(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let r=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,a=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:a}}},YM=class extends te{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new VM(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){var r;let i=this._state.withScrollDimensions(t,e);this._setState(i,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let i=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let r;e?r=new rv(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=rv.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let i=this._state;i.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(i,e)))}},iv=class{constructor(t,e,i){this.scrollLeft=t,this.scrollTop=e,this.isDone=i}};function af(t,e){let i=e-t;return function(r){return t+i*HM(r)}}function qM(t,e,i){return function(r){return r2.5*r){let s,n;return e{var t;(t=this._domNode)==null||t.setClassName(this._visibleClassName)},0))}_hide(t){var e;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(e=this._domNode)==null||e.setClassName(this._invisibleClassName+(t?" fade":"")))}},GM=140,zb=class extends CO{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new UM(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Bb),this._shouldRender=!0,this.domNode=Go(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(U(this.domNode.domNode,et.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new jM(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,i,r){this.slider=Go(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof i=="number"&&this.slider.setWidth(i),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(U(this.slider.domNode,et.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,i=e+this._scrollbarState.getSliderPosition(),r=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(t);i<=s&&s<=r?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,i;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,i=t.offsetY;else{let s=XM(this.domNode.domNode);e=t.pageX-s.left,i=t.pageY-s.top}let r=this._pointerDownRelativePosition(e,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),i=this._sliderOrthogonalPointerPosition(t),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{let n=this._sliderOrthogonalPointerPosition(s),o=Math.abs(n-i);if(Ab&&o>GM){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(s)-e;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Zb=class yp{constructor(e,i,r,s,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new yp(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,r,s,n){let o=Math.max(0,r-e),l=Math.max(0,o-2*i),a=s>0&&s>r;if(!a)return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*l/s))),c=(l-h)/(s-r),u=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=yp._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,r=this._scrollPosition;return i0&&Math.abs(e.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(r+=.25),i){let s=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),l=Math.abs(i.deltaY),a=Math.max(Math.min(s,o),1),h=Math.max(Math.min(n,l),1),c=Math.max(s,o),u=Math.max(n,l);c%a===0&&u%h===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};wp.INSTANCE=new wp;var iL=wp,rL=class extends CO{constructor(t,e,i){super(),this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new L),this.onWillScroll=this._onWillScroll.event,this._options=nL(e),this._scrollable=i,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let r={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new JM(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new KM(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Go(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Go(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Go(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new bO),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=zs(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,tr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new G0(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=zs(this._mouseWheelToDispose),t)){let e=i=>{this._onMouseWheel(new G0(i))};this._mouseWheelToDispose.push(U(this._listenOnDomNode,et.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var s;if((s=t.browserEvent)!=null&&s.defaultPrevented)return;let e=iL.INSTANCE;e.acceptStandardWheelEvent(t);let i=!1;if(t.deltaY||t.deltaX){let n=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!tr&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),h={};if(n){let c=sv*n,u=a.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let c=sv*o,u=a.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,u)}h=this._scrollable.validateScrollPosition(h),(a.scrollLeft!==h.scrollLeft||a.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),i=!0)}let r=i;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,i=t.scrollLeft>0,r=i?" left":"",s=e?" top":"",n=i||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),eL)}},sL=class extends rL{constructor(t,e,i){super(t,e,i)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function nL(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,tr&&(e.className+=" mac"),e}var kp=class extends te{constructor(t,e,i,r,s,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let a=this._register(new YM({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>xO(r.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new sL(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},a)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ut.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(Pe(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(Pe(()=>this._styleElement.remove())),this._register(ut.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var t;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((t=this._optionsService.rawOptions.overviewRuler)==null?void 0:t.width)||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),i=e-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};kp=De([Z(2,Rt),Z(3,xr),Z(4,vb),Z(5,Gn),Z(6,At),Z(7,Cr)],kp);var bp=class extends te{constructor(t,e,i,r,s){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=i,this._decorationService=r,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(Pe(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){var r;let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",((r=t==null?void 0:t.options)==null?void 0:r.layer)==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=t.options.x??0;return i&&i>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let i=this._decorationElements.get(t);i||(i=this._createElement(t),t.element=i,this._decorationElements.set(t,i),this._container.appendChild(i),t.onDispose(()=>{this._decorationElements.delete(t),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(i)}}_refreshXPosition(t,e=t.element){if(!e)return;let i=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){var e;(e=this._decorationElements.get(t))==null||e.remove(),this._decorationElements.delete(t),t.dispose()}};bp=De([Z(1,Rt),Z(2,xr),Z(3,Hl),Z(4,Cr)],bp);var oL=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,i){return e>=t.startBufferLine-this._linePadding[i||"full"]&&e<=t.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},zi={full:0,left:0,center:0,right:0},Rr={full:0,left:0,center:0,right:0},mo={full:0,left:0,center:0,right:0},cc=class extends te{constructor(t,e,i,r,s,n,o,l){var h;super(),this._viewportElement=t,this._screenElement=e,this._bufferService=i,this._decorationService=r,this._renderService=s,this._optionsService=n,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new oL,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(Pe(()=>{var c;return(c=this._canvas)==null?void 0:c.remove()}));let a=this._canvas.getContext("2d");if(a)this._ctx=a;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var t;return((t=this._optionsService.options.overviewRuler)==null?void 0:t.width)||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Rr.full=this._canvas.width,Rr.left=t,Rr.center=e,Rr.right=t,this._refreshDrawHeightConstants(),mo.full=1,mo.left=1,mo.center=1+Rr.left,mo.right=1+Rr.left+Rr.center}_refreshDrawHeightConstants(){zi.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);zi.left=e,zi.center=e,zi.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zi.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(mo[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-zi[t.position||"full"]/2),Rr[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+zi[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};cc=De([Z(2,Rt),Z(3,Hl),Z(4,Cr),Z(5,At),Z(6,Gn),Z(7,xr)],cc);var P;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=` +`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(P||(P={}));var ch;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(ch||(ch={}));var Xb;(t=>t.ST=`${P.ESC}\\`)(Xb||(Xb={}));var xp=class{constructor(t,e,i,r,s,n){this._textarea=t,this._compositionView=e,this._bufferService=i,this._optionsService=r,this._coreService=s,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;e.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(e.start,this._compositionPosition.start):i=this._textarea.value.substring(e.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,i=e.replace(t,"");this._dataAlreadySent=i,e.length>t.length?this._coreService.triggerDataEvent(i,!0):e.lengththis.updateCompositionElements(!0),0)}}};xp=De([Z(2,Rt),Z(3,At),Z(4,Ws),Z(5,Cr)],xp);var it=0,rt=0,st=0,Ae=0,nv={css:"#00000000",rgba:0},Ne;(t=>{function e(s,n,o,l){return l!==void 0?`#${fs(s)}${fs(n)}${fs(o)}${fs(l)}`:`#${fs(s)}${fs(n)}${fs(o)}`}t.toCss=e;function i(s,n,o,l=255){return(s<<24|n<<16|o<<8|l)>>>0}t.toRgba=i;function r(s,n,o,l){return{css:t.toCss(s,n,o,l),rgba:t.toRgba(s,n,o,l)}}t.toColor=r})(Ne||(Ne={}));var ke;(t=>{function e(a,h){if(Ae=(h.rgba&255)/255,Ae===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,u=h.rgba>>16&255,f=h.rgba>>8&255,d=a.rgba>>24&255,p=a.rgba>>16&255,g=a.rgba>>8&255;it=d+Math.round((c-d)*Ae),rt=p+Math.round((u-p)*Ae),st=g+Math.round((f-g)*Ae);let v=Ne.toCss(it,rt,st),O=Ne.toRgba(it,rt,st);return{css:v,rgba:O}}t.blend=e;function i(a){return(a.rgba&255)===255}t.isOpaque=i;function r(a,h,c){let u=uh.ensureContrastRatio(a.rgba,h.rgba,c);if(u)return Ne.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=r;function s(a){let h=(a.rgba|255)>>>0;return[it,rt,st]=uh.toChannels(h),{css:Ne.toCss(it,rt,st),rgba:h}}t.opaque=s;function n(a,h){return Ae=Math.round(h*255),[it,rt,st]=uh.toChannels(a.rgba),{css:Ne.toCss(it,rt,st,Ae),rgba:Ne.toRgba(it,rt,st,Ae)}}t.opacity=n;function o(a,h){return Ae=a.rgba&255,n(a,Ae*h/255)}t.multiplyOpacity=o;function l(a){return[a.rgba>>24&255,a.rgba>>16&255,a.rgba>>8&255]}t.toColorRGB=l})(ke||(ke={}));var Qe;(t=>{let e,i;try{let s=document.createElement("canvas");s.width=1,s.height=1;let n=s.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return it=parseInt(s.slice(1,2).repeat(2),16),rt=parseInt(s.slice(2,3).repeat(2),16),st=parseInt(s.slice(3,4).repeat(2),16),Ne.toColor(it,rt,st);case 5:return it=parseInt(s.slice(1,2).repeat(2),16),rt=parseInt(s.slice(2,3).repeat(2),16),st=parseInt(s.slice(3,4).repeat(2),16),Ae=parseInt(s.slice(4,5).repeat(2),16),Ne.toColor(it,rt,st,Ae);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let n=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return it=parseInt(n[1]),rt=parseInt(n[2]),st=parseInt(n[3]),Ae=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ne.toColor(it,rt,st,Ae);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[it,rt,st,Ae]=e.getImageData(0,0,1,1).data,Ae!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ne.toRgba(it,rt,st,Ae),css:s}}t.toColor=r})(Qe||(Qe={}));var bt;(t=>{function e(r){return i(r>>16&255,r>>8&255,r&255)}t.relativeLuminance=e;function i(r,s,n){let o=r/255,l=s/255,a=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4);return h*.2126+c*.7152+u*.0722}t.relativeLuminance2=i})(bt||(bt={}));var uh;(t=>{function e(o,l){if(Ae=(l&255)/255,Ae===1)return l;let a=l>>24&255,h=l>>16&255,c=l>>8&255,u=o>>24&255,f=o>>16&255,d=o>>8&255;return it=u+Math.round((a-u)*Ae),rt=f+Math.round((h-f)*Ae),st=d+Math.round((c-d)*Ae),Ne.toRgba(it,rt,st)}t.blend=e;function i(o,l,a){let h=bt.relativeLuminance(o>>8),c=bt.relativeLuminance(l>>8);if(sr(h,c)>8));if(p>8));return p>v?d:g}return d}let u=s(o,l,a),f=sr(h,bt.relativeLuminance(u>>8));if(f>8));return f>p?u:d}return u}}t.ensureContrastRatio=i;function r(o,l,a){let h=o>>24&255,c=o>>16&255,u=o>>8&255,f=l>>24&255,d=l>>16&255,p=l>>8&255,g=sr(bt.relativeLuminance2(f,d,p),bt.relativeLuminance2(h,c,u));for(;g0||d>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),d-=Math.max(0,Math.ceil(d*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=sr(bt.relativeLuminance2(f,d,p),bt.relativeLuminance2(h,c,u));return(f<<24|d<<16|p<<8|255)>>>0}t.reduceLuminance=r;function s(o,l,a){let h=o>>24&255,c=o>>16&255,u=o>>8&255,f=l>>24&255,d=l>>16&255,p=l>>8&255,g=sr(bt.relativeLuminance2(f,d,p),bt.relativeLuminance2(h,c,u));for(;g>>0}t.increaseLuminance=s;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(uh||(uh={}));function fs(t){let e=t.toString(16);return e.length<2?"0"+e:e}function sr(t,e){return t1){let c=this._getJoinedRanges(r,o,n,e,s);for(let u=0;u1){let h=this._getJoinedRanges(r,o,n,e,s);for(let c=0;c=j,q=C,b=this._workCell;if(f.length>0&&C===f[0][0]&&z){let ce=f.shift(),Gc=this._isCellInSelection(ce[0],e);for(m=ce[0]+1;m=ce[1]),z?(A=!0,b=new lL(this._workCell,t.translateToString(!0,ce[0],ce[1]),ce[1]-ce[0]),q=ce[1]-1,R=b.getWidth()):j=ce[1]}let B=this._isCellInSelection(C,e),V=i&&C===n,K=$&&C>=h&&C<=c,J=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,ce=>{J=!0});let pe=b.getChars()||Vr;if(pe===" "&&(b.isUnderline()||b.isOverline())&&(pe=" "),N=R*l-a.get(pe,b.isBold(),b.isItalic()),!g)g=this._document.createElement("span");else if(v&&(B&&T||!B&&!T&&b.bg===_)&&(B&&T&&d.selectionForeground||b.fg===S)&&b.extended.ext===w&&K===k&&N===x&&!V&&!A&&!J&&z){b.isInvisible()?O+=Vr:O+=pe,v++;continue}else v&&(g.textContent=O),g=this._document.createElement("span"),v=0,O="";if(_=b.bg,S=b.fg,w=b.extended.ext,k=K,x=N,T=B,A&&n>=C&&n<=q&&(n=C),!this._coreService.isCursorHidden&&V&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&X.push("xterm-cursor-blink"),X.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(b.isBold()&&X.push("xterm-bold"),b.isItalic()&&X.push("xterm-italic"),b.isDim()&&X.push("xterm-dim"),b.isInvisible()?O=Vr:O=b.getChars()||Vr,b.isUnderline()&&(X.push(`xterm-underline-${b.extended.underlineStyle}`),O===" "&&(O=" "),!b.isUnderlineColorDefault()))if(b.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${Fl.toColorRGB(b.getUnderlineColor()).join(",")})`;else{let ce=b.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&b.isBold()&&ce<8&&(ce+=8),g.style.textDecorationColor=d.ansi[ce].css}b.isOverline()&&(X.push("xterm-overline"),O===" "&&(O=" ")),b.isStrikethrough()&&X.push("xterm-strikethrough"),K&&(g.style.textDecoration="underline");let ae=b.getFgColor(),Be=b.getFgColorMode(),ye=b.getBgColor(),kt=b.getBgColorMode(),Uc=!!b.isInverse();if(Uc){let ce=ae;ae=ye,ye=ce;let Gc=Be;Be=kt,kt=Gc}let Pr,Kl,Jn=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,ce=>{ce.options.layer!=="top"&&Jn||(ce.backgroundColorRGB&&(kt=50331648,ye=ce.backgroundColorRGB.rgba>>8&16777215,Pr=ce.backgroundColorRGB),ce.foregroundColorRGB&&(Be=50331648,ae=ce.foregroundColorRGB.rgba>>8&16777215,Kl=ce.foregroundColorRGB),Jn=ce.options.layer==="top")}),!Jn&&B&&(Pr=this._coreBrowserService.isFocused?d.selectionBackgroundOpaque:d.selectionInactiveBackgroundOpaque,ye=Pr.rgba>>8&16777215,kt=50331648,Jn=!0,d.selectionForeground&&(Be=50331648,ae=d.selectionForeground.rgba>>8&16777215,Kl=d.selectionForeground)),Jn&&X.push("xterm-decoration-top");let $r;switch(kt){case 16777216:case 33554432:$r=d.ansi[ye],X.push(`xterm-bg-${ye}`);break;case 50331648:$r=Ne.toColor(ye>>16,ye>>8&255,ye&255),this._addStyle(g,`background-color:#${ov((ye>>>0).toString(16),"0",6)}`);break;case 0:default:Uc?($r=d.foreground,X.push("xterm-bg-257")):$r=d.background}switch(Pr||b.isDim()&&(Pr=ke.multiplyOpacity($r,.5)),Be){case 16777216:case 33554432:b.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(g,$r,d.ansi[ae],b,Pr,void 0)||X.push(`xterm-fg-${ae}`);break;case 50331648:let ce=Ne.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(g,$r,ce,b,Pr,Kl)||this._addStyle(g,`color:#${ov(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,$r,d.foreground,b,Pr,Kl)||Uc&&X.push("xterm-fg-257")}X.length&&(g.className=X.join(" "),X.length=0),!V&&!A&&!J&&z?v++:g.textContent=O,N!==this.defaultSpacing&&(g.style.letterSpacing=`${N}px`),u.push(g),C=q}return g&&v&&(g.textContent=O),u}_applyMinimumContrast(t,e,i,r,s,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||cL(r.getCode()))return!1;let o=this._getContrastCache(r),l;if(!s&&!n&&(l=o.getColor(e.rgba,i.rgba)),l===void 0){let a=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=ke.ensureContrastRatio(s||e,n||i,a),o.setColor((s||e).rgba,(n||i).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let i=this._selectionStart,r=this._selectionEnd;return!i||!r?!1:this._columnSelectMode?i[0]<=r[0]?t>=i[0]&&e>=i[1]&&t=i[1]&&t>=r[0]&&e<=r[1]:e>i[1]&&e=i[0]&&t=i[0]}};Cp=De([Z(1,wb),Z(2,At),Z(3,xr),Z(4,Ws),Z(5,Hl),Z(6,Gn)],Cp);function ov(t,e,i){for(;t.length0&&(this._flat[r]=o),o}let s=t;e&&(s+="B"),i&&(s+="I");let n=this._holey.get(s);if(n===void 0){let o=0;e&&(o|=1),i&&(o|=2),n=this._measure(t,o),n>0&&this._holey.set(s,n)}return n}_measure(t,e){let i=this._measureElements[e];return i.textContent=t.repeat(32),i.offsetWidth/32}},dL=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,i,r=!1){if(this.selectionStart=e,this.selectionEnd=i,!e||!i||e[0]===i[0]&&e[1]===i[1]){this.clear();return}let s=t.buffers.active.ydisp,n=e[1]-s,o=i[1]-s,l=Math.max(n,0),a=Math.min(o,t.rows-1);if(l>=t.rows||a<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=a,this.startCol=e[0],this.endCol=i[0]}isCellSelected(t,e,i){return this.hasSelection?(i-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&i>=this.viewportCappedStartRow&&e=this.viewportCappedStartRow&&e>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i=this.startCol&&e=this.startCol):!1}};function pL(){return new dL}var hf="xterm-dom-renderer-owner-",si="xterm-rows",Ba="xterm-fg-",lv="xterm-bg-",_o="xterm-focus",za="xterm-selection",gL=1,Pp=class extends te{constructor(t,e,i,r,s,n,o,l,a,h,c,u,f,d){super(),this._terminal=t,this._document=e,this._element=i,this._screenElement=r,this._viewportElement=s,this._helperContainer=n,this._linkifier2=o,this._charSizeService=a,this._optionsService=h,this._bufferService=c,this._coreService=u,this._coreBrowserService=f,this._themeService=d,this._terminalClass=gL++,this._rowElements=[],this._selectionRenderModel=pL(),this.onRequestRedraw=this._register(new L).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(si),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(za),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=uL(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Cp,document),this._element.classList.add(hf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(Pe(()=>{this._element.classList.remove(hf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new fL(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${si} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${si} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${si} .xterm-dim { color: ${ke.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;e+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${r} { 50% { box-shadow: none; }}`,e+=`@keyframes ${s} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${si}.${_o} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${si}.${_o} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${si}.${_o} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${si} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${si} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${si} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${si} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${si} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${za} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${za} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${za} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of t.ansi.entries())e+=`${this._terminalSelector} .${Ba}${n} { color: ${o.css}; }${this._terminalSelector} .${Ba}${n}.xterm-dim { color: ${ke.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${lv}${n} { background-color: ${o.css}; }`;e+=`${this._terminalSelector} .${Ba}257 { color: ${ke.opaque(t.background).css}; }${this._terminalSelector} .${Ba}257.xterm-dim { color: ${ke.multiplyOpacity(ke.opaque(t.background),.5).css}; }${this._terminalSelector} .${lv}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let i=this._rowElements.length;i<=e;i++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(_o),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(_o),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,i),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,i),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(i){let a=t[0]>e[0];l.appendChild(this._createSelectionElement(n,a?e[0]:t[0],a?t[0]:e[0],o-n+1))}else{let a=r===n?t[0]:0,h=n===s?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,a,h));let c=o-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let u=s===o?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,i,r=1){let s=this._document.createElement("div"),n=e*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-e);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${t*this.dimensions.css.cell.height}px`,s.style.left=`${n}px`,s.style.width=`${o}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let i=this._bufferService.buffer,r=i.ybase+i.y,s=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=t;a<=e;a++){let h=a+i.ydisp,c=this._rowElements[a],u=i.lines.get(h);if(!c||!u)break;c.replaceChildren(...this._rowFactory.createRow(u,h,h===r,o,l,s,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${hf}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,i,r,s,n){i<0&&(t=0),r<0&&(e=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),r=Math.max(Math.min(r,o),0),s=Math.min(s,this._bufferService.cols);let l=this._bufferService.buffer,a=l.ybase+l.y,h=Math.min(l.x,s-1),c=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let d=i;d<=r;++d){let p=d+l.ydisp,g=this._rowElements[d],v=l.lines.get(p);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,p,p===a,u,f,h,c,this.dimensions.css.cell.width,this._widthCache,n?d===i?t:0:-1,n?(d===r?e:s)-1:-1))}}};Pp=De([Z(7,vO),Z(8,qc),Z(9,At),Z(10,Rt),Z(11,Ws),Z(12,xr),Z(13,Gn)],Pp);var $p=class extends te{constructor(t,e,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new L),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new mL(this._optionsService))}catch{this._measureStrategy=this._register(new OL(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};$p=De([Z(2,At)],$p);var Ib=class extends te{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},OL=class extends Ib{constructor(t,e,i){super(),this._document=t,this._parentElement=e,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},mL=class extends Ib{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},_L=class extends te{constructor(t,e,i){super(),this._textarea=t,this._window=e,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new vL(this._window)),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new L),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(U(this._textarea,"focus",()=>this._isFocused=!0)),this._register(U(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},vL=class extends te{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new jn),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Pe(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=U(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var t;this._outerListener&&((t=this._resolutionMediaMatchList)==null||t.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},SL=class extends te{constructor(){super(),this.linkProviders=[],this._register(Pe(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function PO(t,e,i){let r=i.getBoundingClientRect(),s=t.getComputedStyle(i),n=parseInt(s.getPropertyValue("padding-left")),o=parseInt(s.getPropertyValue("padding-top"));return[e.clientX-r.left-n,e.clientY-r.top-o]}function yL(t,e,i,r,s,n,o,l,a){if(!n)return;let h=PO(t,e,i);if(h)return h[0]=Math.ceil((h[0]+(a?o/2:0))/o),h[1]=Math.ceil(h[1]/l),h[0]=Math.min(Math.max(h[0],1),r+(a?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var Qp=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,i,r,s){return yL(window,t,e,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(t,e){let i=PO(window,t,e);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Qp=De([Z(0,Cr),Z(1,qc)],Qp);var wL=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,i){this._rowCount=i,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Wb={};RA(Wb,{getSafariVersion:()=>bL,isChromeOS:()=>Yb,isFirefox:()=>Nb,isIpad:()=>xL,isIphone:()=>CL,isLegacyEdge:()=>kL,isLinux:()=>$O,isMac:()=>fc,isNode:()=>Fc,isSafari:()=>jb,isWindows:()=>Vb});var Fc=typeof process<"u"&&"title"in process,Ul=Fc?"node":navigator.userAgent,Gl=Fc?"node":navigator.platform,Nb=Ul.includes("Firefox"),kL=Ul.includes("Edge"),jb=/^((?!chrome|android).)*safari/i.test(Ul);function bL(){if(!jb)return 0;let t=Ul.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var fc=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Gl),xL=Gl==="iPad",CL=Gl==="iPhone",Vb=["Windows","Win16","Win32","WinCE"].includes(Gl),$O=Gl.indexOf("Linux")>=0,Yb=/\bCrOS\b/.test(Ul),qb=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._is){r-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-e))}ms`),this._start();return}r=s}this.clear()}},PL=class extends qb{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},$L=class extends qb{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},dc=!Fc&&"requestIdleCallback"in window?$L:PL,QL=class{constructor(){this._queue=new dc}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Tp=class extends te{constructor(t,e,i,r,s,n,o,l,a){super(),this._rowCount=t,this._optionsService=i,this._charSizeService=r,this._coreService=s,this._coreBrowserService=l,this._renderer=this._register(new jn),this._pausedResizeTask=new QL,this._observerDisposable=this._register(new jn),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new L),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new L),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new L),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new wL((h,c)=>this._renderRows(h,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new TL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Pe(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(a.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let i=new t.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});i.observe(e),this._observerDisposable.value=Pe(()=>i.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let r=this._syncOutputHandler.flush();r&&(t=Math.min(t,r.start),e=Math.max(e,r.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var t,e;this._renderer.value&&((e=(t=this._renderer.value).clearTextureAtlas)==null||e.call(t),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(t,e)}):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){var t;(t=this._renderer.value)==null||t.handleCharSizeChanged()}handleBlur(){var t;(t=this._renderer.value)==null||t.handleBlur()}handleFocus(){var t;(t=this._renderer.value)==null||t.handleFocus()}handleSelectionChanged(t,e,i){var r;this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=i,(r=this._renderer.value)==null||r.handleSelectionChanged(t,e,i)}handleCursorMove(){var t;(t=this._renderer.value)==null||t.handleCursorMove()}clear(){var t;(t=this._renderer.value)==null||t.clear()}};Tp=De([Z(2,At),Z(3,qc),Z(4,Ws),Z(5,Hl),Z(6,Rt),Z(7,xr),Z(8,Gn)],Tp);var TL=class{constructor(t,e,i){this._coreBrowserService=t,this._coreService=e,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function EL(t,e,i,r){let s=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return ML(s,n,t,e,i,r)+Hc(n,e,i,r)+LL(s,n,t,e,i,r);let o;if(n===e)return o=s>t?"D":"C",El(Math.abs(s-t),Tl(o,r));o=n>e?"D":"C";let l=Math.abs(n-e),a=AL(n>e?t:s,i)+(l-1)*i.cols+1+RL(n>e?s:t);return El(a,Tl(o,r))}function RL(t,e){return t-1}function AL(t,e){return e.cols-t}function ML(t,e,i,r,s,n){return Hc(e,r,s,n).length===0?"":El(Hb(t,e,t,e-Zs(e,s),!1,s).length,Tl("D",n))}function Hc(t,e,i,r){let s=t-Zs(t,i),n=e-Zs(e,i),o=Math.abs(s-n)-DL(t,e,i);return El(o,Tl(Fb(t,e),r))}function LL(t,e,i,r,s,n){let o;Hc(e,r,s,n).length>0?o=r-Zs(r,s):o=e;let l=r,a=BL(t,e,i,r,s,n);return El(Hb(t,o,i,l,a==="C",s).length,Tl(a,n))}function DL(t,e,i){var o;let r=0,s=t-Zs(t,i),n=e-Zs(e,i);for(let l=0;l=0&&t0?o=r-Zs(r,s):o=e,t=i&&oe?"A":"B"}function Hb(t,e,i,r,s,n){let o=t,l=e,a="";for(;(o!==i||l!==r)&&l>=0&&ln.cols-1?(a+=n.buffer.translateBufferLineToString(l,!1,t,o),o=0,t=0,l++):!s&&o<0&&(a+=n.buffer.translateBufferLineToString(l,!1,0,t+1),o=n.cols-1,t=o,l--);return a+n.buffer.translateBufferLineToString(l,!1,t,o)}function Tl(t,e){let i=e?"O":"[";return P.ESC+i+t}function El(t,e){t=Math.floor(t);let i="";for(let r=0;rthis._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function av(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var cf=50,ZL=15,XL=50,IL=500,WL=" ",NL=new RegExp(WL,"g"),Ep=class extends te{constructor(t,e,i,r,s,n,o,l,a){super(),this._element=t,this._screenElement=e,this._linkifier=i,this._bufferService=r,this._coreService=s,this._mouseService=n,this._optionsService=o,this._renderService=l,this._coreBrowserService=a,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new gi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new L),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new L),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new zL(this._bufferService),this._activeSelectionMode=0,this._register(Pe(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let i=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let s=t[0]s.replace(NL," ")).join(Vb?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),$O&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r||!e?!1:this._areCoordsInSelection(e,i,r)}isCellInSelection(t,e){let i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r?!1:this._areCoordsInSelection([t,e],i,r)}_areCoordsInSelection(t,e,i){return t[1]>e[1]&&t[1]=e[0]&&t[0]=e[0]}_selectWordAtCursor(t,e){var s,n;let i=(n=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=av(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(t);return r?(this._selectWordAt(r,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=PO(this._coreBrowserService.window,t,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=i?0:(e>i&&(e-=i),e=Math.min(Math.max(e,-cf),cf),e/=cf,e/Math.abs(e)+Math.round(e*(ZL-1)))}shouldForceSelection(t){return fc?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),XL)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(fc&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&ethis._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let i=e;for(let r=0;e>=r;r++){let s=t.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:s>1&&e!==r&&(i+=s-1)}return i}setSelection(t,e,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,i=!0,r=!0){if(t[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,n=s.lines.get(t[1]);if(!n)return;let o=s.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(n,t[0]),a=l,h=t[0]-l,c=0,u=0,f=0,d=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;a1&&(d+=m-1,a+=m-1);v>0&&l>0&&!this._isCharWordSeparator(n.loadCell(v-1,this._workCell));){n.loadCell(v-1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,v--):_>1&&(f+=_-1,l-=_-1),l--,v--}for(;O1&&(d+=_-1,a+=_-1),a++,O++}}a++;let p=l+h-c+f,g=Math.min(this._bufferService.cols,a-l+c+u-f-d);if(!(!e&&o.slice(l,a).trim()==="")){if(i&&p===0&&n.getCodePoint(0)!==32){let v=s.lines.get(t[1]-1);if(v&&n.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let O=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(O){let m=this._bufferService.cols-O.start;p-=m,g+=m}}}if(r&&p+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let v=s.lines.get(t[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let O=this._getWordAt([0,t[1]+1],!1,!1,!0);O&&(g+=O.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let i=this._getWordAt(t,e);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[i.start,t[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let i=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,i]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),i={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=av(i,this._bufferService.cols)}};Ep=De([Z(3,Rt),Z(4,Ws),Z(5,SO),Z(6,At),Z(7,Cr),Z(8,xr)],Ep);var hv=class{constructor(){this._data={}}set(t,e,i){this._data[t]||(this._data[t]={}),this._data[t][e]=i}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},cv=class{constructor(){this._color=new hv,this._css=new hv}setCss(t,e,i){this._css.set(t,e,i)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,i){this._color.set(t,e,i)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},qe=Object.freeze((()=>{let t=[Qe.toColor("#2e3436"),Qe.toColor("#cc0000"),Qe.toColor("#4e9a06"),Qe.toColor("#c4a000"),Qe.toColor("#3465a4"),Qe.toColor("#75507b"),Qe.toColor("#06989a"),Qe.toColor("#d3d7cf"),Qe.toColor("#555753"),Qe.toColor("#ef2929"),Qe.toColor("#8ae234"),Qe.toColor("#fce94f"),Qe.toColor("#729fcf"),Qe.toColor("#ad7fa8"),Qe.toColor("#34e2e2"),Qe.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let i=0;i<216;i++){let r=e[i/36%6|0],s=e[i/6%6|0],n=e[i%6];t.push({css:Ne.toCss(r,s,n),rgba:Ne.toRgba(r,s,n)})}for(let i=0;i<24;i++){let r=8+i*10;t.push({css:Ne.toCss(r,r,r),rgba:Ne.toRgba(r,r,r)})}return t})()),Os=Qe.toColor("#ffffff"),Eo=Qe.toColor("#000000"),uv=Qe.toColor("#ffffff"),fv=Eo,vo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},jL=Os,Rp=class extends te{constructor(t){super(),this._optionsService=t,this._contrastCache=new cv,this._halfContrastCache=new cv,this._onChangeColors=this._register(new L),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Os,background:Eo,cursor:uv,cursorAccent:fv,selectionForeground:void 0,selectionBackgroundTransparent:vo,selectionBackgroundOpaque:ke.blend(Eo,vo),selectionInactiveBackgroundTransparent:vo,selectionInactiveBackgroundOpaque:ke.blend(Eo,vo),scrollbarSliderBackground:ke.opacity(Os,.2),scrollbarSliderHoverBackground:ke.opacity(Os,.4),scrollbarSliderActiveBackground:ke.opacity(Os,.5),overviewRulerBorder:Os,ansi:qe.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=ge(t.foreground,Os),e.background=ge(t.background,Eo),e.cursor=ke.blend(e.background,ge(t.cursor,uv)),e.cursorAccent=ke.blend(e.background,ge(t.cursorAccent,fv)),e.selectionBackgroundTransparent=ge(t.selectionBackground,vo),e.selectionBackgroundOpaque=ke.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ge(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=ke.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ge(t.selectionForeground,nv):void 0,e.selectionForeground===nv&&(e.selectionForeground=void 0),ke.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=ke.opacity(e.selectionBackgroundTransparent,.3)),ke.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=ke.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ge(t.scrollbarSliderBackground,ke.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ge(t.scrollbarSliderHoverBackground,ke.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ge(t.scrollbarSliderActiveBackground,ke.opacity(e.foreground,.5)),e.overviewRulerBorder=ge(t.overviewRulerBorder,jL),e.ansi=qe.slice(),e.ansi[0]=ge(t.black,qe[0]),e.ansi[1]=ge(t.red,qe[1]),e.ansi[2]=ge(t.green,qe[2]),e.ansi[3]=ge(t.yellow,qe[3]),e.ansi[4]=ge(t.blue,qe[4]),e.ansi[5]=ge(t.magenta,qe[5]),e.ansi[6]=ge(t.cyan,qe[6]),e.ansi[7]=ge(t.white,qe[7]),e.ansi[8]=ge(t.brightBlack,qe[8]),e.ansi[9]=ge(t.brightRed,qe[9]),e.ansi[10]=ge(t.brightGreen,qe[10]),e.ansi[11]=ge(t.brightYellow,qe[11]),e.ansi[12]=ge(t.brightBlue,qe[12]),e.ansi[13]=ge(t.brightMagenta,qe[13]),e.ansi[14]=ge(t.brightCyan,qe[14]),e.ansi[15]=ge(t.brightWhite,qe[15]),t.extendedAnsi){let i=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let r=0;rn.index-o.index),r=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);r.push(o)}let s=i.length>0?i[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new t(...e,...r)}},qL={trace:0,debug:1,info:2,warn:3,error:4,off:5},FL="xterm.js: ",Ap=class extends te{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=qL[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;ethis._length)for(let e=this._length;e=t;r--)this._array[this._getCyclicIndex(r+i.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;rthis._maxLength){let r=this._length+i.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=i.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,i){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let s=e-1;s>=0;s--)this.set(t+s+i,this.get(t+s));let r=t+e+i-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):r]}set(e,i){this._data[e*ee+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[e*ee+0]=e|2097152|i[2]<<22):this._data[e*ee+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[e*ee+0]>>22}hasWidth(e){return this._data[e*ee+0]&12582912}getFg(e){return this._data[e*ee+1]}getBg(e){return this._data[e*ee+2]}hasContent(e){return this._data[e*ee+0]&4194303}getCodePoint(e){let i=this._data[e*ee+0];return i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i&2097151}isCombined(e){return this._data[e*ee+0]&2097152}getString(e){let i=this._data[e*ee+0];return i&2097152?this._combined[e]:i&2097151?zr(i&2097151):""}isProtected(e){return this._data[e*ee+2]&536870912}loadCell(e,i){return Za=e*ee,i.content=this._data[Za+0],i.fg=this._data[Za+1],i.bg=this._data[Za+2],i.content&2097152&&(i.combinedData=this._combined[e]),i.bg&268435456&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){i.content&2097152&&(this._combined[e]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*ee+0]=i.content,this._data[e*ee+1]=i.fg,this._data[e*ee+2]=i.bg}setCellFromCodepoint(e,i,r,s){s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*ee+0]=i|r<<22,this._data[e*ee+1]=s.fg,this._data[e*ee+2]=s.bg}addCodepointToCell(e,i,r){let s=this._data[e*ee+0];s&2097152?this._combined[e]+=zr(i):s&2097151?(this._combined[e]=zr(s&2097151)+zr(i),s&=-2097152,s|=2097152):s=i|1<<22,r&&(s&=-12582913,s|=r<<22),this._data[e*ee+0]=s}insertCells(e,i,r){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,r),i=0;--n)this.setCell(e+i+n,this.loadCell(e+n,s));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let s=new Uint32Array(r);s.set(this._data),this._data=s}for(let s=this.length;s=e&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=e&&delete this._extendedAttrs[l]}}return this.length=e,r*4*uf=0;--e)if(this._data[e*ee+0]&4194303)return e+(this._data[e*ee+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ee+0]&4194303||this._data[e*ee+2]&50331648)return e+(this._data[e*ee+0]>>22);return 0}copyCellsFrom(e,i,r,s,n){let o=e._data;if(n)for(let a=s-1;a>=0;a--){for(let h=0;h=i&&(this._combined[h-i+r]=e._combined[h])}}translateToString(e,i,r,s){i=i??0,r=r??this.length,e&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let n="";for(;i>22||1}return s&&s.push(i),n}};function HL(t,e,i,r,s,n){let o=[];for(let l=0;l=l&&r0&&(v>u||c[v].getTrimmedLength()===0);v--)g++;g>0&&(o.push(l+c.length-g),o.push(g)),l+=c.length-1}return o}function UL(t,e){let i=[],r=0,s=e[r],n=0;for(let o=0;oRl(t,h,e)).reduce((a,h)=>a+h),n=0,o=0,l=0;for(;la&&(n-=a,o++);let h=t[o].getWidth(n-1)===2;h&&n--;let c=h?i-1:i;r.push(c),l+=c}return r}function Rl(t,e,i){if(e===t.length-1)return t[e].getTrimmedLength();let r=!t[e].hasContent(i-1)&&t[e].getWidth(i-1)===1,s=t[e+1].getWidth(0)===2;return r&&s?i-1:i}var Gb=class Kb{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Kb._nextId++,this._onDispose=this.register(new L),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),zs(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Gb._nextId=1;var JL=Gb,Je={},ms=Je.B;Je[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Je.A={"#":"£"};Je.B=void 0;Je[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Je.C=Je[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Je.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Je.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Je.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Je.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Je.E=Je[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Je.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Je.H=Je[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Je["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var pv=4294967295,gv=class{constructor(t,e,i){this._hasScrollback=t,this._optionsService=e,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=We.clone(),this.savedCharset=ms,this.markers=[],this._nullCell=gi.fromCharData([0,gb,1,0]),this._whitespaceCell=gi.fromCharData([0,Vr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new dc,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new dv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new hc),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new hc),this._whitespaceCell}getBlankLine(t,e){return new Ro(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&tpv?pv:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=We);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new dv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let i=this.getNullCell(We),r=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ro(t,i)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=s}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,r=HL(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(We),i);if(r.length>0){let s=UL(this.lines,r);GL(this.lines,s.layout),this._reflowLargerAdjustViewport(t,e,s.countRemoved)}}_reflowLargerAdjustViewport(t,e,i){let r=this.getNullCell(We),s=i;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let a=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),a.unshift(l);if(!i){let _=this.ybase+this.y;if(_>=o&&_0&&(s.push({start:o+a.length+n,newLines:d}),n+=d.length),a.push(...d);let p=c.length-1,g=c[p];g===0&&(p--,g=c[p]);let v=a.length-u-1,O=h;for(;v>=0;){let _=Math.min(O,g);if(a[p]===void 0)break;if(a[p].copyCellsFrom(a[v],O-_,g-_,_,!0),g-=_,g===0&&(p--,g=c[p]),O-=_,O===0){v--;let S=Math.max(v,0);O=Rl(a,S,this._cols)}}for(let _=0;_0;)this.ybase===0?this.y0){let o=[],l=[];for(let g=0;g=0;g--)if(u&&u.start>h+f){for(let v=u.newLines.length-1;v>=0;v--)this.lines.set(g--,u.newLines[v]);g++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=s[++c]}else this.lines.set(g,l[h--]);let d=0;for(let g=o.length-1;g>=0;g--)o[g].index+=d,this.lines.onInsertEmitter.fire(o[g]),d+=o[g].amount;let p=Math.max(0,a+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,i=0,r){let s=this.lines.get(t);return s?s.translateToString(e,i,r):""}getWrappedRangeForLine(t){let e=t,i=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;i+10;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e{e.line-=i,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(i=>{e.line>=i.index&&(e.line+=i.amount)})),e.register(this.lines.onDelete(i=>{e.line>=i.index&&e.linei.index&&(e.line-=i.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},e3=class extends te{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new L),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new gv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gv(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},Jb=2,ex=1,Mp=class extends te{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Jb),this.rows=Math.max(t.rawOptions.rows||0,ex),this.buffers=this._register(new e3(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let i=this.cols!==t,r=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:i,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let i=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==t.fg||r.getBg(0)!==t.bg)&&(r=i.getBlankLine(t,e),this._cachedBlankLine=r),r.isWrapped=e;let s=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(n+1,0,r.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-s+1;i.lines.shiftElements(s+1,o-1,-1),i.lines.set(n,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(t,e){let i=this.buffer;if(t<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else t+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let r=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+t,i.ybase),0),r!==i.ydisp&&(e||this._onScroll.fire(i.ydisp))}};Mp=De([Z(0,At)],Mp);var Vs={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:fc,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},t3=["normal","bold","100","200","300","400","500","600","700","800","900"],i3=class extends te{constructor(t){super(),this._onOptionChange=this._register(new L),this.onOptionChange=this._onOptionChange.event;let e={...Vs};for(let i in t)if(i in e)try{let r=t[i];e[i]=this._sanitizeAndValidateOption(i,r)}catch(r){console.error(r)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Pe(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(i=>{i===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(i=>{t.indexOf(i)!==-1&&e()})}_setupOptions(){let t=i=>{if(!(i in Vs))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},e=(i,r)=>{if(!(i in Vs))throw new Error(`No option with key "${i}"`);r=this._sanitizeAndValidateOption(i,r),this.rawOptions[i]!==r&&(this.rawOptions[i]=r,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let r={get:t.bind(this,i),set:e.bind(this,i)};Object.defineProperty(this.options,i,r)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Vs[t]),!r3(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Vs[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=t3.includes(e)?e:Vs[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function r3(t){return t==="block"||t==="underline"||t==="bar"}function Ao(t,e=5){if(typeof t!="object")return t;let i=Array.isArray(t)?[]:{};for(let r in t)i[r]=e<=1?t[r]:t[r]&&Ao(t[r],e-1);return i}var Ov=Object.freeze({insertMode:!1}),mv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Lp=class extends te{constructor(t,e,i){super(),this._bufferService=t,this._logService=e,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new L),this.onData=this._onData.event,this._onUserInput=this._register(new L),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new L),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ao(Ov),this.decPrivateModes=Ao(mv)}reset(){this.modes=Ao(Ov),this.decPrivateModes=Ao(mv)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(r=>r.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};Lp=De([Z(0,Rt),Z(1,Sb),Z(2,At)],Lp);var _v={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function ff(t,e){let i=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(i|=64,i|=t.action):(i|=t.button&3,t.button&4&&(i|=64),t.button&8&&(i|=128),t.action===32?i|=32:t.action===0&&!e&&(i|=3)),i}var df=String.fromCharCode,vv={DEFAULT:t=>{let e=[ff(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${df(e[0])}${df(e[1])}${df(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ff(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ff(t,!0)};${t.x};${t.y}${e}`}},Dp=class extends te{constructor(t,e,i){super(),this._bufferService=t,this._coreService=e,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new L),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(_v))this.addProtocol(r,_v[r]);for(let r of Object.keys(vv))this.addEncoding(r,vv[r]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,i){if(t.deltaY===0||t.shiftKey||e===void 0||i===void 0)return 0;let r=e/i,s=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=r+0,Math.abs(t.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,i){if(i){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Dp=De([Z(0,Rt),Z(1,Ws),Z(2,At)],Dp);var pf=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],s3=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Fe;function n3(t,e){let i=0,r=e.length-1,s;if(te[r][1])return!1;for(;r>=i;)if(s=i+r>>1,t>e[s][1])i=s+1;else if(t=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let i=this.wcwidth(t),r=i===0&&e!==0;if(r){let s=xs.extractWidth(e);s===0?r=!1:s>i&&(i=s)}return xs.createPropertyValue(0,i,r)}},xs=class fh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new L,this.onChange=this._onChange.event;let e=new o3;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,r=!1){return(e&16777215)<<3|(i&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let i=0,r=0,s=e.length;for(let n=0;n=s)return i+this.wcwidth(o);let h=e.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let l=this.charProperties(o,r),a=fh.extractWidth(l);fh.extractShouldJoin(l)&&(a-=fh.extractWidth(r)),i+=a,r=l}return i}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},l3=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function Sv(t){var r;let e=(r=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:r.get(t.cols-1),i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);i&&e&&(i.isWrapped=e[3]!==0&&e[3]!==32)}var So=2147483647,a3=256,tx=class Bp{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>a3)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let i=new Bp;if(!e.length)return i;for(let r=Array.isArray(e[0])?1:0;r>8,s=this._subParamsIdx[i]&255;s-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>So?So:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>So?So:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,r=this._subParamsIdx[e]&255;return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let e={};for(let i=0;i>8,s=this._subParamsIdx[i]&255;s-r>0&&(e[i]=this._subParams.slice(r,s))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[i-1];r[i-1]=~s?Math.min(s*10+e,So):e}},yo=[],h3=class{constructor(){this._state=0,this._active=yo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let i=this._handlers[t];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=yo}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=yo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||yo,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Yc(t,e,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(t,e,i)}start(){this.reset(),this._state=1}put(t,e,i){if(this._state!==3){if(this._state===1)for(;e0&&this._put(t,e,i)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].end(t),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=yo,this._id=-1,this._state=0}}},qt=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=Yc(t,e,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,e}},wo=[],c3=class{constructor(){this._handlers=Object.create(null),this._active=wo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=wo}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let i=this._handlers[t];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=wo,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||wo,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(e)}put(t,e,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Yc(t,e,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(t,e,i)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let i=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&i===!1){for(;r>=0&&(i=this._active[r].unhook(t),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=wo,this._ident=0}},Mo=new tx;Mo.addParam(0);var yv=class{constructor(t){this._handler=t,this._data="",this._params=Mo,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Mo,this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=Yc(t,e,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(i=>(this._params=Mo,this._data="",this._hitLimit=!1,i));return this._params=Mo,this._data="",this._hitLimit=!1,e}},u3=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,i,r){this.table[e<<8|t]=i<<4|r}addMany(t,e,i,r){for(let s=0;sa),i=(l,a)=>e.slice(l,a),r=i(32,127),s=i(0,24);s.push(25),s.push.apply(s,i(28,32));let n=i(0,14),o;t.setDefault(1,0),t.addMany(r,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(i(128,144),o,3,0),t.addMany(i(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(s,0,3,0),t.addMany(s,1,3,1),t.add(127,1,0,1),t.addMany(s,8,0,8),t.addMany(s,3,3,3),t.add(127,3,0,3),t.addMany(s,4,3,4),t.add(127,4,0,4),t.addMany(s,6,3,6),t.addMany(s,5,3,5),t.add(127,5,0,5),t.addMany(s,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(r,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(i(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(r,7,0,7),t.addMany(s,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(i(64,127),3,7,0),t.addMany(i(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(i(48,60),4,8,4),t.addMany(i(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(i(32,64),6,0,6),t.add(127,6,0,6),t.addMany(i(64,127),6,0,0),t.addMany(i(32,48),3,9,5),t.addMany(i(32,48),5,9,5),t.addMany(i(48,64),5,0,6),t.addMany(i(64,127),5,7,0),t.addMany(i(32,48),4,9,5),t.addMany(i(32,48),1,9,2),t.addMany(i(32,48),2,9,2),t.addMany(i(48,127),2,10,0),t.addMany(i(48,80),1,10,0),t.addMany(i(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(i(96,127),1,10,0),t.add(80,1,11,9),t.addMany(s,9,0,9),t.add(127,9,0,9),t.addMany(i(28,32),9,0,9),t.addMany(i(32,48),9,9,12),t.addMany(i(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(s,11,0,11),t.addMany(i(32,128),11,0,11),t.addMany(i(28,32),11,0,11),t.addMany(s,10,0,10),t.add(127,10,0,10),t.addMany(i(28,32),10,0,10),t.addMany(i(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(i(32,48),10,9,12),t.addMany(s,12,0,12),t.add(127,12,0,12),t.addMany(i(28,32),12,0,12),t.addMany(i(32,48),12,9,12),t.addMany(i(48,64),12,0,11),t.addMany(i(64,127),12,12,13),t.addMany(i(64,127),10,12,13),t.addMany(i(64,127),9,12,13),t.addMany(s,13,13,13),t.addMany(r,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(oi,0,2,0),t.add(oi,8,5,8),t.add(oi,6,0,6),t.add(oi,11,0,11),t.add(oi,13,13,13),t}(),d3=class extends te{constructor(t=f3){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new tx,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,r)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Pe(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new h3),this._dcsParser=this._register(new c3),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let i=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=t.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;sn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(t.final.length!==1)throw new Error("final must be a single byte");let r=t.final.charCodeAt(0);if(e[0]>r||r>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return i<<=8,i|=r,i}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let i=this._identifier(t,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let r=this._escHandlers[i];return r.push(e),{dispose:()=>{let s=r.indexOf(e);s!==-1&&r.splice(s,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let i=this._identifier(t);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let r=this._csiHandlers[i];return r.push(e),{dispose:()=>{let s=r.indexOf(e);s!==-1&&r.splice(s,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,i,r,s){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=i,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(t,e,i){let r=0,s=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&a>-1){for(;a>=0&&(o=l[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&a>-1){for(;a>=0&&(o=l[a](),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 6:if(r=t[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=t[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,i),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l>4){case 2:for(let f=l+1;;++f){if(f>=e||(r=t[f])<32||r>126&&r=e||(r=t[f])<32||r>126&&r=e||(r=t[f])<32||r>126&&r=e||(r=t[f])<32||r>126&&r=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,a,h,s,l),o;h<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++l47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],u=c?c.length-1:-1;for(;u>=0&&(o=c[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,c,u,s,l),o;u<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(r=t[f])===24||r===26||r===27||r>127&&r=e||(r=t[f])<32||r>127&&r>4:n>>8}return r}}function gf(t,e){let i=t.toString(16),r=i.length<2?"0"+i:i;switch(e){case 4:return i[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function O3(t,e=16){let[i,r,s]=t;return`rgb:${gf(i,e)}/${gf(r,e)}/${gf(s,e)}`}var m3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ar=131072,kv=10;function bv(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var xv=5e3,Cv=0,_3=class extends te{constructor(t,e,i,r,s,n,o,l,a=new d3){super(),this._bufferService=t,this._charsetService=e,this._coreService=i,this._logService=r,this._optionsService=s,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=a,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new BA,this._utf8Decoder=new zA,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=We.clone(),this._eraseAttrDataInternal=We.clone(),this._onRequestBell=this._register(new L),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new L),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new L),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new L),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new L),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new L),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new L),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new L),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new L),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new zp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:u})}),this._parser.setDcsHandlerFallback((h,c,u)=>{c==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:u})}),this._parser.setPrintHandler((h,c,u)=>this.print(h,c,u)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(P.BEL,()=>this.bell()),this._parser.setExecuteHandler(P.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(P.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(P.BS,()=>this.backspace()),this._parser.setExecuteHandler(P.HT,()=>this.tab()),this._parser.setExecuteHandler(P.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(P.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ch.IND,()=>this.index()),this._parser.setExecuteHandler(ch.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ch.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qt(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new qt(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new qt(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new qt(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new qt(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new qt(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new qt(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new qt(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new qt(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new qt(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new qt(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new qt(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Je)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new yv((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,i,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=i,this._parseStack.position=r}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),xv))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${xv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let i,r=this._activeBuffer.x,s=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(i),i;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Ar&&(n=this._parseStack.position+Ar)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(h=>h.charCodeAt(0)):t),this._parseBuffer.lengthAr)for(let h=n;h0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let f=this._parser.precedingJoinState;for(let d=e;dl){if(a){let O=u,m=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&u instanceof Ro&&u.copyCellsFrom(O,m,0,v,!1);m=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(u.insertCells(this._activeBuffer.x,s-v,this._activeBuffer.getNullCell(c)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,c)),u.setCellFromCodepoint(this._activeBuffer.x++,r,s,c),s>0)for(;--s;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,i=>bv(i.params[0],this._optionsService.rawOptions.windowOptions)?e(i):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new yv(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new qt(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var t;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&t.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,i,r=!1,s=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,i,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(n.isWrapped=!1)}_resetBufferLine(t,e=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),i.isWrapped=!1)}eraseInDisplay(t,e=!1){var r;this._restrictCursor(this._bufferService.cols);let i;switch(t.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);i=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&r.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let a=l;for(let h=1;h0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(P.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(P.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(P.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(P.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(P.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let r=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:a}=this._bufferService,{active:h,alt:c}=l,u=this._optionsService.rawOptions,f=(g,v)=>(o.triggerDataEvent(`${P.ESC}[${e?"":"?"}${g};${v}$y`),!0),d=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,d(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,d(u.convertEol)):f(p,0):p===1?f(p,d(r.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?a===80?2:a===132?1:0:0):p===6?f(p,d(r.origin)):p===7?f(p,d(r.wraparound)):p===8?f(p,3):p===9?f(p,d(s==="X10")):p===12?f(p,d(u.cursorBlink)):p===25?f(p,d(!o.isCursorHidden)):p===45?f(p,d(r.reverseWraparound)):p===66?f(p,d(r.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,d(s==="VT200")):p===1002?f(p,d(s==="DRAG")):p===1003?f(p,d(s==="ANY")):p===1004?f(p,d(r.sendFocus)):p===1005?f(p,4):p===1006?f(p,d(n==="SGR")):p===1015?f(p,4):p===1016?f(p,d(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,d(h===c)):p===2004?f(p,d(r.bracketedPasteMode)):p===2026?f(p,d(r.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,i,r,s){return e===2?(t|=50331648,t&=-16777216,t|=Fl.fromColorRGB([i,r,s])):e===5&&(t&=-50331904,t|=33554432|i&255),t}_extractColor(t,e,i){let r=[0,0,-1,0,0,0],s=0,n=0;do{if(r[n+s]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),l=0;do r[1]===5&&(s=1),r[n+l+1+s]=o[l];while(++l=2||r[1]===2&&n+s>=5)break;r[1]&&(s=1)}while(++n+e5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=We.fg,t.bg=We.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,i,r=this._curAttrData;for(let s=0;s=30&&i<=37?(r.fg&=-50331904,r.fg|=16777216|i-30):i>=40&&i<=47?(r.bg&=-50331904,r.bg|=16777216|i-40):i>=90&&i<=97?(r.fg&=-50331904,r.fg|=16777216|i-90|8):i>=100&&i<=107?(r.bg&=-50331904,r.bg|=16777216|i-100|8):i===0?this._processSGR0(r):i===1?r.fg|=134217728:i===3?r.bg|=67108864:i===4?(r.fg|=268435456,this._processUnderline(t.hasSubParams(s)?t.getSubParams(s)[0]:1,r)):i===5?r.fg|=536870912:i===7?r.fg|=67108864:i===8?r.fg|=1073741824:i===9?r.fg|=2147483648:i===2?r.bg|=134217728:i===21?this._processUnderline(2,r):i===22?(r.fg&=-134217729,r.bg&=-134217729):i===23?r.bg&=-67108865:i===24?(r.fg&=-268435457,this._processUnderline(0,r)):i===25?r.fg&=-536870913:i===27?r.fg&=-67108865:i===28?r.fg&=-1073741825:i===29?r.fg&=2147483647:i===39?(r.fg&=-67108864,r.fg|=We.fg&16777215):i===49?(r.bg&=-67108864,r.bg|=We.bg&16777215):i===38||i===48||i===58?s+=this._extractColor(t,s,r):i===53?r.bg|=1073741824:i===55?r.bg&=-1073741825:i===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):i===100?(r.fg&=-67108864,r.fg|=We.fg&16777215,r.bg&=-67108864,r.bg|=We.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${P.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[${e};${i}R`);break}return!0}deviceStatusPrivate(t){switch(t.params[0]){case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[?${e};${i}R`);break}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=We.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=e%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(t){let e=t.params[0]||1,i;return(t.length<2||(i=t.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!bv(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${P.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>kv&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>kv&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],i=t.split(";");for(;i.length>1;){let r=i.shift(),s=i.shift();if(/^\d+$/.exec(r)){let n=parseInt(r);if(Pv(n))if(s==="?")e.push({type:0,index:n});else{let o=wv(s);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let i=t.slice(0,e).trim(),r=t.slice(e+1);return r?this._createHyperlink(i,r):i.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let i=t.split(":"),r,s=i.findIndex(n=>n.startsWith("id="));return s!==-1&&(r=i[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let i=t.split(";");for(let r=0;r=this._specialColors.length);++r,++e)if(i[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let s=wv(i[r]);s&&this._onColor.fire([{type:1,index:this._specialColors[e],color:s}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],i=t.split(";");for(let r=0;r=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=We.clone(),this._eraseAttrDataInternal=We.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new gi;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e(this._coreService.triggerDataEvent(`${P.ESC}${o}${P.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return i(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},zp=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){tthis.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Cv=t,t=e,e=Cv),tthis.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};zp=De([Z(0,Rt)],zp);function Pv(t){return 0<=t&&t<256}var v3=5e7,$v=12,S3=50,y3=class extends te{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>v3)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let i=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],s=this._action(r,e);if(s){let o=l=>performance.now()-i>=$v?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(i,l);s.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-i>=$v)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>S3&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Zp=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),a={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(a,l)),this._dataByLinkId.set(a.id,a),a.id}let i=t,r=this._getEntryIdKey(i),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,e.ybase+e.y),s.id;let n=e.addMarker(e.ybase+e.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(t,e){let i=this._dataByLinkId.get(t);if(i&&i.lines.every(r=>r.line!==e)){let r=this._bufferService.buffer.addMarker(e);i.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(i,r))}}getLinkData(t){var e;return(e=this._dataByLinkId.get(t))==null?void 0:e.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let i=t.lines.indexOf(e);i!==-1&&(t.lines.splice(i,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Zp=De([Z(0,Rt)],Zp);var Qv=!1,w3=class extends te{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new jn),this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onData=this._register(new L),this.onData=this._onData.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new L),this._instantiationService=new YL,this.optionsService=this._register(new i3(t)),this._instantiationService.setService(At,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Mp)),this._instantiationService.setService(Rt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ap)),this._instantiationService.setService(Sb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Lp)),this._instantiationService.setService(Ws,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Dp)),this._instantiationService.setService(vb,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(xs)),this._instantiationService.setService(WA,this.unicodeService),this._charsetService=this._instantiationService.createInstance(l3),this._instantiationService.setService(IA,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Zp),this._instantiationService.setService(yb,this._oscLinkService),this._inputHandler=this._register(new _3(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ut.forward(this._bufferService.onResize,this._onResize)),this._register(ut.forward(this.coreService.onData,this._onData)),this._register(ut.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new y3((e,i)=>this._inputHandler.parse(e,i))),this._register(ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new L),this._onScroll.event(t=>{var e;(e=this._onScrollApi)==null||e.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!Qv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Qv=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,Jb),e=Math.max(e,ex),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(Sv.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(Sv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Pe(()=>{for(let e of t)e.dispose()})}}},k3={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function b3(t,e,i,r){var o;let s={type:0,cancel:!1,key:void 0},n=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?s.key=P.ESC+"OA":s.key=P.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?s.key=P.ESC+"OD":s.key=P.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?s.key=P.ESC+"OC":s.key=P.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?s.key=P.ESC+"OB":s.key=P.ESC+"[B");break;case 8:s.key=t.ctrlKey?"\b":P.DEL,t.altKey&&(s.key=P.ESC+s.key);break;case 9:if(t.shiftKey){s.key=P.ESC+"[Z";break}s.key=P.HT,s.cancel=!0;break;case 13:s.key=t.altKey?P.ESC+P.CR:P.CR,s.cancel=!0;break;case 27:s.key=P.ESC,t.altKey&&(s.key=P.ESC+P.ESC),s.cancel=!0;break;case 37:if(t.metaKey)break;n?s.key=P.ESC+"[1;"+(n+1)+"D":e?s.key=P.ESC+"OD":s.key=P.ESC+"[D";break;case 39:if(t.metaKey)break;n?s.key=P.ESC+"[1;"+(n+1)+"C":e?s.key=P.ESC+"OC":s.key=P.ESC+"[C";break;case 38:if(t.metaKey)break;n?s.key=P.ESC+"[1;"+(n+1)+"A":e?s.key=P.ESC+"OA":s.key=P.ESC+"[A";break;case 40:if(t.metaKey)break;n?s.key=P.ESC+"[1;"+(n+1)+"B":e?s.key=P.ESC+"OB":s.key=P.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(s.key=P.ESC+"[2~");break;case 46:n?s.key=P.ESC+"[3;"+(n+1)+"~":s.key=P.ESC+"[3~";break;case 36:n?s.key=P.ESC+"[1;"+(n+1)+"H":e?s.key=P.ESC+"OH":s.key=P.ESC+"[H";break;case 35:n?s.key=P.ESC+"[1;"+(n+1)+"F":e?s.key=P.ESC+"OF":s.key=P.ESC+"[F";break;case 33:t.shiftKey?s.type=2:t.ctrlKey?s.key=P.ESC+"[5;"+(n+1)+"~":s.key=P.ESC+"[5~";break;case 34:t.shiftKey?s.type=3:t.ctrlKey?s.key=P.ESC+"[6;"+(n+1)+"~":s.key=P.ESC+"[6~";break;case 112:n?s.key=P.ESC+"[1;"+(n+1)+"P":s.key=P.ESC+"OP";break;case 113:n?s.key=P.ESC+"[1;"+(n+1)+"Q":s.key=P.ESC+"OQ";break;case 114:n?s.key=P.ESC+"[1;"+(n+1)+"R":s.key=P.ESC+"OR";break;case 115:n?s.key=P.ESC+"[1;"+(n+1)+"S":s.key=P.ESC+"OS";break;case 116:n?s.key=P.ESC+"[15;"+(n+1)+"~":s.key=P.ESC+"[15~";break;case 117:n?s.key=P.ESC+"[17;"+(n+1)+"~":s.key=P.ESC+"[17~";break;case 118:n?s.key=P.ESC+"[18;"+(n+1)+"~":s.key=P.ESC+"[18~";break;case 119:n?s.key=P.ESC+"[19;"+(n+1)+"~":s.key=P.ESC+"[19~";break;case 120:n?s.key=P.ESC+"[20;"+(n+1)+"~":s.key=P.ESC+"[20~";break;case 121:n?s.key=P.ESC+"[21;"+(n+1)+"~":s.key=P.ESC+"[21~";break;case 122:n?s.key=P.ESC+"[23;"+(n+1)+"~":s.key=P.ESC+"[23~";break;case 123:n?s.key=P.ESC+"[24;"+(n+1)+"~":s.key=P.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?s.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?s.key=P.NUL:t.keyCode>=51&&t.keyCode<=55?s.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?s.key=P.DEL:t.keyCode===219?s.key=P.ESC:t.keyCode===220?s.key=P.FS:t.keyCode===221&&(s.key=P.GS);else if((!i||r)&&t.altKey&&!t.metaKey){let l=(o=k3[t.keyCode])==null?void 0:o[t.shiftKey?1:0];if(l)s.key=P.ESC+l;else if(t.keyCode>=65&&t.keyCode<=90){let a=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(a);t.shiftKey&&(h=h.toUpperCase()),s.key=P.ESC+h}else if(t.keyCode===32)s.key=P.ESC+(t.ctrlKey?P.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),s.key=P.ESC+a,s.cancel=!0}}else i&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(s.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?s.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(s.key=P.US),t.key==="@"&&(s.key=P.NUL));break}return s}var ze=0,x3=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new dc,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new dc,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((s,n)=>this._getKey(s)-this._getKey(n)),e=0,i=0,r=new Array(this._array.length+this._insertedValues.length);for(let s=0;s=this._array.length||this._getKey(t[e])<=this._getKey(this._array[i])?(r[s]=t[e],e++):r[s]=this._array[i++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(ze=this._search(e),ze===-1)||this._getKey(this._array[ze])!==e)return!1;do if(this._array[ze]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ze),!0;while(++zes-n),e=0,i=new Array(this._array.length-t.length),r=0;for(let s=0;s0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ze=this._search(t),!(ze<0||ze>=this._array.length)&&this._getKey(this._array[ze])===t))do yield this._array[ze];while(++ze=this._array.length)&&this._getKey(this._array[ze])===t))do e(this._array[ze]);while(++ze=e;){let r=e+i>>1,s=this._getKey(this._array[r]);if(s>t)i=r-1;else if(s0&&this._getKey(this._array[r-1])===t;)r--;return r}}return e}},Of=0,Tv=0,C3=class extends te{constructor(){super(),this._decorations=new x3(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new L),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new L),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Pe(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new P3(t);if(e){let i=e.marker.onDispose(()=>e.dispose()),r=e.onDispose(()=>{r.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),i.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,i){let r=0,s=0;for(let n of this._decorations.getKeyIterator(e))r=n.options.x??0,s=r+(n.options.width??1),t>=r&&t{Of=s.options.x??0,Tv=Of+(s.options.width??1),t>=Of&&t=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=r-this._lastRefreshMs,n=this._debounceThresholdMS-s;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},Ev=20,pc=class extends te{constructor(t,e,i,r){super(),this._terminal=t,this._coreBrowserService=i,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Q3(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(U(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Pe(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ev+1&&(this._liveRegion.textContent+=np.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let i=this._terminal.buffer,r=i.lines.length.toString();for(let s=t;s<=e;s++){let n=i.lines.get(i.ydisp+s),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",a=(i.ydisp+s+1).toString(),h=this._rowElements[s];h&&(l.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=l,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",a),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let i=t.target,r=this._rowElements[e===0?1:this._rowElements.length-2],s=i.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(s===n||t.relatedTarget!==r)return;let o,l;if(e===0?(o=i,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},i={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===i.node&&e.offset>i.offset)&&([e,i]=[i,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let r=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:r,offset:((l=r.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(i.node))return;let s=({node:a,offset:h})=>{let c=a instanceof Text?a.parentNode:a,u=parseInt(c==null?void 0:c.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(c);if(!f)return console.warn("columns is null. Race condition?"),null;let d=h=this._terminal.cols&&(++u,d=0),{row:u,column:d}},n=s(e),o=s(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;et;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t{var n;zs(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(U(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(U(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(U(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(U(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let i=t.composedPath();for(let r=0;r{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())e?(s=this._activeProviderReplies)!=null&&s.get(n)&&(i=this._checkLinkProviderResult(n,t,i)):o.provideLinks(t.y,l=>{var h,c;if(this._isMouseOut)return;let a=l==null?void 0:l.map(u=>({link:u}));(h=this._activeProviderReplies)==null||h.set(n,a),i=this._checkLinkProviderResult(n,t,i),((c=this._activeProviderReplies)==null?void 0:c.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let i=new Set;for(let r=0;rt?this._bufferService.cols:o.link.range.end.x;for(let h=l;h<=a;h++){if(i.has(h)){s.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(t,e,i){var n;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(t),s=!1;for(let o=0;othis._linkAtPosition(l.link,e));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;othis._linkAtPosition(a.link,e));if(l){i=!0,this._handleNewLink(l);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&T3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,zs(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.pointerCursor},set:i=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,r;return(r=(i=this._currentLink)==null?void 0:i.state)==null?void 0:r.decorations.underline},set:i=>{var r,s,n;(r=this._currentLink)!=null&&r.state&&((n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let r=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(t,e,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(i,e.text)}_fireUnderlineEvent(t,e){let i=t.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-r-1,i.end.x,i.end.y-r-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(t,e,i){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(i,e.text)}_linkAtPosition(t,e){let i=t.range.start.y*this._bufferService.cols+t.range.start.x,r=t.range.end.y*this._bufferService.cols+t.range.end.x,s=e.y*this._bufferService.cols+e.x;return i<=s&&s<=r}_positionFromMouseEvent(t,e,i){let r=i.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,i,r,s){return{x1:t,y1:e,x2:i,y2:r,cols:this._bufferService.cols,fg:s}}};Xp=De([Z(1,SO),Z(2,Cr),Z(3,Rt),Z(4,kb)],Xp);function T3(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var E3=class extends w3{constructor(t={}){super(t),this._linkifier=this._register(new jn),this.browser=Wb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new jn),this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new L),this.onKey=this._onKey.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new L),this.onBell=this._onBell.event,this._onFocus=this._register(new L),this._onBlur=this._register(new L),this._onA11yCharEmitter=this._register(new L),this._onA11yTabEmitter=this._register(new L),this._onWillOpen=this._register(new L),this._setup(),this._decorationService=this._instantiationService.createInstance(C3),this._instantiationService.setService(Hl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(SL),this._instantiationService.setService(kb,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(lp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh((e==null?void 0:e.start)??0,(e==null?void 0:e.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Pe(()=>{var e,i;this._customKeyEventHandler=void 0,(i=(e=this.element)==null?void 0:e.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let i,r="";switch(e.index){case 256:i="foreground",r="10";break;case 257:i="background",r="11";break;case 258:i="cursor",r="12";break;default:i="ansi",r="4;"+e.index}switch(e.type){case 0:let s=ke.toColorRGB(i==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${P.ESC}]${r};${O3(s)}${Xb.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Ne.toColor(...e.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Ne.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(pc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var t;return(t=this.textarea)==null?void 0:t.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let i=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=e.getWidth(i),n=this._renderService.dimensions.css.cell.width*s,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(U(this.element,"copy",e=>{this.hasSelection()&&LA(e,this._selectionService)}));let t=e=>DA(e,this.textarea,this.coreService,this.optionsService);this._register(U(this.textarea,"paste",t)),this._register(U(this.element,"paste",t)),Nb?this._register(U(this.element,"mousedown",e=>{e.button===2&&I0(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(U(this.element,"contextmenu",e=>{I0(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),$O&&this._register(U(this.element,"auxclick",e=>{e.button===1&&pb(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(U(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(U(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(U(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(U(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(U(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(U(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(U(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){var s;if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(U(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",sp.get()),Yb||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(_L,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xr,this._coreBrowserService),this._register(U(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(U(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance($p,this._document,this._helperContainer),this._instantiationService.setService(qc,this._charSizeService),this._themeService=this._instantiationService.createInstance(Rp),this._instantiationService.setService(Gn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(uc),this._instantiationService.setService(wb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Tp,this.rows,this.screenElement)),this._instantiationService.setService(Cr,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(xp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Qp),this._instantiationService.setService(SO,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Xp,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(kp,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ep,this.element,this.screenElement,r)),this._instantiationService.setService(jA,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(bp,this.screenElement)),this._register(U(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(pc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cc,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cc,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Pp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function i(n){var h,c,u,f,d;let o=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!o)return!1;let l,a;switch(n.overrideType||n.type){case"mousemove":a=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":a=0,l=n.button<3?n.button:3;break;case"mousedown":a=1,l=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||t.coreMouseService.consumeWheelEvent(n,(f=(u=(c=(h=t._renderService)==null?void 0:h.dimensions)==null?void 0:c.device)==null?void 0:u.cell)==null?void 0:f.height,(d=t._coreBrowserService)==null?void 0:d.dpr)===0)return!1;a=p<0?0:1,l=4;break;default:return!1}return a===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:a,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?r.mousemove||(e.addEventListener("mousemove",s.mousemove),r.mousemove=s.mousemove):(e.removeEventListener("mousemove",r.mousemove),r.mousemove=null),n&16?r.wheel||(e.addEventListener("wheel",s.wheel,{passive:!1}),r.wheel=s.wheel):(e.removeEventListener("wheel",r.wheel),r.wheel=null),n&2?r.mouseup||(r.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),n&4?r.mousedrag||(r.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(U(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(n)})),this._register(U(e,"wheel",n=>{var o,l,a,h,c;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,(h=(a=(l=(o=t._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:a.cell)==null?void 0:h.height,(c=t._coreBrowserService)==null?void 0:c.dpr)===0)return this.cancel(n,!0);let u=P.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(t,e){var i;(i=this._renderService)==null||i.refreshRows(t,e)}updateCursorStyle(t){var e;(e=this._selectionService)!=null&&e.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){db(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,i){this._selectionService.setSelection(t,e,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var t;(t=this._selectionService)==null||t.clearSelection()}selectAll(){var t;(t=this._selectionService)==null||t.selectAll()}selectLines(t,e){var i;(i=this._selectionService)==null||i.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=b3(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),this.cancel(t,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(i.cancel&&this.cancel(t,!0),!i.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===P.ETX||i.key===P.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let i=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?i:i&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(R3(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let i={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(i),e.dispose=()=>this._wrappedAddonDispose(i),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let i=0;i=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new gi)}translateToString(t,e,i){return this._line.translateToString(t,e,i)}},Rv=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new M3(e)}getNullCell(){return new gi}},L3=class extends te{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new L),this.onBufferChange=this._onBufferChange.event,this._normal=new Rv(this._core.buffers.normal,"normal"),this._alternate=new Rv(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},D3=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,r)=>e(i,r.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},B3=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},z3=["cols","rows"],Zi=0,Z3=class extends te{constructor(t){super(),this._core=this._register(new E3(t)),this._addonManager=this._register(new A3),this._publicOptions={...this._core.options};let e=r=>this._core.options[r],i=(r,s)=>{this._checkReadonlyOptions(r),this._core.options[r]=s};for(let r in this._core.options){let s={get:e.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,s)}}_checkReadonlyOptions(t){if(z3.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new D3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new B3(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new L3(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r +`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return sp.get()},set promptLabel(t){sp.set(t)},get tooMuchOutput(){return np.get()},set tooMuchOutput(t){np.set(t)}}}_verifyIntegers(...t){for(Zi of t)if(Zi===1/0||isNaN(Zi)||Zi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Zi of t)if(Zi&&(Zi===1/0||isNaN(Zi)||Zi%1!==0||Zi<0))throw new Error("This API only accepts positive integers")}};/** + * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. + * @license MIT + * + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * @license MIT + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + */var X3=2,I3=1,W3=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var u;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=o.top+o.bottom,a=o.right+o.left,h=r-l,c=s-a-e;return{cols:Math.max(X3,Math.floor(c/t.css.cell.width)),rows:Math.max(I3,Math.floor(h/t.css.cell.height))}}};function N3(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function un(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}var Av;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_SUSPENDED="tauri://suspended",t.WINDOW_RESUMED="tauri://resumed",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(Av||(Av={}));async function j3(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await un("plugin:event|unlisten",{event:t,eventId:e})}async function Mv(t,e,i){var r;const s=(r=void 0)!==null&&r!==void 0?r:{kind:"Any"};return un("plugin:event|listen",{event:t,target:s,handler:N3(e)}).then(n=>async()=>j3(t,n))}const Ys={spawn:t=>un("pty_spawn",{opts:t}),write:(t,e)=>un("pty_write",{id:t,data:e}),resize:(t,e,i)=>un("pty_resize",{id:t,cols:e,rows:i}),kill:t=>un("pty_kill",{id:t}),onData:t=>Mv("pty:data",e=>t(e.payload)),onExit:t=>Mv("pty:exit",e=>t(e.payload))};function V3(t){let e="";for(let i=0;ie(c)),s=ue.useRef(null),n=ue.useRef(null),o=ue.useRef(null),l=ue.useRef(t.ptyId),[a,h]=ue.useState(!1);return ue.useEffect(()=>{let c,u,f=!1;const d=new Z3({fontSize:Lv*i.scale,fontFamily:'Menlo, "Cascadia Code", Consolas, monospace',theme:{background:"#1d1d23",foreground:"#e8e8ec",cursor:"#e8e8ec"},cursorBlink:!0,allowProposedApi:!0}),p=new W3;return d.loadAddon(p),d.open(s.current),p.fit(),n.current=d,o.current=p,(async()=>{let g=l.current;if(!g){if(g=await Ys.spawn({cols:d.cols,rows:d.rows}),f){await Ys.kill(g);return}l.current=g,e({ptyId:g})}c=await Ys.onData(v=>{v.id===g&&d.write(Y3(v.data))}),u=await Ys.onExit(v=>{v.id===g&&d.write(`\r +\x1B[2m[process exited]\x1B[0m\r +`)}),d.onData(v=>{Ys.write(g,q3(v)).catch(O=>console.error("pty_write",O))}),d.onResize(({cols:v,rows:O})=>{Ys.resize(g,v,O).catch(()=>{})}),h(!0)})(),()=>{f=!0,c==null||c(),u==null||u(),d.dispose()}},[]),ue.useEffect(()=>{if(!a)return;const c=n.current,u=o.current;!c||!u||(c.options.fontSize=Lv*i.scale,u.fit())},[i.scale,a]),ue.useEffect(()=>{var c;a&&((c=o.current)==null||c.fit())},[t.width,t.height,a]),Oe.jsxs("div",{className:"card terminal-card",style:{left:i.x+t.x*i.scale,top:i.y+t.y*i.scale,width:t.width*i.scale,height:t.height*i.scale,zIndex:t.z,"--scale":i.scale},children:[Oe.jsx("div",{className:"card-header",...r,children:"terminal"}),Oe.jsx("div",{className:"card-body terminal-body",ref:s,onPointerDown:c=>c.stopPropagation(),onWheel:c=>c.stopPropagation()}),Oe.jsx(J1,{card:t,onUpdate:c=>e(c)})]})}const H3=.1,U3=4,G3=.0015;function K3({initialCards:t}){const[e,i]=ue.useState(t),[r,s]=ue.useState({x:0,y:0,scale:1}),[n,o]=ue.useState(!1),l=ue.useRef(null),a=ue.useRef(null),h=ue.useRef(t.reduce((m,_)=>Math.max(m,_.z),0));ue.useEffect(()=>{const m=S=>{S.code==="Space"&&!S.repeat&&o(!0)},_=S=>{S.code==="Space"&&o(!1)};return window.addEventListener("keydown",m),window.addEventListener("keyup",_),()=>{window.removeEventListener("keydown",m),window.removeEventListener("keyup",_)}},[]),ue.useEffect(()=>{const m=l.current;if(!m)return;const _=S=>{S.button===1&&S.preventDefault()};return m.addEventListener("mousedown",_),m.addEventListener("auxclick",_),()=>{m.removeEventListener("mousedown",_),m.removeEventListener("auxclick",_)}},[]);const c=ue.useCallback(m=>{if(!m.ctrlKey&&!m.metaKey)return;m.preventDefault();const _=l.current.getBoundingClientRect(),S=m.clientX-_.left,w=m.clientY-_.top;s(k=>{const x=Math.exp(-m.deltaY*G3),T=Math.max(H3,Math.min(U3,k.scale*x)),N=T/k.scale;return{x:S-(S-k.x)*N,y:w-(w-k.y)*N,scale:T}})},[]),u=m=>{var S;(m.button===1||m.button===0&&n)&&(m.preventDefault(),(S=l.current)==null||S.setPointerCapture(m.pointerId),a.current={startX:m.clientX,startY:m.clientY,vpX:r.x,vpY:r.y})},f=m=>{const _=a.current;if(!_)return;const S=_.vpX+(m.clientX-_.startX),w=_.vpY+(m.clientY-_.startY);s(k=>({...k,x:S,y:w}))},d=m=>{var _;if(a.current){try{(_=l.current)==null||_.releasePointerCapture(m.pointerId)}catch{}a.current=null}},p=(m,_)=>{i(S=>S.map(w=>w.id===m?{...w,..._}:w))},g=m=>{const _=window.innerWidth/2,S=window.innerHeight/2,w=(_-r.x)/r.scale,k=(S-r.y)/r.scale,x=crypto.randomUUID();h.current+=1;const T=m(x,w,k,h.current);i(N=>[...N,T])},v=()=>g((m,_,S,w)=>({id:m,kind:"note",x:_-160,y:S-90,width:320,height:180,z:w,text:""})),O=()=>g((m,_,S,w)=>({id:m,kind:"terminal",x:_-280,y:S-180,width:560,height:360,z:w,ptyId:""}));return Oe.jsxs("div",{ref:l,className:`canvas-container ${n?"pan-mode":""} ${a.current?"panning":""}`,onWheel:c,onPointerDown:u,onPointerMove:f,onPointerUp:d,onPointerCancel:d,children:[Oe.jsx("div",{className:"canvas-grid",style:{backgroundPosition:`${r.x}px ${r.y}px`,backgroundSize:`${40*r.scale}px ${40*r.scale}px`}}),Oe.jsx(G1.Provider,{value:r,children:e.map(m=>m.kind==="note"?Oe.jsx(TA,{card:m,onUpdate:_=>p(m.id,_)},m.id):m.kind==="terminal"?Oe.jsx(F3,{card:m,onUpdate:_=>p(m.id,_)},m.id):null)}),Oe.jsxs("div",{className:"toolbar",children:[Oe.jsx("button",{onClick:v,children:"+ Note"}),Oe.jsx("button",{onClick:O,children:"+ Terminal"})]}),Oe.jsxs("div",{className:"canvas-hud",children:[Oe.jsxs("span",{children:["x ",r.x.toFixed(0)]}),Oe.jsxs("span",{children:["y ",r.y.toFixed(0)]}),Oe.jsxs("span",{children:[(r.scale*100).toFixed(0),"%"]})]})]})}const J3=[{id:"welcome",kind:"note",x:200,y:200,width:340,height:200,z:1,text:`Welcome to Infinite. + +Pan: middle-drag or Space + drag +Zoom: Ctrl + scroll + +Use the toolbar to add notes and terminals.`}];function eD(){return Oe.jsx(K3,{initialCards:J3})}mf.createRoot(document.getElementById("root")).render(Oe.jsx(Sx.StrictMode,{children:Oe.jsx(eD,{})})); diff --git a/dist/index.html b/dist/index.html index 3718ec2..fb01cfb 100644 --- a/dist/index.html +++ b/dist/index.html @@ -4,8 +4,8 @@ Infinite - - + +
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 3c2ebec..6e1eeed 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -316,6 +316,147 @@ "node": ">=6.9.0" } }, + "node_modules/@codemirror/autocomplete": { + "version": "6.20.2", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.2.tgz", + "integrity": "sha512-G5FPkgIiLjOgZMjqVjvuKQ1rGPtHogLldJr33eFJdVLtmwY+giGrlv/ewljLz6b9BSQLkjxuwBc6g6omDM+YxQ==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@codemirror/commands": { + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.3.tgz", + "integrity": "sha512-JFRiqhKu+bvSkDLI+rUhJwSxQxYb759W5GBezE8Uc8mHLqC9aV/9aTC7yJSqCtB3F00pylrLCwnyS91Ap5ej4Q==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.6.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" + } + }, + "node_modules/@codemirror/lang-css": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz", + "integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.2", + "@lezer/css": "^1.1.7" + } + }, + "node_modules/@codemirror/lang-html": { + "version": "6.4.11", + "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.11.tgz", + "integrity": "sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/lang-css": "^6.0.0", + "@codemirror/lang-javascript": "^6.0.0", + "@codemirror/language": "^6.4.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/css": "^1.1.0", + "@lezer/html": "^1.3.12" + } + }, + "node_modules/@codemirror/lang-javascript": { + "version": "6.2.5", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz", + "integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.6.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-markdown": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.0.tgz", + "integrity": "sha512-0K40bZ35jpHya6FriukbgaleaqzBLZfOh7HuzqbMxBXkbYMJDxfF39c23xOgxFezR+3G+tR2/Mup+Xk865OMvw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.7.1", + "@codemirror/lang-html": "^6.0.0", + "@codemirror/language": "^6.3.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.2.1", + "@lezer/markdown": "^1.0.0" + } + }, + "node_modules/@codemirror/language": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz", + "integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } + }, + "node_modules/@codemirror/lint": { + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.6.tgz", + "integrity": "sha512-6Kp7r6XfCi/D/5sdXieMfg9pJU1bUEx96WITuLU6ESaKizCz0QHFMjY/TaFSbigDdEAIgi93itLBIUETP4oK+A==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.42.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/search": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.0.tgz", + "integrity": "sha512-ZvGm99wc/s2cITtMT15LFdn8aH/aS+V+DqyGq/N5ZlV5vWtH+nILvC2nw0zX7ByNoHHDZ2IxxdW38O0tc5nVHg==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.37.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/state": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.6.0.tgz", + "integrity": "sha512-4nbvra5R5EtiCzr9BTHiTLc+MLXK2QGiAVYMyi8PkQd3SR+6ixar/Q/01Fa21TBIDOZXgeWV4WppsQolSreAPQ==", + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } + }, + "node_modules/@codemirror/view": { + "version": "6.43.0", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.0.tgz", + "integrity": "sha512-V7ZCLQO3Jus9hzh2jVCCPW3mO4IBMr43O37PqSUYautJSnnJF41YlgLw21x0fLJTYvJ+Vkm6Gp+qKGH9pltgXA==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.6.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" + } + }, "node_modules/@esbuild/linux-x64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", @@ -383,6 +524,79 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@lezer/common": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz", + "integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==", + "license": "MIT" + }, + "node_modules/@lezer/css": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.3.tgz", + "integrity": "sha512-RzBo8r+/6QJeow7aPHIpGVIH59xTcJXp399820gZoMo9noQDRVpJLheIBUicYwKcsbOYoBRoLZlf2720dG/4Tg==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", + "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" + } + }, + "node_modules/@lezer/html": { + "version": "1.3.13", + "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz", + "integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/javascript": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz", + "integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.1.3", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/lr": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz", + "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@lezer/markdown": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.3.tgz", + "integrity": "sha512-jpGm5Ps+XErS+xA4urw7ogEGkeZOahVQF21Z6oECF0sj+2liwZopd2+I8uH5I/vZsRuuze3OxBREIANLf6KKUw==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0" + } + }, + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz", + "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", + "license": "MIT" + }, "node_modules/@rolldown/pluginutils": { "version": "1.0.0-beta.27", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", @@ -688,6 +902,21 @@ ], "license": "CC-BY-4.0" }, + "node_modules/codemirror": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz", + "integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/commands": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/search": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -695,6 +924,12 @@ "dev": true, "license": "MIT" }, + "node_modules/crelt": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", + "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", + "license": "MIT" + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", @@ -998,6 +1233,12 @@ "node": ">=0.10.0" } }, + "node_modules/style-mod": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", + "integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==", + "license": "MIT" + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -1112,6 +1353,12 @@ } } }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/node_modules/@codemirror/autocomplete/CHANGELOG.md b/node_modules/@codemirror/autocomplete/CHANGELOG.md new file mode 100644 index 0000000..547e7a2 --- /dev/null +++ b/node_modules/@codemirror/autocomplete/CHANGELOG.md @@ -0,0 +1,645 @@ +## 6.20.2 (2026-05-06) + +### Bug fixes + +Fix an issue where you couldn't move to the last page of completions when its count was a precise multiple of the page size. + +## 6.20.1 (2026-03-02) + +### Bug fixes + +Clicking the horizontal dots at the top/bottom of a list of completion options now moves the selection there, so that more completions become visible. +## 6.20.0 (2025-11-20) + +### New features + +Completions now support a `sortText` property to influence sort order. + +## 6.19.1 (2025-10-23) + +### Bug fixes + +Make sure a completion's info panel is associated with that completion in the accessibility tree. + +## 6.19.0 (2025-09-26) + +### New features + +Completion sections may now set their rank to `dynamic` to indicate their order should be determined by the matching score of their best-matching option. + +## 6.18.7 (2025-09-02) + +### Bug fixes + +Add a binding for Alt-i to trigger `startCompletion`, following VS Code's current default bindings. + +Improve handling of nested fields in snippets. + +## 6.18.6 (2025-02-12) + +### Bug fixes + +Fix an issue where the closing character for double-angle quotation marks and full-width brackets was computed incorrectly. + +## 6.18.5 (2025-02-11) + +### Bug fixes + +Fix an issue where clicking on the scrollbar for the completion list could move focus out of the editor. + +## 6.18.4 (2024-12-17) + +### Bug fixes + +Align the behavior of snippet completions with text completions in that they overwrite the selected text. + +## 6.18.3 (2024-11-13) + +### Bug fixes + +Backspacing to the start of the completed range will no longer close the completion tooltip when it was triggered implicitly by typing the character before that range. + +## 6.18.2 (2024-10-30) + +### Bug fixes + +Don't immediately show synchronously updated completions when there are some sources that still need to return. + +## 6.18.1 (2024-09-14) + +### Bug fixes + +Fix an issue where `insertCompletionText` would get confused about the length of the inserted text when it contained CRLF line breaks, and create an invalid selection. + +Add Alt-Backtick as additional binding on macOS, where IME can take over Ctrl-Space. + +## 6.18.0 (2024-08-05) + +### Bug fixes + +Style the info element so that newlines are preserved, to make it easier to display multi-line info from a string source. + +### New features + +When registering an `abort` handler for a completion query, you can now use the `onDocChange` option to indicate that your query should be aborted as soon as the document changes while it is running. + +## 6.17.0 (2024-07-03) + +### Bug fixes + +Fix an issue where completions weren't properly reset when starting a new completion through `activateOnCompletion`. + +### New features + +`CompletionContext` objects now have a `view` property that holds the editor view when the query context has a view available. + +## 6.16.3 (2024-06-19) + +### Bug fixes + +Avoid adding an `aria-autocomplete` attribute to the editor when there are no active sources active. + +## 6.16.2 (2024-05-31) + +### Bug fixes + +Allow backslash-escaped closing braces inside snippet field names/content. + +## 6.16.1 (2024-05-29) + +### Bug fixes + +Fix a bug where multiple backslashes before a brace in a snippet were all removed. + +## 6.16.0 (2024-04-12) + +### New features + +The new `activateOnCompletion` option allows autocompletion to be configured to chain completion activation for some types of completions. + +## 6.15.0 (2024-03-13) + +### New features + +The new `filterStrict` option can be used to turn off fuzzy matching of completions. + +## 6.14.0 (2024-03-10) + +### New features + +Completion results can now define a `map` method that can be used to adjust position-dependent information for document changes. + +## 6.13.0 (2024-02-29) + +### New features + +Completions may now provide 'commit characters' that, when typed, commit the completion before inserting the character. + +## 6.12.0 (2024-01-12) + +### Bug fixes + +Make sure snippet completions also set `userEvent` to `input.complete`. + +Fix a crash when the editor lost focus during an update and autocompletion was active. + +Fix a crash when using a snippet that has only one field, but multiple instances of that field. + +### New features + +The new `activateOnTypingDelay` option allows control over the debounce time before the completions are queried when the user types. + +## 6.11.1 (2023-11-27) + +### Bug fixes + +Fix a bug that caused typing over closed brackets after pressing enter to still not work in many situations. + +## 6.11.0 (2023-11-09) + +### Bug fixes + +Fix an issue that would prevent typing over closed brackets after starting a new line with enter. + +### New features + +Additional elements rendered in completion options with `addToOptions` are now given access to the editor view. + +## 6.10.2 (2023-10-13) + +### Bug fixes + +Fix a bug that caused `updateSyncTime` to always delay the initial population of the tooltip. + +## 6.10.1 (2023-10-11) + +### Bug fixes + +Fix a bug where picking a selection with the mouse could use the wrong completion if the completion list was updated after being opened. + +## 6.10.0 (2023-10-11) + +### New features + +The new autocompletion configuration option `updateSyncTime` allows control over how long fast sources are held back waiting for slower completion sources. + +## 6.9.2 (2023-10-06) + +### Bug fixes + +Fix a bug in `completeAnyWord` that could cause it to generate invalid regular expressions and crash. + +## 6.9.1 (2023-09-14) + +### Bug fixes + +Make sure the cursor is scrolled into view after inserting completion text. + +Make sure scrolling completions into view doesn't get confused when the tooltip is scaled. + +## 6.9.0 (2023-07-18) + +### New features + +Completions may now provide a `displayLabel` property that overrides the way they are displayed in the completion list. + +## 6.8.1 (2023-06-23) + +### Bug fixes + +`acceptCompletion` now returns false (allowing other handlers to take effect) when the completion popup is open but disabled. + +## 6.8.0 (2023-06-12) + +### New features + +The result of `Completion.info` may now include a `destroy` method that will be called when the tooltip is removed. + +## 6.7.1 (2023-05-13) + +### Bug fixes + +Fix a bug that cause incorrect ordering of completions when some results covered input text and others didn't. + +## 6.7.0 (2023-05-11) + +### New features + +The new `hasNextSnippetField` and `hasPrevSnippetField` functions can be used to figure out if the snippet-field-motion commands apply to a given state. + +## 6.6.1 (2023-05-03) + +### Bug fixes + +Fix a bug that made the editor use the completion's original position, rather than its current position, when changes happened in the document while a result was active. + +## 6.6.0 (2023-04-27) + +### Bug fixes + +Fix a bug in `insertCompletionText` that caused it to replace the wrong range when a result set's `to` fell after the cursor. + +### New features + +Functions returned by `snippet` can now be called without a completion object. + +## 6.5.1 (2023-04-13) + +### Bug fixes + +Keep completions open when interaction with an info tooltip moves focus out of the editor. + +## 6.5.0 (2023-04-13) + +### Bug fixes + +When `closeBrackets` skips a bracket, it now generates a change that overwrites the bracket. + +Replace the entire selected range when picking a completion with a non-cursor selection active. + +### New features + +Completions can now provide a `section` field that is used to group them into sections. + +The new `positionInfo` option can be used to provide custom logic for positioning the info tooltips. + +## 6.4.2 (2023-02-17) + +### Bug fixes + +Fix a bug where the apply method created by `snippet` didn't add a `pickedCompletion` annotation to the transactions it created. + +## 6.4.1 (2023-02-14) + +### Bug fixes + +Don't consider node names in trees that aren't the same language as the one at the completion position in `ifIn` and `ifNotIn`. + +Make sure completions that exactly match the input get a higher score than those that don't (so that even if the latter has a score boost, it ends up lower in the list). + +## 6.4.0 (2022-12-14) + +### Bug fixes + +Fix an issue where the extension would sometimes try to draw a disabled dialog at an outdated position, leading to plugin crashes. + +### New features + +A `tooltipClass` option to autocompletion can now be used to add additional CSS classes to the completion tooltip. + +## 6.3.4 (2022-11-24) + +### Bug fixes + +Fix an issue where completion lists could end up being higher than the tooltip they were in. + +## 6.3.3 (2022-11-18) + +### Bug fixes + +Set an explicit `box-sizing` style on completion icons so CSS resets don't mess them up. + +Allow closing braces in templates to be escaped with a backslash. + +## 6.3.2 (2022-11-15) + +### Bug fixes + +Fix a regression that could cause the completion dialog to stick around when it should be hidden. + +## 6.3.1 (2022-11-14) + +### Bug fixes + +Fix a regression where transactions for picking a completion (without custom `apply` method) no longer had the `pickedCompletion` annotation. + +Reduce flickering for completion sources without `validFor` info by temporarily showing a disabled tooltip while the completion updates. + +Make sure completion info tooltips are kept within the space provided by the `tooltipSpace` option. + +## 6.3.0 (2022-09-22) + +### New features + +Close bracket configuration now supports a `stringPrefixes` property that can be used to allow autoclosing of prefixed strings. + +## 6.2.0 (2022-09-13) + +### New features + +Autocompletion now takes an `interactionDelay` option that can be used to control the delay between the time where completion opens and the time where commands like `acceptCompletion` affect it. + +## 6.1.1 (2022-09-08) + +### Bug fixes + +Fix a bug that prevented transactions produced by `deleteBracketPair` from being marked as deletion user events. + +Improve positioning of completion info tooltips so they are less likely to stick out of the screen on small displays. + +## 6.1.0 (2022-07-19) + +### New features + +You can now provide a `compareCompletions` option to autocompletion to influence the way completions with the same match score are sorted. + +The `selectOnOpen` option to autocompletion can be used to require explicitly selecting a completion option before `acceptCompletion` does anything. + +## 6.0.4 (2022-07-07) + +### Bug fixes + +Remove a leftover `console.log` in bracket closing code. + +## 6.0.3 (2022-07-04) + +### Bug fixes + +Fix a bug that caused `closeBrackets` to not close quotes when at the end of a syntactic construct that starts with a similar quote. + +## 6.0.2 (2022-06-15) + +### Bug fixes + +Declare package dependencies as peer dependencies as an attempt to avoid duplicated package issues. + +## 6.0.1 (2022-06-09) + +### Bug fixes + +Support escaping `${` or `#{` in snippets. + +## 6.0.0 (2022-06-08) + +### Bug fixes + +Scroll the cursor into view when inserting a snippet. + +## 0.20.3 (2022-05-30) + +### Bug fixes + +Add an aria-label to the completion listbox. + +Fix a regression that caused transactions generated for completion to not have a `userEvent` annotation. + +## 0.20.2 (2022-05-24) + +### New features + +The package now exports an `insertCompletionText` helper that implements the default behavior for applying a completion. + +## 0.20.1 (2022-05-16) + +### New features + +The new `closeOnBlur` option determines whether the completion tooltip is closed when the editor loses focus. + +`CompletionResult` objects with `filter: false` may now have a `getMatch` property that determines the matched range in the options. + +## 0.20.0 (2022-04-20) + +### Breaking changes + +`CompletionResult.span` has been renamed to `validFor`, and may now hold a function as well as a regular expression. + +### Bug fixes + +Remove code that dropped any options beyond the 300th one when matching and sorting option lists. + +Completion will now apply to all cursors when there are multiple cursors. + +### New features + +`CompletionResult.update` can now be used to implement quick autocompletion updates in a synchronous way. + +The @codemirror/closebrackets package was merged into this one. + +## 0.19.15 (2022-03-23) + +### New features + +The `selectedCompletionIndex` function tells you the position of the currently selected completion. + +The new `setSelectionCompletion` function creates a state effect that moves the selected completion to a given index. + +A completion's `info` method may now return null to indicate that no further info is available. + +## 0.19.14 (2022-03-10) + +### Bug fixes + +Make the ARIA attributes added to the editor during autocompletion spec-compliant. + +## 0.19.13 (2022-02-18) + +### Bug fixes + +Fix an issue where the completion tooltip stayed open if it was explicitly opened and the user backspaced past its start. + +Stop snippet filling when a change happens across one of the snippet fields' boundaries. + +## 0.19.12 (2022-01-11) + +### Bug fixes + +Fix completion navigation with PageUp/Down when the completion tooltip isn't part of the view DOM. + +## 0.19.11 (2022-01-11) + +### Bug fixes + +Fix a bug that caused page up/down to only move the selection by two options in the completion tooltip. + +## 0.19.10 (2022-01-05) + +### Bug fixes + +Make sure the info tooltip is hidden when the selected option is scrolled out of view. + +Fix a bug in the completion ranking that would sometimes give options that match the input by word start chars higher scores than appropriate. + +Options are now sorted (ascending) by length when their match score is otherwise identical. + +## 0.19.9 (2021-11-26) + +### Bug fixes + +Fix an issue where info tooltips would be visible in an inappropriate position when there was no room to place them properly. + +## 0.19.8 (2021-11-17) + +### Bug fixes + +Give the completion tooltip a minimal width, and show ellipsis when completions overflow the tooltip width. + +### New features + +`autocompletion` now accepts an `aboveCursor` option to make the completion tooltip show up above the cursor. + +## 0.19.7 (2021-11-16) + +### Bug fixes + +Make option deduplication less aggressive, so that options with different `type` or `apply` fields don't get merged. + +## 0.19.6 (2021-11-12) + +### Bug fixes + +Fix an issue where parsing a snippet with a field that was labeled only by a number crashed. + +## 0.19.5 (2021-11-09) + +### Bug fixes + +Make sure info tooltips don't stick out of the bottom of the page. + +### New features + +The package exports a new function `selectedCompletion`, which can be used to find out which completion is currently selected. + +Transactions created by picking a completion now have an annotation (`pickedCompletion`) holding the original completion. + +## 0.19.4 (2021-10-24) + +### Bug fixes + +Don't rely on the platform's highlight colors for the active completion, since those are inconsistent and may not be appropriate for the theme. + +Fix incorrect match underline for some kinds of matched completions. + +## 0.19.3 (2021-08-31) + +### Bug fixes + +Improve the sorting of completions by using `localeCompare`. + +Fix reading of autocompletions in NVDA screen reader. + +### New features + +The new `icons` option can be used to turn off icons in the completion list. + +The `optionClass` option can now be used to add CSS classes to the options in the completion list. + +It is now possible to inject additional content into rendered completion options with the `addToOptions` configuration option. + +## 0.19.2 (2021-08-25) + +### Bug fixes + +Fix an issue where `completeAnyWord` would return results when there was no query and `explicit` was false. + +## 0.19.1 (2021-08-11) + +### Bug fixes + +Fix incorrect versions for @lezer dependencies. + +## 0.19.0 (2021-08-11) + +### Breaking changes + +Update dependencies to 0.19.0 + +## 0.18.8 (2021-06-30) + +### New features + +Add an `ifIn` helper function that constrains a completion source to only fire when in a given syntax node. Add support for unfiltered completions + +A completion result can now set a `filter: false` property to disable filtering and sorting of completions, when it already did so itself. + +## 0.18.7 (2021-06-14) + +### Bug fixes + +Don't treat continued completions when typing after an explicit completion as explicit. + +## 0.18.6 (2021-06-03) + +### Bug fixes + +Adding or reconfiguring completion sources will now cause them to be activated right away if a completion was active. + +### New features + +You can now specify multiple types in `Completion.type` by separating them by spaces. Small doc comment tweak for Completion.type + +## 0.18.5 (2021-04-23) + +### Bug fixes + +Fix a regression where snippet field selection didn't work with @codemirror/state 0.18.6. + +Fix a bug where snippet fields with different position numbers were inappropriately merged. + +## 0.18.4 (2021-04-20) + +### Bug fixes + +Fix a crash in Safari when moving the selection during composition. + +## 0.18.3 (2021-03-15) + +### Bug fixes + +Adjust to updated @codemirror/tooltip interface. + +## 0.18.2 (2021-03-14) + +### Bug fixes + +Fix unintended ES2020 output (the package contains ES6 code again). + +## 0.18.1 (2021-03-11) + +### Bug fixes + +Stop active completion when all sources resolve without producing any matches. + +### New features + +`Completion.info` may now return a promise. + +## 0.18.0 (2021-03-03) + +### Bug fixes + +Only preserve selected option across updates when it isn't the first option. + +## 0.17.4 (2021-01-18) + +### Bug fixes + +Fix a styling issue where the selection had become invisible inside snippet fields (when using `drawSelection`). + +### New features + +Snippet fields can now be selected with the pointing device (so that they are usable on touch devices). + +## 0.17.3 (2021-01-18) + +### Bug fixes + +Fix a bug where uppercase completions would be incorrectly matched against the typed input. + +## 0.17.2 (2021-01-12) + +### Bug fixes + +Don't bind Cmd-Space on macOS, since that already has a system default binding. Use Ctrl-Space for autocompletion. + +## 0.17.1 (2021-01-06) + +### New features + +The package now also exports a CommonJS module. + +## 0.17.0 (2020-12-29) + +### Breaking changes + +First numbered release. + diff --git a/node_modules/@codemirror/autocomplete/LICENSE b/node_modules/@codemirror/autocomplete/LICENSE new file mode 100644 index 0000000..9a91f48 --- /dev/null +++ b/node_modules/@codemirror/autocomplete/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2018-2021 by Marijn Haverbeke and others + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/@codemirror/autocomplete/README.md b/node_modules/@codemirror/autocomplete/README.md new file mode 100644 index 0000000..e7fc0bf --- /dev/null +++ b/node_modules/@codemirror/autocomplete/README.md @@ -0,0 +1,43 @@ +# @codemirror/autocomplete [![NPM version](https://img.shields.io/npm/v/@codemirror/autocomplete.svg)](https://www.npmjs.org/package/@codemirror/autocomplete) + +[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/autocomplete/src/branch/main/CHANGELOG.md) ] + +This package implements autocompletion for the +[CodeMirror](https://codemirror.net/) code editor. + +The [project page](https://codemirror.net/) has more information, a +number of [examples](https://codemirror.net/examples/) and the +[documentation](https://codemirror.net/docs/). + +This code is released under an +[MIT license](https://code.haverbeke.berlin/codemirror/autocomplete/tree/main/LICENSE). + +We aim to be an inclusive, welcoming community. To make that explicit, +we have a [code of +conduct](http://contributor-covenant.org/version/1/1/0/) that applies +to communication around the project. + +## Usage + +```javascript +import {EditorView} from "@codemirror/view" +import {autocompletion} from "@codemirror/autocomplete" +import {jsonLanguage} from "@codemirror/lang-json" + +const view = new EditorView({ + parent: document.body, + extensions: [ + jsonLanguage, + autocompletion(), + jsonLanguage.data.of({ + autocomplete: ["id", "name", "address"] + }) + ] +}) +``` + +This configuration will just complete the given words anywhere in JSON +context. Most language modules come with more refined autocompletion +built-in, but you can also write your own custom autocompletion +[sources](https://codemirror.net/docs/ref/#autocomplete.CompletionSource) +and associate them with your language this way. diff --git a/node_modules/@codemirror/autocomplete/dist/index.cjs b/node_modules/@codemirror/autocomplete/dist/index.cjs new file mode 100644 index 0000000..903f423 --- /dev/null +++ b/node_modules/@codemirror/autocomplete/dist/index.cjs @@ -0,0 +1,2152 @@ +'use strict'; + +var state = require('@codemirror/state'); +var view = require('@codemirror/view'); +var language = require('@codemirror/language'); + +/** +An instance of this is passed to completion source functions. +*/ +class CompletionContext { + /** + Create a new completion context. (Mostly useful for testing + completion sources—in the editor, the extension will create + these for you.) + */ + constructor( + /** + The editor state that the completion happens in. + */ + state, + /** + The position at which the completion is happening. + */ + pos, + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + explicit, + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + view) { + this.state = state; + this.pos = pos; + this.explicit = explicit; + this.view = view; + /** + @internal + */ + this.abortListeners = []; + /** + @internal + */ + this.abortOnDocChange = false; + } + /** + Get the extent, content, and (if there is a token) type of the + token before `this.pos`. + */ + tokenBefore(types) { + let token = language.syntaxTree(this.state).resolveInner(this.pos, -1); + while (token && types.indexOf(token.name) < 0) + token = token.parent; + return token ? { from: token.from, to: this.pos, + text: this.state.sliceDoc(token.from, this.pos), + type: token.type } : null; + } + /** + Get the match of the given expression directly before the + cursor. + */ + matchBefore(expr) { + let line = this.state.doc.lineAt(this.pos); + let start = Math.max(line.from, this.pos - 250); + let str = line.text.slice(start - line.from, this.pos - line.from); + let found = str.search(ensureAnchor(expr, false)); + return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) }; + } + /** + Yields true when the query has been aborted. Can be useful in + asynchronous queries to avoid doing work that will be ignored. + */ + get aborted() { return this.abortListeners == null; } + /** + Allows you to register abort handlers, which will be called when + the query is + [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted). + + By default, running queries will not be aborted for regular + typing or backspacing, on the assumption that they are likely to + return a result with a + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that + allows the result to be used after all. Passing `onDocChange: + true` will cause this query to be aborted for any document + change. + */ + addEventListener(type, listener, options) { + if (type == "abort" && this.abortListeners) { + this.abortListeners.push(listener); + if (options && options.onDocChange) + this.abortOnDocChange = true; + } + } +} +function toSet(chars) { + let flat = Object.keys(chars).join(""); + let words = /\w/.test(flat); + if (words) + flat = flat.replace(/\w/g, ""); + return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`; +} +function prefixMatch(options) { + let first = Object.create(null), rest = Object.create(null); + for (let { label } of options) { + first[label[0]] = true; + for (let i = 1; i < label.length; i++) + rest[label[i]] = true; + } + let source = toSet(first) + toSet(rest) + "*$"; + return [new RegExp("^" + source), new RegExp(source)]; +} +/** +Given a a fixed array of options, return an autocompleter that +completes them. +*/ +function completeFromList(list) { + let options = list.map(o => typeof o == "string" ? { label: o } : o); + let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options); + return (context) => { + let token = context.matchBefore(match); + return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null; + }; +} +/** +Wrap the given completion source so that it will only fire when the +cursor is in a syntax node with one of the given names. +*/ +function ifIn(nodes, source) { + return (context) => { + for (let pos = language.syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) { + if (nodes.indexOf(pos.name) > -1) + return source(context); + if (pos.type.isTop) + break; + } + return null; + }; +} +/** +Wrap the given completion source so that it will not fire when the +cursor is in a syntax node with one of the given names. +*/ +function ifNotIn(nodes, source) { + return (context) => { + for (let pos = language.syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) { + if (nodes.indexOf(pos.name) > -1) + return null; + if (pos.type.isTop) + break; + } + return source(context); + }; +} +class Option { + constructor(completion, source, match, score) { + this.completion = completion; + this.source = source; + this.match = match; + this.score = score; + } +} +function cur(state) { return state.selection.main.from; } +// Make sure the given regexp has a $ at its end and, if `start` is +// true, a ^ at its start. +function ensureAnchor(expr, start) { + var _a; + let { source } = expr; + let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$"; + if (!addStart && !addEnd) + return expr; + return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : "")); +} +/** +This annotation is added to transactions that are produced by +picking a completion. +*/ +const pickedCompletion = state.Annotation.define(); +/** +Helper function that returns a transaction spec which inserts a +completion's text in the main selection range, and any other +selection range that has the same text in front of it. +*/ +function insertCompletionText(state$1, text, from, to) { + let { main } = state$1.selection, fromOff = from - main.from, toOff = to - main.from; + return { + ...state$1.changeByRange(range => { + if (range != main && from != to && + state$1.sliceDoc(range.from + fromOff, range.from + toOff) != state$1.sliceDoc(from, to)) + return { range }; + let lines = state$1.toText(text); + return { + changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines }, + range: state.EditorSelection.cursor(range.from + fromOff + lines.length) + }; + }), + scrollIntoView: true, + userEvent: "input.complete" + }; +} +const SourceCache = new WeakMap(); +function asSource(source) { + if (!Array.isArray(source)) + return source; + let known = SourceCache.get(source); + if (!known) + SourceCache.set(source, known = completeFromList(source)); + return known; +} +const startCompletionEffect = state.StateEffect.define(); +const closeCompletionEffect = state.StateEffect.define(); + +// A pattern matcher for fuzzy completion matching. Create an instance +// once for a pattern, and then use that to match any number of +// completions. +class FuzzyMatcher { + constructor(pattern) { + this.pattern = pattern; + this.chars = []; + this.folded = []; + // Buffers reused by calls to `match` to track matched character + // positions. + this.any = []; + this.precise = []; + this.byWord = []; + this.score = 0; + this.matched = []; + for (let p = 0; p < pattern.length;) { + let char = state.codePointAt(pattern, p), size = state.codePointSize(char); + this.chars.push(char); + let part = pattern.slice(p, p + size), upper = part.toUpperCase(); + this.folded.push(state.codePointAt(upper == part ? part.toLowerCase() : upper, 0)); + p += size; + } + this.astral = pattern.length != this.chars.length; + } + ret(score, matched) { + this.score = score; + this.matched = matched; + return this; + } + // Matches a given word (completion) against the pattern (input). + // Will return a boolean indicating whether there was a match and, + // on success, set `this.score` to the score, `this.matched` to an + // array of `from, to` pairs indicating the matched parts of `word`. + // + // The score is a number that is more negative the worse the match + // is. See `Penalty` above. + match(word) { + if (this.pattern.length == 0) + return this.ret(-100 /* Penalty.NotFull */, []); + if (word.length < this.pattern.length) + return null; + let { chars, folded, any, precise, byWord } = this; + // For single-character queries, only match when they occur right + // at the start + if (chars.length == 1) { + let first = state.codePointAt(word, 0), firstSize = state.codePointSize(first); + let score = firstSize == word.length ? 0 : -100 /* Penalty.NotFull */; + if (first == chars[0]) ; + else if (first == folded[0]) + score += -200 /* Penalty.CaseFold */; + else + return null; + return this.ret(score, [0, firstSize]); + } + let direct = word.indexOf(this.pattern); + if (direct == 0) + return this.ret(word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */, [0, this.pattern.length]); + let len = chars.length, anyTo = 0; + if (direct < 0) { + for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) { + let next = state.codePointAt(word, i); + if (next == chars[anyTo] || next == folded[anyTo]) + any[anyTo++] = i; + i += state.codePointSize(next); + } + // No match, exit immediately + if (anyTo < len) + return null; + } + // This tracks the extent of the precise (non-folded, not + // necessarily adjacent) match + let preciseTo = 0; + // Tracks whether there is a match that hits only characters that + // appear to be starting words. `byWordFolded` is set to true when + // a case folded character is encountered in such a match + let byWordTo = 0, byWordFolded = false; + // If we've found a partial adjacent match, these track its state + let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1; + let hasLower = /[a-z]/.test(word), wordAdjacent = true; + // Go over the option's text, scanning for the various kinds of matches + for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) { + let next = state.codePointAt(word, i); + if (direct < 0) { + if (preciseTo < len && next == chars[preciseTo]) + precise[preciseTo++] = i; + if (adjacentTo < len) { + if (next == chars[adjacentTo] || next == folded[adjacentTo]) { + if (adjacentTo == 0) + adjacentStart = i; + adjacentEnd = i + 1; + adjacentTo++; + } + else { + adjacentTo = 0; + } + } + } + let ch, type = next < 0xff + ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */) + : ((ch = state.fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */); + if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) { + if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true))) + byWord[byWordTo++] = i; + else if (byWord.length) + wordAdjacent = false; + } + prevType = type; + i += state.codePointSize(next); + } + if (byWordTo == len && byWord[0] == 0 && wordAdjacent) + return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word); + if (adjacentTo == len && adjacentStart == 0) + return this.ret(-200 /* Penalty.CaseFold */ - word.length + (adjacentEnd == word.length ? 0 : -100 /* Penalty.NotFull */), [0, adjacentEnd]); + if (direct > -1) + return this.ret(-700 /* Penalty.NotStart */ - word.length, [direct, direct + this.pattern.length]); + if (adjacentTo == len) + return this.ret(-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, [adjacentStart, adjacentEnd]); + if (byWordTo == len) + return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ + + (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word); + return chars.length == 2 ? null + : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word); + } + result(score, positions, word) { + let result = [], i = 0; + for (let pos of positions) { + let to = pos + (this.astral ? state.codePointSize(state.codePointAt(word, pos)) : 1); + if (i && result[i - 1] == pos) + result[i - 1] = to; + else { + result[i++] = pos; + result[i++] = to; + } + } + return this.ret(score - word.length, result); + } +} +class StrictMatcher { + constructor(pattern) { + this.pattern = pattern; + this.matched = []; + this.score = 0; + this.folded = pattern.toLowerCase(); + } + match(word) { + if (word.length < this.pattern.length) + return null; + let start = word.slice(0, this.pattern.length); + let match = start == this.pattern ? 0 : start.toLowerCase() == this.folded ? -200 /* Penalty.CaseFold */ : null; + if (match == null) + return null; + this.matched = [0, start.length]; + this.score = match + (word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */); + return this; + } +} + +const completionConfig = state.Facet.define({ + combine(configs) { + return state.combineConfig(configs, { + activateOnTyping: true, + activateOnCompletion: () => false, + activateOnTypingDelay: 100, + selectOnOpen: true, + override: null, + closeOnBlur: true, + maxRenderedOptions: 100, + defaultKeymap: true, + tooltipClass: () => "", + optionClass: () => "", + aboveCursor: false, + icons: true, + addToOptions: [], + positionInfo: defaultPositionInfo, + filterStrict: false, + compareCompletions: (a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label), + interactionDelay: 75, + updateSyncTime: 100 + }, { + defaultKeymap: (a, b) => a && b, + closeOnBlur: (a, b) => a && b, + icons: (a, b) => a && b, + tooltipClass: (a, b) => c => joinClass(a(c), b(c)), + optionClass: (a, b) => c => joinClass(a(c), b(c)), + addToOptions: (a, b) => a.concat(b), + filterStrict: (a, b) => a || b, + }); + } +}); +function joinClass(a, b) { + return a ? b ? a + " " + b : a : b; +} +function defaultPositionInfo(view$1, list, option, info, space, tooltip) { + let rtl = view$1.textDirection == view.Direction.RTL, left = rtl, narrow = false; + let side = "top", offset, maxWidth; + let spaceLeft = list.left - space.left, spaceRight = space.right - list.right; + let infoWidth = info.right - info.left, infoHeight = info.bottom - info.top; + if (left && spaceLeft < Math.min(infoWidth, spaceRight)) + left = false; + else if (!left && spaceRight < Math.min(infoWidth, spaceLeft)) + left = true; + if (infoWidth <= (left ? spaceLeft : spaceRight)) { + offset = Math.max(space.top, Math.min(option.top, space.bottom - infoHeight)) - list.top; + maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight); + } + else { + narrow = true; + maxWidth = Math.min(400 /* Info.Width */, (rtl ? list.right : space.right - list.left) - 30 /* Info.Margin */); + let spaceBelow = space.bottom - list.bottom; + if (spaceBelow >= infoHeight || spaceBelow > list.top) { // Below the completion + offset = option.bottom - list.top; + } + else { // Above it + side = "bottom"; + offset = list.bottom - option.top; + } + } + let scaleY = (list.bottom - list.top) / tooltip.offsetHeight; + let scaleX = (list.right - list.left) / tooltip.offsetWidth; + return { + style: `${side}: ${offset / scaleY}px; max-width: ${maxWidth / scaleX}px`, + class: "cm-completionInfo-" + (narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right") + }; +} + +const setSelectedEffect = state.StateEffect.define(); +function optionContent(config) { + let content = config.addToOptions.slice(); + if (config.icons) + content.push({ + render(completion) { + let icon = document.createElement("div"); + icon.classList.add("cm-completionIcon"); + if (completion.type) + icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls)); + icon.setAttribute("aria-hidden", "true"); + return icon; + }, + position: 20 + }); + content.push({ + render(completion, _s, _v, match) { + let labelElt = document.createElement("span"); + labelElt.className = "cm-completionLabel"; + let label = completion.displayLabel || completion.label, off = 0; + for (let j = 0; j < match.length;) { + let from = match[j++], to = match[j++]; + if (from > off) + labelElt.appendChild(document.createTextNode(label.slice(off, from))); + let span = labelElt.appendChild(document.createElement("span")); + span.appendChild(document.createTextNode(label.slice(from, to))); + span.className = "cm-completionMatchedText"; + off = to; + } + if (off < label.length) + labelElt.appendChild(document.createTextNode(label.slice(off))); + return labelElt; + }, + position: 50 + }, { + render(completion) { + if (!completion.detail) + return null; + let detailElt = document.createElement("span"); + detailElt.className = "cm-completionDetail"; + detailElt.textContent = completion.detail; + return detailElt; + }, + position: 80 + }); + return content.sort((a, b) => a.position - b.position).map(a => a.render); +} +function rangeAroundSelected(total, selected, max) { + if (total <= max) + return { from: 0, to: total }; + if (selected < 0) + selected = 0; + if (selected <= (total >> 1)) { + let off = Math.floor(selected / max); + return { from: off * max, to: (off + 1) * max }; + } + let off = Math.ceil((total - selected) / max); + return { from: total - off * max, to: total - (off - 1) * max }; +} +class CompletionTooltip { + constructor(view, stateField, applyCompletion) { + this.view = view; + this.stateField = stateField; + this.applyCompletion = applyCompletion; + this.info = null; + this.infoDestroy = null; + this.placeInfoReq = { + read: () => this.measureInfo(), + write: (pos) => this.placeInfo(pos), + key: this + }; + this.space = null; + this.currentClass = ""; + let cState = view.state.field(stateField); + let { options, selected } = cState.open; + let config = view.state.facet(completionConfig); + this.optionContent = optionContent(config); + this.optionClass = config.optionClass; + this.tooltipClass = config.tooltipClass; + this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions); + this.dom = document.createElement("div"); + this.dom.className = "cm-tooltip-autocomplete"; + this.updateTooltipClass(view.state); + this.dom.addEventListener("mousedown", (e) => { + let { options } = view.state.field(stateField).open; + for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) { + if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) { + this.applyCompletion(view, options[+match[1]]); + e.preventDefault(); + return; + } + } + if (e.target == this.list) { + let move = this.list.classList.contains("cm-completionListIncompleteTop") && + e.clientY < this.list.firstChild.getBoundingClientRect().top ? this.range.from - 1 : + this.list.classList.contains("cm-completionListIncompleteBottom") && + e.clientY > this.list.lastChild.getBoundingClientRect().bottom ? this.range.to : null; + if (move != null) { + view.dispatch({ effects: setSelectedEffect.of(move) }); + e.preventDefault(); + } + } + }); + this.dom.addEventListener("focusout", (e) => { + let state = view.state.field(this.stateField, false); + if (state && state.tooltip && view.state.facet(completionConfig).closeOnBlur && + e.relatedTarget != view.contentDOM) + view.dispatch({ effects: closeCompletionEffect.of(null) }); + }); + this.showOptions(options, cState.id); + } + mount() { this.updateSel(); } + showOptions(options, id) { + if (this.list) + this.list.remove(); + this.list = this.dom.appendChild(this.createListBox(options, id, this.range)); + this.list.addEventListener("scroll", () => { + if (this.info) + this.view.requestMeasure(this.placeInfoReq); + }); + } + update(update) { + var _a; + let cState = update.state.field(this.stateField); + let prevState = update.startState.field(this.stateField); + this.updateTooltipClass(update.state); + if (cState != prevState) { + let { options, selected, disabled } = cState.open; + if (!prevState.open || prevState.open.options != options) { + this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions); + this.showOptions(options, cState.id); + } + this.updateSel(); + if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled)) + this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled); + } + } + updateTooltipClass(state) { + let cls = this.tooltipClass(state); + if (cls != this.currentClass) { + for (let c of this.currentClass.split(" ")) + if (c) + this.dom.classList.remove(c); + for (let c of cls.split(" ")) + if (c) + this.dom.classList.add(c); + this.currentClass = cls; + } + } + positioned(space) { + this.space = space; + if (this.info) + this.view.requestMeasure(this.placeInfoReq); + } + updateSel() { + let cState = this.view.state.field(this.stateField), open = cState.open; + if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) { + this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions); + this.showOptions(open.options, cState.id); + } + let newSel = this.updateSelectedOption(open.selected); + if (newSel) { + this.destroyInfo(); + let { completion } = open.options[open.selected]; + let { info } = completion; + if (!info) + return; + let infoResult = typeof info === "string" ? document.createTextNode(info) : info(completion); + if (!infoResult) + return; + if ("then" in infoResult) { + infoResult.then(obj => { + if (obj && this.view.state.field(this.stateField, false) == cState) + this.addInfoPane(obj, completion); + }).catch(e => view.logException(this.view.state, e, "completion info")); + } + else { + this.addInfoPane(infoResult, completion); + newSel.setAttribute("aria-describedby", this.info.id); + } + } + } + addInfoPane(content, completion) { + this.destroyInfo(); + let wrap = this.info = document.createElement("div"); + wrap.className = "cm-tooltip cm-completionInfo"; + wrap.id = "cm-completionInfo-" + Math.floor(Math.random() * 0xffff).toString(16); + if (content.nodeType != null) { + wrap.appendChild(content); + this.infoDestroy = null; + } + else { + let { dom, destroy } = content; + wrap.appendChild(dom); + this.infoDestroy = destroy || null; + } + this.dom.appendChild(wrap); + this.view.requestMeasure(this.placeInfoReq); + } + updateSelectedOption(selected) { + let set = null; + for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) { + if (opt.nodeName != "LI" || !opt.id) { + i--; // A section header + } + else if (i == selected) { + if (!opt.hasAttribute("aria-selected")) { + opt.setAttribute("aria-selected", "true"); + set = opt; + } + } + else { + if (opt.hasAttribute("aria-selected")) { + opt.removeAttribute("aria-selected"); + opt.removeAttribute("aria-describedby"); + } + } + } + if (set) + scrollIntoView(this.list, set); + return set; + } + measureInfo() { + let sel = this.dom.querySelector("[aria-selected]"); + if (!sel || !this.info) + return null; + let listRect = this.dom.getBoundingClientRect(); + let infoRect = this.info.getBoundingClientRect(); + let selRect = sel.getBoundingClientRect(); + let space = this.space; + if (!space) { + let docElt = this.dom.ownerDocument.documentElement; + space = { left: 0, top: 0, right: docElt.clientWidth, bottom: docElt.clientHeight }; + } + if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 || + selRect.bottom < Math.max(space.top, listRect.top) + 10) + return null; + return this.view.state.facet(completionConfig).positionInfo(this.view, listRect, selRect, infoRect, space, this.dom); + } + placeInfo(pos) { + if (this.info) { + if (pos) { + if (pos.style) + this.info.style.cssText = pos.style; + this.info.className = "cm-tooltip cm-completionInfo " + (pos.class || ""); + } + else { + this.info.style.cssText = "top: -1e6px"; + } + } + } + createListBox(options, id, range) { + const ul = document.createElement("ul"); + ul.id = id; + ul.setAttribute("role", "listbox"); + ul.setAttribute("aria-expanded", "true"); + ul.setAttribute("aria-label", this.view.state.phrase("Completions")); + ul.addEventListener("mousedown", e => { + // Prevent focus change when clicking the scrollbar + if (e.target == ul) + e.preventDefault(); + }); + let curSection = null; + for (let i = range.from; i < range.to; i++) { + let { completion, match } = options[i], { section } = completion; + if (section) { + let name = typeof section == "string" ? section : section.name; + if (name != curSection && (i > range.from || range.from == 0)) { + curSection = name; + if (typeof section != "string" && section.header) { + ul.appendChild(section.header(section)); + } + else { + let header = ul.appendChild(document.createElement("completion-section")); + header.textContent = name; + } + } + } + const li = ul.appendChild(document.createElement("li")); + li.id = id + "-" + i; + li.setAttribute("role", "option"); + let cls = this.optionClass(completion); + if (cls) + li.className = cls; + for (let source of this.optionContent) { + let node = source(completion, this.view.state, this.view, match); + if (node) + li.appendChild(node); + } + } + if (range.from) + ul.classList.add("cm-completionListIncompleteTop"); + if (range.to < options.length) + ul.classList.add("cm-completionListIncompleteBottom"); + return ul; + } + destroyInfo() { + if (this.info) { + if (this.infoDestroy) + this.infoDestroy(); + this.info.remove(); + this.info = null; + } + } + destroy() { + this.destroyInfo(); + } +} +function completionTooltip(stateField, applyCompletion) { + return (view) => new CompletionTooltip(view, stateField, applyCompletion); +} +function scrollIntoView(container, element) { + let parent = container.getBoundingClientRect(); + let self = element.getBoundingClientRect(); + let scaleY = parent.height / container.offsetHeight; + if (self.top < parent.top) + container.scrollTop -= (parent.top - self.top) / scaleY; + else if (self.bottom > parent.bottom) + container.scrollTop += (self.bottom - parent.bottom) / scaleY; +} + +// Used to pick a preferred option when two options with the same +// label occur in the result. +function score(option) { + return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) + + (option.type ? 1 : 0); +} +function sortOptions(active, state) { + let options = []; + let sections = null, dynamicSectionScore = null; + let addOption = (option) => { + options.push(option); + let { section } = option.completion; + if (section) { + if (!sections) + sections = []; + let name = typeof section == "string" ? section : section.name; + if (!sections.some(s => s.name == name)) + sections.push(typeof section == "string" ? { name } : section); + } + }; + let conf = state.facet(completionConfig); + for (let a of active) + if (a.hasResult()) { + let getMatch = a.result.getMatch; + if (a.result.filter === false) { + for (let option of a.result.options) { + addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length)); + } + } + else { + let pattern = state.sliceDoc(a.from, a.to), match; + let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern); + for (let option of a.result.options) + if (match = matcher.match(option.label)) { + let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : []; + let score = match.score + (option.boost || 0); + addOption(new Option(option, a.source, matched, score)); + if (typeof option.section == "object" && option.section.rank === "dynamic") { + let { name } = option.section; + if (!dynamicSectionScore) + dynamicSectionScore = Object.create(null); + dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9); + } + } + } + } + if (sections) { + let sectionOrder = Object.create(null), pos = 0; + let cmp = (a, b) => { + return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) || + (typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) || + (a.name < b.name ? -1 : 1); + }; + for (let s of sections.sort(cmp)) { + pos -= 1e5; + sectionOrder[s.name] = pos; + } + for (let option of options) { + let { section } = option.completion; + if (section) + option.score += sectionOrder[typeof section == "string" ? section : section.name]; + } + } + let result = [], prev = null; + let compare = conf.compareCompletions; + for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) { + let cur = opt.completion; + if (!prev || prev.label != cur.label || prev.detail != cur.detail || + (prev.type != null && cur.type != null && prev.type != cur.type) || + prev.apply != cur.apply || prev.boost != cur.boost) + result.push(opt); + else if (score(opt.completion) > score(prev)) + result[result.length - 1] = opt; + prev = opt.completion; + } + return result; +} +class CompletionDialog { + constructor(options, attrs, tooltip, timestamp, selected, disabled) { + this.options = options; + this.attrs = attrs; + this.tooltip = tooltip; + this.timestamp = timestamp; + this.selected = selected; + this.disabled = disabled; + } + setSelected(selected, id) { + return selected == this.selected || selected >= this.options.length ? this + : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled); + } + static build(active, state, id, prev, conf, didSetActive) { + if (prev && !didSetActive && active.some(s => s.isPending)) + return prev.setDisabled(); + let options = sortOptions(active, state); + if (!options.length) + return prev && active.some(a => a.isPending) ? prev.setDisabled() : null; + let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1; + if (prev && prev.selected != selected && prev.selected != -1) { + let selectedValue = prev.options[prev.selected].completion; + for (let i = 0; i < options.length; i++) + if (options[i].completion == selectedValue) { + selected = i; + break; + } + } + return new CompletionDialog(options, makeAttrs(id, selected), { + pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8), + create: createTooltip, + above: conf.aboveCursor, + }, prev ? prev.timestamp : Date.now(), selected, false); + } + map(changes) { + return new CompletionDialog(this.options, this.attrs, { ...this.tooltip, pos: changes.mapPos(this.tooltip.pos) }, this.timestamp, this.selected, this.disabled); + } + setDisabled() { + return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true); + } +} +class CompletionState { + constructor(active, id, open) { + this.active = active; + this.id = id; + this.open = open; + } + static start() { + return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null); + } + update(tr) { + let { state } = tr, conf = state.facet(completionConfig); + let sources = conf.override || + state.languageDataAt("autocomplete", cur(state)).map(asSource); + let active = sources.map(source => { + let value = this.active.find(s => s.source == source) || + new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */); + return value.update(tr, conf); + }); + if (active.length == this.active.length && active.every((a, i) => a == this.active[i])) + active = this.active; + let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect)); + if (open && tr.docChanged) + open = open.map(tr.changes); + if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) || + !sameResults(active, this.active) || didSet) + open = CompletionDialog.build(active, state, this.id, open, conf, didSet); + else if (open && open.disabled && !active.some(a => a.isPending)) + open = null; + if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult())) + active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a); + for (let effect of tr.effects) + if (effect.is(setSelectedEffect)) + open = open && open.setSelected(effect.value, this.id); + return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open); + } + get tooltip() { return this.open ? this.open.tooltip : null; } + get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; } +} +function sameResults(a, b) { + if (a == b) + return true; + for (let iA = 0, iB = 0;;) { + while (iA < a.length && !a[iA].hasResult()) + iA++; + while (iB < b.length && !b[iB].hasResult()) + iB++; + let endA = iA == a.length, endB = iB == b.length; + if (endA || endB) + return endA == endB; + if (a[iA++].result != b[iB++].result) + return false; + } +} +const baseAttrs = { + "aria-autocomplete": "list" +}; +const noAttrs = {}; +function makeAttrs(id, selected) { + let result = { + "aria-autocomplete": "list", + "aria-haspopup": "listbox", + "aria-controls": id + }; + if (selected > -1) + result["aria-activedescendant"] = id + "-" + selected; + return result; +} +const none = []; +function getUpdateType(tr, conf) { + if (tr.isUserEvent("input.complete")) { + let completion = tr.annotation(pickedCompletion); + if (completion && conf.activateOnCompletion(completion)) + return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */; + } + let typing = tr.isUserEvent("input.type"); + return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */ + : typing ? 1 /* UpdateType.Typing */ + : tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */ + : tr.selection ? 8 /* UpdateType.Reset */ + : tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */; +} +class ActiveSource { + constructor(source, state, explicit = false) { + this.source = source; + this.state = state; + this.explicit = explicit; + } + hasResult() { return false; } + get isPending() { return this.state == 1 /* State.Pending */; } + update(tr, conf) { + let type = getUpdateType(tr, conf), value = this; + if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr)) + value = new ActiveSource(value.source, 0 /* State.Inactive */); + if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */) + value = new ActiveSource(this.source, 1 /* State.Pending */); + value = value.updateFor(tr, type); + for (let effect of tr.effects) { + if (effect.is(startCompletionEffect)) + value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value); + else if (effect.is(closeCompletionEffect)) + value = new ActiveSource(value.source, 0 /* State.Inactive */); + else if (effect.is(setActiveEffect)) + for (let active of effect.value) + if (active.source == value.source) + value = active; + } + return value; + } + updateFor(tr, type) { return this.map(tr.changes); } + map(changes) { return this; } + touches(tr) { + return tr.changes.touchesRange(cur(tr.state)); + } +} +class ActiveResult extends ActiveSource { + constructor(source, explicit, limit, result, from, to) { + super(source, 3 /* State.Result */, explicit); + this.limit = limit; + this.result = result; + this.from = from; + this.to = to; + } + hasResult() { return true; } + updateFor(tr, type) { + var _a; + if (!(type & 3 /* UpdateType.SimpleInteraction */)) + return this.map(tr.changes); + let result = this.result; + if (result.map && !tr.changes.empty) + result = result.map(result, tr.changes); + let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1); + let pos = cur(tr.state); + if (pos > to || !result || + (type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit)) + return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */); + let limit = tr.changes.mapPos(this.limit); + if (checkValid(result.validFor, tr.state, from, to)) + return new ActiveResult(this.source, this.explicit, limit, result, from, to); + if (result.update && + (result = result.update(result, from, to, new CompletionContext(tr.state, pos, false)))) + return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state)); + return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit); + } + map(mapping) { + if (mapping.empty) + return this; + let result = this.result.map ? this.result.map(this.result, mapping) : this.result; + if (!result) + return new ActiveSource(this.source, 0 /* State.Inactive */); + return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1)); + } + touches(tr) { + return tr.changes.touchesRange(this.from, this.to); + } +} +function checkValid(validFor, state, from, to) { + if (!validFor) + return false; + let text = state.sliceDoc(from, to); + return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text); +} +const setActiveEffect = state.StateEffect.define({ + map(sources, mapping) { return sources.map(s => s.map(mapping)); } +}); +const completionState = state.StateField.define({ + create() { return CompletionState.start(); }, + update(value, tr) { return value.update(tr); }, + provide: f => [ + view.showTooltip.from(f, val => val.tooltip), + view.EditorView.contentAttributes.from(f, state => state.attrs) + ] +}); +function applyCompletion(view, option) { + const apply = option.completion.apply || option.completion.label; + let result = view.state.field(completionState).active.find(a => a.source == option.source); + if (!(result instanceof ActiveResult)) + return false; + if (typeof apply == "string") + view.dispatch({ + ...insertCompletionText(view.state, apply, result.from, result.to), + annotations: pickedCompletion.of(option.completion) + }); + else + apply(view, option.completion, result.from, result.to); + return true; +} +const createTooltip = completionTooltip(completionState, applyCompletion); + +/** +Returns a command that moves the completion selection forward or +backward by the given amount. +*/ +function moveCompletionSelection(forward, by = "option") { + return (view$1) => { + let cState = view$1.state.field(completionState, false); + if (!cState || !cState.open || cState.open.disabled || + Date.now() - cState.open.timestamp < view$1.state.facet(completionConfig).interactionDelay) + return false; + let step = 1, tooltip; + if (by == "page" && (tooltip = view.getTooltip(view$1, cState.open.tooltip))) + step = Math.max(2, Math.floor(tooltip.dom.offsetHeight / + tooltip.dom.querySelector("li").offsetHeight) - 1); + let { length } = cState.open.options; + let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1; + if (selected < 0) + selected = by == "page" ? 0 : length - 1; + else if (selected >= length) + selected = by == "page" ? length - 1 : 0; + view$1.dispatch({ effects: setSelectedEffect.of(selected) }); + return true; + }; +} +/** +Accept the current completion. +*/ +const acceptCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled || + Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay) + return false; + return applyCompletion(view, cState.open.options[cState.open.selected]); +}; +/** +Explicitly start autocompletion. +*/ +const startCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (!cState) + return false; + view.dispatch({ effects: startCompletionEffect.of(true) }); + return true; +}; +/** +Close the currently active completion. +*/ +const closeCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */)) + return false; + view.dispatch({ effects: closeCompletionEffect.of(null) }); + return true; +}; +class RunningQuery { + constructor(active, context) { + this.active = active; + this.context = context; + this.time = Date.now(); + this.updates = []; + // Note that 'undefined' means 'not done yet', whereas 'null' means + // 'query returned null'. + this.done = undefined; + } +} +const MaxUpdateCount = 50, MinAbortTime = 1000; +const completionPlugin = view.ViewPlugin.fromClass(class { + constructor(view) { + this.view = view; + this.debounceUpdate = -1; + this.running = []; + this.debounceAccept = -1; + this.pendingStart = false; + this.composing = 0 /* CompositionState.None */; + for (let active of view.state.field(completionState).active) + if (active.isPending) + this.startQuery(active); + } + update(update) { + let cState = update.state.field(completionState); + let conf = update.state.facet(completionConfig); + if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState) + return; + let doesReset = update.transactions.some(tr => { + let type = getUpdateType(tr, conf); + return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */); + }); + for (let i = 0; i < this.running.length; i++) { + let query = this.running[i]; + if (doesReset || + query.context.abortOnDocChange && update.docChanged || + query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) { + for (let handler of query.context.abortListeners) { + try { + handler(); + } + catch (e) { + view.logException(this.view.state, e); + } + } + query.context.abortListeners = null; + this.running.splice(i--, 1); + } + else { + query.updates.push(...update.transactions); + } + } + if (this.debounceUpdate > -1) + clearTimeout(this.debounceUpdate); + if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect)))) + this.pendingStart = true; + let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay; + this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source)) + ? setTimeout(() => this.startUpdate(), delay) : -1; + if (this.composing != 0 /* CompositionState.None */) + for (let tr of update.transactions) { + if (tr.isUserEvent("input.type")) + this.composing = 2 /* CompositionState.Changed */; + else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection) + this.composing = 3 /* CompositionState.ChangedAndMoved */; + } + } + startUpdate() { + this.debounceUpdate = -1; + this.pendingStart = false; + let { state } = this.view, cState = state.field(completionState); + for (let active of cState.active) { + if (active.isPending && !this.running.some(r => r.active.source == active.source)) + this.startQuery(active); + } + if (this.running.length && cState.open && cState.open.disabled) + this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime); + } + startQuery(active) { + let { state } = this.view, pos = cur(state); + let context = new CompletionContext(state, pos, active.explicit, this.view); + let pending = new RunningQuery(active, context); + this.running.push(pending); + Promise.resolve(active.source(context)).then(result => { + if (!pending.context.aborted) { + pending.done = result || null; + this.scheduleAccept(); + } + }, err => { + this.view.dispatch({ effects: closeCompletionEffect.of(null) }); + view.logException(this.view.state, err); + }); + } + scheduleAccept() { + if (this.running.every(q => q.done !== undefined)) + this.accept(); + else if (this.debounceAccept < 0) + this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime); + } + // For each finished query in this.running, try to create a result + // or, if appropriate, restart the query. + accept() { + var _a; + if (this.debounceAccept > -1) + clearTimeout(this.debounceAccept); + this.debounceAccept = -1; + let updated = []; + let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState); + for (let i = 0; i < this.running.length; i++) { + let query = this.running[i]; + if (query.done === undefined) + continue; + this.running.splice(i--, 1); + if (query.done) { + let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state); + let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1)); + let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos); + // Replay the transactions that happened since the start of + // the request and see if that preserves the result + for (let tr of query.updates) + active = active.update(tr, conf); + if (active.hasResult()) { + updated.push(active); + continue; + } + } + let current = cState.active.find(a => a.source == query.active.source); + if (current && current.isPending) { + if (query.done == null) { + // Explicitly failed. Should clear the pending status if it + // hasn't been re-set in the meantime. + let active = new ActiveSource(query.active.source, 0 /* State.Inactive */); + for (let tr of query.updates) + active = active.update(tr, conf); + if (!active.isPending) + updated.push(active); + } + else { + // Cleared by subsequent transactions. Restart. + this.startQuery(current); + } + } + } + if (updated.length || cState.open && cState.open.disabled) + this.view.dispatch({ effects: setActiveEffect.of(updated) }); + } +}, { + eventHandlers: { + blur(event) { + let state = this.view.state.field(completionState, false); + if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) { + let dialog = state.open && view.getTooltip(this.view, state.open.tooltip); + if (!dialog || !dialog.dom.contains(event.relatedTarget)) + setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10); + } + }, + compositionstart() { + this.composing = 1 /* CompositionState.Started */; + }, + compositionend() { + if (this.composing == 3 /* CompositionState.ChangedAndMoved */) { + // Safari fires compositionend events synchronously, possibly + // from inside an update, so dispatch asynchronously to avoid reentrancy + setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20); + } + this.composing = 0 /* CompositionState.None */; + } + } +}); +const windows = typeof navigator == "object" && /Win/.test(navigator.platform); +const commitCharacters = state.Prec.highest(view.EditorView.domEventHandlers({ + keydown(event, view) { + let field = view.state.field(completionState, false); + if (!field || !field.open || field.open.disabled || field.open.selected < 0 || + event.key.length > 1 || event.ctrlKey && !(windows && event.altKey) || event.metaKey) + return false; + let option = field.open.options[field.open.selected]; + let result = field.active.find(a => a.source == option.source); + let commitChars = option.completion.commitCharacters || result.result.commitCharacters; + if (commitChars && commitChars.indexOf(event.key) > -1) + applyCompletion(view, option); + return false; + } +})); + +const baseTheme = view.EditorView.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: 0.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: 0.5, + display: "block", + textAlign: "center", + cursor: "pointer", + }, + ".cm-tooltip.cm-completionInfo": { + position: "absolute", + padding: "3px 9px", + width: "max-content", + maxWidth: `${400 /* Info.Width */}px`, + boxSizing: "border-box", + whiteSpace: "pre-line" + }, + ".cm-completionInfo.cm-completionInfo-left": { right: "100%" }, + ".cm-completionInfo.cm-completionInfo-right": { left: "100%" }, + ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` }, + ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` }, + "&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: "'🔑\uFE0E'" } // Disable emoji rendering + }, + ".cm-completionIcon-namespace": { + "&:after": { content: "'▢'" } + }, + ".cm-completionIcon-text": { + "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" } + } +}); + +class FieldPos { + constructor(field, line, from, to) { + this.field = field; + this.line = line; + this.from = from; + this.to = to; + } +} +class FieldRange { + constructor(field, from, to) { + this.field = field; + this.from = from; + this.to = to; + } + map(changes) { + let from = changes.mapPos(this.from, -1, state.MapMode.TrackDel); + let to = changes.mapPos(this.to, 1, state.MapMode.TrackDel); + return from == null || to == null ? null : new FieldRange(this.field, from, to); + } +} +class Snippet { + constructor(lines, fieldPositions) { + this.lines = lines; + this.fieldPositions = fieldPositions; + } + instantiate(state, pos) { + let text = [], lineStart = [pos]; + let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0]; + for (let line of this.lines) { + if (text.length) { + let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length; + for (let i = 0; i < tabs; i++) + indent += state.facet(language.indentUnit); + lineStart.push(pos + indent.length - tabs); + line = indent + line.slice(tabs); + } + text.push(line); + pos += line.length + 1; + } + let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to)); + return { text, ranges }; + } + static parse(template) { + let fields = []; + let lines = [], positions = [], m; + for (let line of template.split(/\r\n?|\n/)) { + while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) { + let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1; + let name = rawName.replace(/\\[{}]/g, m => m[1]); + for (let i = 0; i < fields.length; i++) { + if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false) + found = i; + } + if (found < 0) { + let i = 0; + while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq))) + i++; + fields.splice(i, 0, { seq, name }); + found = i; + for (let pos of positions) + if (pos.field >= found) + pos.field++; + } + for (let pos of positions) + if (pos.line == lines.length && pos.from > m.index) { + let snip = m[2] ? 3 + (m[1] || "").length : 2; + pos.from -= snip; + pos.to -= snip; + } + positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length)); + line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length); + } + line = line.replace(/\\([{}])/g, (_, brace, index) => { + for (let pos of positions) + if (pos.line == lines.length && pos.from > index) { + pos.from--; + pos.to--; + } + return brace; + }); + lines.push(line); + } + return new Snippet(lines, positions); + } +} +let fieldMarker = view.Decoration.widget({ widget: new class extends view.WidgetType { + toDOM() { + let span = document.createElement("span"); + span.className = "cm-snippetFieldPosition"; + return span; + } + ignoreEvent() { return false; } + } }); +let fieldRange = view.Decoration.mark({ class: "cm-snippetField" }); +class ActiveSnippet { + constructor(ranges, active) { + this.ranges = ranges; + this.active = active; + this.deco = view.Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)), true); + } + map(changes) { + let ranges = []; + for (let r of this.ranges) { + let mapped = r.map(changes); + if (!mapped) + return null; + ranges.push(mapped); + } + return new ActiveSnippet(ranges, this.active); + } + selectionInsideField(sel) { + return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to)); + } +} +const setActive = state.StateEffect.define({ + map(value, changes) { return value && value.map(changes); } +}); +const moveToField = state.StateEffect.define(); +const snippetState = state.StateField.define({ + create() { return null; }, + update(value, tr) { + for (let effect of tr.effects) { + if (effect.is(setActive)) + return effect.value; + if (effect.is(moveToField) && value) + return new ActiveSnippet(value.ranges, effect.value); + } + if (value && tr.docChanged) + value = value.map(tr.changes); + if (value && tr.selection && !value.selectionInsideField(tr.selection)) + value = null; + return value; + }, + provide: f => view.EditorView.decorations.from(f, val => val ? val.deco : view.Decoration.none) +}); +function fieldSelection(ranges, field) { + return state.EditorSelection.create(ranges.filter(r => r.field == field).map(r => state.EditorSelection.range(r.from, r.to))); +} +/** +Convert a snippet template to a function that can +[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written +using syntax like this: + + "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" + +Each `${}` placeholder (you may also use `#{}`) indicates a field +that the user can fill in. Its name, if any, will be the default +content for the field. + +When the snippet is activated by calling the returned function, +the code is inserted at the given position. Newlines in the +template are indented by the indentation of the start line, plus +one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after +the newline. + +On activation, (all instances of) the first field are selected. +The user can move between fields with Tab and Shift-Tab as long as +the fields are active. Moving to the last field or moving the +cursor out of the current field deactivates the fields. + +The order of fields defaults to textual order, but you can add +numbers to placeholders (`${1}` or `${1:defaultText}`) to provide +a custom order. + +To include a literal `{` or `}` in your template, put a backslash +in front of it. This will be removed and the brace will not be +interpreted as indicating a placeholder. +*/ +function snippet(template) { + let snippet = Snippet.parse(template); + return (editor, completion, from, to) => { + let { text, ranges } = snippet.instantiate(editor.state, from); + let { main } = editor.state.selection; + let spec = { + changes: { from, to: to == main.from ? main.to : to, insert: state.Text.of(text) }, + scrollIntoView: true, + annotations: completion ? [pickedCompletion.of(completion), state.Transaction.userEvent.of("input.complete")] : undefined + }; + if (ranges.length) + spec.selection = fieldSelection(ranges, 0); + if (ranges.some(r => r.field > 0)) { + let active = new ActiveSnippet(ranges, 0); + let effects = spec.effects = [setActive.of(active)]; + if (editor.state.field(snippetState, false) === undefined) + effects.push(state.StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme])); + } + editor.dispatch(editor.state.update(spec)); + }; +} +function moveField(dir) { + return ({ state, dispatch }) => { + let active = state.field(snippetState, false); + if (!active || dir < 0 && active.active == 0) + return false; + let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir); + dispatch(state.update({ + selection: fieldSelection(active.ranges, next), + effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)), + scrollIntoView: true + })); + return true; + }; +} +/** +A command that clears the active snippet, if any. +*/ +const clearSnippet = ({ state, dispatch }) => { + let active = state.field(snippetState, false); + if (!active) + return false; + dispatch(state.update({ effects: setActive.of(null) })); + return true; +}; +/** +Move to the next snippet field, if available. +*/ +const nextSnippetField = moveField(1); +/** +Move to the previous snippet field, if available. +*/ +const prevSnippetField = moveField(-1); +/** +Check if there is an active snippet with a next field for +`nextSnippetField` to move to. +*/ +function hasNextSnippetField(state) { + let active = state.field(snippetState, false); + return !!(active && active.ranges.some(r => r.field == active.active + 1)); +} +/** +Returns true if there is an active snippet and a previous field +for `prevSnippetField` to move to. +*/ +function hasPrevSnippetField(state) { + let active = state.field(snippetState, false); + return !!(active && active.active > 0); +} +const defaultSnippetKeymap = [ + { key: "Tab", run: nextSnippetField, shift: prevSnippetField }, + { key: "Escape", run: clearSnippet } +]; +/** +A facet that can be used to configure the key bindings used by +snippets. The default binds Tab to +[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to +[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape +to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet). +*/ +const snippetKeymap = state.Facet.define({ + combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; } +}); +const addSnippetKeymap = state.Prec.highest(view.keymap.compute([snippetKeymap], state => state.facet(snippetKeymap))); +/** +Create a completion from a snippet. Returns an object with the +properties from `completion`, plus an `apply` function that +applies the snippet. +*/ +function snippetCompletion(template, completion) { + return { ...completion, apply: snippet(template) }; +} +const snippetPointerHandler = view.EditorView.domEventHandlers({ + mousedown(event, view) { + let active = view.state.field(snippetState, false), pos; + if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null) + return false; + let match = active.ranges.find(r => r.from <= pos && r.to >= pos); + if (!match || match.field == active.active) + return false; + view.dispatch({ + selection: fieldSelection(active.ranges, match.field), + effects: setActive.of(active.ranges.some(r => r.field > match.field) + ? new ActiveSnippet(active.ranges, match.field) : null), + scrollIntoView: true + }); + return true; + } +}); + +function wordRE(wordChars) { + let escaped = wordChars.replace(/[\]\-\\]/g, "\\$&"); + try { + return new RegExp(`[\\p{Alphabetic}\\p{Number}_${escaped}]+`, "ug"); + } + catch (_a) { + return new RegExp(`[\w${escaped}]`, "g"); + } +} +function mapRE(re, f) { + return new RegExp(f(re.source), re.unicode ? "u" : ""); +} +const wordCaches = Object.create(null); +function wordCache(wordChars) { + return wordCaches[wordChars] || (wordCaches[wordChars] = new WeakMap); +} +function storeWords(doc, wordRE, result, seen, ignoreAt) { + for (let lines = doc.iterLines(), pos = 0; !lines.next().done;) { + let { value } = lines, m; + wordRE.lastIndex = 0; + while (m = wordRE.exec(value)) { + if (!seen[m[0]] && pos + m.index != ignoreAt) { + result.push({ type: "text", label: m[0] }); + seen[m[0]] = true; + if (result.length >= 2000 /* C.MaxList */) + return; + } + } + pos += value.length + 1; + } +} +function collectWords(doc, cache, wordRE, to, ignoreAt) { + let big = doc.length >= 1000 /* C.MinCacheLen */; + let cached = big && cache.get(doc); + if (cached) + return cached; + let result = [], seen = Object.create(null); + if (doc.children) { + let pos = 0; + for (let ch of doc.children) { + if (ch.length >= 1000 /* C.MinCacheLen */) { + for (let c of collectWords(ch, cache, wordRE, to - pos, ignoreAt - pos)) { + if (!seen[c.label]) { + seen[c.label] = true; + result.push(c); + } + } + } + else { + storeWords(ch, wordRE, result, seen, ignoreAt - pos); + } + pos += ch.length + 1; + } + } + else { + storeWords(doc, wordRE, result, seen, ignoreAt); + } + if (big && result.length < 2000 /* C.MaxList */) + cache.set(doc, result); + return result; +} +/** +A completion source that will scan the document for words (using a +[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and +return those as completions. +*/ +const completeAnyWord = context => { + var _a; + let wordChars = (_a = context.state.languageDataAt("wordChars", context.pos)[0]) !== null && _a !== void 0 ? _a : ""; + let re = wordRE(wordChars); + let token = context.matchBefore(mapRE(re, s => s + "$")); + if (!token && !context.explicit) + return null; + let from = token ? token.from : context.pos; + let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* C.Range */, from); + return { from, options, validFor: mapRE(re, s => "^" + s) }; +}; + +const defaults = { + brackets: ["(", "[", "{", "'", '"'], + before: ")]}:;>", + stringPrefixes: [] +}; +const closeBracketEffect = state.StateEffect.define({ + map(value, mapping) { + let mapped = mapping.mapPos(value, -1, state.MapMode.TrackAfter); + return mapped == null ? undefined : mapped; + } +}); +const closedBracket = new class extends state.RangeValue { +}; +closedBracket.startSide = 1; +closedBracket.endSide = -1; +const bracketState = state.StateField.define({ + create() { return state.RangeSet.empty; }, + update(value, tr) { + value = value.map(tr.changes); + if (tr.selection) { + let line = tr.state.doc.lineAt(tr.selection.main.head); + value = value.update({ filter: from => from >= line.from && from <= line.to }); + } + for (let effect of tr.effects) + if (effect.is(closeBracketEffect)) + value = value.update({ add: [closedBracket.range(effect.value, effect.value + 1)] }); + return value; + } +}); +/** +Extension to enable bracket-closing behavior. When a closeable +bracket is typed, its closing bracket is immediately inserted +after the cursor. When closing a bracket directly in front of a +closing bracket inserted by the extension, the cursor moves over +that bracket. +*/ +function closeBrackets() { + return [inputHandler, bracketState]; +} +const definedClosing = "()[]{}<>«»»«[]{}"; +function closing(ch) { + for (let i = 0; i < definedClosing.length; i += 2) + if (definedClosing.charCodeAt(i) == ch) + return definedClosing.charAt(i + 1); + return state.fromCodePoint(ch < 128 ? ch : ch + 1); +} +function config(state, pos) { + return state.languageDataAt("closeBrackets", pos)[0] || defaults; +} +const android = typeof navigator == "object" && /Android\b/.test(navigator.userAgent); +const inputHandler = view.EditorView.inputHandler.of((view, from, to, insert) => { + if ((android ? view.composing : view.compositionStarted) || view.state.readOnly) + return false; + let sel = view.state.selection.main; + if (insert.length > 2 || insert.length == 2 && state.codePointSize(state.codePointAt(insert, 0)) == 1 || + from != sel.from || to != sel.to) + return false; + let tr = insertBracket(view.state, insert); + if (!tr) + return false; + view.dispatch(tr); + return true; +}); +/** +Command that implements deleting a pair of matching brackets when +the cursor is between them. +*/ +const deleteBracketPair = ({ state: state$1, dispatch }) => { + if (state$1.readOnly) + return false; + let conf = config(state$1, state$1.selection.main.head); + let tokens = conf.brackets || defaults.brackets; + let dont = null, changes = state$1.changeByRange(range => { + if (range.empty) { + let before = prevChar(state$1.doc, range.head); + for (let token of tokens) { + if (token == before && nextChar(state$1.doc, range.head) == closing(state.codePointAt(token, 0))) + return { changes: { from: range.head - token.length, to: range.head + token.length }, + range: state.EditorSelection.cursor(range.head - token.length) }; + } + } + return { range: dont = range }; + }); + if (!dont) + dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "delete.backward" })); + return !dont; +}; +/** +Close-brackets related key bindings. Binds Backspace to +[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair). +*/ +const closeBracketsKeymap = [ + { key: "Backspace", run: deleteBracketPair } +]; +/** +Implements the extension's behavior on text insertion. If the +given string counts as a bracket in the language around the +selection, and replacing the selection with it requires custom +behavior (inserting a closing version or skipping past a +previously-closed bracket), this function returns a transaction +representing that custom behavior. (You only need this if you want +to programmatically insert brackets—the +[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will +take care of running this for user input.) +*/ +function insertBracket(state$1, bracket) { + let conf = config(state$1, state$1.selection.main.head); + let tokens = conf.brackets || defaults.brackets; + for (let tok of tokens) { + let closed = closing(state.codePointAt(tok, 0)); + if (bracket == tok) + return closed == tok ? handleSame(state$1, tok, tokens.indexOf(tok + tok + tok) > -1, conf) + : handleOpen(state$1, tok, closed, conf.before || defaults.before); + if (bracket == closed && closedBracketAt(state$1, state$1.selection.main.from)) + return handleClose(state$1, tok, closed); + } + return null; +} +function closedBracketAt(state, pos) { + let found = false; + state.field(bracketState).between(0, state.doc.length, from => { + if (from == pos) + found = true; + }); + return found; +} +function nextChar(doc, pos) { + let next = doc.sliceString(pos, pos + 2); + return next.slice(0, state.codePointSize(state.codePointAt(next, 0))); +} +function prevChar(doc, pos) { + let prev = doc.sliceString(pos - 2, pos); + return state.codePointSize(state.codePointAt(prev, 0)) == prev.length ? prev : prev.slice(1); +} +function handleOpen(state$1, open, close, closeBefore) { + let dont = null, changes = state$1.changeByRange(range => { + if (!range.empty) + return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }], + effects: closeBracketEffect.of(range.to + open.length), + range: state.EditorSelection.range(range.anchor + open.length, range.head + open.length) }; + let next = nextChar(state$1.doc, range.head); + if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1) + return { changes: { insert: open + close, from: range.head }, + effects: closeBracketEffect.of(range.head + open.length), + range: state.EditorSelection.cursor(range.head + open.length) }; + return { range: dont = range }; + }); + return dont ? null : state$1.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +function handleClose(state$1, _open, close) { + let dont = null, changes = state$1.changeByRange(range => { + if (range.empty && nextChar(state$1.doc, range.head) == close) + return { changes: { from: range.head, to: range.head + close.length, insert: close }, + range: state.EditorSelection.cursor(range.head + close.length) }; + return dont = { range }; + }); + return dont ? null : state$1.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +// Handles cases where the open and close token are the same, and +// possibly triple quotes (as in `"""abc"""`-style quoting). +function handleSame(state$1, token, allowTriple, config) { + let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes; + let dont = null, changes = state$1.changeByRange(range => { + if (!range.empty) + return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }], + effects: closeBracketEffect.of(range.to + token.length), + range: state.EditorSelection.range(range.anchor + token.length, range.head + token.length) }; + let pos = range.head, next = nextChar(state$1.doc, pos), start; + if (next == token) { + if (nodeStart(state$1, pos)) { + return { changes: { insert: token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: state.EditorSelection.cursor(pos + token.length) }; + } + else if (closedBracketAt(state$1, pos)) { + let isTriple = allowTriple && state$1.sliceDoc(pos, pos + token.length * 3) == token + token + token; + let content = isTriple ? token + token + token : token; + return { changes: { from: pos, to: pos + content.length, insert: content }, + range: state.EditorSelection.cursor(pos + content.length) }; + } + } + else if (allowTriple && state$1.sliceDoc(pos - 2 * token.length, pos) == token + token && + (start = canStartStringAt(state$1, pos - 2 * token.length, stringPrefixes)) > -1 && + nodeStart(state$1, start)) { + return { changes: { insert: token + token + token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: state.EditorSelection.cursor(pos + token.length) }; + } + else if (state$1.charCategorizer(pos)(next) != state.CharCategory.Word) { + if (canStartStringAt(state$1, pos, stringPrefixes) > -1 && !probablyInString(state$1, pos, token, stringPrefixes)) + return { changes: { insert: token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: state.EditorSelection.cursor(pos + token.length) }; + } + return { range: dont = range }; + }); + return dont ? null : state$1.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +function nodeStart(state, pos) { + let tree = language.syntaxTree(state).resolveInner(pos + 1); + return tree.parent && tree.from == pos; +} +function probablyInString(state, pos, quoteToken, prefixes) { + let node = language.syntaxTree(state).resolveInner(pos, -1); + let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0); + for (let i = 0; i < 5; i++) { + let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix)); + let quotePos = start.indexOf(quoteToken); + if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) { + let first = node.firstChild; + while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) { + if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken) + return false; + first = first.firstChild; + } + return true; + } + let parent = node.to == pos && node.parent; + if (!parent) + break; + node = parent; + } + return false; +} +function canStartStringAt(state$1, pos, prefixes) { + let charCat = state$1.charCategorizer(pos); + if (charCat(state$1.sliceDoc(pos - 1, pos)) != state.CharCategory.Word) + return pos; + for (let prefix of prefixes) { + let start = pos - prefix.length; + if (state$1.sliceDoc(start, pos) == prefix && charCat(state$1.sliceDoc(start - 1, start)) != state.CharCategory.Word) + return start; + } + return -1; +} + +/** +Returns an extension that enables autocompletion. +*/ +function autocompletion(config = {}) { + return [ + commitCharacters, + completionState, + completionConfig.of(config), + completionPlugin, + completionKeymapExt, + baseTheme + ]; +} +/** +Basic keybindings for autocompletion. + + - Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion) + - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion) + - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)` + - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)` + - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")` + - PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")` + - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion) +*/ +const completionKeymap = [ + { key: "Ctrl-Space", run: startCompletion }, + { mac: "Alt-`", run: startCompletion }, + { mac: "Alt-i", run: startCompletion }, + { key: "Escape", run: closeCompletion }, + { key: "ArrowDown", run: moveCompletionSelection(true) }, + { key: "ArrowUp", run: moveCompletionSelection(false) }, + { key: "PageDown", run: moveCompletionSelection(true, "page") }, + { key: "PageUp", run: moveCompletionSelection(false, "page") }, + { key: "Enter", run: acceptCompletion } +]; +const completionKeymapExt = state.Prec.highest(view.keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : [])); +/** +Get the current completion status. When completions are available, +this will return `"active"`. When completions are pending (in the +process of being queried), this returns `"pending"`. Otherwise, it +returns `null`. +*/ +function completionStatus(state) { + let cState = state.field(completionState, false); + return cState && cState.active.some(a => a.isPending) ? "pending" + : cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null; +} +const completionArrayCache = new WeakMap; +/** +Returns the available completions as an array. +*/ +function currentCompletions(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + if (!open || open.disabled) + return []; + let completions = completionArrayCache.get(open.options); + if (!completions) + completionArrayCache.set(open.options, completions = open.options.map(o => o.completion)); + return completions; +} +/** +Return the currently selected completion, if any. +*/ +function selectedCompletion(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + return open && !open.disabled && open.selected >= 0 ? open.options[open.selected].completion : null; +} +/** +Returns the currently selected position in the active completion +list, or null if no completions are active. +*/ +function selectedCompletionIndex(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + return open && !open.disabled && open.selected >= 0 ? open.selected : null; +} +/** +Create an effect that can be attached to a transaction to change +the currently selected completion. +*/ +function setSelectedCompletion(index) { + return setSelectedEffect.of(index); +} + +exports.CompletionContext = CompletionContext; +exports.acceptCompletion = acceptCompletion; +exports.autocompletion = autocompletion; +exports.clearSnippet = clearSnippet; +exports.closeBrackets = closeBrackets; +exports.closeBracketsKeymap = closeBracketsKeymap; +exports.closeCompletion = closeCompletion; +exports.completeAnyWord = completeAnyWord; +exports.completeFromList = completeFromList; +exports.completionKeymap = completionKeymap; +exports.completionStatus = completionStatus; +exports.currentCompletions = currentCompletions; +exports.deleteBracketPair = deleteBracketPair; +exports.hasNextSnippetField = hasNextSnippetField; +exports.hasPrevSnippetField = hasPrevSnippetField; +exports.ifIn = ifIn; +exports.ifNotIn = ifNotIn; +exports.insertBracket = insertBracket; +exports.insertCompletionText = insertCompletionText; +exports.moveCompletionSelection = moveCompletionSelection; +exports.nextSnippetField = nextSnippetField; +exports.pickedCompletion = pickedCompletion; +exports.prevSnippetField = prevSnippetField; +exports.selectedCompletion = selectedCompletion; +exports.selectedCompletionIndex = selectedCompletionIndex; +exports.setSelectedCompletion = setSelectedCompletion; +exports.snippet = snippet; +exports.snippetCompletion = snippetCompletion; +exports.snippetKeymap = snippetKeymap; +exports.startCompletion = startCompletion; diff --git a/node_modules/@codemirror/autocomplete/dist/index.d.cts b/node_modules/@codemirror/autocomplete/dist/index.d.cts new file mode 100644 index 0000000..23ea041 --- /dev/null +++ b/node_modules/@codemirror/autocomplete/dist/index.d.cts @@ -0,0 +1,648 @@ +import * as _codemirror_state from '@codemirror/state'; +import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state'; +import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view'; +import * as _lezer_common from '@lezer/common'; + +/** +Objects type used to represent individual completions. +*/ +interface Completion { + /** + The label to show in the completion picker. This is what input + is matched against to determine whether a completion matches (and + how well it matches). + */ + label: string; + /** + An optional override for the completion's visible label. When + using this, matched characters will only be highlighted if you + provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch) + function. + */ + displayLabel?: string; + /** + Overrides the text that is used to sort completions. Will + default to `label` if not given. + */ + sortText?: string; + /** + An optional short piece of information to show (with a different + style) after the label. + */ + detail?: string; + /** + Additional info to show when the completion is selected. Can be + a plain string or a function that'll render the DOM structure to + show when invoked. + */ + info?: string | ((completion: Completion) => CompletionInfo | Promise); + /** + How to apply the completion. The default is to replace it with + its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a + string, the completion range is replaced by that string. When it + is a function, that function is called to perform the + completion. If it fires a transaction, it is responsible for + adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion) + annotation to it. + */ + apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void); + /** + The type of the completion. This is used to pick an icon to show + for the completion. Icons are styled with a CSS class created by + appending the type name to `"cm-completionIcon-"`. You can + define or restyle icons by defining these selectors. The base + library defines simple icons for `class`, `constant`, `enum`, + `function`, `interface`, `keyword`, `method`, `namespace`, + `property`, `text`, `type`, and `variable`. + + Multiple types can be provided by separating them with spaces. + */ + type?: string; + /** + When this option is selected, and one of these characters is + typed, insert the completion before typing the character. + */ + commitCharacters?: readonly string[]; + /** + When given, should be a number from -99 to 99 that adjusts how + this completion is ranked compared to other completions that + match the input as well as this one. A negative number moves it + down the list, a positive number moves it up. + */ + boost?: number; + /** + Can be used to divide the completion list into sections. + Completions in a given section (matched by name) will be grouped + together, with a heading above them. Options without section + will appear above all sections. A string value is equivalent to + a `{name}` object. + */ + section?: string | CompletionSection; +} +/** +The type returned from +[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM +node, null to indicate there is no info, or an object with an +optional `destroy` method that cleans up the node. +*/ +type CompletionInfo = Node | null | { + dom: Node; + destroy?(): void; +}; +/** +Object used to describe a completion +[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to +create a shared object used by all the completions in a given +section. +*/ +interface CompletionSection { + /** + The name of the section. If no `render` method is present, this + will be displayed above the options. + */ + name: string; + /** + An optional function that renders the section header. Since the + headers are shown inside a list, you should make sure the + resulting element has a `display: list-item` style. + */ + header?: (section: CompletionSection) => HTMLElement; + /** + By default, sections are ordered alphabetically by name. To + specify an explicit order, `rank` can be used. Sections with a + lower rank will be shown above sections with a higher rank. + + When set to `"dynamic"`, the section's position compared to + other dynamic sections depends on the matching score of the + best-matching option in the sections. + */ + rank?: number | "dynamic"; +} +/** +An instance of this is passed to completion source functions. +*/ +declare class CompletionContext { + /** + The editor state that the completion happens in. + */ + readonly state: EditorState; + /** + The position at which the completion is happening. + */ + readonly pos: number; + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + readonly explicit: boolean; + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + readonly view?: EditorView | undefined; + /** + Create a new completion context. (Mostly useful for testing + completion sources—in the editor, the extension will create + these for you.) + */ + constructor( + /** + The editor state that the completion happens in. + */ + state: EditorState, + /** + The position at which the completion is happening. + */ + pos: number, + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + explicit: boolean, + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + view?: EditorView | undefined); + /** + Get the extent, content, and (if there is a token) type of the + token before `this.pos`. + */ + tokenBefore(types: readonly string[]): { + from: number; + to: number; + text: string; + type: _lezer_common.NodeType; + } | null; + /** + Get the match of the given expression directly before the + cursor. + */ + matchBefore(expr: RegExp): { + from: number; + to: number; + text: string; + } | null; + /** + Yields true when the query has been aborted. Can be useful in + asynchronous queries to avoid doing work that will be ignored. + */ + get aborted(): boolean; + /** + Allows you to register abort handlers, which will be called when + the query is + [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted). + + By default, running queries will not be aborted for regular + typing or backspacing, on the assumption that they are likely to + return a result with a + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that + allows the result to be used after all. Passing `onDocChange: + true` will cause this query to be aborted for any document + change. + */ + addEventListener(type: "abort", listener: () => void, options?: { + onDocChange: boolean; + }): void; +} +/** +Given a a fixed array of options, return an autocompleter that +completes them. +*/ +declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource; +/** +Wrap the given completion source so that it will only fire when the +cursor is in a syntax node with one of the given names. +*/ +declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource; +/** +Wrap the given completion source so that it will not fire when the +cursor is in a syntax node with one of the given names. +*/ +declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource; +/** +The function signature for a completion source. Such a function +may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult) +synchronously or as a promise. Returning null indicates no +completions are available. +*/ +type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise; +/** +Interface for objects returned by completion sources. +*/ +interface CompletionResult { + /** + The start of the range that is being completed. + */ + from: number; + /** + The end of the range that is being completed. Defaults to the + main cursor position. + */ + to?: number; + /** + The completions returned. These don't have to be compared with + the input by the source—the autocompletion system will do its + own matching (against the text between `from` and `to`) and + sorting. + */ + options: readonly Completion[]; + /** + When given, further typing or deletion that causes the part of + the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from` + and `to` to match this regular expression or predicate function + will not query the completion source again, but continue with + this list of options. This can help a lot with responsiveness, + since it allows the completion list to be updated synchronously. + */ + validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean); + /** + By default, the library filters and scores completions. Set + `filter` to `false` to disable this, and cause your completions + to all be included, in the order they were given. When there are + other sources, unfiltered completions appear at the top of the + list of completions. `validFor` must not be given when `filter` + is `false`, because it only works when filtering. + */ + filter?: boolean; + /** + When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to + `false` or a completion has a + [`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this + may be provided to compute the ranges on the label that match + the input. Should return an array of numbers where each pair of + adjacent numbers provide the start and end of a range. The + second argument, the match found by the library, is only passed + when `filter` isn't `false`. + */ + getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[]; + /** + Synchronously update the completion result after typing or + deletion. If given, this should not do any expensive work, since + it will be called during editor state updates. The function + should make sure (similar to + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the + completion still applies in the new state. + */ + update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null; + /** + When results contain position-dependent information in, for + example, `apply` methods, you can provide this method to update + the result for transactions that happen after the query. It is + not necessary to update `from` and `to`—those are tracked + automatically. + */ + map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null; + /** + Set a default set of [commit + characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all + options in this result. + */ + commitCharacters?: readonly string[]; +} +/** +This annotation is added to transactions that are produced by +picking a completion. +*/ +declare const pickedCompletion: _codemirror_state.AnnotationType; +/** +Helper function that returns a transaction spec which inserts a +completion's text in the main selection range, and any other +selection range that has the same text in front of it. +*/ +declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec; + +interface CompletionConfig { + /** + When enabled (defaults to true), autocompletion will start + whenever the user types something that can be completed. + */ + activateOnTyping?: boolean; + /** + When given, if a completion that matches the predicate is + picked, reactivate completion again as if it was typed normally. + */ + activateOnCompletion?: (completion: Completion) => boolean; + /** + The amount of time to wait for further typing before querying + completion sources via + [`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping). + Defaults to 100, which should be fine unless your completion + source is very slow and/or doesn't use `validFor`. + */ + activateOnTypingDelay?: number; + /** + By default, when completion opens, the first option is selected + and can be confirmed with + [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this + is set to false, the completion widget starts with no completion + selected, and the user has to explicitly move to a completion + before you can confirm one. + */ + selectOnOpen?: boolean; + /** + Override the completion sources used. By default, they will be + taken from the `"autocomplete"` [language + data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold + [completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays + of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)). + */ + override?: readonly CompletionSource[] | null; + /** + Determines whether the completion tooltip is closed when the + editor loses focus. Defaults to true. + */ + closeOnBlur?: boolean; + /** + The maximum number of options to render to the DOM. + */ + maxRenderedOptions?: number; + /** + Set this to false to disable the [default completion + keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to + add bindings to control completion yourself. The bindings should + probably have a higher precedence than other bindings for the + same keys.) + */ + defaultKeymap?: boolean; + /** + By default, completions are shown below the cursor when there is + space. Setting this to true will make the extension put the + completions above the cursor when possible. + */ + aboveCursor?: boolean; + /** + When given, this may return an additional CSS class to add to + the completion dialog element. + */ + tooltipClass?: (state: EditorState) => string; + /** + This can be used to add additional CSS classes to completion + options. + */ + optionClass?: (completion: Completion) => string; + /** + By default, the library will render icons based on the + completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of + each option. Set this to false to turn that off. + */ + icons?: boolean; + /** + This option can be used to inject additional content into + options. The `render` function will be called for each visible + completion, and should produce a DOM node to show. `position` + determines where in the DOM the result appears, relative to + other added widgets and the standard content. The default icons + have position 20, the label position 50, and the detail position + 80. + */ + addToOptions?: { + render: (completion: Completion, state: EditorState, view: EditorView) => Node | null; + position: number; + }[]; + /** + By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are + placed to the side of the selected completion. This option can + be used to override that. It will be given rectangles for the + list of completions, the selected option, the info element, and + the availble [tooltip + space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return + style and/or class strings for the info element. + */ + positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => { + style?: string; + class?: string; + }; + /** + The comparison function to use when sorting completions with the same + match score. Defaults to using + [`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare). + */ + compareCompletions?: (a: Completion, b: Completion) => number; + /** + When set to true (the default is false), turn off fuzzy matching + of completions and only show those that start with the text the + user typed. Only takes effect for results where + [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false. + */ + filterStrict?: boolean; + /** + By default, commands relating to an open completion only take + effect 75 milliseconds after the completion opened, so that key + presses made before the user is aware of the tooltip don't go to + the tooltip. This option can be used to configure that delay. + */ + interactionDelay?: number; + /** + When there are multiple asynchronous completion sources, this + controls how long the extension waits for a slow source before + displaying results from faster sources. Defaults to 100 + milliseconds. + */ + updateSyncTime?: number; +} + +/** +Convert a snippet template to a function that can +[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written +using syntax like this: + + "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" + +Each `${}` placeholder (you may also use `#{}`) indicates a field +that the user can fill in. Its name, if any, will be the default +content for the field. + +When the snippet is activated by calling the returned function, +the code is inserted at the given position. Newlines in the +template are indented by the indentation of the start line, plus +one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after +the newline. + +On activation, (all instances of) the first field are selected. +The user can move between fields with Tab and Shift-Tab as long as +the fields are active. Moving to the last field or moving the +cursor out of the current field deactivates the fields. + +The order of fields defaults to textual order, but you can add +numbers to placeholders (`${1}` or `${1:defaultText}`) to provide +a custom order. + +To include a literal `{` or `}` in your template, put a backslash +in front of it. This will be removed and the brace will not be +interpreted as indicating a placeholder. +*/ +declare function snippet(template: string): (editor: { + state: EditorState; + dispatch: (tr: Transaction) => void; +}, completion: Completion | null, from: number, to: number) => void; +/** +A command that clears the active snippet, if any. +*/ +declare const clearSnippet: StateCommand; +/** +Move to the next snippet field, if available. +*/ +declare const nextSnippetField: StateCommand; +/** +Move to the previous snippet field, if available. +*/ +declare const prevSnippetField: StateCommand; +/** +Check if there is an active snippet with a next field for +`nextSnippetField` to move to. +*/ +declare function hasNextSnippetField(state: EditorState): boolean; +/** +Returns true if there is an active snippet and a previous field +for `prevSnippetField` to move to. +*/ +declare function hasPrevSnippetField(state: EditorState): boolean; +/** +A facet that can be used to configure the key bindings used by +snippets. The default binds Tab to +[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to +[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape +to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet). +*/ +declare const snippetKeymap: Facet; +/** +Create a completion from a snippet. Returns an object with the +properties from `completion`, plus an `apply` function that +applies the snippet. +*/ +declare function snippetCompletion(template: string, completion: Completion): Completion; + +/** +Returns a command that moves the completion selection forward or +backward by the given amount. +*/ +declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command; +/** +Accept the current completion. +*/ +declare const acceptCompletion: Command; +/** +Explicitly start autocompletion. +*/ +declare const startCompletion: Command; +/** +Close the currently active completion. +*/ +declare const closeCompletion: Command; + +/** +A completion source that will scan the document for words (using a +[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and +return those as completions. +*/ +declare const completeAnyWord: CompletionSource; + +/** +Configures bracket closing behavior for a syntax (via +[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"` +identifier. +*/ +interface CloseBracketConfig { + /** + The opening brackets to close. Defaults to `["(", "[", "{", "'", + '"']`. Brackets may be single characters or a triple of quotes + (as in `"'''"`). + */ + brackets?: string[]; + /** + Characters in front of which newly opened brackets are + automatically closed. Closing always happens in front of + whitespace. Defaults to `")]}:;>"`. + */ + before?: string; + /** + When determining whether a given node may be a string, recognize + these prefixes before the opening quote. + */ + stringPrefixes?: string[]; +} +/** +Extension to enable bracket-closing behavior. When a closeable +bracket is typed, its closing bracket is immediately inserted +after the cursor. When closing a bracket directly in front of a +closing bracket inserted by the extension, the cursor moves over +that bracket. +*/ +declare function closeBrackets(): Extension; +/** +Command that implements deleting a pair of matching brackets when +the cursor is between them. +*/ +declare const deleteBracketPair: StateCommand; +/** +Close-brackets related key bindings. Binds Backspace to +[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair). +*/ +declare const closeBracketsKeymap: readonly KeyBinding[]; +/** +Implements the extension's behavior on text insertion. If the +given string counts as a bracket in the language around the +selection, and replacing the selection with it requires custom +behavior (inserting a closing version or skipping past a +previously-closed bracket), this function returns a transaction +representing that custom behavior. (You only need this if you want +to programmatically insert brackets—the +[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will +take care of running this for user input.) +*/ +declare function insertBracket(state: EditorState, bracket: string): Transaction | null; + +/** +Returns an extension that enables autocompletion. +*/ +declare function autocompletion(config?: CompletionConfig): Extension; +/** +Basic keybindings for autocompletion. + + - Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion) + - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion) + - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)` + - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)` + - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")` + - PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")` + - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion) +*/ +declare const completionKeymap: readonly KeyBinding[]; +/** +Get the current completion status. When completions are available, +this will return `"active"`. When completions are pending (in the +process of being queried), this returns `"pending"`. Otherwise, it +returns `null`. +*/ +declare function completionStatus(state: EditorState): null | "active" | "pending"; +/** +Returns the available completions as an array. +*/ +declare function currentCompletions(state: EditorState): readonly Completion[]; +/** +Return the currently selected completion, if any. +*/ +declare function selectedCompletion(state: EditorState): Completion | null; +/** +Returns the currently selected position in the active completion +list, or null if no completions are active. +*/ +declare function selectedCompletionIndex(state: EditorState): number | null; +/** +Create an effect that can be attached to a transaction to change +the currently selected completion. +*/ +declare function setSelectedCompletion(index: number): StateEffect; + +export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion }; diff --git a/node_modules/@codemirror/autocomplete/dist/index.d.ts b/node_modules/@codemirror/autocomplete/dist/index.d.ts new file mode 100644 index 0000000..23ea041 --- /dev/null +++ b/node_modules/@codemirror/autocomplete/dist/index.d.ts @@ -0,0 +1,648 @@ +import * as _codemirror_state from '@codemirror/state'; +import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state'; +import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view'; +import * as _lezer_common from '@lezer/common'; + +/** +Objects type used to represent individual completions. +*/ +interface Completion { + /** + The label to show in the completion picker. This is what input + is matched against to determine whether a completion matches (and + how well it matches). + */ + label: string; + /** + An optional override for the completion's visible label. When + using this, matched characters will only be highlighted if you + provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch) + function. + */ + displayLabel?: string; + /** + Overrides the text that is used to sort completions. Will + default to `label` if not given. + */ + sortText?: string; + /** + An optional short piece of information to show (with a different + style) after the label. + */ + detail?: string; + /** + Additional info to show when the completion is selected. Can be + a plain string or a function that'll render the DOM structure to + show when invoked. + */ + info?: string | ((completion: Completion) => CompletionInfo | Promise); + /** + How to apply the completion. The default is to replace it with + its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a + string, the completion range is replaced by that string. When it + is a function, that function is called to perform the + completion. If it fires a transaction, it is responsible for + adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion) + annotation to it. + */ + apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void); + /** + The type of the completion. This is used to pick an icon to show + for the completion. Icons are styled with a CSS class created by + appending the type name to `"cm-completionIcon-"`. You can + define or restyle icons by defining these selectors. The base + library defines simple icons for `class`, `constant`, `enum`, + `function`, `interface`, `keyword`, `method`, `namespace`, + `property`, `text`, `type`, and `variable`. + + Multiple types can be provided by separating them with spaces. + */ + type?: string; + /** + When this option is selected, and one of these characters is + typed, insert the completion before typing the character. + */ + commitCharacters?: readonly string[]; + /** + When given, should be a number from -99 to 99 that adjusts how + this completion is ranked compared to other completions that + match the input as well as this one. A negative number moves it + down the list, a positive number moves it up. + */ + boost?: number; + /** + Can be used to divide the completion list into sections. + Completions in a given section (matched by name) will be grouped + together, with a heading above them. Options without section + will appear above all sections. A string value is equivalent to + a `{name}` object. + */ + section?: string | CompletionSection; +} +/** +The type returned from +[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM +node, null to indicate there is no info, or an object with an +optional `destroy` method that cleans up the node. +*/ +type CompletionInfo = Node | null | { + dom: Node; + destroy?(): void; +}; +/** +Object used to describe a completion +[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to +create a shared object used by all the completions in a given +section. +*/ +interface CompletionSection { + /** + The name of the section. If no `render` method is present, this + will be displayed above the options. + */ + name: string; + /** + An optional function that renders the section header. Since the + headers are shown inside a list, you should make sure the + resulting element has a `display: list-item` style. + */ + header?: (section: CompletionSection) => HTMLElement; + /** + By default, sections are ordered alphabetically by name. To + specify an explicit order, `rank` can be used. Sections with a + lower rank will be shown above sections with a higher rank. + + When set to `"dynamic"`, the section's position compared to + other dynamic sections depends on the matching score of the + best-matching option in the sections. + */ + rank?: number | "dynamic"; +} +/** +An instance of this is passed to completion source functions. +*/ +declare class CompletionContext { + /** + The editor state that the completion happens in. + */ + readonly state: EditorState; + /** + The position at which the completion is happening. + */ + readonly pos: number; + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + readonly explicit: boolean; + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + readonly view?: EditorView | undefined; + /** + Create a new completion context. (Mostly useful for testing + completion sources—in the editor, the extension will create + these for you.) + */ + constructor( + /** + The editor state that the completion happens in. + */ + state: EditorState, + /** + The position at which the completion is happening. + */ + pos: number, + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + explicit: boolean, + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + view?: EditorView | undefined); + /** + Get the extent, content, and (if there is a token) type of the + token before `this.pos`. + */ + tokenBefore(types: readonly string[]): { + from: number; + to: number; + text: string; + type: _lezer_common.NodeType; + } | null; + /** + Get the match of the given expression directly before the + cursor. + */ + matchBefore(expr: RegExp): { + from: number; + to: number; + text: string; + } | null; + /** + Yields true when the query has been aborted. Can be useful in + asynchronous queries to avoid doing work that will be ignored. + */ + get aborted(): boolean; + /** + Allows you to register abort handlers, which will be called when + the query is + [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted). + + By default, running queries will not be aborted for regular + typing or backspacing, on the assumption that they are likely to + return a result with a + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that + allows the result to be used after all. Passing `onDocChange: + true` will cause this query to be aborted for any document + change. + */ + addEventListener(type: "abort", listener: () => void, options?: { + onDocChange: boolean; + }): void; +} +/** +Given a a fixed array of options, return an autocompleter that +completes them. +*/ +declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource; +/** +Wrap the given completion source so that it will only fire when the +cursor is in a syntax node with one of the given names. +*/ +declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource; +/** +Wrap the given completion source so that it will not fire when the +cursor is in a syntax node with one of the given names. +*/ +declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource; +/** +The function signature for a completion source. Such a function +may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult) +synchronously or as a promise. Returning null indicates no +completions are available. +*/ +type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise; +/** +Interface for objects returned by completion sources. +*/ +interface CompletionResult { + /** + The start of the range that is being completed. + */ + from: number; + /** + The end of the range that is being completed. Defaults to the + main cursor position. + */ + to?: number; + /** + The completions returned. These don't have to be compared with + the input by the source—the autocompletion system will do its + own matching (against the text between `from` and `to`) and + sorting. + */ + options: readonly Completion[]; + /** + When given, further typing or deletion that causes the part of + the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from` + and `to` to match this regular expression or predicate function + will not query the completion source again, but continue with + this list of options. This can help a lot with responsiveness, + since it allows the completion list to be updated synchronously. + */ + validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean); + /** + By default, the library filters and scores completions. Set + `filter` to `false` to disable this, and cause your completions + to all be included, in the order they were given. When there are + other sources, unfiltered completions appear at the top of the + list of completions. `validFor` must not be given when `filter` + is `false`, because it only works when filtering. + */ + filter?: boolean; + /** + When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to + `false` or a completion has a + [`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this + may be provided to compute the ranges on the label that match + the input. Should return an array of numbers where each pair of + adjacent numbers provide the start and end of a range. The + second argument, the match found by the library, is only passed + when `filter` isn't `false`. + */ + getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[]; + /** + Synchronously update the completion result after typing or + deletion. If given, this should not do any expensive work, since + it will be called during editor state updates. The function + should make sure (similar to + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the + completion still applies in the new state. + */ + update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null; + /** + When results contain position-dependent information in, for + example, `apply` methods, you can provide this method to update + the result for transactions that happen after the query. It is + not necessary to update `from` and `to`—those are tracked + automatically. + */ + map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null; + /** + Set a default set of [commit + characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all + options in this result. + */ + commitCharacters?: readonly string[]; +} +/** +This annotation is added to transactions that are produced by +picking a completion. +*/ +declare const pickedCompletion: _codemirror_state.AnnotationType; +/** +Helper function that returns a transaction spec which inserts a +completion's text in the main selection range, and any other +selection range that has the same text in front of it. +*/ +declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec; + +interface CompletionConfig { + /** + When enabled (defaults to true), autocompletion will start + whenever the user types something that can be completed. + */ + activateOnTyping?: boolean; + /** + When given, if a completion that matches the predicate is + picked, reactivate completion again as if it was typed normally. + */ + activateOnCompletion?: (completion: Completion) => boolean; + /** + The amount of time to wait for further typing before querying + completion sources via + [`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping). + Defaults to 100, which should be fine unless your completion + source is very slow and/or doesn't use `validFor`. + */ + activateOnTypingDelay?: number; + /** + By default, when completion opens, the first option is selected + and can be confirmed with + [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this + is set to false, the completion widget starts with no completion + selected, and the user has to explicitly move to a completion + before you can confirm one. + */ + selectOnOpen?: boolean; + /** + Override the completion sources used. By default, they will be + taken from the `"autocomplete"` [language + data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold + [completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays + of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)). + */ + override?: readonly CompletionSource[] | null; + /** + Determines whether the completion tooltip is closed when the + editor loses focus. Defaults to true. + */ + closeOnBlur?: boolean; + /** + The maximum number of options to render to the DOM. + */ + maxRenderedOptions?: number; + /** + Set this to false to disable the [default completion + keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to + add bindings to control completion yourself. The bindings should + probably have a higher precedence than other bindings for the + same keys.) + */ + defaultKeymap?: boolean; + /** + By default, completions are shown below the cursor when there is + space. Setting this to true will make the extension put the + completions above the cursor when possible. + */ + aboveCursor?: boolean; + /** + When given, this may return an additional CSS class to add to + the completion dialog element. + */ + tooltipClass?: (state: EditorState) => string; + /** + This can be used to add additional CSS classes to completion + options. + */ + optionClass?: (completion: Completion) => string; + /** + By default, the library will render icons based on the + completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of + each option. Set this to false to turn that off. + */ + icons?: boolean; + /** + This option can be used to inject additional content into + options. The `render` function will be called for each visible + completion, and should produce a DOM node to show. `position` + determines where in the DOM the result appears, relative to + other added widgets and the standard content. The default icons + have position 20, the label position 50, and the detail position + 80. + */ + addToOptions?: { + render: (completion: Completion, state: EditorState, view: EditorView) => Node | null; + position: number; + }[]; + /** + By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are + placed to the side of the selected completion. This option can + be used to override that. It will be given rectangles for the + list of completions, the selected option, the info element, and + the availble [tooltip + space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return + style and/or class strings for the info element. + */ + positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => { + style?: string; + class?: string; + }; + /** + The comparison function to use when sorting completions with the same + match score. Defaults to using + [`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare). + */ + compareCompletions?: (a: Completion, b: Completion) => number; + /** + When set to true (the default is false), turn off fuzzy matching + of completions and only show those that start with the text the + user typed. Only takes effect for results where + [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false. + */ + filterStrict?: boolean; + /** + By default, commands relating to an open completion only take + effect 75 milliseconds after the completion opened, so that key + presses made before the user is aware of the tooltip don't go to + the tooltip. This option can be used to configure that delay. + */ + interactionDelay?: number; + /** + When there are multiple asynchronous completion sources, this + controls how long the extension waits for a slow source before + displaying results from faster sources. Defaults to 100 + milliseconds. + */ + updateSyncTime?: number; +} + +/** +Convert a snippet template to a function that can +[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written +using syntax like this: + + "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" + +Each `${}` placeholder (you may also use `#{}`) indicates a field +that the user can fill in. Its name, if any, will be the default +content for the field. + +When the snippet is activated by calling the returned function, +the code is inserted at the given position. Newlines in the +template are indented by the indentation of the start line, plus +one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after +the newline. + +On activation, (all instances of) the first field are selected. +The user can move between fields with Tab and Shift-Tab as long as +the fields are active. Moving to the last field or moving the +cursor out of the current field deactivates the fields. + +The order of fields defaults to textual order, but you can add +numbers to placeholders (`${1}` or `${1:defaultText}`) to provide +a custom order. + +To include a literal `{` or `}` in your template, put a backslash +in front of it. This will be removed and the brace will not be +interpreted as indicating a placeholder. +*/ +declare function snippet(template: string): (editor: { + state: EditorState; + dispatch: (tr: Transaction) => void; +}, completion: Completion | null, from: number, to: number) => void; +/** +A command that clears the active snippet, if any. +*/ +declare const clearSnippet: StateCommand; +/** +Move to the next snippet field, if available. +*/ +declare const nextSnippetField: StateCommand; +/** +Move to the previous snippet field, if available. +*/ +declare const prevSnippetField: StateCommand; +/** +Check if there is an active snippet with a next field for +`nextSnippetField` to move to. +*/ +declare function hasNextSnippetField(state: EditorState): boolean; +/** +Returns true if there is an active snippet and a previous field +for `prevSnippetField` to move to. +*/ +declare function hasPrevSnippetField(state: EditorState): boolean; +/** +A facet that can be used to configure the key bindings used by +snippets. The default binds Tab to +[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to +[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape +to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet). +*/ +declare const snippetKeymap: Facet; +/** +Create a completion from a snippet. Returns an object with the +properties from `completion`, plus an `apply` function that +applies the snippet. +*/ +declare function snippetCompletion(template: string, completion: Completion): Completion; + +/** +Returns a command that moves the completion selection forward or +backward by the given amount. +*/ +declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command; +/** +Accept the current completion. +*/ +declare const acceptCompletion: Command; +/** +Explicitly start autocompletion. +*/ +declare const startCompletion: Command; +/** +Close the currently active completion. +*/ +declare const closeCompletion: Command; + +/** +A completion source that will scan the document for words (using a +[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and +return those as completions. +*/ +declare const completeAnyWord: CompletionSource; + +/** +Configures bracket closing behavior for a syntax (via +[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"` +identifier. +*/ +interface CloseBracketConfig { + /** + The opening brackets to close. Defaults to `["(", "[", "{", "'", + '"']`. Brackets may be single characters or a triple of quotes + (as in `"'''"`). + */ + brackets?: string[]; + /** + Characters in front of which newly opened brackets are + automatically closed. Closing always happens in front of + whitespace. Defaults to `")]}:;>"`. + */ + before?: string; + /** + When determining whether a given node may be a string, recognize + these prefixes before the opening quote. + */ + stringPrefixes?: string[]; +} +/** +Extension to enable bracket-closing behavior. When a closeable +bracket is typed, its closing bracket is immediately inserted +after the cursor. When closing a bracket directly in front of a +closing bracket inserted by the extension, the cursor moves over +that bracket. +*/ +declare function closeBrackets(): Extension; +/** +Command that implements deleting a pair of matching brackets when +the cursor is between them. +*/ +declare const deleteBracketPair: StateCommand; +/** +Close-brackets related key bindings. Binds Backspace to +[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair). +*/ +declare const closeBracketsKeymap: readonly KeyBinding[]; +/** +Implements the extension's behavior on text insertion. If the +given string counts as a bracket in the language around the +selection, and replacing the selection with it requires custom +behavior (inserting a closing version or skipping past a +previously-closed bracket), this function returns a transaction +representing that custom behavior. (You only need this if you want +to programmatically insert brackets—the +[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will +take care of running this for user input.) +*/ +declare function insertBracket(state: EditorState, bracket: string): Transaction | null; + +/** +Returns an extension that enables autocompletion. +*/ +declare function autocompletion(config?: CompletionConfig): Extension; +/** +Basic keybindings for autocompletion. + + - Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion) + - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion) + - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)` + - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)` + - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")` + - PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")` + - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion) +*/ +declare const completionKeymap: readonly KeyBinding[]; +/** +Get the current completion status. When completions are available, +this will return `"active"`. When completions are pending (in the +process of being queried), this returns `"pending"`. Otherwise, it +returns `null`. +*/ +declare function completionStatus(state: EditorState): null | "active" | "pending"; +/** +Returns the available completions as an array. +*/ +declare function currentCompletions(state: EditorState): readonly Completion[]; +/** +Return the currently selected completion, if any. +*/ +declare function selectedCompletion(state: EditorState): Completion | null; +/** +Returns the currently selected position in the active completion +list, or null if no completions are active. +*/ +declare function selectedCompletionIndex(state: EditorState): number | null; +/** +Create an effect that can be attached to a transaction to change +the currently selected completion. +*/ +declare function setSelectedCompletion(index: number): StateEffect; + +export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion }; diff --git a/node_modules/@codemirror/autocomplete/dist/index.js b/node_modules/@codemirror/autocomplete/dist/index.js new file mode 100644 index 0000000..73183bf --- /dev/null +++ b/node_modules/@codemirror/autocomplete/dist/index.js @@ -0,0 +1,2121 @@ +import { Annotation, StateEffect, EditorSelection, codePointAt, codePointSize, fromCodePoint, Facet, combineConfig, StateField, Prec, Text, Transaction, MapMode, RangeValue, RangeSet, CharCategory } from '@codemirror/state'; +import { Direction, logException, showTooltip, EditorView, ViewPlugin, getTooltip, Decoration, WidgetType, keymap } from '@codemirror/view'; +import { syntaxTree, indentUnit } from '@codemirror/language'; + +/** +An instance of this is passed to completion source functions. +*/ +class CompletionContext { + /** + Create a new completion context. (Mostly useful for testing + completion sources—in the editor, the extension will create + these for you.) + */ + constructor( + /** + The editor state that the completion happens in. + */ + state, + /** + The position at which the completion is happening. + */ + pos, + /** + Indicates whether completion was activated explicitly, or + implicitly by typing. The usual way to respond to this is to + only return completions when either there is part of a + completable entity before the cursor, or `explicit` is true. + */ + explicit, + /** + The editor view. May be undefined if the context was created + in a situation where there is no such view available, such as + in synchronous updates via + [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) + or when called by test code. + */ + view) { + this.state = state; + this.pos = pos; + this.explicit = explicit; + this.view = view; + /** + @internal + */ + this.abortListeners = []; + /** + @internal + */ + this.abortOnDocChange = false; + } + /** + Get the extent, content, and (if there is a token) type of the + token before `this.pos`. + */ + tokenBefore(types) { + let token = syntaxTree(this.state).resolveInner(this.pos, -1); + while (token && types.indexOf(token.name) < 0) + token = token.parent; + return token ? { from: token.from, to: this.pos, + text: this.state.sliceDoc(token.from, this.pos), + type: token.type } : null; + } + /** + Get the match of the given expression directly before the + cursor. + */ + matchBefore(expr) { + let line = this.state.doc.lineAt(this.pos); + let start = Math.max(line.from, this.pos - 250); + let str = line.text.slice(start - line.from, this.pos - line.from); + let found = str.search(ensureAnchor(expr, false)); + return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) }; + } + /** + Yields true when the query has been aborted. Can be useful in + asynchronous queries to avoid doing work that will be ignored. + */ + get aborted() { return this.abortListeners == null; } + /** + Allows you to register abort handlers, which will be called when + the query is + [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted). + + By default, running queries will not be aborted for regular + typing or backspacing, on the assumption that they are likely to + return a result with a + [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that + allows the result to be used after all. Passing `onDocChange: + true` will cause this query to be aborted for any document + change. + */ + addEventListener(type, listener, options) { + if (type == "abort" && this.abortListeners) { + this.abortListeners.push(listener); + if (options && options.onDocChange) + this.abortOnDocChange = true; + } + } +} +function toSet(chars) { + let flat = Object.keys(chars).join(""); + let words = /\w/.test(flat); + if (words) + flat = flat.replace(/\w/g, ""); + return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`; +} +function prefixMatch(options) { + let first = Object.create(null), rest = Object.create(null); + for (let { label } of options) { + first[label[0]] = true; + for (let i = 1; i < label.length; i++) + rest[label[i]] = true; + } + let source = toSet(first) + toSet(rest) + "*$"; + return [new RegExp("^" + source), new RegExp(source)]; +} +/** +Given a a fixed array of options, return an autocompleter that +completes them. +*/ +function completeFromList(list) { + let options = list.map(o => typeof o == "string" ? { label: o } : o); + let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options); + return (context) => { + let token = context.matchBefore(match); + return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null; + }; +} +/** +Wrap the given completion source so that it will only fire when the +cursor is in a syntax node with one of the given names. +*/ +function ifIn(nodes, source) { + return (context) => { + for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) { + if (nodes.indexOf(pos.name) > -1) + return source(context); + if (pos.type.isTop) + break; + } + return null; + }; +} +/** +Wrap the given completion source so that it will not fire when the +cursor is in a syntax node with one of the given names. +*/ +function ifNotIn(nodes, source) { + return (context) => { + for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) { + if (nodes.indexOf(pos.name) > -1) + return null; + if (pos.type.isTop) + break; + } + return source(context); + }; +} +class Option { + constructor(completion, source, match, score) { + this.completion = completion; + this.source = source; + this.match = match; + this.score = score; + } +} +function cur(state) { return state.selection.main.from; } +// Make sure the given regexp has a $ at its end and, if `start` is +// true, a ^ at its start. +function ensureAnchor(expr, start) { + var _a; + let { source } = expr; + let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$"; + if (!addStart && !addEnd) + return expr; + return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : "")); +} +/** +This annotation is added to transactions that are produced by +picking a completion. +*/ +const pickedCompletion = /*@__PURE__*/Annotation.define(); +/** +Helper function that returns a transaction spec which inserts a +completion's text in the main selection range, and any other +selection range that has the same text in front of it. +*/ +function insertCompletionText(state, text, from, to) { + let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from; + return { + ...state.changeByRange(range => { + if (range != main && from != to && + state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to)) + return { range }; + let lines = state.toText(text); + return { + changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines }, + range: EditorSelection.cursor(range.from + fromOff + lines.length) + }; + }), + scrollIntoView: true, + userEvent: "input.complete" + }; +} +const SourceCache = /*@__PURE__*/new WeakMap(); +function asSource(source) { + if (!Array.isArray(source)) + return source; + let known = SourceCache.get(source); + if (!known) + SourceCache.set(source, known = completeFromList(source)); + return known; +} +const startCompletionEffect = /*@__PURE__*/StateEffect.define(); +const closeCompletionEffect = /*@__PURE__*/StateEffect.define(); + +// A pattern matcher for fuzzy completion matching. Create an instance +// once for a pattern, and then use that to match any number of +// completions. +class FuzzyMatcher { + constructor(pattern) { + this.pattern = pattern; + this.chars = []; + this.folded = []; + // Buffers reused by calls to `match` to track matched character + // positions. + this.any = []; + this.precise = []; + this.byWord = []; + this.score = 0; + this.matched = []; + for (let p = 0; p < pattern.length;) { + let char = codePointAt(pattern, p), size = codePointSize(char); + this.chars.push(char); + let part = pattern.slice(p, p + size), upper = part.toUpperCase(); + this.folded.push(codePointAt(upper == part ? part.toLowerCase() : upper, 0)); + p += size; + } + this.astral = pattern.length != this.chars.length; + } + ret(score, matched) { + this.score = score; + this.matched = matched; + return this; + } + // Matches a given word (completion) against the pattern (input). + // Will return a boolean indicating whether there was a match and, + // on success, set `this.score` to the score, `this.matched` to an + // array of `from, to` pairs indicating the matched parts of `word`. + // + // The score is a number that is more negative the worse the match + // is. See `Penalty` above. + match(word) { + if (this.pattern.length == 0) + return this.ret(-100 /* Penalty.NotFull */, []); + if (word.length < this.pattern.length) + return null; + let { chars, folded, any, precise, byWord } = this; + // For single-character queries, only match when they occur right + // at the start + if (chars.length == 1) { + let first = codePointAt(word, 0), firstSize = codePointSize(first); + let score = firstSize == word.length ? 0 : -100 /* Penalty.NotFull */; + if (first == chars[0]) ; + else if (first == folded[0]) + score += -200 /* Penalty.CaseFold */; + else + return null; + return this.ret(score, [0, firstSize]); + } + let direct = word.indexOf(this.pattern); + if (direct == 0) + return this.ret(word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */, [0, this.pattern.length]); + let len = chars.length, anyTo = 0; + if (direct < 0) { + for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) { + let next = codePointAt(word, i); + if (next == chars[anyTo] || next == folded[anyTo]) + any[anyTo++] = i; + i += codePointSize(next); + } + // No match, exit immediately + if (anyTo < len) + return null; + } + // This tracks the extent of the precise (non-folded, not + // necessarily adjacent) match + let preciseTo = 0; + // Tracks whether there is a match that hits only characters that + // appear to be starting words. `byWordFolded` is set to true when + // a case folded character is encountered in such a match + let byWordTo = 0, byWordFolded = false; + // If we've found a partial adjacent match, these track its state + let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1; + let hasLower = /[a-z]/.test(word), wordAdjacent = true; + // Go over the option's text, scanning for the various kinds of matches + for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) { + let next = codePointAt(word, i); + if (direct < 0) { + if (preciseTo < len && next == chars[preciseTo]) + precise[preciseTo++] = i; + if (adjacentTo < len) { + if (next == chars[adjacentTo] || next == folded[adjacentTo]) { + if (adjacentTo == 0) + adjacentStart = i; + adjacentEnd = i + 1; + adjacentTo++; + } + else { + adjacentTo = 0; + } + } + } + let ch, type = next < 0xff + ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */) + : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */); + if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) { + if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true))) + byWord[byWordTo++] = i; + else if (byWord.length) + wordAdjacent = false; + } + prevType = type; + i += codePointSize(next); + } + if (byWordTo == len && byWord[0] == 0 && wordAdjacent) + return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word); + if (adjacentTo == len && adjacentStart == 0) + return this.ret(-200 /* Penalty.CaseFold */ - word.length + (adjacentEnd == word.length ? 0 : -100 /* Penalty.NotFull */), [0, adjacentEnd]); + if (direct > -1) + return this.ret(-700 /* Penalty.NotStart */ - word.length, [direct, direct + this.pattern.length]); + if (adjacentTo == len) + return this.ret(-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, [adjacentStart, adjacentEnd]); + if (byWordTo == len) + return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ + + (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word); + return chars.length == 2 ? null + : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word); + } + result(score, positions, word) { + let result = [], i = 0; + for (let pos of positions) { + let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1); + if (i && result[i - 1] == pos) + result[i - 1] = to; + else { + result[i++] = pos; + result[i++] = to; + } + } + return this.ret(score - word.length, result); + } +} +class StrictMatcher { + constructor(pattern) { + this.pattern = pattern; + this.matched = []; + this.score = 0; + this.folded = pattern.toLowerCase(); + } + match(word) { + if (word.length < this.pattern.length) + return null; + let start = word.slice(0, this.pattern.length); + let match = start == this.pattern ? 0 : start.toLowerCase() == this.folded ? -200 /* Penalty.CaseFold */ : null; + if (match == null) + return null; + this.matched = [0, start.length]; + this.score = match + (word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */); + return this; + } +} + +const completionConfig = /*@__PURE__*/Facet.define({ + combine(configs) { + return combineConfig(configs, { + activateOnTyping: true, + activateOnCompletion: () => false, + activateOnTypingDelay: 100, + selectOnOpen: true, + override: null, + closeOnBlur: true, + maxRenderedOptions: 100, + defaultKeymap: true, + tooltipClass: () => "", + optionClass: () => "", + aboveCursor: false, + icons: true, + addToOptions: [], + positionInfo: defaultPositionInfo, + filterStrict: false, + compareCompletions: (a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label), + interactionDelay: 75, + updateSyncTime: 100 + }, { + defaultKeymap: (a, b) => a && b, + closeOnBlur: (a, b) => a && b, + icons: (a, b) => a && b, + tooltipClass: (a, b) => c => joinClass(a(c), b(c)), + optionClass: (a, b) => c => joinClass(a(c), b(c)), + addToOptions: (a, b) => a.concat(b), + filterStrict: (a, b) => a || b, + }); + } +}); +function joinClass(a, b) { + return a ? b ? a + " " + b : a : b; +} +function defaultPositionInfo(view, list, option, info, space, tooltip) { + let rtl = view.textDirection == Direction.RTL, left = rtl, narrow = false; + let side = "top", offset, maxWidth; + let spaceLeft = list.left - space.left, spaceRight = space.right - list.right; + let infoWidth = info.right - info.left, infoHeight = info.bottom - info.top; + if (left && spaceLeft < Math.min(infoWidth, spaceRight)) + left = false; + else if (!left && spaceRight < Math.min(infoWidth, spaceLeft)) + left = true; + if (infoWidth <= (left ? spaceLeft : spaceRight)) { + offset = Math.max(space.top, Math.min(option.top, space.bottom - infoHeight)) - list.top; + maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight); + } + else { + narrow = true; + maxWidth = Math.min(400 /* Info.Width */, (rtl ? list.right : space.right - list.left) - 30 /* Info.Margin */); + let spaceBelow = space.bottom - list.bottom; + if (spaceBelow >= infoHeight || spaceBelow > list.top) { // Below the completion + offset = option.bottom - list.top; + } + else { // Above it + side = "bottom"; + offset = list.bottom - option.top; + } + } + let scaleY = (list.bottom - list.top) / tooltip.offsetHeight; + let scaleX = (list.right - list.left) / tooltip.offsetWidth; + return { + style: `${side}: ${offset / scaleY}px; max-width: ${maxWidth / scaleX}px`, + class: "cm-completionInfo-" + (narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right") + }; +} + +const setSelectedEffect = /*@__PURE__*/StateEffect.define(); +function optionContent(config) { + let content = config.addToOptions.slice(); + if (config.icons) + content.push({ + render(completion) { + let icon = document.createElement("div"); + icon.classList.add("cm-completionIcon"); + if (completion.type) + icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls)); + icon.setAttribute("aria-hidden", "true"); + return icon; + }, + position: 20 + }); + content.push({ + render(completion, _s, _v, match) { + let labelElt = document.createElement("span"); + labelElt.className = "cm-completionLabel"; + let label = completion.displayLabel || completion.label, off = 0; + for (let j = 0; j < match.length;) { + let from = match[j++], to = match[j++]; + if (from > off) + labelElt.appendChild(document.createTextNode(label.slice(off, from))); + let span = labelElt.appendChild(document.createElement("span")); + span.appendChild(document.createTextNode(label.slice(from, to))); + span.className = "cm-completionMatchedText"; + off = to; + } + if (off < label.length) + labelElt.appendChild(document.createTextNode(label.slice(off))); + return labelElt; + }, + position: 50 + }, { + render(completion) { + if (!completion.detail) + return null; + let detailElt = document.createElement("span"); + detailElt.className = "cm-completionDetail"; + detailElt.textContent = completion.detail; + return detailElt; + }, + position: 80 + }); + return content.sort((a, b) => a.position - b.position).map(a => a.render); +} +function rangeAroundSelected(total, selected, max) { + if (total <= max) + return { from: 0, to: total }; + if (selected < 0) + selected = 0; + if (selected <= (total >> 1)) { + let off = Math.floor(selected / max); + return { from: off * max, to: (off + 1) * max }; + } + let off = Math.ceil((total - selected) / max); + return { from: total - off * max, to: total - (off - 1) * max }; +} +class CompletionTooltip { + constructor(view, stateField, applyCompletion) { + this.view = view; + this.stateField = stateField; + this.applyCompletion = applyCompletion; + this.info = null; + this.infoDestroy = null; + this.placeInfoReq = { + read: () => this.measureInfo(), + write: (pos) => this.placeInfo(pos), + key: this + }; + this.space = null; + this.currentClass = ""; + let cState = view.state.field(stateField); + let { options, selected } = cState.open; + let config = view.state.facet(completionConfig); + this.optionContent = optionContent(config); + this.optionClass = config.optionClass; + this.tooltipClass = config.tooltipClass; + this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions); + this.dom = document.createElement("div"); + this.dom.className = "cm-tooltip-autocomplete"; + this.updateTooltipClass(view.state); + this.dom.addEventListener("mousedown", (e) => { + let { options } = view.state.field(stateField).open; + for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) { + if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) { + this.applyCompletion(view, options[+match[1]]); + e.preventDefault(); + return; + } + } + if (e.target == this.list) { + let move = this.list.classList.contains("cm-completionListIncompleteTop") && + e.clientY < this.list.firstChild.getBoundingClientRect().top ? this.range.from - 1 : + this.list.classList.contains("cm-completionListIncompleteBottom") && + e.clientY > this.list.lastChild.getBoundingClientRect().bottom ? this.range.to : null; + if (move != null) { + view.dispatch({ effects: setSelectedEffect.of(move) }); + e.preventDefault(); + } + } + }); + this.dom.addEventListener("focusout", (e) => { + let state = view.state.field(this.stateField, false); + if (state && state.tooltip && view.state.facet(completionConfig).closeOnBlur && + e.relatedTarget != view.contentDOM) + view.dispatch({ effects: closeCompletionEffect.of(null) }); + }); + this.showOptions(options, cState.id); + } + mount() { this.updateSel(); } + showOptions(options, id) { + if (this.list) + this.list.remove(); + this.list = this.dom.appendChild(this.createListBox(options, id, this.range)); + this.list.addEventListener("scroll", () => { + if (this.info) + this.view.requestMeasure(this.placeInfoReq); + }); + } + update(update) { + var _a; + let cState = update.state.field(this.stateField); + let prevState = update.startState.field(this.stateField); + this.updateTooltipClass(update.state); + if (cState != prevState) { + let { options, selected, disabled } = cState.open; + if (!prevState.open || prevState.open.options != options) { + this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions); + this.showOptions(options, cState.id); + } + this.updateSel(); + if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled)) + this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled); + } + } + updateTooltipClass(state) { + let cls = this.tooltipClass(state); + if (cls != this.currentClass) { + for (let c of this.currentClass.split(" ")) + if (c) + this.dom.classList.remove(c); + for (let c of cls.split(" ")) + if (c) + this.dom.classList.add(c); + this.currentClass = cls; + } + } + positioned(space) { + this.space = space; + if (this.info) + this.view.requestMeasure(this.placeInfoReq); + } + updateSel() { + let cState = this.view.state.field(this.stateField), open = cState.open; + if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) { + this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions); + this.showOptions(open.options, cState.id); + } + let newSel = this.updateSelectedOption(open.selected); + if (newSel) { + this.destroyInfo(); + let { completion } = open.options[open.selected]; + let { info } = completion; + if (!info) + return; + let infoResult = typeof info === "string" ? document.createTextNode(info) : info(completion); + if (!infoResult) + return; + if ("then" in infoResult) { + infoResult.then(obj => { + if (obj && this.view.state.field(this.stateField, false) == cState) + this.addInfoPane(obj, completion); + }).catch(e => logException(this.view.state, e, "completion info")); + } + else { + this.addInfoPane(infoResult, completion); + newSel.setAttribute("aria-describedby", this.info.id); + } + } + } + addInfoPane(content, completion) { + this.destroyInfo(); + let wrap = this.info = document.createElement("div"); + wrap.className = "cm-tooltip cm-completionInfo"; + wrap.id = "cm-completionInfo-" + Math.floor(Math.random() * 0xffff).toString(16); + if (content.nodeType != null) { + wrap.appendChild(content); + this.infoDestroy = null; + } + else { + let { dom, destroy } = content; + wrap.appendChild(dom); + this.infoDestroy = destroy || null; + } + this.dom.appendChild(wrap); + this.view.requestMeasure(this.placeInfoReq); + } + updateSelectedOption(selected) { + let set = null; + for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) { + if (opt.nodeName != "LI" || !opt.id) { + i--; // A section header + } + else if (i == selected) { + if (!opt.hasAttribute("aria-selected")) { + opt.setAttribute("aria-selected", "true"); + set = opt; + } + } + else { + if (opt.hasAttribute("aria-selected")) { + opt.removeAttribute("aria-selected"); + opt.removeAttribute("aria-describedby"); + } + } + } + if (set) + scrollIntoView(this.list, set); + return set; + } + measureInfo() { + let sel = this.dom.querySelector("[aria-selected]"); + if (!sel || !this.info) + return null; + let listRect = this.dom.getBoundingClientRect(); + let infoRect = this.info.getBoundingClientRect(); + let selRect = sel.getBoundingClientRect(); + let space = this.space; + if (!space) { + let docElt = this.dom.ownerDocument.documentElement; + space = { left: 0, top: 0, right: docElt.clientWidth, bottom: docElt.clientHeight }; + } + if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 || + selRect.bottom < Math.max(space.top, listRect.top) + 10) + return null; + return this.view.state.facet(completionConfig).positionInfo(this.view, listRect, selRect, infoRect, space, this.dom); + } + placeInfo(pos) { + if (this.info) { + if (pos) { + if (pos.style) + this.info.style.cssText = pos.style; + this.info.className = "cm-tooltip cm-completionInfo " + (pos.class || ""); + } + else { + this.info.style.cssText = "top: -1e6px"; + } + } + } + createListBox(options, id, range) { + const ul = document.createElement("ul"); + ul.id = id; + ul.setAttribute("role", "listbox"); + ul.setAttribute("aria-expanded", "true"); + ul.setAttribute("aria-label", this.view.state.phrase("Completions")); + ul.addEventListener("mousedown", e => { + // Prevent focus change when clicking the scrollbar + if (e.target == ul) + e.preventDefault(); + }); + let curSection = null; + for (let i = range.from; i < range.to; i++) { + let { completion, match } = options[i], { section } = completion; + if (section) { + let name = typeof section == "string" ? section : section.name; + if (name != curSection && (i > range.from || range.from == 0)) { + curSection = name; + if (typeof section != "string" && section.header) { + ul.appendChild(section.header(section)); + } + else { + let header = ul.appendChild(document.createElement("completion-section")); + header.textContent = name; + } + } + } + const li = ul.appendChild(document.createElement("li")); + li.id = id + "-" + i; + li.setAttribute("role", "option"); + let cls = this.optionClass(completion); + if (cls) + li.className = cls; + for (let source of this.optionContent) { + let node = source(completion, this.view.state, this.view, match); + if (node) + li.appendChild(node); + } + } + if (range.from) + ul.classList.add("cm-completionListIncompleteTop"); + if (range.to < options.length) + ul.classList.add("cm-completionListIncompleteBottom"); + return ul; + } + destroyInfo() { + if (this.info) { + if (this.infoDestroy) + this.infoDestroy(); + this.info.remove(); + this.info = null; + } + } + destroy() { + this.destroyInfo(); + } +} +function completionTooltip(stateField, applyCompletion) { + return (view) => new CompletionTooltip(view, stateField, applyCompletion); +} +function scrollIntoView(container, element) { + let parent = container.getBoundingClientRect(); + let self = element.getBoundingClientRect(); + let scaleY = parent.height / container.offsetHeight; + if (self.top < parent.top) + container.scrollTop -= (parent.top - self.top) / scaleY; + else if (self.bottom > parent.bottom) + container.scrollTop += (self.bottom - parent.bottom) / scaleY; +} + +// Used to pick a preferred option when two options with the same +// label occur in the result. +function score(option) { + return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) + + (option.type ? 1 : 0); +} +function sortOptions(active, state) { + let options = []; + let sections = null, dynamicSectionScore = null; + let addOption = (option) => { + options.push(option); + let { section } = option.completion; + if (section) { + if (!sections) + sections = []; + let name = typeof section == "string" ? section : section.name; + if (!sections.some(s => s.name == name)) + sections.push(typeof section == "string" ? { name } : section); + } + }; + let conf = state.facet(completionConfig); + for (let a of active) + if (a.hasResult()) { + let getMatch = a.result.getMatch; + if (a.result.filter === false) { + for (let option of a.result.options) { + addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length)); + } + } + else { + let pattern = state.sliceDoc(a.from, a.to), match; + let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern); + for (let option of a.result.options) + if (match = matcher.match(option.label)) { + let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : []; + let score = match.score + (option.boost || 0); + addOption(new Option(option, a.source, matched, score)); + if (typeof option.section == "object" && option.section.rank === "dynamic") { + let { name } = option.section; + if (!dynamicSectionScore) + dynamicSectionScore = Object.create(null); + dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9); + } + } + } + } + if (sections) { + let sectionOrder = Object.create(null), pos = 0; + let cmp = (a, b) => { + return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) || + (typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) || + (a.name < b.name ? -1 : 1); + }; + for (let s of sections.sort(cmp)) { + pos -= 1e5; + sectionOrder[s.name] = pos; + } + for (let option of options) { + let { section } = option.completion; + if (section) + option.score += sectionOrder[typeof section == "string" ? section : section.name]; + } + } + let result = [], prev = null; + let compare = conf.compareCompletions; + for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) { + let cur = opt.completion; + if (!prev || prev.label != cur.label || prev.detail != cur.detail || + (prev.type != null && cur.type != null && prev.type != cur.type) || + prev.apply != cur.apply || prev.boost != cur.boost) + result.push(opt); + else if (score(opt.completion) > score(prev)) + result[result.length - 1] = opt; + prev = opt.completion; + } + return result; +} +class CompletionDialog { + constructor(options, attrs, tooltip, timestamp, selected, disabled) { + this.options = options; + this.attrs = attrs; + this.tooltip = tooltip; + this.timestamp = timestamp; + this.selected = selected; + this.disabled = disabled; + } + setSelected(selected, id) { + return selected == this.selected || selected >= this.options.length ? this + : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled); + } + static build(active, state, id, prev, conf, didSetActive) { + if (prev && !didSetActive && active.some(s => s.isPending)) + return prev.setDisabled(); + let options = sortOptions(active, state); + if (!options.length) + return prev && active.some(a => a.isPending) ? prev.setDisabled() : null; + let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1; + if (prev && prev.selected != selected && prev.selected != -1) { + let selectedValue = prev.options[prev.selected].completion; + for (let i = 0; i < options.length; i++) + if (options[i].completion == selectedValue) { + selected = i; + break; + } + } + return new CompletionDialog(options, makeAttrs(id, selected), { + pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8), + create: createTooltip, + above: conf.aboveCursor, + }, prev ? prev.timestamp : Date.now(), selected, false); + } + map(changes) { + return new CompletionDialog(this.options, this.attrs, { ...this.tooltip, pos: changes.mapPos(this.tooltip.pos) }, this.timestamp, this.selected, this.disabled); + } + setDisabled() { + return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true); + } +} +class CompletionState { + constructor(active, id, open) { + this.active = active; + this.id = id; + this.open = open; + } + static start() { + return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null); + } + update(tr) { + let { state } = tr, conf = state.facet(completionConfig); + let sources = conf.override || + state.languageDataAt("autocomplete", cur(state)).map(asSource); + let active = sources.map(source => { + let value = this.active.find(s => s.source == source) || + new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */); + return value.update(tr, conf); + }); + if (active.length == this.active.length && active.every((a, i) => a == this.active[i])) + active = this.active; + let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect)); + if (open && tr.docChanged) + open = open.map(tr.changes); + if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) || + !sameResults(active, this.active) || didSet) + open = CompletionDialog.build(active, state, this.id, open, conf, didSet); + else if (open && open.disabled && !active.some(a => a.isPending)) + open = null; + if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult())) + active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a); + for (let effect of tr.effects) + if (effect.is(setSelectedEffect)) + open = open && open.setSelected(effect.value, this.id); + return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open); + } + get tooltip() { return this.open ? this.open.tooltip : null; } + get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; } +} +function sameResults(a, b) { + if (a == b) + return true; + for (let iA = 0, iB = 0;;) { + while (iA < a.length && !a[iA].hasResult()) + iA++; + while (iB < b.length && !b[iB].hasResult()) + iB++; + let endA = iA == a.length, endB = iB == b.length; + if (endA || endB) + return endA == endB; + if (a[iA++].result != b[iB++].result) + return false; + } +} +const baseAttrs = { + "aria-autocomplete": "list" +}; +const noAttrs = {}; +function makeAttrs(id, selected) { + let result = { + "aria-autocomplete": "list", + "aria-haspopup": "listbox", + "aria-controls": id + }; + if (selected > -1) + result["aria-activedescendant"] = id + "-" + selected; + return result; +} +const none = []; +function getUpdateType(tr, conf) { + if (tr.isUserEvent("input.complete")) { + let completion = tr.annotation(pickedCompletion); + if (completion && conf.activateOnCompletion(completion)) + return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */; + } + let typing = tr.isUserEvent("input.type"); + return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */ + : typing ? 1 /* UpdateType.Typing */ + : tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */ + : tr.selection ? 8 /* UpdateType.Reset */ + : tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */; +} +class ActiveSource { + constructor(source, state, explicit = false) { + this.source = source; + this.state = state; + this.explicit = explicit; + } + hasResult() { return false; } + get isPending() { return this.state == 1 /* State.Pending */; } + update(tr, conf) { + let type = getUpdateType(tr, conf), value = this; + if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr)) + value = new ActiveSource(value.source, 0 /* State.Inactive */); + if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */) + value = new ActiveSource(this.source, 1 /* State.Pending */); + value = value.updateFor(tr, type); + for (let effect of tr.effects) { + if (effect.is(startCompletionEffect)) + value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value); + else if (effect.is(closeCompletionEffect)) + value = new ActiveSource(value.source, 0 /* State.Inactive */); + else if (effect.is(setActiveEffect)) + for (let active of effect.value) + if (active.source == value.source) + value = active; + } + return value; + } + updateFor(tr, type) { return this.map(tr.changes); } + map(changes) { return this; } + touches(tr) { + return tr.changes.touchesRange(cur(tr.state)); + } +} +class ActiveResult extends ActiveSource { + constructor(source, explicit, limit, result, from, to) { + super(source, 3 /* State.Result */, explicit); + this.limit = limit; + this.result = result; + this.from = from; + this.to = to; + } + hasResult() { return true; } + updateFor(tr, type) { + var _a; + if (!(type & 3 /* UpdateType.SimpleInteraction */)) + return this.map(tr.changes); + let result = this.result; + if (result.map && !tr.changes.empty) + result = result.map(result, tr.changes); + let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1); + let pos = cur(tr.state); + if (pos > to || !result || + (type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit)) + return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */); + let limit = tr.changes.mapPos(this.limit); + if (checkValid(result.validFor, tr.state, from, to)) + return new ActiveResult(this.source, this.explicit, limit, result, from, to); + if (result.update && + (result = result.update(result, from, to, new CompletionContext(tr.state, pos, false)))) + return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state)); + return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit); + } + map(mapping) { + if (mapping.empty) + return this; + let result = this.result.map ? this.result.map(this.result, mapping) : this.result; + if (!result) + return new ActiveSource(this.source, 0 /* State.Inactive */); + return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1)); + } + touches(tr) { + return tr.changes.touchesRange(this.from, this.to); + } +} +function checkValid(validFor, state, from, to) { + if (!validFor) + return false; + let text = state.sliceDoc(from, to); + return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text); +} +const setActiveEffect = /*@__PURE__*/StateEffect.define({ + map(sources, mapping) { return sources.map(s => s.map(mapping)); } +}); +const completionState = /*@__PURE__*/StateField.define({ + create() { return CompletionState.start(); }, + update(value, tr) { return value.update(tr); }, + provide: f => [ + showTooltip.from(f, val => val.tooltip), + EditorView.contentAttributes.from(f, state => state.attrs) + ] +}); +function applyCompletion(view, option) { + const apply = option.completion.apply || option.completion.label; + let result = view.state.field(completionState).active.find(a => a.source == option.source); + if (!(result instanceof ActiveResult)) + return false; + if (typeof apply == "string") + view.dispatch({ + ...insertCompletionText(view.state, apply, result.from, result.to), + annotations: pickedCompletion.of(option.completion) + }); + else + apply(view, option.completion, result.from, result.to); + return true; +} +const createTooltip = /*@__PURE__*/completionTooltip(completionState, applyCompletion); + +/** +Returns a command that moves the completion selection forward or +backward by the given amount. +*/ +function moveCompletionSelection(forward, by = "option") { + return (view) => { + let cState = view.state.field(completionState, false); + if (!cState || !cState.open || cState.open.disabled || + Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay) + return false; + let step = 1, tooltip; + if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip))) + step = Math.max(2, Math.floor(tooltip.dom.offsetHeight / + tooltip.dom.querySelector("li").offsetHeight) - 1); + let { length } = cState.open.options; + let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1; + if (selected < 0) + selected = by == "page" ? 0 : length - 1; + else if (selected >= length) + selected = by == "page" ? length - 1 : 0; + view.dispatch({ effects: setSelectedEffect.of(selected) }); + return true; + }; +} +/** +Accept the current completion. +*/ +const acceptCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled || + Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay) + return false; + return applyCompletion(view, cState.open.options[cState.open.selected]); +}; +/** +Explicitly start autocompletion. +*/ +const startCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (!cState) + return false; + view.dispatch({ effects: startCompletionEffect.of(true) }); + return true; +}; +/** +Close the currently active completion. +*/ +const closeCompletion = (view) => { + let cState = view.state.field(completionState, false); + if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */)) + return false; + view.dispatch({ effects: closeCompletionEffect.of(null) }); + return true; +}; +class RunningQuery { + constructor(active, context) { + this.active = active; + this.context = context; + this.time = Date.now(); + this.updates = []; + // Note that 'undefined' means 'not done yet', whereas 'null' means + // 'query returned null'. + this.done = undefined; + } +} +const MaxUpdateCount = 50, MinAbortTime = 1000; +const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class { + constructor(view) { + this.view = view; + this.debounceUpdate = -1; + this.running = []; + this.debounceAccept = -1; + this.pendingStart = false; + this.composing = 0 /* CompositionState.None */; + for (let active of view.state.field(completionState).active) + if (active.isPending) + this.startQuery(active); + } + update(update) { + let cState = update.state.field(completionState); + let conf = update.state.facet(completionConfig); + if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState) + return; + let doesReset = update.transactions.some(tr => { + let type = getUpdateType(tr, conf); + return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */); + }); + for (let i = 0; i < this.running.length; i++) { + let query = this.running[i]; + if (doesReset || + query.context.abortOnDocChange && update.docChanged || + query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) { + for (let handler of query.context.abortListeners) { + try { + handler(); + } + catch (e) { + logException(this.view.state, e); + } + } + query.context.abortListeners = null; + this.running.splice(i--, 1); + } + else { + query.updates.push(...update.transactions); + } + } + if (this.debounceUpdate > -1) + clearTimeout(this.debounceUpdate); + if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect)))) + this.pendingStart = true; + let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay; + this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source)) + ? setTimeout(() => this.startUpdate(), delay) : -1; + if (this.composing != 0 /* CompositionState.None */) + for (let tr of update.transactions) { + if (tr.isUserEvent("input.type")) + this.composing = 2 /* CompositionState.Changed */; + else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection) + this.composing = 3 /* CompositionState.ChangedAndMoved */; + } + } + startUpdate() { + this.debounceUpdate = -1; + this.pendingStart = false; + let { state } = this.view, cState = state.field(completionState); + for (let active of cState.active) { + if (active.isPending && !this.running.some(r => r.active.source == active.source)) + this.startQuery(active); + } + if (this.running.length && cState.open && cState.open.disabled) + this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime); + } + startQuery(active) { + let { state } = this.view, pos = cur(state); + let context = new CompletionContext(state, pos, active.explicit, this.view); + let pending = new RunningQuery(active, context); + this.running.push(pending); + Promise.resolve(active.source(context)).then(result => { + if (!pending.context.aborted) { + pending.done = result || null; + this.scheduleAccept(); + } + }, err => { + this.view.dispatch({ effects: closeCompletionEffect.of(null) }); + logException(this.view.state, err); + }); + } + scheduleAccept() { + if (this.running.every(q => q.done !== undefined)) + this.accept(); + else if (this.debounceAccept < 0) + this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime); + } + // For each finished query in this.running, try to create a result + // or, if appropriate, restart the query. + accept() { + var _a; + if (this.debounceAccept > -1) + clearTimeout(this.debounceAccept); + this.debounceAccept = -1; + let updated = []; + let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState); + for (let i = 0; i < this.running.length; i++) { + let query = this.running[i]; + if (query.done === undefined) + continue; + this.running.splice(i--, 1); + if (query.done) { + let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state); + let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1)); + let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos); + // Replay the transactions that happened since the start of + // the request and see if that preserves the result + for (let tr of query.updates) + active = active.update(tr, conf); + if (active.hasResult()) { + updated.push(active); + continue; + } + } + let current = cState.active.find(a => a.source == query.active.source); + if (current && current.isPending) { + if (query.done == null) { + // Explicitly failed. Should clear the pending status if it + // hasn't been re-set in the meantime. + let active = new ActiveSource(query.active.source, 0 /* State.Inactive */); + for (let tr of query.updates) + active = active.update(tr, conf); + if (!active.isPending) + updated.push(active); + } + else { + // Cleared by subsequent transactions. Restart. + this.startQuery(current); + } + } + } + if (updated.length || cState.open && cState.open.disabled) + this.view.dispatch({ effects: setActiveEffect.of(updated) }); + } +}, { + eventHandlers: { + blur(event) { + let state = this.view.state.field(completionState, false); + if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) { + let dialog = state.open && getTooltip(this.view, state.open.tooltip); + if (!dialog || !dialog.dom.contains(event.relatedTarget)) + setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10); + } + }, + compositionstart() { + this.composing = 1 /* CompositionState.Started */; + }, + compositionend() { + if (this.composing == 3 /* CompositionState.ChangedAndMoved */) { + // Safari fires compositionend events synchronously, possibly + // from inside an update, so dispatch asynchronously to avoid reentrancy + setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20); + } + this.composing = 0 /* CompositionState.None */; + } + } +}); +const windows = typeof navigator == "object" && /*@__PURE__*//Win/.test(navigator.platform); +const commitCharacters = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.domEventHandlers({ + keydown(event, view) { + let field = view.state.field(completionState, false); + if (!field || !field.open || field.open.disabled || field.open.selected < 0 || + event.key.length > 1 || event.ctrlKey && !(windows && event.altKey) || event.metaKey) + return false; + let option = field.open.options[field.open.selected]; + let result = field.active.find(a => a.source == option.source); + let commitChars = option.completion.commitCharacters || result.result.commitCharacters; + if (commitChars && commitChars.indexOf(event.key) > -1) + applyCompletion(view, option); + return false; + } +})); + +const baseTheme = /*@__PURE__*/EditorView.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: 0.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: 0.5, + display: "block", + textAlign: "center", + cursor: "pointer", + }, + ".cm-tooltip.cm-completionInfo": { + position: "absolute", + padding: "3px 9px", + width: "max-content", + maxWidth: `${400 /* Info.Width */}px`, + boxSizing: "border-box", + whiteSpace: "pre-line" + }, + ".cm-completionInfo.cm-completionInfo-left": { right: "100%" }, + ".cm-completionInfo.cm-completionInfo-right": { left: "100%" }, + ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` }, + ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` }, + "&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: "'🔑\uFE0E'" } // Disable emoji rendering + }, + ".cm-completionIcon-namespace": { + "&:after": { content: "'▢'" } + }, + ".cm-completionIcon-text": { + "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" } + } +}); + +class FieldPos { + constructor(field, line, from, to) { + this.field = field; + this.line = line; + this.from = from; + this.to = to; + } +} +class FieldRange { + constructor(field, from, to) { + this.field = field; + this.from = from; + this.to = to; + } + map(changes) { + let from = changes.mapPos(this.from, -1, MapMode.TrackDel); + let to = changes.mapPos(this.to, 1, MapMode.TrackDel); + return from == null || to == null ? null : new FieldRange(this.field, from, to); + } +} +class Snippet { + constructor(lines, fieldPositions) { + this.lines = lines; + this.fieldPositions = fieldPositions; + } + instantiate(state, pos) { + let text = [], lineStart = [pos]; + let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0]; + for (let line of this.lines) { + if (text.length) { + let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length; + for (let i = 0; i < tabs; i++) + indent += state.facet(indentUnit); + lineStart.push(pos + indent.length - tabs); + line = indent + line.slice(tabs); + } + text.push(line); + pos += line.length + 1; + } + let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to)); + return { text, ranges }; + } + static parse(template) { + let fields = []; + let lines = [], positions = [], m; + for (let line of template.split(/\r\n?|\n/)) { + while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) { + let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1; + let name = rawName.replace(/\\[{}]/g, m => m[1]); + for (let i = 0; i < fields.length; i++) { + if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false) + found = i; + } + if (found < 0) { + let i = 0; + while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq))) + i++; + fields.splice(i, 0, { seq, name }); + found = i; + for (let pos of positions) + if (pos.field >= found) + pos.field++; + } + for (let pos of positions) + if (pos.line == lines.length && pos.from > m.index) { + let snip = m[2] ? 3 + (m[1] || "").length : 2; + pos.from -= snip; + pos.to -= snip; + } + positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length)); + line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length); + } + line = line.replace(/\\([{}])/g, (_, brace, index) => { + for (let pos of positions) + if (pos.line == lines.length && pos.from > index) { + pos.from--; + pos.to--; + } + return brace; + }); + lines.push(line); + } + return new Snippet(lines, positions); + } +} +let fieldMarker = /*@__PURE__*/Decoration.widget({ widget: /*@__PURE__*/new class extends WidgetType { + toDOM() { + let span = document.createElement("span"); + span.className = "cm-snippetFieldPosition"; + return span; + } + ignoreEvent() { return false; } + } }); +let fieldRange = /*@__PURE__*/Decoration.mark({ class: "cm-snippetField" }); +class ActiveSnippet { + constructor(ranges, active) { + this.ranges = ranges; + this.active = active; + this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)), true); + } + map(changes) { + let ranges = []; + for (let r of this.ranges) { + let mapped = r.map(changes); + if (!mapped) + return null; + ranges.push(mapped); + } + return new ActiveSnippet(ranges, this.active); + } + selectionInsideField(sel) { + return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to)); + } +} +const setActive = /*@__PURE__*/StateEffect.define({ + map(value, changes) { return value && value.map(changes); } +}); +const moveToField = /*@__PURE__*/StateEffect.define(); +const snippetState = /*@__PURE__*/StateField.define({ + create() { return null; }, + update(value, tr) { + for (let effect of tr.effects) { + if (effect.is(setActive)) + return effect.value; + if (effect.is(moveToField) && value) + return new ActiveSnippet(value.ranges, effect.value); + } + if (value && tr.docChanged) + value = value.map(tr.changes); + if (value && tr.selection && !value.selectionInsideField(tr.selection)) + value = null; + return value; + }, + provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none) +}); +function fieldSelection(ranges, field) { + return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to))); +} +/** +Convert a snippet template to a function that can +[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written +using syntax like this: + + "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" + +Each `${}` placeholder (you may also use `#{}`) indicates a field +that the user can fill in. Its name, if any, will be the default +content for the field. + +When the snippet is activated by calling the returned function, +the code is inserted at the given position. Newlines in the +template are indented by the indentation of the start line, plus +one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after +the newline. + +On activation, (all instances of) the first field are selected. +The user can move between fields with Tab and Shift-Tab as long as +the fields are active. Moving to the last field or moving the +cursor out of the current field deactivates the fields. + +The order of fields defaults to textual order, but you can add +numbers to placeholders (`${1}` or `${1:defaultText}`) to provide +a custom order. + +To include a literal `{` or `}` in your template, put a backslash +in front of it. This will be removed and the brace will not be +interpreted as indicating a placeholder. +*/ +function snippet(template) { + let snippet = Snippet.parse(template); + return (editor, completion, from, to) => { + let { text, ranges } = snippet.instantiate(editor.state, from); + let { main } = editor.state.selection; + let spec = { + changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) }, + scrollIntoView: true, + annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined + }; + if (ranges.length) + spec.selection = fieldSelection(ranges, 0); + if (ranges.some(r => r.field > 0)) { + let active = new ActiveSnippet(ranges, 0); + let effects = spec.effects = [setActive.of(active)]; + if (editor.state.field(snippetState, false) === undefined) + effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme])); + } + editor.dispatch(editor.state.update(spec)); + }; +} +function moveField(dir) { + return ({ state, dispatch }) => { + let active = state.field(snippetState, false); + if (!active || dir < 0 && active.active == 0) + return false; + let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir); + dispatch(state.update({ + selection: fieldSelection(active.ranges, next), + effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)), + scrollIntoView: true + })); + return true; + }; +} +/** +A command that clears the active snippet, if any. +*/ +const clearSnippet = ({ state, dispatch }) => { + let active = state.field(snippetState, false); + if (!active) + return false; + dispatch(state.update({ effects: setActive.of(null) })); + return true; +}; +/** +Move to the next snippet field, if available. +*/ +const nextSnippetField = /*@__PURE__*/moveField(1); +/** +Move to the previous snippet field, if available. +*/ +const prevSnippetField = /*@__PURE__*/moveField(-1); +/** +Check if there is an active snippet with a next field for +`nextSnippetField` to move to. +*/ +function hasNextSnippetField(state) { + let active = state.field(snippetState, false); + return !!(active && active.ranges.some(r => r.field == active.active + 1)); +} +/** +Returns true if there is an active snippet and a previous field +for `prevSnippetField` to move to. +*/ +function hasPrevSnippetField(state) { + let active = state.field(snippetState, false); + return !!(active && active.active > 0); +} +const defaultSnippetKeymap = [ + { key: "Tab", run: nextSnippetField, shift: prevSnippetField }, + { key: "Escape", run: clearSnippet } +]; +/** +A facet that can be used to configure the key bindings used by +snippets. The default binds Tab to +[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to +[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape +to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet). +*/ +const snippetKeymap = /*@__PURE__*/Facet.define({ + combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; } +}); +const addSnippetKeymap = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap))); +/** +Create a completion from a snippet. Returns an object with the +properties from `completion`, plus an `apply` function that +applies the snippet. +*/ +function snippetCompletion(template, completion) { + return { ...completion, apply: snippet(template) }; +} +const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({ + mousedown(event, view) { + let active = view.state.field(snippetState, false), pos; + if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null) + return false; + let match = active.ranges.find(r => r.from <= pos && r.to >= pos); + if (!match || match.field == active.active) + return false; + view.dispatch({ + selection: fieldSelection(active.ranges, match.field), + effects: setActive.of(active.ranges.some(r => r.field > match.field) + ? new ActiveSnippet(active.ranges, match.field) : null), + scrollIntoView: true + }); + return true; + } +}); + +function wordRE(wordChars) { + let escaped = wordChars.replace(/[\]\-\\]/g, "\\$&"); + try { + return new RegExp(`[\\p{Alphabetic}\\p{Number}_${escaped}]+`, "ug"); + } + catch (_a) { + return new RegExp(`[\w${escaped}]`, "g"); + } +} +function mapRE(re, f) { + return new RegExp(f(re.source), re.unicode ? "u" : ""); +} +const wordCaches = /*@__PURE__*/Object.create(null); +function wordCache(wordChars) { + return wordCaches[wordChars] || (wordCaches[wordChars] = new WeakMap); +} +function storeWords(doc, wordRE, result, seen, ignoreAt) { + for (let lines = doc.iterLines(), pos = 0; !lines.next().done;) { + let { value } = lines, m; + wordRE.lastIndex = 0; + while (m = wordRE.exec(value)) { + if (!seen[m[0]] && pos + m.index != ignoreAt) { + result.push({ type: "text", label: m[0] }); + seen[m[0]] = true; + if (result.length >= 2000 /* C.MaxList */) + return; + } + } + pos += value.length + 1; + } +} +function collectWords(doc, cache, wordRE, to, ignoreAt) { + let big = doc.length >= 1000 /* C.MinCacheLen */; + let cached = big && cache.get(doc); + if (cached) + return cached; + let result = [], seen = Object.create(null); + if (doc.children) { + let pos = 0; + for (let ch of doc.children) { + if (ch.length >= 1000 /* C.MinCacheLen */) { + for (let c of collectWords(ch, cache, wordRE, to - pos, ignoreAt - pos)) { + if (!seen[c.label]) { + seen[c.label] = true; + result.push(c); + } + } + } + else { + storeWords(ch, wordRE, result, seen, ignoreAt - pos); + } + pos += ch.length + 1; + } + } + else { + storeWords(doc, wordRE, result, seen, ignoreAt); + } + if (big && result.length < 2000 /* C.MaxList */) + cache.set(doc, result); + return result; +} +/** +A completion source that will scan the document for words (using a +[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and +return those as completions. +*/ +const completeAnyWord = context => { + var _a; + let wordChars = (_a = context.state.languageDataAt("wordChars", context.pos)[0]) !== null && _a !== void 0 ? _a : ""; + let re = wordRE(wordChars); + let token = context.matchBefore(mapRE(re, s => s + "$")); + if (!token && !context.explicit) + return null; + let from = token ? token.from : context.pos; + let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* C.Range */, from); + return { from, options, validFor: mapRE(re, s => "^" + s) }; +}; + +const defaults = { + brackets: ["(", "[", "{", "'", '"'], + before: ")]}:;>", + stringPrefixes: [] +}; +const closeBracketEffect = /*@__PURE__*/StateEffect.define({ + map(value, mapping) { + let mapped = mapping.mapPos(value, -1, MapMode.TrackAfter); + return mapped == null ? undefined : mapped; + } +}); +const closedBracket = /*@__PURE__*/new class extends RangeValue { +}; +closedBracket.startSide = 1; +closedBracket.endSide = -1; +const bracketState = /*@__PURE__*/StateField.define({ + create() { return RangeSet.empty; }, + update(value, tr) { + value = value.map(tr.changes); + if (tr.selection) { + let line = tr.state.doc.lineAt(tr.selection.main.head); + value = value.update({ filter: from => from >= line.from && from <= line.to }); + } + for (let effect of tr.effects) + if (effect.is(closeBracketEffect)) + value = value.update({ add: [closedBracket.range(effect.value, effect.value + 1)] }); + return value; + } +}); +/** +Extension to enable bracket-closing behavior. When a closeable +bracket is typed, its closing bracket is immediately inserted +after the cursor. When closing a bracket directly in front of a +closing bracket inserted by the extension, the cursor moves over +that bracket. +*/ +function closeBrackets() { + return [inputHandler, bracketState]; +} +const definedClosing = "()[]{}<>«»»«[]{}"; +function closing(ch) { + for (let i = 0; i < definedClosing.length; i += 2) + if (definedClosing.charCodeAt(i) == ch) + return definedClosing.charAt(i + 1); + return fromCodePoint(ch < 128 ? ch : ch + 1); +} +function config(state, pos) { + return state.languageDataAt("closeBrackets", pos)[0] || defaults; +} +const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent); +const inputHandler = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, insert) => { + if ((android ? view.composing : view.compositionStarted) || view.state.readOnly) + return false; + let sel = view.state.selection.main; + if (insert.length > 2 || insert.length == 2 && codePointSize(codePointAt(insert, 0)) == 1 || + from != sel.from || to != sel.to) + return false; + let tr = insertBracket(view.state, insert); + if (!tr) + return false; + view.dispatch(tr); + return true; +}); +/** +Command that implements deleting a pair of matching brackets when +the cursor is between them. +*/ +const deleteBracketPair = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let conf = config(state, state.selection.main.head); + let tokens = conf.brackets || defaults.brackets; + let dont = null, changes = state.changeByRange(range => { + if (range.empty) { + let before = prevChar(state.doc, range.head); + for (let token of tokens) { + if (token == before && nextChar(state.doc, range.head) == closing(codePointAt(token, 0))) + return { changes: { from: range.head - token.length, to: range.head + token.length }, + range: EditorSelection.cursor(range.head - token.length) }; + } + } + return { range: dont = range }; + }); + if (!dont) + dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete.backward" })); + return !dont; +}; +/** +Close-brackets related key bindings. Binds Backspace to +[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair). +*/ +const closeBracketsKeymap = [ + { key: "Backspace", run: deleteBracketPair } +]; +/** +Implements the extension's behavior on text insertion. If the +given string counts as a bracket in the language around the +selection, and replacing the selection with it requires custom +behavior (inserting a closing version or skipping past a +previously-closed bracket), this function returns a transaction +representing that custom behavior. (You only need this if you want +to programmatically insert brackets—the +[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will +take care of running this for user input.) +*/ +function insertBracket(state, bracket) { + let conf = config(state, state.selection.main.head); + let tokens = conf.brackets || defaults.brackets; + for (let tok of tokens) { + let closed = closing(codePointAt(tok, 0)); + if (bracket == tok) + return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1, conf) + : handleOpen(state, tok, closed, conf.before || defaults.before); + if (bracket == closed && closedBracketAt(state, state.selection.main.from)) + return handleClose(state, tok, closed); + } + return null; +} +function closedBracketAt(state, pos) { + let found = false; + state.field(bracketState).between(0, state.doc.length, from => { + if (from == pos) + found = true; + }); + return found; +} +function nextChar(doc, pos) { + let next = doc.sliceString(pos, pos + 2); + return next.slice(0, codePointSize(codePointAt(next, 0))); +} +function prevChar(doc, pos) { + let prev = doc.sliceString(pos - 2, pos); + return codePointSize(codePointAt(prev, 0)) == prev.length ? prev : prev.slice(1); +} +function handleOpen(state, open, close, closeBefore) { + let dont = null, changes = state.changeByRange(range => { + if (!range.empty) + return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }], + effects: closeBracketEffect.of(range.to + open.length), + range: EditorSelection.range(range.anchor + open.length, range.head + open.length) }; + let next = nextChar(state.doc, range.head); + if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1) + return { changes: { insert: open + close, from: range.head }, + effects: closeBracketEffect.of(range.head + open.length), + range: EditorSelection.cursor(range.head + open.length) }; + return { range: dont = range }; + }); + return dont ? null : state.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +function handleClose(state, _open, close) { + let dont = null, changes = state.changeByRange(range => { + if (range.empty && nextChar(state.doc, range.head) == close) + return { changes: { from: range.head, to: range.head + close.length, insert: close }, + range: EditorSelection.cursor(range.head + close.length) }; + return dont = { range }; + }); + return dont ? null : state.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +// Handles cases where the open and close token are the same, and +// possibly triple quotes (as in `"""abc"""`-style quoting). +function handleSame(state, token, allowTriple, config) { + let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes; + let dont = null, changes = state.changeByRange(range => { + if (!range.empty) + return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }], + effects: closeBracketEffect.of(range.to + token.length), + range: EditorSelection.range(range.anchor + token.length, range.head + token.length) }; + let pos = range.head, next = nextChar(state.doc, pos), start; + if (next == token) { + if (nodeStart(state, pos)) { + return { changes: { insert: token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: EditorSelection.cursor(pos + token.length) }; + } + else if (closedBracketAt(state, pos)) { + let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token; + let content = isTriple ? token + token + token : token; + return { changes: { from: pos, to: pos + content.length, insert: content }, + range: EditorSelection.cursor(pos + content.length) }; + } + } + else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token && + (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 && + nodeStart(state, start)) { + return { changes: { insert: token + token + token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: EditorSelection.cursor(pos + token.length) }; + } + else if (state.charCategorizer(pos)(next) != CharCategory.Word) { + if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes)) + return { changes: { insert: token + token, from: pos }, + effects: closeBracketEffect.of(pos + token.length), + range: EditorSelection.cursor(pos + token.length) }; + } + return { range: dont = range }; + }); + return dont ? null : state.update(changes, { + scrollIntoView: true, + userEvent: "input.type" + }); +} +function nodeStart(state, pos) { + let tree = syntaxTree(state).resolveInner(pos + 1); + return tree.parent && tree.from == pos; +} +function probablyInString(state, pos, quoteToken, prefixes) { + let node = syntaxTree(state).resolveInner(pos, -1); + let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0); + for (let i = 0; i < 5; i++) { + let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix)); + let quotePos = start.indexOf(quoteToken); + if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) { + let first = node.firstChild; + while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) { + if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken) + return false; + first = first.firstChild; + } + return true; + } + let parent = node.to == pos && node.parent; + if (!parent) + break; + node = parent; + } + return false; +} +function canStartStringAt(state, pos, prefixes) { + let charCat = state.charCategorizer(pos); + if (charCat(state.sliceDoc(pos - 1, pos)) != CharCategory.Word) + return pos; + for (let prefix of prefixes) { + let start = pos - prefix.length; + if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != CharCategory.Word) + return start; + } + return -1; +} + +/** +Returns an extension that enables autocompletion. +*/ +function autocompletion(config = {}) { + return [ + commitCharacters, + completionState, + completionConfig.of(config), + completionPlugin, + completionKeymapExt, + baseTheme + ]; +} +/** +Basic keybindings for autocompletion. + + - Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion) + - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion) + - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)` + - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)` + - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")` + - PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")` + - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion) +*/ +const completionKeymap = [ + { key: "Ctrl-Space", run: startCompletion }, + { mac: "Alt-`", run: startCompletion }, + { mac: "Alt-i", run: startCompletion }, + { key: "Escape", run: closeCompletion }, + { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection(true) }, + { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection(false) }, + { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection(true, "page") }, + { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection(false, "page") }, + { key: "Enter", run: acceptCompletion } +]; +const completionKeymapExt = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : [])); +/** +Get the current completion status. When completions are available, +this will return `"active"`. When completions are pending (in the +process of being queried), this returns `"pending"`. Otherwise, it +returns `null`. +*/ +function completionStatus(state) { + let cState = state.field(completionState, false); + return cState && cState.active.some(a => a.isPending) ? "pending" + : cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null; +} +const completionArrayCache = /*@__PURE__*/new WeakMap; +/** +Returns the available completions as an array. +*/ +function currentCompletions(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + if (!open || open.disabled) + return []; + let completions = completionArrayCache.get(open.options); + if (!completions) + completionArrayCache.set(open.options, completions = open.options.map(o => o.completion)); + return completions; +} +/** +Return the currently selected completion, if any. +*/ +function selectedCompletion(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + return open && !open.disabled && open.selected >= 0 ? open.options[open.selected].completion : null; +} +/** +Returns the currently selected position in the active completion +list, or null if no completions are active. +*/ +function selectedCompletionIndex(state) { + var _a; + let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open; + return open && !open.disabled && open.selected >= 0 ? open.selected : null; +} +/** +Create an effect that can be attached to a transaction to change +the currently selected completion. +*/ +function setSelectedCompletion(index) { + return setSelectedEffect.of(index); +} + +export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion }; diff --git a/node_modules/@codemirror/autocomplete/package.json b/node_modules/@codemirror/autocomplete/package.json new file mode 100644 index 0000000..ff5de8b --- /dev/null +++ b/node_modules/@codemirror/autocomplete/package.json @@ -0,0 +1,41 @@ +{ + "name": "@codemirror/autocomplete", + "version": "6.20.2", + "description": "Autocompletion for the CodeMirror code editor", + "scripts": { + "test": "cm-runtests", + "prepare": "cm-buildhelper src/index.ts" + }, + "keywords": [ + "editor", + "code" + ], + "author": { + "name": "Marijn Haverbeke", + "email": "marijn@haverbeke.berlin", + "url": "http://marijnhaverbeke.nl" + }, + "type": "module", + "main": "dist/index.cjs", + "exports": { + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, + "types": "dist/index.d.ts", + "module": "dist/index.js", + "sideEffects": false, + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" + }, + "devDependencies": { + "@codemirror/buildhelper": "^1.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://code.haverbeke.berlin/codemirror/autocomplete.git" + } +} diff --git a/node_modules/@codemirror/commands/.github/workflows/dispatch.yml b/node_modules/@codemirror/commands/.github/workflows/dispatch.yml new file mode 100644 index 0000000..d050072 --- /dev/null +++ b/node_modules/@codemirror/commands/.github/workflows/dispatch.yml @@ -0,0 +1,16 @@ +name: Trigger CI +on: push + +jobs: + build: + name: Dispatch to main repo + runs-on: ubuntu-latest + steps: + - name: Emit repository_dispatch + uses: mvasigh/dispatch-action@main + with: + # You should create a personal access token and store it in your repository + token: ${{ secrets.DISPATCH_AUTH }} + repo: dev + owner: codemirror + event_type: push diff --git a/node_modules/@codemirror/commands/CHANGELOG.md b/node_modules/@codemirror/commands/CHANGELOG.md new file mode 100644 index 0000000..8a801b5 --- /dev/null +++ b/node_modules/@codemirror/commands/CHANGELOG.md @@ -0,0 +1,386 @@ +## 6.10.3 (2026-03-12) + +### Bug fixes + +Make sure selection-extending commands preserve the associativity of the selection head. + +## 6.10.2 (2026-02-06) + +### Bug fixes + +Move the selection to a less surprising place when undoing, moving the selection, redoing, then undoing again. + +## 6.10.1 (2025-12-17) + +### Bug fixes + +Fix a bug where `copyLineDown` would leave the cursor on the wrong line when it was at the start of the line. + +## 6.10.0 (2025-10-23) + +### New features + +The new `deleteGroupForwardWin` command provides by-group forward deletion using the Windows convention. + +## 6.9.0 (2025-10-02) + +### Bug fixes + +Prevent the default behavior of backspace and delete keys, to prevent the browser from doing anything creative when there's nothing to delete. + +### New features + +Implement new `addCursorAbove` and `addCursorBelow` commands. Bind them to Mod-Alt-ArrowUp/Down in the default keymap. + +## 6.8.1 (2025-03-31) + +### Bug fixes + +Fix an issue where creating a comment for a line that starts an inner language would use the comment style from the outer language. + +## 6.8.0 (2025-01-08) + +### New features + +The new `cursorGroupForwardWin` and `selectGroupForwardWin` commands implement Windows-style forward motion by group. + +## 6.7.1 (2024-10-21) + +### Bug fixes + +Change `toggleBlockCommentByLine` to not affect lines with the selection end right at their start. + +## 6.7.0 (2024-10-07) + +### Bug fixes + +Bind Shift-Enter to the same command as Enter in the default keymap, so that it doesn't do nothing when on an EditContext-supporting browser. + +### New features + +Add commands for by-string-index cursor motion that ignores text direction. + +## 6.6.2 (2024-09-17) + +### Bug fixes + +Fix an issue causing `selectParentSyntax` to not select syntax that is a direct child of the top node. + +Make `selectParentSyntax` return false when it doesn't change the selection. + +## 6.6.1 (2024-08-31) + +### Bug fixes + +Fix a bug in the undo history that would cause it to incorrectly track inverted effects when adding multiple edits to a single history event. + +## 6.6.0 (2024-06-04) + +### New features + +The new `toggleTabFocusMode` and `temporarilySetTabFocusMode` commands provide control over the view's tab-focus mode. + +The default keymap now binds Ctrl-m (Shift-Alt-m on macOS) to `toggleTabFocusMode`. + +## 6.5.0 (2024-04-19) + +### New features + +The `insertNewlineKeepIndent` command inserts a newline along with the same indentation as the line before. + +## 6.4.0 (2024-04-17) + +### Bug fixes + +Fix an issue where `deleteLine` sometimes leaves the cursor on the wrong line. + +### New features + +The new `deleteCharBackwardStrict` command just deletes a character, without further smart behavior around indentation. + +## 6.3.3 (2023-12-28) + +### Bug fixes + +Fix an issue causing cursor motion commands to not dispatch a transaction when the change only affects cursor associativity. + +## 6.3.2 (2023-11-28) + +### Bug fixes + +Fix a regression that caused `deleteCharBackward` to sometimes delete a large chunk of text. + +## 6.3.1 (2023-11-27) + +### Bug fixes + +When undoing, store the selection after the undone change with the redo event, so that redoing restores it. + +`deleteCharBackward` will no longer delete variant selector characters as separate characters. + +## 6.3.0 (2023-09-29) + +### Bug fixes + +Make it possible for `selectParentSyntax` to jump out of or into a syntax tree overlay. + +Make Cmd-Backspace and Cmd-Delete on macOS delete to the next line wrap point, not the start/end of the line. + +### New features + +The new `deleteLineBoundaryForward` and `deleteLineBoundaryBackward` commands delete to the start/end of the line or the next line wrapping point. + +## 6.2.5 (2023-08-26) + +### Bug fixes + +Make `insertNewlineAndIndent` properly count indentation for tabs when copying over the previous line's indentation. + +The various sub-word motion commands will now use `Intl.Segmenter`, when available, to stop at CJK language word boundaries. + +Fix a bug in `insertNewlineAndIndent` that would delete text between brackets if it had no corresponding AST node. + +## 6.2.4 (2023-05-03) + +### Bug fixes + +The by-subword motion commands now properly treat dashes, underscores, and similar as subword separators. + +## 6.2.3 (2023-04-19) + +### Bug fixes + +Block commenting the selection no longer includes indentation on the first line. + +## 6.2.2 (2023-03-10) + +### Bug fixes + +Fix a bug where line commenting got confused when commenting a range that crossed language boundaries. + +## 6.2.1 (2023-02-15) + +### Bug fixes + +Keep cursor position stable in `cursorPageUp`/`cursorPageDown` when there are panels or other scroll margins active. + +Make sure `toggleComment` doesn't get thrown off by local language nesting, by fetching the language data for the start of the selection line. + +## 6.2.0 (2023-01-18) + +### New features + +The new `joinToEvent` history configuration option allows you to provide custom logic that determines whether a new transaction is added to an existing history event. + +## 6.1.3 (2022-12-26) + +### Bug fixes + +Preserve selection bidi level when extending the selection, to prevent shift-selection from getting stuck in some kinds of bidirectional text. + +## 6.1.2 (2022-10-13) + +### Bug fixes + +Fix a bug that caused deletion commands on non-empty ranges to incorrectly return false and do nothing, causing the editor to fall back to native behavior. + +## 6.1.1 (2022-09-28) + +### Bug fixes + +Make sure the selection endpoints are moved out of atomic ranges when applying a deletion command to a non-empty selection. + +## 6.1.0 (2022-08-18) + +### Bug fixes + +Prevent native behavior on Ctrl/Cmd-ArrowLeft/ArrowRight bindings, so that browsers with odd bidi behavior won't do the wrong thing at start/end of line. + +Cmd-ArrowLeft/Right on macOS now moves the cursor in the direction of the arrow even in right-to-left content. + +### New features + +The new `cursorLineBoundaryLeft`/`Right` and `selectLineBoundaryLeft`/`Right` commands allow directional motion to line boundaries. + +## 6.0.1 (2022-06-30) + +### Bug fixes + +Announce to the screen reader when the selection is deleted. + +Also bind Ctrl-Shift-z to redo on Linux. + +## 6.0.0 (2022-06-08) + +### Bug fixes + +Fix a bug where by-page selection commands sometimes moved one line too far. + +## 0.20.0 (2022-04-20) + +### Breaking changes + +There is no longer a separate `commentKeymap`. Those bindings are now part of `defaultKeymap`. + +### Bug fixes + +Make `cursorPageUp` and `cursorPageDown` move by window height when the editor is higher than the window. + +Make sure the default behavior of Home/End is prevented, since it could produce unexpected results on macOS. + +### New features + +The exports from @codemirror/comment are now available in this package. + +The exports from the @codemirror/history package are now available from this package. + +## 0.19.8 (2022-01-26) + +### Bug fixes + +`deleteCharBackward` now removes extending characters one at a time, rather than deleting the entire glyph at once. + +Alt-v is no longer bound in `emacsStyleKeymap` and macOS's `standardKeymap`, because macOS doesn't bind it by default and it conflicts with some keyboard layouts. + +## 0.19.7 (2022-01-11) + +### Bug fixes + +Don't bind Alt-\< and Alt-> on macOS by default, since those interfere with some keyboard layouts. Make cursorPageUp/Down scroll the view to keep the cursor in place + +`cursorPageUp` and `cursorPageDown` now scroll the view by the amount that the cursor moved. + +## 0.19.6 (2021-12-10) + +### Bug fixes + +The standard keymap no longer overrides Shift-Delete, in order to allow the native behavior of that key to happen on platforms that support it. + +## 0.19.5 (2021-09-21) + +### New features + +Adds an `insertBlankLine` command which creates an empty line below the selection, and binds it to Mod-Enter in the default keymap. + +## 0.19.4 (2021-09-13) + +### Bug fixes + +Make commands that affect the editor's content check `state.readOnly` and return false when that is true. + +## 0.19.3 (2021-09-09) + +### Bug fixes + +Make by-line cursor motion commands move the cursor to the start/end of the document when they hit the first/last line. + +Fix a bug where `deleteCharForward`/`Backward` behaved incorrectly when deleting directly before or after an atomic range. + +## 0.19.2 (2021-08-24) + +### New features + +New commands `cursorSubwordForward`, `cursorSubwordBackward`, `selectSubwordForward`, and `selectSubwordBackward` which implement motion by camel case subword. + +## 0.19.1 (2021-08-11) + +### Bug fixes + +Fix incorrect versions for @lezer dependencies. + +## 0.19.0 (2021-08-11) + +### Breaking changes + +Change default binding for backspace to `deleteCharBackward`, drop `deleteCodePointBackward`/`Forward` from the library. + +`defaultTabBinding` was removed. + +### Bug fixes + +Drop Alt-d, Alt-f, and Alt-b bindings from `emacsStyleKeymap` (and thus from the default macOS bindings). + +`deleteCharBackward` and `deleteCharForward` now take atomic ranges into account. + +### New features + +Attach more granular user event strings to transactions. + +The module exports a new binding `indentWithTab` that binds tab and shift-tab to `indentMore` and `indentLess`. + +## 0.18.3 (2021-06-11) + +### Bug fixes + +`moveLineDown` will no longer incorrectly grow the selection. + +Line-based commands will no longer include lines where a range selection ends right at the start of the line. + +## 0.18.2 (2021-05-06) + +### Bug fixes + +Use Ctrl-l, not Alt-l, to bind `selectLine` on macOS, to avoid conflicting with special-character-insertion bindings. + +Make the macOS Command-ArrowLeft/Right commands behave more like their native versions. + +## 0.18.1 (2021-04-08) + +### Bug fixes + +Also bind Shift-Backspace and Shift-Delete in the default keymap (to do the same thing as the Shift-less binding). + +### New features + +Adds a `deleteToLineStart` command. + +Adds bindings for Cmd-Delete and Cmd-Backspace on macOS. + +## 0.18.0 (2021-03-03) + +### Breaking changes + +Update dependencies to 0.18. + +## 0.17.5 (2021-02-25) + +### Bug fixes + +Use Alt-l for the default `selectLine` binding, because Mod-l already has an important meaning in the browser. + +Make `deleteGroupBackward`/`deleteGroupForward` delete groups of whitespace when bigger than a single space. + +Don't change lines that have the end of a range selection directly at their start in `indentLess`, `indentMore`, and `indentSelection`. + +## 0.17.4 (2021-02-18) + +### Bug fixes + +Fix a bug where `deleteToLineEnd` would delete the rest of the document when at the end of a line. + +## 0.17.3 (2021-02-16) + +### Bug fixes + +Fix an issue where `insertNewlineAndIndent` behaved strangely with the cursor between brackets that sat on different lines. + +## 0.17.2 (2021-01-22) + +### New features + +The new `insertTab` command inserts a tab when nothing is selected, and defers to `indentMore` otherwise. + +The package now exports a `defaultTabBinding` object that provides a recommended binding for tab (if you must bind tab). + +## 0.17.1 (2021-01-06) + +### New features + +The package now also exports a CommonJS module. + +## 0.17.0 (2020-12-29) + +### Breaking changes + +First numbered release. + diff --git a/node_modules/@codemirror/commands/LICENSE b/node_modules/@codemirror/commands/LICENSE new file mode 100644 index 0000000..9a91f48 --- /dev/null +++ b/node_modules/@codemirror/commands/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2018-2021 by Marijn Haverbeke and others + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/@codemirror/commands/README.md b/node_modules/@codemirror/commands/README.md new file mode 100644 index 0000000..ecce387 --- /dev/null +++ b/node_modules/@codemirror/commands/README.md @@ -0,0 +1,35 @@ +# @codemirror/commands [![NPM version](https://img.shields.io/npm/v/@codemirror/commands.svg)](https://www.npmjs.org/package/@codemirror/commands) + +[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) ] + +This package implements a collection of editing commands for the +[CodeMirror](https://codemirror.net/) code editor. + +The [project page](https://codemirror.net/) has more information, a +number of [examples](https://codemirror.net/examples/) and the +[documentation](https://codemirror.net/docs/). + +This code is released under an +[MIT license](https://github.com/codemirror/commands/tree/main/LICENSE). + +We aim to be an inclusive, welcoming community. To make that explicit, +we have a [code of +conduct](http://contributor-covenant.org/version/1/1/0/) that applies +to communication around the project. + +## Usage + +```javascript +import {EditorView, keymap} from "@codemirror/view" +import {standardKeymap, selectLine} from "@codemirror/commands" + +const view = new EditorView({ + parent: document.body, + extensions: [ + keymap.of([ + ...standardKeymap, + {key: "Alt-l", mac: "Ctrl-l", run: selectLine} + ]) + ] +}) +``` \ No newline at end of file diff --git a/node_modules/@codemirror/commands/dist/index.cjs b/node_modules/@codemirror/commands/dist/index.cjs new file mode 100644 index 0000000..5d75fa0 --- /dev/null +++ b/node_modules/@codemirror/commands/dist/index.cjs @@ -0,0 +1,1909 @@ +'use strict'; + +var state = require('@codemirror/state'); +var view = require('@codemirror/view'); +var language = require('@codemirror/language'); +var common = require('@lezer/common'); + +/** +Comment or uncomment the current selection. Will use line comments +if available, otherwise falling back to block comments. +*/ +const toggleComment = target => { + let { state } = target, line = state.doc.lineAt(state.selection.main.from), config = getConfig(target.state, line.from); + return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false; +}; +function command(f, option) { + return ({ state, dispatch }) => { + if (state.readOnly) + return false; + let tr = f(option, state); + if (!tr) + return false; + dispatch(state.update(tr)); + return true; + }; +} +/** +Comment or uncomment the current selection using line comments. +The line comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +const toggleLineComment = command(changeLineComment, 0 /* CommentOption.Toggle */); +/** +Comment the current selection using line comments. +*/ +const lineComment = command(changeLineComment, 1 /* CommentOption.Comment */); +/** +Uncomment the current selection using line comments. +*/ +const lineUncomment = command(changeLineComment, 2 /* CommentOption.Uncomment */); +/** +Comment or uncomment the current selection using block comments. +The block comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +const toggleBlockComment = command(changeBlockComment, 0 /* CommentOption.Toggle */); +/** +Comment the current selection using block comments. +*/ +const blockComment = command(changeBlockComment, 1 /* CommentOption.Comment */); +/** +Uncomment the current selection using block comments. +*/ +const blockUncomment = command(changeBlockComment, 2 /* CommentOption.Uncomment */); +/** +Comment or uncomment the lines around the current selection using +block comments. +*/ +const toggleBlockCommentByLine = command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */); +function getConfig(state, pos) { + let data = state.languageDataAt("commentTokens", pos, 1); + return data.length ? data[0] : {}; +} +const SearchMargin = 50; +/** +Determines if the given range is block-commented in the given +state. +*/ +function findBlockComment(state, { open, close }, from, to) { + let textBefore = state.sliceDoc(from - SearchMargin, from); + let textAfter = state.sliceDoc(to, to + SearchMargin); + let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length; + let beforeOff = textBefore.length - spaceBefore; + if (textBefore.slice(beforeOff - open.length, beforeOff) == open && + textAfter.slice(spaceAfter, spaceAfter + close.length) == close) { + return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 }, + close: { pos: to + spaceAfter, margin: spaceAfter && 1 } }; + } + let startText, endText; + if (to - from <= 2 * SearchMargin) { + startText = endText = state.sliceDoc(from, to); + } + else { + startText = state.sliceDoc(from, from + SearchMargin); + endText = state.sliceDoc(to - SearchMargin, to); + } + let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length; + let endOff = endText.length - endSpace - close.length; + if (startText.slice(startSpace, startSpace + open.length) == open && + endText.slice(endOff, endOff + close.length) == close) { + return { open: { pos: from + startSpace + open.length, + margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 }, + close: { pos: to - endSpace - close.length, + margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } }; + } + return null; +} +function selectedLineRanges(state) { + let ranges = []; + for (let r of state.selection.ranges) { + let fromLine = state.doc.lineAt(r.from); + let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to); + if (toLine.from > fromLine.from && toLine.from == r.to) + toLine = r.to == fromLine.to + 1 ? fromLine : state.doc.lineAt(r.to - 1); + let last = ranges.length - 1; + if (last >= 0 && ranges[last].to > fromLine.from) + ranges[last].to = toLine.to; + else + ranges.push({ from: fromLine.from + /^\s*/.exec(fromLine.text)[0].length, to: toLine.to }); + } + return ranges; +} +// Performs toggle, comment and uncomment of block comments in +// languages that support them. +function changeBlockComment(option, state, ranges = state.selection.ranges) { + let tokens = ranges.map(r => getConfig(state, r.from).block); + if (!tokens.every(c => c)) + return null; + let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to)); + if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) { + return { changes: state.changes(ranges.map((range, i) => { + if (comments[i]) + return []; + return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }]; + })) }; + } + else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) { + let changes = []; + for (let i = 0, comment; i < comments.length; i++) + if (comment = comments[i]) { + let token = tokens[i], { open, close } = comment; + changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length }); + } + return { changes }; + } + return null; +} +// Performs toggle, comment and uncomment of line comments. +function changeLineComment(option, state, ranges = state.selection.ranges) { + let lines = []; + let prevLine = -1; + ranges: for (let { from, to } of ranges) { + let startI = lines.length, minIndent = 1e9, token; + for (let pos = from; pos <= to;) { + let line = state.doc.lineAt(pos); + if (token == undefined) { + token = getConfig(state, line.from).line; + if (!token) + continue ranges; + } + if (line.from > prevLine && (from == to || to > line.from)) { + prevLine = line.from; + let indent = /^\s*/.exec(line.text)[0].length; + let empty = indent == line.length; + let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1; + if (indent < line.text.length && indent < minIndent) + minIndent = indent; + lines.push({ line, comment, token, indent, empty, single: false }); + } + pos = line.to + 1; + } + if (minIndent < 1e9) + for (let i = startI; i < lines.length; i++) + if (lines[i].indent < lines[i].line.text.length) + lines[i].indent = minIndent; + if (lines.length == startI + 1) + lines[startI].single = true; + } + if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) { + let changes = []; + for (let { line, token, indent, empty, single } of lines) + if (single || !empty) + changes.push({ from: line.from + indent, insert: token + " " }); + let changeSet = state.changes(changes); + return { changes: changeSet, selection: state.selection.map(changeSet, 1) }; + } + else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) { + let changes = []; + for (let { line, comment, token } of lines) + if (comment >= 0) { + let from = line.from + comment, to = from + token.length; + if (line.text[to - line.from] == " ") + to++; + changes.push({ from, to }); + } + return { changes }; + } + return null; +} + +const fromHistory = state.Annotation.define(); +/** +Transaction annotation that will prevent that transaction from +being combined with other transactions in the undo history. Given +`"before"`, it'll prevent merging with previous transactions. With +`"after"`, subsequent transactions won't be combined with this +one. With `"full"`, the transaction is isolated on both sides. +*/ +const isolateHistory = state.Annotation.define(); +/** +This facet provides a way to register functions that, given a +transaction, provide a set of effects that the history should +store when inverting the transaction. This can be used to +integrate some kinds of effects in the history, so that they can +be undone (and redone again). +*/ +const invertedEffects = state.Facet.define(); +const historyConfig = state.Facet.define({ + combine(configs) { + return state.combineConfig(configs, { + minDepth: 100, + newGroupDelay: 500, + joinToEvent: (_t, isAdjacent) => isAdjacent, + }, { + minDepth: Math.max, + newGroupDelay: Math.min, + joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj) + }); + } +}); +const historyField_ = state.StateField.define({ + create() { + return HistoryState.empty; + }, + update(state$1, tr) { + let config = tr.state.facet(historyConfig); + let fromHist = tr.annotation(fromHistory); + if (fromHist) { + let item = HistEvent.fromTransaction(tr, fromHist.selection), from = fromHist.side; + let other = from == 0 /* BranchName.Done */ ? state$1.undone : state$1.done; + if (item) + other = updateBranch(other, other.length, config.minDepth, item); + else + other = addSelection(other, tr.startState.selection); + return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest); + } + let isolate = tr.annotation(isolateHistory); + if (isolate == "full" || isolate == "before") + state$1 = state$1.isolate(); + if (tr.annotation(state.Transaction.addToHistory) === false) + return !tr.changes.empty ? state$1.addMapping(tr.changes.desc) : state$1; + let event = HistEvent.fromTransaction(tr); + let time = tr.annotation(state.Transaction.time), userEvent = tr.annotation(state.Transaction.userEvent); + if (event) + state$1 = state$1.addChanges(event, time, userEvent, config, tr); + else if (tr.selection) + state$1 = state$1.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay); + if (isolate == "full" || isolate == "after") + state$1 = state$1.isolate(); + return state$1; + }, + toJSON(value) { + return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) }; + }, + fromJSON(json) { + return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON)); + } +}); +/** +Create a history extension with the given configuration. +*/ +function history(config = {}) { + return [ + historyField_, + historyConfig.of(config), + view.EditorView.domEventHandlers({ + beforeinput(e, view) { + let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null; + if (!command) + return false; + e.preventDefault(); + return command(view); + } + }) + ]; +} +/** +The state field used to store the history data. Should probably +only be used when you want to +[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or +[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way +that preserves history. +*/ +const historyField = historyField_; +function cmd(side, selection) { + return function ({ state, dispatch }) { + if (!selection && state.readOnly) + return false; + let historyState = state.field(historyField_, false); + if (!historyState) + return false; + let tr = historyState.pop(side, state, selection); + if (!tr) + return false; + dispatch(tr); + return true; + }; +} +/** +Undo a single group of history events. Returns false if no group +was available. +*/ +const undo = cmd(0 /* BranchName.Done */, false); +/** +Redo a group of history events. Returns false if no group was +available. +*/ +const redo = cmd(1 /* BranchName.Undone */, false); +/** +Undo a change or selection change. +*/ +const undoSelection = cmd(0 /* BranchName.Done */, true); +/** +Redo a change or selection change. +*/ +const redoSelection = cmd(1 /* BranchName.Undone */, true); +function depth(side) { + return function (state) { + let histState = state.field(historyField_, false); + if (!histState) + return 0; + let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone; + return branch.length - (branch.length && !branch[0].changes ? 1 : 0); + }; +} +/** +The amount of undoable change events available in a given state. +*/ +const undoDepth = depth(0 /* BranchName.Done */); +/** +The amount of redoable change events available in a given state. +*/ +const redoDepth = depth(1 /* BranchName.Undone */); +// History events store groups of changes or effects that need to be +// undone/redone together. +class HistEvent { + constructor( + // The changes in this event. Normal events hold at least one + // change or effect. But it may be necessary to store selection + // events before the first change, in which case a special type of + // instance is created which doesn't hold any changes, with + // changes == startSelection == undefined + changes, + // The effects associated with this event + effects, + // Accumulated mapping (from addToHistory==false) that should be + // applied to events below this one. + mapped, + // The selection before this event + startSelection, + // Stores selection changes after this event, to be used for + // selection undo/redo. + selectionsAfter) { + this.changes = changes; + this.effects = effects; + this.mapped = mapped; + this.startSelection = startSelection; + this.selectionsAfter = selectionsAfter; + } + setSelAfter(after) { + return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after); + } + toJSON() { + var _a, _b, _c; + return { + changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(), + mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(), + startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(), + selectionsAfter: this.selectionsAfter.map(s => s.toJSON()) + }; + } + static fromJSON(json) { + return new HistEvent(json.changes && state.ChangeSet.fromJSON(json.changes), [], json.mapped && state.ChangeDesc.fromJSON(json.mapped), json.startSelection && state.EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(state.EditorSelection.fromJSON)); + } + // This does not check `addToHistory` and such, it assumes the + // transaction needs to be converted to an item. Returns null when + // there are no changes or effects in the transaction. + static fromTransaction(tr, selection) { + let effects = none; + for (let invert of tr.startState.facet(invertedEffects)) { + let result = invert(tr); + if (result.length) + effects = effects.concat(result); + } + if (!effects.length && tr.changes.empty) + return null; + return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none); + } + static selection(selections) { + return new HistEvent(undefined, none, undefined, undefined, selections); + } +} +function updateBranch(branch, to, maxLen, newEvent) { + let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0; + let newBranch = branch.slice(start, to); + newBranch.push(newEvent); + return newBranch; +} +function isAdjacent(a, b) { + let ranges = [], isAdjacent = false; + a.iterChangedRanges((f, t) => ranges.push(f, t)); + b.iterChangedRanges((_f, _t, f, t) => { + for (let i = 0; i < ranges.length;) { + let from = ranges[i++], to = ranges[i++]; + if (t >= from && f <= to) + isAdjacent = true; + } + }); + return isAdjacent; +} +function eqSelectionShape(a, b) { + return a.ranges.length == b.ranges.length && + a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0; +} +function conc(a, b) { + return !a.length ? b : !b.length ? a : a.concat(b); +} +const none = []; +const MaxSelectionsPerEvent = 200; +function addSelection(branch, selection) { + if (!branch.length) { + return [HistEvent.selection([selection])]; + } + else { + let lastEvent = branch[branch.length - 1]; + let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent)); + if (sels.length && sels[sels.length - 1].eq(selection)) + return branch; + sels.push(selection); + return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels)); + } +} +// Assumes the top item has one or more selectionAfter values +function popSelection(branch) { + let last = branch[branch.length - 1]; + let newBranch = branch.slice(); + newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1)); + return newBranch; +} +// Add a mapping to the top event in the given branch. If this maps +// away all the changes and effects in that item, drop it and +// propagate the mapping to the next item. +function addMappingToBranch(branch, mapping) { + if (!branch.length) + return branch; + let length = branch.length, selections = none; + while (length) { + let event = mapEvent(branch[length - 1], mapping, selections); + if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping + let result = branch.slice(0, length); + result[length - 1] = event; + return result; + } + else { // Drop this event, since there's no changes or effects left + mapping = event.mapped; + length--; + selections = event.selectionsAfter; + } + } + return selections.length ? [HistEvent.selection(selections)] : none; +} +function mapEvent(event, mapping, extraSelections) { + let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections); + // Change-less events don't store mappings (they are always the last event in a branch) + if (!event.changes) + return HistEvent.selection(selections); + let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true); + let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before; + return new HistEvent(mappedChanges, state.StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections); +} +const joinableUserEvent = /^(input\.type|delete)($|\.)/; +class HistoryState { + constructor(done, undone, prevTime = 0, prevUserEvent = undefined) { + this.done = done; + this.undone = undone; + this.prevTime = prevTime; + this.prevUserEvent = prevUserEvent; + } + isolate() { + return this.prevTime ? new HistoryState(this.done, this.undone) : this; + } + addChanges(event, time, userEvent, config, tr) { + let done = this.done, lastEvent = done[done.length - 1]; + if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes && + (!userEvent || joinableUserEvent.test(userEvent)) && + ((!lastEvent.selectionsAfter.length && + time - this.prevTime < config.newGroupDelay && + config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) || + // For compose (but not compose.start) events, always join with previous event + userEvent == "input.type.compose")) { + done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(state.StateEffect.mapEffects(event.effects, lastEvent.changes), lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none)); + } + else { + done = updateBranch(done, done.length, config.minDepth, event); + } + return new HistoryState(done, none, time, userEvent); + } + addSelection(selection, time, userEvent, newGroupDelay) { + let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none; + if (last.length > 0 && + time - this.prevTime < newGroupDelay && + userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) && + eqSelectionShape(last[last.length - 1], selection)) + return this; + return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent); + } + addMapping(mapping) { + return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent); + } + pop(side, state, onlySelection) { + let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone; + if (branch.length == 0) + return null; + let event = branch[branch.length - 1], selection = event.selectionsAfter[0] || + (event.startSelection ? event.startSelection.map(event.changes.invertedDesc, 1) : state.selection); + if (onlySelection && event.selectionsAfter.length) { + return state.update({ + selection: event.selectionsAfter[event.selectionsAfter.length - 1], + annotations: fromHistory.of({ side, rest: popSelection(branch), selection }), + userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo", + scrollIntoView: true + }); + } + else if (!event.changes) { + return null; + } + else { + let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1); + if (event.mapped) + rest = addMappingToBranch(rest, event.mapped); + return state.update({ + changes: event.changes, + selection: event.startSelection, + effects: event.effects, + annotations: fromHistory.of({ side, rest, selection }), + filter: false, + userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo", + scrollIntoView: true + }); + } + } +} +HistoryState.empty = new HistoryState(none, none); +/** +Default key bindings for the undo history. + +- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo). +- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo). +- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection). +- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection). +*/ +const historyKeymap = [ + { key: "Mod-z", run: undo, preventDefault: true }, + { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true }, + { linux: "Ctrl-Shift-z", run: redo, preventDefault: true }, + { key: "Mod-u", run: undoSelection, preventDefault: true }, + { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true } +]; + +function updateSel(sel, by) { + return state.EditorSelection.create(sel.ranges.map(by), sel.mainIndex); +} +function setSel(state, selection) { + return state.update({ selection, scrollIntoView: true, userEvent: "select" }); +} +function moveSel({ state, dispatch }, how) { + let selection = updateSel(state.selection, how); + if (selection.eq(state.selection, true)) + return false; + dispatch(setSel(state, selection)); + return true; +} +function rangeEnd(range, forward) { + return state.EditorSelection.cursor(forward ? range.to : range.from); +} +function cursorByChar(view, forward) { + return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward)); +} +function ltrAtCursor(view$1) { + return view$1.textDirectionAt(view$1.state.selection.main.head) == view.Direction.LTR; +} +/** +Move the selection one character to the left (which is backward in +left-to-right text, forward in right-to-left text). +*/ +const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view)); +/** +Move the selection one character to the right. +*/ +const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view)); +/** +Move the selection one character forward. +*/ +const cursorCharForward = view => cursorByChar(view, true); +/** +Move the selection one character backward. +*/ +const cursorCharBackward = view => cursorByChar(view, false); +function byCharLogical(state$1, range, forward) { + let pos = range.head, line = state$1.doc.lineAt(pos); + if (pos == (forward ? line.to : line.from)) + pos = forward ? Math.min(state$1.doc.length, line.to + 1) : Math.max(0, line.from - 1); + else + pos = line.from + state.findClusterBreak(line.text, pos - line.from, forward); + return state.EditorSelection.cursor(pos, forward ? -1 : 1); +} +function moveByCharLogical(target, forward) { + return moveSel(target, range => range.empty ? byCharLogical(target.state, range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection one character forward, in logical +(non-text-direction-aware) string index order. +*/ +const cursorCharForwardLogical = target => moveByCharLogical(target, true); +/** +Move the selection one character backward, in logical string index +order. +*/ +const cursorCharBackwardLogical = target => moveByCharLogical(target, false); +function cursorByGroup(view, forward) { + return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection to the left across one group of word or +non-word (but also non-space) characters. +*/ +const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view)); +/** +Move the selection one group to the right. +*/ +const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view)); +/** +Move the selection one group forward. +*/ +const cursorGroupForward = view => cursorByGroup(view, true); +/** +Move the selection one group backward. +*/ +const cursorGroupBackward = view => cursorByGroup(view, false); +function toGroupStart(view, pos, start) { + let categorize = view.state.charCategorizer(pos); + let cat = categorize(start), initial = cat != state.CharCategory.Space; + return (next) => { + let nextCat = categorize(next); + if (nextCat != state.CharCategory.Space) + return initial && nextCat == cat; + initial = false; + return true; + }; +} +/** +Move the cursor one group forward in the default Windows style, +where it moves to the start of the next group. +*/ +const cursorGroupForwardWin = view => { + return moveSel(view, range => range.empty + ? view.moveByChar(range, true, start => toGroupStart(view, range.head, start)) + : rangeEnd(range, true)); +}; +const segmenter = typeof Intl != "undefined" && Intl.Segmenter ? + new (Intl.Segmenter)(undefined, { granularity: "word" }) : null; +function moveBySubword(view, range, forward) { + let categorize = view.state.charCategorizer(range.from); + let cat = state.CharCategory.Space, pos = range.from, steps = 0; + let done = false, sawUpper = false, sawLower = false; + let step = (next) => { + if (done) + return false; + pos += forward ? next.length : -next.length; + let nextCat = categorize(next), ahead; + if (nextCat == state.CharCategory.Word && next.charCodeAt(0) < 128 && /[\W_]/.test(next)) + nextCat = -1; // Treat word punctuation specially + if (cat == state.CharCategory.Space) + cat = nextCat; + if (cat != nextCat) + return false; + if (cat == state.CharCategory.Word) { + if (next.toLowerCase() == next) { + if (!forward && sawUpper) + return false; + sawLower = true; + } + else if (sawLower) { + if (forward) + return false; + done = true; + } + else { + if (sawUpper && forward && categorize(ahead = view.state.sliceDoc(pos, pos + 1)) == state.CharCategory.Word && + ahead.toLowerCase() == ahead) + return false; + sawUpper = true; + } + } + steps++; + return true; + }; + let end = view.moveByChar(range, forward, start => { + step(start); + return step; + }); + if (segmenter && cat == state.CharCategory.Word && end.from == range.from + steps * (forward ? 1 : -1)) { + let from = Math.min(range.head, end.head), to = Math.max(range.head, end.head); + let skipped = view.state.sliceDoc(from, to); + if (skipped.length > 1 && /[\u4E00-\uffff]/.test(skipped)) { + let segments = Array.from(segmenter.segment(skipped)); + if (segments.length > 1) { + if (forward) + return state.EditorSelection.cursor(range.head + segments[1].index, -1); + return state.EditorSelection.cursor(end.head + segments[segments.length - 1].index, 1); + } + } + } + return end; +} +function cursorBySubword(view, forward) { + return moveSel(view, range => range.empty ? moveBySubword(view, range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection one group or camel-case subword forward. +*/ +const cursorSubwordForward = view => cursorBySubword(view, true); +/** +Move the selection one group or camel-case subword backward. +*/ +const cursorSubwordBackward = view => cursorBySubword(view, false); +function interestingNode(state, node, bracketProp) { + if (node.type.prop(bracketProp)) + return true; + let len = node.to - node.from; + return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild; +} +function moveBySyntax(state$1, start, forward) { + let pos = language.syntaxTree(state$1).resolveInner(start.head); + let bracketProp = forward ? common.NodeProp.closedBy : common.NodeProp.openedBy; + // Scan forward through child nodes to see if there's an interesting + // node ahead. + for (let at = start.head;;) { + let next = forward ? pos.childAfter(at) : pos.childBefore(at); + if (!next) + break; + if (interestingNode(state$1, next, bracketProp)) + pos = next; + else + at = forward ? next.to : next.from; + } + let bracket = pos.type.prop(bracketProp), match, newPos; + if (bracket && (match = forward ? language.matchBrackets(state$1, pos.from, 1) : language.matchBrackets(state$1, pos.to, -1)) && match.matched) + newPos = forward ? match.end.to : match.end.from; + else + newPos = forward ? pos.to : pos.from; + return state.EditorSelection.cursor(newPos, forward ? -1 : 1); +} +/** +Move the cursor over the next syntactic element to the left. +*/ +const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view))); +/** +Move the cursor over the next syntactic element to the right. +*/ +const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view))); +function cursorByLine(view, forward) { + return moveSel(view, range => { + if (!range.empty) + return rangeEnd(range, forward); + let moved = view.moveVertically(range, forward); + return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward); + }); +} +/** +Move the selection one line up. +*/ +const cursorLineUp = view => cursorByLine(view, false); +/** +Move the selection one line down. +*/ +const cursorLineDown = view => cursorByLine(view, true); +function pageInfo(view$1) { + let selfScroll = view$1.scrollDOM.clientHeight < view$1.scrollDOM.scrollHeight - 2; + let marginTop = 0, marginBottom = 0, height; + if (selfScroll) { + for (let source of view$1.state.facet(view.EditorView.scrollMargins)) { + let margins = source(view$1); + if (margins === null || margins === void 0 ? void 0 : margins.top) + marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop); + if (margins === null || margins === void 0 ? void 0 : margins.bottom) + marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom); + } + height = view$1.scrollDOM.clientHeight - marginTop - marginBottom; + } + else { + height = (view$1.dom.ownerDocument.defaultView || window).innerHeight; + } + return { marginTop, marginBottom, selfScroll, + height: Math.max(view$1.defaultLineHeight, height - 5) }; +} +function cursorByPage(view$1, forward) { + let page = pageInfo(view$1); + let { state } = view$1, selection = updateSel(state.selection, range => { + return range.empty ? view$1.moveVertically(range, forward, page.height) + : rangeEnd(range, forward); + }); + if (selection.eq(state.selection)) + return false; + let effect; + if (page.selfScroll) { + let startPos = view$1.coordsAtPos(state.selection.main.head); + let scrollRect = view$1.scrollDOM.getBoundingClientRect(); + let scrollTop = scrollRect.top + page.marginTop, scrollBottom = scrollRect.bottom - page.marginBottom; + if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom) + effect = view.EditorView.scrollIntoView(selection.main.head, { y: "start", yMargin: startPos.top - scrollTop }); + } + view$1.dispatch(setSel(state, selection), { effects: effect }); + return true; +} +/** +Move the selection one page up. +*/ +const cursorPageUp = view => cursorByPage(view, false); +/** +Move the selection one page down. +*/ +const cursorPageDown = view => cursorByPage(view, true); +function moveByLineBoundary(view, start, forward) { + let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward); + if (moved.head == start.head && moved.head != (forward ? line.to : line.from)) + moved = view.moveToLineBoundary(start, forward, false); + if (!forward && moved.head == line.from && line.length) { + let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length; + if (space && start.head != line.from + space) + moved = state.EditorSelection.cursor(line.from + space); + } + return moved; +} +/** +Move the selection to the next line wrap point, or to the end of +the line if there isn't one left on this line. +*/ +const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true)); +/** +Move the selection to previous line wrap point, or failing that to +the start of the line. If the line is indented, and the cursor +isn't already at the end of the indentation, this will move to the +end of the indentation instead of the start of the line. +*/ +const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false)); +/** +Move the selection one line wrap point to the left. +*/ +const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view))); +/** +Move the selection one line wrap point to the right. +*/ +const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view))); +/** +Move the selection to the start of the line. +*/ +const cursorLineStart = view => moveSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).from, 1)); +/** +Move the selection to the end of the line. +*/ +const cursorLineEnd = view => moveSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).to, -1)); +function toMatchingBracket(state$1, dispatch, extend) { + let found = false, selection = updateSel(state$1.selection, range => { + let matching = language.matchBrackets(state$1, range.head, -1) + || language.matchBrackets(state$1, range.head, 1) + || (range.head > 0 && language.matchBrackets(state$1, range.head - 1, 1)) + || (range.head < state$1.doc.length && language.matchBrackets(state$1, range.head + 1, -1)); + if (!matching || !matching.end) + return range; + found = true; + let head = matching.start.from == range.head ? matching.end.to : matching.end.from; + return extend ? state.EditorSelection.range(range.anchor, head) : state.EditorSelection.cursor(head); + }); + if (!found) + return false; + dispatch(setSel(state$1, selection)); + return true; +} +/** +Move the selection to the bracket matching the one it is currently +on, if any. +*/ +const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false); +/** +Extend the selection to the bracket matching the one the selection +head is currently on, if any. +*/ +const selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, true); +function extendSel(target, how) { + let selection = updateSel(target.state.selection, range => { + let head = how(range); + return state.EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined, head.assoc); + }); + if (selection.eq(target.state.selection)) + return false; + target.dispatch(setSel(target.state, selection)); + return true; +} +function selectByChar(view, forward) { + return extendSel(view, range => view.moveByChar(range, forward)); +} +/** +Move the selection head one character to the left, while leaving +the anchor in place. +*/ +const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view)); +/** +Move the selection head one character to the right. +*/ +const selectCharRight = view => selectByChar(view, ltrAtCursor(view)); +/** +Move the selection head one character forward. +*/ +const selectCharForward = view => selectByChar(view, true); +/** +Move the selection head one character backward. +*/ +const selectCharBackward = view => selectByChar(view, false); +/** +Move the selection head one character forward by logical +(non-direction aware) string index order. +*/ +const selectCharForwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, true)); +/** +Move the selection head one character backward by logical string +index order. +*/ +const selectCharBackwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, false)); +function selectByGroup(view, forward) { + return extendSel(view, range => view.moveByGroup(range, forward)); +} +/** +Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to +the left. +*/ +const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view)); +/** +Move the selection head one group to the right. +*/ +const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view)); +/** +Move the selection head one group forward. +*/ +const selectGroupForward = view => selectByGroup(view, true); +/** +Move the selection head one group backward. +*/ +const selectGroupBackward = view => selectByGroup(view, false); +/** +Move the selection head one group forward in the default Windows +style, skipping to the start of the next group. +*/ +const selectGroupForwardWin = view => { + return extendSel(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start))); +}; +function selectBySubword(view, forward) { + return extendSel(view, range => moveBySubword(view, range, forward)); +} +/** +Move the selection head one group or camel-case subword forward. +*/ +const selectSubwordForward = view => selectBySubword(view, true); +/** +Move the selection head one group or subword backward. +*/ +const selectSubwordBackward = view => selectBySubword(view, false); +/** +Move the selection head over the next syntactic element to the left. +*/ +const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view))); +/** +Move the selection head over the next syntactic element to the right. +*/ +const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view))); +function selectByLine(view, forward) { + return extendSel(view, range => view.moveVertically(range, forward)); +} +/** +Move the selection head one line up. +*/ +const selectLineUp = view => selectByLine(view, false); +/** +Move the selection head one line down. +*/ +const selectLineDown = view => selectByLine(view, true); +function selectByPage(view, forward) { + return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height)); +} +/** +Move the selection head one page up. +*/ +const selectPageUp = view => selectByPage(view, false); +/** +Move the selection head one page down. +*/ +const selectPageDown = view => selectByPage(view, true); +/** +Move the selection head to the next line boundary. +*/ +const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true)); +/** +Move the selection head to the previous line boundary. +*/ +const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false)); +/** +Move the selection head one line boundary to the left. +*/ +const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view))); +/** +Move the selection head one line boundary to the right. +*/ +const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view))); +/** +Move the selection head to the start of the line. +*/ +const selectLineStart = view => extendSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).from)); +/** +Move the selection head to the end of the line. +*/ +const selectLineEnd = view => extendSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).to)); +/** +Move the selection to the start of the document. +*/ +const cursorDocStart = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: 0 })); + return true; +}; +/** +Move the selection to the end of the document. +*/ +const cursorDocEnd = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.doc.length })); + return true; +}; +/** +Move the selection head to the start of the document. +*/ +const selectDocStart = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 })); + return true; +}; +/** +Move the selection head to the end of the document. +*/ +const selectDocEnd = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length })); + return true; +}; +/** +Select the entire document. +*/ +const selectAll = ({ state, dispatch }) => { + dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: "select" })); + return true; +}; +/** +Expand the selection to cover entire lines. +*/ +const selectLine = ({ state: state$1, dispatch }) => { + let ranges = selectedLineBlocks(state$1).map(({ from, to }) => state.EditorSelection.range(from, Math.min(to + 1, state$1.doc.length))); + dispatch(state$1.update({ selection: state.EditorSelection.create(ranges), userEvent: "select" })); + return true; +}; +/** +Select the next syntactic construct that is larger than the +selection. Note that this will only work insofar as the language +[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full +syntax tree. +*/ +const selectParentSyntax = ({ state: state$1, dispatch }) => { + let selection = updateSel(state$1.selection, range => { + let tree = language.syntaxTree(state$1), stack = tree.resolveStack(range.from, 1); + if (range.empty) { + let stackBefore = tree.resolveStack(range.from, -1); + if (stackBefore.node.from >= stack.node.from && stackBefore.node.to <= stack.node.to) + stack = stackBefore; + } + for (let cur = stack; cur; cur = cur.next) { + let { node } = cur; + if (((node.from < range.from && node.to >= range.to) || + (node.to > range.to && node.from <= range.from)) && + cur.next) + return state.EditorSelection.range(node.to, node.from); + } + return range; + }); + if (selection.eq(state$1.selection)) + return false; + dispatch(setSel(state$1, selection)); + return true; +}; +function addCursorVertically(view, forward) { + let { state: state$1 } = view, sel = state$1.selection, ranges = state$1.selection.ranges.slice(); + for (let range of state$1.selection.ranges) { + let line = state$1.doc.lineAt(range.head); + if (forward ? line.to < view.state.doc.length : line.from > 0) + for (let cur = range;;) { + let next = view.moveVertically(cur, forward); + if (next.head < line.from || next.head > line.to) { + if (!ranges.some(r => r.head == next.head)) + ranges.push(next); + break; + } + else if (next.head == cur.head) { + break; + } + else { + cur = next; + } + } + } + if (ranges.length == sel.ranges.length) + return false; + view.dispatch(setSel(state$1, state.EditorSelection.create(ranges, ranges.length - 1))); + return true; +} +/** +Expand the selection by adding a cursor above the heads of +currently selected ranges. +*/ +const addCursorAbove = view => addCursorVertically(view, false); +/** +Expand the selection by adding a cursor below the heads of +currently selected ranges. +*/ +const addCursorBelow = view => addCursorVertically(view, true); +/** +Simplify the current selection. When multiple ranges are selected, +reduce it to its main range. Otherwise, if the selection is +non-empty, convert it to a cursor selection. +*/ +const simplifySelection = ({ state: state$1, dispatch }) => { + let cur = state$1.selection, selection = null; + if (cur.ranges.length > 1) + selection = state.EditorSelection.create([cur.main]); + else if (!cur.main.empty) + selection = state.EditorSelection.create([state.EditorSelection.cursor(cur.main.head)]); + if (!selection) + return false; + dispatch(setSel(state$1, selection)); + return true; +}; +function deleteBy(target, by) { + if (target.state.readOnly) + return false; + let event = "delete.selection", { state: state$1 } = target; + let changes = state$1.changeByRange(range => { + let { from, to } = range; + if (from == to) { + let towards = by(range); + if (towards < from) { + event = "delete.backward"; + towards = skipAtomic(target, towards, false); + } + else if (towards > from) { + event = "delete.forward"; + towards = skipAtomic(target, towards, true); + } + from = Math.min(from, towards); + to = Math.max(to, towards); + } + else { + from = skipAtomic(target, from, false); + to = skipAtomic(target, to, true); + } + return from == to ? { range } : { changes: { from, to }, range: state.EditorSelection.cursor(from, from < range.head ? -1 : 1) }; + }); + if (changes.changes.empty) + return false; + target.dispatch(state$1.update(changes, { + scrollIntoView: true, + userEvent: event, + effects: event == "delete.selection" ? view.EditorView.announce.of(state$1.phrase("Selection deleted")) : undefined + })); + return true; +} +function skipAtomic(target, pos, forward) { + if (target instanceof view.EditorView) + for (let ranges of target.state.facet(view.EditorView.atomicRanges).map(f => f(target))) + ranges.between(pos, pos, (from, to) => { + if (from < pos && to > pos) + pos = forward ? to : from; + }); + return pos; +} +const deleteByChar = (target, forward, byIndentUnit) => deleteBy(target, range => { + let pos = range.from, { state: state$1 } = target, line = state$1.doc.lineAt(pos), before, targetPos; + if (byIndentUnit && !forward && pos > line.from && pos < line.from + 200 && + !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) { + if (before[before.length - 1] == "\t") + return pos - 1; + let col = state.countColumn(before, state$1.tabSize), drop = col % language.getIndentUnit(state$1) || language.getIndentUnit(state$1); + for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++) + pos--; + targetPos = pos; + } + else { + targetPos = state.findClusterBreak(line.text, pos - line.from, forward, forward) + line.from; + if (targetPos == pos && line.number != (forward ? state$1.doc.lines : 1)) + targetPos += forward ? 1 : -1; + else if (!forward && /[\ufe00-\ufe0f]/.test(line.text.slice(targetPos - line.from, pos - line.from))) + targetPos = state.findClusterBreak(line.text, targetPos - line.from, false, false) + line.from; + } + return targetPos; +}); +/** +Delete the selection, or, for cursor selections, the character or +indentation unit before the cursor. +*/ +const deleteCharBackward = view => deleteByChar(view, false, true); +/** +Delete the selection or the character before the cursor. Does not +implement any extended behavior like deleting whole indentation +units in one go. +*/ +const deleteCharBackwardStrict = view => deleteByChar(view, false, false); +/** +Delete the selection or the character after the cursor. +*/ +const deleteCharForward = view => deleteByChar(view, true, false); +const deleteByGroup = (target, forward) => deleteBy(target, range => { + let pos = range.head, { state: state$1 } = target, line = state$1.doc.lineAt(pos); + let categorize = state$1.charCategorizer(pos); + for (let cat = null;;) { + if (pos == (forward ? line.to : line.from)) { + if (pos == range.head && line.number != (forward ? state$1.doc.lines : 1)) + pos += forward ? 1 : -1; + break; + } + let next = state.findClusterBreak(line.text, pos - line.from, forward) + line.from; + let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from); + let nextCat = categorize(nextChar); + if (cat != null && nextCat != cat) + break; + if (nextChar != " " || pos != range.head) + cat = nextCat; + pos = next; + } + return pos; +}); +/** +Delete the selection or backward until the end of the next +[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of +whitespace when they consist of a single space. +*/ +const deleteGroupBackward = target => deleteByGroup(target, false); +/** +Delete the selection or forward until the end of the next group. +*/ +const deleteGroupForward = target => deleteByGroup(target, true); +/** +Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) +that uses the Windows convention of also deleting the whitespace +after a word. +*/ +const deleteGroupForwardWin = view => deleteBy(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)).head); +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line. If the cursor is directly at the end of the +line, delete the line break after it. +*/ +const deleteToLineEnd = view => deleteBy(view, range => { + let lineEnd = view.lineBlockAt(range.head).to; + return range.head < lineEnd ? lineEnd : Math.min(view.state.doc.length, range.head + 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line. If the cursor is directly at the start of the +line, delete the line break before it. +*/ +const deleteToLineStart = view => deleteBy(view, range => { + let lineStart = view.lineBlockAt(range.head).from; + return range.head > lineStart ? lineStart : Math.max(0, range.head - 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line or the next line wrap before the cursor. +*/ +const deleteLineBoundaryBackward = view => deleteBy(view, range => { + let lineStart = view.moveToLineBoundary(range, false).head; + return range.head > lineStart ? lineStart : Math.max(0, range.head - 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line or the next line wrap after the cursor. +*/ +const deleteLineBoundaryForward = view => deleteBy(view, range => { + let lineStart = view.moveToLineBoundary(range, true).head; + return range.head < lineStart ? lineStart : Math.min(view.state.doc.length, range.head + 1); +}); +/** +Delete all whitespace directly before a line end from the +document. +*/ +const deleteTrailingWhitespace = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let changes = []; + for (let pos = 0, prev = "", iter = state.doc.iter();;) { + iter.next(); + if (iter.lineBreak || iter.done) { + let trailing = prev.search(/\s+$/); + if (trailing > -1) + changes.push({ from: pos - (prev.length - trailing), to: pos }); + if (iter.done) + break; + prev = ""; + } + else { + prev = iter.value; + } + pos += iter.value.length; + } + if (!changes.length) + return false; + dispatch(state.update({ changes, userEvent: "delete" })); + return true; +}; +/** +Replace each selection range with a line break, leaving the cursor +on the line before the break. +*/ +const splitLine = ({ state: state$1, dispatch }) => { + if (state$1.readOnly) + return false; + let changes = state$1.changeByRange(range => { + return { changes: { from: range.from, to: range.to, insert: state.Text.of(["", ""]) }, + range: state.EditorSelection.cursor(range.from) }; + }); + dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Flip the characters before and after the cursor(s). +*/ +const transposeChars = ({ state: state$1, dispatch }) => { + if (state$1.readOnly) + return false; + let changes = state$1.changeByRange(range => { + if (!range.empty || range.from == 0 || range.from == state$1.doc.length) + return { range }; + let pos = range.from, line = state$1.doc.lineAt(pos); + let from = pos == line.from ? pos - 1 : state.findClusterBreak(line.text, pos - line.from, false) + line.from; + let to = pos == line.to ? pos + 1 : state.findClusterBreak(line.text, pos - line.from, true) + line.from; + return { changes: { from, to, insert: state$1.doc.slice(pos, to).append(state$1.doc.slice(from, pos)) }, + range: state.EditorSelection.cursor(to) }; + }); + if (changes.changes.empty) + return false; + dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "move.character" })); + return true; +}; +function selectedLineBlocks(state) { + let blocks = [], upto = -1; + for (let range of state.selection.ranges) { + let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to); + if (!range.empty && range.to == endLine.from) + endLine = state.doc.lineAt(range.to - 1); + if (upto >= startLine.number) { + let prev = blocks[blocks.length - 1]; + prev.to = endLine.to; + prev.ranges.push(range); + } + else { + blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] }); + } + upto = endLine.number + 1; + } + return blocks; +} +function moveLine(state$1, dispatch, forward) { + if (state$1.readOnly) + return false; + let changes = [], ranges = []; + for (let block of selectedLineBlocks(state$1)) { + if (forward ? block.to == state$1.doc.length : block.from == 0) + continue; + let nextLine = state$1.doc.lineAt(forward ? block.to + 1 : block.from - 1); + let size = nextLine.length + 1; + if (forward) { + changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state$1.lineBreak }); + for (let r of block.ranges) + ranges.push(state.EditorSelection.range(Math.min(state$1.doc.length, r.anchor + size), Math.min(state$1.doc.length, r.head + size))); + } + else { + changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state$1.lineBreak + nextLine.text }); + for (let r of block.ranges) + ranges.push(state.EditorSelection.range(r.anchor - size, r.head - size)); + } + } + if (!changes.length) + return false; + dispatch(state$1.update({ + changes, + scrollIntoView: true, + selection: state.EditorSelection.create(ranges, state$1.selection.mainIndex), + userEvent: "move.line" + })); + return true; +} +/** +Move the selected lines up one line. +*/ +const moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false); +/** +Move the selected lines down one line. +*/ +const moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true); +function copyLine(state, dispatch, forward) { + if (state.readOnly) + return false; + let changes = []; + for (let block of selectedLineBlocks(state)) { + if (forward) + changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak }); + else + changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) }); + } + let changeSet = state.changes(changes); + dispatch(state.update({ + changes: changeSet, + selection: state.selection.map(changeSet, forward ? 1 : -1), + scrollIntoView: true, + userEvent: "input.copyline" + })); + return true; +} +/** +Create a copy of the selected lines. Keep the selection in the top copy. +*/ +const copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false); +/** +Create a copy of the selected lines. Keep the selection in the bottom copy. +*/ +const copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true); +/** +Delete selected lines. +*/ +const deleteLine = view => { + if (view.state.readOnly) + return false; + let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => { + if (from > 0) + from--; + else if (to < state.doc.length) + to++; + return { from, to }; + })); + let selection = updateSel(state.selection, range => { + let dist = undefined; + if (view.lineWrapping) { + let block = view.lineBlockAt(range.head), pos = view.coordsAtPos(range.head, range.assoc || 1); + if (pos) + dist = (block.bottom + view.documentTop) - pos.bottom + view.defaultLineHeight / 2; + } + return view.moveVertically(range, true, dist); + }).map(changes); + view.dispatch({ changes, selection, scrollIntoView: true, userEvent: "delete.line" }); + return true; +}; +/** +Replace the selection with a newline. +*/ +const insertNewline = ({ state, dispatch }) => { + dispatch(state.update(state.replaceSelection(state.lineBreak), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Replace the selection with a newline and the same amount of +indentation as the line above. +*/ +const insertNewlineKeepIndent = ({ state: state$1, dispatch }) => { + dispatch(state$1.update(state$1.changeByRange(range => { + let indent = /^\s*/.exec(state$1.doc.lineAt(range.from).text)[0]; + return { + changes: { from: range.from, to: range.to, insert: state$1.lineBreak + indent }, + range: state.EditorSelection.cursor(range.from + indent.length + 1) + }; + }), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +function isBetweenBrackets(state, pos) { + if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1))) + return { from: pos, to: pos }; + let context = language.syntaxTree(state).resolveInner(pos); + let before = context.childBefore(pos), after = context.childAfter(pos), closedBy; + if (before && after && before.to <= pos && after.from >= pos && + (closedBy = before.type.prop(common.NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 && + state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from && + !/\S/.test(state.sliceDoc(before.to, after.from))) + return { from: before.to, to: after.from }; + return null; +} +/** +Replace the selection with a newline and indent the newly created +line(s). If the current line consists only of whitespace, this +will also delete that whitespace. When the cursor is between +matching brackets, an additional newline will be inserted after +the cursor. +*/ +const insertNewlineAndIndent = newlineAndIndent(false); +/** +Create a blank, indented line below the current line. +*/ +const insertBlankLine = newlineAndIndent(true); +function newlineAndIndent(atEof) { + return ({ state: state$1, dispatch }) => { + if (state$1.readOnly) + return false; + let changes = state$1.changeByRange(range => { + let { from, to } = range, line = state$1.doc.lineAt(from); + let explode = !atEof && from == to && isBetweenBrackets(state$1, from); + if (atEof) + from = to = (to <= line.to ? line : state$1.doc.lineAt(to)).to; + let cx = new language.IndentContext(state$1, { simulateBreak: from, simulateDoubleBreak: !!explode }); + let indent = language.getIndentation(cx, from); + if (indent == null) + indent = state.countColumn(/^\s*/.exec(state$1.doc.lineAt(from).text)[0], state$1.tabSize); + while (to < line.to && /\s/.test(line.text[to - line.from])) + to++; + if (explode) + ({ from, to } = explode); + else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from))) + from = line.from; + let insert = ["", language.indentString(state$1, indent)]; + if (explode) + insert.push(language.indentString(state$1, cx.lineIndent(line.from, -1))); + return { changes: { from, to, insert: state.Text.of(insert) }, + range: state.EditorSelection.cursor(from + 1 + insert[1].length) }; + }); + dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "input" })); + return true; + }; +} +function changeBySelectedLine(state$1, f) { + let atLine = -1; + return state$1.changeByRange(range => { + let changes = []; + for (let pos = range.from; pos <= range.to;) { + let line = state$1.doc.lineAt(pos); + if (line.number > atLine && (range.empty || range.to > line.from)) { + f(line, changes, range); + atLine = line.number; + } + pos = line.to + 1; + } + let changeSet = state$1.changes(changes); + return { changes, + range: state.EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) }; + }); +} +/** +Auto-indent the selected lines. This uses the [indentation service +facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent +information. +*/ +const indentSelection = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let updated = Object.create(null); + let context = new language.IndentContext(state, { overrideIndentation: start => { + let found = updated[start]; + return found == null ? -1 : found; + } }); + let changes = changeBySelectedLine(state, (line, changes, range) => { + let indent = language.getIndentation(context, line.from); + if (indent == null) + return; + if (!/\S/.test(line.text)) + indent = 0; + let cur = /^\s*/.exec(line.text)[0]; + let norm = language.indentString(state, indent); + if (cur != norm || range.from < line.from + cur.length) { + updated[line.from] = indent; + changes.push({ from: line.from, to: line.from + cur.length, insert: norm }); + } + }); + if (!changes.changes.empty) + dispatch(state.update(changes, { userEvent: "indent" })); + return true; +}; +/** +Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected +lines. +*/ +const indentMore = ({ state, dispatch }) => { + if (state.readOnly) + return false; + dispatch(state.update(changeBySelectedLine(state, (line, changes) => { + changes.push({ from: line.from, insert: state.facet(language.indentUnit) }); + }), { userEvent: "input.indent" })); + return true; +}; +/** +Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all +selected lines. +*/ +const indentLess = ({ state: state$1, dispatch }) => { + if (state$1.readOnly) + return false; + dispatch(state$1.update(changeBySelectedLine(state$1, (line, changes) => { + let space = /^\s*/.exec(line.text)[0]; + if (!space) + return; + let col = state.countColumn(space, state$1.tabSize), keep = 0; + let insert = language.indentString(state$1, Math.max(0, col - language.getIndentUnit(state$1))); + while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep)) + keep++; + changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) }); + }), { userEvent: "delete.dedent" })); + return true; +}; +/** +Enables or disables +[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this +prevents the editor's key bindings from capturing Tab or +Shift-Tab, making it possible for the user to move focus out of +the editor with the keyboard. +*/ +const toggleTabFocusMode = view => { + view.setTabFocusMode(); + return true; +}; +/** +Temporarily enables [tab-focus +mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until +another key is pressed. +*/ +const temporarilySetTabFocusMode = view => { + view.setTabFocusMode(2000); + return true; +}; +/** +Insert a tab character at the cursor or, if something is selected, +use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire +selection. +*/ +const insertTab = ({ state, dispatch }) => { + if (state.selection.ranges.some(r => !r.empty)) + return indentMore({ state, dispatch }); + dispatch(state.update(state.replaceSelection("\t"), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Array of key bindings containing the Emacs-style bindings that are +available on macOS by default. + + - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd) + - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine) + - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars) + - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) + - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) +*/ +const emacsStyleKeymap = [ + { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true }, + { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight }, + { key: "Ctrl-p", run: cursorLineUp, shift: selectLineUp }, + { key: "Ctrl-n", run: cursorLineDown, shift: selectLineDown }, + { key: "Ctrl-a", run: cursorLineStart, shift: selectLineStart }, + { key: "Ctrl-e", run: cursorLineEnd, shift: selectLineEnd }, + { key: "Ctrl-d", run: deleteCharForward }, + { key: "Ctrl-h", run: deleteCharBackward }, + { key: "Ctrl-k", run: deleteToLineEnd }, + { key: "Ctrl-Alt-h", run: deleteGroupBackward }, + { key: "Ctrl-o", run: splitLine }, + { key: "Ctrl-t", run: transposeChars }, + { key: "Ctrl-v", run: cursorPageDown }, +]; +/** +An array of key bindings closely sticking to platform-standard or +widely used bindings. (This includes the bindings from +[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key` +property changed to `mac`.) + + - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift) + - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift) + - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift) + - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift) + - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent) + - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll) + - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) + - Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward). + - Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward). +*/ +const standardKeymap = [ + { key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true }, + { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true }, + { mac: "Cmd-ArrowLeft", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true }, + { key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true }, + { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true }, + { mac: "Cmd-ArrowRight", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true }, + { key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true }, + { mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart }, + { mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp }, + { key: "ArrowDown", run: cursorLineDown, shift: selectLineDown, preventDefault: true }, + { mac: "Cmd-ArrowDown", run: cursorDocEnd, shift: selectDocEnd }, + { mac: "Ctrl-ArrowDown", run: cursorPageDown, shift: selectPageDown }, + { key: "PageUp", run: cursorPageUp, shift: selectPageUp }, + { key: "PageDown", run: cursorPageDown, shift: selectPageDown }, + { key: "Home", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true }, + { key: "Mod-Home", run: cursorDocStart, shift: selectDocStart }, + { key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true }, + { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd }, + { key: "Enter", run: insertNewlineAndIndent, shift: insertNewlineAndIndent }, + { key: "Mod-a", run: selectAll }, + { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward, preventDefault: true }, + { key: "Delete", run: deleteCharForward, preventDefault: true }, + { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward, preventDefault: true }, + { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward, preventDefault: true }, + { mac: "Mod-Backspace", run: deleteLineBoundaryBackward, preventDefault: true }, + { mac: "Mod-Delete", run: deleteLineBoundaryForward, preventDefault: true } +].concat(emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift }))); +/** +The default keymap. Includes all bindings from +[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following: + +- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift) +- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift) +- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp) +- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown) +- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp) +- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown) +- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove). +- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow). +- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection) +- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine) +- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine) +- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax) +- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess) +- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) +- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection) +- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine) +- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket) +- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment). +- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment). +- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode). +*/ +const defaultKeymap = [ + { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: cursorSyntaxLeft, shift: selectSyntaxLeft }, + { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: cursorSyntaxRight, shift: selectSyntaxRight }, + { key: "Alt-ArrowUp", run: moveLineUp }, + { key: "Shift-Alt-ArrowUp", run: copyLineUp }, + { key: "Alt-ArrowDown", run: moveLineDown }, + { key: "Shift-Alt-ArrowDown", run: copyLineDown }, + { key: "Mod-Alt-ArrowUp", run: addCursorAbove }, + { key: "Mod-Alt-ArrowDown", run: addCursorBelow }, + { key: "Escape", run: simplifySelection }, + { key: "Mod-Enter", run: insertBlankLine }, + { key: "Alt-l", mac: "Ctrl-l", run: selectLine }, + { key: "Mod-i", run: selectParentSyntax, preventDefault: true }, + { key: "Mod-[", run: indentLess }, + { key: "Mod-]", run: indentMore }, + { key: "Mod-Alt-\\", run: indentSelection }, + { key: "Shift-Mod-k", run: deleteLine }, + { key: "Shift-Mod-\\", run: cursorMatchingBracket }, + { key: "Mod-/", run: toggleComment }, + { key: "Alt-A", run: toggleBlockComment }, + { key: "Ctrl-m", mac: "Shift-Alt-m", run: toggleTabFocusMode }, +].concat(standardKeymap); +/** +A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and +Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess). +Please see the [Tab example](../../examples/tab/) before using +this. +*/ +const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess }; + +exports.addCursorAbove = addCursorAbove; +exports.addCursorBelow = addCursorBelow; +exports.blockComment = blockComment; +exports.blockUncomment = blockUncomment; +exports.copyLineDown = copyLineDown; +exports.copyLineUp = copyLineUp; +exports.cursorCharBackward = cursorCharBackward; +exports.cursorCharBackwardLogical = cursorCharBackwardLogical; +exports.cursorCharForward = cursorCharForward; +exports.cursorCharForwardLogical = cursorCharForwardLogical; +exports.cursorCharLeft = cursorCharLeft; +exports.cursorCharRight = cursorCharRight; +exports.cursorDocEnd = cursorDocEnd; +exports.cursorDocStart = cursorDocStart; +exports.cursorGroupBackward = cursorGroupBackward; +exports.cursorGroupForward = cursorGroupForward; +exports.cursorGroupForwardWin = cursorGroupForwardWin; +exports.cursorGroupLeft = cursorGroupLeft; +exports.cursorGroupRight = cursorGroupRight; +exports.cursorLineBoundaryBackward = cursorLineBoundaryBackward; +exports.cursorLineBoundaryForward = cursorLineBoundaryForward; +exports.cursorLineBoundaryLeft = cursorLineBoundaryLeft; +exports.cursorLineBoundaryRight = cursorLineBoundaryRight; +exports.cursorLineDown = cursorLineDown; +exports.cursorLineEnd = cursorLineEnd; +exports.cursorLineStart = cursorLineStart; +exports.cursorLineUp = cursorLineUp; +exports.cursorMatchingBracket = cursorMatchingBracket; +exports.cursorPageDown = cursorPageDown; +exports.cursorPageUp = cursorPageUp; +exports.cursorSubwordBackward = cursorSubwordBackward; +exports.cursorSubwordForward = cursorSubwordForward; +exports.cursorSyntaxLeft = cursorSyntaxLeft; +exports.cursorSyntaxRight = cursorSyntaxRight; +exports.defaultKeymap = defaultKeymap; +exports.deleteCharBackward = deleteCharBackward; +exports.deleteCharBackwardStrict = deleteCharBackwardStrict; +exports.deleteCharForward = deleteCharForward; +exports.deleteGroupBackward = deleteGroupBackward; +exports.deleteGroupForward = deleteGroupForward; +exports.deleteGroupForwardWin = deleteGroupForwardWin; +exports.deleteLine = deleteLine; +exports.deleteLineBoundaryBackward = deleteLineBoundaryBackward; +exports.deleteLineBoundaryForward = deleteLineBoundaryForward; +exports.deleteToLineEnd = deleteToLineEnd; +exports.deleteToLineStart = deleteToLineStart; +exports.deleteTrailingWhitespace = deleteTrailingWhitespace; +exports.emacsStyleKeymap = emacsStyleKeymap; +exports.history = history; +exports.historyField = historyField; +exports.historyKeymap = historyKeymap; +exports.indentLess = indentLess; +exports.indentMore = indentMore; +exports.indentSelection = indentSelection; +exports.indentWithTab = indentWithTab; +exports.insertBlankLine = insertBlankLine; +exports.insertNewline = insertNewline; +exports.insertNewlineAndIndent = insertNewlineAndIndent; +exports.insertNewlineKeepIndent = insertNewlineKeepIndent; +exports.insertTab = insertTab; +exports.invertedEffects = invertedEffects; +exports.isolateHistory = isolateHistory; +exports.lineComment = lineComment; +exports.lineUncomment = lineUncomment; +exports.moveLineDown = moveLineDown; +exports.moveLineUp = moveLineUp; +exports.redo = redo; +exports.redoDepth = redoDepth; +exports.redoSelection = redoSelection; +exports.selectAll = selectAll; +exports.selectCharBackward = selectCharBackward; +exports.selectCharBackwardLogical = selectCharBackwardLogical; +exports.selectCharForward = selectCharForward; +exports.selectCharForwardLogical = selectCharForwardLogical; +exports.selectCharLeft = selectCharLeft; +exports.selectCharRight = selectCharRight; +exports.selectDocEnd = selectDocEnd; +exports.selectDocStart = selectDocStart; +exports.selectGroupBackward = selectGroupBackward; +exports.selectGroupForward = selectGroupForward; +exports.selectGroupForwardWin = selectGroupForwardWin; +exports.selectGroupLeft = selectGroupLeft; +exports.selectGroupRight = selectGroupRight; +exports.selectLine = selectLine; +exports.selectLineBoundaryBackward = selectLineBoundaryBackward; +exports.selectLineBoundaryForward = selectLineBoundaryForward; +exports.selectLineBoundaryLeft = selectLineBoundaryLeft; +exports.selectLineBoundaryRight = selectLineBoundaryRight; +exports.selectLineDown = selectLineDown; +exports.selectLineEnd = selectLineEnd; +exports.selectLineStart = selectLineStart; +exports.selectLineUp = selectLineUp; +exports.selectMatchingBracket = selectMatchingBracket; +exports.selectPageDown = selectPageDown; +exports.selectPageUp = selectPageUp; +exports.selectParentSyntax = selectParentSyntax; +exports.selectSubwordBackward = selectSubwordBackward; +exports.selectSubwordForward = selectSubwordForward; +exports.selectSyntaxLeft = selectSyntaxLeft; +exports.selectSyntaxRight = selectSyntaxRight; +exports.simplifySelection = simplifySelection; +exports.splitLine = splitLine; +exports.standardKeymap = standardKeymap; +exports.temporarilySetTabFocusMode = temporarilySetTabFocusMode; +exports.toggleBlockComment = toggleBlockComment; +exports.toggleBlockCommentByLine = toggleBlockCommentByLine; +exports.toggleComment = toggleComment; +exports.toggleLineComment = toggleLineComment; +exports.toggleTabFocusMode = toggleTabFocusMode; +exports.transposeChars = transposeChars; +exports.undo = undo; +exports.undoDepth = undoDepth; +exports.undoSelection = undoSelection; diff --git a/node_modules/@codemirror/commands/dist/index.d.cts b/node_modules/@codemirror/commands/dist/index.d.cts new file mode 100644 index 0000000..4db313d --- /dev/null +++ b/node_modules/@codemirror/commands/dist/index.d.cts @@ -0,0 +1,650 @@ +import * as _codemirror_state from '@codemirror/state'; +import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state'; +import { KeyBinding, Command } from '@codemirror/view'; + +/** +An object of this type can be provided as [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"` +property to configure comment syntax for a language. +*/ +interface CommentTokens { + /** + The block comment syntax, if any. For example, for HTML + you'd provide `{open: ""}`. + */ + block?: { + open: string; + close: string; + }; + /** + The line comment syntax. For example `"//"`. + */ + line?: string; +} +/** +Comment or uncomment the current selection. Will use line comments +if available, otherwise falling back to block comments. +*/ +declare const toggleComment: StateCommand; +/** +Comment or uncomment the current selection using line comments. +The line comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +declare const toggleLineComment: StateCommand; +/** +Comment the current selection using line comments. +*/ +declare const lineComment: StateCommand; +/** +Uncomment the current selection using line comments. +*/ +declare const lineUncomment: StateCommand; +/** +Comment or uncomment the current selection using block comments. +The block comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +declare const toggleBlockComment: StateCommand; +/** +Comment the current selection using block comments. +*/ +declare const blockComment: StateCommand; +/** +Uncomment the current selection using block comments. +*/ +declare const blockUncomment: StateCommand; +/** +Comment or uncomment the lines around the current selection using +block comments. +*/ +declare const toggleBlockCommentByLine: StateCommand; + +/** +Transaction annotation that will prevent that transaction from +being combined with other transactions in the undo history. Given +`"before"`, it'll prevent merging with previous transactions. With +`"after"`, subsequent transactions won't be combined with this +one. With `"full"`, the transaction is isolated on both sides. +*/ +declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">; +/** +This facet provides a way to register functions that, given a +transaction, provide a set of effects that the history should +store when inverting the transaction. This can be used to +integrate some kinds of effects in the history, so that they can +be undone (and redone again). +*/ +declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect[], readonly ((tr: Transaction) => readonly StateEffect[])[]>; +interface HistoryConfig { + /** + The minimum depth (amount of events) to store. Defaults to 100. + */ + minDepth?: number; + /** + The maximum time (in milliseconds) that adjacent events can be + apart and still be grouped together. Defaults to 500. + */ + newGroupDelay?: number; + /** + By default, when close enough together in time, changes are + joined into an existing undo event if they touch any of the + changed ranges from that event. You can pass a custom predicate + here to influence that logic. + */ + joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean; +} +/** +Create a history extension with the given configuration. +*/ +declare function history(config?: HistoryConfig): Extension; +/** +The state field used to store the history data. Should probably +only be used when you want to +[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or +[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way +that preserves history. +*/ +declare const historyField: StateField; +/** +Undo a single group of history events. Returns false if no group +was available. +*/ +declare const undo: StateCommand; +/** +Redo a group of history events. Returns false if no group was +available. +*/ +declare const redo: StateCommand; +/** +Undo a change or selection change. +*/ +declare const undoSelection: StateCommand; +/** +Redo a change or selection change. +*/ +declare const redoSelection: StateCommand; +/** +The amount of undoable change events available in a given state. +*/ +declare const undoDepth: (state: EditorState) => number; +/** +The amount of redoable change events available in a given state. +*/ +declare const redoDepth: (state: EditorState) => number; +/** +Default key bindings for the undo history. + +- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo). +- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo). +- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection). +- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection). +*/ +declare const historyKeymap: readonly KeyBinding[]; + +/** +Move the selection one character to the left (which is backward in +left-to-right text, forward in right-to-left text). +*/ +declare const cursorCharLeft: Command; +/** +Move the selection one character to the right. +*/ +declare const cursorCharRight: Command; +/** +Move the selection one character forward. +*/ +declare const cursorCharForward: Command; +/** +Move the selection one character backward. +*/ +declare const cursorCharBackward: Command; +/** +Move the selection one character forward, in logical +(non-text-direction-aware) string index order. +*/ +declare const cursorCharForwardLogical: StateCommand; +/** +Move the selection one character backward, in logical string index +order. +*/ +declare const cursorCharBackwardLogical: StateCommand; +/** +Move the selection to the left across one group of word or +non-word (but also non-space) characters. +*/ +declare const cursorGroupLeft: Command; +/** +Move the selection one group to the right. +*/ +declare const cursorGroupRight: Command; +/** +Move the selection one group forward. +*/ +declare const cursorGroupForward: Command; +/** +Move the selection one group backward. +*/ +declare const cursorGroupBackward: Command; +/** +Move the cursor one group forward in the default Windows style, +where it moves to the start of the next group. +*/ +declare const cursorGroupForwardWin: Command; +/** +Move the selection one group or camel-case subword forward. +*/ +declare const cursorSubwordForward: Command; +/** +Move the selection one group or camel-case subword backward. +*/ +declare const cursorSubwordBackward: Command; +/** +Move the cursor over the next syntactic element to the left. +*/ +declare const cursorSyntaxLeft: Command; +/** +Move the cursor over the next syntactic element to the right. +*/ +declare const cursorSyntaxRight: Command; +/** +Move the selection one line up. +*/ +declare const cursorLineUp: Command; +/** +Move the selection one line down. +*/ +declare const cursorLineDown: Command; +/** +Move the selection one page up. +*/ +declare const cursorPageUp: Command; +/** +Move the selection one page down. +*/ +declare const cursorPageDown: Command; +/** +Move the selection to the next line wrap point, or to the end of +the line if there isn't one left on this line. +*/ +declare const cursorLineBoundaryForward: Command; +/** +Move the selection to previous line wrap point, or failing that to +the start of the line. If the line is indented, and the cursor +isn't already at the end of the indentation, this will move to the +end of the indentation instead of the start of the line. +*/ +declare const cursorLineBoundaryBackward: Command; +/** +Move the selection one line wrap point to the left. +*/ +declare const cursorLineBoundaryLeft: Command; +/** +Move the selection one line wrap point to the right. +*/ +declare const cursorLineBoundaryRight: Command; +/** +Move the selection to the start of the line. +*/ +declare const cursorLineStart: Command; +/** +Move the selection to the end of the line. +*/ +declare const cursorLineEnd: Command; +/** +Move the selection to the bracket matching the one it is currently +on, if any. +*/ +declare const cursorMatchingBracket: StateCommand; +/** +Extend the selection to the bracket matching the one the selection +head is currently on, if any. +*/ +declare const selectMatchingBracket: StateCommand; +/** +Move the selection head one character to the left, while leaving +the anchor in place. +*/ +declare const selectCharLeft: Command; +/** +Move the selection head one character to the right. +*/ +declare const selectCharRight: Command; +/** +Move the selection head one character forward. +*/ +declare const selectCharForward: Command; +/** +Move the selection head one character backward. +*/ +declare const selectCharBackward: Command; +/** +Move the selection head one character forward by logical +(non-direction aware) string index order. +*/ +declare const selectCharForwardLogical: StateCommand; +/** +Move the selection head one character backward by logical string +index order. +*/ +declare const selectCharBackwardLogical: StateCommand; +/** +Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to +the left. +*/ +declare const selectGroupLeft: Command; +/** +Move the selection head one group to the right. +*/ +declare const selectGroupRight: Command; +/** +Move the selection head one group forward. +*/ +declare const selectGroupForward: Command; +/** +Move the selection head one group backward. +*/ +declare const selectGroupBackward: Command; +/** +Move the selection head one group forward in the default Windows +style, skipping to the start of the next group. +*/ +declare const selectGroupForwardWin: Command; +/** +Move the selection head one group or camel-case subword forward. +*/ +declare const selectSubwordForward: Command; +/** +Move the selection head one group or subword backward. +*/ +declare const selectSubwordBackward: Command; +/** +Move the selection head over the next syntactic element to the left. +*/ +declare const selectSyntaxLeft: Command; +/** +Move the selection head over the next syntactic element to the right. +*/ +declare const selectSyntaxRight: Command; +/** +Move the selection head one line up. +*/ +declare const selectLineUp: Command; +/** +Move the selection head one line down. +*/ +declare const selectLineDown: Command; +/** +Move the selection head one page up. +*/ +declare const selectPageUp: Command; +/** +Move the selection head one page down. +*/ +declare const selectPageDown: Command; +/** +Move the selection head to the next line boundary. +*/ +declare const selectLineBoundaryForward: Command; +/** +Move the selection head to the previous line boundary. +*/ +declare const selectLineBoundaryBackward: Command; +/** +Move the selection head one line boundary to the left. +*/ +declare const selectLineBoundaryLeft: Command; +/** +Move the selection head one line boundary to the right. +*/ +declare const selectLineBoundaryRight: Command; +/** +Move the selection head to the start of the line. +*/ +declare const selectLineStart: Command; +/** +Move the selection head to the end of the line. +*/ +declare const selectLineEnd: Command; +/** +Move the selection to the start of the document. +*/ +declare const cursorDocStart: StateCommand; +/** +Move the selection to the end of the document. +*/ +declare const cursorDocEnd: StateCommand; +/** +Move the selection head to the start of the document. +*/ +declare const selectDocStart: StateCommand; +/** +Move the selection head to the end of the document. +*/ +declare const selectDocEnd: StateCommand; +/** +Select the entire document. +*/ +declare const selectAll: StateCommand; +/** +Expand the selection to cover entire lines. +*/ +declare const selectLine: StateCommand; +/** +Select the next syntactic construct that is larger than the +selection. Note that this will only work insofar as the language +[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full +syntax tree. +*/ +declare const selectParentSyntax: StateCommand; +/** +Expand the selection by adding a cursor above the heads of +currently selected ranges. +*/ +declare const addCursorAbove: Command; +/** +Expand the selection by adding a cursor below the heads of +currently selected ranges. +*/ +declare const addCursorBelow: Command; +/** +Simplify the current selection. When multiple ranges are selected, +reduce it to its main range. Otherwise, if the selection is +non-empty, convert it to a cursor selection. +*/ +declare const simplifySelection: StateCommand; +/** +Delete the selection, or, for cursor selections, the character or +indentation unit before the cursor. +*/ +declare const deleteCharBackward: Command; +/** +Delete the selection or the character before the cursor. Does not +implement any extended behavior like deleting whole indentation +units in one go. +*/ +declare const deleteCharBackwardStrict: Command; +/** +Delete the selection or the character after the cursor. +*/ +declare const deleteCharForward: Command; +/** +Delete the selection or backward until the end of the next +[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of +whitespace when they consist of a single space. +*/ +declare const deleteGroupBackward: StateCommand; +/** +Delete the selection or forward until the end of the next group. +*/ +declare const deleteGroupForward: StateCommand; +/** +Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) +that uses the Windows convention of also deleting the whitespace +after a word. +*/ +declare const deleteGroupForwardWin: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line. If the cursor is directly at the end of the +line, delete the line break after it. +*/ +declare const deleteToLineEnd: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line. If the cursor is directly at the start of the +line, delete the line break before it. +*/ +declare const deleteToLineStart: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line or the next line wrap before the cursor. +*/ +declare const deleteLineBoundaryBackward: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line or the next line wrap after the cursor. +*/ +declare const deleteLineBoundaryForward: Command; +/** +Delete all whitespace directly before a line end from the +document. +*/ +declare const deleteTrailingWhitespace: StateCommand; +/** +Replace each selection range with a line break, leaving the cursor +on the line before the break. +*/ +declare const splitLine: StateCommand; +/** +Flip the characters before and after the cursor(s). +*/ +declare const transposeChars: StateCommand; +/** +Move the selected lines up one line. +*/ +declare const moveLineUp: StateCommand; +/** +Move the selected lines down one line. +*/ +declare const moveLineDown: StateCommand; +/** +Create a copy of the selected lines. Keep the selection in the top copy. +*/ +declare const copyLineUp: StateCommand; +/** +Create a copy of the selected lines. Keep the selection in the bottom copy. +*/ +declare const copyLineDown: StateCommand; +/** +Delete selected lines. +*/ +declare const deleteLine: Command; +/** +Replace the selection with a newline. +*/ +declare const insertNewline: StateCommand; +/** +Replace the selection with a newline and the same amount of +indentation as the line above. +*/ +declare const insertNewlineKeepIndent: StateCommand; +/** +Replace the selection with a newline and indent the newly created +line(s). If the current line consists only of whitespace, this +will also delete that whitespace. When the cursor is between +matching brackets, an additional newline will be inserted after +the cursor. +*/ +declare const insertNewlineAndIndent: StateCommand; +/** +Create a blank, indented line below the current line. +*/ +declare const insertBlankLine: StateCommand; +/** +Auto-indent the selected lines. This uses the [indentation service +facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent +information. +*/ +declare const indentSelection: StateCommand; +/** +Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected +lines. +*/ +declare const indentMore: StateCommand; +/** +Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all +selected lines. +*/ +declare const indentLess: StateCommand; +/** +Enables or disables +[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this +prevents the editor's key bindings from capturing Tab or +Shift-Tab, making it possible for the user to move focus out of +the editor with the keyboard. +*/ +declare const toggleTabFocusMode: Command; +/** +Temporarily enables [tab-focus +mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until +another key is pressed. +*/ +declare const temporarilySetTabFocusMode: Command; +/** +Insert a tab character at the cursor or, if something is selected, +use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire +selection. +*/ +declare const insertTab: StateCommand; +/** +Array of key bindings containing the Emacs-style bindings that are +available on macOS by default. + + - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd) + - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine) + - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars) + - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) + - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) +*/ +declare const emacsStyleKeymap: readonly KeyBinding[]; +/** +An array of key bindings closely sticking to platform-standard or +widely used bindings. (This includes the bindings from +[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key` +property changed to `mac`.) + + - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift) + - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift) + - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift) + - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift) + - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent) + - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll) + - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) + - Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward). + - Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward). +*/ +declare const standardKeymap: readonly KeyBinding[]; +/** +The default keymap. Includes all bindings from +[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following: + +- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift) +- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift) +- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp) +- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown) +- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp) +- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown) +- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove). +- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow). +- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection) +- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine) +- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine) +- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax) +- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess) +- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) +- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection) +- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine) +- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket) +- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment). +- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment). +- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode). +*/ +declare const defaultKeymap: readonly KeyBinding[]; +/** +A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and +Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess). +Please see the [Tab example](../../examples/tab/) before using +this. +*/ +declare const indentWithTab: KeyBinding; + +export { type CommentTokens, addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection }; diff --git a/node_modules/@codemirror/commands/dist/index.d.ts b/node_modules/@codemirror/commands/dist/index.d.ts new file mode 100644 index 0000000..4db313d --- /dev/null +++ b/node_modules/@codemirror/commands/dist/index.d.ts @@ -0,0 +1,650 @@ +import * as _codemirror_state from '@codemirror/state'; +import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state'; +import { KeyBinding, Command } from '@codemirror/view'; + +/** +An object of this type can be provided as [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"` +property to configure comment syntax for a language. +*/ +interface CommentTokens { + /** + The block comment syntax, if any. For example, for HTML + you'd provide `{open: ""}`. + */ + block?: { + open: string; + close: string; + }; + /** + The line comment syntax. For example `"//"`. + */ + line?: string; +} +/** +Comment or uncomment the current selection. Will use line comments +if available, otherwise falling back to block comments. +*/ +declare const toggleComment: StateCommand; +/** +Comment or uncomment the current selection using line comments. +The line comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +declare const toggleLineComment: StateCommand; +/** +Comment the current selection using line comments. +*/ +declare const lineComment: StateCommand; +/** +Uncomment the current selection using line comments. +*/ +declare const lineUncomment: StateCommand; +/** +Comment or uncomment the current selection using block comments. +The block comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +declare const toggleBlockComment: StateCommand; +/** +Comment the current selection using block comments. +*/ +declare const blockComment: StateCommand; +/** +Uncomment the current selection using block comments. +*/ +declare const blockUncomment: StateCommand; +/** +Comment or uncomment the lines around the current selection using +block comments. +*/ +declare const toggleBlockCommentByLine: StateCommand; + +/** +Transaction annotation that will prevent that transaction from +being combined with other transactions in the undo history. Given +`"before"`, it'll prevent merging with previous transactions. With +`"after"`, subsequent transactions won't be combined with this +one. With `"full"`, the transaction is isolated on both sides. +*/ +declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">; +/** +This facet provides a way to register functions that, given a +transaction, provide a set of effects that the history should +store when inverting the transaction. This can be used to +integrate some kinds of effects in the history, so that they can +be undone (and redone again). +*/ +declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect[], readonly ((tr: Transaction) => readonly StateEffect[])[]>; +interface HistoryConfig { + /** + The minimum depth (amount of events) to store. Defaults to 100. + */ + minDepth?: number; + /** + The maximum time (in milliseconds) that adjacent events can be + apart and still be grouped together. Defaults to 500. + */ + newGroupDelay?: number; + /** + By default, when close enough together in time, changes are + joined into an existing undo event if they touch any of the + changed ranges from that event. You can pass a custom predicate + here to influence that logic. + */ + joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean; +} +/** +Create a history extension with the given configuration. +*/ +declare function history(config?: HistoryConfig): Extension; +/** +The state field used to store the history data. Should probably +only be used when you want to +[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or +[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way +that preserves history. +*/ +declare const historyField: StateField; +/** +Undo a single group of history events. Returns false if no group +was available. +*/ +declare const undo: StateCommand; +/** +Redo a group of history events. Returns false if no group was +available. +*/ +declare const redo: StateCommand; +/** +Undo a change or selection change. +*/ +declare const undoSelection: StateCommand; +/** +Redo a change or selection change. +*/ +declare const redoSelection: StateCommand; +/** +The amount of undoable change events available in a given state. +*/ +declare const undoDepth: (state: EditorState) => number; +/** +The amount of redoable change events available in a given state. +*/ +declare const redoDepth: (state: EditorState) => number; +/** +Default key bindings for the undo history. + +- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo). +- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo). +- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection). +- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection). +*/ +declare const historyKeymap: readonly KeyBinding[]; + +/** +Move the selection one character to the left (which is backward in +left-to-right text, forward in right-to-left text). +*/ +declare const cursorCharLeft: Command; +/** +Move the selection one character to the right. +*/ +declare const cursorCharRight: Command; +/** +Move the selection one character forward. +*/ +declare const cursorCharForward: Command; +/** +Move the selection one character backward. +*/ +declare const cursorCharBackward: Command; +/** +Move the selection one character forward, in logical +(non-text-direction-aware) string index order. +*/ +declare const cursorCharForwardLogical: StateCommand; +/** +Move the selection one character backward, in logical string index +order. +*/ +declare const cursorCharBackwardLogical: StateCommand; +/** +Move the selection to the left across one group of word or +non-word (but also non-space) characters. +*/ +declare const cursorGroupLeft: Command; +/** +Move the selection one group to the right. +*/ +declare const cursorGroupRight: Command; +/** +Move the selection one group forward. +*/ +declare const cursorGroupForward: Command; +/** +Move the selection one group backward. +*/ +declare const cursorGroupBackward: Command; +/** +Move the cursor one group forward in the default Windows style, +where it moves to the start of the next group. +*/ +declare const cursorGroupForwardWin: Command; +/** +Move the selection one group or camel-case subword forward. +*/ +declare const cursorSubwordForward: Command; +/** +Move the selection one group or camel-case subword backward. +*/ +declare const cursorSubwordBackward: Command; +/** +Move the cursor over the next syntactic element to the left. +*/ +declare const cursorSyntaxLeft: Command; +/** +Move the cursor over the next syntactic element to the right. +*/ +declare const cursorSyntaxRight: Command; +/** +Move the selection one line up. +*/ +declare const cursorLineUp: Command; +/** +Move the selection one line down. +*/ +declare const cursorLineDown: Command; +/** +Move the selection one page up. +*/ +declare const cursorPageUp: Command; +/** +Move the selection one page down. +*/ +declare const cursorPageDown: Command; +/** +Move the selection to the next line wrap point, or to the end of +the line if there isn't one left on this line. +*/ +declare const cursorLineBoundaryForward: Command; +/** +Move the selection to previous line wrap point, or failing that to +the start of the line. If the line is indented, and the cursor +isn't already at the end of the indentation, this will move to the +end of the indentation instead of the start of the line. +*/ +declare const cursorLineBoundaryBackward: Command; +/** +Move the selection one line wrap point to the left. +*/ +declare const cursorLineBoundaryLeft: Command; +/** +Move the selection one line wrap point to the right. +*/ +declare const cursorLineBoundaryRight: Command; +/** +Move the selection to the start of the line. +*/ +declare const cursorLineStart: Command; +/** +Move the selection to the end of the line. +*/ +declare const cursorLineEnd: Command; +/** +Move the selection to the bracket matching the one it is currently +on, if any. +*/ +declare const cursorMatchingBracket: StateCommand; +/** +Extend the selection to the bracket matching the one the selection +head is currently on, if any. +*/ +declare const selectMatchingBracket: StateCommand; +/** +Move the selection head one character to the left, while leaving +the anchor in place. +*/ +declare const selectCharLeft: Command; +/** +Move the selection head one character to the right. +*/ +declare const selectCharRight: Command; +/** +Move the selection head one character forward. +*/ +declare const selectCharForward: Command; +/** +Move the selection head one character backward. +*/ +declare const selectCharBackward: Command; +/** +Move the selection head one character forward by logical +(non-direction aware) string index order. +*/ +declare const selectCharForwardLogical: StateCommand; +/** +Move the selection head one character backward by logical string +index order. +*/ +declare const selectCharBackwardLogical: StateCommand; +/** +Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to +the left. +*/ +declare const selectGroupLeft: Command; +/** +Move the selection head one group to the right. +*/ +declare const selectGroupRight: Command; +/** +Move the selection head one group forward. +*/ +declare const selectGroupForward: Command; +/** +Move the selection head one group backward. +*/ +declare const selectGroupBackward: Command; +/** +Move the selection head one group forward in the default Windows +style, skipping to the start of the next group. +*/ +declare const selectGroupForwardWin: Command; +/** +Move the selection head one group or camel-case subword forward. +*/ +declare const selectSubwordForward: Command; +/** +Move the selection head one group or subword backward. +*/ +declare const selectSubwordBackward: Command; +/** +Move the selection head over the next syntactic element to the left. +*/ +declare const selectSyntaxLeft: Command; +/** +Move the selection head over the next syntactic element to the right. +*/ +declare const selectSyntaxRight: Command; +/** +Move the selection head one line up. +*/ +declare const selectLineUp: Command; +/** +Move the selection head one line down. +*/ +declare const selectLineDown: Command; +/** +Move the selection head one page up. +*/ +declare const selectPageUp: Command; +/** +Move the selection head one page down. +*/ +declare const selectPageDown: Command; +/** +Move the selection head to the next line boundary. +*/ +declare const selectLineBoundaryForward: Command; +/** +Move the selection head to the previous line boundary. +*/ +declare const selectLineBoundaryBackward: Command; +/** +Move the selection head one line boundary to the left. +*/ +declare const selectLineBoundaryLeft: Command; +/** +Move the selection head one line boundary to the right. +*/ +declare const selectLineBoundaryRight: Command; +/** +Move the selection head to the start of the line. +*/ +declare const selectLineStart: Command; +/** +Move the selection head to the end of the line. +*/ +declare const selectLineEnd: Command; +/** +Move the selection to the start of the document. +*/ +declare const cursorDocStart: StateCommand; +/** +Move the selection to the end of the document. +*/ +declare const cursorDocEnd: StateCommand; +/** +Move the selection head to the start of the document. +*/ +declare const selectDocStart: StateCommand; +/** +Move the selection head to the end of the document. +*/ +declare const selectDocEnd: StateCommand; +/** +Select the entire document. +*/ +declare const selectAll: StateCommand; +/** +Expand the selection to cover entire lines. +*/ +declare const selectLine: StateCommand; +/** +Select the next syntactic construct that is larger than the +selection. Note that this will only work insofar as the language +[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full +syntax tree. +*/ +declare const selectParentSyntax: StateCommand; +/** +Expand the selection by adding a cursor above the heads of +currently selected ranges. +*/ +declare const addCursorAbove: Command; +/** +Expand the selection by adding a cursor below the heads of +currently selected ranges. +*/ +declare const addCursorBelow: Command; +/** +Simplify the current selection. When multiple ranges are selected, +reduce it to its main range. Otherwise, if the selection is +non-empty, convert it to a cursor selection. +*/ +declare const simplifySelection: StateCommand; +/** +Delete the selection, or, for cursor selections, the character or +indentation unit before the cursor. +*/ +declare const deleteCharBackward: Command; +/** +Delete the selection or the character before the cursor. Does not +implement any extended behavior like deleting whole indentation +units in one go. +*/ +declare const deleteCharBackwardStrict: Command; +/** +Delete the selection or the character after the cursor. +*/ +declare const deleteCharForward: Command; +/** +Delete the selection or backward until the end of the next +[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of +whitespace when they consist of a single space. +*/ +declare const deleteGroupBackward: StateCommand; +/** +Delete the selection or forward until the end of the next group. +*/ +declare const deleteGroupForward: StateCommand; +/** +Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) +that uses the Windows convention of also deleting the whitespace +after a word. +*/ +declare const deleteGroupForwardWin: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line. If the cursor is directly at the end of the +line, delete the line break after it. +*/ +declare const deleteToLineEnd: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line. If the cursor is directly at the start of the +line, delete the line break before it. +*/ +declare const deleteToLineStart: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line or the next line wrap before the cursor. +*/ +declare const deleteLineBoundaryBackward: Command; +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line or the next line wrap after the cursor. +*/ +declare const deleteLineBoundaryForward: Command; +/** +Delete all whitespace directly before a line end from the +document. +*/ +declare const deleteTrailingWhitespace: StateCommand; +/** +Replace each selection range with a line break, leaving the cursor +on the line before the break. +*/ +declare const splitLine: StateCommand; +/** +Flip the characters before and after the cursor(s). +*/ +declare const transposeChars: StateCommand; +/** +Move the selected lines up one line. +*/ +declare const moveLineUp: StateCommand; +/** +Move the selected lines down one line. +*/ +declare const moveLineDown: StateCommand; +/** +Create a copy of the selected lines. Keep the selection in the top copy. +*/ +declare const copyLineUp: StateCommand; +/** +Create a copy of the selected lines. Keep the selection in the bottom copy. +*/ +declare const copyLineDown: StateCommand; +/** +Delete selected lines. +*/ +declare const deleteLine: Command; +/** +Replace the selection with a newline. +*/ +declare const insertNewline: StateCommand; +/** +Replace the selection with a newline and the same amount of +indentation as the line above. +*/ +declare const insertNewlineKeepIndent: StateCommand; +/** +Replace the selection with a newline and indent the newly created +line(s). If the current line consists only of whitespace, this +will also delete that whitespace. When the cursor is between +matching brackets, an additional newline will be inserted after +the cursor. +*/ +declare const insertNewlineAndIndent: StateCommand; +/** +Create a blank, indented line below the current line. +*/ +declare const insertBlankLine: StateCommand; +/** +Auto-indent the selected lines. This uses the [indentation service +facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent +information. +*/ +declare const indentSelection: StateCommand; +/** +Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected +lines. +*/ +declare const indentMore: StateCommand; +/** +Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all +selected lines. +*/ +declare const indentLess: StateCommand; +/** +Enables or disables +[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this +prevents the editor's key bindings from capturing Tab or +Shift-Tab, making it possible for the user to move focus out of +the editor with the keyboard. +*/ +declare const toggleTabFocusMode: Command; +/** +Temporarily enables [tab-focus +mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until +another key is pressed. +*/ +declare const temporarilySetTabFocusMode: Command; +/** +Insert a tab character at the cursor or, if something is selected, +use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire +selection. +*/ +declare const insertTab: StateCommand; +/** +Array of key bindings containing the Emacs-style bindings that are +available on macOS by default. + + - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd) + - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine) + - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars) + - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) + - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) +*/ +declare const emacsStyleKeymap: readonly KeyBinding[]; +/** +An array of key bindings closely sticking to platform-standard or +widely used bindings. (This includes the bindings from +[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key` +property changed to `mac`.) + + - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift) + - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift) + - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift) + - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift) + - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent) + - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll) + - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) + - Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward). + - Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward). +*/ +declare const standardKeymap: readonly KeyBinding[]; +/** +The default keymap. Includes all bindings from +[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following: + +- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift) +- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift) +- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp) +- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown) +- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp) +- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown) +- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove). +- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow). +- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection) +- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine) +- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine) +- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax) +- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess) +- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) +- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection) +- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine) +- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket) +- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment). +- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment). +- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode). +*/ +declare const defaultKeymap: readonly KeyBinding[]; +/** +A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and +Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess). +Please see the [Tab example](../../examples/tab/) before using +this. +*/ +declare const indentWithTab: KeyBinding; + +export { type CommentTokens, addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection }; diff --git a/node_modules/@codemirror/commands/dist/index.js b/node_modules/@codemirror/commands/dist/index.js new file mode 100644 index 0000000..76811b3 --- /dev/null +++ b/node_modules/@codemirror/commands/dist/index.js @@ -0,0 +1,1795 @@ +import { Annotation, Facet, combineConfig, StateField, Transaction, ChangeSet, ChangeDesc, EditorSelection, StateEffect, Text, findClusterBreak, countColumn, CharCategory } from '@codemirror/state'; +import { EditorView, Direction } from '@codemirror/view'; +import { IndentContext, getIndentation, indentString, matchBrackets, syntaxTree, getIndentUnit, indentUnit } from '@codemirror/language'; +import { NodeProp } from '@lezer/common'; + +/** +Comment or uncomment the current selection. Will use line comments +if available, otherwise falling back to block comments. +*/ +const toggleComment = target => { + let { state } = target, line = state.doc.lineAt(state.selection.main.from), config = getConfig(target.state, line.from); + return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false; +}; +function command(f, option) { + return ({ state, dispatch }) => { + if (state.readOnly) + return false; + let tr = f(option, state); + if (!tr) + return false; + dispatch(state.update(tr)); + return true; + }; +} +/** +Comment or uncomment the current selection using line comments. +The line comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */); +/** +Comment the current selection using line comments. +*/ +const lineComment = /*@__PURE__*/command(changeLineComment, 1 /* CommentOption.Comment */); +/** +Uncomment the current selection using line comments. +*/ +const lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* CommentOption.Uncomment */); +/** +Comment or uncomment the current selection using block comments. +The block comment syntax is taken from the +[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language +data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). +*/ +const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */); +/** +Comment the current selection using block comments. +*/ +const blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* CommentOption.Comment */); +/** +Uncomment the current selection using block comments. +*/ +const blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* CommentOption.Uncomment */); +/** +Comment or uncomment the lines around the current selection using +block comments. +*/ +const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */); +function getConfig(state, pos) { + let data = state.languageDataAt("commentTokens", pos, 1); + return data.length ? data[0] : {}; +} +const SearchMargin = 50; +/** +Determines if the given range is block-commented in the given +state. +*/ +function findBlockComment(state, { open, close }, from, to) { + let textBefore = state.sliceDoc(from - SearchMargin, from); + let textAfter = state.sliceDoc(to, to + SearchMargin); + let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length; + let beforeOff = textBefore.length - spaceBefore; + if (textBefore.slice(beforeOff - open.length, beforeOff) == open && + textAfter.slice(spaceAfter, spaceAfter + close.length) == close) { + return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 }, + close: { pos: to + spaceAfter, margin: spaceAfter && 1 } }; + } + let startText, endText; + if (to - from <= 2 * SearchMargin) { + startText = endText = state.sliceDoc(from, to); + } + else { + startText = state.sliceDoc(from, from + SearchMargin); + endText = state.sliceDoc(to - SearchMargin, to); + } + let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length; + let endOff = endText.length - endSpace - close.length; + if (startText.slice(startSpace, startSpace + open.length) == open && + endText.slice(endOff, endOff + close.length) == close) { + return { open: { pos: from + startSpace + open.length, + margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 }, + close: { pos: to - endSpace - close.length, + margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } }; + } + return null; +} +function selectedLineRanges(state) { + let ranges = []; + for (let r of state.selection.ranges) { + let fromLine = state.doc.lineAt(r.from); + let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to); + if (toLine.from > fromLine.from && toLine.from == r.to) + toLine = r.to == fromLine.to + 1 ? fromLine : state.doc.lineAt(r.to - 1); + let last = ranges.length - 1; + if (last >= 0 && ranges[last].to > fromLine.from) + ranges[last].to = toLine.to; + else + ranges.push({ from: fromLine.from + /^\s*/.exec(fromLine.text)[0].length, to: toLine.to }); + } + return ranges; +} +// Performs toggle, comment and uncomment of block comments in +// languages that support them. +function changeBlockComment(option, state, ranges = state.selection.ranges) { + let tokens = ranges.map(r => getConfig(state, r.from).block); + if (!tokens.every(c => c)) + return null; + let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to)); + if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) { + return { changes: state.changes(ranges.map((range, i) => { + if (comments[i]) + return []; + return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }]; + })) }; + } + else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) { + let changes = []; + for (let i = 0, comment; i < comments.length; i++) + if (comment = comments[i]) { + let token = tokens[i], { open, close } = comment; + changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length }); + } + return { changes }; + } + return null; +} +// Performs toggle, comment and uncomment of line comments. +function changeLineComment(option, state, ranges = state.selection.ranges) { + let lines = []; + let prevLine = -1; + ranges: for (let { from, to } of ranges) { + let startI = lines.length, minIndent = 1e9, token; + for (let pos = from; pos <= to;) { + let line = state.doc.lineAt(pos); + if (token == undefined) { + token = getConfig(state, line.from).line; + if (!token) + continue ranges; + } + if (line.from > prevLine && (from == to || to > line.from)) { + prevLine = line.from; + let indent = /^\s*/.exec(line.text)[0].length; + let empty = indent == line.length; + let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1; + if (indent < line.text.length && indent < minIndent) + minIndent = indent; + lines.push({ line, comment, token, indent, empty, single: false }); + } + pos = line.to + 1; + } + if (minIndent < 1e9) + for (let i = startI; i < lines.length; i++) + if (lines[i].indent < lines[i].line.text.length) + lines[i].indent = minIndent; + if (lines.length == startI + 1) + lines[startI].single = true; + } + if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) { + let changes = []; + for (let { line, token, indent, empty, single } of lines) + if (single || !empty) + changes.push({ from: line.from + indent, insert: token + " " }); + let changeSet = state.changes(changes); + return { changes: changeSet, selection: state.selection.map(changeSet, 1) }; + } + else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) { + let changes = []; + for (let { line, comment, token } of lines) + if (comment >= 0) { + let from = line.from + comment, to = from + token.length; + if (line.text[to - line.from] == " ") + to++; + changes.push({ from, to }); + } + return { changes }; + } + return null; +} + +const fromHistory = /*@__PURE__*/Annotation.define(); +/** +Transaction annotation that will prevent that transaction from +being combined with other transactions in the undo history. Given +`"before"`, it'll prevent merging with previous transactions. With +`"after"`, subsequent transactions won't be combined with this +one. With `"full"`, the transaction is isolated on both sides. +*/ +const isolateHistory = /*@__PURE__*/Annotation.define(); +/** +This facet provides a way to register functions that, given a +transaction, provide a set of effects that the history should +store when inverting the transaction. This can be used to +integrate some kinds of effects in the history, so that they can +be undone (and redone again). +*/ +const invertedEffects = /*@__PURE__*/Facet.define(); +const historyConfig = /*@__PURE__*/Facet.define({ + combine(configs) { + return combineConfig(configs, { + minDepth: 100, + newGroupDelay: 500, + joinToEvent: (_t, isAdjacent) => isAdjacent, + }, { + minDepth: Math.max, + newGroupDelay: Math.min, + joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj) + }); + } +}); +const historyField_ = /*@__PURE__*/StateField.define({ + create() { + return HistoryState.empty; + }, + update(state, tr) { + let config = tr.state.facet(historyConfig); + let fromHist = tr.annotation(fromHistory); + if (fromHist) { + let item = HistEvent.fromTransaction(tr, fromHist.selection), from = fromHist.side; + let other = from == 0 /* BranchName.Done */ ? state.undone : state.done; + if (item) + other = updateBranch(other, other.length, config.minDepth, item); + else + other = addSelection(other, tr.startState.selection); + return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest); + } + let isolate = tr.annotation(isolateHistory); + if (isolate == "full" || isolate == "before") + state = state.isolate(); + if (tr.annotation(Transaction.addToHistory) === false) + return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state; + let event = HistEvent.fromTransaction(tr); + let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent); + if (event) + state = state.addChanges(event, time, userEvent, config, tr); + else if (tr.selection) + state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay); + if (isolate == "full" || isolate == "after") + state = state.isolate(); + return state; + }, + toJSON(value) { + return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) }; + }, + fromJSON(json) { + return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON)); + } +}); +/** +Create a history extension with the given configuration. +*/ +function history(config = {}) { + return [ + historyField_, + historyConfig.of(config), + EditorView.domEventHandlers({ + beforeinput(e, view) { + let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null; + if (!command) + return false; + e.preventDefault(); + return command(view); + } + }) + ]; +} +/** +The state field used to store the history data. Should probably +only be used when you want to +[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or +[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way +that preserves history. +*/ +const historyField = historyField_; +function cmd(side, selection) { + return function ({ state, dispatch }) { + if (!selection && state.readOnly) + return false; + let historyState = state.field(historyField_, false); + if (!historyState) + return false; + let tr = historyState.pop(side, state, selection); + if (!tr) + return false; + dispatch(tr); + return true; + }; +} +/** +Undo a single group of history events. Returns false if no group +was available. +*/ +const undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false); +/** +Redo a group of history events. Returns false if no group was +available. +*/ +const redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false); +/** +Undo a change or selection change. +*/ +const undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true); +/** +Redo a change or selection change. +*/ +const redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true); +function depth(side) { + return function (state) { + let histState = state.field(historyField_, false); + if (!histState) + return 0; + let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone; + return branch.length - (branch.length && !branch[0].changes ? 1 : 0); + }; +} +/** +The amount of undoable change events available in a given state. +*/ +const undoDepth = /*@__PURE__*/depth(0 /* BranchName.Done */); +/** +The amount of redoable change events available in a given state. +*/ +const redoDepth = /*@__PURE__*/depth(1 /* BranchName.Undone */); +// History events store groups of changes or effects that need to be +// undone/redone together. +class HistEvent { + constructor( + // The changes in this event. Normal events hold at least one + // change or effect. But it may be necessary to store selection + // events before the first change, in which case a special type of + // instance is created which doesn't hold any changes, with + // changes == startSelection == undefined + changes, + // The effects associated with this event + effects, + // Accumulated mapping (from addToHistory==false) that should be + // applied to events below this one. + mapped, + // The selection before this event + startSelection, + // Stores selection changes after this event, to be used for + // selection undo/redo. + selectionsAfter) { + this.changes = changes; + this.effects = effects; + this.mapped = mapped; + this.startSelection = startSelection; + this.selectionsAfter = selectionsAfter; + } + setSelAfter(after) { + return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after); + } + toJSON() { + var _a, _b, _c; + return { + changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(), + mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(), + startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(), + selectionsAfter: this.selectionsAfter.map(s => s.toJSON()) + }; + } + static fromJSON(json) { + return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON)); + } + // This does not check `addToHistory` and such, it assumes the + // transaction needs to be converted to an item. Returns null when + // there are no changes or effects in the transaction. + static fromTransaction(tr, selection) { + let effects = none; + for (let invert of tr.startState.facet(invertedEffects)) { + let result = invert(tr); + if (result.length) + effects = effects.concat(result); + } + if (!effects.length && tr.changes.empty) + return null; + return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none); + } + static selection(selections) { + return new HistEvent(undefined, none, undefined, undefined, selections); + } +} +function updateBranch(branch, to, maxLen, newEvent) { + let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0; + let newBranch = branch.slice(start, to); + newBranch.push(newEvent); + return newBranch; +} +function isAdjacent(a, b) { + let ranges = [], isAdjacent = false; + a.iterChangedRanges((f, t) => ranges.push(f, t)); + b.iterChangedRanges((_f, _t, f, t) => { + for (let i = 0; i < ranges.length;) { + let from = ranges[i++], to = ranges[i++]; + if (t >= from && f <= to) + isAdjacent = true; + } + }); + return isAdjacent; +} +function eqSelectionShape(a, b) { + return a.ranges.length == b.ranges.length && + a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0; +} +function conc(a, b) { + return !a.length ? b : !b.length ? a : a.concat(b); +} +const none = []; +const MaxSelectionsPerEvent = 200; +function addSelection(branch, selection) { + if (!branch.length) { + return [HistEvent.selection([selection])]; + } + else { + let lastEvent = branch[branch.length - 1]; + let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent)); + if (sels.length && sels[sels.length - 1].eq(selection)) + return branch; + sels.push(selection); + return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels)); + } +} +// Assumes the top item has one or more selectionAfter values +function popSelection(branch) { + let last = branch[branch.length - 1]; + let newBranch = branch.slice(); + newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1)); + return newBranch; +} +// Add a mapping to the top event in the given branch. If this maps +// away all the changes and effects in that item, drop it and +// propagate the mapping to the next item. +function addMappingToBranch(branch, mapping) { + if (!branch.length) + return branch; + let length = branch.length, selections = none; + while (length) { + let event = mapEvent(branch[length - 1], mapping, selections); + if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping + let result = branch.slice(0, length); + result[length - 1] = event; + return result; + } + else { // Drop this event, since there's no changes or effects left + mapping = event.mapped; + length--; + selections = event.selectionsAfter; + } + } + return selections.length ? [HistEvent.selection(selections)] : none; +} +function mapEvent(event, mapping, extraSelections) { + let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections); + // Change-less events don't store mappings (they are always the last event in a branch) + if (!event.changes) + return HistEvent.selection(selections); + let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true); + let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before; + return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections); +} +const joinableUserEvent = /^(input\.type|delete)($|\.)/; +class HistoryState { + constructor(done, undone, prevTime = 0, prevUserEvent = undefined) { + this.done = done; + this.undone = undone; + this.prevTime = prevTime; + this.prevUserEvent = prevUserEvent; + } + isolate() { + return this.prevTime ? new HistoryState(this.done, this.undone) : this; + } + addChanges(event, time, userEvent, config, tr) { + let done = this.done, lastEvent = done[done.length - 1]; + if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes && + (!userEvent || joinableUserEvent.test(userEvent)) && + ((!lastEvent.selectionsAfter.length && + time - this.prevTime < config.newGroupDelay && + config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) || + // For compose (but not compose.start) events, always join with previous event + userEvent == "input.type.compose")) { + done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(StateEffect.mapEffects(event.effects, lastEvent.changes), lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none)); + } + else { + done = updateBranch(done, done.length, config.minDepth, event); + } + return new HistoryState(done, none, time, userEvent); + } + addSelection(selection, time, userEvent, newGroupDelay) { + let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none; + if (last.length > 0 && + time - this.prevTime < newGroupDelay && + userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) && + eqSelectionShape(last[last.length - 1], selection)) + return this; + return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent); + } + addMapping(mapping) { + return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent); + } + pop(side, state, onlySelection) { + let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone; + if (branch.length == 0) + return null; + let event = branch[branch.length - 1], selection = event.selectionsAfter[0] || + (event.startSelection ? event.startSelection.map(event.changes.invertedDesc, 1) : state.selection); + if (onlySelection && event.selectionsAfter.length) { + return state.update({ + selection: event.selectionsAfter[event.selectionsAfter.length - 1], + annotations: fromHistory.of({ side, rest: popSelection(branch), selection }), + userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo", + scrollIntoView: true + }); + } + else if (!event.changes) { + return null; + } + else { + let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1); + if (event.mapped) + rest = addMappingToBranch(rest, event.mapped); + return state.update({ + changes: event.changes, + selection: event.startSelection, + effects: event.effects, + annotations: fromHistory.of({ side, rest, selection }), + filter: false, + userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo", + scrollIntoView: true + }); + } + } +} +HistoryState.empty = /*@__PURE__*/new HistoryState(none, none); +/** +Default key bindings for the undo history. + +- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo). +- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo). +- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection). +- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection). +*/ +const historyKeymap = [ + { key: "Mod-z", run: undo, preventDefault: true }, + { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true }, + { linux: "Ctrl-Shift-z", run: redo, preventDefault: true }, + { key: "Mod-u", run: undoSelection, preventDefault: true }, + { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true } +]; + +function updateSel(sel, by) { + return EditorSelection.create(sel.ranges.map(by), sel.mainIndex); +} +function setSel(state, selection) { + return state.update({ selection, scrollIntoView: true, userEvent: "select" }); +} +function moveSel({ state, dispatch }, how) { + let selection = updateSel(state.selection, how); + if (selection.eq(state.selection, true)) + return false; + dispatch(setSel(state, selection)); + return true; +} +function rangeEnd(range, forward) { + return EditorSelection.cursor(forward ? range.to : range.from); +} +function cursorByChar(view, forward) { + return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward)); +} +function ltrAtCursor(view) { + return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR; +} +/** +Move the selection one character to the left (which is backward in +left-to-right text, forward in right-to-left text). +*/ +const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view)); +/** +Move the selection one character to the right. +*/ +const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view)); +/** +Move the selection one character forward. +*/ +const cursorCharForward = view => cursorByChar(view, true); +/** +Move the selection one character backward. +*/ +const cursorCharBackward = view => cursorByChar(view, false); +function byCharLogical(state, range, forward) { + let pos = range.head, line = state.doc.lineAt(pos); + if (pos == (forward ? line.to : line.from)) + pos = forward ? Math.min(state.doc.length, line.to + 1) : Math.max(0, line.from - 1); + else + pos = line.from + findClusterBreak(line.text, pos - line.from, forward); + return EditorSelection.cursor(pos, forward ? -1 : 1); +} +function moveByCharLogical(target, forward) { + return moveSel(target, range => range.empty ? byCharLogical(target.state, range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection one character forward, in logical +(non-text-direction-aware) string index order. +*/ +const cursorCharForwardLogical = target => moveByCharLogical(target, true); +/** +Move the selection one character backward, in logical string index +order. +*/ +const cursorCharBackwardLogical = target => moveByCharLogical(target, false); +function cursorByGroup(view, forward) { + return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection to the left across one group of word or +non-word (but also non-space) characters. +*/ +const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view)); +/** +Move the selection one group to the right. +*/ +const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view)); +/** +Move the selection one group forward. +*/ +const cursorGroupForward = view => cursorByGroup(view, true); +/** +Move the selection one group backward. +*/ +const cursorGroupBackward = view => cursorByGroup(view, false); +function toGroupStart(view, pos, start) { + let categorize = view.state.charCategorizer(pos); + let cat = categorize(start), initial = cat != CharCategory.Space; + return (next) => { + let nextCat = categorize(next); + if (nextCat != CharCategory.Space) + return initial && nextCat == cat; + initial = false; + return true; + }; +} +/** +Move the cursor one group forward in the default Windows style, +where it moves to the start of the next group. +*/ +const cursorGroupForwardWin = view => { + return moveSel(view, range => range.empty + ? view.moveByChar(range, true, start => toGroupStart(view, range.head, start)) + : rangeEnd(range, true)); +}; +const segmenter = typeof Intl != "undefined" && Intl.Segmenter ? + /*@__PURE__*/new (Intl.Segmenter)(undefined, { granularity: "word" }) : null; +function moveBySubword(view, range, forward) { + let categorize = view.state.charCategorizer(range.from); + let cat = CharCategory.Space, pos = range.from, steps = 0; + let done = false, sawUpper = false, sawLower = false; + let step = (next) => { + if (done) + return false; + pos += forward ? next.length : -next.length; + let nextCat = categorize(next), ahead; + if (nextCat == CharCategory.Word && next.charCodeAt(0) < 128 && /[\W_]/.test(next)) + nextCat = -1; // Treat word punctuation specially + if (cat == CharCategory.Space) + cat = nextCat; + if (cat != nextCat) + return false; + if (cat == CharCategory.Word) { + if (next.toLowerCase() == next) { + if (!forward && sawUpper) + return false; + sawLower = true; + } + else if (sawLower) { + if (forward) + return false; + done = true; + } + else { + if (sawUpper && forward && categorize(ahead = view.state.sliceDoc(pos, pos + 1)) == CharCategory.Word && + ahead.toLowerCase() == ahead) + return false; + sawUpper = true; + } + } + steps++; + return true; + }; + let end = view.moveByChar(range, forward, start => { + step(start); + return step; + }); + if (segmenter && cat == CharCategory.Word && end.from == range.from + steps * (forward ? 1 : -1)) { + let from = Math.min(range.head, end.head), to = Math.max(range.head, end.head); + let skipped = view.state.sliceDoc(from, to); + if (skipped.length > 1 && /[\u4E00-\uffff]/.test(skipped)) { + let segments = Array.from(segmenter.segment(skipped)); + if (segments.length > 1) { + if (forward) + return EditorSelection.cursor(range.head + segments[1].index, -1); + return EditorSelection.cursor(end.head + segments[segments.length - 1].index, 1); + } + } + } + return end; +} +function cursorBySubword(view, forward) { + return moveSel(view, range => range.empty ? moveBySubword(view, range, forward) : rangeEnd(range, forward)); +} +/** +Move the selection one group or camel-case subword forward. +*/ +const cursorSubwordForward = view => cursorBySubword(view, true); +/** +Move the selection one group or camel-case subword backward. +*/ +const cursorSubwordBackward = view => cursorBySubword(view, false); +function interestingNode(state, node, bracketProp) { + if (node.type.prop(bracketProp)) + return true; + let len = node.to - node.from; + return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild; +} +function moveBySyntax(state, start, forward) { + let pos = syntaxTree(state).resolveInner(start.head); + let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy; + // Scan forward through child nodes to see if there's an interesting + // node ahead. + for (let at = start.head;;) { + let next = forward ? pos.childAfter(at) : pos.childBefore(at); + if (!next) + break; + if (interestingNode(state, next, bracketProp)) + pos = next; + else + at = forward ? next.to : next.from; + } + let bracket = pos.type.prop(bracketProp), match, newPos; + if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched) + newPos = forward ? match.end.to : match.end.from; + else + newPos = forward ? pos.to : pos.from; + return EditorSelection.cursor(newPos, forward ? -1 : 1); +} +/** +Move the cursor over the next syntactic element to the left. +*/ +const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view))); +/** +Move the cursor over the next syntactic element to the right. +*/ +const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view))); +function cursorByLine(view, forward) { + return moveSel(view, range => { + if (!range.empty) + return rangeEnd(range, forward); + let moved = view.moveVertically(range, forward); + return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward); + }); +} +/** +Move the selection one line up. +*/ +const cursorLineUp = view => cursorByLine(view, false); +/** +Move the selection one line down. +*/ +const cursorLineDown = view => cursorByLine(view, true); +function pageInfo(view) { + let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2; + let marginTop = 0, marginBottom = 0, height; + if (selfScroll) { + for (let source of view.state.facet(EditorView.scrollMargins)) { + let margins = source(view); + if (margins === null || margins === void 0 ? void 0 : margins.top) + marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop); + if (margins === null || margins === void 0 ? void 0 : margins.bottom) + marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom); + } + height = view.scrollDOM.clientHeight - marginTop - marginBottom; + } + else { + height = (view.dom.ownerDocument.defaultView || window).innerHeight; + } + return { marginTop, marginBottom, selfScroll, + height: Math.max(view.defaultLineHeight, height - 5) }; +} +function cursorByPage(view, forward) { + let page = pageInfo(view); + let { state } = view, selection = updateSel(state.selection, range => { + return range.empty ? view.moveVertically(range, forward, page.height) + : rangeEnd(range, forward); + }); + if (selection.eq(state.selection)) + return false; + let effect; + if (page.selfScroll) { + let startPos = view.coordsAtPos(state.selection.main.head); + let scrollRect = view.scrollDOM.getBoundingClientRect(); + let scrollTop = scrollRect.top + page.marginTop, scrollBottom = scrollRect.bottom - page.marginBottom; + if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom) + effect = EditorView.scrollIntoView(selection.main.head, { y: "start", yMargin: startPos.top - scrollTop }); + } + view.dispatch(setSel(state, selection), { effects: effect }); + return true; +} +/** +Move the selection one page up. +*/ +const cursorPageUp = view => cursorByPage(view, false); +/** +Move the selection one page down. +*/ +const cursorPageDown = view => cursorByPage(view, true); +function moveByLineBoundary(view, start, forward) { + let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward); + if (moved.head == start.head && moved.head != (forward ? line.to : line.from)) + moved = view.moveToLineBoundary(start, forward, false); + if (!forward && moved.head == line.from && line.length) { + let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length; + if (space && start.head != line.from + space) + moved = EditorSelection.cursor(line.from + space); + } + return moved; +} +/** +Move the selection to the next line wrap point, or to the end of +the line if there isn't one left on this line. +*/ +const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true)); +/** +Move the selection to previous line wrap point, or failing that to +the start of the line. If the line is indented, and the cursor +isn't already at the end of the indentation, this will move to the +end of the indentation instead of the start of the line. +*/ +const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false)); +/** +Move the selection one line wrap point to the left. +*/ +const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view))); +/** +Move the selection one line wrap point to the right. +*/ +const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view))); +/** +Move the selection to the start of the line. +*/ +const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1)); +/** +Move the selection to the end of the line. +*/ +const cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1)); +function toMatchingBracket(state, dispatch, extend) { + let found = false, selection = updateSel(state.selection, range => { + let matching = matchBrackets(state, range.head, -1) + || matchBrackets(state, range.head, 1) + || (range.head > 0 && matchBrackets(state, range.head - 1, 1)) + || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1)); + if (!matching || !matching.end) + return range; + found = true; + let head = matching.start.from == range.head ? matching.end.to : matching.end.from; + return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head); + }); + if (!found) + return false; + dispatch(setSel(state, selection)); + return true; +} +/** +Move the selection to the bracket matching the one it is currently +on, if any. +*/ +const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false); +/** +Extend the selection to the bracket matching the one the selection +head is currently on, if any. +*/ +const selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, true); +function extendSel(target, how) { + let selection = updateSel(target.state.selection, range => { + let head = how(range); + return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined, head.assoc); + }); + if (selection.eq(target.state.selection)) + return false; + target.dispatch(setSel(target.state, selection)); + return true; +} +function selectByChar(view, forward) { + return extendSel(view, range => view.moveByChar(range, forward)); +} +/** +Move the selection head one character to the left, while leaving +the anchor in place. +*/ +const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view)); +/** +Move the selection head one character to the right. +*/ +const selectCharRight = view => selectByChar(view, ltrAtCursor(view)); +/** +Move the selection head one character forward. +*/ +const selectCharForward = view => selectByChar(view, true); +/** +Move the selection head one character backward. +*/ +const selectCharBackward = view => selectByChar(view, false); +/** +Move the selection head one character forward by logical +(non-direction aware) string index order. +*/ +const selectCharForwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, true)); +/** +Move the selection head one character backward by logical string +index order. +*/ +const selectCharBackwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, false)); +function selectByGroup(view, forward) { + return extendSel(view, range => view.moveByGroup(range, forward)); +} +/** +Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to +the left. +*/ +const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view)); +/** +Move the selection head one group to the right. +*/ +const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view)); +/** +Move the selection head one group forward. +*/ +const selectGroupForward = view => selectByGroup(view, true); +/** +Move the selection head one group backward. +*/ +const selectGroupBackward = view => selectByGroup(view, false); +/** +Move the selection head one group forward in the default Windows +style, skipping to the start of the next group. +*/ +const selectGroupForwardWin = view => { + return extendSel(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start))); +}; +function selectBySubword(view, forward) { + return extendSel(view, range => moveBySubword(view, range, forward)); +} +/** +Move the selection head one group or camel-case subword forward. +*/ +const selectSubwordForward = view => selectBySubword(view, true); +/** +Move the selection head one group or subword backward. +*/ +const selectSubwordBackward = view => selectBySubword(view, false); +/** +Move the selection head over the next syntactic element to the left. +*/ +const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view))); +/** +Move the selection head over the next syntactic element to the right. +*/ +const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view))); +function selectByLine(view, forward) { + return extendSel(view, range => view.moveVertically(range, forward)); +} +/** +Move the selection head one line up. +*/ +const selectLineUp = view => selectByLine(view, false); +/** +Move the selection head one line down. +*/ +const selectLineDown = view => selectByLine(view, true); +function selectByPage(view, forward) { + return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height)); +} +/** +Move the selection head one page up. +*/ +const selectPageUp = view => selectByPage(view, false); +/** +Move the selection head one page down. +*/ +const selectPageDown = view => selectByPage(view, true); +/** +Move the selection head to the next line boundary. +*/ +const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true)); +/** +Move the selection head to the previous line boundary. +*/ +const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false)); +/** +Move the selection head one line boundary to the left. +*/ +const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view))); +/** +Move the selection head one line boundary to the right. +*/ +const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view))); +/** +Move the selection head to the start of the line. +*/ +const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from)); +/** +Move the selection head to the end of the line. +*/ +const selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to)); +/** +Move the selection to the start of the document. +*/ +const cursorDocStart = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: 0 })); + return true; +}; +/** +Move the selection to the end of the document. +*/ +const cursorDocEnd = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.doc.length })); + return true; +}; +/** +Move the selection head to the start of the document. +*/ +const selectDocStart = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 })); + return true; +}; +/** +Move the selection head to the end of the document. +*/ +const selectDocEnd = ({ state, dispatch }) => { + dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length })); + return true; +}; +/** +Select the entire document. +*/ +const selectAll = ({ state, dispatch }) => { + dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: "select" })); + return true; +}; +/** +Expand the selection to cover entire lines. +*/ +const selectLine = ({ state, dispatch }) => { + let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length))); + dispatch(state.update({ selection: EditorSelection.create(ranges), userEvent: "select" })); + return true; +}; +/** +Select the next syntactic construct that is larger than the +selection. Note that this will only work insofar as the language +[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full +syntax tree. +*/ +const selectParentSyntax = ({ state, dispatch }) => { + let selection = updateSel(state.selection, range => { + let tree = syntaxTree(state), stack = tree.resolveStack(range.from, 1); + if (range.empty) { + let stackBefore = tree.resolveStack(range.from, -1); + if (stackBefore.node.from >= stack.node.from && stackBefore.node.to <= stack.node.to) + stack = stackBefore; + } + for (let cur = stack; cur; cur = cur.next) { + let { node } = cur; + if (((node.from < range.from && node.to >= range.to) || + (node.to > range.to && node.from <= range.from)) && + cur.next) + return EditorSelection.range(node.to, node.from); + } + return range; + }); + if (selection.eq(state.selection)) + return false; + dispatch(setSel(state, selection)); + return true; +}; +function addCursorVertically(view, forward) { + let { state } = view, sel = state.selection, ranges = state.selection.ranges.slice(); + for (let range of state.selection.ranges) { + let line = state.doc.lineAt(range.head); + if (forward ? line.to < view.state.doc.length : line.from > 0) + for (let cur = range;;) { + let next = view.moveVertically(cur, forward); + if (next.head < line.from || next.head > line.to) { + if (!ranges.some(r => r.head == next.head)) + ranges.push(next); + break; + } + else if (next.head == cur.head) { + break; + } + else { + cur = next; + } + } + } + if (ranges.length == sel.ranges.length) + return false; + view.dispatch(setSel(state, EditorSelection.create(ranges, ranges.length - 1))); + return true; +} +/** +Expand the selection by adding a cursor above the heads of +currently selected ranges. +*/ +const addCursorAbove = view => addCursorVertically(view, false); +/** +Expand the selection by adding a cursor below the heads of +currently selected ranges. +*/ +const addCursorBelow = view => addCursorVertically(view, true); +/** +Simplify the current selection. When multiple ranges are selected, +reduce it to its main range. Otherwise, if the selection is +non-empty, convert it to a cursor selection. +*/ +const simplifySelection = ({ state, dispatch }) => { + let cur = state.selection, selection = null; + if (cur.ranges.length > 1) + selection = EditorSelection.create([cur.main]); + else if (!cur.main.empty) + selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]); + if (!selection) + return false; + dispatch(setSel(state, selection)); + return true; +}; +function deleteBy(target, by) { + if (target.state.readOnly) + return false; + let event = "delete.selection", { state } = target; + let changes = state.changeByRange(range => { + let { from, to } = range; + if (from == to) { + let towards = by(range); + if (towards < from) { + event = "delete.backward"; + towards = skipAtomic(target, towards, false); + } + else if (towards > from) { + event = "delete.forward"; + towards = skipAtomic(target, towards, true); + } + from = Math.min(from, towards); + to = Math.max(to, towards); + } + else { + from = skipAtomic(target, from, false); + to = skipAtomic(target, to, true); + } + return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from, from < range.head ? -1 : 1) }; + }); + if (changes.changes.empty) + return false; + target.dispatch(state.update(changes, { + scrollIntoView: true, + userEvent: event, + effects: event == "delete.selection" ? EditorView.announce.of(state.phrase("Selection deleted")) : undefined + })); + return true; +} +function skipAtomic(target, pos, forward) { + if (target instanceof EditorView) + for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target))) + ranges.between(pos, pos, (from, to) => { + if (from < pos && to > pos) + pos = forward ? to : from; + }); + return pos; +} +const deleteByChar = (target, forward, byIndentUnit) => deleteBy(target, range => { + let pos = range.from, { state } = target, line = state.doc.lineAt(pos), before, targetPos; + if (byIndentUnit && !forward && pos > line.from && pos < line.from + 200 && + !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) { + if (before[before.length - 1] == "\t") + return pos - 1; + let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state); + for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++) + pos--; + targetPos = pos; + } + else { + targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from; + if (targetPos == pos && line.number != (forward ? state.doc.lines : 1)) + targetPos += forward ? 1 : -1; + else if (!forward && /[\ufe00-\ufe0f]/.test(line.text.slice(targetPos - line.from, pos - line.from))) + targetPos = findClusterBreak(line.text, targetPos - line.from, false, false) + line.from; + } + return targetPos; +}); +/** +Delete the selection, or, for cursor selections, the character or +indentation unit before the cursor. +*/ +const deleteCharBackward = view => deleteByChar(view, false, true); +/** +Delete the selection or the character before the cursor. Does not +implement any extended behavior like deleting whole indentation +units in one go. +*/ +const deleteCharBackwardStrict = view => deleteByChar(view, false, false); +/** +Delete the selection or the character after the cursor. +*/ +const deleteCharForward = view => deleteByChar(view, true, false); +const deleteByGroup = (target, forward) => deleteBy(target, range => { + let pos = range.head, { state } = target, line = state.doc.lineAt(pos); + let categorize = state.charCategorizer(pos); + for (let cat = null;;) { + if (pos == (forward ? line.to : line.from)) { + if (pos == range.head && line.number != (forward ? state.doc.lines : 1)) + pos += forward ? 1 : -1; + break; + } + let next = findClusterBreak(line.text, pos - line.from, forward) + line.from; + let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from); + let nextCat = categorize(nextChar); + if (cat != null && nextCat != cat) + break; + if (nextChar != " " || pos != range.head) + cat = nextCat; + pos = next; + } + return pos; +}); +/** +Delete the selection or backward until the end of the next +[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of +whitespace when they consist of a single space. +*/ +const deleteGroupBackward = target => deleteByGroup(target, false); +/** +Delete the selection or forward until the end of the next group. +*/ +const deleteGroupForward = target => deleteByGroup(target, true); +/** +Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) +that uses the Windows convention of also deleting the whitespace +after a word. +*/ +const deleteGroupForwardWin = view => deleteBy(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)).head); +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line. If the cursor is directly at the end of the +line, delete the line break after it. +*/ +const deleteToLineEnd = view => deleteBy(view, range => { + let lineEnd = view.lineBlockAt(range.head).to; + return range.head < lineEnd ? lineEnd : Math.min(view.state.doc.length, range.head + 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line. If the cursor is directly at the start of the +line, delete the line break before it. +*/ +const deleteToLineStart = view => deleteBy(view, range => { + let lineStart = view.lineBlockAt(range.head).from; + return range.head > lineStart ? lineStart : Math.max(0, range.head - 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the start of the line or the next line wrap before the cursor. +*/ +const deleteLineBoundaryBackward = view => deleteBy(view, range => { + let lineStart = view.moveToLineBoundary(range, false).head; + return range.head > lineStart ? lineStart : Math.max(0, range.head - 1); +}); +/** +Delete the selection, or, if it is a cursor selection, delete to +the end of the line or the next line wrap after the cursor. +*/ +const deleteLineBoundaryForward = view => deleteBy(view, range => { + let lineStart = view.moveToLineBoundary(range, true).head; + return range.head < lineStart ? lineStart : Math.min(view.state.doc.length, range.head + 1); +}); +/** +Delete all whitespace directly before a line end from the +document. +*/ +const deleteTrailingWhitespace = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let changes = []; + for (let pos = 0, prev = "", iter = state.doc.iter();;) { + iter.next(); + if (iter.lineBreak || iter.done) { + let trailing = prev.search(/\s+$/); + if (trailing > -1) + changes.push({ from: pos - (prev.length - trailing), to: pos }); + if (iter.done) + break; + prev = ""; + } + else { + prev = iter.value; + } + pos += iter.value.length; + } + if (!changes.length) + return false; + dispatch(state.update({ changes, userEvent: "delete" })); + return true; +}; +/** +Replace each selection range with a line break, leaving the cursor +on the line before the break. +*/ +const splitLine = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let changes = state.changeByRange(range => { + return { changes: { from: range.from, to: range.to, insert: Text.of(["", ""]) }, + range: EditorSelection.cursor(range.from) }; + }); + dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Flip the characters before and after the cursor(s). +*/ +const transposeChars = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let changes = state.changeByRange(range => { + if (!range.empty || range.from == 0 || range.from == state.doc.length) + return { range }; + let pos = range.from, line = state.doc.lineAt(pos); + let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from; + let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from; + return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) }, + range: EditorSelection.cursor(to) }; + }); + if (changes.changes.empty) + return false; + dispatch(state.update(changes, { scrollIntoView: true, userEvent: "move.character" })); + return true; +}; +function selectedLineBlocks(state) { + let blocks = [], upto = -1; + for (let range of state.selection.ranges) { + let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to); + if (!range.empty && range.to == endLine.from) + endLine = state.doc.lineAt(range.to - 1); + if (upto >= startLine.number) { + let prev = blocks[blocks.length - 1]; + prev.to = endLine.to; + prev.ranges.push(range); + } + else { + blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] }); + } + upto = endLine.number + 1; + } + return blocks; +} +function moveLine(state, dispatch, forward) { + if (state.readOnly) + return false; + let changes = [], ranges = []; + for (let block of selectedLineBlocks(state)) { + if (forward ? block.to == state.doc.length : block.from == 0) + continue; + let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1); + let size = nextLine.length + 1; + if (forward) { + changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak }); + for (let r of block.ranges) + ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size))); + } + else { + changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text }); + for (let r of block.ranges) + ranges.push(EditorSelection.range(r.anchor - size, r.head - size)); + } + } + if (!changes.length) + return false; + dispatch(state.update({ + changes, + scrollIntoView: true, + selection: EditorSelection.create(ranges, state.selection.mainIndex), + userEvent: "move.line" + })); + return true; +} +/** +Move the selected lines up one line. +*/ +const moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false); +/** +Move the selected lines down one line. +*/ +const moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true); +function copyLine(state, dispatch, forward) { + if (state.readOnly) + return false; + let changes = []; + for (let block of selectedLineBlocks(state)) { + if (forward) + changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak }); + else + changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) }); + } + let changeSet = state.changes(changes); + dispatch(state.update({ + changes: changeSet, + selection: state.selection.map(changeSet, forward ? 1 : -1), + scrollIntoView: true, + userEvent: "input.copyline" + })); + return true; +} +/** +Create a copy of the selected lines. Keep the selection in the top copy. +*/ +const copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false); +/** +Create a copy of the selected lines. Keep the selection in the bottom copy. +*/ +const copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true); +/** +Delete selected lines. +*/ +const deleteLine = view => { + if (view.state.readOnly) + return false; + let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => { + if (from > 0) + from--; + else if (to < state.doc.length) + to++; + return { from, to }; + })); + let selection = updateSel(state.selection, range => { + let dist = undefined; + if (view.lineWrapping) { + let block = view.lineBlockAt(range.head), pos = view.coordsAtPos(range.head, range.assoc || 1); + if (pos) + dist = (block.bottom + view.documentTop) - pos.bottom + view.defaultLineHeight / 2; + } + return view.moveVertically(range, true, dist); + }).map(changes); + view.dispatch({ changes, selection, scrollIntoView: true, userEvent: "delete.line" }); + return true; +}; +/** +Replace the selection with a newline. +*/ +const insertNewline = ({ state, dispatch }) => { + dispatch(state.update(state.replaceSelection(state.lineBreak), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Replace the selection with a newline and the same amount of +indentation as the line above. +*/ +const insertNewlineKeepIndent = ({ state, dispatch }) => { + dispatch(state.update(state.changeByRange(range => { + let indent = /^\s*/.exec(state.doc.lineAt(range.from).text)[0]; + return { + changes: { from: range.from, to: range.to, insert: state.lineBreak + indent }, + range: EditorSelection.cursor(range.from + indent.length + 1) + }; + }), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +function isBetweenBrackets(state, pos) { + if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1))) + return { from: pos, to: pos }; + let context = syntaxTree(state).resolveInner(pos); + let before = context.childBefore(pos), after = context.childAfter(pos), closedBy; + if (before && after && before.to <= pos && after.from >= pos && + (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 && + state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from && + !/\S/.test(state.sliceDoc(before.to, after.from))) + return { from: before.to, to: after.from }; + return null; +} +/** +Replace the selection with a newline and indent the newly created +line(s). If the current line consists only of whitespace, this +will also delete that whitespace. When the cursor is between +matching brackets, an additional newline will be inserted after +the cursor. +*/ +const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false); +/** +Create a blank, indented line below the current line. +*/ +const insertBlankLine = /*@__PURE__*/newlineAndIndent(true); +function newlineAndIndent(atEof) { + return ({ state, dispatch }) => { + if (state.readOnly) + return false; + let changes = state.changeByRange(range => { + let { from, to } = range, line = state.doc.lineAt(from); + let explode = !atEof && from == to && isBetweenBrackets(state, from); + if (atEof) + from = to = (to <= line.to ? line : state.doc.lineAt(to)).to; + let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode }); + let indent = getIndentation(cx, from); + if (indent == null) + indent = countColumn(/^\s*/.exec(state.doc.lineAt(from).text)[0], state.tabSize); + while (to < line.to && /\s/.test(line.text[to - line.from])) + to++; + if (explode) + ({ from, to } = explode); + else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from))) + from = line.from; + let insert = ["", indentString(state, indent)]; + if (explode) + insert.push(indentString(state, cx.lineIndent(line.from, -1))); + return { changes: { from, to, insert: Text.of(insert) }, + range: EditorSelection.cursor(from + 1 + insert[1].length) }; + }); + dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" })); + return true; + }; +} +function changeBySelectedLine(state, f) { + let atLine = -1; + return state.changeByRange(range => { + let changes = []; + for (let pos = range.from; pos <= range.to;) { + let line = state.doc.lineAt(pos); + if (line.number > atLine && (range.empty || range.to > line.from)) { + f(line, changes, range); + atLine = line.number; + } + pos = line.to + 1; + } + let changeSet = state.changes(changes); + return { changes, + range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) }; + }); +} +/** +Auto-indent the selected lines. This uses the [indentation service +facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent +information. +*/ +const indentSelection = ({ state, dispatch }) => { + if (state.readOnly) + return false; + let updated = Object.create(null); + let context = new IndentContext(state, { overrideIndentation: start => { + let found = updated[start]; + return found == null ? -1 : found; + } }); + let changes = changeBySelectedLine(state, (line, changes, range) => { + let indent = getIndentation(context, line.from); + if (indent == null) + return; + if (!/\S/.test(line.text)) + indent = 0; + let cur = /^\s*/.exec(line.text)[0]; + let norm = indentString(state, indent); + if (cur != norm || range.from < line.from + cur.length) { + updated[line.from] = indent; + changes.push({ from: line.from, to: line.from + cur.length, insert: norm }); + } + }); + if (!changes.changes.empty) + dispatch(state.update(changes, { userEvent: "indent" })); + return true; +}; +/** +Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected +lines. +*/ +const indentMore = ({ state, dispatch }) => { + if (state.readOnly) + return false; + dispatch(state.update(changeBySelectedLine(state, (line, changes) => { + changes.push({ from: line.from, insert: state.facet(indentUnit) }); + }), { userEvent: "input.indent" })); + return true; +}; +/** +Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all +selected lines. +*/ +const indentLess = ({ state, dispatch }) => { + if (state.readOnly) + return false; + dispatch(state.update(changeBySelectedLine(state, (line, changes) => { + let space = /^\s*/.exec(line.text)[0]; + if (!space) + return; + let col = countColumn(space, state.tabSize), keep = 0; + let insert = indentString(state, Math.max(0, col - getIndentUnit(state))); + while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep)) + keep++; + changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) }); + }), { userEvent: "delete.dedent" })); + return true; +}; +/** +Enables or disables +[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this +prevents the editor's key bindings from capturing Tab or +Shift-Tab, making it possible for the user to move focus out of +the editor with the keyboard. +*/ +const toggleTabFocusMode = view => { + view.setTabFocusMode(); + return true; +}; +/** +Temporarily enables [tab-focus +mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until +another key is pressed. +*/ +const temporarilySetTabFocusMode = view => { + view.setTabFocusMode(2000); + return true; +}; +/** +Insert a tab character at the cursor or, if something is selected, +use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire +selection. +*/ +const insertTab = ({ state, dispatch }) => { + if (state.selection.ranges.some(r => !r.empty)) + return indentMore({ state, dispatch }); + dispatch(state.update(state.replaceSelection("\t"), { scrollIntoView: true, userEvent: "input" })); + return true; +}; +/** +Array of key bindings containing the Emacs-style bindings that are +available on macOS by default. + + - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd) + - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine) + - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars) + - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) + - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) +*/ +const emacsStyleKeymap = [ + { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true }, + { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight }, + { key: "Ctrl-p", run: cursorLineUp, shift: selectLineUp }, + { key: "Ctrl-n", run: cursorLineDown, shift: selectLineDown }, + { key: "Ctrl-a", run: cursorLineStart, shift: selectLineStart }, + { key: "Ctrl-e", run: cursorLineEnd, shift: selectLineEnd }, + { key: "Ctrl-d", run: deleteCharForward }, + { key: "Ctrl-h", run: deleteCharBackward }, + { key: "Ctrl-k", run: deleteToLineEnd }, + { key: "Ctrl-Alt-h", run: deleteGroupBackward }, + { key: "Ctrl-o", run: splitLine }, + { key: "Ctrl-t", run: transposeChars }, + { key: "Ctrl-v", run: cursorPageDown }, +]; +/** +An array of key bindings closely sticking to platform-standard or +widely used bindings. (This includes the bindings from +[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key` +property changed to `mac`.) + + - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) + - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) + - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift) + - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift) + - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) + - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) + - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) + - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) + - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) + - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) + - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift) + - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift) + - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) + - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) + - Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent) + - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll) + - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) + - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) + - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) + - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) + - Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward). + - Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward). +*/ +const standardKeymap = /*@__PURE__*/[ + { key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true }, + { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true }, + { mac: "Cmd-ArrowLeft", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true }, + { key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true }, + { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true }, + { mac: "Cmd-ArrowRight", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true }, + { key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true }, + { mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart }, + { mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp }, + { key: "ArrowDown", run: cursorLineDown, shift: selectLineDown, preventDefault: true }, + { mac: "Cmd-ArrowDown", run: cursorDocEnd, shift: selectDocEnd }, + { mac: "Ctrl-ArrowDown", run: cursorPageDown, shift: selectPageDown }, + { key: "PageUp", run: cursorPageUp, shift: selectPageUp }, + { key: "PageDown", run: cursorPageDown, shift: selectPageDown }, + { key: "Home", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true }, + { key: "Mod-Home", run: cursorDocStart, shift: selectDocStart }, + { key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true }, + { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd }, + { key: "Enter", run: insertNewlineAndIndent, shift: insertNewlineAndIndent }, + { key: "Mod-a", run: selectAll }, + { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward, preventDefault: true }, + { key: "Delete", run: deleteCharForward, preventDefault: true }, + { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward, preventDefault: true }, + { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward, preventDefault: true }, + { mac: "Mod-Backspace", run: deleteLineBoundaryBackward, preventDefault: true }, + { mac: "Mod-Delete", run: deleteLineBoundaryForward, preventDefault: true } +].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift }))); +/** +The default keymap. Includes all bindings from +[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following: + +- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift) +- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift) +- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp) +- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown) +- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp) +- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown) +- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove). +- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow). +- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection) +- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine) +- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine) +- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax) +- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess) +- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) +- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection) +- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine) +- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket) +- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment). +- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment). +- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode). +*/ +const defaultKeymap = /*@__PURE__*/[ + { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: cursorSyntaxLeft, shift: selectSyntaxLeft }, + { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: cursorSyntaxRight, shift: selectSyntaxRight }, + { key: "Alt-ArrowUp", run: moveLineUp }, + { key: "Shift-Alt-ArrowUp", run: copyLineUp }, + { key: "Alt-ArrowDown", run: moveLineDown }, + { key: "Shift-Alt-ArrowDown", run: copyLineDown }, + { key: "Mod-Alt-ArrowUp", run: addCursorAbove }, + { key: "Mod-Alt-ArrowDown", run: addCursorBelow }, + { key: "Escape", run: simplifySelection }, + { key: "Mod-Enter", run: insertBlankLine }, + { key: "Alt-l", mac: "Ctrl-l", run: selectLine }, + { key: "Mod-i", run: selectParentSyntax, preventDefault: true }, + { key: "Mod-[", run: indentLess }, + { key: "Mod-]", run: indentMore }, + { key: "Mod-Alt-\\", run: indentSelection }, + { key: "Shift-Mod-k", run: deleteLine }, + { key: "Shift-Mod-\\", run: cursorMatchingBracket }, + { key: "Mod-/", run: toggleComment }, + { key: "Alt-A", run: toggleBlockComment }, + { key: "Ctrl-m", mac: "Shift-Alt-m", run: toggleTabFocusMode }, +].concat(standardKeymap); +/** +A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and +Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess). +Please see the [Tab example](../../examples/tab/) before using +this. +*/ +const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess }; + +export { addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection }; diff --git a/node_modules/@codemirror/commands/package.json b/node_modules/@codemirror/commands/package.json new file mode 100644 index 0000000..c78feba --- /dev/null +++ b/node_modules/@codemirror/commands/package.json @@ -0,0 +1,42 @@ +{ + "name": "@codemirror/commands", + "version": "6.10.3", + "description": "Collection of editing commands for the CodeMirror code editor", + "scripts": { + "test": "cm-runtests", + "prepare": "cm-buildhelper src/commands.ts" + }, + "keywords": [ + "editor", + "code" + ], + "author": { + "name": "Marijn Haverbeke", + "email": "marijn@haverbeke.berlin", + "url": "http://marijnhaverbeke.nl" + }, + "type": "module", + "main": "dist/index.cjs", + "exports": { + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, + "types": "dist/index.d.ts", + "module": "dist/index.js", + "sideEffects": false, + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.6.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" + }, + "devDependencies": { + "@codemirror/buildhelper": "^1.0.0", + "@codemirror/lang-javascript": "^6.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/codemirror/commands.git" + } +} diff --git a/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml b/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml new file mode 100644 index 0000000..d050072 --- /dev/null +++ b/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml @@ -0,0 +1,16 @@ +name: Trigger CI +on: push + +jobs: + build: + name: Dispatch to main repo + runs-on: ubuntu-latest + steps: + - name: Emit repository_dispatch + uses: mvasigh/dispatch-action@main + with: + # You should create a personal access token and store it in your repository + token: ${{ secrets.DISPATCH_AUTH }} + repo: dev + owner: codemirror + event_type: push diff --git a/node_modules/@codemirror/lang-css/CHANGELOG.md b/node_modules/@codemirror/lang-css/CHANGELOG.md new file mode 100644 index 0000000..26edc23 --- /dev/null +++ b/node_modules/@codemirror/lang-css/CHANGELOG.md @@ -0,0 +1,106 @@ +## 6.3.1 (2024-11-26) + +### Bug fixes + +When completing a property name, insert a colon and space after the name. + +## 6.3.0 (2024-09-07) + +### New features + +CSS autocompletion now completes `@`-keywords. + +## 6.2.1 (2023-08-04) + +### Bug fixes + +Allow keyframe blocks to be code-folded. + +## 6.2.0 (2023-04-26) + +### Bug fixes + +Explicitly list @lezer/common as a package dependency. + +### New features + +Export `defineCSSCompletionSource`, which allows one to define a CSS-style completion source for dialects with their own variable syntax. + +## 6.1.1 (2023-03-08) + +### Bug fixes + +Provide better completions when completing directly in a `Styles` top node. + +## 6.1.0 (2023-03-06) + +### New features + +CSS completion can now complete variable names. + +## 6.0.2 (2023-01-28) + +### Bug fixes + +Fetch the available CSS property names in a way that works on Chrome. + +## 6.0.1 (2022-10-24) + +### Bug fixes + +CSS completion now supports a number of additional recent and semi-standardized pseudo-class names. + +## 6.0.0 (2022-06-08) + +### Breaking changes + +Update dependencies to 6.0.0 + +## 0.20.0 (2022-04-20) + +### Breaking changes + +Update dependencies to 0.20.0 + +## 0.19.3 (2021-09-24) + +### Bug fixes + +Use more appropriate highlighting tags for attribute names, tag names, and CSS variables. + +## 0.19.2 (2021-09-22) + +### New features + +The package now exports a completion source function, rather than a prebuilt completion extension. + +## 0.19.1 (2021-08-11) + +### Bug fixes + +Fix incorrect versions for @lezer dependencies. + +## 0.19.0 (2021-08-11) + +### Breaking changes + +Update dependencies to 0.19.0 + +## 0.18.0 (2021-03-03) + +### Breaking changes + +Update dependencies to 0.18. + +## 0.17.1 (2021-01-06) + +### New features + +The package now also exports a CommonJS module. + +## 0.17.0 (2020-12-29) + +### Breaking changes + +First numbered release. + diff --git a/node_modules/@codemirror/lang-css/LICENSE b/node_modules/@codemirror/lang-css/LICENSE new file mode 100644 index 0000000..9a91f48 --- /dev/null +++ b/node_modules/@codemirror/lang-css/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2018-2021 by Marijn Haverbeke and others + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/@codemirror/lang-css/README.md b/node_modules/@codemirror/lang-css/README.md new file mode 100644 index 0000000..f481789 --- /dev/null +++ b/node_modules/@codemirror/lang-css/README.md @@ -0,0 +1,50 @@ + + +# @codemirror/lang-css [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-css.svg)](https://www.npmjs.org/package/@codemirror/lang-css) + +[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-css/blob/main/CHANGELOG.md) ] + +This package implements CSS language support for the +[CodeMirror](https://codemirror.net/) code editor. + +The [project page](https://codemirror.net/) has more information, a +number of [examples](https://codemirror.net/examples/) and the +[documentation](https://codemirror.net/docs/). + +This code is released under an +[MIT license](https://github.com/codemirror/lang-css/tree/main/LICENSE). + +We aim to be an inclusive, welcoming community. To make that explicit, +we have a [code of +conduct](http://contributor-covenant.org/version/1/1/0/) that applies +to communication around the project. + +## API Reference + +
+
+ css() → LanguageSupport
+ +

Language support for CSS.

+
+
+ cssLanguage: LRLanguage
+ +

A language provider based on the Lezer CSS +parser, extended with +highlighting and indentation information.

+
+
+ cssCompletionSource: CompletionSource
+ +

CSS property, variable, and value keyword completion source.

+
+
+ defineCSSCompletionSource(isVariable: fn(nodeSyntaxNodeRef) → boolean) → CompletionSource
+ +

Create a completion source for a CSS dialect, providing a +predicate for determining what kind of syntax node can act as a +completable variable. This is used by language modes like Sass and +Less to reuse this package's completion logic.

+
+
diff --git a/node_modules/@codemirror/lang-css/dist/index.cjs b/node_modules/@codemirror/lang-css/dist/index.cjs new file mode 100644 index 0000000..2b52c5c --- /dev/null +++ b/node_modules/@codemirror/lang-css/dist/index.cjs @@ -0,0 +1,269 @@ +'use strict'; + +var css$1 = require('@lezer/css'); +var language = require('@codemirror/language'); +var common = require('@lezer/common'); + +let _properties = null; +function properties() { + if (!_properties && typeof document == "object" && document.body) { + let { style } = document.body, names = [], seen = new Set; + for (let prop in style) + if (prop != "cssText" && prop != "cssFloat") { + if (typeof style[prop] == "string") { + if (/[A-Z]/.test(prop)) + prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase()); + if (!seen.has(prop)) { + names.push(prop); + seen.add(prop); + } + } + } + _properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " })); + } + return _properties || []; +} +const pseudoClasses = [ + "active", "after", "any-link", "autofill", "backdrop", "before", + "checked", "cue", "default", "defined", "disabled", "empty", + "enabled", "file-selector-button", "first", "first-child", + "first-letter", "first-line", "first-of-type", "focus", + "focus-visible", "focus-within", "fullscreen", "has", "host", + "host-context", "hover", "in-range", "indeterminate", "invalid", + "is", "lang", "last-child", "last-of-type", "left", "link", "marker", + "modal", "not", "nth-child", "nth-last-child", "nth-last-of-type", + "nth-of-type", "only-child", "only-of-type", "optional", "out-of-range", + "part", "placeholder", "placeholder-shown", "read-only", "read-write", + "required", "right", "root", "scope", "selection", "slotted", "target", + "target-text", "valid", "visited", "where" +].map(name => ({ type: "class", label: name })); +const values = [ + "above", "absolute", "activeborder", "additive", "activecaption", "after-white-space", + "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", + "antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", + "avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", + "bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", + "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", + "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize", + "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", + "cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", + "color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", + "contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", + "crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", + "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", + "destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed", + "disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", + "ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", + "ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion", + "expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box", + "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", + "geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide", + "higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", + "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", + "inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", + "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all", + "landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", + "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", + "lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation", + "match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic", + "mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower", + "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", + "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", + "oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside", + "outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", + "perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", + "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", + "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", + "repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", + "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", + "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", + "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", + "se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", + "single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", + "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", + "small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out", + "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start", + "static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks", + "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", + "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", + "table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin", + "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top", + "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", + "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin", + "uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", + "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", + "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" +].map(name => ({ type: "keyword", label: name })).concat([ + "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", + "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", + "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", + "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", + "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", + "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", + "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", + "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", + "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", + "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", + "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", + "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", + "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", + "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", + "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", + "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", + "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", + "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", + "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", + "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", + "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", + "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", + "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", + "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", + "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", + "whitesmoke", "yellow", "yellowgreen" +].map(name => ({ type: "constant", label: name }))); +const tags = [ + "a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body", + "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del", + "details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer", + "form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", + "img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output", + "p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary", + "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul" +].map(name => ({ type: "type", label: name })); +const atRules = [ + "@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values", + "@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page", + "@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition" +].map(label => ({ type: "keyword", label })); +const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/; +function isVarArg(node, doc) { + var _a; + if (node.name == "(" || node.type.isError) + node = node.parent || node; + if (node.name != "ArgList") + return false; + let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild; + if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee") + return false; + return doc.sliceString(callee.from, callee.to) == "var"; +} +const VariablesByNode = new common.NodeWeakMap(); +const declSelector = ["Declaration"]; +function astTop(node) { + for (let cur = node;;) { + if (cur.type.isTop) + return cur; + if (!(cur = cur.parent)) + return node; + } +} +function variableNames(doc, node, isVariable) { + if (node.to - node.from > 4096) { + let known = VariablesByNode.get(node); + if (known) + return known; + let result = [], seen = new Set, cursor = node.cursor(common.IterMode.IncludeAnonymous); + if (cursor.firstChild()) + do { + for (let option of variableNames(doc, cursor.node, isVariable)) + if (!seen.has(option.label)) { + seen.add(option.label); + result.push(option); + } + } while (cursor.nextSibling()); + VariablesByNode.set(node, result); + return result; + } + else { + let result = [], seen = new Set; + node.cursor().iterate(node => { + var _a; + if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") { + let name = doc.sliceString(node.from, node.to); + if (!seen.has(name)) { + seen.add(name); + result.push({ label: name, type: "variable" }); + } + } + }); + return result; + } +} +/** +Create a completion source for a CSS dialect, providing a +predicate for determining what kind of syntax node can act as a +completable variable. This is used by language modes like Sass and +Less to reuse this package's completion logic. +*/ +const defineCSSCompletionSource = (isVariable) => context => { + let { state, pos } = context, node = language.syntaxTree(state).resolveInner(pos, -1); + let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-"; + if (node.name == "PropertyName" || + (isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name)) + return { from: node.from, options: properties(), validFor: identifier }; + if (node.name == "ValueName") + return { from: node.from, options: values, validFor: identifier }; + if (node.name == "PseudoClassName") + return { from: node.from, options: pseudoClasses, validFor: identifier }; + if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc)) + return { from: isVariable(node) || isDash ? node.from : pos, + options: variableNames(state.doc, astTop(node), isVariable), + validFor: variable }; + if (node.name == "TagName") { + for (let { parent } = node; parent; parent = parent.parent) + if (parent.name == "Block") + return { from: node.from, options: properties(), validFor: identifier }; + return { from: node.from, options: tags, validFor: identifier }; + } + if (node.name == "AtKeyword") + return { from: node.from, options: atRules, validFor: identifier }; + if (!context.explicit) + return null; + let above = node.resolve(pos), before = above.childBefore(pos); + if (before && before.name == ":" && above.name == "PseudoClassSelector") + return { from: pos, options: pseudoClasses, validFor: identifier }; + if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList") + return { from: pos, options: values, validFor: identifier }; + if (above.name == "Block" || above.name == "Styles") + return { from: pos, options: properties(), validFor: identifier }; + return null; +}; +/** +CSS property, variable, and value keyword completion source. +*/ +const cssCompletionSource = defineCSSCompletionSource(n => n.name == "VariableName"); + +/** +A language provider based on the [Lezer CSS +parser](https://github.com/lezer-parser/css), extended with +highlighting and indentation information. +*/ +const cssLanguage = language.LRLanguage.define({ + name: "css", + parser: css$1.parser.configure({ + props: [ + language.indentNodeProp.add({ + Declaration: language.continuedIndent() + }), + language.foldNodeProp.add({ + "Block KeyframeList": language.foldInside + }) + ] + }), + languageData: { + commentTokens: { block: { open: "/*", close: "*/" } }, + indentOnInput: /^\s*\}$/, + wordChars: "-" + } +}); +/** +Language support for CSS. +*/ +function css() { + return new language.LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource })); +} + +exports.css = css; +exports.cssCompletionSource = cssCompletionSource; +exports.cssLanguage = cssLanguage; +exports.defineCSSCompletionSource = defineCSSCompletionSource; diff --git a/node_modules/@codemirror/lang-css/dist/index.d.cts b/node_modules/@codemirror/lang-css/dist/index.d.cts new file mode 100644 index 0000000..e46ef82 --- /dev/null +++ b/node_modules/@codemirror/lang-css/dist/index.d.cts @@ -0,0 +1,28 @@ +import { LRLanguage, LanguageSupport } from '@codemirror/language'; +import { CompletionSource } from '@codemirror/autocomplete'; +import { SyntaxNodeRef } from '@lezer/common'; + +/** +Create a completion source for a CSS dialect, providing a +predicate for determining what kind of syntax node can act as a +completable variable. This is used by language modes like Sass and +Less to reuse this package's completion logic. +*/ +declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource; +/** +CSS property, variable, and value keyword completion source. +*/ +declare const cssCompletionSource: CompletionSource; + +/** +A language provider based on the [Lezer CSS +parser](https://github.com/lezer-parser/css), extended with +highlighting and indentation information. +*/ +declare const cssLanguage: LRLanguage; +/** +Language support for CSS. +*/ +declare function css(): LanguageSupport; + +export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; diff --git a/node_modules/@codemirror/lang-css/dist/index.d.ts b/node_modules/@codemirror/lang-css/dist/index.d.ts new file mode 100644 index 0000000..e46ef82 --- /dev/null +++ b/node_modules/@codemirror/lang-css/dist/index.d.ts @@ -0,0 +1,28 @@ +import { LRLanguage, LanguageSupport } from '@codemirror/language'; +import { CompletionSource } from '@codemirror/autocomplete'; +import { SyntaxNodeRef } from '@lezer/common'; + +/** +Create a completion source for a CSS dialect, providing a +predicate for determining what kind of syntax node can act as a +completable variable. This is used by language modes like Sass and +Less to reuse this package's completion logic. +*/ +declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource; +/** +CSS property, variable, and value keyword completion source. +*/ +declare const cssCompletionSource: CompletionSource; + +/** +A language provider based on the [Lezer CSS +parser](https://github.com/lezer-parser/css), extended with +highlighting and indentation information. +*/ +declare const cssLanguage: LRLanguage; +/** +Language support for CSS. +*/ +declare function css(): LanguageSupport; + +export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; diff --git a/node_modules/@codemirror/lang-css/dist/index.js b/node_modules/@codemirror/lang-css/dist/index.js new file mode 100644 index 0000000..4e76eda --- /dev/null +++ b/node_modules/@codemirror/lang-css/dist/index.js @@ -0,0 +1,264 @@ +import { parser } from '@lezer/css'; +import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language'; +import { NodeWeakMap, IterMode } from '@lezer/common'; + +let _properties = null; +function properties() { + if (!_properties && typeof document == "object" && document.body) { + let { style } = document.body, names = [], seen = new Set; + for (let prop in style) + if (prop != "cssText" && prop != "cssFloat") { + if (typeof style[prop] == "string") { + if (/[A-Z]/.test(prop)) + prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase()); + if (!seen.has(prop)) { + names.push(prop); + seen.add(prop); + } + } + } + _properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " })); + } + return _properties || []; +} +const pseudoClasses = /*@__PURE__*/[ + "active", "after", "any-link", "autofill", "backdrop", "before", + "checked", "cue", "default", "defined", "disabled", "empty", + "enabled", "file-selector-button", "first", "first-child", + "first-letter", "first-line", "first-of-type", "focus", + "focus-visible", "focus-within", "fullscreen", "has", "host", + "host-context", "hover", "in-range", "indeterminate", "invalid", + "is", "lang", "last-child", "last-of-type", "left", "link", "marker", + "modal", "not", "nth-child", "nth-last-child", "nth-last-of-type", + "nth-of-type", "only-child", "only-of-type", "optional", "out-of-range", + "part", "placeholder", "placeholder-shown", "read-only", "read-write", + "required", "right", "root", "scope", "selection", "slotted", "target", + "target-text", "valid", "visited", "where" +].map(name => ({ type: "class", label: name })); +const values = /*@__PURE__*/[ + "above", "absolute", "activeborder", "additive", "activecaption", "after-white-space", + "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", + "antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", + "avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", + "bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", + "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", + "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize", + "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", + "cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", + "color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", + "contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", + "crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", + "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", + "destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed", + "disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", + "ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", + "ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion", + "expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box", + "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", + "geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide", + "higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", + "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", + "inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", + "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all", + "landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", + "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", + "lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation", + "match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic", + "mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower", + "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", + "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", + "oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside", + "outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", + "perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", + "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", + "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", + "repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", + "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", + "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", + "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", + "se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", + "single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", + "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", + "small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out", + "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start", + "static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks", + "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", + "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", + "table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin", + "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top", + "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", + "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin", + "uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", + "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", + "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" +].map(name => ({ type: "keyword", label: name })).concat(/*@__PURE__*/[ + "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", + "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", + "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", + "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", + "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", + "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", + "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", + "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", + "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", + "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", + "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", + "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", + "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", + "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", + "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", + "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", + "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", + "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", + "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", + "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", + "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", + "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", + "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", + "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", + "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", + "whitesmoke", "yellow", "yellowgreen" +].map(name => ({ type: "constant", label: name }))); +const tags = /*@__PURE__*/[ + "a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body", + "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del", + "details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer", + "form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", + "img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output", + "p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary", + "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul" +].map(name => ({ type: "type", label: name })); +const atRules = /*@__PURE__*/[ + "@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values", + "@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page", + "@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition" +].map(label => ({ type: "keyword", label })); +const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/; +function isVarArg(node, doc) { + var _a; + if (node.name == "(" || node.type.isError) + node = node.parent || node; + if (node.name != "ArgList") + return false; + let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild; + if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee") + return false; + return doc.sliceString(callee.from, callee.to) == "var"; +} +const VariablesByNode = /*@__PURE__*/new NodeWeakMap(); +const declSelector = ["Declaration"]; +function astTop(node) { + for (let cur = node;;) { + if (cur.type.isTop) + return cur; + if (!(cur = cur.parent)) + return node; + } +} +function variableNames(doc, node, isVariable) { + if (node.to - node.from > 4096) { + let known = VariablesByNode.get(node); + if (known) + return known; + let result = [], seen = new Set, cursor = node.cursor(IterMode.IncludeAnonymous); + if (cursor.firstChild()) + do { + for (let option of variableNames(doc, cursor.node, isVariable)) + if (!seen.has(option.label)) { + seen.add(option.label); + result.push(option); + } + } while (cursor.nextSibling()); + VariablesByNode.set(node, result); + return result; + } + else { + let result = [], seen = new Set; + node.cursor().iterate(node => { + var _a; + if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") { + let name = doc.sliceString(node.from, node.to); + if (!seen.has(name)) { + seen.add(name); + result.push({ label: name, type: "variable" }); + } + } + }); + return result; + } +} +/** +Create a completion source for a CSS dialect, providing a +predicate for determining what kind of syntax node can act as a +completable variable. This is used by language modes like Sass and +Less to reuse this package's completion logic. +*/ +const defineCSSCompletionSource = (isVariable) => context => { + let { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1); + let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-"; + if (node.name == "PropertyName" || + (isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name)) + return { from: node.from, options: properties(), validFor: identifier }; + if (node.name == "ValueName") + return { from: node.from, options: values, validFor: identifier }; + if (node.name == "PseudoClassName") + return { from: node.from, options: pseudoClasses, validFor: identifier }; + if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc)) + return { from: isVariable(node) || isDash ? node.from : pos, + options: variableNames(state.doc, astTop(node), isVariable), + validFor: variable }; + if (node.name == "TagName") { + for (let { parent } = node; parent; parent = parent.parent) + if (parent.name == "Block") + return { from: node.from, options: properties(), validFor: identifier }; + return { from: node.from, options: tags, validFor: identifier }; + } + if (node.name == "AtKeyword") + return { from: node.from, options: atRules, validFor: identifier }; + if (!context.explicit) + return null; + let above = node.resolve(pos), before = above.childBefore(pos); + if (before && before.name == ":" && above.name == "PseudoClassSelector") + return { from: pos, options: pseudoClasses, validFor: identifier }; + if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList") + return { from: pos, options: values, validFor: identifier }; + if (above.name == "Block" || above.name == "Styles") + return { from: pos, options: properties(), validFor: identifier }; + return null; +}; +/** +CSS property, variable, and value keyword completion source. +*/ +const cssCompletionSource = /*@__PURE__*/defineCSSCompletionSource(n => n.name == "VariableName"); + +/** +A language provider based on the [Lezer CSS +parser](https://github.com/lezer-parser/css), extended with +highlighting and indentation information. +*/ +const cssLanguage = /*@__PURE__*/LRLanguage.define({ + name: "css", + parser: /*@__PURE__*/parser.configure({ + props: [ + /*@__PURE__*/indentNodeProp.add({ + Declaration: /*@__PURE__*/continuedIndent() + }), + /*@__PURE__*/foldNodeProp.add({ + "Block KeyframeList": foldInside + }) + ] + }), + languageData: { + commentTokens: { block: { open: "/*", close: "*/" } }, + indentOnInput: /^\s*\}$/, + wordChars: "-" + } +}); +/** +Language support for CSS. +*/ +function css() { + return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource })); +} + +export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; diff --git a/node_modules/@codemirror/lang-css/package.json b/node_modules/@codemirror/lang-css/package.json new file mode 100644 index 0000000..a8acffc --- /dev/null +++ b/node_modules/@codemirror/lang-css/package.json @@ -0,0 +1,42 @@ +{ + "name": "@codemirror/lang-css", + "version": "6.3.1", + "description": "CSS language support for the CodeMirror code editor", + "scripts": { + "test": "cm-runtests", + "prepare": "cm-buildhelper src/css.ts" + }, + "keywords": [ + "editor", + "code" + ], + "author": { + "name": "Marijn Haverbeke", + "email": "marijn@haverbeke.berlin", + "url": "http://marijnhaverbeke.nl" + }, + "type": "module", + "main": "dist/index.cjs", + "exports": { + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, + "types": "dist/index.d.ts", + "module": "dist/index.js", + "sideEffects": false, + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.2", + "@lezer/css": "^1.1.7" + }, + "devDependencies": { + "@codemirror/buildhelper": "^1.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/codemirror/lang-css.git" + } +} diff --git a/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml b/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml new file mode 100644 index 0000000..d050072 --- /dev/null +++ b/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml @@ -0,0 +1,16 @@ +name: Trigger CI +on: push + +jobs: + build: + name: Dispatch to main repo + runs-on: ubuntu-latest + steps: + - name: Emit repository_dispatch + uses: mvasigh/dispatch-action@main + with: + # You should create a personal access token and store it in your repository + token: ${{ secrets.DISPATCH_AUTH }} + repo: dev + owner: codemirror + event_type: push diff --git a/node_modules/@codemirror/lang-html/CHANGELOG.md b/node_modules/@codemirror/lang-html/CHANGELOG.md new file mode 100644 index 0000000..c72a7c0 --- /dev/null +++ b/node_modules/@codemirror/lang-html/CHANGELOG.md @@ -0,0 +1,210 @@ +## 6.4.11 (2025-10-02) + +### Bug fixes + +Adjust autocompletion to work with @lezer/html's improved handling of `<` characters without tag name after them. + +## 6.4.10 (2025-09-11) + +### Bug fixes + +Don't include period characters in the language's word characters. + +## 6.4.9 (2024-04-12) + +### Bug fixes + +Fix a bug in `autoCloseTags` that made tags not close when typing > after an attribute. + +## 6.4.8 (2024-01-23) + +### Bug fixes + +Complete attribute names after whitespace in a tag even when completion isn't explicitly triggered. + +## 6.4.7 (2023-11-27) + +### Bug fixes + +Parse `script` tags with `application/json` type as JSON syntax. + +## 6.4.6 (2023-08-28) + +### Bug fixes + +`autoCloseTags` now generates two separate transactions, so that the completion can be undone separately. + +Add highlighting for the content of ` + +==> + +Document(Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,AttributeValue),EndTag), + ScriptText, +CloseTag(StartCloseTag,TagName,EndTag))) + +# Does parse type-less script tags as JS + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Script(ExpressionStatement(RegExp)), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Still doesn't end script tags on closing tags + + + +==> + +Document(Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag), + ScriptText, +CloseTag(StartCloseTag,TagName,EndTag))) + +# Missing end tag + + + +==> + +Document(Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,AttributeValue),EndTag), + Script(...), +CloseTag(StartCloseTag,TagName,EndTag))) + +# JS with unquoted script type + + + +==> + +Document(Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag), + Script(...), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Error in JS + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Script(...), +CloseTag(StartCloseTag,TagName,EndTag))) diff --git a/node_modules/@lezer/html/test/tags.txt b/node_modules/@lezer/html/test/tags.txt new file mode 100644 index 0000000..8484ab8 --- /dev/null +++ b/node_modules/@lezer/html/test/tags.txt @@ -0,0 +1,370 @@ +# Regular tag + +bar + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),Text,CloseTag(StartCloseTag,TagName,EndTag))) + +# Nested tag + +c
+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag),Text,CloseTag(StartCloseTag,TagName,EndTag)), + Element(SelfClosingTag(StartTag,TagName,EndTag)), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Attribute + +
+ +==> + +Document(Element(SelfClosingTag(StartTag,TagName,Attribute(AttributeName,Is,AttributeValue),EndTag))) + +# Multiple attributes + + + +==> + +Document(Element(OpenTag(StartTag,TagName, + Attribute(AttributeName,Is,AttributeValue), + Attribute(AttributeName,Is,AttributeValue), + Attribute(AttributeName,Is,AttributeValue),EndTag), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Value-less attributes + + + +==> + +Document(Element(OpenTag(StartTag,TagName, + Attribute(AttributeName), + Attribute(AttributeName,Is,AttributeValue), + Attribute(AttributeName),EndTag), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Unquoted attributes + + + +==> + +Document(Element(OpenTag(StartTag,TagName, + Attribute(AttributeName,Is,UnquotedAttributeValue), + Attribute(AttributeName), + Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Unquoted attributes with slashes + + + +==> + +Document(Element(SelfClosingTag(StartTag,TagName, + Attribute(AttributeName,Is,UnquotedAttributeValue), + Attribute(AttributeName,Is,UnquotedAttributeValue), + Attribute(AttributeName,Is,UnquotedAttributeValue), + Attribute(AttributeName,Is,UnquotedAttributeValue), +EndTag))) + +# Single-quoted attributes + + + +==> + +Document(Element(SelfClosingTag(StartTag, TagName, + Attribute(AttributeName, Is, AttributeValue), + Attribute(AttributeName, Is, AttributeValue(EntityReference)), +EndTag))) + +# Entities + +&C + +==> + +Document(Element(OpenTag(StartTag,TagName, + Attribute(AttributeName,Is,AttributeValue(EntityReference)),EndTag), + EntityReference,CharacterReference, +CloseTag(StartCloseTag,TagName,EndTag))) + +# Doctype + + + + +==> + +Document(DoctypeDecl,Text,Element(OpenTag(StartTag,TagName,EndTag),CloseTag(StartCloseTag,TagName,EndTag))) + +# Processing instructions + + + +==> + +Document(ProcessingInst,Element(OpenTag(StartTag,TagName,EndTag),ProcessingInst,CloseTag(StartCloseTag,TagName,EndTag))) + +# Comments + + + text + + + +==> + +Document(Comment,Text,Element(OpenTag(StartTag,TagName,EndTag),Comment,Text,CloseTag(StartCloseTag,TagName,EndTag)),Text,Comment,Text,Comment) + +# Mismatched tag + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),MismatchedCloseTag(StartCloseTag,TagName,EndTag))) + +# Unclosed tag + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag))) + +# Ignore pseudo-xml self-closers + +
+ +==> + +Document(Element(SelfClosingTag(StartTag,TagName,EndTag))) + +# Unclosed implicitly closed tag + +

+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag))) + +# Nested mismatched tag + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag),CloseTag(StartCloseTag,TagName,EndTag)), + MismatchedCloseTag(StartCloseTag,TagName,EndTag), + ⚠), + CloseTag(StartCloseTag,TagName,EndTag))) + +# Incomplete close tag + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag), IncompleteCloseTag, ⚠), + CloseTag(StartCloseTag,TagName,EndTag))) + +# Re-synchronize close tags + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag), + MismatchedCloseTag(StartCloseTag,TagName,EndTag), + CloseTag(StartCloseTag,TagName,EndTag)), + ⚠), + CloseTag(StartCloseTag,TagName,EndTag))) + +# Top-level mismatched close tag + + + +==> + +Document( + Element(OpenTag(StartTag,TagName,EndTag),CloseTag(StartCloseTag,TagName,EndTag)), + MismatchedCloseTag(StartCloseTag,TagName,EndTag)) + +# Self-closing tags + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(SelfClosingTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag)), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Implicitly closed + +

Hello
+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag),Text), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Closed by sibling + +
+

Foo +

Bar +

+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Text, + Element(OpenTag(StartTag,TagName,EndTag),Text), + Element(OpenTag(StartTag,TagName,EndTag),Text), +CloseTag(StartCloseTag,TagName,EndTag))) + +# Closed by sibling at top + +

Foo +

Bar + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),Text),Element(OpenTag(StartTag,TagName,EndTag),Text)) + +# Textarea + +

Enter something: + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Text, + Element(OpenTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),EndTag), + TextareaText, + CloseTag(StartCloseTag,TagName,EndTag)))) + +# Script + + + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),ScriptText,CloseTag(StartCloseTag,TagName,EndTag))) + +# Doesn't get confused by a stray ampersand + +a&b + +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),Text,InvalidEntity,Text,CloseTag(StartCloseTag,TagName,EndTag))) + +# Can ignore mismatches {"dialect": "noMatch"} + +

foo

+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag),Text,CloseTag(StartCloseTag,TagName,EndTag))) + +# Can handle lone close tags {"dialect": "noMatch"} + + + +==> + +Document(CloseTag(StartCloseTag,TagName,EndTag)) + +# Parses ampersands in attributes + + + +==> + +Document(Element(SelfClosingTag(StartTag, TagName, Attribute(AttributeName, Is, AttributeValue(InvalidEntity)), EndTag))) + +# Supports self-closing dialect {"dialect": "selfClosing"} + +
+ +==> + +Document(Element( + OpenTag(StartTag,TagName,EndTag), + Element(SelfClosingTag(StartTag,TagName,Attribute(AttributeName,Is,UnquotedAttributeValue),SelfClosingEndTag)), + CloseTag(StartCloseTag,TagName,EndTag))) + +# Allows self-closing in foreign elements + +
+ +==> + +Document(Element(OpenTag(StartTag,TagName,EndTag), + Element(OpenTag(StartTag,TagName,EndTag), + Element(SelfClosingTag(StartTag,TagName,SelfClosingEndTag)), + CloseTag(StartCloseTag,TagName,EndTag)), + CloseTag(StartCloseTag,TagName,EndTag))) + +# Parses multiple unfinished tags in a row + +
+ +Document(Element(OpenTag(StartTag,TagName,⚠), + Element(OpenTag(StartTag,TagName,⚠), + Element(OpenTag(StartTag,TagName,⚠),⚠),⚠),⚠)) + +# Allows self-closing on special tags {"dialect": "selfClosing"} + + +
+