vendor: 10,835 bytes, lines 1-6
1// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js 2 3import{findClusterBreak as e}from"@marijn/find-cluster-break";class Text{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=i(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),TextNode.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=i(this,e,t);let n=[];return this.decompose(e,t,n,0),TextNode.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new RawTextCursor(this),i=new RawTextCursor(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new RawTextCursor(this,e)}iterRange(e,t=this.length){return new PartialTextCursor(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new LineCursor(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw RangeError(`A document must have at least one line`);return e.length==1&&!e[0]?Text.empty:e.length<=32?new TextLeaf(e):TextNode.from(TextLeaf.split(e,[]))}}class TextLeaf extends Text{constructor(e,n=t(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Line(r,o,n,a);r=o+1,n++}}decompose(e,t,i,a){let o=e<=0&&t>=this.length?this:new TextLeaf(r(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(a&1){let e=i.pop(),t=n(o.text,e.text.slice(),0,o.length);if(t.length<=32)i.push(new TextLeaf(t,e.length+o.length));else{let e=t.length>>1;i.push(new TextLeaf(t.slice(0,e)),new TextLeaf(t.slice(e)))}}else i.push(o)}replace(e,t,a){if(!(a instanceof TextLeaf))return super.replace(e,t,a);[e,t]=i(this,e,t);let o=n(this.text,n(a.text,r(this.text,0,e)),t),s=this.length+a.length-(t-e);return o.length<=32?new TextLeaf(o,s):TextNode.from(TextLeaf.split(o,[]),s)}sliceString(e,t=this.length,n=` 4`){[e,t]=i(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,n.length==32&&(t.push(new TextLeaf(n,r)),n=[],r=-1);return r>-1&&t.push(new TextLeaf(n,r)),t}}class TextNode extends Text{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(e,t,n){if([e,t]=i(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let a=this.children[r],o=i+a.length;if(e>=i&&t<=o){let s=a.replace(e-i,t-i,n),c=this.lines-a.lines+s.lines;if(s.lines<c>>4&&s.lines>c>>6){let i=this.children.slice();return i[r]=s,new TextNode(i,this.length-(t-e)+n.length)}return super.replace(i,o,s)}i=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` 5`){[e,t]=i(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof TextNode))return 0;let n=0,[r,i,a,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==a||i==o)return n;let s=this.children[r],c=e.children[i];if(s!=c)return n+s.scanIdentical(c,t);n+=s.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new TextLeaf(n,t)}let r=Math.max(32,n>>5),i=r<<1,a=r>>1,o=[],s=0,c=-1,l=[];function u(e){let t;if(e.lines>i&&e instanceof TextNode)for(let t of e.children)u(t);else e.lines>a&&(s>a||!s)?(d(),o.push(e)):e instanceof TextLeaf&&s&&(t=l[l.length-1])instanceof TextLeaf&&e.lines+t.lines<=32?(s+=e.lines,c+=e.length+1,l[l.length-1]=new TextLeaf(t.text.concat(e.text),t.length+1+e.length)):(s+e.lines>r&&d(),s+=e.lines,c+=e.length+1,l.push(e))}function d(){s!=0&&(o.push(l.length==1?l[0]:TextNode.from(l,c)),c=-1,s=l.length=0)}for(let t of e)u(t);return d(),o.length==1?o[0]:new TextNode(o,t)}}Text.empty=/* @__PURE__ */ new TextLeaf([``],0);function t(e){let t=-1;for(let n of e)t+=n.length+1;return t}function n(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function r(e,t,r){return n(e,[``],t,r)}class RawTextCursor{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof TextLeaf?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof TextLeaf?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` 6`,this;e--}else if(r instanceof TextLeaf){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof TextLeaf?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class PartialTextCursor{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new RawTextCursor(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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 LineCursor{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<`u`&&(Text.prototype[Symbol.iterator]=function(){return this.iter()},RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this});class Line{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function i(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function a(t,n,r=!0,i=!0){return e(t,n,r,i)}function o(e){return e>=56320&&e<57344}function s(e){return e>=55296&&e<56320}function c(e,t){let n=e.charCodeAt(t);if(!s(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return o(r)?(n-55296<<10)+(r-56320)+65536:n}function l(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function u(e){return e<65536?1:2}const d=/\r\n?|\n/;var f=/* @__PURE__ */ (function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(f||(f={}));class ChangeDesc{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){h(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new ChangeDesc(e)}composeDesc(e){return this.empty?e:e.empty?this:_(this,e)}mapDesc(e,t=!1){return e.empty?this:g(this,e,t)}mapPos(e,t=-1,n=f.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=f.Simple&&c>=e&&(n==f.TrackDel&&r<e&&c>e||n==f.TrackBefore&&r<e||n==f.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new ChangeDesc(e)}static create(e){return new ChangeDesc(e)}}class ChangeSet extends ChangeDesc{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return h(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}
vendor: 5,098 bytes, line 6
6mapDesc(e,t=!1){return g(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let a=t[r],o=t[r+1];if(o>=0){t[r]=o,t[r+1]=a;let s=r>>1;for(;n.length<s;)n.push(Text.empty);n.push(a?e.slice(i,i+a):Text.empty)}i+=a}return new ChangeSet(t,n)}compose(e){return this.empty?e:e.empty?this:_(this,e,!0)}map(e,t=!1){return e.empty?this:g(this,e,t,!0)}iterChanges(e,t=!1){h(this,e,t)}get desc(){return ChangeDesc.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new SectionIter(this);done:for(let a=0,o=0;;){let s=a==e.length?1e9:e[a++];for(;o<s||o==s&&i.len==0;){if(i.done)break done;let e=Math.min(i.len,s-o);p(r,e,-1);let a=i.ins==-1?-1:i.off==0?i.ins:0;p(t,e,a),a>0&&m(n,t,i.text),i.forward(e),o+=e}let c=e[a++];for(;o<c;){if(i.done)break done;let e=Math.min(i.len,c-o);p(t,e,-1),p(r,e,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(e),o+=e}}return{changes:new ChangeSet(t,n),filtered:ChangeDesc.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],a=0,o=null;function s(e=!1){if(!e&&!r.length)return;a<t&&p(r,t-a,-1);let n=new ChangeSet(r,i);o=o?o.compose(n.map(o)):n,r=[],i=[],a=0}function c(e){if(Array.isArray(e))for(let t of e)c(t);else if(e instanceof ChangeSet){if(e.length!=t)throw RangeError(`Mismatched change set length (got ${e.length}, expected ${t})`);s(),o=o?o.compose(e.map(o)):e}else{let{from:o,to:c=o,insert:l}=e;if(o>c||o<0||c>t)throw RangeError(`Invalid change range ${o} to ${c} (in doc of length ${t})`);let u=l?typeof l==`string`?Text.of(l.split(n||d)):l:Text.empty,f=u.length;if(o==c&&f==0)return;o<a&&s(),o>a&&p(r,o-a,-1),p(r,c-o,f),m(i,r,u),a=c}}return c(e),s(!o),o}static empty(e){return new ChangeSet(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError(`Invalid JSON representation of ChangeSet`);let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`number`)t.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)t.push(i[0],0);else{for(;n.length<r;)n.push(Text.empty);n[r]=Text.of(i.slice(1)),t.push(i[0],n[r].length)}}return new ChangeSet(t,n)}static createSet(e,t){return new ChangeSet(e,t)}}function p(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function m(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Text.empty);e.push(n)}}function h(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=Text.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function g(e,t,n,r=!1){let i=[],a=r?[]:null,o=new SectionIter(e),s=new SectionIter(t);for(let e=-1;;){if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);p(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(p(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(p(i,0,o.ins),a&&m(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;p(i,t,e<o.i?o.ins:0),a&&e<o.i&&m(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?ChangeSet.createSet(i,a):ChangeDesc.create(i);else throw Error(`Mismatched change set lengths`)}}function _(e,t,n=!1){let r=[],i=n?[]:null,a=new SectionIter(e),o=new SectionIter(t);for(let e=!1;;){if(a.done&&o.done)return i?ChangeSet.createSet(r,i):ChangeDesc.create(r);if(a.ins==0)p(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)p(r,0,o.ins,e),i&&m(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;p(r,t,n,e),i&&n&&m(i,r,o.text)}else o.ins==-1?(p(r,a.off?0:a.len,t,e),i&&m(i,r,a.textBit(t))):(p(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&m(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}}class SectionIter{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Text.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Text.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}
vendor: 4,765 bytes, line 6
6forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class SelectionRange{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new SelectionRange(n,r,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return EditorSelection.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return EditorSelection.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!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 RangeError(`Invalid JSON representation for SelectionRange`);return EditorSelection.range(e.anchor,e.head)}static create(e,t,n,r){return new SelectionRange(e,t,n,r)}}class EditorSelection{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:EditorSelection.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new EditorSelection([this.main],0)}addRange(e,t=!0){return EditorSelection.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,EditorSelection.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!=`number`||e.main>=e.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new EditorSelection(e.ranges.map(e=>SelectionRange.fromJSON(e)),e.main)}static single(e,t=e){return new EditorSelection([EditorSelection.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw RangeError(`A selection needs at least one range`);for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return EditorSelection.normalized(e.slice(),t);n=i.to}return new EditorSelection(e,t)}static cursor(e,t=0,n,r){return SelectionRange.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?SelectionRange.create(t,e,a|32,n):SelectionRange.create(e,t,a,n)}static undirectionalRange(e,t){return SelectionRange.create(e,t,64,void 0)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let a=i.from,o=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?EditorSelection.range(o,a):EditorSelection.range(a,o))}}return new EditorSelection(e,t)}}function v(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}let y=0;class Facet{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=y++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(e={}){return new Facet(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:b),!!e.static,e.enables)}of(e){return new FacetProvider([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new FacetProvider(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new FacetProvider(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function b(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class FacetProvider{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=y++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,a=e[i]>>1,o=this.type==2,s=!1,c=!1,l=[];for(let n of this.dependencies)n==`doc`?s=!0:n==`selection`?c=!0:((t=e[n.id])==null?1:t)&1||l.push(e[n.id]);return{create(e){return e.values[a]=n(e),1},update(e,t){if(s&&t.docChanged||c&&(t.docChanged||t.selection)||S(e,l)){let t=n(e);if(o?!x(t,e.values[a],r):!r(t,e.values[a]))return e.values[a]=t,1}return 0},reconfigure:(e,t)=>
vendor: 9,134 bytes, line 6
6{let s,c=t.config.address[i];if(c!=null){let i=D(t,c);if(this.dependencies.every(n=>n instanceof Facet?t.facet(n)===e.facet(n):n instanceof StateField?t.field(n,!1)==e.field(n,!1):!0)||(o?x(s=n(e),i,r):r(s=n(e),i)))return e.values[a]=i,0}else s=n(e);return e.values[a]=s,1}}}get extension(){return this}}function x(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function S(e,t){let n=!1;for(let r of t)E(e,r)&1&&(n=!0);return n}function ee(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=D(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)E(e,t);return e.values[o]=s(e),1},update(e,n){if(!S(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=S(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&b(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}const C=/* @__PURE__ */ Facet.define({static:!0});class StateField{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new StateField(y++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(C).find(e=>e.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(C),i=n.facet(C),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,C.of({field:this,create:e})]}get extension(){return this}}const w={lowest:4,low:3,default:2,high:1,highest:0};function T(e){return t=>new PrecExtension(t,e)}const te={highest:/* @__PURE__ */ T(w.highest),high:/* @__PURE__ */ T(w.high),default:/* @__PURE__ */ T(w.default),low:/* @__PURE__ */ T(w.low),lowest:/* @__PURE__ */ T(w.lowest)};class PrecExtension{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Compartment{of(e){return new CompartmentInstance(this,e)}reconfigure(e){return Compartment.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class CompartmentInstance{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Configuration{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),a=/* @__PURE__ */ new Map;for(let n of ne(e,t,a))n instanceof StateField?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let o=Object.create(null),s=[],c=[];for(let e of r)o[e.id]=c.length<<1,c.push(t=>e.slot(t));let l=n==null?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,a=l&&l[e]||[];if(t.every(e=>e.type==0))if(o[r.id]=s.length<<1|1,b(a,t))s.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));s.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)e.type==0?(o[e.id]=s.length<<1|1,s.push(e.value)):(o[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));o[r.id]=c.length<<1,c.push(e=>ee(e,r,t))}}return new Configuration(e,a,c.map(e=>e(o)),o,s,i)}}function ne(e,t,n){let r=[[],[],[],[],[]],i=/* @__PURE__ */ new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof CompartmentInstance&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof CompartmentInstance){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof PrecExtension)a(e.inner,e.prec);else if(e instanceof StateField)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof FacetProvider)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,w.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,w.default),r.reduce((e,t)=>e.concat(t))}function E(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function D(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const O=/* @__PURE__ */ Facet.define(),k=/* @__PURE__ */ Facet.define({combine:e=>e.some(e=>e),static:!0}),A=/* @__PURE__ */ Facet.define({combine:e=>e.length?e[0]:void 0,static:!0}),j=/* @__PURE__ */ Facet.define(),M=/* @__PURE__ */ Facet.define(),N=/* @__PURE__ */ Facet.define(),P=/* @__PURE__ */ Facet.define({combine:e=>e.length?e[0]:!1});class Annotation{constructor(e,t){this.type=e,this.value=t}static define(){return new AnnotationType}}class AnnotationType{of(e){return new Annotation(this,e)}}class StateEffectType{constructor(e){this.map=e}of(e){return new StateEffect(this,e)}}class StateEffect{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new StateEffect(this.type,t)}is(e){return this.type==e}static define(e={}){return new StateEffectType(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}StateEffect.reconfigure=/* @__PURE__ */ StateEffect.define(),StateEffect.appendConfig=/* @__PURE__ */ StateEffect.define();class Transaction{constructor(e,t,n,r,i,a){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=a,this._doc=null,this._state=null,n&&v(n,t.newLength),i.some(e=>e.type==Transaction.time)||(this.annotations=i.concat(Transaction.time.of(Date.now())))}static create(e,t,n,r,i,a){return new Transaction(e,t,n,r,i,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Transaction.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]==`.`))}}Transaction.time=/* @__PURE__ */ Annotation.define(),Transaction.userEvent=/* @__PURE__ */ Annotation.define(),Transaction.addToHistory=/* @__PURE__ */ Annotation.define(),Transaction.remote=/* @__PURE__ */ Annotation.define();function F(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function I(e,t,n){var r;let i,a,o;return n?(i=t.changes,a=ChangeSet.empty(t.changes.length),o=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),a=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(i)),{changes:o,selection:t.selection?t.selection.map(a):(r=e.selection)==null?void 0:r.map(i),effects:StateEffect.mapEffects(e.effects,i).concat(StateEffect.mapEffects(t.effects,a)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function L(e,t,n){let r=t.selection,i=H(t.annotations);return t.userEvent&&(i=i.concat(Transaction.userEvent.of(t.userEvent))),{changes:t.changes instanceof ChangeSet?t.changes:ChangeSet.of(t.changes||[],n,e.facet(A)),selection:r&&(r instanceof EditorSelection?r:EditorSelection.single(r.anchor,r.head)),effects:H(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function R(e,t,n){let r=L(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=I(r,L(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=Transaction.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return B(n?z(i):i)}function z(e){let t=e.startState,n=!0;for(let r of t.facet(j)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:F(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=ChangeSet.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Transaction.create(t,r,e.selection&&e.selection.map(i),StateEffe
vendor: 4,106 bytes, line 6
6ct.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(M);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof Transaction?i:Array.isArray(i)&&i.length==1&&i[0]instanceof Transaction?i[0]:R(t,H(i),!1)}return e}function B(e){let t=e.startState,n=t.facet(N),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=I(r,L(t,a,e.changes.newLength),!0))}return r==e?e:Transaction.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}const V=[];function H(e){return e==null?V:Array.isArray(e)?e:[e]}var U=/* @__PURE__ */ (function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(U||(U={}));const re=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let W;try{W=/* @__PURE__ */ RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch(e){}function ie(e){if(W)return W.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`Â`&&(n.toUpperCase()!=n.toLowerCase()||re.test(n)))return!0}return!1}function ae(e){return t=>{if(!/\S/.test(t))return U.Space;if(ie(t))return U.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return U.Word;return U.Other}}class EditorState{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)E(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return E(this,n),D(this,n)}update(...e){return R(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let i of e.effects)i.is(Compartment.reconfigure)?(t&&(r=/* @__PURE__ */ new Map,t.compartments.forEach((e,t)=>r.set(t,e)),t=null),r.set(i.value.compartment,i.value.extension)):i.is(StateEffect.reconfigure)?(t=null,n=i.value):i.is(StateEffect.appendConfig)&&(t=null,n=H(n).concat(i.value));let i;t?i=e.startState.values.slice():(t=Configuration.resolve(n,r,this),i=new EditorState(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let a=e.startState.facet(k)?e.newSelection:e.newSelection.asSingle();new EditorState(t,e.newDoc,a,i,(t,n)=>n.update(t,e),e)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:EditorSelection.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=H(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=StateEffect.mapEffects(a,c).concat(StateEffect.mapEffects(H(o.effects),l))}return{changes:r,selection:EditorSelection.create(i,t.mainIndex),effects:a}}changes(e=[]){return e instanceof ChangeSet?e:ChangeSet.of(e,this.doc.length,this.facet(EditorState.lineSeparator))}toText(e){return Text.of(e.split(this.facet(EditorState.lineSeparator)||d))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(E(this,t),D(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof StateField&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let r=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],a=e[t];r.push(i.init(e=>i.spec.fromJSON(a,e)))}}return EditorState.create({doc:e.doc,selection:EditorSelection.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Configuration.resolve(e.extensions||[],/* @__PURE__ */ new Map),n=e.doc instanceof Text?e.doc:Text.of((e.doc||``).split(t.staticFacet(EditorState.lineSeparator)||d)),r
vendor: 5,124 bytes, lines 6-7
6=e.selection?e.selection instanceof EditorSelection?e.selection:EditorSelection.single(e.selection.anchor,e.selection.head):EditorSelection.single(0);return v(r,n.length),t.staticFacet(k)||(r=r.asSingle()),new EditorState(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(EditorState.tabSize)}get lineBreak(){return this.facet(EditorState.lineSeparator)||` 7`}get readOnly(){return this.facet(P)}phrase(e,...t){for(let t of this.facet(EditorState.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if(n==`$`)return`$`;let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(O))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return ae(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=a(t,o,!1);if(i(t.slice(e,o))!=U.Word)break;o=e}for(;s<r;){let e=a(t,s);if(i(t.slice(s,e))!=U.Word)break;s=e}return o==s?null:EditorSelection.range(o+n,s+n)}}EditorState.allowMultipleSelections=k,EditorState.tabSize=/* @__PURE__ */ Facet.define({combine:e=>e.length?e[0]:4}),EditorState.lineSeparator=A,EditorState.readOnly=P,EditorState.phrases=/* @__PURE__ */ Facet.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),EditorState.languageData=O,EditorState.changeFilter=j,EditorState.transactionFilter=M,EditorState.transactionExtender=N,Compartment.reconfigure=/* @__PURE__ */ StateEffect.define();function oe(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}class RangeValue{eq(e){return this==e}range(e,t=e){return Range.create(e,t,this)}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0,RangeValue.prototype.point=!1,RangeValue.prototype.mapMode=f.TrackDel;function G(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}class Range{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Range(e,t,n)}}function K(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Chunk{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,t){let n=[],r=[],i=[],a=-1,o=-1;for(let s=0;s<this.value.length;s++){let c=this.value[s],l=this.from[s]+e,u=this.to[s]+e,d,f;if(l==u){let e=t.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=t.mapPos(l,c.endSide),f<d)))continue}else if(d=t.mapPos(l,c.startSide),f=t.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(a<0&&(a=d),c.point&&(o=Math.max(o,f-d)),n.push(c),r.push(d-a),i.push(f-a))}return{mapped:n.length?new Chunk(r,i,n,o):null,pos:a}}}class RangeSet{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new RangeSet(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(n&&(t=t.slice().sort(K)),this.isEmpty)return t.length?RangeSet.of(t):this;let o=new LayerCursor(this,null,-1).goto(0),s=0,c=[],l=new RangeSetBuilder;for(;o.value||s<t.length;)if(s<t.length&&(o.from-t[s].from||o.startSide-t[s].value.startSide)>=0){let e=t[s++];l.addInner(e.from,e.to,e.value)||c.push(e)}else o.rangeIndex==1&&o.chunkIndex<this.chunk.length&&(s==t.length||this.chunkEnd(o.chunkIndex)<t[s].from)&&(!a||r>this.chunkEnd(o.chunkIndex)||i<this.chunkPos[o.chunkIndex])&&l.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!a||r>o.to||i<o.from||a(o.from,o.to,o.value))&&(l.addInner(o.from,o.to,o.value)||c.push(Range.create(o.from,o.to,o.value))),o.next());return l.finishInner(this.nextLayer.isEmpty&&!c.length?RangeSet.empty:this.nextLayer.update({add:c,filter:a,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let a=this.chunkPos[i],o=this.chunk[i],s=e.touchesRange(a,a+o.length);if(s===!1)r=Math.max(r,o.maxPoint),t.push(o),n.push(e.mapPos(a));else if(s===!0){let{mapped:i,pos:s}=o.map(a,e);
vendor: 7,522 bytes, line 7
7i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(s))}}let i=this.nextLayer.map(e);return t.length==0?i:new RangeSet(n,t,i||RangeSet.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return HeapCursor.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return HeapCursor.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=q(a,o,n),c=new SpanCursor(a,s,i),l=new SpanCursor(o,s,i);n.iterGaps((e,t,n)=>Y(c,e,l,t,n,r)),n.empty&&n.length==0&&Y(c,0,l,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=q(i,a),s=new SpanCursor(i,o,0).goto(n),c=new SpanCursor(a,o,0).goto(n);for(;;){if(s.to!=c.to||!X(s.active,c.active)||s.point&&(!c.point||!G(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new SpanCursor(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new RangeSetBuilder;for(let r of e instanceof Range?[e]:t?se(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return RangeSet.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=RangeSet.empty;r=r.nextLayer)t=new RangeSet(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}RangeSet.empty=/* @__PURE__ */ new RangeSet([],[],null,-1);function se(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(K(t,r)>0)return e.slice().sort(K);t=r}return e}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(e){this.chunks.push(new Chunk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new RangeSetBuilder)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(RangeSet.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function q(e,t,n){let r=/* @__PURE__ */ new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=/* @__PURE__ */ new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!(n!=null&&n.touchesRange(a,a+e.chunk[t].length))&&i.add(e.chunk[t])}return i}class LayerCursor{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class HeapCursor{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let a=e[i];!a.isEmpty;a=a.nextLayer)a.maxPoint>=n&&r.push(new LayerCursor(a,t,n,i));return r.length==1?r[0]:new HeapCursor(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)J(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)J(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),J(this.heap,0)}}}function J(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class SpanCursor{constructor(e,t,n){this.minPoint=n,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=HeapCursor.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Z(this.active,e),Z(this.activeTo,e),Z(this.activeRank,e),this.minActive=$(this.active,this.activeTo)}
vendor: 3,097 bytes, lines 7-8
7addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Q(this.active,t,n),Q(this.activeTo,t,r),Q(this.activeRank,t,i),e&&Q(e,t,this.cursor.from),this.minActive=$(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Z(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Y(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&G(e.point,n.point)&&X(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!X(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function X(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!G(e[n],t[n]))return!1;return!0}function Z(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Q(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function $(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function ce(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=a(e,i));return r}function le(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=a(e,r)}return r===!0?-1:e.length}export{Annotation,AnnotationType,ChangeDesc,ChangeSet,U as CharCategory,Compartment,EditorSelection,EditorState,Facet,Line,f as MapMode,te as Prec,Range,RangeSet,RangeSetBuilder,RangeValue,SelectionRange,StateEffect,StateEffectType,StateField,Text,Transaction,c as codePointAt,u as codePointSize,oe as combineConfig,ce as countColumn,a as findClusterBreak,le as findColumn,l as fromCodePoint}; 8
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.