6 lines
184 KiB
JavaScript
6 lines
184 KiB
JavaScript
|
|
import{l as Wt,S as it,F as C,T as Mn,A as kn,E as S,P as ci,a as G,j as ms,R,g as fi,i as ot,n as Ke,b as di,M as vt,e as ui,c as bs,h as ys,d as An,m as Tn,C as Dn}from"./cm-state-X9WpHEQO.js";import{S as kt}from"./vendor-style-mod-Bs6eFhZE.js";import{k as On,b as Ln,s as Bn}from"./vendor-w3c-keyname-Vcq4gwWv.js";import{c as yt}from"./vendor-crelt-C8TCjufn.js";let N=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},qe=typeof document<"u"?document:{documentElement:{style:{}}};const _e=/Edge\/(\d+)/.exec(N.userAgent),ws=/MSIE \d/.test(N.userAgent),je=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(N.userAgent),Ce=!!(ws||je||_e),Ti=!Ce&&/gecko\/(\d+)/i.test(N.userAgent),Oe=!Ce&&/Chrome\/(\d+)/.exec(N.userAgent),Rn="webkitFontSmoothing"in qe.documentElement.style,Ge=!Ce&&/Apple Computer/.test(N.vendor),Di=Ge&&(/Mobile\/\w+/.test(N.userAgent)||N.maxTouchPoints>2);var y={mac:Di||/Mac/.test(N.platform),windows:/Win/.test(N.platform),linux:/Linux|X11/.test(N.platform),ie:Ce,ie_version:ws?qe.documentMode||6:je?+je[1]:_e?+_e[1]:0,gecko:Ti,gecko_version:Ti?+(/Firefox\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,chrome:!!Oe,chrome_version:Oe?+Oe[1]:0,ios:Di,android:/Android\b/.test(N.userAgent),webkit_version:Rn?+(/\bAppleWebKit\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,safari:Ge,safari_version:Ge?+(/\bVersion\/(\d+(\.\d+)?)/.exec(N.userAgent)||[0,0])[1]:0,tabSize:qe.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function pi(n,t){for(let e in n)e=="class"&&t.class?t.class+=" "+n.class:e=="style"&&t.style?t.style+=";"+n.style:t[e]=n[e];return t}const ue=Object.create(null);function gi(n,t,e){if(n==t)return!0;n||(n=ue),t||(t=ue);let i=Object.keys(n),s=Object.keys(t);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=e&&(s.indexOf(r)==-1||n[r]!==t[r]))return!1;return!0}function En(n,t){for(let e=n.attributes.length-1;e>=0;e--){let i=n.attributes[e].name;t[i]==null&&n.removeAttribute(i)}for(let e in t){let i=t[e];e=="style"?n.style.cssText=i:n.getAttribute(e)!=i&&n.setAttribute(e,i)}}function Oi(n,t,e){let i=!1;if(t)for(let s in t)e&&s in e||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(e)for(let s in e)t&&t[s]==e[s]||(i=!0,s=="style"?n.style.cssText=e[s]:n.setAttribute(s,e[s]));return i}function Hn(n){let t=Object.create(null);for(let e=0;e<n.attributes.length;e++){let i=n.attributes[e];t[i.name]=i.value}return t}class Lt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var W=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(W||(W={}));class E extends fi{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new _t(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new pt(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=xs(t,e);i=(r?e?-3e8:-1:5e8)-1,s=(o?e?2e8:1:-6e8)+1}return new pt(t,i,s,e,t.widget||null,!0)}static line(t){return new jt(t)}static set(t,e=!1){return R.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}E.none=R.empty;class _t extends E{constructor(t){let{start:e,end:i}=xs(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?pi(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||ue}eq(t){return this==t||t instanceof _t&&this.tagName==t.tagName&&gi(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}_t.prototype.point=!1;class jt extends E{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof jt&&this.spec.class==t.spec.class&&gi(this.spec.attributes,t.spec.attrib
|
|||
|
|
`,s=n.state.doc.line(s.number+(e?1:-1)),r=n.bidiSpans(s),h=n.visualLineSide(s,!e)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Sr(n,t,e){let i=n.state.charCategorizer(t),s=i(e);return r=>{let o=i(r);return s==Dn.Space&&(s=o),s==o}}function Cr(n,t,e,i){let s=t.head,r=e?1:-1;if(s==(e?n.state.doc.length:0))return S.cursor(s,t.assoc);let o=t.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,t.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+c}let f=a.left+o,d=i??n.viewState.heightOracle.textHeight>>1,u=ti(n,{x:f,y:l+d*r},!1,r);return S.cursor(u.pos,u.assoc,void 0,o)}function Ft(n,t,e){for(;;){let i=0;for(let s of n)s.between(t-1,t+1,(r,o,l)=>{if(t>r&&t<o){let a=i||e||(t-r<o-t?-1:1);t=a<0?r:o,i=a}});if(!i)return t}}function Ys(n,t){let e=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],r=null;if(s.empty){let o=Ft(n,s.from,0);o!=s.from&&(r=S.cursor(o,-1))}else{let o=Ft(n,s.from,-1),l=Ft(n,s.to,1);(o!=s.from||l!=s.to)&&(r=S.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?S.create(e,t.mainIndex):t}function He(n,t,e){let i=Ft(n.state.facet(Gt).map(s=>s(n)),e.from,t.head>e.from?-1:1);return i==e.from?e:S.cursor(i,i<e.from?1:-1)}class ${constructor(t,e){this.pos=t,this.assoc=e}}function ti(n,t,e,i){let s=n.contentDOM.getBoundingClientRect(),r=s.top+n.viewState.paddingTop,{x:o,y:l}=t,a=l-r,h;for(;;){if(a<0)return new $(0,1);if(a>n.viewState.docHeight)return new $(n.state.doc.length,-1);if(h=n.elementAtHeight(a),i==null)break;if(h.type==W.Text){let d=n.docView.coordsAt(i<0?h.from:h.to,i);if(d&&(i<0?d.top<=a+r:d.bottom>=a+r))break}let f=n.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(n.viewport.from>=h.to||n.viewport.to<=h.from){if(e)return null;if(h.type==W.Text){let f=xr(n,s,h,o,l);return new $(f,f==h.from?1:-1)}}if(h.type!=W.Text)return a<(h.top+h.bottom)/2?new $(h.from,1):new $(h.to,-1);let c=n.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=n.docView.lineAt(h.from,-2)),Xs(n,c,h.from,o,l)}function Xs(n,t,e,i,s){let r=-1,o=null,l=1e9,a=1e9,h=s,c=s,f=(d,u)=>{for(let p=0;p<d.length;p++){let g=d[p];if(g.top==g.bottom)continue;let m=g.left>i?g.left-i:g.right<i?i-g.right:0,b=g.top>s?g.top-s:g.bottom<s?s-g.bottom:0;g.top<=c&&g.bottom>=h&&(h=Math.min(g.top,h),c=Math.max(g.bottom,c),b=0),(r<0||(b-a||m-l)<0)&&(r>=0&&a&&l<m&&o.top<=c-2&&o.bottom>=h+2?a=0:(r=u,l=m,a=b,o=g))}};if(t.isText()){for(let u=0;u<t.length;){let p=ot(t.text,u);if(f(Kt(t.dom,u,p).getClientRects(),u),!l&&!a)break;u=p}return i>(o.left+o.right)/2==(Ni(n,r+e)==L.LTR)?new $(e+ot(t.text,r),-1):new $(e+r,1)}else{if(!t.length)return new $(e,1);for(let g=0;g<t.children.length;g++){let m=t.children[g];if(m.flags&48)continue;let b=(m.dom.nodeType==1?m.dom:Kt(m.dom,0,m.length)).getClientRects();if(f(b,g),!l&&!a)break}let d=t.children[r],u=t.posBefore(d,e);return d.isComposite()||d.isText()?Xs(n,d,u,Math.max(o.left,Math.min(o.right,i)),s):i>(o.left+o.right)/2==(Ni(n,r+e)==L.LTR)?new $(u+d.length,-1):new $(u,1)}}function Ni(n,t){let e=n.state.doc.lineAt(t);return n.bidiSpans(e)[tt.find(n.bidiSpans(e),t-e.from,-1,1)].dir}const Et="";class Mr{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(Wt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Et}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=B.get(s),l=s.nextSibling;if(l==e){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=B.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:pe(s))||pe(l)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!Ar(l,e)&&this.lineBreak(),s=l}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1
|
|||
|
|
`&&n.lineWrapping&&(i&&(i=S.single(i.main.anchor-1,i.main.head-1)),e={from:s.from,to:s.to,insert:G.of([" "])}),e)return Si(n,e,i,r);if(i&&!we(i,s)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=Ys(n.state.facet(Gt).map(a=>a(n)),i))),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Si(n,t,e,i=-1){if(y.ios&&n.inputState.flushIOSKey(t))return!0;let s=n.state.selection.main;if(y.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&n.state.sliceDoc(t.from,s.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Ct(n.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>s.head)&&Ct(n.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&Ct(n.contentDOM,"Delete",46)))return!0;let r=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=Dr(n,t,e));return n.state.facet(Ps).some(a=>a(n,t.from,t.to,r,l))||n.dispatch(l()),!0}function Dr(n,t,e){let i,s=n.state,r=s.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let a=t.from<r.from?-1:1,h=a<0?r.from:r.to,c=Ft(s.facet(Gt).map(f=>f(n)),h,a);t.from==c&&(o=c)}if(o>-1)i={changes:t,selection:S.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let a=r.from<t.from?s.sliceDoc(r.from,t.from):"",h=r.to>t.to?s.sliceDoc(t.to,r.to):"";i=s.replaceSelection(n.state.toText(a+t.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=s.changes(t),h=e&&e.main.to<=a.newLength?e.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let c=n.state.sliceDoc(t.from,t.to),f,d=e&&Gs(n,e.main.head);if(d){let p=t.insert.length-(t.to-t.from);f={from:d.from,to:d.to-p}}else f=n.state.doc.lineAt(r.head);let u=r.to-t.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let g=p.to-u,m=g-c.length;if(n.state.sliceDoc(m,g)!=c||g>=f.from&&m<=f.to)return{range:p};let b=s.changes({from:m,to:g,insert:t.insert}),w=p.to-r.to;return{changes:b,range:h?S.range(Math.max(0,h.anchor+w),Math.max(0,h.head+w)):p.map(b)}})}else i={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:l,scrollIntoView:!0})}function Qs(n,t,e,i){let s=Math.min(n.length,t.length),r=0;for(;r<s&&n.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==s&&n.length==t.length)return null;let o=n.length,l=t.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));e-=o+a-r}if(o<r&&n.length<t.length){let a=e<=r&&e>=o?r-e:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=e<=r&&e>=l?r-e:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Or(n){let t=[];if(n.root.activeElement!=n.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return e&&(t.push(new Vi(e,i)),(s!=e||r!=i)&&t.push(new Vi(s,r))),t}function Lr(n,t){if(n.length==0)return null;let e=n[0].pos,i=n.length==2?n[1].pos:e;return e>-1&&i>-1?S.single(e+t,i+t):null}function we(n,t){return t.head==n.main.head&&t.anchor==n.main.anchor}class Br{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=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.c
|
|||
|
|
`))};if((y.mac||y.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:G.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);Si(t,f,S.single(this.toEditorPos(i.selectionStart,d),this.toEditorPos(i.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from<f.to&&!f.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=t.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(E.mark({attributes:{style:c}}).range(a,h))}}}t.dispatch({effects:Is.of(E.set(s))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=At(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,e+=c,this.to+=c;return}else s=null,this.revertPending(t.state);if(r+=e,o+=e,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}e+=c}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i
|
|||
|
|
--\u2028\u2029\uFEFF-]`,oi),Oo={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ne=null;function Lo(){var n;if(Ne==null&&typeof document<"u"&&document.body){let t=document.body.style;Ne=((n=t.tabSize)!==null&&n!==void 0?n:t.MozTabSize)!=null}return Ne||!1}const fe=C.define({combine(n){let t=ui(n,{render:null,specialChars:Do,addSpecialChars:null});return(t.replaceTabs=!Lo())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,oi)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,oi)),t}});function ml(n={}){return[fe.of(n),Bo()]}let os=null;function Bo(){return os||(os=I.fromClass(class{constructor(n){this.view=n,this.decorations=E.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(fe)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new To({regexp:n.specialChars,decoration:(t,e,i)=>{let{doc:s}=e.state,r=bs(t[0],0);if(r==9){let o=s.lineAt(i),l=e.state.tabSize,a=ys(o.text,l,i-o.from);return E.replace({widget:new Po((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=E.replace({widget:new Ho(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let t=n.state.facet(fe);n.startState.facet(fe)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const Ro="•";function Eo(n){return n>=32?Ro:n==10?"":String.fromCharCode(9216+n)}class Ho extends Lt{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=Eo(this.code),i=t.state.phrase("Control character")+" "+(Oo[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,e);if(s)return s;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Po extends Lt{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function bl(){return No}const Wo=E.line({class:"cm-activeLine"}),No=I.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let t=-1,e=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>t&&(e.push(Wo.range(s.from)),t=s.from)}return E.set(e)}},{decorations:n=>n.decorations}),li=2e3;function Vo(n,t,e){let i=Math.min(t.line,e.line),s=Math.max(t.line,e.line),r=[];if(t.off>li||e.off>li||t.col<0||e.col<0){let o=Math.min(t.off,e.off),l=Math.max(t.off,e.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(S.range(h.from+o,h.to+l))}}else{let o=Math.min(t.col,e.col),l=Math.max(t.col,e.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=Ke(h.text,o,n.tabSize,!0);if(c<0)r.push(S.cursor(h.to));else{let f=Ke(h.text,l,n.tabSize);r.push(S.range(h.from+c,h.from+f))}}}return r}function Fo(n,t){let e=n.coordsAtPos(n.viewport.from);return e?Math.round(Math.abs((e.left-t)/n.defaultCharacterWidth)):-1}function ls(n,t){let e=n.posAtCoords({x:t.clientX,y:t.clientY},!1),i=n.state.doc.lineAt(e),s=e-i.from,r=s>li?-1:s==i.length?Fo(n,t.clientX):ys(i.text,n.state.tabSize,e-i.from);return{line:i.number,col:r,off:s}}function Io(n,t){let e=ls(n,t),i=n.state.selection;return e?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.
|