UNPKG

p3x-redis-ui-material

Version:

💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity

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