/* esm.sh - @codemirror/commands@6.11.1 */ import{Annotation as ke,Facet as Se,combineConfig as nt,StateField as rt,Transaction as K,ChangeSet as ot,ChangeDesc as lt,EditorSelection as h,StateEffect as Ae,Text as Be,findClusterBreak as T,countColumn as ee,CharCategory as C}from"./cm-state.mjs";import{EditorView as O,Direction as ct}from"./cm-view.mjs";import{IndentContext as Ce,getIndentation as De,indentString as G,matchBrackets as E,syntaxTree as te,getIndentUnit as Q,indentUnit as st}from"./cm-language.mjs";import{NodeProp as X}from"./lezer-common.mjs";var it=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ne(e.state,n.from);return r.line?ut(e):r.block?at(e):!1};function x(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let l=e(t,n);return l?(r(n.update(l)),!0):!1}}var ut=x(re,0),An=x(re,1),Bn=x(re,2),ft=x(N,0),Cn=x(N,1),Dn=x(N,2),at=x((e,t)=>N(e,t,dt(t)),0);function ne(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var I=50;function ht(e,{open:t,close:n},r,l){let o=e.sliceDoc(r-I,r),c=e.sliceDoc(l,l+I),s=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(c)[0].length,f=o.length-s;if(o.slice(f-t.length,f)==t&&c.slice(i,i+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-r<=2*I?u=a=e.sliceDoc(r,l):(u=e.sliceDoc(r,r+I),a=e.sliceDoc(l-I,l));let d=/^\s*/.exec(u)[0].length,S=/\s*$/.exec(a)[0].length,y=a.length-S-n.length;return u.slice(d,d+t.length)==t&&a.slice(y,y+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(u.charAt(d+t.length))?1:0},close:{pos:l-S-n.length,margin:/\s/.test(a.charAt(y-1))?1:0}}:null}function dt(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),l=n.to<=r.to?r:e.doc.lineAt(n.to);l.from>r.from&&l.from==n.to&&(l=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=l.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:l.to})}return t}function N(e,t,n=t.selection.ranges){let r=n.map(o=>ne(t,o.from).block);if(!r.every(o=>o))return null;let l=n.map((o,c)=>ht(t,r[c],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(n.map((o,c)=>l[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let c=0,s;cl&&(o==c||c>a.from)){l=a.from;let d=/^\s*/.exec(a.text)[0].length,S=d==a.length,y=a.text.slice(d,d+f.length)==f?d:-1;do.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:s,token:i,indent:f,empty:u,single:a}of r)(a||!u)&&o.push({from:s.from+f,insert:i+" "});let c=t.changes(o);return{changes:c,selection:t.selection.map(c,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:s,token:i}of r)if(s>=0){let f=c.from+s,u=f+i.length;c.text[u-c.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}var Y=ke.define(),mt=ke.define(),pt=Se.define(),Le=Se.define({combine(e){return nt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,l)=>t(r,l)||n(r,l)})}}),R=rt.define({create(){return L.empty},update(e,t){let n=t.state.facet(Le),r=t.annotation(Y);if(r){let i=A.fromTransaction(t,r.selection),f=r.side,u=f==0?e.undone:e.done;return i?u=V(u,u.length,n.minDepth,i):u=Te(u,t.startState.selection),new L(f==0?r.rest:u,f==0?u:r.rest)}let l=t.annotation(mt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(K.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=A.fromTransaction(t),c=t.annotation(K.time),s=t.annotation(K.userEvent);return o?e=e.addChanges(o,c,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,c,s,n.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new L(e.done.map(A.fromJSON),e.undone.map(A.fromJSON))}});function Ln(e={}){return[R,Le.of(e),O.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?xe:t.inputType=="historyRedo"?Z:null;return r?(t.preventDefault(),r(n)):!1}})]}var xn=R;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let l=n.field(R,!1);if(!l)return!1;let o=l.pop(e,n,t);return o?(r(o),!0):!1}}var xe=P(0,!1),Z=P(1,!1),gt=P(0,!0),yt=P(1,!0);function Me(e){return function(t){let n=t.field(R,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}var Mn=Me(0),bn=Me(1);function be(e){return function(t){let n=t.field(R,!1);if(!n)return!1;let r=e==0?n.done:n.undone;return r.length>0&&r[0].selectionsAfter.length>0}}var En=be(0),Tn=be(0),A=class e{constructor(t,n,r,l,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new e(t.changes&&ot.fromJSON(t.changes),[],t.mapped&<.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=k;for(let l of t.startState.facet(pt)){let o=l(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,k)}static selection(t){return new e(void 0,k,void 0,void 0,t)}};function V(e,t,n,r){let l=t+1>n+20?t-n-1:0,o=e.slice(l,t);return o.push(r),o}function kt(e,t){let n=[],r=!1;return e.iterChangedRanges((l,o)=>n.push(l,o)),t.iterChangedRanges((l,o,c,s)=>{for(let i=0;i=f&&c<=u&&(r=!0)}}),r}function St(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function Ee(e,t){return e.length?t.length?e.concat(t):e:t}var k=[],At=200;function Te(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-At));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),V(e,e.length-1,1e9,n.setSelAfter(r)))}else return[A.selection([t])]}function Bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function $(e,t){if(!e.length)return e;let n=e.length,r=k;for(;n;){let l=Ct(e[n-1],t,r);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,n);return o[n-1]=l,o}else t=l.mapped,n--,r=l.selectionsAfter}return r.length?[A.selection(r)]:k}function Ct(e,t,n){let r=Ee(e.selectionsAfter.length?e.selectionsAfter.map(s=>s.map(t)):k,n);if(!e.changes)return A.selection(r);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),c=e.mapped?e.mapped.composeDesc(o):o;return new A(l,Ae.mapEffects(e.effects,t),c,e.startSelection.map(o),r)}var Dt=/^(input\.type|delete)($|\.)/,L=class e{constructor(t,n,r=0,l=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=l}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,l,o){let c=this.done,s=c[c.length-1];return s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Dt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):M(n,t))}function m(e){return e.textDirectionAt(e.state.selection.main.head)==ct.LTR}var Oe=e=>J(e,!m(e)),ve=e=>J(e,m(e)),vn=e=>J(e,!0),In=e=>J(e,!1);function oe(e,t,n){let r=t.head,l=e.doc.lineAt(r);return r==(n?l.to:l.from)?r=n?Math.min(e.doc.length,l.to+1):Math.max(0,l.from-1):r=l.from+T(l.text,r-l.from,n),h.cursor(r,n?-1:1)}function Ie(e,t){return g(e,n=>n.empty?oe(e.state,n,t):M(n,t))}var Rn=e=>Ie(e,!0),Fn=e=>Ie(e,!1);function w(e,t){return g(e,n=>n.empty?e.moveByGroup(n,t):M(n,t))}var Lt=e=>w(e,!m(e)),xt=e=>w(e,m(e)),Un=e=>w(e,!0),Gn=e=>w(e,!1);function le(e,t,n){let r=e.state.charCategorizer(t),l=r(n),o=l!=C.Space;return c=>{let s=r(c);return s!=C.Space?o&&s==l:(o=!1,!0)}}var Vn=e=>g(e,t=>t.empty?e.moveByChar(t,!0,n=>le(e,t.head,n)):M(t,!0)),ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Re(e,t,n){let r=e.state.charCategorizer(t.from),l=C.Space,o=t.from,c=0,s=!1,i=!1,f=!1,u=d=>{if(s)return!1;o+=n?d.length:-d.length;let S=r(d),y;if(S==C.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(S=-1),l==C.Space&&(l=S),l!=S)return!1;if(l==C.Word)if(d.toLowerCase()==d){if(!n&&i)return!1;f=!0}else if(f){if(n)return!1;s=!0}else{if(i&&n&&r(y=e.state.sliceDoc(o,o+1))==C.Word&&y.toLowerCase()==y)return!1;i=!0}return c++,!0},a=e.moveByChar(t,n,d=>(u(d),u));if(ue&&l==C.Word&&a.from==t.from+c*(n?1:-1)){let d=Math.min(t.head,a.head),S=Math.max(t.head,a.head),y=e.state.sliceDoc(d,S);if(y.length>1&&/[\u4E00-\uffff]/.test(y)){let F=Array.from(ue.segment(y));if(F.length>1)return n?h.cursor(t.head+F[1].index,-1):h.cursor(a.head+F[F.length-1].index,1)}}return a}function Fe(e,t){return g(e,n=>n.empty?Re(e,n,t):M(n,t))}var Nn=e=>Fe(e,!0),Pn=e=>Fe(e,!1);function Mt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function z(e,t,n){let r=te(e).resolveInner(t.head),l=n?X.closedBy:X.openedBy;for(let i=t.head;;){let f=n?r.childAfter(i):r.childBefore(i);if(!f)break;Mt(e,f,l)?r=f:i=n?f.to:f.from}let o=r.type.prop(l),c,s;return o&&(c=n?E(e,r.from,1):E(e,r.to,-1))&&c.matched?s=n?c.end.to:c.end.from:s=n?r.to:r.from,h.cursor(s,n?-1:1)}var bt=e=>g(e,t=>z(e.state,t,!m(e))),Et=e=>g(e,t=>z(e.state,t,m(e)));function Ue(e,t){return g(e,n=>{if(!n.empty)return M(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var Ge=e=>Ue(e,!1),Ve=e=>Ue(e,!0);function Ne(e){let t=e.scrollDOM.clientHeightc.empty?e.moveVertically(c,t,n.height):M(c,t));if(l.eq(r.selection))return!1;let o;if(n.selfScroll){let c=e.coordsAtPos(r.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),i=s.top+n.marginTop,f=s.bottom-n.marginBottom;c&&c.top>i&&c.bottomPe(e,!1),_=e=>Pe(e,!0);function D(e,t,n){let r=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?r.to:r.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(l=h.cursor(r.from+o))}return l}var Tt=e=>g(e,t=>D(e,t,!0)),Ot=e=>g(e,t=>D(e,t,!1)),vt=e=>g(e,t=>D(e,t,!m(e))),It=e=>g(e,t=>D(e,t,m(e))),Rt=e=>g(e,t=>e.moveToLineBoundary(t,!1,!1)),Ft=e=>g(e,t=>e.moveToLineBoundary(t,!0,!1));function Je(e,t,n){let r=!1,l=v(e.selection,o=>{let c=E(e,o.head,-1)||E(e,o.head,1)||o.head>0&&E(e,o.head-1,1)||o.headJe(e,t,!1),Jn=({state:e,dispatch:t})=>Je(e,t,!0);function p(e,t,n){let r=v(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=h.range(l.head,l.anchor));let o=n(l);return h.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(B(e.state,r)),!0)}function H(e,t){return p(e,t,n=>e.moveByChar(n,t))}var we=e=>H(e,!m(e)),ze=e=>H(e,m(e)),wn=e=>H(e,!0),zn=e=>H(e,!1),Hn=e=>p(e,!0,t=>oe(e.state,t,!0)),Wn=e=>p(e,!1,t=>oe(e.state,t,!1));function W(e,t){return p(e,t,n=>e.moveByGroup(n,t))}var Gt=e=>W(e,!m(e)),Vt=e=>W(e,m(e)),qn=e=>W(e,!0),Kn=e=>W(e,!1),$n=e=>p(e,!0,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)));function He(e,t){return p(e,t,n=>Re(e,n,t))}var Qn=e=>He(e,!0),Xn=e=>He(e,!1),Nt=e=>{let t=!m(e);return p(e,t,n=>z(e.state,n,t))},Pt=e=>{let t=m(e);return p(e,t,n=>z(e.state,n,t))};function We(e,t){return p(e,t,n=>e.moveVertically(n,t))}var qe=e=>We(e,!1),Ke=e=>We(e,!0);function $e(e,t){return p(e,t,n=>e.moveVertically(n,t,Ne(e).height))}var ae=e=>$e(e,!1),he=e=>$e(e,!0),Jt=e=>p(e,!0,t=>D(e,t,!0)),wt=e=>p(e,!1,t=>D(e,t,!1)),zt=e=>{let t=!m(e);return p(e,t,n=>D(e,n,t))},Ht=e=>{let t=m(e);return p(e,t,n=>D(e,n,t))},Wt=e=>p(e,!1,t=>h.cursor(e.lineBlockAt(t.head).from)),qt=e=>p(e,!0,t=>h.cursor(e.lineBlockAt(t.head).to)),de=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),me=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Kt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),$t=({state:e,dispatch:t})=>{let n=q(e).map(({from:r,to:l})=>h.undirectionalRange(r,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:"select"})),!0},Qt=({state:e,dispatch:t})=>{let n=v(e.selection,r=>{let l=te(e),o=l.resolveStack(r.from,1);if(r.empty){let c=l.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:s}=c;if((s.from=r.to||s.to>r.to&&s.from<=r.from)&&c.next)return h.undirectionalRange(s.from,s.to)}return r});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Qe(e,t){let{state:n}=e,r=n.selection,l=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(t?c.to0)for(let s=o;;){let i=e.moveVertically(s,t);if(i.headc.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==s.head)break;s=i}}}return l.length==r.ranges.length?!1:(e.dispatch(B(n,h.create(l,l.length-1))),!0)}var Xt=e=>Qe(e,!1),Yt=e=>Qe(e,!0),Zt=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function b(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,l=r.changeByRange(o=>{let{from:c,to:s}=o;if(c==s){let i=t(o);ic&&(n="delete.forward",i=U(e,i,!0)),c=Math.min(c,i),s=Math.max(s,i)}else c=U(e,c,!1),s=U(e,s,!0);return c==s?{range:o}:{changes:{from:c,to:s},range:h.cursor(c,cl(e)))r.between(t,t,(l,o)=>{lt&&(t=n?o:l)});return t}var ce=(e,t,n)=>b(e,r=>{let l=r.from,{state:o}=e,c=o.doc.lineAt(l),s,i;if(n&&!t&&l>c.from&&lce(e,!1,!0),Yn=e=>ce(e,!1,!1),Xe=e=>ce(e,!0,!1),Ye=(e,t)=>b(e,n=>{let r=n.head,{state:l}=e,o=l.doc.lineAt(r),c=l.charCategorizer(r);for(let s=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let i=T(o.text,r-o.from,t)+o.from,f=o.text.slice(Math.min(r,i)-o.from,Math.max(r,i)-o.from),u=c(f);if(s!=null&&u!=s)break;(f!=" "||r!=n.head)&&(s=u),r=i}return r}),Ze=e=>Ye(e,!1),_t=e=>Ye(e,!0),Zn=e=>b(e,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)).head),jt=e=>b(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headb(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),en=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),tn=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=[];for(let r=0,l="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let c=l.search(/\s+$/);if(c>-1&&n.push({from:r-(l.length-c),to:r}),o.done)break;l=""}else l=o.value;r+=o.value.length}return n.length?(t(e.update({changes:n,userEvent:"delete"})),!0):!1},nn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Be.of(["",""])},range:h.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},rn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let l=r.from,o=e.doc.lineAt(l),c=l==o.from?l-1:T(o.text,l-o.from,!1)+o.from,s=l==o.to?l+1:T(o.text,l-o.from,!0)+o.from;return{changes:{from:c,to:s,insert:e.doc.slice(l,s).append(e.doc.slice(c,l))},range:h.cursor(s)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function q(e){let t=[],n=-1;for(let r of e.selection.ranges){let l=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=l.number){let c=t[t.length-1];c.to=o.to,c.ranges.push(r)}else t.push({from:l.from,to:o.to,ranges:[r]});n=o.number+1}return t}function _e(e,t,n){if(e.readOnly)return!1;let r=[],l=[];for(let o of q(e)){if(n?o.to==e.doc.length:o.from==0)continue;let c=e.doc.lineAt(n?o.to+1:o.from-1),s=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+s),Math.min(e.doc.length,i.head+s)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:e.lineBreak+c.text});for(let i of o.ranges)l.push(h.range(i.anchor-s,i.head-s))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var on=({state:e,dispatch:t})=>_e(e,t,!1),ln=({state:e,dispatch:t})=>_e(e,t,!0);function je(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of q(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(r);return t(e.update({changes:l,selection:e.selection.map(l,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var cn=({state:e,dispatch:t})=>je(e,t,!1),sn=({state:e,dispatch:t})=>je(e,t,!0),un=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(q(t).map(({from:l,to:o})=>(l>0?l--:o{let o;if(e.lineWrapping){let c=e.lineBlockAt(l.head),s=e.coordsAtPos(l.head,l.assoc||1);s&&(o=c.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},er=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),tr=({state:e,dispatch:t})=>(t(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:h.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function fn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=te(e).resolveInner(t),r=n.childBefore(t),l=n.childAfter(t),o;return r&&l&&r.to<=t&&l.from>=t&&(o=r.type.prop(X.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(r.to,l.from))?{from:r.to,to:l.from}:null}var ye=et(!1),an=et(!0);function et(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(l=>{let{from:o,to:c}=l,s=t.doc.lineAt(o),i=!e&&o==c&&fn(t,o);e&&(o=c=(c<=s.to?s:t.doc.lineAt(c)).to);let f=new Ce(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=De(f,o);for(u==null&&(u=ee(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));cs.from&&o{let l=[];for(let c=r.from;c<=r.to;){let s=e.doc.lineAt(c);s.number>n&&(r.empty||r.to>s.from)&&(t(s,l,r),n=s.number),c=s.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}var hn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ce(e,{overrideIndentation:o=>{let c=n[o];return c??-1}}),l=se(e,(o,c,s)=>{let i=De(r,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=G(e,i);(f!=u||s.frome.readOnly?!1:(t(e.update(se(e,(n,r)=>{r.push({from:n.from,insert:e.facet(st)})}),{userEvent:"input.indent"})),!0),tt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(se(e,(n,r)=>{let l=/^\s*/.exec(n.text)[0];if(!l)return;let o=ee(l,e.tabSize),c=0,s=G(e,Math.max(0,o-Q(e)));for(;c(e.setTabFocusMode(),!0),nr=e=>(e.setTabFocusMode(2e3),!0),rr=({state:e,dispatch:t})=>e.selection.ranges.some(n=>!n.empty)?ie({state:e,dispatch:t}):(t(e.update(e.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),mn=[{key:"Ctrl-b",run:Oe,shift:we,preventDefault:!0},{key:"Ctrl-f",run:ve,shift:ze},{key:"Ctrl-p",run:Ge,shift:qe},{key:"Ctrl-n",run:Ve,shift:Ke},{key:"Ctrl-a",run:Rt,shift:Wt},{key:"Ctrl-e",run:Ft,shift:qt},{key:"Ctrl-d",run:Xe},{key:"Ctrl-h",run:j},{key:"Ctrl-k",run:jt},{key:"Ctrl-Alt-h",run:Ze},{key:"Ctrl-o",run:nn},{key:"Ctrl-t",run:rn},{key:"Ctrl-v",run:_}],pn=[{key:"ArrowLeft",run:Oe,shift:we,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Lt,shift:Gt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:vt,shift:zt,preventDefault:!0},{key:"ArrowRight",run:ve,shift:ze,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xt,shift:Vt,preventDefault:!0},{mac:"Cmd-ArrowRight",run:It,shift:Ht,preventDefault:!0},{key:"ArrowUp",run:Ge,shift:qe,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:fe,shift:ae},{key:"ArrowDown",run:Ve,shift:Ke,preventDefault:!0},{mac:"Cmd-ArrowDown",run:me,shift:ge},{mac:"Ctrl-ArrowDown",run:_,shift:he},{key:"PageUp",run:fe,shift:ae},{key:"PageDown",run:_,shift:he},{key:"Home",run:Ot,shift:wt,preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:Tt,shift:Jt,preventDefault:!0},{key:"Mod-End",run:me,shift:ge},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:Kt},{key:"Backspace",run:j,shift:j,preventDefault:!0},{key:"Delete",run:Xe,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ze,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:_t,preventDefault:!0},{mac:"Mod-Backspace",run:en,preventDefault:!0},{mac:"Mod-Delete",run:tn,preventDefault:!0}].concat(mn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),or=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:bt,shift:Nt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Et,shift:Pt},{key:"Alt-ArrowUp",run:on},{key:"Shift-Alt-ArrowUp",run:cn},{key:"Alt-ArrowDown",run:ln},{key:"Shift-Alt-ArrowDown",run:sn},{key:"Mod-Alt-ArrowUp",run:Xt},{key:"Mod-Alt-ArrowDown",run:Yt},{key:"Escape",run:Zt},{key:"Mod-Enter",run:an},{key:"Alt-l",mac:"Ctrl-l",run:$t},{key:"Mod-i",run:Qt,preventDefault:!0},{key:"Mod-[",run:tt},{key:"Mod-]",run:ie},{key:"Mod-Alt-\\",run:hn},{key:"Shift-Mod-k",run:un},{key:"Shift-Mod-\\",run:Ut},{key:"Mod-/",run:it},{key:"Alt-A",mac:"Ctrl-A",run:ft},{key:"Ctrl-m",mac:"Shift-Alt-m",run:dn}].concat(pn),lr={key:"Tab",run:ie,shift:tt};export{Xt as addCursorAbove,Yt as addCursorBelow,Cn as blockComment,Dn as blockUncomment,Tn as canRedoSelection,En as canUndoSelection,sn as copyLineDown,cn as copyLineUp,In as cursorCharBackward,Fn as cursorCharBackwardLogical,vn as cursorCharForward,Rn as cursorCharForwardLogical,Oe as cursorCharLeft,ve as cursorCharRight,me as cursorDocEnd,de as cursorDocStart,Gn as cursorGroupBackward,Un as cursorGroupForward,Vn as cursorGroupForwardWin,Lt as cursorGroupLeft,xt as cursorGroupRight,Ot as cursorLineBoundaryBackward,Tt as cursorLineBoundaryForward,vt as cursorLineBoundaryLeft,It as cursorLineBoundaryRight,Ve as cursorLineDown,Ft as cursorLineEnd,Rt as cursorLineStart,Ge as cursorLineUp,Ut as cursorMatchingBracket,_ as cursorPageDown,fe as cursorPageUp,Pn as cursorSubwordBackward,Nn as cursorSubwordForward,bt as cursorSyntaxLeft,Et as cursorSyntaxRight,or as defaultKeymap,j as deleteCharBackward,Yn as deleteCharBackwardStrict,Xe as deleteCharForward,Ze as deleteGroupBackward,_t as deleteGroupForward,Zn as deleteGroupForwardWin,un as deleteLine,en as deleteLineBoundaryBackward,tn as deleteLineBoundaryForward,jt as deleteToLineEnd,_n as deleteToLineStart,jn as deleteTrailingWhitespace,mn as emacsStyleKeymap,Ln as history,xn as historyField,On as historyKeymap,tt as indentLess,ie as indentMore,hn as indentSelection,lr as indentWithTab,an as insertBlankLine,er as insertNewline,ye as insertNewlineAndIndent,tr as insertNewlineKeepIndent,rr as insertTab,pt as invertedEffects,mt as isolateHistory,An as lineComment,Bn as lineUncomment,ln as moveLineDown,on as moveLineUp,Z as redo,bn as redoDepth,yt as redoSelection,Kt as selectAll,zn as selectCharBackward,Wn as selectCharBackwardLogical,wn as selectCharForward,Hn as selectCharForwardLogical,we as selectCharLeft,ze as selectCharRight,ge as selectDocEnd,pe as selectDocStart,Kn as selectGroupBackward,qn as selectGroupForward,$n as selectGroupForwardWin,Gt as selectGroupLeft,Vt as selectGroupRight,$t as selectLine,wt as selectLineBoundaryBackward,Jt as selectLineBoundaryForward,zt as selectLineBoundaryLeft,Ht as selectLineBoundaryRight,Ke as selectLineDown,qt as selectLineEnd,Wt as selectLineStart,qe as selectLineUp,Jn as selectMatchingBracket,he as selectPageDown,ae as selectPageUp,Qt as selectParentSyntax,Xn as selectSubwordBackward,Qn as selectSubwordForward,Nt as selectSyntaxLeft,Pt as selectSyntaxRight,Zt as simplifySelection,nn as splitLine,pn as standardKeymap,nr as temporarilySetTabFocusMode,ft as toggleBlockComment,at as toggleBlockCommentByLine,it as toggleComment,ut as toggleLineComment,dn as toggleTabFocusMode,rn as transposeChars,xe as undo,Mn as undoDepth,gt as undoSelection}; //# sourceMappingURL=commands.bundle.mjs.map