CoreFiles by mySites.guru
lezer-common.min.js1 lines, 25,966 bytes, from Joomla_5.0.2-Stable-Full_Package.zip
Raw History Compare with 5.0.1
md5
a523f0bc741753095a204e22a82d47b9
sha1
dacc33eeefd1b2df5aca9a4b5c9b1d3e12a421fc
sha256
d79230eb67ee2c7a3e23be0ec1a0a533431f3e614d86eb30b87745102ea4068a
const ye=1024;let be=0;class I{constructor(e,t){this.from=e,this.to=t}}class w{constructor(e={}){this.id=be++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=z.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}}w.closedBy=new w({deserialize:l=>l.split(" ")}),w.openedBy=new w({deserialize:l=>l.split(" ")}),w.group=new w({deserialize:l=>l.split(" ")}),w.contextHash=new w({perNode:!0}),w.lookAhead=new w({perNode:!0}),w.mounted=new w({perNode:!0});class he{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}}const xe=Object.create(null);class z{constructor(e,t,r,i=0){this.name=e,this.props=t,this.id=r,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):xe,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new z(e.name||"",t,e.id,r);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(w.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let i of r.split(" "))t[i]=e[r];return r=>{for(let i=r.prop(w.group),n=-1;n<(i?i.length:0);n++){let s=t[n<0?r.name:i[n]];if(s)return s}}}}z.none=new z("",Object.create(null),0,8);class ie{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let i=null;for(let n of e){let s=n(r);s&&(i||(i=Object.assign({},r.props)),i[s[0].id]=s[1])}t.push(i?new z(r.name,i,r.id,r.flags):r)}return new ie(t)}}const Q=new WeakMap,fe=new WeakMap;var C;(function(l){l[l.ExcludeBuffers=1]="ExcludeBuffers",l[l.IncludeAnonymous=2]="IncludeAnonymous",l[l.IgnoreMounts=4]="IgnoreMounts",l[l.IgnoreOverlays=8]="IgnoreOverlays"})(C||(C={}));class N{constructor(e,t,r,i,n){if(this.type=e,this.children=t,this.positions=r,this.length=i,this.props=null,n&&n.length){this.props=Object.create(null);for(let[s,h]of n)this.props[typeof s=="number"?s:s.id]=h}}toString(){let e=this.prop(w.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let i=r.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new $(this.topNode,e)}cursorAt(e,t=0,r=0){let i=Q.get(this)||this.topNode,n=new $(i);return n.moveTo(e,t),Q.set(this,n._tree),n}get topNode(){return new M(this,0,0,null)}resolve(e,t=0){let r=G(Q.get(this)||this.topNode,e,t,!1);return Q.set(this,r),r}resolveInner(e,t=0){let r=G(fe.get(this)||this.topNode,e,t,!0);return fe.set(this,r),r}iterate(e){let{enter:t,leave:r,from:i=0,to:n=this.length}=e,s=e.mode||0,h=(s&C.IncludeAnonymous)>0;for(let f=this.cursor(s|C.IncludeAnonymous);;){let u=!1;if(f.from<=n&&f.to>=i&&(!h&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;u=!0}for(;u&&r&&(h||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:te(z.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,i)=>new N(this.type,t,r,i,this.propValues),e.makeTree||((t,r,i)=>new N(z.none,t,r,i)))}static build(e){return ve(e)}}N.empty=new N(z.none,[],[],0);class ne{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ne(this.buffer,this.index)}}class U{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return z.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],i=this.set.types[t],n=i.name;if(/\W/.test(n)&&!i.isError&&(n=JSON.stringify(n)),e+=4,r==e)return n;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return n+"("+s.join(",")+")"}findChild(e,t,r,i,n){let{buffer:s}=this,h=-1;for(let f=e;f!=t&&!(oe(n,i,s[f+1],s[f+2])&&(h=f,r>0));f=s[f+3]);return h}slice(e,t,r){let i=this.buffer,n=new Uint16Array(t-e),s=0;for(let h=e,f=0;h<t;){n[f++]=i[h++],n[f++]=i[h++]-r;let u=n[f++]=i[h++]-r;n[f++]=i[h++]-e,s=Math.max(s,u)}return new U(n,s,this.set)}}function oe(l,e,t,r){switch(l){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function ue(l,e){let t=l.childBefore(e);for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(l=t,t=r.prevSibling):t=r}return l}function G(l,e,t,r){for(var i;l.from==l.to||(t<1?l.from>=e:l.from>e)||(t>-1?l.to<=e:l.to<e);){let s=!r&&l instanceof M&&l.index<0?null:l.parent;if(!s)return l;l=s}let n=r?0:C.IgnoreOverlays;if(r)for(let s=l,h=s.parent;h;s=h,h=s.parent)s instanceof M&&s.index<0&&((i=h.enter(e,t,n))===null||i===void 0?void 0:i.from)!=s.from&&(l=h);for(;;){let s=l.enter(e,t,n);if(!s)return l;l=s}}class M{constructor(e,t,r,i){this._tree=e,this.from=t,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,i,n=0){for(let s=this;;){for(let{children:h,positions:f}=s._tree,u=t>0?h.length:-1;e!=u;e+=t){let o=h[e],d=f[e]+s.from;if(oe(i,r,d,d+o.length)){if(o instanceof U){if(n&C.ExcludeBuffers)continue;let a=o.findChild(0,o.buffer.length,t,r-d,i);if(a>-1)return new O(new we(s,o,e,d),null,a)}else if(n&C.IncludeAnonymous||!o.type.isAnonymous||ee(o)){let a;if(!(n&C.IgnoreMounts)&&o.props&&(a=o.prop(w.mounted))&&!a.overlay)return new M(a.tree,d,e,s);let b=new M(o,d,e,s);return n&C.IncludeAnonymous||!b.type.isAnonymous?b:b.nextChild(t<0?o.children.length-1:0,t,r,i)}}}if(n&C.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let i;if(!(r&C.IgnoreOverlays)&&(i=this._tree.prop(w.mounted))&&i.overlay){let n=e-this.from;for(let{from:s,to:h}of i.overlay)if((t>0?s<=n:s<n)&&(t<0?h>=n:h>n))return new M(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new $(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return G(this,e,t,!1)}resolveInner(e,t=0){return G(this,e,t,!0)}enterUnfinishedNodesBefore(e){return ue(this,e)}getChild(e,t=null,r=null){let i=X(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return X(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Y(this,e)}}function X(l,e,t,r){let i=l.cursor(),n=[];if(!i.firstChild())return n;if(t!=null){for(;!i.type.is(t);)if(!i.nextSibling())return n}for(;;){if(r!=null&&i.type.is(r))return n;if(i.type.is(e)&&n.push(i.node),!i.nextSibling())return r==null?n:[]}}function Y(l,e,t=e.length-1){for(let r=l.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}class we{constructor(e,t,r,i){this.parent=e,this.buffer=t,this.index=r,this.start=i}}class O{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,r);return n<0?null:new O(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&C.ExcludeBuffers)return null;let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new O(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new O(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new O(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new $(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,i=this.index+4,n=r.buffer[this.index+3];if(n>i){let s=r.buffer[this.index+1];e.push(r.slice(i,n,s)),t.push(0)}return new N(this.type,e,t,this.to-this.from)}resolve(e,t=0){return G(this,e,t,!1)}resolveInner(e,t=0){return G(this,e,t,!0)}enterUnfinishedNodesBefore(e){return ue(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let i=X(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return X(this,e,t,r)}get node(){return this}matchContext(e){return Y(this,e)}}class ${get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof M)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof M?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:i}=this.buffer,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,r);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?r&C.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&C.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&C.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(i.buffer.buffer[n+3]<this.index)return!1;({index:t,parent:r}=i)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let n=t+e,s=e<0?-1:r._tree.children.length;n!=s;n+=e){let h=r._tree.children[n];if(this.mode&C.IncludeAnonymous||h instanceof U||!h.type.isAnonymous||ee(h))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,n=this.stack.length;n>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;t=s,r=n+1;break e}i=this.stack[--n]}for(let i=r;i<this.stack.length;i++)t=new O(this.buffer,t,this.stack[i]);return this.bufferNode=new O(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;i&&t&&t(this),i=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return Y(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let i=e.length-1,n=this.stack.length-1;i>=0;n--){if(n<0)return Y(this.node,e,i);let s=r[t.buffer[this.stack[n]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}}function ee(l){return l.children.some(e=>e instanceof U||!e.type.isAnonymous||ee(e))}function ve(l){var e;let{buffer:t,nodeSet:r,maxBufferLength:i=1024,reused:n=[],minRepeatType:s=r.types.length}=l,h=Array.isArray(t)?new ne(t,t.length):t,f=r.types,u=0,o=0;function d(x,v,p,m,A){let{id:y,start:g,end:k,size:P}=h,E=o;for(;P<0;)if(h.next(),P==-1){let W=n[y];p.push(W),m.push(g-x);return}else if(P==-3){u=y;return}else if(P==-4){o=y;return}else throw new RangeError(`Unrecognized record size: ${P}`);let J=f[y],L,D,se=g-x;if(k-g<=i&&(D=_(h.pos-v,A))){let W=new Uint16Array(D.size-D.skip),T=h.pos-D.size,R=W.length;for(;h.pos>T;)R=F(D.start,W,R);L=new U(W,k-D.start,r),se=D.start-x}else{let W=h.pos-P;h.next();let T=[],R=[],H=y>=s?y:-1,V=0,K=k;for(;h.pos>W;)H>=0&&h.id==H&&h.size>=0?(h.end<=K-i&&(b(T,R,g,V,h.end,K,H,E),V=T.length,K=h.end),h.next()):d(g,W,T,R,H);if(H>=0&&V>0&&V<T.length&&b(T,R,g,V,g,K,H,E),T.reverse(),R.reverse(),H>-1&&V>0){let le=a(J);L=te(J,T,R,0,T.length,0,k-g,le,le)}else L=c(J,T,R,k-g,E-k)}p.push(L),m.push(se)}function a(x){return(v,p,m)=>{let A=0,y=v.length-1,g,k;if(y>=0&&(g=v[y])instanceof N){if(!y&&g.type==x&&g.length==m)return g;(k=g.prop(w.lookAhead))&&(A=p[y]+g.length+k)}return c(x,v,p,m,A)}}function b(x,v,p,m,A,y,g,k){let P=[],E=[];for(;x.length>m;)P.push(x.pop()),E.push(v.pop()+p-A);x.push(c(r.types[g],P,E,y-A,k-y)),v.push(A-p)}function c(x,v,p,m,A=0,y){if(u){let g=[w.contextHash,u];y=y?[g].concat(y):[g]}if(A>25){let g=[w.lookAhead,A];y=y?[g].concat(y):[g]}return new N(x,v,p,m,y)}function _(x,v){let p=h.fork(),m=0,A=0,y=0,g=p.end-i,k={size:0,start:0,skip:0};e:for(let P=p.pos-x;p.pos>P;){let E=p.size;if(p.id==v&&E>=0){k.size=m,k.start=A,k.skip=y,y+=4,m+=4,p.next();continue}let J=p.pos-E;if(E<0||J<P||p.start<g)break;let L=p.id>=s?4:0,D=p.start;for(p.next();p.pos>J;){if(p.size<0)if(p.size==-3)L+=4;else break e;else p.id>=s&&(L+=4);p.next()}A=D,m+=E,y+=L}return(v<0||m==x)&&(k.size=m,k.start=A,k.skip=y),k.size>4?k:void 0}function F(x,v,p){let{id:m,start:A,end:y,size:g}=h;if(h.next(),g>=0&&m<s){let k=p;if(g>4){let P=h.pos-(g-4);for(;h.pos>P;)p=F(x,v,p)}v[--p]=k,v[--p]=y-x,v[--p]=A-x,v[--p]=m}else g==-3?u=m:g==-4&&(o=m);return p}let B=[],j=[];for(;h.pos>0;)d(l.start||0,l.bufferStart||0,B,j,-1);let S=(e=l.length)!==null&&e!==void 0?e:B.length?j[0]+B[0].length:0;return new N(f[l.topID],B.reverse(),j.reverse(),S)}const ae=new WeakMap;function Z(l,e){if(!l.isAnonymous||e instanceof U||e.type!=l)return 1;let t=ae.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=l||!(r instanceof N)){t=1;break}t+=Z(l,r)}ae.set(e,t)}return t}function te(l,e,t,r,i,n,s,h,f){let u=0;for(let c=r;c<i;c++)u+=Z(l,e[c]);let o=Math.ceil(u*1.5/8),d=[],a=[];function b(c,_,F,B,j){for(let S=F;S<B;){let x=S,v=_[S],p=Z(l,c[S]);for(S++;S<B;S++){let m=Z(l,c[S]);if(p+m>=o)break;p+=m}if(S==x+1){if(p>o){let m=c[x];b(m.children,m.positions,0,m.children.length,_[x]+j);continue}d.push(c[x])}else{let m=_[S-1]+c[S-1].length-v;d.push(te(l,c,_,x,S,v,m,null,f))}a.push(v+j-n)}}return b(e,t,r,i,0),(h||f)(d,a,s)}class Ce{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof O?this.setBuffer(e.context.buffer,e.index,t):e instanceof M&&this.map.set(e.tree,t)}get(e){return e instanceof O?this.getBuffer(e.context.buffer,e.index):e instanceof M?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class q{constructor(e,t,r,i,n=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=i,this.open=(n?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let i=[new q(0,e.length,e,0,!1,r)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,r=128){if(!t.length)return e;let i=[],n=1,s=e.length?e[0]:null;for(let h=0,f=0,u=0;;h++){let o=h<t.length?t[h]:null,d=o?o.fromA:1e9;if(d-f>=r)for(;s&&s.from<d;){let a=s;if(f>=a.from||d<=a.to||u){let b=Math.max(a.from,f)-u,c=Math.min(a.to,d)-u;a=b>=c?null:new q(b,c,a.tree,a.offset+u,h>0,!!o)}if(a&&i.push(a),s.to>d)break;s=n<e.length?e[n++]:null}if(!o)break;f=o.toA,u=o.toA-o.toB}return i}}class ke{startParse(e,t,r){return typeof e=="string"&&(e=new Ae(e)),r=r?r.length?r.map(i=>new I(i.from,i.to)):[new I(0,0)]:[new I(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let i=this.startParse(e,t,r);for(;;){let n=i.advance();if(n)return n}}}class Ae{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Se(l){return(e,t,r,i)=>new Pe(e,l,t,r,i)}class pe{constructor(e,t,r,i,n){if(this.parser=e,this.parse=t,this.overlay=r,this.target=i,this.ranges=n,!n.length||n.some(s=>s.from>=s.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}}class _e{constructor(e,t,r,i,n,s,h){this.parser=e,this.predicate=t,this.mounts=r,this.index=i,this.start=n,this.target=s,this.prev=h,this.depth=0,this.ranges=[]}}const re=new w({perNode:!0});class Pe{constructor(e,t,r,i,n){this.nest=t,this.input=r,this.fragments=i,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new N(r.type,r.children,r.positions,r.length,r.propValues.concat([[re,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[w.mounted.id]=new he(t,e.overlay,e.parser),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].ranges[0].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Ie(this.fragments),t=null,r=null,i=new $(new M(this.baseTree,this.ranges[0].from,0,null),C.IncludeAnonymous|C.IgnoreMounts);e:for(let n,s;this.stoppedAt==null||i.from<this.stoppedAt;){let h=!0,f;if(e.hasNode(i)){if(t){let u=t.mounts.find(o=>o.frag.from<=i.from&&o.frag.to>=i.to&&o.mount.overlay);if(u)for(let o of u.mount.overlay){let d=o.from+u.pos,a=o.to+u.pos;d>=i.from&&a<=i.to&&!t.ranges.some(b=>b.from<a&&b.to>d)&&t.ranges.push({from:d,to:a})}}h=!1}else if(r&&(s=Ne(r.ranges,i.from,i.to)))h=s!=2;else if(!i.type.isAnonymous&&i.from<i.to&&(n=this.nest(i,this.input))){i.tree||Be(i);let u=e.findMounts(i.from,n.parser);if(typeof n.overlay=="function")t=new _e(n.parser,n.overlay,u,this.inner.length,i.from,i.tree,t);else{let o=ge(this.ranges,n.overlay||[new I(i.from,i.to)]);o.length&&this.inner.push(new pe(n.parser,n.parser.startParse(this.input,me(u,o),o),n.overlay?n.overlay.map(d=>new I(d.from-i.from,d.to-i.from)):null,i.tree,o)),n.overlay?o.length&&(r={ranges:o,depth:0,prev:r}):h=!1}}else t&&(f=t.predicate(i))&&(f===!0&&(f=new I(i.from,i.to)),f.from<f.to&&t.ranges.push(f));if(h&&i.firstChild())t&&t.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(t&&!--t.depth){let u=ge(this.ranges,t.ranges);u.length&&this.inner.splice(t.index,0,new pe(t.parser,t.parser.startParse(this.input,me(t.mounts,u),u),t.ranges.map(o=>new I(o.from-t.start,o.to-t.start)),t.target,u)),t=t.prev}r&&!--r.depth&&(r=r.prev)}}}}function Ne(l,e,t){for(let r of l){if(r.from>=t)break;if(r.to>e)return r.from<=e&&r.to>=t?2:1}return 0}function de(l,e,t,r,i,n){if(e<t){let s=l.buffer[e+1];r.push(l.slice(e,t,s)),i.push(s-n)}}function Be(l){let{node:e}=l,t=0;do l.parent(),t++;while(!l.tree);let r=0,i=l.tree,n=0;for(;n=i.positions[r]+l.from,!(n<=e.from&&n+i.children[r].length>=e.to);r++);let s=i.children[r],h=s.buffer;function f(u,o,d,a,b){let c=u;for(;h[c+2]+n<=e.from;)c=h[c+3];let _=[],F=[];de(s,u,c,_,F,a);let B=h[c+1],j=h[c+2],S=B+n==e.from&&j+n==e.to&&h[c]==e.type.id;return _.push(S?e.toTree():f(c+4,h[c+3],s.set.types[h[c]],B,j-B)),F.push(B-a),de(s,h[c+3],o,_,F,a),new N(d,_,F,b)}i.children[r]=f(0,h.length,z.none,0,s.length);for(let u=0;u<=t;u++)l.childAfter(e.from)}class ce{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(C.IncludeAnonymous|C.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)t.to>=e&&t.enter(r,1,C.IgnoreOverlays|C.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof N)t=t.children[0];else break}return!1}}class Ie{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(re))!==null&&t!==void 0?t:r.to,this.inner=new ce(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(re))!==null&&e!==void 0?e:t.to,this.inner=new ce(t.tree,-t.offset)}}findMounts(e,t){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let s=(r=n.tree)===null||r===void 0?void 0:r.prop(w.mounted);if(s&&s.parser==t)for(let h=this.fragI;h<this.fragments.length;h++){let f=this.fragments[h];if(f.from>=n.to)break;f.tree==this.curFrag.tree&&i.push({frag:f,pos:n.from-f.offset,mount:s})}}}return i}}function ge(l,e){let t=null,r=e;for(let i=1,n=0;i<l.length;i++){let s=l[i-1].to,h=l[i].from;for(;n<r.length;n++){let f=r[n];if(f.from>=h)break;f.to<=s||(t||(r=t=e.slice()),f.from<s?(t[n]=new I(f.from,s),f.to>h&&t.splice(n+1,0,new I(h,f.to))):f.to>h?t[n--]=new I(h,f.to):t.splice(n--,1))}}return r}function ze(l,e,t,r){let i=0,n=0,s=!1,h=!1,f=-1e9,u=[];for(;;){let o=i==l.length?1e9:s?l[i].to:l[i].from,d=n==e.length?1e9:h?e[n].to:e[n].from;if(s!=h){let a=Math.max(f,t),b=Math.min(o,d,r);a<b&&u.push(new I(a,b))}if(f=Math.min(o,d),f==1e9)break;o==f&&(s?(s=!1,i++):s=!0),d==f&&(h?(h=!1,n++):h=!0)}return u}function me(l,e){let t=[];for(let{pos:r,mount:i,frag:n}of l){let s=r+(i.overlay?i.overlay[0].from:0),h=s+i.tree.length,f=Math.max(n.from,s),u=Math.min(n.to,h);if(i.overlay){let o=i.overlay.map(a=>new I(a.from+r,a.to+r)),d=ze(e,o,f,u);for(let a=0,b=f;;a++){let c=a==d.length,_=c?u:d[a].from;if(_>b&&t.push(new q(b,_,i.tree,-s,n.from>=b||n.openStart,n.to<=_||n.openEnd)),c)break;b=d[a].to}}else t.push(new q(f,u,i.tree,-s,n.from>=s||n.openStart,n.to<=h||n.openEnd))}return t}export{ye as DefaultBufferLength,C as IterMode,he as MountedTree,w as NodeProp,ie as NodeSet,z as NodeType,Ce as NodeWeakMap,ke as Parser,N as Tree,U as TreeBuffer,$ as TreeCursor,q as TreeFragment,Se as parseMixed};

The same content is in 12 releases, Joomla 5.0.1-rc1 to 5.1.0-alpha4. See them all, or every version of this file.